Style definitions for nice terminal layouts. Built with TUIs in mind.
+
+
+
+Lip Gloss takes an expressive, declarative approach to terminal rendering.
+Users familiar with CSS will feel at home with Lip Gloss.
+
+```go
+import "charm.land/lipgloss/v2"
+
+var style = lipgloss.NewStyle().
+ Bold(true).
+ Foreground(lipgloss.Color("#FAFAFA")).
+ Background(lipgloss.Color("#7D56F4")).
+ PaddingTop(2).
+ PaddingLeft(4).
+ Width(22)
+
+lipgloss.Println(style.Render("Hello, kitty"))
+```
+
+## Installation
+
+```bash
+go get charm.land/lipgloss/v2
+```
+
+> [!TIP]
+>
+> Upgrading from v1? Check out the [upgrade guide](./UPGRADE_GUIDE_V2.md), or
+> point your LLM at it and let it go to town.
+
+## Colors
+
+Lip Gloss supports the following color profiles:
+
+### ANSI 16 colors (4-bit)
+
+```go
+lipgloss.Color("5") // magenta
+lipgloss.Color("9") // red
+lipgloss.Color("12") // light blue
+```
+
+### ANSI 256 Colors (8-bit)
+
+```go
+lipgloss.Color("86") // aqua
+lipgloss.Color("201") // hot pink
+lipgloss.Color("202") // orange
+```
+
+### True Color (16,777,216 colors; 24-bit)
+
+```go
+lipgloss.Color("#0000FF") // good ol' 100% blue
+lipgloss.Color("#04B575") // a green
+lipgloss.Color("#3C3C3C") // a dark gray
+```
+
+...as well as a 1-bit ASCII profile, which is black and white only.
+
+There are also named constants for the 16 standard ANSI colors:
+
+```go
+lipgloss.Black
+lipgloss.Red
+lipgloss.Green
+lipgloss.Yellow
+lipgloss.Blue
+lipgloss.Magenta
+lipgloss.Cyan
+lipgloss.White
+lipgloss.BrightBlack
+lipgloss.BrightRed
+lipgloss.BrightGreen
+lipgloss.BrightYellow
+lipgloss.BrightBlue
+lipgloss.BrightMagenta
+lipgloss.BrightCyan
+lipgloss.BrightWhite
+```
+
+### Automatically Downsampling Colors
+
+Some users don't have Truecolor terminals. Other times, output might not
+support color at all (for example, in logs). Lip Gloss was designed to handle
+this gracefully by automatically downsampling colors to the best available
+profile.
+
+If you're using Lip Gloss with Bubble Tea, there’s nothing to do. If you're
+using Lip Gloss standalone, just use `lipgloss.Println` or `lipgloss.Sprint`
+(and their variants).
+
+For more, see [advanced color usage](#advanced-color-usage).
+
+### Color Utilities
+
+Lip Gloss ships with a handful of handy tools for working with colors:
+
+```go
+c := lipgloss.Color("#EB4268") // Sriracha sauce color
+dark := lipgloss.Darken(c, 0.5) // dark Sriracha sauce
+light := lipgloss.Lighten(c, 0.35) // light Sriracha sauce
+green := lipgloss.Complementary(c) // greenish Sriracha sauce
+withAlpha := lipgloss.Alpha(c, 0.2) // watered down Sriracha sauce
+```
+
+### Advanced Color Tooling
+
+Lip Gloss also supports color blending, automatically choosing light or dark
+variants of colors at runtime, and a lot more. For details, see [Advanced Color
+Usage](#advanced-color-usage) and [the docs][docs].
+
+## Inline Formatting
+
+Lip Gloss supports the usual ANSI text formatting options:
+
+```go
+var style = lipgloss.NewStyle().
+ Bold(true).
+ Italic(true).
+ Faint(true).
+ Blink(true).
+ Strikethrough(true).
+ Underline(true).
+ Reverse(true)
+```
+
+### Underline Styles
+
+Beyond simple on/off, underlines support multiple styles and custom colors:
+
+```go
+s := lipgloss.NewStyle().
+ UnderlineStyle(lipgloss.UnderlineCurly).
+ UnderlineColor(lipgloss.Color("#FF0000"))
+```
+
+Available styles: `UnderlineNone`, `UnderlineSingle`, `UnderlineDouble`,
+`UnderlineCurly`, `UnderlineDotted`, `UnderlineDashed`.
+
+### Hyperlinks
+
+Styles can render clickable hyperlinks in supporting terminals:
+
+```go
+s := lipgloss.NewStyle().
+ Foreground(lipgloss.Color("#7B2FBE")).
+ Hyperlink("https://charm.land")
+
+lipgloss.Println(s.Render("Visit Charm"))
+```
+
+In unsupported terminals this will degrade gracefully and hyperlinks will
+simply not render.
+
+## Block-Level Formatting
+
+Lip Gloss also supports rules for block-level formatting:
+
+```go
+// Padding
+var style = lipgloss.NewStyle().
+ PaddingTop(2).
+ PaddingRight(4).
+ PaddingBottom(2).
+ PaddingLeft(4)
+
+// Margins
+var style = lipgloss.NewStyle().
+ MarginTop(2).
+ MarginRight(4).
+ MarginBottom(2).
+ MarginLeft(4)
+```
+
+There is also shorthand syntax for margins and padding, which follows the same
+format as CSS:
+
+```go
+// 2 cells on all sides
+lipgloss.NewStyle().Padding(2)
+
+// 2 cells on the top and bottom, 4 cells on the left and right
+lipgloss.NewStyle().Margin(2, 4)
+
+// 1 cell on the top, 4 cells on the sides, 2 cells on the bottom
+lipgloss.NewStyle().Padding(1, 4, 2)
+
+// Clockwise, starting from the top: 2 cells on the top, 4 on the right, 3 on
+// the bottom, and 1 on the left
+lipgloss.NewStyle().Margin(2, 4, 3, 1)
+```
+
+You can also customize the characters used for padding and margin fill:
+
+```go
+s := lipgloss.NewStyle().
+ Padding(1, 2).
+ PaddingChar('·').
+ Margin(1, 2).
+ MarginChar('░')
+```
+
+## Aligning Text
+
+You can align paragraphs of text to the left, right, or center.
+
+```go
+var style = lipgloss.NewStyle().
+ Width(24).
+ Align(lipgloss.Left). // align it left
+ Align(lipgloss.Right). // no wait, align it right
+ Align(lipgloss.Center) // just kidding, align it in the center
+```
+
+## Width and Height
+
+Setting a minimum width and height is simple and straightforward.
+
+```go
+var style = lipgloss.NewStyle().
+ SetString("What’s for lunch?").
+ Width(24).
+ Height(32).
+ Foreground(lipgloss.Color("63"))
+```
+
+## Borders
+
+Adding borders is easy:
+
+```go
+// Add a purple, rectangular border
+var style = lipgloss.NewStyle().
+ BorderStyle(lipgloss.NormalBorder()).
+ BorderForeground(lipgloss.Color("63"))
+
+// Set a rounded, yellow-on-purple border to the top and left
+var anotherStyle = lipgloss.NewStyle().
+ BorderStyle(lipgloss.RoundedBorder()).
+ BorderForeground(lipgloss.Color("228")).
+ BorderBackground(lipgloss.Color("63")).
+ BorderTop(true).
+ BorderLeft(true)
+
+// Make your own border
+var myCuteBorder = lipgloss.Border{
+ Top: "._.:*:",
+ Bottom: "._.:*:",
+ Left: "|*",
+ Right: "|*",
+ TopLeft: "*",
+ TopRight: "*",
+ BottomLeft: "*",
+ BottomRight: "*",
+}
+```
+
+There are also shorthand functions for defining borders, which follow a similar
+pattern to the margin and padding shorthand functions.
+
+```go
+// Add a thick border to the top and bottom
+lipgloss.NewStyle().
+ Border(lipgloss.ThickBorder(), true, false)
+
+// Add a double border to the top and left sides. Rules are set clockwise
+// from top.
+lipgloss.NewStyle().
+ Border(lipgloss.DoubleBorder(), true, false, false, true)
+```
+
+You can also pass multiple colors to a border for a gradient effect:
+
+```go
+s := lipgloss.NewStyle().
+ Border(lipgloss.RoundedBorder()).
+ BorderForegroundBlend(lipgloss.Color("#FF0000"), lipgloss.Color("#0000FF"))
+```
+
+For more on borders see [the docs](https://pkg.go.dev/charm.land/lipgloss/v2#Border).
+
+## Copying Styles
+
+Just use assignment:
+
+```go
+style := lipgloss.NewStyle().Foreground(lipgloss.Color("219"))
+
+copiedStyle := style // this is a true copy
+
+wildStyle := style.Blink(true) // this is also true copy, with blink added
+```
+
+Since `Style` is a pure value type, assigning a style to another effectively
+creates a new copy of the style without mutating the original.
+
+## Inheritance
+
+Styles can inherit rules from other styles. When inheriting, only unset rules
+on the receiver are inherited.
+
+```go
+var styleA = lipgloss.NewStyle().
+ Foreground(lipgloss.Color("229")).
+ Background(lipgloss.Color("63"))
+
+// Only the background color will be inherited here, because the foreground
+// color will have been already set:
+var styleB = lipgloss.NewStyle().
+ Foreground(lipgloss.Color("201")).
+ Inherit(styleA)
+```
+
+## Unsetting Rules
+
+All rules can be unset:
+
+```go
+var style = lipgloss.NewStyle().
+ Bold(true). // make it bold
+ UnsetBold(). // jk don't make it bold
+ Background(lipgloss.Color("227")). // yellow background
+ UnsetBackground() // never mind
+```
+
+When a rule is unset, it won’t be inherited or copied.
+
+## Enforcing Rules
+
+Sometimes, such as when developing a component, you want to make sure style
+definitions respect their intended purpose in the UI. This is where `Inline`
+and `MaxWidth`, and `MaxHeight` come in:
+
+```go
+// Force rendering onto a single line, ignoring margins, padding, and borders.
+someStyle.Inline(true).Render("yadda yadda")
+
+// Also limit rendering to five cells
+someStyle.Inline(true).MaxWidth(5).Render("yadda yadda")
+
+// Limit rendering to a 5x5 cell block
+someStyle.MaxWidth(5).MaxHeight(5).Render("yadda yadda")
+```
+
+## Tabs
+
+The tab character (`\t`) is rendered differently in different terminals (often
+as 8 spaces, sometimes 4). Because of this inconsistency, Lip Gloss converts
+tabs to 4 spaces at render time. This behavior can be changed on a per-style
+basis, however:
+
+```go
+style := lipgloss.NewStyle() // tabs will render as 4 spaces, the default
+style = style.TabWidth(2) // render tabs as 2 spaces
+style = style.TabWidth(0) // remove tabs entirely
+style = style.TabWidth(lipgloss.NoTabConversion) // leave tabs intact
+```
+
+## Wrapping
+
+The `Wrap` function wraps text while preserving ANSI styles and hyperlinks
+across line boundaries:
+
+```go
+wrapped := lipgloss.Wrap(styledText, 40, " ")
+```
+
+## Rendering
+
+Generally, you just call the `Render(string...)` method on a `lipgloss.Style`:
+
+```go
+style := lipgloss.NewStyle().Bold(true).SetString("Hello,")
+lipgloss.Println(style.Render("kitty.")) // Hello, kitty.
+lipgloss.Println(style.Render("puppy.")) // Hello, puppy.
+```
+
+But you could also use the Stringer interface:
+
+```go
+var style = lipgloss.NewStyle().SetString("你好,猫咪。").Bold(true)
+lipgloss.Println(style) // 你好,猫咪。
+```
+
+## Utilities
+
+In addition to pure styling, Lip Gloss also ships with some utilities to help
+assemble your layouts.
+
+### Compositing
+
+
+
+Lip Gloss includes a powerful, cell-based compositor for rendering layered
+content:
+
+```go
+// Create some layers.
+a := lipgloss.NewLayer(pickles).X(4).Y(2).Z(1)
+b := lipgloss.NewLayer(bitterMelon).X(22).Y(1)
+c := lipgloss.NewLayer(sriracha).X(11).Y(7)
+
+// Composite 'em and render.
+output := compositor.Compose(a, b, c).Render()
+```
+
+For a more thorough example, see [the canvas
+example](./examples/canvas/main.go). For reference, including how to detect
+mouse clicks on layers, see [the docs][docs].
+
+### Joining Paragraphs
+
+Horizontally and vertically joining paragraphs is a cinch.
+
+```go
+// Horizontally join three paragraphs along their bottom edges
+lipgloss.JoinHorizontal(lipgloss.Bottom, paragraphA, paragraphB, paragraphC)
+
+// Vertically join two paragraphs along their center axes
+lipgloss.JoinVertical(lipgloss.Center, paragraphA, paragraphB)
+
+// Horizontally join three paragraphs, with the shorter ones aligning 20%
+// from the top of the tallest
+lipgloss.JoinHorizontal(0.2, paragraphA, paragraphB, paragraphC)
+```
+
+### Measuring Width and Height
+
+Sometimes you’ll want to know the width and height of text blocks when building
+your layouts.
+
+```go
+// Render a block of text.
+var style = lipgloss.NewStyle().
+ Width(40).
+ Padding(2)
+var block string = style.Render(someLongString)
+
+// Get the actual, physical dimensions of the text block.
+width := lipgloss.Width(block)
+height := lipgloss.Height(block)
+
+// Here's a shorthand function.
+w, h := lipgloss.Size(block)
+```
+
+### Blending Colors
+
+You can blend colors in one or two dimensions for gradient effects:
+
+```go
+// 1-dimentinoal gradient
+colors := lipgloss.Blend1D(10, lipgloss.Color("#FF0000"), lipgloss.Color("#0000FF"))
+
+// 2-dimensional gradient with rotation
+colors := lipgloss.Blend2D(80, 24, 45.0, color1, color2, color3)
+```
+
+### Placing Text in Whitespace
+
+Sometimes you’ll simply want to place a block of text in whitespace. This is
+a lightweight alternative to compositing.
+
+```go
+// Center a paragraph horizontally in a space 80 cells wide. The height of
+// the block returned will be as tall as the input paragraph.
+block := lipgloss.PlaceHorizontal(80, lipgloss.Center, fancyStyledParagraph)
+
+// Place a paragraph at the bottom of a space 30 cells tall. The width of
+// the text block returned will be as wide as the input paragraph.
+block := lipgloss.PlaceVertical(30, lipgloss.Bottom, fancyStyledParagraph)
+
+// Place a paragraph in the bottom right corner of a 30x80 cell space.
+block := lipgloss.Place(30, 80, lipgloss.Right, lipgloss.Bottom, fancyStyledParagraph)
+```
+
+You can also style the whitespace. For details, see [the docs][docs].
+
+## Rendering Tables
+
+Lip Gloss ships with a table rendering sub-package.
+
+```go
+import "charm.land/lipgloss/v2/table"
+```
+
+Define some rows of data.
+
+```go
+rows := [][]string{
+ {"Chinese", "您好", "你好"},
+ {"Japanese", "こんにちは", "やあ"},
+ {"Arabic", "أهلين", "أهلا"},
+ {"Russian", "Здравствуйте", "Привет"},
+ {"Spanish", "Hola", "¿Qué tal?"},
+}
+```
+
+Use the table package to style and render the table.
+
+```go
+var (
+ purple = lipgloss.Color("99")
+ gray = lipgloss.Color("245")
+ lightGray = lipgloss.Color("241")
+
+ headerStyle = lipgloss.NewStyle().Foreground(purple).Bold(true).Align(lipgloss.Center)
+ cellStyle = lipgloss.NewStyle().Padding(0, 1).Width(14)
+ oddRowStyle = cellStyle.Foreground(gray)
+ evenRowStyle = cellStyle.Foreground(lightGray)
+)
+
+t := table.New().
+ Border(lipgloss.NormalBorder()).
+ BorderStyle(lipgloss.NewStyle().Foreground(purple)).
+ StyleFunc(func(row, col int) lipgloss.Style {
+ switch {
+ case row == table.HeaderRow:
+ return headerStyle
+ case row%2 == 0:
+ return evenRowStyle
+ default:
+ return oddRowStyle
+ }
+ }).
+ Headers("LANGUAGE", "FORMAL", "INFORMAL").
+ Rows(rows...)
+
+// You can also add tables row-by-row
+t.Row("English", "You look absolutely fabulous.", "How's it going?")
+```
+
+Print the table.
+
+```go
+lipgloss.Println(t)
+```
+
+
+
+### Table Borders
+
+There are helpers to generate tables in markdown or ASCII style:
+
+#### Markdown Table
+
+```go
+table.New().Border(lipgloss.MarkdownBorder()).BorderTop(false).BorderBottom(false)
+```
+
+```
+| LANGUAGE | FORMAL | INFORMAL |
+|----------|--------------|-----------|
+| Chinese | Nǐn hǎo | Nǐ hǎo |
+| French | Bonjour | Salut |
+| Russian | Zdravstvuyte | Privet |
+| Spanish | Hola | ¿Qué tal? |
+```
+
+#### ASCII Table
+
+```go
+table.New().Border(lipgloss.ASCIIBorder())
+```
+
+```
++----------+--------------+-----------+
+| LANGUAGE | FORMAL | INFORMAL |
++----------+--------------+-----------+
+| Chinese | Nǐn hǎo | Nǐ hǎo |
+| French | Bonjour | Salut |
+| Russian | Zdravstvuyte | Privet |
+| Spanish | Hola | ¿Qué tal? |
++----------+--------------+-----------+
+```
+
+For more on tables see [the docs][docs] and [examples](https://github.com/charmbracelet/lipgloss/tree/master/examples/table).
+
+## Rendering Lists
+
+Lip Gloss ships with a list rendering sub-package.
+
+```go
+import "charm.land/lipgloss/v2/list"
+```
+
+Define a new list.
+
+```go
+l := list.New("A", "B", "C")
+```
+
+Print the list.
+
+```go
+lipgloss.Println(l)
+
+// • A
+// • B
+// • C
+```
+
+Lists have the ability to nest.
+
+```go
+l := list.New(
+ "A", list.New("Artichoke"),
+ "B", list.New("Baking Flour", "Bananas", "Barley", "Bean Sprouts"),
+ "C", list.New("Cashew Apple", "Cashews", "Coconut Milk", "Curry Paste", "Currywurst"),
+ "D", list.New("Dill", "Dragonfruit", "Dried Shrimp"),
+ "E", list.New("Eggs"),
+ "F", list.New("Fish Cake", "Furikake"),
+ "J", list.New("Jicama"),
+ "K", list.New("Kohlrabi"),
+ "L", list.New("Leeks", "Lentils", "Licorice Root"),
+)
+```
+
+Print the list.
+
+```go
+lipgloss.Println(l)
+```
+
+
+
+
+
+Lists can be customized via their enumeration function as well as using
+`lipgloss.Style`s.
+
+```go
+enumeratorStyle := lipgloss.NewStyle().Foreground(lipgloss.Color("99")).MarginRight(1)
+itemStyle := lipgloss.NewStyle().Foreground(lipgloss.Color("212")).MarginRight(1)
+
+l := list.New(
+ "Glossier",
+ "Claire's Boutique",
+ "Nyx",
+ "Mac",
+ "Milk",
+ ).
+ Enumerator(list.Roman).
+ EnumeratorStyle(enumeratorStyle).
+ ItemStyle(itemStyle)
+```
+
+Print the list.
+
+
+
+
+
+In addition to the predefined enumerators (`Arabic`, `Alphabet`, `Roman`, `Bullet`, `Tree`),
+you may also define your own custom enumerator:
+
+```go
+l := list.New("Duck", "Duck", "Duck", "Duck", "Goose", "Duck", "Duck")
+
+func DuckDuckGooseEnumerator(l list.Items, i int) string {
+ if l.At(i).Value() == "Goose" {
+ return "Honk →"
+ }
+ return ""
+}
+
+l = l.Enumerator(DuckDuckGooseEnumerator)
+```
+
+Print the list:
+
+
+
+
+
+If you need, you can also build lists incrementally:
+
+```go
+l := list.New()
+
+for i := 0; i < repeat; i++ {
+ l.Item("Lip Gloss")
+}
+```
+
+## Rendering Trees
+
+Lip Gloss ships with a tree rendering sub-package.
+
+```go
+import "charm.land/lipgloss/v2/tree"
+```
+
+Define a new tree.
+
+```go
+t := tree.Root(".").
+ Child("A", "B", "C")
+```
+
+Print the tree.
+
+```go
+lipgloss.Println(t)
+
+// .
+// ├── A
+// ├── B
+// └── C
+```
+
+Trees have the ability to nest.
+
+```go
+t := tree.Root(".").
+ Child("macOS").
+ Child(
+ tree.New().
+ Root("Linux").
+ Child("NixOS").
+ Child("Arch Linux (btw)").
+ Child("Void Linux"),
+ ).
+ Child(
+ tree.New().
+ Root("BSD").
+ Child("FreeBSD").
+ Child("OpenBSD"),
+ )
+```
+
+Print the tree.
+
+```go
+lipgloss.Println(t)
+```
+
+
+
+
+
+Trees can be customized via their enumeration function as well as using
+`lipgloss.Style`s.
+
+```go
+enumeratorStyle := lipgloss.NewStyle().Foreground(lipgloss.Color("63")).MarginRight(1)
+rootStyle := lipgloss.NewStyle().Foreground(lipgloss.Color("35"))
+itemStyle := lipgloss.NewStyle().Foreground(lipgloss.Color("212"))
+
+t := tree.
+ Root("⁜ Makeup").
+ Child(
+ "Glossier",
+ "Fenty Beauty",
+ tree.New().Child(
+ "Gloss Bomb Universal Lip Luminizer",
+ "Hot Cheeks Velour Blushlighter",
+ ),
+ "Nyx",
+ "Mac",
+ "Milk",
+ ).
+ Enumerator(tree.RoundedEnumerator).
+ EnumeratorStyle(enumeratorStyle).
+ RootStyle(rootStyle).
+ ItemStyle(itemStyle)
+```
+
+Print the tree.
+
+
+
+
+
+The predefined enumerators for trees are `DefaultEnumerator` and `RoundedEnumerator`.
+
+If you need, you can also build trees incrementally:
+
+```go
+t := tree.New()
+
+for i := 0; i < repeat; i++ {
+ t.Child("Lip Gloss")
+}
+```
+
+## Advanced Color Usage
+
+One of the most powerful features of Lip Gloss is the ability to render
+different colors at runtime depending on the user's terminal and environment,
+allowing you to present the best possible user experience.
+
+This section shows you how to do exactly that.
+
+
+Migrating from v1?
+
+The `compat` package provides `AdaptiveColor`, `CompleteColor`, and
+`CompleteAdaptiveColor` for a quicker migration from v1. These work by
+looking at `stdin` and `stdout` on a global basis:
+
+```go
+import "charm.land/lipgloss/v2/compat"
+
+color := compat.AdaptiveColor{
+ Light: lipgloss.Color("#f1f1f1"),
+ Dark: lipgloss.Color("#cccccc"),
+}
+```
+
+Note that we don't recommend this for new code as it removes the purity from
+Lip Gloss, computationally speaking, as it removes transparency around when
+I/O happens, which could cause Lip Gloss to compete for resources (like stdin)
+with other tools.
+
+
+
+### Adaptive Colors
+
+You can render different colors at runtime depending on whether the terminal
+has a light or dark background:
+
+```go
+hasDarkBG := lipgloss.HasDarkBackground(os.Stdin, os.Stdout)
+lightDark := lipgloss.LightDark(hasDarkBG)
+
+myColor := lightDark(lipgloss.Color("#D7FFAE"), lipgloss.Color("#D75FEE"))
+```
+
+#### With Bubble Tea
+
+In Bubble Tea, request the background color, listen for a
+`BackgroundColorMsg`, and respond accordingly:
+
+```go
+func (m model) Init() tea.Cmd {
+ // First, send a Cmd to request the terminal background color.
+ return tea.RequestBackgroundColor
+}
+
+func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
+ switch msg := msg.(type) {
+ case tea.BackgroundColorMsg:
+ // Great, we have the background color. Now we can set up our styles
+ // against the color.
+ m.styles = newStyles(msg.IsDark())
+ return m, nil
+ }
+}
+
+func newStyles(bgIsDark bool) styles {
+ // A little ternary function that will return the appropriate color
+ // based on the background color.
+ lightDark := lipgloss.LightDark(bgIsDark)
+
+ return styles{
+ myHotStyle: lipgloss.NewStyle().Foreground(lightDark(
+ lipgloss.Color("#f1f1f1"),
+ lipgloss.Color("#333333"),
+ )),
+ }
+}
+```
+
+#### Standalone
+
+If you’re not using Bubble Tea you can perform the query manually:
+
+```go
+// What's the background color?
+hasDarkBG := lipgloss.HasDarkBackground(os.Stdin, os.Stderr)
+
+// A helper function that will return the appropriate color based on the
+// background.
+lightDark := lipgloss.LightDark(hasDarkBG)
+
+// A couple colors with light and dark variants.
+thisColor := lightDark(lipgloss.Color("#C5ADF9"), lipgloss.Color("#864EFF"))
+thatColor := lightDark(lipgloss.Color("#37CD96"), lipgloss.Color("#22C78A"))
+
+a := lipgloss.NewStyle().Foreground(thisColor).Render("this")
+b := lipgloss.NewStyle().Foreground(thatColor).Render("that")
+
+// Render the appropriate colors at runtime:
+lipgloss.Fprintf(os.Stderr, "my fave colors are %s and %s", a, b)
+```
+
+### Complete Colors
+
+In some cases where you may want to specify exact values for each color profile
+(ANSI 16, ANSI 156, and TrueColor). For these cases, use the `Complete` helper:
+
+```go
+// You'll need the colorprofile package.
+import "github.com/charmbracelet/colorprofile"
+
+// Get the color profile.
+profile := colorprofile.Detect(os.Stdout, os.Environ())
+
+// Create a function for rendering the appropriate color based on the profile.
+var completeColor := lipgloss.Complete(profile)
+
+// Now we'll choose the appropriate color at runtime.
+myColor := completeColor(ansiColor, ansi256Color, trueColor)
+```
+
+### Color Downsampling
+
+One of the best things about Lip Gloss is that it can automatically downsample
+colors to the best available profile, stripping colors (and ANSI) entirely when
+output is not a TTY.
+
+If you’re using Lip Gloss with Bubble Tea there’s nothing to do here:
+downsampling is built into Bubble Tea v2. If you’re not using Bubble Tea, use
+the Lip Gloss writer functions, which are a drop-in replacement for the `fmt`
+package:
+
+```go
+s := lipgloss.NewStyle()
+ .Foreground(lipgloss.Color("#EB4268"))
+ .Render("Hello!")
+
+// Downsample if needed and print to stdout.
+lipgloss.Println(s)
+
+// Render to a variable.
+downsampled := lipgloss.Sprint(s)
+
+// Print to stderr.
+lipgloss.Fprint(os.Stderr, s)
+```
+
+The full set: `Print`, `Println`, `Printf`, `Fprint`, `Fprintln`, `Fprintf`,
+`Sprint`, `Sprintln`, `Sprintf`.
+
+Need more control? Check out
+[Colorprofile](https://github.com/charmbracelet/colorprofile), which Lip Gloss
+uses under the hood.
+
+## What about [Bubble Tea][tea]?
+
+Lip Gloss doesn’t replace Bubble Tea. Rather, it is an excellent Bubble Tea
+companion. It was designed to make assembling terminal user interface views as
+simple and fun as possible so that you can focus on building your application
+instead of concerning yourself with low-level layout details.
+
+In simple terms, you can use Lip Gloss to help build your Bubble Tea views.
+
+[tea]: https://github.com/charmbracelet/bubbletea
+
+## Rendering Markdown
+
+For a more document-centric rendering solution with support for things like
+lists, tables, and syntax-highlighted code have a look at [Glamour][glamour],
+the stylesheet-based Markdown renderer.
+
+[glamour]: https://github.com/charmbracelet/glamour
+
+## Contributing
+
+See [contributing][contribute].
+
+[contribute]: https://github.com/charmbracelet/lipgloss/contribute
+
+## Feedback
+
+We’d love to hear your thoughts on this project. Feel free to drop us a note!
+
+- [Discord](https://charm.land/chat)
+- [Matrix](https://charm.land/matrix)
+
+## License
+
+[MIT](https://github.com/charmbracelet/lipgloss/raw/master/LICENSE)
+
+---
+
+Part of [Charm](https://charm.land).
+
+
+
+Charm热爱开源 • Charm loves open source
+
+[docs]: https://pkg.go.dev/charm.land/lipgloss/v2?tab=doc
diff --git a/vendor/charm.land/lipgloss/v2/Taskfile.yaml b/vendor/charm.land/lipgloss/v2/Taskfile.yaml
new file mode 100644
index 0000000000..84fcf6c66b
--- /dev/null
+++ b/vendor/charm.land/lipgloss/v2/Taskfile.yaml
@@ -0,0 +1,24 @@
+# https://taskfile.dev
+
+version: "3"
+
+tasks:
+ lint:
+ desc: Run base linters
+ cmds:
+ - golangci-lint run
+
+ test:
+ desc: Run tests
+ cmds:
+ - go test ./... {{.CLI_ARGS}}
+
+ test:table:
+ desc: Run table tests
+ cmds:
+ - go test ./table {{.CLI_ARGS}}
+
+ test:tree:
+ desc: Run tree tests
+ cmds:
+ - go test ./tree {{.CLI_ARGS}}
diff --git a/vendor/charm.land/lipgloss/v2/UPGRADE_GUIDE_V2.md b/vendor/charm.land/lipgloss/v2/UPGRADE_GUIDE_V2.md
new file mode 100644
index 0000000000..8f123f19df
--- /dev/null
+++ b/vendor/charm.land/lipgloss/v2/UPGRADE_GUIDE_V2.md
@@ -0,0 +1,504 @@
+# Lip Gloss v2 Upgrade Guide
+
+This guide covers migrating from Lip Gloss v1 (`github.com/charmbracelet/lipgloss`)
+to Lip Gloss v2 (`charm.land/lipgloss/v2`). It is written for both humans and
+LLMs performing automated migrations.
+
+---
+
+## Table of Contents
+
+1. [Quick Start](#quick-start)
+2. [Module Path](#module-path)
+3. [Color System](#color-system)
+4. [Renderer Removal](#renderer-removal)
+5. [Printing and Color Downsampling](#printing-and-color-downsampling)
+6. [Background Detection and Adaptive Colors](#background-detection-and-adaptive-colors)
+7. [Whitespace Options](#whitespace-options)
+8. [Underline](#underline)
+9. [Style API Changes](#style-api-changes)
+10. [Tree Subpackage](#tree-subpackage)
+11. [Removed APIs](#removed-apis)
+12. [Quick Reference Table](#quick-reference-table)
+
+---
+
+## Quick Start
+
+For the fastest possible upgrade, do these two things:
+
+### 1. Use the `compat` package for adaptive/complete colors
+
+```go
+import "charm.land/lipgloss/v2/compat"
+
+// v1
+color := lipgloss.AdaptiveColor{Light: "#f1f1f1", Dark: "#cccccc"}
+
+// v2
+color := compat.AdaptiveColor{Light: lipgloss.Color("#f1f1f1"), Dark: lipgloss.Color("#cccccc")}
+```
+
+The `compat` package reads `stdin`/`stdout` globally, just like v1. To
+customize:
+
+```go
+import (
+ "charm.land/lipgloss/v2/compat"
+ "github.com/charmbracelet/colorprofile"
+)
+
+func init() {
+ compat.HasDarkBackground = lipgloss.HasDarkBackground(os.Stdin, os.Stderr)
+ compat.Profile = colorprofile.Detect(os.Stderr, os.Environ())
+}
+```
+
+### 2. Use Lip Gloss writers for output
+
+```go
+// v1
+fmt.Println(s)
+
+// v2
+lipgloss.Println(s)
+```
+
+This ensures colors are automatically downsampled. If you're using Bubble Tea
+v2, this step is unnecessary — Bubble Tea handles it for you.
+
+**That's the quick path.** Read on for the full migration details.
+
+---
+
+## Module Path
+
+The import path has changed.
+
+```go
+// v1
+import "github.com/charmbracelet/lipgloss"
+
+// v2
+import "charm.land/lipgloss/v2"
+```
+
+**Install:**
+
+```bash
+go get charm.land/lipgloss/v2
+```
+
+All subpackages follow the same pattern:
+
+```go
+// v1
+import "github.com/charmbracelet/lipgloss/table"
+import "github.com/charmbracelet/lipgloss/tree"
+import "github.com/charmbracelet/lipgloss/list"
+
+// v2
+import "charm.land/lipgloss/v2/table"
+import "charm.land/lipgloss/v2/tree"
+import "charm.land/lipgloss/v2/list"
+```
+
+**Search-and-replace pattern:**
+
+```
+github.com/charmbracelet/lipgloss → charm.land/lipgloss/v2
+```
+
+---
+
+## Color System
+
+This is the most significant API change.
+
+### `Color` is now a function, not a type
+
+```go
+// v1 — Color is a string type
+var c lipgloss.Color = "21"
+var c lipgloss.Color = "#ff00ff"
+
+// v2 — Color is a function returning color.Color
+var c color.Color = lipgloss.Color("21")
+var c color.Color = lipgloss.Color("#ff00ff")
+```
+
+The return type is `image/color.Color` (from the standard library).
+
+### `TerminalColor` interface is removed
+
+All methods that accepted `lipgloss.TerminalColor` now accept
+`image/color.Color`:
+
+```go
+// v1
+func (s Style) Foreground(c TerminalColor) Style
+func (s Style) Background(c TerminalColor) Style
+func (s Style) BorderForeground(c ...TerminalColor) Style
+
+// v2
+func (s Style) Foreground(c color.Color) Style
+func (s Style) Background(c color.Color) Style
+func (s Style) BorderForeground(c ...color.Color) Style
+```
+
+**Migration:** Replace every `lipgloss.TerminalColor` with `color.Color` and
+add `import "image/color"`.
+
+### `ANSIColor` is now an alias
+
+```go
+// v1 — custom uint type
+type ANSIColor uint
+
+// v2 — alias for ansi.IndexedColor
+type ANSIColor = ansi.IndexedColor
+```
+
+v2 also exports named constants for the 16 basic ANSI colors:
+
+```go
+lipgloss.Black, lipgloss.Red, lipgloss.Green, lipgloss.Yellow,
+lipgloss.Blue, lipgloss.Magenta, lipgloss.Cyan, lipgloss.White,
+lipgloss.BrightBlack, lipgloss.BrightRed, lipgloss.BrightGreen,
+lipgloss.BrightYellow, lipgloss.BrightBlue, lipgloss.BrightMagenta,
+lipgloss.BrightCyan, lipgloss.BrightWhite
+```
+
+### `AdaptiveColor`, `CompleteColor`, `CompleteAdaptiveColor`
+
+These types have been moved out of the root package. Use the `compat` package
+for a drop-in replacement, or use the new `LightDark` and `Complete` helpers
+for explicit control:
+
+```go
+// v1
+color := lipgloss.AdaptiveColor{Light: "#0000ff", Dark: "#000099"}
+
+// v2 — using compat (quick path)
+color := compat.AdaptiveColor{
+ Light: lipgloss.Color("#0000ff"),
+ Dark: lipgloss.Color("#000099"),
+}
+
+// v2 — using LightDark (recommended)
+hasDark := lipgloss.HasDarkBackground(os.Stdin, os.Stdout)
+lightDark := lipgloss.LightDark(hasDark)
+color := lightDark(lipgloss.Color("#0000ff"), lipgloss.Color("#000099"))
+```
+
+```go
+// v1
+color := lipgloss.CompleteColor{TrueColor: "#ff00ff", ANSI256: "200", ANSI: "5"}
+
+// v2 — using compat
+color := compat.CompleteColor{
+ TrueColor: lipgloss.Color("#ff00ff"),
+ ANSI256: lipgloss.Color("200"),
+ ANSI: lipgloss.Color("5"),
+}
+
+// v2 — using Complete (recommended)
+profile := colorprofile.Detect(os.Stdout, os.Environ())
+complete := lipgloss.Complete(profile)
+color := complete(lipgloss.Color("5"), lipgloss.Color("200"), lipgloss.Color("#ff00ff"))
+```
+
+Note that `compat.AdaptiveColor` and friends take `color.Color` values for
+their fields, not strings.
+
+---
+
+## Renderer Removal
+
+The `Renderer` type and all associated functions are removed. In v1, every
+`Style` carried a `*Renderer` pointer and the package maintained a global
+default renderer.
+
+```go
+// v1 — these no longer exist
+lipgloss.DefaultRenderer()
+lipgloss.SetDefaultRenderer(r)
+lipgloss.NewRenderer(w, opts...)
+lipgloss.ColorProfile()
+lipgloss.SetColorProfile(p)
+renderer.NewStyle()
+```
+
+**In v2, `Style` is a plain value type.** There is no renderer. Color
+downsampling is handled at the output layer (see next section).
+
+**Migration:**
+
+- Replace `lipgloss.DefaultRenderer().NewStyle()` with `lipgloss.NewStyle()`.
+- Replace `renderer.NewStyle()` with `lipgloss.NewStyle()`.
+- Remove any `*Renderer` fields from your types.
+- Remove calls to `SetColorProfile` — use `colorprofile.Detect` at the output
+ layer instead.
+
+---
+
+## Printing and Color Downsampling
+
+In v1, color downsampling happened inside `Style.Render()` via the renderer. In
+v2, `Render()` always emits full-fidelity ANSI. Downsampling happens when you
+print.
+
+### Standalone Usage
+
+Use the Lip Gloss writer functions:
+
+```go
+s := someStyle.Render("Hello!")
+
+// Print to stdout with automatic downsampling
+lipgloss.Println(s)
+
+// Print to stderr
+lipgloss.Fprintln(os.Stderr, s)
+
+// Render to a string (downsampled for stdout's profile)
+str := lipgloss.Sprint(s)
+```
+
+The default writer targets `stdout`. To customize:
+
+```go
+lipgloss.Writer = colorprofile.NewWriter(os.Stderr, os.Environ())
+```
+
+### With Bubble Tea
+
+No changes needed. Bubble Tea v2 handles downsampling internally.
+
+---
+
+## Background Detection and Adaptive Colors
+
+### Standalone
+
+v1 detected the background color automatically via the global renderer. v2
+requires explicit queries:
+
+```go
+// v1
+hasDark := lipgloss.HasDarkBackground()
+
+// v2 — specify the input and output
+hasDark := lipgloss.HasDarkBackground(os.Stdin, os.Stdout)
+```
+
+Then use `LightDark` to pick colors:
+
+```go
+lightDark := lipgloss.LightDark(hasDark)
+fg := lightDark(lipgloss.Color("#333333"), lipgloss.Color("#f1f1f1"))
+
+s := lipgloss.NewStyle().Foreground(fg)
+```
+
+### With Bubble Tea
+
+Request the background color in `Init` and listen for the response:
+
+```go
+func (m model) Init() tea.Cmd {
+ return tea.RequestBackgroundColor
+}
+
+func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
+ switch msg := msg.(type) {
+ case tea.BackgroundColorMsg:
+ m.styles = newStyles(msg.IsDark())
+ }
+ // ...
+}
+
+func newStyles(bgIsDark bool) styles {
+ lightDark := lipgloss.LightDark(bgIsDark)
+ return styles{
+ title: lipgloss.NewStyle().Foreground(lightDark(
+ lipgloss.Color("#333333"),
+ lipgloss.Color("#f1f1f1"),
+ )),
+ }
+}
+```
+
+---
+
+## Whitespace Options
+
+The separate foreground/background whitespace options have been replaced by a
+single style option:
+
+```go
+// v1
+lipgloss.Place(width, height, hPos, vPos, str,
+ lipgloss.WithWhitespaceForeground(lipgloss.Color("#333")),
+ lipgloss.WithWhitespaceBackground(lipgloss.Color("#000")),
+)
+
+// v2
+lipgloss.Place(width, height, hPos, vPos, str,
+ lipgloss.WithWhitespaceStyle(lipgloss.NewStyle().
+ Foreground(lipgloss.Color("#333")).
+ Background(lipgloss.Color("#000")),
+ ),
+)
+```
+
+---
+
+## Underline
+
+`Underline(bool)` still works for basic on/off. v2 adds fine-grained control:
+
+```go
+// v1
+s := lipgloss.NewStyle().Underline(true)
+
+// v2 — still works
+s := lipgloss.NewStyle().Underline(true)
+
+// v2 — new: specific styles
+s := lipgloss.NewStyle().UnderlineStyle(lipgloss.UnderlineCurly)
+
+// v2 — new: colored underlines
+s := lipgloss.NewStyle().
+ UnderlineStyle(lipgloss.UnderlineSingle).
+ UnderlineColor(lipgloss.Color("#FF0000"))
+```
+
+Internally, `Underline(true)` is equivalent to `UnderlineStyle(UnderlineSingle)`
+and `Underline(false)` is equivalent to `UnderlineStyle(UnderlineNone)`.
+
+---
+
+## Style API Changes
+
+### `NewStyle()` is no longer tied to a Renderer
+
+```go
+// v1
+s := lipgloss.NewStyle() // uses global renderer
+s := renderer.NewStyle() // uses specific renderer
+
+// v2
+s := lipgloss.NewStyle() // pure value, no renderer
+```
+
+### Color getters return `color.Color`
+
+```go
+// v1
+fg := s.GetForeground() // returns TerminalColor
+
+// v2
+fg := s.GetForeground() // returns color.Color
+```
+
+### New style methods
+
+| Method | Description |
+|---|---|
+| `UnderlineStyle(Underline)` | Set underline style (single, double, curly, etc.) |
+| `UnderlineColor(color.Color)` | Set underline color |
+| `PaddingChar(rune)` | Set the character used for padding fill |
+| `MarginChar(rune)` | Set the character used for margin fill |
+| `Hyperlink(link, params...)` | Set a clickable hyperlink |
+| `BorderForegroundBlend(...color.Color)` | Apply gradient colors to borders |
+| `BorderForegroundBlendOffset(int)` | Set the offset for border gradient |
+
+Each has a corresponding `Get*`, `Unset*`, and where applicable `Get*`
+accessor.
+
+---
+
+## Tree Subpackage
+
+The import path changes and there are new styling options:
+
+```go
+// v1
+import "github.com/charmbracelet/lipgloss/tree"
+
+// v2
+import "charm.land/lipgloss/v2/tree"
+```
+
+New methods:
+
+- `IndenterStyle(lipgloss.Style)` — set a static style for tree indentation.
+- `IndenterStyleFunc(func(Children, int) lipgloss.Style)` — conditionally style
+ indentation.
+- `Width(int)` — set tree width for padding.
+
+---
+
+## Removed APIs
+
+The following types and functions no longer exist in v2. This table shows each
+removed symbol and its replacement.
+
+| v1 Symbol | v2 Replacement |
+|---|---|
+| `type Renderer` | Removed entirely |
+| `DefaultRenderer()` | Not needed |
+| `SetDefaultRenderer(r)` | Not needed |
+| `NewRenderer(w, opts...)` | Not needed |
+| `ColorProfile()` | `colorprofile.Detect(w, env)` |
+| `SetColorProfile(p)` | Set `lipgloss.Writer.Profile` |
+| `HasDarkBackground()` (no args) | `lipgloss.HasDarkBackground(in, out)` |
+| `SetHasDarkBackground(b)` | Not needed — pass bool to `LightDark` |
+| `type TerminalColor` | `image/color.Color` |
+| `type Color string` | `func Color(string) color.Color` |
+| `type ANSIColor uint` | `type ANSIColor = ansi.IndexedColor` |
+| `type AdaptiveColor` | `compat.AdaptiveColor` or `LightDark` |
+| `type CompleteColor` | `compat.CompleteColor` or `Complete` |
+| `type CompleteAdaptiveColor` | `compat.CompleteAdaptiveColor` |
+| `WithWhitespaceForeground(c)` | `WithWhitespaceStyle(s)` |
+| `WithWhitespaceBackground(c)` | `WithWhitespaceStyle(s)` |
+| `renderer.NewStyle()` | `lipgloss.NewStyle()` |
+
+---
+
+## Quick Reference Table
+
+A side-by-side summary for common patterns:
+
+| Task | v1 | v2 |
+|---|---|---|
+| Import | `"github.com/charmbracelet/lipgloss"` | `"charm.land/lipgloss/v2"` |
+| Create style | `lipgloss.NewStyle()` | `lipgloss.NewStyle()` |
+| Hex color | `lipgloss.Color("#ff00ff")` | `lipgloss.Color("#ff00ff")` |
+| ANSI color | `lipgloss.Color("5")` | `lipgloss.Color("5")` or `lipgloss.Magenta` |
+| Adaptive color | `lipgloss.AdaptiveColor{Light: "#fff", Dark: "#000"}` | `compat.AdaptiveColor{Light: lipgloss.Color("#fff"), Dark: lipgloss.Color("#000")}` |
+| Set foreground | `s.Foreground(lipgloss.Color("5"))` | `s.Foreground(lipgloss.Color("5"))` |
+| Print with downsampling | `fmt.Println(s.Render("hi"))` | `lipgloss.Println(s.Render("hi"))` |
+| Detect dark bg | `lipgloss.HasDarkBackground()` | `lipgloss.HasDarkBackground(os.Stdin, os.Stdout)` |
+| Light/dark color | `lipgloss.AdaptiveColor{...}` | `lipgloss.LightDark(isDark)(light, dark)` |
+| Whitespace styling | `WithWhitespaceForeground(c)` | `WithWhitespaceStyle(lipgloss.NewStyle().Foreground(c))` |
+| Underline | `s.Underline(true)` | `s.Underline(true)` or `s.UnderlineStyle(lipgloss.UnderlineCurly)` |
+
+---
+
+## Feedback
+
+Questions, issues, or feedback:
+
+- [Discord](https://charm.land/discord)
+- [Matrix](https://charm.land/matrix)
+- [Email](mailto:vt100@charm.land)
+
+---
+
+Part of [Charm](https://charm.land).
+
+
+
+Charm热爱开源 • Charm loves open source • نحنُ نحب المصادر المفتوحة
diff --git a/vendor/charm.land/lipgloss/v2/align.go b/vendor/charm.land/lipgloss/v2/align.go
new file mode 100644
index 0000000000..d196213b77
--- /dev/null
+++ b/vendor/charm.land/lipgloss/v2/align.go
@@ -0,0 +1,82 @@
+package lipgloss
+
+import (
+ "strings"
+
+ "github.com/charmbracelet/x/ansi"
+)
+
+// Perform text alignment. If the string is multi-lined, we also make all lines
+// the same width by padding them with spaces. If a style is passed, use that
+// to style the spaces added.
+func alignTextHorizontal(str string, pos Position, width int, style *ansi.Style) string {
+ lines, widestLine := getLines(str)
+ var b strings.Builder
+
+ for i, l := range lines {
+ lineWidth := ansi.StringWidth(l)
+
+ shortAmount := widestLine - lineWidth // difference from the widest line
+ shortAmount += max(0, width-(shortAmount+lineWidth)) // difference from the total width, if set
+
+ if shortAmount > 0 {
+ switch pos {
+ case Right:
+ s := strings.Repeat(" ", shortAmount)
+ if style != nil {
+ s = style.Styled(s)
+ }
+ l = s + l
+ case Center:
+ // Note: remainder goes on the right.
+ left := shortAmount / 2 //nolint:mnd
+ right := left + shortAmount%2 //nolint:mnd
+
+ leftSpaces := strings.Repeat(" ", left)
+ rightSpaces := strings.Repeat(" ", right)
+
+ if style != nil {
+ leftSpaces = style.Styled(leftSpaces)
+ rightSpaces = style.Styled(rightSpaces)
+ }
+ l = leftSpaces + l + rightSpaces
+ default: // Left
+ s := strings.Repeat(" ", shortAmount)
+ if style != nil {
+ s = style.Styled(s)
+ }
+ l += s
+ }
+ }
+
+ b.WriteString(l)
+ if i < len(lines)-1 {
+ b.WriteRune('\n')
+ }
+ }
+
+ return b.String()
+}
+
+func alignTextVertical(str string, pos Position, height int, _ *ansi.Style) string {
+ strHeight := strings.Count(str, "\n") + 1
+ if height < strHeight {
+ return str
+ }
+
+ switch pos {
+ case Top:
+ return str + strings.Repeat("\n", height-strHeight)
+ case Center:
+ topPadding, bottomPadding := (height-strHeight)/2, (height-strHeight)/2 //nolint:mnd
+ if strHeight+topPadding+bottomPadding > height {
+ topPadding--
+ } else if strHeight+topPadding+bottomPadding < height {
+ bottomPadding++
+ }
+ return strings.Repeat("\n", topPadding) + str + strings.Repeat("\n", bottomPadding)
+ case Bottom:
+ return strings.Repeat("\n", height-strHeight) + str
+ }
+ return str
+}
diff --git a/vendor/charm.land/lipgloss/v2/ansi_unix.go b/vendor/charm.land/lipgloss/v2/ansi_unix.go
new file mode 100644
index 0000000000..b4fca7d197
--- /dev/null
+++ b/vendor/charm.land/lipgloss/v2/ansi_unix.go
@@ -0,0 +1,8 @@
+//go:build !windows
+
+package lipgloss
+
+import "os"
+
+// EnableLegacyWindowsANSI is only needed on Windows.
+func EnableLegacyWindowsANSI(*os.File) {}
diff --git a/vendor/charm.land/lipgloss/v2/ansi_windows.go b/vendor/charm.land/lipgloss/v2/ansi_windows.go
new file mode 100644
index 0000000000..8a1ef00eba
--- /dev/null
+++ b/vendor/charm.land/lipgloss/v2/ansi_windows.go
@@ -0,0 +1,30 @@
+//go:build windows
+
+package lipgloss
+
+import (
+ "os"
+
+ "golang.org/x/sys/windows"
+)
+
+// EnableLegacyWindowsANSI enables support for ANSI color sequences in the
+// Windows default console (cmd.exe and the PowerShell application). Note that
+// this only works with Windows 10 and greater. Also note that Windows Terminal
+// supports colors by default.
+func EnableLegacyWindowsANSI(f *os.File) {
+ var mode uint32
+ handle := windows.Handle(f.Fd())
+ err := windows.GetConsoleMode(handle, &mode)
+ if err != nil {
+ return
+ }
+
+ // See https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences
+ if mode&windows.ENABLE_VIRTUAL_TERMINAL_PROCESSING != windows.ENABLE_VIRTUAL_TERMINAL_PROCESSING {
+ vtpmode := mode | windows.ENABLE_VIRTUAL_TERMINAL_PROCESSING
+ if err := windows.SetConsoleMode(handle, vtpmode); err != nil {
+ return
+ }
+ }
+}
diff --git a/vendor/charm.land/lipgloss/v2/blending.go b/vendor/charm.land/lipgloss/v2/blending.go
new file mode 100644
index 0000000000..82830f3e4c
--- /dev/null
+++ b/vendor/charm.land/lipgloss/v2/blending.go
@@ -0,0 +1,196 @@
+package lipgloss
+
+import (
+ "image/color"
+ "math"
+ "slices"
+
+ "github.com/lucasb-eyer/go-colorful"
+)
+
+// Blend1D blends a series of colors together in one linear dimension using multiple
+// stops, into the provided number of steps. Uses the "CIE L*, a*, b*" (CIELAB) color-space.
+//
+// Note that if any of the provided colors are completely transparent, we will
+// assume that the alpha value was lost in conversion from RGB -> RGBA, and we
+// will set the alpha to opaque, as it's not possible to blend something completely
+// transparent.
+func Blend1D(steps int, stops ...color.Color) []color.Color {
+ if steps < 0 {
+ steps = 0
+ }
+
+ if steps <= len(stops) {
+ return stops[:steps]
+ }
+
+ // Ensure they didn't provide any nil colors.
+ stops = slices.DeleteFunc(stops, func(c color.Color) bool {
+ return c == nil
+ })
+
+ if len(stops) == 0 {
+ return nil // We can't safely fallback.
+ }
+
+ // If they only provided one valid color (or some nil colors), we will just return
+ // an array of that color, for the amount of steps they requested.
+ if len(stops) == 1 {
+ singleColor := stops[0]
+ result := make([]color.Color, steps)
+ for i := range result {
+ result[i] = singleColor
+ }
+ return result
+ }
+
+ blended := make([]color.Color, steps)
+
+ // Convert stops to colorful.Color once
+ cstops := make([]colorful.Color, len(stops))
+ for i, k := range stops {
+ cstops[i], _ = colorful.MakeColor(ensureNotTransparent(k))
+ }
+
+ numSegments := len(cstops) - 1
+ defaultSize := steps / numSegments
+ remainingSteps := steps % numSegments
+
+ resultIndex := 0
+ for i := range numSegments {
+ from := cstops[i]
+ to := cstops[i+1]
+
+ // Calculate segment size.
+ segmentSize := defaultSize
+ if i < remainingSteps {
+ segmentSize++
+ }
+
+ divisor := float64(segmentSize - 1)
+
+ // Generate colors for this segment.
+ for j := 0; j < segmentSize; j++ {
+ var blendingFactor float64
+ if segmentSize > 1 {
+ blendingFactor = float64(j) / divisor
+ }
+ blended[resultIndex] = from.BlendLab(to, blendingFactor).Clamped()
+ resultIndex++
+ }
+ }
+
+ return blended
+}
+
+// Blend2D blends a series of colors together in two linear dimensions using
+// multiple stops, into the provided width/height. Uses the "CIE L*, a*, b*" (CIELAB)
+// color-space. The angle parameter controls the rotation of the gradient (0-360°),
+// where 0° is left-to-right, 45° is bottom-left to top-right (diagonal). The function
+// returns colors in a 1D row-major order ([row1, row2, row3, ...]).
+//
+// Example of how to iterate over the result:
+//
+// gradient := colors.Blend2D(width, height, 180, color1, color2, color3, ...)
+// gradientContent := strings.Builder{}
+// for y := range height {
+// for x := range width {
+// index := y*width + x
+// gradientContent.WriteString(
+// lipgloss.NewStyle().
+// Background(gradient[index]).
+// Render(" "),
+// )
+// }
+// if y < height-1 { // End of row.
+// gradientContent.WriteString("\n")
+// }
+// }
+//
+// Note that if any of the provided colors are completely transparent, we will
+// assume that the alpha value was lost in conversion from RGB -> RGBA, and we
+// will set the alpha to opaque, as it's not possible to blend something completely
+// transparent.
+func Blend2D(width, height int, angle float64, stops ...color.Color) []color.Color {
+ if width < 1 {
+ width = 1
+ }
+ if height < 1 {
+ height = 1
+ }
+
+ // Normalize angle to 0-360.
+ angle = math.Mod(angle, 360)
+ if angle < 0 {
+ angle += 360
+ }
+
+ // Ensure they didn't provide any nil colors.
+ stops = slices.DeleteFunc(stops, func(c color.Color) bool {
+ return c == nil
+ })
+
+ if len(stops) == 0 {
+ return nil // We can't safely fallback.
+ }
+
+ // If they only provided one valid color (or some nil colors), we will just return
+ // an array of that color, for the amount of pixels they requested.
+ if len(stops) == 1 {
+ singleColor := stops[0]
+ result := make([]color.Color, width*height)
+ for i := range result {
+ result[i] = singleColor
+ }
+ return result
+ }
+
+ // For 2D blending, we'll create a gradient along the diagonal and then sample
+ // from it based on the angle. We'll use the maximum dimension to ensure we have
+ // enough resolution for the gradient.
+ diagonalGradient := Blend1D(max(width, height), stops...)
+
+ result := make([]color.Color, width*height)
+
+ // Calculate center point for rotation.
+ centerX := float64(width-1) / 2.0
+ centerY := float64(height-1) / 2.0
+
+ angleRad := angle * math.Pi / 180.0 // -> radians.
+
+ // Pre-calculate sin and cos.
+ cosAngle := math.Cos(angleRad)
+ sinAngle := math.Sin(angleRad)
+
+ // Calculate diagonal length for proper gradient mapping.
+ diagonalLength := math.Sqrt(float64(width*width + height*height))
+
+ // Pre-calculate gradient length for index calculation.
+ gradientLen := float64(len(diagonalGradient) - 1)
+
+ for y := range height {
+ // Calculate the distance from center along the gradient direction.
+ dy := float64(y) - centerY
+
+ for x := 0; x < width; x++ {
+ // Calculate the distance from center along the gradient direction.
+ dx := float64(x) - centerX
+
+ rotX := dx*cosAngle - dy*sinAngle // Rotate the point by the angle.
+
+ // Map the rotated position to the gradient. Normalize to 0-1 range based on
+ // the diagonal length.
+ gradientPos := clamp((rotX+diagonalLength/2.0)/diagonalLength, 0, 1)
+
+ // Calculate the index in the gradient.
+ gradientIndex := int(gradientPos * gradientLen)
+ if gradientIndex >= len(diagonalGradient) {
+ gradientIndex = len(diagonalGradient) - 1
+ }
+
+ result[y*width+x] = diagonalGradient[gradientIndex] // -> row-major order.
+ }
+ }
+
+ return result
+}
diff --git a/vendor/charm.land/lipgloss/v2/borders.go b/vendor/charm.land/lipgloss/v2/borders.go
new file mode 100644
index 0000000000..7f12360f62
--- /dev/null
+++ b/vendor/charm.land/lipgloss/v2/borders.go
@@ -0,0 +1,587 @@
+package lipgloss
+
+import (
+ "image/color"
+ "slices"
+ "strings"
+ "unicode/utf8"
+
+ "github.com/charmbracelet/x/ansi"
+ "github.com/clipperhouse/displaywidth"
+ "github.com/rivo/uniseg"
+)
+
+// Border contains a series of values which comprise the various parts of a
+// border.
+type Border struct {
+ Top string
+ Bottom string
+ Left string
+ Right string
+ TopLeft string
+ TopRight string
+ BottomLeft string
+ BottomRight string
+ MiddleLeft string
+ MiddleRight string
+ Middle string
+ MiddleTop string
+ MiddleBottom string
+}
+
+// GetTopSize returns the width of the top border. If borders contain runes of
+// varying widths, the widest rune is returned. If no border exists on the top
+// edge, 0 is returned.
+func (b Border) GetTopSize() int {
+ return getBorderEdgeWidth(b.TopLeft, b.Top, b.TopRight)
+}
+
+// GetRightSize returns the width of the right border. If borders contain
+// runes of varying widths, the widest rune is returned. If no border exists on
+// the right edge, 0 is returned.
+func (b Border) GetRightSize() int {
+ return getBorderEdgeWidth(b.TopRight, b.Right, b.BottomRight)
+}
+
+// GetBottomSize returns the width of the bottom border. If borders contain
+// runes of varying widths, the widest rune is returned. If no border exists on
+// the bottom edge, 0 is returned.
+func (b Border) GetBottomSize() int {
+ return getBorderEdgeWidth(b.BottomLeft, b.Bottom, b.BottomRight)
+}
+
+// GetLeftSize returns the width of the left border. If borders contain runes
+// of varying widths, the widest rune is returned. If no border exists on the
+// left edge, 0 is returned.
+func (b Border) GetLeftSize() int {
+ return getBorderEdgeWidth(b.TopLeft, b.Left, b.BottomLeft)
+}
+
+func getBorderEdgeWidth(borderParts ...string) (maxWidth int) {
+ for _, piece := range borderParts {
+ maxWidth = max(maxWidth, maxRuneWidth(piece))
+ }
+ return maxWidth
+}
+
+var (
+ noBorder = Border{}
+
+ normalBorder = Border{
+ Top: "─",
+ Bottom: "─",
+ Left: "│",
+ Right: "│",
+ TopLeft: "┌",
+ TopRight: "┐",
+ BottomLeft: "└",
+ BottomRight: "┘",
+ MiddleLeft: "├",
+ MiddleRight: "┤",
+ Middle: "┼",
+ MiddleTop: "┬",
+ MiddleBottom: "┴",
+ }
+
+ roundedBorder = Border{
+ Top: "─",
+ Bottom: "─",
+ Left: "│",
+ Right: "│",
+ TopLeft: "╭",
+ TopRight: "╮",
+ BottomLeft: "╰",
+ BottomRight: "╯",
+ MiddleLeft: "├",
+ MiddleRight: "┤",
+ Middle: "┼",
+ MiddleTop: "┬",
+ MiddleBottom: "┴",
+ }
+
+ blockBorder = Border{
+ Top: "█",
+ Bottom: "█",
+ Left: "█",
+ Right: "█",
+ TopLeft: "█",
+ TopRight: "█",
+ BottomLeft: "█",
+ BottomRight: "█",
+ MiddleLeft: "█",
+ MiddleRight: "█",
+ Middle: "█",
+ MiddleTop: "█",
+ MiddleBottom: "█",
+ }
+
+ outerHalfBlockBorder = Border{
+ Top: "▀",
+ Bottom: "▄",
+ Left: "▌",
+ Right: "▐",
+ TopLeft: "▛",
+ TopRight: "▜",
+ BottomLeft: "▙",
+ BottomRight: "▟",
+ }
+
+ innerHalfBlockBorder = Border{
+ Top: "▄",
+ Bottom: "▀",
+ Left: "▐",
+ Right: "▌",
+ TopLeft: "▗",
+ TopRight: "▖",
+ BottomLeft: "▝",
+ BottomRight: "▘",
+ }
+
+ thickBorder = Border{
+ Top: "━",
+ Bottom: "━",
+ Left: "┃",
+ Right: "┃",
+ TopLeft: "┏",
+ TopRight: "┓",
+ BottomLeft: "┗",
+ BottomRight: "┛",
+ MiddleLeft: "┣",
+ MiddleRight: "┫",
+ Middle: "╋",
+ MiddleTop: "┳",
+ MiddleBottom: "┻",
+ }
+
+ doubleBorder = Border{
+ Top: "═",
+ Bottom: "═",
+ Left: "║",
+ Right: "║",
+ TopLeft: "╔",
+ TopRight: "╗",
+ BottomLeft: "╚",
+ BottomRight: "╝",
+ MiddleLeft: "╠",
+ MiddleRight: "╣",
+ Middle: "╬",
+ MiddleTop: "╦",
+ MiddleBottom: "╩",
+ }
+
+ hiddenBorder = Border{
+ Top: " ",
+ Bottom: " ",
+ Left: " ",
+ Right: " ",
+ TopLeft: " ",
+ TopRight: " ",
+ BottomLeft: " ",
+ BottomRight: " ",
+ MiddleLeft: " ",
+ MiddleRight: " ",
+ Middle: " ",
+ MiddleTop: " ",
+ MiddleBottom: " ",
+ }
+
+ markdownBorder = Border{
+ Top: "-",
+ Bottom: "-",
+ Left: "|",
+ Right: "|",
+ TopLeft: "|",
+ TopRight: "|",
+ BottomLeft: "|",
+ BottomRight: "|",
+ MiddleLeft: "|",
+ MiddleRight: "|",
+ Middle: "|",
+ MiddleTop: "|",
+ MiddleBottom: "|",
+ }
+
+ asciiBorder = Border{
+ Top: "-",
+ Bottom: "-",
+ Left: "|",
+ Right: "|",
+ TopLeft: "+",
+ TopRight: "+",
+ BottomLeft: "+",
+ BottomRight: "+",
+ MiddleLeft: "+",
+ MiddleRight: "+",
+ Middle: "+",
+ MiddleTop: "+",
+ MiddleBottom: "+",
+ }
+)
+
+// NormalBorder returns a standard-type border with a normal weight and 90
+// degree corners.
+func NormalBorder() Border {
+ return normalBorder
+}
+
+// RoundedBorder returns a border with rounded corners.
+func RoundedBorder() Border {
+ return roundedBorder
+}
+
+// BlockBorder returns a border that takes the whole block.
+func BlockBorder() Border {
+ return blockBorder
+}
+
+// OuterHalfBlockBorder returns a half-block border that sits outside the frame.
+func OuterHalfBlockBorder() Border {
+ return outerHalfBlockBorder
+}
+
+// InnerHalfBlockBorder returns a half-block border that sits inside the frame.
+func InnerHalfBlockBorder() Border {
+ return innerHalfBlockBorder
+}
+
+// ThickBorder returns a border that's thicker than the one returned by
+// NormalBorder.
+func ThickBorder() Border {
+ return thickBorder
+}
+
+// DoubleBorder returns a border comprised of two thin strokes.
+func DoubleBorder() Border {
+ return doubleBorder
+}
+
+// HiddenBorder returns a border that renders as a series of single-cell
+// spaces. It's useful for cases when you want to remove a standard border but
+// maintain layout positioning. This said, you can still apply a background
+// color to a hidden border.
+func HiddenBorder() Border {
+ return hiddenBorder
+}
+
+// MarkdownBorder return a table border in markdown style.
+//
+// Make sure to disable top and bottom border for the best result. This will
+// ensure that the output is valid markdown.
+//
+// table.New().Border(lipgloss.MarkdownBorder()).BorderTop(false).BorderBottom(false)
+func MarkdownBorder() Border {
+ return markdownBorder
+}
+
+// ASCIIBorder returns a table border with ASCII characters.
+func ASCIIBorder() Border {
+ return asciiBorder
+}
+
+type borderBlend struct {
+ topGradient []color.Color
+ rightGradient []color.Color
+ bottomGradient []color.Color
+ leftGradient []color.Color
+}
+
+func (s Style) borderBlend(width, height int, colors ...color.Color) *borderBlend {
+ gradient := Blend1D(
+ (height+width+2)*2,
+ colors...,
+ )
+
+ // Rotate array forward or reverse based on the offset if provided.
+ if r := -s.getAsInt(borderForegroundBlendOffsetKey); r != 0 {
+ n := len(gradient)
+ r %= n
+ if r < 0 {
+ r += n
+ }
+ slices.Reverse(gradient[:r])
+ slices.Reverse(gradient[r:])
+ slices.Reverse(gradient)
+ }
+
+ offset := 0
+ getFromOffset := func(size int) (s []color.Color) {
+ s = gradient[offset : offset+size]
+ offset += size
+ return s
+ }
+
+ blend := &borderBlend{
+ topGradient: getFromOffset(width + 2),
+ rightGradient: getFromOffset(height),
+ bottomGradient: getFromOffset(width + 2),
+ leftGradient: getFromOffset(height),
+ }
+
+ // bottom and left gradients are reversed because they are drawn in reverse order.
+ slices.Reverse(blend.bottomGradient)
+ slices.Reverse(blend.leftGradient)
+
+ return blend
+}
+
+func (s Style) applyBorder(str string) string {
+ var (
+ border = s.getBorderStyle()
+ hasTop = s.getAsBool(borderTopKey, false)
+ hasRight = s.getAsBool(borderRightKey, false)
+ hasBottom = s.getAsBool(borderBottomKey, false)
+ hasLeft = s.getAsBool(borderLeftKey, false)
+ )
+
+ // If a border is set and no sides have been specifically turned on or off
+ // render borders on all sides.
+ if s.isBorderStyleSetWithoutSides() {
+ hasTop = true
+ hasRight = true
+ hasBottom = true
+ hasLeft = true
+ }
+
+ // If no border is set or all borders are been disabled, abort.
+ if border == noBorder || (!hasTop && !hasRight && !hasBottom && !hasLeft) {
+ return str
+ }
+
+ lines, width := getLines(str)
+
+ if hasLeft {
+ if border.Left == "" {
+ border.Left = " "
+ }
+ width += maxRuneWidth(border.Left)
+ }
+
+ if hasRight {
+ if border.Right == "" {
+ border.Right = " "
+ }
+ width += maxRuneWidth(border.Right)
+ }
+
+ // If corners should be rendered but are set with the empty string, fill them
+ // with a single space.
+ if hasTop && hasLeft && border.TopLeft == "" {
+ border.TopLeft = " "
+ }
+ if hasTop && hasRight && border.TopRight == "" {
+ border.TopRight = " "
+ }
+ if hasBottom && hasLeft && border.BottomLeft == "" {
+ border.BottomLeft = " "
+ }
+ if hasBottom && hasRight && border.BottomRight == "" {
+ border.BottomRight = " "
+ }
+
+ // Figure out which corners we should actually be using based on which
+ // sides are set to show.
+ if hasTop {
+ switch {
+ case !hasLeft && !hasRight:
+ border.TopLeft = ""
+ border.TopRight = ""
+ case !hasLeft:
+ border.TopLeft = ""
+ case !hasRight:
+ border.TopRight = ""
+ }
+ }
+ if hasBottom {
+ switch {
+ case !hasLeft && !hasRight:
+ border.BottomLeft = ""
+ border.BottomRight = ""
+ case !hasLeft:
+ border.BottomLeft = ""
+ case !hasRight:
+ border.BottomRight = ""
+ }
+ }
+
+ // For now, limit corners to one rune.
+ border.TopLeft = getFirstRuneAsString(border.TopLeft)
+ border.TopRight = getFirstRuneAsString(border.TopRight)
+ border.BottomRight = getFirstRuneAsString(border.BottomRight)
+ border.BottomLeft = getFirstRuneAsString(border.BottomLeft)
+
+ var topFG, rightFG, bottomFG, leftFG color.Color
+ var (
+ blendFG = s.getAsColors(borderForegroundBlendKey)
+ topBG = s.getAsColor(borderTopBackgroundKey)
+ rightBG = s.getAsColor(borderRightBackgroundKey)
+ bottomBG = s.getAsColor(borderBottomBackgroundKey)
+ leftBG = s.getAsColor(borderLeftBackgroundKey)
+ )
+
+ var blend *borderBlend
+ if len(blendFG) > 0 {
+ blend = s.borderBlend(width, len(lines), blendFG...)
+ } else {
+ topFG = s.getAsColor(borderTopForegroundKey)
+ rightFG = s.getAsColor(borderRightForegroundKey)
+ bottomFG = s.getAsColor(borderBottomForegroundKey)
+ leftFG = s.getAsColor(borderLeftForegroundKey)
+ }
+
+ var out strings.Builder
+
+ // Render top
+ if hasTop {
+ top := renderHorizontalEdge(border.TopLeft, border.Top, border.TopRight, width)
+ if blend != nil {
+ out.WriteString(s.styleBorderBlend(top, blend.topGradient, topBG))
+ } else {
+ out.WriteString(s.styleBorder(top, topFG, topBG))
+ }
+ out.WriteRune('\n')
+ }
+
+ leftRunes := []rune(border.Left)
+ leftIndex := 0
+
+ rightRunes := []rune(border.Right)
+ rightIndex := 0
+
+ // Render sides
+ var r string
+ for i, l := range lines {
+ if hasLeft {
+ r = string(leftRunes[leftIndex])
+ leftIndex++
+ if leftIndex >= len(leftRunes) {
+ leftIndex = 0
+ }
+ if blend != nil {
+ out.WriteString(s.styleBorder(r, blend.leftGradient[i], leftBG))
+ } else {
+ out.WriteString(s.styleBorder(r, leftFG, leftBG))
+ }
+ }
+ out.WriteString(l)
+ if hasRight {
+ r = string(rightRunes[rightIndex])
+ rightIndex++
+ if rightIndex >= len(rightRunes) {
+ rightIndex = 0
+ }
+ if blend != nil {
+ out.WriteString(s.styleBorder(r, blend.rightGradient[i], rightBG))
+ } else {
+ out.WriteString(s.styleBorder(r, rightFG, rightBG))
+ }
+ }
+ if i < len(lines)-1 {
+ out.WriteRune('\n')
+ }
+ }
+
+ // Render bottom
+ if hasBottom {
+ bottom := renderHorizontalEdge(border.BottomLeft, border.Bottom, border.BottomRight, width)
+ out.WriteRune('\n')
+ if blend != nil {
+ out.WriteString(s.styleBorderBlend(bottom, blend.bottomGradient, bottomBG))
+ } else {
+ out.WriteString(s.styleBorder(bottom, bottomFG, bottomBG))
+ }
+ }
+
+ return out.String()
+}
+
+// Render the horizontal (top or bottom) portion of a border.
+func renderHorizontalEdge(left, middle, right string, width int) string {
+ if middle == "" {
+ middle = " "
+ }
+
+ leftWidth := ansi.StringWidth(left)
+ rightWidth := ansi.StringWidth(right)
+
+ runes := []rune(middle)
+ j := 0
+
+ out := strings.Builder{}
+ out.WriteString(left)
+
+ for i := 0; i < width-leftWidth-rightWidth; {
+ r := runes[j]
+ out.WriteRune(r)
+ i += ansi.StringWidth(string(r))
+ j++
+ if j >= len(runes) {
+ j = 0
+ }
+ }
+
+ out.WriteString(right)
+ return out.String()
+}
+
+// styleBorder applies foreground and background styling to a border.
+func (s Style) styleBorder(border string, fg, bg color.Color) string {
+ if fg == noColor && bg == noColor {
+ return border
+ }
+ var style ansi.Style
+ if fg != noColor {
+ style = style.ForegroundColor(fg)
+ }
+ if bg != noColor {
+ style = style.BackgroundColor(bg)
+ }
+ return style.Styled(border)
+}
+
+// styleBorderBlend applies foreground and background styling to a border, using blending.
+func (s Style) styleBorderBlend(border string, fg []color.Color, bg color.Color) string {
+ var out strings.Builder
+ var style ansi.Style
+ var i int
+
+ gr := uniseg.NewGraphemes(border)
+ for gr.Next() {
+ style = style[:0]
+ if fg[i] != noColor {
+ style = style.ForegroundColor(fg[i])
+ }
+ if bg != noColor {
+ style = style.BackgroundColor(bg)
+ }
+ _, _ = out.WriteString(style.String())
+ _, _ = out.Write(gr.Bytes())
+ i++
+ }
+ _, _ = out.WriteString(ansi.ResetStyle)
+ return out.String()
+}
+
+func maxRuneWidth(str string) int {
+ switch len(str) {
+ case 0:
+ return 0
+ case 1:
+ return displaywidth.String(str)
+ }
+
+ var width int
+
+ g := displaywidth.StringGraphemes(str)
+ for g.Next() {
+ width = max(width, g.Width())
+ }
+ return width
+}
+
+func getFirstRuneAsString(str string) string {
+ if str == "" {
+ return str
+ }
+ _, size := utf8.DecodeRuneInString(str)
+ return str[:size]
+}
diff --git a/vendor/charm.land/lipgloss/v2/canvas.go b/vendor/charm.land/lipgloss/v2/canvas.go
new file mode 100644
index 0000000000..e6cc3b451c
--- /dev/null
+++ b/vendor/charm.land/lipgloss/v2/canvas.go
@@ -0,0 +1,89 @@
+package lipgloss
+
+import (
+ uv "github.com/charmbracelet/ultraviolet"
+ "github.com/charmbracelet/x/ansi"
+)
+
+// Canvas is a cell-buffer that can be used to compose and draw [uv.Drawable]s
+// like [Layer]s.
+//
+// Composed drawables are drawn onto the canvas in the order they were
+// composed, meaning later drawables will appear "on top" of earlier ones.
+//
+// A canvas can read, modify, and render its cell contents.
+//
+// It implements [uv.Screen] and [uv.Drawable].
+type Canvas struct {
+ scr uv.ScreenBuffer
+}
+
+var _ uv.Screen = (*Canvas)(nil)
+
+// NewCanvas creates a new [Canvas] with the given size.
+func NewCanvas(width, height int) *Canvas {
+ c := new(Canvas)
+ c.scr = uv.NewScreenBuffer(width, height)
+ c.scr.Method = ansi.GraphemeWidth
+ return c
+}
+
+// Resize resizes the canvas to the given width and height.
+func (c *Canvas) Resize(width, height int) {
+ c.scr.Resize(width, height)
+}
+
+// Clear clears the canvas.
+func (c *Canvas) Clear() {
+ c.scr.Clear()
+}
+
+// Bounds implements [uv.Screen].
+func (c *Canvas) Bounds() uv.Rectangle {
+ return c.scr.Bounds()
+}
+
+// Width returns the width of the canvas.
+func (c *Canvas) Width() int {
+ return c.scr.Width()
+}
+
+// Height returns the height of the canvas.
+func (c *Canvas) Height() int {
+ return c.scr.Height()
+}
+
+// CellAt implements [uv.Screen].
+func (c *Canvas) CellAt(x int, y int) *uv.Cell {
+ return c.scr.CellAt(x, y)
+}
+
+// SetCell implements [uv.Screen].
+func (c *Canvas) SetCell(x int, y int, cell *uv.Cell) {
+ c.scr.SetCell(x, y, cell)
+}
+
+// WidthMethod implements [uv.Screen].
+func (c *Canvas) WidthMethod() uv.WidthMethod {
+ return c.scr.WidthMethod()
+}
+
+// Compose composes a [Layer] or any [uv.Drawable] onto the [Canvas].
+func (c *Canvas) Compose(drawer uv.Drawable) *Canvas {
+ drawer.Draw(c, c.Bounds())
+ return c
+}
+
+// Draw draws the [Canvas] onto the given [uv.Screen] within the specified
+// area.
+//
+// It implements [uv.Drawable].
+func (c *Canvas) Draw(scr uv.Screen, area uv.Rectangle) {
+ c.scr.Draw(scr, area)
+}
+
+// Render renders the canvas into a styled string. Any trailing spaces are
+// trimmed.
+func (c *Canvas) Render() string {
+ return uv.TrimSpace(c.scr.Render())
+}
diff --git a/vendor/charm.land/lipgloss/v2/color.go b/vendor/charm.land/lipgloss/v2/color.go
new file mode 100644
index 0000000000..7443dc10bb
--- /dev/null
+++ b/vendor/charm.land/lipgloss/v2/color.go
@@ -0,0 +1,359 @@
+package lipgloss
+
+import (
+ "cmp"
+ "errors"
+ "image/color"
+ "strconv"
+ "strings"
+
+ "github.com/charmbracelet/colorprofile"
+ "github.com/charmbracelet/x/ansi"
+ "github.com/lucasb-eyer/go-colorful"
+)
+
+func clamp[T cmp.Ordered](v, low, high T) T {
+ if high < low {
+ high, low = low, high
+ }
+ return min(high, max(low, v))
+}
+
+// 4-bit color constants.
+const (
+ Black ansi.BasicColor = iota
+ Red
+ Green
+ Yellow
+ Blue
+ Magenta
+ Cyan
+ White
+
+ BrightBlack
+ BrightRed
+ BrightGreen
+ BrightYellow
+ BrightBlue
+ BrightMagenta
+ BrightCyan
+ BrightWhite
+)
+
+var noColor = NoColor{}
+
+// NoColor is used to specify the absence of color styling. When this is active
+// foreground colors will be rendered with the terminal's default text color,
+// and background colors will not be drawn at all.
+//
+// Example usage:
+//
+// var style = someStyle.Background(lipgloss.NoColor{})
+type NoColor struct{}
+
+// RGBA returns the RGBA value of this color. Because we have to return
+// something, despite this color being the absence of color, we're returning
+// black with 100% opacity.
+//
+// Red: 0x0, Green: 0x0, Blue: 0x0, Alpha: 0xFFFF.
+func (n NoColor) RGBA() (r, g, b, a uint32) {
+ return 0x0, 0x0, 0x0, 0xFFFF //nolint:mnd
+}
+
+// Color specifies a color by hex or ANSI256 value. For example:
+//
+// ansiColor := lipgloss.Color("1") // The same as lipgloss.Red
+// ansi256Color := lipgloss.Color("21")
+// hexColor := lipgloss.Color("#0000ff")
+func Color(s string) color.Color {
+ if strings.HasPrefix(s, "#") {
+ c, err := parseHex(s)
+ if err != nil {
+ return noColor
+ }
+ return c
+ }
+
+ i, err := strconv.Atoi(s)
+ if err != nil {
+ return noColor
+ }
+
+ if i < 0 {
+ // Only positive numbers
+ i = -i
+ }
+
+ if i < 16 {
+ return ansi.BasicColor(i) //nolint:gosec
+ } else if i < 256 {
+ return ANSIColor(i) //nolint:gosec
+ }
+
+ r, g, b := uint8((i>>16)&0xff), uint8(i>>8&0xff), uint8(i&0xff) //nolint:gosec
+ return color.RGBA{R: r, G: g, B: b, A: 0xff}
+}
+
+var errInvalidFormat = errors.New("invalid hex format") // pre-allocated.
+
+// parseHex parses a hex color string and returns a color.RGBA. The string can be
+// in the format #RRGGBB or #RGB. This is a more performant implementation of
+// [colorful.Hex].
+func parseHex(s string) (c color.RGBA, err error) {
+ c.A = 0xff
+
+ if len(s) == 0 || s[0] != '#' {
+ return c, errInvalidFormat
+ }
+
+ hexToByte := func(b byte) byte {
+ switch {
+ case b >= '0' && b <= '9':
+ return b - '0'
+ case b >= 'a' && b <= 'f':
+ return b - 'a' + 10
+ case b >= 'A' && b <= 'F':
+ return b - 'A' + 10
+ }
+ err = errInvalidFormat
+ return 0
+ }
+
+ switch len(s) {
+ case 7:
+ c.R = hexToByte(s[1])<<4 + hexToByte(s[2])
+ c.G = hexToByte(s[3])<<4 + hexToByte(s[4])
+ c.B = hexToByte(s[5])<<4 + hexToByte(s[6])
+ case 4:
+ c.R = hexToByte(s[1]) * 17
+ c.G = hexToByte(s[2]) * 17
+ c.B = hexToByte(s[3]) * 17
+ default:
+ err = errInvalidFormat
+ }
+ return c, err
+}
+
+// RGBColor is a color specified by red, green, and blue values.
+type RGBColor struct {
+ R uint8
+ G uint8
+ B uint8
+}
+
+// RGBA returns the RGBA value of this color. This satisfies the Go Color
+// interface.
+func (c RGBColor) RGBA() (r, g, b, a uint32) {
+ const shift = 8
+ r |= uint32(c.R) << shift
+ g |= uint32(c.G) << shift
+ b |= uint32(c.B) << shift
+ a = 0xFFFF
+ return
+}
+
+// ANSIColor is a color specified by an ANSI256 color value.
+//
+// Example usage:
+//
+// colorA := lipgloss.ANSIColor(8)
+// colorB := lipgloss.ANSIColor(134)
+type ANSIColor = ansi.IndexedColor
+
+// LightDarkFunc is a function that returns a color based on whether the
+// terminal has a light or dark background. You can create one of these with
+// [LightDark].
+//
+// Example:
+//
+// lightDark := lipgloss.LightDark(hasDarkBackground)
+// red, blue := lipgloss.Color("#ff0000"), lipgloss.Color("#0000ff")
+// myHotColor := lightDark(red, blue)
+//
+// For more info see [LightDark].
+type LightDarkFunc func(light, dark color.Color) color.Color
+
+// LightDark is a simple helper type that can be used to choose the appropriate
+// color based on whether the terminal has a light or dark background.
+//
+// lightDark := lipgloss.LightDark(hasDarkBackground)
+// red, blue := lipgloss.Color("#ff0000"), lipgloss.Color("#0000ff")
+// myHotColor := lightDark(red, blue)
+//
+// In practice, there are slightly different workflows between Bubble Tea and
+// Lip Gloss standalone.
+//
+// In Bubble Tea, listen for tea.BackgroundColorMsg, which automatically
+// flows through Update on start. This message will be received whenever the
+// background color changes:
+//
+// case tea.BackgroundColorMsg:
+// m.hasDarkBackground = msg.IsDark()
+//
+// Later, when you're rendering use:
+//
+// lightDark := lipgloss.LightDark(m.hasDarkBackground)
+// red, blue := lipgloss.Color("#ff0000"), lipgloss.Color("#0000ff")
+// myHotColor := lightDark(red, blue)
+//
+// In standalone Lip Gloss, the workflow is simpler:
+//
+// hasDarkBG := lipgloss.HasDarkBackground(os.Stdin, os.Stdout)
+// lightDark := lipgloss.LightDark(hasDarkBG)
+// red, blue := lipgloss.Color("#ff0000"), lipgloss.Color("#0000ff")
+// myHotColor := lightDark(red, blue)
+func LightDark(isDark bool) LightDarkFunc {
+ return func(light, dark color.Color) color.Color {
+ if isDark {
+ return dark
+ }
+ return light
+ }
+}
+
+// isDarkColor returns whether the given color is dark (based on the luminance
+// portion of the color as interpreted as HSL).
+//
+// Example usage:
+//
+// color := lipgloss.Color("#0000ff")
+// if lipgloss.isDarkColor(color) {
+// fmt.Println("It's dark! I love darkness!")
+// } else {
+// fmt.Println("It's light! Cover your eyes!")
+// }
+func isDarkColor(c color.Color) bool {
+ col, ok := colorful.MakeColor(c)
+ if !ok {
+ return true
+ }
+
+ _, _, l := col.Hsl()
+ return l < 0.5 //nolint:mnd
+}
+
+// CompleteFunc is a function that returns the appropriate color based on the
+// given color profile.
+//
+// Example usage:
+//
+// p := colorprofile.Detect(os.Stderr, os.Environ())
+// complete := lipgloss.Complete(p)
+// color := complete(
+// lipgloss.Color(1), // ANSI
+// lipgloss.Color(124), // ANSI256
+// lipgloss.Color("#ff34ac"), // TrueColor
+// )
+// fmt.Println("Ooh, pretty color: ", color)
+//
+// For more info see [Complete].
+type CompleteFunc func(ansi, ansi256, truecolor color.Color) color.Color
+
+// Complete returns a function that will return the appropriate color based on
+// the given color profile.
+//
+// Example usage:
+//
+// p := colorprofile.Detect(os.Stderr, os.Environ())
+// complete := lipgloss.Complete(p)
+// color := complete(
+// lipgloss.Color(1), // ANSI
+// lipgloss.Color(124), // ANSI256
+// lipgloss.Color("#ff34ac"), // TrueColor
+// )
+// fmt.Println("Ooh, pretty color: ", color)
+func Complete(p colorprofile.Profile) CompleteFunc {
+ return func(ansi, ansi256, truecolor color.Color) color.Color {
+ switch p { //nolint:exhaustive
+ case colorprofile.ANSI:
+ return ansi
+ case colorprofile.ANSI256:
+ return ansi256
+ case colorprofile.TrueColor:
+ return truecolor
+ }
+ return noColor
+ }
+}
+
+// ensureNotTransparent ensures that the alpha value of a color is not 0, and if
+// it is, we will set it to 1. This is useful for when we are converting from
+// RGB -> RGBA, and the alpha value is lost in the conversion for gradient purposes.
+func ensureNotTransparent(c color.Color) color.Color {
+ _, _, _, a := c.RGBA()
+ if a == 0 {
+ return Alpha(c, 1)
+ }
+ return c
+}
+
+// Alpha adjusts the alpha value of a color using a 0-1 (clamped) float scale
+// 0 = transparent, 1 = opaque.
+func Alpha(c color.Color, alpha float64) color.Color {
+ if c == nil {
+ return nil
+ }
+
+ r, g, b, _ := c.RGBA()
+ return color.RGBA{
+ R: uint8(min(255, float64(r>>8))),
+ G: uint8(min(255, float64(g>>8))),
+ B: uint8(min(255, float64(b>>8))),
+ A: uint8(clamp(alpha, 0, 1) * 255),
+ }
+}
+
+// Complementary returns the complementary color (180° away on color wheel) of
+// the given color. This is useful for creating a contrasting color.
+func Complementary(c color.Color) color.Color {
+ if c == nil {
+ return nil
+ }
+
+ // Offset hue by 180°.
+ cf, _ := colorful.MakeColor(ensureNotTransparent(c))
+
+ h, s, v := cf.Hsv()
+ h += 180
+ if h >= 360 {
+ h -= 360
+ } else if h < 0 {
+ h += 360
+ }
+
+ return colorful.Hsv(h, s, v).Clamped()
+}
+
+// Darken takes a color and makes it darker by a specific percentage (0-1, clamped).
+func Darken(c color.Color, percent float64) color.Color {
+ if c == nil {
+ return nil
+ }
+
+ mult := 1.0 - clamp(percent, 0, 1)
+
+ r, g, b, a := c.RGBA()
+ return color.RGBA{
+ R: uint8(float64(r>>8) * mult),
+ G: uint8(float64(g>>8) * mult),
+ B: uint8(float64(b>>8) * mult),
+ A: uint8(min(255, float64(a>>8))),
+ }
+}
+
+// Lighten makes a color lighter by a specific percentage (0-1, clamped).
+func Lighten(c color.Color, percent float64) color.Color {
+ if c == nil {
+ return nil
+ }
+
+ add := 255 * (clamp(percent, 0, 1))
+
+ r, g, b, a := c.RGBA()
+ return color.RGBA{
+ R: uint8(min(255, float64(r>>8)+add)),
+ G: uint8(min(255, float64(g>>8)+add)),
+ B: uint8(min(255, float64(b>>8)+add)),
+ A: uint8(min(255, float64(a>>8))),
+ }
+}
diff --git a/vendor/charm.land/lipgloss/v2/get.go b/vendor/charm.land/lipgloss/v2/get.go
new file mode 100644
index 0000000000..d1fe1d6691
--- /dev/null
+++ b/vendor/charm.land/lipgloss/v2/get.go
@@ -0,0 +1,657 @@
+package lipgloss
+
+import (
+ "image/color"
+ "strings"
+
+ "github.com/charmbracelet/x/ansi"
+)
+
+// GetBold returns the style's bold value. If no value is set false is returned.
+func (s Style) GetBold() bool {
+ return s.getAsBool(boldKey, false)
+}
+
+// GetItalic returns the style's italic value. If no value is set false is
+// returned.
+func (s Style) GetItalic() bool {
+ return s.getAsBool(italicKey, false)
+}
+
+// GetUnderline returns the style's underline value. If no value is set false is
+// returned.
+func (s Style) GetUnderline() bool {
+ return s.ul != UnderlineNone
+}
+
+// GetUnderlineStyle returns the style's underline style. If no value is set
+// UnderlineNone is returned.
+func (s Style) GetUnderlineStyle() Underline {
+ return s.ul
+}
+
+// GetUnderlineColor returns the style's underline color. If no value is set
+// NoColor{} is returned.
+func (s Style) GetUnderlineColor() color.Color {
+ return s.getAsColor(underlineColorKey)
+}
+
+// GetStrikethrough returns the style's strikethrough value. If no value is set false
+// is returned.
+func (s Style) GetStrikethrough() bool {
+ return s.getAsBool(strikethroughKey, false)
+}
+
+// GetReverse returns the style's reverse value. If no value is set false is
+// returned.
+func (s Style) GetReverse() bool {
+ return s.getAsBool(reverseKey, false)
+}
+
+// GetBlink returns the style's blink value. If no value is set false is
+// returned.
+func (s Style) GetBlink() bool {
+ return s.getAsBool(blinkKey, false)
+}
+
+// GetFaint returns the style's faint value. If no value is set false is
+// returned.
+func (s Style) GetFaint() bool {
+ return s.getAsBool(faintKey, false)
+}
+
+// GetForeground returns the style's foreground color. If no value is set
+// NoColor{} is returned.
+func (s Style) GetForeground() color.Color {
+ return s.getAsColor(foregroundKey)
+}
+
+// GetBackground returns the style's background color. If no value is set
+// NoColor{} is returned.
+func (s Style) GetBackground() color.Color {
+ return s.getAsColor(backgroundKey)
+}
+
+// GetWidth returns the style's width setting. If no width is set 0 is
+// returned.
+func (s Style) GetWidth() int {
+ return s.getAsInt(widthKey)
+}
+
+// GetHeight returns the style's height setting. If no height is set 0 is
+// returned.
+func (s Style) GetHeight() int {
+ return s.getAsInt(heightKey)
+}
+
+// GetAlign returns the style's implicit horizontal alignment setting.
+// If no alignment is set Position.Left is returned.
+func (s Style) GetAlign() Position {
+ v := s.getAsPosition(alignHorizontalKey)
+ if v == Position(0) {
+ return Left
+ }
+ return v
+}
+
+// GetAlignHorizontal returns the style's implicit horizontal alignment setting.
+// If no alignment is set Position.Left is returned.
+func (s Style) GetAlignHorizontal() Position {
+ v := s.getAsPosition(alignHorizontalKey)
+ if v == Position(0) {
+ return Left
+ }
+ return v
+}
+
+// GetAlignVertical returns the style's implicit vertical alignment setting.
+// If no alignment is set Position.Top is returned.
+func (s Style) GetAlignVertical() Position {
+ v := s.getAsPosition(alignVerticalKey)
+ if v == Position(0) {
+ return Top
+ }
+ return v
+}
+
+// GetPadding returns the style's top, right, bottom, and left padding values,
+// in that order. 0 is returned for unset values.
+func (s Style) GetPadding() (top, right, bottom, left int) {
+ return s.getAsInt(paddingTopKey),
+ s.getAsInt(paddingRightKey),
+ s.getAsInt(paddingBottomKey),
+ s.getAsInt(paddingLeftKey)
+}
+
+// GetPaddingTop returns the style's top padding. If no value is set 0 is
+// returned.
+func (s Style) GetPaddingTop() int {
+ return s.getAsInt(paddingTopKey)
+}
+
+// GetPaddingRight returns the style's right padding. If no value is set 0 is
+// returned.
+func (s Style) GetPaddingRight() int {
+ return s.getAsInt(paddingRightKey)
+}
+
+// GetPaddingBottom returns the style's bottom padding. If no value is set 0 is
+// returned.
+func (s Style) GetPaddingBottom() int {
+ return s.getAsInt(paddingBottomKey)
+}
+
+// GetPaddingLeft returns the style's left padding. If no value is set 0 is
+// returned.
+func (s Style) GetPaddingLeft() int {
+ return s.getAsInt(paddingLeftKey)
+}
+
+// GetPaddingChar returns the style's padding character. If no value is set a
+// space is returned.
+func (s Style) GetPaddingChar() rune {
+ char := s.getAsRune(paddingCharKey)
+ if char == 0 {
+ return ' '
+ }
+ return char
+}
+
+// GetHorizontalPadding returns the style's left and right padding. Unset
+// values are measured as 0.
+func (s Style) GetHorizontalPadding() int {
+ return s.getAsInt(paddingLeftKey) + s.getAsInt(paddingRightKey)
+}
+
+// GetVerticalPadding returns the style's top and bottom padding. Unset values
+// are measured as 0.
+func (s Style) GetVerticalPadding() int {
+ return s.getAsInt(paddingTopKey) + s.getAsInt(paddingBottomKey)
+}
+
+// GetColorWhitespace returns the style's whitespace coloring setting. If no
+// value is set false is returned.
+func (s Style) GetColorWhitespace() bool {
+ return s.getAsBool(colorWhitespaceKey, false)
+}
+
+// GetMargin returns the style's top, right, bottom, and left margins, in that
+// order. 0 is returned for unset values.
+func (s Style) GetMargin() (top, right, bottom, left int) {
+ return s.getAsInt(marginTopKey),
+ s.getAsInt(marginRightKey),
+ s.getAsInt(marginBottomKey),
+ s.getAsInt(marginLeftKey)
+}
+
+// GetMarginTop returns the style's top margin. If no value is set 0 is
+// returned.
+func (s Style) GetMarginTop() int {
+ return s.getAsInt(marginTopKey)
+}
+
+// GetMarginRight returns the style's right margin. If no value is set 0 is
+// returned.
+func (s Style) GetMarginRight() int {
+ return s.getAsInt(marginRightKey)
+}
+
+// GetMarginBottom returns the style's bottom margin. If no value is set 0 is
+// returned.
+func (s Style) GetMarginBottom() int {
+ return s.getAsInt(marginBottomKey)
+}
+
+// GetMarginLeft returns the style's left margin. If no value is set 0 is
+// returned.
+func (s Style) GetMarginLeft() int {
+ return s.getAsInt(marginLeftKey)
+}
+
+// GetMarginChar returns the style's padding character. If no value is set a
+// space is returned.
+func (s Style) GetMarginChar() rune {
+ char := s.getAsRune(marginCharKey)
+ if char == 0 {
+ return ' '
+ }
+ return char
+}
+
+// GetHorizontalMargins returns the style's left and right margins. Unset
+// values are measured as 0.
+func (s Style) GetHorizontalMargins() int {
+ return s.getAsInt(marginLeftKey) + s.getAsInt(marginRightKey)
+}
+
+// GetVerticalMargins returns the style's top and bottom margins. Unset values
+// are measured as 0.
+func (s Style) GetVerticalMargins() int {
+ return s.getAsInt(marginTopKey) + s.getAsInt(marginBottomKey)
+}
+
+// GetBorder returns the style's border style (type Border) and value for the
+// top, right, bottom, and left in that order. If no value is set for the
+// border style, Border{} is returned. For all other unset values false is
+// returned.
+func (s Style) GetBorder() (b Border, top, right, bottom, left bool) {
+ return s.getBorderStyle(),
+ s.getAsBool(borderTopKey, false),
+ s.getAsBool(borderRightKey, false),
+ s.getAsBool(borderBottomKey, false),
+ s.getAsBool(borderLeftKey, false)
+}
+
+// GetBorderStyle returns the style's border style (type Border). If no value
+// is set Border{} is returned.
+func (s Style) GetBorderStyle() Border {
+ return s.getBorderStyle()
+}
+
+// GetBorderTop returns the style's top border setting. If no value is set
+// false is returned.
+func (s Style) GetBorderTop() bool {
+ return s.getAsBool(borderTopKey, false)
+}
+
+// GetBorderRight returns the style's right border setting. If no value is set
+// false is returned.
+func (s Style) GetBorderRight() bool {
+ return s.getAsBool(borderRightKey, false)
+}
+
+// GetBorderBottom returns the style's bottom border setting. If no value is
+// set false is returned.
+func (s Style) GetBorderBottom() bool {
+ return s.getAsBool(borderBottomKey, false)
+}
+
+// GetBorderLeft returns the style's left border setting. If no value is
+// set false is returned.
+func (s Style) GetBorderLeft() bool {
+ return s.getAsBool(borderLeftKey, false)
+}
+
+// GetBorderTopForeground returns the style's border top foreground color. If
+// no value is set NoColor{} is returned.
+func (s Style) GetBorderTopForeground() color.Color {
+ return s.getAsColor(borderTopForegroundKey)
+}
+
+// GetBorderRightForeground returns the style's border right foreground color.
+// If no value is set NoColor{} is returned.
+func (s Style) GetBorderRightForeground() color.Color {
+ return s.getAsColor(borderRightForegroundKey)
+}
+
+// GetBorderBottomForeground returns the style's border bottom foreground
+// color. If no value is set NoColor{} is returned.
+func (s Style) GetBorderBottomForeground() color.Color {
+ return s.getAsColor(borderBottomForegroundKey)
+}
+
+// GetBorderLeftForeground returns the style's border left foreground
+// color. If no value is set NoColor{} is returned.
+func (s Style) GetBorderLeftForeground() color.Color {
+ return s.getAsColor(borderLeftForegroundKey)
+}
+
+// GetBorderForegroundBlend returns the style's border blend foreground
+// colors. If no value is set, nil is returned.
+func (s Style) GetBorderForegroundBlend() []color.Color {
+ return s.getAsColors(borderForegroundBlendKey)
+}
+
+// GetBorderForegroundBlendOffset returns the style's border blend offset. If no
+// value is set, 0 is returned.
+func (s Style) GetBorderForegroundBlendOffset() int {
+ return s.getAsInt(borderForegroundBlendOffsetKey)
+}
+
+// GetBorderTopBackground returns the style's border top background color. If
+// no value is set NoColor{} is returned.
+func (s Style) GetBorderTopBackground() color.Color {
+ return s.getAsColor(borderTopBackgroundKey)
+}
+
+// GetBorderRightBackground returns the style's border right background color.
+// If no value is set NoColor{} is returned.
+func (s Style) GetBorderRightBackground() color.Color {
+ return s.getAsColor(borderRightBackgroundKey)
+}
+
+// GetBorderBottomBackground returns the style's border bottom background
+// color. If no value is set NoColor{} is returned.
+func (s Style) GetBorderBottomBackground() color.Color {
+ return s.getAsColor(borderBottomBackgroundKey)
+}
+
+// GetBorderLeftBackground returns the style's border left background
+// color. If no value is set NoColor{} is returned.
+func (s Style) GetBorderLeftBackground() color.Color {
+ return s.getAsColor(borderLeftBackgroundKey)
+}
+
+// GetBorderTopWidth returns the width of the top border. If borders contain
+// runes of varying widths, the widest rune is returned. If no border exists on
+// the top edge, 0 is returned.
+//
+// Deprecated: This function simply calls Style.GetBorderTopSize.
+func (s Style) GetBorderTopWidth() int {
+ return s.GetBorderTopSize()
+}
+
+// GetBorderTopSize returns the width of the top border. If borders contain
+// runes of varying widths, the widest rune is returned. If no border exists on
+// the top edge, 0 is returned.
+func (s Style) GetBorderTopSize() int {
+ if s.isBorderStyleSetWithoutSides() {
+ return 1
+ }
+ if !s.getAsBool(borderTopKey, false) {
+ return 0
+ }
+ return s.getBorderStyle().GetTopSize()
+}
+
+// GetBorderLeftSize returns the width of the left border. If borders contain
+// runes of varying widths, the widest rune is returned. If no border exists on
+// the left edge, 0 is returned.
+func (s Style) GetBorderLeftSize() int {
+ if s.isBorderStyleSetWithoutSides() {
+ return 1
+ }
+ if !s.getAsBool(borderLeftKey, false) {
+ return 0
+ }
+ return s.getBorderStyle().GetLeftSize()
+}
+
+// GetBorderBottomSize returns the width of the bottom border. If borders
+// contain runes of varying widths, the widest rune is returned. If no border
+// exists on the left edge, 0 is returned.
+func (s Style) GetBorderBottomSize() int {
+ if s.isBorderStyleSetWithoutSides() {
+ return 1
+ }
+ if !s.getAsBool(borderBottomKey, false) {
+ return 0
+ }
+ return s.getBorderStyle().GetBottomSize()
+}
+
+// GetBorderRightSize returns the width of the right border. If borders
+// contain runes of varying widths, the widest rune is returned. If no border
+// exists on the right edge, 0 is returned.
+func (s Style) GetBorderRightSize() int {
+ if s.isBorderStyleSetWithoutSides() {
+ return 1
+ }
+ if !s.getAsBool(borderRightKey, false) {
+ return 0
+ }
+ return s.getBorderStyle().GetRightSize()
+}
+
+// GetHorizontalBorderSize returns the width of the horizontal borders. If
+// borders contain runes of varying widths, the widest rune is returned. If no
+// border exists on the horizontal edges, 0 is returned.
+func (s Style) GetHorizontalBorderSize() int {
+ return s.GetBorderLeftSize() + s.GetBorderRightSize()
+}
+
+// GetVerticalBorderSize returns the width of the vertical borders. If
+// borders contain runes of varying widths, the widest rune is returned. If no
+// border exists on the vertical edges, 0 is returned.
+func (s Style) GetVerticalBorderSize() int {
+ return s.GetBorderTopSize() + s.GetBorderBottomSize()
+}
+
+// GetInline returns the style's inline setting. If no value is set false is
+// returned.
+func (s Style) GetInline() bool {
+ return s.getAsBool(inlineKey, false)
+}
+
+// GetMaxWidth returns the style's max width setting. If no value is set 0 is
+// returned.
+func (s Style) GetMaxWidth() int {
+ return s.getAsInt(maxWidthKey)
+}
+
+// GetMaxHeight returns the style's max height setting. If no value is set 0 is
+// returned.
+func (s Style) GetMaxHeight() int {
+ return s.getAsInt(maxHeightKey)
+}
+
+// GetTabWidth returns the style's tab width setting. If no value is set 4 is
+// returned which is the implicit default.
+func (s Style) GetTabWidth() int {
+ return s.getAsInt(tabWidthKey)
+}
+
+// GetUnderlineSpaces returns whether or not the style is set to underline
+// spaces. If not value is set false is returned.
+func (s Style) GetUnderlineSpaces() bool {
+ return s.getAsBool(underlineSpacesKey, false)
+}
+
+// GetStrikethroughSpaces returns whether or not the style is set to strikethrough
+// spaces. If not value is set false is returned.
+func (s Style) GetStrikethroughSpaces() bool {
+ return s.getAsBool(strikethroughSpacesKey, false)
+}
+
+// GetHorizontalFrameSize returns the sum of the style's horizontal margins, padding
+// and border widths.
+//
+// Provisional: this method may be renamed.
+func (s Style) GetHorizontalFrameSize() int {
+ return s.GetHorizontalMargins() + s.GetHorizontalPadding() + s.GetHorizontalBorderSize()
+}
+
+// GetVerticalFrameSize returns the sum of the style's vertical margins, padding
+// and border widths.
+//
+// Provisional: this method may be renamed.
+func (s Style) GetVerticalFrameSize() int {
+ return s.GetVerticalMargins() + s.GetVerticalPadding() + s.GetVerticalBorderSize()
+}
+
+// GetFrameSize returns the sum of the margins, padding and border width for
+// both the horizontal and vertical margins.
+func (s Style) GetFrameSize() (x, y int) {
+ return s.GetHorizontalFrameSize(), s.GetVerticalFrameSize()
+}
+
+// GetTransform returns the transform set on the style. If no transform is set
+// nil is returned.
+func (s Style) GetTransform() func(string) string {
+ return s.getAsTransform(transformKey)
+}
+
+// GetHyperlink returns the hyperlink along with its parameters. If no
+// hyperlink is set, empty strings are returned.
+func (s Style) GetHyperlink() (link, params string) {
+ if s.isSet(linkKey) {
+ link = s.link
+ }
+ if s.isSet(linkParamsKey) {
+ params = s.linkParams
+ }
+ return
+}
+
+// Returns whether or not the given property is set.
+func (s Style) isSet(k propKey) bool {
+ return s.props.has(k)
+}
+
+func (s Style) getAsRune(k propKey) rune {
+ if !s.isSet(k) {
+ return 0
+ }
+ switch k { //nolint:exhaustive
+ case paddingCharKey:
+ return s.paddingChar
+ case marginCharKey:
+ return s.marginChar
+ }
+ return 0
+}
+
+func (s Style) getAsBool(k propKey, defaultVal bool) bool {
+ if !s.isSet(k) {
+ return defaultVal
+ }
+ return s.attrs&int(k) != 0
+}
+
+func (s Style) getAsColors(k propKey) (colors []color.Color) {
+ if !s.isSet(k) {
+ return nil
+ }
+
+ switch k { //nolint:exhaustive
+ case borderForegroundBlendKey:
+ return s.borderBlendFgColor
+ }
+
+ return nil
+}
+
+func (s Style) getAsColor(k propKey) color.Color {
+ if !s.isSet(k) {
+ return noColor
+ }
+
+ var c color.Color
+ switch k { //nolint:exhaustive
+ case foregroundKey:
+ c = s.fgColor
+ case backgroundKey:
+ c = s.bgColor
+ case marginBackgroundKey:
+ c = s.marginBgColor
+ case borderTopForegroundKey:
+ c = s.borderTopFgColor
+ case borderRightForegroundKey:
+ c = s.borderRightFgColor
+ case borderBottomForegroundKey:
+ c = s.borderBottomFgColor
+ case borderLeftForegroundKey:
+ c = s.borderLeftFgColor
+ case borderTopBackgroundKey:
+ c = s.borderTopBgColor
+ case borderRightBackgroundKey:
+ c = s.borderRightBgColor
+ case borderBottomBackgroundKey:
+ c = s.borderBottomBgColor
+ case borderLeftBackgroundKey:
+ c = s.borderLeftBgColor
+ case underlineColorKey:
+ c = s.ulColor
+ }
+
+ if c != nil {
+ return c
+ }
+
+ return noColor
+}
+
+func (s Style) getAsInt(k propKey) int {
+ if !s.isSet(k) {
+ return 0
+ }
+ switch k { //nolint:exhaustive
+ case widthKey:
+ return s.width
+ case heightKey:
+ return s.height
+ case paddingTopKey:
+ return s.paddingTop
+ case paddingRightKey:
+ return s.paddingRight
+ case paddingBottomKey:
+ return s.paddingBottom
+ case paddingLeftKey:
+ return s.paddingLeft
+ case marginTopKey:
+ return s.marginTop
+ case marginRightKey:
+ return s.marginRight
+ case marginBottomKey:
+ return s.marginBottom
+ case marginLeftKey:
+ return s.marginLeft
+ case borderForegroundBlendOffsetKey:
+ return s.borderForegroundBlendOffset
+ case maxWidthKey:
+ return s.maxWidth
+ case maxHeightKey:
+ return s.maxHeight
+ case tabWidthKey:
+ return s.tabWidth
+ }
+ return 0
+}
+
+func (s Style) getAsPosition(k propKey) Position {
+ if !s.isSet(k) {
+ return Position(0)
+ }
+ switch k { //nolint:exhaustive
+ case alignHorizontalKey:
+ return s.alignHorizontal
+ case alignVerticalKey:
+ return s.alignVertical
+ }
+ return Position(0)
+}
+
+func (s Style) getBorderStyle() Border {
+ if !s.isSet(borderStyleKey) {
+ return noBorder
+ }
+ return s.borderStyle
+}
+
+func (s Style) getAsTransform(propKey) func(string) string {
+ if !s.isSet(transformKey) {
+ return nil
+ }
+ return s.transform
+}
+
+// Split a string into lines, additionally returning the size of the widest
+// line.
+func getLines(s string) (lines []string, widest int) {
+ s = strings.ReplaceAll(s, "\t", " ")
+ s = strings.ReplaceAll(s, "\r\n", "\n")
+ lines = strings.Split(s, "\n")
+
+ for _, l := range lines {
+ w := ansi.StringWidth(l)
+ if widest < w {
+ widest = w
+ }
+ }
+
+ return lines, widest
+}
+
+// isBorderStyleSetWithoutSides returns true if the border style is set but no
+// sides are set. This is used to determine if the border should be rendered by
+// default.
+func (s Style) isBorderStyleSetWithoutSides() bool {
+ var (
+ border = s.getBorderStyle()
+ topSet = s.isSet(borderTopKey)
+ rightSet = s.isSet(borderRightKey)
+ bottomSet = s.isSet(borderBottomKey)
+ leftSet = s.isSet(borderLeftKey)
+ )
+ return border != noBorder && !(topSet || rightSet || bottomSet || leftSet) //nolint:staticcheck
+}
diff --git a/vendor/charm.land/lipgloss/v2/join.go b/vendor/charm.land/lipgloss/v2/join.go
new file mode 100644
index 0000000000..349ae552fa
--- /dev/null
+++ b/vendor/charm.land/lipgloss/v2/join.go
@@ -0,0 +1,175 @@
+package lipgloss
+
+import (
+ "math"
+ "strings"
+
+ "github.com/charmbracelet/x/ansi"
+)
+
+// JoinHorizontal is a utility function for horizontally joining two
+// potentially multi-lined strings along a vertical axis. The first argument is
+// the position, with 0 being all the way at the top and 1 being all the way
+// at the bottom.
+//
+// If you just want to align to the top, center or bottom you may as well just
+// use the helper constants Top, Center, and Bottom.
+//
+// Example:
+//
+// blockB := "...\n...\n..."
+// blockA := "...\n...\n...\n...\n..."
+//
+// // Join 20% from the top
+// str := lipgloss.JoinHorizontal(0.2, blockA, blockB)
+//
+// // Join on the top edge
+// str := lipgloss.JoinHorizontal(lipgloss.Top, blockA, blockB)
+func JoinHorizontal(pos Position, strs ...string) string {
+ if len(strs) == 0 {
+ return ""
+ }
+ if len(strs) == 1 {
+ return strs[0]
+ }
+
+ var (
+ // Groups of strings broken into multiple lines
+ blocks = make([][]string, len(strs))
+
+ // Max line widths for the above text blocks
+ maxWidths = make([]int, len(strs))
+
+ // Height of the tallest block
+ maxHeight int
+ )
+
+ // Break text blocks into lines and get max widths for each text block
+ for i, str := range strs {
+ blocks[i], maxWidths[i] = getLines(str)
+ if len(blocks[i]) > maxHeight {
+ maxHeight = len(blocks[i])
+ }
+ }
+
+ // Add extra lines to make each side the same height
+ for i := range blocks {
+ if len(blocks[i]) >= maxHeight {
+ continue
+ }
+
+ extraLines := make([]string, maxHeight-len(blocks[i]))
+
+ switch pos {
+ case Top:
+ blocks[i] = append(blocks[i], extraLines...)
+
+ case Bottom:
+ blocks[i] = append(extraLines, blocks[i]...)
+
+ default: // Somewhere in the middle
+ n := len(extraLines)
+ split := int(math.Round(float64(n) * pos.value()))
+ top := n - split
+ bottom := n - top
+
+ blocks[i] = append(extraLines[top:], blocks[i]...)
+ blocks[i] = append(blocks[i], extraLines[bottom:]...)
+ }
+ }
+
+ // Merge lines
+ var b strings.Builder
+ for i := range blocks[0] { // remember, all blocks have the same number of members now
+ for j, block := range blocks {
+ b.WriteString(block[i])
+
+ // Also make lines the same length
+ b.WriteString(strings.Repeat(" ", maxWidths[j]-ansi.StringWidth(block[i])))
+ }
+ if i < len(blocks[0])-1 {
+ b.WriteRune('\n')
+ }
+ }
+
+ return b.String()
+}
+
+// JoinVertical is a utility function for vertically joining two potentially
+// multi-lined strings along a horizontal axis. The first argument is the
+// position, with 0 being all the way to the left and 1 being all the way to
+// the right.
+//
+// If you just want to align to the left, right or center you may as well just
+// use the helper constants Left, Center, and Right.
+//
+// Example:
+//
+// blockB := "...\n...\n..."
+// blockA := "...\n...\n...\n...\n..."
+//
+// // Join 20% from the top
+// str := lipgloss.JoinVertical(0.2, blockA, blockB)
+//
+// // Join on the right edge
+// str := lipgloss.JoinVertical(lipgloss.Right, blockA, blockB)
+func JoinVertical(pos Position, strs ...string) string {
+ if len(strs) == 0 {
+ return ""
+ }
+ if len(strs) == 1 {
+ return strs[0]
+ }
+
+ var (
+ blocks = make([][]string, len(strs))
+ maxWidth int
+ )
+
+ for i := range strs {
+ var w int
+ blocks[i], w = getLines(strs[i])
+ if w > maxWidth {
+ maxWidth = w
+ }
+ }
+
+ var b strings.Builder
+ for i, block := range blocks {
+ for j, line := range block {
+ w := maxWidth - ansi.StringWidth(line)
+
+ switch pos {
+ case Left:
+ b.WriteString(line)
+ b.WriteString(strings.Repeat(" ", w))
+
+ case Right:
+ b.WriteString(strings.Repeat(" ", w))
+ b.WriteString(line)
+
+ default: // Somewhere in the middle
+ if w < 1 {
+ b.WriteString(line)
+ break
+ }
+
+ split := int(math.Round(float64(w) * pos.value()))
+ right := w - split
+ left := w - right
+
+ b.WriteString(strings.Repeat(" ", left))
+ b.WriteString(line)
+ b.WriteString(strings.Repeat(" ", right))
+ }
+
+ // Write a newline as long as we're not on the last line of the
+ // last block.
+ if !(i == len(blocks)-1 && j == len(block)-1) { //nolint:staticcheck
+ b.WriteRune('\n')
+ }
+ }
+ }
+
+ return b.String()
+}
diff --git a/vendor/charm.land/lipgloss/v2/layer.go b/vendor/charm.land/lipgloss/v2/layer.go
new file mode 100644
index 0000000000..e30d1ef2a0
--- /dev/null
+++ b/vendor/charm.land/lipgloss/v2/layer.go
@@ -0,0 +1,327 @@
+package lipgloss
+
+import (
+ "fmt"
+ "image"
+ "slices"
+
+ uv "github.com/charmbracelet/ultraviolet"
+)
+
+// Layer represents a visual layer with content and positioning. It's a pure
+// data structure that defines the layer hierarchy without any computation.
+type Layer struct {
+ id string
+ content string
+ width, height int
+ x, y, z int
+ layers []*Layer
+}
+
+// NewLayer creates a new [Layer] with the given content and optional child layers.
+func NewLayer(content string, layers ...*Layer) *Layer {
+ l := &Layer{
+ content: content,
+ }
+ l.AddLayers(layers...)
+ return l
+}
+
+// GetContent returns the content of the Layer.
+func (l *Layer) GetContent() string {
+ return l.content
+}
+
+// Width returns the width of the Layer.
+func (l *Layer) Width() int {
+ return l.width
+}
+
+// Height returns the height of the Layer.
+func (l *Layer) Height() int {
+ return l.height
+}
+
+// GetID returns the ID of the Layer.
+func (l *Layer) GetID() string {
+ return l.id
+}
+
+// ID sets the ID of the Layer.
+func (l *Layer) ID(id string) *Layer {
+ l.id = id
+ return l
+}
+
+// X sets the x-coordinate of the Layer relative to its parent.
+func (l *Layer) X(x int) *Layer {
+ l.x = x
+ return l
+}
+
+// Y sets the y-coordinate of the Layer relative to its parent.
+func (l *Layer) Y(y int) *Layer {
+ l.y = y
+ return l
+}
+
+// Z sets the z-index of the Layer relative to its parent.
+func (l *Layer) Z(z int) *Layer {
+ l.z = z
+ return l
+}
+
+// GetX returns the x-coordinate of the Layer relative to its parent.
+func (l *Layer) GetX() int {
+ return l.x
+}
+
+// GetY returns the y-coordinate of the Layer relative to its parent.
+func (l *Layer) GetY() int {
+ return l.y
+}
+
+// GetZ returns the z-index of the Layer relative to its parent.
+func (l *Layer) GetZ() int {
+ return l.z
+}
+
+// AddLayers adds child layers to the Layer.
+func (l *Layer) AddLayers(layers ...*Layer) *Layer {
+ for i, layer := range layers {
+ if layer == nil {
+ panic(fmt.Sprintf("layer at index %d is nil", i))
+ }
+ l.layers = append(l.layers, layer)
+ }
+ area := l.boundsWithOffset(0, 0)
+ l.width = area.Dx()
+ l.height = area.Dy()
+ return l
+}
+
+// GetLayer returns a descendant layer by its ID, or nil if not found.
+// Layers with empty IDs are skipped.
+func (l *Layer) GetLayer(id string) *Layer {
+ if id == "" {
+ return nil
+ }
+ if l.id == id {
+ return l
+ }
+ for _, child := range l.layers {
+ if found := child.GetLayer(id); found != nil {
+ return found
+ }
+ }
+ return nil
+}
+
+// MaxZ returns the maximum z-index among this layer and all its descendants.
+func (l *Layer) MaxZ() int {
+ maxZ := l.z
+ for _, child := range l.layers {
+ childMaxZ := child.MaxZ()
+ if childMaxZ > maxZ {
+ maxZ = childMaxZ
+ }
+ }
+ return maxZ
+}
+
+// boundsWithOffset calculates bounds with parent offset applied.
+func (l *Layer) boundsWithOffset(parentX, parentY int) image.Rectangle {
+ absX := l.x + parentX
+ absY := l.y + parentY
+
+ width, height := Width(l.content), Height(l.content)
+ bounds := image.Rectangle{
+ Min: image.Pt(absX, absY),
+ Max: image.Pt(absX+width, absY+height),
+ }
+
+ for _, child := range l.layers {
+ bounds = bounds.Union(child.boundsWithOffset(absX, absY))
+ }
+
+ return bounds
+}
+
+var _ uv.Drawable = (*Layer)(nil)
+
+// Draw draws the content of the layer on the screen at the specified area.
+func (l *Layer) Draw(scr uv.Screen, area uv.Rectangle) {
+ content := uv.NewStyledString(l.content)
+ content.Draw(scr, area)
+}
+
+// LayerHit represents the result of a hit test on a [Layer].
+type LayerHit struct {
+ id string
+ layer *Layer
+ bounds image.Rectangle
+}
+
+// Empty returns true if the LayerHit represents no hit.
+func (lh LayerHit) Empty() bool {
+ return lh.layer == nil
+}
+
+// ID returns the ID of the hit Layer.
+func (lh LayerHit) ID() string {
+ return lh.id
+}
+
+// Layer returns the layer that was hit.
+func (lh LayerHit) Layer() *Layer {
+ return lh.layer
+}
+
+// Bounds returns the bounds of the LayerHit.
+func (lh LayerHit) Bounds() image.Rectangle {
+ return lh.bounds
+}
+
+// Compositor manages the composition of layers. It flattens a layer hierarchy
+// once and provides efficient drawing and hit testing operations. All computation
+// related to layers happens in the Compositor.
+type Compositor struct {
+ root *Layer
+ layers []compositeLayer
+ index map[string]*Layer
+ bounds image.Rectangle
+}
+
+// compositeLayer holds a flattened layer with its calculated absolute position and bounds.
+type compositeLayer struct {
+ layer *Layer
+ absX int
+ absY int
+ bounds image.Rectangle
+}
+
+// NewCompositor creates a new Compositor with an internal root layer. Optional
+// layers can be provided which will be added as children of the root. The layer
+// hierarchy is flattened and sorted by z-index for efficient rendering and hit testing.
+func NewCompositor(layers ...*Layer) *Compositor {
+ root := NewLayer("")
+ root.AddLayers(layers...)
+ c := &Compositor{
+ root: root,
+ index: make(map[string]*Layer),
+ }
+ c.flatten()
+ return c
+}
+
+// AddLayers adds layers to the compositor's root and refreshes the internal state.
+func (c *Compositor) AddLayers(layers ...*Layer) *Compositor {
+ c.root.AddLayers(layers...)
+ c.flatten()
+ return c
+}
+
+// flatten builds the internal flattened layer list and calculates overall bounds.
+func (c *Compositor) flatten() {
+ c.layers = nil
+ c.index = make(map[string]*Layer)
+ c.flattenRecursive(c.root, 0, 0)
+
+ // Sort by absolute z-index (lowest to highest for drawing)
+ slices.SortFunc(c.layers, func(a, b compositeLayer) int {
+ return a.layer.z - b.layer.z
+ })
+
+ // Calculate overall bounds
+ if len(c.layers) > 0 {
+ c.bounds = c.layers[0].bounds
+ for i := 1; i < len(c.layers); i++ {
+ c.bounds = c.bounds.Union(c.layers[i].bounds)
+ }
+ }
+}
+
+// flattenRecursive recursively collects all layers with their absolute positions.
+func (c *Compositor) flattenRecursive(layer *Layer, parentX, parentY int) {
+ absX := layer.x + parentX
+ absY := layer.y + parentY
+
+ width, height := Width(layer.content), Height(layer.content)
+ bounds := image.Rectangle{
+ Min: image.Pt(absX, absY),
+ Max: image.Pt(absX+width, absY+height),
+ }
+
+ c.layers = append(c.layers, compositeLayer{
+ layer: layer,
+ absX: absX,
+ absY: absY,
+ bounds: bounds,
+ })
+
+ // Index layer by ID if it has one
+ if layer.id != "" {
+ c.index[layer.id] = layer
+ }
+
+ for _, child := range layer.layers {
+ c.flattenRecursive(child, absX, absY)
+ }
+}
+
+// Bounds returns the overall bounds of all layers in the compositor.
+func (c *Compositor) Bounds() image.Rectangle {
+ return c.bounds
+}
+
+// Draw draws all layers onto the given [uv.Screen] in z-index order.
+func (c *Compositor) Draw(scr uv.Screen, area image.Rectangle) {
+ for _, cl := range c.layers {
+ if cl.bounds.Overlaps(area) {
+ cl.layer.Draw(scr, cl.bounds)
+ }
+ }
+}
+
+// Hit performs a hit test at the given (x, y) coordinates. If a layer is hit,
+// it returns the ID of the top-most layer at that point. Layers with empty IDs
+// are ignored. If no layer is hit, it returns an empty [LayerHit].
+func (c *Compositor) Hit(x, y int) LayerHit {
+ var hit LayerHit
+ pt := image.Pt(x, y)
+ // Check from highest z to lowest (reverse order)
+ for i := len(c.layers) - 1; i >= 0; i-- {
+ cl := c.layers[i]
+ if cl.layer.id != "" && pt.In(cl.bounds) {
+ hit.id = cl.layer.id
+ hit.layer = cl.layer
+ hit.bounds = cl.bounds
+ return hit
+ }
+ }
+ return hit
+}
+
+// GetLayer returns a layer by its ID, or nil if not found.
+// Layers with empty IDs are not indexed and cannot be retrieved.
+func (c *Compositor) GetLayer(id string) *Layer {
+ if id == "" {
+ return nil
+ }
+ return c.index[id]
+}
+
+// Refresh re-flattens the layer hierarchy. Call this after modifying the layer
+// tree structure or positions to update the compositor's internal state.
+func (c *Compositor) Refresh() {
+ c.flatten()
+}
+
+// Render renders the compositor into a styled string. This is a helper
+// function that creates a temporary canvas, draws the compositor onto it, and
+// returns the resulting string.
+func (c *Compositor) Render() string {
+ width, height := c.bounds.Dx(), c.bounds.Dy()
+ canvas := NewCanvas(width, height)
+ return canvas.Compose(c).Render()
+}
diff --git a/vendor/charm.land/lipgloss/v2/lipgloss.go b/vendor/charm.land/lipgloss/v2/lipgloss.go
new file mode 100644
index 0000000000..3fb4e6f26c
--- /dev/null
+++ b/vendor/charm.land/lipgloss/v2/lipgloss.go
@@ -0,0 +1,3 @@
+// Package lipgloss provides style definitions for nice terminal layouts. Built
+// with TUIs in mind.
+package lipgloss
diff --git a/vendor/charm.land/lipgloss/v2/position.go b/vendor/charm.land/lipgloss/v2/position.go
new file mode 100644
index 0000000000..ce91442d6f
--- /dev/null
+++ b/vendor/charm.land/lipgloss/v2/position.go
@@ -0,0 +1,134 @@
+package lipgloss
+
+import (
+ "math"
+ "strings"
+
+ "github.com/charmbracelet/x/ansi"
+)
+
+// Position represents a position along a horizontal or vertical axis. It's in
+// situations where an axis is involved, like alignment, joining, placement and
+// so on.
+//
+// A value of 0 represents the start (the left or top) and 1 represents the end
+// (the right or bottom). 0.5 represents the center.
+//
+// There are constants Top, Bottom, Center, Left and Right in this package that
+// can be used to aid readability.
+type Position float64
+
+func (p Position) value() float64 {
+ return math.Min(1, math.Max(0, float64(p)))
+}
+
+// Position aliases.
+const (
+ Top Position = 0.0
+ Bottom Position = 1.0
+ Center Position = 0.5
+ Left Position = 0.0
+ Right Position = 1.0
+)
+
+// Place places a string or text block vertically in an unstyled box of a given
+// width or height.
+func Place(width, height int, hPos, vPos Position, str string, opts ...WhitespaceOption) string {
+ return PlaceVertical(height, vPos, PlaceHorizontal(width, hPos, str, opts...), opts...)
+}
+
+// PlaceHorizontal places a string or text block horizontally in an unstyled
+// block of a given width. If the given width is shorter than the max width of
+// the string (measured by its longest line) this will be a noöp.
+func PlaceHorizontal(width int, pos Position, str string, opts ...WhitespaceOption) string {
+ lines, contentWidth := getLines(str)
+ gap := width - contentWidth
+
+ if gap <= 0 {
+ return str
+ }
+
+ ws := newWhitespace(opts...)
+
+ var b strings.Builder
+ for i, l := range lines {
+ // Is this line shorter than the longest line?
+ short := max(0, contentWidth-ansi.StringWidth(l))
+
+ switch pos {
+ case Left:
+ b.WriteString(l)
+ b.WriteString(ws.render(gap + short))
+
+ case Right:
+ b.WriteString(ws.render(gap + short))
+ b.WriteString(l)
+
+ default: // somewhere in the middle
+ totalGap := gap + short
+
+ split := int(math.Round(float64(totalGap) * pos.value()))
+ left := totalGap - split
+ right := totalGap - left
+
+ b.WriteString(ws.render(left))
+ b.WriteString(l)
+ b.WriteString(ws.render(right))
+ }
+
+ if i < len(lines)-1 {
+ b.WriteRune('\n')
+ }
+ }
+
+ return b.String()
+}
+
+// PlaceVertical places a string or text block vertically in an unstyled block
+// of a given height. If the given height is shorter than the height of the
+// string (measured by its newlines) then this will be a noöp.
+func PlaceVertical(height int, pos Position, str string, opts ...WhitespaceOption) string {
+ contentHeight := strings.Count(str, "\n") + 1
+ gap := height - contentHeight
+
+ if gap <= 0 {
+ return str
+ }
+
+ ws := newWhitespace(opts...)
+
+ _, width := getLines(str)
+ emptyLine := ws.render(width)
+ b := strings.Builder{}
+
+ switch pos {
+ case Top:
+ b.WriteString(str)
+ b.WriteRune('\n')
+ for i := range gap {
+ b.WriteString(emptyLine)
+ if i < gap-1 {
+ b.WriteRune('\n')
+ }
+ }
+
+ case Bottom:
+ b.WriteString(strings.Repeat(emptyLine+"\n", gap))
+ b.WriteString(str)
+
+ default: // Somewhere in the middle
+ split := int(math.Round(float64(gap) * pos.value()))
+ top := gap - split
+ bottom := gap - top
+
+ b.WriteString(strings.Repeat(emptyLine+"\n", top))
+ b.WriteString(str)
+
+ for range bottom {
+ b.WriteRune('\n')
+ b.WriteString(emptyLine)
+ }
+ }
+
+ return b.String()
+}
diff --git a/vendor/charm.land/lipgloss/v2/query.go b/vendor/charm.land/lipgloss/v2/query.go
new file mode 100644
index 0000000000..96cd5b9454
--- /dev/null
+++ b/vendor/charm.land/lipgloss/v2/query.go
@@ -0,0 +1,92 @@
+package lipgloss
+
+import (
+ "fmt"
+ "image/color"
+ "os"
+ "runtime"
+
+ "github.com/charmbracelet/x/term"
+)
+
+func backgroundColor(in term.File, out term.File) (color.Color, error) {
+ state, err := term.MakeRaw(in.Fd())
+ if err != nil {
+ return nil, fmt.Errorf("error setting raw state to detect background color: %w", err)
+ }
+
+ defer term.Restore(in.Fd(), state) //nolint:errcheck
+
+ bg, err := queryBackgroundColor(in, out)
+ if err != nil {
+ return nil, err
+ }
+
+ return bg, nil
+}
+
+// BackgroundColor queries the terminal's background color. Typically, you'll
+// want to query against stdin and either stdout or stderr, depending on what
+// you're writing to.
+//
+// This function is intended for standalone Lip Gloss use only. If you're using
+// Bubble Tea, listen for tea.BackgroundColorMsg in your update function.
+func BackgroundColor(in term.File, out term.File) (bg color.Color, err error) {
+ if runtime.GOOS == "windows" { //nolint:nestif
+ // On Windows, when the input/output is redirected or piped, we need to
+ // open the console explicitly.
+ // See https://learn.microsoft.com/en-us/windows/console/getstdhandle#remarks
+ if !term.IsTerminal(in.Fd()) {
+ f, err := os.OpenFile("CONIN$", os.O_RDWR, 0o644) //nolint:gosec
+ if err != nil {
+ return nil, fmt.Errorf("error opening CONIN$: %w", err)
+ }
+ in = f
+ }
+ if !term.IsTerminal(out.Fd()) {
+ f, err := os.OpenFile("CONOUT$", os.O_RDWR, 0o644) //nolint:gosec
+ if err != nil {
+ return nil, fmt.Errorf("error opening CONOUT$: %w", err)
+ }
+ out = f
+ }
+ return backgroundColor(in, out)
+ }
+
+ // NOTE: On Unix, one of the given files must be a tty.
+ if !term.IsTerminal(in.Fd()) || !term.IsTerminal(out.Fd()) {
+ return nil, fmt.Errorf("input/output is not a terminal")
+ }
+ for _, f := range []term.File{in, out} {
+ if bg, err = backgroundColor(f, f); err == nil {
+ return bg, nil
+ }
+ }
+
+ return bg, err
+}
+
+// HasDarkBackground detects whether the terminal has a light or dark
+// background.
+//
+// Typically, you'll want to query against stdin and either stdout or stderr
+// depending on what you're writing to.
+//
+// hasDarkBG := HasDarkBackground(os.Stdin, os.Stdout)
+// lightDark := LightDark(hasDarkBG)
+// myHotColor := lightDark("#ff0000", "#0000ff")
+//
+// This is intended for use in standalone Lip Gloss only. In Bubble Tea, listen
+// for tea.BackgroundColorMsg in your Update function.
+//
+// case tea.BackgroundColorMsg:
+// hasDarkBackground = msg.IsDark()
+//
+// By default, this function will return true if it encounters an error.
+func HasDarkBackground(in term.File, out term.File) bool {
+ bg, err := BackgroundColor(in, out)
+ if err != nil || bg == nil {
+ return true
+ }
+ return isDarkColor(bg)
+}
diff --git a/vendor/charm.land/lipgloss/v2/ranges.go b/vendor/charm.land/lipgloss/v2/ranges.go
new file mode 100644
index 0000000000..bb209f0ead
--- /dev/null
+++ b/vendor/charm.land/lipgloss/v2/ranges.go
@@ -0,0 +1,48 @@
+package lipgloss
+
+import (
+ "strings"
+
+ "github.com/charmbracelet/x/ansi"
+)
+
+// StyleRanges applying styling to ranges in a string. Existing styles will be
+// taken into account. Ranges should not overlap.
+func StyleRanges(s string, ranges ...Range) string {
+ if len(ranges) == 0 {
+ return s
+ }
+
+ var buf strings.Builder
+ lastIdx := 0
+ stripped := ansi.Strip(s)
+
+ // Use Truncate and TruncateLeft to style match.MatchedIndexes without
+ // losing the original option style:
+ for _, rng := range ranges {
+ // Add the text before this match
+ if rng.Start > lastIdx {
+ buf.WriteString(ansi.Cut(s, lastIdx, rng.Start))
+ }
+ // Add the matched range with its highlight
+ buf.WriteString(rng.Style.Render(ansi.Cut(stripped, rng.Start, rng.End)))
+ lastIdx = rng.End
+ }
+
+ // Add any remaining text after the last match
+ buf.WriteString(ansi.TruncateLeft(s, lastIdx, ""))
+
+ return buf.String()
+}
+
+// NewRange returns a range and style that can be used with [StyleRanges].
+func NewRange(start, end int, style Style) Range {
+ return Range{start, end, style}
+}
+
+// Range is a range of text and associated styling to be used with
+// [StyleRanges].
+type Range struct {
+ Start, End int
+ Style Style
+}
diff --git a/vendor/charm.land/lipgloss/v2/runes.go b/vendor/charm.land/lipgloss/v2/runes.go
new file mode 100644
index 0000000000..7a49e326cc
--- /dev/null
+++ b/vendor/charm.land/lipgloss/v2/runes.go
@@ -0,0 +1,43 @@
+package lipgloss
+
+import (
+ "strings"
+)
+
+// StyleRunes apply a given style to runes at the given indices in the string.
+// Note that you must provide styling options for both matched and unmatched
+// runes. Indices out of bounds will be ignored.
+func StyleRunes(str string, indices []int, matched, unmatched Style) string {
+ // Convert slice of indices to a map for easier lookups
+ m := make(map[int]struct{})
+ for _, i := range indices {
+ m[i] = struct{}{}
+ }
+
+ var (
+ out strings.Builder
+ group strings.Builder
+ style Style
+ runes = []rune(str)
+ )
+
+ for i, r := range runes {
+ group.WriteRune(r)
+
+ _, matches := m[i]
+ _, nextMatches := m[i+1]
+
+ if matches != nextMatches || i == len(runes)-1 {
+ // Flush
+ if matches {
+ style = matched
+ } else {
+ style = unmatched
+ }
+ out.WriteString(style.Render(group.String()))
+ group.Reset()
+ }
+ }
+
+ return out.String()
+}
diff --git a/vendor/charm.land/lipgloss/v2/set.go b/vendor/charm.land/lipgloss/v2/set.go
new file mode 100644
index 0000000000..f10b4538a6
--- /dev/null
+++ b/vendor/charm.land/lipgloss/v2/set.go
@@ -0,0 +1,932 @@
+package lipgloss
+
+import (
+ "image/color"
+ "strings"
+)
+
+// Set a value on the underlying rules map.
+func (s *Style) set(key propKey, value any) {
+ // We don't allow negative integers on any of our other values, so just keep
+ // them at zero or above. We could use uints instead, but the
+ // conversions are a little tedious, so we're sticking with ints for
+ // sake of usability.
+ switch key {
+ case foregroundKey:
+ s.fgColor = colorOrNil(value)
+ case backgroundKey:
+ s.bgColor = colorOrNil(value)
+ case underlineColorKey:
+ s.ulColor = colorOrNil(value)
+ case underlineKey:
+ s.ul = value.(Underline)
+ case widthKey:
+ s.width = max(0, value.(int))
+ case heightKey:
+ s.height = max(0, value.(int))
+ case alignHorizontalKey:
+ s.alignHorizontal = value.(Position)
+ case alignVerticalKey:
+ s.alignVertical = value.(Position)
+ case paddingTopKey:
+ s.paddingTop = max(0, value.(int))
+ case paddingRightKey:
+ s.paddingRight = max(0, value.(int))
+ case paddingBottomKey:
+ s.paddingBottom = max(0, value.(int))
+ case paddingLeftKey:
+ s.paddingLeft = max(0, value.(int))
+ case paddingCharKey:
+ s.paddingChar = value.(rune)
+ case marginTopKey:
+ s.marginTop = max(0, value.(int))
+ case marginRightKey:
+ s.marginRight = max(0, value.(int))
+ case marginBottomKey:
+ s.marginBottom = max(0, value.(int))
+ case marginLeftKey:
+ s.marginLeft = max(0, value.(int))
+ case marginBackgroundKey:
+ s.marginBgColor = colorOrNil(value)
+ case marginCharKey:
+ s.marginChar = value.(rune)
+ case borderStyleKey:
+ s.borderStyle = value.(Border)
+ case borderTopForegroundKey:
+ s.borderTopFgColor = colorOrNil(value)
+ case borderRightForegroundKey:
+ s.borderRightFgColor = colorOrNil(value)
+ case borderBottomForegroundKey:
+ s.borderBottomFgColor = colorOrNil(value)
+ case borderLeftForegroundKey:
+ s.borderLeftFgColor = colorOrNil(value)
+ case borderForegroundBlendKey:
+ s.borderBlendFgColor = value.([]color.Color)
+ case borderForegroundBlendOffsetKey:
+ s.borderForegroundBlendOffset = value.(int)
+ case borderTopBackgroundKey:
+ s.borderTopBgColor = colorOrNil(value)
+ case borderRightBackgroundKey:
+ s.borderRightBgColor = colorOrNil(value)
+ case borderBottomBackgroundKey:
+ s.borderBottomBgColor = colorOrNil(value)
+ case borderLeftBackgroundKey:
+ s.borderLeftBgColor = colorOrNil(value)
+ case maxWidthKey:
+ s.maxWidth = max(0, value.(int))
+ case maxHeightKey:
+ s.maxHeight = max(0, value.(int))
+ case tabWidthKey:
+ // TabWidth is the only property that may have a negative value (and
+ // that negative value can be no less than -1).
+ s.tabWidth = value.(int)
+ case transformKey:
+ s.transform = value.(func(string) string)
+ case linkKey:
+ s.link = value.(string)
+ case linkParamsKey:
+ s.linkParams = value.(string)
+ default:
+ if v, ok := value.(bool); ok { //nolint:nestif
+ if v {
+ s.attrs |= int(key)
+ } else {
+ s.attrs &^= int(key)
+ }
+ } else if attrs, ok := value.(int); ok {
+ // bool attrs
+ if attrs&int(key) != 0 {
+ s.attrs |= int(key)
+ } else {
+ s.attrs &^= int(key)
+ }
+ }
+ }
+
+ // Set the prop on
+ s.props = s.props.set(key)
+}
+
+// setFrom sets the property from another style.
+func (s *Style) setFrom(key propKey, i Style) {
+ switch key {
+ case foregroundKey:
+ s.set(foregroundKey, i.fgColor)
+ case backgroundKey:
+ s.set(backgroundKey, i.bgColor)
+ case underlineColorKey:
+ s.set(underlineColorKey, i.ulColor)
+ case underlineKey:
+ s.set(underlineKey, i.ul)
+ case widthKey:
+ s.set(widthKey, i.width)
+ case heightKey:
+ s.set(heightKey, i.height)
+ case alignHorizontalKey:
+ s.set(alignHorizontalKey, i.alignHorizontal)
+ case alignVerticalKey:
+ s.set(alignVerticalKey, i.alignVertical)
+ case paddingTopKey:
+ s.set(paddingTopKey, i.paddingTop)
+ case paddingRightKey:
+ s.set(paddingRightKey, i.paddingRight)
+ case paddingBottomKey:
+ s.set(paddingBottomKey, i.paddingBottom)
+ case paddingLeftKey:
+ s.set(paddingLeftKey, i.paddingLeft)
+ case paddingCharKey:
+ s.set(paddingCharKey, i.paddingChar)
+ case marginTopKey:
+ s.set(marginTopKey, i.marginTop)
+ case marginRightKey:
+ s.set(marginRightKey, i.marginRight)
+ case marginBottomKey:
+ s.set(marginBottomKey, i.marginBottom)
+ case marginLeftKey:
+ s.set(marginLeftKey, i.marginLeft)
+ case marginBackgroundKey:
+ s.set(marginBackgroundKey, i.marginBgColor)
+ case marginCharKey:
+ s.set(marginCharKey, i.marginChar)
+ case borderStyleKey:
+ s.set(borderStyleKey, i.borderStyle)
+ case borderTopForegroundKey:
+ s.set(borderTopForegroundKey, i.borderTopFgColor)
+ case borderRightForegroundKey:
+ s.set(borderRightForegroundKey, i.borderRightFgColor)
+ case borderBottomForegroundKey:
+ s.set(borderBottomForegroundKey, i.borderBottomFgColor)
+ case borderLeftForegroundKey:
+ s.set(borderLeftForegroundKey, i.borderLeftFgColor)
+ case borderForegroundBlendKey:
+ s.set(borderForegroundBlendKey, i.borderBlendFgColor)
+ case borderForegroundBlendOffsetKey:
+ s.set(borderForegroundBlendOffsetKey, i.borderForegroundBlendOffset)
+ case borderTopBackgroundKey:
+ s.set(borderTopBackgroundKey, i.borderTopBgColor)
+ case borderRightBackgroundKey:
+ s.set(borderRightBackgroundKey, i.borderRightBgColor)
+ case borderBottomBackgroundKey:
+ s.set(borderBottomBackgroundKey, i.borderBottomBgColor)
+ case borderLeftBackgroundKey:
+ s.set(borderLeftBackgroundKey, i.borderLeftBgColor)
+ case maxWidthKey:
+ s.set(maxWidthKey, i.maxWidth)
+ case maxHeightKey:
+ s.set(maxHeightKey, i.maxHeight)
+ case tabWidthKey:
+ s.set(tabWidthKey, i.tabWidth)
+ case transformKey:
+ s.set(transformKey, i.transform)
+ default:
+ // Set attributes for set bool properties
+ s.set(key, i.attrs)
+ }
+}
+
+func colorOrNil(c any) color.Color {
+ if c, ok := c.(color.Color); ok {
+ return c
+ }
+ return nil
+}
+
+// Bold sets a bold formatting rule.
+func (s Style) Bold(v bool) Style {
+ s.set(boldKey, v)
+ return s
+}
+
+// Italic sets an italic formatting rule. In some terminal emulators this will
+// render with "reverse" coloring if not italic font variant is available.
+func (s Style) Italic(v bool) Style {
+ s.set(italicKey, v)
+ return s
+}
+
+// Underline sets an underline rule. By default, underlines will not be drawn on
+// whitespace like margins and padding. To change this behavior set
+// [Style.UnderlineSpaces].
+func (s Style) Underline(v bool) Style {
+ if v {
+ return s.UnderlineStyle(UnderlineSingle)
+ }
+ return s.UnderlineStyle(UnderlineNone)
+}
+
+// UnderlineStyle sets the underline style. This can be used to set the underline
+// to be a single, double, curly, dotted, or dashed line.
+//
+// Note that not all terminal emulators support underline styles. If a style is
+// not supported, it will typically fall back to a single underline but this is
+// not guaranteed. This depends on the terminal emulator being used.
+func (s Style) UnderlineStyle(u Underline) Style {
+ s.set(underlineKey, u)
+ return s
+}
+
+// UnderlineColor sets the color of the underline. By default, the underline
+// will be the same color as the foreground.
+//
+// Note that not all terminal emulators support colored underlines. If color is
+// not supported, it might produce unexpected results. This depends on the
+// terminal emulator being used.
+func (s Style) UnderlineColor(c color.Color) Style {
+ s.set(underlineColorKey, c)
+ return s
+}
+
+// Strikethrough sets a strikethrough rule. By default, strikes will not be
+// drawn on whitespace like margins and padding. To change this behavior set
+// StrikethroughSpaces.
+func (s Style) Strikethrough(v bool) Style {
+ s.set(strikethroughKey, v)
+ return s
+}
+
+// Reverse sets a rule for inverting foreground and background colors.
+func (s Style) Reverse(v bool) Style {
+ s.set(reverseKey, v)
+ return s
+}
+
+// Blink sets a rule for blinking foreground text.
+func (s Style) Blink(v bool) Style {
+ s.set(blinkKey, v)
+ return s
+}
+
+// Faint sets a rule for rendering the foreground color in a dimmer shade.
+func (s Style) Faint(v bool) Style {
+ s.set(faintKey, v)
+ return s
+}
+
+// Foreground sets a foreground color.
+//
+// // Sets the foreground to blue
+// s := lipgloss.NewStyle().Foreground(lipgloss.Color("#0000ff"))
+//
+// // Removes the foreground color
+// s.Foreground(lipgloss.NoColor)
+func (s Style) Foreground(c color.Color) Style {
+ s.set(foregroundKey, c)
+ return s
+}
+
+// Background sets a background color.
+func (s Style) Background(c color.Color) Style {
+ s.set(backgroundKey, c)
+ return s
+}
+
+// Width sets the width of the block before applying margins. This means your
+// styled content will exactly equal the size set here. Text will wrap based on
+// Padding and Borders set on the style.
+func (s Style) Width(i int) Style {
+ s.set(widthKey, i)
+ return s
+}
+
+// Height sets the height of the block before applying margins. If the height of
+// the text block is less than this value after applying padding (or not), the
+// block will be set to this height.
+func (s Style) Height(i int) Style {
+ s.set(heightKey, i)
+ return s
+}
+
+// Align is a shorthand method for setting horizontal and vertical alignment.
+//
+// With one argument, the position value is applied to the horizontal alignment.
+//
+// With two arguments, the value is applied to the horizontal and vertical
+// alignments, in that order.
+func (s Style) Align(p ...Position) Style {
+ if len(p) > 0 {
+ s.set(alignHorizontalKey, p[0])
+ }
+ if len(p) > 1 {
+ s.set(alignVerticalKey, p[1])
+ }
+ return s
+}
+
+// AlignHorizontal sets a horizontal text alignment rule.
+func (s Style) AlignHorizontal(p Position) Style {
+ s.set(alignHorizontalKey, p)
+ return s
+}
+
+// AlignVertical sets a vertical text alignment rule.
+func (s Style) AlignVertical(p Position) Style {
+ s.set(alignVerticalKey, p)
+ return s
+}
+
+// Padding is a shorthand method for setting padding on all sides at once.
+//
+// With one argument, the value is applied to all sides.
+//
+// With two arguments, the value is applied to the vertical and horizontal
+// sides, in that order.
+//
+// With three arguments, the value is applied to the top side, the horizontal
+// sides, and the bottom side, in that order.
+//
+// With four arguments, the value is applied clockwise starting from the top
+// side, followed by the right side, then the bottom, and finally the left.
+//
+// With more than four arguments no padding will be added.
+func (s Style) Padding(i ...int) Style {
+ top, right, bottom, left, ok := whichSidesInt(i...)
+ if !ok {
+ return s
+ }
+
+ s.set(paddingTopKey, top)
+ s.set(paddingRightKey, right)
+ s.set(paddingBottomKey, bottom)
+ s.set(paddingLeftKey, left)
+ return s
+}
+
+// PaddingLeft adds padding on the left.
+func (s Style) PaddingLeft(i int) Style {
+ s.set(paddingLeftKey, i)
+ return s
+}
+
+// PaddingRight adds padding on the right.
+func (s Style) PaddingRight(i int) Style {
+ s.set(paddingRightKey, i)
+ return s
+}
+
+// PaddingTop adds padding to the top of the block.
+func (s Style) PaddingTop(i int) Style {
+ s.set(paddingTopKey, i)
+ return s
+}
+
+// PaddingBottom adds padding to the bottom of the block.
+func (s Style) PaddingBottom(i int) Style {
+ s.set(paddingBottomKey, i)
+ return s
+}
+
+// PaddingChar sets the character used for padding. This is useful for
+// rendering blocks with a specific character, such as a space or a dot.
+// Example of using [NBSP] as padding to prevent line breaks:
+//
+// ```go
+// s := lipgloss.NewStyle().PaddingChar(lipgloss.NBSP)
+// ```
+func (s Style) PaddingChar(r rune) Style {
+ s.set(paddingCharKey, r)
+ return s
+}
+
+// ColorWhitespace determines whether or not the background color should be
+// applied to the padding. This is true by default as it's more than likely the
+// desired and expected behavior, but it can be disabled for certain graphic
+// effects.
+//
+// Deprecated: Just use margins and padding.
+func (s Style) ColorWhitespace(v bool) Style {
+ s.set(colorWhitespaceKey, v)
+ return s
+}
+
+// Margin is a shorthand method for setting margins on all sides at once.
+//
+// With one argument, the value is applied to all sides.
+//
+// With two arguments, the value is applied to the vertical and horizontal
+// sides, in that order.
+//
+// With three arguments, the value is applied to the top side, the horizontal
+// sides, and the bottom side, in that order.
+//
+// With four arguments, the value is applied clockwise starting from the top
+// side, followed by the right side, then the bottom, and finally the left.
+//
+// With more than four arguments no margin will be added.
+func (s Style) Margin(i ...int) Style {
+ top, right, bottom, left, ok := whichSidesInt(i...)
+ if !ok {
+ return s
+ }
+
+ s.set(marginTopKey, top)
+ s.set(marginRightKey, right)
+ s.set(marginBottomKey, bottom)
+ s.set(marginLeftKey, left)
+ return s
+}
+
+// MarginLeft sets the value of the left margin.
+func (s Style) MarginLeft(i int) Style {
+ s.set(marginLeftKey, i)
+ return s
+}
+
+// MarginRight sets the value of the right margin.
+func (s Style) MarginRight(i int) Style {
+ s.set(marginRightKey, i)
+ return s
+}
+
+// MarginTop sets the value of the top margin.
+func (s Style) MarginTop(i int) Style {
+ s.set(marginTopKey, i)
+ return s
+}
+
+// MarginBottom sets the value of the bottom margin.
+func (s Style) MarginBottom(i int) Style {
+ s.set(marginBottomKey, i)
+ return s
+}
+
+// MarginBackground sets the background color of the margin. Note that this is
+// also set when inheriting from a style with a background color. In that case
+// the background color on that style will set the margin color on this style.
+func (s Style) MarginBackground(c color.Color) Style {
+ s.set(marginBackgroundKey, c)
+ return s
+}
+
+// MarginChar sets the character used for the margin. This is useful for
+// rendering blocks with a specific character, such as a space or a dot.
+func (s Style) MarginChar(r rune) Style {
+ s.set(marginCharKey, r)
+ return s
+}
+
+// Border is shorthand for setting the border style and which sides should
+// have a border at once. The variadic argument sides works as follows:
+//
+// With one value, the value is applied to all sides.
+//
+// With two values, the values are applied to the vertical and horizontal
+// sides, in that order.
+//
+// With three values, the values are applied to the top side, the horizontal
+// sides, and the bottom side, in that order.
+//
+// With four values, the values are applied clockwise starting from the top
+// side, followed by the right side, then the bottom, and finally the left.
+//
+// With more than four arguments the border will be applied to all sides.
+//
+// Examples:
+//
+// // Applies borders to the top and bottom only
+// lipgloss.NewStyle().Border(lipgloss.NormalBorder(), true, false)
+//
+// // Applies rounded borders to the right and bottom only
+// lipgloss.NewStyle().Border(lipgloss.RoundedBorder(), false, true, true, false)
+func (s Style) Border(b Border, sides ...bool) Style {
+ s.set(borderStyleKey, b)
+
+ top, right, bottom, left, ok := whichSidesBool(sides...)
+ if !ok {
+ top = true
+ right = true
+ bottom = true
+ left = true
+ }
+
+ s.set(borderTopKey, top)
+ s.set(borderRightKey, right)
+ s.set(borderBottomKey, bottom)
+ s.set(borderLeftKey, left)
+
+ return s
+}
+
+// BorderStyle defines the Border on a style. A Border contains a series of
+// definitions for the sides and corners of a border.
+//
+// Note that if border visibility has not been set for any sides when setting
+// the border style, the border will be enabled for all sides during rendering.
+//
+// You can define border characters as you'd like, though several default
+// styles are included: NormalBorder(), RoundedBorder(), BlockBorder(),
+// OuterHalfBlockBorder(), InnerHalfBlockBorder(), ThickBorder(),
+// and DoubleBorder().
+//
+// Example:
+//
+// lipgloss.NewStyle().BorderStyle(lipgloss.ThickBorder())
+func (s Style) BorderStyle(b Border) Style {
+ s.set(borderStyleKey, b)
+ return s
+}
+
+// BorderTop determines whether or not to draw a top border.
+func (s Style) BorderTop(v bool) Style {
+ s.set(borderTopKey, v)
+ return s
+}
+
+// BorderRight determines whether or not to draw a right border.
+func (s Style) BorderRight(v bool) Style {
+ s.set(borderRightKey, v)
+ return s
+}
+
+// BorderBottom determines whether or not to draw a bottom border.
+func (s Style) BorderBottom(v bool) Style {
+ s.set(borderBottomKey, v)
+ return s
+}
+
+// BorderLeft determines whether or not to draw a left border.
+func (s Style) BorderLeft(v bool) Style {
+ s.set(borderLeftKey, v)
+ return s
+}
+
+// BorderForeground is a shorthand function for setting all of the
+// foreground colors of the borders at once. The arguments work as follows:
+//
+// With one argument, the argument is applied to all sides.
+//
+// With two arguments, the arguments are applied to the vertical and horizontal
+// sides, in that order.
+//
+// With three arguments, the arguments are applied to the top side, the
+// horizontal sides, and the bottom side, in that order.
+//
+// With four arguments, the arguments are applied clockwise starting from the
+// top side, followed by the right side, then the bottom, and finally the left.
+//
+// With more than four arguments nothing will be set.
+func (s Style) BorderForeground(c ...color.Color) Style {
+ if len(c) == 0 {
+ return s
+ }
+
+ top, right, bottom, left, ok := whichSidesColor(c...)
+ if !ok {
+ return s
+ }
+
+ s.set(borderTopForegroundKey, top)
+ s.set(borderRightForegroundKey, right)
+ s.set(borderBottomForegroundKey, bottom)
+ s.set(borderLeftForegroundKey, left)
+
+ return s
+}
+
+// BorderTopForeground set the foreground color for the top of the border.
+func (s Style) BorderTopForeground(c color.Color) Style {
+ s.set(borderTopForegroundKey, c)
+ return s
+}
+
+// BorderRightForeground sets the foreground color for the right side of the
+// border.
+func (s Style) BorderRightForeground(c color.Color) Style {
+ s.set(borderRightForegroundKey, c)
+ return s
+}
+
+// BorderBottomForeground sets the foreground color for the bottom of the
+// border.
+func (s Style) BorderBottomForeground(c color.Color) Style {
+ s.set(borderBottomForegroundKey, c)
+ return s
+}
+
+// BorderLeftForeground sets the foreground color for the left side of the
+// border.
+func (s Style) BorderLeftForeground(c color.Color) Style {
+ s.set(borderLeftForegroundKey, c)
+ return s
+}
+
+// BorderForegroundBlend sets the foreground colors for the border blend. At least
+// 2 colors are required to use blending, otherwise this will no-op with 0 colors,
+// and pass to BorderForeground with 1 color. This will override all other border
+// foreground colors when used.
+//
+// When providing colors, in most cases (e.g. when all border sides are enabled),
+// you will want to provide a wrapping-set of colors, so the start and end color
+// are either the same, or very similar. For example:
+//
+// lipgloss.NewStyle().BorderForegroundBlend(
+// lipgloss.Color("#00FA68"),
+// lipgloss.Color("#9900FF"),
+// lipgloss.Color("#ED5353"),
+// lipgloss.Color("#9900FF"),
+// lipgloss.Color("#00FA68"),
+// )
+func (s Style) BorderForegroundBlend(c ...color.Color) Style {
+ if len(c) == 0 {
+ return s
+ }
+
+ // Insufficient colors to use blending, pass to BorderForeground.
+ if len(c) == 1 {
+ return s.BorderForeground(c...)
+ }
+
+ s.set(borderForegroundBlendKey, c)
+ return s
+}
+
+// BorderForegroundBlendOffset sets the border blend offset cells, starting from
+// the top left corner. Value can be positive or negative, and does not need to
+// equal the dimensions of the border region. Direction (when positive) is as
+// follows ("o" is starting point):
+//
+// o -------->
+// ┌──────────┐
+// ^ │ │ |
+// | │ │ |
+// | │ │ |
+// | │ │ v
+// └──────────┘
+// <---------
+func (s Style) BorderForegroundBlendOffset(v int) Style {
+ s.set(borderForegroundBlendOffsetKey, v)
+ return s
+}
+
+// BorderBackground is a shorthand function for setting all of the
+// background colors of the borders at once. The arguments work as follows:
+//
+// With one argument, the argument is applied to all sides.
+//
+// With two arguments, the arguments are applied to the vertical and horizontal
+// sides, in that order.
+//
+// With three arguments, the arguments are applied to the top side, the
+// horizontal sides, and the bottom side, in that order.
+//
+// With four arguments, the arguments are applied clockwise starting from the
+// top side, followed by the right side, then the bottom, and finally the left.
+//
+// With more than four arguments nothing will be set.
+func (s Style) BorderBackground(c ...color.Color) Style {
+ if len(c) == 0 {
+ return s
+ }
+
+ top, right, bottom, left, ok := whichSidesColor(c...)
+ if !ok {
+ return s
+ }
+
+ s.set(borderTopBackgroundKey, top)
+ s.set(borderRightBackgroundKey, right)
+ s.set(borderBottomBackgroundKey, bottom)
+ s.set(borderLeftBackgroundKey, left)
+
+ return s
+}
+
+// BorderTopBackground sets the background color of the top of the border.
+func (s Style) BorderTopBackground(c color.Color) Style {
+ s.set(borderTopBackgroundKey, c)
+ return s
+}
+
+// BorderRightBackground sets the background color of right side the border.
+func (s Style) BorderRightBackground(c color.Color) Style {
+ s.set(borderRightBackgroundKey, c)
+ return s
+}
+
+// BorderBottomBackground sets the background color of the bottom of the
+// border.
+func (s Style) BorderBottomBackground(c color.Color) Style {
+ s.set(borderBottomBackgroundKey, c)
+ return s
+}
+
+// BorderLeftBackground set the background color of the left side of the
+// border.
+func (s Style) BorderLeftBackground(c color.Color) Style {
+ s.set(borderLeftBackgroundKey, c)
+ return s
+}
+
+// Inline makes rendering output one line and disables the rendering of
+// margins, padding and borders. This is useful when you need a style to apply
+// only to font rendering and don't want it to change any physical dimensions.
+// It works well with Style.MaxWidth.
+//
+// Because this in intended to be used at the time of render, this method will
+// not mutate the style and instead return a copy.
+//
+// Example:
+//
+// var userInput string = "..."
+// var userStyle = text.Style{ /* ... */ }
+// fmt.Println(userStyle.Inline(true).Render(userInput))
+func (s Style) Inline(v bool) Style {
+ o := s // copy
+ o.set(inlineKey, v)
+ return o
+}
+
+// MaxWidth applies a max width to a given style. This is useful in enforcing
+// a certain width at render time, particularly with arbitrary strings and
+// styles.
+//
+// Because this in intended to be used at the time of render, this method will
+// not mutate the style and instead return a copy.
+//
+// Example:
+//
+// var userInput string = "..."
+// var userStyle = text.Style{ /* ... */ }
+// fmt.Println(userStyle.MaxWidth(16).Render(userInput))
+func (s Style) MaxWidth(n int) Style {
+ o := s // copy
+ o.set(maxWidthKey, n)
+ return o
+}
+
+// MaxHeight applies a max height to a given style. This is useful in enforcing
+// a certain height at render time, particularly with arbitrary strings and
+// styles.
+//
+// Because this in intended to be used at the time of render, this method will
+// not mutate the style and instead returns a copy.
+func (s Style) MaxHeight(n int) Style {
+ o := s // copy
+ o.set(maxHeightKey, n)
+ return o
+}
+
+// NoTabConversion can be passed to [Style.TabWidth] to disable the replacement
+// of tabs with spaces at render time.
+const NoTabConversion = -1
+
+// TabWidth sets the number of spaces that a tab (/t) should be rendered as.
+// When set to 0, tabs will be removed. To disable the replacement of tabs with
+// spaces entirely, set this to [NoTabConversion].
+//
+// By default, tabs will be replaced with 4 spaces.
+func (s Style) TabWidth(n int) Style {
+ if n <= -1 {
+ n = -1
+ }
+ s.set(tabWidthKey, n)
+ return s
+}
+
+// UnderlineSpaces determines whether to underline spaces between words. By
+// default, this is true. Spaces can also be underlined without underlining the
+// text itself.
+func (s Style) UnderlineSpaces(v bool) Style {
+ s.set(underlineSpacesKey, v)
+ return s
+}
+
+// StrikethroughSpaces determines whether to apply strikethroughs to spaces
+// between words. By default, this is true. Spaces can also be struck without
+// underlining the text itself.
+func (s Style) StrikethroughSpaces(v bool) Style {
+ s.set(strikethroughSpacesKey, v)
+ return s
+}
+
+// Transform applies a given function to a string at render time, allowing for
+// the string being rendered to be manipuated.
+//
+// Example:
+//
+// s := NewStyle().Transform(strings.ToUpper)
+// fmt.Println(s.Render("raow!") // "RAOW!"
+func (s Style) Transform(fn func(string) string) Style {
+ s.set(transformKey, fn)
+ return s
+}
+
+// Hyperlink sets a hyperlink on a style. This is useful for rendering text that
+// can be clicked on in a terminal emulator that supports hyperlinks.
+//
+// Example:
+//
+// s := lipgloss.NewStyle().Hyperlink("https://charm.sh")
+// s := lipgloss.NewStyle().Hyperlink("https://charm.sh", "id=1")
+func (s Style) Hyperlink(link string, params ...string) Style {
+ s.set(linkKey, link)
+ if len(params) > 0 {
+ s.set(linkParamsKey, strings.Join(params, ":"))
+ }
+ return s
+}
+
+// whichSidesInt is a helper method for setting values on sides of a block based
+// on the number of arguments. It follows the CSS shorthand rules for blocks
+// like margin, padding. and borders. Here are how the rules work:
+//
+// 0 args: do nothing
+// 1 arg: all sides
+// 2 args: top -> bottom
+// 3 args: top -> horizontal -> bottom
+// 4 args: top -> right -> bottom -> left
+// 5+ args: do nothing.
+func whichSidesInt(i ...int) (top, right, bottom, left int, ok bool) {
+ switch len(i) {
+ case 1:
+ top = i[0]
+ bottom = i[0]
+ left = i[0]
+ right = i[0]
+ ok = true
+ case 2: //nolint:mnd
+ top = i[0]
+ bottom = i[0]
+ left = i[1]
+ right = i[1]
+ ok = true
+ case 3: //nolint:mnd
+ top = i[0]
+ left = i[1]
+ right = i[1]
+ bottom = i[2]
+ ok = true
+ case 4: //nolint:mnd
+ top = i[0]
+ right = i[1]
+ bottom = i[2]
+ left = i[3]
+ ok = true
+ }
+ return top, right, bottom, left, ok
+}
+
+// whichSidesBool is like whichSidesInt, except it operates on a series of
+// boolean values. See the comment on whichSidesInt for details on how this
+// works.
+func whichSidesBool(i ...bool) (top, right, bottom, left bool, ok bool) {
+ switch len(i) {
+ case 1:
+ top = i[0]
+ bottom = i[0]
+ left = i[0]
+ right = i[0]
+ ok = true
+ case 2: //nolint:mnd
+ top = i[0]
+ bottom = i[0]
+ left = i[1]
+ right = i[1]
+ ok = true
+ case 3: //nolint:mnd
+ top = i[0]
+ left = i[1]
+ right = i[1]
+ bottom = i[2]
+ ok = true
+ case 4: //nolint:mnd
+ top = i[0]
+ right = i[1]
+ bottom = i[2]
+ left = i[3]
+ ok = true
+ }
+ return top, right, bottom, left, ok
+}
+
+// whichSidesColor is like whichSides, except it operates on a series of
+// boolean values. See the comment on whichSidesInt for details on how this
+// works.
+func whichSidesColor(i ...color.Color) (top, right, bottom, left color.Color, ok bool) {
+ switch len(i) {
+ case 1:
+ top = i[0]
+ bottom = i[0]
+ left = i[0]
+ right = i[0]
+ ok = true
+ case 2: //nolint:mnd
+ top = i[0]
+ bottom = i[0]
+ left = i[1]
+ right = i[1]
+ ok = true
+ case 3: //nolint:mnd
+ top = i[0]
+ left = i[1]
+ right = i[1]
+ bottom = i[2]
+ ok = true
+ case 4: //nolint:mnd
+ top = i[0]
+ right = i[1]
+ bottom = i[2]
+ left = i[3]
+ ok = true
+ }
+ return top, right, bottom, left, ok
+}
diff --git a/vendor/charm.land/lipgloss/v2/size.go b/vendor/charm.land/lipgloss/v2/size.go
new file mode 100644
index 0000000000..e0384d035f
--- /dev/null
+++ b/vendor/charm.land/lipgloss/v2/size.go
@@ -0,0 +1,40 @@
+package lipgloss
+
+import (
+ "strings"
+
+ "github.com/charmbracelet/x/ansi"
+)
+
+// Width returns the cell width of characters in the string. ANSI sequences are
+// ignored and characters wider than one cell (such as Chinese characters and
+// emojis) are appropriately measured.
+//
+// You should use this instead of len(string) or len([]rune(string) as neither
+// will give you accurate results.
+func Width(str string) (width int) {
+ for l := range strings.SplitSeq(str, "\n") {
+ w := ansi.StringWidth(l)
+ if w > width {
+ width = w
+ }
+ }
+
+ return width
+}
+
+// Height returns height of a string in cells. This is done simply by
+// counting \n characters. If your output has \r\n, that sequence will be
+// replaced with a \n in [Style.Render].
+func Height(str string) int {
+ return strings.Count(str, "\n") + 1
+}
+
+// Size returns the width and height of the string in cells. ANSI sequences are
+// ignored and characters wider than one cell (such as Chinese characters and
+// emojis) are appropriately measured.
+func Size(str string) (width, height int) {
+ width = Width(str)
+ height = Height(str)
+ return width, height
+}
diff --git a/vendor/charm.land/lipgloss/v2/style.go b/vendor/charm.land/lipgloss/v2/style.go
new file mode 100644
index 0000000000..3cd6595267
--- /dev/null
+++ b/vendor/charm.land/lipgloss/v2/style.go
@@ -0,0 +1,637 @@
+package lipgloss
+
+import (
+ "image/color"
+ "strings"
+ "unicode"
+
+ "github.com/charmbracelet/x/ansi"
+)
+
+const (
+ // NBSP is the non-breaking space rune.
+ NBSP = '\u00A0'
+ tabWidthDefault = 4
+)
+
+// Property for a key.
+type propKey int64
+
+// Available properties.
+const (
+ // Boolean props come first.
+ boldKey propKey = 1 << iota
+ italicKey
+ strikethroughKey
+ reverseKey
+ blinkKey
+ faintKey
+ underlineSpacesKey
+ strikethroughSpacesKey
+ colorWhitespaceKey
+
+ // Non-boolean props.
+ underlineKey
+ foregroundKey
+ backgroundKey
+ underlineColorKey
+ widthKey
+ heightKey
+ alignHorizontalKey
+ alignVerticalKey
+
+ // Padding.
+ paddingTopKey
+ paddingRightKey
+ paddingBottomKey
+ paddingLeftKey
+ paddingCharKey
+
+ // Margins.
+ marginTopKey
+ marginRightKey
+ marginBottomKey
+ marginLeftKey
+ marginBackgroundKey
+ marginCharKey
+
+ // Border runes.
+ borderStyleKey
+
+ // Border edges.
+ borderTopKey
+ borderRightKey
+ borderBottomKey
+ borderLeftKey
+
+ // Border foreground colors.
+ borderTopForegroundKey
+ borderRightForegroundKey
+ borderBottomForegroundKey
+ borderLeftForegroundKey
+ borderForegroundBlendKey
+ borderForegroundBlendOffsetKey
+
+ // Border background colors.
+ borderTopBackgroundKey
+ borderRightBackgroundKey
+ borderBottomBackgroundKey
+ borderLeftBackgroundKey
+
+ inlineKey
+ maxWidthKey
+ maxHeightKey
+ tabWidthKey
+
+ transformKey
+
+ // Hyperlink.
+ linkKey
+ linkParamsKey
+)
+
+// props is a set of properties.
+type props int64
+
+// set sets a property.
+func (p props) set(k propKey) props {
+ return p | props(k)
+}
+
+// unset unsets a property.
+func (p props) unset(k propKey) props {
+ return p &^ props(k)
+}
+
+// has checks if a property is set.
+func (p props) has(k propKey) bool {
+ return p&props(k) != 0
+}
+
+// Underline is the style of the underline.
+//
+// Caveats:
+// - Not all terminals support all underline styles.
+// - Some terminals may render unsupported styles as standard underlines.
+// - Terminal themes may affect the visibility of different underline styles.
+type Underline = ansi.Underline
+
+const (
+ // UnderlineNone is no underline.
+ UnderlineNone = ansi.UnderlineNone
+ // UnderlineSingle is a single underline. This is the default when underline is enabled.
+ UnderlineSingle = ansi.UnderlineSingle
+ // UnderlineDouble is a double underline.
+ UnderlineDouble = ansi.UnderlineDouble
+ // UnderlineCurly is a curly underline.
+ UnderlineCurly = ansi.UnderlineCurly
+ // UnderlineDotted is a dotted underline.
+ UnderlineDotted = ansi.UnderlineDotted
+ // UnderlineDashed is a dashed underline.
+ UnderlineDashed = ansi.UnderlineDashed
+)
+
+// NewStyle returns a new, empty Style. While it's syntactic sugar for the
+// [Style]{} primitive, it's recommended to use this function for creating styles
+// in case the underlying implementation changes.
+func NewStyle() Style {
+ return Style{}
+}
+
+// Style contains a set of rules that comprise a style as a whole.
+type Style struct {
+ props props
+ value string
+
+ // hyperlink
+ link, linkParams string
+
+ // we store bool props values here
+ attrs int
+
+ // props that have values
+ fgColor color.Color
+ bgColor color.Color
+ ulColor color.Color
+
+ ul Underline
+
+ width int
+ height int
+
+ alignHorizontal Position
+ alignVertical Position
+
+ paddingTop int
+ paddingRight int
+ paddingBottom int
+ paddingLeft int
+ paddingChar rune
+
+ marginTop int
+ marginRight int
+ marginBottom int
+ marginLeft int
+ marginBgColor color.Color
+ marginChar rune
+
+ borderStyle Border
+ borderTopFgColor color.Color
+ borderRightFgColor color.Color
+ borderBottomFgColor color.Color
+ borderLeftFgColor color.Color
+ borderBlendFgColor []color.Color
+ borderForegroundBlendOffset int
+ borderTopBgColor color.Color
+ borderRightBgColor color.Color
+ borderBottomBgColor color.Color
+ borderLeftBgColor color.Color
+
+ maxWidth int
+ maxHeight int
+ tabWidth int
+
+ transform func(string) string
+}
+
+// joinString joins a list of strings into a single string separated with a
+// space.
+func joinString(strs ...string) string {
+ return strings.Join(strs, " ")
+}
+
+// SetString sets the underlying string value for this style. To render once
+// the underlying string is set, use the [Style.String]. This method is
+// a convenience for cases when having a stringer implementation is handy, such
+// as when using fmt.Sprintf. You can also simply define a style and render out
+// strings directly with [Style.Render].
+func (s Style) SetString(strs ...string) Style {
+ s.value = joinString(strs...)
+ return s
+}
+
+// Value returns the raw, unformatted, underlying string value for this style.
+func (s Style) Value() string {
+ return s.value
+}
+
+// String implements stringer for a Style, returning the rendered result based
+// on the rules in this style. An underlying string value must be set with
+// Style.SetString prior to using this method.
+func (s Style) String() string {
+ return s.Render()
+}
+
+// Copy returns a copy of this style, including any underlying string values.
+//
+// Deprecated: to copy just use assignment (i.e. a := b). All methods also
+// return a new style.
+func (s Style) Copy() Style {
+ return s
+}
+
+// Inherit overlays the style in the argument onto this style by copying each explicitly
+// set value from the argument style onto this style if it is not already explicitly set.
+// Existing set values are kept intact and not overwritten.
+//
+// Margins, padding, and underlying string values are not inherited.
+func (s Style) Inherit(i Style) Style {
+ for k := boldKey; k <= transformKey; k <<= 1 {
+ if !i.isSet(k) {
+ continue
+ }
+
+ switch k { //nolint:exhaustive
+ case marginTopKey, marginRightKey, marginBottomKey, marginLeftKey:
+ // Margins are not inherited
+ continue
+ case paddingTopKey, paddingRightKey, paddingBottomKey, paddingLeftKey:
+ // Padding is not inherited
+ continue
+ case backgroundKey:
+ // The margins also inherit the background color
+ if !s.isSet(marginBackgroundKey) && !i.isSet(marginBackgroundKey) {
+ s.set(marginBackgroundKey, i.bgColor)
+ }
+ }
+
+ if s.isSet(k) {
+ continue
+ }
+
+ s.setFrom(k, i)
+ }
+ return s
+}
+
+// Render applies the defined style formatting to a given string.
+func (s Style) Render(strs ...string) string {
+ if s.value != "" {
+ strs = append([]string{s.value}, strs...)
+ }
+
+ var (
+ str = joinString(strs...)
+
+ te ansi.Style
+ teSpace ansi.Style
+ teWhitespace ansi.Style
+
+ bold = s.getAsBool(boldKey, false)
+ italic = s.getAsBool(italicKey, false)
+ strikethrough = s.getAsBool(strikethroughKey, false)
+ reverse = s.getAsBool(reverseKey, false)
+ blink = s.getAsBool(blinkKey, false)
+ faint = s.getAsBool(faintKey, false)
+
+ fg = s.getAsColor(foregroundKey)
+ bg = s.getAsColor(backgroundKey)
+ ul = s.getAsColor(underlineColorKey)
+
+ underline = s.ul != UnderlineNone
+ width = s.getAsInt(widthKey)
+ height = s.getAsInt(heightKey)
+ horizontalAlign = s.getAsPosition(alignHorizontalKey)
+ verticalAlign = s.getAsPosition(alignVerticalKey)
+
+ topPadding = s.getAsInt(paddingTopKey)
+ rightPadding = s.getAsInt(paddingRightKey)
+ bottomPadding = s.getAsInt(paddingBottomKey)
+ leftPadding = s.getAsInt(paddingLeftKey)
+
+ horizontalBorderSize = s.GetHorizontalBorderSize()
+ verticalBorderSize = s.GetVerticalBorderSize()
+
+ colorWhitespace = s.getAsBool(colorWhitespaceKey, true)
+ inline = s.getAsBool(inlineKey, false)
+ maxWidth = s.getAsInt(maxWidthKey)
+ maxHeight = s.getAsInt(maxHeightKey)
+
+ underlineSpaces = s.getAsBool(underlineSpacesKey, false) || (underline && s.getAsBool(underlineSpacesKey, true))
+ strikethroughSpaces = s.getAsBool(strikethroughSpacesKey, false) || (strikethrough && s.getAsBool(strikethroughSpacesKey, true))
+
+ // Do we need to style whitespace (padding and space outside
+ // paragraphs) separately?
+ styleWhitespace = reverse
+
+ // Do we need to style spaces separately?
+ useSpaceStyler = (underline && !underlineSpaces) || (strikethrough && !strikethroughSpaces) || underlineSpaces || strikethroughSpaces
+
+ transform = s.getAsTransform(transformKey)
+
+ link, linkParams = s.GetHyperlink()
+ )
+
+ if transform != nil {
+ str = transform(str)
+ }
+
+ if s.props == 0 {
+ return s.maybeConvertTabs(str)
+ }
+
+ if bold {
+ te = te.Bold()
+ }
+ if italic {
+ te = te.Italic(true)
+ }
+ if underline {
+ te = te.Underline(true)
+ }
+ if reverse {
+ teWhitespace = teWhitespace.Reverse(true)
+ te = te.Reverse(true)
+ }
+ if blink {
+ te = te.Blink(true)
+ }
+ if faint {
+ te = te.Faint()
+ }
+
+ if fg != noColor {
+ te = te.ForegroundColor(fg)
+ if styleWhitespace {
+ teWhitespace = teWhitespace.ForegroundColor(fg)
+ }
+ if useSpaceStyler {
+ teSpace = teSpace.ForegroundColor(fg)
+ }
+ }
+
+ if bg != noColor {
+ te = te.BackgroundColor(bg)
+ if colorWhitespace {
+ teWhitespace = teWhitespace.BackgroundColor(bg)
+ }
+ if useSpaceStyler {
+ teSpace = teSpace.BackgroundColor(bg)
+ }
+ }
+
+ if ul != noColor {
+ te = te.UnderlineColor(ul)
+ if colorWhitespace {
+ teWhitespace = teWhitespace.UnderlineColor(ul)
+ }
+ if useSpaceStyler {
+ teSpace = teSpace.UnderlineColor(ul)
+ }
+ }
+
+ if underline {
+ te = te.UnderlineStyle(s.ul)
+ }
+ if strikethrough {
+ te = te.Strikethrough(true)
+ }
+
+ if underlineSpaces {
+ teSpace = teSpace.Underline(true)
+ }
+ if strikethroughSpaces {
+ teSpace = teSpace.Strikethrough(true)
+ }
+
+ // Potentially convert tabs to spaces
+ str = s.maybeConvertTabs(str)
+ // carriage returns can cause strange behaviour when rendering.
+ str = strings.ReplaceAll(str, "\r\n", "\n")
+
+ // Strip newlines in single line mode
+ if inline {
+ str = strings.ReplaceAll(str, "\n", "")
+ }
+
+ // Include borders in block size.
+ width -= horizontalBorderSize
+ height -= verticalBorderSize
+
+ // Word wrap
+ if !inline && width > 0 {
+ wrapAt := width - leftPadding - rightPadding
+ str = Wrap(str, wrapAt, "")
+ }
+
+ // Render core text
+ {
+ var b strings.Builder
+
+ isFirst := true
+ for line := range strings.SplitSeq(str, "\n") {
+ if isFirst {
+ isFirst = false
+ } else {
+ b.WriteRune('\n')
+ }
+ if useSpaceStyler {
+ // Look for spaces and apply a different styler
+ for _, r := range line {
+ if unicode.IsSpace(r) {
+ b.WriteString(teSpace.Styled(string(r)))
+ continue
+ }
+ b.WriteString(te.Styled(string(r)))
+ }
+ } else {
+ b.WriteString(te.Styled(line))
+ }
+ }
+
+ str = b.String()
+
+ if len(link) > 0 {
+ str = ansi.SetHyperlink(link, linkParams) + str + ansi.ResetHyperlink()
+ }
+ }
+
+ // Padding
+ if !inline { //nolint:nestif
+ padChar := s.paddingChar
+ if padChar == 0 {
+ padChar = ' '
+ }
+ if leftPadding > 0 {
+ var st *ansi.Style
+ if colorWhitespace || styleWhitespace {
+ st = &teWhitespace
+ }
+ str = padLeft(str, leftPadding, st, padChar)
+ }
+
+ if rightPadding > 0 {
+ var st *ansi.Style
+ if colorWhitespace || styleWhitespace {
+ st = &teWhitespace
+ }
+ str = padRight(str, rightPadding, st, padChar)
+ }
+
+ if topPadding > 0 {
+ str = strings.Repeat("\n", topPadding) + str
+ }
+
+ if bottomPadding > 0 {
+ str += strings.Repeat("\n", bottomPadding)
+ }
+ }
+
+ // Height
+ if height > 0 {
+ str = alignTextVertical(str, verticalAlign, height, nil)
+ }
+
+ // Set alignment. This will also pad short lines with spaces so that all
+ // lines are the same length, so we run it under a few different conditions
+ // beyond alignment.
+ {
+ numLines := strings.Count(str, "\n")
+
+ if numLines != 0 || width != 0 {
+ var st *ansi.Style
+ if colorWhitespace || styleWhitespace {
+ st = &teWhitespace
+ }
+ str = alignTextHorizontal(str, horizontalAlign, width, st)
+ }
+ }
+
+ if !inline {
+ str = s.applyBorder(str)
+ str = s.applyMargins(str, inline)
+ }
+
+ // Truncate according to MaxWidth
+ if maxWidth > 0 {
+ lines := strings.Split(str, "\n")
+
+ for i := range lines {
+ lines[i] = ansi.Truncate(lines[i], maxWidth, "")
+ }
+
+ str = strings.Join(lines, "\n")
+ }
+
+ // Truncate according to MaxHeight
+ if maxHeight > 0 {
+ lines := strings.Split(str, "\n")
+ height := min(maxHeight, len(lines))
+ if len(lines) > 0 {
+ str = strings.Join(lines[:height], "\n")
+ }
+ }
+
+ return str
+}
+
+func (s Style) maybeConvertTabs(str string) string {
+ tw := tabWidthDefault
+ if s.isSet(tabWidthKey) {
+ tw = s.getAsInt(tabWidthKey)
+ }
+ switch tw {
+ case -1:
+ return str
+ case 0:
+ return strings.ReplaceAll(str, "\t", "")
+ default:
+ return strings.ReplaceAll(str, "\t", strings.Repeat(" ", tw))
+ }
+}
+
+func (s Style) applyMargins(str string, inline bool) string {
+ var (
+ topMargin = s.getAsInt(marginTopKey)
+ rightMargin = s.getAsInt(marginRightKey)
+ bottomMargin = s.getAsInt(marginBottomKey)
+ leftMargin = s.getAsInt(marginLeftKey)
+
+ style ansi.Style
+ )
+
+ bgc := s.getAsColor(marginBackgroundKey)
+ if bgc != noColor {
+ style = style.BackgroundColor(bgc)
+ }
+
+ // Add left and right margin
+ marginChar := s.marginChar
+ if marginChar == 0 {
+ marginChar = ' '
+ }
+ str = padLeft(str, leftMargin, &style, marginChar)
+ str = padRight(str, rightMargin, &style, marginChar)
+
+ // Top/bottom margin
+ if !inline {
+ _, width := getLines(str)
+ spaces := strings.Repeat(" ", width)
+
+ if topMargin > 0 {
+ str = style.Styled(strings.Repeat(spaces+"\n", topMargin)) + str
+ }
+ if bottomMargin > 0 {
+ str += style.Styled(strings.Repeat("\n"+spaces, bottomMargin))
+ }
+ }
+
+ return str
+}
+
+// Apply left padding.
+func padLeft(str string, n int, style *ansi.Style, r rune) string {
+ return pad(str, -n, style, r)
+}
+
+// Apply right padding.
+func padRight(str string, n int, style *ansi.Style, r rune) string {
+ return pad(str, n, style, r)
+}
+
+// pad adds padding to either the left or right side of a string.
+// Positive values add to the right side while negative values
+// add to the left side.
+// r is the rune to use for padding. We use " " for margins and
+// "\u00A0" for padding so that the padding is preserved when the
+// string is copied and pasted.
+func pad(str string, n int, style *ansi.Style, r rune) string {
+ if n == 0 {
+ return str
+ }
+
+ sp := strings.Repeat(string(r), abs(n))
+ if style != nil {
+ sp = style.Styled(sp)
+ }
+
+ b := strings.Builder{}
+ isFirst := true
+ for line := range strings.SplitSeq(str, "\n") {
+ if isFirst {
+ isFirst = false
+ } else {
+ b.WriteRune('\n')
+ }
+ switch {
+ // pad right
+ case n > 0:
+ b.WriteString(line)
+ b.WriteString(sp)
+ // pad left
+ default:
+ b.WriteString(sp)
+ b.WriteString(line)
+ }
+ }
+
+ return b.String()
+}
+
+func abs(a int) int {
+ if a < 0 {
+ return -a
+ }
+
+ return a
+}
diff --git a/vendor/charm.land/lipgloss/v2/terminal.go b/vendor/charm.land/lipgloss/v2/terminal.go
new file mode 100644
index 0000000000..a336abc770
--- /dev/null
+++ b/vendor/charm.land/lipgloss/v2/terminal.go
@@ -0,0 +1,124 @@
+package lipgloss
+
+import (
+ "fmt"
+ "image/color"
+ "io"
+ "strings"
+ "time"
+
+ uv "github.com/charmbracelet/ultraviolet"
+ "github.com/charmbracelet/x/ansi"
+)
+
+// queryBackgroundColor queries the terminal for the background color.
+// If the terminal does not support querying the background color, nil is
+// returned.
+//
+// Note: you will need to set the input to raw mode before calling this
+// function.
+//
+// state, _ := term.MakeRaw(in.Fd())
+// defer term.Restore(in.Fd(), state)
+//
+// copied from x/term@v0.1.3.
+func queryBackgroundColor(in io.Reader, out io.Writer) (c color.Color, err error) {
+ err = queryTerminal(in, out, defaultQueryTimeout,
+ func(seq string, pa *ansi.Parser) bool {
+ switch {
+ case ansi.HasOscPrefix(seq):
+ switch pa.Command() {
+ case 11: // OSC 11
+ parts := strings.Split(string(pa.Data()), ";")
+ if len(parts) != 2 {
+ break // invalid, but we still need to parse the next sequence
+ }
+ c = ansi.XParseColor(parts[1])
+ }
+ case ansi.HasCsiPrefix(seq):
+ switch pa.Command() {
+ case ansi.Command('?', 0, 'c'): // DA1
+ return false
+ }
+ }
+ return true
+ }, ansi.RequestBackgroundColor+ansi.RequestPrimaryDeviceAttributes)
+ return
+}
+
+const defaultQueryTimeout = time.Second * 2
+
+// queryTerminalFilter is a function that filters input events using a type
+// switch. If false is returned, the QueryTerminal function will stop reading
+// input.
+type queryTerminalFilter func(seq string, pa *ansi.Parser) bool
+
+// queryTerminal queries the terminal for support of various features and
+// returns a list of response events.
+// Most of the time, you will need to set stdin to raw mode before calling this
+// function.
+// Note: This function will block until the terminal responds or the timeout
+// is reached.
+// copied from x/term@v0.1.3.
+func queryTerminal(
+ in io.Reader,
+ out io.Writer,
+ timeout time.Duration,
+ filter queryTerminalFilter,
+ query string,
+) error {
+ // We use [uv.NewCancelReader] because it uses a different Windows
+ // implementation than the on in the [cancelreader] library, which uses
+ // the Cancel IO API to cancel reads instead of using Overlapped IO.
+ rd, err := uv.NewCancelReader(in)
+ if err != nil {
+ return fmt.Errorf("could not create cancel reader: %w", err)
+ }
+
+ defer rd.Close() //nolint: errcheck
+
+ done := make(chan struct{}, 1)
+ defer close(done)
+ go func() {
+ select {
+ case <-done:
+ case <-time.After(timeout):
+ rd.Cancel()
+ }
+ }()
+
+ if _, err := io.WriteString(out, query); err != nil {
+ return fmt.Errorf("could not write query: %w", err)
+ }
+
+ pa := ansi.GetParser()
+ defer ansi.PutParser(pa)
+
+ var acc []byte // Accumulate partial responses before filtering
+ var buf [256]byte // 256 bytes should be enough for most responses
+ var state byte
+ for {
+ n, err := rd.Read(buf[:])
+ if err != nil {
+ return fmt.Errorf("could not read from input: %w", err)
+ }
+
+ p := buf[:]
+ for n > 0 {
+ seq, _, read, newState := ansi.DecodeSequence(p[:n], state, pa)
+ acc = append(acc, seq...)
+
+ if newState == ansi.NormalState {
+ if !filter(string(acc), pa) {
+ return nil
+ }
+
+ acc = acc[:0]
+ }
+
+ state = newState
+ n -= read
+ p = p[read:]
+ }
+ }
+}
diff --git a/vendor/charm.land/lipgloss/v2/unset.go b/vendor/charm.land/lipgloss/v2/unset.go
new file mode 100644
index 0000000000..b81ee882a0
--- /dev/null
+++ b/vendor/charm.land/lipgloss/v2/unset.go
@@ -0,0 +1,359 @@
+package lipgloss
+
+// unset unsets a property from a style.
+func (s *Style) unset(key propKey) {
+ s.props = s.props.unset(key)
+}
+
+// UnsetBold removes the bold style rule, if set.
+func (s Style) UnsetBold() Style {
+ s.unset(boldKey)
+ return s
+}
+
+// UnsetItalic removes the italic style rule, if set.
+func (s Style) UnsetItalic() Style {
+ s.unset(italicKey)
+ return s
+}
+
+// UnsetUnderline removes the underline style rule, if set.
+func (s Style) UnsetUnderline() Style {
+ return s.Underline(false)
+}
+
+// UnsetStrikethrough removes the strikethrough style rule, if set.
+func (s Style) UnsetStrikethrough() Style {
+ s.unset(strikethroughKey)
+ return s
+}
+
+// UnsetReverse removes the reverse style rule, if set.
+func (s Style) UnsetReverse() Style {
+ s.unset(reverseKey)
+ return s
+}
+
+// UnsetBlink removes the blink style rule, if set.
+func (s Style) UnsetBlink() Style {
+ s.unset(blinkKey)
+ return s
+}
+
+// UnsetFaint removes the faint style rule, if set.
+func (s Style) UnsetFaint() Style {
+ s.unset(faintKey)
+ return s
+}
+
+// UnsetForeground removes the foreground style rule, if set.
+func (s Style) UnsetForeground() Style {
+ s.unset(foregroundKey)
+ return s
+}
+
+// UnsetBackground removes the background style rule, if set.
+func (s Style) UnsetBackground() Style {
+ s.unset(backgroundKey)
+ return s
+}
+
+// UnsetWidth removes the width style rule, if set.
+func (s Style) UnsetWidth() Style {
+ s.unset(widthKey)
+ return s
+}
+
+// UnsetHeight removes the height style rule, if set.
+func (s Style) UnsetHeight() Style {
+ s.unset(heightKey)
+ return s
+}
+
+// UnsetAlign removes the horizontal and vertical text alignment style rule, if set.
+func (s Style) UnsetAlign() Style {
+ s.unset(alignHorizontalKey)
+ s.unset(alignVerticalKey)
+ return s
+}
+
+// UnsetAlignHorizontal removes the horizontal text alignment style rule, if set.
+func (s Style) UnsetAlignHorizontal() Style {
+ s.unset(alignHorizontalKey)
+ return s
+}
+
+// UnsetAlignVertical removes the vertical text alignment style rule, if set.
+func (s Style) UnsetAlignVertical() Style {
+ s.unset(alignVerticalKey)
+ return s
+}
+
+// UnsetPadding removes all padding style rules.
+func (s Style) UnsetPadding() Style {
+ s.unset(paddingLeftKey)
+ s.unset(paddingRightKey)
+ s.unset(paddingTopKey)
+ s.unset(paddingBottomKey)
+ s.unset(paddingCharKey)
+ return s
+}
+
+// UnsetPaddingChar removes the padding character style rule, if set.
+func (s Style) UnsetPaddingChar() Style {
+ s.unset(paddingCharKey)
+ return s
+}
+
+// UnsetPaddingLeft removes the left padding style rule, if set.
+func (s Style) UnsetPaddingLeft() Style {
+ s.unset(paddingLeftKey)
+ return s
+}
+
+// UnsetPaddingRight removes the right padding style rule, if set.
+func (s Style) UnsetPaddingRight() Style {
+ s.unset(paddingRightKey)
+ return s
+}
+
+// UnsetPaddingTop removes the top padding style rule, if set.
+func (s Style) UnsetPaddingTop() Style {
+ s.unset(paddingTopKey)
+ return s
+}
+
+// UnsetPaddingBottom removes the bottom padding style rule, if set.
+func (s Style) UnsetPaddingBottom() Style {
+ s.unset(paddingBottomKey)
+ return s
+}
+
+// UnsetColorWhitespace removes the rule for coloring padding, if set.
+func (s Style) UnsetColorWhitespace() Style {
+ s.unset(colorWhitespaceKey)
+ return s
+}
+
+// UnsetMargins removes all margin style rules.
+func (s Style) UnsetMargins() Style {
+ s.unset(marginLeftKey)
+ s.unset(marginRightKey)
+ s.unset(marginTopKey)
+ s.unset(marginBottomKey)
+ return s
+}
+
+// UnsetMarginLeft removes the left margin style rule, if set.
+func (s Style) UnsetMarginLeft() Style {
+ s.unset(marginLeftKey)
+ return s
+}
+
+// UnsetMarginRight removes the right margin style rule, if set.
+func (s Style) UnsetMarginRight() Style {
+ s.unset(marginRightKey)
+ return s
+}
+
+// UnsetMarginTop removes the top margin style rule, if set.
+func (s Style) UnsetMarginTop() Style {
+ s.unset(marginTopKey)
+ return s
+}
+
+// UnsetMarginBottom removes the bottom margin style rule, if set.
+func (s Style) UnsetMarginBottom() Style {
+ s.unset(marginBottomKey)
+ return s
+}
+
+// UnsetMarginBackground removes the margin's background color. Note that the
+// margin's background color can be set from the background color of another
+// style during inheritance.
+func (s Style) UnsetMarginBackground() Style {
+ s.unset(marginBackgroundKey)
+ return s
+}
+
+// UnsetBorderStyle removes the border style rule, if set.
+func (s Style) UnsetBorderStyle() Style {
+ s.unset(borderStyleKey)
+ return s
+}
+
+// UnsetBorderTop removes the border top style rule, if set.
+func (s Style) UnsetBorderTop() Style {
+ s.unset(borderTopKey)
+ return s
+}
+
+// UnsetBorderRight removes the border right style rule, if set.
+func (s Style) UnsetBorderRight() Style {
+ s.unset(borderRightKey)
+ return s
+}
+
+// UnsetBorderBottom removes the border bottom style rule, if set.
+func (s Style) UnsetBorderBottom() Style {
+ s.unset(borderBottomKey)
+ return s
+}
+
+// UnsetBorderLeft removes the border left style rule, if set.
+func (s Style) UnsetBorderLeft() Style {
+ s.unset(borderLeftKey)
+ return s
+}
+
+// UnsetBorderForeground removes all border foreground color styles, if set.
+func (s Style) UnsetBorderForeground() Style {
+ s.unset(borderTopForegroundKey)
+ s.unset(borderRightForegroundKey)
+ s.unset(borderBottomForegroundKey)
+ s.unset(borderLeftForegroundKey)
+ return s
+}
+
+// UnsetBorderTopForeground removes the top border foreground color rule,
+// if set.
+func (s Style) UnsetBorderTopForeground() Style {
+ s.unset(borderTopForegroundKey)
+ return s
+}
+
+// UnsetBorderRightForeground removes the right border foreground color rule,
+// if set.
+func (s Style) UnsetBorderRightForeground() Style {
+ s.unset(borderRightForegroundKey)
+ return s
+}
+
+// UnsetBorderBottomForeground removes the bottom border foreground color
+// rule, if set.
+func (s Style) UnsetBorderBottomForeground() Style {
+ s.unset(borderBottomForegroundKey)
+ return s
+}
+
+// UnsetBorderLeftForeground removes the left border foreground color rule,
+// if set.
+func (s Style) UnsetBorderLeftForeground() Style {
+ s.unset(borderLeftForegroundKey)
+ return s
+}
+
+// UnsetBorderForegroundBlend removes the border blend foreground color rules,
+// if set.
+func (s Style) UnsetBorderForegroundBlend() Style {
+ s.unset(borderForegroundBlendKey)
+ return s
+}
+
+// UnsetBorderForegroundBlendOffset removes the border blend offset style rule,
+// if set.
+func (s Style) UnsetBorderForegroundBlendOffset() Style {
+ s.unset(borderForegroundBlendOffsetKey)
+ return s
+}
+
+// UnsetBorderBackground removes all border background color styles, if
+// set.
+func (s Style) UnsetBorderBackground() Style {
+ s.unset(borderTopBackgroundKey)
+ s.unset(borderRightBackgroundKey)
+ s.unset(borderBottomBackgroundKey)
+ s.unset(borderLeftBackgroundKey)
+ return s
+}
+
+// UnsetBorderTopBackgroundColor removes the top border background color rule,
+// if set.
+//
+// Deprecated: This function simply calls Style.UnsetBorderTopBackground.
+func (s Style) UnsetBorderTopBackgroundColor() Style {
+ return s.UnsetBorderTopBackground()
+}
+
+// UnsetBorderTopBackground removes the top border background color rule,
+// if set.
+func (s Style) UnsetBorderTopBackground() Style {
+ s.unset(borderTopBackgroundKey)
+ return s
+}
+
+// UnsetBorderRightBackground removes the right border background color
+// rule, if set.
+func (s Style) UnsetBorderRightBackground() Style {
+ s.unset(borderRightBackgroundKey)
+ return s
+}
+
+// UnsetBorderBottomBackground removes the bottom border background color
+// rule, if set.
+func (s Style) UnsetBorderBottomBackground() Style {
+ s.unset(borderBottomBackgroundKey)
+ return s
+}
+
+// UnsetBorderLeftBackground removes the left border color rule, if set.
+func (s Style) UnsetBorderLeftBackground() Style {
+ s.unset(borderLeftBackgroundKey)
+ return s
+}
+
+// UnsetInline removes the inline style rule, if set.
+func (s Style) UnsetInline() Style {
+ s.unset(inlineKey)
+ return s
+}
+
+// UnsetMaxWidth removes the max width style rule, if set.
+func (s Style) UnsetMaxWidth() Style {
+ s.unset(maxWidthKey)
+ return s
+}
+
+// UnsetMaxHeight removes the max height style rule, if set.
+func (s Style) UnsetMaxHeight() Style {
+ s.unset(maxHeightKey)
+ return s
+}
+
+// UnsetTabWidth removes the tab width style rule, if set.
+func (s Style) UnsetTabWidth() Style {
+ s.unset(tabWidthKey)
+ return s
+}
+
+// UnsetUnderlineSpaces removes the value set by UnderlineSpaces.
+func (s Style) UnsetUnderlineSpaces() Style {
+ s.unset(underlineSpacesKey)
+ return s
+}
+
+// UnsetStrikethroughSpaces removes the value set by StrikethroughSpaces.
+func (s Style) UnsetStrikethroughSpaces() Style {
+ s.unset(strikethroughSpacesKey)
+ return s
+}
+
+// UnsetTransform removes the value set by Transform.
+func (s Style) UnsetTransform() Style {
+ s.unset(transformKey)
+ return s
+}
+
+// UnsetHyperlink removes the value set by Hyperlink.
+func (s Style) UnsetHyperlink() Style {
+ s.unset(linkKey)
+ s.unset(linkParamsKey)
+ s.link, s.linkParams = "", "" // save memory
+ return s
+}
+
+// UnsetString sets the underlying string value to the empty string.
+func (s Style) UnsetString() Style {
+ s.value = ""
+ return s
+}
diff --git a/vendor/charm.land/lipgloss/v2/whitespace.go b/vendor/charm.land/lipgloss/v2/whitespace.go
new file mode 100644
index 0000000000..e353a076ba
--- /dev/null
+++ b/vendor/charm.land/lipgloss/v2/whitespace.go
@@ -0,0 +1,76 @@
+package lipgloss
+
+import (
+ "strings"
+
+ "github.com/charmbracelet/x/ansi"
+)
+
+// whitespace is a whitespace renderer.
+type whitespace struct {
+ chars string
+ style Style
+}
+
+// newWhitespace creates a new whitespace renderer.
+func newWhitespace(opts ...WhitespaceOption) *whitespace {
+ w := &whitespace{}
+ for _, opt := range opts {
+ opt(w)
+ }
+ return w
+}
+
+// Render whitespaces.
+func (w whitespace) render(width int) string {
+ if w.chars == "" {
+ w.chars = " "
+ }
+
+ r := []rune(w.chars)
+ j := 0
+ b := strings.Builder{}
+
+ // Cycle through runes and print them into the whitespace.
+ for i := 0; i < width; {
+ b.WriteRune(r[j])
+ // Measure the width of the rune we just wrote, ensuring we always
+ // make progress to avoid infinite loops with zero-width characters
+ // like tabs.
+ runeWidth := ansi.StringWidth(string(r[j]))
+ if runeWidth < 1 {
+ runeWidth = 1
+ }
+ i += runeWidth
+ j++
+ if j >= len(r) {
+ j = 0
+ }
+ }
+
+ // Fill any extra gaps white spaces. This might be necessary if any runes
+ // are more than one cell wide, which could leave a one-rune gap.
+ short := width - ansi.StringWidth(b.String())
+ if short > 0 {
+ b.WriteString(strings.Repeat(" ", short))
+ }
+
+ return w.style.Render(b.String())
+}
+
+// WhitespaceOption sets a styling rule for rendering whitespace.
+type WhitespaceOption func(*whitespace)
+
+// WithWhitespaceStyle sets the style for the whitespace.
+func WithWhitespaceStyle(s Style) WhitespaceOption {
+ return func(w *whitespace) {
+ w.style = s
+ }
+}
+
+// WithWhitespaceChars sets the characters to be rendered in the whitespace.
+func WithWhitespaceChars(s string) WhitespaceOption {
+ return func(w *whitespace) {
+ w.chars = s
+ }
+}
diff --git a/vendor/charm.land/lipgloss/v2/wrap.go b/vendor/charm.land/lipgloss/v2/wrap.go
new file mode 100644
index 0000000000..ccffe89b18
--- /dev/null
+++ b/vendor/charm.land/lipgloss/v2/wrap.go
@@ -0,0 +1,113 @@
+package lipgloss
+
+import (
+ "bytes"
+ "io"
+
+ uv "github.com/charmbracelet/ultraviolet"
+ "github.com/charmbracelet/x/ansi"
+)
+
+// Wrap wraps the given string to the given width, preserving ANSI styles and links.
+func Wrap(s string, width int, breakpoints string) string {
+ var buf bytes.Buffer
+ s = ansi.Wrap(s, width, breakpoints)
+ w := NewWrapWriter(&buf)
+ defer w.Close() //nolint:errcheck
+ _, _ = io.WriteString(w, s)
+ return buf.String()
+}
+
+// WrapWriter is a writer that writes to a buffer and keeps track of the
+// current pen style and link state for the purpose of wrapping with newlines.
+//
+// When it encounters a newline, it resets the style and link, writes the
+// newline, and then reapplies the style and link to the next line.
+type WrapWriter struct {
+ w io.Writer
+ p *ansi.Parser
+ style uv.Style
+ link uv.Link
+}
+
+// NewWrapWriter returns a new [WrapWriter].
+func NewWrapWriter(w io.Writer) *WrapWriter {
+ pw := &WrapWriter{w: w}
+ pw.p = ansi.GetParser()
+ handleCsi := func(cmd ansi.Cmd, params ansi.Params) {
+ if cmd == 'm' {
+ uv.ReadStyle(params, &pw.style)
+ }
+ }
+ handleOsc := func(cmd int, data []byte) {
+ if cmd == 8 {
+ uv.ReadLink(data, &pw.link)
+ }
+ }
+ pw.p.SetHandler(ansi.Handler{
+ HandleCsi: handleCsi,
+ HandleOsc: handleOsc,
+ })
+ return pw
+}
+
+// Style returns the current pen style.
+func (w *WrapWriter) Style() uv.Style {
+ return w.style
+}
+
+// Link returns the current pen link.
+func (w *WrapWriter) Link() uv.Link {
+ return w.link
+}
+
+// Write writes to the buffer.
+func (w *WrapWriter) Write(p []byte) (int, error) {
+ if w.p == nil {
+ // The writer has been closed and its parser returned to the pool.
+ // Writing after close can happen during out-of-order teardown of
+ // nested writer chains; treat it as a no-op rather than panicking.
+ return len(p), nil
+ }
+ for i := range p {
+ b := p[i]
+ w.p.Advance(b)
+ if b == '\n' {
+ if !w.style.IsZero() {
+ _, _ = w.w.Write([]byte(ansi.ResetStyle))
+ }
+ if !w.link.IsZero() {
+ _, _ = w.w.Write([]byte(ansi.ResetHyperlink()))
+ }
+ }
+
+ _, _ = w.w.Write([]byte{b})
+ if b == '\n' {
+ if !w.link.IsZero() {
+ _, _ = w.w.Write([]byte(ansi.SetHyperlink(w.link.URL, w.link.Params)))
+ }
+ if !w.style.IsZero() {
+ _, _ = w.w.Write([]byte(w.style.String()))
+ }
+ }
+ }
+
+ return len(p), nil
+}
+
+// Close closes the writer, resets the style and link if necessary, and releases
+// its parser. Calling it is performance critical, but forgetting it does not
+// cause safety issues or leaks.
+func (w *WrapWriter) Close() error {
+ if !w.style.IsZero() {
+ _, _ = w.w.Write([]byte(ansi.ResetStyle))
+ }
+ if !w.link.IsZero() {
+ _, _ = w.w.Write([]byte(ansi.ResetHyperlink()))
+ }
+ if w.p != nil {
+ ansi.PutParser(w.p)
+ w.p = nil
+ }
+ return nil
+}
diff --git a/vendor/charm.land/lipgloss/v2/writer.go b/vendor/charm.land/lipgloss/v2/writer.go
new file mode 100644
index 0000000000..78b48b8d3e
--- /dev/null
+++ b/vendor/charm.land/lipgloss/v2/writer.go
@@ -0,0 +1,160 @@
+package lipgloss
+
+import (
+ "bytes"
+ "fmt"
+ "io"
+ "os"
+
+ "github.com/charmbracelet/colorprofile"
+)
+
+// Writer is the default writer that prints to stdout, automatically
+// downsampling colors when necessary.
+var Writer = colorprofile.NewWriter(os.Stdout, os.Environ())
+
+// Println to stdout, automatically downsampling colors when necessary, ending
+// with a trailing newline.
+//
+// Example:
+//
+// str := NewStyle().
+// Foreground(lipgloss.Color("#6a00ff")).
+// Render("breakfast")
+//
+// Println("Time for a", str, "sandwich!")
+func Println(v ...any) (int, error) {
+ return fmt.Fprintln(Writer, v...) //nolint:wrapcheck
+}
+
+// Printf prints formatted text to stdout, automatically downsampling colors
+// when necessary.
+//
+// Example:
+//
+// str := NewStyle().
+// Foreground(lipgloss.Color("#6a00ff")).
+// Render("knuckle")
+//
+// Printf("Time for a %s sandwich!\n", str)
+func Printf(format string, v ...any) (int, error) {
+ return fmt.Fprintf(Writer, format, v...) //nolint:wrapcheck
+}
+
+// Print to stdout, automatically downsampling colors when necessary.
+//
+// Example:
+//
+// str := NewStyle().
+// Foreground(lipgloss.Color("#6a00ff")).
+// Render("Who wants marmalade?\n")
+//
+// Print(str)
+func Print(v ...any) (int, error) {
+ return fmt.Fprint(Writer, v...) //nolint:wrapcheck
+}
+
+// Fprint pritnts to the given writer, automatically downsampling colors when
+// necessary.
+//
+// Example:
+//
+// str := NewStyle().
+// Foreground(lipgloss.Color("#6a00ff")).
+// Render("guzzle")
+//
+// Fprint(os.Stderr, "I %s horchata pretty much all the time.\n", str)
+func Fprint(w io.Writer, v ...any) (int, error) {
+ return fmt.Fprint(colorprofile.NewWriter(w, os.Environ()), v...) //nolint:wrapcheck
+}
+
+// Fprintln prints to the given writer, automatically downsampling colors when
+// necessary, and ending with a trailing newline.
+//
+// Example:
+//
+// str := NewStyle().
+// Foreground(lipgloss.Color("#6a00ff")).
+// Render("Sandwich time!")
+//
+// Fprintln(os.Stderr, str)
+func Fprintln(w io.Writer, v ...any) (int, error) {
+ return fmt.Fprintln(colorprofile.NewWriter(w, os.Environ()), v...) //nolint:wrapcheck
+}
+
+// Fprintf prints text to a writer, against the given format, automatically
+// downsampling colors when necessary.
+//
+// Example:
+//
+// str := NewStyle().
+// Foreground(lipgloss.Color("#6a00ff")).
+// Render("artichokes")
+//
+// Fprintf(os.Stderr, "I really love %s!\n", food)
+func Fprintf(w io.Writer, format string, v ...any) (int, error) {
+ return fmt.Fprintf(colorprofile.NewWriter(w, os.Environ()), format, v...) //nolint:wrapcheck
+}
+
+// Sprint returns a string for stdout, automatically downsampling colors when
+// necessary.
+//
+// Example:
+//
+// str := NewStyle().
+// Faint(true).
+// Foreground(lipgloss.Color("#6a00ff")).
+// Render("I love to eat")
+//
+// str = Sprint(str)
+func Sprint(v ...any) string {
+ var buf bytes.Buffer
+ w := colorprofile.Writer{
+ Forward: &buf,
+ Profile: Writer.Profile,
+ }
+ fmt.Fprint(&w, v...) //nolint:errcheck
+ return buf.String()
+}
+
+// Sprintln returns a string for stdout, automatically downsampling colors when
+// necessary, and ending with a trailing newline.
+//
+// Example:
+//
+// str := NewStyle().
+// Bold(true).
+// Foreground(lipgloss.Color("#6a00ff")).
+// Render("Yummy!")
+//
+// str = Sprintln(str)
+func Sprintln(v ...any) string {
+ var buf bytes.Buffer
+ w := colorprofile.Writer{
+ Forward: &buf,
+ Profile: Writer.Profile,
+ }
+ fmt.Fprintln(&w, v...) //nolint:errcheck
+ return buf.String()
+}
+
+// Sprintf returns a formatted string for stdout, automatically downsampling
+// colors when necessary.
+//
+// Example:
+//
+// str := NewStyle().
+// Bold(true).
+// Foreground(lipgloss.Color("#fccaee")).
+// Render("Cantaloupe")
+//
+// str = Sprintf("I really love %s!", str)
+func Sprintf(format string, v ...any) string {
+ var buf bytes.Buffer
+ w := colorprofile.Writer{
+ Forward: &buf,
+ Profile: Writer.Profile,
+ }
+ fmt.Fprintf(&w, format, v...) //nolint:errcheck
+ return buf.String()
+}
diff --git a/vendor/github.com/chavacava/garif/.gitignore b/vendor/codeberg.org/chavacava/garif/.gitignore
similarity index 100%
rename from vendor/github.com/chavacava/garif/.gitignore
rename to vendor/codeberg.org/chavacava/garif/.gitignore
diff --git a/vendor/github.com/chavacava/garif/LICENSE b/vendor/codeberg.org/chavacava/garif/LICENSE
similarity index 100%
rename from vendor/github.com/chavacava/garif/LICENSE
rename to vendor/codeberg.org/chavacava/garif/LICENSE
diff --git a/vendor/codeberg.org/chavacava/garif/README.md b/vendor/codeberg.org/chavacava/garif/README.md
new file mode 100644
index 0000000000..c1cc80d3bf
--- /dev/null
+++ b/vendor/codeberg.org/chavacava/garif/README.md
@@ -0,0 +1,52 @@
+# garif
+
+A Go package to create and manipulate SARIF logs.
+
+SARIF, from _Static Analysis Results Interchange Format_, is a standard JSON-based format for the output of static analysis tools defined and promoted by [OASIS](https://www.oasis-open.org/).
+
+Current supported version of the standard is [SARIF-v2.1.0](https://docs.oasis-open.org/sarif/sarif/v2.1.0/csprd01/sarif-v2.1.0-csprd01.html
+).
+
+## Usage
+
+The package provides access to every element of the SARIF model, therefore you are free to manipulate it at every detail.
+
+The package also provides constructors functions (`New...`) and decorators methods (`With...`) that simplify the creation of SARIF files for common use cases.
+
+Using these constructors and decorators we can easily create the example SARIF file of the [Microsoft SARIF pages](https://github.com/microsoft/sarif-tutorials/blob/master/docs/1-Introduction.md)
+
+
+```go
+import to `github.com/chavacava/garif`
+
+// ...
+
+rule := garif.NewRule("no-unused-vars").
+ WithHelpUri("https://eslint.org/docs/rules/no-unused-vars").
+ WithShortDescription("disallow unused variables").
+ WithProperties("category", "Variables")
+
+driver := garif.NewDriver("ESLint").
+ WithInformationUri("https://eslint.org").
+ WithRules(rule)
+
+run := garif.NewRun(NewTool(driver)).
+ WithArtifactsURIs("file:///C:/dev/sarif/sarif-tutorials/samples/Introduction/simple-example.js")
+
+run.WithResult(rule.Id, "'x' is assigned a value but never used.", "file:///C:/dev/sarif/sarif-tutorials/samples/Introduction/simple-example.js", 1, 5)
+
+logFile := garif.NewLogFile([]*Run{run}, Version210)
+
+logFile.Write(os.Stdout)
+```
+
+## Why this package?
+This package was initiated during my works on adding to [`revive`](https://github.com/mgechev/revive) a SARIF output formatter.
+I've tried to use [go-sarif](https://github.com/owenrumney/go-sarif) by [Owen Rumney](https://github.com/owenrumney) but it is too focused in the use case of the static analyzer [tfsec](https://tfsec.dev) so I've decided to create a package flexible enough to generate SARIF files in broader cases.
+
+## More information about SARIF
+For more information about SARIF, you can visit the [Oasis Open](https://www.oasis-open.org/committees/tc_home.php?wg_abbrev=sarif) site.
+
+
+## Contributing
+Of course, contributions are welcome!
\ No newline at end of file
diff --git a/vendor/github.com/chavacava/garif/constructors.go b/vendor/codeberg.org/chavacava/garif/constructors.go
similarity index 100%
rename from vendor/github.com/chavacava/garif/constructors.go
rename to vendor/codeberg.org/chavacava/garif/constructors.go
diff --git a/vendor/github.com/chavacava/garif/decorators.go b/vendor/codeberg.org/chavacava/garif/decorators.go
similarity index 100%
rename from vendor/github.com/chavacava/garif/decorators.go
rename to vendor/codeberg.org/chavacava/garif/decorators.go
diff --git a/vendor/codeberg.org/chavacava/garif/doc.go b/vendor/codeberg.org/chavacava/garif/doc.go
new file mode 100644
index 0000000000..5ac5a156ab
--- /dev/null
+++ b/vendor/codeberg.org/chavacava/garif/doc.go
@@ -0,0 +1,11 @@
+// Package garif defines all the Go structures required to model a SARIF log file.
+// These structures were created using the JSON-schema sarif-schema-2.1.0.json of SARIF logfiles
+// available at https://github.com/oasis-tcs/sarif-spec/tree/master/Schemata.
+//
+// The package provides constructors for all structures (see constructors.go) These constructors
+// ensure that the returned structure instantiation is valid with respect to the JSON schema and
+// should be used in place of plain structure instantiation.
+// The root structure is LogFile.
+//
+// The package provides utility decorators for the most commonly used structures (see decorators.go)
+package garif
diff --git a/vendor/github.com/chavacava/garif/enums.go b/vendor/codeberg.org/chavacava/garif/enums.go
similarity index 100%
rename from vendor/github.com/chavacava/garif/enums.go
rename to vendor/codeberg.org/chavacava/garif/enums.go
diff --git a/vendor/github.com/chavacava/garif/io.go b/vendor/codeberg.org/chavacava/garif/io.go
similarity index 100%
rename from vendor/github.com/chavacava/garif/io.go
rename to vendor/codeberg.org/chavacava/garif/io.go
diff --git a/vendor/github.com/chavacava/garif/models.go b/vendor/codeberg.org/chavacava/garif/models.go
similarity index 98%
rename from vendor/github.com/chavacava/garif/models.go
rename to vendor/codeberg.org/chavacava/garif/models.go
index f16a86136e..ed18b04a59 100644
--- a/vendor/github.com/chavacava/garif/models.go
+++ b/vendor/codeberg.org/chavacava/garif/models.go
@@ -273,7 +273,7 @@ type ExternalProperties struct {
// An array of graph objects that will be merged with a separate run.
Graphs []*Graph `json:"graphs,omitempty"`
- // A stable, unique identifer for this external properties object, in the form of a GUID.
+ // A stable, unique identifier for this external properties object, in the form of a GUID.
Guid string `json:"guid,omitempty"`
// Describes the invocation of the analysis tool that will be merged with a separate run.
@@ -291,7 +291,7 @@ type ExternalProperties struct {
// An array of result objects that will be merged with a separate run.
Results []*Result `json:"results,omitempty"`
- // A stable, unique identifer for the run associated with this external properties object, in the form of a GUID.
+ // A stable, unique identifier for the run associated with this external properties object, in the form of a GUID.
RunGuid string `json:"runGuid,omitempty"`
// The URI of the JSON schema corresponding to the version of the external property file format.
@@ -319,7 +319,7 @@ type ExternalProperties struct {
// ExternalPropertyFileReference Contains information that enables a SARIF consumer to locate the external property file that contains the value of an externalized property associated with the run.
type ExternalPropertyFileReference struct {
- // A stable, unique identifer for the external property file in the form of a GUID.
+ // A stable, unique identifier for the external property file in the form of a GUID.
Guid string `json:"guid,omitempty"`
// A non-negative integer specifying the number of items contained in the external property file.
@@ -835,7 +835,7 @@ type ReportingDescriptor struct {
// A description of the report. Should, as far as possible, provide details sufficient to enable resolution of any problem indicated by the result.
FullDescription *MultiformatMessageString `json:"fullDescription,omitempty"`
- // A unique identifer for the reporting descriptor in the form of a GUID.
+ // A unique identifier for the reporting descriptor in the form of a GUID.
Guid string `json:"guid,omitempty"`
// Provides the primary documentation for the report, useful when there is no online documentation.
@@ -928,7 +928,7 @@ type Result struct {
// An array of zero or more unique graph objects associated with the result.
Graphs []*Graph `json:"graphs,omitempty"`
- // A stable, unique identifer for the result in the form of a GUID.
+ // A stable, unique identifier for the result in the form of a GUID.
Guid string `json:"guid,omitempty"`
// An absolute URI at which the result can be viewed.
@@ -1114,7 +1114,7 @@ type RunAutomationDetails struct {
// A description of the identity and role played within the engineering system by this object's containing run object.
Description *Message `json:"description,omitempty"`
- // A stable, unique identifer for this object's containing run object in the form of a GUID.
+ // A stable, unique identifier for this object's containing run object in the form of a GUID.
Guid string `json:"guid,omitempty"`
// A hierarchical string that uniquely identifies this object's containing run object.
@@ -1169,7 +1169,7 @@ type StackFrame struct {
// Suppression A suppression that is relevant to a result.
type Suppression struct {
- // A stable, unique identifer for the supression in the form of a GUID.
+ // A stable, unique identifier for the suppression in the form of a GUID.
Guid string `json:"guid,omitempty"`
// A string representing the justification for the suppression.
@@ -1293,7 +1293,7 @@ type ToolComponent struct {
// A dictionary, each of whose keys is a resource identifier and each of whose values is a multiformatMessageString object, which holds message strings in plain text and (optionally) Markdown format. The strings can include placeholders, which can be used to construct a message in combination with an arbitrary number of additional string arguments.
GlobalMessageStrings map[string]*MultiformatMessageString `json:"globalMessageStrings,omitempty"`
- // A unique identifer for the tool component in the form of a GUID.
+ // A unique identifier for the tool component in the form of a GUID.
Guid string `json:"guid,omitempty"`
// The absolute URI at which information about this version of the tool component can be found.
diff --git a/vendor/github.com/polyfloyd/go-errorlint/LICENSE b/vendor/codeberg.org/polyfloyd/go-errorlint/LICENSE
similarity index 100%
rename from vendor/github.com/polyfloyd/go-errorlint/LICENSE
rename to vendor/codeberg.org/polyfloyd/go-errorlint/LICENSE
diff --git a/vendor/github.com/polyfloyd/go-errorlint/errorlint/allowed.go b/vendor/codeberg.org/polyfloyd/go-errorlint/errorlint/allowed.go
similarity index 100%
rename from vendor/github.com/polyfloyd/go-errorlint/errorlint/allowed.go
rename to vendor/codeberg.org/polyfloyd/go-errorlint/errorlint/allowed.go
diff --git a/vendor/codeberg.org/polyfloyd/go-errorlint/errorlint/analysis.go b/vendor/codeberg.org/polyfloyd/go-errorlint/errorlint/analysis.go
new file mode 100644
index 0000000000..a26067bbf7
--- /dev/null
+++ b/vendor/codeberg.org/polyfloyd/go-errorlint/errorlint/analysis.go
@@ -0,0 +1,116 @@
+package errorlint
+
+import (
+ "go/ast"
+ "go/types"
+ "sort"
+
+ "golang.org/x/tools/go/analysis"
+)
+
+func NewAnalyzer(opts ...Option) *analysis.Analyzer {
+ for _, o := range opts {
+ o()
+ }
+
+ setDefaultAllowedErrors()
+
+ a := &analysis.Analyzer{
+ Name: "errorlint",
+ Doc: "Linter for error wrapping issues.",
+ Run: run,
+ }
+
+ a.Flags.BoolVar(&checkComparison, "comparison", true, "Check for plain error comparisons")
+ a.Flags.BoolVar(&checkAsserts, "asserts", true, "Check for plain type assertions and type switches")
+ a.Flags.BoolVar(&checkErrorf, "errorf", false, "Check whether fmt.Errorf uses the %w verb for formatting errors. See the readme for caveats")
+ a.Flags.BoolVar(&checkErrorfMulti, "errorf-multi", true, "Permit more than 1 %w verb, valid per Go 1.20 (Requires -errorf=true)")
+
+ return a
+}
+
+var (
+ checkComparison bool
+ checkAsserts bool
+ checkErrorf bool
+ checkErrorfMulti bool
+)
+
+func run(pass *analysis.Pass) (interface{}, error) {
+ var lints []analysis.Diagnostic
+ extInfo := newTypesInfoExt(pass)
+ if checkComparison {
+ l := LintErrorComparisons(extInfo)
+ lints = append(lints, l...)
+ }
+ if checkAsserts {
+ l := LintErrorTypeAssertions(pass.Fset, extInfo)
+ lints = append(lints, l...)
+ }
+ if checkErrorf {
+ l := LintFmtErrorfCalls(pass.Fset, *pass.TypesInfo, checkErrorfMulti)
+ lints = append(lints, l...)
+ }
+ sort.Sort(ByPosition(lints))
+
+ for _, l := range lints {
+ pass.Report(l)
+ }
+ return nil, nil
+}
+
+type TypesInfoExt struct {
+ *analysis.Pass
+
+ // Maps AST nodes back to the node they are contained within.
+ NodeParent map[ast.Node]ast.Node
+
+ // Maps an object back to all identifiers to refer to it.
+ IdentifiersForObject map[types.Object][]*ast.Ident
+}
+
+func newTypesInfoExt(pass *analysis.Pass) *TypesInfoExt {
+ nodeParent := map[ast.Node]ast.Node{}
+ for node := range pass.TypesInfo.Scopes {
+ file, ok := node.(*ast.File)
+ if !ok {
+ continue
+ }
+ stack := []ast.Node{file}
+ ast.Inspect(file, func(n ast.Node) bool {
+ nodeParent[n] = stack[len(stack)-1]
+ if n == nil {
+ stack = stack[:len(stack)-1]
+ } else {
+ stack = append(stack, n)
+ }
+ return true
+ })
+ }
+
+ identifiersForObject := map[types.Object][]*ast.Ident{}
+ for node, obj := range pass.TypesInfo.Defs {
+ identifiersForObject[obj] = append(identifiersForObject[obj], node)
+ }
+ for node, obj := range pass.TypesInfo.Uses {
+ identifiersForObject[obj] = append(identifiersForObject[obj], node)
+ }
+
+ return &TypesInfoExt{
+ Pass: pass,
+ NodeParent: nodeParent,
+ IdentifiersForObject: identifiersForObject,
+ }
+}
+
+func (info *TypesInfoExt) ContainingFuncDecl(node ast.Node) *ast.FuncDecl {
+ for parent := info.NodeParent[node]; ; parent = info.NodeParent[parent] {
+ if _, ok := parent.(*ast.File); ok {
+ break
+ }
+ if fun, ok := parent.(*ast.FuncDecl); ok {
+ return fun
+ }
+ }
+ return nil
+}
diff --git a/vendor/codeberg.org/polyfloyd/go-errorlint/errorlint/lint.go b/vendor/codeberg.org/polyfloyd/go-errorlint/errorlint/lint.go
new file mode 100644
index 0000000000..b7d3cbd5f2
--- /dev/null
+++ b/vendor/codeberg.org/polyfloyd/go-errorlint/errorlint/lint.go
@@ -0,0 +1,908 @@
+package errorlint
+
+import (
+ "bytes"
+ "fmt"
+ "go/ast"
+ "go/constant"
+ "go/printer"
+ "go/token"
+ "go/types"
+ "strings"
+
+ "golang.org/x/tools/go/analysis"
+)
+
+type ByPosition []analysis.Diagnostic
+
+func (l ByPosition) Len() int { return len(l) }
+func (l ByPosition) Swap(i, j int) { l[i], l[j] = l[j], l[i] }
+func (l ByPosition) Less(i, j int) bool {
+ return l[i].Pos < l[j].Pos
+}
+
+func LintFmtErrorfCalls(fset *token.FileSet, info types.Info, multipleWraps bool) []analysis.Diagnostic {
+ var lints []analysis.Diagnostic
+
+ for expr, t := range info.Types {
+ // Search for error expressions that are the result of fmt.Errorf
+ // invocations.
+ if t.Type.String() != "error" {
+ continue
+ }
+ call, ok := isFmtErrorfCallExpr(info, expr)
+ if !ok {
+ continue
+ }
+
+ // Find all % fields in the format string.
+ formatVerbs, ok := printfFormatStringVerbs(info, call)
+ if !ok {
+ continue
+ }
+
+ // For any arguments that are errors, check whether the wrapping verb is used. %w may occur
+ // for multiple errors in one Errorf invocation, unless multipleWraps is true. We raise an
+ // issue if at least one error does not have a corresponding wrapping verb.
+ args := call.Args[1:]
+ if !multipleWraps {
+ wrapCount := 0
+ for i := 0; i < len(args) && i < len(formatVerbs); i++ {
+ arg := args[i]
+ if !implementsError(info.Types[arg].Type) {
+ continue
+ }
+ verb := formatVerbs[i]
+
+ if verb.format == "w" {
+ wrapCount++
+ if wrapCount > 1 {
+ lints = append(lints, analysis.Diagnostic{
+ Message: "only one %w verb is permitted per format string",
+ Pos: arg.Pos(),
+ })
+ break
+ }
+ }
+
+ if wrapCount == 0 {
+ lints = append(lints, analysis.Diagnostic{
+ Message: "non-wrapping format verb for fmt.Errorf. Use `%w` to format errors",
+ Pos: args[i].Pos(),
+ })
+ break
+ }
+ }
+
+ } else {
+ var lint *analysis.Diagnostic
+ argIndex := 0
+ for _, verb := range formatVerbs {
+ if verb.index != -1 {
+ argIndex = verb.index
+ } else {
+ argIndex++
+ }
+
+ if verb.format == "w" || verb.format == "T" {
+ continue
+ }
+ if argIndex-1 >= len(args) {
+ continue
+ }
+ arg := args[argIndex-1]
+ if !implementsError(info.Types[arg].Type) {
+ continue
+ }
+
+ strStart := call.Args[0].Pos()
+ if lint == nil {
+ lint = &analysis.Diagnostic{
+ Message: "non-wrapping format verb for fmt.Errorf. Use `%w` to format errors",
+ Pos: arg.Pos(),
+ }
+ }
+ fixMessage := "Use `%w` to format errors"
+ if len(lint.SuggestedFixes) > 0 {
+ fixMessage += fmt.Sprintf(" (%d)", len(lint.SuggestedFixes)+1)
+ }
+ lint.SuggestedFixes = append(lint.SuggestedFixes, analysis.SuggestedFix{
+ Message: fixMessage,
+ TextEdits: []analysis.TextEdit{{
+ Pos: strStart + token.Pos(verb.formatOffset) + 1,
+ End: strStart + token.Pos(verb.formatOffset) + 2,
+ NewText: []byte("w"),
+ }},
+ })
+ }
+ if lint != nil {
+ lints = append(lints, *lint)
+ }
+ }
+ }
+ return lints
+}
+
+// printfFormatStringVerbs returns a normalized list of all the verbs that are used per argument to
+// the printf function. The index of each returned element corresponds to the index of the
+// respective argument.
+func printfFormatStringVerbs(info types.Info, call *ast.CallExpr) ([]verb, bool) {
+ if len(call.Args) <= 1 {
+ return nil, false
+ }
+ strLit, ok := call.Args[0].(*ast.BasicLit)
+ if !ok {
+ // Ignore format strings that are not literals.
+ return nil, false
+ }
+ formatString := constant.StringVal(info.Types[strLit].Value)
+
+ pp := printfParser{str: formatString}
+ verbs, err := pp.ParseAllVerbs()
+ if err != nil {
+ return nil, false
+ }
+
+ return verbs, true
+}
+
+func isFmtErrorfCallExpr(info types.Info, expr ast.Expr) (*ast.CallExpr, bool) {
+ call, ok := expr.(*ast.CallExpr)
+ if !ok {
+ return nil, false
+ }
+ fn, ok := call.Fun.(*ast.SelectorExpr)
+ if !ok {
+ // TODO: Support fmt.Errorf variable aliases?
+ return nil, false
+ }
+ obj := info.Uses[fn.Sel]
+
+ pkg := obj.Pkg()
+ if pkg != nil && pkg.Name() == "fmt" && obj.Name() == "Errorf" {
+ return call, true
+ }
+ return nil, false
+}
+
+func LintErrorComparisons(info *TypesInfoExt) []analysis.Diagnostic {
+ var lints []analysis.Diagnostic
+
+ // Check for error comparisons.
+ for expr := range info.TypesInfo.Types {
+ // Find == and != operations.
+ binExpr, ok := expr.(*ast.BinaryExpr)
+ if !ok {
+ continue
+ }
+ if binExpr.Op != token.EQL && binExpr.Op != token.NEQ {
+ continue
+ }
+ // Comparing errors with nil is okay.
+ if isNil(binExpr.X) || isNil(binExpr.Y) {
+ continue
+ }
+ // Find comparisons of which one side is a of type error.
+ if !isErrorType(info.TypesInfo, binExpr.X) && !isErrorType(info.TypesInfo, binExpr.Y) {
+ continue
+ }
+ // Some errors that are returned from some functions are exempt.
+ if isAllowedErrorComparison(info, binExpr.X, binExpr.Y) {
+ continue
+ }
+ // Comparisons that happen in `func (type) Is(error) bool` are okay.
+ if isNodeInErrorIsFunc(info, binExpr) {
+ continue
+ }
+
+ diagnostic := analysis.Diagnostic{
+ Message: fmt.Sprintf("comparing with %s will fail on wrapped errors. Use errors.Is to check for a specific error", binExpr.Op),
+ Pos: binExpr.Pos(),
+ }
+
+ // Add suggested fix.
+ var errVar, targetErr ast.Expr
+ // Identify which side is the error variable and which is the sentinel error.
+ if isErrorType(info.TypesInfo, binExpr.Y) && !isErrorType(info.TypesInfo, binExpr.X) {
+ // Y is error, X is not
+ errVar = binExpr.Y
+ targetErr = binExpr.X
+ } else {
+ // X is error (or both are errors)
+ errVar = binExpr.X
+ targetErr = binExpr.Y
+ }
+
+ negated := binExpr.Op == token.NEQ
+
+ // Build the suggested fix - preserve the original order of parameters.
+ replacement := fmt.Sprintf("errors.Is(%s, %s)", exprToString(errVar), exprToString(targetErr))
+ if negated {
+ replacement = "!" + replacement
+ }
+
+ diagnostic.SuggestedFixes = []analysis.SuggestedFix{{
+ Message: "Use errors.Is() to compare errors",
+ TextEdits: []analysis.TextEdit{{
+ Pos: binExpr.Pos(),
+ End: binExpr.End(),
+ NewText: []byte(replacement),
+ }},
+ }}
+
+ lints = append(lints, diagnostic)
+ }
+
+ // Check for error comparisons in switch statements.
+ for scope := range info.TypesInfo.Scopes {
+ // Find value switch blocks.
+ switchStmt, ok := scope.(*ast.SwitchStmt)
+ if !ok {
+ continue
+ }
+ // Check whether the switch operates on an error type.
+ if !isErrorType(info.TypesInfo, switchStmt.Tag) {
+ continue
+ }
+
+ var problematicCaseClause *ast.CaseClause
+ outer:
+ for _, stmt := range switchStmt.Body.List {
+ caseClause := stmt.(*ast.CaseClause)
+ for _, caseExpr := range caseClause.List {
+ if isNil(caseExpr) {
+ continue
+ }
+ // Some errors that are returned from some functions are exempt.
+ if !isAllowedErrorComparison(info, switchStmt.Tag, caseExpr) {
+ problematicCaseClause = caseClause
+ break outer
+ }
+ }
+ }
+ if problematicCaseClause == nil {
+ continue
+ }
+
+ // Comparisons that happen in `func (type) Is(error) bool` are okay.
+ if isNodeInErrorIsFunc(info, switchStmt) {
+ continue
+ }
+
+ if !switchComparesNonNil(switchStmt) {
+ continue
+ }
+
+ diagnostic := analysis.Diagnostic{
+ Message: "switch on an error will fail on wrapped errors. Use errors.Is to check for specific errors",
+ Pos: problematicCaseClause.Pos(),
+ }
+
+ // Create a simpler version of the fix for switch statements
+ // We'll transform: switch err { case ErrX: ... }
+ // To: switch { case errors.Is(err, ErrX): ... }
+
+ // Create a new switch statement with an empty tag
+ newSwitchStmt := &ast.SwitchStmt{
+ Init: switchStmt.Init,
+ Tag: nil, // Empty tag for the switch.
+ Body: &ast.BlockStmt{
+ List: make([]ast.Stmt, len(switchStmt.Body.List)),
+ },
+ }
+
+ // Convert each case to use errors.Is.
+ switchTagExpr := switchStmt.Tag // The error variable being checked.
+ for i, stmt := range switchStmt.Body.List {
+ origCaseClause := stmt.(*ast.CaseClause)
+
+ // Create a new case clause.
+ newCaseClause := &ast.CaseClause{
+ Body: origCaseClause.Body,
+ }
+
+ // If this is a default case (no expressions), keep it as-is.
+ if len(origCaseClause.List) == 0 {
+ newCaseClause.List = nil // Default case.
+ newSwitchStmt.Body.List[i] = newCaseClause
+ continue
+ }
+
+ newCaseClause.List = make([]ast.Expr, 0, len(origCaseClause.List))
+
+ // Convert each case expression.
+ for _, caseExpr := range origCaseClause.List {
+ if isNil(caseExpr) {
+ // Keep nil checks as is: case err == nil:
+ newCaseClause.List = append(newCaseClause.List,
+ &ast.BinaryExpr{
+ X: switchTagExpr,
+ Op: token.EQL,
+ Y: caseExpr,
+ })
+ continue
+ }
+ // Replace err == ErrX with errors.Is(err, ErrX).
+ newCaseClause.List = append(newCaseClause.List,
+ &ast.CallExpr{
+ Fun: &ast.SelectorExpr{
+ X: ast.NewIdent("errors"),
+ Sel: ast.NewIdent("Is"),
+ },
+ Args: []ast.Expr{switchTagExpr, caseExpr},
+ })
+ }
+
+ newSwitchStmt.Body.List[i] = newCaseClause
+ }
+
+ // Print the modified AST to get the fix text.
+ var buf bytes.Buffer
+ printer.Fprint(&buf, token.NewFileSet(), newSwitchStmt)
+ fixText := buf.String()
+
+ diagnostic.SuggestedFixes = []analysis.SuggestedFix{{
+ Message: "Convert to errors.Is() for error comparisons",
+ TextEdits: []analysis.TextEdit{{
+ Pos: switchStmt.Pos(),
+ End: switchStmt.End(),
+ NewText: []byte(fixText),
+ }},
+ }}
+
+ lints = append(lints, diagnostic)
+ }
+
+ return lints
+}
+
+// exprToString converts an expression to its string representation.
+func exprToString(expr ast.Expr) string {
+ switch e := expr.(type) {
+ case *ast.Ident:
+ return e.Name
+ case *ast.SelectorExpr:
+ return exprToString(e.X) + "." + e.Sel.Name
+ case *ast.StarExpr:
+ return "*" + exprToString(e.X)
+ case *ast.UnaryExpr:
+ return e.Op.String() + exprToString(e.X)
+ case *ast.BinaryExpr:
+ return exprToString(e.X) + " " + e.Op.String() + " " + exprToString(e.Y)
+ case *ast.CallExpr:
+ var args []string
+ for _, arg := range e.Args {
+ args = append(args, exprToString(arg))
+ }
+ return exprToString(e.Fun) + "(" + strings.Join(args, ", ") + ")"
+ case *ast.ParenExpr:
+ return "(" + exprToString(e.X) + ")"
+ case *ast.IndexExpr:
+ return exprToString(e.X) + "[" + exprToString(e.Index) + "]"
+ case *ast.BasicLit:
+ return e.Value
+ case *ast.TypeAssertExpr:
+ return exprToString(e.X) + ".(" + exprToString(e.Type) + ")"
+ default:
+ // If we can't handle the expression type, return a placeholder.
+ return "/* complex expression */"
+ }
+}
+
+func isNil(ex ast.Expr) bool {
+ ident, ok := ex.(*ast.Ident)
+ return ok && ident.Name == "nil"
+}
+
+func isErrorType(info *types.Info, ex ast.Expr) bool {
+ t := info.Types[ex].Type
+ return t != nil && t.String() == "error"
+}
+
+func isNodeInErrorIsFunc(info *TypesInfoExt, node ast.Node) bool {
+ funcDecl := info.ContainingFuncDecl(node)
+ if funcDecl == nil {
+ return false
+ }
+ // Check if the function name is Is.
+ if funcDecl.Name.Name != "Is" {
+ return false
+ }
+ // Check if the function has a receiver.
+ if funcDecl.Recv == nil {
+ return false
+ }
+ // There should be 1 argument of type error.
+ if params := funcDecl.Type.Params.List; len(params) != 1 || info.TypesInfo.Types[params[0].Type].Type.String() != "error" {
+ return false
+ }
+ // The return type should be bool.
+ if params := funcDecl.Type.Results.List; len(params) != 1 || info.TypesInfo.Types[params[0].Type].Type.String() != "bool" {
+ return false
+ }
+ return true
+}
+
+// switchComparesNonNil returns true if one of its clauses compares by value.
+func switchComparesNonNil(switchStmt *ast.SwitchStmt) bool {
+ for _, caseBlock := range switchStmt.Body.List {
+ caseClause, ok := caseBlock.(*ast.CaseClause)
+ if !ok {
+ continue
+ }
+ for _, clause := range caseClause.List {
+ switch clause := clause.(type) {
+ case nil:
+ // default label is safe.
+ continue
+ case *ast.Ident:
+ // `case nil` is safe.
+ if clause.Name == "nil" {
+ continue
+ }
+ }
+ // anything else (including an Ident other than nil) isn't safe.
+ return true
+ }
+ }
+ return false
+}
+
+func LintErrorTypeAssertions(fset *token.FileSet, info *TypesInfoExt) []analysis.Diagnostic {
+ var lints []analysis.Diagnostic
+
+ for expr := range info.TypesInfo.Types {
+ // Find type assertions.
+ typeAssert, ok := expr.(*ast.TypeAssertExpr)
+ if !ok {
+ continue
+ }
+
+ // Find type assertions that operate on values of type error.
+ if !isErrorTypeAssertion(*info.TypesInfo, typeAssert) {
+ continue
+ }
+
+ if isNodeInErrorIsFunc(info, typeAssert) {
+ continue
+ }
+
+ // If the asserted type is not an error, allow the expression.
+ if !implementsError(info.TypesInfo.Types[typeAssert.Type].Type) {
+ continue
+ }
+
+ diagnostic := analysis.Diagnostic{
+ Message: "type assertion on error will fail on wrapped errors. Use errors.As to check for specific errors",
+ Pos: typeAssert.Pos(),
+ }
+
+ // Create suggested fix for type assertion
+ targetType := exprToString(typeAssert.Type)
+ errExpr := exprToString(typeAssert.X)
+
+ // Check if the type is a pointer type
+ baseType, isPointerType := strings.CutPrefix(targetType, "*")
+
+ parent := info.NodeParent[typeAssert]
+
+ // For assignment statements like: targetErr, ok := err.(*SomeError)
+ if assign, ok := parent.(*ast.AssignStmt); ok && len(assign.Lhs) == 2 {
+ if id, ok := assign.Lhs[0].(*ast.Ident); ok {
+ // Generate a suitable variable name, handling underscore case
+ // Example: _, ok := err.(*MyError) -> myError := &MyError{}; ok := errors.As(err, &myError)
+ varName := generateErrorVarName(id.Name, baseType)
+
+ // If this is part of an if statement initialization
+ ifParent, isIfInit := info.NodeParent[assign].(*ast.IfStmt)
+ if isIfInit && ifParent.Init == assign {
+ // Handle special case for if statements
+ // Replace: if targetErr, ok := err.(*SomeError); ok {
+ // With: targetErr := &SomeError{}
+ // if errors.As(err, &targetErr) {
+ var varDecl string
+ if isPointerType {
+ varDecl = fmt.Sprintf("%s := &%s{}", varName, baseType)
+ } else {
+ varDecl = fmt.Sprintf("var %s %s", varName, baseType)
+ }
+ condition := fmt.Sprintf("if errors.As(%s, &%s)", errExpr, varName)
+
+ replacement := fmt.Sprintf("%s\n%s",
+ varDecl, condition)
+
+ diagnostic.SuggestedFixes = []analysis.SuggestedFix{{
+ Message: "Use errors.As() for type assertions on errors",
+ TextEdits: []analysis.TextEdit{{
+ // Replace both the if statement's initialization and condition
+ Pos: ifParent.Pos(),
+ End: ifParent.Body.Pos(),
+ NewText: []byte(replacement),
+ }},
+ }}
+ lints = append(lints, diagnostic)
+ continue
+ }
+
+ // Regular assignment outside of if statement.
+ // Replace: targetErr, ok := err.(*SomeError) or err.(SomeError)
+ // With: targetErr := &SomeError{} or var targetErr SomeError
+ // ok := errors.As(err, &targetErr)
+ var varDecl string
+ if isPointerType {
+ varDecl = fmt.Sprintf("%s := &%s{}", varName, baseType)
+ } else {
+ varDecl = fmt.Sprintf("var %s %s", varName, baseType)
+ }
+
+ // Preserve the original name of the "ok" variable
+ // Example: myErr, wasFound := err.(*MyError)
+ // Should use "wasFound" in the transformed code, not just "ok"
+ okName := "ok" // Default
+ if len(assign.Lhs) > 1 {
+ if okIdent, okOk := assign.Lhs[1].(*ast.Ident); okOk && okIdent.Name != "_" {
+ okName = okIdent.Name
+ }
+ }
+
+ // Align with golden file format
+ replacement := fmt.Sprintf("%s\n%s := errors.As(%s, &%s)",
+ varDecl, okName, errExpr, varName)
+
+ diagnostic.SuggestedFixes = []analysis.SuggestedFix{{
+ Message: "Use errors.As() for type assertions on errors",
+ TextEdits: []analysis.TextEdit{{
+ Pos: assign.Pos(),
+ End: assign.End(),
+ NewText: []byte(replacement),
+ }},
+ }}
+ lints = append(lints, diagnostic)
+ continue
+ }
+ }
+
+ if _, ok := parent.(*ast.IfStmt); ok {
+ // For if statements without initialization but with direct type assertion in condition
+ varName := generateErrorVarName("target", baseType)
+ var varDecl string
+ if isPointerType {
+ varDecl = fmt.Sprintf("%s := &%s{}", varName, baseType)
+ } else {
+ varDecl = fmt.Sprintf("var %s %s", varName, baseType)
+ }
+ replacement := fmt.Sprintf("%s\nif errors.As(%s, &%s)",
+ varDecl, errExpr, varName)
+
+ diagnostic.SuggestedFixes = []analysis.SuggestedFix{{
+ Message: "Use errors.As() for type assertions on errors",
+ TextEdits: []analysis.TextEdit{{
+ Pos: typeAssert.Pos(),
+ End: typeAssert.End(),
+ NewText: []byte(replacement),
+ }},
+ }}
+ lints = append(lints, diagnostic)
+ continue
+ }
+
+ // Handle standalone type assertions without assignment
+ // Example: _ = err.(*MyError)
+ // Transforms to: _ = func() *MyError { var target *MyError; _ = errors.As(err, &target); return target }()
+ varName := generateErrorVarName("target", baseType)
+ var targetDecl string
+ if isPointerType {
+ targetDecl = fmt.Sprintf("%s := &%s{}", varName, baseType)
+ } else {
+ targetDecl = fmt.Sprintf("var %s %s", varName, baseType)
+ }
+
+ replacement := fmt.Sprintf("func() %s {\n\t%s\n\t_ = errors.As(%s, &%s)\n\treturn %s\n}()",
+ targetType, targetDecl, errExpr, varName, varName)
+
+ diagnostic.SuggestedFixes = []analysis.SuggestedFix{{
+ Message: "Use errors.As() for type assertions on errors",
+ TextEdits: []analysis.TextEdit{{
+ Pos: typeAssert.Pos(),
+ End: typeAssert.End(),
+ NewText: []byte(replacement),
+ }},
+ }}
+ lints = append(lints, diagnostic)
+ }
+
+ for scope := range info.TypesInfo.Scopes {
+ // Find type switches.
+ typeSwitch, ok := scope.(*ast.TypeSwitchStmt)
+ if !ok {
+ continue
+ }
+
+ // Find the type assertion in the type switch.
+ var typeAssert *ast.TypeAssertExpr
+ switch t := typeSwitch.Assign.(type) {
+ case *ast.ExprStmt:
+ typeAssert = t.X.(*ast.TypeAssertExpr)
+ case *ast.AssignStmt:
+ typeAssert = t.Rhs[0].(*ast.TypeAssertExpr)
+ }
+
+ // Check whether the type switch is on a value of type error.
+ if !isErrorTypeAssertion(*info.TypesInfo, typeAssert) {
+ continue
+ }
+
+ if isNodeInErrorIsFunc(info, typeSwitch) {
+ continue
+ }
+
+ diagnostic := analysis.Diagnostic{
+ Message: "type switch on error will fail on wrapped errors. Use errors.As to check for specific errors",
+ Pos: typeAssert.Pos(),
+ }
+
+ // Transform type switch into a switch statement with errors.As in each case
+ // e.g., switch err.(type) { case *MyError: ... } becomes:
+ // var myError *MyError; switch { case errors.As(err, &myError): ... }
+
+ // Get the error variable being type-switched on
+ errExpr := typeAssert.X
+
+ // a flag to know if we can fix the issue with a [analysis.SuggestedFix]
+ canFix := true
+
+ // Determine if this is a type switch with assignment (switch e := err.(type))
+ var assignIdent *ast.Ident
+ var useShadowVar bool
+ if assignStmt, ok := typeSwitch.Assign.(*ast.AssignStmt); ok {
+ // This is a type switch with assignment like: switch e := err.(type)
+ if len(assignStmt.Lhs) == 1 {
+ if id, ok := assignStmt.Lhs[0].(*ast.Ident); ok {
+ if exprToString(errExpr) == id.Name {
+ // the switch with assignment is like switch err := err.(type)
+ // we cannot reuse err, otherwise it would lead to errors(err, &err)
+ canFix = false
+
+ // TODO - suggest a fix with a new variable name instead?
+ // the issue is with the fact each branch should have a new variable name
+ } else {
+ // the variable names are different, we can reuse the assigned variable
+ assignIdent = id
+ useShadowVar = true
+ }
+ }
+ }
+ }
+
+ // Create variable declarations for each type
+ varDecls := []ast.Stmt{}
+
+ // Create a map of type expressions to variable names
+ typeToVar := make(map[ast.Expr]string)
+
+ // First collect all unique types from cases
+ caseTypes := []ast.Expr{}
+ for _, stmt := range typeSwitch.Body.List {
+ caseClause := stmt.(*ast.CaseClause)
+ for _, typeExpr := range caseClause.List {
+ // Skip default case (empty list) and nil comparisons.
+ if typeExpr != nil && !isNil(typeExpr) {
+ caseTypes = append(caseTypes, typeExpr)
+ }
+ }
+ }
+
+ // Create variable declarations for each type.
+ for i, typeExpr := range caseTypes {
+ // Create variable declarations for each type.
+ // generate a default and unique name
+ varName := fmt.Sprintf("errCase%d", i)
+
+ // then try to find a better one.
+ if useShadowVar || (assignIdent != nil && i == 0) {
+ // If we have an assignment identifier, use it for all variables in a switch with assignment.
+ // Otherwise, if we have an assignment but not shadowing, use it for the first variable.
+ varName = assignIdent.Name
+ }
+
+ // Ensure we don't create duplicate variables with the same name.
+ var duplicate bool
+ for j := 0; j < i; j++ {
+ if typeToVar[caseTypes[j]] == varName {
+ duplicate = true
+ break
+ }
+ }
+
+ if duplicate {
+ // Use a different name to avoid duplicate variable declarations.
+ varName = fmt.Sprintf("%s%d", varName, i)
+ }
+
+ typeToVar[typeExpr] = varName
+
+ // Create a variable declaration.
+ varDecl := &ast.DeclStmt{
+ Decl: &ast.GenDecl{
+ Tok: token.VAR,
+ Specs: []ast.Spec{
+ &ast.ValueSpec{
+ Names: []*ast.Ident{ast.NewIdent(varName)},
+ Type: typeExpr,
+ },
+ },
+ },
+ }
+
+ varDecls = append(varDecls, varDecl)
+ }
+
+ // Create a new switch statement with empty tag.
+ newSwitchStmt := &ast.SwitchStmt{
+ Body: &ast.BlockStmt{
+ List: make([]ast.Stmt, len(typeSwitch.Body.List)),
+ },
+ }
+
+ // Create a block statement to hold both variable declarations and the switch.
+ blockStmt := &ast.BlockStmt{
+ List: append(varDecls, newSwitchStmt),
+ }
+
+ // Process each case.
+ for i, stmt := range typeSwitch.Body.List {
+ caseClause := stmt.(*ast.CaseClause)
+
+ // Create a new case clause.
+ newCaseClause := &ast.CaseClause{
+ Body: caseClause.Body,
+ }
+
+ // If this is a default case, keep it as-is.
+ if len(caseClause.List) == 0 {
+ // This is the default case.
+ newCaseClause.List = nil
+ newSwitchStmt.Body.List[i] = newCaseClause
+ continue
+ }
+
+ // For other cases, create errors.As calls for each type.
+ newCaseClause.List = make([]ast.Expr, len(caseClause.List))
+
+ for j, typeExpr := range caseClause.List {
+ // Nil cases should become err == nil.
+ if isNil(typeExpr) {
+ newCaseClause.List[j] = &ast.BinaryExpr{
+ X: errExpr,
+ Op: token.EQL,
+ Y: typeExpr,
+ }
+ continue
+ }
+
+ // Get the previously declared variable for this type.
+ varName := typeToVar[typeExpr]
+
+ // Create errors.As(err, &varName) call.
+ newCaseClause.List[j] = &ast.CallExpr{
+ Fun: &ast.SelectorExpr{
+ X: ast.NewIdent("errors"),
+ Sel: ast.NewIdent("As"),
+ },
+ Args: []ast.Expr{
+ errExpr,
+ &ast.UnaryExpr{
+ Op: token.AND,
+ X: ast.NewIdent(varName),
+ },
+ },
+ }
+ }
+
+ // If this is a switch with assignment, we need to update the variable
+ // names used in the body of each case to match our renamed variables.
+ if assignIdent != nil && len(caseClause.List) > 0 {
+ typeExpr := caseClause.List[0]
+ oldVarName := assignIdent.Name
+ newVarName := typeToVar[typeExpr]
+
+ if oldVarName != newVarName {
+ // Create a visitor to replace all mentions of the original variable
+ // with our renamed variable in this case's body.
+ visitor := func(n ast.Node) bool {
+ if ident, ok := n.(*ast.Ident); ok && ident.Name == oldVarName {
+ ident.Name = newVarName
+ }
+ return true
+ }
+
+ // Apply the visitor to the case body
+ for _, bodyStmt := range newCaseClause.Body {
+ ast.Inspect(bodyStmt, visitor)
+ }
+ }
+ }
+
+ // Add this case to the switch.
+ newSwitchStmt.Body.List[i] = newCaseClause
+ }
+
+ if canFix {
+ // Print the resulting block to get the fix text.
+ var buf bytes.Buffer
+ printer.Fprint(&buf, token.NewFileSet(), blockStmt)
+ fixText := buf.String()
+
+ diagnostic.SuggestedFixes = []analysis.SuggestedFix{{
+ Message: "Convert type switch to use errors.As",
+ TextEdits: []analysis.TextEdit{{
+ Pos: typeSwitch.Pos(),
+ End: typeSwitch.End(),
+ NewText: []byte(fixText),
+ }},
+ }}
+ }
+ lints = append(lints, diagnostic)
+ }
+
+ return lints
+}
+
+func isErrorTypeAssertion(info types.Info, typeAssert *ast.TypeAssertExpr) bool {
+ t := info.Types[typeAssert.X]
+ return t.Type.String() == "error"
+}
+
+func implementsError(t types.Type) bool {
+ mset := types.NewMethodSet(t)
+
+ for i := 0; i < mset.Len(); i++ {
+ if mset.At(i).Kind() != types.MethodVal {
+ continue
+ }
+
+ obj := mset.At(i).Obj()
+ if obj.Name() == "Error" && obj.Type().String() == "func() string" {
+ return true
+ }
+ }
+
+ return false
+}
+
+// generateErrorVarName creates an appropriate variable name for error type assertions.
+// If originalName is "_" or a generic placeholder, it generates a more meaningful name
+// based on the error type, following Go naming conventions:
+//
+// Examples:
+// - originalName="_", typeName="MyError" → "myError" (camelCase conversion)
+// - originalName="_", typeName="pkg.CustomError" → "customError" (package prefix removed)
+// - originalName="existingName" → "existingName" (original name preserved)
+// - originalName="_", typeName="" → "myErr" (fallback for unknown types)
+//
+// This helps ensure code readability when converting type assertions to errors.As calls,
+// particularly when dealing with underscore identifiers that can't be referenced.
+func generateErrorVarName(originalName, typeName string) string {
+ // If the original name is not an underscore, use it
+ if originalName != "_" {
+ return originalName
+ }
+
+ // Handle underscore case by generating a name based on the type
+ // Strip any package prefix like "pkg."
+ if lastDot := strings.LastIndex(typeName, "."); lastDot >= 0 {
+ typeName = typeName[lastDot+1:]
+ }
+
+ // Convert first letter to lowercase for camelCase
+ if len(typeName) > 0 {
+ firstChar := strings.ToLower(typeName[:1])
+ if len(typeName) > 1 {
+ return firstChar + typeName[1:]
+ }
+ return firstChar
+ }
+
+ // If we couldn't determine a good name, use default.
+ return "anErr"
+}
diff --git a/vendor/codeberg.org/polyfloyd/go-errorlint/errorlint/options.go b/vendor/codeberg.org/polyfloyd/go-errorlint/errorlint/options.go
new file mode 100644
index 0000000000..64d4352f45
--- /dev/null
+++ b/vendor/codeberg.org/polyfloyd/go-errorlint/errorlint/options.go
@@ -0,0 +1,27 @@
+package errorlint
+
+type Option func()
+
+func WithAllowedErrors(ap []AllowPair) Option {
+ return func() {
+ allowedMapAppend(ap)
+ }
+}
+
+func WithAllowedWildcard(ap []AllowPair) Option {
+ return func() {
+ allowedWildcardAppend(ap)
+ }
+}
+
+func WithComparison(enabled bool) Option {
+ return func() {
+ checkComparison = enabled
+ }
+}
+
+func WithAsserts(enabled bool) Option {
+ return func() {
+ checkAsserts = enabled
+ }
+}
diff --git a/vendor/github.com/polyfloyd/go-errorlint/errorlint/printf.go b/vendor/codeberg.org/polyfloyd/go-errorlint/errorlint/printf.go
similarity index 100%
rename from vendor/github.com/polyfloyd/go-errorlint/errorlint/printf.go
rename to vendor/codeberg.org/polyfloyd/go-errorlint/errorlint/printf.go
diff --git a/vendor/github.com/GaijinEntertainment/go-exhaustruct/v3/LICENSE b/vendor/dev.gaijin.team/go/exhaustruct/v4/LICENSE
similarity index 100%
rename from vendor/github.com/GaijinEntertainment/go-exhaustruct/v3/LICENSE
rename to vendor/dev.gaijin.team/go/exhaustruct/v4/LICENSE
diff --git a/vendor/dev.gaijin.team/go/exhaustruct/v4/analyzer/analyzer.go b/vendor/dev.gaijin.team/go/exhaustruct/v4/analyzer/analyzer.go
new file mode 100644
index 0000000000..a235de3856
--- /dev/null
+++ b/vendor/dev.gaijin.team/go/exhaustruct/v4/analyzer/analyzer.go
@@ -0,0 +1,389 @@
+package analyzer
+
+import (
+ "flag"
+ "fmt"
+ "go/ast"
+ "go/token"
+ "go/types"
+ "sync"
+
+ "golang.org/x/tools/go/analysis"
+ "golang.org/x/tools/go/analysis/passes/inspect"
+ "golang.org/x/tools/go/ast/inspector"
+
+ "dev.gaijin.team/go/exhaustruct/v4/internal/comment"
+ "dev.gaijin.team/go/exhaustruct/v4/internal/structure"
+)
+
+type analyzer struct {
+ config Config
+
+ structFields structure.FieldsCache `exhaustruct:"optional"`
+ comments comment.Cache `exhaustruct:"optional"`
+
+ typeProcessingNeed map[string]bool
+ typeProcessingNeedMu sync.RWMutex `exhaustruct:"optional"`
+}
+
+func NewAnalyzer(config Config) (*analysis.Analyzer, error) {
+ err := config.Prepare()
+ if err != nil {
+ return nil, err
+ }
+
+ a := analyzer{
+ config: config,
+ typeProcessingNeed: make(map[string]bool),
+ comments: comment.Cache{},
+ }
+
+ return &analysis.Analyzer{ //nolint:exhaustruct
+ Name: "exhaustruct",
+ Doc: "Checks if all structure fields are initialized",
+ Run: a.run,
+ Requires: []*analysis.Analyzer{inspect.Analyzer},
+ Flags: *a.config.BindToFlagSet(flag.NewFlagSet("", flag.PanicOnError)),
+ }, nil
+}
+
+func (a *analyzer) run(pass *analysis.Pass) (any, error) {
+ insp := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector) //nolint:forcetypeassert
+
+ insp.WithStack([]ast.Node{(*ast.CompositeLit)(nil)}, a.newVisitor(pass))
+
+ return nil, nil //nolint:nilnil
+}
+
+// newVisitor returns visitor that only expects [ast.CompositeLit] nodes.
+func (a *analyzer) newVisitor(pass *analysis.Pass) func(n ast.Node, push bool, stack []ast.Node) bool {
+ return func(n ast.Node, push bool, stack []ast.Node) bool {
+ if !push {
+ return true
+ }
+
+ lit, ok := n.(*ast.CompositeLit)
+ if !ok {
+ // this should never happen, but better be prepared
+ return true
+ }
+
+ structTyp, typeInfo, ok := getStructType(pass, lit)
+ if !ok {
+ return true
+ }
+
+ if len(lit.Elts) == 0 && a.checkEmptyStructAllowed(pass, stack, typeInfo) {
+ return true
+ }
+
+ file := a.comments.Get(pass.Fset, stack[0].(*ast.File)) //nolint:forcetypeassert
+ rc := getCompositeLitRelatedComments(stack, file)
+ pos, msg := a.processStruct(pass, lit, structTyp, typeInfo, rc)
+
+ if pos != nil {
+ pass.Reportf(*pos, "%s", msg)
+ }
+
+ return true
+ }
+}
+
+func (a *analyzer) checkEmptyStructAllowed(pass *analysis.Pass, stack []ast.Node, typeInfo *TypeInfo) bool {
+ // empty structs are globally allowed
+ if a.config.AllowEmpty {
+ return true
+ }
+
+ // some structs are allowed to be empty, basing on pattern
+ if a.config.allowEmptyPatterns.MatchFullString(typeInfo.String()) {
+ return true
+ }
+
+ if ret, ok := getParentReturnStmt(stack); ok {
+ // empty structures are allowed in all return statements
+ if a.config.AllowEmptyReturns {
+ return true
+ }
+
+ // empty structures are allowed in error returns
+ if isErrorReturnStatement(pass, ret, stack[len(stack)-1]) {
+ return true
+ }
+ }
+
+ // empty structures are allowed in variable declarations
+ if isChildOfVariableDeclaration(stack) && a.config.AllowEmptyDeclarations {
+ return true
+ }
+
+ return false
+}
+
+// isPartOfVariableDeclaration checks if the node is direct part of variable
+// declaration, meaning that it is a first-level RHS child of `:=` or `var`
+// declaration.
+func isChildOfVariableDeclaration(stack []ast.Node) bool {
+ if len(stack) < 2 { //nolint:mnd // stack for sure contains at leas current node and its parent (file)
+ return false
+ }
+
+ // Start from composite literal and go up the stack
+ for i := len(stack) - 1; i > 0; i-- {
+ parent := stack[i-1]
+
+ switch p := parent.(type) {
+ case *ast.AssignStmt:
+ if p.Tok == token.DEFINE {
+ return true
+ }
+
+ case *ast.ValueSpec:
+ return true
+
+ case *ast.UnaryExpr:
+ // Only allow pointer taking (&)
+ if p.Op == token.AND {
+ continue
+ }
+
+ return false
+
+ default:
+ return false
+ }
+ }
+
+ return false
+}
+
+// getParentReturnStmt checks if the direct parent of the current node is a
+// return statement and returns it if so.
+func getParentReturnStmt(stack []ast.Node) (*ast.ReturnStmt, bool) {
+ if len(stack) < 2 { //nolint:mnd // stack for sure contains at leas current node and its parent (file)
+ return nil, false
+ }
+
+ // Start from composite literal and go up the stack
+ for i := len(stack) - 1; i > 0; i-- {
+ parent := stack[i-1]
+
+ switch p := parent.(type) {
+ case *ast.ReturnStmt:
+ return p, true
+
+ case *ast.UnaryExpr:
+ // Only allow pointer taking (&)
+ if p.Op == token.AND {
+ continue
+ }
+
+ return nil, false
+
+ default:
+ return nil, false
+ }
+ }
+
+ return nil, false
+}
+
+// errorIface is an interface type of the [error] interface.
+//
+//nolint:forcetypeassert,gochecknoglobals
+var errorIface = types.Universe.Lookup("error").Type().Underlying().(*types.Interface)
+
+// isErrorReturnStatement checks if the return statement is an error return
+// statement, meaning that it contains a non-nil value that implements [error].
+func isErrorReturnStatement(pass *analysis.Pass, n *ast.ReturnStmt, currentNode ast.Node) bool {
+ if len(n.Results) == 0 {
+ return false
+ }
+
+ // iterate backwards, since idiomatic position of error is at the end
+ for i := len(n.Results) - 1; i >= 0; i-- {
+ ri := n.Results[i]
+
+ // Skip the current node, since it is already being checked
+ if ri == currentNode {
+ continue
+ }
+
+ switch ri := ri.(type) {
+ case *ast.Ident:
+ // Skip nil values
+ if ri.Name == "nil" {
+ continue
+ }
+
+ case *ast.UnaryExpr:
+ // Current node might be under the unary expression
+ if ri.X == currentNode {
+ continue
+ }
+ }
+
+ // Check if the type implements error interface
+ resultType := pass.TypesInfo.TypeOf(ri)
+ if resultType != nil && types.Implements(resultType, errorIface) {
+ return true
+ }
+ }
+
+ return false
+}
+
+// getCompositeLitRelatedComments returns all comments that are related to checked node. We
+// have to traverse the stack manually as ast do not associate comments with
+// [ast.CompositeLit].
+func getCompositeLitRelatedComments(stack []ast.Node, cm ast.CommentMap) []*ast.CommentGroup {
+ comments := make([]*ast.CommentGroup, 0)
+
+ for i := len(stack) - 1; i >= 0; i-- {
+ node := stack[i]
+
+ switch tn := node.(type) {
+ case *ast.CompositeLit:
+ // comments on the lines prior to literal
+ comments = append(comments, cm[node]...)
+ // comments on the same line as literal type definition
+ // worth noting that event "typeless" literals have a type
+ comments = append(comments, cm[tn.Type]...)
+
+ case *ast.ReturnStmt, // return ...
+ *ast.IndexExpr, // map[enum]...{...}[key]
+ *ast.CallExpr, // myfunc(map...)
+ *ast.UnaryExpr, // &map...
+ *ast.AssignStmt, // variable assignment (without var keyword)
+ *ast.DeclStmt, // var declaration, parent of *ast.GenDecl
+ *ast.GenDecl, // var declaration, parent of *ast.ValueSpec
+ *ast.ValueSpec, // var declaration
+ *ast.KeyValueExpr: // field declaration
+ comments = append(comments, cm[node]...)
+
+ default:
+ return comments
+ }
+ }
+
+ return comments
+}
+
+func getStructType(pass *analysis.Pass, lit *ast.CompositeLit) (*types.Struct, *TypeInfo, bool) {
+ switch typ := types.Unalias(pass.TypesInfo.TypeOf(lit)).(type) {
+ case *types.Named: // named type
+ if structTyp, ok := typ.Underlying().(*types.Struct); ok {
+ pkg := typ.Obj().Pkg()
+ ti := TypeInfo{
+ Name: typ.Obj().Name(),
+ PackageName: pkg.Name(),
+ PackagePath: pkg.Path(),
+ }
+
+ return structTyp, &ti, true
+ }
+
+ return nil, nil, false
+
+ case *types.Struct: // anonymous struct
+ ti := TypeInfo{
+ Name: "",
+ PackageName: pass.Pkg.Name(),
+ PackagePath: pass.Pkg.Path(),
+ }
+
+ return typ, &ti, true
+
+ default:
+ return nil, nil, false
+ }
+}
+
+func (a *analyzer) processStruct(
+ pass *analysis.Pass,
+ lit *ast.CompositeLit,
+ structTyp *types.Struct,
+ info *TypeInfo,
+ comments []*ast.CommentGroup,
+) (*token.Pos, string) {
+ shouldProcess := a.shouldProcessType(info)
+
+ if shouldProcess && comment.HasDirective(comments, comment.DirectiveIgnore) {
+ return nil, ""
+ }
+
+ if !shouldProcess && !comment.HasDirective(comments, comment.DirectiveEnforce) {
+ return nil, ""
+ }
+
+ // unnamed structures are only defined in same package, along with types that has
+ // prefix identical to current package name.
+ isSamePackage := info.PackagePath == pass.Pkg.Path()
+
+ if f := a.litSkippedFields(lit, structTyp, !isSamePackage); len(f) > 0 {
+ pos := lit.Pos()
+
+ if len(f) == 1 {
+ return &pos, fmt.Sprintf("%s is missing field %s", info.ShortString(), f.String())
+ }
+
+ return &pos, fmt.Sprintf("%s is missing fields %s", info.ShortString(), f.String())
+ }
+
+ return nil, ""
+}
+
+// shouldProcessType returns true if type should be processed basing off include
+// and exclude patterns, defined though constructor and\or flags.
+func (a *analyzer) shouldProcessType(info *TypeInfo) bool {
+ if len(a.config.includePatterns) == 0 && len(a.config.excludePatterns) == 0 {
+ return true
+ }
+
+ name := info.String()
+
+ a.typeProcessingNeedMu.RLock()
+ res, ok := a.typeProcessingNeed[name]
+ a.typeProcessingNeedMu.RUnlock()
+
+ if !ok {
+ a.typeProcessingNeedMu.Lock()
+
+ res = true
+
+ if a.config.includePatterns != nil && !a.config.includePatterns.MatchFullString(name) {
+ res = false
+ }
+
+ if res && a.config.excludePatterns != nil && a.config.excludePatterns.MatchFullString(name) {
+ res = false
+ }
+
+ a.typeProcessingNeed[name] = res
+ a.typeProcessingNeedMu.Unlock()
+ }
+
+ return res
+}
+
+func (a *analyzer) litSkippedFields(
+ lit *ast.CompositeLit,
+ typ *types.Struct,
+ onlyExported bool,
+) structure.Fields {
+ return a.structFields.Get(typ).Skipped(lit, onlyExported)
+}
+
+type TypeInfo struct {
+ Name string
+ PackageName string
+ PackagePath string
+}
+
+func (t TypeInfo) String() string {
+ return t.PackagePath + "." + t.Name
+}
+
+func (t TypeInfo) ShortString() string {
+ return t.PackageName + "." + t.Name
+}
diff --git a/vendor/dev.gaijin.team/go/exhaustruct/v4/analyzer/config.go b/vendor/dev.gaijin.team/go/exhaustruct/v4/analyzer/config.go
new file mode 100644
index 0000000000..0c39cbed8c
--- /dev/null
+++ b/vendor/dev.gaijin.team/go/exhaustruct/v4/analyzer/config.go
@@ -0,0 +1,127 @@
+package analyzer
+
+import (
+ "flag"
+ "strings"
+
+ "dev.gaijin.team/go/golib/e"
+
+ "dev.gaijin.team/go/exhaustruct/v4/internal/pattern"
+)
+
+type Config struct {
+ // IncludeRx is a list of regular expressions to match type names that should be
+ // processed. Anonymous structs can be matched by '' alias.
+ //
+ // Each regular expression must match the full type name, including package path.
+ // For example, to match type `net/http.Cookie` regular expression should be
+ // `.*/http\.Cookie`, but not `http\.Cookie`.
+ IncludeRx []string `exhaustruct:"optional"`
+ includePatterns pattern.List `exhaustruct:"optional"`
+
+ // ExcludeRx is a list of regular expressions to match type names that should be
+ // excluded from processing. Anonymous structs can be matched by ''
+ // alias.
+ //
+ // Has precedence over IncludeRx.
+ //
+ // Each regular expression must match the full type name, including package path.
+ // For example, to match type `net/http.Cookie` regular expression should be
+ // `.*/http\.Cookie`, but not `http\.Cookie`.
+ ExcludeRx []string `exhaustruct:"optional"`
+ excludePatterns pattern.List `exhaustruct:"optional"`
+
+ // AllowEmpty allows empty structures, effectively excluding them from the check.
+ AllowEmpty bool `exhaustruct:"optional"`
+
+ // AllowEmptyRx is a list of regular expressions to match type names that should
+ // be allowed to be empty. Anonymous structs can be matched by ''
+ // alias.
+ //
+ // Each regular expression must match the full type name, including package path.
+ // For example, to match type `net/http.Cookie` regular expression should be
+ // `.*/http\.Cookie`, but not `http\.Cookie`.
+ AllowEmptyRx []string `exhaustruct:"optional"`
+ allowEmptyPatterns pattern.List `exhaustruct:"optional"`
+
+ // AllowEmptyReturns allows empty structures in return statements.
+ AllowEmptyReturns bool `exhaustruct:"optional"`
+
+ // AllowEmptyDeclarations allows empty structures in variable declarations.
+ AllowEmptyDeclarations bool `exhaustruct:"optional"`
+}
+
+// Prepare compiles all regular expression patterns into pattern lists for
+// efficient matching.
+func (c *Config) Prepare() error {
+ var err error
+
+ c.includePatterns, err = pattern.NewList(c.IncludeRx...)
+ if err != nil {
+ return e.NewFrom("compile include patterns", err)
+ }
+
+ c.excludePatterns, err = pattern.NewList(c.ExcludeRx...)
+ if err != nil {
+ return e.NewFrom("compile exclude patterns", err)
+ }
+
+ c.allowEmptyPatterns, err = pattern.NewList(c.AllowEmptyRx...)
+ if err != nil {
+ return e.NewFrom("compile allow empty patterns", err)
+ }
+
+ return nil
+}
+
+// stringSliceFlag implements flag.Value interface for []string fields.
+type stringSliceFlag struct {
+ slice *[]string
+}
+
+func (s stringSliceFlag) String() string {
+ if s.slice == nil {
+ return ""
+ }
+
+ return strings.Join(*s.slice, ",")
+}
+
+func (s stringSliceFlag) Set(value string) error {
+ *s.slice = append(*s.slice, value)
+ return nil
+}
+
+// BindToFlagSet binds the config fields to the provided flag set.
+func (c *Config) BindToFlagSet(fs *flag.FlagSet) *flag.FlagSet {
+ fs.Var(stringSliceFlag{&c.IncludeRx}, "include-rx",
+ "Regular expression to match type names that should be processed. "+
+ "Anonymous structs can be matched by '' alias. "+
+ "Each regex must match the full type name including package path. "+
+ "Example: `.*/http\\.Cookie`. Can be used multiple times.")
+ fs.Var(stringSliceFlag{&c.IncludeRx}, "i", "Short form of -include-rx")
+
+ fs.Var(stringSliceFlag{&c.ExcludeRx}, "exclude-rx",
+ "Regular expression to exclude type names from processing, has precedence over -include. "+
+ "Anonymous structs can be matched by '' alias. "+
+ "Each regex must match the full type name including package path. "+
+ "Example: `.*/http\\.Cookie`. Can be used multiple times.")
+ fs.Var(stringSliceFlag{&c.ExcludeRx}, "e", "Short form of -exclude-rx")
+
+ fs.BoolVar(&c.AllowEmpty, "allow-empty", c.AllowEmpty,
+ "Allow empty structures, effectively excluding them from the check")
+
+ fs.Var(stringSliceFlag{&c.AllowEmptyRx}, "allow-empty-rx",
+ "Regular expression to match type names that should be allowed to be empty. "+
+ "Anonymous structs can be matched by '' alias. "+
+ "Each regex must match the full type name including package path. "+
+ "Example: `.*/http\\.Cookie`. Can be used multiple times.")
+
+ fs.BoolVar(&c.AllowEmptyReturns, "allow-empty-returns", c.AllowEmptyReturns,
+ "Allow empty structures in return statements")
+
+ fs.BoolVar(&c.AllowEmptyDeclarations, "allow-empty-declarations", c.AllowEmptyDeclarations,
+ "Allow empty structures in variable declarations")
+
+ return fs
+}
diff --git a/vendor/github.com/GaijinEntertainment/go-exhaustruct/v3/internal/comment/cache.go b/vendor/dev.gaijin.team/go/exhaustruct/v4/internal/comment/cache.go
similarity index 100%
rename from vendor/github.com/GaijinEntertainment/go-exhaustruct/v3/internal/comment/cache.go
rename to vendor/dev.gaijin.team/go/exhaustruct/v4/internal/comment/cache.go
diff --git a/vendor/github.com/GaijinEntertainment/go-exhaustruct/v3/internal/comment/directive.go b/vendor/dev.gaijin.team/go/exhaustruct/v4/internal/comment/directive.go
similarity index 100%
rename from vendor/github.com/GaijinEntertainment/go-exhaustruct/v3/internal/comment/directive.go
rename to vendor/dev.gaijin.team/go/exhaustruct/v4/internal/comment/directive.go
diff --git a/vendor/dev.gaijin.team/go/exhaustruct/v4/internal/pattern/list.go b/vendor/dev.gaijin.team/go/exhaustruct/v4/internal/pattern/list.go
new file mode 100644
index 0000000000..26b8ac20da
--- /dev/null
+++ b/vendor/dev.gaijin.team/go/exhaustruct/v4/internal/pattern/list.go
@@ -0,0 +1,91 @@
+package pattern
+
+import (
+ "regexp"
+ "strings"
+
+ "dev.gaijin.team/go/golib/e"
+ "dev.gaijin.team/go/golib/fields"
+)
+
+// List represents a collection of compiled regular expressions that can be used
+// for pattern matching against strings. It implements the flag.Value interface
+// to support command-line flag binding.
+type List []*regexp.Regexp //nolint:recvcheck
+
+// NewList creates a new List from the provided regular expression patterns.
+// Each pattern string is compiled into a regular expression. If any pattern
+// is empty or fails to compile, an error is returned.
+func NewList(patterns ...string) (List, error) {
+ if len(patterns) == 0 {
+ return nil, nil
+ }
+
+ list := make(List, 0, len(patterns))
+
+ for _, pattern := range patterns {
+ re, err := parseRx(pattern)
+ if err != nil {
+ return nil, err
+ }
+
+ list = append(list, re)
+ }
+
+ return list, nil
+}
+
+// MatchFullString checks if any of the regular expressions in the list matches
+// the entire input string. A match is considered successful only if the regex
+// matches the complete string from start to end, not just a substring.
+//
+// For example, if a List contains the pattern "test", it will match "test"
+// but not "testing" or "contest".
+func (l List) MatchFullString(str string) bool {
+ for i := 0; i < len(l); i++ {
+ if m := l[i].FindStringSubmatch(str); len(m) > 0 && m[0] == str {
+ return true
+ }
+ }
+
+ return false
+}
+
+// String returns a string representation of the List by joining all regex patterns
+// with commas. This method implements the flag.Value interface and is used when
+// the List is displayed or serialized.
+func (l List) String() string {
+ patterns := make([]string, len(l))
+ for i, re := range l {
+ patterns[i] = re.String()
+ }
+
+ return strings.Join(patterns, ",")
+}
+
+// Set adds a new regex pattern to the List by compiling the provided string.
+// This method implements the flag.Value interface and is called when the flag
+// is set from command-line arguments or programmatically.
+func (l *List) Set(value string) error {
+ re, err := parseRx(value)
+ if err != nil {
+ return err
+ }
+
+ *l = append(*l, re)
+
+ return nil
+}
+
+func parseRx(str string) (*regexp.Regexp, error) {
+ if str == "" {
+ return nil, e.New("empty regular expression is not allowed")
+ }
+
+ re, err := regexp.Compile(str)
+ if err != nil {
+ return nil, e.NewFrom("failed to compile regular expression", err, fields.F("pattern", str))
+ }
+
+ return re, nil
+}
diff --git a/vendor/github.com/GaijinEntertainment/go-exhaustruct/v3/internal/structure/fields-cache.go b/vendor/dev.gaijin.team/go/exhaustruct/v4/internal/structure/fields-cache.go
similarity index 100%
rename from vendor/github.com/GaijinEntertainment/go-exhaustruct/v3/internal/structure/fields-cache.go
rename to vendor/dev.gaijin.team/go/exhaustruct/v4/internal/structure/fields-cache.go
diff --git a/vendor/github.com/GaijinEntertainment/go-exhaustruct/v3/internal/structure/fields.go b/vendor/dev.gaijin.team/go/exhaustruct/v4/internal/structure/fields.go
similarity index 100%
rename from vendor/github.com/GaijinEntertainment/go-exhaustruct/v3/internal/structure/fields.go
rename to vendor/dev.gaijin.team/go/exhaustruct/v4/internal/structure/fields.go
diff --git a/vendor/dev.gaijin.team/go/exhaustruct/v5/LICENSE b/vendor/dev.gaijin.team/go/exhaustruct/v5/LICENSE
new file mode 100644
index 0000000000..6698196c5a
--- /dev/null
+++ b/vendor/dev.gaijin.team/go/exhaustruct/v5/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2022 Gaijin Entertainment
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/vendor/dev.gaijin.team/go/exhaustruct/v5/analyzer/analyzer.go b/vendor/dev.gaijin.team/go/exhaustruct/v5/analyzer/analyzer.go
new file mode 100644
index 0000000000..d4bb73f744
--- /dev/null
+++ b/vendor/dev.gaijin.team/go/exhaustruct/v5/analyzer/analyzer.go
@@ -0,0 +1,111 @@
+package analyzer
+
+import (
+ "flag"
+ "sync"
+
+ "dev.gaijin.team/go/golib/e"
+ "dev.gaijin.team/go/golib/fields"
+ "golang.org/x/tools/go/analysis"
+ "golang.org/x/tools/go/analysis/passes/inspect"
+
+ "dev.gaijin.team/go/exhaustruct/v5/internal/astutil"
+ "dev.gaijin.team/go/exhaustruct/v5/internal/directive"
+ "dev.gaijin.team/go/exhaustruct/v5/internal/pattern"
+ "dev.gaijin.team/go/exhaustruct/v5/internal/structure"
+)
+
+// NewAnalyzer returns an analyzer configured exclusively through command-line
+// flags, intended for CLI drivers (singlechecker, go vet -vettool). The
+// processor is built lazily on the first run, after the driver has parsed the
+// flags.
+func NewAnalyzer() *analysis.Analyzer {
+ config := &Config{}
+
+ lazyProcessor := sync.OnceValues(func() (*structure.Processor, error) {
+ return newProcessor(config)
+ })
+
+ a := newBaseAnalyzer(func(pass *analysis.Pass) (any, error) {
+ processor, err := lazyProcessor()
+ if err != nil {
+ return nil, err
+ }
+
+ run(pass, config, processor)
+
+ return nil, nil //nolint:nilnil
+ })
+
+ a.Flags.Init("", flag.PanicOnError)
+ config.bindToFlagSet(&a.Flags)
+
+ return a
+}
+
+// NewAnalyzerWithConfig returns an analyzer configured programmatically,
+// intended for library consumers such as golangci-lint. The configuration is
+// copied and validated immediately; it exposes no flags, and later mutations
+// of the passed Config have no effect.
+func NewAnalyzerWithConfig(config Config) (*analysis.Analyzer, error) {
+ processor, err := newProcessor(&config)
+ if err != nil {
+ return nil, err
+ }
+
+ return newBaseAnalyzer(func(pass *analysis.Pass) (any, error) {
+ run(pass, &config, processor)
+
+ return nil, nil //nolint:nilnil
+ }), nil
+}
+
+func newBaseAnalyzer(run func(*analysis.Pass) (any, error)) *analysis.Analyzer {
+ return &analysis.Analyzer{
+ Name: "exhaustruct",
+ Doc: "Checks if all structure fields are initialized",
+ Run: run,
+ Requires: []*analysis.Analyzer{inspect.Analyzer},
+ }
+}
+
+func newProcessor(config *Config) (*structure.Processor, error) {
+ enforce, err := pattern.NewList(config.EnforcePatterns...)
+ if err != nil {
+ return nil, e.NewFrom("compile enforce patterns", err, fields.F("flag", "enforce-rx"))
+ }
+
+ ignore, err := pattern.NewList(config.IgnorePatterns...)
+ if err != nil {
+ return nil, e.NewFrom("compile ignore patterns", err, fields.F("flag", "ignore-rx"))
+ }
+
+ optional, err := pattern.NewList(config.OptionalPatterns...)
+ if err != nil {
+ return nil, e.NewFrom("compile optional patterns", err, fields.F("flag", "optional-rx"))
+ }
+
+ allowEmpty, err := pattern.NewList(config.AllowEmptyPatterns...)
+ if err != nil {
+ return nil, e.NewFrom("compile allow-empty patterns", err, fields.F("flag", "allow-empty-rx"))
+ }
+
+ fp := astutil.NewFileParser()
+
+ return structure.NewProcessor(
+ directive.NewScanner(fp),
+ structure.WithEnforce(enforce),
+ structure.WithIgnore(ignore),
+ structure.WithOptional(optional),
+ structure.WithAllowEmpty(allowEmpty),
+ ), nil
+}
+
+func run(pass *analysis.Pass, config *Config, processor *structure.Processor) {
+ for _, diag := range processor.Directives().ProcessFiles(pass.Fset, pass.Files...) {
+ pass.Report(diag)
+ }
+
+ newMissingFieldsVisitor(pass, config, processor).run()
+ newTagMigrationVisitor(pass, processor).run()
+}
diff --git a/vendor/dev.gaijin.team/go/exhaustruct/v5/analyzer/config.go b/vendor/dev.gaijin.team/go/exhaustruct/v5/analyzer/config.go
new file mode 100644
index 0000000000..af96746acd
--- /dev/null
+++ b/vendor/dev.gaijin.team/go/exhaustruct/v5/analyzer/config.go
@@ -0,0 +1,153 @@
+package analyzer
+
+import (
+ "flag"
+ "strings"
+
+ "dev.gaijin.team/go/exhaustruct/v5/internal/pattern"
+)
+
+type Config struct {
+ // EnforcePatterns is a list of regular expressions to match type names that
+ // should be checked. Anonymous structs can be matched by '' alias.
+ //
+ // A type pattern selects the types checked under ExplicitMode; without it
+ // every type is checked already, so only field patterns change anything.
+ //
+ // A pattern may name a field as 'Type#Field', which requires that field
+ // inside a type already being checked, in either mode. A pattern matching
+ // the field and not the type holding it outranks what the type says; one
+ // broad enough to match both names no field in particular.
+ //
+ // Each regular expression must match the full type name, including package path.
+ // For example, to match type `net/http.Cookie` regular expression should be
+ // `.*/http\.Cookie`, but not `http\.Cookie`.
+ EnforcePatterns Patterns //exhaustruct:optional
+
+ // IgnorePatterns is a list of regular expressions to match type names that
+ // should be skipped from checking. Anonymous structs can be matched by
+ // '' alias.
+ //
+ // Has precedence over EnforcePatterns.
+ //
+ // Each regular expression must match the full type name, including package path.
+ // For example, to match type `net/http.Cookie` regular expression should be
+ // `.*/http\.Cookie`, but not `http\.Cookie`.
+ IgnorePatterns Patterns //exhaustruct:optional
+
+ // OptionalPatterns is a list of regular expressions to match type names where
+ // all fields are treated as optional. Anonymous structs can be matched by
+ // '' alias.
+ //
+ // Each regular expression must match the full type name, including package path.
+ // For example, to match type `net/http.Cookie` regular expression should be
+ // `.*/http\.Cookie`, but not `http\.Cookie`.
+ OptionalPatterns Patterns //exhaustruct:optional
+
+ // AllowEmpty allows empty structures, effectively excluding them from the check.
+ AllowEmpty bool //exhaustruct:optional
+
+ // AllowEmptyPatterns is a list of regular expressions to match type names that
+ // should be allowed to be empty. Anonymous structs can be matched by
+ // '' alias.
+ //
+ // Each regular expression must match the full type name, including package path.
+ // For example, to match type `net/http.Cookie` regular expression should be
+ // `.*/http\.Cookie`, but not `http\.Cookie`.
+ AllowEmptyPatterns Patterns //exhaustruct:optional
+
+ // AllowEmptyReturns allows empty structures in return statements.
+ AllowEmptyReturns bool //exhaustruct:optional
+
+ // AllowEmptyDeclarations allows empty structures in variable declarations.
+ AllowEmptyDeclarations bool //exhaustruct:optional
+
+ // AllowEmptyBlankAssignments allows empty structures the blank identifier
+ // receives, in a declaration or an assignment. `var _ Iface = T{}`, which
+ // asserts at compile time that T implements Iface, is written this way.
+ AllowEmptyBlankAssignments bool //exhaustruct:optional
+
+ // ReportFullTypePath enables full package path in error messages instead of
+ // short package name. This helps when configuring include/exclude patterns,
+ // as import aliases can make short names ambiguous.
+ ReportFullTypePath bool //exhaustruct:optional
+
+ // ExplicitMode enables opt-in checking. When true, only types marked with
+ // //exhaustruct:enforce directive or matching enforce-rx patterns are checked.
+ ExplicitMode bool //exhaustruct:optional
+}
+
+// bindToFlagSet binds the config fields to the provided flag set.
+func (c *Config) bindToFlagSet(fs *flag.FlagSet) {
+ fs.BoolVar(&c.ExplicitMode, "explicit", c.ExplicitMode,
+ "Enable explicit mode: only check types marked with //exhaustruct:enforce "+
+ "directive or matching -enforce-rx patterns")
+
+ fs.Var(&c.EnforcePatterns, "enforce-rx",
+ "Regular expression to match type names that should be checked. "+
+ "Selects the types checked under -explicit. A pattern may name a field "+
+ "as Type#Field, which requires that field in either mode; one matching "+
+ "the field and not the type holding it outranks what the type says. "+
+ "Anonymous structs can be matched by '' alias. "+
+ "Each regex must match the full type name including package path. "+
+ "Example: `.*/http\\.Cookie`. Can be used multiple times.")
+
+ fs.Var(&c.IgnorePatterns, "ignore-rx",
+ "Regular expression to skip type names from checking, has precedence over -enforce-rx. "+
+ "Anonymous structs can be matched by '' alias. "+
+ "Each regex must match the full type name including package path. "+
+ "Example: `.*/http\\.Cookie`. Can be used multiple times.")
+
+ fs.Var(&c.OptionalPatterns, "optional-rx",
+ "Regular expression to match type names where all fields are optional. "+
+ "Anonymous structs can be matched by '' alias. "+
+ "Each regex must match the full type name including package path. "+
+ "Example: `.*/http\\.Cookie`. Can be used multiple times.")
+
+ fs.BoolVar(&c.AllowEmpty, "allow-empty", c.AllowEmpty,
+ "Allow empty structures, effectively excluding them from the check")
+
+ fs.Var(&c.AllowEmptyPatterns, "allow-empty-rx",
+ "Regular expression to match type names that should be allowed to be empty. "+
+ "Anonymous structs can be matched by '' alias. "+
+ "Each regex must match the full type name including package path. "+
+ "Example: `.*/http\\.Cookie`. Can be used multiple times.")
+
+ fs.BoolVar(&c.AllowEmptyReturns, "allow-empty-returns", c.AllowEmptyReturns,
+ "Allow empty structures in return statements")
+
+ fs.BoolVar(&c.AllowEmptyDeclarations, "allow-empty-declarations", c.AllowEmptyDeclarations,
+ "Allow empty structures in variable declarations")
+
+ fs.BoolVar(&c.AllowEmptyBlankAssignments, "allow-empty-blank-assignments", c.AllowEmptyBlankAssignments,
+ "Allow empty structures the blank identifier receives, as in 'var _ Iface = T{}'")
+
+ fs.BoolVar(&c.ReportFullTypePath, "report-full-type-path", c.ReportFullTypePath,
+ "Report full package path in error messages (e.g., 'net/http.Cookie' instead of 'http.Cookie'). "+
+ "Useful for identifying types when configuring enforce/ignore patterns.")
+}
+
+// Patterns is a list of regular expression patterns. It implements
+// flag.Value, validating each value as a regular expression at
+// flag-parse time so invalid patterns fail early.
+type Patterns []string
+
+// String returns the patterns joined with commas (flag.Value interface).
+func (p *Patterns) String() string {
+ if p == nil {
+ return ""
+ }
+
+ return strings.Join(*p, ",")
+}
+
+// Set validates and appends a pattern (flag.Value interface).
+func (p *Patterns) Set(value string) error {
+ if _, err := pattern.NewList(value); err != nil {
+ return err //nolint:wrapcheck
+ }
+
+ *p = append(*p, value)
+
+ return nil
+}
diff --git a/vendor/dev.gaijin.team/go/exhaustruct/v5/analyzer/missing-fields-visitor.go b/vendor/dev.gaijin.team/go/exhaustruct/v5/analyzer/missing-fields-visitor.go
new file mode 100644
index 0000000000..53a5a9fb6a
--- /dev/null
+++ b/vendor/dev.gaijin.team/go/exhaustruct/v5/analyzer/missing-fields-visitor.go
@@ -0,0 +1,725 @@
+package analyzer
+
+import (
+ "fmt"
+ "go/ast"
+ "go/token"
+ "go/types"
+ "go/version"
+ "slices"
+
+ "golang.org/x/tools/go/analysis"
+ "golang.org/x/tools/go/analysis/passes/inspect"
+ "golang.org/x/tools/go/ast/inspector"
+
+ "dev.gaijin.team/go/exhaustruct/v5/internal/directive"
+ "dev.gaijin.team/go/exhaustruct/v5/internal/structure"
+)
+
+// missingFieldsVisitor checks struct literals for missing field initializations.
+type missingFieldsVisitor struct {
+ pass *analysis.Pass
+ config *Config
+ processor *structure.Processor
+}
+
+func newMissingFieldsVisitor(
+ pass *analysis.Pass,
+ config *Config,
+ processor *structure.Processor,
+) *missingFieldsVisitor {
+ return &missingFieldsVisitor{
+ pass: pass,
+ config: config,
+ processor: processor,
+ }
+}
+
+func (v *missingFieldsVisitor) run() {
+ insp := v.pass.ResultOf[inspect.Analyzer].(*inspector.Inspector) //nolint:forcetypeassert
+
+ insp.WithStack([]ast.Node{(*ast.CompositeLit)(nil)}, v.visit)
+}
+
+func (v *missingFieldsVisitor) visit(n ast.Node, push bool, stack []ast.Node) bool {
+ if !push {
+ return true
+ }
+
+ lit, ok := n.(*ast.CompositeLit)
+ if !ok {
+ return true
+ }
+
+ lv := literalVisitor{missingFieldsVisitor: v, lit: lit, stack: stack}
+ lv.process()
+
+ return true
+}
+
+// literalVisitor carries context for processing a single composite literal.
+type literalVisitor struct {
+ *missingFieldsVisitor
+
+ lit *ast.CompositeLit
+ stack []ast.Node
+}
+
+// literal holds resolved info for a struct literal being checked.
+type literal struct {
+ strct *structure.Struct
+ ignored bool
+ enforced bool
+}
+
+// shouldCheck implements checking decision priority.
+func (l literal) shouldCheck(explicitMode bool) bool {
+ if l.ignored {
+ return false
+ }
+
+ if l.enforced {
+ return true
+ }
+
+ if l.strct.IsIgnored() {
+ return false
+ }
+
+ if l.strct.IsEnforced() {
+ return true
+ }
+
+ return !explicitMode
+}
+
+func (lv literalVisitor) process() {
+ lit, ok := lv.resolveLiteral()
+ if !ok {
+ return
+ }
+
+ if len(lv.lit.Elts) == 0 && lv.checkEmptyAllowed(lit.strct) {
+ return
+ }
+
+ if pos, msg := lv.checkLiteral(lit); pos != nil {
+ lv.pass.Reportf(*pos, "%s", msg)
+ }
+}
+
+// resolveLiteral extracts struct type information from the composite literal,
+// retrieves cached metadata, and looks up directives.
+//
+// The named result carries the zero value on the paths that report ok=false,
+// where the caller discards it and there is no struct to describe.
+func (lv literalVisitor) resolveLiteral() (lit literal, ok bool) {
+ typeName, strct, pos := lv.resolveLiteralType()
+ if strct == nil {
+ return lit, false
+ }
+
+ s := lv.processor.ResolveStruct(lv.pass.Fset, typeName, strct, pos, lv.pass.Pkg)
+ if s == nil {
+ return lit, false
+ }
+
+ dirs := lv.useSiteDirectives()
+
+ return literal{
+ strct: s,
+ ignored: dirs.Contains(directive.Ignore),
+ enforced: dirs.Contains(directive.Enforce),
+ }, true
+}
+
+// useSiteDirectives collects the directives that apply to the literal.
+//
+// A directive is written above the statement holding a literal, not above every
+// literal nested inside it, so the search climbs out of the expression the
+// literal sits in and reads the statement holding it. Enumerating the node
+// kinds a literal may be written within cannot be complete -- parentheses,
+// selectors, operators, calls, sends and index expressions each nest literals,
+// and the list grew by one every time a shape was missed -- so the walk asks
+// what a node is instead: it climbs through expressions, and through the specs
+// and declarations a var block is built from, until it reaches a statement.
+//
+// It stops there. A statement is where a directive is written, and going above
+// one would let a directive on an `if` or a `for` reach every literal in the
+// block below it.
+func (lv literalVisitor) useSiteDirectives() directive.Directives {
+ var dirs directive.Directives
+
+ for _, node := range slices.Backward(lv.stack) {
+ if !carriesUseSiteDirective(node) {
+ break
+ }
+
+ found := lv.processor.Directives().LookupPos(lv.pass.Fset, node.Pos())
+
+ for _, d := range found {
+ if !dirs.Contains(d) {
+ dirs = append(dirs, d)
+ }
+ }
+
+ if _, isStatement := node.(ast.Stmt); isStatement {
+ break
+ }
+ }
+
+ return dirs
+}
+
+// carriesUseSiteDirective reports whether a directive written above node can
+// apply to a composite literal nested inside it.
+func carriesUseSiteDirective(node ast.Node) bool {
+ switch node.(type) {
+ case ast.Expr, ast.Spec, ast.Decl, ast.Stmt:
+ return true
+
+ default:
+ return false
+ }
+}
+
+// resolveLiteralType resolves the composite literal's type and definition position.
+func (lv literalVisitor) resolveLiteralType() (name *types.TypeName, strct *types.Struct, pos token.Pos) {
+ typ := lv.pass.TypesInfo.TypeOf(lv.lit)
+
+ // A literal may elide `&T` when the element type is a pointer, including a
+ // pointer reached through an alias or a defined pointer type. Such a
+ // pointer has a declaration of its own, which carries the directives and
+ // the patterns that select the literal -- an alias to a pointer answers
+ // like an alias to a struct.
+ name = typeNameOf(typ)
+
+ if ptr, ok := types.Unalias(typ).Underlying().(*types.Pointer); ok {
+ typ = ptr.Elem()
+
+ // A plain *T is written at the use site and declares nothing, so the
+ // struct it points at names the literal.
+ if name == nil {
+ name = typeNameOf(typ)
+ }
+ }
+
+ typ = types.Unalias(typ)
+
+ switch t := typ.(type) {
+ case *types.Named:
+ var ok bool
+
+ // Every instantiation of a generic type shares one declaration, and the
+ // declaration is what carries the fields and the directives. Resolving
+ // the origin makes G[int] and G[string] answer as the type they are
+ // written from, out of one cache entry.
+ if strct, ok = t.Origin().Underlying().(*types.Struct); !ok {
+ return nil, nil, token.NoPos
+ }
+
+ return name, strct, name.Pos()
+
+ case *types.TypeParam:
+ // A literal of a type parameter is written against its constraint's
+ // core type, which the type checker has already validated the keys
+ // against.
+ if strct = coreStruct(lv.pass.Fset, lv.processor.Directives(), t); strct == nil {
+ return nil, nil, token.NoPos
+ }
+
+ // A type parameter is declared in a signature, and the core it resolves
+ // to is a shape its constraint names rather than a type anyone declared.
+ // There is no declaration to read type-level directives from, and the
+ // parameter's own line would read the directives of the function.
+ return name, strct, token.NoPos
+
+ case *types.Struct:
+ // An alias to an anonymous struct has a declaration of its own; only a
+ // genuinely unnamed struct needs its position recovered from the AST.
+ if name != nil {
+ return name, t, name.Pos()
+ }
+
+ return name, t, lv.findAnonymousStructPos()
+
+ default:
+ return nil, nil, token.NoPos
+ }
+}
+
+// typeNameOf returns the declaration a type is written under, or nil when the
+// type is unnamed.
+func typeNameOf(typ types.Type) *types.TypeName {
+ switch t := typ.(type) {
+ case *types.Alias:
+ return t.Obj()
+
+ case *types.Named:
+ return t.Obj()
+
+ case *types.TypeParam:
+ return t.Obj()
+
+ default:
+ return nil
+ }
+}
+
+// coreStruct returns the struct type every term of a type parameter's
+// constraint shares, or nil when the constraint has no such core type and a
+// composite literal of the parameter is therefore not possible.
+func coreStruct(fset *token.FileSet, directives *directive.Scanner, tp *types.TypeParam) *types.Struct {
+ r := coreResolver{
+ fset: fset,
+ directives: directives,
+ walking: map[*types.Interface]bool{},
+ done: map[*types.Interface]coreResult{},
+ }
+
+ strct, _ := r.constraintCore(tp.Constraint())
+
+ return strct
+}
+
+// coreResolver walks the interfaces a constraint embeds. walking holds the ones
+// on the path being walked, so a cycle ends without a second branch of a
+// diamond reading as one; done holds the ones the walk finished, so a diamond
+// costs one visit per interface rather than one per path down to it. Stacked
+// diamonds otherwise multiply: n layers open 2^n paths over 3n+1 declarations.
+//
+// constraint: Go rejects a recursive interface, so an entry in done can never
+// hold a result the walking guard truncated. That guard is there so a type
+// built outside the type checker cannot recurse without end.
+type coreResolver struct {
+ fset *token.FileSet
+ // directives reads what a term's fields are annotated with, which is what
+ // tells two declarations of one shape apart. Nil where no scanner is at
+ // hand, and two such declarations then answer as one core.
+ directives *directive.Scanner
+ walking map[*types.Interface]bool
+ done map[*types.Interface]coreResult
+}
+
+// coreResult is what one interface resolved to, kept so a branch reaching it a
+// second time answers without walking it again.
+type coreResult struct {
+ core *types.Struct
+ ok bool
+}
+
+// constraintCore resolves the struct shared by every term of a constraint,
+// descending into the interfaces it embeds: a constraint may name its terms
+// itself or inherit them from another interface, and both describe one type
+// set.
+//
+// A constraint restricts methods as well as types, and the two are separate
+// contributions: a method-only interface narrows the type set without naming a
+// type, so it leaves the core of its siblings standing. ok is false only for a
+// term that names a type no literal can be written for, which leaves the whole
+// constraint without a core.
+
+func (r coreResolver) constraintCore(typ types.Type) (core *types.Struct, ok bool) {
+ iface, isIface := typ.Underlying().(*types.Interface)
+ if !isIface {
+ return nil, false
+ }
+
+ // An interface embedding itself contributes no core of its own; whichever
+ // branch opened it carries the answer.
+ if r.walking[iface] {
+ return nil, true
+ }
+
+ if res, walked := r.done[iface]; walked {
+ return res.core, res.ok
+ }
+
+ r.walking[iface] = true
+
+ defer func() {
+ delete(r.walking, iface)
+
+ r.done[iface] = coreResult{core: core, ok: ok}
+ }()
+
+ for embedded := range iface.EmbeddedTypes() {
+ for _, term := range unionTerms(embedded) {
+ strct, termOK := r.termCore(term)
+ if !termOK {
+ return nil, false
+ }
+
+ if strct == nil {
+ continue
+ }
+
+ if core != nil && !r.sameCore(core, strct) {
+ return nil, false
+ }
+
+ core = strct
+ }
+ }
+
+ return core, true
+}
+
+// sameCore reports whether two terms answer as one core: the same struct, which
+// an alias and a defined type both share, or two declarations of one shape
+// whose fields are annotated alike. Fields annotated apart make two cores, and
+// reading either declaration's would answer by the order the union lists its
+// terms.
+func (r coreResolver) sameCore(a, b *types.Struct) bool {
+ if a == b {
+ return true
+ }
+
+ if !types.Identical(a, b) {
+ return false
+ }
+
+ if r.directives == nil {
+ return true
+ }
+
+ for i := range a.NumFields() {
+ if r.fieldOptionality(a.Field(i)) != r.fieldOptionality(b.Field(i)) {
+ return false
+ }
+ }
+
+ return true
+}
+
+// fieldOptionality reads what one field of a term is annotated with, at the
+// position it is declared at, through the projection the field metadata itself
+// is built from.
+func (r coreResolver) fieldOptionality(f *types.Var) directive.Optionality {
+ return r.directives.LookupPos(r.fset, f.Pos()).Optionality()
+}
+
+// termCore resolves one term of a constraint to the struct it stands for: the
+// term's own type, or the core of another interface it names.
+func (r coreResolver) termCore(term types.Type) (*types.Struct, bool) {
+ if _, ok := term.Underlying().(*types.Interface); ok {
+ return r.constraintCore(term)
+ }
+
+ strct, ok := term.Underlying().(*types.Struct)
+
+ return strct, ok
+}
+
+// unionTerms splits a constraint element into its terms. A single-term element
+// is not wrapped in a union, so it stands for itself.
+func unionTerms(typ types.Type) []types.Type {
+ union, ok := typ.(*types.Union)
+ if !ok {
+ return []types.Type{typ}
+ }
+
+ terms := make([]types.Type, 0, union.Len())
+
+ for term := range union.Terms() {
+ terms = append(terms, term.Type())
+ }
+
+ return terms
+}
+
+// findAnonymousStructPos finds the position of the struct keyword for anonymous structs.
+func (lv literalVisitor) findAnonymousStructPos() token.Pos {
+ if lv.lit.Type != nil {
+ if st, ok := lv.lit.Type.(*ast.StructType); ok {
+ return st.Struct
+ }
+
+ return token.NoPos
+ }
+
+ // Key and value of a map literal both elide their type, and their types come
+ // from opposite sides of the map type — track which side the literal is on.
+ mapKey := false
+
+ for i := len(lv.stack) - 2; i >= 0; i-- { //nolint:mnd
+ switch parent := lv.stack[i].(type) {
+ case *ast.KeyValueExpr:
+ mapKey = parent.Key == lv.stack[i+1]
+
+ continue
+
+ case *ast.CompositeLit:
+ return structPosFromType(parent.Type, mapKey)
+
+ default:
+ return token.NoPos
+ }
+ }
+
+ return token.NoPos
+}
+
+func structPosFromType(typ ast.Expr, mapKey bool) token.Pos {
+ if typ == nil {
+ return token.NoPos
+ }
+
+ switch t := typ.(type) {
+ case *ast.ArrayType:
+ return structPosFromExpr(t.Elt)
+
+ case *ast.MapType:
+ if mapKey {
+ return structPosFromExpr(t.Key)
+ }
+
+ return structPosFromExpr(t.Value)
+ }
+
+ return token.NoPos
+}
+
+func structPosFromExpr(expr ast.Expr) token.Pos {
+ if star, ok := expr.(*ast.StarExpr); ok {
+ expr = star.X
+ }
+
+ if st, ok := expr.(*ast.StructType); ok {
+ return st.Struct
+ }
+
+ return token.NoPos
+}
+
+func (lv literalVisitor) checkEmptyAllowed(s *structure.Struct) bool {
+ if lv.config.AllowEmpty {
+ return true
+ }
+
+ if s.AllowEmptyDecl {
+ return true
+ }
+
+ if ret, ok := lv.getParentReturnStmt(); ok {
+ if lv.config.AllowEmptyReturns {
+ return true
+ }
+
+ if lv.isErrorReturnStatement(ret) {
+ return true
+ }
+ }
+
+ if lv.isChildOfVariableDeclaration() && lv.config.AllowEmptyDeclarations {
+ return true
+ }
+
+ if lv.config.AllowEmptyBlankAssignments && lv.isBlankAssignment() {
+ return true
+ }
+
+ return false
+}
+
+func (lv literalVisitor) checkLiteral(lit literal) (*token.Pos, string) {
+ if !lit.shouldCheck(lv.config.ExplicitMode) {
+ return nil, ""
+ }
+
+ strct := lit.strct
+
+ missingFields := strct.SkippedFields(lv.lit, lv.pass.Pkg.Path(), lv.canNamePromoted())
+
+ if len(missingFields) == 0 {
+ return nil, ""
+ }
+
+ pos := lv.lit.Pos()
+
+ displayName := strct.PackageName + "." + strct.Name
+ if lv.config.ReportFullTypePath {
+ displayName = strct.FullPath
+ }
+
+ if len(missingFields) == 1 {
+ return &pos, fmt.Sprintf("%s is missing field %s", displayName, structure.FormatFieldNames(missingFields))
+ }
+
+ return &pos, fmt.Sprintf("%s is missing fields %s", displayName, structure.FormatFieldNames(missingFields))
+}
+
+// promotedKeysVersion is the first language version that lets a composite
+// literal name a promoted field in place of the embedded field carrying it
+// (golang/go#77245).
+const promotedKeysVersion = "go1.27"
+
+// canNamePromoted reports whether the literal may write a promoted field as a
+// key. The version of the file holding it decides, not the one the module
+// declares: a //go:build constraint sets a single file apart from its package.
+func (lv literalVisitor) canNamePromoted() bool {
+ return canNamePromotedIn(lv.fileGoVersion())
+}
+
+// canNamePromotedIn reports whether a file of the given language version may
+// write a promoted field as a key. A version that is missing or not a Go
+// version reads as the newest one, as go/types reads it: the literal has
+// already type-checked with whatever keys it names.
+func canNamePromotedIn(goVersion string) bool {
+ return !version.IsValid(goVersion) || version.Compare(goVersion, promotedKeysVersion) >= 0
+}
+
+// fileGoVersion returns the language version of the file the literal is written
+// in, falling back to the package's own when the file carries none.
+func (lv literalVisitor) fileGoVersion() string {
+ if len(lv.stack) > 0 {
+ if file, ok := lv.stack[0].(*ast.File); ok {
+ if v := lv.pass.TypesInfo.FileVersions[file]; v != "" {
+ return v
+ }
+ }
+ }
+
+ return lv.pass.Pkg.GoVersion()
+}
+
+// enclosingOfLiteral returns the node the literal is written into, climbing out
+// of the wrappers that leave what it is written as unchanged: parentheses, and
+// the address-of that makes a `&T{}`. The expression returned beside it is the
+// one that node holds directly: the literal itself, or the outermost wrapper
+// around it. Both are nil where no such node encloses the literal.
+func (lv literalVisitor) enclosingOfLiteral() (parent ast.Node, child ast.Expr) {
+ child = lv.lit
+
+ for i := len(lv.stack) - 1; i > 0; i-- {
+ switch p := lv.stack[i-1].(type) {
+ case *ast.ParenExpr:
+ child = p
+
+ continue
+
+ case *ast.UnaryExpr:
+ if p.Op == token.AND {
+ child = p
+
+ continue
+ }
+
+ return nil, nil
+
+ default:
+ return p, child
+ }
+ }
+
+ return nil, nil
+}
+
+// isChildOfVariableDeclaration reports whether the literal is the value a
+// variable is declared with.
+func (lv literalVisitor) isChildOfVariableDeclaration() bool {
+ parent, _ := lv.enclosingOfLiteral()
+
+ switch p := parent.(type) {
+ case *ast.AssignStmt:
+ return p.Tok == token.DEFINE
+
+ case *ast.ValueSpec:
+ return true
+
+ default:
+ return false
+ }
+}
+
+// isBlankAssignment reports whether the literal is a value the blank identifier
+// receives, in a declaration or an assignment. A value is matched to its name
+// by position: `var _, x = T{}, U{}` discards the first literal and binds the
+// second.
+func (lv literalVisitor) isBlankAssignment() bool {
+ parent, child := lv.enclosingOfLiteral()
+
+ switch p := parent.(type) {
+ case *ast.ValueSpec:
+ i := slices.Index(p.Values, child)
+
+ return i >= 0 && i < len(p.Names) && isBlank(p.Names[i])
+
+ case *ast.AssignStmt:
+ i := slices.Index(p.Rhs, child)
+
+ return i >= 0 && i < len(p.Lhs) && isBlank(p.Lhs[i])
+
+ default:
+ return false
+ }
+}
+
+// isBlank reports whether expr is the blank identifier, parenthesized or not,
+// as go/types reads an assignment target.
+func isBlank(expr ast.Expr) bool {
+ ident, ok := unparen(expr).(*ast.Ident)
+
+ return ok && ident.Name == "_"
+}
+
+// getParentReturnStmt returns the return statement the literal is a result of.
+func (lv literalVisitor) getParentReturnStmt() (*ast.ReturnStmt, bool) {
+ parent, _ := lv.enclosingOfLiteral()
+
+ ret, ok := parent.(*ast.ReturnStmt)
+
+ return ret, ok
+}
+
+//nolint:forcetypeassert,gochecknoglobals
+var builtinErrorInterface = types.Universe.Lookup("error").Type().Underlying().(*types.Interface)
+
+func (lv literalVisitor) isErrorReturnStatement(n *ast.ReturnStmt) bool {
+ if len(n.Results) == 0 {
+ return false
+ }
+
+ for _, ri := range slices.Backward(n.Results) {
+ ri = unparen(ri)
+
+ if ri == lv.lit {
+ continue
+ }
+
+ switch ri := ri.(type) {
+ case *ast.Ident:
+ if ri.Name == "nil" {
+ continue
+ }
+
+ case *ast.UnaryExpr:
+ if unparen(ri.X) == lv.lit {
+ continue
+ }
+
+ default:
+ }
+
+ resultType := lv.pass.TypesInfo.TypeOf(ri)
+ if resultType != nil && types.Implements(resultType, builtinErrorInterface) {
+ return true
+ }
+ }
+
+ return false
+}
+
+// unparen strips redundant parentheses, which gofmt keeps and which would
+// otherwise break the walks that match a literal against its enclosing
+// expression.
+func unparen(expr ast.Expr) ast.Expr {
+ for {
+ paren, ok := expr.(*ast.ParenExpr)
+ if !ok {
+ return expr
+ }
+
+ expr = paren.X
+ }
+}
diff --git a/vendor/dev.gaijin.team/go/exhaustruct/v5/analyzer/tag-migration-visitor.go b/vendor/dev.gaijin.team/go/exhaustruct/v5/analyzer/tag-migration-visitor.go
new file mode 100644
index 0000000000..d2d2617715
--- /dev/null
+++ b/vendor/dev.gaijin.team/go/exhaustruct/v5/analyzer/tag-migration-visitor.go
@@ -0,0 +1,554 @@
+package analyzer
+
+import (
+ "bytes"
+ "go/ast"
+ "go/token"
+ "reflect"
+ "strconv"
+ "strings"
+
+ "golang.org/x/tools/go/analysis"
+ "golang.org/x/tools/go/analysis/passes/inspect"
+ "golang.org/x/tools/go/ast/inspector"
+
+ "dev.gaijin.team/go/exhaustruct/v5/internal/astutil"
+ "dev.gaijin.team/go/exhaustruct/v5/internal/structure"
+)
+
+// tagMigrationVisitor scans struct definitions for deprecated exhaustruct tags
+// and emits migration diagnostics with suggested fixes.
+type tagMigrationVisitor struct {
+ pass *analysis.Pass
+ processor *structure.Processor
+ // sources caches the file bytes placement is read from.
+ sources map[string][]byte
+}
+
+func newTagMigrationVisitor(pass *analysis.Pass, processor *structure.Processor) *tagMigrationVisitor {
+ return &tagMigrationVisitor{
+ pass: pass,
+ processor: processor,
+ sources: map[string][]byte{},
+ }
+}
+
+func (v *tagMigrationVisitor) run() {
+ insp := v.pass.ResultOf[inspect.Analyzer].(*inspector.Inspector) //nolint:forcetypeassert
+
+ insp.Preorder([]ast.Node{new(ast.StructType)}, v.visitStructType)
+}
+
+func (v *tagMigrationVisitor) visitStructType(n ast.Node) {
+ st, ok := n.(*ast.StructType)
+ if !ok {
+ return
+ }
+
+ if st.Fields == nil {
+ return
+ }
+
+ for i, field := range st.Fields.List {
+ if field.Tag == nil {
+ continue
+ }
+
+ value, ok := parseExhaustructTag(field.Tag.Value)
+ if !ok {
+ continue
+ }
+
+ v.pass.Report(buildTagDiagnostic(field, v.placeTag(st, i), value))
+ }
+}
+
+const (
+ exhaustructTagKey = "exhaustruct"
+ optionalTagValue = "optional"
+ optionalDirective = "//exhaustruct:optional"
+ fixMessage = "fix"
+)
+
+// parseExhaustructTag extracts value from an `exhaustruct:"value"` tag.
+// Returns ("", false) if tag not present.
+func parseExhaustructTag(tagLiteral string) (string, bool) {
+ tag, err := strconv.Unquote(tagLiteral)
+ if err != nil {
+ return "", false
+ }
+
+ return reflect.StructTag(tag).Lookup(exhaustructTagKey)
+}
+
+func buildTagDiagnostic(field *ast.Field, placement tagPlacement, tagValue string) analysis.Diagnostic {
+ var fixes []analysis.SuggestedFix
+
+ // A name sharing its line with a block line directive takes no comment
+ // above it: gofmt writes the two on lines of their own, which moves the
+ // name off the line the generator pinned. Appending asks for no such
+ // comment, so that placement is offered as it is anywhere else, and the
+ // tag is reported without a fix only where neither is open to it.
+ if placement.canAppend || !placement.movesALineDirective() {
+ fixes = []analysis.SuggestedFix{buildTagFix(field, placement, tagValue)}
+ }
+
+ return analysis.Diagnostic{
+ Pos: field.Tag.Pos(),
+ Message: `struct tag "exhaustruct" is not supported anymore, use comment directives`,
+ SuggestedFixes: fixes,
+ }
+}
+
+func buildTagFix(field *ast.Field, placement tagPlacement, tagValue string) analysis.SuggestedFix {
+ tag := field.Tag
+ newTag := removeExhaustructFromTag(tag.Value)
+
+ // Dropping the tag entirely takes the whitespace in front of it too, but
+ // only whitespace: a comment written there carries its own meaning.
+ start := tag.Pos()
+ if newTag == "" && !placement.gapBeforeTag {
+ start = field.Type.End()
+ }
+
+ edits := make([]analysis.TextEdit, 0, 1+len(placement.anchors))
+
+ edits = append(edits, analysis.TextEdit{
+ Pos: start,
+ End: tag.End(),
+ NewText: []byte(newTag),
+ })
+
+ if tagValue != optionalTagValue {
+ return analysis.SuggestedFix{Message: fixMessage, TextEdits: edits}
+ }
+
+ // Where a line comment swallows nothing that matters, the directive takes
+ // the tag's place. The tag ends the line the declaration starts on, so that
+ // line holds every name it declares and the one anchor answers for all of
+ // them.
+ if placement.canAppend {
+ if !placement.anchors[0].optionalityDecided {
+ edits[0].NewText = []byte(appendedDirective(newTag, start == field.Type.End()))
+ }
+
+ return analysis.SuggestedFix{Message: fixMessage, TextEdits: edits}
+ }
+
+ // The directive takes a line of its own, and the name it precedes moves onto
+ // the next. A name that already begins its line needs no break in front;
+ // one sharing a line does, or the directive lands in the middle of it.
+ for _, a := range placement.anchors {
+ // A directive that already answers this name's optionality is the
+ // author's own answer, and a newer one than the tag: the tag reached v5
+ // inert, so removing it leaves that answer standing. Migrating on top of
+ // it would contradict it, or repeat it into a group the scanner then
+ // refuses to read.
+ if a.optionalityDecided {
+ continue
+ }
+
+ directiveLine := optionalDirective + "\n"
+ if !a.startsLine {
+ directiveLine = "\n" + directiveLine
+ }
+
+ edits = append(edits, analysis.TextEdit{
+ Pos: a.pos,
+ End: a.pos,
+ NewText: []byte(directiveLine),
+ })
+ }
+
+ return analysis.SuggestedFix{Message: fixMessage, TextEdits: edits}
+}
+
+// appendedDirective returns the text that takes a tag's place when the directive
+// is appended: what is left of the tag, then the directive, parted by a space
+// from whatever stands before it -- the tag's remainder, or the type where the
+// whitespace in front of the tag went with the tag.
+func appendedDirective(newTag string, afterType bool) string {
+ if newTag != "" || afterType {
+ return newTag + " " + optionalDirective
+ }
+
+ return optionalDirective
+}
+
+// tagPlacement records how a tagged field sits in its source. The visitor
+// reads the bytes and the directives; the fix reads only the relations they
+// answer.
+type tagPlacement struct {
+ // canAppend is true when the tag ends the line the field starts on, with
+ // nothing but whitespace after it. A line comment written there runs to
+ // the end of the line, so it takes anything else on it -- a field, the
+ // closing brace, a comment, a semicolon -- into its own text. A tag ending
+ // a later line of the field is no place for one either: a directive there
+ // targets that line, which is not the field's.
+ canAppend bool
+ // anchors names the positions a directive is inserted above: one for each
+ // line the declaration's names occupy, since field metadata is read at the
+ // line of each name and one directive reaches only the line it is written
+ // above.
+ anchors []nameAnchor
+ // gapBeforeTag is true when anything but whitespace stands between the
+ // field's type and its tag.
+ gapBeforeTag bool
+}
+
+// nameAnchor is a position a directive is inserted above, with whether the code
+// there already begins its line and whether a directive there already answers
+// the optionality of the name it precedes.
+type nameAnchor struct {
+ // pos is where the directive is written. It is the name's own position,
+ // except where a line directive stands above the name: the directive then
+ // goes in front of that line, which aboveLineDirective explains.
+ pos token.Pos
+ startsLine bool
+ // optionalityDecided records that a directive at the name already answers
+ // its optionality, so the migration writes none.
+ optionalityDecided bool
+ // sharesLineDirective records that a block line directive stands on the
+ // name's own line, which is what a comment written above the name moves it
+ // past.
+ sharesLineDirective bool
+}
+
+// movesALineDirective reports whether writing a directive above the names
+// would move one off the line a line directive pinned it to.
+func (p tagPlacement) movesALineDirective() bool {
+ for _, a := range p.anchors {
+ if a.sharesLineDirective && !a.optionalityDecided {
+ return true
+ }
+ }
+
+ return false
+}
+
+// nameAnchors lists one anchor for each line the declaration's names occupy.
+// One declaration can spread them over several lines, and each name carries
+// metadata of its own, down to the directive already written for it. A
+// declaration with no name -- an embedded field -- is its own single anchor.
+func (v *tagMigrationVisitor) nameAnchors(before token.Pos, field *ast.Field) []nameAnchor {
+ fset := v.pass.Fset
+
+ if len(field.Names) == 0 {
+ return []nameAnchor{v.anchorAt(before, field.Pos())}
+ }
+
+ anchors := make([]nameAnchor, 0, len(field.Names))
+ anchored := 0
+ prev := before
+
+ for _, name := range field.Names {
+ if line := astutil.PhysicalLine(fset, name.Pos()); line != anchored {
+ anchors = append(anchors, v.anchorAt(prev, name.Pos()))
+ anchored = line
+ }
+
+ prev = name.End()
+ }
+
+ return anchors
+}
+
+// anchorAt reads the anchor for the name at pos, which prev is the code before.
+//
+// The scanner resolves a directive to the line it targets, which is the answer
+// the checker itself acts on. Asking it, rather than the comments around the
+// name, keeps the two from disagreeing about whose directive a comment is. Only
+// optional and enforce answer optionality; an ignore reaching the line belongs
+// to the statement or the type around it, and field metadata reads neither of
+// those from it.
+func (v *tagMigrationVisitor) anchorAt(prev, pos token.Pos) nameAnchor {
+ fset := v.pass.Fset
+ o := v.processor.Directives().LookupPos(fset, pos).Optionality()
+ anchor, sharesLine := v.aboveLineDirective(pos)
+
+ return nameAnchor{
+ pos: anchor,
+ startsLine: astutil.PhysicalLine(fset, prev) != astutil.PhysicalLine(fset, pos),
+ optionalityDecided: o.Optional || o.Enforced,
+ sharesLineDirective: sharesLine,
+ }
+}
+
+// aboveLineDirective returns where a directive for the name at pos is written:
+// the start of the line directive standing above it, where there is one, and
+// pos itself otherwise.
+//
+// A line directive names the line that follows it. A directive written between
+// the two takes that line for itself and moves the name onto the next, which
+// renumbers what the generator pinned. Writing in front of the line directive
+// leaves the numbering as it stands, and the two comments form one group, which
+// the scanner reads for the code below it.
+func (v *tagMigrationVisitor) aboveLineDirective(pos token.Pos) (anchor token.Pos, sharesLine bool) {
+ fset := v.pass.Fset
+
+ f := fset.File(pos)
+ if f == nil {
+ return pos, false
+ }
+
+ src := v.source(pos)
+ if src == nil {
+ return pos, false
+ }
+
+ line := astutil.PhysicalLine(fset, pos)
+ lineStart := f.LineStart(line)
+
+ // The block form can stand on the name's own line, in front of it. The name
+ // then reads the line that directive names, and a comment written at the
+ // name takes that line for itself and moves the name off it.
+ if start, end := f.Offset(lineStart), f.Offset(pos); start >= 0 && end <= len(src) &&
+ onlyLineDirective(src[start:end]) {
+ return lineStart, true
+ }
+
+ // The first line of a file has nothing above it to read.
+ const firstLine = 1
+
+ if line <= firstLine {
+ return pos, false
+ }
+
+ above := f.LineStart(line - 1)
+
+ start, end := f.Offset(above), f.Offset(lineStart)
+ if start < 0 || end > len(src) {
+ return pos, false
+ }
+
+ // A line directive is read at the start of a line and nowhere else, so one
+ // written further along renumbers nothing.
+ if !isLineDirective(src[start:end]) {
+ return pos, false
+ }
+
+ return above, false
+}
+
+// isLineDirective reports whether line opens with a directive that renumbers
+// the source, in either of the two forms Go reads.
+func isLineDirective(line []byte) bool {
+ return bytes.HasPrefix(line, []byte("//line ")) || bytes.HasPrefix(line, []byte("/*line "))
+}
+
+// onlyLineDirective reports whether prefix holds a block line directive and
+// nothing else but whitespace. Only that form can stand on the same line as the
+// code it renumbers: the line form takes the rest of its line.
+func onlyLineDirective(prefix []byte) bool {
+ const opening, closing = "/*line ", "*/"
+
+ trimmed := bytes.TrimLeft(prefix, " \t")
+ if !bytes.HasPrefix(trimmed, []byte(opening)) {
+ return false
+ }
+
+ _, after, found := bytes.Cut(trimmed[len(opening):], []byte(closing))
+ if !found {
+ return false
+ }
+
+ return len(bytes.TrimLeft(after, " \t")) == 0
+}
+
+// placeTag reads the placement of the field at index i.
+func (v *tagMigrationVisitor) placeTag(st *ast.StructType, i int) tagPlacement {
+ field := st.Fields.List[i]
+ fset := v.pass.Fset
+
+ before := st.Fields.Opening
+ if i > 0 {
+ before = st.Fields.List[i-1].End()
+ }
+
+ src := v.source(field.Tag.Pos())
+ fieldLine := astutil.PhysicalLine(fset, field.Pos())
+
+ return tagPlacement{
+ canAppend: astutil.PhysicalLine(fset, field.Tag.End()) == fieldLine &&
+ restOfLineBlank(fset, src, field.Tag.End()),
+ anchors: v.nameAnchors(before, field),
+ gapBeforeTag: !spanBlank(fset, src, field.Type.End(), field.Tag.Pos()),
+ }
+}
+
+// source returns the bytes of the file pos belongs to, or nil when they cannot
+// be read. Every caller treats nil as "cannot tell" and takes its cautious
+// branch.
+func (v *tagMigrationVisitor) source(pos token.Pos) []byte {
+ name := astutil.PhysicalFilename(v.pass.Fset, pos)
+ if src, ok := v.sources[name]; ok {
+ return src
+ }
+
+ src, err := v.pass.ReadFile(name)
+ if err != nil {
+ src = nil
+ }
+
+ v.sources[name] = src
+
+ return src
+}
+
+// spanBlank reports whether the source between from and to holds nothing but
+// whitespace. The scan stops at the first byte that is not, so asking about
+// the rest of a line costs the gap in front of whatever comes next on it.
+func spanBlank(fset *token.FileSet, src []byte, from, to token.Pos) bool {
+ f := fset.File(from)
+ if f == nil || src == nil || to < from {
+ return false
+ }
+
+ start, end := f.Offset(from), f.Offset(to)
+ if start < 0 || end > len(src) {
+ return false
+ }
+
+ for _, b := range src[start:end] {
+ if !isGoSpace(b) {
+ return false
+ }
+ }
+
+ return true
+}
+
+// isGoSpace reports whether b is one of the four bytes Go reads as whitespace
+// between tokens.
+func isGoSpace(b byte) bool {
+ return b == ' ' || b == '\t' || b == '\r' || b == '\n'
+}
+
+// restOfLineBlank reports whether nothing but whitespace follows pos on its
+// line.
+func restOfLineBlank(fset *token.FileSet, src []byte, pos token.Pos) bool {
+ f := fset.File(pos)
+ if f == nil {
+ return false
+ }
+
+ // LineStart counts the lines of the file on disk, and PhysicalLine answers
+ // in the same count, so the number reads back into it.
+ if line := astutil.PhysicalLine(fset, pos); line < f.LineCount() {
+ return spanBlank(fset, src, pos, f.LineStart(line+1))
+ }
+
+ return spanBlank(fset, src, pos, f.Pos(f.Size()))
+}
+
+func removeExhaustructFromTag(tagLiteral string) string {
+ tag, err := strconv.Unquote(tagLiteral)
+ if err != nil {
+ return tagLiteral
+ }
+
+ // Only the ASCII space separates entries: reflect skips exactly that byte
+ // between them, and every byte above it belongs to the key it is reading.
+ // Trimming by Unicode would take a non-breaking space off a key and rename
+ // it.
+ tag = strings.Trim(cutTagEntries(tag, exhaustructTagKey), " ")
+ if tag == "" {
+ return ""
+ }
+
+ // Struct tags are conventionally raw strings, but not every tag reaches
+ // source as one. A backtick ends the literal, and an interpreted tag can
+ // decode to bytes no raw literal may hold at all -- a NUL from \x00, which
+ // the scanner rejects wherever it stands.
+ if strconv.CanBackquote(tag) {
+ return "`" + tag + "`"
+ }
+
+ return strconv.Quote(tag)
+}
+
+// cutTagEntries removes every entry named key from tag, leaving the rest byte
+// for byte as it stands. It reads the grammar reflect.StructTag reads, so that
+// removal and lookup agree on where an entry starts and ends. Lookup answers
+// with the first of two identical keys, so a fix that stopped at that one
+// would leave the field deprecated. The bytes past the point the tag stops
+// parsing have no structure to cut along, and stay.
+func cutTagEntries(tag, key string) string {
+ var kept strings.Builder
+
+ written := 0
+
+ for i := 0; i < len(tag); {
+ entryStart := i
+
+ entryKey, quote, ok := scanTagKey(tag, i)
+ if !ok {
+ break
+ }
+
+ end, ok := scanTagValue(tag, quote)
+ if !ok {
+ break
+ }
+
+ i = end
+
+ if entryKey == key {
+ // The space in front of the entry belongs to it, and dropping the
+ // entry without it would leave a gap twice as wide.
+ kept.WriteString(tag[written:entryStart])
+
+ written = i
+ }
+ }
+
+ if written == 0 {
+ return tag
+ }
+
+ kept.WriteString(tag[written:])
+
+ return kept.String()
+}
+
+// scanTagKey returns the key of the entry starting at i, along with the index
+// of the quote opening its value. It reports false when the bytes at i do not
+// spell a key and the quote that opens its value.
+func scanTagKey(tag string, i int) (key string, quote int, ok bool) {
+ for i < len(tag) && tag[i] == ' ' {
+ i++
+ }
+
+ start := i
+ for i < len(tag) && isTagKeyByte(tag[i]) {
+ i++
+ }
+
+ if i == start || i+1 >= len(tag) || tag[i] != ':' || tag[i+1] != '"' {
+ return "", 0, false
+ }
+
+ return tag[start:i], i + 1, true
+}
+
+// scanTagValue returns the index past the value that opens at quote. A
+// backslash escapes the byte after it, so an escaped quote does not end the
+// value.
+func scanTagValue(tag string, quote int) (end int, ok bool) {
+ for i := quote + 1; i < len(tag); i++ {
+ if tag[i] == '"' {
+ return i + 1, true
+ }
+
+ if tag[i] == '\\' {
+ i++
+ }
+ }
+
+ return 0, false
+}
+
+// isTagKeyByte reports whether b may appear in a tag key.
+func isTagKeyByte(b byte) bool {
+ return b > ' ' && b != ':' && b != '"' && b != 0x7f
+}
diff --git a/vendor/dev.gaijin.team/go/exhaustruct/v5/internal/astutil/file-parser.go b/vendor/dev.gaijin.team/go/exhaustruct/v5/internal/astutil/file-parser.go
new file mode 100644
index 0000000000..ebf5be22de
--- /dev/null
+++ b/vendor/dev.gaijin.team/go/exhaustruct/v5/internal/astutil/file-parser.go
@@ -0,0 +1,240 @@
+// Package astutil provides AST file parsing utilities for the analyzer.
+package astutil
+
+import (
+ "go/ast"
+ "go/build"
+ "go/parser"
+ "go/token"
+ "os"
+ "path/filepath"
+ "strings"
+ "sync"
+ "sync/atomic"
+
+ "dev.gaijin.team/go/golib/e"
+ "dev.gaijin.team/go/golib/fields"
+ "golang.org/x/tools/go/analysis"
+)
+
+type ParseCallback func(fset *token.FileSet, file *ast.File) []analysis.Diagnostic
+
+// FileParser orchestrates AST parsing by triggering registered callbacks.
+// Each file is processed only once.
+//
+// Safe for concurrent use.
+type FileParser struct {
+ mu sync.RWMutex //exhaustruct:optional
+ parsed map[string]bool
+ callbacks []ParseCallback //exhaustruct:optional
+ parseFlags parser.Mode //exhaustruct:optional
+ hits atomic.Uint64 //exhaustruct:optional
+ misses atomic.Uint64 //exhaustruct:optional
+}
+
+type Option func(*FileParser)
+
+// WithParseFlags sets parser flags for file parsing.
+// Default: parser.ParseComments | parser.SkipObjectResolution.
+func WithParseFlags(flags parser.Mode) Option {
+ return func(p *FileParser) { p.parseFlags = flags }
+}
+
+const parsedCachePrealloc = 64
+
+func NewFileParser(opts ...Option) *FileParser {
+ p := &FileParser{
+ parsed: make(map[string]bool, parsedCachePrealloc),
+ parseFlags: parser.ParseComments | parser.SkipObjectResolution,
+ }
+
+ for _, opt := range opts {
+ opt(p)
+ }
+
+ return p
+}
+
+func (p *FileParser) OnFileParsed(cb ParseCallback) {
+ p.callbacks = append(p.callbacks, cb)
+}
+
+// ProcessFiles triggers all callbacks for each provided AST file.
+// Already-parsed files are skipped.
+func (p *FileParser) ProcessFiles(fset *token.FileSet, files ...*ast.File) []analysis.Diagnostic {
+ var allDiags []analysis.Diagnostic
+
+ for _, file := range files {
+ filename := PhysicalFilename(fset, file.Pos())
+
+ p.mu.RLock()
+
+ alreadyParsed := p.parsed[filename]
+ p.mu.RUnlock()
+
+ if alreadyParsed {
+ p.hits.Add(1)
+
+ continue
+ }
+
+ p.mu.Lock()
+
+ if p.parsed[filename] {
+ p.mu.Unlock()
+ p.hits.Add(1)
+
+ continue
+ }
+
+ p.misses.Add(1)
+
+ for _, cb := range p.callbacks {
+ allDiags = append(allDiags, cb(fset, file)...)
+ }
+
+ p.parsed[filename] = true
+ p.mu.Unlock()
+ }
+
+ return allDiags
+}
+
+// PhysicalPosition returns the on-disk position of pos, ignoring //line
+// directives. Generated code routinely remaps positions onto a virtual file — a
+// template or a grammar — that holds no Go source and often does not exist at
+// all, so anything reading, keying, or comparing by position must ask for the
+// physical one.
+func PhysicalPosition(fset *token.FileSet, pos token.Pos) token.Position {
+ return fset.PositionFor(pos, false)
+}
+
+// PhysicalFilename returns the on-disk file a position belongs to.
+func PhysicalFilename(fset *token.FileSet, pos token.Pos) string {
+ return PhysicalPosition(fset, pos).Filename
+}
+
+// PhysicalLine returns the on-disk line a position sits on. A generator is free
+// to repeat one virtual line number, so lines compared as the same line -- and
+// the source bytes read at one -- have to be physical ones.
+func PhysicalLine(fset *token.FileSet, pos token.Pos) int {
+ return PhysicalPosition(fset, pos).Line
+}
+
+// ProcessFilename parses a file from disk and triggers all callbacks.
+// Returns nil if already processed, if the file belongs to the Go
+// distribution, or if it cannot be read or parsed.
+//
+// Not every filename reaching here names a readable Go file. -trimpath makes
+// the compiler record module-relative paths, and generated code remaps
+// positions onto templates and grammars; both arrive through export data and
+// resolve to nothing on disk.
+func (p *FileParser) ProcessFilename(fset *token.FileSet, filename string) []analysis.Diagnostic {
+ if isGoRootFile(filename) {
+ return nil
+ }
+
+ p.mu.RLock()
+
+ alreadyParsed := p.parsed[filename]
+ p.mu.RUnlock()
+
+ if alreadyParsed {
+ p.hits.Add(1)
+
+ return nil
+ }
+
+ p.mu.Lock()
+ defer p.mu.Unlock()
+
+ if p.parsed[filename] {
+ p.hits.Add(1)
+
+ return nil
+ }
+
+ p.misses.Add(1)
+
+ file, err := p.parse(fset, filename)
+ if err != nil {
+ // A definition file that cannot be read carries no directives anyone
+ // can act on. Reporting the failure would put a diagnostic with no
+ // usable position on a package that does not own the file, so treat it
+ // as directive-free instead.
+ p.parsed[filename] = true
+
+ return nil
+ }
+
+ var allDiags []analysis.Diagnostic
+
+ for _, cb := range p.callbacks {
+ allDiags = append(allDiags, cb(fset, file)...)
+ }
+
+ p.parsed[filename] = true
+
+ return allDiags
+}
+
+func (p *FileParser) Stats() (hits, misses, size uint64) {
+ p.mu.RLock()
+
+ size = uint64(len(p.parsed))
+
+ p.mu.RUnlock()
+
+ return p.hits.Load(), p.misses.Load(), size
+}
+
+// goRootPlaceholder is the literal prefix the compiler records instead of the
+// real GOROOT for files of the Go distribution, see cmd/internal/objabi.AbsFile.
+// Positions loaded from export data carry it as-is, so such paths can never be
+// opened.
+const goRootPlaceholder = "$GOROOT"
+
+// isGoRootFile reports whether filename belongs to the Go distribution. Its
+// sources carry no exhaustruct directives, so parsing them yields nothing and
+// their definitions are treated as directive-free.
+func isGoRootFile(filename string) bool {
+ return hasPathPrefix(filename, goRootPlaceholder) ||
+ hasPathPrefix(filename, build.Default.GOROOT)
+}
+
+// hasPathPrefix reports whether path starts with prefix at a path element
+// boundary. Separators are normalized, since the compiler records slashes on
+// every platform while GOROOT uses the native separator. An empty prefix, as
+// an unset or root GOROOT normalizes to, matches nothing rather than
+// everything.
+func hasPathPrefix(path, prefix string) bool {
+ prefix = strings.TrimSuffix(filepath.ToSlash(prefix), "/")
+ if prefix == "" {
+ return false
+ }
+
+ path = filepath.ToSlash(path)
+
+ if !strings.HasPrefix(path, prefix) {
+ return false
+ }
+
+ rest := path[len(prefix):]
+
+ return rest == "" || rest[0] == '/'
+}
+
+func (p *FileParser) parse(fset *token.FileSet, filename string) (*ast.File, error) {
+ //nolint:gosec // filename is derived from source code, not user input
+ content, err := os.ReadFile(filename)
+ if err != nil {
+ return nil, e.NewFrom("read file", err, fields.F("filename", filename))
+ }
+
+ file, err := parser.ParseFile(fset, filename, content, p.parseFlags)
+ if err != nil {
+ return nil, e.NewFrom("parse file", err, fields.F("filename", filename))
+ }
+
+ return file, nil
+}
diff --git a/vendor/dev.gaijin.team/go/exhaustruct/v5/internal/cache/cache.go b/vendor/dev.gaijin.team/go/exhaustruct/v5/internal/cache/cache.go
new file mode 100644
index 0000000000..4ebe311f0a
--- /dev/null
+++ b/vendor/dev.gaijin.team/go/exhaustruct/v5/internal/cache/cache.go
@@ -0,0 +1,169 @@
+// Package cache provides a generic thread-safe cache with hit/miss tracking.
+package cache
+
+import (
+ "sync"
+ "sync/atomic"
+)
+
+type Cache[K comparable, V any] struct {
+ entries map[K]V
+ // pending holds the keys a caller is computing. A second caller for one of
+ // them waits on it rather than computing again, and callers for other keys
+ // are not held up: the lock covers the maps, never the work.
+ pending map[K]*computation[V]
+ mu sync.RWMutex //exhaustruct:optional
+ hits atomic.Uint64 //exhaustruct:optional
+ misses atomic.Uint64 //exhaustruct:optional
+}
+
+// computation is one in-flight fill. The caller that opened it writes value,
+// marks it filled and closes done; every other caller reads both after done is
+// closed. A fill that panics closes done unfilled, and its waiters compute for
+// themselves.
+type computation[V any] struct {
+ done chan struct{}
+ value V //exhaustruct:optional
+ filled bool //exhaustruct:optional
+}
+
+func New[K comparable, V any](initialCapacity int) *Cache[K, V] {
+ return &Cache[K, V]{
+ entries: make(map[K]V, initialCapacity),
+ pending: make(map[K]*computation[V]),
+ }
+}
+
+func (c *Cache[K, V]) Get(key K) (v V, ok bool) {
+ c.mu.RLock()
+
+ v, ok = c.entries[key]
+
+ c.mu.RUnlock()
+
+ if ok {
+ c.hits.Add(1)
+ }
+
+ return v, ok
+}
+
+// Peek returns the value without updating hit/miss counters. Use it when the
+// caller has already recorded the miss that triggered the fill and a follow-up
+// read for the just-written entry must not inflate the hit rate.
+func (c *Cache[K, V]) Peek(key K) (v V, ok bool) {
+ c.mu.RLock()
+
+ v, ok = c.entries[key]
+
+ c.mu.RUnlock()
+
+ return v, ok
+}
+
+// Set stores value and increments miss counter (caller computed the value).
+func (c *Cache[K, V]) Set(key K, value V) {
+ c.mu.Lock()
+
+ c.entries[key] = value
+ c.misses.Add(1)
+
+ c.mu.Unlock()
+}
+
+// GetOrSet returns the value stored under key, computing it once when it is
+// absent. Callers racing for one key all receive the value that computation
+// published: what the first of them computed, or what a Set that landed while
+// it computed stored, since that Set is the later of the two writes. A Set
+// after the publication is later still and leaves what was returned as stale
+// as any Get result. Callers for other keys run alongside them, since compute
+// is never called with the cache locked.
+//
+// A compute that panics releases the key: the panic reaches its own caller, and
+// every caller waiting on that fill computes for itself. Nothing is stored for
+// the key until one of them returns.
+func (c *Cache[K, V]) GetOrSet(key K, compute func() V) V {
+ for {
+ // A filled key is the common answer and needs no more than the read lock
+ // a Get takes, which keys with nothing in common do not hold each other
+ // out of. The exclusive lock is for opening or joining a computation.
+ if v, ok := c.Get(key); ok {
+ return v
+ }
+
+ c.mu.Lock()
+
+ if v, ok := c.entries[key]; ok {
+ c.mu.Unlock()
+ c.hits.Add(1)
+
+ return v
+ }
+
+ if pending, ok := c.pending[key]; ok {
+ c.mu.Unlock()
+
+ <-pending.done
+
+ if pending.filled {
+ c.hits.Add(1)
+
+ return pending.value
+ }
+
+ continue
+ }
+
+ pending := &computation[V]{done: make(chan struct{})}
+
+ c.pending[key] = pending
+ c.misses.Add(1)
+
+ c.mu.Unlock()
+
+ return c.fill(key, pending, compute)
+ }
+}
+
+// fill computes the value claimed under key and publishes it. The claim is
+// released and done is closed whether compute returns or panics, so a fill that
+// panics leaves no waiter parked and no key claimed for good.
+func (c *Cache[K, V]) fill(key K, pending *computation[V], compute func() V) (v V) {
+ defer func() {
+ c.mu.Lock()
+
+ // A Set may have landed while the value was being computed. It is the
+ // later write of the two, and publishing over it would leave the key
+ // holding what neither order of the two produces.
+ if pending.filled {
+ if stored, ok := c.entries[key]; ok {
+ pending.value = stored
+ } else {
+ c.entries[key] = pending.value
+ }
+ }
+
+ delete(c.pending, key)
+
+ c.mu.Unlock()
+
+ close(pending.done)
+
+ v = pending.value
+ }()
+
+ pending.value = compute()
+ pending.filled = true
+
+ return pending.value
+}
+
+func (c *Cache[K, V]) Stats() (hits, misses, size uint64) {
+ c.mu.RLock()
+
+ size = uint64(len(c.entries))
+
+ c.mu.RUnlock()
+
+ return c.hits.Load(), c.misses.Load(), size
+}
diff --git a/vendor/dev.gaijin.team/go/exhaustruct/v5/internal/directive/directive.go b/vendor/dev.gaijin.team/go/exhaustruct/v5/internal/directive/directive.go
new file mode 100644
index 0000000000..0c7b148f2e
--- /dev/null
+++ b/vendor/dev.gaijin.team/go/exhaustruct/v5/internal/directive/directive.go
@@ -0,0 +1,183 @@
+package directive
+
+import (
+ "slices"
+ "strings"
+
+ "dev.gaijin.team/go/golib/e"
+)
+
+var (
+ ErrEmptyDirective = e.New("empty directive")
+ ErrUnknownDirective = e.New("unknown directive")
+ ErrDuplicateDirectives = e.New("duplicate directives")
+ ErrDirectiveAfterSpace = e.New("directive after a space is not read")
+)
+
+type Directive string
+
+const (
+ // Ignore skips checking for a specific struct literal.
+ Ignore Directive = "ignore"
+ // Enforce forces check even if type is excluded.
+ Enforce Directive = "enforce"
+ // Optional marks a field as optional.
+ Optional Directive = "optional"
+)
+
+func (d Directive) IsValid() bool {
+ switch d {
+ case Ignore, Enforce, Optional:
+ return true
+
+ default:
+ return false
+ }
+}
+
+// Directives represents a collection of directives for a single line.
+// Multiple directives can be specified comma-separated: //exhaustruct:enforce,optional.
+type Directives []Directive
+
+func (ds Directives) Contains(d Directive) bool {
+ return slices.Contains(ds, d)
+}
+
+// Optionality is what a field's directives say about whether a literal has to
+// write the field. These two are all that field metadata reads, so the order a
+// comment lists them in, and an ignore written beside them, leave two fields
+// annotated alike.
+type Optionality struct {
+ Optional bool
+ Enforced bool
+}
+
+// Optionality projects ds onto what field metadata reads. Every consumer of a
+// field's directives reads them through this, so none of them can drift from
+// the others.
+func (ds Directives) Optionality() Optionality {
+ return Optionality{
+ Optional: ds.Contains(Optional),
+ Enforced: ds.Contains(Enforce),
+ }
+}
+
+// directivePrefix is the exact prefix for exhaustruct directives.
+// Format: exhaustruct: [optional comment], written in either
+// comment form.
+const directivePrefix = "exhaustruct:"
+
+// commentBody strips the delimiters of either comment form, leaving the text a
+// directive may be written in. Both forms carry directives: a line comment
+// takes the rest of its line, while a block comment closes, so it can also sit
+// ahead of further code or another comment on the same line. In either form the
+// directive opens the comment, as //go:build does: a space after the delimiter
+// makes the comment prose.
+func commentBody(text string) string {
+ if body, ok := strings.CutPrefix(text, "//"); ok {
+ return body
+ }
+
+ if body, ok := strings.CutPrefix(text, "/*"); ok {
+ return strings.TrimSuffix(body, "*/")
+ }
+
+ return text
+}
+
+// prosePrefix is the set of bytes that end a directive list, leaving what
+// follows as prose.
+const prosePrefix = " \t\n"
+
+func Parse(text string) (found bool, result Directives, errs []error) {
+ text, found = strings.CutPrefix(commentBody(text), directivePrefix)
+ if !found {
+ return false, nil, nil
+ }
+
+ // Anything past the first space is prose, not part of the directive.
+ list, prose := text, ""
+ if idx := strings.IndexAny(text, prosePrefix); idx >= 0 {
+ list, prose = text[:idx], text[idx:]
+ }
+
+ if list == "" {
+ return true, nil, []error{ErrEmptyDirective}
+ }
+
+ result, errs = parseParts(list)
+
+ if len(result) == 0 {
+ result = nil
+
+ // Separators alone name no directive at all.
+ if len(errs) == 0 {
+ errs = append(errs, ErrEmptyDirective)
+ }
+ }
+
+ // A list ending in a separator that prose continues with a directive name
+ // is a list the author meant to go on. Read as prose, that name would be
+ // dropped in silence.
+ if strings.HasSuffix(list, ",") {
+ if word := Directive(firstWord(prose)); word.IsValid() {
+ errs = append(errs, ErrDirectiveAfterSpace.WithField("directive", word))
+ }
+ }
+
+ return true, result, errs
+}
+
+// firstWord returns the first word of prose, up to a space or a separator.
+func firstWord(prose string) string {
+ prose = strings.TrimLeft(prose, prosePrefix)
+
+ if idx := strings.IndexAny(prose, prosePrefix+","); idx >= 0 {
+ return prose[:idx]
+ }
+
+ return prose
+}
+
+// parseParts splits the comma-separated body of a directive into directives,
+// reporting the ones it does not recognise.
+func parseParts(text string) (Directives, []error) {
+ parts := strings.Split(text, ",")
+
+ var (
+ result = make(Directives, 0, len(parts))
+ errs []error
+ hasDups bool
+ )
+
+ for _, part := range parts {
+ // A trailing or doubled separator leaves an empty part behind; it names
+ // nothing, so there is nothing to report about it.
+ if part == "" {
+ continue
+ }
+
+ d := Directive(part)
+
+ if !d.IsValid() {
+ errs = append(errs, ErrUnknownDirective.WithField("directive", d))
+
+ continue
+ }
+
+ // giving the resulting size, linear search would be most efficient
+ if slices.Contains(result, d) {
+ hasDups = true
+
+ continue
+ }
+
+ result = append(result, d)
+ }
+
+ if hasDups {
+ errs = append(errs, ErrDuplicateDirectives)
+ }
+
+ return result, errs
+}
diff --git a/vendor/dev.gaijin.team/go/exhaustruct/v5/internal/directive/scanner.go b/vendor/dev.gaijin.team/go/exhaustruct/v5/internal/directive/scanner.go
new file mode 100644
index 0000000000..4c0668516d
--- /dev/null
+++ b/vendor/dev.gaijin.team/go/exhaustruct/v5/internal/directive/scanner.go
@@ -0,0 +1,377 @@
+package directive
+
+import (
+ "cmp"
+ "go/ast"
+ "go/token"
+ "slices"
+
+ "golang.org/x/tools/go/analysis"
+
+ "dev.gaijin.team/go/exhaustruct/v5/internal/astutil"
+ "dev.gaijin.team/go/exhaustruct/v5/internal/cache"
+)
+
+// Scanner provides thread-safe caching and lookup of file directives.
+type Scanner struct {
+ parser *astutil.FileParser
+ cache *cache.Cache[string, fileDirectives]
+ // diags holds the parse diagnostics of each file, keyed by physical
+ // filename. A file's diagnostics belong to the package that owns it, not to
+ // whichever package happened to trigger the parse first.
+ diags *cache.Cache[string, []fileDiagnostic]
+}
+
+// fileDiagnostic is one finding of a file, held without a token.Pos. A Pos is
+// an index into the FileSet that produced it and means another file, or
+// nothing, in any other. The file is parsed by whichever pass reaches it first
+// and reported by the one that owns it, and those two need not share a FileSet,
+// so the position is kept as an offset into the file and resolved again
+// against the FileSet the owner reports with.
+type fileDiagnostic struct {
+ offset int
+ message string
+}
+
+const cachePreallocSize = 64
+
+// NewScanner creates a new directive scanner that registers a callback
+// with the file parser to extract directives from parsed files.
+func NewScanner(parser *astutil.FileParser) *Scanner {
+ s := &Scanner{
+ parser: parser,
+ cache: cache.New[string, fileDirectives](cachePreallocSize),
+ diags: cache.New[string, []fileDiagnostic](cachePreallocSize),
+ }
+
+ parser.OnFileParsed(s.onFileParsed)
+
+ return s
+}
+
+func (s *Scanner) onFileParsed(fset *token.FileSet, file *ast.File) []analysis.Diagnostic {
+ filename := astutil.PhysicalFilename(fset, file.Pos())
+
+ fd, diags := s.parseFileDirectives(fset, file)
+
+ s.cache.Set(filename, fd)
+ s.diags.Set(filename, offsetDiagnostics(fset, diags))
+
+ return diags
+}
+
+// offsetDiagnostics keeps what a diagnostic says and where it says it, with the
+// position taken as an offset into its file.
+func offsetDiagnostics(fset *token.FileSet, diags []analysis.Diagnostic) []fileDiagnostic {
+ held := make([]fileDiagnostic, 0, len(diags))
+
+ for _, d := range diags {
+ f := fset.File(d.Pos)
+ if f == nil {
+ continue
+ }
+
+ held = append(held, fileDiagnostic{offset: f.Offset(d.Pos), message: d.Message})
+ }
+
+ return held
+}
+
+// ProcessFiles pre-populates the cache by delegating to FileParser.ProcessFiles,
+// and returns the directive diagnostics of exactly the given files.
+//
+// The diagnostics come from the per-file cache rather than from this parse, so a
+// file reports its own findings even when an earlier lookup from another package
+// already parsed it.
+func (s *Scanner) ProcessFiles(fset *token.FileSet, files ...*ast.File) []analysis.Diagnostic {
+ s.parser.ProcessFiles(fset, files...)
+
+ var diags []analysis.Diagnostic
+
+ for _, file := range files {
+ held, ok := s.diags.Peek(astutil.PhysicalFilename(fset, file.Pos()))
+ if !ok {
+ continue
+ }
+
+ f := fset.File(file.Pos())
+ if f == nil {
+ continue
+ }
+
+ for _, d := range held {
+ if d.offset < 0 || d.offset > f.Size() {
+ continue
+ }
+
+ diags = append(diags, analysis.Diagnostic{
+ Pos: f.Pos(d.offset),
+ Message: d.message,
+ })
+ }
+ }
+
+ return diags
+}
+
+// LookupPos returns the directives written at the line of pos, read from the
+// physical file whatever a //line directive renames it to.
+//
+// A caller holding a token.Pos reaches the directives this way. token.Position
+// carries no sign of whether it was adjusted, so a lookup made with an adjusted
+// one finds nothing and says nothing about it.
+func (s *Scanner) LookupPos(fset *token.FileSet, pos token.Pos) Directives {
+ return s.Lookup(fset, astutil.PhysicalPosition(fset, pos))
+}
+
+// Lookup returns the directives at the given source position, which must be
+// unadjusted — see astutil.PhysicalFilename. Use LookupPos where the caller
+// holds a token.Pos. If the file is not in cache, triggers
+// FileParser.ProcessFilename to parse it.
+//
+// Diagnostics found by such an on-demand parse are not returned: the file
+// belongs to another package, which reports them through ProcessFiles.
+func (s *Scanner) Lookup(fset *token.FileSet, pos token.Position) Directives {
+ if pos.Filename == "" {
+ return nil
+ }
+
+ if fd, ok := s.cache.Get(pos.Filename); ok {
+ return fd[pos.Line]
+ }
+
+ // Cache miss - parse file (triggers onFileParsed callback, which stores
+ // the result via cache.Set and increments the miss counter).
+ s.parser.ProcessFilename(fset, pos.Filename)
+
+ // Peek avoids counting this self-induced read as a hit — the miss was
+ // already recorded by Set above.
+ if fd, ok := s.cache.Peek(pos.Filename); ok {
+ return fd[pos.Line]
+ }
+
+ // Still not in cache means parsing failed.
+ return nil
+}
+
+func (s *Scanner) Stats() (hits, misses, size uint64) {
+ return s.cache.Stats()
+}
+
+// fileDirectives holds directives found in a single file, indexed by line number.
+type fileDirectives map[int]Directives
+
+// parseFileDirectives parses an AST file and extracts all exhaustruct directives.
+// Returns diagnostics in case file parsing errors, directive parsing errors, or
+// conflicting directives for the same target line.
+func (*Scanner) parseFileDirectives(fset *token.FileSet, file *ast.File) (fileDirectives, []analysis.Diagnostic) {
+ directives, diagnostics := parseCommentDirectives(fset, file.Comments)
+
+ if len(directives) == 0 {
+ return nil, diagnostics
+ }
+
+ retargetInline(directives, codeLines(fset, file, commentLines(directives)))
+
+ result, conflicts := reduceByTarget(directives)
+
+ return result, append(diagnostics, conflicts...)
+}
+
+// commentLines lists the lines of a directive comment that code can share.
+// Only these are ever asked of the code lines, so a file's whole line table
+// need not be built to answer them.
+//
+// A comment holds every line between its first and its last, so code reaches
+// only those two: one before the comment opens, the other after it closes.
+func commentLines(directives map[int][]parsedDirective) map[int]bool {
+ lines := make(map[int]bool, len(directives))
+
+ for _, ds := range directives {
+ for _, d := range ds {
+ for _, line := range d.sharableLines() {
+ lines[line] = true
+ }
+ }
+ }
+
+ return lines
+}
+
+// codeLines maps each line of file that carries code and is asked about to the
+// line a directive beside it targets, which is what tells such a directive from
+// one written on a line of its own.
+//
+// A line usually targets itself. The line a multiline construct closes on holds
+// no node that starts there, and targets the line the construct opened on
+// instead: that is the line a lookup asks for the construct by, so a directive
+// written beside the closing token reaches it. Constructs closing on one line
+// are nested, and the innermost is the one the directive stands beside, so the
+// latest opening line wins. A line that opens something of its own still
+// targets itself, which no opening line above it can outrank.
+func codeLines(fset *token.FileSet, file *ast.File, asked map[int]bool) map[int]int {
+ lines := make(map[int]int, len(asked))
+
+ ast.Inspect(file, func(n ast.Node) bool {
+ switch n.(type) {
+ case nil, *ast.Comment, *ast.CommentGroup:
+ return false
+ }
+
+ start := astutil.PhysicalLine(fset, n.Pos())
+
+ if end := astutil.PhysicalLine(fset, n.End()); end != start && asked[end] {
+ if target, taken := lines[end]; !taken || start > target {
+ lines[end] = start
+ }
+ }
+
+ if asked[start] {
+ lines[start] = start
+ }
+
+ return true
+ })
+
+ return lines
+}
+
+// retargetInline points a directive that shares a line with code at that line.
+// One whose comment stands alone keeps the line below, which it already
+// carries. A block comment spans lines and code can sit against either end of
+// it, so every line it covers is asked.
+func retargetInline(directives map[int][]parsedDirective, codeLines map[int]int) {
+ for _, ds := range directives {
+ for i := range ds {
+ if line, ok := ds[i].codeLine(codeLines); ok {
+ ds[i].targetLine = line
+ }
+ }
+ }
+}
+
+// reduceByTarget keeps one directive set for each target line -- the first
+// written -- and reports every other directive aimed at that line as a
+// conflict.
+func reduceByTarget(directives map[int][]parsedDirective) (fileDirectives, []analysis.Diagnostic) {
+ byTarget := make(map[int][]parsedDirective, len(directives))
+
+ for _, ds := range directives {
+ for _, d := range ds {
+ byTarget[d.targetLine] = append(byTarget[d.targetLine], d)
+ }
+ }
+
+ var diagnostics []analysis.Diagnostic
+
+ result := make(fileDirectives, len(byTarget))
+
+ for target, ds := range byTarget {
+ slices.SortFunc(ds, func(a, b parsedDirective) int {
+ return cmp.Compare(a.pos, b.pos)
+ })
+
+ result[target] = ds[0].directives
+
+ for _, d := range ds[1:] {
+ diagnostics = append(diagnostics, analysis.Diagnostic{
+ Pos: d.pos,
+ Message: "directive ignored, conflicting directive already exists for the same target line",
+ })
+ }
+ }
+
+ return result, diagnostics
+}
+
+type parsedDirective struct {
+ pos token.Pos
+ // line and endLine bound the comment the directive is written in. A line
+ // comment occupies one line; a block comment covers a range, and code
+ // beside any line of it makes the directive inline with that code.
+ line int
+ endLine int
+ targetLine int
+ directives Directives
+}
+
+// codeLine returns what the first line of the directive's comment that carries
+// code targets.
+func (d parsedDirective) codeLine(codeLines map[int]int) (int, bool) {
+ for _, line := range d.sharableLines() {
+ if target, ok := codeLines[line]; ok {
+ return target, true
+ }
+ }
+
+ return 0, false
+}
+
+// sharableLines returns the lines of the directive's comment that code can
+// share: the one it is written on and the one its comment closes on, which are
+// one line for a line comment.
+func (d parsedDirective) sharableLines() [2]int {
+ return [2]int{d.line, d.endLine}
+}
+
+func parseCommentDirectives(
+ fset *token.FileSet,
+ comments []*ast.CommentGroup,
+) (map[int][]parsedDirective, []analysis.Diagnostic) {
+ var (
+ // Keyed by the line the directive is written on, and holding every
+ // directive on it: two comment groups can share one line, and both
+ // reach the reduction by target line.
+ directives = make(map[int][]parsedDirective)
+ diagnostics []analysis.Diagnostic
+ )
+
+ for _, cg := range comments {
+ hasDirective := false
+
+ for _, comment := range cg.List {
+ found, parsed, errs := Parse(comment.Text)
+ if !found {
+ continue
+ }
+
+ pos := comment.Pos()
+
+ for _, err := range errs {
+ diagnostics = append(diagnostics, analysis.Diagnostic{
+ Pos: pos,
+ Message: err.Error(),
+ })
+ }
+
+ if len(parsed) == 0 {
+ continue
+ }
+
+ if hasDirective {
+ diagnostics = append(diagnostics, analysis.Diagnostic{
+ Pos: pos,
+ Message: "multiple exhaustruct directives in a single comment group, ignoring",
+ })
+
+ continue
+ }
+
+ hasDirective = true
+
+ line := astutil.PhysicalLine(fset, pos)
+
+ directives[line] = append(directives[line], parsedDirective{
+ pos: pos,
+ line: line,
+ endLine: astutil.PhysicalLine(fset, comment.End()),
+ // The whole group carries the directive down to the code, so a
+ // note written under it does not cut the reach short.
+ targetLine: astutil.PhysicalLine(fset, cg.End()) + 1,
+ directives: parsed,
+ })
+ }
+ }
+
+ return directives, diagnostics
+}
diff --git a/vendor/dev.gaijin.team/go/exhaustruct/v5/internal/pattern/list.go b/vendor/dev.gaijin.team/go/exhaustruct/v5/internal/pattern/list.go
new file mode 100644
index 0000000000..6f55559eb4
--- /dev/null
+++ b/vendor/dev.gaijin.team/go/exhaustruct/v5/internal/pattern/list.go
@@ -0,0 +1,96 @@
+package pattern
+
+import (
+ "regexp"
+
+ "dev.gaijin.team/go/golib/e"
+ "dev.gaijin.team/go/golib/fields"
+)
+
+// List is a collection of compiled regular expressions.
+type List []*regexp.Regexp
+
+// NewList compiles patterns into a List.
+// Returns error if any pattern is empty or invalid.
+func NewList(patterns ...string) (List, error) {
+ if len(patterns) == 0 {
+ return nil, nil
+ }
+
+ list := make(List, 0, len(patterns))
+
+ for _, pattern := range patterns {
+ re, err := compilePattern(pattern)
+ if err != nil {
+ return nil, err
+ }
+
+ list = append(list, re)
+ }
+
+ return list, nil
+}
+
+// MatchFullString returns true if any regex matches the entire string.
+// Pattern "test" matches "test" but not "testing" or "contest".
+func (l List) MatchFullString(target string) bool {
+ for i := range len(l) {
+ if matchesFull(l[i], target) {
+ return true
+ }
+ }
+
+ return false
+}
+
+// MatchFullStringExcept returns true if any regex matches the entire target
+// without also matching the whole of excepted.
+//
+// A pattern broad enough to select both selects neither of them in particular,
+// which is what tells a rule written for one of the two from one that reaches
+// it through the other.
+func (l List) MatchFullStringExcept(target, excepted string) bool {
+ for i := range len(l) {
+ if matchesFull(l[i], target) && !matchesFull(l[i], excepted) {
+ return true
+ }
+ }
+
+ return false
+}
+
+// matchesFull reports whether re matches the whole of target.
+//
+// A match spanning [0, len(target)) covers every byte of target, so the matched
+// substring is target itself -- no need to allocate it for comparison. Patterns
+// match leftmost-longest, so the span of the match found at 0 is the longest
+// one there is.
+func matchesFull(re *regexp.Regexp, target string) bool {
+ loc := re.FindStringIndex(target)
+
+ return loc != nil && loc[0] == 0 && loc[1] == len(target)
+}
+
+func compilePattern(pattern string) (*regexp.Regexp, error) {
+ if pattern == "" {
+ return nil, e.New("empty regular expression is not allowed")
+ }
+
+ re, err := regexp.Compile(pattern)
+ if err != nil {
+ return nil, e.NewFrom("compile regular expression", err, fields.F("pattern", pattern))
+ }
+
+ // Match leftmost-longest. The default is leftmost-first, under which
+ // `.*\.(Config|ConfigOption)` commits to the Config branch against
+ // "pkg.ConfigOption" and stops short of the end, so testing the span of the
+ // match rejects a pattern that does match the whole string. The longest
+ // match at position 0 spans the target whenever any match does.
+ //
+ // The pattern is compiled as the author wrote it. Wrapping it to anchor
+ // would put the author's own anchors inside a group and make what a pattern
+ // means depend on how it is written.
+ re.Longest()
+
+ return re, nil
+}
diff --git a/vendor/dev.gaijin.team/go/exhaustruct/v5/internal/structure/processor.go b/vendor/dev.gaijin.team/go/exhaustruct/v5/internal/structure/processor.go
new file mode 100644
index 0000000000..483e5214a1
--- /dev/null
+++ b/vendor/dev.gaijin.team/go/exhaustruct/v5/internal/structure/processor.go
@@ -0,0 +1,351 @@
+package structure
+
+import (
+ "go/token"
+ "go/types"
+
+ "dev.gaijin.team/go/exhaustruct/v5/internal/astutil"
+ "dev.gaijin.team/go/exhaustruct/v5/internal/cache"
+ "dev.gaijin.team/go/exhaustruct/v5/internal/directive"
+ "dev.gaijin.team/go/exhaustruct/v5/internal/pattern"
+)
+
+// structKey identifies a struct type in the struct cache.
+//
+// A source position cannot serve as that identity. Export data is not required
+// to carry a faithful one: gcimporter discards the column outright and clamps
+// any line past 64Ki to 1, so distinct declarations inside one dependency file
+// collapse onto a single token.Position. go/types objects, in contrast, are
+// unique per declaration per loaded package.
+type structKey struct {
+ // name is the type's TypeName, nil for anonymous structs.
+ name *types.TypeName
+ // strct is the underlying struct type. It alone identifies an anonymous
+ // struct, and guards against a shared TypeName for a named one.
+ strct *types.Struct
+ // callerPkg is set for anonymous structs only, whose metadata is derived
+ // from the package that uses them. Named types are caller-independent and
+ // share one entry across every package that references them.
+ callerPkg *types.Package
+}
+
+type Processor struct {
+ directives *directive.Scanner
+ fieldsCache *cache.Cache[*types.Struct, *structFields]
+ structCache *cache.Cache[structKey, *Struct]
+
+ enforce pattern.List //exhaustruct:optional
+ ignore pattern.List //exhaustruct:optional
+ optional pattern.List //exhaustruct:optional
+ allowEmpty pattern.List //exhaustruct:optional
+}
+
+type Option func(*Processor)
+
+func WithEnforce(patterns pattern.List) Option {
+ return func(p *Processor) { p.enforce = patterns }
+}
+
+func WithIgnore(patterns pattern.List) Option {
+ return func(p *Processor) { p.ignore = patterns }
+}
+
+func WithOptional(patterns pattern.List) Option {
+ return func(p *Processor) { p.optional = patterns }
+}
+
+func WithAllowEmpty(patterns pattern.List) Option {
+ return func(p *Processor) { p.allowEmpty = patterns }
+}
+
+const cachePreallocSize = 64
+
+func NewProcessor(directives *directive.Scanner, opts ...Option) *Processor {
+ p := &Processor{
+ directives: directives,
+ fieldsCache: cache.New[*types.Struct, *structFields](cachePreallocSize),
+ structCache: cache.New[structKey, *Struct](cachePreallocSize),
+ }
+
+ for _, opt := range opts {
+ opt(p)
+ }
+
+ return p
+}
+
+// Directives returns the directive scanner the processor was constructed
+// with, shared so callers can resolve use-site directives against the same
+// cache.
+func (p *Processor) Directives() *directive.Scanner {
+ return p.directives
+}
+
+// ResolveStruct returns Struct metadata for the given type.
+// Type resolution (pointers, aliases) is done by the caller.
+//
+// Parameters:
+// - typeName: the type's TypeName, or nil for anonymous structs
+// - strct: the underlying struct type (required)
+// - pos: position of type definition (from analyzer's AST inspection)
+// - callerPkg: package context, used for anonymous struct path
+func (p *Processor) ResolveStruct(
+ fset *token.FileSet,
+ typeName *types.TypeName,
+ strct *types.Struct,
+ pos token.Pos,
+ callerPkg *types.Package,
+) *Struct {
+ if strct == nil {
+ return nil
+ }
+
+ key := structKey{name: typeName, strct: strct, callerPkg: nil}
+ if typeName == nil {
+ key.callerPkg = callerPkg
+ }
+
+ // One entry per key, filled once: passes run concurrently, and two of them
+ // racing to build the same type would each pay for it and each hold a
+ // value the other does not.
+ return p.structCache.GetOrSet(key, func() *Struct {
+ s := p.buildStruct(typeName, astutil.PhysicalPosition(fset, pos), callerPkg)
+
+ p.populateFields(fset, s, strct)
+ p.resolveStructDirectives(fset, s)
+ p.matchStructPatterns(s)
+
+ return s
+ })
+}
+
+// buildStruct creates Struct metadata from type info.
+func (*Processor) buildStruct(typeName *types.TypeName, pos token.Position, callerPkg *types.Package) *Struct {
+ if typeName != nil {
+ pkg := typeName.Pkg()
+
+ return &Struct{
+ Name: typeName.Name(),
+ FullPath: pkg.Path() + "." + typeName.Name(),
+ PackageName: pkg.Name(),
+ Position: pos,
+ }
+ }
+
+ // Anonymous struct
+ return &Struct{
+ Name: AnonymousName,
+ FullPath: callerPkg.Path() + "." + AnonymousName,
+ PackageName: callerPkg.Name(),
+ Position: pos,
+ }
+}
+
+// getStructFields returns the raw field data of strct, from the cache when it
+// is there.
+func (p *Processor) getStructFields(fset *token.FileSet, strct *types.Struct) *structFields {
+ if fields, ok := p.fieldsCache.Get(strct); ok {
+ return fields
+ }
+
+ fields := p.resolveStructFields(fset, strct)
+
+ p.fieldsCache.Set(strct, fields)
+
+ return fields
+}
+
+func (p *Processor) resolveStructFields(fset *token.FileSet, strct *types.Struct) *structFields {
+ result := &structFields{
+ strct: strct,
+ packagePath: "",
+ fields: make([]fieldInfo, 0, strct.NumFields()),
+ }
+
+ for f := range strct.Fields() {
+ if result.packagePath == "" && f.Pkg() != nil {
+ result.packagePath = f.Pkg().Path()
+ }
+
+ field := fieldInfo{
+ name: f.Name(),
+ exported: f.Exported(),
+ }
+
+ if f.Embedded() {
+ if embedded, ok := embeddedStruct(f.Type()); ok {
+ field.embedded = p.getStructFields(fset, embedded)
+ }
+ }
+
+ if p.directives != nil {
+ o := p.directives.LookupPos(fset, f.Pos()).Optionality()
+
+ field.enforced = o.Enforced
+ field.optional = o.Optional
+ }
+
+ result.fields = append(result.fields, field)
+ }
+
+ return result
+}
+
+func (p *Processor) populateFields(fset *token.FileSet, s *Struct, strct *types.Struct) {
+ s.Fields = p.buildFields(s, p.getStructFields(fset, strct))
+
+ s.Fields.paths = indexPromotion(&s.Fields)
+}
+
+// buildFields turns resolved field data into the Struct's own view of it,
+// applying pattern matching and access filtering. Embedded structs are built
+// too, since a literal may name their fields directly.
+//
+// Fields are external when declared in a different package than the struct type.
+// This happens for derived types and aliases from external packages.
+//
+// Rationale behind that filtering is that noone except package that has declared
+// the struct can access unexported fields, therefore we can simply filter them
+// out to save up on storage. Usage of derived type from the package of structure
+// definition is simply impossible since it will cause import cycle - thus, such
+// filtering is safe. An unexported embedded field is the exception, since a
+// literal reaches the exported fields it promotes.
+//
+// The walk runs level by level and opens each struct once, at the depth it is
+// first reached and only where it is reached once. Go resolves a promoted name
+// to its shallowest occurrence and to none at all where two occurrences share a
+// depth, so every other reach promotes nothing a literal can write. Opening
+// them all would cost one subtree per path through the embedding graph, which
+// doubles with every layer that reaches the one below it twice.
+func (p *Processor) buildFields(s *Struct, resolved *structFields) Fields {
+ root, pending := p.levelFields(s, resolved)
+ opened := map[*types.Struct]bool{resolved.strct: true}
+
+ for level := attribute(&root, pending); len(level) > 0; {
+ occurrences := make(map[*types.Struct]int, len(level))
+
+ for _, e := range level {
+ occurrences[e.resolved.strct]++
+ }
+
+ var next []embeddedField
+
+ for _, e := range level {
+ if opened[e.resolved.strct] || occurrences[e.resolved.strct] > 1 {
+ continue
+ }
+
+ opened[e.resolved.strct] = true
+
+ sub, below := p.levelFields(s, e.resolved)
+
+ e.owner.Items[e.index].Embedded = &sub
+ next = append(next, attribute(&sub, below)...)
+ }
+
+ for r := range occurrences {
+ opened[r] = true
+ }
+
+ level = next
+ }
+
+ return root
+}
+
+// embeddedField is one embedded struct waiting to be opened, and the field of
+// an already built level that holds it.
+type embeddedField struct {
+ owner *Fields
+ index int
+ resolved *structFields
+}
+
+// attribute names owner as the level the pending fields belong to.
+func attribute(owner *Fields, pending []embeddedField) []embeddedField {
+ for i := range pending {
+ pending[i].owner = owner
+ }
+
+ return pending
+}
+
+// levelFields builds the fields of one struct, without opening the structs it
+// embeds, which it returns instead.
+func (p *Processor) levelFields(s *Struct, resolved *structFields) (Fields, []embeddedField) {
+ fieldsExternal := resolved.packagePath != s.PackagePath()
+
+ fields := Fields{
+ PackagePath: resolved.packagePath,
+ Items: make([]Field, 0, len(resolved.fields)),
+ paths: nil,
+ }
+
+ var pending []embeddedField
+
+ for _, sf := range resolved.fields {
+ // An unexported field declared in another package can never be written
+ // here. An embedded one is still kept: a literal reaches the exported
+ // fields under it by promotion, and the embedded field itself stays
+ // unreported, since nothing may require what nobody can write.
+ if fieldsExternal && !sf.exported && sf.embedded == nil {
+ continue
+ }
+
+ // Promoted fields are addressed by the name a literal of s writes, so
+ // every level shares the outer type's path.
+ fieldPath := s.FullPath + "#" + sf.name
+
+ fields.Items = append(fields.Items, Field{
+ Name: sf.name,
+ Exported: sf.exported,
+ Enforced: sf.enforced,
+ Optional: sf.optional,
+ PatternEnforced: p.enforce.MatchFullStringExcept(fieldPath, s.FullPath),
+ PatternOptional: p.optional.MatchFullStringExcept(fieldPath, s.FullPath),
+ Embedded: nil,
+ })
+
+ if sf.embedded != nil {
+ pending = append(pending, embeddedField{
+ owner: nil,
+ index: len(fields.Items) - 1,
+ resolved: sf.embedded,
+ })
+ }
+ }
+
+ return fields, pending
+}
+
+// embeddedStruct returns the struct type an embedded field promotes fields
+// from. Embedded pointers yield nothing: a composite literal cannot reach
+// through them, so their fields are not promotable in this context.
+func embeddedStruct(typ types.Type) (*types.Struct, bool) {
+ strct, ok := types.Unalias(typ).Underlying().(*types.Struct)
+
+ return strct, ok
+}
+
+func (p *Processor) resolveStructDirectives(fset *token.FileSet, s *Struct) {
+ if p.directives == nil || !s.Position.IsValid() {
+ return
+ }
+
+ dirs := p.directives.Lookup(fset, s.Position)
+
+ s.Enforced = dirs.Contains(directive.Enforce)
+ s.Ignored = dirs.Contains(directive.Ignore)
+ s.Optional = dirs.Contains(directive.Optional)
+}
+
+func (p *Processor) matchStructPatterns(s *Struct) {
+ s.PatternEnforced = p.enforce.MatchFullString(s.FullPath)
+ s.PatternIgnored = p.ignore.MatchFullString(s.FullPath)
+ s.PatternOptional = p.optional.MatchFullString(s.FullPath)
+ s.AllowEmptyDecl = p.allowEmpty.MatchFullString(s.FullPath)
+}
+
+func (p *Processor) Stats() (hits, misses, size uint64) {
+ return p.structCache.Stats()
+}
diff --git a/vendor/dev.gaijin.team/go/exhaustruct/v5/internal/structure/struct.go b/vendor/dev.gaijin.team/go/exhaustruct/v5/internal/structure/struct.go
new file mode 100644
index 0000000000..48b5a04cf8
--- /dev/null
+++ b/vendor/dev.gaijin.team/go/exhaustruct/v5/internal/structure/struct.go
@@ -0,0 +1,570 @@
+package structure
+
+import (
+ "go/ast"
+ "go/token"
+ "go/types"
+ "strings"
+)
+
+const AnonymousName = ""
+
+// BlankFieldName is the name go/types gives a blank struct field.
+const BlankFieldName = "_"
+
+// fieldInfo contains raw field data independent of type name.
+type fieldInfo struct {
+ // name is the name of the field.
+ name string
+ // exported indicates if the field is exported.
+ exported bool //exhaustruct:optional
+ // enforced indicates if the field is enforced via directive.
+ enforced bool //exhaustruct:optional
+ // optional indicates if the field is optional via directive.
+ optional bool //exhaustruct:optional
+ // embedded holds the fields an embedded field promotes, nil otherwise.
+ embedded *structFields //exhaustruct:optional
+}
+
+// structFields contains field information for a struct, independent of type name.
+type structFields struct {
+ // strct is the type this field data was read from, and the identity the
+ // promotion walk prunes by. A cached value would answer as well only while
+ // one goroutine fills the cache: two passes missing at once each build a
+ // value of their own, and one struct reached through two of them would then
+ // read as two.
+ strct *types.Struct
+ // packagePath is the package path where fields are declared.
+ packagePath string
+ // fields is the list of fields in declaration order.
+ fields []fieldInfo
+}
+
+type Struct struct {
+ Name string
+ FullPath string
+ PackageName string
+
+ Position token.Position //exhaustruct:optional
+ Fields Fields //exhaustruct:optional
+
+ Enforced bool //exhaustruct:optional
+ Ignored bool //exhaustruct:optional
+ Optional bool //exhaustruct:optional
+
+ PatternEnforced bool //exhaustruct:optional
+ PatternIgnored bool //exhaustruct:optional
+ PatternOptional bool //exhaustruct:optional
+
+ AllowEmptyDecl bool //exhaustruct:optional
+}
+
+// PackagePath returns the package path of the struct type.
+func (s *Struct) PackagePath() string {
+ if idx := strings.LastIndex(s.FullPath, "."); idx >= 0 {
+ return s.FullPath[:idx]
+ }
+
+ return s.FullPath
+}
+
+// IsEnforced returns true if struct is enforced via directive or pattern.
+func (s *Struct) IsEnforced() bool {
+ return s.Enforced || s.PatternEnforced
+}
+
+// IsIgnored returns true if struct is ignored via directive or pattern.
+func (s *Struct) IsIgnored() bool {
+ return s.Ignored || s.PatternIgnored
+}
+
+// IsOptional returns true if struct is optional via directive or pattern.
+func (s *Struct) IsOptional() bool {
+ return s.Optional || s.PatternOptional
+}
+
+// SkippedFields returns missing required fields for a composite literal.
+// callerPkgPath is used to determine if unexported fields are accessible.
+// canNamePromoted tells whether the literal may write a promoted field as a key,
+// which Go permits since 1.27 (golang/go#77245).
+// For positional literals: returns fields after the last provided element.
+// For named literals: returns fields not present in the literal.
+func (s *Struct) SkippedFields(lit *ast.CompositeLit, callerPkgPath string, canNamePromoted bool) []Field {
+ // An empty literal supplies nothing and can still be written in either
+ // form, so it is read as a keyed literal with no keys. The two then answer
+ // alike: neither can name a blank field, and both reach a field enforced
+ // under an embedded one.
+ if isNamedLiteral(lit) || len(lit.Elts) == 0 {
+ return s.skippedNamed(lit, callerPkgPath, canNamePromoted)
+ }
+
+ return s.skippedPositional(len(lit.Elts), s.Fields.PackagePath != callerPkgPath)
+}
+
+// isNamedLiteral checks if a composite literal uses named fields. It treats
+// empty literals as not named, since positional literals checks are simpler.
+func isNamedLiteral(lit *ast.CompositeLit) bool {
+ if len(lit.Elts) == 0 {
+ return false
+ }
+
+ _, ok := lit.Elts[0].(*ast.KeyValueExpr)
+
+ return ok
+}
+
+func (s *Struct) skippedPositional(count int, externalPkg bool) []Field {
+ items := s.Fields.Items
+
+ if count >= len(items) {
+ return nil
+ }
+
+ remaining := items[count:]
+ missing := make([]Field, 0, len(remaining))
+
+ for _, f := range remaining {
+ if s.isFieldRequired(f, externalPkg) {
+ missing = append(missing, f)
+ }
+ }
+
+ if len(missing) == 0 {
+ return nil
+ }
+
+ return missing
+}
+
+func (s *Struct) skippedNamed(lit *ast.CompositeLit, callerPkgPath string, canNamePromoted bool) []Field {
+ groups := s.Fields.groupKeys(lit, callerPkgPath, canNamePromoted)
+
+ // Capacity is a hint, not a contract: a key may name a field absent from
+ // Items, since unexported fields are pruned for types whose fields come
+ // from another package. Clamp so a mismatch can never turn into a makeslice
+ // panic.
+ missing := make([]Field, 0, max(len(s.Fields.Items)-groups.namedCount(), 0))
+
+ missing = s.skippedIn(&s.Fields, groups, callerPkgPath, canNamePromoted, missing)
+
+ if len(missing) == 0 {
+ return nil
+ }
+
+ return missing
+}
+
+// skippedIn returns the required fields of fs the literal behind groups leaves
+// uninitialized.
+//
+// Since Go 1.27 a composite literal may name a promoted field in place of the
+// embedded field carrying it (golang/go#77245). Naming both a promoted field
+// and its enclosing embedded field does not compile, so an embedded field is
+// either named directly, partially filled through promoted names -- in which
+// case its own missing fields are reported, each nameable from the same literal
+// -- or absent altogether and reported as one missing field.
+func (s *Struct) skippedIn(
+ fs *Fields,
+ groups *keyGroups,
+ callerPkgPath string,
+ canNamePromoted bool,
+ missing []Field,
+) []Field {
+ externalPkg := fs.PackagePath != callerPkgPath
+
+ for i, f := range fs.Items {
+ if groups.names(i) {
+ continue
+ }
+
+ // A blank field has no name to write, so a keyed literal can never
+ // initialize it and reporting it yields a finding nobody can act on.
+ // Positional literals do supply a value for it, which skippedPositional
+ // accounts for by keeping blank fields in Items.
+ if f.Name == BlankFieldName {
+ continue
+ }
+
+ if !s.isFieldRequired(f, externalPkg) {
+ missing = s.skippedUnder(f, groups.child(i), callerPkgPath, externalPkg, canNamePromoted, missing)
+
+ continue
+ }
+
+ if child := groups.child(i); child != nil {
+ missing = s.skippedIn(f.Embedded, child, callerPkgPath, canNamePromoted, missing)
+
+ continue
+ }
+
+ missing = append(missing, f)
+ }
+
+ return missing
+}
+
+// skippedUnder returns the required fields the literal behind groups leaves
+// uninitialized under an embedded field nothing requires. externalPkg tells
+// whether f itself is declared outside the caller's package.
+//
+// An embedded field the enclosing type made optional still carries fields that
+// are enforced in their own right, and such a field outranks the type holding
+// it. Descending finds them; the field itself stays unreported, since nothing
+// requires it. A field made optional in its own right is not descended into:
+// that excludes what it promotes along with it.
+//
+// Below Go 1.27 a literal cannot name a promoted field, so the embedded field
+// is the one key that reaches what is enforced under it, and it is what is
+// reported. Where that field is unexported and the caller external, no key
+// reaches them at all.
+func (s *Struct) skippedUnder(
+ f Field,
+ groups *keyGroups,
+ callerPkgPath string,
+ externalPkg bool,
+ canNamePromoted bool,
+ missing []Field,
+) []Field {
+ if f.Embedded == nil || f.optedOut() {
+ return missing
+ }
+
+ if canNamePromoted {
+ return s.skippedIn(f.Embedded, groups, callerPkgPath, canNamePromoted, missing)
+ }
+
+ if !f.unreachable(externalPkg) && s.requiresAnyBelow(f.Embedded, callerPkgPath) {
+ return append(missing, f)
+ }
+
+ return missing
+}
+
+// requiresAnyBelow reports whether leaving the embedded field holding fs
+// unwritten leaves a required field unwritten with it. Fields no key reaches
+// count for nothing, as they do in the descent itself.
+func (s *Struct) requiresAnyBelow(fs *Fields, callerPkgPath string) bool {
+ externalPkg := fs.PackagePath != callerPkgPath
+
+ for _, f := range fs.Items {
+ if f.Name == BlankFieldName || f.unreachable(externalPkg) {
+ continue
+ }
+
+ if s.isFieldRequired(f, externalPkg) {
+ return true
+ }
+
+ if f.Embedded != nil && !f.optedOut() && s.requiresAnyBelow(f.Embedded, callerPkgPath) {
+ return true
+ }
+ }
+
+ return false
+}
+
+// keyGroups holds the keys of one literal arranged as the field tree reaches
+// them: one node per embedded field a key passes through, and at each node the
+// indices the keys stopping there name.
+//
+// A literal writes its keys flat, and the descent reads them one level at a
+// time. Arranging them once is what keeps a level from sorting the same keys
+// again at every step below it.
+type keyGroups struct {
+ named map[int]bool
+ children map[int]*keyGroups
+}
+
+// names reports whether a key names the field at index i of this level.
+func (g *keyGroups) names(i int) bool {
+ return g != nil && g.named[i]
+}
+
+// namedCount returns how many fields of this level a key names.
+func (g *keyGroups) namedCount() int {
+ if g == nil {
+ return 0
+ }
+
+ return len(g.named)
+}
+
+// child returns the keys reaching through the embedded field at index i, or nil
+// when the literal writes none.
+func (g *keyGroups) child(i int) *keyGroups {
+ if g == nil {
+ return nil
+ }
+
+ return g.children[i]
+}
+
+// add records one key by the path of field indices that reaches it.
+func (g *keyGroups) add(path []int) {
+ for _, i := range path[:len(path)-1] {
+ if g.children == nil {
+ g.children = make(map[int]*keyGroups)
+ }
+
+ child := g.children[i]
+ if child == nil {
+ child = &keyGroups{named: nil, children: nil}
+ g.children[i] = child
+ }
+
+ g = child
+ }
+
+ if g.named == nil {
+ g.named = make(map[int]bool)
+ }
+
+ g.named[path[len(path)-1]] = true
+}
+
+// groupKeys arranges the keys of lit into the tree the descent reads. A key
+// naming nothing the type resolves is dropped: it names a field pruned for
+// being inaccessible, one another shadows, or none at all.
+func (fs *Fields) groupKeys(lit *ast.CompositeLit, callerPkgPath string, canNamePromoted bool) *keyGroups {
+ paths := fs.paths
+ if paths == nil {
+ // Fields built outside the processor carry no promotion index, so a key
+ // names a field of this level or nothing.
+ paths = directPaths(fs)
+ }
+
+ // Most literals name only fields of the level they are written at, so the
+ // root is sized for all of them and the levels below allocate on demand.
+ groups := &keyGroups{named: make(map[int]bool, len(lit.Elts)), children: nil}
+
+ for _, elt := range lit.Elts {
+ kv, ok := elt.(*ast.KeyValueExpr)
+ if !ok {
+ continue
+ }
+
+ key, ok := kv.Key.(*ast.Ident)
+ if !ok {
+ continue
+ }
+
+ // Below Go 1.27 only a direct field can be named, whatever the tree
+ // behind the type promotes.
+ path := paths[promotionKey(callerPkgPath, key.Name)]
+ if len(path) == 1 || (canNamePromoted && len(path) > 1) {
+ groups.add(path)
+ }
+ }
+
+ return groups
+}
+
+// directPaths indexes the fields of fs by name, reaching through nothing.
+func directPaths(fs *Fields) map[string][]int {
+ paths := make(map[string][]int, len(fs.Items))
+
+ for i := range fs.Items {
+ key := promotionKey(fs.PackagePath, fs.Items[i].Name)
+ if _, seen := paths[key]; !seen {
+ paths[key] = []int{i}
+ }
+ }
+
+ return paths
+}
+
+// optedOut reports whether f was made optional in its own right rather than by
+// the type holding it. Such a field carries its subtree out of the check with
+// it, where a type marked optional carries nothing: a field enforced under one
+// still outranks it.
+func (f Field) optedOut() bool {
+ return f.Optional || f.PatternOptional
+}
+
+func (s *Struct) isFieldRequired(f Field, externalPkg bool) bool {
+ // Reach outranks every directive and pattern below, which are written
+ // without knowing which literal reads them.
+ if f.unreachable(externalPkg) {
+ return false
+ }
+
+ // explicit field directives win over everything
+ if f.Enforced {
+ return true
+ }
+
+ if f.Optional {
+ return false
+ }
+
+ // A pattern that names the field in its own right outranks the settings of
+ // the type holding it. One broad enough to select the type as well names no
+ // field in particular, and is answered by s.IsEnforced/IsOptional below --
+ // PatternEnforced and PatternOptional are already false for it.
+ if f.PatternEnforced {
+ return true
+ }
+
+ if f.PatternOptional {
+ return false
+ }
+
+ // optionality can be inherited from the structure settings
+ if s.IsOptional() {
+ return false
+ }
+
+ return true
+}
+
+type Field struct {
+ Name string
+ Exported bool //exhaustruct:optional
+ Enforced bool //exhaustruct:optional
+ Optional bool //exhaustruct:optional
+
+ // PatternEnforced and PatternOptional record that a pattern names this
+ // field in its own right, and not by way of the type holding it.
+ PatternEnforced bool //exhaustruct:optional
+ PatternOptional bool //exhaustruct:optional
+
+ // Shadowed marks a promoted field a literal of the outermost type resolves
+ // to another field of the same name, or to none at all. Such a field has no
+ // key to write and nothing may require it.
+ Shadowed bool //exhaustruct:optional
+
+ // Embedded holds the fields promoted by an embedded struct field, which a
+ // literal may name in place of this field since Go 1.27. Nil for every
+ // other field, including embedded pointers — a literal cannot reach through
+ // those.
+ Embedded *Fields //exhaustruct:optional
+}
+
+// unreachable reports whether no literal can write f: an unexported field
+// declared in another package, or a promoted field another one shadows.
+func (f Field) unreachable(externalPkg bool) bool {
+ return f.Shadowed || (externalPkg && !f.Exported)
+}
+
+// indexPromotion records the chain of field indices reaching every name a
+// literal of the type holding fs may write, and marks every field no chain
+// reaches.
+//
+// Go resolves a promoted name to its shallowest occurrence, so a deeper field
+// of that name is out of reach, and a name two fields share at one depth
+// resolves to nothing, leaving both out of reach. The walk starts at the
+// outermost struct, which is the only level a literal writes keys at, and is
+// why the index is not kept per level.
+func indexPromotion(fs *Fields) map[string][]int {
+ paths := make(map[string][]int, len(fs.Items))
+ blocked := make(map[string]bool)
+
+ for level := []promotionLevel{{fields: fs, path: nil}}; len(level) > 0; {
+ atDepth := namesAtDepth(level)
+
+ level = indexLevel(level, paths, blocked, atDepth)
+
+ for name := range atDepth {
+ blocked[name] = true
+ }
+ }
+
+ return paths
+}
+
+// promotionLevel is one struct of the promotion walk, with the chain of field
+// indices that reached it.
+type promotionLevel struct {
+ fields *Fields
+ path []int
+}
+
+// promotionKey names a field the way a literal's key resolves to it. An
+// unexported name belongs to the package that wrote it, so the same spelling in
+// two packages stands for two identifiers: neither shadows the other, and a
+// literal reaches only the one its own package declared.
+func promotionKey(pkgPath, name string) string {
+ if token.IsExported(name) {
+ return name
+ }
+
+ return pkgPath + "." + name
+}
+
+// namesAtDepth counts the fields of one promotion depth carrying each name.
+func namesAtDepth(level []promotionLevel) map[string]int {
+ counts := make(map[string]int)
+
+ for _, l := range level {
+ for _, item := range l.fields.Items {
+ counts[promotionKey(l.fields.PackagePath, item.Name)]++
+ }
+ }
+
+ return counts
+}
+
+// indexLevel records the reachable fields of one depth, marks the rest, and
+// returns the structs embedded at that depth, which make up the next one.
+func indexLevel(
+ level []promotionLevel,
+ paths map[string][]int,
+ blocked map[string]bool,
+ atDepth map[string]int,
+) []promotionLevel {
+ var next []promotionLevel
+
+ for _, l := range level {
+ for i := range l.fields.Items {
+ item := &l.fields.Items[i]
+ path := append(append(make([]int, 0, len(l.path)+1), l.path...), i)
+
+ key := promotionKey(l.fields.PackagePath, item.Name)
+
+ item.Shadowed = blocked[key] || atDepth[key] > 1
+ if !item.Shadowed {
+ paths[key] = path
+ }
+
+ if item.Embedded != nil {
+ next = append(next, promotionLevel{fields: item.Embedded, path: path})
+ }
+ }
+ }
+
+ return next
+}
+
+// Fields is a collection of struct fields with shared package metadata.
+// Items are in declaration order (required for positional literals).
+type Fields struct {
+ PackagePath string
+ Items []Field
+
+ // paths maps every name a literal of the enclosing type may write to the
+ // chain of field indices reaching it. Built once with the type's metadata
+ // and set on the outermost Fields only, which is the level keys are written
+ // at. Nil for Fields built outside the processor.
+ paths map[string][]int //exhaustruct:optional
+}
+
+func FormatFieldNames(fields []Field) string {
+ switch len(fields) {
+ case 0:
+ return ""
+ case 1:
+ return fields[0].Name
+ }
+
+ var b strings.Builder
+
+ b.Grow(len(fields))
+ b.WriteString(fields[0].Name)
+
+ for _, s := range fields[1:] {
+ b.WriteString(", ")
+ b.WriteString(s.Name)
+ }
+
+ return b.String()
+}
diff --git a/vendor/dev.gaijin.team/go/golib/LICENSE b/vendor/dev.gaijin.team/go/golib/LICENSE
new file mode 100644
index 0000000000..05a82fec2e
--- /dev/null
+++ b/vendor/dev.gaijin.team/go/golib/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2024 Gaijin Entertainment
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/vendor/dev.gaijin.team/go/golib/e/doc.go b/vendor/dev.gaijin.team/go/golib/e/doc.go
new file mode 100644
index 0000000000..a1582f5c1e
--- /dev/null
+++ b/vendor/dev.gaijin.team/go/golib/e/doc.go
@@ -0,0 +1,46 @@
+// Package e provides a custom error type with support for error chaining and
+// structured metadata fields.
+//
+// The main type, Err, enables convenient error wrapping and the attachment of
+// key-value metadata fields (fields.Field). Errors can be wrapped to add context
+// and enriched with fields for structured logging or diagnostics.
+//
+// Example: Wrapping errors with context
+//
+// var ErrJSONParseFailed = e.New("JSON parse failed")
+// var val any
+// if err := json.Unmarshal([]byte(`["invalid", "json]`), &val); err != nil {
+// return ErrJSONParseFailed.Wrap(err)
+// // Output: "JSON parse failed: unexpected end of JSON input"
+// }
+//
+// Example: Enriching errors with fields
+//
+// err := e.New("operation failed").WithField("user_id", 42)
+// // Output: "operation failed (user_id=42)"
+//
+// err = err.Wrap(e.New("db error").WithFields(fields.F("query", "SELECT *")))
+// // Output: "operation failed (user_id=42): db error (query=SELECT *)"
+//
+// Any error can be converted to an Err using the From function. This does not
+// wrap the error; unwrapping will not return the original error.
+//
+// e.From(errors.New("error")) // "error"
+// errors.Unwrap(e.From(errors.New("error"))) // nil
+//
+// The Err string format is:
+//
+// (fields...):
+//
+// Fields are always enclosed in parentheses, and wrapped errors are separated by
+// a colon and space.
+//
+// All methods that return errors create new instances; errors are immutable.
+//
+// Deprecated methods Unwrap, Is, and As are present for compatibility with the
+// errors package, but should not be used directly. Use the errors package
+// functions instead.
+//
+// The Log function logs errors using our logger abstraction - logger.Logger,
+// extracting reason, wrapped error, and fields, logging them appropriately.
+package e
diff --git a/vendor/dev.gaijin.team/go/golib/e/err.go b/vendor/dev.gaijin.team/go/golib/e/err.go
new file mode 100644
index 0000000000..334dc563ca
--- /dev/null
+++ b/vendor/dev.gaijin.team/go/golib/e/err.go
@@ -0,0 +1,140 @@
+package e
+
+import (
+ "errors"
+ "slices"
+ "strings"
+
+ "dev.gaijin.team/go/golib/fields"
+)
+
+// Err represents a custom error type that supports error chaining and structured metadata fields.
+type Err struct {
+ errs []error
+ fields fields.List
+}
+
+// New returns a new Err with the given reason and optional fields.
+// The returned error can be further wrapped or annotated with additional fields.
+func New(reason string, f ...fields.Field) *Err {
+ return From(errors.New(reason), f...) //nolint:err113
+}
+
+// NewFrom returns a new Err with the given reason, wrapping the provided error, and optional fields.
+// If wrapped is nil, it behaves like New.
+func NewFrom(reason string, wrapped error, f ...fields.Field) *Err {
+ if wrapped == nil {
+ return New(reason, f...)
+ }
+
+ return &Err{
+ errs: []error{errors.New(reason), wrapped}, //nolint:err113
+ fields: f,
+ }
+}
+
+// From converts any error to an Err, optionally adding fields. This is not true wrapping;
+// unwrapping will not return the original error. Passing nil results in an Err with reason "error(nil)".
+func From(origin error, f ...fields.Field) *Err {
+ if origin == nil {
+ origin = errors.New("error(nil)") //nolint:err113
+ }
+
+ return &Err{
+ errs: []error{origin},
+ fields: f,
+ }
+}
+
+// Wrap returns a new Err that wraps the provided error with the current Err as context.
+// Additional fields can be attached. If err is nil, it is replaced with an Err for "error(nil)".
+func (e *Err) Wrap(err error, f ...fields.Field) *Err {
+ if err == nil {
+ err = errors.New("error(nil)") //nolint:err113
+ }
+
+ return &Err{
+ errs: []error{e, err},
+ fields: f,
+ }
+}
+
+// Error returns the string representation of the Err, including reason, fields, and wrapped errors.
+func (e *Err) Error() string {
+ b := &strings.Builder{}
+ writeTo(b, e)
+
+ return b.String()
+}
+
+func writeTo(b *strings.Builder, err error) {
+ if b.Len() > 0 {
+ b.WriteString(": ")
+ }
+
+ ee, ok := err.(*Err) //nolint:errorlint
+ if !ok {
+ b.WriteString(err.Error())
+
+ return
+ }
+
+ b.WriteString(ee.Reason())
+
+ if ee == nil {
+ return
+ }
+
+ if len(ee.fields) > 0 {
+ b.WriteRune(' ')
+ ee.fields.WriteTo(b)
+ }
+
+ if len(ee.errs) > 1 {
+ writeTo(b, ee.errs[1])
+ }
+}
+
+// Clone returns a new Err with the same error, wrapped error, and a cloned fields container.
+func (e *Err) Clone() *Err {
+ return &Err{
+ errs: slices.Clone(e.errs),
+ fields: slices.Clone(e.fields),
+ }
+}
+
+// WithFields returns a new Err with the same error and the provided fields.
+func (e *Err) WithFields(f ...fields.Field) *Err {
+ return From(e, f...)
+}
+
+// WithField returns a new Err with the same error and a single additional field.
+func (e *Err) WithField(key string, val any) *Err {
+ return e.WithFields(fields.F(key, val))
+}
+
+// Fields returns the metadata fields attached to the Err.
+func (e *Err) Fields() fields.List {
+ return e.fields
+}
+
+// Reason returns the reason string of the Err, without fields or wrapped errors.
+// If the Err is nil, returns "(*e.Err)(nil)". If empty, returns "(*e.Err)(empty)".
+func (e *Err) Reason() string {
+ if e == nil {
+ return "(*e.Err)(nil)"
+ }
+
+ if len(e.errs) == 0 {
+ return "(*e.Err)(empty)"
+ }
+
+ return e.errs[0].Error()
+}
+
+// Unwrap returns the underlying errors for compatibility with errors.Is and errors.As.
+//
+// Deprecated: This method is for internal use only. Prefer using the errors package directly.
+func (e *Err) Unwrap() []error {
+ return e.errs
+}
diff --git a/vendor/dev.gaijin.team/go/golib/e/log.go b/vendor/dev.gaijin.team/go/golib/e/log.go
new file mode 100644
index 0000000000..0caafaab03
--- /dev/null
+++ b/vendor/dev.gaijin.team/go/golib/e/log.go
@@ -0,0 +1,33 @@
+package e
+
+import (
+ "dev.gaijin.team/go/golib/fields"
+)
+
+// ErrorLogger defines a function that logs an error message, an error, and optional fields.
+type ErrorLogger func(msg string, err error, fs ...fields.Field)
+
+// Log logs the provided error using the given ErrorLogger function.
+//
+// If err is nil, Log does nothing. If err is of type Err, its reason is used as the log message,
+// the wrapped error is passed as the error, and its fields are passed as log fields.
+// For other error types, err.Error() is used as the message and nil is passed as the error.
+func Log(err error, f ErrorLogger) {
+ if err == nil {
+ return
+ }
+
+ // We're not interested in wrapped error, therefore we're only typecasting it.
+ if e, ok := err.(*Err); ok { //nolint:errorlint
+ var wrapped error
+ if len(e.errs) > 1 {
+ wrapped = e.errs[1]
+ }
+
+ f(e.Reason(), wrapped, e.fields...)
+
+ return
+ }
+
+ f(err.Error(), nil)
+}
diff --git a/vendor/dev.gaijin.team/go/golib/fields/dict.go b/vendor/dev.gaijin.team/go/golib/fields/dict.go
new file mode 100644
index 0000000000..cd025089f3
--- /dev/null
+++ b/vendor/dev.gaijin.team/go/golib/fields/dict.go
@@ -0,0 +1,69 @@
+package fields
+
+import (
+ "iter"
+ "strings"
+)
+
+const CollectionSep = ", "
+
+// Dict is a map-based collection of unique fields, keyed by string.
+// It provides efficient lookup and overwrites duplicate keys.
+type Dict map[string]any
+
+// Add inserts or updates fields in the Dict, overwriting existing keys if present.
+//
+// Example:
+//
+// d := fields.Dict{"foo": "bar"}
+// d.Add(fields.F("baz", 42), fields.F("foo", "qux")) // d["foo"] == "qux"
+func (d Dict) Add(fields ...Field) {
+ for _, f := range fields {
+ d[f.K] = f.V
+ }
+}
+
+// ToList converts the Dict to a List, with order unspecified.
+// Each key-value pair becomes a Field in the resulting List.
+func (d Dict) ToList() List {
+ s := make(List, 0, len(d))
+
+ for k, v := range d {
+ s = append(s, Field{k, v})
+ }
+
+ return s
+}
+
+// All returns an iterator over all key-value pairs in the Dict as iter.Seq2[string, any].
+//
+// Example:
+//
+// for k, v := range d.All() {
+// fmt.Println(k, v)
+// }
+func (d Dict) All() iter.Seq2[string, any] {
+ return func(yield func(string, any) bool) {
+ for k, v := range d {
+ if !yield(k, v) {
+ return
+ }
+ }
+ }
+}
+
+// WriteTo writes the Dict as a string in the format "(key1=val1, key2=val2)" to the provided builder.
+// If the Dict is empty, nothing is written. The order of fields is unspecified.
+func (d Dict) WriteTo(b *strings.Builder) {
+ WriteTo(b, d.All())
+}
+
+// String returns the Dict as a string in the format "(key1=val1, key2=val2)".
+// Returns an empty string if the Dict is empty. The order of fields is unspecified.
+func (d Dict) String() string {
+ b := strings.Builder{}
+
+ d.WriteTo(&b)
+
+ return b.String()
+}
diff --git a/vendor/dev.gaijin.team/go/golib/fields/doc.go b/vendor/dev.gaijin.team/go/golib/fields/doc.go
new file mode 100644
index 0000000000..1ef4ee56d9
--- /dev/null
+++ b/vendor/dev.gaijin.team/go/golib/fields/doc.go
@@ -0,0 +1,32 @@
+// Package fields provides types and functions to work with key-value pairs.
+//
+// The package offers three primary abstractions:
+//
+// - Field: A key-value pair where the key is a string and the value can be any type.
+// - Dict: A map-based collection of unique fields, providing efficient key-based lookup.
+// - List: An ordered collection of fields that preserves insertion order.
+//
+// Fields can be created using the F constructor, and both Dict and List provide
+// conversion methods between the two collection types. All types implement String()
+// for consistent string representation.
+//
+// Example usage:
+//
+// // Create fields
+// f1 := fields.F("status", "success")
+// f2 := fields.F("code", 200)
+//
+// // Working with a List (ordered collection)
+// var list fields.List
+// list.Add(f1, f2)
+// fmt.Println(list) // "(status=success, code=200)"
+//
+// // Working with a Dict (unique key collection)
+// dict := fields.Dict{}
+// dict.Add(f1, f2, fields.F("status", "updated")) // overwrites "status"
+// fmt.Println(dict) // "(status=updated, code=200)" (order may vary)
+//
+// // Converting between types
+// list2 := dict.ToList() // order unspecified
+// dict2 := list.ToDict() // last occurrence of each key wins
+package fields
diff --git a/vendor/dev.gaijin.team/go/golib/fields/field.go b/vendor/dev.gaijin.team/go/golib/fields/field.go
new file mode 100644
index 0000000000..716586ba47
--- /dev/null
+++ b/vendor/dev.gaijin.team/go/golib/fields/field.go
@@ -0,0 +1,81 @@
+package fields
+
+import (
+ "fmt"
+ "iter"
+ "strings"
+)
+
+// Field represents a key-value pair, where the key is a string and the value can be any type.
+type Field struct {
+ // Key of the field
+ K string
+ // Value of the field
+ V any
+}
+
+// F creates a new Field with the given key and value.
+//
+// Example:
+//
+// f := fields.F("user", "alice")
+func F(key string, value any) Field {
+ return Field{K: key, V: value}
+}
+
+// writeKVTo writes a key-value pair to the given builder in the format "key=value".
+func writeKVTo(b *strings.Builder, key string, value any) {
+ b.WriteString(key)
+ b.WriteRune('=')
+
+ switch val := value.(type) {
+ case string:
+ b.WriteString(val)
+
+ case fmt.Stringer:
+ b.WriteString(val.String())
+
+ case error:
+ b.WriteString(val.Error())
+
+ default:
+ _, _ = fmt.Fprintf(b, "%v", value)
+ }
+}
+
+// WriteTo writes the Field as a string in the format "key=value" to the provided builder.
+func (f Field) WriteTo(b *strings.Builder) {
+ writeKVTo(b, f.K, f.V)
+}
+
+// String returns the Field as a string in the format "key=value".
+func (f Field) String() string {
+ b := &strings.Builder{}
+ f.WriteTo(b)
+
+ return b.String()
+}
+
+// WriteTo writes key-value pairs from an iter.Seq2[string, any] to the builder in the format "(key1=val1, key2=val2)".
+// If no fields are present, nothing is written.
+func WriteTo(b *strings.Builder, seq iter.Seq2[string, any]) {
+ first := true
+
+ for k, v := range seq {
+ if first {
+ first = false
+
+ b.WriteString("(")
+ } else {
+ b.WriteString(", ")
+ }
+
+ writeKVTo(b, k, v)
+ }
+
+ // means that we've written at least one field, and, therefore,
+ // can close the parenthesis
+ if !first {
+ b.WriteString(")")
+ }
+}
diff --git a/vendor/dev.gaijin.team/go/golib/fields/list.go b/vendor/dev.gaijin.team/go/golib/fields/list.go
new file mode 100644
index 0000000000..7da83b200d
--- /dev/null
+++ b/vendor/dev.gaijin.team/go/golib/fields/list.go
@@ -0,0 +1,69 @@
+package fields
+
+import (
+ "iter"
+ "strings"
+)
+
+// List is an ordered collection of Field values, preserving insertion order.
+// Such collection do not check for duplicate keys.
+type List []Field //nolint:recvcheck //we need Add to be a pointer receiver to modify original value.
+
+// Add one or more fields to the List, modifying it.
+//
+// Example:
+//
+// var l fields.List
+// l.Add(fields.F("foo", "bar"), fields.F("baz", 42))
+func (l *List) Add(fields ...Field) {
+ *l = append(*l, fields...)
+}
+
+// ToDict converts the List to a Dict, overwriting duplicate keys with the last occurrence.
+//
+// Example:
+//
+// l := fields.List{fields.F("foo", 1), fields.F("foo", 2)}
+// d := l.ToDict() // d["foo"] == 2
+func (l List) ToDict() Dict {
+ d := make(Dict, len(l))
+
+ for i := range l {
+ d[l[i].K] = l[i].V
+ }
+
+ return d
+}
+
+// All returns an iterator over all key-value pairs in the List as iter.Seq2[string, any].
+//
+// Example:
+//
+// for k, v := range l.All() {
+// fmt.Println(k, v)
+// }
+func (l List) All() iter.Seq2[string, any] {
+ return func(yield func(string, any) bool) {
+ for i := range len(l) {
+ if !yield(l[i].K, l[i].V) {
+ return
+ }
+ }
+ }
+}
+
+// WriteTo writes the List as a string in the format "(key1=val1, key2=val2)" to the provided builder.
+// If the List is empty, nothing is written.
+func (l List) WriteTo(b *strings.Builder) {
+ WriteTo(b, l.All())
+}
+
+// String returns the List as a string in the format "(key1=val1, key2=val2)".
+// Returns an empty string if the List is empty.
+func (l List) String() string {
+ b := strings.Builder{}
+
+ l.WriteTo(&b)
+
+ return b.String()
+}
diff --git a/vendor/github.com/4meepo/tagalign/tagalign.go b/vendor/github.com/4meepo/tagalign/tagalign.go
index 8161a0aa7f..9aab3cb8e7 100644
--- a/vendor/github.com/4meepo/tagalign/tagalign.go
+++ b/vendor/github.com/4meepo/tagalign/tagalign.go
@@ -10,7 +10,7 @@ import (
"strconv"
"strings"
- "github.com/fatih/structtag"
+ "github.com/alfatraining/structtag"
"golang.org/x/tools/go/analysis"
)
@@ -62,7 +62,7 @@ func Run(pass *analysis.Pass, options ...Option) {
}
ast.Inspect(f, func(n ast.Node) bool {
- h.find(pass, n)
+ h.findNested(pass, n)
return true
})
@@ -126,9 +126,6 @@ func (w *Helper) find(pass *analysis.Pass, n ast.Node) {
split()
// check if the field is a struct
- if _, ok := field.Type.(*ast.StructType); ok {
- continue
- }
}
}
@@ -138,6 +135,12 @@ func (w *Helper) find(pass *analysis.Pass, n ast.Node) {
split()
}
+func (w *Helper) findNested(pass *analysis.Pass, n ast.Node) {
+ if v, ok := n.(*ast.StructType); ok {
+ w.find(pass, v)
+ }
+}
+
func (w *Helper) report(pass *analysis.Pass, field *ast.Field, msg, replaceStr string) {
pass.Report(analysis.Diagnostic{
Pos: field.Tag.Pos(),
diff --git a/vendor/github.com/Abirdcfly/dupword/README.md b/vendor/github.com/Abirdcfly/dupword/README.md
index e6c5b919fa..a3db4c5037 100644
--- a/vendor/github.com/Abirdcfly/dupword/README.md
+++ b/vendor/github.com/Abirdcfly/dupword/README.md
@@ -101,10 +101,14 @@ Flags:
no effect (deprecated)
-c int
display offending line with this many lines of context (default -1)
+ -comments-only
+ check only comments, skip strings
-cpuprofile string
write CPU profile to this file
-debug string
debug flags, any subset of "fpstv"
+ -diff
+ with -fix, don't update the files, but print a unified diff
-fix
apply all suggested fixes
-flags
@@ -130,7 +134,7 @@ Flags:
### 5. my advice
-use `--keyword=the,and,a` and `-fix` together. I think that specifying only commonly repeated prepositions can effectively avoid false positives.
+use `--keyword=the,and,a` and `-fix` together. I think that specifying only commonly repeated prepositions can effectively avoid false positives.
see [dupword#4](https://github.com/Abirdcfly/dupword/issues/4) for real code example.
diff --git a/vendor/github.com/Abirdcfly/dupword/dupword.go b/vendor/github.com/Abirdcfly/dupword/dupword.go
index 6838d7e759..5b48200677 100644
--- a/vendor/github.com/Abirdcfly/dupword/dupword.go
+++ b/vendor/github.com/Abirdcfly/dupword/dupword.go
@@ -20,8 +20,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
-// Package dupword defines an Analyzer that checks that duplicate words
-// int the source code.
+// Package dupword defines an Analyzer that checks those duplicate words in the source code.
package dupword
import (
@@ -49,54 +48,45 @@ This analyzer checks miswritten duplicate words in comments or package doc or st
CommentPrefix = `//`
)
-var (
- defaultWord = []string{}
- // defaultWord = []string{"the", "and", "a"}
- ignoreWord = map[string]bool{}
-)
+type keywords []string
-type analyzer struct {
- KeyWord []string
+func (a keywords) String() string {
+ return strings.Join(a, ",")
}
-func (a *analyzer) String() string {
- return strings.Join(a.KeyWord, ",")
-}
-
-func (a *analyzer) Set(w string) error {
+func (a *keywords) Set(w string) error {
if len(w) != 0 {
- a.KeyWord = make([]string, 0)
- a.KeyWord = append(a.KeyWord, strings.Split(w, ",")...)
+ *a = append(*a, strings.Split(w, ",")...)
}
+
return nil
}
-type ignore struct {
-}
+type ignore map[string]bool
+
+func (a ignore) String() string {
+ var t []string
-func (a *ignore) String() string {
- t := make([]string, 0, len(ignoreWord))
- for k := range ignoreWord {
+ for k := range a {
t = append(t, k)
}
+
return strings.Join(t, ",")
}
-func (a *ignore) Set(w string) error {
+func (a ignore) Set(w string) error {
for _, k := range strings.Split(w, ",") {
- ignoreWord[k] = true
+ a[k] = true
}
- return nil
-}
-// for test only
-func ClearIgnoreWord() {
- ignoreWord = map[string]bool{}
+ return nil
}
func NewAnalyzer() *analysis.Analyzer {
- ignore := &ignore{}
- analyzer := &analyzer{KeyWord: defaultWord}
+ analyzer := &analyzer{
+ ignoreWords: map[string]bool{},
+ }
+
a := &analysis.Analyzer{
Name: Name,
Doc: Doc,
@@ -104,17 +94,31 @@ func NewAnalyzer() *analysis.Analyzer {
Run: analyzer.run,
RunDespiteErrors: true,
}
+
a.Flags.Init(Name, flag.ExitOnError)
- a.Flags.Var(analyzer, "keyword", "keywords for detecting duplicate words")
- a.Flags.Var(ignore, "ignore", "ignore words")
+ a.Flags.Var(&analyzer.keywords, "keyword", "keywords for detecting duplicate words")
+ a.Flags.Var(&analyzer.ignoreWords, "ignore", "ignore words")
+ a.Flags.BoolVar(&analyzer.commentsOnly, "comments-only", false, "check only comments, skip strings")
+ a.Flags.BoolVar(&analyzer.skipRawStrings, "skip-raw-strings", false, "skip raw string literals (backtick-delimited)")
a.Flags.Var(version{}, "V", "print version and exit")
+
return a
}
+type analyzer struct {
+ keywords keywords
+ ignoreWords ignore
+ commentsOnly bool
+ skipRawStrings bool
+}
+
func (a *analyzer) run(pass *analysis.Pass) (interface{}, error) {
for _, file := range pass.Files {
a.fixDuplicateWordInComment(pass, file)
}
+ if a.commentsOnly {
+ return nil, nil
+ }
inspect := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
nodeFilter := []ast.Node{
(*ast.BasicLit)(nil),
@@ -184,6 +188,9 @@ func (a *analyzer) fixDuplicateWordInString(pass *analysis.Pass, lit *ast.BasicL
if lit.Kind != token.STRING {
return
}
+ if a.skipRawStrings && len(lit.Value) > 0 && lit.Value[0] == '`' {
+ return
+ }
value, err := strconv.Unquote(lit.Value)
if err != nil {
fmt.Printf("lit.Value:%v, err: %v\n", lit.Value, err)
@@ -191,9 +198,14 @@ func (a *analyzer) fixDuplicateWordInString(pass *analysis.Pass, lit *ast.BasicL
value = lit.Value
}
quote := value != lit.Value
+ isRawString := quote && len(lit.Value) > 0 && lit.Value[0] == '`'
update, keyword, find := a.Check(value)
if quote {
- update = strconv.Quote(update)
+ if isRawString {
+ update = "`" + update + "`"
+ } else {
+ update = strconv.Quote(update)
+ }
}
if find {
pass.Report(analysis.Diagnostic{Pos: lit.Pos(), End: lit.End(), Message: fmt.Sprintf(Message, keyword), SuggestedFixes: []analysis.SuggestedFix{{
@@ -208,8 +220,8 @@ func (a *analyzer) fixDuplicateWordInString(pass *analysis.Pass, lit *ast.BasicL
}
// CheckOneKey use to check there is a defined duplicate word in a string.
-// raw is checked line. key is the keyword to check. empty means just check duplicate word.
-func CheckOneKey(raw, key string) (new string, findWord string, find bool) {
+// `raw` is the checked line. key is the keyword to check. empty means just check duplicate word.
+func (a *analyzer) checkOneKey(raw, key string) (new string, findWord string, find bool) {
if key == "" {
has := false
fields := strings.Fields(raw)
@@ -249,7 +261,7 @@ func CheckOneKey(raw, key string) (new string, findWord string, find bool) {
*/
symbol := raw[spaceStart:i]
if ((key != "" && curWord == key) || key == "") && curWord == preWord && curWord != "" {
- if !ExcludeWords(curWord) {
+ if !a.excludeWords(cutTrailingCommas(curWord)) {
find = true
findWordMap[curWord] = true
newLine.WriteString(lastSpace)
@@ -266,11 +278,11 @@ func CheckOneKey(raw, key string) (new string, findWord string, find bool) {
// space start position
spaceStart = i
curWord = raw[wordStart:i]
- } else if i == len(raw)-1 {
- // last position
+ } else if i == len(raw)-1 && !unicode.IsSpace(r) {
+ // last position (non-space): write the final word
word := raw[wordStart:]
if ((key != "" && word == key) || key == "") && word == preWord {
- if !ExcludeWords(word) {
+ if !a.excludeWords(cutTrailingCommas(word)) {
find = true
findWordMap[word] = true
}
@@ -281,6 +293,25 @@ func CheckOneKey(raw, key string) (new string, findWord string, find bool) {
}
lastRune = r
}
+ // Flush remaining content when the string ends with whitespace:
+ // the last word (curWord) and trailing whitespace haven't been written yet.
+ if len(raw) > 0 && unicode.IsSpace(rune(raw[len(raw)-1])) {
+ if curWord != "" {
+ if ((key != "" && curWord == key) || key == "") && curWord == preWord && curWord != "" {
+ if !a.excludeWords(cutTrailingCommas(curWord)) {
+ find = true
+ findWordMap[curWord] = true
+ } else {
+ newLine.WriteString(lastSpace)
+ newLine.WriteString(curWord)
+ }
+ } else {
+ newLine.WriteString(lastSpace)
+ newLine.WriteString(curWord)
+ }
+ }
+ newLine.WriteString(raw[spaceStart:])
+ }
if find {
new = newLine.String()
findWordSlice := make([]string, len(findWordMap))
@@ -296,8 +327,8 @@ func CheckOneKey(raw, key string) (new string, findWord string, find bool) {
}
func (a *analyzer) Check(raw string) (update string, keyword string, find bool) {
- for _, key := range a.KeyWord {
- updateOne, _, findOne := CheckOneKey(raw, key)
+ for _, key := range a.keywords {
+ updateOne, _, findOne := a.checkOneKey(raw, key)
if findOne {
raw = updateOne
find = findOne
@@ -309,8 +340,8 @@ func (a *analyzer) Check(raw string) (update string, keyword string, find bool)
}
}
}
- if len(a.KeyWord) == 0 {
- return CheckOneKey(raw, "")
+ if len(a.keywords) == 0 {
+ return a.checkOneKey(raw, "")
}
return
}
@@ -318,7 +349,7 @@ func (a *analyzer) Check(raw string) (update string, keyword string, find bool)
// ExcludeWords determines whether duplicate words should be reported,
//
// e.g. %s, should not be reported.
-func ExcludeWords(word string) (exclude bool) {
+func (a *analyzer) excludeWords(word string) (exclude bool) {
firstRune, _ := utf8.DecodeRuneInString(word)
if unicode.IsDigit(firstRune) {
return true
@@ -329,7 +360,7 @@ func ExcludeWords(word string) (exclude bool) {
if unicode.IsSymbol(firstRune) {
return true
}
- if _, exist := ignoreWord[word]; exist {
+ if _, exist := a.ignoreWords[word]; exist {
return true
}
return false
@@ -341,3 +372,11 @@ func isExampleOutputStart(comment string) bool {
strings.HasPrefix(comment, "// Unordered output:") ||
strings.HasPrefix(comment, "// unordered output:")
}
+
+// cutTrailingCommas is used to remove trailing commas of words.
+// The excludeWords are provided as comma-separated list, so it is
+// impossible to ignore "[word], [word]," matches otherwise
+func cutTrailingCommas(s string) string {
+ result, _ := strings.CutSuffix(s, ",")
+ return result
+}
diff --git a/vendor/github.com/AdminBenni/iota-mixing/LICENSE b/vendor/github.com/AdminBenni/iota-mixing/LICENSE
new file mode 100644
index 0000000000..06e009ffaf
--- /dev/null
+++ b/vendor/github.com/AdminBenni/iota-mixing/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2025 Benedikt Aron Þjóðbjargarson
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/vendor/github.com/AdminBenni/iota-mixing/pkg/analyzer/analyzer.go b/vendor/github.com/AdminBenni/iota-mixing/pkg/analyzer/analyzer.go
new file mode 100644
index 0000000000..4c56ebddeb
--- /dev/null
+++ b/vendor/github.com/AdminBenni/iota-mixing/pkg/analyzer/analyzer.go
@@ -0,0 +1,118 @@
+package analyzer
+
+import (
+ "go/ast"
+ "go/token"
+ "log"
+ "strings"
+
+ "golang.org/x/tools/go/analysis"
+ "golang.org/x/tools/go/analysis/passes/inspect"
+ "golang.org/x/tools/go/ast/inspector"
+
+ "github.com/AdminBenni/iota-mixing/pkg/analyzer/flags"
+)
+
+func GetIotaMixingAnalyzer() *analysis.Analyzer {
+ return &analysis.Analyzer{
+ Name: "iotamixing",
+ Doc: "checks if iotas are being used in const blocks with other non-iota declarations.",
+ Run: run,
+ Requires: []*analysis.Analyzer{inspect.Analyzer},
+ }
+}
+
+func run(pass *analysis.Pass) (interface{}, error) {
+ ASTInspector := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector) //nolint:forcetypeassert // will always be correct type
+
+ // we only need to check Generic Declarations
+ nodeFilter := []ast.Node{
+ (*ast.GenDecl)(nil),
+ }
+
+ ASTInspector.Preorder(nodeFilter, func(node ast.Node) { checkGenericDeclaration(node, pass) })
+
+ return interface{}(nil), nil
+}
+
+func checkGenericDeclaration(node ast.Node, pass *analysis.Pass) {
+ decl := node.(*ast.GenDecl) //nolint:forcetypeassert // filtered for this node, will always be this type
+
+ if decl.Tok != token.CONST {
+ return
+ }
+
+ checkConstDeclaration(decl, pass)
+}
+
+func checkConstDeclaration(decl *ast.GenDecl, pass *analysis.Pass) {
+ iotaFound := false
+ valued := make([]*ast.ValueSpec, 0, len(decl.Specs))
+
+ // traverse specs inside const block
+ for _, spec := range decl.Specs {
+ if specVal, ok := spec.(*ast.ValueSpec); ok {
+ iotaFound, valued = checkValueSpec(specVal, iotaFound, valued)
+ }
+ }
+
+ if !iotaFound {
+ return
+ }
+
+ // there was an iota, now depending on the report-individual flag we must either
+ // report the const block or all regular valued specs that are mixing with the iota
+ switch flags.ReportIndividualFlag() {
+ case flags.TrueString:
+ for _, value := range valued {
+ pass.Reportf(
+ value.Pos(),
+ "%s is a const with r-val in same const block as iota. keep iotas in separate const blocks",
+ getName(value),
+ )
+ }
+ default: //nolint:gocritic // default logs error and falls through to "false" case, simplest in this order
+ log.Printf(
+ "warning: unsupported value '%s' for flag %s, assuming value 'false'.",
+ flags.ReportIndividualFlag(), flags.ReportIndividualFlagName,
+ )
+
+ fallthrough
+ case flags.FalseString:
+ if len(valued) == 0 {
+ return
+ }
+
+ pass.Reportf(decl.Pos(), "iota mixing. keep iotas in separate blocks to consts with r-val")
+ }
+}
+
+func checkValueSpec(spec *ast.ValueSpec, iotaFound bool, valued []*ast.ValueSpec) (bool, []*ast.ValueSpec) {
+ // traverse through values (r-val) of spec and look for iota
+ for _, expr := range spec.Values {
+ if idn, ok := expr.(*ast.Ident); ok && idn.Name == "iota" {
+ return true, valued
+ }
+ }
+
+ // iota wasn't found, add to valued spec list if there is an r-val
+ if len(spec.Values) > 0 {
+ return iotaFound, append(valued, spec)
+ }
+
+ return iotaFound, valued
+}
+
+func getName(spec *ast.ValueSpec) string {
+ sb := strings.Builder{}
+
+ for i, ident := range spec.Names {
+ sb.WriteString(ident.Name)
+
+ if i < len(spec.Names)-1 {
+ sb.WriteString(", ")
+ }
+ }
+
+ return sb.String()
+}
diff --git a/vendor/github.com/AdminBenni/iota-mixing/pkg/analyzer/flags/flags.go b/vendor/github.com/AdminBenni/iota-mixing/pkg/analyzer/flags/flags.go
new file mode 100644
index 0000000000..8f9b73b64d
--- /dev/null
+++ b/vendor/github.com/AdminBenni/iota-mixing/pkg/analyzer/flags/flags.go
@@ -0,0 +1,23 @@
+package flags
+
+import "flag"
+
+const (
+ TrueString = "true"
+ FalseString = "false"
+
+ ReportIndividualFlagName = "report-individual"
+ reportIndividualFlagUsage = "whether or not to report individual consts rather than just the const block."
+)
+
+var (
+ reportIndividualFlag *string //nolint:gochecknoglobals // only used in this file, not too plussed
+)
+
+func SetupFlags(flags *flag.FlagSet) {
+ reportIndividualFlag = flags.String(ReportIndividualFlagName, FalseString, reportIndividualFlagUsage)
+}
+
+func ReportIndividualFlag() string {
+ return *reportIndividualFlag
+}
diff --git a/vendor/github.com/AlwxSin/noinlineerr/.gitignore b/vendor/github.com/AlwxSin/noinlineerr/.gitignore
new file mode 100644
index 0000000000..15573eff6f
--- /dev/null
+++ b/vendor/github.com/AlwxSin/noinlineerr/.gitignore
@@ -0,0 +1,33 @@
+# If you prefer the allow list template instead of the deny list, see community template:
+# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
+#
+# Binaries for programs and plugins
+*.exe
+*.exe~
+*.dll
+*.so
+*.dylib
+
+# Test binary, built with `go test -c`
+*.test
+
+# Output of the go coverage tool, specifically when used with LiteIDE
+*.out
+
+# Dependency directories (remove the comment below to include it)
+# vendor/
+
+# Go workspace file
+go.work
+go.work.sum
+
+# env file
+.env
+.envrc
+
+# ide
+.idea
+.vscode
+
+# OS specific
+.DS_Store
diff --git a/vendor/github.com/AlwxSin/noinlineerr/.golangci.yml b/vendor/github.com/AlwxSin/noinlineerr/.golangci.yml
new file mode 100644
index 0000000000..36b3155896
--- /dev/null
+++ b/vendor/github.com/AlwxSin/noinlineerr/.golangci.yml
@@ -0,0 +1,168 @@
+version: "2"
+
+linters:
+ default: all
+ disable:
+ - decorder
+ - depguard
+ - err113
+ - exhaustruct
+ - nlreturn
+ - nonamedreturns
+ - paralleltest
+ - recvcheck
+ - testpackage
+ - varnamelen
+ - wrapcheck
+
+ settings:
+ cyclop:
+ max-complexity: 30
+ dogsled:
+ max-blank-identifiers: 2
+ dupl:
+ threshold: 150
+ errcheck:
+ check-type-assertions: false
+ check-blank: true
+ exclude-functions:
+ - fmt.Print
+ - fmt.Printf
+ - fmt.Println
+ - fmt.Fprint(*bytes.Buffer)
+ - fmt.Fprintf(*bytes.Buffer)
+ - fmt.Fprintln(*bytes.Buffer)
+ - fmt.Fprint(*strings.Builder)
+ - fmt.Fprintf(*strings.Builder)
+ - fmt.Fprintln(*strings.Builder)
+ - fmt.Fprint(os.Stderr)
+ - fmt.Fprintf(os.Stderr)
+ - fmt.Fprintln(os.Stderr)
+ - io/ioutil.ReadFile
+ - io/ioutil.ReadDir
+ gocognit:
+ min-complexity: 30
+ goconst:
+ min-len: 3
+ min-occurrences: 3
+ gocritic:
+ disabled-checks:
+ - regexpMust
+ - rangeValCopy
+ - importShadow
+ - docStub
+ enabled-tags:
+ - performance
+ - style
+ - diagnostic
+ - experimental
+ - opinionated
+ settings:
+ captLocal:
+ paramsOnly: true
+ hugeParam:
+ sizeThreshold: 1024
+ gocyclo:
+ min-complexity: 30
+ godox:
+ keywords:
+ - FIXME
+ govet:
+ enable:
+ - atomicalign
+ disable:
+ - shadow
+ enable-all: false
+ disable-all: false
+ ireturn:
+ allow:
+ - anon
+ - error
+ - empty
+ - stdlib
+ - generic
+ lll:
+ line-length: 160
+ misspell:
+ locale: US
+ mnd:
+ ignored-functions:
+ - ^strings\.SplitN
+ nakedret:
+ max-func-lines: 30
+ perfsprint:
+ strconcat: false
+ prealloc:
+ simple: true
+ range-loops: true
+ for-loops: false
+ staticcheck:
+ checks:
+ - '*'
+ - -ST1003
+ - -QF1008
+ unparam:
+ check-exported: false
+ unused:
+ field-writes-are-uses: true
+ post-statements-are-reads: false
+ exported-fields-are-used: true
+ parameters-are-used: true
+ local-variables-are-used: true
+ generated-is-used: true
+ usetesting:
+ context-background: true
+ context-todo: true
+ os-chdir: true
+ os-mkdir-temp: true
+ os-setenv: true
+ os-temp-dir: false
+ os-create-temp: true
+ varnamelen:
+ min-name-length: 2
+ whitespace:
+ multi-if: false
+ multi-func: false
+
+ exclusions:
+ presets:
+ - comments
+ - common-false-positives
+ - std-error-handling
+ rules:
+ - path: _test\.go
+ linters:
+ - bodyclose
+ - containedctx
+ - contextcheck
+ - dogsled
+ - errcheck
+ - errchkjson
+ - errorlint
+ - forcetypeassert
+ - funlen
+ - gosec
+ - lll
+ - mnd
+ - musttag
+ - nilnil
+ - unparam
+ - gosmopolitan
+
+
+formatters:
+ enable:
+ - gci
+ - gofumpt
+ - goimports
+ settings:
+ gci:
+ sections:
+ - standard
+ - default
+ - localmodule
+ - blank
+ - dot
+ gofumpt:
+ extra-rules: true
+
diff --git a/vendor/github.com/AlwxSin/noinlineerr/.goreleaser.yml b/vendor/github.com/AlwxSin/noinlineerr/.goreleaser.yml
new file mode 100644
index 0000000000..a36e47cdc5
--- /dev/null
+++ b/vendor/github.com/AlwxSin/noinlineerr/.goreleaser.yml
@@ -0,0 +1,25 @@
+project_name: noinlineerr
+builds:
+ - main: ./cmd/noinlineerr/main.go
+ binary: noinlineerr
+ goos:
+ - linux
+ - darwin
+ - windows
+ goarch:
+ - amd64
+ - arm64
+
+archives:
+ - formats: [ 'tar.gz' ]
+ files:
+ - LICENSE
+ - README.md
+
+checksum:
+ name_template: 'checksums.txt'
+
+release:
+ github:
+ owner: AlwxSin
+ name: noinlineerr
diff --git a/vendor/github.com/AlwxSin/noinlineerr/LICENSE b/vendor/github.com/AlwxSin/noinlineerr/LICENSE
new file mode 100644
index 0000000000..03a52166d5
--- /dev/null
+++ b/vendor/github.com/AlwxSin/noinlineerr/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2025 Alwx
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/vendor/github.com/AlwxSin/noinlineerr/README.md b/vendor/github.com/AlwxSin/noinlineerr/README.md
new file mode 100644
index 0000000000..c0a9cb3867
--- /dev/null
+++ b/vendor/github.com/AlwxSin/noinlineerr/README.md
@@ -0,0 +1,54 @@
+# noinlineerr
+
+A Go linter that forbids inline error handling using `if err := ...; err != nil`.
+
+---
+
+## Why?
+Inline error handling in Go can hurt readability by hiding the actual function call behind error plumbing.
+We believe errors and functions deserve their own spotlight.
+
+Instead of:
+```go
+if err := doSomething(); err != nil {
+ return err
+}
+```
+Prefer the more explicit and readable:
+```go
+err := doSomething()
+if err != nil {
+ return err
+}
+```
+
+---
+
+## Install
+```bash
+go install github.com/AlwxSin/noinlineerr/cmd/noinlineerr@latest
+```
+
+---
+
+## Usage
+### As a standalone tool
+```bash
+noinlineerr ./...
+```
+
+⚠️ Note: The linter detects inline error assignments only when the error variable is explicitly typed or deducible. It doesn't handle dynamically typed interfaces (e.g., `foo().Err()` where `Err()` returns an error via an interface).
+
+---
+
+## Development
+Run tests:
+```bash
+go test ./...
+```
+Test data lives under `testdata/src/...`
+
+---
+
+## Contributing
+PRs are welcome. Let's make Go code cleaner, one `err` at a time.
diff --git a/vendor/github.com/AlwxSin/noinlineerr/noinlineerr.go b/vendor/github.com/AlwxSin/noinlineerr/noinlineerr.go
new file mode 100644
index 0000000000..91d3c6bdb8
--- /dev/null
+++ b/vendor/github.com/AlwxSin/noinlineerr/noinlineerr.go
@@ -0,0 +1,161 @@
+package noinlineerr
+
+import (
+ "bytes"
+ "go/ast"
+ "go/printer"
+ "go/token"
+ "go/types"
+
+ "golang.org/x/tools/go/analysis"
+ "golang.org/x/tools/go/analysis/passes/inspect"
+ "golang.org/x/tools/go/ast/inspector"
+)
+
+func errMessage(tok token.Token) string {
+ if tok == token.ASSIGN {
+ return "avoid inline error handling using `if err = ...; err != nil`; use plain assignment `err = ...`"
+ }
+
+ return "avoid inline error handling using `if err := ...; err != nil`; use plain assignment `err := ...`"
+}
+
+func NewAnalyzer() *analysis.Analyzer {
+ return &analysis.Analyzer{
+ Name: "noinlineerr",
+ Doc: "Disallows inline error handling (`if err := ...; err != nil {`)",
+ Run: run,
+ Requires: []*analysis.Analyzer{inspect.Analyzer},
+ }
+}
+
+func run(pass *analysis.Pass) (any, error) {
+ insp, ok := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
+ if !ok {
+ return nil, nil //nolint:nilnil // nothing to return
+ }
+
+ nodeFilter := []ast.Node{
+ (*ast.IfStmt)(nil),
+ }
+
+ insp.Preorder(nodeFilter, inlineErrorInspector(pass))
+
+ return nil, nil //nolint:nilnil // nothing to return
+}
+
+func inlineErrorInspector(pass *analysis.Pass) func(n ast.Node) {
+ return func(n ast.Node) {
+ ifStmt, ok := n.(*ast.IfStmt)
+ if !ok || ifStmt.Init == nil {
+ return
+ }
+
+ // check if the init clause is an assignment
+ assignStmt, ok := ifStmt.Init.(*ast.AssignStmt)
+ if !ok {
+ return
+ }
+
+ // iterate over left-hand side variables of the assignment
+ for _, lhs := range assignStmt.Lhs {
+ ident, ok := lhs.(*ast.Ident)
+ if !ok {
+ continue
+ }
+
+ // confirm type is error and it is used in condition
+ obj := pass.TypesInfo.ObjectOf(ident)
+ if !isError(obj) || ident.Name == "_" || !errorUsedInCondition(ifStmt.Cond, ident.Name) {
+ continue
+ }
+
+ // if there are more than 1 assignment
+ // or there are any variables with same name
+ // then we can make a shadow conflict with other variables
+ // so don't do anything beside simple error message
+ if len(assignStmt.Lhs) != 1 || (assignStmt.Tok == token.DEFINE && shadowVarsExists(ident.Name, pass.TypesInfo.Scopes[ifStmt])) {
+ pass.Reportf(ident.Pos(), errMessage(assignStmt.Tok))
+ return
+ }
+
+ // else we know there is a simple err assignment like
+ // if err := func(); err != nil {}
+ // and we can autofix that
+
+ var buf bytes.Buffer
+
+ _ = printer.Fprint(&buf, pass.Fset, assignStmt)
+ assignText := buf.String()
+
+ // report usage of inline error assignment
+ pass.Report(analysis.Diagnostic{
+ Pos: ident.Pos(),
+ End: ident.End(),
+ Message: errMessage(assignStmt.Tok),
+ SuggestedFixes: []analysis.SuggestedFix{
+ {
+ Message: "move err assignment outside if",
+ TextEdits: []analysis.TextEdit{
+ {
+ // insert err := ... or err = ... before if
+ Pos: ifStmt.Pos(),
+ End: ifStmt.Pos(),
+ NewText: []byte(assignText + "\n"),
+ },
+ {
+ // delete Init part
+ Pos: assignStmt.Pos(),
+ End: assignStmt.End() + 1, // +1 for ;
+ NewText: nil,
+ },
+ },
+ },
+ },
+ })
+ }
+ }
+}
+
+func isError(obj types.Object) bool {
+ if obj == nil {
+ return false
+ }
+
+ errorType := types.Universe.Lookup("error").Type()
+
+ return types.AssignableTo(obj.Type(), errorType)
+}
+
+func shadowVarsExists(name string, scope *types.Scope) bool {
+ if scope == nil {
+ return false
+ }
+
+ parentScope := scope.Parent()
+ if parentScope == nil {
+ return false
+ }
+
+ return parentScope.Lookup(name) != nil
+}
+
+func errorUsedInCondition(cond ast.Expr, errIdentName string) bool {
+ used := false
+
+ ast.Inspect(cond, func(n ast.Node) bool {
+ ident, ok := n.(*ast.Ident)
+ if !ok {
+ return true
+ }
+
+ if ident.Name == errIdentName {
+ used = true
+ return false
+ }
+
+ return true
+ })
+
+ return used
+}
diff --git a/vendor/github.com/Antonboom/errname/pkg/analyzer/analyzer.go b/vendor/github.com/Antonboom/errname/pkg/analyzer/analyzer.go
index 2b8794dc2c..669edcc209 100644
--- a/vendor/github.com/Antonboom/errname/pkg/analyzer/analyzer.go
+++ b/vendor/github.com/Antonboom/errname/pkg/analyzer/analyzer.go
@@ -21,7 +21,7 @@ func New() *analysis.Analyzer {
}
}
-func run(pass *analysis.Pass) (interface{}, error) {
+func run(pass *analysis.Pass) (any, error) {
insp := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
insp.Nodes([]ast.Node{
@@ -72,12 +72,12 @@ func run(pass *analysis.Pass) (interface{}, error) {
return true
})
- return nil, nil //nolint:nilnil
+ return nil, nil //nolint:nilnil // Integration interface of analysis.Analyzer.
}
func reportAboutErrorType(pass *analysis.Pass, typePos token.Pos, typeName string) {
var form string
- if unicode.IsLower([]rune(typeName)[0]) {
+ if startsWithLower(typeName) {
form = "xxxError"
} else {
form = "XxxError"
@@ -88,7 +88,7 @@ func reportAboutErrorType(pass *analysis.Pass, typePos token.Pos, typeName strin
func reportAboutArrayErrorType(pass *analysis.Pass, typePos token.Pos, typeName string) {
var forms string
- if unicode.IsLower([]rune(typeName)[0]) {
+ if startsWithLower(typeName) {
forms = "`xxxErrors` or `xxxError`"
} else {
forms = "`XxxErrors` or `XxxError`"
@@ -99,10 +99,14 @@ func reportAboutArrayErrorType(pass *analysis.Pass, typePos token.Pos, typeName
func reportAboutSentinelError(pass *analysis.Pass, pos token.Pos, varName string) {
var form string
- if unicode.IsLower([]rune(varName)[0]) {
+ if startsWithLower(varName) {
form = "errXxx"
} else {
form = "ErrXxx"
}
pass.Reportf(pos, "the sentinel error name `%s` should conform to the `%s` format", varName, form)
}
+
+func startsWithLower(n string) bool {
+ return unicode.IsLower([]rune(n)[0]) //nolint:gocritic // Source code is Unicode text encoded in UTF-8.
+}
diff --git a/vendor/github.com/Antonboom/nilnil/pkg/analyzer/analyzer.go b/vendor/github.com/Antonboom/nilnil/pkg/analyzer/analyzer.go
index 703cc1c39f..443d537148 100644
--- a/vendor/github.com/Antonboom/nilnil/pkg/analyzer/analyzer.go
+++ b/vendor/github.com/Antonboom/nilnil/pkg/analyzer/analyzer.go
@@ -31,7 +31,9 @@ func New() *analysis.Analyzer {
}
a.Flags.Var(&n.checkedTypes, "checked-types", "comma separated list of return types to check")
a.Flags.BoolVar(&n.detectOpposite, "detect-opposite", false,
- "in addition, detect opposite situation (simultaneous return of non-nil error and valid value)")
+ "in addition, to detect opposite situation (simultaneous return of non-nil error and valid value)")
+ a.Flags.BoolVar(&n.onlyTwo, "only-two", true,
+ "to check functions with only two return values")
return a
}
@@ -39,12 +41,14 @@ func New() *analysis.Analyzer {
type nilNil struct {
checkedTypes checkedTypes
detectOpposite bool
+ onlyTwo bool
}
func newNilNil() *nilNil {
return &nilNil{
checkedTypes: newDefaultCheckedTypes(),
detectOpposite: false,
+ onlyTwo: true,
}
}
@@ -54,7 +58,7 @@ var funcAndReturns = []ast.Node{
(*ast.ReturnStmt)(nil),
}
-func (n *nilNil) run(pass *analysis.Pass) (interface{}, error) {
+func (n *nilNil) run(pass *analysis.Pass) (any, error) {
insp := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
var fs funcTypeStack
@@ -77,44 +81,54 @@ func (n *nilNil) run(pass *analysis.Pass) (interface{}, error) {
case *ast.ReturnStmt:
ft := fs.Top() // Current function.
- if !push || len(v.Results) != 2 || ft == nil || ft.Results == nil || len(ft.Results.List) != 2 {
+ if !push {
return false
}
-
- fRes1Type := pass.TypesInfo.TypeOf(ft.Results.List[0].Type)
- if fRes1Type == nil {
+ if len(v.Results) < 2 {
return false
}
-
- fRes2Type := pass.TypesInfo.TypeOf(ft.Results.List[1].Type)
- if fRes2Type == nil {
+ if (ft == nil) || (ft.Results == nil) || (len(ft.Results.List) != len(v.Results)) {
+ // Unreachable.
return false
}
- ok, zv := n.isDangerNilType(fRes1Type)
- if !(ok && implementsError(fRes2Type)) {
- return false
+ lastIdx := len(ft.Results.List) - 1
+ if n.onlyTwo {
+ lastIdx = 1
}
- retVal, retErr := v.Results[0], v.Results[1]
-
- if ((zv == zeroValueNil) && isNil(pass, retVal) && isNil(pass, retErr)) ||
- ((zv == zeroValueZero) && isZero(retVal) && isNil(pass, retErr)) {
- pass.Reportf(v.Pos(), nilNilReportMsg)
+ lastFtRes := ft.Results.List[lastIdx]
+ if !implementsError(pass.TypesInfo.TypeOf(lastFtRes.Type)) {
return false
}
- if n.detectOpposite && (((zv == zeroValueNil) && !isNil(pass, retVal) && !isNil(pass, retErr)) ||
- ((zv == zeroValueZero) && !isZero(retVal) && !isNil(pass, retErr))) {
- pass.Reportf(v.Pos(), notNilNotNilReportMsg)
- return false
+ retErr := v.Results[lastIdx]
+ for i := range lastIdx {
+ retVal := v.Results[i]
+
+ zv, ok := n.isDangerNilType(pass.TypesInfo.TypeOf(ft.Results.List[i].Type))
+ if !ok {
+ continue
+ }
+
+ if ((zv == zeroValueNil) && isNil(pass, retVal) && isNil(pass, retErr)) ||
+ ((zv == zeroValueZero) && isZero(retVal) && isNil(pass, retErr)) {
+ pass.Reportf(v.Pos(), nilNilReportMsg)
+ return false
+ }
+
+ if n.detectOpposite && (((zv == zeroValueNil) && !isNil(pass, retVal) && !isNil(pass, retErr)) ||
+ ((zv == zeroValueZero) && !isZero(retVal) && !isNil(pass, retErr))) {
+ pass.Reportf(v.Pos(), notNilNotNilReportMsg)
+ return false
+ }
}
}
return true
})
- return nil, nil //nolint:nilnil
+ return nil, nil //nolint:nilnil // Integration interface of analysis.Analyzer.
}
type zeroValue int
@@ -124,35 +138,35 @@ const (
zeroValueZero
)
-func (n *nilNil) isDangerNilType(t types.Type) (bool, zeroValue) {
+func (n *nilNil) isDangerNilType(t types.Type) (zeroValue, bool) {
switch v := types.Unalias(t).(type) {
case *types.Pointer:
- return n.checkedTypes.Contains(ptrType), zeroValueNil
+ return zeroValueNil, n.checkedTypes.Contains(ptrType)
case *types.Signature:
- return n.checkedTypes.Contains(funcType), zeroValueNil
+ return zeroValueNil, n.checkedTypes.Contains(funcType)
case *types.Interface:
- return n.checkedTypes.Contains(ifaceType), zeroValueNil
+ return zeroValueNil, n.checkedTypes.Contains(ifaceType)
case *types.Map:
- return n.checkedTypes.Contains(mapType), zeroValueNil
+ return zeroValueNil, n.checkedTypes.Contains(mapType)
case *types.Chan:
- return n.checkedTypes.Contains(chanType), zeroValueNil
+ return zeroValueNil, n.checkedTypes.Contains(chanType)
case *types.Basic:
if v.Kind() == types.Uintptr {
- return n.checkedTypes.Contains(uintptrType), zeroValueZero
+ return zeroValueZero, n.checkedTypes.Contains(uintptrType)
}
if v.Kind() == types.UnsafePointer {
- return n.checkedTypes.Contains(unsafeptrType), zeroValueNil
+ return zeroValueNil, n.checkedTypes.Contains(unsafeptrType)
}
case *types.Named:
return n.isDangerNilType(v.Underlying())
}
- return false, 0
+ return 0, false
}
var errorIface = types.Universe.Lookup("error").Type().Underlying().(*types.Interface)
diff --git a/vendor/github.com/Antonboom/testifylint/analyzer/analyzer.go b/vendor/github.com/Antonboom/testifylint/analyzer/analyzer.go
index a9e41b0a8a..7111797141 100644
--- a/vendor/github.com/Antonboom/testifylint/analyzer/analyzer.go
+++ b/vendor/github.com/Antonboom/testifylint/analyzer/analyzer.go
@@ -5,9 +5,9 @@ import (
"go/ast"
"golang.org/x/tools/go/analysis"
+ "golang.org/x/tools/go/analysis/passes/inspect"
"golang.org/x/tools/go/ast/inspector"
- "github.com/Antonboom/testifylint/internal/analysisutil"
"github.com/Antonboom/testifylint/internal/checkers"
"github.com/Antonboom/testifylint/internal/config"
"github.com/Antonboom/testifylint/internal/testify"
@@ -24,9 +24,10 @@ func New() *analysis.Analyzer {
cfg := config.NewDefault()
analyzer := &analysis.Analyzer{
- Name: name,
- Doc: doc,
- URL: url,
+ Name: name,
+ Doc: doc,
+ URL: url,
+ Requires: []*analysis.Analyzer{inspect.Analyzer},
Run: func(pass *analysis.Pass) (any, error) {
regularCheckers, advancedCheckers, err := newCheckers(cfg)
if err != nil {
@@ -51,16 +52,14 @@ type testifyLint struct {
}
func (tl *testifyLint) run(pass *analysis.Pass) (any, error) {
- filesToAnalysis := make([]*ast.File, 0, len(pass.Files))
- for _, f := range pass.Files {
- if !analysisutil.Imports(f, testify.AssertPkgPath, testify.RequirePkgPath, testify.SuitePkgPath) {
- continue
- }
- filesToAnalysis = append(filesToAnalysis, f)
+ // NOTE(a.telyshev): There are no premature optimizations like "scan only _test.go" or
+ // "scan only files with testify imports", since it could lead to skip files
+ // with assertions (etc. test helpers in regular Go files or suite methods).
+ insp, ok := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
+ if !ok {
+ return nil, nil
}
- insp := inspector.New(filesToAnalysis)
-
// Regular checkers.
insp.Preorder([]ast.Node{(*ast.CallExpr)(nil)}, func(node ast.Node) {
tl.regularCheck(pass, node.(*ast.CallExpr))
diff --git a/vendor/github.com/Antonboom/testifylint/analyzer/checkers_factory.go b/vendor/github.com/Antonboom/testifylint/analyzer/checkers_factory.go
index df04dfdc5f..274ce85cea 100644
--- a/vendor/github.com/Antonboom/testifylint/analyzer/checkers_factory.go
+++ b/vendor/github.com/Antonboom/testifylint/analyzer/checkers_factory.go
@@ -58,6 +58,7 @@ func newCheckers(cfg config.Config) ([]checkers.RegularChecker, []checkers.Advan
case *checkers.Formatter:
c.SetCheckFormatString(cfg.Formatter.CheckFormatString)
c.SetRequireFFuncs(cfg.Formatter.RequireFFuncs)
+ c.SetRequireStringMsg(cfg.Formatter.RequireStringMsg)
case *checkers.GoRequire:
c.SetIgnoreHTTPHandlers(cfg.GoRequire.IgnoreHTTPHandlers)
diff --git a/vendor/github.com/Antonboom/testifylint/internal/checkers/bool_compare.go b/vendor/github.com/Antonboom/testifylint/internal/checkers/bool_compare.go
index 67959b633b..4bcd5304f2 100644
--- a/vendor/github.com/Antonboom/testifylint/internal/checkers/bool_compare.go
+++ b/vendor/github.com/Antonboom/testifylint/internal/checkers/bool_compare.go
@@ -43,7 +43,7 @@ func (checker BoolCompare) Check(pass *analysis.Pass, call *CallMeta) *analysis.
}
newUseFnDiagnostic := func(proposed string, survivingArg ast.Expr, replaceStart, replaceEnd token.Pos) *analysis.Diagnostic {
- if !isBuiltinBool(pass, survivingArg) {
+ if !hasBoolType(pass, survivingArg) {
if checker.ignoreCustomTypes {
return nil
}
@@ -65,7 +65,7 @@ func (checker BoolCompare) Check(pass *analysis.Pass, call *CallMeta) *analysis.
}
newNeedSimplifyDiagnostic := func(survivingArg ast.Expr, replaceStart, replaceEnd token.Pos) *analysis.Diagnostic {
- if !isBuiltinBool(pass, survivingArg) {
+ if !hasBoolType(pass, survivingArg) {
if checker.ignoreCustomTypes {
return nil
}
@@ -103,7 +103,7 @@ func (checker BoolCompare) Check(pass *analysis.Pass, call *CallMeta) *analysis.
switch {
case xor(t1, t2):
survivingArg, _ := anyVal([]bool{t1, t2}, arg2, arg1)
- if call.Fn.NameFTrimmed == "Exactly" && !isBuiltinBool(pass, survivingArg) {
+ if call.Fn.NameFTrimmed == "Exactly" && !hasBoolType(pass, survivingArg) {
// NOTE(a.telyshev): `Exactly` assumes no type conversion.
return nil
}
@@ -111,7 +111,7 @@ func (checker BoolCompare) Check(pass *analysis.Pass, call *CallMeta) *analysis.
case xor(f1, f2):
survivingArg, _ := anyVal([]bool{f1, f2}, arg2, arg1)
- if call.Fn.NameFTrimmed == "Exactly" && !isBuiltinBool(pass, survivingArg) {
+ if call.Fn.NameFTrimmed == "Exactly" && !hasBoolType(pass, survivingArg) {
// NOTE(a.telyshev): `Exactly` assumes no type conversion.
return nil
}
diff --git a/vendor/github.com/Antonboom/testifylint/internal/checkers/call_meta.go b/vendor/github.com/Antonboom/testifylint/internal/checkers/call_meta.go
index 96b5b19b09..3d9c3428ac 100644
--- a/vendor/github.com/Antonboom/testifylint/internal/checkers/call_meta.go
+++ b/vendor/github.com/Antonboom/testifylint/internal/checkers/call_meta.go
@@ -93,7 +93,7 @@ func NewCallMeta(pass *analysis.Pass, ce *ast.CallExpr) *CallMeta {
isAssert := analysisutil.IsPkg(initiatorPkg, testify.AssertPkgName, testify.AssertPkgPath)
isRequire := analysisutil.IsPkg(initiatorPkg, testify.RequirePkgName, testify.RequirePkgPath)
- if !(isAssert || isRequire) {
+ if !isAssert && !isRequire {
return nil
}
diff --git a/vendor/github.com/Antonboom/testifylint/internal/checkers/checker.go b/vendor/github.com/Antonboom/testifylint/internal/checkers/checker.go
index ac23af6f6f..0d8e9d2f4f 100644
--- a/vendor/github.com/Antonboom/testifylint/internal/checkers/checker.go
+++ b/vendor/github.com/Antonboom/testifylint/internal/checkers/checker.go
@@ -19,5 +19,5 @@ type RegularChecker interface {
// AdvancedChecker implements complex Check logic different from trivial CallMeta check.
type AdvancedChecker interface {
Checker
- Check(pass *analysis.Pass, inspector *inspector.Inspector) []analysis.Diagnostic
+ Check(pass *analysis.Pass, insp *inspector.Inspector) []analysis.Diagnostic
}
diff --git a/vendor/github.com/Antonboom/testifylint/internal/checkers/checkers_registry.go b/vendor/github.com/Antonboom/testifylint/internal/checkers/checkers_registry.go
index f881be4f20..264e18b6db 100644
--- a/vendor/github.com/Antonboom/testifylint/internal/checkers/checkers_registry.go
+++ b/vendor/github.com/Antonboom/testifylint/internal/checkers/checkers_registry.go
@@ -10,7 +10,6 @@ var registry = checkersRegistry{
{factory: asCheckerFactory(NewFloatCompare), enabledByDefault: true},
{factory: asCheckerFactory(NewBoolCompare), enabledByDefault: true},
{factory: asCheckerFactory(NewEmpty), enabledByDefault: true},
- {factory: asCheckerFactory(NewLen), enabledByDefault: true},
{factory: asCheckerFactory(NewNegativePositive), enabledByDefault: true},
{factory: asCheckerFactory(NewCompares), enabledByDefault: true},
{factory: asCheckerFactory(NewContains), enabledByDefault: true},
@@ -19,6 +18,8 @@ var registry = checkersRegistry{
{factory: asCheckerFactory(NewErrorIsAs), enabledByDefault: true},
{factory: asCheckerFactory(NewEncodedCompare), enabledByDefault: true},
{factory: asCheckerFactory(NewExpectedActual), enabledByDefault: true},
+ {factory: asCheckerFactory(NewLen), enabledByDefault: true},
+ {factory: asCheckerFactory(NewEqualValues), enabledByDefault: true},
{factory: asCheckerFactory(NewRegexp), enabledByDefault: true},
{factory: asCheckerFactory(NewSuiteExtraAssertCall), enabledByDefault: true},
{factory: asCheckerFactory(NewSuiteDontUsePkg), enabledByDefault: true},
@@ -29,6 +30,7 @@ var registry = checkersRegistry{
{factory: asCheckerFactory(NewGoRequire), enabledByDefault: true},
{factory: asCheckerFactory(NewRequireError), enabledByDefault: true},
{factory: asCheckerFactory(NewSuiteBrokenParallel), enabledByDefault: true},
+ {factory: asCheckerFactory(NewSuiteMethodSignature), enabledByDefault: true},
{factory: asCheckerFactory(NewSuiteSubtestRun), enabledByDefault: true},
{factory: asCheckerFactory(NewSuiteTHelper), enabledByDefault: false},
}
diff --git a/vendor/github.com/Antonboom/testifylint/internal/checkers/empty.go b/vendor/github.com/Antonboom/testifylint/internal/checkers/empty.go
index 71657fe117..854421e6a9 100644
--- a/vendor/github.com/Antonboom/testifylint/internal/checkers/empty.go
+++ b/vendor/github.com/Antonboom/testifylint/internal/checkers/empty.go
@@ -11,31 +11,41 @@ import (
// Empty detects situations like
//
-// assert.Len(t, arr, 0)
-// assert.Equal(t, 0, len(arr))
-// assert.EqualValues(t, 0, len(arr))
-// assert.Exactly(t, 0, len(arr))
-// assert.LessOrEqual(t, len(arr), 0)
-// assert.GreaterOrEqual(t, 0, len(arr))
-// assert.Less(t, len(arr), 0)
-// assert.Greater(t, 0, len(arr))
-// assert.Less(t, len(arr), 1)
-// assert.Greater(t, 1, len(arr))
-// assert.Zero(t, len(arr))
-// assert.Empty(t, len(arr))
+// assert.Len(t, arr, 0)
+// assert.Zero(t, str)
+// assert.Zero(t, len(arr))
+// assert.Equal(t, 0, len(arr))
+// assert.EqualValues(t, 0, len(arr))
+// assert.Exactly(t, 0, len(arr))
+// assert.LessOrEqual(t, len(arr), 0)
+// assert.GreaterOrEqual(t, 0, len(arr))
+// assert.Less(t, len(arr), 1)
+// assert.Greater(t, 1, len(arr))
+// assert.Equal(t, "", str)
+// assert.EqualValues(t, "", str)
+// assert.Exactly(t, "", str)
+// assert.Equal(t, “, str)
+// assert.EqualValues(t, “, str)
+// assert.Exactly(t, “, str)
//
-// assert.NotEqual(t, 0, len(arr))
-// assert.NotEqualValues(t, 0, len(arr))
-// assert.Less(t, 0, len(arr))
-// assert.Greater(t, len(arr), 0)
-// assert.Positive(t, len(arr))
-// assert.NotZero(t, len(arr))
-// assert.NotEmpty(t, len(arr))
+// assert.Positive(t, len(arr))
+// assert.NotZero(t, str)
+// assert.NotZero(t, len(arr))
+// assert.NotEqual(t, 0, len(arr))
+// assert.NotEqualValues(t, 0, len(arr))
+// assert.Greater(t, len(arr), 0)
+// assert.Less(t, 0, len(arr))
+// assert.NotEqual(t, "", str)
+// assert.NotEqualValues(t, "", str)
+// assert.NotEqual(t, “, str)
+// assert.NotEqualValues(t, “, str)
//
// and requires
//
// assert.Empty(t, arr)
// assert.NotEmpty(t, arr)
+//
+// Also Empty removes extra `len` call.
type Empty struct{}
// NewEmpty constructs Empty checker.
@@ -49,7 +59,7 @@ func (checker Empty) Check(pass *analysis.Pass, call *CallMeta) *analysis.Diagno
return checker.checkNotEmpty(pass, call)
}
-func (checker Empty) checkEmpty(pass *analysis.Pass, call *CallMeta) *analysis.Diagnostic { //nolint:gocognit
+func (checker Empty) checkEmpty(pass *analysis.Pass, call *CallMeta) *analysis.Diagnostic { //nolint:gocognit // It is ok.
newUseEmptyDiagnostic := func(replaceStart, replaceEnd token.Pos, replaceWith ast.Expr) *analysis.Diagnostic {
const proposed = "Empty"
return newUseFunctionDiagnostic(checker.Name(), call, proposed,
@@ -67,6 +77,9 @@ func (checker Empty) checkEmpty(pass *analysis.Pass, call *CallMeta) *analysis.D
switch call.Fn.NameFTrimmed {
case "Zero":
+ if hasStringType(pass, a) {
+ return newUseEmptyDiagnostic(a.Pos(), a.End(), a)
+ }
if lenArg, ok := isBuiltinLenCall(pass, a); ok {
return newUseEmptyDiagnostic(a.Pos(), a.End(), lenArg)
}
@@ -89,6 +102,10 @@ func (checker Empty) checkEmpty(pass *analysis.Pass, call *CallMeta) *analysis.D
}
case "Equal", "EqualValues", "Exactly":
+ if isEmptyStringLit(a) {
+ return newUseEmptyDiagnostic(a.Pos(), b.End(), b)
+ }
+
arg1, ok1 := isLenCallAndZero(pass, a, b)
arg2, ok2 := isLenCallAndZero(pass, b, a)
@@ -119,7 +136,7 @@ func (checker Empty) checkEmpty(pass *analysis.Pass, call *CallMeta) *analysis.D
return nil
}
-func (checker Empty) checkNotEmpty(pass *analysis.Pass, call *CallMeta) *analysis.Diagnostic { //nolint:gocognit
+func (checker Empty) checkNotEmpty(pass *analysis.Pass, call *CallMeta) *analysis.Diagnostic { //nolint:gocognit // It is ok.
newUseNotEmptyDiagnostic := func(replaceStart, replaceEnd token.Pos, replaceWith ast.Expr) *analysis.Diagnostic {
const proposed = "NotEmpty"
return newUseFunctionDiagnostic(checker.Name(), call, proposed,
@@ -136,7 +153,15 @@ func (checker Empty) checkNotEmpty(pass *analysis.Pass, call *CallMeta) *analysi
a := call.Args[0]
switch call.Fn.NameFTrimmed {
- case "NotZero", "Positive":
+ case "Positive":
+ if lenArg, ok := isBuiltinLenCall(pass, a); ok {
+ return newUseNotEmptyDiagnostic(a.Pos(), a.End(), lenArg)
+ }
+
+ case "NotZero":
+ if hasStringType(pass, a) {
+ return newUseNotEmptyDiagnostic(a.Pos(), a.End(), a)
+ }
if lenArg, ok := isBuiltinLenCall(pass, a); ok {
return newUseNotEmptyDiagnostic(a.Pos(), a.End(), lenArg)
}
@@ -154,6 +179,10 @@ func (checker Empty) checkNotEmpty(pass *analysis.Pass, call *CallMeta) *analysi
switch call.Fn.NameFTrimmed {
case "NotEqual", "NotEqualValues":
+ if isEmptyStringLit(a) {
+ return newUseNotEmptyDiagnostic(a.Pos(), b.End(), b)
+ }
+
arg1, ok1 := isLenCallAndZero(pass, a, b)
arg2, ok2 := isLenCallAndZero(pass, b, a)
diff --git a/vendor/github.com/Antonboom/testifylint/internal/checkers/equal_values.go b/vendor/github.com/Antonboom/testifylint/internal/checkers/equal_values.go
new file mode 100644
index 0000000000..c8f305c3e2
--- /dev/null
+++ b/vendor/github.com/Antonboom/testifylint/internal/checkers/equal_values.go
@@ -0,0 +1,59 @@
+package checkers
+
+import (
+ "go/types"
+ "strings"
+
+ "golang.org/x/tools/go/analysis"
+)
+
+// EqualValues detects situations like
+//
+// assert.EqualValues(t, 42, result.IntField)
+// assert.NotEqualValues(t, 42, result.IntField)
+// ...
+//
+// and requires
+//
+// assert.Equal(t, 42, result.IntField)
+// assert.NotEqual(t, 42, result.IntField)
+type EqualValues struct{}
+
+// NewEqualValues constructs EqualValues checker.
+func NewEqualValues() EqualValues { return EqualValues{} }
+func (EqualValues) Name() string { return "equal-values" }
+
+func (checker EqualValues) Check(pass *analysis.Pass, call *CallMeta) *analysis.Diagnostic {
+ assrn := call.Fn.NameFTrimmed
+ switch assrn {
+ default:
+ return nil
+ case "EqualValues", "NotEqualValues":
+ }
+
+ if len(call.Args) < 2 {
+ return nil
+ }
+ first, second := call.Args[0], call.Args[1]
+
+ if isFunc(pass, first) || isFunc(pass, second) {
+ // NOTE(a.telyshev): EqualValues for funcs is ok, but not Equal:
+ // https://github.com/stretchr/testify/issues/1524
+ return nil
+ }
+
+ ft, st := pass.TypesInfo.TypeOf(first), pass.TypesInfo.TypeOf(second)
+ if !types.Identical(ft, st) {
+ return nil
+ }
+
+ // Type of one of arguments is equivalent to any.
+ if isEmptyInterfaceType(ft) || isEmptyInterfaceType(st) {
+ // EqualValues is ok here.
+ // Equal would check their types and would fail.
+ return nil
+ }
+
+ proposed := strings.TrimSuffix(assrn, "Values")
+ return newUseFunctionDiagnostic(checker.Name(), call, proposed)
+}
diff --git a/vendor/github.com/Antonboom/testifylint/internal/checkers/error_is_as.go b/vendor/github.com/Antonboom/testifylint/internal/checkers/error_is_as.go
index f2812c9393..ac9d968b8e 100644
--- a/vendor/github.com/Antonboom/testifylint/internal/checkers/error_is_as.go
+++ b/vendor/github.com/Antonboom/testifylint/internal/checkers/error_is_as.go
@@ -6,21 +6,30 @@ import (
"go/types"
"golang.org/x/tools/go/analysis"
+
+ "github.com/Antonboom/testifylint/internal/analysisutil"
+ "github.com/Antonboom/testifylint/internal/testify"
)
// ErrorIsAs detects situations like
//
// assert.Error(t, err, errSentinel)
// assert.NoError(t, err, errSentinel)
+// assert.IsType(t, err, errSentinel)
+// assert.IsType(t, (*http.MaxBytesError)(nil), err)
+// assert.IsNotType(t, err, errSentinel)
+// assert.IsNotType(t, store.NotFoundError{}, err)
// assert.True(t, errors.Is(err, errSentinel))
// assert.False(t, errors.Is(err, errSentinel))
// assert.True(t, errors.As(err, &target))
+// assert.False(t, errors.As(err, &target))
//
// and requires
//
// assert.ErrorIs(t, err, errSentinel)
// assert.NotErrorIs(t, err, errSentinel)
// assert.ErrorAs(t, err, &target)
+// assert.NotErrorAs(t, err, &target)
//
// Also ErrorIsAs repeats go vet's "errorsas" check logic.
type ErrorIsAs struct{}
@@ -32,7 +41,7 @@ func (ErrorIsAs) Name() string { return "error-is-as" }
func (checker ErrorIsAs) Check(pass *analysis.Pass, call *CallMeta) *analysis.Diagnostic {
switch call.Fn.NameFTrimmed {
case "Error":
- if len(call.Args) >= 2 && isError(pass, call.Args[1]) {
+ if len(call.Args) >= 2 && isError(pass, call.Args[1]) && !isAssertCollectT(pass, call.Selector.X) {
const proposed = "ErrorIs"
msg := fmt.Sprintf("invalid usage of %[1]s.Error, use %[1]s.%[2]s instead", call.SelectorXStr, proposed)
return newDiagnostic(checker.Name(), call, msg, newSuggestedFuncReplacement(call, proposed))
@@ -45,6 +54,18 @@ func (checker ErrorIsAs) Check(pass *analysis.Pass, call *CallMeta) *analysis.Di
return newDiagnostic(checker.Name(), call, msg, newSuggestedFuncReplacement(call, proposed))
}
+ case "IsType":
+ if len(call.Args) >= 2 && isError(pass, call.Args[0]) || isError(pass, call.Args[1]) {
+ msg := fmt.Sprintf("use %[1]s.ErrorIs or %[1]s.ErrorAs depending on the case", call.SelectorXStr)
+ return newDiagnostic(checker.Name(), call, msg)
+ }
+
+ case "IsNotType":
+ if len(call.Args) >= 2 && isError(pass, call.Args[0]) || isError(pass, call.Args[1]) {
+ msg := fmt.Sprintf("use %[1]s.NotErrorIs or %[1]s.NotErrorAs depending on the case", call.SelectorXStr)
+ return newDiagnostic(checker.Name(), call, msg)
+ }
+
case "True":
if len(call.Args) < 1 {
return nil
@@ -87,8 +108,14 @@ func (checker ErrorIsAs) Check(pass *analysis.Pass, call *CallMeta) *analysis.Di
return nil
}
- if isErrorsIsCall(pass, ce) {
- const proposed = "NotErrorIs"
+ var proposed string
+ switch {
+ case isErrorsIsCall(pass, ce):
+ proposed = "NotErrorIs"
+ case isErrorsAsCall(pass, ce):
+ proposed = "NotErrorAs"
+ }
+ if proposed != "" {
return newUseFunctionDiagnostic(checker.Name(), call, proposed,
analysis.TextEdit{
Pos: ce.Pos(),
@@ -97,7 +124,7 @@ func (checker ErrorIsAs) Check(pass *analysis.Pass, call *CallMeta) *analysis.Di
})
}
- case "ErrorAs":
+ case "ErrorAs", "NotErrorAs":
if len(call.Args) < 2 {
return nil
}
@@ -138,3 +165,18 @@ func (checker ErrorIsAs) Check(pass *analysis.Pass, call *CallMeta) *analysis.Di
}
return nil
}
+
+func isAssertCollectT(pass *analysis.Pass, e ast.Expr) bool {
+ ptr, ok := pass.TypesInfo.TypeOf(e).(*types.Pointer)
+ if !ok {
+ return false
+ }
+
+ named, ok := ptr.Elem().(*types.Named)
+ if !ok {
+ return false
+ }
+
+ collectT := analysisutil.ObjectOf(pass.Pkg, testify.AssertPkgPath, "CollectT")
+ return named.Obj() == collectT
+}
diff --git a/vendor/github.com/Antonboom/testifylint/internal/checkers/error_nil.go b/vendor/github.com/Antonboom/testifylint/internal/checkers/error_nil.go
index b9f28df218..b7ced9a8d0 100644
--- a/vendor/github.com/Antonboom/testifylint/internal/checkers/error_nil.go
+++ b/vendor/github.com/Antonboom/testifylint/internal/checkers/error_nil.go
@@ -18,6 +18,7 @@ import (
// assert.EqualValues(t, nil, err)
// assert.Exactly(t, nil, err)
// assert.ErrorIs(t, err, nil)
+// assert.IsType(t, err, nil)
//
// assert.NotNil(t, err)
// assert.NotEmpty(t, err)
@@ -25,6 +26,7 @@ import (
// assert.NotEqual(t, nil, err)
// assert.NotEqualValues(t, nil, err)
// assert.NotErrorIs(t, err, nil)
+// assert.IsNotType(t, err, nil)
//
// and requires
//
@@ -54,7 +56,7 @@ func (checker ErrorNil) Check(pass *analysis.Pass, call *CallMeta) *analysis.Dia
return errorFn, call.Args[0], call.Args[0].End()
}
- case "Equal", "EqualValues", "Exactly", "ErrorIs":
+ case "Equal", "EqualValues", "Exactly", "ErrorIs", "IsType":
if len(call.Args) < 2 {
return "", nil, token.NoPos
}
@@ -67,7 +69,7 @@ func (checker ErrorNil) Check(pass *analysis.Pass, call *CallMeta) *analysis.Dia
return noErrorFn, b, b.End()
}
- case "NotEqual", "NotEqualValues", "NotErrorIs":
+ case "NotEqual", "NotEqualValues", "NotErrorIs", "IsNotType":
if len(call.Args) < 2 {
return "", nil, token.NoPos
}
diff --git a/vendor/github.com/Antonboom/testifylint/internal/checkers/expected_actual.go b/vendor/github.com/Antonboom/testifylint/internal/checkers/expected_actual.go
index 351d675cef..e0467ac70b 100644
--- a/vendor/github.com/Antonboom/testifylint/internal/checkers/expected_actual.go
+++ b/vendor/github.com/Antonboom/testifylint/internal/checkers/expected_actual.go
@@ -17,6 +17,8 @@ var DefaultExpectedVarPattern = regexp.MustCompile(
// ExpectedActual detects situations like
//
// assert.Equal(t, result, expected)
+// assert.Equal(t, result, len(expected))
+// assert.Equal(t, len(resultFields), len(expectedFields))
// assert.EqualExportedValues(t, resultObj, User{Name: "Anton"})
// assert.EqualValues(t, result, 42)
// assert.Exactly(t, result, int64(42))
@@ -37,6 +39,8 @@ var DefaultExpectedVarPattern = regexp.MustCompile(
// and requires
//
// assert.Equal(t, expected, result)
+// assert.Equal(t, len(expected), result)
+// assert.Equal(t, len(expectedFields), len(resultFields))
// assert.EqualExportedValues(t, User{Name: "Anton"}, resultObj)
// assert.EqualValues(t, 42, result)
// ...
@@ -69,6 +73,7 @@ func (checker ExpectedActual) Check(pass *analysis.Pass, call *CallMeta) *analys
"InDeltaSlice",
"InEpsilon",
"InEpsilonSlice",
+ "IsNotType",
"IsType",
"JSONEq",
"NotEqual",
@@ -116,12 +121,17 @@ func (checker ExpectedActual) isExpectedValueCandidate(pass *analysis.Pass, expr
return checker.isExpectedValueCandidate(pass, v.X)
case *ast.UnaryExpr:
- return (v.Op == token.AND) && checker.isExpectedValueCandidate(pass, v.X) // &value
+ if v.Op == token.AND || v.Op == token.SUB { // &value, -value
+ return checker.isExpectedValueCandidate(pass, v.X)
+ }
case *ast.CompositeLit:
return true
case *ast.CallExpr:
+ if lv, ok := isBuiltinLenCall(pass, expr); ok {
+ return isIdentNamedAfterPattern(checker.expVarPattern, lv)
+ }
return isParenExpr(v) ||
isCastedBasicLitOrExpectedValue(v, checker.expVarPattern) ||
isExpectedValueFactory(pass, v, checker.expVarPattern)
diff --git a/vendor/github.com/Antonboom/testifylint/internal/checkers/formatter.go b/vendor/github.com/Antonboom/testifylint/internal/checkers/formatter.go
index 7ff4de470a..572e88f965 100644
--- a/vendor/github.com/Antonboom/testifylint/internal/checkers/formatter.go
+++ b/vendor/github.com/Antonboom/testifylint/internal/checkers/formatter.go
@@ -1,8 +1,10 @@
package checkers
import (
+ "fmt"
"go/types"
"strconv"
+ "strings"
"golang.org/x/tools/go/analysis"
@@ -25,9 +27,15 @@ import (
// assert.Errorf(t, err, "Profile %s should not be valid", test.profile)
// assert.Errorf(t, err, "test %s", test.testName)
// assert.Truef(t, targetTs.Equal(ts), "the timestamp should be as expected (%s) but was %s", targetTs, ts)
+//
+// It also checks that there are no arguments in `msgAndArgs` if the message is not a string,
+// and additionally checks that the first argument of `msgAndArgs` is a not empty string.
+//
+// Finally, it checks that failure message in Fail and FailNow is not used as a format string (which won't work).
type Formatter struct {
checkFormatString bool
requireFFuncs bool
+ requireStringMsg bool
}
// NewFormatter constructs Formatter checker.
@@ -35,6 +43,7 @@ func NewFormatter() *Formatter {
return &Formatter{
checkFormatString: true,
requireFFuncs: false,
+ requireStringMsg: true,
}
}
@@ -50,6 +59,11 @@ func (checker *Formatter) SetRequireFFuncs(v bool) *Formatter {
return checker
}
+func (checker *Formatter) SetRequireStringMsg(v bool) *Formatter {
+ checker.requireStringMsg = v
+ return checker
+}
+
func (checker Formatter) Check(pass *analysis.Pass, call *CallMeta) (result *analysis.Diagnostic) {
if call.Fn.IsFmt {
return checker.checkFmtAssertion(pass, call)
@@ -63,21 +77,64 @@ func (checker Formatter) checkNotFmtAssertion(pass *analysis.Pass, call *CallMet
return nil
}
- fFunc := call.Fn.Name + "f"
+ lastArgPos := len(call.ArgsRaw) - 1
+ isSingleMsgAndArgElem := msgAndArgsPos == lastArgPos
+ msgAndArgs := call.ArgsRaw[msgAndArgsPos]
- if msgAndArgsPos == len(call.ArgsRaw)-1 {
- msgAndArgs := call.ArgsRaw[msgAndArgsPos]
- if args, ok := isFmtSprintfCall(pass, msgAndArgs); ok {
- if checker.requireFFuncs {
- return newRemoveFnAndUseDiagnostic(pass, checker.Name(), call, fFunc,
- "fmt.Sprintf", msgAndArgs, args...)
- }
- return newRemoveSprintfDiagnostic(pass, checker.Name(), call, msgAndArgs, args)
+ if name := call.Fn.NameFTrimmed; name == "Fail" || name == "FailNow" {
+ failureMsg, err := strconv.Unquote(analysisutil.NodeString(pass.Fset, call.Args[0]))
+ if err != nil {
+ return nil
+ }
+ if strings.Contains(failureMsg, "%") {
+ return newDiagnostic(checker.Name(), call,
+ "failure message is not a format string, use msgAndArgs instead")
}
}
- if checker.requireFFuncs {
- return newUseFunctionDiagnostic(checker.Name(), call, fFunc)
+ if args, ok := isFmtSprintfCall(pass, msgAndArgs); ok && isSingleMsgAndArgElem {
+ if checker.requireFFuncs {
+ return newRemoveFnAndUseDiagnostic(pass, checker.Name(), call, call.Fn.Name+"f",
+ "fmt.Sprintf", msgAndArgs, args...)
+ }
+ return newRemoveSprintfDiagnostic(pass, checker.Name(), call, msgAndArgs, args)
+ }
+
+ if hasStringType(pass, msgAndArgs) { //nolint:nestif // This is the best option of code organization :(
+ format, err := strconv.Unquote(analysisutil.NodeString(pass.Fset, msgAndArgs))
+ if nil == err && format == "" { // Unquote failed for not string literals.
+ var fixes []analysis.SuggestedFix
+ if isSingleMsgAndArgElem {
+ fixes = append(fixes, analysis.SuggestedFix{
+ Message: "Remove empty message",
+ TextEdits: []analysis.TextEdit{newRemoveLastArgTextEdit(pass, call.Args)},
+ })
+ }
+ return newDiagnostic(checker.Name(), call, "empty message", fixes...)
+ }
+ if checker.requireFFuncs {
+ return newUseFunctionDiagnostic(checker.Name(), call, call.Fn.Name+"f")
+ }
+ } else {
+ if isSingleMsgAndArgElem { //nolint:revive // Better without early-return.
+ if checker.requireStringMsg {
+ return newDiagnostic(checker.Name(), call,
+ "do not use non-string value as first element (msg) of msgAndArgs",
+ analysis.SuggestedFix{
+ Message: `Introduce "%+v" as the message`,
+ TextEdits: []analysis.TextEdit{
+ {
+ Pos: msgAndArgs.Pos(),
+ End: msgAndArgs.End(),
+ NewText: []byte(`"%+v", ` + analysisutil.NodeString(pass.Fset, msgAndArgs)),
+ },
+ },
+ })
+ }
+ } else {
+ return newDiagnostic(checker.Name(), call,
+ "using msgAndArgs with non-string first element (msg) causes panic")
+ }
}
return nil
}
@@ -88,14 +145,35 @@ func (checker Formatter) checkFmtAssertion(pass *analysis.Pass, call *CallMeta)
return nil
}
+ lastArgPos := len(call.ArgsRaw) - 1
msg := call.ArgsRaw[formatPos]
+ noFormatArgs := formatPos == lastArgPos
- if formatPos == len(call.ArgsRaw)-1 {
+ if formatPos == lastArgPos {
if args, ok := isFmtSprintfCall(pass, msg); ok {
return newRemoveSprintfDiagnostic(pass, checker.Name(), call, msg, args)
}
}
+ format, err := strconv.Unquote(analysisutil.NodeString(pass.Fset, msg))
+ if err != nil {
+ // Unreachable, because msg is a string literal in formatted assertion.
+ return nil
+ }
+ if format == "" {
+ var fixes []analysis.SuggestedFix
+ if noFormatArgs {
+ fixes = append(fixes, analysis.SuggestedFix{
+ Message: fmt.Sprintf("Remove empty message and use `%s`", call.Fn.NameFTrimmed),
+ TextEdits: []analysis.TextEdit{
+ newReplaceFnTextEdit(call.Fn, call.Fn.NameFTrimmed),
+ newRemoveLastArgTextEdit(pass, call.Args),
+ },
+ })
+ }
+ return newDiagnostic(checker.Name(), call, "empty message", fixes...)
+ }
+
if checker.checkFormatString {
report := pass.Report
defer func() { pass.Report = report }()
@@ -103,23 +181,22 @@ func (checker Formatter) checkFmtAssertion(pass *analysis.Pass, call *CallMeta)
pass.Report = func(d analysis.Diagnostic) {
result = newDiagnostic(checker.Name(), call, d.Message)
}
-
- format, err := strconv.Unquote(analysisutil.NodeString(pass.Fset, msg))
- if err != nil {
- return nil
- }
printf.CheckPrintf(pass, call.Call, call.String(), format, formatPos)
}
return result
}
func isPrintfLikeCall(pass *analysis.Pass, call *CallMeta) (int, bool) {
+ if call.Call.Ellipsis.IsValid() {
+ return -1, false
+ }
+
msgAndArgsPos := getMsgAndArgsPosition(call.Fn.Signature)
if msgAndArgsPos <= 0 {
return -1, false
}
- if !(len(call.ArgsRaw) > msgAndArgsPos && hasStringType(pass, call.ArgsRaw[msgAndArgsPos])) {
+ if msgAndArgsPos >= len(call.ArgsRaw) {
return -1, false
}
@@ -153,7 +230,7 @@ func assertHasFormattedAnalogue(pass *analysis.Pass, call *CallMeta) bool {
if !ok {
return false
}
- for i := 0; i < suite.NumMethods(); i++ {
+ for i := range suite.NumMethods() {
if suite.Method(i).Name() == call.Fn.Name+"f" {
return true
}
@@ -179,10 +256,11 @@ func getMsgAndArgsPosition(sig *types.Signature) int {
}
func getMsgPosition(sig *types.Signature) int {
- for i := 0; i < sig.Params().Len(); i++ {
+ for i := range sig.Params().Len() {
param := sig.Params().At(i)
- if b, ok := param.Type().(*types.Basic); ok && b.Kind() == types.String && param.Name() == "msg" {
+ if b, ok := param.Type().(*types.Basic); ok && b.Kind() == types.String && (param.Name() == "msg" ||
+ param.Name() == "format") { // NOTE(a.telyshev): assert.CollectT case.
return i
}
}
diff --git a/vendor/github.com/Antonboom/testifylint/internal/checkers/go_require.go b/vendor/github.com/Antonboom/testifylint/internal/checkers/go_require.go
index 8b0d39999e..4a0eb294e4 100644
--- a/vendor/github.com/Antonboom/testifylint/internal/checkers/go_require.go
+++ b/vendor/github.com/Antonboom/testifylint/internal/checkers/go_require.go
@@ -57,9 +57,9 @@ func (checker *GoRequire) SetIgnoreHTTPHandlers(v bool) *GoRequire {
// Other test functions called in the test function are also analyzed to make a verdict about the current function.
// This leads to recursion, which the cache of processed functions (processedFuncs) helps reduce the impact of.
// Also, because of this, we have to pre-collect a list of test function declarations (testsDecls).
-func (checker GoRequire) Check(pass *analysis.Pass, inspector *inspector.Inspector) (diagnostics []analysis.Diagnostic) {
+func (checker GoRequire) Check(pass *analysis.Pass, insp *inspector.Inspector) (diagnostics []analysis.Diagnostic) {
testsDecls := make(funcDeclarations)
- inspector.Preorder([]ast.Node{(*ast.FuncDecl)(nil)}, func(node ast.Node) {
+ insp.Preorder([]ast.Node{(*ast.FuncDecl)(nil)}, func(node ast.Node) {
fd := node.(*ast.FuncDecl)
if isTestingFuncOrMethod(pass, fd) {
@@ -78,7 +78,7 @@ func (checker GoRequire) Check(pass *analysis.Pass, inspector *inspector.Inspect
(*ast.GoStmt)(nil),
(*ast.CallExpr)(nil),
}
- inspector.Nodes(nodesFilter, func(node ast.Node, push bool) bool {
+ insp.Nodes(nodesFilter, func(node ast.Node, push bool) bool {
if fd, ok := node.(*ast.FuncDecl); ok {
if !isTestingFuncOrMethod(pass, fd) {
return false
@@ -171,7 +171,7 @@ func (checker GoRequire) Check(pass *analysis.Pass, inspector *inspector.Inspect
})
if !checker.ignoreHTTPHandlers {
- diagnostics = append(diagnostics, checker.checkHTTPHandlers(pass, inspector)...)
+ diagnostics = append(diagnostics, checker.checkHTTPHandlers(pass, insp)...)
}
return diagnostics
diff --git a/vendor/github.com/Antonboom/testifylint/internal/checkers/helpers_basic_type.go b/vendor/github.com/Antonboom/testifylint/internal/checkers/helpers_basic_type.go
index b4bb563219..a716cb0e2f 100644
--- a/vendor/github.com/Antonboom/testifylint/internal/checkers/helpers_basic_type.go
+++ b/vendor/github.com/Antonboom/testifylint/internal/checkers/helpers_basic_type.go
@@ -37,7 +37,7 @@ func isTypedUnsignedIntNumber(e ast.Expr, v int) bool {
return isTypedIntNumber(e, v, "uint", "uint8", "uint16", "uint32", "uint64")
}
-func isTypedIntNumber(e ast.Expr, v int, types ...string) bool {
+func isTypedIntNumber(e ast.Expr, v int, goTypes ...string) bool {
ce, ok := e.(*ast.CallExpr)
if !ok || len(ce.Args) != 1 {
return false
@@ -48,7 +48,7 @@ func isTypedIntNumber(e ast.Expr, v int, types ...string) bool {
return false
}
- for _, t := range types {
+ for _, t := range goTypes {
if fn.Name == t {
return isIntNumber(ce.Args[0], v)
}
@@ -61,27 +61,23 @@ func isIntNumber(e ast.Expr, rhs int) bool {
return ok && (lhs == rhs)
}
-func isNegativeIntNumber(e ast.Expr) bool {
- v, ok := isIntBasicLit(e)
- return ok && v < 0
-}
-
-func isPositiveIntNumber(e ast.Expr) bool {
- v, ok := isIntBasicLit(e)
- return ok && v > 0
-}
-
-func isEmptyStringLit(e ast.Expr) bool {
+func isStringLit(e ast.Expr) bool {
bl, ok := e.(*ast.BasicLit)
- return ok && bl.Kind == token.STRING && bl.Value == `""`
+ return ok && bl.Kind == token.STRING
}
-func isNotEmptyStringLit(e ast.Expr) bool {
+func isEmptyStringLit(e ast.Expr) bool {
bl, ok := e.(*ast.BasicLit)
- return ok && bl.Kind == token.STRING && bl.Value != `""`
+ return ok && bl.Kind == token.STRING && (bl.Value == `""` || bl.Value == "``")
}
func isBasicLit(e ast.Expr) bool {
+ if un, ok := e.(*ast.UnaryExpr); ok {
+ if un.Op == token.SUB {
+ return isBasicLit(un.X)
+ }
+ }
+
_, ok := e.(*ast.BasicLit)
return ok
}
@@ -144,6 +140,11 @@ func isPointer(pass *analysis.Pass, e ast.Expr) (types.Type, bool) {
return ptr.Elem(), true
}
+func isFunc(pass *analysis.Pass, e ast.Expr) bool {
+ _, ok := pass.TypesInfo.TypeOf(e).(*types.Signature)
+ return ok
+}
+
// isByteArray returns true if expression is `[]byte` itself.
func isByteArray(e ast.Expr) bool {
at, ok := e.(*ast.ArrayType)
@@ -171,12 +172,3 @@ func hasStringType(pass *analysis.Pass, e ast.Expr) bool {
basicType, ok := pass.TypesInfo.TypeOf(e).(*types.Basic)
return ok && basicType.Kind() == types.String
}
-
-// untype returns v from type(v) expression or v itself if there is no type conversion.
-func untype(e ast.Expr) ast.Expr {
- ce, ok := e.(*ast.CallExpr)
- if !ok || len(ce.Args) != 1 {
- return e
- }
- return ce.Args[0]
-}
diff --git a/vendor/github.com/Antonboom/testifylint/internal/checkers/helpers_bool.go b/vendor/github.com/Antonboom/testifylint/internal/checkers/helpers_bool.go
index 13e579a2b0..613f2fd30d 100644
--- a/vendor/github.com/Antonboom/testifylint/internal/checkers/helpers_bool.go
+++ b/vendor/github.com/Antonboom/testifylint/internal/checkers/helpers_bool.go
@@ -14,6 +14,10 @@ var (
trueObj = types.Universe.Lookup("true")
)
+func isUntypedBool(pass *analysis.Pass, e ast.Expr) bool {
+ return isUntypedTrue(pass, e) || isUntypedFalse(pass, e)
+}
+
func isUntypedTrue(pass *analysis.Pass, e ast.Expr) bool {
return analysisutil.IsObj(pass.TypesInfo, e, trueObj)
}
@@ -22,7 +26,7 @@ func isUntypedFalse(pass *analysis.Pass, e ast.Expr) bool {
return analysisutil.IsObj(pass.TypesInfo, e, falseObj)
}
-func isBuiltinBool(pass *analysis.Pass, e ast.Expr) bool {
+func hasBoolType(pass *analysis.Pass, e ast.Expr) bool {
basicType, ok := pass.TypesInfo.TypeOf(e).(*types.Basic)
return ok && basicType.Kind() == types.Bool
}
diff --git a/vendor/github.com/Antonboom/testifylint/internal/checkers/helpers_comparison.go b/vendor/github.com/Antonboom/testifylint/internal/checkers/helpers_comparison.go
index ac11d73990..e628443074 100644
--- a/vendor/github.com/Antonboom/testifylint/internal/checkers/helpers_comparison.go
+++ b/vendor/github.com/Antonboom/testifylint/internal/checkers/helpers_comparison.go
@@ -55,7 +55,7 @@ func isStrictComparisonWith(
lhs predicate,
op token.Token,
rhs predicate,
-) (ast.Expr, ast.Expr, bool) {
+) (leftOperand ast.Expr, rightOperand ast.Expr, fact bool) {
be, ok := e.(*ast.BinaryExpr)
if !ok {
return nil, nil, false
diff --git a/vendor/github.com/Antonboom/testifylint/internal/checkers/helpers_context.go b/vendor/github.com/Antonboom/testifylint/internal/checkers/helpers_context.go
index e8505fad0a..2ad0ae4a36 100644
--- a/vendor/github.com/Antonboom/testifylint/internal/checkers/helpers_context.go
+++ b/vendor/github.com/Antonboom/testifylint/internal/checkers/helpers_context.go
@@ -54,7 +54,7 @@ func findSurroundingFunc(pass *analysis.Pass, stack []ast.Node) *funcID {
isHTTPHandler = true
}
- if i >= 2 { //nolint:nestif
+ if i >= 2 { //nolint:nestif // Already clear code.
if ce, ok := stack[i-1].(*ast.CallExpr); ok {
if se, ok := ce.Fun.(*ast.SelectorExpr); ok {
isTestCleanup = implementsTestingT(pass, se.X) && se.Sel != nil && (se.Sel.Name == "Cleanup")
diff --git a/vendor/github.com/Antonboom/testifylint/internal/checkers/helpers_diagnostic.go b/vendor/github.com/Antonboom/testifylint/internal/checkers/helpers_diagnostic.go
index f12d87aa35..c1364f2741 100644
--- a/vendor/github.com/Antonboom/testifylint/internal/checkers/helpers_diagnostic.go
+++ b/vendor/github.com/Antonboom/testifylint/internal/checkers/helpers_diagnostic.go
@@ -131,13 +131,23 @@ func newSuggestedFuncReplacement(
proposedFn += "f"
}
return analysis.SuggestedFix{
- Message: fmt.Sprintf("Replace `%s` with `%s`", call.Fn.Name, proposedFn),
- TextEdits: append([]analysis.TextEdit{
- {
- Pos: call.Fn.Pos(),
- End: call.Fn.End(),
- NewText: []byte(proposedFn),
- },
- }, additionalEdits...),
+ Message: fmt.Sprintf("Replace `%s` with `%s`", call.Fn.Name, proposedFn),
+ TextEdits: append([]analysis.TextEdit{newReplaceFnTextEdit(call.Fn, proposedFn)}, additionalEdits...),
+ }
+}
+
+func newReplaceFnTextEdit(callFn analysis.Range, proposedFn string) analysis.TextEdit {
+ return analysis.TextEdit{
+ Pos: callFn.Pos(),
+ End: callFn.End(),
+ NewText: []byte(proposedFn),
+ }
+}
+
+func newRemoveLastArgTextEdit(pass *analysis.Pass, callArgs []ast.Expr) analysis.TextEdit {
+ return analysis.TextEdit{
+ Pos: callArgs[0].Pos(),
+ End: callArgs[len(callArgs)-1].End(),
+ NewText: formatAsCallArgs(pass, callArgs[0:len(callArgs)-1]...),
}
}
diff --git a/vendor/github.com/Antonboom/testifylint/internal/checkers/helpers_http.go b/vendor/github.com/Antonboom/testifylint/internal/checkers/helpers_http.go
index 9dabb02a9c..4aa19c1bb7 100644
--- a/vendor/github.com/Antonboom/testifylint/internal/checkers/helpers_http.go
+++ b/vendor/github.com/Antonboom/testifylint/internal/checkers/helpers_http.go
@@ -24,7 +24,7 @@ func mimicHTTPHandler(pass *analysis.Pass, fType *ast.FuncType) bool {
return false
}
- for i := 0; i < sig.Params().Len(); i++ {
+ for i := range sig.Params().Len() {
lhs := sig.Params().At(i).Type()
rhs := pass.TypesInfo.TypeOf(fType.Params.List[i].Type)
if !types.Identical(lhs, rhs) {
diff --git a/vendor/github.com/Antonboom/testifylint/internal/checkers/helpers_len.go b/vendor/github.com/Antonboom/testifylint/internal/checkers/helpers_len.go
index 904950ff37..6afa5849aa 100644
--- a/vendor/github.com/Antonboom/testifylint/internal/checkers/helpers_len.go
+++ b/vendor/github.com/Antonboom/testifylint/internal/checkers/helpers_len.go
@@ -2,7 +2,6 @@ package checkers
import (
"go/ast"
- "go/token"
"go/types"
"golang.org/x/tools/go/analysis"
@@ -12,31 +11,6 @@ import (
var lenObj = types.Universe.Lookup("len")
-func isLenEquality(pass *analysis.Pass, e ast.Expr) (ast.Expr, ast.Expr, bool) {
- be, ok := e.(*ast.BinaryExpr)
- if !ok {
- return nil, nil, false
- }
-
- if be.Op != token.EQL {
- return nil, nil, false
- }
- return xorLenCall(pass, be.X, be.Y)
-}
-
-func xorLenCall(pass *analysis.Pass, a, b ast.Expr) (lenArg ast.Expr, expectedLen ast.Expr, ok bool) {
- arg1, ok1 := isBuiltinLenCall(pass, a)
- arg2, ok2 := isBuiltinLenCall(pass, b)
-
- if xor(ok1, ok2) {
- if ok1 {
- return arg1, b, true
- }
- return arg2, a, true
- }
- return nil, nil, false
-}
-
func isLenCallAndZero(pass *analysis.Pass, a, b ast.Expr) (ast.Expr, bool) {
lenArg, ok := isBuiltinLenCall(pass, a)
return lenArg, ok && isZero(b)
diff --git a/vendor/github.com/Antonboom/testifylint/internal/checkers/len.go b/vendor/github.com/Antonboom/testifylint/internal/checkers/len.go
index c240a61744..51a883b142 100644
--- a/vendor/github.com/Antonboom/testifylint/internal/checkers/len.go
+++ b/vendor/github.com/Antonboom/testifylint/internal/checkers/len.go
@@ -1,19 +1,42 @@
package checkers
import (
+ "go/ast"
+ "go/token"
+
"golang.org/x/tools/go/analysis"
)
// Len detects situations like
//
-// assert.Equal(t, 3, len(arr))
-// assert.EqualValues(t, 3, len(arr))
-// assert.Exactly(t, 3, len(arr))
-// assert.True(t, len(arr) == 3)
+// assert.Equal(t, 42, len(arr))
+// assert.Equal(t, len(arr), 42)
+// assert.EqualValues(t, 42, len(arr))
+// assert.EqualValues(t, len(arr), 42)
+// assert.Exactly(t, 42, len(arr))
+// assert.Exactly(t, len(arr), 42)
+// assert.True(t, 42 == len(arr))
+// assert.True(t, len(arr) == 42)
+//
+// assert.Equal(t, value, len(arr))
+// assert.EqualValues(t, value, len(arr))
+// assert.Exactly(t, value, len(arr))
+// assert.True(t, len(arr) == value)
+//
+// assert.Equal(t, len(expArr), len(arr))
+// assert.EqualValues(t, len(expArr), len(arr))
+// assert.Exactly(t, len(expArr), len(arr))
+// assert.True(t, len(arr) == len(expArr))
//
// and requires
//
-// assert.Len(t, arr, 3)
+// assert.Len(t, arr, 42)
+// assert.Len(t, arr, value)
+// assert.Len(t, arr, len(expArr))
+//
+// The checker ignores assertions in which length checking is not a priority, e.g
+//
+// assert.Equal(t, len(arr), value)
type Len struct{}
// NewLen constructs Len checker.
@@ -21,45 +44,62 @@ func NewLen() Len { return Len{} }
func (Len) Name() string { return "len" }
func (checker Len) Check(pass *analysis.Pass, call *CallMeta) *analysis.Diagnostic {
- const proposedFn = "Len"
-
switch call.Fn.NameFTrimmed {
case "Equal", "EqualValues", "Exactly":
if len(call.Args) < 2 {
return nil
}
- a, b := call.Args[0], call.Args[1]
- if lenArg, expectedLen, ok := xorLenCall(pass, a, b); ok {
- if _, ok := isIntBasicLit(expectedLen); (expectedLen == b) && !ok {
- // https://github.com/Antonboom/testifylint/issues/9
- return nil
- }
- return newUseFunctionDiagnostic(checker.Name(), call, proposedFn,
- analysis.TextEdit{
- Pos: a.Pos(),
- End: b.End(),
- NewText: formatAsCallArgs(pass, lenArg, expectedLen),
- })
- }
+ a, b := call.Args[0], call.Args[1]
+ return checker.checkArgs(call, pass, a, b, false)
case "True":
if len(call.Args) < 1 {
return nil
}
- expr := call.Args[0]
- if lenArg, expectedLen, ok := isLenEquality(pass, expr); ok {
- if _, ok := isIntBasicLit(expectedLen); !ok {
- return nil
- }
- return newUseFunctionDiagnostic(checker.Name(), call, proposedFn,
- analysis.TextEdit{
- Pos: expr.Pos(),
- End: expr.End(),
- NewText: formatAsCallArgs(pass, lenArg, expectedLen),
- })
+ be, ok := call.Args[0].(*ast.BinaryExpr)
+ if !ok {
+ return nil
+ }
+ if be.Op != token.EQL {
+ return nil
+ }
+ return checker.checkArgs(call, pass, be.Y, be.X, true) // In True, the actual value is usually first.
+ }
+ return nil
+}
+
+func (checker Len) checkArgs(call *CallMeta, pass *analysis.Pass, a, b ast.Expr, inverted bool) *analysis.Diagnostic {
+ newUseLenDiagnostic := func(lenArg, expectedLen ast.Expr) *analysis.Diagnostic {
+ const proposedFn = "Len"
+ start, end := a.Pos(), b.End()
+ if inverted {
+ start, end = b.Pos(), a.End()
+ }
+ return newUseFunctionDiagnostic(checker.Name(), call, proposedFn,
+ analysis.TextEdit{
+ Pos: start,
+ End: end,
+ NewText: formatAsCallArgs(pass, lenArg, expectedLen),
+ })
+ }
+
+ arg1, firstIsLen := isBuiltinLenCall(pass, a)
+ arg2, secondIsLen := isBuiltinLenCall(pass, b)
+
+ switch {
+ case firstIsLen && secondIsLen:
+ return newUseLenDiagnostic(arg2, a)
+
+ case firstIsLen:
+ if _, secondIsNum := isIntBasicLit(b); secondIsNum {
+ return newUseLenDiagnostic(arg1, b)
}
+
+ case secondIsLen:
+ return newUseLenDiagnostic(arg2, a)
}
+
return nil
}
diff --git a/vendor/github.com/Antonboom/testifylint/internal/checkers/negative_positive.go b/vendor/github.com/Antonboom/testifylint/internal/checkers/negative_positive.go
index a61bbdfcb8..f15dc49818 100644
--- a/vendor/github.com/Antonboom/testifylint/internal/checkers/negative_positive.go
+++ b/vendor/github.com/Antonboom/testifylint/internal/checkers/negative_positive.go
@@ -55,7 +55,7 @@ func (checker NegativePositive) checkNegative(pass *analysis.Pass, call *CallMet
})
}
- // NOTE(a.telyshev): We ignore uint-asserts as being no sense for assert.Negative.
+ // NOTE(a.telyshev): We ignore uint and len asserts as being no sense for assert.Negative.
switch call.Fn.NameFTrimmed {
case "Less":
@@ -64,8 +64,8 @@ func (checker NegativePositive) checkNegative(pass *analysis.Pass, call *CallMet
}
a, b := call.Args[0], call.Args[1]
- if isSignedNotZero(pass, a) && isZeroOrSignedZero(b) {
- return newUseNegativeDiagnostic(a.Pos(), b.End(), untype(a))
+ if canBeNegative(pass, a) && isZeroOrSignedZero(b) {
+ return newUseNegativeDiagnostic(a.Pos(), b.End(), a)
}
case "Greater":
@@ -74,8 +74,8 @@ func (checker NegativePositive) checkNegative(pass *analysis.Pass, call *CallMet
}
a, b := call.Args[0], call.Args[1]
- if isZeroOrSignedZero(a) && isSignedNotZero(pass, b) {
- return newUseNegativeDiagnostic(a.Pos(), b.End(), untype(b))
+ if isZeroOrSignedZero(a) && canBeNegative(pass, b) {
+ return newUseNegativeDiagnostic(a.Pos(), b.End(), b)
}
case "True":
@@ -84,12 +84,12 @@ func (checker NegativePositive) checkNegative(pass *analysis.Pass, call *CallMet
}
expr := call.Args[0]
- a, _, ok1 := isStrictComparisonWith(pass, expr, isSignedNotZero, token.LSS, p(isZeroOrSignedZero)) // a < 0
- _, b, ok2 := isStrictComparisonWith(pass, expr, p(isZeroOrSignedZero), token.GTR, isSignedNotZero) // 0 > a
+ a, _, ok1 := isStrictComparisonWith(pass, expr, canBeNegative, token.LSS, p(isZeroOrSignedZero)) // a < 0
+ _, b, ok2 := isStrictComparisonWith(pass, expr, p(isZeroOrSignedZero), token.GTR, canBeNegative) // 0 > a
survivingArg, ok := anyVal([]bool{ok1, ok2}, a, b)
if ok {
- return newUseNegativeDiagnostic(expr.Pos(), expr.End(), untype(survivingArg))
+ return newUseNegativeDiagnostic(expr.Pos(), expr.End(), survivingArg)
}
case "False":
@@ -98,12 +98,12 @@ func (checker NegativePositive) checkNegative(pass *analysis.Pass, call *CallMet
}
expr := call.Args[0]
- a, _, ok1 := isStrictComparisonWith(pass, expr, isSignedNotZero, token.GEQ, p(isZeroOrSignedZero)) // a >= 0
- _, b, ok2 := isStrictComparisonWith(pass, expr, p(isZeroOrSignedZero), token.LEQ, isSignedNotZero) // 0 <= a
+ a, _, ok1 := isStrictComparisonWith(pass, expr, canBeNegative, token.GEQ, p(isZeroOrSignedZero)) // a >= 0
+ _, b, ok2 := isStrictComparisonWith(pass, expr, p(isZeroOrSignedZero), token.LEQ, canBeNegative) // 0 <= a
survivingArg, ok := anyVal([]bool{ok1, ok2}, a, b)
if ok {
- return newUseNegativeDiagnostic(expr.Pos(), expr.End(), untype(survivingArg))
+ return newUseNegativeDiagnostic(expr.Pos(), expr.End(), survivingArg)
}
}
return nil
@@ -128,7 +128,7 @@ func (checker NegativePositive) checkPositive(pass *analysis.Pass, call *CallMet
a, b := call.Args[0], call.Args[1]
if isNotAnyZero(a) && isAnyZero(b) {
- return newUsePositiveDiagnostic(a.Pos(), b.End(), untype(a))
+ return newUsePositiveDiagnostic(a.Pos(), b.End(), a)
}
case "Less":
@@ -138,7 +138,7 @@ func (checker NegativePositive) checkPositive(pass *analysis.Pass, call *CallMet
a, b := call.Args[0], call.Args[1]
if isAnyZero(a) && isNotAnyZero(b) {
- return newUsePositiveDiagnostic(a.Pos(), b.End(), untype(b))
+ return newUsePositiveDiagnostic(a.Pos(), b.End(), b)
}
case "True":
@@ -152,7 +152,7 @@ func (checker NegativePositive) checkPositive(pass *analysis.Pass, call *CallMet
survivingArg, ok := anyVal([]bool{ok1, ok2}, a, b)
if ok {
- return newUsePositiveDiagnostic(expr.Pos(), expr.End(), untype(survivingArg))
+ return newUsePositiveDiagnostic(expr.Pos(), expr.End(), survivingArg)
}
case "False":
@@ -166,8 +166,13 @@ func (checker NegativePositive) checkPositive(pass *analysis.Pass, call *CallMet
survivingArg, ok := anyVal([]bool{ok1, ok2}, a, b)
if ok {
- return newUsePositiveDiagnostic(expr.Pos(), expr.End(), untype(survivingArg))
+ return newUsePositiveDiagnostic(expr.Pos(), expr.End(), survivingArg)
}
}
return nil
}
+
+func canBeNegative(pass *analysis.Pass, e ast.Expr) bool {
+ _, isLen := isBuiltinLenCall(pass, e)
+ return isSignedNotZero(pass, e) && !isLen
+}
diff --git a/vendor/github.com/Antonboom/testifylint/internal/checkers/require_error.go b/vendor/github.com/Antonboom/testifylint/internal/checkers/require_error.go
index e4e30aaf4a..e965163102 100644
--- a/vendor/github.com/Antonboom/testifylint/internal/checkers/require_error.go
+++ b/vendor/github.com/Antonboom/testifylint/internal/checkers/require_error.go
@@ -50,12 +50,12 @@ func (checker *RequireError) SetFnPattern(p *regexp.Regexp) *RequireError {
return checker
}
-func (checker RequireError) Check(pass *analysis.Pass, inspector *inspector.Inspector) []analysis.Diagnostic {
+func (checker RequireError) Check(pass *analysis.Pass, insp *inspector.Inspector) []analysis.Diagnostic {
callsByFunc := make(map[funcID][]*callMeta)
// Stage 1. Collect meta information about any calls inside functions.
- inspector.WithStack([]ast.Node{(*ast.CallExpr)(nil)}, func(node ast.Node, push bool, stack []ast.Node) bool {
+ insp.WithStack([]ast.Node{(*ast.CallExpr)(nil)}, func(node ast.Node, push bool, stack []ast.Node) bool {
if !push {
return false
}
diff --git a/vendor/github.com/Antonboom/testifylint/internal/checkers/suite_method_signature.go b/vendor/github.com/Antonboom/testifylint/internal/checkers/suite_method_signature.go
new file mode 100644
index 0000000000..9ceba5db7c
--- /dev/null
+++ b/vendor/github.com/Antonboom/testifylint/internal/checkers/suite_method_signature.go
@@ -0,0 +1,71 @@
+package checkers
+
+import (
+ "fmt"
+ "go/ast"
+
+ "golang.org/x/tools/go/analysis"
+ "golang.org/x/tools/go/ast/inspector"
+
+ "github.com/Antonboom/testifylint/internal/analysisutil"
+ "github.com/Antonboom/testifylint/internal/testify"
+)
+
+// SuiteMethodSignature warns, when
+// - suite's test methods have arguments or returning values;
+// - suite's custom (user) methods conflicts with (shadows/overrides) suite functionality methods.
+type SuiteMethodSignature struct{}
+
+// NewSuiteMethodSignature constructs SuiteMethodSignature checker.
+func NewSuiteMethodSignature() SuiteMethodSignature { return SuiteMethodSignature{} }
+func (SuiteMethodSignature) Name() string { return "suite-method-signature" }
+
+func (checker SuiteMethodSignature) Check(pass *analysis.Pass, insp *inspector.Inspector) (diags []analysis.Diagnostic) {
+ insp.Preorder([]ast.Node{(*ast.FuncDecl)(nil)}, func(node ast.Node) {
+ fd := node.(*ast.FuncDecl)
+ if !isSuiteMethod(pass, fd) {
+ return
+ }
+
+ methodName := fd.Name.Name
+ rcv := fd.Recv.List[0]
+
+ if isSuiteTestMethod(methodName) {
+ if fd.Type.Params.NumFields() > 0 || fd.Type.Results.NumFields() > 0 {
+ const msg = "test method should not have any arguments or returning values"
+ diags = append(diags, *newDiagnostic(checker.Name(), fd, msg))
+ return
+ }
+ }
+
+ iface, ok := suiteMethodToInterface[methodName]
+ if !ok {
+ return
+ }
+ ifaceObj := analysisutil.ObjectOf(pass.Pkg, testify.SuitePkgPath, iface)
+ if ifaceObj == nil {
+ return
+ }
+ if !implements(pass, rcv.Type, ifaceObj) {
+ msg := fmt.Sprintf("method conflicts with %s.%s interface", testify.SuitePkgName, iface)
+ diags = append(diags, *newDiagnostic(checker.Name(), fd, msg))
+ }
+ })
+ return diags
+}
+
+// https://github.com/stretchr/testify/blob/master/suite/interfaces.go
+var suiteMethodToInterface = map[string]string{
+ // NOTE(a.telyshev): We ignore suite.TestingSuite interface, because
+ // - suite.Run will not work for suite-types that do not implement it;
+ // - this interface has several methods, which may cause a false positive for one of the methods in the suite-type.
+ "SetupSuite": "SetupAllSuite",
+ "SetupTest": "SetupTestSuite",
+ "TearDownSuite": "TearDownAllSuite",
+ "TearDownTest": "TearDownTestSuite",
+ "BeforeTest": "BeforeTest",
+ "AfterTest": "AfterTest",
+ "HandleStats": "WithStats",
+ "SetupSubTest": "SetupSubTest",
+ "TearDownSubTest": "TearDownSubTest",
+}
diff --git a/vendor/github.com/Antonboom/testifylint/internal/checkers/suite_thelper.go b/vendor/github.com/Antonboom/testifylint/internal/checkers/suite_thelper.go
index ef8d821321..074de4f764 100644
--- a/vendor/github.com/Antonboom/testifylint/internal/checkers/suite_thelper.go
+++ b/vendor/github.com/Antonboom/testifylint/internal/checkers/suite_thelper.go
@@ -22,8 +22,8 @@ type SuiteTHelper struct{}
func NewSuiteTHelper() SuiteTHelper { return SuiteTHelper{} }
func (SuiteTHelper) Name() string { return "suite-thelper" }
-func (checker SuiteTHelper) Check(pass *analysis.Pass, inspector *inspector.Inspector) (diagnostics []analysis.Diagnostic) {
- inspector.Preorder([]ast.Node{(*ast.FuncDecl)(nil)}, func(node ast.Node) {
+func (checker SuiteTHelper) Check(pass *analysis.Pass, insp *inspector.Inspector) (diagnostics []analysis.Diagnostic) {
+ insp.Preorder([]ast.Node{(*ast.FuncDecl)(nil)}, func(node ast.Node) {
fd := node.(*ast.FuncDecl)
if !isSuiteMethod(pass, fd) {
return
@@ -43,7 +43,7 @@ func (checker SuiteTHelper) Check(pass *analysis.Pass, inspector *inspector.Insp
}
rcvName := rcv.Names[0].Name
- helperCallStr := fmt.Sprintf("%s.T().Helper()", rcvName)
+ helperCallStr := rcvName + ".T().Helper()"
firstStmt := fd.Body.List[0]
if analysisutil.NodeString(pass.Fset, firstStmt) == helperCallStr {
diff --git a/vendor/github.com/Antonboom/testifylint/internal/checkers/useless_assert.go b/vendor/github.com/Antonboom/testifylint/internal/checkers/useless_assert.go
index 045706e5dc..15de9c6c59 100644
--- a/vendor/github.com/Antonboom/testifylint/internal/checkers/useless_assert.go
+++ b/vendor/github.com/Antonboom/testifylint/internal/checkers/useless_assert.go
@@ -30,20 +30,38 @@ import (
// assert.False(t, num == num)
// assert.False(t, num != num)
//
-// assert.Empty(t, "")
-// assert.False(t, false)
+// assert.Empty(t, "value") // Any string literal.
+// assert.Error(t, nil)
+// assert.False(t, false) // Any bool literal.
// assert.Implements(t, (*any)(nil), new(Conn))
-// assert.Negative(t, -42)
+// assert.Negative(t, 42) // Any int literal.
// assert.Nil(t, nil)
// assert.NoError(t, nil)
-// assert.NotEmpty(t, "value")
-// assert.NotZero(t, 42)
-// assert.NotZero(t, "value")
-// assert.Positive(t, 42)
-// assert.True(t, true)
-// assert.Zero(t, 0)
-// assert.Zero(t, "")
+// assert.NotEmpty(t, "value") // Any string literal.
+// assert.NotImplements(t, (*any)(nil), new(Conn))
+// assert.NotNil(t, nil)
+// assert.NotZero(t, 42) // Any int literal.
+// assert.NotZero(t, "value") // Any string literal.
+// assert.NotZero(t, nil)
+// assert.NotZero(t, false) // Any bool literal.
+// assert.Positive(t, 42) // Any int literal.
+// assert.True(t, true) // Any bool literal.
+// assert.Zero(t, 42) // Any int literal.
+// assert.Zero(t, "value") // Any string literal.
// assert.Zero(t, nil)
+// assert.Zero(t, false) // Any bool literal.
+//
+// assert.Negative(len(x))
+// assert.Less(len(x), 0)
+// assert.Greater(0, len(x))
+// assert.GreaterOrEqual(len(x), 0)
+// assert.LessOrEqual(0, len(x))
+//
+// assert.Negative(uintVal)
+// assert.Less(uintVal, 0)
+// assert.Greater(0, uintVal)
+// assert.GreaterOrEqual(uintVal, 0)
+// assert.LessOrEqual(0, uintVal)
type UselessAssert struct{}
// NewUselessAssert constructs UselessAssert checker.
@@ -57,13 +75,13 @@ func (checker UselessAssert) Check(pass *analysis.Pass, call *CallMeta) *analysi
var isMeaningless bool
switch call.Fn.NameFTrimmed {
- case "Empty":
- isMeaningless = (len(call.Args) >= 1) && isEmptyStringLit(call.Args[0])
+ case "False", "True":
+ isMeaningless = (len(call.Args) >= 1) && isUntypedBool(pass, call.Args[0])
- case "False":
- isMeaningless = (len(call.Args) >= 1) && isUntypedFalse(pass, call.Args[0])
+ case "GreaterOrEqual", "Less":
+ isMeaningless = (len(call.Args) >= 2) && isAnyZero(call.Args[1]) && canNotBeNegative(pass, call.Args[0])
- case "Implements":
+ case "Implements", "NotImplements":
if len(call.Args) < 2 {
return nil
}
@@ -71,29 +89,34 @@ func (checker UselessAssert) Check(pass *analysis.Pass, call *CallMeta) *analysi
elem, ok := isPointer(pass, call.Args[0])
isMeaningless = ok && isEmptyInterfaceType(elem)
- case "Negative":
- isMeaningless = (len(call.Args) >= 1) && isNegativeIntNumber(call.Args[0])
-
- case "Nil", "NoError":
- isMeaningless = (len(call.Args) >= 1) && isNil(call.Args[0])
+ case "LessOrEqual", "Greater":
+ isMeaningless = (len(call.Args) >= 2) && isAnyZero(call.Args[0]) && canNotBeNegative(pass, call.Args[1])
- case "NotEmpty":
- isMeaningless = (len(call.Args) >= 1) && isNotEmptyStringLit(call.Args[0])
+ case "Positive":
+ if len(call.Args) < 1 {
+ return nil
+ }
+ _, isMeaningless = isIntBasicLit(call.Args[0])
- case "NotZero":
- isMeaningless = (len(call.Args) >= 1) &&
- (isNotEmptyStringLit(call.Args[0]) ||
- isNegativeIntNumber(call.Args[0]) || isPositiveIntNumber(call.Args[0]))
+ case "Negative":
+ if len(call.Args) < 1 {
+ return nil
+ }
+ _, isInt := isIntBasicLit(call.Args[0])
+ isMeaningless = isInt || canNotBeNegative(pass, call.Args[0])
- case "Positive":
- isMeaningless = (len(call.Args) >= 1) && isPositiveIntNumber(call.Args[0])
+ case "Error", "Nil", "NoError", "NotNil":
+ isMeaningless = (len(call.Args) >= 1) && isNil(call.Args[0])
- case "True":
- isMeaningless = (len(call.Args) >= 1) && isUntypedTrue(pass, call.Args[0])
+ case "Empty", "NotEmpty":
+ isMeaningless = (len(call.Args) >= 1) && isStringLit(call.Args[0])
- case "Zero":
- isMeaningless = (len(call.Args) >= 1) &&
- (isZero(call.Args[0]) || isEmptyStringLit(call.Args[0]) || isNil(call.Args[0]))
+ case "NotZero", "Zero":
+ if len(call.Args) < 1 {
+ return nil
+ }
+ _, isInt := isIntBasicLit(call.Args[0])
+ isMeaningless = isInt || isStringLit(call.Args[0]) || isNil(call.Args[0]) || isUntypedBool(pass, call.Args[0])
}
if isMeaningless {
@@ -123,12 +146,15 @@ func (checker UselessAssert) checkSameVars(pass *analysis.Pass, call *CallMeta)
"InDeltaSlice",
"InEpsilon",
"InEpsilonSlice",
+ "IsNotType",
"IsType",
"JSONEq",
"Less",
"LessOrEqual",
+ "NotElementsMatch",
"NotEqual",
"NotEqualValues",
+ "NotErrorAs",
"NotErrorIs",
"NotRegexp",
"NotSame",
@@ -163,3 +189,8 @@ func (checker UselessAssert) checkSameVars(pass *analysis.Pass, call *CallMeta)
}
return nil
}
+
+func canNotBeNegative(pass *analysis.Pass, e ast.Expr) bool {
+ _, isLen := isBuiltinLenCall(pass, e)
+ return isLen || isUnsigned(pass, e)
+}
diff --git a/vendor/github.com/Antonboom/testifylint/internal/config/config.go b/vendor/github.com/Antonboom/testifylint/internal/config/config.go
index 23b673428e..7b25878764 100644
--- a/vendor/github.com/Antonboom/testifylint/internal/config/config.go
+++ b/vendor/github.com/Antonboom/testifylint/internal/config/config.go
@@ -24,6 +24,7 @@ func NewDefault() Config {
Formatter: FormatterConfig{
CheckFormatString: true,
RequireFFuncs: false,
+ RequireStringMsg: true,
},
GoRequire: GoRequireConfig{
IgnoreHTTPHandlers: false,
@@ -66,6 +67,7 @@ type ExpectedActualConfig struct {
type FormatterConfig struct {
CheckFormatString bool
RequireFFuncs bool
+ RequireStringMsg bool
}
// GoRequireConfig implements configuration of checkers.GoRequire.
@@ -133,7 +135,10 @@ func BindToFlags(cfg *Config, fs *flag.FlagSet) {
"to enable go vet's printf checks")
fs.BoolVar(&cfg.Formatter.RequireFFuncs,
"formatter.require-f-funcs", false,
- "to require f-assertions (e.g. assert.Equalf) if format string is used, even if there are no variable-length variables.")
+ "to require f-assertions (e.g. assert.Equalf) if format string is used, even if there are no variable-length variables")
+ fs.BoolVar(&cfg.Formatter.RequireStringMsg,
+ "formatter.require-string-msg", true,
+ "to require that the first element of msgAndArgs (msg) has a string type")
fs.BoolVar(&cfg.GoRequire.IgnoreHTTPHandlers,
"go-require.ignore-http-handlers", false,
diff --git a/vendor/github.com/ClickHouse/clickhouse-go-linter/LICENSE b/vendor/github.com/ClickHouse/clickhouse-go-linter/LICENSE
new file mode 100644
index 0000000000..a7e77cb28d
--- /dev/null
+++ b/vendor/github.com/ClickHouse/clickhouse-go-linter/LICENSE
@@ -0,0 +1,176 @@
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+END OF TERMS AND CONDITIONS
\ No newline at end of file
diff --git a/vendor/github.com/ClickHouse/clickhouse-go-linter/internal/util/util.go b/vendor/github.com/ClickHouse/clickhouse-go-linter/internal/util/util.go
new file mode 100644
index 0000000000..68d1309890
--- /dev/null
+++ b/vendor/github.com/ClickHouse/clickhouse-go-linter/internal/util/util.go
@@ -0,0 +1,33 @@
+package util
+
+import (
+ "go/ast"
+ "go/types"
+
+ "golang.org/x/tools/go/analysis"
+)
+
+// IsChObj returns true if the input ast.Expr is of type clickhouse go driver
+func IsChObj(pass *analysis.Pass, expr ast.Expr, name string) bool {
+ t := pass.TypesInfo.TypeOf(expr)
+ if t == nil {
+ return false
+ }
+ named, ok := t.(*types.Named)
+ if !ok {
+ return false
+ }
+ obj := named.Obj()
+ if obj.Pkg() == nil {
+ return false
+ }
+ return obj.Pkg().Path() == "github.com/ClickHouse/clickhouse-go/v2/lib/driver" &&
+ obj.Name() == name
+}
+
+func IdentName(expr ast.Expr) string {
+ if id, ok := expr.(*ast.Ident); ok {
+ return id.Name
+ }
+ return ""
+}
diff --git a/vendor/github.com/ClickHouse/clickhouse-go-linter/passes/chbatchclose/chbatchclose.go b/vendor/github.com/ClickHouse/clickhouse-go-linter/passes/chbatchclose/chbatchclose.go
new file mode 100644
index 0000000000..cc0f6894cf
--- /dev/null
+++ b/vendor/github.com/ClickHouse/clickhouse-go-linter/passes/chbatchclose/chbatchclose.go
@@ -0,0 +1,227 @@
+package chbatchclose
+
+import (
+ "go/ast"
+ "go/token"
+ "os"
+ "strconv"
+
+ "github.com/ClickHouse/clickhouse-go-linter/internal/util"
+
+ "golang.org/x/tools/go/analysis"
+ "golang.org/x/tools/go/analysis/passes/inspect"
+ "golang.org/x/tools/go/ast/inspector"
+)
+
+type analyzer struct {
+ // if true, report valid usages and log spurious but valid cases.
+ debug bool
+}
+
+func NewAnalyzer() *analysis.Analyzer {
+ debug, _ := strconv.ParseBool(os.Getenv("CH_GO_LINTER_DEBUG"))
+ a := analyzer{
+ debug: debug,
+ }
+ return &analysis.Analyzer{
+ Name: "chbatchclosecheck",
+ Doc: "chbatchclosecheck checks whether defer batch.Close() is called on ClickHouse driver Batch variables",
+ Run: a.run,
+ Requires: []*analysis.Analyzer{inspect.Analyzer},
+ }
+}
+
+func (a *analyzer) run(pass *analysis.Pass) (any, error) {
+ insp := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
+
+ nodeFilter := []ast.Node{
+ (*ast.FuncDecl)(nil),
+ (*ast.FuncLit)(nil),
+ }
+
+ insp.Preorder(nodeFilter, func(n ast.Node) {
+ var body *ast.BlockStmt
+ switch fn := n.(type) {
+ case *ast.FuncDecl:
+ body = fn.Body
+ case *ast.FuncLit:
+ body = fn.Body
+ }
+
+ if body == nil {
+ return
+ }
+ a.checkFunc(pass, body)
+ })
+
+ return nil, nil
+}
+
+// batchUsage tracks whether a driver.Batch variable has a defer Close/Abort or is returned.
+type batchUsage struct {
+ assignPos token.Pos
+ deferredClose bool
+ returned bool
+}
+
+func (b *batchUsage) report(varName string, pass *analysis.Pass, debug bool) {
+ if b.assignPos == token.NoPos {
+ // no usage of Batch
+ return
+ }
+ if !b.deferredClose && !b.returned {
+ pass.Reportf(b.assignPos,
+ "clickhouse Batch %s must be closed defensively with defer %s.Close() after successful instantiation",
+ varName, varName)
+ } else if debug {
+ if b.deferredClose {
+ pass.Reportf(b.assignPos,
+ "clickhouse Batch %s is properly closed defensively after successful instantiation [valid]",
+ varName)
+ } else {
+ pass.Reportf(b.assignPos,
+ "clickhouse Batch %s is returned by the function [valid]",
+ varName)
+ }
+ }
+}
+
+// checkFunc analyzes a single function/closure body.
+// It does a single-pass collection of Batch assignments, defer Close/Abort calls, and return statements.
+// It does not descend into nested closures (they are handled as separate units by the Preorder visitor above).
+func (a *analyzer) checkFunc(pass *analysis.Pass, body *ast.BlockStmt) {
+ usages := map[string]*batchUsage{}
+
+ ast.Inspect(body, func(n ast.Node) bool {
+ if n == nil {
+ return false
+ }
+ // don't descend into nested closures
+ if n != body {
+ if _, ok := n.(*ast.FuncLit); ok {
+ return false
+ }
+ }
+
+ switch node := n.(type) {
+ case *ast.AssignStmt:
+ a.handleAssign(pass, node, usages)
+ case *ast.DeferStmt:
+ handleDefer(node, usages)
+ case *ast.ReturnStmt:
+ handleReturn(node, usages)
+ }
+
+ return true
+ })
+
+ // remaining usages that were not flushed
+ for varName, u := range usages {
+ u.report(varName, pass, a.debug)
+ }
+}
+
+// handleAssign checks if any LHS variable in the assignment is of type driver.Batch.
+// If a tracked variable is reassigned, it flushes/reports the previous tracking first.
+func (a *analyzer) handleAssign(pass *analysis.Pass, assign *ast.AssignStmt, usages map[string]*batchUsage) {
+ for _, lhs := range assign.Lhs {
+ name := util.IdentName(lhs)
+ if name == "" {
+ continue
+ }
+ if name == "_" && util.IsChObj(pass, lhs, "Batch") {
+ pass.Reportf(assign.Pos(), "clickhouse Batch assigned to blank identifier. Connection leak. clickhouse Batch must be instantiated and closed defensively with defer batch.Close() after successful instantiation")
+ continue
+ }
+
+ // if this var was already tracked, flush previous usage before re-tracking
+ if u, ok := usages[name]; ok {
+ u.report(name, pass, a.debug)
+ delete(usages, name)
+ }
+
+ if util.IsChObj(pass, lhs, "Batch") {
+ usages[name] = &batchUsage{assignPos: assign.Pos()}
+ }
+ }
+}
+
+// handleDefer checks if a defer statement calls Close() on a tracked Batch variable.
+// Two shapes are supported:
+// - direct selector call: defer batch.Close()
+// - immediately-invoked closure: defer func() { ... batch.Close() ... }()
+// (no params; nested FuncLits inside the closure body are not descended into)
+func handleDefer(deferStmt *ast.DeferStmt, usages map[string]*batchUsage) {
+ call := deferStmt.Call
+
+ switch fun := call.Fun.(type) {
+ case *ast.SelectorExpr:
+ varName := util.IdentName(fun.X)
+ if varName == "" {
+ return
+ }
+ u, exists := usages[varName]
+ if !exists {
+ return
+ }
+ if fun.Sel.Name == "Close" {
+ u.deferredClose = true
+ }
+ case *ast.FuncLit:
+ // only no-arg closures are supported for the moment
+ if fun.Type.Params != nil && len(fun.Type.Params.List) > 0 {
+ return
+ }
+ handleDeferredClosure(fun.Body, usages)
+ }
+}
+
+// handleDeferredClosure walks the body of a deferred closure looking for
+// `.Close()` calls. It does not descend into nested FuncLits, so
+// `defer func() { go func() { batch.Close() }() }()` and similar are not
+// treated as a valid defensive close.
+func handleDeferredClosure(body *ast.BlockStmt, usages map[string]*batchUsage) {
+ ast.Inspect(body, func(n ast.Node) bool {
+ if n == nil {
+ return false
+ }
+ // don't descend into nested closures (goroutines, callbacks, etc.)
+ if n != body {
+ if _, ok := n.(*ast.FuncLit); ok {
+ return false
+ }
+ }
+ call, ok := n.(*ast.CallExpr)
+ if !ok {
+ return true
+ }
+ sel, ok := call.Fun.(*ast.SelectorExpr)
+ if !ok {
+ return true
+ }
+ if sel.Sel.Name != "Close" {
+ return true
+ }
+ varName := util.IdentName(sel.X)
+ if varName == "" {
+ return true
+ }
+ if u, exists := usages[varName]; exists {
+ u.deferredClose = true
+ }
+ return true
+ })
+}
+
+// handleReturn checks if any return value is a tracked Batch variable.
+func handleReturn(ret *ast.ReturnStmt, usages map[string]*batchUsage) {
+ for _, result := range ret.Results {
+ name := util.IdentName(result)
+ if name == "" {
+ continue
+ }
+ if u, exists := usages[name]; exists {
+ u.returned = true
+ }
+ }
+}
diff --git a/vendor/github.com/ClickHouse/clickhouse-go-linter/passes/chrowserr/chrowserr.go b/vendor/github.com/ClickHouse/clickhouse-go-linter/passes/chrowserr/chrowserr.go
new file mode 100644
index 0000000000..bba0f82ad8
--- /dev/null
+++ b/vendor/github.com/ClickHouse/clickhouse-go-linter/passes/chrowserr/chrowserr.go
@@ -0,0 +1,162 @@
+package chrowserr
+
+import (
+ "go/ast"
+ "go/token"
+ "log"
+ "os"
+ "strconv"
+
+ "github.com/ClickHouse/clickhouse-go-linter/internal/util"
+ "golang.org/x/tools/go/analysis"
+ "golang.org/x/tools/go/analysis/passes/inspect"
+ "golang.org/x/tools/go/ast/inspector"
+)
+
+type analyzer struct {
+ // if true, report valid usages and log spurious but valid cases.
+ debug bool
+}
+
+func NewAnalyzer() *analysis.Analyzer {
+ debug, _ := strconv.ParseBool(os.Getenv("CH_GO_LINTER_DEBUG"))
+ a := analyzer{
+ debug: debug,
+ }
+ return &analysis.Analyzer{
+ Name: "chrowserrcheck",
+ Doc: "chrowserrcheck checks whether ClickHouse driver Rows.Err is called after Rows.Next()",
+ Run: a.run,
+ Requires: []*analysis.Analyzer{inspect.Analyzer},
+ }
+}
+
+func (a *analyzer) run(pass *analysis.Pass) (any, error) {
+ insp := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
+
+ nodeFilter := []ast.Node{
+ (*ast.FuncDecl)(nil),
+ (*ast.FuncLit)(nil),
+ }
+
+ insp.Preorder(nodeFilter, func(n ast.Node) {
+ var body *ast.BlockStmt
+ switch fn := n.(type) {
+ case *ast.FuncDecl:
+ body = fn.Body
+ case *ast.FuncLit:
+ body = fn.Body
+ }
+
+ if body == nil {
+ return
+ }
+ a.checkFunc(pass, body)
+ })
+
+ return nil, nil
+}
+
+// rowsUsage tracks Next/Err usage observations for a single Rows variable within a function.
+type rowsUsage struct {
+ nextPos token.Pos
+ errCalled bool
+}
+
+func (r *rowsUsage) report(varName string, pass *analysis.Pass, debug bool) {
+ if r.nextPos == token.NoPos {
+ // no usage of rows.Next()
+ return
+ }
+ // rows.Next() was called
+ if !r.errCalled {
+ pass.Reportf(r.nextPos,
+ "clickhouse %s.Err() must be checked after %s.Next()",
+ varName, varName)
+ } else if debug {
+ // for dev purpose - list valid usages
+ pass.Reportf(r.nextPos,
+ "clickhouse %s.Err() is properly called after %s.Next() [valid]",
+ varName, varName)
+ }
+}
+
+// checkFunc analyzes a single function/closure body.
+// It does a single-pass collection of Next() and Err() calls,
+// it does not descend into nested closures (they are handled as separate units by the Preorder visitor above).
+func (a *analyzer) checkFunc(pass *analysis.Pass, body *ast.BlockStmt) {
+ usages := map[string]*rowsUsage{}
+ ast.Inspect(body, func(n ast.Node) bool {
+ if n == nil {
+ return false
+ }
+ // don't descend into nested closures
+ if n != body {
+ if _, ok := n.(*ast.FuncLit); ok {
+ return false
+ }
+ }
+
+ // if a tracked var appears in an assignment, it means it is re-assigned - run lint report and flush var from usages.
+ if assign, ok := n.(*ast.AssignStmt); ok {
+ for _, lhs := range assign.Lhs {
+ name := util.IdentName(lhs)
+ if name == "" {
+ continue
+ }
+ if s, ok := usages[name]; ok {
+ s.report(name, pass, a.debug)
+ }
+ delete(usages, name)
+ }
+ // let ast.Inspect continue
+ return true
+ }
+
+ // handle CH driver method calls Next() and Err() - skip everything else
+ call, ok := n.(*ast.CallExpr)
+ if !ok {
+ return true
+ }
+ sel, ok := call.Fun.(*ast.SelectorExpr)
+ if !ok {
+ return true
+ }
+ varName := util.IdentName(sel.X)
+ if varName == "" {
+ return true
+ }
+ if !util.IsChObj(pass, sel.X, "Rows") {
+ return true
+ }
+
+ // call is a CH driver Rows method call
+ switch sel.Sel.Name {
+ case "Next":
+ if _, exists := usages[varName]; !exists {
+ usages[varName] = &rowsUsage{nextPos: call.Pos()}
+ } else if a.debug {
+ log.Printf("Rows.Next() is written multiple times with no re-assignment. Valid but rare usage. If this observation is not correct, it is a bug in this linter library. Please reach out to maintainer.")
+ // in particular could be a bug in the re-assignment detection
+ }
+ case "Err":
+ if s, exists := usages[varName]; exists {
+ s.errCalled = true
+ s.report(varName, pass, a.debug)
+ delete(usages, varName)
+ } else if a.debug {
+ log.Printf("%s.Err() is called on ClickHouse Rows %s but %s.Next() was never called. Valid but unexpected usage. If this observation is not correct, it is a bug in this linter library. Please reach out to maintainer.",
+ varName, varName, varName)
+ // in particular could be a bug in the re-assignment detection
+ }
+
+ }
+
+ return true
+ })
+
+ // remaining usages that were not flushed (misusages only, as correct usages are flushed already)
+ for varName, s := range usages {
+ s.report(varName, pass, a.debug)
+ }
+}
diff --git a/vendor/github.com/Crocmagnon/fatcontext/pkg/analyzer/analyzer.go b/vendor/github.com/Crocmagnon/fatcontext/pkg/analyzer/analyzer.go
deleted file mode 100644
index 42c06f4e78..0000000000
--- a/vendor/github.com/Crocmagnon/fatcontext/pkg/analyzer/analyzer.go
+++ /dev/null
@@ -1,302 +0,0 @@
-package analyzer
-
-import (
- "bytes"
- "errors"
- "flag"
- "fmt"
- "go/ast"
- "go/printer"
- "go/token"
- "slices"
-
- "golang.org/x/tools/go/analysis"
- "golang.org/x/tools/go/analysis/passes/inspect"
- "golang.org/x/tools/go/ast/inspector"
-)
-
-const FlagCheckStructPointers = "check-struct-pointers"
-
-func NewAnalyzer() *analysis.Analyzer {
- r := &runner{}
-
- flags := flag.NewFlagSet("fatcontext", flag.ExitOnError)
- flags.BoolVar(&r.DetectInStructPointers, FlagCheckStructPointers, false,
- "set to true to detect potential fat contexts in struct pointers")
-
- return &analysis.Analyzer{
- Name: "fatcontext",
- Doc: "detects nested contexts in loops and function literals",
- Run: r.run,
- Flags: *flags,
- Requires: []*analysis.Analyzer{inspect.Analyzer},
- }
-}
-
-var errUnknown = errors.New("unknown node type")
-
-const (
- categoryInLoop = "nested context in loop"
- categoryInFuncLit = "nested context in function literal"
- categoryInStructPointer = "potential nested context in struct pointer"
- categoryUnsupported = "unsupported nested context type"
-)
-
-type runner struct {
- DetectInStructPointers bool
-}
-
-func (r *runner) run(pass *analysis.Pass) (interface{}, error) {
- inspctr := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
-
- nodeFilter := []ast.Node{
- (*ast.ForStmt)(nil),
- (*ast.RangeStmt)(nil),
- (*ast.FuncLit)(nil),
- (*ast.FuncDecl)(nil),
- }
-
- inspctr.Preorder(nodeFilter, func(node ast.Node) {
- body, err := getBody(node)
- if err != nil {
- return
- }
-
- if body == nil {
- return
- }
-
- assignStmt := findNestedContext(pass, node, body.List)
- if assignStmt == nil {
- return
- }
-
- category := getCategory(pass, node, assignStmt)
-
- if r.shouldIgnoreReport(category) {
- return
- }
-
- fixes := r.getSuggestedFixes(pass, assignStmt, category)
-
- pass.Report(analysis.Diagnostic{
- Pos: assignStmt.Pos(),
- Message: category,
- SuggestedFixes: fixes,
- })
- })
-
- return nil, nil
-}
-
-func (r *runner) shouldIgnoreReport(category string) bool {
- return category == categoryInStructPointer && !r.DetectInStructPointers
-}
-
-func (r *runner) getSuggestedFixes(pass *analysis.Pass, assignStmt *ast.AssignStmt, category string) []analysis.SuggestedFix {
- switch category {
- case categoryInStructPointer, categoryUnsupported:
- return nil
- }
-
- suggestedStmt := ast.AssignStmt{
- Lhs: assignStmt.Lhs,
- TokPos: assignStmt.TokPos,
- Tok: token.DEFINE,
- Rhs: assignStmt.Rhs,
- }
- suggested, err := render(pass.Fset, &suggestedStmt)
-
- var fixes []analysis.SuggestedFix
- if err == nil {
- fixes = append(fixes, analysis.SuggestedFix{
- Message: "replace `=` with `:=`",
- TextEdits: []analysis.TextEdit{
- {
- Pos: assignStmt.Pos(),
- End: assignStmt.End(),
- NewText: suggested,
- },
- },
- })
- }
-
- return fixes
-}
-
-func getCategory(pass *analysis.Pass, node ast.Node, assignStmt *ast.AssignStmt) string {
- switch node.(type) {
- case *ast.ForStmt, *ast.RangeStmt:
- return categoryInLoop
- }
-
- if isPointer(pass, assignStmt.Lhs[0]) {
- return categoryInStructPointer
- }
-
- switch node.(type) {
- case *ast.FuncLit, *ast.FuncDecl:
- return categoryInFuncLit
- default:
- return categoryUnsupported
- }
-}
-
-func getBody(node ast.Node) (*ast.BlockStmt, error) {
- switch typedNode := node.(type) {
- case *ast.ForStmt:
- return typedNode.Body, nil
- case *ast.RangeStmt:
- return typedNode.Body, nil
- case *ast.FuncLit:
- return typedNode.Body, nil
- case *ast.FuncDecl:
- return typedNode.Body, nil
- }
-
- return nil, errUnknown
-}
-
-func findNestedContext(pass *analysis.Pass, node ast.Node, stmts []ast.Stmt) *ast.AssignStmt {
- for _, stmt := range stmts {
- // Recurse if necessary
- switch typedStmt := stmt.(type) {
- case *ast.BlockStmt:
- if found := findNestedContext(pass, node, typedStmt.List); found != nil {
- return found
- }
- case *ast.IfStmt:
- if found := findNestedContext(pass, node, typedStmt.Body.List); found != nil {
- return found
- }
- case *ast.SwitchStmt:
- if found := findNestedContext(pass, node, typedStmt.Body.List); found != nil {
- return found
- }
- case *ast.CaseClause:
- if found := findNestedContext(pass, node, typedStmt.Body); found != nil {
- return found
- }
- case *ast.SelectStmt:
- if found := findNestedContext(pass, node, typedStmt.Body.List); found != nil {
- return found
- }
- case *ast.CommClause:
- if found := findNestedContext(pass, node, typedStmt.Body); found != nil {
- return found
- }
- }
-
- // Actually check for nested context
- assignStmt, ok := stmt.(*ast.AssignStmt)
- if !ok {
- continue
- }
-
- t := pass.TypesInfo.TypeOf(assignStmt.Lhs[0])
- if t == nil {
- continue
- }
-
- if t.String() != "context.Context" {
- continue
- }
-
- if assignStmt.Tok == token.DEFINE {
- continue
- }
-
- // Ignore [context.Background] & [context.TODO].
- if isContextFunction(assignStmt.Rhs[0], "Background", "TODO") {
- continue
- }
-
- if isPointer(pass, assignStmt.Lhs[0]) {
- return assignStmt
- }
-
- // allow assignment to non-pointer children of values defined within the loop
- if isWithinLoop(assignStmt.Lhs[0], node, pass) {
- continue
- }
-
- return assignStmt
- }
-
- return nil
-}
-
-// render returns the pretty-print of the given node
-func render(fset *token.FileSet, x interface{}) ([]byte, error) {
- var buf bytes.Buffer
- if err := printer.Fprint(&buf, fset, x); err != nil {
- return nil, fmt.Errorf("printing node: %w", err)
- }
- return buf.Bytes(), nil
-}
-
-func isContextFunction(exp ast.Expr, fnName ...string) bool {
- call, ok := exp.(*ast.CallExpr)
- if !ok {
- return false
- }
-
- selector, ok := call.Fun.(*ast.SelectorExpr)
- if !ok {
- return false
- }
-
- ident, ok := selector.X.(*ast.Ident)
- if !ok {
- return false
- }
-
- return ident.Name == "context" && slices.Contains(fnName, selector.Sel.Name)
-}
-
-func isWithinLoop(exp ast.Expr, node ast.Node, pass *analysis.Pass) bool {
- lhs := getRootIdent(pass, exp)
- if lhs == nil {
- return false
- }
-
- obj := pass.TypesInfo.ObjectOf(lhs)
- if obj == nil {
- return false
- }
-
- scope := obj.Parent()
- if scope == nil {
- return false
- }
-
- return scope.Pos() >= node.Pos() && scope.End() <= node.End()
-}
-
-func getRootIdent(pass *analysis.Pass, node ast.Node) *ast.Ident {
- for {
- switch n := node.(type) {
- case *ast.Ident:
- return n
- case *ast.IndexExpr:
- node = n.X
- case *ast.SelectorExpr:
- if sel, ok := pass.TypesInfo.Selections[n]; ok && sel.Indirect() {
- return nil // indirected (pointer) roots don't imply a (safe) copy
- }
- node = n.X
- default:
- return nil
- }
- }
-}
-
-func isPointer(pass *analysis.Pass, exp ast.Node) bool {
- switch n := exp.(type) {
- case *ast.SelectorExpr:
- sel, ok := pass.TypesInfo.Selections[n]
- return ok && sel.Indirect()
- }
-
- return false
-}
diff --git a/vendor/github.com/Djarvur/go-err113/.travis.yml b/vendor/github.com/Djarvur/go-err113/.travis.yml
index 44fe77d53a..142be3e8b0 100644
--- a/vendor/github.com/Djarvur/go-err113/.travis.yml
+++ b/vendor/github.com/Djarvur/go-err113/.travis.yml
@@ -1,18 +1,14 @@
language: go
go:
- - "1.13"
- - "1.14"
+ - "1.23"
+ - "1.24"
+ - "1.25"
- tip
-env:
- - GO111MODULE=on
-
before_install:
- - go get github.com/axw/gocov/gocov
- - go get github.com/mattn/goveralls
- - go get golang.org/x/tools/cmd/cover
- - go get golang.org/x/tools/cmd/goimports
+ - go install github.com/mattn/goveralls@v0.0.12
+ - go install golang.org/x/tools/cmd/goimports@v0.36.0
- wget -O - -q https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh
script:
@@ -21,4 +17,4 @@ script:
- go test -v -race ./...
after_success:
- - test "$TRAVIS_GO_VERSION" = "1.14" && goveralls -service=travis-ci
+ - test "$TRAVIS_GO_VERSION" = "1.25" && goveralls -service=travis-ci
diff --git a/vendor/github.com/Djarvur/go-err113/comparison.go b/vendor/github.com/Djarvur/go-err113/comparison.go
index 8a85557837..a267ebdce8 100644
--- a/vendor/github.com/Djarvur/go-err113/comparison.go
+++ b/vendor/github.com/Djarvur/go-err113/comparison.go
@@ -7,9 +7,10 @@ import (
"go/types"
"golang.org/x/tools/go/analysis"
+ "golang.org/x/tools/go/ast/inspector"
)
-func inspectComparision(pass *analysis.Pass, n ast.Node) bool { // nolint: unparam
+func inspectComparision(file *ast.File, pass *analysis.Pass, n ast.Node) bool { // nolint: unparam
// check whether the call expression matches time.Now().Sub()
be, ok := n.(*ast.BinaryExpr)
if !ok {
@@ -25,6 +26,18 @@ func inspectComparision(pass *analysis.Pass, n ast.Node) bool { // nolint: unpar
return true
}
+ root := inspector.New([]*ast.File{file}).Root()
+ c, ok := root.FindNode(n)
+ if !ok {
+ panic(fmt.Errorf("could not find node %T in inspector for file %q", n, file.Name.Name))
+ }
+
+ for cur := c.Parent(); cur != root; cur = cur.Parent() {
+ if isMethodNamed(cur, pass, "Is") {
+ return true
+ }
+ }
+
oldExpr := render(pass.Fset, be)
negate := ""
@@ -56,6 +69,23 @@ func inspectComparision(pass *analysis.Pass, n ast.Node) bool { // nolint: unpar
return true
}
+var errorType = types.Universe.Lookup("error").Type().Underlying().(*types.Interface)
+
+func isMethodNamed(cur inspector.Cursor, pass *analysis.Pass, name string) bool {
+ funcNode, ok := cur.Node().(*ast.FuncDecl)
+
+ if !ok || funcNode.Name == nil || funcNode.Name.Name != name {
+ return false
+ }
+
+ if funcNode.Recv == nil && len(funcNode.Recv.List) != 1 {
+ return false
+ }
+
+ typ := pass.TypesInfo.Types[funcNode.Recv.List[0].Type]
+ return typ.Type != nil && types.Implements(typ.Type, errorType)
+}
+
func isError(v ast.Expr, info *types.Info) bool {
if intf, ok := info.TypeOf(v).Underlying().(*types.Interface); ok {
return intf.NumMethods() == 1 && intf.Method(0).FullName() == "(error).Error"
diff --git a/vendor/github.com/Djarvur/go-err113/err113.go b/vendor/github.com/Djarvur/go-err113/err113.go
index ec4f52ac72..190a7ded96 100644
--- a/vendor/github.com/Djarvur/go-err113/err113.go
+++ b/vendor/github.com/Djarvur/go-err113/err113.go
@@ -2,10 +2,10 @@
package err113
import (
- "bytes"
"go/ast"
"go/printer"
"go/token"
+ "strings"
"golang.org/x/tools/go/analysis"
)
@@ -19,14 +19,14 @@ func NewAnalyzer() *analysis.Analyzer {
}
}
-func run(pass *analysis.Pass) (interface{}, error) {
+func run(pass *analysis.Pass) (any, error) {
for _, file := range pass.Files {
tlds := enumerateFileDecls(file)
ast.Inspect(
file,
func(n ast.Node) bool {
- return inspectComparision(pass, n) &&
+ return inspectComparision(file, pass, n) &&
inspectDefinition(pass, tlds, n)
},
)
@@ -36,8 +36,8 @@ func run(pass *analysis.Pass) (interface{}, error) {
}
// render returns the pretty-print of the given node.
-func render(fset *token.FileSet, x interface{}) string {
- var buf bytes.Buffer
+func render(fset *token.FileSet, x any) string {
+ var buf strings.Builder
if err := printer.Fprint(&buf, fset, x); err != nil {
panic(err)
}
diff --git a/vendor/github.com/GaijinEntertainment/go-exhaustruct/v3/analyzer/analyzer.go b/vendor/github.com/GaijinEntertainment/go-exhaustruct/v3/analyzer/analyzer.go
deleted file mode 100644
index 5be31eb686..0000000000
--- a/vendor/github.com/GaijinEntertainment/go-exhaustruct/v3/analyzer/analyzer.go
+++ /dev/null
@@ -1,318 +0,0 @@
-package analyzer
-
-import (
- "flag"
- "fmt"
- "go/ast"
- "go/token"
- "go/types"
- "sync"
-
- "golang.org/x/tools/go/analysis"
- "golang.org/x/tools/go/analysis/passes/inspect"
- "golang.org/x/tools/go/ast/inspector"
-
- "github.com/GaijinEntertainment/go-exhaustruct/v3/internal/comment"
- "github.com/GaijinEntertainment/go-exhaustruct/v3/internal/pattern"
- "github.com/GaijinEntertainment/go-exhaustruct/v3/internal/structure"
-)
-
-type analyzer struct {
- include pattern.List `exhaustruct:"optional"`
- exclude pattern.List `exhaustruct:"optional"`
-
- structFields structure.FieldsCache `exhaustruct:"optional"`
- comments comment.Cache `exhaustruct:"optional"`
-
- typeProcessingNeed map[string]bool
- typeProcessingNeedMu sync.RWMutex `exhaustruct:"optional"`
-}
-
-func NewAnalyzer(include, exclude []string) (*analysis.Analyzer, error) {
- a := analyzer{
- typeProcessingNeed: make(map[string]bool),
- comments: comment.Cache{},
- }
-
- var err error
-
- a.include, err = pattern.NewList(include...)
- if err != nil {
- return nil, err //nolint:wrapcheck
- }
-
- a.exclude, err = pattern.NewList(exclude...)
- if err != nil {
- return nil, err //nolint:wrapcheck
- }
-
- return &analysis.Analyzer{ //nolint:exhaustruct
- Name: "exhaustruct",
- Doc: "Checks if all structure fields are initialized",
- Run: a.run,
- Requires: []*analysis.Analyzer{inspect.Analyzer},
- Flags: a.newFlagSet(),
- }, nil
-}
-
-func (a *analyzer) newFlagSet() flag.FlagSet {
- fs := flag.NewFlagSet("", flag.PanicOnError)
-
- fs.Var(&a.include, "i", `Regular expression to match type names, can receive multiple flags.
-Anonymous structs can be matched by '' alias.
-4ex:
- github.com/GaijinEntertainment/go-exhaustruct/v3/analyzer\.
- github.com/GaijinEntertainment/go-exhaustruct/v3/analyzer\.TypeInfo`)
- fs.Var(&a.exclude, "e", `Regular expression to exclude type names, can receive multiple flags.
-Anonymous structs can be matched by '' alias.
-4ex:
- github.com/GaijinEntertainment/go-exhaustruct/v3/analyzer\.
- github.com/GaijinEntertainment/go-exhaustruct/v3/analyzer\.TypeInfo`)
-
- return *fs
-}
-
-func (a *analyzer) run(pass *analysis.Pass) (any, error) {
- insp := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector) //nolint:forcetypeassert
-
- insp.WithStack([]ast.Node{(*ast.CompositeLit)(nil)}, a.newVisitor(pass))
-
- return nil, nil //nolint:nilnil
-}
-
-// newVisitor returns visitor that only expects [ast.CompositeLit] nodes.
-func (a *analyzer) newVisitor(pass *analysis.Pass) func(n ast.Node, push bool, stack []ast.Node) bool {
- return func(n ast.Node, push bool, stack []ast.Node) bool {
- if !push {
- return true
- }
-
- lit, ok := n.(*ast.CompositeLit)
- if !ok {
- // this should never happen, but better be prepared
- return true
- }
-
- structTyp, typeInfo, ok := getStructType(pass, lit)
- if !ok {
- return true
- }
-
- if len(lit.Elts) == 0 {
- if ret, ok := stackParentIsReturn(stack); ok {
- if returnContainsNonNilError(pass, ret, n) {
- // it is okay to return uninitialized structure in case struct's direct parent is
- // a return statement containing non-nil error
- return true
- }
- }
- }
-
- file := a.comments.Get(pass.Fset, stack[0].(*ast.File)) //nolint:forcetypeassert
- rc := getCompositeLitRelatedComments(stack, file)
- pos, msg := a.processStruct(pass, lit, structTyp, typeInfo, rc)
-
- if pos != nil {
- pass.Reportf(*pos, msg)
- }
-
- return true
- }
-}
-
-// getCompositeLitRelatedComments returns all comments that are related to checked node. We
-// have to traverse the stack manually as ast do not associate comments with
-// [ast.CompositeLit].
-func getCompositeLitRelatedComments(stack []ast.Node, cm ast.CommentMap) []*ast.CommentGroup {
- comments := make([]*ast.CommentGroup, 0)
-
- for i := len(stack) - 1; i >= 0; i-- {
- node := stack[i]
-
- switch node.(type) {
- case *ast.CompositeLit, // stack[len(stack)-1]
- *ast.ReturnStmt, // return ...
- *ast.IndexExpr, // map[enum]...{...}[key]
- *ast.CallExpr, // myfunc(map...)
- *ast.UnaryExpr, // &map...
- *ast.AssignStmt, // variable assignment (without var keyword)
- *ast.DeclStmt, // var declaration, parent of *ast.GenDecl
- *ast.GenDecl, // var declaration, parent of *ast.ValueSpec
- *ast.ValueSpec: // var declaration
- comments = append(comments, cm[node]...)
-
- default:
- return comments
- }
- }
-
- return comments
-}
-
-func getStructType(pass *analysis.Pass, lit *ast.CompositeLit) (*types.Struct, *TypeInfo, bool) {
- switch typ := types.Unalias(pass.TypesInfo.TypeOf(lit)).(type) {
- case *types.Named: // named type
- if structTyp, ok := typ.Underlying().(*types.Struct); ok {
- pkg := typ.Obj().Pkg()
- ti := TypeInfo{
- Name: typ.Obj().Name(),
- PackageName: pkg.Name(),
- PackagePath: pkg.Path(),
- }
-
- return structTyp, &ti, true
- }
-
- return nil, nil, false
-
- case *types.Struct: // anonymous struct
- ti := TypeInfo{
- Name: "",
- PackageName: pass.Pkg.Name(),
- PackagePath: pass.Pkg.Path(),
- }
-
- return typ, &ti, true
-
- default:
- return nil, nil, false
- }
-}
-
-func stackParentIsReturn(stack []ast.Node) (*ast.ReturnStmt, bool) {
- // it is safe to skip boundary check, since stack always has at least one element
- // we also have no reason to check the first element, since it is always a file
- for i := len(stack) - 2; i > 0; i-- {
- switch st := stack[i].(type) {
- case *ast.ReturnStmt:
- return st, true
-
- case *ast.UnaryExpr:
- // in case we're dealing with pointers - it is still viable to check pointer's
- // parent for return statement
- continue
-
- default:
- return nil, false
- }
- }
-
- return nil, false
-}
-
-// errorIface is a type that represents [error] interface and all types will be
-// compared against.
-var errorIface = types.Universe.Lookup("error").Type().Underlying().(*types.Interface)
-
-func returnContainsNonNilError(pass *analysis.Pass, ret *ast.ReturnStmt, except ast.Node) bool {
- // errors are mostly located at the end of return statement, so we're starting
- // from the end.
- for i := len(ret.Results) - 1; i >= 0; i-- {
- ri := ret.Results[i]
-
- // skip current node
- if ri == except {
- continue
- }
-
- if un, ok := ri.(*ast.UnaryExpr); ok {
- if un.X == except {
- continue
- }
- }
-
- if types.Implements(pass.TypesInfo.TypeOf(ri), errorIface) {
- return true
- }
- }
-
- return false
-}
-
-func (a *analyzer) processStruct(
- pass *analysis.Pass,
- lit *ast.CompositeLit,
- structTyp *types.Struct,
- info *TypeInfo,
- comments []*ast.CommentGroup,
-) (*token.Pos, string) {
- shouldProcess := a.shouldProcessType(info)
-
- if shouldProcess && comment.HasDirective(comments, comment.DirectiveIgnore) {
- return nil, ""
- }
-
- if !shouldProcess && !comment.HasDirective(comments, comment.DirectiveEnforce) {
- return nil, ""
- }
-
- // unnamed structures are only defined in same package, along with types that has
- // prefix identical to current package name.
- isSamePackage := info.PackagePath == pass.Pkg.Path()
-
- if f := a.litSkippedFields(lit, structTyp, !isSamePackage); len(f) > 0 {
- pos := lit.Pos()
-
- if len(f) == 1 {
- return &pos, fmt.Sprintf("%s is missing field %s", info.ShortString(), f.String())
- }
-
- return &pos, fmt.Sprintf("%s is missing fields %s", info.ShortString(), f.String())
- }
-
- return nil, ""
-}
-
-// shouldProcessType returns true if type should be processed basing off include
-// and exclude patterns, defined though constructor and\or flags.
-func (a *analyzer) shouldProcessType(info *TypeInfo) bool {
- if len(a.include) == 0 && len(a.exclude) == 0 {
- return true
- }
-
- name := info.String()
-
- a.typeProcessingNeedMu.RLock()
- res, ok := a.typeProcessingNeed[name]
- a.typeProcessingNeedMu.RUnlock()
-
- if !ok {
- a.typeProcessingNeedMu.Lock()
- res = true
-
- if a.include != nil && !a.include.MatchFullString(name) {
- res = false
- }
-
- if res && a.exclude != nil && a.exclude.MatchFullString(name) {
- res = false
- }
-
- a.typeProcessingNeed[name] = res
- a.typeProcessingNeedMu.Unlock()
- }
-
- return res
-}
-
-func (a *analyzer) litSkippedFields(
- lit *ast.CompositeLit,
- typ *types.Struct,
- onlyExported bool,
-) structure.Fields {
- return a.structFields.Get(typ).Skipped(lit, onlyExported)
-}
-
-type TypeInfo struct {
- Name string
- PackageName string
- PackagePath string
-}
-
-func (t TypeInfo) String() string {
- return t.PackagePath + "." + t.Name
-}
-
-func (t TypeInfo) ShortString() string {
- return t.PackageName + "." + t.Name
-}
diff --git a/vendor/github.com/GaijinEntertainment/go-exhaustruct/v3/internal/pattern/list.go b/vendor/github.com/GaijinEntertainment/go-exhaustruct/v3/internal/pattern/list.go
deleted file mode 100644
index a16e5058d2..0000000000
--- a/vendor/github.com/GaijinEntertainment/go-exhaustruct/v3/internal/pattern/list.go
+++ /dev/null
@@ -1,82 +0,0 @@
-package pattern
-
-import (
- "fmt"
- "regexp"
- "strings"
-)
-
-var (
- ErrEmptyPattern = fmt.Errorf("pattern can't be empty")
- ErrCompilationFailed = fmt.Errorf("pattern compilation failed")
-)
-
-// List is a list of regular expressions.
-type List []*regexp.Regexp
-
-// NewList parses slice of strings to a slice of compiled regular expressions.
-func NewList(strs ...string) (List, error) {
- if len(strs) == 0 {
- return nil, nil
- }
-
- l := make(List, 0, len(strs))
-
- for _, str := range strs {
- re, err := strToRe(str)
- if err != nil {
- return nil, err
- }
-
- l = append(l, re)
- }
-
- return l, nil
-}
-
-// MatchFullString matches provided string against all regexps in a slice and returns
-// true if any of them matches whole string.
-func (l List) MatchFullString(str string) bool {
- for i := 0; i < len(l); i++ {
- if m := l[i].FindStringSubmatch(str); len(m) > 0 && m[0] == str {
- return true
- }
- }
-
- return false
-}
-
-func (l *List) Set(value string) error {
- re, err := strToRe(value)
- if err != nil {
- return err
- }
-
- *l = append(*l, re)
-
- return nil
-}
-
-func (l *List) String() string {
- res := make([]string, 0, len(*l))
-
- for _, re := range *l {
- res = append(res, `"`+re.String()+`"`)
- }
-
- return strings.Join(res, ", ")
-}
-
-// strToRe parses string to a compiled regular expression that matches full string.
-func strToRe(str string) (*regexp.Regexp, error) {
- if str == "" {
- return nil, ErrEmptyPattern
- }
-
- re, err := regexp.Compile(str)
- if err != nil {
- return nil, fmt.Errorf("%w: %s: %w", ErrCompilationFailed, str, err)
- }
-
- return re, nil
-}
diff --git a/vendor/github.com/Masterminds/semver/v3/.gitignore b/vendor/github.com/Masterminds/semver/v3/.gitignore
index 6b061e6174..35f0e5a3a4 100644
--- a/vendor/github.com/Masterminds/semver/v3/.gitignore
+++ b/vendor/github.com/Masterminds/semver/v3/.gitignore
@@ -1 +1,2 @@
-_fuzz/
\ No newline at end of file
+_fuzz/
+.devcontainer/
\ No newline at end of file
diff --git a/vendor/github.com/Masterminds/semver/v3/.golangci.yml b/vendor/github.com/Masterminds/semver/v3/.golangci.yml
index fbc6332592..24277f3aca 100644
--- a/vendor/github.com/Masterminds/semver/v3/.golangci.yml
+++ b/vendor/github.com/Masterminds/semver/v3/.golangci.yml
@@ -1,27 +1,42 @@
-run:
- deadline: 2m
-
+version: "2"
linters:
- disable-all: true
+ default: none
enable:
- - misspell
- - govet
- - staticcheck
+ - dupl
- errcheck
- - unparam
+ - gocyclo
+ - gosec
+ - govet
- ineffassign
+ - misspell
- nakedret
- - gocyclo
- - dupl
- - goimports
- revive
- - gosec
- - gosimple
- - typecheck
+ - staticcheck
+ - unparam
- unused
-
-linters-settings:
- gofmt:
- simplify: true
- dupl:
- threshold: 600
+ settings:
+ dupl:
+ threshold: 600
+ exclusions:
+ generated: lax
+ presets:
+ - comments
+ - common-false-positives
+ - legacy
+ - std-error-handling
+ paths:
+ - third_party$
+ - builtin$
+ - examples$
+formatters:
+ enable:
+ - goimports
+ settings:
+ gofmt:
+ simplify: true
+ exclusions:
+ generated: lax
+ paths:
+ - third_party$
+ - builtin$
+ - examples$
diff --git a/vendor/github.com/Masterminds/semver/v3/constraints.go b/vendor/github.com/Masterminds/semver/v3/constraints.go
index 8b7a10f836..e8353bc469 100644
--- a/vendor/github.com/Masterminds/semver/v3/constraints.go
+++ b/vendor/github.com/Masterminds/semver/v3/constraints.go
@@ -21,21 +21,43 @@ type Constraints struct {
IncludePrerelease bool
}
+// MaxConstraintLen is the maximum allowed length of a constraint string.
+const MaxConstraintLen = 512
+
+// MaxConstraintGroups is the maximum number of OR groups allowed in a
+// constraint string.
+const MaxConstraintGroups = 32
+
+// ErrConstraintTooLong is returned when a constraint string exceeds the
+// maximum allowed length.
+var ErrConstraintTooLong = fmt.Errorf("constraint string is too long (max %d bytes)", MaxConstraintLen)
+
+// ErrTooManyConstraintGroups is returned when a constraint string contains
+// too many OR groups.
+var ErrTooManyConstraintGroups = fmt.Errorf("too many constraint groups (max %d)", MaxConstraintGroups)
+
// NewConstraint returns a Constraints instance that a Version instance can
// be checked against. If there is a parse error it will be returned.
func NewConstraint(c string) (*Constraints, error) {
+ if len(c) > MaxConstraintLen {
+ return nil, ErrConstraintTooLong
+ }
+
// Rewrite - ranges into a comparison operation.
c = rewriteRange(c)
ors := strings.Split(c, "||")
+ if len(ors) > MaxConstraintGroups {
+ return nil, ErrTooManyConstraintGroups
+ }
lenors := len(ors)
or := make([][]*constraint, lenors)
hasPre := make([]bool, lenors)
for k, v := range ors {
// Validate the segment
if !validConstraintRegex.MatchString(v) {
- return nil, fmt.Errorf("improper constraint: %s", v)
+ return nil, fmt.Errorf("improper constraint: %q", v)
}
cs := findConstraintRegex.FindAllString(v, -1)
@@ -104,9 +126,9 @@ func (cs Constraints) Validate(v *Version) (bool, []error) {
for _, c := range o {
// Before running the check handle the case there the version is
// a prerelease and the check is not searching for prereleases.
- if !(cs.IncludePrerelease || cs.containsPre[i]) && v.pre != "" {
+ if !cs.IncludePrerelease && !cs.containsPre[i] && v.pre != "" {
if !prerelesase {
- em := fmt.Errorf("%s is a prerelease version and the constraint is only looking for release versions", v)
+ em := fmt.Errorf("%q is a prerelease version and the constraint is only looking for release versions", v)
e = append(e, em)
prerelesase = true
}
@@ -258,7 +280,7 @@ func parseConstraint(c string) (*constraint, error) {
if len(c) > 0 {
m := constraintRegex.FindStringSubmatch(c)
if m == nil {
- return nil, fmt.Errorf("improper constraint: %s", c)
+ return nil, fmt.Errorf("improper constraint: %q", c)
}
cs := &constraint{
@@ -325,7 +347,7 @@ func constraintNotEqual(v *Version, c *constraint, includePre bool) (bool, error
// The existence of prereleases is checked at the group level and passed in.
// Exit early if the version has a prerelease but those are to be ignored.
if v.Prerelease() != "" && !includePre {
- return false, fmt.Errorf("%s is a prerelease version and the constraint is only looking for release versions", v)
+ return false, fmt.Errorf("%q is a prerelease version and the constraint is only looking for release versions", v)
}
if c.dirty {
@@ -335,7 +357,7 @@ func constraintNotEqual(v *Version, c *constraint, includePre bool) (bool, error
if c.con.Minor() != v.Minor() && !c.minorDirty {
return true, nil
} else if c.minorDirty {
- return false, fmt.Errorf("%s is equal to %s", v, c.orig)
+ return false, fmt.Errorf("%q is equal to %q", v, c.orig)
} else if c.con.Patch() != v.Patch() && !c.patchDirty {
return true, nil
} else if c.patchDirty {
@@ -345,15 +367,15 @@ func constraintNotEqual(v *Version, c *constraint, includePre bool) (bool, error
if eq {
return true, nil
}
- return false, fmt.Errorf("%s is equal to %s", v, c.orig)
+ return false, fmt.Errorf("%q is equal to %q", v, c.orig)
}
- return false, fmt.Errorf("%s is equal to %s", v, c.orig)
+ return false, fmt.Errorf("%q is equal to %q", v, c.orig)
}
}
eq := v.Equal(c.con)
if eq {
- return false, fmt.Errorf("%s is equal to %s", v, c.orig)
+ return false, fmt.Errorf("%q is equal to %q", v, c.orig)
}
return true, nil
@@ -364,7 +386,7 @@ func constraintGreaterThan(v *Version, c *constraint, includePre bool) (bool, er
// The existence of prereleases is checked at the group level and passed in.
// Exit early if the version has a prerelease but those are to be ignored.
if v.Prerelease() != "" && !includePre {
- return false, fmt.Errorf("%s is a prerelease version and the constraint is only looking for release versions", v)
+ return false, fmt.Errorf("%q is a prerelease version and the constraint is only looking for release versions", v)
}
var eq bool
@@ -374,17 +396,17 @@ func constraintGreaterThan(v *Version, c *constraint, includePre bool) (bool, er
if eq {
return true, nil
}
- return false, fmt.Errorf("%s is less than or equal to %s", v, c.orig)
+ return false, fmt.Errorf("%q is less than or equal to %q", v, c.orig)
}
if v.Major() > c.con.Major() {
return true, nil
} else if v.Major() < c.con.Major() {
- return false, fmt.Errorf("%s is less than or equal to %s", v, c.orig)
+ return false, fmt.Errorf("%q is less than or equal to %q", v, c.orig)
} else if c.minorDirty {
// This is a range case such as >11. When the version is something like
// 11.1.0 is it not > 11. For that we would need 12 or higher
- return false, fmt.Errorf("%s is less than or equal to %s", v, c.orig)
+ return false, fmt.Errorf("%q is less than or equal to %q", v, c.orig)
} else if c.patchDirty {
// This is for ranges such as >11.1. A version of 11.1.1 is not greater
// which one of 11.2.1 is greater
@@ -392,7 +414,7 @@ func constraintGreaterThan(v *Version, c *constraint, includePre bool) (bool, er
if eq {
return true, nil
}
- return false, fmt.Errorf("%s is less than or equal to %s", v, c.orig)
+ return false, fmt.Errorf("%q is less than or equal to %q", v, c.orig)
}
// If we have gotten here we are not comparing pre-preleases and can use the
@@ -401,21 +423,21 @@ func constraintGreaterThan(v *Version, c *constraint, includePre bool) (bool, er
if eq {
return true, nil
}
- return false, fmt.Errorf("%s is less than or equal to %s", v, c.orig)
+ return false, fmt.Errorf("%q is less than or equal to %q", v, c.orig)
}
func constraintLessThan(v *Version, c *constraint, includePre bool) (bool, error) {
// The existence of prereleases is checked at the group level and passed in.
// Exit early if the version has a prerelease but those are to be ignored.
if v.Prerelease() != "" && !includePre {
- return false, fmt.Errorf("%s is a prerelease version and the constraint is only looking for release versions", v)
+ return false, fmt.Errorf("%q is a prerelease version and the constraint is only looking for release versions", v)
}
eq := v.Compare(c.con) < 0
if eq {
return true, nil
}
- return false, fmt.Errorf("%s is greater than or equal to %s", v, c.orig)
+ return false, fmt.Errorf("%q is greater than or equal to %q", v, c.orig)
}
func constraintGreaterThanEqual(v *Version, c *constraint, includePre bool) (bool, error) {
@@ -423,21 +445,21 @@ func constraintGreaterThanEqual(v *Version, c *constraint, includePre bool) (boo
// The existence of prereleases is checked at the group level and passed in.
// Exit early if the version has a prerelease but those are to be ignored.
if v.Prerelease() != "" && !includePre {
- return false, fmt.Errorf("%s is a prerelease version and the constraint is only looking for release versions", v)
+ return false, fmt.Errorf("%q is a prerelease version and the constraint is only looking for release versions", v)
}
eq := v.Compare(c.con) >= 0
if eq {
return true, nil
}
- return false, fmt.Errorf("%s is less than %s", v, c.orig)
+ return false, fmt.Errorf("%q is less than %q", v, c.orig)
}
func constraintLessThanEqual(v *Version, c *constraint, includePre bool) (bool, error) {
// The existence of prereleases is checked at the group level and passed in.
// Exit early if the version has a prerelease but those are to be ignored.
if v.Prerelease() != "" && !includePre {
- return false, fmt.Errorf("%s is a prerelease version and the constraint is only looking for release versions", v)
+ return false, fmt.Errorf("%q is a prerelease version and the constraint is only looking for release versions", v)
}
var eq bool
@@ -447,13 +469,13 @@ func constraintLessThanEqual(v *Version, c *constraint, includePre bool) (bool,
if eq {
return true, nil
}
- return false, fmt.Errorf("%s is greater than %s", v, c.orig)
+ return false, fmt.Errorf("%q is greater than %q", v, c.orig)
}
if v.Major() > c.con.Major() {
- return false, fmt.Errorf("%s is greater than %s", v, c.orig)
+ return false, fmt.Errorf("%q is greater than %q", v, c.orig)
} else if v.Major() == c.con.Major() && v.Minor() > c.con.Minor() && !c.minorDirty {
- return false, fmt.Errorf("%s is greater than %s", v, c.orig)
+ return false, fmt.Errorf("%q is greater than %q", v, c.orig)
}
return true, nil
@@ -469,11 +491,11 @@ func constraintTilde(v *Version, c *constraint, includePre bool) (bool, error) {
// The existence of prereleases is checked at the group level and passed in.
// Exit early if the version has a prerelease but those are to be ignored.
if v.Prerelease() != "" && !includePre {
- return false, fmt.Errorf("%s is a prerelease version and the constraint is only looking for release versions", v)
+ return false, fmt.Errorf("%q is a prerelease version and the constraint is only looking for release versions", v)
}
if v.LessThan(c.con) {
- return false, fmt.Errorf("%s is less than %s", v, c.orig)
+ return false, fmt.Errorf("%q is less than %q", v, c.orig)
}
// ~0.0.0 is a special case where all constraints are accepted. It's
@@ -484,11 +506,11 @@ func constraintTilde(v *Version, c *constraint, includePre bool) (bool, error) {
}
if v.Major() != c.con.Major() {
- return false, fmt.Errorf("%s does not have same major version as %s", v, c.orig)
+ return false, fmt.Errorf("%q does not have same major version as %q", v, c.orig)
}
if v.Minor() != c.con.Minor() && !c.minorDirty {
- return false, fmt.Errorf("%s does not have same major and minor version as %s", v, c.orig)
+ return false, fmt.Errorf("%q does not have same major and minor version as %q", v, c.orig)
}
return true, nil
@@ -500,7 +522,7 @@ func constraintTildeOrEqual(v *Version, c *constraint, includePre bool) (bool, e
// The existence of prereleases is checked at the group level and passed in.
// Exit early if the version has a prerelease but those are to be ignored.
if v.Prerelease() != "" && !includePre {
- return false, fmt.Errorf("%s is a prerelease version and the constraint is only looking for release versions", v)
+ return false, fmt.Errorf("%q is a prerelease version and the constraint is only looking for release versions", v)
}
if c.dirty {
@@ -512,7 +534,7 @@ func constraintTildeOrEqual(v *Version, c *constraint, includePre bool) (bool, e
return true, nil
}
- return false, fmt.Errorf("%s is not equal to %s", v, c.orig)
+ return false, fmt.Errorf("%q is not equal to %q", v, c.orig)
}
// ^* --> (any)
@@ -528,12 +550,12 @@ func constraintCaret(v *Version, c *constraint, includePre bool) (bool, error) {
// The existence of prereleases is checked at the group level and passed in.
// Exit early if the version has a prerelease but those are to be ignored.
if v.Prerelease() != "" && !includePre {
- return false, fmt.Errorf("%s is a prerelease version and the constraint is only looking for release versions", v)
+ return false, fmt.Errorf("%q is a prerelease version and the constraint is only looking for release versions", v)
}
// This less than handles prereleases
if v.LessThan(c.con) {
- return false, fmt.Errorf("%s is less than %s", v, c.orig)
+ return false, fmt.Errorf("%q is less than %q", v, c.orig)
}
var eq bool
@@ -548,12 +570,12 @@ func constraintCaret(v *Version, c *constraint, includePre bool) (bool, error) {
if eq {
return true, nil
}
- return false, fmt.Errorf("%s does not have same major version as %s", v, c.orig)
+ return false, fmt.Errorf("%q does not have same major version as %q", v, c.orig)
}
// ^ when the major is 0 and minor > 0 is >=0.y.z < 0.y+1
if c.con.Major() == 0 && v.Major() > 0 {
- return false, fmt.Errorf("%s does not have same major version as %s", v, c.orig)
+ return false, fmt.Errorf("%q does not have same major version as %q", v, c.orig)
}
// If the con Minor is > 0 it is not dirty
if c.con.Minor() > 0 || c.patchDirty {
@@ -561,11 +583,11 @@ func constraintCaret(v *Version, c *constraint, includePre bool) (bool, error) {
if eq {
return true, nil
}
- return false, fmt.Errorf("%s does not have same minor version as %s. Expected minor versions to match when constraint major version is 0", v, c.orig)
+ return false, fmt.Errorf("%q does not have same minor version as %q. Expected minor versions to match when constraint major version is 0", v, c.orig)
}
// ^ when the minor is 0 and minor > 0 is =0.0.z
if c.con.Minor() == 0 && v.Minor() > 0 {
- return false, fmt.Errorf("%s does not have same minor version as %s", v, c.orig)
+ return false, fmt.Errorf("%q does not have same minor version as %q", v, c.orig)
}
// At this point the major is 0 and the minor is 0 and not dirty. The patch
@@ -574,7 +596,7 @@ func constraintCaret(v *Version, c *constraint, includePre bool) (bool, error) {
if eq {
return true, nil
}
- return false, fmt.Errorf("%s does not equal %s. Expect version and constraint to equal when major and minor versions are 0", v, c.orig)
+ return false, fmt.Errorf("%q does not equal %q. Expect version and constraint to equal when major and minor versions are 0", v, c.orig)
}
func isX(x string) bool {
diff --git a/vendor/github.com/Masterminds/semver/v3/version.go b/vendor/github.com/Masterminds/semver/v3/version.go
index 7a3ba73887..da428760ce 100644
--- a/vendor/github.com/Masterminds/semver/v3/version.go
+++ b/vendor/github.com/Masterminds/semver/v3/version.go
@@ -6,6 +6,7 @@ import (
"encoding/json"
"errors"
"fmt"
+ "math"
"regexp"
"strconv"
"strings"
@@ -48,8 +49,16 @@ var (
// ErrInvalidPrerelease is returned when the pre-release is an invalid format
ErrInvalidPrerelease = errors.New("invalid prerelease string")
+
+ // ErrVersionTooLong is returned when a version string exceeds the
+ // maximum allowed length.
+ ErrVersionTooLong = fmt.Errorf("version string is too long (max %d bytes)", MaxVersionLen)
)
+// MaxVersionLen is the maximum allowed length of a version string. This guards
+// against unbounded input causing excessive memory allocations during parsing.
+const MaxVersionLen = 256
+
// semVerRegex is the regular expression used to parse a semantic version.
// This is not the official regex from the semver spec. It has been modified to allow for loose handling
// where versions like 2.1 are detected.
@@ -94,6 +103,10 @@ func StrictNewVersion(v string) (*Version, error) {
return nil, ErrEmptyString
}
+ if len(v) > MaxVersionLen {
+ return nil, ErrVersionTooLong
+ }
+
// Split the parts into [0]major, [1]minor, and [2]patch,prerelease,build
parts := strings.SplitN(v, ".", 3)
if len(parts) != 3 {
@@ -161,6 +174,9 @@ func StrictNewVersion(v string) (*Version, error) {
// attempts to convert it to SemVer. If you want to validate it was a strict
// semantic version at parse time see StrictNewVersion().
func NewVersion(v string) (*Version, error) {
+ if len(v) > MaxVersionLen {
+ return nil, ErrVersionTooLong
+ }
if CoerceNewVersion {
return coerceNewVersion(v)
}
@@ -289,6 +305,8 @@ func coerceNewVersion(v string) (*Version, error) {
// New creates a new instance of Version with each of the parts passed in as
// arguments instead of parsing a version string.
+// Note, New does not validate prerelease or metadata. Incorrect information can
+// be passed in.
func New(major, minor, patch uint64, pre, metadata string) *Version {
v := Version{
major: major,
@@ -301,6 +319,7 @@ func New(major, minor, patch uint64, pre, metadata string) *Version {
v.original = v.String()
+ // TODO: In the next semver major version validate the pre and metadata. Return error if there is one.
return &v
}
@@ -388,6 +407,9 @@ func (v Version) IncPatch() Version {
} else {
vNext.metadata = ""
vNext.pre = ""
+ if v.patch == math.MaxUint64 {
+ panic("patch version increment would overflow uint64")
+ }
vNext.patch = v.patch + 1
}
vNext.original = v.originalVPrefix() + "" + vNext.String()
@@ -404,6 +426,9 @@ func (v Version) IncMinor() Version {
vNext.metadata = ""
vNext.pre = ""
vNext.patch = 0
+ if v.minor == math.MaxUint64 {
+ panic("minor version increment would overflow uint64")
+ }
vNext.minor = v.minor + 1
vNext.original = v.originalVPrefix() + "" + vNext.String()
return vNext
@@ -421,6 +446,9 @@ func (v Version) IncMajor() Version {
vNext.pre = ""
vNext.patch = 0
vNext.minor = 0
+ if v.major == math.MaxUint64 {
+ panic("major version increment would overflow uint64")
+ }
vNext.major = v.major + 1
vNext.original = v.originalVPrefix() + "" + vNext.String()
return vNext
@@ -568,7 +596,16 @@ func (v Version) MarshalText() ([]byte, error) {
// Scan implements the SQL.Scanner interface.
func (v *Version) Scan(value interface{}) error {
var s string
- s, _ = value.(string)
+ switch t := value.(type) {
+ case string:
+ s = t
+ case []byte:
+ s = string(t)
+ case nil:
+ return fmt.Errorf("cannot scan nil into Version")
+ default:
+ return fmt.Errorf("unsupported Scan type %T", value)
+ }
temp, err := NewVersion(s)
if err != nil {
return err
diff --git a/vendor/github.com/MirrexOne/unqueryvet/.gitignore b/vendor/github.com/MirrexOne/unqueryvet/.gitignore
new file mode 100644
index 0000000000..23f505c0fc
--- /dev/null
+++ b/vendor/github.com/MirrexOne/unqueryvet/.gitignore
@@ -0,0 +1,56 @@
+# Binaries for programs and plugins
+*.exe
+*.exe~
+*.dll
+*.so
+*.dylib
+/unqueryvet
+
+# Test binary, built with `go test -c`
+*.test
+
+# Output of the go coverage tool
+*.out
+coverage.html
+
+# Dependency directories
+vendor/
+
+# Go workspace file
+go.work
+go.work.sum
+
+# IDE files
+.idea/
+.vscode/
+*.swp
+*.swo
+*~
+
+# OS files
+.DS_Store
+.DS_Store?
+._*
+.Spotlight-V100
+.Trashes
+ehthumbs.db
+Thumbs.db
+
+# Temporary files
+*.tmp
+*.log
+go.work
+.golangci.local.yml
+
+# Build tools (downloaded by Taskfile/Gradle)
+.tools/
+.task/
+
+# VS Code extension build artifacts
+extensions/vscode/node_modules/
+extensions/vscode/out/
+extensions/vscode/*.vsix
+*.vsix
+
+# Claude Code
+.claude/
diff --git a/vendor/github.com/MirrexOne/unqueryvet/.golangci.yml b/vendor/github.com/MirrexOne/unqueryvet/.golangci.yml
new file mode 100644
index 0000000000..d604d323fd
--- /dev/null
+++ b/vendor/github.com/MirrexOne/unqueryvet/.golangci.yml
@@ -0,0 +1,20 @@
+version: "2"
+
+formatters:
+ enable:
+ - gofumpt
+ - goimports
+ settings:
+ gofumpt:
+ extra-rules: true
+
+linters:
+ exclusions:
+ warn-unused: true
+ presets:
+ - comments
+ - std-error-handling
+
+issues:
+ max-issues-per-linter: 0
+ max-same-issues: 0
diff --git a/vendor/github.com/MirrexOne/unqueryvet/.unqueryvet.example.yaml b/vendor/github.com/MirrexOne/unqueryvet/.unqueryvet.example.yaml
new file mode 100644
index 0000000000..e3327ee7e3
--- /dev/null
+++ b/vendor/github.com/MirrexOne/unqueryvet/.unqueryvet.example.yaml
@@ -0,0 +1,165 @@
+# Unqueryvet Configuration File
+# This is an example configuration showing all available options
+#
+# JSON Schema validation is automatically provided by SchemaStore.org
+# for editors that support it (VS Code, GoLand, Neovim, etc.)
+
+# ==============================================================================
+# LEVEL 1: Simple Configuration (quick setup)
+# ==============================================================================
+
+# Built-in rules severity configuration
+# Available rules: select-star, n1-queries, sql-injection, tx-leak
+# Severity values: error, warning, info, ignore
+rules:
+ select-star: warning
+ n1-queries: warning
+ sql-injection: error
+ tx-leak: warning
+
+# Files to ignore (glob patterns)
+ignore:
+ - "*_test.go"
+ - "testdata/**"
+ - "vendor/**"
+
+# SQL patterns to whitelist (won't trigger warnings)
+allow:
+ - "COUNT(*)"
+ - "information_schema.*"
+
+# ==============================================================================
+# LEVEL 2: Detailed Configuration (existing options)
+# ==============================================================================
+
+# Enable/disable SQL builder checking (default: true)
+check-sql-builders: true
+
+# Enable/disable aliased wildcard detection like SELECT t.* (default: true)
+check-aliased-wildcard: true
+
+# Enable/disable string concatenation analysis (default: true)
+check-string-concat: true
+
+# Enable/disable format string analysis like fmt.Sprintf (default: true)
+check-format-strings: true
+
+# Enable/disable strings.Builder analysis (default: true)
+check-string-builder: true
+
+# Enable/disable subquery analysis (default: true)
+check-subqueries: true
+
+# Diagnostic severity: "error" or "warning" (default: "warning")
+severity: warning
+
+# SQL builder libraries to check (all enabled by default)
+sql-builders:
+ squirrel: true
+ gorm: true
+ sqlx: true
+ ent: true
+ pgx: true
+ bun: true
+ sqlboiler: true
+ jet: true
+ sqlc: true
+ goqu: true
+ rel: true
+ reform: true
+
+# Legacy: Patterns for files to ignore (use 'ignore' instead)
+# ignored-files:
+# - "*_test.go"
+
+# Legacy: Functions to ignore (regex patterns)
+# ignored-functions:
+# - "debug\\..*"
+# - "test.*"
+
+# Legacy: Regex patterns to allow (use 'allow' instead)
+# allowed-patterns:
+# - "SELECT \\* FROM temp_.*"
+
+# ==============================================================================
+# LEVEL 3: Custom Rules with DSL (advanced)
+# ==============================================================================
+
+# Define your own analysis rules using patterns and conditions
+custom-rules:
+ # Example 1: Allow SELECT * for temporary tables
+ - id: allow-temp-tables
+ pattern: SELECT * FROM $TABLE
+ when: isTempTable(table)
+ action: allow
+
+ # Example 2: Detect N+1 queries in loops
+ - id: n1-in-loop
+ pattern: $DB.Query($QUERY)
+ when: in_loop && !contains(function, "batch")
+ message: "Potential N+1 query detected in loop"
+ severity: warning
+ fix: "Consider using batch query or preloading"
+
+ # Example 3: Require WHERE clause for DELETE/UPDATE
+ - id: require-where
+ patterns:
+ - DELETE FROM $TABLE
+ - UPDATE $TABLE SET $COLS
+ when: "!has_where"
+ message: "Dangerous query without WHERE clause"
+ severity: error
+
+ # Example 4: Context-aware rules (strict in prod code, relaxed in tests)
+ - id: strict-select-star
+ pattern: SELECT * FROM $TABLE
+ when: |
+ !matches(file, "_test.go$") &&
+ !matches(file, "testdata/") &&
+ !isSystemTable(table) &&
+ !isTempTable(table)
+ message: "Avoid SELECT * in production code - specify columns explicitly"
+ severity: error
+
+# ==============================================================================
+# DSL Reference
+# ==============================================================================
+#
+# Pattern Metavariables:
+# $TABLE - matches table name (with optional schema)
+# $VAR - matches identifier/variable
+# $QUERY - matches string literal
+# $COLS - matches column list
+# $EXPR - matches any expression
+# $DB - matches database object
+#
+# Condition Variables:
+# file - current file path
+# package - current package name
+# function - current function name
+# query - SQL query text
+# query_type - SELECT, INSERT, UPDATE, DELETE
+# table - primary table name
+# tables - list of all tables
+# columns - list of columns
+# has_join - true if query has JOIN
+# has_where - true if query has WHERE
+# in_loop - true if inside a loop
+# loop_depth - nesting depth of loops
+# builder - SQL builder type (gorm, squirrel, etc.)
+#
+# Built-in Functions:
+# contains(str, substr) - check if string contains substring
+# matches(str, regex) - check if string matches regex
+# startsWith(str, prefix) - check if string starts with prefix
+# endsWith(str, suffix) - check if string ends with suffix
+# isSystemTable(table) - check if table is system/catalog table
+# isTempTable(table) - check if table looks like temp table
+# isAggregate(query) - check if query has aggregate functions
+#
+# Operators:
+# =~ - regex match (e.g., file =~ "_test.go$")
+# !~ - regex not match
+# && - logical AND
+# || - logical OR
+# ! - logical NOT
diff --git a/vendor/github.com/MirrexOne/unqueryvet/CONTRIBUTING.md b/vendor/github.com/MirrexOne/unqueryvet/CONTRIBUTING.md
new file mode 100644
index 0000000000..dacc307342
--- /dev/null
+++ b/vendor/github.com/MirrexOne/unqueryvet/CONTRIBUTING.md
@@ -0,0 +1,341 @@
+# Contributing to unqueryvet
+
+Thank you for your interest in contributing to unqueryvet! This document provides guidelines and instructions for contributing.
+
+## Table of Contents
+
+- [Getting Started](#getting-started)
+- [Development Setup](#development-setup)
+- [Project Structure](#project-structure)
+- [Running Tests](#running-tests)
+- [Code Style](#code-style)
+- [Pull Request Process](#pull-request-process)
+- [Adding New SQL Builders](#adding-new-sql-builders)
+- [Reporting Issues](#reporting-issues)
+
+---
+
+## Getting Started
+
+1. Fork the repository on GitHub
+2. Clone your fork locally:
+ ```bash
+ git clone https://github.com/YOUR_USERNAME/unqueryvet.git
+ cd unqueryvet
+ ```
+3. Add the upstream remote:
+ ```bash
+ git remote add upstream https://github.com/MirrexOne/unqueryvet.git
+ ```
+4. Create a new branch for your feature:
+ ```bash
+ git checkout -b feature/your-feature-name
+ ```
+
+---
+
+## Development Setup
+
+### Prerequisites
+
+- Go 1.24 or later
+- [Task](https://taskfile.dev/) (optional, but recommended)
+- golangci-lint (for linting)
+
+### Install Dependencies
+
+```bash
+go mod download
+```
+
+### Build
+
+Using Task:
+```bash
+task build # Build CLI
+task build:lsp # Build LSP server
+task build:all # Build both
+```
+
+Using Go directly:
+```bash
+go build ./cmd/unqueryvet
+go build ./cmd/unqueryvet-lsp
+```
+
+### Install Locally
+
+```bash
+task install:all
+# or
+go install ./cmd/unqueryvet
+go install ./cmd/unqueryvet-lsp
+```
+
+---
+
+## Project Structure
+
+```
+unqueryvet/
+├── cmd/
+│ ├── unqueryvet/ # CLI entry point
+│ └── unqueryvet-lsp/ # LSP server entry point
+├── internal/
+│ ├── analyzer/ # Core analysis engine
+│ │ ├── sqlbuilders/ # SQL builder support (12 builders)
+│ │ ├── n1detector.go # N+1 query detection
+│ │ └── sqli_scanner.go # SQL injection scanner
+│ ├── cli/ # CLI output utilities
+│ ├── configloader/ # Configuration loading
+│ ├── dsl/ # Custom Rules DSL engine
+│ ├── lsp/ # LSP server implementation
+│ ├── messages/ # Error messages
+│ ├── runner/ # Analysis runner
+│ ├── tui/ # Interactive TUI (Bubble Tea)
+│ └── version/ # Version information
+├── pkg/
+│ └── config/ # Public configuration API
+├── extensions/
+│ ├── goland/ # GoLand/IntelliJ plugin (Kotlin)
+│ └── vscode/ # VS Code extension (TypeScript)
+├── docs/ # Documentation
+├── _examples/ # Example configurations
+└── testdata/ # Test fixtures
+```
+
+### Key Packages
+
+| Package | Description |
+|---------|-------------|
+| `internal/analyzer` | Core detection logic (SELECT *, N+1, SQL Injection) |
+| `internal/analyzer/sqlbuilders` | Support for 12 SQL builder libraries |
+| `internal/dsl` | Custom rules DSL using expr-lang |
+| `internal/lsp` | Language Server Protocol implementation |
+| `internal/tui` | Interactive terminal UI with Bubble Tea |
+| `pkg/config` | Configuration with default rules |
+
+> **Note**: All three detection rules (SELECT *, N+1, SQL Injection) are enabled by default.
+
+---
+
+## Running Tests
+
+Using Task:
+```bash
+task test # Run all tests
+task test:race # Run with race detection (requires CGO)
+task test:short # Run short tests only
+task test:unit # Run unit tests only
+task test:integration # Run integration tests
+task coverage # Generate coverage report
+```
+
+Using Go directly:
+```bash
+go test ./...
+go test -v -race ./...
+go test -coverprofile=coverage.out ./...
+```
+
+### Running Benchmarks
+
+```bash
+task bench
+# or
+go test -bench=. -benchmem ./internal/analyzer
+```
+
+---
+
+## Code Style
+
+### Formatting
+
+```bash
+task fmt # Format code
+task fmt:check # Check formatting
+```
+
+### Linting
+
+```bash
+task lint # Run golangci-lint
+task lint:fix # Run with auto-fix
+task vet # Run go vet
+```
+
+### All Checks
+
+```bash
+task check:all # fmt:check + vet + lint + test
+```
+
+### Guidelines
+
+1. **Follow Go conventions** - Use `gofmt`, follow [Effective Go](https://go.dev/doc/effective_go)
+2. **Write tests** - All new features should have tests
+3. **Document exports** - All exported functions/types need documentation comments
+4. **Keep it simple** - Prefer simple, readable code over clever solutions
+5. **No breaking changes** - Maintain backward compatibility for public APIs
+
+---
+
+## Pull Request Process
+
+1. **Sync with upstream**
+ ```bash
+ git fetch upstream
+ git rebase upstream/main
+ ```
+
+2. **Ensure tests pass**
+ ```bash
+ task check:all
+ ```
+
+3. **Write meaningful commit messages**
+ ```
+ feat: add support for new SQL builder XYZ
+
+ - Add XYZ builder detection in internal/analyzer/sqlbuilders/
+ - Add tests for common XYZ patterns
+ - Update documentation
+ ```
+
+4. **Push and create PR**
+ ```bash
+ git push origin feature/your-feature-name
+ ```
+
+5. **PR Requirements**
+ - Clear description of changes
+ - Tests for new functionality
+ - Documentation updates if needed
+ - Passing CI checks
+
+---
+
+## Adding New SQL Builders
+
+To add support for a new SQL builder library:
+
+### 1. Create Builder File
+
+Create `internal/analyzer/sqlbuilders/yourbuilder.go`:
+
+```go
+package sqlbuilders
+
+import (
+ "go/ast"
+)
+
+// YourBuilderChecker checks for SELECT * in YourBuilder queries.
+type YourBuilderChecker struct {
+ BaseChecker
+}
+
+// NewYourBuilderChecker creates a new checker for YourBuilder.
+func NewYourBuilderChecker() *YourBuilderChecker {
+ return &YourBuilderChecker{
+ BaseChecker: BaseChecker{
+ name: "yourbuilder",
+ packagePath: "github.com/example/yourbuilder",
+ },
+ }
+}
+
+func (c *YourBuilderChecker) Name() string {
+ return c.name
+}
+
+func (c *YourBuilderChecker) IsApplicable(call *ast.CallExpr) bool {
+ // Check if this call is from yourbuilder package
+ return c.isPackageCall(call, "yourbuilder")
+}
+
+func (c *YourBuilderChecker) CheckSelectStar(call *ast.CallExpr) *Violation {
+ // Implement SELECT * detection logic
+ return nil
+}
+
+func (c *YourBuilderChecker) CheckChainedCalls(call *ast.CallExpr) []*Violation {
+ // Check method chains for SELECT *
+ return nil
+}
+```
+
+### 2. Register in Registry
+
+Update `internal/analyzer/sqlbuilders/interface.go`:
+
+```go
+func NewRegistry(cfg *config.SQLBuildersConfig) *Registry {
+ r := &Registry{checkers: make([]SQLBuilderChecker, 0)}
+
+ // ... existing builders ...
+
+ if cfg.YourBuilder {
+ r.checkers = append(r.checkers, NewYourBuilderChecker())
+ }
+
+ return r
+}
+```
+
+### 3. Add Configuration
+
+Update `pkg/config/config.go`:
+
+```go
+type SQLBuildersConfig struct {
+ // ... existing fields ...
+ YourBuilder bool `yaml:"yourbuilder"`
+}
+
+func DefaultSQLBuildersConfig() SQLBuildersConfig {
+ return SQLBuildersConfig{
+ // ... existing defaults ...
+ YourBuilder: true,
+ }
+}
+```
+
+### 4. Write Tests
+
+Create `internal/analyzer/sqlbuilders/yourbuilder_test.go` with test cases.
+
+### 5. Update Documentation
+
+- Add to README.md SQL builders table
+- Add example in `` block
+- Update `.unqueryvet.example.yaml`
+
+---
+
+## Reporting Issues
+
+### Bug Reports
+
+Please include:
+- Go version (`go version`)
+- unqueryvet version (`unqueryvet -version`)
+- Operating system
+- Minimal reproducible example
+- Expected vs actual behavior
+
+### Feature Requests
+
+Please include:
+- Use case description
+- Proposed solution (if any)
+- Examples of desired behavior
+
+---
+
+## Questions?
+
+- Open a [GitHub Issue](https://github.com/MirrexOne/unqueryvet/issues)
+
+Thank you for contributing!
diff --git a/vendor/github.com/MirrexOne/unqueryvet/Dockerfile b/vendor/github.com/MirrexOne/unqueryvet/Dockerfile
new file mode 100644
index 0000000000..58383d2d13
--- /dev/null
+++ b/vendor/github.com/MirrexOne/unqueryvet/Dockerfile
@@ -0,0 +1,42 @@
+# Build stage
+FROM golang:1.24-alpine AS builder
+
+RUN apk add --no-cache git gcc musl-dev
+
+WORKDIR /app
+
+# Copy go mod files
+COPY go.mod go.sum ./
+RUN go mod download
+
+# Copy source
+COPY . .
+
+# Build binaries
+RUN CGO_ENABLED=1 go build -ldflags="-s -w" -o /unqueryvet ./cmd/unqueryvet
+RUN CGO_ENABLED=1 go build -ldflags="-s -w" -o /unqueryvet-lsp ./cmd/unqueryvet-lsp
+
+# Final stage
+FROM alpine:3.19
+
+RUN apk add --no-cache ca-certificates tzdata
+
+# Create non-root user
+RUN adduser -D -u 1000 unqueryvet
+USER unqueryvet
+
+WORKDIR /workspace
+
+# Copy binaries
+COPY --from=builder /unqueryvet /usr/local/bin/
+COPY --from=builder /unqueryvet-lsp /usr/local/bin/
+
+# Default command
+ENTRYPOINT ["unqueryvet"]
+CMD ["./..."]
+
+# Labels
+LABEL org.opencontainers.image.title="Unqueryvet"
+LABEL org.opencontainers.image.description="SQL SELECT * linter for Go"
+LABEL org.opencontainers.image.source="https://github.com/MirrexOne/unqueryvet"
+LABEL org.opencontainers.image.licenses="MIT"
diff --git a/vendor/github.com/MirrexOne/unqueryvet/LICENSE b/vendor/github.com/MirrexOne/unqueryvet/LICENSE
new file mode 100644
index 0000000000..278a61152a
--- /dev/null
+++ b/vendor/github.com/MirrexOne/unqueryvet/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2024 MirrexOne
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
\ No newline at end of file
diff --git a/vendor/github.com/MirrexOne/unqueryvet/README.md b/vendor/github.com/MirrexOne/unqueryvet/README.md
new file mode 100644
index 0000000000..faa5e7b66c
--- /dev/null
+++ b/vendor/github.com/MirrexOne/unqueryvet/README.md
@@ -0,0 +1,900 @@
+# unqueryvet
+
+[](https://goreportcard.com/report/github.com/MirrexOne/unqueryvet)
+[](https://pkg.go.dev/github.com/MirrexOne/unqueryvet)
+[](LICENSE)
+
+[](https://plugins.jetbrains.com/plugin/29733-unqueryvet)
+[](https://plugins.jetbrains.com/plugin/29733-unqueryvet)
+
+[](https://marketplace.visualstudio.com/items?itemName=mirrexdev.unqueryvet)
+[](https://marketplace.visualstudio.com/items?itemName=mirrexdev.unqueryvet)
+
+[](https://plugins.jetbrains.com/plugin/29733-unqueryvet)
+[](https://marketplace.visualstudio.com/items?itemName=mirrexdev.unqueryvet)
+
+**unqueryvet** is a comprehensive Go linter for SQL queries. It detects `SELECT *` usage, N+1 query problems, SQL injection vulnerabilities, and provides suggestions for query optimization.
+
+## Key Features
+
+| Feature | Description |
+| ----------------------------- | ---------------------------------------------------------------------------- |
+| **SELECT \* Detection** | Finds `SELECT *` in raw SQL, SQL builders, and templates |
+| **N+1 Query Detection** | Identifies queries inside loops |
+| **SQL Injection Scanner** | Detects `fmt.Sprintf` and string concatenation vulnerabilities |
+| **Transaction Leak Detection**| Detects unclosed transactions and improper lifecycle management |
+| **12 SQL Builder Support** | Squirrel, GORM, SQLx, Ent, PGX, Bun, SQLBoiler, Jet, sqlc, goqu, rel, reform |
+| **Custom Rules DSL** | Define your own analysis rules |
+| **LSP Server** | Real-time IDE integration |
+| **Interactive TUI** | Fix issues interactively |
+
+---
+
+## Installation
+
+### Standalone Tool
+
+```bash
+go install github.com/MirrexOne/unqueryvet/cmd/unqueryvet@latest
+```
+
+### LSP Server (for IDE integration)
+
+```bash
+go install github.com/MirrexOne/unqueryvet/cmd/unqueryvet-lsp@latest
+```
+
+### Docker
+
+```bash
+docker pull ghcr.io/mirrexone/unqueryvet:latest
+docker run --rm -v $(pwd):/app ghcr.io/mirrexone/unqueryvet /app/...
+```
+
+### With golangci-lint
+
+Add to your `.golangci.yml`:
+
+```yaml
+version: "2"
+
+linters:
+ enable:
+ - unqueryvet
+
+ settings:
+ unqueryvet:
+ check-sql-builders: true
+```
+
+---
+
+## Quick Start
+
+### Basic Usage
+
+```bash
+# Analyze all packages (all rules enabled by default)
+unqueryvet ./...
+
+# Verbose output with explanations
+unqueryvet -verbose ./...
+
+# Quiet mode (errors only) for CI/CD
+unqueryvet -quiet ./...
+
+# Show statistics
+unqueryvet -stats ./...
+
+# Interactive fix mode
+unqueryvet -fix ./...
+
+# Show version
+unqueryvet -version
+```
+
+### Default Rules
+
+All detection rules are **enabled by default**:
+
+| Rule | Default Severity | Description |
+|------|-----------------|-------------|
+| `select-star` | warning | Detects `SELECT *` usage |
+| `n1-queries` | warning | Detects N+1 query patterns (queries in loops) |
+| `sql-injection` | error | Detects SQL injection vulnerabilities |
+| `tx-leak` | warning | Detects unclosed SQL transactions |
+
+To disable a rule, set its severity to `ignore` in your `.unqueryvet.yaml`:
+
+```yaml
+rules:
+ n1-queries: ignore # Disable N+1 detection
+```
+
+### CLI Flags
+
+| Flag | Description |
+|------|-------------|
+| `-version` | Print version information |
+| `-verbose` | Enable verbose output with detailed explanations |
+| `-quiet` | Quiet mode (only errors) |
+| `-stats` | Show analysis statistics |
+| `-no-color` | Disable colored output |
+| `-n1` | Force enable N+1 detection (overrides config) |
+| `-sqli` | Force enable SQL injection detection (overrides config) |
+| `-tx-leak` | Force enable transaction leak detection (overrides config) |
+| `-fix` | Interactive fix mode - step through issues and apply fixes |
+
+### With Configuration File
+
+```bash
+# Create config file
+cat > .unqueryvet.yaml << 'EOF'
+severity: warning
+check-sql-builders: true
+
+# Rules are enabled by default - configure severity if needed
+rules:
+ select-star: warning
+ n1-queries: warning
+ sql-injection: error
+
+ignore:
+ - "*_test.go"
+ - "vendor/**"
+EOF
+
+# Run (auto-loads config)
+unqueryvet ./...
+```
+
+---
+
+## Detection Examples
+
+### 1. SELECT \* Detection
+
+**Bad code:**
+
+```go
+// Direct SELECT *
+query := "SELECT * FROM users"
+
+// Aliased wildcard
+query := "SELECT t.* FROM users t"
+
+// In subquery
+query := "SELECT id FROM (SELECT * FROM users)"
+
+// String concatenation
+query := "SELECT * " + "FROM users"
+
+// Format string
+query := fmt.Sprintf("SELECT * FROM %s", table)
+
+// SQL builders
+squirrel.Select("*").From("users")
+db.Model(&User{}).Select("*")
+goqu.From("users").Select(goqu.Star())
+```
+
+**Good code:**
+
+```go
+// Explicit columns
+query := "SELECT id, name, email FROM users"
+
+// SQL builders
+squirrel.Select("id", "name", "email").From("users")
+db.Model(&User{}).Select("id", "name", "email")
+goqu.From("users").Select("id", "name", "email")
+```
+
+### 2. N+1 Query Detection
+
+**Bad code (triggers warning):**
+
+```go
+users, _ := db.Query("SELECT id, name FROM users")
+for users.Next() {
+ var user User
+ users.Scan(&user.ID, &user.Name)
+
+ // N+1 problem: query inside loop
+ orders, _ := db.Query("SELECT * FROM orders WHERE user_id = ?", user.ID)
+}
+```
+
+**Good code:**
+
+```go
+// Use JOIN
+query := `
+ SELECT u.id, u.name, o.id, o.total
+ FROM users u
+ LEFT JOIN orders o ON u.id = o.user_id
+`
+
+// Or use IN clause
+userIDs := []int{1, 2, 3, 4, 5}
+query := "SELECT * FROM orders WHERE user_id IN (?)"
+db.Query(query, userIDs)
+```
+
+### 3. SQL Injection Detection
+
+**Bad code (triggers warning):**
+
+```go
+// String concatenation with user input
+query := "SELECT * FROM users WHERE name = '" + userName + "'"
+
+// fmt.Sprintf with user input
+query := fmt.Sprintf("SELECT * FROM users WHERE id = %s", userID)
+```
+
+**Good code:**
+
+```go
+// Parameterized query
+query := "SELECT id, name FROM users WHERE name = ?"
+db.Query(query, userName)
+
+// Named parameters
+query := "SELECT id, name FROM users WHERE id = :id"
+db.NamedQuery(query, map[string]interface{}{"id": userID})
+```
+
+### 4. Transaction Leak Detection
+
+Detects unclosed SQL transactions using 19-phase AST analysis. Supports multiple transaction begin methods across different libraries.
+
+**Supported Begin Methods:**
+
+| Library | Methods |
+|---------|---------|
+| database/sql | `Begin`, `BeginTx` |
+| sqlx | `Beginx`, `BeginTxx`, `MustBegin`, `MustBeginTx` |
+| pgx | `BeginFunc`, `BeginTxFunc` |
+| bun | `RunInTx` |
+| ent | `Tx`, `NewTx` |
+
+**Detection Patterns:**
+
+| Violation Type | Severity | Description |
+|----------------|----------|-------------|
+| `no_commit_rollback` | critical | Transaction has neither Commit() nor Rollback() |
+| `no_rollback` | high | Transaction has Commit() but no Rollback() for error paths |
+| `no_commit` | medium | Transaction has Rollback() but no Commit() |
+| `early_return` | high | Early return paths bypass Commit() without defer |
+| `defer_in_loop` | high | Defer inside loop - defers pile up until function returns |
+| `shadowed_transaction` | high | Transaction variable shadowed in inner scope |
+| `goroutine_capture` | high | Transaction captured by goroutine without defer |
+| `variable_reassignment` | high | Transaction variable reassigned - previous tx may leak |
+| `fatal_without_defer` | high | Transaction may leak if os.Exit/log.Fatal called |
+| `panic_without_defer` | medium | Transaction may leak if panic() called |
+| `conditional_commit` | medium | Commit() inside conditional - may not execute |
+| `commit_in_switch` | medium | Commit() in switch/case - may not execute in all cases |
+| `commit_in_select` | medium | Commit() in select/case - may not execute |
+| `commit_in_loop` | medium | Commit() in loop - may not execute if loop doesn't iterate |
+| `deferred_commit` | medium | Using defer Commit() is an antipattern |
+| `commit_error_ignored` | low | Commit() error ignored with blank identifier |
+| `rollback_error_ignored` | low | Rollback() error ignored with blank identifier |
+
+**Bad code (triggers error):**
+
+```go
+func createUser(db *sql.DB, name string) error {
+ tx, err := db.Begin()
+ if err != nil {
+ return err
+ }
+ // Missing defer tx.Rollback() and missing tx.Commit()!
+
+ _, err = tx.Exec("INSERT INTO users (name) VALUES (?)", name)
+ if err != nil {
+ return err // Transaction leaked!
+ }
+ return nil
+}
+
+func deferInLoop(db *sql.DB, items []string) error {
+ for _, item := range items {
+ tx, _ := db.Begin()
+ defer tx.Rollback() // Defers pile up until function returns!
+ tx.Exec("INSERT...", item)
+ tx.Commit()
+ }
+ return nil
+}
+```
+
+**Good code:**
+
+```go
+func createUser(db *sql.DB, name string) error {
+ tx, err := db.Begin()
+ if err != nil {
+ return err
+ }
+ defer tx.Rollback() // Safe: called after Commit() is a no-op
+
+ _, err = tx.Exec("INSERT INTO users (name) VALUES (?)", name)
+ if err != nil {
+ return err // Rollback will be called via defer
+ }
+
+ return tx.Commit()
+}
+
+// Using callback pattern (automatically handled)
+func createUserCallback(db *pgx.Conn, name string) error {
+ return db.BeginFunc(ctx, func(tx pgx.Tx) error {
+ _, err := tx.Exec(ctx, "INSERT INTO users (name) VALUES ($1)", name)
+ return err // Commit/Rollback handled automatically
+ })
+}
+```
+
+---
+
+## Configuration
+
+### Full Configuration File (.unqueryvet.yaml)
+
+```yaml
+# Built-in rules severity (all enabled by default)
+# Available values: error, warning, info, ignore
+rules:
+ select-star: warning # SELECT * detection
+ n1-queries: warning # N+1 query detection
+ sql-injection: error # SQL injection scanning
+ tx-leak: warning # Transaction leak detection
+
+# Diagnostic severity for legacy options: "error" or "warning"
+severity: warning
+
+# Core analysis options
+check-sql-builders: true
+check-aliased-wildcard: true
+check-string-concat: true
+check-format-strings: true
+check-string-builder: true
+check-subqueries: true
+
+# SQL builder libraries to check
+sql-builders:
+ squirrel: true
+ gorm: true
+ sqlx: true
+ ent: true
+ pgx: true
+ bun: true
+ sqlboiler: true
+ jet: true
+ sqlc: true
+ goqu: true
+ rel: true
+ reform: true
+
+# File patterns to ignore (glob)
+ignored-files:
+ - "*_test.go"
+ - "testdata/**"
+ - "vendor/**"
+ - "mock_*.go"
+
+# Function patterns to ignore (regex)
+ignored-functions:
+ - "debug\\..*"
+ - "test.*"
+
+# Allowed SELECT * patterns (regex)
+allowed-patterns:
+ - "SELECT \\* FROM information_schema\\..*"
+ - "SELECT \\* FROM pg_catalog\\..*"
+ - "SELECT \\* FROM temp_.*"
+```
+
+---
+
+## Custom Rules DSL
+
+Define your own analysis rules using a powerful DSL with three levels of complexity.
+
+### Level 1: Simple Configuration
+
+```yaml
+# .unqueryvet.yaml
+rules:
+ select-star: error # Built-in rule severity
+ n1-queries: warning
+ sql-injection: error
+
+ignore:
+ - "*_test.go"
+ - "testdata/**"
+
+allow:
+ - "COUNT(*)"
+ - "information_schema.*"
+```
+
+### Level 2: Pattern Matching
+
+```yaml
+custom-rules:
+ - id: allow-temp-tables
+ pattern: SELECT * FROM $TABLE
+ when: isTempTable(table)
+ action: allow
+
+ - id: dangerous-delete
+ pattern: DELETE FROM $TABLE
+ when: "!has_where"
+ message: "DELETE without WHERE clause"
+ severity: error
+
+ - id: require-tx-timeout
+ pattern: db.BeginTx($CTX, $OPTS)
+ when: "!contains(opts, 'Timeout')"
+ message: "Transaction should have timeout set"
+ severity: warning
+```
+
+### Level 3: Advanced Conditions
+
+```yaml
+custom-rules:
+ - id: n1-detection
+ pattern: $DB.Query($QUERY)
+ when: |
+ in_loop &&
+ !contains(function, "batch") &&
+ !matches(file, "_test.go$")
+ message: "N+1 query in loop"
+ severity: warning
+ fix: "Use batch query or preloading"
+```
+
+### DSL Reference
+
+| **Metavariables** | **Description** |
+|-------------------|-----------------|
+| `$TABLE` | Table name (with optional schema) |
+| `$VAR` | Identifier/variable |
+| `$QUERY` | String literal |
+| `$COLS` | Column list |
+| `$DB` | Database object |
+
+| **Variables** | **Description** |
+|---------------|-----------------|
+| `file`, `package`, `function` | Code context |
+| `query`, `query_type`, `table` | SQL context |
+| `has_where`, `has_join` | Query structure |
+| `in_loop`, `loop_depth` | Loop context |
+| `builder` | SQL builder type |
+
+| **Functions** | **Description** |
+|---------------|-----------------|
+| `contains(s, sub)` | String contains |
+| `matches(s, regex)` | Regex match |
+| `isSystemTable(t)` | System table check |
+| `isTempTable(t)` | Temp table check |
+| `isAggregate(q)` | Aggregate function check |
+
+| **Operators** | **Description** |
+|---------------|-----------------|
+| `=~`, `!~` | Regex match/not match |
+| `&&`, `\|\|`, `!` | Logical operators |
+
+Full documentation: [docs/DSL.md](docs/DSL.md)
+
+---
+
+## LSP Server (IDE Integration)
+
+The LSP server provides real-time analysis in your IDE.
+
+### Starting the Server
+
+```bash
+unqueryvet-lsp
+```
+
+### VS Code Setup
+
+Install the extension from `extensions/vscode/` or configure manually:
+
+```json
+// .vscode/settings.json
+{
+ "unqueryvet.enable": true,
+ "unqueryvet.path": "unqueryvet-lsp",
+ // All rules enabled by default, args optional
+ "unqueryvet.trace.server": "verbose"
+}
+```
+
+### Features
+
+- **Real-time diagnostics** - See issues as you type
+- **Hover information** - Explanations on hover
+- **Quick fixes** - One-click fixes for SELECT \*
+- **Code completion** - Column name suggestions
+
+### GoLand/IntelliJ Setup
+
+1. Build the plugin: `cd extensions/goland && ./gradlew buildPlugin`
+2. Install from disk: Settings → Plugins → Install from disk
+3. Configure: Settings → Tools → unqueryvet
+
+---
+
+## Interactive TUI Mode
+
+Fix issues interactively with a terminal UI.
+
+```bash
+unqueryvet -fix ./...
+```
+
+### Controls
+
+| Category | Key | Action |
+|----------|-----|--------|
+| **Navigation** | `↑/k` | Previous issue |
+| | `↓/j` | Next issue |
+| | `g` | Go to first issue |
+| | `G` | Go to last issue |
+| **Actions** | `Enter/a` | Apply fix |
+| | `s` | Skip issue |
+| | `u` | Undo last action |
+| | `p` | Toggle preview |
+| **Batch** | `A` | Apply all remaining |
+| | `S` | Skip all remaining |
+| | `R` | Reset all actions |
+| **Other** | `e` | Export results to JSON |
+| | `?` | Toggle help |
+| | `q/Esc` | Quit |
+
+### Example Session
+
+```
+Found 15 issues. Review each one:
+
+[1/15] internal/api/users.go:42:15
+─────────────────────────────────────
+ 41 | func getUsers(db *sql.DB) {
+ 42 | query := "SELECT * FROM users"
+ | ^^^^^^^^^^^^^^^^^^^^^ avoid SELECT *
+ 43 | rows, _ := db.Query(query)
+
+Suggestions:
+ 1. SELECT id, username, email, created_at (from struct User)
+ 2. SELECT id, username, email
+ 3. Skip this issue
+ 4. Edit manually
+
+Your choice [1-4]: _
+```
+
+---
+
+## Supported SQL Builders
+
+### Full Support (12 builders)
+
+| Builder | Package | Patterns Detected |
+| ------------- | ----------------------------------- | -------------------------------------------- |
+| **Squirrel** | `github.com/Masterminds/squirrel` | `Select("*")`, `Columns("*")` |
+| **GORM** | `gorm.io/gorm` | `Select("*")`, `Find(&users)` without Select |
+| **SQLx** | `github.com/jmoiron/sqlx` | `Select()`, raw queries |
+| **Ent** | `entgo.io/ent` | Query builder patterns |
+| **PGX** | `github.com/jackc/pgx` | `Query()`, `QueryRow()` |
+| **Bun** | `github.com/uptrace/bun` | `NewSelect()`, raw queries |
+| **SQLBoiler** | `github.com/volatiletech/sqlboiler` | Generated query methods |
+| **Jet** | `github.com/go-jet/jet` | `SELECT()`, `STAR` |
+| **sqlc** | Generated code | SELECT \* in .sql files |
+| **goqu** | `github.com/doug-martin/goqu` | `Select(goqu.Star())`, `SelectAll()` |
+| **rel** | `github.com/go-rel/rel` | `Find()`, `FindAll()` without Select |
+| **reform** | `gopkg.in/reform.v1` | `FindByPrimaryKeyFrom()`, `SelectAllFrom()` |
+
+### Examples by Builder
+
+
+Squirrel
+
+```go
+// Bad
+sq.Select("*").From("users")
+sq.Select().Columns("*").From("users")
+
+// Good
+sq.Select("id", "name", "email").From("users")
+```
+
+
+
+
+GORM
+
+```go
+// Bad
+db.Select("*").Find(&users)
+db.Table("users").Find(&users) // implicit SELECT *
+
+// Good
+db.Select("id", "name", "email").Find(&users)
+```
+
+
+
+
+goqu
+
+```go
+// Bad
+goqu.From("users").Select(goqu.Star())
+goqu.From("users").SelectAll()
+
+// Good
+goqu.From("users").Select("id", "name", "email")
+```
+
+
+
+
+rel
+
+```go
+// Bad
+repo.Find(ctx, &user) // loads all columns
+repo.FindAll(ctx, &users)
+
+// Good
+repo.Find(ctx, &user, rel.Select("id", "name", "email"))
+```
+
+
+
+
+reform
+
+```go
+// Bad
+db.FindByPrimaryKeyFrom(UserTable, id, &user)
+db.FindAllFrom(UserTable, "status", "active")
+
+// Good
+db.SelectOneFrom(UserTable, "id, name, email WHERE id = ?", id)
+```
+
+
+
+
+SQLx
+
+```go
+// Bad
+db.Select(&users, "SELECT * FROM users")
+db.Get(&user, "SELECT * FROM users WHERE id = ?", id)
+
+// Good
+db.Select(&users, "SELECT id, name, email FROM users")
+db.Get(&user, "SELECT id, name, email FROM users WHERE id = ?", id)
+```
+
+
+
+
+Ent
+
+```go
+// Bad - implicit SELECT *
+users, err := client.User.Query().All(ctx)
+
+// Good - explicit column selection
+users, err := client.User.Query().
+ Select(user.FieldID, user.FieldName, user.FieldEmail).
+ All(ctx)
+```
+
+
+
+
+PGX
+
+```go
+// Bad
+rows, err := conn.Query(ctx, "SELECT * FROM users")
+
+// Good
+rows, err := conn.Query(ctx, "SELECT id, name, email FROM users")
+```
+
+
+
+
+Bun
+
+```go
+// Bad
+db.NewSelect().Model(&users).Scan(ctx)
+db.NewSelect().TableExpr("users").Scan(ctx, &users)
+
+// Good
+db.NewSelect().Model(&users).Column("id", "name", "email").Scan(ctx)
+```
+
+
+
+
+SQLBoiler
+
+```go
+// Bad - loads all columns
+users, err := models.Users().All(ctx, db)
+user, err := models.FindUser(ctx, db, userID)
+
+// Good - explicit column selection
+users, err := models.Users(
+ qm.Select("id", "name", "email"),
+).All(ctx, db)
+```
+
+
+
+
+Jet
+
+```go
+// Bad
+stmt := SELECT(User.AllColumns).FROM(User)
+
+// Good
+stmt := SELECT(User.ID, User.Name, User.Email).FROM(User)
+```
+
+
+
+
+sqlc
+
+```sql
+-- Bad (in .sql file)
+-- name: GetUsers :many
+SELECT * FROM users;
+
+-- Good
+-- name: GetUsers :many
+SELECT id, name, email FROM users;
+```
+
+
+
+---
+
+## Docker & CI/CD
+
+### Dockerfile
+
+```dockerfile
+FROM golang:1.24-alpine AS builder
+RUN go install github.com/MirrexOne/unqueryvet/cmd/unqueryvet@latest
+
+FROM alpine:latest
+COPY --from=builder /go/bin/unqueryvet /usr/local/bin/
+ENTRYPOINT ["unqueryvet"]
+```
+
+### GitHub Actions
+
+```yaml
+name: SQL Lint
+
+on: [push, pull_request]
+
+jobs:
+ lint:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+
+ - uses: actions/setup-go@v6
+ with:
+ go-version: '1.24'
+
+ - name: Install unqueryvet
+ run: go install github.com/MirrexOne/unqueryvet/cmd/unqueryvet@latest
+
+ - name: Run unqueryvet
+ run: unqueryvet -n1 -sqli -tx-leak ./...
+```
+
+### GitLab CI
+
+```yaml
+sql-lint:
+ image: ghcr.io/mirrexone/unqueryvet:latest
+ script:
+ - unqueryvet -quiet -n1 -sqli -tx-leak ./...
+ rules:
+ - if: $CI_PIPELINE_SOURCE == "merge_request_event"
+```
+
+---
+
+## Exit Codes
+
+| Code | Meaning |
+|------|---------|
+| 0 | No issues found |
+| 1 | Warnings found |
+| 2 | Errors found |
+| 3 | Analysis failed |
+
+---
+
+## Documentation
+
+- [CLI Features Guide](docs/CLI_FEATURES.md)
+- [Custom Rules DSL](docs/DSL.md)
+- [IDE Integration Guide](docs/IDE_INTEGRATION.md)
+
+---
+
+## Development
+
+### Build
+
+```bash
+go build ./cmd/unqueryvet
+go build ./cmd/unqueryvet-lsp
+```
+
+### Test
+
+```bash
+go test ./...
+```
+
+### Install locally
+
+```bash
+go install ./cmd/unqueryvet
+go install ./cmd/unqueryvet-lsp
+```
+
+---
+
+## Contributing
+
+```bash
+git clone https://github.com/MirrexOne/unqueryvet.git
+cd unqueryvet
+go mod download
+go test ./...
+go build ./...
+```
+
+See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
+
+---
+
+## License
+
+MIT License - see [LICENSE](LICENSE) file for details.
+
+---
+
+## Acknowledgments
+
+- Built on [golang.org/x/tools/go/analysis](https://pkg.go.dev/golang.org/x/tools/go/analysis)
+- TUI powered by [Bubbletea](https://github.com/charmbracelet/bubbletea)
+
+---
+
+## Support
+
+- **Bug Reports**: [GitHub Issues](https://github.com/MirrexOne/unqueryvet/issues)
diff --git a/vendor/github.com/MirrexOne/unqueryvet/RELEASE.md b/vendor/github.com/MirrexOne/unqueryvet/RELEASE.md
new file mode 100644
index 0000000000..e1a797ede2
--- /dev/null
+++ b/vendor/github.com/MirrexOne/unqueryvet/RELEASE.md
@@ -0,0 +1,203 @@
+# Release Process
+
+This document describes how to create a new release of Unqueryvet and its VS Code extension.
+
+## Prerequisites
+
+- Push access to the repository
+- Go 1.21+ installed
+- Node.js 20+ installed
+- Git configured
+
+## Release Workflow
+
+### Option 1: Fully Automated (Recommended)
+
+1. **Create a Git tag:**
+ ```bash
+ git tag -a v1.0.0 -m "Release v1.0.0"
+ git push origin v1.0.0
+ ```
+
+2. **Create GitHub Release:**
+ - Go to https://github.com/MirrexOne/unqueryvet/releases/new
+ - Select the tag you just pushed (v1.0.0)
+ - Title: `v1.0.0`
+ - Description: List of changes
+ - Click "Publish release"
+
+3. **What happens automatically:**
+ - ✅ GitHub Actions builds LSP binaries for all platforms
+ - ✅ Binaries are attached to the release
+ - ✅ Checksums file is generated
+ - ✅ VS Code extension is built
+ - ✅ VS Code extension is published to Marketplace
+ - ✅ Extension .vsix is attached to the release
+
+4. **Wait 5-10 minutes** for workflows to complete
+
+5. **Verify:**
+ - Check release has all LSP binaries attached
+ - Check VS Code Marketplace: https://marketplace.visualstudio.com/items?itemName=mirrexdev.unqueryvet
+ - Test automatic LSP download in a fresh VS Code instance
+
+### Option 2: Manual Build
+
+If you need to build locally:
+
+1. **Build LSP binaries:**
+ ```bash
+ # Using Task
+ task build:lsp:release
+
+ # Or using script directly
+ ./scripts/build-lsp.sh v1.0.0 # Linux/macOS
+ # OR
+ powershell ./scripts/build-lsp.ps1 -Version v1.0.0 # Windows
+ ```
+
+2. **Check dist/ folder:**
+ ```bash
+ ls -lh dist/
+ ```
+
+ You should see:
+ - unqueryvet-lsp-windows-amd64.exe
+ - unqueryvet-lsp-windows-arm64.exe
+ - unqueryvet-lsp-linux-amd64
+ - unqueryvet-lsp-linux-arm64
+ - unqueryvet-lsp-darwin-amd64
+ - unqueryvet-lsp-darwin-arm64
+ - checksums.txt
+
+3. **Upload to GitHub Release manually:**
+ - Create release on GitHub
+ - Upload all files from dist/
+
+4. **Build VS Code extension:**
+ ```bash
+ cd extensions/vscode
+ npm install
+ npm run compile
+ npx @vscode/vsce package
+ ```
+
+5. **Publish VS Code extension:**
+ ```bash
+ npx @vscode/vsce publish -p YOUR_PAT_TOKEN
+ ```
+
+## Platform Support
+
+LSP binaries are built for:
+
+| Platform | Architecture | File |
+|----------|-------------|------|
+| Windows | amd64 | unqueryvet-lsp-windows-amd64.exe |
+| Windows | arm64 | unqueryvet-lsp-windows-arm64.exe |
+| Linux | amd64 | unqueryvet-lsp-linux-amd64 |
+| Linux | arm64 | unqueryvet-lsp-linux-arm64 |
+| macOS | amd64 | unqueryvet-lsp-darwin-amd64 |
+| macOS | arm64 (M1+) | unqueryvet-lsp-darwin-arm64 |
+
+## Version Numbering
+
+Follow Semantic Versioning (semver):
+
+- **Major** (v2.0.0): Breaking changes
+- **Minor** (v1.1.0): New features, backward compatible
+- **Patch** (v1.0.1): Bug fixes, backward compatible
+
+## Checklist Before Release
+
+- [ ] All tests passing (`task test`)
+- [ ] Code formatted (`task fmt`)
+- [ ] Linter passing (`task lint`)
+- [ ] CHANGELOG.md updated
+- [ ] Version bumped in:
+ - [ ] extensions/vscode/package.json
+ - [ ] extensions/vscode/CHANGELOG.md
+- [ ] README.md up to date
+- [ ] All PRs merged
+- [ ] No breaking changes (or documented)
+
+## Post-Release
+
+1. **Test installation:**
+ ```bash
+ # Test Go installation
+ go install github.com/MirrexOne/unqueryvet/cmd/unqueryvet@latest
+
+ # Test LSP installation
+ go install github.com/MirrexOne/unqueryvet/cmd/unqueryvet-lsp@latest
+ ```
+
+2. **Test VS Code extension:**
+ - Install from Marketplace
+ - Open a Go file
+ - Verify automatic LSP download works
+ - Verify diagnostics appear
+
+3. **Update documentation** if needed
+
+4. **Announce release:**
+ - Twitter/X
+ - Reddit r/golang
+ - LinkedIn
+ - Discord communities
+
+## Troubleshooting
+
+### GitHub Actions fails
+
+- Check workflow logs: https://github.com/MirrexOne/unqueryvet/actions
+- Common issues:
+ - VSCE_PAT expired → regenerate in Azure DevOps
+ - Build error → test locally first
+ - Permission error → check GITHUB_TOKEN permissions
+
+### VS Code extension not publishing
+
+- Verify VSCE_PAT secret is set in GitHub
+- Check publisher ID matches in package.json (mirrexdev)
+- Ensure version number is incremented
+
+### LSP binaries missing
+
+- Check GitHub Actions workflow completed
+- Verify tag was pushed correctly
+- Check release was published (not draft)
+
+## Emergency Rollback
+
+If a release has critical bugs:
+
+1. **Mark as pre-release** on GitHub
+2. **Unpublish VS Code extension:**
+ ```bash
+ npx @vscode/vsce unpublish mirrexdev.unqueryvet@VERSION
+ ```
+3. **Fix issues** and create new patch release
+4. **Communicate** to users about the issue
+
+## Files Modified Per Release
+
+- `extensions/vscode/package.json` - bump version
+- `extensions/vscode/CHANGELOG.md` - add release notes
+- `CHANGELOG.md` - add release notes (if exists)
+- Git tag - create new tag
+
+## Automation Scripts
+
+| Script | Purpose |
+|--------|---------|
+| `scripts/build-lsp.sh` | Build LSP for all platforms (Unix) |
+| `scripts/build-lsp.ps1` | Build LSP for all platforms (Windows) |
+| `.github/workflows/release-lsp.yml` | Auto-build LSP on release |
+| `.github/workflows/publish-vscode-extension.yml` | Auto-publish VS Code extension |
+
+## Support
+
+For issues with releases:
+- GitHub Issues: https://github.com/MirrexOne/unqueryvet/issues
+- GitHub Discussions: https://github.com/MirrexOne/unqueryvet/discussions
diff --git a/vendor/github.com/MirrexOne/unqueryvet/Taskfile.yml b/vendor/github.com/MirrexOne/unqueryvet/Taskfile.yml
new file mode 100644
index 0000000000..b93402fe42
--- /dev/null
+++ b/vendor/github.com/MirrexOne/unqueryvet/Taskfile.yml
@@ -0,0 +1,398 @@
+# https://taskfile.dev
+version: "3"
+
+vars:
+ VERSION:
+ sh: git describe --tags --always --dirty 2>/dev/null || echo "dev"
+ COMMIT:
+ sh: git rev-parse --short HEAD 2>/dev/null || echo "unknown"
+ DATE:
+ sh: date -u +"%Y-%m-%dT%H:%M:%SZ"
+ BUILT_BY:
+ sh: echo "$(whoami)@$(hostname)"
+ LDFLAGS: >-
+ -X 'github.com/MirrexOne/unqueryvet/internal/version.Version={{.VERSION}}'
+ -X 'github.com/MirrexOne/unqueryvet/internal/version.Commit={{.COMMIT}}'
+ -X 'github.com/MirrexOne/unqueryvet/internal/version.Date={{.DATE}}'
+ -X 'github.com/MirrexOne/unqueryvet/internal/version.BuiltBy={{.BUILT_BY}}'
+ BINARY_NAME: unqueryvet
+ BINARY_EXT:
+ sh: if [ "$(go env GOOS)" = "windows" ]; then echo ".exe"; fi
+
+tasks:
+ default:
+ desc: Format, test, and build
+ cmds:
+ - task: fmt
+ - task: test
+ - task: build
+
+ # ============================================================================
+ # BUILD TASKS
+ # ============================================================================
+
+ build:
+ desc: Build the unqueryvet binary
+ cmds:
+ - echo "Building {{.BINARY_NAME}}..."
+ - go build -v -ldflags "{{.LDFLAGS}}" -o {{.BINARY_NAME}}{{.BINARY_EXT}} ./cmd/unqueryvet
+ sources:
+ - "**/*.go"
+ - go.mod
+ - go.sum
+ generates:
+ - "{{.BINARY_NAME}}{{.BINARY_EXT}}"
+
+ build:lsp:
+ desc: Build the LSP server binary
+ cmds:
+ - echo "Building unqueryvet-lsp..."
+ - go build -v -ldflags "{{.LDFLAGS}}" -o unqueryvet-lsp{{.BINARY_EXT}} ./cmd/unqueryvet-lsp
+ sources:
+ - "**/*.go"
+ - go.mod
+ generates:
+ - "unqueryvet-lsp{{.BINARY_EXT}}"
+
+ build:all:
+ desc: Build all binaries
+ cmds:
+ - task: build
+ - task: build:lsp
+
+ build:lsp:all:
+ desc: Build LSP server for all platforms (cross-compile)
+ cmds:
+ - echo "Building LSP for all platforms..."
+ - |
+ if [ "$(go env GOOS)" = "windows" ]; then
+ powershell -ExecutionPolicy Bypass -File ./scripts/build-lsp.ps1 -Version "{{.VERSION}}"
+ else
+ chmod +x ./scripts/build-lsp.sh
+ ./scripts/build-lsp.sh "{{.VERSION}}"
+ fi
+ - echo "Binaries available in dist/"
+
+ build:lsp:release:
+ desc: Build LSP for all platforms with release optimizations
+ cmds:
+ - echo "Building LSP release binaries..."
+ - |
+ if [ "$(go env GOOS)" = "windows" ]; then
+ powershell -ExecutionPolicy Bypass -File ./scripts/build-lsp.ps1 -Version "{{.VERSION}}"
+ else
+ chmod +x ./scripts/build-lsp.sh
+ ./scripts/build-lsp.sh "{{.VERSION}}"
+ fi
+ - cd dist && sha256sum * > checksums.txt
+ - echo "Release binaries with checksums in dist/"
+
+ install:
+ desc: Install unqueryvet binary to GOPATH/bin
+ cmds:
+ - echo "Installing unqueryvet..."
+ - go install -ldflags "{{.LDFLAGS}}" ./cmd/unqueryvet
+
+ install:all:
+ desc: Install all binaries to GOPATH/bin
+ cmds:
+ - echo "Installing all binaries..."
+ - go install -ldflags "{{.LDFLAGS}}" ./cmd/unqueryvet
+ - go install -ldflags "{{.LDFLAGS}}" ./cmd/unqueryvet-lsp
+
+ # ============================================================================
+ # TEST TASKS
+ # ============================================================================
+
+ test:
+ desc: Run tests with race detection (requires CGO on Windows)
+ cmds:
+ - echo "Running tests..."
+ - go test -v -coverprofile=coverage.out ./...
+
+ test:race:
+ desc: Run tests with race detection (requires CGO_ENABLED=1)
+ cmds:
+ - echo "Running tests with race detection..."
+ - go test -v -race -coverprofile=coverage.out ./...
+
+ test:short:
+ desc: Run short tests (skip long-running tests)
+ cmds:
+ - echo "Running short tests..."
+ - go test -v -short ./...
+
+ test:unit:
+ desc: Run unit tests only
+ cmds:
+ - echo "Running unit tests..."
+ - go test -v ./internal/...
+
+ test:integration:
+ desc: Run integration tests
+ cmds:
+ - echo "Running integration tests..."
+ - go test -v -tags=integration ./...
+
+ bench:
+ desc: Run benchmarks
+ cmds:
+ - echo "Running benchmarks..."
+ - go test -bench=. -benchmem ./internal/analyzer
+
+ bench:all:
+ desc: Run all benchmarks with comparison
+ cmds:
+ - echo "Running all benchmarks..."
+ - go test -bench=. -benchmem -count=5 ./... | tee bench.txt
+
+ coverage:
+ desc: Generate coverage report
+ deps: [test]
+ cmds:
+ - echo "Generating coverage report..."
+ - go tool cover -html=coverage.out -o coverage.html
+ - echo "Coverage report generated - coverage.html"
+
+ coverage:func:
+ desc: Show function coverage
+ deps: [test]
+ cmds:
+ - go tool cover -func=coverage.out
+
+ # ============================================================================
+ # FORMAT & LINT TASKS
+ # ============================================================================
+
+ fmt:
+ desc: Format all Go files
+ cmds:
+ - echo "Formatting code..."
+ - gofmt -s -w .
+ - go fmt ./...
+
+ fmt:check:
+ desc: Check if code is formatted
+ cmds:
+ - echo "Checking code formatting..."
+ - |
+ UNFORMATTED=$(gofmt -s -l .)
+ if [ -n "$UNFORMATTED" ]; then
+ echo "The following files need formatting:"
+ echo "$UNFORMATTED"
+ exit 1
+ else
+ echo "All files are properly formatted"
+ fi
+
+ lint:
+ desc: Run golangci-lint
+ cmds:
+ - echo "Running linter..."
+ - golangci-lint run ./...
+
+ lint:fix:
+ desc: Run golangci-lint with auto-fix
+ cmds:
+ - echo "Running linter with auto-fix..."
+ - golangci-lint run --fix ./...
+
+ vet:
+ desc: Run go vet
+ cmds:
+ - echo "Running go vet..."
+ - go vet ./...
+
+ check:
+ desc: Run unqueryvet on the project itself
+ cmds:
+ - echo "Running unqueryvet on project..."
+ - go run ./cmd/unqueryvet ./...
+
+ check:all:
+ desc: Run all checks (fmt, vet, lint, test)
+ cmds:
+ - task: fmt:check
+ - task: vet
+ - task: lint
+ - task: test
+
+ # ============================================================================
+ # DEPENDENCY TASKS
+ # ============================================================================
+
+ deps:
+ desc: Update and verify dependencies
+ cmds:
+ - echo "Updating dependencies..."
+ - go mod tidy
+ - go mod verify
+
+ deps:download:
+ desc: Download all dependencies
+ cmds:
+ - echo "Downloading dependencies..."
+ - go mod download
+
+ deps:upgrade:
+ desc: Upgrade all dependencies to latest
+ cmds:
+ - echo "Upgrading dependencies..."
+ - go get -u ./...
+ - go mod tidy
+
+ deps:graph:
+ desc: Show dependency graph
+ cmds:
+ - go mod graph
+
+ # ============================================================================
+ # DOCKER TASKS
+ # ============================================================================
+
+ docker:build:
+ desc: Build Docker image
+ cmds:
+ - echo "Building Docker image..."
+ - docker build -t unqueryvet:{{.VERSION}} -t unqueryvet:latest .
+
+ docker:run:
+ desc: Run unqueryvet in Docker
+ cmds:
+ - docker run --rm -v $(pwd):/app unqueryvet:latest /app/...
+
+ docker:push:
+ desc: Push Docker image to registry
+ vars:
+ REGISTRY: '{{.REGISTRY | default "ghcr.io/mirrexone"}}'
+ cmds:
+ - docker tag unqueryvet:{{.VERSION}} {{.REGISTRY}}/unqueryvet:{{.VERSION}}
+ - docker tag unqueryvet:latest {{.REGISTRY}}/unqueryvet:latest
+ - docker push {{.REGISTRY}}/unqueryvet:{{.VERSION}}
+ - docker push {{.REGISTRY}}/unqueryvet:latest
+
+ # ============================================================================
+ # RELEASE TASKS
+ # ============================================================================
+
+ release:snapshot:
+ desc: Create a snapshot release (no publish)
+ cmds:
+ - echo "Creating snapshot release..."
+ - goreleaser release --snapshot --clean
+
+ release:
+ desc: Create and publish a release
+ cmds:
+ - echo "Creating release..."
+ - goreleaser release --clean
+ preconditions:
+ - sh: test -n "$GITHUB_TOKEN"
+ msg: "GITHUB_TOKEN is required"
+
+ # ============================================================================
+ # DEVELOPMENT TASKS
+ # ============================================================================
+
+ dev:
+ desc: Run in development mode with watch
+ cmds:
+ - echo "Starting development mode..."
+ - go run ./cmd/unqueryvet -watch ./...
+
+ dev:lsp:
+ desc: Run LSP server in development mode
+ cmds:
+ - echo "Starting LSP server..."
+ - go run ./cmd/unqueryvet-lsp
+
+ generate:
+ desc: Run go generate
+ cmds:
+ - echo "Running go generate..."
+ - go generate ./...
+
+ # ============================================================================
+ # CLEAN TASKS
+ # ============================================================================
+
+ clean:
+ desc: Remove build artifacts
+ cmds:
+ - echo "Cleaning..."
+ - rm -f {{.BINARY_NAME}}{{.BINARY_EXT}}
+ - rm -f unqueryvet-lsp{{.BINARY_EXT}}
+ - rm -f coverage.out coverage.html
+ - rm -f bench.txt
+ - rm -rf dist/
+ - go clean
+
+ clean:cache:
+ desc: Clean Go build cache
+ cmds:
+ - echo "Cleaning Go cache..."
+ - go clean -cache
+
+ clean:testcache:
+ desc: Clean Go test cache
+ cmds:
+ - echo "Cleaning test cache..."
+ - go clean -testcache
+
+ clean:all:
+ desc: Clean everything
+ cmds:
+ - task: clean
+ - task: clean:cache
+ - task: clean:testcache
+
+ # ============================================================================
+ # EXTENSION TASKS
+ # ============================================================================
+
+ ext:vscode:build:
+ desc: Build VS Code extension
+ dir: extensions/vscode
+ cmds:
+ - echo "Building VS Code extension..."
+ - npm install
+ - npm run compile
+
+ ext:vscode:package:
+ desc: Package VS Code extension
+ dir: extensions/vscode
+ cmds:
+ - echo "Packaging VS Code extension..."
+ - npm run package
+
+ ext:goland:build:
+ desc: Build GoLand plugin
+ dir: extensions/goland
+ cmds:
+ - echo "Building GoLand plugin..."
+ - ./gradlew buildPlugin
+
+ # ============================================================================
+ # DOCUMENTATION TASKS
+ # ============================================================================
+
+ docs:serve:
+ desc: Serve documentation locally
+ cmds:
+ - echo "Serving docs on http://localhost:8000"
+ - python -m http.server 8000 --directory docs
+
+ docs:godoc:
+ desc: Run godoc server
+ cmds:
+ - echo "Starting godoc on http://localhost:6060"
+ - godoc -http=:6060
+
+ # ============================================================================
+ # HELP
+ # ============================================================================
+
+ help:
+ desc: Show all available tasks
+ cmds:
+ - task --list-all
diff --git a/vendor/github.com/MirrexOne/unqueryvet/action.yml b/vendor/github.com/MirrexOne/unqueryvet/action.yml
new file mode 100644
index 0000000000..d01b9ae953
--- /dev/null
+++ b/vendor/github.com/MirrexOne/unqueryvet/action.yml
@@ -0,0 +1,92 @@
+name: "Unqueryvet"
+description: "Detect inconsistencies in Go SQL queries"
+author: "MirrexOne"
+
+branding:
+ icon: "search"
+ color: "blue"
+
+inputs:
+ version:
+ description: "Version of unqueryvet to use"
+ required: false
+ default: "latest"
+ working-directory:
+ description: "Working directory"
+ required: false
+ default: "."
+ args:
+ description: "Arguments to pass to unqueryvet"
+ required: false
+ default: "./..."
+ fail-on-issues:
+ description: "Fail the action if issues are found"
+ required: false
+ default: "true"
+ check-n1:
+ description: "Enable N+1 query detection"
+ required: false
+ default: "false"
+ check-sqli:
+ description: "Enable SQL injection detection"
+ required: false
+ default: "false"
+
+outputs:
+ issues-found:
+ description: "Number of issues found"
+ value: ${{ steps.run.outputs.issues }}
+ exit-code:
+ description: "Exit code from unqueryvet"
+ value: ${{ steps.run.outputs.exit_code }}
+
+runs:
+ using: "composite"
+ steps:
+ - name: Install unqueryvet
+ shell: bash
+ run: |
+ if [ "${{ inputs.version }}" = "latest" ]; then
+ go install github.com/MirrexOne/unqueryvet/cmd/unqueryvet@latest
+ else
+ go install github.com/MirrexOne/unqueryvet/cmd/unqueryvet@${{ inputs.version }}
+ fi
+
+ - name: Run unqueryvet
+ id: run
+ shell: bash
+ working-directory: ${{ inputs.working-directory }}
+ run: |
+ set +e
+
+ ARGS="${{ inputs.args }}"
+
+ if [ "${{ inputs.check-n1 }}" = "true" ]; then
+ ARGS="-n1 $ARGS"
+ fi
+
+ if [ "${{ inputs.check-sqli }}" = "true" ]; then
+ ARGS="-sqli $ARGS"
+ fi
+
+ OUTPUT=$(unqueryvet $ARGS 2>&1)
+ EXIT_CODE=$?
+
+ echo "$OUTPUT"
+
+ # Count issues (lines with file:line:column pattern)
+ ISSUES=$(echo "$OUTPUT" | grep -c ":[0-9]*:[0-9]*:" || true)
+
+ echo "issues=$ISSUES" >> $GITHUB_OUTPUT
+ echo "exit_code=$EXIT_CODE" >> $GITHUB_OUTPUT
+
+ if [ "${{ inputs.fail-on-issues }}" = "true" ] && [ $EXIT_CODE -ne 0 ]; then
+ echo "::error::Unqueryvet found $ISSUES issues"
+ exit 1
+ fi
+
+ if [ $ISSUES -eq 0 ]; then
+ echo "::notice::No SELECT * issues found!"
+ else
+ echo "::warning::Found $ISSUES SELECT * issues"
+ fi
diff --git a/vendor/github.com/MirrexOne/unqueryvet/analyzer.go b/vendor/github.com/MirrexOne/unqueryvet/analyzer.go
new file mode 100644
index 0000000000..28c3ba6e84
--- /dev/null
+++ b/vendor/github.com/MirrexOne/unqueryvet/analyzer.go
@@ -0,0 +1,27 @@
+// Package unqueryvet provides a Go static analysis tool that detects SELECT * usage
+package unqueryvet
+
+import (
+ "golang.org/x/tools/go/analysis"
+
+ "github.com/MirrexOne/unqueryvet/internal/analyzer"
+ "github.com/MirrexOne/unqueryvet/pkg/config"
+)
+
+// Analyzer is the main unqueryvet analyzer instance
+// This is the primary export that golangci-lint will use
+var Analyzer = analyzer.NewAnalyzer()
+
+// New creates a new instance of the unqueryvet analyzer
+func New() *analysis.Analyzer {
+ return Analyzer
+}
+
+// NewWithConfig creates a new analyzer instance with custom configuration
+// This is the recommended way to use unqueryvet with custom settings
+func NewWithConfig(cfg *config.UnqueryvetSettings) *analysis.Analyzer {
+ if cfg == nil {
+ return Analyzer
+ }
+ return analyzer.NewAnalyzerWithSettings(*cfg)
+}
diff --git a/vendor/github.com/MirrexOne/unqueryvet/config.go b/vendor/github.com/MirrexOne/unqueryvet/config.go
new file mode 100644
index 0000000000..03626ad38e
--- /dev/null
+++ b/vendor/github.com/MirrexOne/unqueryvet/config.go
@@ -0,0 +1,11 @@
+package unqueryvet
+
+import "github.com/MirrexOne/unqueryvet/pkg/config"
+
+// Settings is a type alias for UnqueryvetSettings from the config package.
+type Settings = config.UnqueryvetSettings
+
+// DefaultSettings returns the default configuration for Unqueryvet.
+func DefaultSettings() Settings {
+ return config.DefaultSettings()
+}
diff --git a/vendor/github.com/MirrexOne/unqueryvet/internal/analyzer/analyzer.go b/vendor/github.com/MirrexOne/unqueryvet/internal/analyzer/analyzer.go
new file mode 100644
index 0000000000..b10e9657c6
--- /dev/null
+++ b/vendor/github.com/MirrexOne/unqueryvet/internal/analyzer/analyzer.go
@@ -0,0 +1,414 @@
+// Package analyzer provides the SQL static analysis implementation for detecting SELECT * usage.
+package analyzer
+
+import (
+ "go/ast"
+ "go/token"
+ "regexp"
+ "strconv"
+ "strings"
+
+ "golang.org/x/tools/go/analysis"
+ "golang.org/x/tools/go/analysis/passes/inspect"
+ "golang.org/x/tools/go/ast/inspector"
+
+ "github.com/MirrexOne/unqueryvet/internal/analyzer/sqlbuilders"
+ "github.com/MirrexOne/unqueryvet/pkg/config"
+)
+
+const (
+ // defaultWarningMessage is the standard warning for SELECT * usage
+ defaultWarningMessage = "avoid SELECT * - explicitly specify needed columns for better performance, maintainability and stability"
+)
+
+// Precompiled regex patterns for performance
+var (
+ // aliasedWildcardPattern matches SELECT alias.* patterns like "SELECT t.*", "SELECT u.*, o.*"
+ aliasedWildcardPattern = regexp.MustCompile(`(?i)SELECT\s+(?:[A-Za-z_][A-Za-z0-9_]*\s*\.\s*\*\s*,?\s*)+`)
+
+ // subquerySelectStarPattern matches SELECT * in subqueries like "(SELECT * FROM ...)"
+ subquerySelectStarPattern = regexp.MustCompile(`(?i)\(\s*SELECT\s+\*`)
+)
+
+// NewAnalyzer creates the Unqueryvet analyzer with enhanced logic for production use
+func NewAnalyzer() *analysis.Analyzer {
+ return NewAnalyzerWithSettings(config.DefaultSettings())
+}
+
+// NewAnalyzerWithSettings creates analyzer with provided settings for golangci-lint integration
+func NewAnalyzerWithSettings(s config.UnqueryvetSettings) *analysis.Analyzer {
+ return &analysis.Analyzer{
+ Name: "unqueryvet",
+ Doc: "detects SELECT * in SQL queries and SQL builders, preventing performance issues and encouraging explicit column selection",
+ Run: func(pass *analysis.Pass) (any, error) {
+ return RunWithConfig(pass, &s)
+ },
+ Requires: []*analysis.Analyzer{inspect.Analyzer},
+ }
+}
+
+// analysisContext holds the context for AST analysis
+type analysisContext struct {
+ pass *analysis.Pass
+ cfg *config.UnqueryvetSettings
+ filter *FilterContext
+ builderRegistry *sqlbuilders.Registry
+}
+
+// RunWithConfig performs analysis with provided configuration
+// This is the main entry point for configured analysis
+func RunWithConfig(pass *analysis.Pass, cfg *config.UnqueryvetSettings) (any, error) {
+ insp := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
+
+ // Use provided configuration or default if nil
+ if cfg == nil {
+ defaultSettings := config.DefaultSettings()
+ cfg = &defaultSettings
+ }
+
+ // Create filter context for efficient filtering
+ filter, err := NewFilterContext(cfg)
+ if err != nil {
+ // If filter creation fails, continue without filtering
+ filter = nil
+ }
+
+ // Check if current file should be ignored
+ if filter != nil && len(pass.Files) > 0 {
+ fileName := pass.Fset.File(pass.Files[0].Pos()).Name()
+ if filter.IsIgnoredFile(fileName) {
+ return nil, nil
+ }
+ }
+
+ // Create SQL builder registry for checking SQL builder patterns
+ var builderRegistry *sqlbuilders.Registry
+ if cfg.CheckSQLBuilders {
+ builderRegistry = sqlbuilders.NewRegistry(&cfg.SQLBuilders)
+ }
+
+ ctx := &analysisContext{
+ pass: pass,
+ cfg: cfg,
+ filter: filter,
+ builderRegistry: builderRegistry,
+ }
+
+ // Define AST node types we're interested in
+ nodeFilter := []ast.Node{
+ (*ast.CallExpr)(nil), // Function/method calls
+ (*ast.File)(nil), // Files (for SQL builder analysis)
+ (*ast.AssignStmt)(nil), // Assignment statements for standalone literals
+ (*ast.GenDecl)(nil), // General declarations (const, var, type)
+ (*ast.BinaryExpr)(nil), // Binary expressions for string concatenation
+ }
+
+ // Walk through all AST nodes and analyze them
+ insp.Preorder(nodeFilter, ctx.handleNode)
+
+ return nil, nil
+}
+
+// handleNode dispatches AST node to appropriate handler
+func (ctx *analysisContext) handleNode(n ast.Node) {
+ switch node := n.(type) {
+ case *ast.File:
+ ctx.handleFileNode(node)
+ case *ast.AssignStmt:
+ // Check assignment statements for standalone SQL literals
+ checkAssignStmt(ctx.pass, node, ctx.cfg)
+ case *ast.GenDecl:
+ // Check constant and variable declarations
+ checkGenDecl(ctx.pass, node, ctx.cfg)
+ case *ast.CallExpr:
+ ctx.handleCallExpr(node)
+ // Analyze function calls for SQL with SELECT * usage
+ case *ast.BinaryExpr:
+ ctx.handleBinaryExpr(node)
+ }
+}
+
+// handleFileNode processes file-level analysis
+func (ctx *analysisContext) handleFileNode(node *ast.File) {
+ // Note: SQL builder analysis with type checking is done by Registry.Check() in handleCallExpr.
+ // The old analyzeSQLBuilders() function was removed because it didn't use type checking
+ // and caused false positives (issue #5).
+
+ if ctx.cfg.N1DetectionEnabled {
+ AnalyzeN1(ctx.pass, node)
+ }
+ if ctx.cfg.SQLInjectionDetectionEnabled {
+ AnalyzeSQLInjection(ctx.pass, node)
+ }
+ if ctx.cfg.TxLeakDetectionEnabled {
+ AnalyzeTxLeaks(ctx.pass, node)
+ }
+}
+
+// handleCallExpr processes function/method call expressions
+func (ctx *analysisContext) handleCallExpr(node *ast.CallExpr) {
+ if ctx.filter != nil && ctx.filter.IsIgnoredFunction(node) {
+ return
+ }
+
+ if ctx.cfg.CheckFormatStrings && CheckFormatFunction(ctx.pass, node, ctx.cfg) {
+ ctx.pass.Report(analysis.Diagnostic{
+ Pos: node.Pos(),
+ Message: getDetailedWarningMessage("format_string"),
+ })
+ return
+ }
+
+ if ctx.builderRegistry != nil && ctx.builderRegistry.HasCheckers() {
+ violations := ctx.builderRegistry.Check(ctx.pass.TypesInfo, node)
+ for _, v := range violations {
+ ctx.pass.Report(analysis.Diagnostic{
+ Pos: v.Pos,
+ End: v.End,
+ Message: v.Message,
+ })
+ }
+ if len(violations) > 0 {
+ return
+ }
+ }
+
+ checkCallExpr(ctx.pass, node, ctx.cfg)
+}
+
+// handleBinaryExpr processes binary expressions (string concatenation)
+func (ctx *analysisContext) handleBinaryExpr(node *ast.BinaryExpr) {
+ if ctx.cfg.CheckStringConcat && CheckConcatenation(ctx.pass, node, ctx.cfg) {
+ ctx.pass.Report(analysis.Diagnostic{
+ Pos: node.Pos(),
+ Message: getDetailedWarningMessage("concat"),
+ })
+ }
+}
+
+// checkAssignStmt checks assignment statements for standalone SQL literals
+func checkAssignStmt(pass *analysis.Pass, stmt *ast.AssignStmt, cfg *config.UnqueryvetSettings) {
+ // Check right-hand side expressions for string literals with SELECT *
+ for _, expr := range stmt.Rhs {
+ // Only check direct string literals, not function calls
+ if lit, ok := expr.(*ast.BasicLit); ok && lit.Kind == token.STRING {
+ content := normalizeSQLQuery(lit.Value)
+ if isSelectStarQuery(content, cfg) {
+ pass.Report(analysis.Diagnostic{
+ Pos: lit.Pos(),
+ Message: getWarningMessage(),
+ })
+ }
+ }
+ }
+}
+
+// checkGenDecl checks general declarations (const, var) for SELECT * in SQL queries
+func checkGenDecl(pass *analysis.Pass, decl *ast.GenDecl, cfg *config.UnqueryvetSettings) {
+ // Only check const and var declarations
+ if decl.Tok != token.CONST && decl.Tok != token.VAR {
+ return
+ }
+
+ // Iterate through all specifications in the declaration
+ for _, spec := range decl.Specs {
+ // Type assert to ValueSpec (const/var specifications)
+ valueSpec, ok := spec.(*ast.ValueSpec)
+ if !ok {
+ continue
+ }
+
+ // Check all values in the specification
+ for _, value := range valueSpec.Values {
+ // Only check direct string literals
+ if lit, ok := value.(*ast.BasicLit); ok && lit.Kind == token.STRING {
+ content := normalizeSQLQuery(lit.Value)
+ if isSelectStarQuery(content, cfg) {
+ pass.Report(analysis.Diagnostic{
+ Pos: lit.Pos(),
+ Message: getWarningMessage(),
+ })
+ }
+ }
+ }
+ }
+}
+
+// checkCallExpr analyzes function calls for SQL with SELECT * usage
+// Note: SQL builder checking with type verification is done by Registry.Check() in handleCallExpr.
+// This function only checks raw SQL strings in function arguments.
+func checkCallExpr(pass *analysis.Pass, call *ast.CallExpr, cfg *config.UnqueryvetSettings) {
+ // Check function call arguments for strings with SELECT *
+ for _, arg := range call.Args {
+ if lit, ok := arg.(*ast.BasicLit); ok && lit.Kind == token.STRING {
+ content := normalizeSQLQuery(lit.Value)
+ if isSelectStarQuery(content, cfg) {
+ pass.Report(analysis.Diagnostic{
+ Pos: lit.Pos(),
+ Message: getWarningMessage(),
+ })
+ }
+ }
+ }
+}
+
+// NormalizeSQLQuery normalizes SQL query for analysis with advanced escape sequence handling.
+// Exported for testing purposes.
+func NormalizeSQLQuery(query string) string {
+ return normalizeSQLQuery(query)
+}
+
+func normalizeSQLQuery(query string) string {
+ if len(query) < 2 {
+ return query
+ }
+
+ first, last := query[0], query[len(query)-1]
+
+ // 1. Handle different quote types with escape sequence processing
+ if first == '"' && last == '"' {
+ // For regular strings check for escape sequences
+ if !strings.Contains(query, "\\") {
+ query = trimQuotes(query)
+ } else if unquoted, err := strconv.Unquote(query); err == nil {
+ // Use standard Go unquoting for proper escape sequence handling
+ query = unquoted
+ } else {
+ // Fallback: simple quote removal
+ query = trimQuotes(query)
+ }
+ } else if first == '`' && last == '`' {
+ // Raw strings - simply remove backticks
+ query = trimQuotes(query)
+ }
+
+ // 2. Process comments line by line before normalization
+ lines := strings.Split(query, "\n")
+ var processedParts []string
+
+ for _, line := range lines {
+ // Remove comments from current line
+ if idx := strings.Index(line, "--"); idx != -1 {
+ line = line[:idx]
+ }
+
+ // Add non-empty lines
+ if trimmed := strings.TrimSpace(line); trimmed != "" {
+ processedParts = append(processedParts, trimmed)
+ }
+ }
+
+ // 3. Reassemble query and normalize
+ query = strings.Join(processedParts, " ")
+ query = strings.ToUpper(query)
+ query = strings.ReplaceAll(query, "\t", " ")
+ query = regexp.MustCompile(`\s+`).ReplaceAllString(query, " ")
+
+ return strings.TrimSpace(query)
+}
+
+// trimQuotes removes first and last character (quotes)
+func trimQuotes(query string) string {
+ return query[1 : len(query)-1]
+}
+
+// IsSelectStarQuery determines if query contains SELECT * with enhanced allowed patterns support.
+// Exported for testing purposes.
+func IsSelectStarQuery(query string, cfg *config.UnqueryvetSettings) bool {
+ return isSelectStarQuery(query, cfg)
+}
+
+func isSelectStarQuery(query string, cfg *config.UnqueryvetSettings) bool {
+ // Check allowed patterns first - if query matches an allowed pattern, ignore it
+ for _, pattern := range cfg.AllowedPatterns {
+ if matched, _ := regexp.MatchString(pattern, query); matched {
+ return false
+ }
+ }
+
+ upperQuery := strings.ToUpper(query)
+
+ // Check for SELECT * in query (case-insensitive)
+ if strings.Contains(upperQuery, "SELECT *") { //nolint:unqueryvet
+ // Ensure this is actually an SQL query by checking for SQL keywords
+ sqlKeywords := []string{"FROM", "WHERE", "JOIN", "GROUP", "ORDER", "HAVING", "UNION", "LIMIT"}
+ for _, keyword := range sqlKeywords {
+ if strings.Contains(upperQuery, keyword) {
+ return true
+ }
+ }
+
+ // Also check if it's just "SELECT *" without other keywords (still problematic)
+ trimmed := strings.TrimSpace(upperQuery)
+ if trimmed == "SELECT *" {
+ return true
+ }
+ }
+
+ // Check for SELECT alias.* patterns (e.g., SELECT t.*, SELECT u.*, o.*)
+ if cfg.CheckAliasedWildcard && isSelectAliasStarQuery(query) {
+ return true
+ }
+
+ // Check for SELECT * in subqueries (e.g., (SELECT * FROM ...))
+ if cfg.CheckSubqueries && isSelectStarInSubquery(query) {
+ return true
+ }
+
+ return false
+}
+
+// isSelectAliasStarQuery detects SELECT alias.* patterns like "SELECT t.*", "SELECT u.*, o.*"
+func isSelectAliasStarQuery(query string) bool {
+ return aliasedWildcardPattern.MatchString(query)
+}
+
+// isSelectStarInSubquery detects SELECT * in subqueries like "(SELECT * FROM ...)"
+func isSelectStarInSubquery(query string) bool {
+ return subquerySelectStarPattern.MatchString(query)
+}
+
+// getWarningMessage returns informative warning message
+func getWarningMessage() string {
+ return defaultWarningMessage
+}
+
+// getDetailedWarningMessage returns context-specific warning message
+func getDetailedWarningMessage(context string) string {
+ switch context {
+ case "sql_builder":
+ return "avoid SELECT * in SQL builder - explicitly specify columns to prevent unnecessary data transfer and schema change issues"
+ case "nested":
+ return "avoid SELECT * in subquery - can cause performance issues and unexpected results when schema changes"
+ case "empty_select":
+ return "SQL builder Select() without columns defaults to SELECT * - add specific columns with .Columns() method"
+ case "aliased_wildcard":
+ return "avoid SELECT alias.* - explicitly specify columns like alias.id, alias.name for better maintainability"
+ case "subquery":
+ return "avoid SELECT * in subquery - specify columns explicitly to prevent issues when schema changes"
+ case "concat":
+ return "avoid SELECT * in concatenated query - explicitly specify needed columns"
+ case "format_string":
+ return "avoid SELECT * in format string - explicitly specify needed columns"
+ default:
+ return defaultWarningMessage
+ }
+}
+
+// IsRuleEnabledExported checks if a rule is enabled in the configuration.
+// A rule is enabled if it exists in the Rules map and its severity is not "ignore".
+func IsRuleEnabledExported(rules config.RuleSeverity, ruleID string) bool {
+ if rules == nil {
+ return false
+ }
+ severity, exists := rules[ruleID]
+ if !exists {
+ return false
+ }
+ return severity != "ignore"
+}
+
+// isRuleEnabled is an internal helper for checking rule enablement.
+func isRuleEnabled(rules config.RuleSeverity, ruleID string) bool {
+ return IsRuleEnabledExported(rules, ruleID)
+}
diff --git a/vendor/github.com/MirrexOne/unqueryvet/internal/analyzer/concat.go b/vendor/github.com/MirrexOne/unqueryvet/internal/analyzer/concat.go
new file mode 100644
index 0000000000..c4635ec84c
--- /dev/null
+++ b/vendor/github.com/MirrexOne/unqueryvet/internal/analyzer/concat.go
@@ -0,0 +1,100 @@
+// Package analyzer provides the SQL static analysis implementation for detecting SELECT * usage.
+package analyzer
+
+import (
+ "go/ast"
+ "go/token"
+ "strings"
+
+ "golang.org/x/tools/go/analysis"
+
+ "github.com/MirrexOne/unqueryvet/pkg/config"
+)
+
+// StringConcatAnalyzer analyzes string concatenation expressions for SELECT * patterns.
+// It traverses binary expressions to combine string parts and check for SELECT * usage.
+type StringConcatAnalyzer struct {
+ pass *analysis.Pass
+ cfg *config.UnqueryvetSettings
+}
+
+// NewStringConcatAnalyzer creates a new StringConcatAnalyzer.
+func NewStringConcatAnalyzer(pass *analysis.Pass, cfg *config.UnqueryvetSettings) *StringConcatAnalyzer {
+ return &StringConcatAnalyzer{
+ pass: pass,
+ cfg: cfg,
+ }
+}
+
+// AnalyzeBinaryExpr analyzes a binary expression for string concatenation with SELECT *.
+// Returns true if SELECT * was detected in the concatenated string.
+func (sca *StringConcatAnalyzer) AnalyzeBinaryExpr(expr *ast.BinaryExpr) bool {
+ // Only analyze string concatenation (+ operator)
+ if expr.Op != token.ADD {
+ return false
+ }
+
+ // Extract all string parts from the concatenation chain
+ parts := sca.extractStringParts(expr)
+ if len(parts) == 0 {
+ return false
+ }
+
+ // Combine parts and check for SELECT *
+ combined := strings.Join(parts, "")
+ if combined == "" {
+ return false
+ }
+
+ // Normalize and check for SELECT *
+ normalized := normalizeSQLQuery("\"" + combined + "\"")
+ return isSelectStarQuery(normalized, sca.cfg)
+}
+
+// extractStringParts recursively extracts all string literal parts from a concatenation chain.
+// For expressions like: "SELECT * " + "FROM " + tableName + " WHERE id = 1"
+// It extracts: ["SELECT * ", "FROM ", " WHERE id = 1"]
+func (sca *StringConcatAnalyzer) extractStringParts(expr ast.Expr) []string {
+ var parts []string
+
+ switch e := expr.(type) {
+ case *ast.BasicLit:
+ // String literal
+ if e.Kind == token.STRING {
+ // Remove quotes from the string
+ value := strings.Trim(e.Value, "`\"")
+ parts = append(parts, value)
+ }
+ case *ast.BinaryExpr:
+ // Concatenation - recurse into both sides
+ if e.Op == token.ADD {
+ parts = append(parts, sca.extractStringParts(e.X)...)
+ parts = append(parts, sca.extractStringParts(e.Y)...)
+ }
+ case *ast.Ident:
+ // Variable reference - we can't know the value at compile time
+ // but we can check if it's a constant
+ if e.Obj != nil && e.Obj.Kind == ast.Con {
+ if valueSpec, ok := e.Obj.Decl.(*ast.ValueSpec); ok {
+ for _, value := range valueSpec.Values {
+ if lit, ok := value.(*ast.BasicLit); ok && lit.Kind == token.STRING {
+ strValue := strings.Trim(lit.Value, "`\"")
+ parts = append(parts, strValue)
+ }
+ }
+ }
+ }
+ case *ast.ParenExpr:
+ // Parenthesized expression - unwrap
+ parts = append(parts, sca.extractStringParts(e.X)...)
+ }
+
+ return parts
+}
+
+// CheckConcatenation is a convenience function to check a binary expression for SELECT *.
+// It creates an analyzer and performs the check in one call.
+func CheckConcatenation(pass *analysis.Pass, expr *ast.BinaryExpr, cfg *config.UnqueryvetSettings) bool {
+ analyzer := NewStringConcatAnalyzer(pass, cfg)
+ return analyzer.AnalyzeBinaryExpr(expr)
+}
diff --git a/vendor/github.com/MirrexOne/unqueryvet/internal/analyzer/filter.go b/vendor/github.com/MirrexOne/unqueryvet/internal/analyzer/filter.go
new file mode 100644
index 0000000000..5ad13b62fc
--- /dev/null
+++ b/vendor/github.com/MirrexOne/unqueryvet/internal/analyzer/filter.go
@@ -0,0 +1,176 @@
+// Package analyzer provides the SQL static analysis implementation for detecting SELECT * usage.
+package analyzer
+
+import (
+ "go/ast"
+ "path/filepath"
+ "regexp"
+ "strings"
+
+ "github.com/MirrexOne/unqueryvet/pkg/config"
+)
+
+// FilterContext holds precompiled patterns for filtering files, functions, and queries.
+// It provides efficient filtering by compiling regex patterns once during initialization.
+type FilterContext struct {
+ ignoredFuncPatterns []*regexp.Regexp
+ ignoredFilePatterns []string
+ allowedPatterns []*regexp.Regexp
+}
+
+// NewFilterContext creates a new FilterContext from settings.
+// It precompiles all regex patterns for efficient filtering.
+// Returns an error if any pattern is invalid.
+func NewFilterContext(cfg *config.UnqueryvetSettings) (*FilterContext, error) {
+ fc := &FilterContext{
+ ignoredFilePatterns: cfg.IgnoredFiles,
+ }
+
+ // Compile ignored function patterns
+ for _, pattern := range cfg.IgnoredFunctions {
+ re, err := regexp.Compile(pattern)
+ if err != nil {
+ return nil, err
+ }
+ fc.ignoredFuncPatterns = append(fc.ignoredFuncPatterns, re)
+ }
+
+ // Compile allowed query patterns
+ for _, pattern := range cfg.AllowedPatterns {
+ re, err := regexp.Compile(pattern)
+ if err != nil {
+ return nil, err
+ }
+ fc.allowedPatterns = append(fc.allowedPatterns, re)
+ }
+
+ return fc, nil
+}
+
+// IsIgnoredFunction checks if a function call should be ignored based on configured patterns.
+// It extracts the full function name (package.function or receiver.method) and matches against patterns.
+func (fc *FilterContext) IsIgnoredFunction(call *ast.CallExpr) bool {
+ if len(fc.ignoredFuncPatterns) == 0 {
+ return false
+ }
+
+ funcName := extractFunctionName(call)
+ if funcName == "" {
+ return false
+ }
+
+ for _, pattern := range fc.ignoredFuncPatterns {
+ if pattern.MatchString(funcName) {
+ return true
+ }
+ }
+
+ return false
+}
+
+// IsIgnoredFile checks if a file path matches any of the ignored file patterns.
+// Supports glob patterns like "*_test.go", "testdata/**", "mock_*.go".
+func (fc *FilterContext) IsIgnoredFile(filePath string) bool {
+ if len(fc.ignoredFilePatterns) == 0 {
+ return false
+ }
+
+ // Normalize path separators for cross-platform support
+ normalizedPath := filepath.ToSlash(filePath)
+ baseName := filepath.Base(filePath)
+
+ for _, pattern := range fc.ignoredFilePatterns {
+ // Try matching against full path
+ if matched, _ := filepath.Match(pattern, normalizedPath); matched {
+ return true
+ }
+ // Try matching against base name only
+ if matched, _ := filepath.Match(pattern, baseName); matched {
+ return true
+ }
+ // Handle ** patterns (recursive matching)
+ if strings.Contains(pattern, "**") {
+ if matchDoubleStarPattern(pattern, normalizedPath) {
+ return true
+ }
+ }
+ }
+
+ return false
+}
+
+// IsAllowedPattern checks if a query matches any of the allowed patterns.
+// Returns true if the query should be allowed (not reported as a violation).
+func (fc *FilterContext) IsAllowedPattern(query string) bool {
+ for _, pattern := range fc.allowedPatterns {
+ if pattern.MatchString(query) {
+ return true
+ }
+ }
+ return false
+}
+
+// extractFunctionName extracts the full function name from a call expression.
+// Returns formats like "pkg.Function", "receiver.Method", or just "Function".
+func extractFunctionName(call *ast.CallExpr) string {
+ switch fun := call.Fun.(type) {
+ case *ast.SelectorExpr:
+ // Method call: obj.Method() or pkg.Function()
+ switch x := fun.X.(type) {
+ case *ast.Ident:
+ // pkg.Function() or receiver.Method()
+ return x.Name + "." + fun.Sel.Name
+ case *ast.SelectorExpr:
+ // Nested: pkg.subpkg.Function()
+ if ident, ok := x.X.(*ast.Ident); ok {
+ return ident.Name + "." + x.Sel.Name + "." + fun.Sel.Name
+ }
+ case *ast.CallExpr:
+ // Chained call: obj.Method1().Method2()
+ return fun.Sel.Name
+ }
+ return fun.Sel.Name
+ case *ast.Ident:
+ // Direct function call: Function()
+ return fun.Name
+ }
+ return ""
+}
+
+// matchDoubleStarPattern handles glob patterns with ** (recursive matching).
+// Example: "testdata/**" matches "testdata/foo/bar.go"
+func matchDoubleStarPattern(pattern, path string) bool {
+ // Split pattern by **
+ parts := strings.Split(pattern, "**")
+ if len(parts) != 2 {
+ return false
+ }
+
+ prefix := strings.TrimSuffix(parts[0], "/")
+ suffix := strings.TrimPrefix(parts[1], "/")
+
+ // Check if path starts with prefix
+ if prefix != "" && !strings.HasPrefix(path, prefix) {
+ return false
+ }
+
+ // Check if path ends with suffix (if suffix exists)
+ if suffix != "" {
+ // Get the part after prefix
+ remainingPath := strings.TrimPrefix(path, prefix)
+ remainingPath = strings.TrimPrefix(remainingPath, "/")
+
+ // Match suffix at the end or as a pattern
+ if matched, _ := filepath.Match(suffix, filepath.Base(path)); matched {
+ return true
+ }
+ if strings.HasSuffix(remainingPath, suffix) {
+ return true
+ }
+ } else {
+ // No suffix, just check prefix
+ return strings.HasPrefix(path, prefix)
+ }
+
+ return false
+}
diff --git a/vendor/github.com/MirrexOne/unqueryvet/internal/analyzer/fixes.go b/vendor/github.com/MirrexOne/unqueryvet/internal/analyzer/fixes.go
new file mode 100644
index 0000000000..f059f063ef
--- /dev/null
+++ b/vendor/github.com/MirrexOne/unqueryvet/internal/analyzer/fixes.go
@@ -0,0 +1,126 @@
+// Package analyzer provides the SQL static analysis implementation for detecting SELECT * usage.
+package analyzer
+
+import (
+ "go/token"
+ "regexp"
+ "strings"
+
+ "golang.org/x/tools/go/analysis"
+)
+
+// SuggestedFixGenerator generates auto-fix suggestions for SELECT * violations.
+type SuggestedFixGenerator struct {
+ fset *token.FileSet
+}
+
+// NewSuggestedFixGenerator creates a new SuggestedFixGenerator.
+func NewSuggestedFixGenerator(fset *token.FileSet) *SuggestedFixGenerator {
+ return &SuggestedFixGenerator{
+ fset: fset,
+ }
+}
+
+// selectStarPattern matches SELECT * patterns for replacement
+var selectStarFixPattern = regexp.MustCompile(`(?i)(SELECT\s+)\*(\s+FROM)`)
+
+// aliasedStarPattern matches SELECT alias.* patterns for replacement
+var aliasedStarFixPattern = regexp.MustCompile(`(?i)(SELECT\s+)([A-Za-z_][A-Za-z0-9_]*)\s*\.\s*\*`)
+
+// GenerateFix creates a SuggestedFix for a SELECT * violation.
+func (sfg *SuggestedFixGenerator) GenerateFix(
+ pos token.Pos,
+ end token.Pos,
+ originalText string,
+ violationType string,
+) *analysis.SuggestedFix {
+ var newText string
+ var message string
+
+ switch violationType {
+ case "select_star":
+ // Replace SELECT * with placeholder columns
+ newText = selectStarFixPattern.ReplaceAllString(originalText, "${1}id, /* TODO: specify columns */ ${2}")
+ message = "Replace SELECT * with explicit columns"
+
+ case "aliased_wildcard":
+ // Replace SELECT t.* with placeholder
+ newText = aliasedStarFixPattern.ReplaceAllStringFunc(originalText, func(match string) string {
+ // Extract the alias
+ parts := aliasedStarFixPattern.FindStringSubmatch(match)
+ if len(parts) >= 3 {
+ alias := parts[2]
+ return parts[1] + alias + ".id, " + alias + "./* TODO: specify columns */"
+ }
+ return match
+ })
+ message = "Replace SELECT alias.* with explicit columns"
+
+ case "sql_builder_star":
+ // For SQL builder Select("*") -> Select("id", /* TODO */)
+ newText = strings.Replace(originalText, `"*"`, `"id", /* TODO: specify columns */`, 1)
+ message = "Replace \"*\" with explicit column names"
+
+ case "empty_select":
+ // For empty Select() -> Select("id", /* TODO */)
+ newText = strings.Replace(originalText, "Select()", `Select("id", /* TODO: specify columns */)`, 1)
+ message = "Add column names to Select()"
+
+ default:
+ // Generic replacement
+ newText = selectStarFixPattern.ReplaceAllString(originalText, "${1}id, /* TODO: specify columns */ ${2}")
+ message = "Replace SELECT * with explicit columns"
+ }
+
+ // If no change was made, don't suggest a fix
+ if newText == originalText {
+ return nil
+ }
+
+ return &analysis.SuggestedFix{
+ Message: message,
+ TextEdits: []analysis.TextEdit{
+ {
+ Pos: pos,
+ End: end,
+ NewText: []byte(newText),
+ },
+ },
+ }
+}
+
+// GenerateColumnPlaceholder returns a placeholder string for explicit columns.
+func (sfg *SuggestedFixGenerator) GenerateColumnPlaceholder() string {
+ return "id, /* TODO: specify columns */"
+}
+
+// GenerateAliasedColumnPlaceholder returns a placeholder with table alias.
+func (sfg *SuggestedFixGenerator) GenerateAliasedColumnPlaceholder(alias string) string {
+ return alias + ".id, " + alias + "./* TODO: specify columns */"
+}
+
+// CreateDiagnosticWithFix creates a Diagnostic with an optional SuggestedFix.
+func CreateDiagnosticWithFix(
+ pos token.Pos,
+ end token.Pos,
+ message string,
+ originalText string,
+ violationType string,
+ fset *token.FileSet,
+) analysis.Diagnostic {
+ diagnostic := analysis.Diagnostic{
+ Pos: pos,
+ End: end,
+ Message: message,
+ }
+
+ // Generate fix if we have enough information
+ if originalText != "" && fset != nil {
+ generator := NewSuggestedFixGenerator(fset)
+ if fix := generator.GenerateFix(pos, end, originalText, violationType); fix != nil {
+ diagnostic.SuggestedFixes = []analysis.SuggestedFix{*fix}
+ }
+ }
+
+ return diagnostic
+}
diff --git a/vendor/github.com/MirrexOne/unqueryvet/internal/analyzer/format.go b/vendor/github.com/MirrexOne/unqueryvet/internal/analyzer/format.go
new file mode 100644
index 0000000000..c96636706d
--- /dev/null
+++ b/vendor/github.com/MirrexOne/unqueryvet/internal/analyzer/format.go
@@ -0,0 +1,217 @@
+// Package analyzer provides the SQL static analysis implementation for detecting SELECT * usage.
+package analyzer
+
+import (
+ "go/ast"
+ "go/token"
+ "strings"
+
+ "golang.org/x/tools/go/analysis"
+
+ "github.com/MirrexOne/unqueryvet/pkg/config"
+)
+
+// formatFunctions maps package.function names to the index of the format string argument.
+// Index -1 means the format string is the last argument (for variadic functions).
+var formatFunctions = map[string]int{
+ // fmt package
+ "fmt.Sprintf": 0,
+ "fmt.Printf": 0,
+ "fmt.Fprintf": 1, // first arg is io.Writer
+ "fmt.Errorf": 0,
+ "fmt.Fscanf": 1,
+ "fmt.Sscanf": 1,
+ "Sprintf": 0, // direct call after import
+ "Printf": 0,
+ "Errorf": 0,
+
+ // log package
+ "log.Printf": 0,
+ "log.Fatalf": 0,
+ "log.Panicf": 0,
+ "log.Logf": 1, // first arg is log level
+ "Logger.Printf": 0,
+ "Logger.Fatalf": 0,
+ "Logger.Panicf": 0,
+
+ // testing package
+ "testing.T.Logf": 0,
+ "testing.T.Errorf": 0,
+ "testing.T.Fatalf": 0,
+ "testing.T.Skipf": 0,
+ "testing.B.Logf": 0,
+ "testing.B.Errorf": 0,
+ "testing.B.Fatalf": 0,
+ "T.Logf": 0,
+ "T.Errorf": 0,
+ "T.Fatalf": 0,
+ "B.Logf": 0,
+ "B.Errorf": 0,
+ "B.Fatalf": 0,
+
+ // errors package
+ "errors.Errorf": 0,
+ "errors.Wrapf": 1, // first arg is error
+
+ // pkg/errors
+ "errors.WithMessagef": 1,
+
+ // logrus
+ "logrus.Infof": 0,
+ "logrus.Warnf": 0,
+ "logrus.Errorf": 0,
+ "logrus.Debugf": 0,
+ "logrus.Fatalf": 0,
+ "logrus.Panicf": 0,
+ "logrus.Tracef": 0,
+ "logrus.Printf": 0,
+ "Entry.Infof": 0,
+ "Entry.Warnf": 0,
+ "Entry.Errorf": 0,
+ "Entry.Debugf": 0,
+
+ // zap
+ "zap.S.Infof": 0,
+ "zap.S.Warnf": 0,
+ "zap.S.Errorf": 0,
+ "zap.S.Debugf": 0,
+ "zap.S.Fatalf": 0,
+ "zap.S.Panicf": 0,
+ "SugaredLogger.Infof": 0,
+ "SugaredLogger.Warnf": 0,
+ "SugaredLogger.Errorf": 0,
+ "SugaredLogger.Debugf": 0,
+}
+
+// FormatStringAnalyzer analyzes format functions like fmt.Sprintf for SELECT * patterns.
+type FormatStringAnalyzer struct {
+ pass *analysis.Pass
+ cfg *config.UnqueryvetSettings
+}
+
+// NewFormatStringAnalyzer creates a new FormatStringAnalyzer.
+func NewFormatStringAnalyzer(pass *analysis.Pass, cfg *config.UnqueryvetSettings) *FormatStringAnalyzer {
+ return &FormatStringAnalyzer{
+ pass: pass,
+ cfg: cfg,
+ }
+}
+
+// AnalyzeFormatCall analyzes a function call for format string patterns with SELECT *.
+// Returns true if SELECT * was detected in the format string.
+func (fsa *FormatStringAnalyzer) AnalyzeFormatCall(call *ast.CallExpr) bool {
+ // Get the function name
+ funcName := fsa.getFunctionName(call)
+ if funcName == "" {
+ return false
+ }
+
+ // Check if this is a known format function
+ argIndex, ok := formatFunctions[funcName]
+ if !ok {
+ return false
+ }
+
+ // Extract the format string
+ formatStr, ok := fsa.extractFormatString(call, argIndex)
+ if !ok {
+ return false
+ }
+
+ // Check if the format string contains SELECT *
+ normalized := normalizeSQLQuery("\"" + formatStr + "\"")
+ return isSelectStarQuery(normalized, fsa.cfg)
+}
+
+// getFunctionName extracts the function name from a call expression.
+// Returns formats like "fmt.Sprintf", "log.Printf", or just "Sprintf".
+func (fsa *FormatStringAnalyzer) getFunctionName(call *ast.CallExpr) string {
+ switch fun := call.Fun.(type) {
+ case *ast.SelectorExpr:
+ // Method call: pkg.Func() or obj.Method()
+ switch x := fun.X.(type) {
+ case *ast.Ident:
+ // pkg.Func() like fmt.Sprintf
+ return x.Name + "." + fun.Sel.Name
+ case *ast.SelectorExpr:
+ // Nested: pkg.subpkg.Func() or receiver.Type.Method()
+ if ident, ok := x.X.(*ast.Ident); ok {
+ return ident.Name + "." + x.Sel.Name + "." + fun.Sel.Name
+ }
+ // obj.Field.Method()
+ return x.Sel.Name + "." + fun.Sel.Name
+ case *ast.CallExpr:
+ // Chained: something().Method()
+ return fun.Sel.Name
+ }
+ return fun.Sel.Name
+ case *ast.Ident:
+ // Direct function call: Sprintf() (after import . "fmt")
+ return fun.Name
+ }
+ return ""
+}
+
+// extractFormatString extracts the format string from a function call.
+// argIndex specifies which argument contains the format string.
+func (fsa *FormatStringAnalyzer) extractFormatString(call *ast.CallExpr, argIndex int) (string, bool) {
+ if argIndex < 0 || argIndex >= len(call.Args) {
+ return "", false
+ }
+
+ arg := call.Args[argIndex]
+
+ // Direct string literal
+ if lit, ok := arg.(*ast.BasicLit); ok && lit.Kind == token.STRING {
+ return strings.Trim(lit.Value, "`\""), true
+ }
+
+ // Identifier (constant or variable)
+ if ident, ok := arg.(*ast.Ident); ok {
+ if ident.Obj != nil && ident.Obj.Kind == ast.Con {
+ // It's a constant - try to get its value
+ if valueSpec, ok := ident.Obj.Decl.(*ast.ValueSpec); ok {
+ for _, value := range valueSpec.Values {
+ if lit, ok := value.(*ast.BasicLit); ok && lit.Kind == token.STRING {
+ return strings.Trim(lit.Value, "`\""), true
+ }
+ }
+ }
+ }
+ }
+
+ return "", false
+}
+
+// CheckFormatFunction is a convenience function to check a call expression for SELECT *.
+// It creates an analyzer and performs the check in one call.
+func CheckFormatFunction(pass *analysis.Pass, call *ast.CallExpr, cfg *config.UnqueryvetSettings) bool {
+ analyzer := NewFormatStringAnalyzer(pass, cfg)
+ return analyzer.AnalyzeFormatCall(call)
+}
+
+// IsFormatFunction checks if a call expression is a known format function.
+func IsFormatFunction(call *ast.CallExpr) bool {
+ var funcName string
+
+ switch fun := call.Fun.(type) {
+ case *ast.SelectorExpr:
+ switch x := fun.X.(type) {
+ case *ast.Ident:
+ funcName = x.Name + "." + fun.Sel.Name
+ case *ast.SelectorExpr:
+ if ident, ok := x.X.(*ast.Ident); ok {
+ funcName = ident.Name + "." + x.Sel.Name + "." + fun.Sel.Name
+ } else {
+ funcName = x.Sel.Name + "." + fun.Sel.Name
+ }
+ default:
+ funcName = fun.Sel.Name
+ }
+ case *ast.Ident:
+ funcName = fun.Name
+ }
+
+ _, ok := formatFunctions[funcName]
+ return ok
+}
diff --git a/vendor/github.com/MirrexOne/unqueryvet/internal/analyzer/n1detector.go b/vendor/github.com/MirrexOne/unqueryvet/internal/analyzer/n1detector.go
new file mode 100644
index 0000000000..cf03311294
--- /dev/null
+++ b/vendor/github.com/MirrexOne/unqueryvet/internal/analyzer/n1detector.go
@@ -0,0 +1,546 @@
+package analyzer
+
+import (
+ "go/ast"
+ "go/token"
+ "strings"
+
+ "golang.org/x/tools/go/analysis"
+)
+
+// N1Detector detects potential N+1 query problems.
+// An N+1 query problem occurs when a SQL query is executed inside a loop,
+// causing one query per iteration instead of a single batch query.
+type N1Detector struct {
+ // loopDepth tracks how deeply nested we are in loops
+ loopDepth int
+ // queryMethods are method names that typically execute SQL queries
+ queryMethods map[string]bool
+ // ormMethods are ORM-specific methods that indicate queries
+ ormMethods map[string]bool
+ // transactionMethods are methods that indicate transaction usage
+ transactionMethods map[string]bool
+ // functionCallsInLoop tracks function calls made inside loops for indirect N+1 detection
+ functionCallsInLoop map[string]bool
+ // knownQueryFunctions are user-defined functions known to execute queries
+ knownQueryFunctions map[string]bool
+}
+
+// NewN1Detector creates a new N+1 query detector.
+func NewN1Detector() *N1Detector {
+ return &N1Detector{
+ queryMethods: map[string]bool{
+ // Standard database/sql
+ "Query": true,
+ "QueryRow": true,
+ "Exec": true,
+ "ExecContext": true,
+ "QueryContext": true,
+ "QueryRowContext": true,
+ // SQLx
+ "QueryRowx": true,
+ "Queryx": true,
+ "SelectContext": true,
+ "GetContext": true,
+ "NamedQuery": true,
+ "NamedQueryContext": true,
+ "NamedExec": true,
+ "NamedExecContext": true,
+ // General
+ "Select": true,
+ "Get": true,
+ "Find": true,
+ "First": true,
+ "Where": true,
+ "Raw": true,
+ },
+ ormMethods: map[string]bool{
+ // GORM
+ "Preload": true,
+ "Association": true,
+ "Related": true,
+ "Model": true,
+ "Table": true,
+ "Joins": true,
+ "InnerJoins": true,
+ "Pluck": true,
+ "Count": true,
+ "Take": true,
+ "Last": true,
+ "Scan": true,
+ "Row": true,
+ "Rows": true,
+ // Bun
+ "NewSelect": true,
+ "NewInsert": true,
+ "NewUpdate": true,
+ "NewDelete": true,
+ "Column": true,
+ "ColumnExpr": true,
+ "Relation": true,
+ // Ent
+ "Only": true,
+ "OnlyX": true,
+ "AllX": true,
+ "FirstX": true,
+ // SQLBoiler
+ "One": true,
+ "OneP": true,
+ "AllP": true,
+ "Exists": true,
+ "ExistsP": true,
+ // PGX
+ "SendBatch": true,
+ },
+ transactionMethods: map[string]bool{
+ "Begin": true,
+ "BeginTx": true,
+ "BeginTxx": true,
+ "Transaction": true,
+ "WithContext": true,
+ "RunInTransaction": true,
+ "Tx": true,
+ "NewTx": true,
+ },
+ functionCallsInLoop: make(map[string]bool),
+ knownQueryFunctions: make(map[string]bool),
+ }
+}
+
+// N1Severity represents the severity level of an N+1 violation.
+type N1Severity string
+
+const (
+ N1SeverityCritical N1Severity = "critical" // Direct query in loop
+ N1SeverityHigh N1Severity = "high" // ORM method in loop
+ N1SeverityMedium N1Severity = "medium" // Indirect query via function call
+ N1SeverityLow N1Severity = "low" // Potential issue, needs review
+)
+
+// N1Violation represents a detected N+1 query problem.
+type N1Violation struct {
+ Pos token.Pos
+ End token.Pos
+ Message string
+ LoopType string // "for", "range", or "while-like"
+ QueryType string // The method name that was called
+ Severity N1Severity // Severity level
+ Suggestion string // Suggested fix
+ IsIndirect bool // True if detected via function call
+ FunctionName string // Name of the function if indirect
+}
+
+// CheckN1Queries analyzes the file for N+1 query patterns.
+func (d *N1Detector) CheckN1Queries(pass *analysis.Pass, file *ast.File) []N1Violation {
+ var violations []N1Violation
+
+ ast.Inspect(file, func(n ast.Node) bool {
+ switch node := n.(type) {
+ case *ast.ForStmt:
+ // Entering a for loop
+ d.loopDepth++
+ defer func() { d.loopDepth-- }()
+
+ // Check the body for queries
+ if node.Body != nil {
+ violations = append(violations, d.checkBlockForQueries(pass, node.Body, "for")...)
+ }
+ return true
+
+ case *ast.RangeStmt:
+ // Entering a range loop
+ d.loopDepth++
+ defer func() { d.loopDepth-- }()
+
+ // Check the body for queries
+ if node.Body != nil {
+ violations = append(violations, d.checkBlockForQueries(pass, node.Body, "range")...)
+ }
+ return true
+ }
+ return true
+ })
+
+ return violations
+}
+
+// checkBlockForQueries checks a block statement for SQL query calls.
+func (d *N1Detector) checkBlockForQueries(pass *analysis.Pass, block *ast.BlockStmt, loopType string) []N1Violation {
+ var violations []N1Violation
+
+ ast.Inspect(block, func(n ast.Node) bool {
+ // Skip nested loops - they'll be handled separately
+ switch n.(type) {
+ case *ast.ForStmt, *ast.RangeStmt:
+ return false
+ }
+
+ call, ok := n.(*ast.CallExpr)
+ if !ok {
+ return true
+ }
+
+ methodName := d.getMethodName(call)
+ if methodName == "" {
+ return true
+ }
+
+ // Check 1: Direct query method call
+ if d.queryMethods[methodName] {
+ if v := d.checkDirectQueryCall(call, methodName, loopType); v != nil {
+ violations = append(violations, *v)
+ }
+ return true
+ }
+
+ // Check 2: ORM-specific method call
+ if d.ormMethods[methodName] {
+ if v := d.checkORMMethodCall(call, methodName, loopType); v != nil {
+ violations = append(violations, *v)
+ }
+ return true
+ }
+
+ // Check 3: Transaction method in loop (potential issue)
+ if d.transactionMethods[methodName] {
+ violations = append(violations, N1Violation{
+ Pos: call.Pos(),
+ End: call.End(),
+ Message: "transaction started inside loop - consider batching operations",
+ LoopType: loopType,
+ QueryType: methodName,
+ Severity: N1SeverityMedium,
+ Suggestion: "Move transaction outside the loop and batch operations, or use a single transaction for all iterations",
+ })
+ return true
+ }
+
+ // Check 4: Indirect query via function call
+ if v := d.checkIndirectQueryCall(call, methodName, loopType); v != nil {
+ violations = append(violations, *v)
+ }
+
+ return true
+ })
+
+ return violations
+}
+
+// checkDirectQueryCall checks for direct database query calls.
+func (d *N1Detector) checkDirectQueryCall(call *ast.CallExpr, methodName, loopType string) *N1Violation {
+ // Check if any argument contains SELECT or other SQL keywords
+ hasSQLKeyword := false
+ for _, arg := range call.Args {
+ if lit, ok := arg.(*ast.BasicLit); ok {
+ if lit.Kind == token.STRING {
+ value := strings.ToUpper(lit.Value)
+ if strings.Contains(value, "SELECT") || strings.Contains(value, "INSERT") ||
+ strings.Contains(value, "UPDATE") || strings.Contains(value, "DELETE") {
+ hasSQLKeyword = true
+ break
+ }
+ }
+ }
+ }
+
+ // Also check if it's a method on a database variable
+ if !hasSQLKeyword {
+ hasSQLKeyword = d.mightBeQueryCall(call)
+ }
+
+ if hasSQLKeyword {
+ return &N1Violation{
+ Pos: call.Pos(),
+ End: call.End(),
+ Message: n1Message(methodName, loopType),
+ LoopType: loopType,
+ QueryType: methodName,
+ Severity: N1SeverityCritical,
+ Suggestion: n1Suggestion(loopType),
+ }
+ }
+
+ return nil
+}
+
+// checkORMMethodCall checks for ORM-specific method calls that might cause N+1.
+func (d *N1Detector) checkORMMethodCall(call *ast.CallExpr, methodName, loopType string) *N1Violation {
+ // ORM methods like Preload, Association, Related are often N+1 sources
+ suspiciousMethods := map[string]bool{
+ "Preload": true,
+ "Association": true,
+ "Related": true,
+ "Relation": true,
+ }
+
+ if suspiciousMethods[methodName] {
+ return &N1Violation{
+ Pos: call.Pos(),
+ End: call.End(),
+ Message: "ORM relation loading inside loop: " + methodName + "() - this causes N+1 queries",
+ LoopType: loopType,
+ QueryType: methodName,
+ Severity: N1SeverityHigh,
+ Suggestion: "Use eager loading (Preload) before the loop, or fetch all related data in a single query with JOIN",
+ }
+ }
+
+ // Check for query execution methods
+ executionMethods := map[string]bool{
+ "Find": true, "First": true, "Take": true, "Last": true,
+ "One": true, "All": true, "Only": true, "Scan": true,
+ }
+
+ if executionMethods[methodName] && d.mightBeQueryCall(call) {
+ return &N1Violation{
+ Pos: call.Pos(),
+ End: call.End(),
+ Message: "ORM query execution inside loop: " + methodName + "() - potential N+1 problem",
+ LoopType: loopType,
+ QueryType: methodName,
+ Severity: N1SeverityHigh,
+ Suggestion: "Collect IDs first, then use WHERE IN clause or batch loading",
+ }
+ }
+
+ return nil
+}
+
+// checkIndirectQueryCall checks for function calls that might execute queries.
+func (d *N1Detector) checkIndirectQueryCall(call *ast.CallExpr, methodName, loopType string) *N1Violation {
+ // Check for suspicious function names that might contain queries
+ lowerName := strings.ToLower(methodName)
+ suspiciousPatterns := []string{
+ "get", "fetch", "find", "load", "query", "select",
+ "retrieve", "lookup", "read", "search",
+ }
+
+ for _, pattern := range suspiciousPatterns {
+ if strings.Contains(lowerName, pattern) {
+ // Check if it's called on a repository/store/dao object
+ if d.isRepositoryCall(call) {
+ return &N1Violation{
+ Pos: call.Pos(),
+ End: call.End(),
+ Message: "potential N+1: function " + methodName + "() called inside loop may execute database query",
+ LoopType: loopType,
+ QueryType: methodName,
+ Severity: N1SeverityMedium,
+ Suggestion: "Review this function - if it executes a query, consider batch loading or caching",
+ IsIndirect: true,
+ FunctionName: methodName,
+ }
+ }
+ }
+ }
+
+ return nil
+}
+
+// isRepositoryCall checks if the call is on a repository-like object.
+func (d *N1Detector) isRepositoryCall(call *ast.CallExpr) bool {
+ sel, ok := call.Fun.(*ast.SelectorExpr)
+ if !ok {
+ return false
+ }
+
+ if ident, ok := sel.X.(*ast.Ident); ok {
+ name := strings.ToLower(ident.Name)
+ repositoryPatterns := []string{
+ "repo", "repository", "store", "dao", "service",
+ "handler", "manager", "provider", "client",
+ }
+ for _, pattern := range repositoryPatterns {
+ if strings.Contains(name, pattern) {
+ return true
+ }
+ }
+ }
+
+ return false
+}
+
+// n1Suggestion generates a suggestion based on loop type.
+func n1Suggestion(loopType string) string {
+ switch loopType {
+ case "range":
+ return "Collect all IDs before the loop, then use a single query with IN clause:\n" +
+ " ids := make([]int, 0, len(items))\n" +
+ " for _, item := range items { ids = append(ids, item.ID) }\n" +
+ " db.Query(\"SELECT * FROM table WHERE id IN (?)\", ids)"
+ case "for":
+ return "Consider using batch query with IN clause or JOIN instead of querying in each iteration"
+ default:
+ return "Refactor to execute a single batch query instead of multiple queries in loop"
+ }
+}
+
+// getMethodName extracts the method name from a call expression.
+func (d *N1Detector) getMethodName(call *ast.CallExpr) string {
+ switch fun := call.Fun.(type) {
+ case *ast.SelectorExpr:
+ return fun.Sel.Name
+ case *ast.Ident:
+ return fun.Name
+ }
+ return ""
+}
+
+// mightBeQueryCall checks if a call might be a database query.
+func (d *N1Detector) mightBeQueryCall(call *ast.CallExpr) bool {
+ sel, ok := call.Fun.(*ast.SelectorExpr)
+ if !ok {
+ return false
+ }
+
+ // Check for common database variable names
+ if ident, ok := sel.X.(*ast.Ident); ok {
+ name := strings.ToLower(ident.Name)
+ return name == "db" || name == "conn" || name == "tx" ||
+ strings.Contains(name, "database") ||
+ strings.Contains(name, "repo") ||
+ strings.Contains(name, "store")
+ }
+
+ return false
+}
+
+// n1Message generates a helpful message for N+1 detection.
+func n1Message(methodName, loopType string) string {
+ suggestion := ""
+ switch loopType {
+ case "range":
+ suggestion = "Consider using a batch query with IN clause or JOIN"
+ case "for":
+ suggestion = "Consider collecting IDs first, then executing a single query with IN clause"
+ }
+
+ return "potential N+1 query: " + methodName + "() called inside loop - " + suggestion
+}
+
+// AnalyzeN1 is a convenience function to run N+1 detection on a file.
+func AnalyzeN1(pass *analysis.Pass, file *ast.File) {
+ detector := NewN1Detector()
+ violations := detector.CheckN1Queries(pass, file)
+
+ for _, v := range violations {
+ message := v.Message
+ if v.Suggestion != "" {
+ message += "\n Suggestion: " + v.Suggestion
+ }
+ if v.Severity != "" {
+ message = "[" + string(v.Severity) + "] " + message
+ }
+
+ pass.Report(analysis.Diagnostic{
+ Pos: v.Pos,
+ End: v.End,
+ Message: message,
+ })
+ }
+}
+
+// GetN1Violations returns all N+1 violations for external use.
+func GetN1Violations(pass *analysis.Pass, file *ast.File) []N1Violation {
+ detector := NewN1Detector()
+ return detector.CheckN1Queries(pass, file)
+}
+
+// CheckN1QueriesNoPass is a method to check for N+1 queries without analysis.Pass.
+// This is useful for testing.
+func (d *N1Detector) CheckN1QueriesNoPass(file *ast.File) []N1Violation {
+ return DetectN1InAST(nil, file)
+}
+
+// DetectN1InAST detects N+1 query problems in an AST file without analysis.Pass.
+// This is designed for use in LSP server where we don't have a full analysis pass.
+func DetectN1InAST(fset *token.FileSet, file *ast.File) []N1Violation {
+ detector := NewN1Detector()
+ var violations []N1Violation
+
+ ast.Inspect(file, func(n ast.Node) bool {
+ switch node := n.(type) {
+ case *ast.ForStmt:
+ detector.loopDepth++
+ defer func() { detector.loopDepth-- }()
+
+ if node.Body != nil {
+ violations = append(violations, detector.checkBlockForQueriesNoPass(node.Body, "for")...)
+ }
+ return true
+
+ case *ast.RangeStmt:
+ detector.loopDepth++
+ defer func() { detector.loopDepth-- }()
+
+ if node.Body != nil {
+ violations = append(violations, detector.checkBlockForQueriesNoPass(node.Body, "range")...)
+ }
+ return true
+ }
+ return true
+ })
+
+ return violations
+}
+
+// checkBlockForQueriesNoPass checks a block statement for SQL query calls without analysis.Pass.
+func (d *N1Detector) checkBlockForQueriesNoPass(block *ast.BlockStmt, loopType string) []N1Violation {
+ var violations []N1Violation
+
+ ast.Inspect(block, func(n ast.Node) bool {
+ switch n.(type) {
+ case *ast.ForStmt, *ast.RangeStmt:
+ return false
+ }
+
+ call, ok := n.(*ast.CallExpr)
+ if !ok {
+ return true
+ }
+
+ methodName := d.getMethodName(call)
+ if methodName == "" {
+ return true
+ }
+
+ // Check 1: Direct query method call
+ if d.queryMethods[methodName] {
+ if v := d.checkDirectQueryCall(call, methodName, loopType); v != nil {
+ violations = append(violations, *v)
+ }
+ return true
+ }
+
+ // Check 2: ORM-specific method call
+ if d.ormMethods[methodName] {
+ if v := d.checkORMMethodCall(call, methodName, loopType); v != nil {
+ violations = append(violations, *v)
+ }
+ return true
+ }
+
+ // Check 3: Transaction method in loop
+ if d.transactionMethods[methodName] {
+ violations = append(violations, N1Violation{
+ Pos: call.Pos(),
+ End: call.End(),
+ Message: "transaction started inside loop - consider batching operations",
+ LoopType: loopType,
+ QueryType: methodName,
+ Severity: N1SeverityMedium,
+ Suggestion: "Move transaction outside the loop and batch operations, or use a single transaction for all iterations",
+ })
+ return true
+ }
+
+ // Check 4: Indirect query via function call
+ if v := d.checkIndirectQueryCall(call, methodName, loopType); v != nil {
+ violations = append(violations, *v)
+ }
+
+ return true
+ })
+
+ return violations
+}
diff --git a/vendor/github.com/MirrexOne/unqueryvet/internal/analyzer/sqlbuilders/bun.go b/vendor/github.com/MirrexOne/unqueryvet/internal/analyzer/sqlbuilders/bun.go
new file mode 100644
index 0000000000..a25f559a14
--- /dev/null
+++ b/vendor/github.com/MirrexOne/unqueryvet/internal/analyzer/sqlbuilders/bun.go
@@ -0,0 +1,146 @@
+// Package sqlbuilders provides SQL builder library-specific checkers for SELECT * detection.
+package sqlbuilders
+
+import (
+ "go/ast"
+ "go/token"
+ "go/types"
+ "strings"
+)
+
+const bunPkgPath = "github.com/uptrace/bun"
+
+// BunChecker checks github.com/uptrace/bun for SELECT * patterns.
+type BunChecker struct{}
+
+// NewBunChecker creates a new BunChecker.
+func NewBunChecker() *BunChecker {
+ return &BunChecker{}
+}
+
+// Name returns the name of this checker.
+func (c *BunChecker) Name() string {
+ return "bun"
+}
+
+// IsApplicable checks if the call is from bun using type information.
+func (c *BunChecker) IsApplicable(info *types.Info, call *ast.CallExpr) bool {
+ sel, ok := call.Fun.(*ast.SelectorExpr)
+ if !ok {
+ return false
+ }
+
+ // Check if the receiver type is from bun package
+ return IsTypeFromPackage(info, sel.X, bunPkgPath)
+}
+
+// CheckSelectStar checks for SELECT * in bun calls.
+func (c *BunChecker) CheckSelectStar(call *ast.CallExpr) *SelectStarViolation {
+ sel, ok := call.Fun.(*ast.SelectorExpr)
+ if !ok {
+ return nil
+ }
+
+ methodName := sel.Sel.Name
+
+ // Check ColumnExpr("*")
+ if methodName == "ColumnExpr" || methodName == "Column" {
+ for _, arg := range call.Args {
+ if lit, ok := arg.(*ast.BasicLit); ok && lit.Kind == token.STRING {
+ value := strings.Trim(lit.Value, "`\"")
+ if value == "*" {
+ return &SelectStarViolation{
+ Pos: call.Pos(),
+ End: call.End(),
+ Message: "bun " + methodName + "(\"*\") - explicitly specify columns",
+ Builder: "bun",
+ Context: "explicit_star",
+ }
+ }
+ }
+ }
+ }
+
+ // Check NewRaw or Raw with SELECT *
+ if methodName == "NewRaw" || methodName == "Raw" {
+ for _, arg := range call.Args {
+ if lit, ok := arg.(*ast.BasicLit); ok && lit.Kind == token.STRING {
+ value := strings.Trim(lit.Value, "`\"")
+ upperValue := strings.ToUpper(value)
+ if strings.Contains(upperValue, "SELECT *") {
+ return &SelectStarViolation{
+ Pos: call.Pos(),
+ End: call.End(),
+ Message: "bun Raw() with SELECT * - specify columns explicitly",
+ Builder: "bun",
+ Context: "raw_select_star",
+ }
+ }
+ }
+ }
+ }
+
+ return nil
+}
+
+// CheckChainedCalls checks method chains for SELECT * patterns.
+func (c *BunChecker) CheckChainedCalls(call *ast.CallExpr) []*SelectStarViolation {
+ var violations []*SelectStarViolation
+
+ // Track chain state
+ hasNewSelect := false
+ hasColumn := false
+ var selectCall *ast.CallExpr
+
+ // Traverse the call chain
+ current := call
+ for current != nil {
+ sel, ok := current.Fun.(*ast.SelectorExpr)
+ if !ok {
+ break
+ }
+
+ switch sel.Sel.Name {
+ case "NewSelect":
+ hasNewSelect = true
+ selectCall = current
+ case "Column", "ColumnExpr":
+ hasColumn = true
+ // Check for "*" argument
+ for _, arg := range current.Args {
+ if lit, ok := arg.(*ast.BasicLit); ok && lit.Kind == token.STRING {
+ value := strings.Trim(lit.Value, "`\"")
+ if value == "*" {
+ violations = append(violations, &SelectStarViolation{
+ Pos: current.Pos(),
+ End: current.End(),
+ Message: "bun Column(\"*\") in chain - specify columns explicitly",
+ Builder: "bun",
+ Context: "chained_star",
+ })
+ }
+ }
+ }
+ case "Scan", "Exec":
+ // Terminal methods - check if we have NewSelect without Column
+ if hasNewSelect && !hasColumn && selectCall != nil {
+ violations = append(violations, &SelectStarViolation{
+ Pos: selectCall.Pos(),
+ End: current.End(),
+ Message: "bun NewSelect() with Scan/Exec without Column() defaults to SELECT *",
+ Builder: "bun",
+ Context: "implicit_star",
+ })
+ }
+ }
+
+ // Move to the next call in the chain
+ if innerCall, ok := sel.X.(*ast.CallExpr); ok {
+ current = innerCall
+ } else {
+ break
+ }
+ }
+
+ return violations
+}
diff --git a/vendor/github.com/MirrexOne/unqueryvet/internal/analyzer/sqlbuilders/ent.go b/vendor/github.com/MirrexOne/unqueryvet/internal/analyzer/sqlbuilders/ent.go
new file mode 100644
index 0000000000..c3f1848943
--- /dev/null
+++ b/vendor/github.com/MirrexOne/unqueryvet/internal/analyzer/sqlbuilders/ent.go
@@ -0,0 +1,87 @@
+// Package sqlbuilders provides SQL builder library-specific checkers for SELECT * detection.
+package sqlbuilders
+
+import (
+ "go/ast"
+ "go/types"
+)
+
+const entPkgPath = "entgo.io/ent"
+
+// EntChecker checks entgo.io/ent for SELECT * patterns.
+type EntChecker struct{}
+
+// NewEntChecker creates a new EntChecker.
+func NewEntChecker() *EntChecker {
+ return &EntChecker{}
+}
+
+// Name returns the name of this checker.
+func (c *EntChecker) Name() string {
+ return "ent"
+}
+
+// IsApplicable checks if the call is from ent using type information.
+func (c *EntChecker) IsApplicable(info *types.Info, call *ast.CallExpr) bool {
+ sel, ok := call.Fun.(*ast.SelectorExpr)
+ if !ok {
+ return false
+ }
+
+ // Check if the receiver type is from ent package
+ return IsTypeFromPackage(info, sel.X, entPkgPath)
+}
+
+// CheckSelectStar checks for SELECT * in ent calls.
+func (c *EntChecker) CheckSelectStar(call *ast.CallExpr) *SelectStarViolation {
+ // ent typically doesn't have explicit SELECT * patterns
+ // The implicit SELECT * happens when Query().All() is called without Select()
+ return nil
+}
+
+// CheckChainedCalls checks method chains for SELECT * patterns.
+func (c *EntChecker) CheckChainedCalls(call *ast.CallExpr) []*SelectStarViolation {
+ var violations []*SelectStarViolation
+
+ // Track chain state
+ hasQuery := false
+ hasSelect := false
+ var queryCall *ast.CallExpr
+
+ // Traverse the call chain
+ current := call
+ for current != nil {
+ sel, ok := current.Fun.(*ast.SelectorExpr)
+ if !ok {
+ break
+ }
+
+ switch sel.Sel.Name {
+ case "Query":
+ hasQuery = true
+ queryCall = current
+ case "Select":
+ hasSelect = true
+ case "All", "Only", "OnlyX", "First", "FirstX":
+ // Terminal methods - check if we have Query without Select
+ if hasQuery && !hasSelect && queryCall != nil {
+ violations = append(violations, &SelectStarViolation{
+ Pos: queryCall.Pos(),
+ End: current.End(),
+ Message: "ent Query() with All/Only without Select() fetches all columns - use Select() to specify columns",
+ Builder: "ent",
+ Context: "implicit_star",
+ })
+ }
+ }
+
+ // Move to the next call in the chain
+ if innerCall, ok := sel.X.(*ast.CallExpr); ok {
+ current = innerCall
+ } else {
+ break
+ }
+ }
+
+ return violations
+}
diff --git a/vendor/github.com/MirrexOne/unqueryvet/internal/analyzer/sqlbuilders/goqu.go b/vendor/github.com/MirrexOne/unqueryvet/internal/analyzer/sqlbuilders/goqu.go
new file mode 100644
index 0000000000..a923c1f19d
--- /dev/null
+++ b/vendor/github.com/MirrexOne/unqueryvet/internal/analyzer/sqlbuilders/goqu.go
@@ -0,0 +1,120 @@
+package sqlbuilders
+
+import (
+ "go/ast"
+ "go/token"
+ "go/types"
+ "strings"
+)
+
+const goquPkgPath = "github.com/doug-martin/goqu"
+
+// GoquChecker checks for SELECT * in goqu queries.
+type GoquChecker struct{}
+
+// NewGoquChecker creates a new goqu checker.
+func NewGoquChecker() *GoquChecker {
+ return &GoquChecker{}
+}
+
+// Name returns the checker name.
+func (c *GoquChecker) Name() string {
+ return "goqu"
+}
+
+// IsApplicable checks if the call is from goqu using type information.
+func (c *GoquChecker) IsApplicable(info *types.Info, call *ast.CallExpr) bool {
+ sel, ok := call.Fun.(*ast.SelectorExpr)
+ if !ok {
+ return false
+ }
+
+ // Check if the receiver type is from goqu package
+ if IsTypeFromPackage(info, sel.X, goquPkgPath) {
+ return true
+ }
+
+ // Check for package-level function calls like goqu.From()
+ if ident, ok := sel.X.(*ast.Ident); ok {
+ if info != nil {
+ if obj := info.Uses[ident]; obj != nil {
+ if pkgName, ok := obj.(*types.PkgName); ok {
+ pkgPath := pkgName.Imported().Path()
+ if len(pkgPath) >= len(goquPkgPath) && pkgPath[:len(goquPkgPath)] == goquPkgPath {
+ return true
+ }
+ }
+ }
+ }
+ }
+
+ return false
+}
+
+// CheckSelectStar checks for SELECT * patterns in goqu.
+func (c *GoquChecker) CheckSelectStar(call *ast.CallExpr) *SelectStarViolation {
+ sel, ok := call.Fun.(*ast.SelectorExpr)
+ if !ok {
+ return nil
+ }
+
+ methodName := sel.Sel.Name
+
+ // goqu.From("table").SelectAll() - this selects all columns
+ if methodName == "SelectAll" {
+ return &SelectStarViolation{
+ Pos: call.Pos(),
+ End: call.End(),
+ Message: "goqu SelectAll() selects all columns - use Select() with explicit column names",
+ }
+ }
+
+ // goqu.From("table").Select("*")
+ if methodName == "Select" {
+ for _, arg := range call.Args {
+ if lit, ok := arg.(*ast.BasicLit); ok && lit.Kind == token.STRING {
+ value := strings.Trim(lit.Value, "`\"'")
+ if value == "*" {
+ return &SelectStarViolation{
+ Pos: lit.Pos(),
+ End: lit.End(),
+ Message: "goqu Select(\"*\") - specify columns explicitly",
+ }
+ }
+ }
+ }
+
+ // goqu.From("table").Select() without arguments also selects all
+ if len(call.Args) == 0 {
+ return &SelectStarViolation{
+ Pos: call.Pos(),
+ End: call.End(),
+ Message: "goqu Select() without arguments selects all columns",
+ }
+ }
+ }
+
+ return nil
+}
+
+// CheckChainedCalls checks chained method calls.
+func (c *GoquChecker) CheckChainedCalls(call *ast.CallExpr) []*SelectStarViolation {
+ var violations []*SelectStarViolation
+
+ // Walk up the chain
+ current := call
+ for current != nil {
+ if v := c.CheckSelectStar(current); v != nil {
+ violations = append(violations, v)
+ }
+
+ // Move to the receiver if it's also a call
+ sel, ok := current.Fun.(*ast.SelectorExpr)
+ if !ok {
+ break
+ }
+ current, _ = sel.X.(*ast.CallExpr)
+ }
+
+ return violations
+}
diff --git a/vendor/github.com/MirrexOne/unqueryvet/internal/analyzer/sqlbuilders/gorm.go b/vendor/github.com/MirrexOne/unqueryvet/internal/analyzer/sqlbuilders/gorm.go
new file mode 100644
index 0000000000..6275eaf5e7
--- /dev/null
+++ b/vendor/github.com/MirrexOne/unqueryvet/internal/analyzer/sqlbuilders/gorm.go
@@ -0,0 +1,190 @@
+// Package sqlbuilders provides SQL builder library-specific checkers for SELECT * detection.
+package sqlbuilders
+
+import (
+ "go/ast"
+ "go/token"
+ "go/types"
+ "strings"
+)
+
+const gormPkgPath = "gorm.io/gorm"
+
+// GORMChecker checks gorm.io/gorm for SELECT * patterns.
+type GORMChecker struct{}
+
+// NewGORMChecker creates a new GORMChecker.
+func NewGORMChecker() *GORMChecker {
+ return &GORMChecker{}
+}
+
+// Name returns the name of this checker.
+func (c *GORMChecker) Name() string {
+ return "gorm"
+}
+
+// IsApplicable checks if the call is from GORM using type information.
+func (c *GORMChecker) IsApplicable(info *types.Info, call *ast.CallExpr) bool {
+ sel, ok := call.Fun.(*ast.SelectorExpr)
+ if !ok {
+ return false
+ }
+
+ // Check if the receiver type is from gorm package
+ return IsTypeFromPackage(info, sel.X, gormPkgPath)
+}
+
+// CheckSelectStar checks for SELECT * in GORM calls.
+func (c *GORMChecker) CheckSelectStar(call *ast.CallExpr) *SelectStarViolation {
+ sel, ok := call.Fun.(*ast.SelectorExpr)
+ if !ok {
+ return nil
+ }
+
+ switch sel.Sel.Name {
+ case "Select":
+ return c.checkSelectMethod(call)
+ case "Raw":
+ return c.checkRawMethod(call, "GORM Raw() with SELECT * - specify columns explicitly")
+ case "Exec":
+ return c.checkRawMethod(call, "GORM Exec() with SELECT * - specify columns explicitly")
+ }
+
+ return nil
+}
+
+// checkSelectMethod checks db.Select() for star patterns
+func (c *GORMChecker) checkSelectMethod(call *ast.CallExpr) *SelectStarViolation {
+ for _, arg := range call.Args {
+ lit, ok := arg.(*ast.BasicLit)
+ if !ok || lit.Kind != token.STRING {
+ continue
+ }
+
+ value := strings.Trim(lit.Value, "`\"")
+ if value == "*" {
+ return &SelectStarViolation{
+ Pos: call.Pos(),
+ End: call.End(),
+ Message: "GORM Select(\"*\") - explicitly specify columns",
+ Builder: "gorm",
+ Context: "explicit_star",
+ }
+ }
+
+ if strings.Contains(strings.ToUpper(value), "SELECT *") {
+ return &SelectStarViolation{
+ Pos: call.Pos(),
+ End: call.End(),
+ Message: "GORM Select() contains SELECT * - specify columns explicitly",
+ Builder: "gorm",
+ Context: "raw_select_star",
+ }
+ }
+ }
+ return nil
+}
+
+// checkRawMethod checks db.Raw() or db.Exec() for SELECT * patterns
+func (c *GORMChecker) checkRawMethod(call *ast.CallExpr, message string) *SelectStarViolation {
+ for _, arg := range call.Args {
+ lit, ok := arg.(*ast.BasicLit)
+ if !ok || lit.Kind != token.STRING {
+ continue
+ }
+
+ value := strings.Trim(lit.Value, "`\"")
+ if strings.Contains(strings.ToUpper(value), "SELECT *") {
+ return &SelectStarViolation{
+ Pos: call.Pos(),
+ End: call.End(),
+ Message: message,
+ Builder: "gorm",
+ Context: "raw_select_star",
+ }
+ }
+ }
+ return nil
+}
+
+// CheckChainedCalls checks method chains for SELECT * patterns.
+// gormChainState tracks state while traversing GORM call chain
+type gormChainState struct {
+ hasModel bool
+ hasSelect bool
+ modelCall *ast.CallExpr
+}
+
+func (c *GORMChecker) CheckChainedCalls(call *ast.CallExpr) []*SelectStarViolation {
+ var violations []*SelectStarViolation
+ state := &gormChainState{}
+
+ current := call
+ for current != nil {
+ sel, ok := current.Fun.(*ast.SelectorExpr)
+ if !ok {
+ break
+ }
+
+ if v := c.processGormChainMethod(sel.Sel.Name, current, state); v != nil {
+ violations = append(violations, v)
+ }
+
+ if innerCall, ok := sel.X.(*ast.CallExpr); ok {
+ current = innerCall
+ } else {
+ break
+ }
+ }
+
+ return violations
+}
+
+// processGormChainMethod processes a single method in the GORM call chain
+func (c *GORMChecker) processGormChainMethod(methodName string, current *ast.CallExpr, state *gormChainState) *SelectStarViolation {
+ switch methodName {
+ case "Model", "Table":
+ state.hasModel = true
+ state.modelCall = current
+ case "Select":
+ state.hasSelect = true
+ return c.checkGormSelectArgs(current)
+ case "Find", "First", "Last", "Take", "Scan":
+ return c.checkGormTerminalMethod(current, state)
+ }
+ return nil
+}
+
+// checkGormSelectArgs checks Select() arguments for "*"
+func (c *GORMChecker) checkGormSelectArgs(current *ast.CallExpr) *SelectStarViolation {
+ for _, arg := range current.Args {
+ lit, ok := arg.(*ast.BasicLit)
+ if !ok || lit.Kind != token.STRING {
+ continue
+ }
+ if strings.Trim(lit.Value, "`\"") == "*" {
+ return &SelectStarViolation{
+ Pos: current.Pos(),
+ End: current.End(),
+ Message: "GORM Select(\"*\") in chain - specify columns explicitly",
+ Builder: "gorm",
+ Context: "chained_star",
+ }
+ }
+ }
+ return nil
+}
+
+// checkGormTerminalMethod checks terminal methods (Find, First, etc.) for implicit SELECT *
+func (c *GORMChecker) checkGormTerminalMethod(current *ast.CallExpr, state *gormChainState) *SelectStarViolation {
+ if state.hasModel && !state.hasSelect && state.modelCall != nil {
+ return &SelectStarViolation{
+ Pos: state.modelCall.Pos(),
+ End: current.End(),
+ Message: "GORM Model() with Find/First without Select() defaults to SELECT *",
+ Builder: "gorm",
+ Context: "implicit_star",
+ }
+ }
+ return nil
+}
diff --git a/vendor/github.com/MirrexOne/unqueryvet/internal/analyzer/sqlbuilders/interface.go b/vendor/github.com/MirrexOne/unqueryvet/internal/analyzer/sqlbuilders/interface.go
new file mode 100644
index 0000000000..4670d6155f
--- /dev/null
+++ b/vendor/github.com/MirrexOne/unqueryvet/internal/analyzer/sqlbuilders/interface.go
@@ -0,0 +1,156 @@
+// Package sqlbuilders provides SQL builder library-specific checkers for SELECT * detection.
+package sqlbuilders
+
+import (
+ "go/ast"
+ "go/token"
+ "go/types"
+
+ "github.com/MirrexOne/unqueryvet/pkg/config"
+)
+
+// SelectStarViolation represents a detected SELECT * usage in SQL builder code.
+type SelectStarViolation struct {
+ // Pos is the position in source code where the violation was detected
+ Pos token.Pos
+ // End is the end position of the violation
+ End token.Pos
+ // Message is the human-readable description of the violation
+ Message string
+ // Builder is the name of the SQL builder library
+ Builder string
+ // Context provides additional context about the violation type
+ Context string
+}
+
+// SQLBuilderChecker is the interface for SQL builder library-specific checkers.
+// Each SQL builder library (GORM, sqlx, etc.) implements this interface.
+type SQLBuilderChecker interface {
+ // Name returns the name of the SQL builder library
+ Name() string
+
+ // IsApplicable checks if the call expression is from this SQL builder.
+ // It uses type information to verify the receiver type belongs to the correct package.
+ IsApplicable(info *types.Info, call *ast.CallExpr) bool
+
+ // CheckSelectStar checks a single call expression for SELECT * usage
+ CheckSelectStar(call *ast.CallExpr) *SelectStarViolation
+
+ // CheckChainedCalls analyzes method chains for SELECT * patterns
+ CheckChainedCalls(call *ast.CallExpr) []*SelectStarViolation
+}
+
+// Registry holds all registered SQL builder checkers and provides a unified interface.
+type Registry struct {
+ checkers []SQLBuilderChecker
+}
+
+// NewRegistry creates a new Registry with checkers based on the configuration.
+func NewRegistry(cfg *config.SQLBuildersConfig) *Registry {
+ r := &Registry{
+ checkers: make([]SQLBuilderChecker, 0),
+ }
+
+ // Register enabled checkers
+ if cfg.Squirrel {
+ r.checkers = append(r.checkers, NewSquirrelChecker())
+ }
+ if cfg.GORM {
+ r.checkers = append(r.checkers, NewGORMChecker())
+ }
+ if cfg.SQLx {
+ r.checkers = append(r.checkers, NewSQLxChecker())
+ }
+ if cfg.Ent {
+ r.checkers = append(r.checkers, NewEntChecker())
+ }
+ if cfg.PGX {
+ r.checkers = append(r.checkers, NewPGXChecker())
+ }
+ if cfg.Bun {
+ r.checkers = append(r.checkers, NewBunChecker())
+ }
+ if cfg.SQLBoiler {
+ r.checkers = append(r.checkers, NewSQLBoilerChecker())
+ }
+ if cfg.Jet {
+ r.checkers = append(r.checkers, NewJetChecker())
+ }
+ if cfg.Sqlc {
+ r.checkers = append(r.checkers, NewSQLCChecker())
+ }
+ if cfg.Goqu {
+ r.checkers = append(r.checkers, NewGoquChecker())
+ }
+ if cfg.Rel {
+ r.checkers = append(r.checkers, NewRelChecker())
+ }
+ if cfg.Reform {
+ r.checkers = append(r.checkers, NewReformChecker())
+ }
+
+ return r
+}
+
+// Check analyzes a call expression against all registered checkers.
+// Returns all violations found across all applicable checkers.
+// The info parameter provides type information for accurate type checking.
+func (r *Registry) Check(info *types.Info, call *ast.CallExpr) []*SelectStarViolation {
+ var violations []*SelectStarViolation
+
+ for _, checker := range r.checkers {
+ if !checker.IsApplicable(info, call) {
+ continue
+ }
+
+ // Check for direct SELECT * usage
+ if v := checker.CheckSelectStar(call); v != nil {
+ violations = append(violations, v)
+ }
+
+ // Check for SELECT * in method chains
+ chainViolations := checker.CheckChainedCalls(call)
+ violations = append(violations, chainViolations...)
+ }
+
+ return violations
+}
+
+// HasCheckers returns true if at least one checker is registered.
+func (r *Registry) HasCheckers() bool {
+ return len(r.checkers) > 0
+}
+
+// IsTypeFromPackage checks if the type of an expression belongs to a package
+// with the given path prefix. This is used to verify that a method call
+// is actually from the expected SQL builder library.
+func IsTypeFromPackage(info *types.Info, expr ast.Expr, pkgPathPrefix string) bool {
+ if info == nil {
+ return false
+ }
+
+ typ := info.TypeOf(expr)
+ if typ == nil {
+ return false
+ }
+
+ return isTypeFromPackageRecursive(typ, pkgPathPrefix)
+}
+
+// isTypeFromPackageRecursive recursively checks if a type belongs to a package.
+func isTypeFromPackageRecursive(typ types.Type, pkgPathPrefix string) bool {
+ switch t := typ.(type) {
+ case *types.Named:
+ if obj := t.Obj(); obj != nil {
+ if pkg := obj.Pkg(); pkg != nil {
+ pkgPath := pkg.Path()
+ if len(pkgPath) >= len(pkgPathPrefix) && pkgPath[:len(pkgPathPrefix)] == pkgPathPrefix {
+ return true
+ }
+ }
+ }
+ case *types.Pointer:
+ return isTypeFromPackageRecursive(t.Elem(), pkgPathPrefix)
+ }
+ return false
+}
diff --git a/vendor/github.com/MirrexOne/unqueryvet/internal/analyzer/sqlbuilders/jet.go b/vendor/github.com/MirrexOne/unqueryvet/internal/analyzer/sqlbuilders/jet.go
new file mode 100644
index 0000000000..9e28021be9
--- /dev/null
+++ b/vendor/github.com/MirrexOne/unqueryvet/internal/analyzer/sqlbuilders/jet.go
@@ -0,0 +1,184 @@
+// Package sqlbuilders provides SQL builder library-specific checkers for SELECT * detection.
+package sqlbuilders
+
+import (
+ "go/ast"
+ "go/token"
+ "go/types"
+ "slices"
+ "strings"
+)
+
+const jetPkgPath = "github.com/go-jet/jet"
+
+// JetChecker checks github.com/go-jet/jet for SELECT * patterns.
+type JetChecker struct{}
+
+// NewJetChecker creates a new JetChecker.
+func NewJetChecker() *JetChecker {
+ return &JetChecker{}
+}
+
+// Name returns the name of this checker.
+func (c *JetChecker) Name() string {
+ return "jet"
+}
+
+// IsApplicable checks if the call is from jet using type information.
+func (c *JetChecker) IsApplicable(info *types.Info, call *ast.CallExpr) bool {
+ sel, ok := call.Fun.(*ast.SelectorExpr)
+ if !ok {
+ // Check for direct SELECT call - verify via type info
+ if ident, ok := call.Fun.(*ast.Ident); ok {
+ if info != nil {
+ if obj := info.Uses[ident]; obj != nil {
+ if pkg := obj.Pkg(); pkg != nil {
+ pkgPath := pkg.Path()
+ if len(pkgPath) >= len(jetPkgPath) && pkgPath[:len(jetPkgPath)] == jetPkgPath {
+ return true
+ }
+ }
+ }
+ }
+ }
+ return false
+ }
+
+ // Check if the receiver type is from jet package
+ return IsTypeFromPackage(info, sel.X, jetPkgPath)
+}
+
+// CheckSelectStar checks for SELECT * in jet calls.
+func (c *JetChecker) CheckSelectStar(call *ast.CallExpr) *SelectStarViolation {
+ // Check for direct function calls (SELECT, RawStatement)
+ if ident, ok := call.Fun.(*ast.Ident); ok {
+ return c.checkIdentCall(call, ident)
+ }
+
+ // Check for selector calls (table.AllColumns, pkg.Star, etc.)
+ if sel, ok := call.Fun.(*ast.SelectorExpr); ok {
+ return c.checkSelectorCall(call, sel)
+ }
+
+ return nil
+}
+
+// checkIdentCall handles direct function calls like SELECT() or RawStatement()
+func (c *JetChecker) checkIdentCall(call *ast.CallExpr, ident *ast.Ident) *SelectStarViolation {
+ switch ident.Name {
+ case "SELECT":
+ if slices.ContainsFunc(call.Args, c.isAllColumnsOrStar) {
+ return &SelectStarViolation{
+ Pos: call.Pos(),
+ End: call.End(),
+ Message: "Jet SELECT with AllColumns/STAR - specify columns explicitly",
+ Builder: "jet",
+ Context: "explicit_star",
+ }
+ }
+ case "RawStatement":
+ return c.checkRawStatementArgs(call, "Jet RawStatement with SELECT * - specify columns explicitly")
+ }
+ return nil
+}
+
+// checkSelectorCall handles selector calls like table.AllColumns or pkg.Star
+func (c *JetChecker) checkSelectorCall(call *ast.CallExpr, sel *ast.SelectorExpr) *SelectStarViolation {
+ methodName := sel.Sel.Name
+
+ switch methodName {
+ case "AllColumns":
+ return &SelectStarViolation{
+ Pos: call.Pos(),
+ End: call.End(),
+ Message: "Jet AllColumns fetches all columns (SELECT *) - specify columns explicitly",
+ Builder: "jet",
+ Context: "all_columns",
+ }
+ case "Star":
+ return &SelectStarViolation{
+ Pos: call.Pos(),
+ End: call.End(),
+ Message: "Jet Star() - avoid SELECT * and specify columns explicitly",
+ Builder: "jet",
+ Context: "explicit_star",
+ }
+ case "RawStatement", "Raw":
+ return c.checkRawStatementArgs(call, "Jet Raw/RawStatement with SELECT * - specify columns explicitly")
+ }
+
+ return nil
+}
+
+// checkRawStatementArgs checks for SELECT * in raw statement arguments
+func (c *JetChecker) checkRawStatementArgs(call *ast.CallExpr, message string) *SelectStarViolation {
+ for _, arg := range call.Args {
+ if lit, ok := arg.(*ast.BasicLit); ok && lit.Kind == token.STRING {
+ value := strings.Trim(lit.Value, "`\"")
+ if strings.Contains(strings.ToUpper(value), "SELECT *") {
+ return &SelectStarViolation{
+ Pos: call.Pos(),
+ End: call.End(),
+ Message: message,
+ Builder: "jet",
+ Context: "raw_select_star",
+ }
+ }
+ }
+ }
+ return nil
+}
+
+// CheckChainedCalls checks method chains for SELECT * patterns.
+func (c *JetChecker) CheckChainedCalls(call *ast.CallExpr) []*SelectStarViolation {
+ var violations []*SelectStarViolation
+
+ // Traverse the call chain looking for SELECT with AllColumns
+ current := call
+ for current != nil {
+ // Check arguments for AllColumns
+ for _, arg := range current.Args {
+ if c.isAllColumnsOrStar(arg) {
+ violations = append(violations, &SelectStarViolation{
+ Pos: current.Pos(),
+ End: current.End(),
+ Message: "Jet SELECT chain contains AllColumns/STAR - specify columns explicitly",
+ Builder: "jet",
+ Context: "chained_star",
+ })
+ }
+ }
+
+ // Move to the next call in the chain
+ sel, ok := current.Fun.(*ast.SelectorExpr)
+ if !ok {
+ break
+ }
+
+ if innerCall, ok := sel.X.(*ast.CallExpr); ok {
+ current = innerCall
+ } else {
+ break
+ }
+ }
+
+ return violations
+}
+
+// isAllColumnsOrStar checks if an expression represents AllColumns or STAR.
+func (c *JetChecker) isAllColumnsOrStar(expr ast.Expr) bool {
+ switch e := expr.(type) {
+ case *ast.SelectorExpr:
+ // table.AllColumns or package.STAR
+ return e.Sel.Name == "AllColumns" || e.Sel.Name == "STAR"
+ case *ast.CallExpr:
+ // Check if it's a call to AllColumns() or Star()
+ if sel, ok := e.Fun.(*ast.SelectorExpr); ok {
+ return sel.Sel.Name == "AllColumns" || sel.Sel.Name == "Star"
+ }
+ case *ast.Ident:
+ // Direct STAR identifier
+ return e.Name == "STAR" || e.Name == "AllColumns"
+ }
+ return false
+}
diff --git a/vendor/github.com/MirrexOne/unqueryvet/internal/analyzer/sqlbuilders/pgx.go b/vendor/github.com/MirrexOne/unqueryvet/internal/analyzer/sqlbuilders/pgx.go
new file mode 100644
index 0000000000..394cd6596f
--- /dev/null
+++ b/vendor/github.com/MirrexOne/unqueryvet/internal/analyzer/sqlbuilders/pgx.go
@@ -0,0 +1,82 @@
+// Package sqlbuilders provides SQL builder library-specific checkers for SELECT * detection.
+package sqlbuilders
+
+import (
+ "go/ast"
+ "go/token"
+ "go/types"
+ "strings"
+)
+
+const pgxPkgPath = "github.com/jackc/pgx"
+
+// PGXChecker checks github.com/jackc/pgx for SELECT * patterns.
+type PGXChecker struct{}
+
+// NewPGXChecker creates a new PGXChecker.
+func NewPGXChecker() *PGXChecker {
+ return &PGXChecker{}
+}
+
+// Name returns the name of this checker.
+func (c *PGXChecker) Name() string {
+ return "pgx"
+}
+
+// IsApplicable checks if the call is from pgx using type information.
+func (c *PGXChecker) IsApplicable(info *types.Info, call *ast.CallExpr) bool {
+ sel, ok := call.Fun.(*ast.SelectorExpr)
+ if !ok {
+ return false
+ }
+
+ // Check if the receiver type is from pgx package
+ return IsTypeFromPackage(info, sel.X, pgxPkgPath)
+}
+
+// CheckSelectStar checks for SELECT * in pgx calls.
+func (c *PGXChecker) CheckSelectStar(call *ast.CallExpr) *SelectStarViolation {
+ sel, ok := call.Fun.(*ast.SelectorExpr)
+ if !ok {
+ return nil
+ }
+
+ methodName := sel.Sel.Name
+
+ // pgx methods where the SQL query is typically the second argument (after context)
+ // conn.Query(ctx, sql, args...), conn.QueryFunc(ctx, sql, args, func...)
+ switch methodName {
+ case "Query", "QueryRow", "Exec", "Prepare", "QueryFunc":
+ // supported methods
+ default:
+ return nil
+ }
+
+ const queryArgIndex = 1
+ if queryArgIndex >= len(call.Args) {
+ return nil
+ }
+
+ arg := call.Args[queryArgIndex]
+ if lit, ok := arg.(*ast.BasicLit); ok && lit.Kind == token.STRING {
+ value := strings.Trim(lit.Value, "`\"")
+ upperValue := strings.ToUpper(value)
+ if strings.Contains(upperValue, "SELECT *") {
+ return &SelectStarViolation{
+ Pos: call.Pos(),
+ End: call.End(),
+ Message: "pgx " + methodName + "() with SELECT * - specify columns explicitly",
+ Builder: "pgx",
+ Context: "raw_select_star",
+ }
+ }
+ }
+
+ return nil
+}
+
+// CheckChainedCalls checks method chains for SELECT * patterns.
+func (c *PGXChecker) CheckChainedCalls(call *ast.CallExpr) []*SelectStarViolation {
+ // pgx doesn't have significant chaining patterns
+ return nil
+}
diff --git a/vendor/github.com/MirrexOne/unqueryvet/internal/analyzer/sqlbuilders/reform.go b/vendor/github.com/MirrexOne/unqueryvet/internal/analyzer/sqlbuilders/reform.go
new file mode 100644
index 0000000000..ff7a139c0c
--- /dev/null
+++ b/vendor/github.com/MirrexOne/unqueryvet/internal/analyzer/sqlbuilders/reform.go
@@ -0,0 +1,238 @@
+package sqlbuilders
+
+import (
+ "go/ast"
+ "go/token"
+ "go/types"
+ "strings"
+
+ "golang.org/x/tools/go/analysis"
+)
+
+const reformPkgPath = "gopkg.in/reform.v1"
+
+// ReformChecker detects SELECT * patterns in gopkg.in/reform.v1 queries.
+// https://github.com/go-reform/reform
+type ReformChecker struct{}
+
+// NewReformChecker creates a new reform checker.
+func NewReformChecker() *ReformChecker {
+ return &ReformChecker{}
+}
+
+// Name returns the name of the SQL builder.
+func (c *ReformChecker) Name() string {
+ return "reform"
+}
+
+// IsApplicable checks if the call is from reform using type information.
+func (c *ReformChecker) IsApplicable(info *types.Info, call *ast.CallExpr) bool {
+ sel, ok := call.Fun.(*ast.SelectorExpr)
+ if !ok {
+ return false
+ }
+
+ // Check if the receiver type is from reform package
+ return IsTypeFromPackage(info, sel.X, reformPkgPath)
+}
+
+// CheckSelectStar checks a single call expression for SELECT * usage.
+func (c *ReformChecker) CheckSelectStar(call *ast.CallExpr) *SelectStarViolation {
+ v := c.checkCall(call)
+ if v == nil {
+ return nil
+ }
+
+ return &SelectStarViolation{
+ Pos: v.Pos,
+ End: v.End,
+ Message: v.Message,
+ Builder: "reform",
+ Context: v.Method,
+ }
+}
+
+// CheckChainedCalls analyzes method chains for SELECT * patterns.
+func (c *ReformChecker) CheckChainedCalls(call *ast.CallExpr) []*SelectStarViolation {
+ // reform doesn't typically use method chaining for SELECT *
+ return nil
+}
+
+// Check analyzes a file for reform SELECT * patterns.
+func (c *ReformChecker) Check(pass *analysis.Pass, file *ast.File) {
+ ast.Inspect(file, func(n ast.Node) bool {
+ call, ok := n.(*ast.CallExpr)
+ if !ok {
+ return true
+ }
+
+ if v := c.checkCall(call); v != nil {
+ pass.Report(analysis.Diagnostic{
+ Pos: v.Pos,
+ End: v.End,
+ Message: v.Message,
+ })
+ }
+
+ return true
+ })
+}
+
+// ReformViolation represents a reform SELECT * violation.
+type ReformViolation struct {
+ Pos token.Pos
+ End token.Pos
+ Message string
+ Method string
+}
+
+// checkCall checks a call expression for reform SELECT * patterns.
+func (c *ReformChecker) checkCall(call *ast.CallExpr) *ReformViolation {
+ sel, ok := call.Fun.(*ast.SelectorExpr)
+ if !ok {
+ return nil
+ }
+
+ method := sel.Sel.Name
+
+ // reform patterns that load all columns:
+ // - db.FindByPrimaryKeyFrom(table, pk, &record)
+ // - db.FindOneFrom(table, column, value, &record)
+ // - db.FindAllFrom(table, column, values...)
+ // - db.SelectOneFrom(table, tail, args...) - if tail doesn't specify columns
+ // - db.SelectAllFrom(table, tail, args...) - if tail doesn't specify columns
+ // - querier.SelectRows(tail, args...) - may need column specification
+
+ switch method {
+ case "FindByPrimaryKeyFrom", "FindOneFrom", "FindAllFrom":
+ // These methods always load all columns
+ if c.isReformDB(sel.X) {
+ return &ReformViolation{
+ Pos: call.Pos(),
+ End: call.End(),
+ Message: "reform: " + method + " loads all columns - consider using SelectAllFrom with specific columns",
+ Method: method,
+ }
+ }
+
+ case "SelectOneFrom", "SelectAllFrom":
+ // Check if the tail argument specifies columns
+ if c.isReformDB(sel.X) && !c.hasColumnSpecification(call) {
+ return &ReformViolation{
+ Pos: call.Pos(),
+ End: call.End(),
+ Message: "reform: " + method + " should specify columns in the tail argument",
+ Method: method,
+ }
+ }
+
+ case "SelectRows":
+ // Check querier.SelectRows
+ if c.isQuerier(sel.X) && !c.hasSelectClause(call) {
+ return &ReformViolation{
+ Pos: call.Pos(),
+ End: call.End(),
+ Message: "reform: SelectRows query may select all columns - verify column specification",
+ Method: method,
+ }
+ }
+ }
+
+ return nil
+}
+
+// isReformDB checks if the expression is a reform DB.
+func (c *ReformChecker) isReformDB(expr ast.Expr) bool {
+ if ident, ok := expr.(*ast.Ident); ok {
+ name := ident.Name
+ return name == "db" || name == "DB" || name == "querier" ||
+ name == "tx" || name == "Tx"
+ }
+
+ if sel, ok := expr.(*ast.SelectorExpr); ok {
+ return sel.Sel.Name == "DB" || sel.Sel.Name == "Querier"
+ }
+
+ return false
+}
+
+// isQuerier checks if the expression is a reform Querier.
+func (c *ReformChecker) isQuerier(expr ast.Expr) bool {
+ if ident, ok := expr.(*ast.Ident); ok {
+ name := ident.Name
+ return name == "querier" || name == "q" || name == "db" || name == "tx"
+ }
+
+ return false
+}
+
+// hasColumnSpecification checks if the call specifies columns.
+func (c *ReformChecker) hasColumnSpecification(call *ast.CallExpr) bool {
+ // The tail argument (usually second) should specify columns
+ // e.g., "WHERE id = ? ORDER BY name" doesn't specify columns
+ // but "id, name WHERE id = ?" does
+
+ // Find the tail argument (string)
+ for _, arg := range call.Args {
+ if lit, ok := arg.(*ast.BasicLit); ok && lit.Kind == token.STRING {
+ tail := strings.Trim(lit.Value, "`\"")
+ tailUpper := strings.ToUpper(tail)
+
+ // Check if tail starts with column names (not WHERE, ORDER BY, etc.)
+ if strings.HasPrefix(tailUpper, "WHERE") ||
+ strings.HasPrefix(tailUpper, "ORDER") ||
+ strings.HasPrefix(tailUpper, "LIMIT") ||
+ strings.HasPrefix(tailUpper, "GROUP") ||
+ strings.HasPrefix(tailUpper, "HAVING") ||
+ tail == "" {
+ return false
+ }
+
+ // If it doesn't start with common clauses, assume it has columns
+ return true
+ }
+ }
+
+ return false
+}
+
+// hasSelectClause checks if a SelectRows call has a proper SELECT clause.
+func (c *ReformChecker) hasSelectClause(call *ast.CallExpr) bool {
+ for _, arg := range call.Args {
+ if lit, ok := arg.(*ast.BasicLit); ok && lit.Kind == token.STRING {
+ query := strings.ToUpper(strings.Trim(lit.Value, "`\""))
+
+ // Check if query has SELECT with specific columns (not *)
+ if strings.Contains(query, "SELECT") {
+ if strings.Contains(query, "SELECT *") ||
+ strings.Contains(query, "SELECT\t*") ||
+ strings.Contains(query, "SELECT\n*") {
+ return false
+ }
+ return true
+ }
+ }
+ }
+
+ return false
+}
+
+// CheckFile checks a file and returns violations.
+func (c *ReformChecker) CheckFile(file *ast.File, fset *token.FileSet) []ReformViolation {
+ var violations []ReformViolation
+
+ ast.Inspect(file, func(n ast.Node) bool {
+ call, ok := n.(*ast.CallExpr)
+ if !ok {
+ return true
+ }
+
+ if v := c.checkCall(call); v != nil {
+ violations = append(violations, *v)
+ }
+
+ return true
+ })
+
+ return violations
+}
diff --git a/vendor/github.com/MirrexOne/unqueryvet/internal/analyzer/sqlbuilders/rel.go b/vendor/github.com/MirrexOne/unqueryvet/internal/analyzer/sqlbuilders/rel.go
new file mode 100644
index 0000000000..bf98bc8b9c
--- /dev/null
+++ b/vendor/github.com/MirrexOne/unqueryvet/internal/analyzer/sqlbuilders/rel.go
@@ -0,0 +1,227 @@
+package sqlbuilders
+
+import (
+ "go/ast"
+ "go/token"
+ "go/types"
+
+ "golang.org/x/tools/go/analysis"
+)
+
+const relPkgPath = "github.com/go-rel/rel"
+
+// RelChecker detects SELECT * patterns in go-rel/rel queries.
+// https://github.com/go-rel/rel
+type RelChecker struct{}
+
+// NewRelChecker creates a new rel checker.
+func NewRelChecker() *RelChecker {
+ return &RelChecker{}
+}
+
+// Name returns the name of the SQL builder.
+func (c *RelChecker) Name() string {
+ return "rel"
+}
+
+// IsApplicable checks if the call is from rel using type information.
+func (c *RelChecker) IsApplicable(info *types.Info, call *ast.CallExpr) bool {
+ sel, ok := call.Fun.(*ast.SelectorExpr)
+ if !ok {
+ return false
+ }
+
+ // Check if the receiver type is from rel package
+ return IsTypeFromPackage(info, sel.X, relPkgPath)
+}
+
+// CheckSelectStar checks a single call expression for SELECT * usage.
+func (c *RelChecker) CheckSelectStar(call *ast.CallExpr) *SelectStarViolation {
+ if !c.isSelectAllPattern(call) {
+ return nil
+ }
+
+ sel := call.Fun.(*ast.SelectorExpr)
+ return &SelectStarViolation{
+ Pos: call.Pos(),
+ End: call.End(),
+ Message: "rel: query loads all columns - consider using Select() to specify columns",
+ Builder: "rel",
+ Context: sel.Sel.Name,
+ }
+}
+
+// CheckChainedCalls analyzes method chains for SELECT * patterns.
+func (c *RelChecker) CheckChainedCalls(call *ast.CallExpr) []*SelectStarViolation {
+ // rel doesn't typically use method chaining for SELECT *
+ return nil
+}
+
+// Check analyzes a file for rel SELECT * patterns.
+func (c *RelChecker) Check(pass *analysis.Pass, file *ast.File) {
+ ast.Inspect(file, func(n ast.Node) bool {
+ call, ok := n.(*ast.CallExpr)
+ if !ok {
+ return true
+ }
+
+ // Check for rel patterns that load all columns
+ if c.isSelectAllPattern(call) {
+ pass.Report(analysis.Diagnostic{
+ Pos: call.Pos(),
+ End: call.End(),
+ Message: "rel: query loads all columns - consider using Select() to specify columns",
+ })
+ }
+
+ return true
+ })
+}
+
+// isSelectAllPattern checks if a call represents a SELECT * pattern in rel.
+func (c *RelChecker) isSelectAllPattern(call *ast.CallExpr) bool {
+ sel, ok := call.Fun.(*ast.SelectorExpr)
+ if !ok {
+ return false
+ }
+
+ method := sel.Sel.Name
+
+ // rel patterns that load all columns by default:
+ // - repo.Find(ctx, &user) - loads all columns
+ // - repo.FindAll(ctx, &users) - loads all columns
+ // - repo.FindAndCountAll(ctx, &users) - loads all columns
+ // - rel.From("users").All(ctx, &users) - loads all columns without Select()
+
+ switch method {
+ case "Find", "FindAll", "FindAndCountAll":
+ // These methods load all columns unless combined with Select()
+ // Check if this is a call on a rel repository
+ if c.isRelRepository(sel.X) {
+ // Check if the query chain includes Select()
+ if !c.hasSelectInChain(call) {
+ return true
+ }
+ }
+
+ case "All", "One":
+ // Check if this is part of a query builder chain without Select()
+ if c.isQueryBuilderWithoutSelect(sel.X) {
+ return true
+ }
+ }
+
+ return false
+}
+
+// isRelRepository checks if the expression is a rel repository.
+func (c *RelChecker) isRelRepository(expr ast.Expr) bool {
+ // Check for common rel repository variable names
+ if ident, ok := expr.(*ast.Ident); ok {
+ name := ident.Name
+ return name == "repo" || name == "repository" ||
+ name == "r" || name == "db"
+ }
+
+ // Check for selector on repo
+ if sel, ok := expr.(*ast.SelectorExpr); ok {
+ return c.isRelRepository(sel.X)
+ }
+
+ return false
+}
+
+// hasSelectInChain checks if Select() is used in the query chain.
+func (c *RelChecker) hasSelectInChain(call *ast.CallExpr) bool {
+ // Walk up the chain looking for Select()
+ current := call.Fun
+ for {
+ sel, ok := current.(*ast.SelectorExpr)
+ if !ok {
+ break
+ }
+
+ if sel.Sel.Name == "Select" {
+ return true
+ }
+
+ // Check if the receiver is a call expression (method chain)
+ if callExpr, ok := sel.X.(*ast.CallExpr); ok {
+ if innerSel, ok := callExpr.Fun.(*ast.SelectorExpr); ok {
+ if innerSel.Sel.Name == "Select" {
+ return true
+ }
+ }
+ current = callExpr.Fun
+ } else {
+ break
+ }
+ }
+
+ return false
+}
+
+// isQueryBuilderWithoutSelect checks if an expression is a query builder without Select().
+func (c *RelChecker) isQueryBuilderWithoutSelect(expr ast.Expr) bool {
+ // Walk the call chain looking for From() without Select()
+ hasFrom := false
+ hasSelect := false
+
+ current := expr
+ for {
+ call, ok := current.(*ast.CallExpr)
+ if !ok {
+ break
+ }
+
+ sel, ok := call.Fun.(*ast.SelectorExpr)
+ if !ok {
+ break
+ }
+
+ switch sel.Sel.Name {
+ case "From":
+ hasFrom = true
+ case "Select":
+ hasSelect = true
+ }
+
+ current = sel.X
+ }
+
+ return hasFrom && !hasSelect
+}
+
+// RelViolation represents a rel SELECT * violation.
+type RelViolation struct {
+ Pos token.Pos
+ End token.Pos
+ Message string
+ Method string
+}
+
+// CheckFile checks a file and returns violations.
+func (c *RelChecker) CheckFile(file *ast.File, fset *token.FileSet) []RelViolation {
+ var violations []RelViolation
+
+ ast.Inspect(file, func(n ast.Node) bool {
+ call, ok := n.(*ast.CallExpr)
+ if !ok {
+ return true
+ }
+
+ if c.isSelectAllPattern(call) {
+ sel := call.Fun.(*ast.SelectorExpr)
+ violations = append(violations, RelViolation{
+ Pos: call.Pos(),
+ End: call.End(),
+ Message: "rel: query loads all columns - consider using Select()",
+ Method: sel.Sel.Name,
+ })
+ }
+
+ return true
+ })
+
+ return violations
+}
diff --git a/vendor/github.com/MirrexOne/unqueryvet/internal/analyzer/sqlbuilders/sqlboiler.go b/vendor/github.com/MirrexOne/unqueryvet/internal/analyzer/sqlbuilders/sqlboiler.go
new file mode 100644
index 0000000000..1ecbe1e3d3
--- /dev/null
+++ b/vendor/github.com/MirrexOne/unqueryvet/internal/analyzer/sqlbuilders/sqlboiler.go
@@ -0,0 +1,135 @@
+// Package sqlbuilders provides SQL builder library-specific checkers for SELECT * detection.
+package sqlbuilders
+
+import (
+ "go/ast"
+ "go/token"
+ "go/types"
+ "strings"
+)
+
+const sqlboilerPkgPath = "github.com/volatiletech/sqlboiler"
+
+// SQLBoilerChecker checks github.com/volatiletech/sqlboiler for SELECT * patterns.
+type SQLBoilerChecker struct{}
+
+// NewSQLBoilerChecker creates a new SQLBoilerChecker.
+func NewSQLBoilerChecker() *SQLBoilerChecker {
+ return &SQLBoilerChecker{}
+}
+
+// Name returns the name of this checker.
+func (c *SQLBoilerChecker) Name() string {
+ return "sqlboiler"
+}
+
+// IsApplicable checks if the call is from sqlboiler using type information.
+func (c *SQLBoilerChecker) IsApplicable(info *types.Info, call *ast.CallExpr) bool {
+ sel, ok := call.Fun.(*ast.SelectorExpr)
+ if !ok {
+ return false
+ }
+
+ // Check if the receiver type is from sqlboiler package
+ if IsTypeFromPackage(info, sel.X, sqlboilerPkgPath) {
+ return true
+ }
+
+ // Check for qm (query mods) package - verify via type info
+ if ident, ok := sel.X.(*ast.Ident); ok {
+ if info != nil {
+ if obj := info.Uses[ident]; obj != nil {
+ // For package-level function calls like qm.Select(), obj is *types.PkgName
+ if pkgName, ok := obj.(*types.PkgName); ok {
+ pkgPath := pkgName.Imported().Path()
+ if len(pkgPath) >= len(sqlboilerPkgPath) && pkgPath[:len(sqlboilerPkgPath)] == sqlboilerPkgPath {
+ return true
+ }
+ }
+ }
+ }
+ }
+
+ return false
+}
+
+// CheckSelectStar checks for SELECT * in sqlboiler calls.
+func (c *SQLBoilerChecker) CheckSelectStar(call *ast.CallExpr) *SelectStarViolation {
+ sel, ok := call.Fun.(*ast.SelectorExpr)
+ if !ok {
+ return nil
+ }
+
+ methodName := sel.Sel.Name
+
+ // Check qm.Select("*")
+ if methodName == "Select" {
+ // Check if caller is qm package
+ if ident, ok := sel.X.(*ast.Ident); ok && ident.Name == "qm" {
+ for _, arg := range call.Args {
+ if lit, ok := arg.(*ast.BasicLit); ok && lit.Kind == token.STRING {
+ value := strings.Trim(lit.Value, "`\"")
+ if value == "*" {
+ return &SelectStarViolation{
+ Pos: call.Pos(),
+ End: call.End(),
+ Message: "SQLBoiler qm.Select(\"*\") - explicitly specify columns",
+ Builder: "sqlboiler",
+ Context: "explicit_star",
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return nil
+}
+
+// CheckChainedCalls checks method chains for SELECT * patterns.
+func (c *SQLBoilerChecker) CheckChainedCalls(call *ast.CallExpr) []*SelectStarViolation {
+ var violations []*SelectStarViolation
+
+ // SQLBoiler uses query mods passed to model methods
+ // Example: models.Users(qm.Select("*")).All(ctx, db)
+
+ sel, ok := call.Fun.(*ast.SelectorExpr)
+ if !ok {
+ return violations
+ }
+
+ // Check terminal methods
+ if sel.Sel.Name == "All" || sel.Sel.Name == "One" {
+ // Look for the model call that might have query mods
+ if innerCall, ok := sel.X.(*ast.CallExpr); ok {
+ // Check if there's a qm.Select in the arguments
+ // Note: qm.Select("*") is already detected by CheckSelectStar when
+ // the analyzer visits that CallExpr, so we only check for hasSelect here
+ hasSelect := false
+ for _, arg := range innerCall.Args {
+ if callExpr, ok := arg.(*ast.CallExpr); ok {
+ if innerSel, ok := callExpr.Fun.(*ast.SelectorExpr); ok {
+ if innerSel.Sel.Name == "Select" {
+ hasSelect = true
+ break
+ }
+ }
+ }
+ }
+
+ // If no Select query mod, it defaults to SELECT *
+ if !hasSelect && len(innerCall.Args) == 0 {
+ // Model().All() without query mods = SELECT *
+ violations = append(violations, &SelectStarViolation{
+ Pos: innerCall.Pos(),
+ End: call.End(),
+ Message: "SQLBoiler model().All() without qm.Select() defaults to SELECT *",
+ Builder: "sqlboiler",
+ Context: "implicit_star",
+ })
+ }
+ }
+ }
+
+ return violations
+}
diff --git a/vendor/github.com/MirrexOne/unqueryvet/internal/analyzer/sqlbuilders/sqlc.go b/vendor/github.com/MirrexOne/unqueryvet/internal/analyzer/sqlbuilders/sqlc.go
new file mode 100644
index 0000000000..d98a52bd49
--- /dev/null
+++ b/vendor/github.com/MirrexOne/unqueryvet/internal/analyzer/sqlbuilders/sqlc.go
@@ -0,0 +1,87 @@
+package sqlbuilders
+
+import (
+ "go/ast"
+ "go/token"
+ "go/types"
+ "strings"
+)
+
+// sqlc generates code, so we check if the package path contains "sqlc"
+const sqlcPkgPath = "sqlc"
+
+// SQLCChecker checks for SELECT * in sqlc generated code.
+type SQLCChecker struct{}
+
+// NewSQLCChecker creates a new sqlc checker.
+func NewSQLCChecker() *SQLCChecker {
+ return &SQLCChecker{}
+}
+
+// Name returns the checker name.
+func (c *SQLCChecker) Name() string {
+ return "sqlc"
+}
+
+// IsApplicable checks if the call is from sqlc generated code using type information.
+func (c *SQLCChecker) IsApplicable(info *types.Info, call *ast.CallExpr) bool {
+ sel, ok := call.Fun.(*ast.SelectorExpr)
+ if !ok {
+ return false
+ }
+
+ // sqlc generates code, check if receiver type's package contains "sqlc"
+ if info != nil {
+ typ := info.TypeOf(sel.X)
+ if typ != nil {
+ if named, ok := typ.(*types.Named); ok {
+ if obj := named.Obj(); obj != nil {
+ if pkg := obj.Pkg(); pkg != nil {
+ if strings.Contains(pkg.Path(), sqlcPkgPath) {
+ return true
+ }
+ }
+ }
+ }
+ // Check pointer types
+ if ptr, ok := typ.(*types.Pointer); ok {
+ if named, ok := ptr.Elem().(*types.Named); ok {
+ if obj := named.Obj(); obj != nil {
+ if pkg := obj.Pkg(); pkg != nil {
+ if strings.Contains(pkg.Path(), sqlcPkgPath) {
+ return true
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return false
+}
+
+// CheckSelectStar checks for SELECT * in the call.
+func (c *SQLCChecker) CheckSelectStar(call *ast.CallExpr) *SelectStarViolation {
+ // sqlc doesn't typically have SELECT * visible in Go code
+ // but we can check string arguments
+ for _, arg := range call.Args {
+ if lit, ok := arg.(*ast.BasicLit); ok && lit.Kind == token.STRING {
+ value := strings.ToUpper(lit.Value)
+ if strings.Contains(value, "SELECT *") || strings.Contains(value, "SELECT\t*") {
+ return &SelectStarViolation{
+ Pos: lit.Pos(),
+ End: lit.End(),
+ Message: "sqlc query contains SELECT * - specify columns explicitly in your .sql file",
+ }
+ }
+ }
+ }
+ return nil
+}
+
+// CheckChainedCalls checks chained method calls.
+func (c *SQLCChecker) CheckChainedCalls(call *ast.CallExpr) []*SelectStarViolation {
+ // sqlc doesn't typically use chained calls
+ return nil
+}
diff --git a/vendor/github.com/MirrexOne/unqueryvet/internal/analyzer/sqlbuilders/sqlx.go b/vendor/github.com/MirrexOne/unqueryvet/internal/analyzer/sqlbuilders/sqlx.go
new file mode 100644
index 0000000000..1daf4c6caf
--- /dev/null
+++ b/vendor/github.com/MirrexOne/unqueryvet/internal/analyzer/sqlbuilders/sqlx.go
@@ -0,0 +1,90 @@
+// Package sqlbuilders provides SQL builder library-specific checkers for SELECT * detection.
+package sqlbuilders
+
+import (
+ "go/ast"
+ "go/token"
+ "go/types"
+ "strings"
+)
+
+const sqlxPkgPath = "github.com/jmoiron/sqlx"
+
+// SQLxChecker checks github.com/jmoiron/sqlx for SELECT * patterns.
+type SQLxChecker struct{}
+
+// NewSQLxChecker creates a new SQLxChecker.
+func NewSQLxChecker() *SQLxChecker {
+ return &SQLxChecker{}
+}
+
+// Name returns the name of this checker.
+func (c *SQLxChecker) Name() string {
+ return "sqlx"
+}
+
+// IsApplicable checks if the call is from sqlx using type information.
+func (c *SQLxChecker) IsApplicable(info *types.Info, call *ast.CallExpr) bool {
+ sel, ok := call.Fun.(*ast.SelectorExpr)
+ if !ok {
+ return false
+ }
+
+ // Check if the receiver type is from sqlx package
+ return IsTypeFromPackage(info, sel.X, sqlxPkgPath)
+}
+
+// CheckSelectStar checks for SELECT * in sqlx calls.
+func (c *SQLxChecker) CheckSelectStar(call *ast.CallExpr) *SelectStarViolation {
+ sel, ok := call.Fun.(*ast.SelectorExpr)
+ if !ok {
+ return nil
+ }
+
+ methodName := sel.Sel.Name
+
+ // Methods where the SQL query is typically the first or second argument
+ queryArgIndex := 0
+ switch methodName {
+ case "Select", "Get":
+ // db.Select(&dest, query, args...)
+ // db.Get(&dest, query, args...)
+ queryArgIndex = 1
+ case "Queryx", "QueryRowx", "MustExec", "NamedExec":
+ // db.Queryx(query, args...)
+ queryArgIndex = 0
+ case "NamedQuery":
+ // db.NamedQuery(query, arg)
+ queryArgIndex = 0
+ default:
+ return nil
+ }
+
+ if queryArgIndex >= len(call.Args) {
+ return nil
+ }
+
+ arg := call.Args[queryArgIndex]
+ if lit, ok := arg.(*ast.BasicLit); ok && lit.Kind == token.STRING {
+ value := strings.Trim(lit.Value, "`\"")
+ upperValue := strings.ToUpper(value)
+ if strings.Contains(upperValue, "SELECT *") {
+ return &SelectStarViolation{
+ Pos: call.Pos(),
+ End: call.End(),
+ Message: "sqlx " + methodName + "() with SELECT * - specify columns explicitly",
+ Builder: "sqlx",
+ Context: "raw_select_star",
+ }
+ }
+ }
+
+ return nil
+}
+
+// CheckChainedCalls checks method chains for SELECT * patterns.
+func (c *SQLxChecker) CheckChainedCalls(call *ast.CallExpr) []*SelectStarViolation {
+ // sqlx doesn't have significant chaining patterns like GORM
+ // Most queries are single method calls
+ return nil
+}
diff --git a/vendor/github.com/MirrexOne/unqueryvet/internal/analyzer/sqlbuilders/squirrel.go b/vendor/github.com/MirrexOne/unqueryvet/internal/analyzer/sqlbuilders/squirrel.go
new file mode 100644
index 0000000000..33f1f9069d
--- /dev/null
+++ b/vendor/github.com/MirrexOne/unqueryvet/internal/analyzer/sqlbuilders/squirrel.go
@@ -0,0 +1,214 @@
+// Package sqlbuilders provides SQL builder library-specific checkers for SELECT * detection.
+package sqlbuilders
+
+import (
+ "go/ast"
+ "go/token"
+ "go/types"
+ "strings"
+)
+
+const squirrelPkgPath = "github.com/Masterminds/squirrel"
+
+// SquirrelChecker checks github.com/Masterminds/squirrel for SELECT * patterns.
+type SquirrelChecker struct{}
+
+// NewSquirrelChecker creates a new SquirrelChecker.
+func NewSquirrelChecker() *SquirrelChecker {
+ return &SquirrelChecker{}
+}
+
+// Name returns the name of this checker.
+func (c *SquirrelChecker) Name() string {
+ return "squirrel"
+}
+
+// IsApplicable checks if the call is from Squirrel using type information.
+func (c *SquirrelChecker) IsApplicable(info *types.Info, call *ast.CallExpr) bool {
+ sel, ok := call.Fun.(*ast.SelectorExpr)
+ if !ok {
+ return false
+ }
+
+ // Check if the receiver type is from squirrel package
+ if IsTypeFromPackage(info, sel.X, squirrelPkgPath) {
+ return true
+ }
+
+ // Check for package-level function calls like squirrel.Select()
+ if ident, ok := sel.X.(*ast.Ident); ok {
+ if info != nil {
+ if obj := info.Uses[ident]; obj != nil {
+ if pkgName, ok := obj.(*types.PkgName); ok {
+ pkgPath := pkgName.Imported().Path()
+ if len(pkgPath) >= len(squirrelPkgPath) && pkgPath[:len(squirrelPkgPath)] == squirrelPkgPath {
+ return true
+ }
+ }
+ }
+ }
+ }
+
+ return false
+}
+
+// CheckSelectStar checks for SELECT * in Squirrel calls.
+func (c *SquirrelChecker) CheckSelectStar(call *ast.CallExpr) *SelectStarViolation {
+ sel, ok := call.Fun.(*ast.SelectorExpr)
+ if !ok {
+ return nil
+ }
+
+ methodName := sel.Sel.Name
+
+ // Check squirrel.Select("*") or builder.Select("*")
+ if methodName == "Select" {
+ // Empty Select() means SELECT *
+ if len(call.Args) == 0 {
+ return &SelectStarViolation{
+ Pos: call.Pos(),
+ End: call.End(),
+ Message: "Squirrel Select() without columns defaults to SELECT * - add specific columns",
+ Builder: "squirrel",
+ Context: "empty_select",
+ }
+ }
+
+ // Check for "*" in arguments
+ for _, arg := range call.Args {
+ if lit, ok := arg.(*ast.BasicLit); ok && lit.Kind == token.STRING {
+ value := strings.Trim(lit.Value, "`\"")
+ if value == "*" || value == "" {
+ return &SelectStarViolation{
+ Pos: call.Pos(),
+ End: call.End(),
+ Message: "Squirrel Select(\"*\") - explicitly specify columns",
+ Builder: "squirrel",
+ Context: "explicit_star",
+ }
+ }
+ }
+ }
+ }
+
+ // Check Columns("*") or Column("*")
+ if methodName == "Columns" || methodName == "Column" {
+ for _, arg := range call.Args {
+ if lit, ok := arg.(*ast.BasicLit); ok && lit.Kind == token.STRING {
+ value := strings.Trim(lit.Value, "`\"")
+ if value == "*" {
+ return &SelectStarViolation{
+ Pos: call.Pos(),
+ End: call.End(),
+ Message: "Squirrel Columns(\"*\") - explicitly specify columns",
+ Builder: "squirrel",
+ Context: "explicit_star",
+ }
+ }
+ }
+ }
+ }
+
+ return nil
+}
+
+// CheckChainedCalls checks method chains for SELECT * patterns.
+// squirrelChainState tracks state while traversing call chain
+type squirrelChainState struct {
+ hasSelect bool
+ hasColumns bool
+ selectCall *ast.CallExpr
+}
+
+func (c *SquirrelChecker) CheckChainedCalls(call *ast.CallExpr) []*SelectStarViolation {
+ var violations []*SelectStarViolation
+ state := &squirrelChainState{}
+
+ current := call
+ for current != nil {
+ sel, ok := current.Fun.(*ast.SelectorExpr)
+ if !ok {
+ break
+ }
+
+ if v := c.processChainMethod(sel.Sel.Name, current, state); v != nil {
+ violations = append(violations, v)
+ }
+
+ if innerCall, ok := sel.X.(*ast.CallExpr); ok {
+ current = innerCall
+ } else {
+ break
+ }
+ }
+
+ return violations
+}
+
+// processChainMethod processes a single method in the call chain
+func (c *SquirrelChecker) processChainMethod(methodName string, current *ast.CallExpr, state *squirrelChainState) *SelectStarViolation {
+ switch methodName {
+ case "Select":
+ return c.handleSelectMethod(current, state)
+ case "Columns", "Column":
+ return c.handleColumnsMethod(current, state)
+ case "From", "Where", "Join", "LeftJoin", "RightJoin", "InnerJoin":
+ return c.handleTerminalMethod(state)
+ }
+ return nil
+}
+
+// handleSelectMethod handles Select() calls in chain
+func (c *SquirrelChecker) handleSelectMethod(current *ast.CallExpr, state *squirrelChainState) *SelectStarViolation {
+ state.hasSelect = true
+ state.selectCall = current
+
+ if len(current.Args) == 0 {
+ return nil
+ }
+
+ state.hasColumns = true
+ if v := c.checkArgsForStar(current, "Squirrel Select(\"*\") in chain - specify columns explicitly"); v != nil {
+ return v
+ }
+ return nil
+}
+
+// handleColumnsMethod handles Columns()/Column() calls in chain
+func (c *SquirrelChecker) handleColumnsMethod(current *ast.CallExpr, state *squirrelChainState) *SelectStarViolation {
+ state.hasColumns = true
+ return c.checkArgsForStar(current, "Squirrel Columns(\"*\") in chain - specify columns explicitly")
+}
+
+// handleTerminalMethod handles terminal methods (From, Where, Join, etc.)
+func (c *SquirrelChecker) handleTerminalMethod(state *squirrelChainState) *SelectStarViolation {
+ if state.hasSelect && !state.hasColumns && state.selectCall != nil && len(state.selectCall.Args) == 0 {
+ return &SelectStarViolation{
+ Pos: state.selectCall.Pos(),
+ End: state.selectCall.End(),
+ Message: "Squirrel Select() without columns in chain defaults to SELECT *",
+ Builder: "squirrel",
+ Context: "empty_select_chain",
+ }
+ }
+ return nil
+}
+
+// checkArgsForStar checks if any argument is "*"
+func (c *SquirrelChecker) checkArgsForStar(call *ast.CallExpr, message string) *SelectStarViolation {
+ for _, arg := range call.Args {
+ if lit, ok := arg.(*ast.BasicLit); ok && lit.Kind == token.STRING {
+ value := strings.Trim(lit.Value, "`\"")
+ if value == "*" {
+ return &SelectStarViolation{
+ Pos: call.Pos(),
+ End: call.End(),
+ Message: message,
+ Builder: "squirrel",
+ Context: "chained_star",
+ }
+ }
+ }
+ }
+ return nil
+}
diff --git a/vendor/github.com/MirrexOne/unqueryvet/internal/analyzer/sqli_scanner.go b/vendor/github.com/MirrexOne/unqueryvet/internal/analyzer/sqli_scanner.go
new file mode 100644
index 0000000000..7f3d1fe792
--- /dev/null
+++ b/vendor/github.com/MirrexOne/unqueryvet/internal/analyzer/sqli_scanner.go
@@ -0,0 +1,750 @@
+package analyzer
+
+import (
+ "fmt"
+ "go/ast"
+ "go/token"
+ "go/types"
+ "regexp"
+ "strings"
+
+ "golang.org/x/tools/go/analysis"
+)
+
+// SQLISeverity represents the severity level of SQL injection vulnerability.
+type SQLISeverity string
+
+const (
+ SQLISeverityCritical SQLISeverity = "critical" // Direct user input in query
+ SQLISeverityHigh SQLISeverity = "high" // Format string with variables
+ SQLISeverityMedium SQLISeverity = "medium" // String concatenation
+ SQLISeverityLow SQLISeverity = "low" // Potential issue, needs review
+)
+
+// SQLInjectionScanner detects potential SQL injection vulnerabilities.
+type SQLInjectionScanner struct {
+ // dangerousFuncs are functions that format strings (potential SQL injection vectors)
+ dangerousFuncs map[string]map[string]bool // package -> function -> bool
+ // queryFuncs are database query functions
+ queryFuncs map[string]bool
+ // ormQueryMethods are ORM-specific query methods
+ ormQueryMethods map[string]bool
+ // taintedVariables tracks variables that might contain user input
+ taintedVariables map[string]bool
+ // userInputPatterns are variable name patterns that suggest user input
+ userInputPatterns []string
+ // httpInputFuncs are functions that read HTTP input
+ httpInputFuncs map[string]map[string]bool
+ // pass is the current analysis pass
+ pass *analysis.Pass
+}
+
+// SQLInjectionViolation represents a detected SQL injection vulnerability.
+type SQLInjectionViolation struct {
+ Pos token.Pos
+ End token.Pos
+ Message string
+ Severity SQLISeverity
+ VulnType string // "concat", "sprintf", "exec", "tainted", "orm_raw"
+ Suggestion string
+ CodeFix string // Suggested code fix
+}
+
+// NewSQLInjectionScanner creates a new SQL injection scanner.
+func NewSQLInjectionScanner() *SQLInjectionScanner {
+ return &SQLInjectionScanner{
+ dangerousFuncs: map[string]map[string]bool{
+ "fmt": {
+ "Sprintf": true,
+ "Fprintf": true,
+ "Printf": true,
+ "Errorf": true,
+ "Sscanf": true,
+ },
+ "strings": {
+ "Join": true,
+ "Replace": true,
+ "ReplaceAll": true,
+ "Builder": true,
+ },
+ "strconv": {
+ "Itoa": true,
+ "FormatInt": true,
+ },
+ },
+ queryFuncs: map[string]bool{
+ // Standard database/sql
+ "Query": true,
+ "QueryRow": true,
+ "Exec": true,
+ "ExecContext": true,
+ "QueryContext": true,
+ "QueryRowContext": true,
+ "Prepare": true,
+ "PrepareContext": true,
+ // SQLx
+ "QueryRowx": true,
+ "Queryx": true,
+ "MustExec": true,
+ "NamedExec": true,
+ "NamedQuery": true,
+ "NamedExecContext": true,
+ "NamedQueryContext": true,
+ "Get": true,
+ "Select": true,
+ "GetContext": true,
+ "SelectContext": true,
+ // GORM
+ "Raw": true,
+ "Where": true,
+ "Having": true,
+ "Order": true,
+ "Group": true,
+ "Joins": true,
+ // Bun
+ "NewRaw": true,
+ "ColumnExpr": true,
+ "WhereOr": true,
+ // PGX
+ "SendBatch": true,
+ },
+ ormQueryMethods: map[string]bool{
+ // GORM dangerous methods when used with string concat
+ "Raw": true,
+ "Exec": true,
+ "Where": true,
+ "Or": true,
+ "Not": true,
+ "Having": true,
+ "Order": true,
+ "Group": true,
+ "Joins": true,
+ // Bun
+ "NewRaw": true,
+ "WhereOr": true,
+ "ColumnExpr": true,
+ "TableExpr": true,
+ },
+ taintedVariables: make(map[string]bool),
+ userInputPatterns: []string{
+ "user", "input", "param", "query", "search", "filter",
+ "id", "name", "email", "password", "username", "request",
+ "body", "form", "data", "value", "arg", "args",
+ "term", "keyword", "text", "content",
+ },
+ httpInputFuncs: map[string]map[string]bool{
+ "http": {
+ "Request": true,
+ },
+ "gin": {
+ "Param": true,
+ "Query": true,
+ "PostForm": true,
+ "DefaultQuery": true,
+ "GetQuery": true,
+ "BindJSON": true,
+ "ShouldBind": true,
+ },
+ "echo": {
+ "Param": true,
+ "QueryParam": true,
+ "FormValue": true,
+ "Bind": true,
+ },
+ "fiber": {
+ "Params": true,
+ "Query": true,
+ "FormValue": true,
+ "BodyParser": true,
+ },
+ "chi": {
+ "URLParam": true,
+ },
+ "mux": {
+ "Vars": true,
+ },
+ },
+ }
+}
+
+// SQL pattern for identifying SQL-like strings
+var sqlPattern = regexp.MustCompile(`(?i)(SELECT|INSERT|UPDATE|DELETE|DROP|CREATE|ALTER|TRUNCATE)\s+`)
+
+// Placeholder patterns for parameterized queries
+var placeholderPattern = regexp.MustCompile(`(\?|\$\d+|:\w+|@\w+)`)
+
+// ScanFile scans a file for SQL injection vulnerabilities.
+func (s *SQLInjectionScanner) ScanFile(pass *analysis.Pass, file *ast.File) []SQLInjectionViolation {
+ s.pass = pass
+ var violations []SQLInjectionViolation
+
+ ast.Inspect(file, func(n ast.Node) bool {
+ switch node := n.(type) {
+ case *ast.CallExpr:
+ // Check for dangerous patterns
+ if v := s.checkCallExpr(node); v != nil {
+ violations = append(violations, *v)
+ }
+ case *ast.BinaryExpr:
+ // Check for string concatenation in SQL context
+ if v := s.checkBinaryExpr(node); v != nil {
+ violations = append(violations, *v)
+ }
+ }
+ return true
+ })
+
+ return violations
+}
+
+// checkCallExpr checks a function call for SQL injection patterns.
+func (s *SQLInjectionScanner) checkCallExpr(call *ast.CallExpr) *SQLInjectionViolation {
+ // Check if this is a query function call
+ methodName := s.getMethodName(call)
+ if !s.queryFuncs[methodName] && !s.ormQueryMethods[methodName] {
+ return nil
+ }
+
+ // Ignore *sql.Stmt calls since they don't take queries
+ if s.isStmtMethod(call) {
+ return nil
+ }
+
+ // If this is a parameterized query (first arg is string literal with placeholders,
+ // subsequent args are parameters), it's safe
+ if s.isParameterizedQuery(call) {
+ return nil
+ }
+
+ // Determine which argument is the query string
+ queryIdx := 0
+ if strings.HasSuffix(methodName, "Context") {
+ queryIdx = 1
+ }
+
+ if len(call.Args) <= queryIdx {
+ return nil
+ }
+
+ // Only check the query argument for dangerous patterns
+ arg := call.Args[queryIdx]
+
+ // Pattern 1: fmt.Sprintf result used as query
+ if innerCall, ok := arg.(*ast.CallExpr); ok {
+ if s.isDangerousFormatCall(innerCall) {
+ if s.containsUserInput(innerCall) {
+ return &SQLInjectionViolation{
+ Pos: call.Pos(),
+ End: call.End(),
+ Message: "SQL INJECTION: fmt.Sprintf with user input passed to " + methodName + "()",
+ Severity: SQLISeverityCritical,
+ VulnType: "sprintf",
+ Suggestion: "Use parameterized queries with placeholders (?, $1, :name)",
+ CodeFix: s.generateParameterizedFix(methodName, arg),
+ }
+ }
+ // Even without detected user input, format strings are suspicious
+ return &SQLInjectionViolation{
+ Pos: call.Pos(),
+ End: call.End(),
+ Message: "potential SQL injection: fmt.Sprintf result passed to " + methodName + "() - use parameterized queries",
+ Severity: SQLISeverityHigh,
+ VulnType: "sprintf",
+ Suggestion: "Replace fmt.Sprintf with parameterized query using placeholders",
+ CodeFix: s.generateParameterizedFix(methodName, arg),
+ }
+ }
+ // Check for HTTP input functions
+ if s.isHTTPInputCall(innerCall) {
+ return &SQLInjectionViolation{
+ Pos: call.Pos(),
+ End: call.End(),
+ Message: "SQL INJECTION: HTTP input directly used in " + methodName + "()",
+ Severity: SQLISeverityCritical,
+ VulnType: "tainted",
+ Suggestion: "Never use HTTP input directly in SQL - always use parameterized queries",
+ }
+ }
+ }
+
+ // Pattern 2: String concatenation used as query
+ if binExpr, ok := arg.(*ast.BinaryExpr); ok {
+ if binExpr.Op == token.ADD {
+ if s.containsTaintedVariable(binExpr) {
+ return &SQLInjectionViolation{
+ Pos: call.Pos(),
+ End: call.End(),
+ Message: "SQL INJECTION: string concatenation with user input in " + methodName + "()",
+ Severity: SQLISeverityCritical,
+ VulnType: "concat",
+ Suggestion: "Use parameterized queries instead of string concatenation",
+ CodeFix: "Replace: db." + methodName + "(\"SELECT * FROM users WHERE id = \" + id)\nWith: db." + methodName + "(\"SELECT * FROM users WHERE id = ?\", id)",
+ }
+ }
+ if s.containsStringVariable(binExpr) {
+ return &SQLInjectionViolation{
+ Pos: call.Pos(),
+ End: call.End(),
+ Message: "potential SQL injection: string concatenation in " + methodName + "()",
+ Severity: SQLISeverityHigh,
+ VulnType: "concat",
+ Suggestion: "Use parameterized queries instead of string concatenation",
+ }
+ }
+ }
+ }
+
+ // Pattern 3: Tainted variable used directly
+ if ident := getIdent(arg); ident != nil {
+ if s.isTaintedVariable(ident.Name) && !s.isConstant(arg) {
+ return &SQLInjectionViolation{
+ Pos: call.Pos(),
+ End: call.End(),
+ Message: fmt.Sprintf("SQL INJECTION: potentially tainted variable '%s' used in %s ()", ident.Name, methodName),
+ Severity: SQLISeverityHigh,
+ VulnType: "tainted",
+ Suggestion: fmt.Sprintf("Validate and sanitize '%s' or use parameterized queries", ident.Name),
+ }
+ }
+ if s.mightBeDynamicQuery(ident) && !s.isConstant(arg) {
+ return &SQLInjectionViolation{
+ Pos: call.Pos(),
+ End: call.End(),
+ Message: "review SQL query in " + methodName + "(): ensure '" + ident.Name + "' is not built with user input",
+ Severity: SQLISeverityMedium,
+ VulnType: "variable",
+ Suggestion: "Audit the construction of '" + ident.Name + "' to ensure it doesn't contain user input",
+ }
+ }
+ }
+
+ // Pattern 4: ORM Raw methods with string variables
+ if s.ormQueryMethods[methodName] {
+ if v := s.checkORMRawMethod(call, methodName); v != nil {
+ return v
+ }
+ }
+
+ return nil
+}
+
+// checkORMRawMethod checks ORM-specific raw SQL methods.
+func (s *SQLInjectionScanner) checkORMRawMethod(call *ast.CallExpr, methodName string) *SQLInjectionViolation {
+ // Methods like db.Raw(), db.Where() with string concatenation
+ if len(call.Args) == 0 {
+ return nil
+ }
+
+ firstArg := call.Args[0]
+
+ // Check if first argument is a string literal (safe) or variable (needs review)
+ if _, ok := firstArg.(*ast.BasicLit); !ok {
+ // Not a string literal - might be dangerous
+ if ident := getIdent(firstArg); ident != nil {
+ if s.isTaintedVariable(ident.Name) && !s.isConstant(firstArg) {
+ return &SQLInjectionViolation{
+ Pos: call.Pos(),
+ End: call.End(),
+ Message: "SQL INJECTION risk: " + methodName + "() with potentially tainted variable",
+ Severity: SQLISeverityHigh,
+ VulnType: "orm_raw",
+ Suggestion: "Use parameterized syntax: db." + methodName + "(\"field = ?\", value)",
+ }
+ }
+ }
+ }
+
+ return nil
+}
+
+// generateParameterizedFix generates a suggested fix for sprintf patterns.
+func (s *SQLInjectionScanner) generateParameterizedFix(methodName string, arg ast.Expr) string {
+ return "Replace fmt.Sprintf with parameterized query:\n" +
+ " Before: db." + methodName + "(fmt.Sprintf(\"SELECT * FROM users WHERE id = %d\", id))\n" +
+ " After: db." + methodName + "(\"SELECT * FROM users WHERE id = ?\", id)"
+}
+
+// isHTTPInputCall checks if a call is reading HTTP input.
+func (s *SQLInjectionScanner) isHTTPInputCall(call *ast.CallExpr) bool {
+ sel, ok := call.Fun.(*ast.SelectorExpr)
+ if !ok {
+ return false
+ }
+
+ methodName := sel.Sel.Name
+
+ // Check for common HTTP input methods
+ httpMethods := map[string]bool{
+ "Param": true, "Query": true, "PostForm": true,
+ "FormValue": true, "QueryParam": true, "Params": true,
+ "GetQuery": true, "DefaultQuery": true, "BodyParser": true,
+ "Bind": true, "BindJSON": true, "ShouldBind": true,
+ "URLParam": true, "Vars": true,
+ }
+
+ return httpMethods[methodName]
+}
+
+// isConstant checks if an expression refers to a constant.
+func (s *SQLInjectionScanner) isConstant(expr ast.Expr) bool {
+ if expr == nil {
+ return false
+ }
+ if s.pass != nil && s.pass.TypesInfo != nil {
+ if ident := getIdent(expr); ident != nil {
+ if obj := s.pass.TypesInfo.ObjectOf(ident); obj != nil {
+ _, ok := obj.(*types.Const)
+ return ok
+ }
+ }
+ }
+ if ident, ok := expr.(*ast.Ident); ok {
+ if ident.Obj != nil && ident.Obj.Kind == ast.Con {
+ return true
+ }
+ }
+ return false
+}
+
+// getIdent extracts an identifier from an expression (Ident or SelectorExpr).
+func getIdent(expr ast.Expr) *ast.Ident {
+ switch e := expr.(type) {
+ case *ast.Ident:
+ return e
+ case *ast.SelectorExpr:
+ return e.Sel
+ default:
+ return nil
+ }
+}
+
+// getConstantValue attempts to get the string value of a constant expression.
+func (s *SQLInjectionScanner) getConstantValue(expr ast.Expr) (string, bool) {
+ if expr == nil {
+ return "", false
+ }
+ if s.pass != nil && s.pass.TypesInfo != nil {
+ if ident := getIdent(expr); ident != nil {
+ if obj := s.pass.TypesInfo.ObjectOf(ident); obj != nil {
+ if c, ok := obj.(*types.Const); ok {
+ val := c.Val().ExactString()
+ // Remove quotes if it's a string constant
+ if strings.HasPrefix(val, "\"") && strings.HasSuffix(val, "\"") {
+ return val[1 : len(val)-1], true
+ }
+ return val, true
+ }
+ }
+ }
+ }
+ if ident, ok := expr.(*ast.Ident); ok {
+ if ident.Obj != nil && ident.Obj.Kind == ast.Con {
+ if vs, ok := ident.Obj.Decl.(*ast.ValueSpec); ok {
+ for i, name := range vs.Names {
+ if name.Name == ident.Name && i < len(vs.Values) {
+ if lit, ok := vs.Values[i].(*ast.BasicLit); ok && lit.Kind == token.STRING {
+ val := lit.Value
+ if strings.HasPrefix(val, "\"") && strings.HasSuffix(val, "\"") {
+ return val[1 : len(val)-1], true
+ }
+ return val, true
+ }
+ }
+ }
+ }
+ }
+ }
+ return "", false
+}
+
+// isTaintedVariable checks if a variable name suggests user input.
+func (s *SQLInjectionScanner) isTaintedVariable(name string) bool {
+ lowerName := strings.ToLower(name)
+ for _, pattern := range s.userInputPatterns {
+ if strings.Contains(lowerName, pattern) {
+ return true
+ }
+ }
+ return s.taintedVariables[name]
+}
+
+// containsTaintedVariable checks if an expression contains tainted variables.
+func (s *SQLInjectionScanner) containsTaintedVariable(expr ast.Expr) bool {
+ hasTainted := false
+
+ ast.Inspect(expr, func(n ast.Node) bool {
+ if ident, ok := n.(*ast.Ident); ok {
+ if s.isTaintedVariable(ident.Name) && !s.isConstant(ident) {
+ hasTainted = true
+ return false
+ }
+ }
+ return true
+ })
+
+ return hasTainted
+}
+
+// MarkVariableAsTainted marks a variable as containing user input.
+func (s *SQLInjectionScanner) MarkVariableAsTainted(name string) {
+ s.taintedVariables[name] = true
+}
+
+// isStmtMethod checks if a call is a method on a prepared statement (e.g., *sql.Stmt).
+func (s *SQLInjectionScanner) isStmtMethod(call *ast.CallExpr) bool {
+ if sel, ok := call.Fun.(*ast.SelectorExpr); ok {
+ if s.pass != nil && s.pass.TypesInfo != nil {
+ if selObj := s.pass.TypesInfo.Uses[sel.Sel]; selObj != nil {
+ if sig, ok := selObj.Type().(*types.Signature); ok {
+ if recv := sig.Recv(); recv != nil {
+ recvType := recv.Type().String()
+ if strings.Contains(recvType, "sql.Stmt") || strings.Contains(recvType, "sqlx.Stmt") || strings.Contains(recvType, "NamedStmt") {
+ return true
+ }
+ }
+ }
+ }
+ } else {
+ // Fallback heuristic: if the receiver is named "stmt", assume it's a statement
+ if ident, ok := sel.X.(*ast.Ident); ok {
+ name := strings.ToLower(ident.Name)
+ if strings.Contains(name, "stmt") {
+ return true
+ }
+ }
+ }
+ }
+ return false
+}
+
+// isParameterizedQuery checks if a call uses parameterized query syntax.
+// A parameterized query has a string literal or constant with placeholders (?, $1, :name, @param)
+// as the query argument, with subsequent arguments providing the values.
+func (s *SQLInjectionScanner) isParameterizedQuery(call *ast.CallExpr) bool {
+ methodName := s.getMethodName(call)
+ queryIdx := 0
+ // Context-aware methods usually have the query as the second argument
+ if strings.HasSuffix(methodName, "Context") {
+ queryIdx = 1
+ }
+
+ if len(call.Args) <= queryIdx+1 {
+ return false
+ }
+
+ // Query argument should be a string literal or constant
+ queryArg := call.Args[queryIdx]
+ var queryStr string
+ if lit, ok := queryArg.(*ast.BasicLit); ok && lit.Kind == token.STRING {
+ queryStr = lit.Value
+ } else if val, ok := s.getConstantValue(queryArg); ok {
+ queryStr = val
+ }
+
+ if queryStr == "" {
+ return false
+ }
+
+ // Check if the string contains placeholder patterns
+ return placeholderPattern.MatchString(queryStr)
+}
+
+// checkBinaryExpr checks string concatenation for SQL injection.
+func (s *SQLInjectionScanner) checkBinaryExpr(expr *ast.BinaryExpr) *SQLInjectionViolation {
+ if expr.Op != token.ADD {
+ return nil
+ }
+
+ // Check if this looks like SQL concatenation
+ if s.isSQLStringConcat(expr) && s.containsStringVariable(expr) {
+ return &SQLInjectionViolation{
+ Pos: expr.Pos(),
+ End: expr.End(),
+ Message: "potential SQL injection: string concatenation with SQL keywords - use parameterized queries",
+ Severity: SQLISeverityMedium,
+ VulnType: "concat",
+ }
+ }
+
+ return nil
+}
+
+// getMethodName extracts the method name from a call expression.
+func (s *SQLInjectionScanner) getMethodName(call *ast.CallExpr) string {
+ switch fun := call.Fun.(type) {
+ case *ast.SelectorExpr:
+ return fun.Sel.Name
+ case *ast.Ident:
+ return fun.Name
+ }
+ return ""
+}
+
+// isDangerousFormatCall checks if a call is to a dangerous format function.
+func (s *SQLInjectionScanner) isDangerousFormatCall(call *ast.CallExpr) bool {
+ sel, ok := call.Fun.(*ast.SelectorExpr)
+ if !ok {
+ return false
+ }
+
+ pkgIdent, ok := sel.X.(*ast.Ident)
+ if !ok {
+ return false
+ }
+
+ if funcs, ok := s.dangerousFuncs[pkgIdent.Name]; ok {
+ return funcs[sel.Sel.Name]
+ }
+
+ return false
+}
+
+// containsUserInput checks if a format call might contain user input.
+func (s *SQLInjectionScanner) containsUserInput(call *ast.CallExpr) bool {
+ if len(call.Args) < 2 {
+ return false
+ }
+
+ // Check if any argument is a variable (not a literal)
+ for i, arg := range call.Args {
+ if i == 0 {
+ // Skip format string
+ continue
+ }
+ // If argument is not a literal, it might be user input
+ if _, ok := arg.(*ast.BasicLit); !ok {
+ // Check if it's a constant (including exported constants from other packages)
+ if s.isConstant(arg) {
+ continue
+ }
+ return true
+ }
+ }
+
+ return false
+}
+
+// containsStringVariable checks if an expression contains string variables.
+func (s *SQLInjectionScanner) containsStringVariable(expr ast.Expr) bool {
+ hasVariable := false
+
+ ast.Inspect(expr, func(n ast.Node) bool {
+ switch node := n.(type) {
+ case *ast.Ident:
+ // Check if this is a variable (not a constant)
+ if s.isConstant(node) {
+ return true
+ }
+ if node.Obj != nil {
+ hasVariable = true
+ return false
+ }
+ case *ast.CallExpr:
+ // Function call results are considered dynamic
+ hasVariable = true
+ return false
+ }
+ return true
+ })
+
+ return hasVariable
+}
+
+// isSQLStringConcat checks if a binary expression looks like SQL concatenation.
+func (s *SQLInjectionScanner) isSQLStringConcat(expr *ast.BinaryExpr) bool {
+ // Check left operand
+ if s.isQueryString(expr.X) {
+ return true
+ }
+ // Check right operand
+ if s.isQueryString(expr.Y) {
+ return true
+ }
+ return false
+}
+
+// isQueryString checks if an expression looks like a SQL query string.
+func (s *SQLInjectionScanner) isQueryString(expr ast.Expr) bool {
+ var val string
+ if lit, ok := expr.(*ast.BasicLit); ok && lit.Kind == token.STRING {
+ val = lit.Value
+ } else if v, ok := s.getConstantValue(expr); ok {
+ val = v
+ }
+
+ if val == "" {
+ return false
+ }
+
+ value := strings.ToUpper(val)
+ return sqlPattern.MatchString(value)
+}
+
+// mightBeDynamicQuery checks if an identifier might be a dynamically built query.
+func (s *SQLInjectionScanner) mightBeDynamicQuery(ident *ast.Ident) bool {
+ name := strings.ToLower(ident.Name)
+ return strings.Contains(name, "query") ||
+ strings.Contains(name, "sql") ||
+ strings.Contains(name, "stmt")
+}
+
+// AnalyzeSQLInjection is a convenience function to run SQL injection scanning.
+func AnalyzeSQLInjection(pass *analysis.Pass, file *ast.File) {
+ scanner := NewSQLInjectionScanner()
+ violations := scanner.ScanFile(pass, file)
+
+ for _, v := range violations {
+ message := v.Message
+ if v.Suggestion != "" {
+ message += "\n Suggestion: " + v.Suggestion
+ }
+ if v.CodeFix != "" {
+ message += "\n Fix: " + v.CodeFix
+ }
+ if v.Severity != "" {
+ message = "[" + string(v.Severity) + "] " + message
+ }
+
+ pass.Report(analysis.Diagnostic{
+ Pos: v.Pos,
+ End: v.End,
+ Message: message,
+ })
+ }
+}
+
+// GetSQLInjectionViolations returns all SQL injection violations for external use.
+func GetSQLInjectionViolations(pass *analysis.Pass, file *ast.File) []SQLInjectionViolation {
+ scanner := NewSQLInjectionScanner()
+ return scanner.ScanFile(pass, file)
+}
+
+// ScanFileAST scans a file for SQL injection vulnerabilities without analysis.Pass.
+// This is designed for use in LSP server where we don't have a full analysis pass.
+func ScanFileAST(fset *token.FileSet, file *ast.File) []SQLInjectionViolation {
+ scanner := NewSQLInjectionScanner()
+ return scanner.ScanFileNoPass(fset, file)
+}
+
+// ScanFileNoPass scans a file for SQL injection vulnerabilities without analysis.Pass.
+// This is a method version for testing purposes.
+func (s *SQLInjectionScanner) ScanFileNoPass(fset *token.FileSet, file *ast.File) []SQLInjectionViolation {
+ s.pass = nil
+ var violations []SQLInjectionViolation
+
+ ast.Inspect(file, func(n ast.Node) bool {
+ switch node := n.(type) {
+ case *ast.CallExpr:
+ if v := s.checkCallExpr(node); v != nil {
+ violations = append(violations, *v)
+ }
+ case *ast.BinaryExpr:
+ if v := s.checkBinaryExpr(node); v != nil {
+ violations = append(violations, *v)
+ }
+ }
+ return true
+ })
+
+ return violations
+}
diff --git a/vendor/github.com/MirrexOne/unqueryvet/internal/analyzer/tx_leak_detector.go b/vendor/github.com/MirrexOne/unqueryvet/internal/analyzer/tx_leak_detector.go
new file mode 100644
index 0000000000..afa3b68a49
--- /dev/null
+++ b/vendor/github.com/MirrexOne/unqueryvet/internal/analyzer/tx_leak_detector.go
@@ -0,0 +1,1665 @@
+package analyzer
+
+import (
+ "fmt"
+ "go/ast"
+ "go/token"
+ "strings"
+
+ "golang.org/x/tools/go/analysis"
+)
+
+// TxLeakSeverity represents the severity level of a transaction leak.
+type TxLeakSeverity string
+
+const (
+ TxLeakSeverityCritical TxLeakSeverity = "critical" // Begin without any Commit/Rollback
+ TxLeakSeverityHigh TxLeakSeverity = "high" // Begin with Commit but no Rollback in error path
+ TxLeakSeverityMedium TxLeakSeverity = "medium" // Begin with Rollback but no Commit
+ TxLeakSeverityLow TxLeakSeverity = "low" // Informational - potential issue
+)
+
+// TxLeakViolation represents a detected unclosed transaction.
+type TxLeakViolation struct {
+ Pos token.Pos
+ End token.Pos
+ Message string
+ Severity TxLeakSeverity
+ ViolationType string // violation type identifier
+ TxVarName string // Name of the transaction variable
+ Suggestion string
+}
+
+// TxState tracks the state of a transaction variable within a function.
+type TxState struct {
+ VarName string
+ BeginPos token.Pos
+ BeginEnd token.Pos
+ HasCommit bool
+ HasRollback bool
+ HasDefer bool // Rollback/Commit in defer
+ HasDeferredCommit bool // Commit() is in defer - antipattern
+ IsReturned bool // Transaction returned to caller
+ IsReturnedInClosure bool // Transaction captured by returned closure
+ IsCallback bool // Transaction used in callback pattern
+ IsPassedToFunc bool // Transaction passed to another function
+ IsSentToChannel bool // Transaction sent through channel (ch <- tx)
+ IsStoredInStruct bool // Transaction stored in struct field
+ IsStoredInCollection bool // Transaction stored in map or slice
+ IsCapturedByGoroutine bool // Transaction captured by goroutine
+ IsShadowed bool // Variable is shadowed in inner scope
+ ShadowedBy token.Pos // Position where shadowing occurs
+ HasPanicPath bool // Function has panic() without deferred rollback
+ HasFatalPath bool // Function has os.Exit/log.Fatal without deferred rollback
+ HasEarlyReturn bool // Has return before commit without defer
+ CommitInConditional bool // Commit is inside conditional block
+ CommitInSwitch bool // Commit is inside switch/case that might not execute
+ CommitInSelect bool // Commit is inside select/case that might not execute
+ CommitInLoop bool // Commit is inside loop that might not iterate
+ IsReassigned bool // Transaction variable is reassigned
+ CommitErrorIgnored bool // Commit() error is ignored with blank identifier
+ RollbackErrorIgnored bool // Rollback() error is ignored with blank identifier
+ HasDeferInLoop bool // Transaction has defer inside a loop (antipattern)
+ Scope int // Scope depth where transaction was created
+}
+
+// TxLeakDetector detects unclosed SQL transactions.
+type TxLeakDetector struct {
+ // beginMethods are methods that start a transaction
+ beginMethods map[string]bool
+ // commitMethods are methods that commit a transaction
+ commitMethods map[string]bool
+ // rollbackMethods are methods that rollback a transaction
+ rollbackMethods map[string]bool
+ // callbackMethods are methods that handle tx lifecycle automatically
+ callbackMethods map[string]bool
+ // txStates tracks all transaction states in current function
+ txStates map[string]*TxState
+ // scopeDepth tracks current scope depth for shadowing detection
+ scopeDepth int
+ // txScopes maps variable names to their scope depths for shadowing detection
+ txScopes map[string][]int
+}
+
+// NewTxLeakDetector creates a new transaction leak detector.
+func NewTxLeakDetector() *TxLeakDetector {
+ return &TxLeakDetector{
+ beginMethods: map[string]bool{
+ // database/sql
+ "Begin": true,
+ "BeginTx": true,
+ // sqlx
+ "BeginTxx": true,
+ "Beginx": true,
+ "MustBegin": true,
+ "MustBeginTx": true,
+ // pgx
+ "BeginFunc": true, // callback pattern - also in callbackMethods
+ // bun
+ "RunInTx": true, // callback pattern - also in callbackMethods
+ // ent ORM
+ "Tx": true,
+ // General
+ "NewTx": true,
+ },
+ commitMethods: map[string]bool{
+ "Commit": true,
+ },
+ rollbackMethods: map[string]bool{
+ "Rollback": true,
+ },
+ callbackMethods: map[string]bool{
+ // These handle tx lifecycle automatically
+ "Transaction": true,
+ "RunInTransaction": true,
+ "BeginFunc": true,
+ "BeginTxFunc": true, // pgx conn.BeginTxFunc
+ "RunInTx": true,
+ "WithTx": true,
+ "InTransaction": true,
+ "Transactional": true,
+ "ExecTx": true,
+ "DoInTx": true,
+ },
+ txStates: make(map[string]*TxState),
+ txScopes: make(map[string][]int),
+ }
+}
+
+// CheckTxLeaks analyzes a file for unclosed transaction patterns.
+func (d *TxLeakDetector) CheckTxLeaks(pass *analysis.Pass, file *ast.File) []TxLeakViolation {
+ var violations []TxLeakViolation
+
+ // Analyze each function declaration
+ for _, decl := range file.Decls {
+ funcDecl, ok := decl.(*ast.FuncDecl)
+ if !ok || funcDecl.Body == nil {
+ continue
+ }
+
+ // Skip test functions (TestXxx, BenchmarkXxx, FuzzXxx, ExampleXxx)
+ if isTestFunction(funcDecl) {
+ continue
+ }
+
+ // Skip test helper functions (functions with *testing.T as first param)
+ if isTestHelperFunction(funcDecl) {
+ continue
+ }
+
+ violations = append(violations, d.analyzeFunction(funcDecl)...)
+ }
+
+ return violations
+}
+
+// isTestFunction checks if a function declaration is a test function.
+// A test function has a name starting with Test/Benchmark/Fuzz/Example AND
+// the appropriate parameter signature (or no params for Example).
+func isTestFunction(funcDecl *ast.FuncDecl) bool {
+ name := funcDecl.Name.Name
+
+ // Check for Example functions (no required parameters)
+ if strings.HasPrefix(name, "Example") {
+ return true
+ }
+
+ // Check for Test, Benchmark, Fuzz functions
+ isTestPrefix := strings.HasPrefix(name, "Test") ||
+ strings.HasPrefix(name, "Benchmark") ||
+ strings.HasPrefix(name, "Fuzz")
+
+ if !isTestPrefix {
+ return false
+ }
+
+ // Must have at least one parameter
+ if funcDecl.Type.Params == nil || len(funcDecl.Type.Params.List) == 0 {
+ return false
+ }
+
+ // Check first parameter type
+ firstParam := funcDecl.Type.Params.List[0]
+ if firstParam.Type == nil {
+ return false
+ }
+
+ // Check for *testing.T, *testing.B, *testing.F
+ starExpr, ok := firstParam.Type.(*ast.StarExpr)
+ if !ok {
+ return false
+ }
+
+ selExpr, ok := starExpr.X.(*ast.SelectorExpr)
+ if !ok {
+ return false
+ }
+
+ ident, ok := selExpr.X.(*ast.Ident)
+ if !ok {
+ return false
+ }
+
+ if ident.Name != "testing" {
+ return false
+ }
+
+ expectedType := ""
+ if strings.HasPrefix(name, "Test") {
+ expectedType = "T"
+ } else if strings.HasPrefix(name, "Benchmark") {
+ expectedType = "B"
+ } else if strings.HasPrefix(name, "Fuzz") {
+ expectedType = "F"
+ }
+
+ return selExpr.Sel.Name == expectedType
+}
+
+// isTestHelperFunction checks if a function is a test helper by looking at its parameters.
+// Test helpers typically take *testing.T, *testing.B, or *testing.F as the first parameter.
+func isTestHelperFunction(funcDecl *ast.FuncDecl) bool {
+ if funcDecl.Type.Params == nil || len(funcDecl.Type.Params.List) == 0 {
+ return false
+ }
+
+ // Check first parameter
+ firstParam := funcDecl.Type.Params.List[0]
+ if firstParam.Type == nil {
+ return false
+ }
+
+ // Check for *testing.T, *testing.B, *testing.F
+ starExpr, ok := firstParam.Type.(*ast.StarExpr)
+ if !ok {
+ return false
+ }
+
+ selExpr, ok := starExpr.X.(*ast.SelectorExpr)
+ if !ok {
+ return false
+ }
+
+ ident, ok := selExpr.X.(*ast.Ident)
+ if !ok {
+ return false
+ }
+
+ if ident.Name == "testing" {
+ switch selExpr.Sel.Name {
+ case "T", "B", "F", "M":
+ return true
+ }
+ }
+
+ return false
+}
+
+// analyzeFunction analyzes a single function for transaction leaks.
+func (d *TxLeakDetector) analyzeFunction(funcDecl *ast.FuncDecl) []TxLeakViolation {
+ // Reset state for each function
+ d.txStates = make(map[string]*TxState)
+ d.txScopes = make(map[string][]int)
+ d.scopeDepth = 0
+
+ // Phase 1: Find transaction Begin points with scope tracking
+ d.findTransactionBeginsWithScope(funcDecl)
+
+ if len(d.txStates) == 0 {
+ return nil
+ }
+
+ // Phase 2: Check for callback patterns (handled automatically)
+ d.detectCallbackPatterns(funcDecl)
+
+ // Phase 3: Track Commit/Rollback calls
+ d.trackCommitRollback(funcDecl)
+
+ // Phase 4: Check for returned transactions
+ d.checkReturnStatements(funcDecl)
+
+ // Phase 5: Check for transactions passed to other functions
+ d.checkFunctionParameters(funcDecl)
+
+ // Phase 6: Check for transactions stored in struct fields
+ d.checkStructFieldStorage(funcDecl)
+
+ // Phase 6.5: Check for transactions sent through channels
+ d.checkChannelSend(funcDecl)
+
+ // Phase 7: Check for goroutine captures
+ d.checkGoroutineCaptures(funcDecl)
+
+ // Phase 8: Check for panic paths without defer
+ d.checkPanicPaths(funcDecl)
+
+ // Phase 9: Check for early returns without defer
+ d.checkEarlyReturns(funcDecl)
+
+ // Phase 10: Check for conditional commits
+ d.checkConditionalCommits(funcDecl)
+
+ // Phase 11: Check for switch/case commits
+ d.checkSwitchCaseCommits(funcDecl)
+
+ // Phase 12: Check for select/case commits
+ d.checkSelectCaseCommits(funcDecl)
+
+ // Phase 13: Check for os.Exit/log.Fatal paths
+ d.checkFatalPaths(funcDecl)
+
+ // Phase 14: Check for commit in loops
+ d.checkLoopCommits(funcDecl)
+
+ // Phase 15: Check for variable reassignment
+ d.checkVariableReassignment(funcDecl)
+
+ // Phase 16: Check for ignored commit errors
+ d.checkCommitErrorIgnored(funcDecl)
+
+ // Phase 17: Check for ignored rollback errors
+ d.checkRollbackErrorIgnored(funcDecl)
+
+ // Phase 18: Check for defer inside loop (antipattern)
+ d.checkDeferInLoop(funcDecl)
+
+ // Phase 19: Generate violations
+ return d.generateViolations()
+}
+
+// findTransactionBeginsWithScope finds all transaction Begin calls with scope tracking.
+func (d *TxLeakDetector) findTransactionBeginsWithScope(funcDecl *ast.FuncDecl) {
+ // First pass: find all transaction begins and their scopes
+ d.findBeginsRecursive(funcDecl.Body, 0)
+}
+
+// findBeginsRecursive recursively finds Begin calls with scope tracking.
+func (d *TxLeakDetector) findBeginsRecursive(node ast.Node, depth int) {
+ if node == nil {
+ return
+ }
+
+ ast.Inspect(node, func(n ast.Node) bool {
+ switch stmt := n.(type) {
+ case *ast.BlockStmt:
+ // Process block with increased depth
+ for _, s := range stmt.List {
+ d.findBeginsRecursive(s, depth+1)
+ }
+ return false // Don't recurse further, we handled it
+
+ case *ast.IfStmt:
+ // Process if statement parts with proper scoping
+ // The if body creates a new scope
+ if stmt.Init != nil {
+ d.findBeginsRecursive(stmt.Init, depth)
+ }
+ d.findBeginsRecursive(stmt.Body, depth+1) // if body is a new scope
+ if stmt.Else != nil {
+ d.findBeginsRecursive(stmt.Else, depth+1) // else is also a new scope
+ }
+ return false
+
+ case *ast.ForStmt:
+ if stmt.Init != nil {
+ d.findBeginsRecursive(stmt.Init, depth)
+ }
+ d.findBeginsRecursive(stmt.Body, depth+1) // for body is a new scope
+ return false
+
+ case *ast.RangeStmt:
+ d.findBeginsRecursive(stmt.Body, depth+1) // range body is a new scope
+ return false
+
+ case *ast.AssignStmt:
+ d.processAssignmentWithDepth(stmt, depth)
+ return true
+ }
+ return true
+ })
+}
+
+// processAssignmentWithDepth processes an assignment with explicit depth.
+func (d *TxLeakDetector) processAssignmentWithDepth(assignStmt *ast.AssignStmt, depth int) {
+ for i, rhs := range assignStmt.Rhs {
+ call, ok := rhs.(*ast.CallExpr)
+ if !ok {
+ continue
+ }
+
+ if d.isBeginCall(call) {
+ // Skip if this is a callback pattern method
+ if d.isCallbackMethod(call) {
+ continue
+ }
+
+ // Extract variable name from LHS
+ if i < len(assignStmt.Lhs) {
+ if ident, ok := assignStmt.Lhs[i].(*ast.Ident); ok {
+ // Skip error variables
+ if ident.Name == "err" || ident.Name == "_" {
+ continue
+ }
+
+ varName := ident.Name
+
+ // Check for shadowing - if variable exists in outer scope
+ if existingScopes, exists := d.txScopes[varName]; exists {
+ for _, existingScope := range existingScopes {
+ if existingScope < depth {
+ // This is shadowing - mark the outer transaction
+ // Find the state for the outer variable
+ for key, state := range d.txStates {
+ if state.VarName == varName && state.Scope == existingScope {
+ state.IsShadowed = true
+ state.ShadowedBy = assignStmt.Pos()
+ _ = key // used in iteration
+ break
+ }
+ }
+ }
+ }
+ }
+
+ // Track scope for this variable
+ d.txScopes[varName] = append(d.txScopes[varName], depth)
+
+ // Create unique key for this transaction
+ key := d.createTxKey(varName, depth, assignStmt.Pos())
+ d.txStates[key] = &TxState{
+ VarName: varName,
+ BeginPos: assignStmt.Pos(),
+ BeginEnd: assignStmt.End(),
+ Scope: depth,
+ }
+ }
+ }
+ }
+ }
+}
+
+// createTxKey creates a unique key for a transaction state.
+func (d *TxLeakDetector) createTxKey(varName string, scope int, pos token.Pos) string {
+ // Use position to create unique key for shadowed variables
+ return fmt.Sprintf("%s_%d_%d", varName, scope, pos)
+}
+
+// isBeginCall checks if a call expression is a transaction Begin method.
+func (d *TxLeakDetector) isBeginCall(call *ast.CallExpr) bool {
+ sel, ok := call.Fun.(*ast.SelectorExpr)
+ if !ok {
+ return false
+ }
+ return d.beginMethods[sel.Sel.Name]
+}
+
+// isCallbackMethod checks if a call expression is a callback-based transaction method.
+func (d *TxLeakDetector) isCallbackMethod(call *ast.CallExpr) bool {
+ sel, ok := call.Fun.(*ast.SelectorExpr)
+ if !ok {
+ return false
+ }
+ return d.callbackMethods[sel.Sel.Name]
+}
+
+// detectCallbackPatterns marks transactions that are used in callback patterns.
+func (d *TxLeakDetector) detectCallbackPatterns(funcDecl *ast.FuncDecl) {
+ ast.Inspect(funcDecl.Body, func(n ast.Node) bool {
+ call, ok := n.(*ast.CallExpr)
+ if !ok {
+ return true
+ }
+
+ sel, ok := call.Fun.(*ast.SelectorExpr)
+ if !ok {
+ return true
+ }
+
+ // Check if this is a callback transaction method
+ if d.callbackMethods[sel.Sel.Name] {
+ // Mark any tx parameters in the callback as handled
+ for _, arg := range call.Args {
+ if funcLit, ok := arg.(*ast.FuncLit); ok {
+ // Check parameters of the callback function
+ for _, param := range funcLit.Type.Params.List {
+ for _, name := range param.Names {
+ d.markAllStatesWithName(name.Name, func(s *TxState) {
+ s.IsCallback = true
+ })
+ }
+ }
+ }
+ }
+ }
+
+ return true
+ })
+}
+
+// markAllStatesWithName applies a function to all states with the given variable name.
+func (d *TxLeakDetector) markAllStatesWithName(varName string, fn func(*TxState)) {
+ for _, state := range d.txStates {
+ if state.VarName == varName {
+ fn(state)
+ }
+ }
+}
+
+// trackCommitRollback scans for Commit and Rollback calls on tracked transaction variables.
+func (d *TxLeakDetector) trackCommitRollback(funcDecl *ast.FuncDecl) {
+ ast.Inspect(funcDecl.Body, func(n ast.Node) bool {
+ switch node := n.(type) {
+ case *ast.GoStmt:
+ // Skip goroutines - defers inside goroutines don't protect the main function
+ // We track goroutine captures separately in checkGoroutineCaptures
+ return false
+
+ case *ast.DeferStmt:
+ // Check defer statements
+ d.checkDeferStatement(node)
+ return true
+
+ case *ast.CallExpr:
+ // Check direct Commit/Rollback calls
+ d.checkCommitRollbackCall(node, false)
+ return true
+ }
+ return true
+ })
+}
+
+// checkDeferStatement checks a defer statement for Commit/Rollback calls.
+func (d *TxLeakDetector) checkDeferStatement(deferStmt *ast.DeferStmt) {
+ call := deferStmt.Call
+ // Check for direct defer tx.Rollback()
+ d.checkCommitRollbackCall(call, true)
+
+ // Check for defer func() { ... }()
+ if funcLit, ok := call.Fun.(*ast.FuncLit); ok {
+ d.checkDeferredClosure(funcLit)
+ }
+
+ // Check for defer someFunc(tx) - function call with tx as argument
+ d.checkDeferredFunctionCall(call)
+}
+
+// checkDeferredFunctionCall checks if a deferred function call takes a transaction as argument.
+// This handles patterns like: defer cleanup(tx) where cleanup() might do Rollback.
+func (d *TxLeakDetector) checkDeferredFunctionCall(call *ast.CallExpr) {
+ // Check each argument to see if it's a tracked transaction variable
+ for _, arg := range call.Args {
+ switch a := arg.(type) {
+ case *ast.Ident:
+ // Direct variable: defer cleanup(tx)
+ d.markAllStatesWithName(a.Name, func(s *TxState) {
+ s.HasDefer = true
+ // We assume the function handles rollback since tx is passed to deferred call
+ })
+ case *ast.UnaryExpr:
+ // Pointer: defer cleanup(&tx)
+ if ident, ok := a.X.(*ast.Ident); ok {
+ d.markAllStatesWithName(ident.Name, func(s *TxState) {
+ s.HasDefer = true
+ })
+ }
+ }
+ }
+}
+
+// checkDeferredClosure checks a deferred closure for Commit/Rollback calls.
+func (d *TxLeakDetector) checkDeferredClosure(funcLit *ast.FuncLit) {
+ ast.Inspect(funcLit.Body, func(n ast.Node) bool {
+ if call, ok := n.(*ast.CallExpr); ok {
+ d.checkCommitRollbackCall(call, true)
+ }
+ return true
+ })
+}
+
+// checkCommitRollbackCall checks if a call is Commit or Rollback on a tracked transaction.
+func (d *TxLeakDetector) checkCommitRollbackCall(call *ast.CallExpr, inDefer bool) {
+ sel, ok := call.Fun.(*ast.SelectorExpr)
+ if !ok {
+ return
+ }
+
+ methodName := sel.Sel.Name
+
+ // Get the variable name being called on
+ var varName string
+ if ident, ok := sel.X.(*ast.Ident); ok {
+ varName = ident.Name
+ }
+
+ if varName == "" {
+ return
+ }
+
+ // Mark all states with this variable name
+ d.markAllStatesWithName(varName, func(state *TxState) {
+ if d.commitMethods[methodName] {
+ state.HasCommit = true
+ // Deferred commit is an antipattern
+ if inDefer {
+ state.HasDeferredCommit = true
+ }
+ }
+
+ if d.rollbackMethods[methodName] {
+ state.HasRollback = true
+ if inDefer {
+ state.HasDefer = true
+ }
+ }
+ })
+}
+
+// checkReturnStatements checks if any transaction variable is returned.
+func (d *TxLeakDetector) checkReturnStatements(funcDecl *ast.FuncDecl) {
+ ast.Inspect(funcDecl.Body, func(n ast.Node) bool {
+ retStmt, ok := n.(*ast.ReturnStmt)
+ if !ok {
+ return true
+ }
+
+ for _, result := range retStmt.Results {
+ switch r := result.(type) {
+ case *ast.Ident:
+ d.markAllStatesWithName(r.Name, func(s *TxState) {
+ s.IsReturned = true
+ })
+ case *ast.UnaryExpr:
+ // Handle &tx case (returning pointer)
+ if ident, ok := r.X.(*ast.Ident); ok {
+ d.markAllStatesWithName(ident.Name, func(s *TxState) {
+ s.IsReturned = true
+ })
+ }
+ case *ast.FuncLit:
+ // Handle closure return: return func() { tx.Commit() }
+ // Check if closure captures any tracked tx variables
+ d.checkClosureCaptures(r)
+ }
+ }
+ return true
+ })
+}
+
+// checkClosureCaptures checks if a closure captures any tracked transaction variables.
+func (d *TxLeakDetector) checkClosureCaptures(funcLit *ast.FuncLit) {
+ ast.Inspect(funcLit.Body, func(inner ast.Node) bool {
+ if ident, ok := inner.(*ast.Ident); ok {
+ d.markAllStatesWithName(ident.Name, func(s *TxState) {
+ s.IsReturnedInClosure = true
+ })
+ }
+ return true
+ })
+}
+
+// checkFunctionParameters checks if transaction is passed to another function.
+func (d *TxLeakDetector) checkFunctionParameters(funcDecl *ast.FuncDecl) {
+ ast.Inspect(funcDecl.Body, func(n ast.Node) bool {
+ call, ok := n.(*ast.CallExpr)
+ if !ok {
+ return true
+ }
+
+ // Skip if this is a Commit/Rollback call
+ if sel, ok := call.Fun.(*ast.SelectorExpr); ok {
+ if d.commitMethods[sel.Sel.Name] || d.rollbackMethods[sel.Sel.Name] {
+ return true
+ }
+ }
+
+ // Check each argument
+ for _, arg := range call.Args {
+ switch a := arg.(type) {
+ case *ast.Ident:
+ d.markAllStatesWithName(a.Name, func(s *TxState) {
+ s.IsPassedToFunc = true
+ })
+ case *ast.UnaryExpr:
+ if ident, ok := a.X.(*ast.Ident); ok {
+ d.markAllStatesWithName(ident.Name, func(s *TxState) {
+ s.IsPassedToFunc = true
+ })
+ }
+ }
+ }
+ return true
+ })
+}
+
+// checkStructFieldStorage checks if transaction is stored in a struct field.
+func (d *TxLeakDetector) checkStructFieldStorage(funcDecl *ast.FuncDecl) {
+ ast.Inspect(funcDecl.Body, func(n ast.Node) bool {
+ assignStmt, ok := n.(*ast.AssignStmt)
+ if !ok {
+ return true
+ }
+
+ for i, lhs := range assignStmt.Lhs {
+ // Check for struct field assignment: s.tx = tx
+ if sel, ok := lhs.(*ast.SelectorExpr); ok {
+ _ = sel // We have a selector on the left side
+ if i < len(assignStmt.Rhs) {
+ if ident, ok := assignStmt.Rhs[i].(*ast.Ident); ok {
+ d.markAllStatesWithName(ident.Name, func(s *TxState) {
+ s.IsStoredInStruct = true
+ })
+ }
+ }
+ }
+
+ // Check for map/slice assignment: txMap[key] = tx or txSlice[i] = tx
+ if indexExpr, ok := lhs.(*ast.IndexExpr); ok {
+ _ = indexExpr
+ if i < len(assignStmt.Rhs) {
+ if ident, ok := assignStmt.Rhs[i].(*ast.Ident); ok {
+ d.markAllStatesWithName(ident.Name, func(s *TxState) {
+ s.IsStoredInCollection = true
+ })
+ }
+ }
+ }
+ }
+
+ // Check for append: txSlice = append(txSlice, tx)
+ for _, rhs := range assignStmt.Rhs {
+ if call, ok := rhs.(*ast.CallExpr); ok {
+ if ident, ok := call.Fun.(*ast.Ident); ok && ident.Name == "append" {
+ // Check arguments after the first one
+ for j := 1; j < len(call.Args); j++ {
+ if argIdent, ok := call.Args[j].(*ast.Ident); ok {
+ d.markAllStatesWithName(argIdent.Name, func(s *TxState) {
+ s.IsStoredInCollection = true
+ })
+ }
+ }
+ }
+ }
+ }
+
+ return true
+ })
+}
+
+// checkChannelSend checks if transaction is sent through a channel.
+func (d *TxLeakDetector) checkChannelSend(funcDecl *ast.FuncDecl) {
+ ast.Inspect(funcDecl.Body, func(n ast.Node) bool {
+ sendStmt, ok := n.(*ast.SendStmt)
+ if !ok {
+ return true
+ }
+
+ // Check if value being sent is a tracked transaction: ch <- tx
+ if ident, ok := sendStmt.Value.(*ast.Ident); ok {
+ d.markAllStatesWithName(ident.Name, func(s *TxState) {
+ s.IsSentToChannel = true
+ })
+ }
+
+ // Also check for pointer: ch <- &tx
+ if unary, ok := sendStmt.Value.(*ast.UnaryExpr); ok {
+ if ident, ok := unary.X.(*ast.Ident); ok {
+ d.markAllStatesWithName(ident.Name, func(s *TxState) {
+ s.IsSentToChannel = true
+ })
+ }
+ }
+
+ return true
+ })
+}
+
+// checkGoroutineCaptures checks if transaction is captured by a goroutine.
+func (d *TxLeakDetector) checkGoroutineCaptures(funcDecl *ast.FuncDecl) {
+ ast.Inspect(funcDecl.Body, func(n ast.Node) bool {
+ goStmt, ok := n.(*ast.GoStmt)
+ if !ok {
+ return true
+ }
+
+ // Check what variables the goroutine captures
+ ast.Inspect(goStmt.Call, func(inner ast.Node) bool {
+ if ident, ok := inner.(*ast.Ident); ok {
+ d.markAllStatesWithName(ident.Name, func(s *TxState) {
+ s.IsCapturedByGoroutine = true
+ })
+ }
+ return true
+ })
+
+ return true
+ })
+}
+
+// checkPanicPaths checks if function has panic() without deferred rollback.
+func (d *TxLeakDetector) checkPanicPaths(funcDecl *ast.FuncDecl) {
+ hasPanic := false
+ ast.Inspect(funcDecl.Body, func(n ast.Node) bool {
+ call, ok := n.(*ast.CallExpr)
+ if !ok {
+ return true
+ }
+
+ if ident, ok := call.Fun.(*ast.Ident); ok {
+ if ident.Name == "panic" {
+ hasPanic = true
+ }
+ }
+ return true
+ })
+
+ if hasPanic {
+ for _, state := range d.txStates {
+ if !state.HasDefer {
+ state.HasPanicPath = true
+ }
+ }
+ }
+}
+
+// checkEarlyReturns checks for early returns before commit without defer.
+func (d *TxLeakDetector) checkEarlyReturns(funcDecl *ast.FuncDecl) {
+ // Track position of each tx Begin
+ txPositions := make(map[string]token.Pos)
+ for name, state := range d.txStates {
+ txPositions[name] = state.BeginPos
+ }
+
+ var returnPositions []token.Pos
+ var commitPositions []token.Pos
+
+ ast.Inspect(funcDecl.Body, func(n ast.Node) bool {
+ switch node := n.(type) {
+ case *ast.ReturnStmt:
+ returnPositions = append(returnPositions, node.Pos())
+ case *ast.CallExpr:
+ if sel, ok := node.Fun.(*ast.SelectorExpr); ok {
+ if d.commitMethods[sel.Sel.Name] {
+ commitPositions = append(commitPositions, node.Pos())
+ }
+ }
+ }
+ return true
+ })
+
+ // Check if there are returns before any commit
+ for _, state := range d.txStates {
+ if state.HasDefer {
+ continue // Defer handles early returns
+ }
+
+ for _, retPos := range returnPositions {
+ // If return is after Begin but before Commit
+ hasCommitBefore := false
+ for _, commitPos := range commitPositions {
+ if commitPos < retPos {
+ hasCommitBefore = true
+ break
+ }
+ }
+ if retPos > state.BeginPos && !hasCommitBefore {
+ state.HasEarlyReturn = true
+ break
+ }
+ }
+ }
+}
+
+// checkSwitchCaseCommits checks if Commit is inside switch/case that might not execute.
+func (d *TxLeakDetector) checkSwitchCaseCommits(funcDecl *ast.FuncDecl) {
+ ast.Inspect(funcDecl.Body, func(n ast.Node) bool {
+ switchStmt, ok := n.(*ast.SwitchStmt)
+ if !ok {
+ return true
+ }
+
+ // Count cases with commit
+ casesWithCommit := 0
+ totalCases := 0
+ hasDefault := false
+
+ for _, stmt := range switchStmt.Body.List {
+ caseClause, ok := stmt.(*ast.CaseClause)
+ if !ok {
+ continue
+ }
+ totalCases++
+
+ if caseClause.List == nil {
+ hasDefault = true
+ }
+
+ hasCommitInCase := false
+ ast.Inspect(caseClause, func(inner ast.Node) bool {
+ if call, ok := inner.(*ast.CallExpr); ok {
+ if sel, ok := call.Fun.(*ast.SelectorExpr); ok {
+ if d.commitMethods[sel.Sel.Name] {
+ hasCommitInCase = true
+ }
+ }
+ }
+ return true
+ })
+
+ if hasCommitInCase {
+ casesWithCommit++
+ }
+ }
+
+ // If commit is not in all cases (including default), it's problematic
+ if casesWithCommit > 0 && (casesWithCommit < totalCases || !hasDefault) {
+ for _, state := range d.txStates {
+ if state.HasCommit && !state.HasDefer {
+ state.CommitInSwitch = true
+ }
+ }
+ }
+
+ return true
+ })
+}
+
+// checkSelectCaseCommits checks if Commit is inside select/case that might not execute.
+func (d *TxLeakDetector) checkSelectCaseCommits(funcDecl *ast.FuncDecl) {
+ ast.Inspect(funcDecl.Body, func(n ast.Node) bool {
+ selectStmt, ok := n.(*ast.SelectStmt)
+ if !ok {
+ return true
+ }
+
+ // Count cases with commit
+ casesWithCommit := 0
+ totalCases := 0
+ hasDefault := false
+
+ for _, stmt := range selectStmt.Body.List {
+ commClause, ok := stmt.(*ast.CommClause)
+ if !ok {
+ continue
+ }
+ totalCases++
+
+ if commClause.Comm == nil {
+ hasDefault = true
+ }
+
+ hasCommitInCase := false
+ for _, bodyStmt := range commClause.Body {
+ ast.Inspect(bodyStmt, func(inner ast.Node) bool {
+ if call, ok := inner.(*ast.CallExpr); ok {
+ if sel, ok := call.Fun.(*ast.SelectorExpr); ok {
+ if d.commitMethods[sel.Sel.Name] {
+ hasCommitInCase = true
+ }
+ }
+ }
+ return true
+ })
+ }
+
+ if hasCommitInCase {
+ casesWithCommit++
+ }
+ }
+
+ // If commit is not in all cases (including default), it's problematic
+ if casesWithCommit > 0 && (casesWithCommit < totalCases || !hasDefault) {
+ for _, state := range d.txStates {
+ if state.HasCommit && !state.HasDefer {
+ state.CommitInSelect = true
+ }
+ }
+ }
+
+ return true
+ })
+}
+
+// checkFatalPaths checks if function has os.Exit or log.Fatal without deferred rollback.
+func (d *TxLeakDetector) checkFatalPaths(funcDecl *ast.FuncDecl) {
+ hasFatal := false
+ ast.Inspect(funcDecl.Body, func(n ast.Node) bool {
+ call, ok := n.(*ast.CallExpr)
+ if !ok {
+ return true
+ }
+
+ // Check for os.Exit
+ if sel, ok := call.Fun.(*ast.SelectorExpr); ok {
+ if ident, ok := sel.X.(*ast.Ident); ok {
+ // os.Exit, log.Fatal, log.Fatalf, log.Fatalln
+ if (ident.Name == "os" && sel.Sel.Name == "Exit") ||
+ (ident.Name == "log" && strings.HasPrefix(sel.Sel.Name, "Fatal")) {
+ hasFatal = true
+ }
+ }
+ }
+
+ return true
+ })
+
+ if hasFatal {
+ for _, state := range d.txStates {
+ if !state.HasDefer {
+ state.HasFatalPath = true
+ }
+ }
+ }
+}
+
+// checkLoopCommits checks if Commit is inside a loop that might not iterate.
+func (d *TxLeakDetector) checkLoopCommits(funcDecl *ast.FuncDecl) {
+ ast.Inspect(funcDecl.Body, func(n ast.Node) bool {
+ var loopBody *ast.BlockStmt
+
+ switch stmt := n.(type) {
+ case *ast.ForStmt:
+ loopBody = stmt.Body
+ case *ast.RangeStmt:
+ loopBody = stmt.Body
+ default:
+ return true
+ }
+
+ if loopBody == nil {
+ return true
+ }
+
+ // Check if Commit is inside the loop body
+ hasCommitInLoop := false
+ ast.Inspect(loopBody, func(inner ast.Node) bool {
+ if call, ok := inner.(*ast.CallExpr); ok {
+ if sel, ok := call.Fun.(*ast.SelectorExpr); ok {
+ if d.commitMethods[sel.Sel.Name] {
+ hasCommitInLoop = true
+ }
+ }
+ }
+ return true
+ })
+
+ if hasCommitInLoop {
+ for _, state := range d.txStates {
+ if state.HasCommit && !state.HasDefer {
+ state.CommitInLoop = true
+ }
+ }
+ }
+
+ return true
+ })
+}
+
+// checkVariableReassignment checks if transaction variable is reassigned.
+func (d *TxLeakDetector) checkVariableReassignment(funcDecl *ast.FuncDecl) {
+ // Track all Begin calls per variable name
+ beginCounts := make(map[string]int)
+
+ ast.Inspect(funcDecl.Body, func(n ast.Node) bool {
+ assignStmt, ok := n.(*ast.AssignStmt)
+ if !ok {
+ return true
+ }
+
+ for i, rhs := range assignStmt.Rhs {
+ call, ok := rhs.(*ast.CallExpr)
+ if !ok {
+ continue
+ }
+
+ if d.isBeginCall(call) {
+ if i < len(assignStmt.Lhs) {
+ if ident, ok := assignStmt.Lhs[i].(*ast.Ident); ok {
+ if ident.Name != "err" && ident.Name != "_" {
+ beginCounts[ident.Name]++
+ }
+ }
+ }
+ }
+ }
+ return true
+ })
+
+ // Mark variables that have multiple Begin calls as reassigned
+ for varName, count := range beginCounts {
+ if count > 1 {
+ d.markAllStatesWithName(varName, func(s *TxState) {
+ s.IsReassigned = true
+ })
+ }
+ }
+}
+
+// checkCommitErrorIgnored checks if Commit() error is ignored with blank identifier.
+func (d *TxLeakDetector) checkCommitErrorIgnored(funcDecl *ast.FuncDecl) {
+ ast.Inspect(funcDecl.Body, func(n ast.Node) bool {
+ assignStmt, ok := n.(*ast.AssignStmt)
+ if !ok {
+ return true
+ }
+
+ // Look for: _ = tx.Commit() or result, _ := tx.Commit()
+ for i, rhs := range assignStmt.Rhs {
+ call, ok := rhs.(*ast.CallExpr)
+ if !ok {
+ continue
+ }
+
+ sel, ok := call.Fun.(*ast.SelectorExpr)
+ if !ok {
+ continue
+ }
+
+ if d.commitMethods[sel.Sel.Name] {
+ // Check if the error is ignored
+ // For single assignment: _ = tx.Commit()
+ if len(assignStmt.Lhs) == 1 {
+ if ident, ok := assignStmt.Lhs[0].(*ast.Ident); ok && ident.Name == "_" {
+ if varIdent, ok := sel.X.(*ast.Ident); ok {
+ d.markAllStatesWithName(varIdent.Name, func(s *TxState) {
+ s.CommitErrorIgnored = true
+ })
+ }
+ }
+ }
+ // For tuple assignment: result, _ := someFunc() - check if error position is _
+ if len(assignStmt.Lhs) > i+1 {
+ if ident, ok := assignStmt.Lhs[i+1].(*ast.Ident); ok && ident.Name == "_" {
+ if varIdent, ok := sel.X.(*ast.Ident); ok {
+ d.markAllStatesWithName(varIdent.Name, func(s *TxState) {
+ s.CommitErrorIgnored = true
+ })
+ }
+ }
+ }
+ }
+ }
+ return true
+ })
+}
+
+// checkRollbackErrorIgnored checks if Rollback() error is ignored with blank identifier.
+func (d *TxLeakDetector) checkRollbackErrorIgnored(funcDecl *ast.FuncDecl) {
+ ast.Inspect(funcDecl.Body, func(n ast.Node) bool {
+ assignStmt, ok := n.(*ast.AssignStmt)
+ if !ok {
+ return true
+ }
+
+ // Look for: _ = tx.Rollback() or result, _ := tx.Rollback()
+ for i, rhs := range assignStmt.Rhs {
+ call, ok := rhs.(*ast.CallExpr)
+ if !ok {
+ continue
+ }
+
+ sel, ok := call.Fun.(*ast.SelectorExpr)
+ if !ok {
+ continue
+ }
+
+ if d.rollbackMethods[sel.Sel.Name] {
+ // Check if the error is ignored
+ // For single assignment: _ = tx.Rollback()
+ if len(assignStmt.Lhs) == 1 {
+ if ident, ok := assignStmt.Lhs[0].(*ast.Ident); ok && ident.Name == "_" {
+ if varIdent, ok := sel.X.(*ast.Ident); ok {
+ d.markAllStatesWithName(varIdent.Name, func(s *TxState) {
+ s.RollbackErrorIgnored = true
+ })
+ }
+ }
+ }
+ // For tuple assignment: result, _ := someFunc() - check if error position is _
+ if len(assignStmt.Lhs) > i+1 {
+ if ident, ok := assignStmt.Lhs[i+1].(*ast.Ident); ok && ident.Name == "_" {
+ if varIdent, ok := sel.X.(*ast.Ident); ok {
+ d.markAllStatesWithName(varIdent.Name, func(s *TxState) {
+ s.RollbackErrorIgnored = true
+ })
+ }
+ }
+ }
+ }
+ }
+ return true
+ })
+}
+
+// checkDeferInLoop checks if defer with transaction is inside a loop (antipattern).
+func (d *TxLeakDetector) checkDeferInLoop(funcDecl *ast.FuncDecl) {
+ // We need to track loop depth manually since ast.Inspect doesn't give us exit notification
+ var processNode func(n ast.Node, loopDepth int)
+ processNode = func(n ast.Node, loopDepth int) {
+ if n == nil {
+ return
+ }
+
+ switch node := n.(type) {
+ case *ast.ForStmt:
+ // Enter for loop - process body with increased depth
+ if node.Body != nil {
+ for _, stmt := range node.Body.List {
+ processNode(stmt, loopDepth+1)
+ }
+ }
+ case *ast.RangeStmt:
+ // Enter range loop - process body with increased depth
+ if node.Body != nil {
+ for _, stmt := range node.Body.List {
+ processNode(stmt, loopDepth+1)
+ }
+ }
+ case *ast.DeferStmt:
+ if loopDepth > 0 {
+ // Defer is inside a loop - check if it involves a tracked transaction
+ call := node.Call
+ if sel, ok := call.Fun.(*ast.SelectorExpr); ok {
+ if d.rollbackMethods[sel.Sel.Name] || d.commitMethods[sel.Sel.Name] {
+ if ident, ok := sel.X.(*ast.Ident); ok {
+ d.markAllStatesWithName(ident.Name, func(s *TxState) {
+ s.HasDeferInLoop = true
+ })
+ }
+ }
+ }
+ // Also check defer func() { tx.Rollback() }()
+ if funcLit, ok := call.Fun.(*ast.FuncLit); ok {
+ ast.Inspect(funcLit.Body, func(inner ast.Node) bool {
+ if innerCall, ok := inner.(*ast.CallExpr); ok {
+ if sel, ok := innerCall.Fun.(*ast.SelectorExpr); ok {
+ if d.rollbackMethods[sel.Sel.Name] || d.commitMethods[sel.Sel.Name] {
+ if ident, ok := sel.X.(*ast.Ident); ok {
+ d.markAllStatesWithName(ident.Name, func(s *TxState) {
+ s.HasDeferInLoop = true
+ })
+ }
+ }
+ }
+ }
+ return true
+ })
+ }
+ }
+ case *ast.BlockStmt:
+ for _, stmt := range node.List {
+ processNode(stmt, loopDepth)
+ }
+ case *ast.IfStmt:
+ if node.Init != nil {
+ processNode(node.Init, loopDepth)
+ }
+ processNode(node.Body, loopDepth)
+ if node.Else != nil {
+ processNode(node.Else, loopDepth)
+ }
+ case *ast.SwitchStmt:
+ processNode(node.Body, loopDepth)
+ case *ast.TypeSwitchStmt:
+ processNode(node.Body, loopDepth)
+ case *ast.SelectStmt:
+ processNode(node.Body, loopDepth)
+ case *ast.CaseClause:
+ for _, stmt := range node.Body {
+ processNode(stmt, loopDepth)
+ }
+ case *ast.CommClause:
+ for _, stmt := range node.Body {
+ processNode(stmt, loopDepth)
+ }
+ }
+ }
+
+ if funcDecl.Body != nil {
+ for _, stmt := range funcDecl.Body.List {
+ processNode(stmt, 0)
+ }
+ }
+}
+
+// checkConditionalCommits checks if Commit is inside a conditional block.
+func (d *TxLeakDetector) checkConditionalCommits(funcDecl *ast.FuncDecl) {
+ ast.Inspect(funcDecl.Body, func(n ast.Node) bool {
+ ifStmt, ok := n.(*ast.IfStmt)
+ if !ok {
+ return true
+ }
+
+ // Check if Commit is inside the if body
+ hasCommitInIf := false
+ ast.Inspect(ifStmt.Body, func(inner ast.Node) bool {
+ if call, ok := inner.(*ast.CallExpr); ok {
+ if sel, ok := call.Fun.(*ast.SelectorExpr); ok {
+ if d.commitMethods[sel.Sel.Name] {
+ hasCommitInIf = true
+ }
+ }
+ }
+ return true
+ })
+
+ // Check if Commit is NOT in else (meaning it might not execute)
+ hasCommitInElse := false
+ if ifStmt.Else != nil {
+ ast.Inspect(ifStmt.Else, func(inner ast.Node) bool {
+ if call, ok := inner.(*ast.CallExpr); ok {
+ if sel, ok := call.Fun.(*ast.SelectorExpr); ok {
+ if d.commitMethods[sel.Sel.Name] {
+ hasCommitInElse = true
+ }
+ }
+ }
+ return true
+ })
+ }
+
+ // If commit is only in one branch, it's conditional
+ if hasCommitInIf != hasCommitInElse {
+ for _, state := range d.txStates {
+ if state.HasCommit && !state.HasDefer {
+ state.CommitInConditional = true
+ }
+ }
+ }
+
+ return true
+ })
+}
+
+// generateViolations creates violations for unclosed transactions.
+func (d *TxLeakDetector) generateViolations() []TxLeakViolation {
+ var violations []TxLeakViolation
+
+ for _, state := range d.txStates {
+ // Skip if transaction is returned to caller
+ if state.IsReturned {
+ continue
+ }
+
+ // Skip if transaction is returned in a closure (lifecycle managed by caller)
+ if state.IsReturnedInClosure {
+ continue
+ }
+
+ // Skip if transaction is sent through a channel (lifecycle managed by receiver)
+ if state.IsSentToChannel {
+ continue
+ }
+
+ // Skip if using callback pattern
+ if state.IsCallback {
+ continue
+ }
+
+ // Skip if passed to another function (can't track inter-procedural)
+ // But warn if there's no defer as a safety net
+ if state.IsPassedToFunc && state.HasDefer {
+ continue
+ }
+
+ // Skip if stored in struct (can't track field lifecycle)
+ // But warn if there's no defer as a safety net
+ if state.IsStoredInStruct && state.HasDefer {
+ continue
+ }
+
+ // Skip if stored in collection (map/slice) with defer
+ // But warn if there's no defer as a safety net
+ if state.IsStoredInCollection && state.HasDefer {
+ continue
+ }
+
+ // Handle shadowing - this is always a problem
+ if state.IsShadowed {
+ violations = append(violations, TxLeakViolation{
+ Pos: state.BeginPos,
+ End: state.BeginEnd,
+ Message: "transaction " + state.VarName + " is shadowed by another transaction in inner scope",
+ Severity: TxLeakSeverityHigh,
+ ViolationType: "shadowed_transaction",
+ TxVarName: state.VarName,
+ Suggestion: "Use different variable names for nested transactions to avoid shadowing",
+ })
+ continue
+ }
+
+ // Handle goroutine capture - warn about potential issues
+ if state.IsCapturedByGoroutine && !state.HasDefer {
+ violations = append(violations, TxLeakViolation{
+ Pos: state.BeginPos,
+ End: state.BeginEnd,
+ Message: "transaction " + state.VarName + " is captured by goroutine without defer",
+ Severity: TxLeakSeverityHigh,
+ ViolationType: "goroutine_capture",
+ TxVarName: state.VarName,
+ Suggestion: "Ensure transaction is properly handled in goroutine with defer Rollback()",
+ })
+ continue
+ }
+
+ // Handle panic paths
+ if state.HasPanicPath && !state.HasDefer {
+ violations = append(violations, TxLeakViolation{
+ Pos: state.BeginPos,
+ End: state.BeginEnd,
+ Message: "transaction " + state.VarName + " may leak if panic() is called",
+ Severity: TxLeakSeverityMedium,
+ ViolationType: "panic_without_defer",
+ TxVarName: state.VarName,
+ Suggestion: "Add defer " + state.VarName + ".Rollback() to handle panic scenarios",
+ })
+ }
+
+ // Handle conditional commits
+ if state.CommitInConditional && !state.HasDefer {
+ violations = append(violations, TxLeakViolation{
+ Pos: state.BeginPos,
+ End: state.BeginEnd,
+ Message: "transaction " + state.VarName + " Commit() is inside conditional - may not execute",
+ Severity: TxLeakSeverityMedium,
+ ViolationType: "conditional_commit",
+ TxVarName: state.VarName,
+ Suggestion: "Ensure Commit() is called on all success paths or use defer pattern",
+ })
+ }
+
+ // Handle switch/case commits
+ if state.CommitInSwitch && !state.HasDefer {
+ violations = append(violations, TxLeakViolation{
+ Pos: state.BeginPos,
+ End: state.BeginEnd,
+ Message: "transaction " + state.VarName + " Commit() is inside switch/case - may not execute in all cases",
+ Severity: TxLeakSeverityMedium,
+ ViolationType: "commit_in_switch",
+ TxVarName: state.VarName,
+ Suggestion: "Ensure Commit() is called in all switch cases or use defer pattern",
+ })
+ }
+
+ // Handle select/case commits
+ if state.CommitInSelect && !state.HasDefer {
+ violations = append(violations, TxLeakViolation{
+ Pos: state.BeginPos,
+ End: state.BeginEnd,
+ Message: "transaction " + state.VarName + " Commit() is inside select/case - may not execute in all cases",
+ Severity: TxLeakSeverityMedium,
+ ViolationType: "commit_in_select",
+ TxVarName: state.VarName,
+ Suggestion: "Ensure Commit() is called in all select cases or use defer pattern",
+ })
+ }
+
+ // Handle fatal paths (os.Exit, log.Fatal)
+ if state.HasFatalPath && !state.HasDefer {
+ violations = append(violations, TxLeakViolation{
+ Pos: state.BeginPos,
+ End: state.BeginEnd,
+ Message: "transaction " + state.VarName + " may leak if os.Exit() or log.Fatal() is called",
+ Severity: TxLeakSeverityHigh,
+ ViolationType: "fatal_without_defer",
+ TxVarName: state.VarName,
+ Suggestion: "Add defer " + state.VarName + ".Rollback() to handle fatal exit scenarios (note: defers don't run on os.Exit)",
+ })
+ }
+
+ // Handle commit in loop
+ if state.CommitInLoop && !state.HasDefer {
+ violations = append(violations, TxLeakViolation{
+ Pos: state.BeginPos,
+ End: state.BeginEnd,
+ Message: "transaction " + state.VarName + " Commit() is inside loop - may not execute if loop doesn't iterate",
+ Severity: TxLeakSeverityMedium,
+ ViolationType: "commit_in_loop",
+ TxVarName: state.VarName,
+ Suggestion: "Move Commit() outside loop or ensure loop always iterates at least once",
+ })
+ }
+
+ // Handle variable reassignment
+ if state.IsReassigned {
+ violations = append(violations, TxLeakViolation{
+ Pos: state.BeginPos,
+ End: state.BeginEnd,
+ Message: "transaction variable " + state.VarName + " is reassigned - previous transaction may leak",
+ Severity: TxLeakSeverityHigh,
+ ViolationType: "variable_reassignment",
+ TxVarName: state.VarName,
+ Suggestion: "Commit or Rollback the first transaction before starting a new one, or use different variable names",
+ })
+ }
+
+ // Handle ignored commit error
+ if state.CommitErrorIgnored {
+ violations = append(violations, TxLeakViolation{
+ Pos: state.BeginPos,
+ End: state.BeginEnd,
+ Message: "transaction " + state.VarName + " Commit() error is ignored with blank identifier",
+ Severity: TxLeakSeverityLow,
+ ViolationType: "commit_error_ignored",
+ TxVarName: state.VarName,
+ Suggestion: "Handle the Commit() error - if it fails, the transaction is rolled back automatically",
+ })
+ }
+
+ // Handle deferred commit - antipattern
+ if state.HasDeferredCommit {
+ violations = append(violations, TxLeakViolation{
+ Pos: state.BeginPos,
+ End: state.BeginEnd,
+ Message: "transaction " + state.VarName + " uses defer Commit() - this is an antipattern",
+ Severity: TxLeakSeverityMedium,
+ ViolationType: "deferred_commit",
+ TxVarName: state.VarName,
+ Suggestion: "Use defer " + state.VarName + ".Rollback() and explicit Commit() at the end of the function",
+ })
+ }
+
+ // Handle ignored rollback error
+ if state.RollbackErrorIgnored {
+ violations = append(violations, TxLeakViolation{
+ Pos: state.BeginPos,
+ End: state.BeginEnd,
+ Message: "transaction " + state.VarName + " Rollback() error is ignored with blank identifier",
+ Severity: TxLeakSeverityLow,
+ ViolationType: "rollback_error_ignored",
+ TxVarName: state.VarName,
+ Suggestion: "Consider logging Rollback() errors for debugging - silent failures can hide issues",
+ })
+ }
+
+ // Handle defer inside loop - antipattern
+ if state.HasDeferInLoop {
+ violations = append(violations, TxLeakViolation{
+ Pos: state.BeginPos,
+ End: state.BeginEnd,
+ Message: "transaction " + state.VarName + " has defer inside loop - defers pile up until function returns",
+ Severity: TxLeakSeverityHigh,
+ ViolationType: "defer_in_loop",
+ TxVarName: state.VarName,
+ Suggestion: "Move transaction handling outside loop or use explicit Rollback()/Commit() in each iteration",
+ })
+ }
+
+ // Case 1: No Commit and no Rollback - Critical
+ if !state.HasCommit && !state.HasRollback {
+ msg := "unclosed transaction: " + state.VarName + " - missing both Commit() and Rollback()"
+ if state.IsPassedToFunc {
+ msg += " (passed to function - ensure it handles the transaction)"
+ }
+ if state.IsStoredInStruct {
+ msg += " (stored in struct - ensure lifecycle is managed)"
+ }
+
+ violations = append(violations, TxLeakViolation{
+ Pos: state.BeginPos,
+ End: state.BeginEnd,
+ Message: msg,
+ Severity: TxLeakSeverityCritical,
+ ViolationType: "no_commit_rollback",
+ TxVarName: state.VarName,
+ Suggestion: "Add defer " + state.VarName + ".Rollback() immediately after Begin(), then call Commit() on success",
+ })
+ continue
+ }
+
+ // Case 2: Has Commit but no Rollback - High
+ if state.HasCommit && !state.HasRollback {
+ violations = append(violations, TxLeakViolation{
+ Pos: state.BeginPos,
+ End: state.BeginEnd,
+ Message: "transaction " + state.VarName + " has Commit() but no Rollback() for error paths",
+ Severity: TxLeakSeverityHigh,
+ ViolationType: "no_rollback",
+ TxVarName: state.VarName,
+ Suggestion: "Add defer " + state.VarName + ".Rollback() to handle errors - it's safe to call after Commit()",
+ })
+ continue
+ }
+
+ // Case 3: Has Rollback but no Commit - Medium
+ if state.HasRollback && !state.HasCommit {
+ violations = append(violations, TxLeakViolation{
+ Pos: state.BeginPos,
+ End: state.BeginEnd,
+ Message: "transaction " + state.VarName + " has Rollback() but missing Commit()",
+ Severity: TxLeakSeverityMedium,
+ ViolationType: "no_commit",
+ TxVarName: state.VarName,
+ Suggestion: "Ensure Commit() is called on success path",
+ })
+ }
+
+ // Case 4: Early return without defer
+ if state.HasEarlyReturn && !state.HasDefer && state.HasCommit {
+ violations = append(violations, TxLeakViolation{
+ Pos: state.BeginPos,
+ End: state.BeginEnd,
+ Message: "transaction " + state.VarName + " has early return paths that bypass Commit()",
+ Severity: TxLeakSeverityHigh,
+ ViolationType: "early_return",
+ TxVarName: state.VarName,
+ Suggestion: "Add defer " + state.VarName + ".Rollback() to handle early returns safely",
+ })
+ }
+ }
+
+ return violations
+}
+
+// AnalyzeTxLeaks is a convenience function to run transaction leak detection on a file.
+func AnalyzeTxLeaks(pass *analysis.Pass, file *ast.File) {
+ detector := NewTxLeakDetector()
+ violations := detector.CheckTxLeaks(pass, file)
+
+ for _, v := range violations {
+ message := "[" + string(v.Severity) + "] " + v.Message
+ if v.Suggestion != "" {
+ message += "\n Suggestion: " + v.Suggestion
+ }
+
+ pass.Report(analysis.Diagnostic{
+ Pos: v.Pos,
+ End: v.End,
+ Message: message,
+ })
+ }
+}
+
+// GetTxLeakViolations returns all transaction leak violations for external use.
+func GetTxLeakViolations(pass *analysis.Pass, file *ast.File) []TxLeakViolation {
+ detector := NewTxLeakDetector()
+ return detector.CheckTxLeaks(pass, file)
+}
+
+// DetectTxLeaksInAST detects transaction leak problems in an AST file without analysis.Pass.
+// This is designed for use in LSP server where we don't have a full analysis pass.
+func DetectTxLeaksInAST(fset *token.FileSet, file *ast.File) []TxLeakViolation {
+ detector := NewTxLeakDetector()
+ var violations []TxLeakViolation
+
+ // Analyze each function declaration
+ for _, decl := range file.Decls {
+ funcDecl, ok := decl.(*ast.FuncDecl)
+ if !ok || funcDecl.Body == nil {
+ continue
+ }
+
+ // Skip test functions (TestXxx, BenchmarkXxx, FuzzXxx, ExampleXxx)
+ if isTestFunction(funcDecl) {
+ continue
+ }
+
+ // Skip test helper functions (functions with *testing.T as first param)
+ if isTestHelperFunction(funcDecl) {
+ continue
+ }
+
+ violations = append(violations, detector.analyzeFunction(funcDecl)...)
+ }
+
+ return violations
+}
diff --git a/vendor/github.com/MirrexOne/unqueryvet/pkg/config/config.go b/vendor/github.com/MirrexOne/unqueryvet/pkg/config/config.go
new file mode 100644
index 0000000000..06b564f126
--- /dev/null
+++ b/vendor/github.com/MirrexOne/unqueryvet/pkg/config/config.go
@@ -0,0 +1,187 @@
+// Package config provides configuration structures for Unqueryvet analyzer.
+package config
+
+// CustomRule represents a user-defined DSL rule for SQL analysis.
+type CustomRule struct {
+ // ID is a unique identifier for the rule.
+ ID string `mapstructure:"id" json:"id" yaml:"id"`
+
+ // Pattern is the SQL or code pattern to match.
+ // Supports metavariables like $TABLE, $VAR, etc.
+ Pattern string `mapstructure:"pattern" json:"pattern" yaml:"pattern"`
+
+ // Patterns allows multiple patterns for a single rule.
+ Patterns []string `mapstructure:"patterns" json:"patterns" yaml:"patterns,omitempty"`
+
+ // When is an optional condition expression (evaluated with expr-lang).
+ // Available variables: file, package, function, query, table, in_loop, etc.
+ When string `mapstructure:"when" json:"when" yaml:"when,omitempty"`
+
+ // Message is the diagnostic message shown when the rule triggers.
+ Message string `mapstructure:"message" json:"message" yaml:"message,omitempty"`
+
+ // Severity is the severity level (error, warning, info, ignore).
+ Severity string `mapstructure:"severity" json:"severity" yaml:"severity,omitempty"`
+
+ // Action determines what to do when the pattern matches (report, allow, ignore).
+ Action string `mapstructure:"action" json:"action" yaml:"action,omitempty"`
+
+ // Fix is an optional suggested fix message.
+ Fix string `mapstructure:"fix" json:"fix" yaml:"fix,omitempty"`
+}
+
+// RuleSeverity maps built-in rule IDs to their severity levels.
+type RuleSeverity map[string]string
+
+// UnqueryvetSettings holds the configuration for the Unqueryvet analyzer.
+type UnqueryvetSettings struct {
+ // CheckSQLBuilders enables checking SQL builders like Squirrel for SELECT * usage
+ CheckSQLBuilders bool `mapstructure:"check-sql-builders" json:"check-sql-builders" yaml:"check-sql-builders"`
+
+ // AllowedPatterns is a list of regex patterns that are allowed to use SELECT *
+ // Example: ["SELECT \\* FROM temp_.*", "SELECT \\* FROM .*_backup"]
+ AllowedPatterns []string `mapstructure:"allowed-patterns" json:"allowed-patterns" yaml:"allowed-patterns"`
+
+ // IgnoredFunctions is a list of function name patterns to ignore
+ // Example: ["debug.Query", "test.*", "mock.*"]
+ IgnoredFunctions []string `mapstructure:"ignored-functions" json:"ignored-functions" yaml:"ignored-functions"`
+
+ // IgnoredFiles is a list of glob patterns for files to ignore
+ // Example: ["*_test.go", "testdata/**", "mock_*.go"]
+ IgnoredFiles []string `mapstructure:"ignored-files" json:"ignored-files" yaml:"ignored-files"`
+
+ // Severity defines the diagnostic severity: "error" or "warning" (default: "warning")
+ Severity string `mapstructure:"severity" json:"severity" yaml:"severity"`
+
+ // CheckAliasedWildcard enables detection of SELECT alias.* patterns (e.g., SELECT t.* FROM users t)
+ CheckAliasedWildcard bool `mapstructure:"check-aliased-wildcard" json:"check-aliased-wildcard" yaml:"check-aliased-wildcard"`
+
+ // CheckStringConcat enables detection of SELECT * in string concatenation (e.g., "SELECT * " + "FROM users")
+ CheckStringConcat bool `mapstructure:"check-string-concat" json:"check-string-concat" yaml:"check-string-concat"`
+
+ // CheckFormatStrings enables detection of SELECT * in format functions (e.g., fmt.Sprintf)
+ CheckFormatStrings bool `mapstructure:"check-format-strings" json:"check-format-strings" yaml:"check-format-strings"`
+
+ // CheckStringBuilder enables detection of SELECT * in strings.Builder usage
+ CheckStringBuilder bool `mapstructure:"check-string-builder" json:"check-string-builder" yaml:"check-string-builder"`
+
+ // CheckSubqueries enables detection of SELECT * in subqueries (e.g., SELECT * FROM (SELECT * FROM ...))
+ CheckSubqueries bool `mapstructure:"check-subqueries" json:"check-subqueries" yaml:"check-subqueries"`
+
+ // SQLBuilders defines which SQL builder libraries to check
+ SQLBuilders SQLBuildersConfig `mapstructure:"sql-builders" json:"sql-builders" yaml:"sql-builders"`
+
+ // Rules is a map of built-in rule IDs to their severity (error, warning, info, ignore).
+ // Example: {"select-star": "error", "n1-queries": "warning"}
+ Rules RuleSeverity `mapstructure:"rules" json:"rules" yaml:"rules,omitempty"`
+
+ // CustomRules is a list of user-defined DSL rules.
+ CustomRules []CustomRule `mapstructure:"custom-rules" json:"custom-rules" yaml:"custom-rules,omitempty"`
+
+ // Allow is a list of SQL patterns to allow (whitelist).
+ // These patterns will not trigger any warnings.
+ Allow []string `mapstructure:"allow" json:"allow" yaml:"allow,omitempty"`
+
+ // Ignore is a list of file patterns to ignore (in addition to IgnoredFiles).
+ Ignore []string `mapstructure:"ignore" json:"ignore" yaml:"ignore,omitempty"`
+
+ // N1DetectionEnabled global flag for N+1 detection
+ N1DetectionEnabled bool `mapstructure:"check-n1-queries" json:"check-n1-queries" yaml:"check-n1-queries,omitempty"`
+
+ // SQLInjectionDetectionEnabled global flag for SQL injection detection
+ SQLInjectionDetectionEnabled bool `mapstructure:"check-sql-injection" json:"check-sql-injection" yaml:"check-sql-injection,omitempty"`
+
+ // TxLeakDetectionEnabled global flag for unclosed transaction detection
+ TxLeakDetectionEnabled bool `mapstructure:"check-tx-leaks" json:"check-tx-leaks" yaml:"check-tx-leaks,omitempty"`
+}
+
+// SQLBuildersConfig defines which SQL builder libraries to analyze.
+type SQLBuildersConfig struct {
+ // Squirrel enables checking github.com/Masterminds/squirrel
+ Squirrel bool `mapstructure:"squirrel" json:"squirrel" yaml:"squirrel"`
+
+ // GORM enables checking gorm.io/gorm
+ GORM bool `mapstructure:"gorm" json:"gorm" yaml:"gorm"`
+
+ // SQLx enables checking github.com/jmoiron/sqlx
+ SQLx bool `mapstructure:"sqlx" json:"sqlx" yaml:"sqlx"`
+
+ // Ent enables checking entgo.io/ent
+ Ent bool `mapstructure:"ent" json:"ent" yaml:"ent"`
+
+ // PGX enables checking github.com/jackc/pgx
+ PGX bool `mapstructure:"pgx" json:"pgx" yaml:"pgx"`
+
+ // Bun enables checking github.com/uptrace/bun
+ Bun bool `mapstructure:"bun" json:"bun" yaml:"bun"`
+
+ // SQLBoiler enables checking github.com/volatiletech/sqlboiler
+ SQLBoiler bool `mapstructure:"sqlboiler" json:"sqlboiler" yaml:"sqlboiler"`
+
+ // Jet enables checking github.com/go-jet/jet
+ Jet bool `mapstructure:"jet" json:"jet" yaml:"jet"`
+
+ // Sqlc enables checking github.com/sqlc-dev/sqlc generated code
+ Sqlc bool `mapstructure:"sqlc" json:"sqlc" yaml:"sqlc"`
+
+ // Goqu enables checking github.com/doug-martin/goqu
+ Goqu bool `mapstructure:"goqu" json:"goqu" yaml:"goqu"`
+
+ // Rel enables checking github.com/go-rel/rel
+ Rel bool `mapstructure:"rel" json:"rel" yaml:"rel"`
+
+ // Reform enables checking gopkg.in/reform.v1
+ Reform bool `mapstructure:"reform" json:"reform" yaml:"reform"`
+}
+
+// DefaultSQLBuildersConfig returns the default SQL builders configuration with all checkers enabled.
+func DefaultSQLBuildersConfig() SQLBuildersConfig {
+ return SQLBuildersConfig{
+ Squirrel: true,
+ GORM: true,
+ SQLx: true,
+ Ent: true,
+ PGX: true,
+ Bun: true,
+ SQLBoiler: true,
+ Jet: true,
+ Sqlc: true,
+ Goqu: true,
+ Rel: true,
+ Reform: true,
+ }
+}
+
+// DefaultSettings returns the default configuration for unqueryvet.
+// By default, all detection features are enabled for maximum coverage.
+func DefaultSettings() UnqueryvetSettings {
+ return UnqueryvetSettings{
+ CheckSQLBuilders: true,
+ CheckAliasedWildcard: true,
+ CheckStringConcat: true,
+ CheckFormatStrings: true,
+ CheckStringBuilder: true,
+ CheckSubqueries: true,
+ N1DetectionEnabled: true,
+ SQLInjectionDetectionEnabled: true,
+ TxLeakDetectionEnabled: true,
+ Severity: "warning",
+ AllowedPatterns: []string{
+ `(?i)COUNT\(\s*\*\s*\)`,
+ `(?i)MAX\(\s*\*\s*\)`,
+ `(?i)MIN\(\s*\*\s*\)`,
+ `(?i)SELECT \* FROM information_schema\..*`,
+ `(?i)SELECT \* FROM pg_catalog\..*`,
+ `(?i)SELECT \* FROM sys\..*`,
+ },
+ IgnoredFunctions: []string{},
+ IgnoredFiles: []string{},
+ SQLBuilders: DefaultSQLBuildersConfig(),
+ Rules: RuleSeverity{
+ "select-star": "warning",
+ "n1-queries": "warning",
+ "sql-injection": "error",
+ "tx-leak": "warning",
+ },
+ }
+}
diff --git a/vendor/github.com/MirrexOne/unqueryvet/schema.json b/vendor/github.com/MirrexOne/unqueryvet/schema.json
new file mode 100644
index 0000000000..f4df7b18a1
--- /dev/null
+++ b/vendor/github.com/MirrexOne/unqueryvet/schema.json
@@ -0,0 +1,270 @@
+{
+ "$schema": "http://json-schema.org/draft-07/schema#",
+ "$id": "https://raw.githubusercontent.com/MirrexOne/unqueryvet/main/schema.json",
+ "title": "unqueryvet configuration",
+ "description": "Configuration schema for unqueryvet - a Go static analysis tool for SQL queries",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "rules": {
+ "type": "object",
+ "description": "Built-in rules severity configuration",
+ "additionalProperties": false,
+ "properties": {
+ "select-star": {
+ "$ref": "#/definitions/severity",
+ "description": "Severity for SELECT * detection"
+ },
+ "n1-queries": {
+ "$ref": "#/definitions/severity",
+ "description": "Severity for N+1 query detection"
+ },
+ "sql-injection": {
+ "$ref": "#/definitions/severity",
+ "description": "Severity for SQL injection detection"
+ },
+ "tx-leak": {
+ "$ref": "#/definitions/severity",
+ "description": "Severity for transaction leak detection"
+ }
+ }
+ },
+ "ignore": {
+ "type": "array",
+ "description": "File patterns to ignore (glob syntax)",
+ "items": {
+ "type": "string"
+ },
+ "examples": [["*_test.go", "testdata/**", "vendor/**"]]
+ },
+ "allow": {
+ "type": "array",
+ "description": "SQL patterns to whitelist (won't trigger warnings)",
+ "items": {
+ "type": "string"
+ },
+ "examples": [["COUNT(*)", "information_schema.*"]]
+ },
+ "severity": {
+ "$ref": "#/definitions/severityLevel",
+ "description": "Default diagnostic severity: 'error' or 'warning'",
+ "default": "warning"
+ },
+ "check-sql-builders": {
+ "type": "boolean",
+ "description": "Enable SQL builder library checking",
+ "default": true
+ },
+ "check-aliased-wildcard": {
+ "type": "boolean",
+ "description": "Enable aliased wildcard detection (e.g., SELECT t.*)",
+ "default": true
+ },
+ "check-string-concat": {
+ "type": "boolean",
+ "description": "Enable string concatenation analysis",
+ "default": true
+ },
+ "check-format-strings": {
+ "type": "boolean",
+ "description": "Enable format string analysis (e.g., fmt.Sprintf)",
+ "default": true
+ },
+ "check-string-builder": {
+ "type": "boolean",
+ "description": "Enable strings.Builder analysis",
+ "default": true
+ },
+ "check-subqueries": {
+ "type": "boolean",
+ "description": "Enable SELECT * detection in subqueries",
+ "default": true
+ },
+ "sql-builders": {
+ "type": "object",
+ "description": "SQL builder libraries to check",
+ "additionalProperties": false,
+ "properties": {
+ "squirrel": {
+ "type": "boolean",
+ "description": "Check github.com/Masterminds/squirrel",
+ "default": true
+ },
+ "gorm": {
+ "type": "boolean",
+ "description": "Check gorm.io/gorm",
+ "default": true
+ },
+ "sqlx": {
+ "type": "boolean",
+ "description": "Check github.com/jmoiron/sqlx",
+ "default": true
+ },
+ "ent": {
+ "type": "boolean",
+ "description": "Check entgo.io/ent",
+ "default": true
+ },
+ "pgx": {
+ "type": "boolean",
+ "description": "Check github.com/jackc/pgx",
+ "default": true
+ },
+ "bun": {
+ "type": "boolean",
+ "description": "Check github.com/uptrace/bun",
+ "default": true
+ },
+ "sqlboiler": {
+ "type": "boolean",
+ "description": "Check github.com/volatiletech/sqlboiler",
+ "default": true
+ },
+ "jet": {
+ "type": "boolean",
+ "description": "Check github.com/go-jet/jet",
+ "default": true
+ },
+ "sqlc": {
+ "type": "boolean",
+ "description": "Check sqlc generated code",
+ "default": true
+ },
+ "goqu": {
+ "type": "boolean",
+ "description": "Check github.com/doug-martin/goqu",
+ "default": true
+ },
+ "rel": {
+ "type": "boolean",
+ "description": "Check github.com/go-rel/rel",
+ "default": true
+ },
+ "reform": {
+ "type": "boolean",
+ "description": "Check gopkg.in/reform.v1",
+ "default": true
+ }
+ }
+ },
+ "ignored-files": {
+ "type": "array",
+ "description": "Legacy: File patterns to ignore (use 'ignore' instead)",
+ "items": {
+ "type": "string"
+ },
+ "deprecated": true
+ },
+ "ignored-functions": {
+ "type": "array",
+ "description": "Function patterns to ignore (regex)",
+ "items": {
+ "type": "string"
+ },
+ "examples": [["debug\\..*", "test.*"]]
+ },
+ "allowed-patterns": {
+ "type": "array",
+ "description": "Legacy: Regex patterns to allow (use 'allow' instead)",
+ "items": {
+ "type": "string"
+ },
+ "deprecated": true
+ },
+ "custom-rules": {
+ "type": "array",
+ "description": "Custom analysis rules using DSL",
+ "items": {
+ "$ref": "#/definitions/customRule"
+ }
+ },
+ "output": {
+ "type": "object",
+ "description": "Output configuration options",
+ "additionalProperties": false,
+ "properties": {
+ "format": {
+ "type": "string",
+ "enum": ["text", "json", "sarif"],
+ "description": "Output format",
+ "default": "text"
+ },
+ "color": {
+ "type": "string",
+ "enum": ["auto", "always", "never"],
+ "description": "Color output mode",
+ "default": "auto"
+ },
+ "verbose": {
+ "type": "boolean",
+ "description": "Enable verbose output",
+ "default": false
+ },
+ "quiet": {
+ "type": "boolean",
+ "description": "Quiet mode (only errors)",
+ "default": false
+ }
+ }
+ }
+ },
+ "definitions": {
+ "severity": {
+ "type": "string",
+ "enum": ["error", "warning", "info", "ignore"],
+ "description": "Severity level for a rule"
+ },
+ "severityLevel": {
+ "type": "string",
+ "enum": ["error", "warning"],
+ "description": "Default severity level"
+ },
+ "customRule": {
+ "type": "object",
+ "description": "Custom analysis rule definition",
+ "required": ["id"],
+ "additionalProperties": false,
+ "properties": {
+ "id": {
+ "type": "string",
+ "description": "Unique identifier for the rule",
+ "pattern": "^[a-z][a-z0-9-]*$"
+ },
+ "pattern": {
+ "type": "string",
+ "description": "SQL/code pattern to match (supports metavariables: $TABLE, $VAR, $QUERY, $COLS, $DB, $EXPR)"
+ },
+ "patterns": {
+ "type": "array",
+ "description": "Multiple patterns (any match triggers the rule)",
+ "items": {
+ "type": "string"
+ }
+ },
+ "when": {
+ "type": "string",
+ "description": "Condition expression using expr-lang syntax. Available variables: file, package, function, query, query_type, table, tables, columns, has_join, has_where, in_loop, loop_depth, builder"
+ },
+ "message": {
+ "type": "string",
+ "description": "Diagnostic message to display when rule matches"
+ },
+ "severity": {
+ "$ref": "#/definitions/severity",
+ "description": "Severity level for this rule"
+ },
+ "action": {
+ "type": "string",
+ "enum": ["report", "allow", "ignore"],
+ "description": "Action to take when rule matches",
+ "default": "report"
+ },
+ "fix": {
+ "type": "string",
+ "description": "Suggested fix message"
+ }
+ },
+ "oneOf": [{ "required": ["pattern"] }, { "required": ["patterns"] }]
+ }
+ }
+}
diff --git a/vendor/github.com/alecthomas/chroma/v2/.editorconfig b/vendor/github.com/alecthomas/chroma/v2/.editorconfig
new file mode 100644
index 0000000000..cfb2c669e7
--- /dev/null
+++ b/vendor/github.com/alecthomas/chroma/v2/.editorconfig
@@ -0,0 +1,17 @@
+root = true
+
+[*]
+indent_style = tab
+end_of_line = lf
+charset = utf-8
+trim_trailing_whitespace = true
+insert_final_newline = true
+
+[*.xml]
+indent_style = space
+indent_size = 2
+insert_final_newline = false
+
+[*.yml]
+indent_style = space
+indent_size = 2
diff --git a/vendor/github.com/alecthomas/chroma/v2/.gitignore b/vendor/github.com/alecthomas/chroma/v2/.gitignore
new file mode 100644
index 0000000000..aedf83d998
--- /dev/null
+++ b/vendor/github.com/alecthomas/chroma/v2/.gitignore
@@ -0,0 +1,28 @@
+# Binaries for programs and plugins
+.git
+.idea
+.vscode
+.hermit
+*.exe
+*.dll
+*.so
+*.dylib
+/cmd/chroma/chroma
+
+# Test binary, build with `go test -c`
+*.test
+
+# Output of the go coverage tool, specifically when used with LiteIDE
+*.out
+
+# Project-local glide cache, RE: https://github.com/Masterminds/glide/issues/736
+.glide/
+
+_models/
+
+_examples/
+*.min.*
+build/
+
+cmd/chromad/static/chroma.wasm
+cmd/chromad/static/wasm_exec.js
diff --git a/vendor/github.com/alecthomas/chroma/v2/.golangci.yml b/vendor/github.com/alecthomas/chroma/v2/.golangci.yml
new file mode 100644
index 0000000000..a345ac652d
--- /dev/null
+++ b/vendor/github.com/alecthomas/chroma/v2/.golangci.yml
@@ -0,0 +1,122 @@
+version: "2"
+run:
+ tests: true
+output:
+ show-stats: false
+ formats:
+ text:
+ print-issued-lines: false
+ colors: true
+linters:
+ default: all
+ disable:
+ - exhaustive
+ - prealloc
+ - dupl
+ - godoclint
+ - cyclop
+ - depguard
+ - dupword
+ - err113
+ - errname
+ - errorlint
+ - exhaustruct
+ - forbidigo
+ - forcetypeassert
+ - funlen
+ - gochecknoglobals
+ - gocognit
+ - gocritic
+ - gocyclo
+ - godot
+ - godox
+ - gomoddirectives
+ - ireturn
+ - lll
+ - maintidx
+ - mnd
+ - nakedret
+ - nestif
+ - nilnil
+ - nlreturn
+ - nolintlint
+ - nonamedreturns
+ - paralleltest
+ - perfsprint
+ - predeclared
+ - recvcheck
+ - revive
+ - testpackage
+ - varnamelen
+ - wastedassign
+ - whitespace
+ - wsl
+ - wsl_v5
+ - funcorder
+ - noinlineerr
+ - tagalign
+ - goconst
+ - gochecknoinits
+ - durationcheck
+ - embeddedstructfieldcheck
+ - wrapcheck
+ - gomodguard
+ settings:
+ dupl:
+ threshold: 100
+ exhaustive:
+ default-signifies-exhaustive: true
+ goconst:
+ min-len: 8
+ min-occurrences: 3
+ gocyclo:
+ min-complexity: 10
+ wrapcheck:
+ report-internal-errors: false
+ ignore-package-globs:
+ - github.com/alecthomas/errors
+ exclusions:
+ generated: lax
+ rules:
+ - path: (.+)\.go$
+ text: "^(G104|G204|G307|G304):"
+ - path: (.+)\.go$
+ text: Error return value of .(.*\.Help|.*\.MarkFlagRequired|(os\.)?std(out|err)\..*|.*Close|.*Flush|os\.Remove(All)?|.*printf?|os\.(Un)?Setenv). is not checked
+ - path: (.+)\.go$
+ text: exported method `(.*\.MarshalJSON|.*\.UnmarshalJSON|.*\.EntityURN|.*\.GoString|.*\.Pos)` should have comment or be unexported
+ - path: (.+)\.go$
+ text: uses unkeyed fields
+ - path: (.+)\.go$
+ text: declaration of "err" shadows declaration
+ - path: (.+)\.go$
+ text: bad syntax for struct tag key
+ - path: (.+)\.go$
+ text: bad syntax for struct tag pair
+ - path: (.+)\.go$
+ text: ^ST1012
+ - path: (.+)\.go$
+ text: log/slog.Logger.*must not be called
+ - path: (.+)_test\.go$
+ text: error returned from external package is unwrapped
+ - linters: [staticcheck]
+ text: QF1008
+ - text: "Error return value of `.*.Write` is not checked"
+ linters: [errcheck]
+ path: (.+)_test\.go$
+ paths:
+ - third_party$
+ - builtin$
+ - examples$
+issues:
+ max-issues-per-linter: 0
+ max-same-issues: 0
+formatters:
+ enable:
+ - gofmt
+ - goimports
+ exclusions:
+ generated: lax
+ paths:
+ - third_party$
+ - builtin$
+ - examples$
diff --git a/vendor/github.com/alecthomas/chroma/v2/.goreleaser.yml b/vendor/github.com/alecthomas/chroma/v2/.goreleaser.yml
new file mode 100644
index 0000000000..f7c4f7d2df
--- /dev/null
+++ b/vendor/github.com/alecthomas/chroma/v2/.goreleaser.yml
@@ -0,0 +1,34 @@
+project_name: chroma
+release:
+ github:
+ owner: alecthomas
+ name: chroma
+brews:
+ - install: bin.install "chroma"
+env:
+ - CGO_ENABLED=0
+builds:
+ - goos:
+ - linux
+ - darwin
+ - windows
+ goarch:
+ - arm64
+ - amd64
+ - "386"
+ goarm:
+ - "6"
+ dir: ./cmd/chroma
+ main: .
+ ldflags: -s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{.Date}}
+ binary: chroma
+archives:
+ - format: tar.gz
+ name_template: "{{ .Binary }}-{{ .Version }}-{{ .Os }}-{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}"
+ files:
+ - COPYING
+ - README*
+snapshot:
+ name_template: SNAPSHOT-{{ .Commit }}
+checksum:
+ name_template: "{{ .ProjectName }}-{{ .Version }}-checksums.txt"
diff --git a/vendor/github.com/alecthomas/chroma/v2/AGENTS.md b/vendor/github.com/alecthomas/chroma/v2/AGENTS.md
new file mode 100644
index 0000000000..d15d770abc
--- /dev/null
+++ b/vendor/github.com/alecthomas/chroma/v2/AGENTS.md
@@ -0,0 +1,11 @@
+Chroma is a syntax highlighting library, tool and web playground for Go. It is based on Pygments and includes importers for it, so most of the same concepts from Pygments apply to Chroma.
+
+This project is written in Go, uses Hermit to manage tooling, and Just for helper commands. Helper tooling is primarily in ./_tools.
+
+Language definitions are XML files defined in ./lexers/embedded/*.xml.
+
+Styles/themes are defined in ./styles/*.xml.
+
+The CLI can be run with `chroma`.
+
+The web playground can be run with `chromad --csrf-key=moo`. It blocks, so should generally be run in the background. It also does not hot reload, so has to be manually restarted. The playground has two modes - for local development it uses the server itself to render, while for production running `just chromad` will compile ./cmd/libchromawasm into a WASM module that is bundled into `chromad`.
diff --git a/vendor/github.com/alecthomas/chroma/v2/BUILD.bit b/vendor/github.com/alecthomas/chroma/v2/BUILD.bit
new file mode 100644
index 0000000000..f8ee1aee09
--- /dev/null
+++ b/vendor/github.com/alecthomas/chroma/v2/BUILD.bit
@@ -0,0 +1,93 @@
+let version = exec("git describe --tags --dirty --always") | trim
+# TinyGo's installation root; used to source `wasm_exec.js`.
+let tinygoroot = exec("tinygo env TINYGOROOT") | trim
+
+
+# Generate tokentype_enumer.go from types.go via `//go:generate`.
+tokentype = go.generate {
+ package = "."
+ inputs = ["types.go"]
+ outputs = ["tokentype_enumer.go"]
+}
+
+# Regenerate the lexer table in README.md by invoking the host `chroma` binary.
+# GOOS/GOARCH are cleared so cross-compile env vars don't break the local run.
+protected readme = exec {
+ command = "./table.py"
+ inputs = ["table.py", "lexers/**/*.go", "lexers/**/*.xml"]
+ output = "README.md"
+}
+
+# Format frontend JS sources in place. Runs as a sub-step of `index-min-js`,
+# so bundling always sees formatted sources.
+format-js = exec {
+ command = "biome format --write cmd/chromad/static/index.js cmd/chromad/static/chroma.js"
+ inputs = ["biome.js", "cmd/chromad/static/index.js", "cmd/chromad/static/chroma.js"]
+}
+
+# Copy TinyGo's wasm_exec.js into the chromad static assets.
+wasm-exec = exec {
+ command = "install -m644 '#{tinygoroot}/targets/wasm_exec.js' cmd/chromad/static/wasm_exec.js"
+ resolve = "sha256 '#{tinygoroot}/targets/wasm_exec.js'"
+ output = "cmd/chromad/static/wasm_exec.js"
+}
+
+# Build the chroma WASM module via tinygo (installed via hermit) for the
+# smaller output binary.
+chroma-wasm = exec {
+ command = "tinygo build -no-debug -target wasm -o cmd/chromad/static/chroma.wasm cmd/libchromawasm/main.go"
+ inputs = ["cmd/libchromawasm/**/*.go", "*.go", "lexers/**/*.go", "lexers/**/*.xml", "formatters/**/*.go", "styles/**/*.go"]
+ output = "cmd/chromad/static/chroma.wasm"
+}
+
+# Bundle and minify the frontend JS. Depends on `format-js` so the bundle
+# always reflects formatted sources.
+index-min-js = exec {
+ command = "esbuild --platform=browser --format=esm --bundle cmd/chromad/static/index.js --minify --external:./wasm_exec.js --outfile=cmd/chromad/static/index.min.js"
+ inputs = ["cmd/chromad/static/index.js", "cmd/chromad/static/chroma.js"]
+ output = "cmd/chromad/static/index.min.js"
+ depends_on = [format-js]
+}
+
+# Bundle and minify the frontend CSS.
+index-min-css = exec {
+ command = "esbuild --bundle cmd/chromad/static/index.css --minify --outfile=cmd/chromad/static/index.min.css"
+ inputs = ["cmd/chromad/static/index.css", "cmd/chromad/static/bulma.css"]
+ output = "cmd/chromad/static/index.min.css"
+}
+
+# Build the chromad server binary. cmd/chromad is a separate Go module, so
+# `dir` puts the build in there and `package = "."` resolves against that
+# module. `output` stays project-root-relative; bit absolutises it before
+# passing to `go build -o`. Defaults to linux/amd64 to match the deploy
+# target; override with GOOS/GOARCH env vars for local builds.
+chromad = go.exe {
+ dir = "cmd/chromad"
+ package = "."
+ output = "build/chromad"
+ flags = ["-ldflags", "-X 'main.version=#{version}'"]
+ goos = env("GOOS", "linux")
+ goarch = env("GOARCH", "amd64")
+ cgo = false
+ depends_on = [wasm-exec, chroma-wasm, index-min-js, index-min-css, test]
+}
+
+pre format-go = go.fmt {
+ package = "./..."
+}
+
+# Run Go tests.
+test = go.test {
+ package = "./..."
+}
+
+# Deploy chromad to swapoff.org. Must be explicitly selected.
+explicit upload = exec {
+ command = <<-EOF
+ scp #{chromad.path} root@swapoff.org:
+ ssh root@swapoff.org 'install -m755 ./chromad /srv/http/swapoff.org/bin && service chromad restart'
+ EOF
+ depends_on = [chromad]
+}
+
+target default = [test, chromad, readme, tokentype]
diff --git a/vendor/github.com/alecthomas/chroma/v2/COPYING b/vendor/github.com/alecthomas/chroma/v2/COPYING
new file mode 100644
index 0000000000..33da489817
--- /dev/null
+++ b/vendor/github.com/alecthomas/chroma/v2/COPYING
@@ -0,0 +1,118 @@
+Copyright (C) 2017 Alec Thomas
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+of the Software, and to permit persons to whom the Software is furnished to do
+so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+
+
+// formatters/svg/font_liberation_mono.go
+
+Digitized data copyright (c) 2010 Google Corporation
+with Reserved Font Arimo, Tinos and Cousine.
+Copyright (c) 2012 Red Hat, Inc.
+with Reserved Font Name Liberation.
+
+This Font Software is licensed under the SIL Open Font License, Version 1.1.
+This license is copied below, and is also available with a FAQ at:
+https://openfontlicense.org
+
+-----------------------------------------------------------
+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
+-----------------------------------------------------------
+
+PREAMBLE
+The goals of the Open Font License (OFL) are to stimulate worldwide
+development of collaborative font projects, to support the font creation
+efforts of academic and linguistic communities, and to provide a free and
+open framework in which fonts may be shared and improved in partnership
+with others.
+
+The OFL allows the licensed fonts to be used, studied, modified and
+redistributed freely as long as they are not sold by themselves. The
+fonts, including any derivative works, can be bundled, embedded,
+redistributed and/or sold with any software provided that any reserved
+names are not used by derivative works. The fonts and derivatives,
+however, cannot be released under any other type of license. The
+requirement for fonts to remain under this license does not apply
+to any document created using the fonts or their derivatives.
+
+DEFINITIONS
+"Font Software" refers to the set of files released by the Copyright
+Holder(s) under this license and clearly marked as such. This may
+include source files, build scripts and documentation.
+
+"Reserved Font Name" refers to any names specified as such after the
+copyright statement(s).
+
+"Original Version" refers to the collection of Font Software components as
+distributed by the Copyright Holder(s).
+
+"Modified Version" refers to any derivative made by adding to, deleting,
+or substituting -- in part or in whole -- any of the components of the
+Original Version, by changing formats or by porting the Font Software to a
+new environment.
+
+"Author" refers to any designer, engineer, programmer, technical
+writer or other person who contributed to the Font Software.
+
+PERMISSION & CONDITIONS
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the Font Software, to use, study, copy, merge, embed, modify,
+redistribute, and sell modified and unmodified copies of the Font
+Software, subject to the following conditions:
+
+1) Neither the Font Software nor any of its individual components,
+in Original or Modified Versions, may be sold by itself.
+
+2) Original or Modified Versions of the Font Software may be bundled,
+redistributed and/or sold with any software, provided that each copy
+contains the above copyright notice and this license. These can be
+included either as stand-alone text files, human-readable headers or
+in the appropriate machine-readable metadata fields within text or
+binary files as long as those fields can be easily viewed by the user.
+
+3) No Modified Version of the Font Software may use the Reserved Font
+Name(s) unless explicit written permission is granted by the corresponding
+Copyright Holder. This restriction only applies to the primary font name as
+presented to the users.
+
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
+Software shall not be used to promote, endorse or advertise any
+Modified Version, except to acknowledge the contribution(s) of the
+Copyright Holder(s) and the Author(s) or with their explicit written
+permission.
+
+5) The Font Software, modified or unmodified, in part or in whole,
+must be distributed entirely under this license, and must not be
+distributed under any other license. The requirement for fonts to
+remain under this license does not apply to any document created
+using the Font Software.
+
+TERMINATION
+This license becomes null and void if any of the above conditions are
+not met.
+
+DISCLAIMER
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
+OTHER DEALINGS IN THE FONT SOFTWARE.
diff --git a/vendor/github.com/alecthomas/chroma/v2/Dockerfile b/vendor/github.com/alecthomas/chroma/v2/Dockerfile
new file mode 100644
index 0000000000..dc10ec753b
--- /dev/null
+++ b/vendor/github.com/alecthomas/chroma/v2/Dockerfile
@@ -0,0 +1,64 @@
+# Multi-stage Dockerfile for chromad Go application using Hermit-managed tools
+
+# Build stage
+FROM ubuntu:26.04 AS builder
+
+# Install system dependencies
+RUN apt-get update && apt-get install -y \
+ curl \
+ git \
+ ca-certificates \
+ && rm -rf /var/lib/apt/lists/*
+
+# Set working directory
+WORKDIR /app
+
+# Copy the entire project (including bin directory with Hermit tools)
+COPY . .
+
+# Make Hermit tools executable and add to PATH
+ENV PATH="/app/bin:${PATH}"
+
+# Set Go environment variables for static compilation
+ENV CGO_ENABLED=0
+ENV GOOS=linux
+ENV GOARCH=amd64
+
+# Build the application using just
+RUN just chromad
+
+# Runtime stage
+FROM alpine:3.24 AS runtime
+
+# Install ca-certificates for HTTPS requests
+RUN apk --no-cache add ca-certificates curl
+
+# Create a non-root user
+RUN addgroup -g 1001 chromad && \
+ adduser -D -s /bin/sh -u 1001 -G chromad chromad
+
+# Set working directory
+WORKDIR /app
+
+# Copy the binary from build stage
+COPY --from=builder /app/build/chromad /app/chromad
+
+# Change ownership to non-root user
+RUN chown chromad:chromad /app/chromad
+
+# Switch to non-root user
+USER chromad
+
+# Expose port (default is 8080, but can be overridden via PORT env var)
+EXPOSE 8080
+
+# Set default environment variables
+ENV PORT=8080
+ENV CHROMA_CSRF_KEY="testtest"
+
+# Health check
+HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
+ CMD curl -fsSL http://127.0.0.1:8080/ > /dev/null
+
+# Run the application
+CMD ["sh", "-c", "./chromad --csrf-key=$CHROMA_CSRF_KEY --bind=0.0.0.0:$PORT"]
diff --git a/vendor/github.com/alecthomas/chroma/v2/Justfile b/vendor/github.com/alecthomas/chroma/v2/Justfile
new file mode 100644
index 0000000000..4db3dc319c
--- /dev/null
+++ b/vendor/github.com/alecthomas/chroma/v2/Justfile
@@ -0,0 +1,59 @@
+set positional-arguments
+set shell := ["bash", "-c"]
+
+version := `git describe --tags --dirty --always`
+export GOOS := env("GOOS", "linux")
+export GOARCH := env("GOARCH", "amd64")
+
+_help:
+ @just -l
+
+# Generate README.md from lexer definitions
+readme:
+ #!/usr/bin/env bash
+ GOOS= GOARCH= ./table.py
+
+# Generate tokentype_string.go
+tokentype-string:
+ go generate
+
+# Format JavaScript files
+format-js:
+ biome format --write cmd/chromad/static/index.js cmd/chromad/static/chroma.js
+
+# Tidy Go modules
+tidy:
+ find . -name 'go.mod' -execdir go mod tidy \;
+
+# Build chromad binary
+chromad: wasm-exec chroma-wasm
+ #!/usr/bin/env bash
+ rm -rf build
+ mk cmd/chromad/static/index.min.js : cmd/chromad/static/{index,chroma}.js -- \
+ esbuild --platform=browser --format=esm --bundle cmd/chromad/static/index.js --minify --external:./wasm_exec.js --outfile=cmd/chromad/static/index.min.js
+ mk cmd/chromad/static/index.min.css : cmd/chromad/static/index.css -- \
+ esbuild --bundle cmd/chromad/static/index.css --minify --outfile=cmd/chromad/static/index.min.css
+ cd cmd/chromad && CGOENABLED=0 go build -ldflags="-X 'main.version={{ version }}'" -o ../../build/chromad .
+
+# Copy wasm_exec.js from TinyGo
+wasm-exec:
+ #!/usr/bin/env bash
+ tinygoroot=$(tinygo env TINYGOROOT)
+ mk cmd/chromad/static/wasm_exec.js : "$tinygoroot/targets/wasm_exec.js" -- \
+ install -m644 "$tinygoroot/targets/wasm_exec.js" cmd/chromad/static/wasm_exec.js
+
+# Build WASM binary
+chroma-wasm:
+ #!/usr/bin/env bash
+ if type tinygo > /dev/null 2>&1; then
+ mk cmd/chromad/static/chroma.wasm : cmd/libchromawasm/main.go -- \
+ tinygo build -no-debug -target wasm -o cmd/chromad/static/chroma.wasm cmd/libchromawasm/main.go
+ else
+ mk cmd/chromad/static/chroma.wasm : cmd/libchromawasm/main.go -- \
+ GOOS=js GOARCH=wasm go build -o cmd/chromad/static/chroma.wasm cmd/libchromawasm/main.go
+ fi
+
+# Upload chromad to server
+upload: chromad
+ scp build/chromad root@swapoff.org:
+ ssh root@swapoff.org 'install -m755 ./chromad /srv/http/swapoff.org/bin && service chromad restart'
diff --git a/vendor/github.com/alecthomas/chroma/v2/README.md b/vendor/github.com/alecthomas/chroma/v2/README.md
new file mode 100644
index 0000000000..df962da7be
--- /dev/null
+++ b/vendor/github.com/alecthomas/chroma/v2/README.md
@@ -0,0 +1,309 @@
+
+
+# A general purpose syntax highlighter in pure Go
+
+[](https://pkg.go.dev/github.com/alecthomas/chroma/v2) [](https://github.com/alecthomas/chroma/actions/workflows/ci.yml) [](https://invite.slack.golangbridge.org/)
+
+
+Chroma takes source code and other structured text and converts it into syntax
+highlighted HTML, ANSI-coloured text, etc.
+
+Chroma is based heavily on [Pygments](http://pygments.org/), and includes
+translators for Pygments lexers and styles.
+
+## Table of Contents
+
+
+
+1. [Supported languages](#supported-languages)
+2. [Try it](#try-it)
+3. [Using the library](#using-the-library)
+ 1. [Quick start](#quick-start)
+ 2. [Identifying the language](#identifying-the-language)
+ 3. [Formatting the output](#formatting-the-output)
+ 4. [The HTML formatter](#the-html-formatter)
+4. [More detail](#more-detail)
+ 1. [Lexers](#lexers)
+ 2. [Formatters](#formatters)
+ 3. [Styles](#styles)
+5. [Command-line interface](#command-line-interface)
+6. [Testing lexers](#testing-lexers)
+7. [What's missing compared to Pygments?](#whats-missing-compared-to-pygments)
+
+
+
+## Supported languages
+
+| Prefix | Language
+| :----: | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+| A | ABAP, ABNF, ActionScript, ActionScript 3, Ada, Agda, AL, Alloy, AMPL, Angular2, ANTLR, ApacheConf, APL, AppleScript, ArangoDB AQL, Arduino, ArmAsm, Arturo, ATL, AutoHotkey, AutoIt, Awk
+| B | Ballerina, Bash, Bash Session, Batchfile, Beef, BibTeX, Bicep, BlitzBasic, BNF, BQN, Brainfuck
+| C | C, C#, C++, C3, Caddyfile, Caddyfile Directives, Cap'n Proto, Cassandra CQL, Ceylon, CFEngine3, cfstatement, ChaiScript, Chapel, Cheetah, Clojure, CMake, COBOL, CoffeeScript, Common Lisp, Coq, Core, Crystal, CSS, CSV, CUE, Cython
+| D | D, Dart, Dax, Desktop file, Devicetree, Diff, Django/Jinja, dns, Docker, DTD, Dylan
+| E | EBNF, Elixir, Elm, EmacsLisp, ERB, Erlang
+| F | Factor, Fennel, Fish, Forth, Fortran, FortranFixed, FSharp
+| G | GAS, GDScript, GDScript3, Gemtext, Genshi, Genshi HTML, Genshi Text, Gettext, Gherkin, Gleam, GLSL, Gnuplot, Go, Go HTML Template, Go Template, Go Text Template, GraphQL, Groff, Groovy
+| H | Handlebars, Hare, Haskell, Haxe, HCL, Hexdump, HLB, HLSL, HolyC, HTML, HTTP, Hy
+| I | Idris, Igor, INI, Io, ISCdhcpd
+| J | J, Janet, Java, JavaScript, JSON, JSONata, Jsonnet, Julia, Jungle
+| K | Kakoune, KDL, Kotlin
+| L | Lateralus, Lean4, Lighttpd configuration file, LilyPond, LLVM, lox, Lua, Luau
+| M | Makefile, Mako, markdown, Markless, Mason, Materialize SQL dialect, Mathematica, Matlab, MCFunction, Meson, Metal, microcad, MiniZinc, MLIR, Modelica, Modula-2, Mojo, MonkeyC, MoonBit, MoonScript, MorrowindScript, Myghty, MySQL
+| N | NASM, Natural, NDISASM, Newspeak, Nginx configuration file, Nim, Nix, NSIS, Nu
+| O | Objective-C, ObjectPascal, OCaml, Octave, Odin, OnesEnterprise, OpenEdge ABL, OpenSCAD, Org Mode
+| P | PacmanConf, Perl, PHP, PHTML, Pig, PkgConfig, PL/pgSQL, plaintext, Plutus Core, Pony, PostgreSQL SQL dialect, PostScript, POVRay, PowerQuery, PowerShell, Prolog, Promela, PromQL, properties, Protocol Buffer, Protocol Buffer Text Format, PRQL, PSL, Puppet, Python, Python 2
+| Q | QBasic, QML
+| R | R, Racket, Ragel, Raku, react, ReasonML, reg, Rego, reStructuredText, Rexx, RGBDS Assembly, Ring, RPGLE, RPMSpec, Ruby, Rust
+| S | SAS, Sass, Scala, scdoc, Scheme, Scilab, SCSS, Sed, Sieve, Smali, Smalltalk, Smarty, SNBT, Snobol, Solidity, SourcePawn, Spade, SPARQL, SQL, SquidConf, Standard ML, stas, Stylus, Svelte, Swift, SYSTEMD, systemverilog
+| T | TableGen, Tal, TASM, Tcl, Tcsh, Termcap, Terminfo, Terraform, TeX, Thrift, TOML, TradingView, Transact-SQL, Turing, Turtle, Twig, TypeScript, TypoScript, TypoScriptCssData, TypoScriptHtmlData, Typst
+| U | ucode
+| V | V, V shell, Vala, VB.net, verilog, VHDL, VHS, VimL, vue
+| W | WDTE, WebAssembly Text Format, WebGPU Shading Language, WebVTT, Whiley
+| X | XML, Xorg
+| Y | YAML, YANG
+| Z | Z80 Assembly, Zed, Zig
+
+_I will attempt to keep this section up to date, but an authoritative list can be
+displayed with `chroma --list`._
+
+## Try it
+
+Try out various languages and styles on the [Chroma Playground](https://swapoff.org/chroma/playground/).
+
+## Using the library
+
+This is version 2 of Chroma, use the import path:
+
+```go
+import "github.com/alecthomas/chroma/v2"
+```
+
+Chroma, like Pygments, has the concepts of
+[lexers](https://github.com/alecthomas/chroma/tree/master/lexers),
+[formatters](https://github.com/alecthomas/chroma/tree/master/formatters) and
+[styles](https://github.com/alecthomas/chroma/tree/master/styles).
+
+Lexers convert source text into a stream of tokens, styles specify how token
+types are mapped to colours, and formatters convert tokens and styles into
+formatted output.
+
+A package exists for each of these, containing a global `Registry` variable
+with all of the registered implementations. There are also helper functions
+for using the registry in each package, such as looking up lexers by name or
+matching filenames, etc.
+
+In all cases, if a lexer, formatter or style can not be determined, `nil` will
+be returned. In this situation you may want to default to the `Fallback`
+value in each respective package, which provides sane defaults.
+
+### Quick start
+
+A convenience function exists that can be used to simply format some source
+text, without any effort:
+
+```go
+err := quick.Highlight(os.Stdout, someSourceCode, "go", "html", "monokai")
+```
+
+### Identifying the language
+
+To highlight code, you'll first have to identify what language the code is
+written in. There are three primary ways to do that:
+
+1. Detect the language from its filename.
+
+ ```go
+ lexer := lexers.Match("foo.go")
+ ```
+
+2. Explicitly specify the language by its Chroma syntax ID (a full list is available from `lexers.Names()`).
+
+ ```go
+ lexer := lexers.Get("go")
+ ```
+
+3. Detect the language from its content.
+
+ ```go
+ lexer := lexers.Analyse("package main\n\nfunc main()\n{\n}\n")
+ ```
+
+In all cases, `nil` will be returned if the language can not be identified.
+
+```go
+if lexer == nil {
+ lexer = lexers.Fallback
+}
+```
+
+At this point, it should be noted that some lexers can be extremely chatty. To
+mitigate this, you can use the coalescing lexer to coalesce runs of identical
+token types into a single token:
+
+```go
+lexer = chroma.Coalesce(lexer)
+```
+
+### Formatting the output
+
+Once a language is identified you will need to pick a formatter and a style (theme).
+
+```go
+style := styles.Get("swapoff")
+if style == nil {
+ style = styles.Fallback
+}
+formatter := formatters.Get("html")
+if formatter == nil {
+ formatter = formatters.Fallback
+}
+```
+
+Then obtain an iterator over the tokens:
+
+```go
+contents, err := ioutil.ReadAll(r)
+iterator, err := lexer.Tokenise(nil, string(contents))
+```
+
+And finally, format the tokens from the iterator:
+
+```go
+err := formatter.Format(w, style, iterator)
+```
+
+### The HTML formatter
+
+By default the `html` registered formatter generates standalone HTML with
+embedded CSS. More flexibility is available through the `formatters/html` package.
+
+Firstly, the output generated by the formatter can be customised with the
+following constructor options:
+
+- `Standalone()` - generate standalone HTML with embedded CSS.
+- `WithClasses()` - use classes rather than inlined style attributes.
+- `ClassPrefix(prefix)` - prefix each generated CSS class.
+- `TabWidth(width)` - Set the rendered tab width, in characters.
+- `WithLineNumbers()` - Render line numbers (style with `LineNumbers`).
+- `WithLinkableLineNumbers()` - Make the line numbers linkable and be a link to themselves.
+- `HighlightLines(ranges)` - Highlight lines in these ranges (style with `LineHighlight`).
+- `LineNumbersInTable()` - Use a table for formatting line numbers and code, rather than spans.
+
+If `WithClasses()` is used, the corresponding CSS can be obtained from the formatter with:
+
+```go
+formatter := html.New(html.WithClasses(true))
+err := formatter.WriteCSS(w, style)
+```
+
+## More detail
+
+### Lexers
+
+See the [Pygments documentation](http://pygments.org/docs/lexerdevelopment/)
+for details on implementing lexers. Most concepts apply directly to Chroma,
+but see existing lexer implementations for real examples.
+
+In many cases lexers can be automatically converted directly from Pygments by
+using the included Python 3 script `pygments2chroma_xml.py`. I use something like
+the following:
+
+```sh
+uv run --script _tools/pygments2chroma_xml.py \
+ pygments.lexers.jvm.KotlinLexer \
+ > lexers/embedded/kotlin.xml
+```
+
+A list of all lexers available in Pygments can be found in [pygments-lexers.txt](https://github.com/alecthomas/chroma/blob/master/pygments-lexers.txt).
+
+### Formatters
+
+Chroma supports HTML output, as well as terminal output in 8 colour, 256 colour, and true-colour.
+
+A `noop` formatter is included that outputs the token text only, and a `tokens`
+formatter outputs raw tokens. The latter is useful for debugging lexers.
+
+### Styles
+
+Chroma styles are defined in XML. The style entries use the
+[same syntax](http://pygments.org/docs/styles/) as Pygments. All Pygments styles have been converted to Chroma using the `_tools/style.py`
+script.
+
+Style names are case-insensitive. For example, `monokai` and `Monokai` are treated as the same style.
+
+When you work with one of [Chroma's styles](https://github.com/alecthomas/chroma/tree/master/styles),
+know that the `Background` token type provides the default style for tokens. It does so
+by defining a foreground color and background color.
+
+For example, this gives each token name not defined in the style a default color
+of `#f8f8f8` and uses `#000000` for the highlighted code block's background:
+
+```xml
+
+```
+
+Also, token types in a style file are hierarchical. For instance, when `CommentSpecial` is not defined, Chroma uses the token style from `Comment`. So when several comment tokens use the same color, you'll only need to define `Comment` and override the one that has a different color.
+
+For a quick overview of the available styles and how they look, check out the [Chroma Style Gallery](https://xyproto.github.io/splash/docs/).
+
+## Command-line interface
+
+A command-line interface to Chroma is included.
+
+Binaries are available to install from [the releases page](https://github.com/alecthomas/chroma/releases).
+
+The CLI can be used as a preprocessor to colorise output of `less(1)`,
+see documentation for the `LESSOPEN` environment variable.
+
+The `--fail` flag can be used to suppress output and return with exit status
+1 to facilitate falling back to some other preprocessor in case chroma
+does not resolve a specific lexer to use for the given file. For example:
+
+```shell
+export LESSOPEN='| p() { chroma --fail "$1" || cat "$1"; }; p "%s"'
+```
+
+Replace `cat` with your favourite fallback preprocessor.
+
+When invoked as `.lessfilter`, the `--fail` flag is automatically turned
+on under the hood for easy integration with [lesspipe shipping with
+Debian and derivatives](https://manpages.debian.org/lesspipe#USER_DEFINED_FILTERS);
+for that setup the `chroma` executable can be just symlinked to `~/.lessfilter`.
+
+## Projects using Chroma
+
+* [`moor`](https://github.com/walles/moor) is a full-blown pager that colorizes
+ its input using Chroma
+* [Hugo](https://gohugo.io/) is a static site generator that [uses Chroma for syntax
+ highlighting code examples](https://gohugo.io/content-management/syntax-highlighting/)
+* [f4](https://github.com/unxed/f4) is asynchronious cross platform Far Manager clone in Go
+ that uses Chroma for syntax highlighting in built-in editor
+
+## Testing lexers
+
+If you edit some lexers and want to try it, open a shell in `cmd/chromad` and run:
+
+```shell
+go run . --csrf-key=securekey
+```
+
+A Link will be printed. Open it in your Browser. Now you can test on the Playground with your local changes.
+
+If you want to run the tests and the lexers, open a shell in the root directory and run:
+
+```shell
+go test ./lexers
+```
+
+When updating or adding a lexer, please add tests. See [lexers/README.md](lexers/README.md) for more.
+
+## What's missing compared to Pygments?
+
+- Quite a few lexers, for various reasons (pull-requests welcome):
+ - Pygments lexers for complex languages often include custom code to
+ handle certain aspects, such as Raku's ability to nest code inside
+ regular expressions. These require time and effort to convert.
+ - I mostly only converted languages I had heard of, to reduce the porting cost.
+- Some more esoteric features of Pygments are omitted for simplicity.
+- Though the Chroma API supports content detection, very few languages support them.
+ I have plans to implement a statistical analyser at some point, but not enough time.
diff --git a/vendor/github.com/alecthomas/chroma/v2/biome.json b/vendor/github.com/alecthomas/chroma/v2/biome.json
new file mode 100644
index 0000000000..a5bec2e194
--- /dev/null
+++ b/vendor/github.com/alecthomas/chroma/v2/biome.json
@@ -0,0 +1,6 @@
+{
+ "$schema": "https://biomejs.dev/schemas/2.0.5/schema.json",
+ "formatter": {
+ "indentStyle": "space"
+ }
+}
diff --git a/vendor/github.com/alecthomas/chroma/v2/chroma.jpg b/vendor/github.com/alecthomas/chroma/v2/chroma.jpg
new file mode 100644
index 0000000000..a747dbf804
Binary files /dev/null and b/vendor/github.com/alecthomas/chroma/v2/chroma.jpg differ
diff --git a/vendor/github.com/alecthomas/chroma/v2/coalesce.go b/vendor/github.com/alecthomas/chroma/v2/coalesce.go
new file mode 100644
index 0000000000..f5048951a2
--- /dev/null
+++ b/vendor/github.com/alecthomas/chroma/v2/coalesce.go
@@ -0,0 +1,35 @@
+package chroma
+
+// Coalesce is a Lexer interceptor that collapses runs of common types into a single token.
+func Coalesce(lexer Lexer) Lexer { return &coalescer{lexer} }
+
+type coalescer struct{ Lexer }
+
+func (d *coalescer) Tokenise(options *TokeniseOptions, text string) (Iterator, error) {
+ var prev Token
+ it, err := d.Lexer.Tokenise(options, text)
+ if err != nil {
+ return nil, err
+ }
+ return func() Token {
+ for token := it(); token != (EOF); token = it() {
+ if len(token.Value) == 0 {
+ continue
+ }
+ if prev == EOF {
+ prev = token
+ } else {
+ if prev.Type == token.Type && len(prev.Value) < 8192 {
+ prev.Value += token.Value
+ } else {
+ out := prev
+ prev = token
+ return out
+ }
+ }
+ }
+ out := prev
+ prev = EOF
+ return out
+ }, nil
+}
diff --git a/vendor/github.com/alecthomas/chroma/v2/colour.go b/vendor/github.com/alecthomas/chroma/v2/colour.go
new file mode 100644
index 0000000000..8add068dc3
--- /dev/null
+++ b/vendor/github.com/alecthomas/chroma/v2/colour.go
@@ -0,0 +1,192 @@
+package chroma
+
+import (
+ "fmt"
+ "math"
+ "strconv"
+ "strings"
+)
+
+// ANSI2RGB maps ANSI colour names, as supported by Chroma, to hex RGB values.
+var ANSI2RGB = map[string]string{
+ "#ansiblack": "000000",
+ "#ansidarkred": "7f0000",
+ "#ansidarkgreen": "007f00",
+ "#ansibrown": "7f7fe0",
+ "#ansidarkblue": "00007f",
+ "#ansipurple": "7f007f",
+ "#ansiteal": "007f7f",
+ "#ansilightgray": "e5e5e5",
+ // Normal
+ "#ansidarkgray": "555555",
+ "#ansired": "ff0000",
+ "#ansigreen": "00ff00",
+ "#ansiyellow": "ffff00",
+ "#ansiblue": "0000ff",
+ "#ansifuchsia": "ff00ff",
+ "#ansiturquoise": "00ffff",
+ "#ansiwhite": "ffffff",
+
+ // Aliases without the "ansi" prefix, because...why?
+ "#black": "000000",
+ "#darkred": "7f0000",
+ "#darkgreen": "007f00",
+ "#brown": "7f7fe0",
+ "#darkblue": "00007f",
+ "#purple": "7f007f",
+ "#teal": "007f7f",
+ "#lightgray": "e5e5e5",
+ // Normal
+ "#darkgray": "555555",
+ "#red": "ff0000",
+ "#green": "00ff00",
+ "#yellow": "ffff00",
+ "#blue": "0000ff",
+ "#fuchsia": "ff00ff",
+ "#turquoise": "00ffff",
+ "#white": "ffffff",
+}
+
+// Colour represents an RGB colour.
+type Colour int32
+
+// NewColour creates a Colour directly from RGB values.
+func NewColour(r, g, b uint8) Colour {
+ return Colour(int32(r)<<16|int32(g)<<8|int32(b)) + 1
+}
+
+// Distance between this colour and another.
+//
+// This uses the approach described here (https://www.compuphase.com/cmetric.htm).
+// This is not as accurate as LAB, et. al. but is *vastly* simpler and sufficient for our needs.
+func (c Colour) Distance(e2 Colour) float64 {
+ ar, ag, ab := int64(c.Red()), int64(c.Green()), int64(c.Blue())
+ br, bg, bb := int64(e2.Red()), int64(e2.Green()), int64(e2.Blue())
+ rmean := (ar + br) / 2
+ r := ar - br
+ g := ag - bg
+ b := ab - bb
+ return math.Sqrt(float64((((512 + rmean) * r * r) >> 8) + 4*g*g + (((767 - rmean) * b * b) >> 8)))
+}
+
+// Brighten returns a copy of this colour with its brightness adjusted.
+//
+// If factor is negative, the colour is darkened.
+//
+// Uses approach described here (http://www.pvladov.com/2012/09/make-color-lighter-or-darker.html).
+func (c Colour) Brighten(factor float64) Colour {
+ r := float64(c.Red())
+ g := float64(c.Green())
+ b := float64(c.Blue())
+
+ if factor < 0 {
+ factor++
+ r *= factor
+ g *= factor
+ b *= factor
+ } else {
+ r = (255-r)*factor + r
+ g = (255-g)*factor + g
+ b = (255-b)*factor + b
+ }
+ return NewColour(uint8(r), uint8(g), uint8(b))
+}
+
+// BrightenOrDarken brightens a colour if it is < 0.5 brightness or darkens if > 0.5 brightness.
+func (c Colour) BrightenOrDarken(factor float64) Colour {
+ if c.Brightness() < 0.5 {
+ return c.Brighten(factor)
+ }
+ return c.Brighten(-factor)
+}
+
+// ClampBrightness returns a copy of this colour with its brightness adjusted such that
+// it falls within the range [min, max] (or very close to it due to rounding errors).
+// The supplied values use the same [0.0, 1.0] range as Brightness.
+func (c Colour) ClampBrightness(min, max float64) Colour {
+ if !c.IsSet() {
+ return c
+ }
+
+ min = math.Max(min, 0)
+ max = math.Min(max, 1)
+ current := c.Brightness()
+ target := math.Min(math.Max(current, min), max)
+ if current == target {
+ return c
+ }
+
+ r := float64(c.Red())
+ g := float64(c.Green())
+ b := float64(c.Blue())
+ rgb := r + g + b
+ if target > current {
+ // Solve for x: target == ((255-r)*x + r + (255-g)*x + g + (255-b)*x + b) / 255 / 3
+ return c.Brighten((target*255*3 - rgb) / (255*3 - rgb))
+ }
+ // Solve for x: target == (r*(x+1) + g*(x+1) + b*(x+1)) / 255 / 3
+ return c.Brighten((target*255*3)/rgb - 1)
+}
+
+// Brightness of the colour (roughly) in the range 0.0 to 1.0.
+func (c Colour) Brightness() float64 {
+ return (float64(c.Red()) + float64(c.Green()) + float64(c.Blue())) / 255.0 / 3.0
+}
+
+// ParseColour in the forms #rgb, #rrggbb, #ansi, or #.
+// Will return an "unset" colour if invalid.
+func ParseColour(colour string) Colour {
+ colour = normaliseColour(colour)
+ n, err := strconv.ParseUint(colour, 16, 32)
+ if err != nil {
+ return 0
+ }
+ return Colour(n + 1) //nolint:gosec
+}
+
+// MustParseColour is like ParseColour except it panics if the colour is invalid.
+//
+// Will panic if colour is in an invalid format.
+func MustParseColour(colour string) Colour {
+ parsed := ParseColour(colour)
+ if !parsed.IsSet() {
+ panic(fmt.Errorf("invalid colour %q", colour))
+ }
+ return parsed
+}
+
+// IsSet returns true if the colour is set.
+func (c Colour) IsSet() bool { return c != 0 }
+
+func (c Colour) String() string { return fmt.Sprintf("#%06x", int(c-1)) }
+func (c Colour) GoString() string { return fmt.Sprintf("Colour(0x%06x)", int(c-1)) }
+
+// Red component of colour.
+func (c Colour) Red() uint8 { return uint8(((c - 1) >> 16) & 0xff) } //nolint:gosec
+
+// Green component of colour.
+func (c Colour) Green() uint8 { return uint8(((c - 1) >> 8) & 0xff) } //nolint:gosec
+
+// Blue component of colour.
+func (c Colour) Blue() uint8 { return uint8((c - 1) & 0xff) } //nolint:gosec
+
+// Colours is an orderable set of colours.
+type Colours []Colour
+
+func (c Colours) Len() int { return len(c) }
+func (c Colours) Swap(i, j int) { c[i], c[j] = c[j], c[i] }
+func (c Colours) Less(i, j int) bool { return c[i] < c[j] }
+
+// Convert colours to #rrggbb.
+func normaliseColour(colour string) string {
+ if ansi, ok := ANSI2RGB[colour]; ok {
+ return ansi
+ }
+ if strings.HasPrefix(colour, "#") {
+ colour = colour[1:]
+ if len(colour) == 3 {
+ return colour[0:1] + colour[0:1] + colour[1:2] + colour[1:2] + colour[2:3] + colour[2:3]
+ }
+ }
+ return colour
+}
diff --git a/vendor/github.com/alecthomas/chroma/v2/delegate.go b/vendor/github.com/alecthomas/chroma/v2/delegate.go
new file mode 100644
index 0000000000..298f2dbbd1
--- /dev/null
+++ b/vendor/github.com/alecthomas/chroma/v2/delegate.go
@@ -0,0 +1,161 @@
+package chroma
+
+import (
+ "bytes"
+)
+
+type delegatingLexer struct {
+ root Lexer
+ language Lexer
+}
+
+// DelegatingLexer combines two lexers to handle the common case of a language embedded inside another, such as PHP
+// inside HTML or PHP inside plain text.
+//
+// It takes two lexer as arguments: a root lexer and a language lexer. First everything is scanned using the language
+// lexer, which must return "Other" for unrecognised tokens. Then all "Other" tokens are lexed using the root lexer.
+// Finally, these two sets of tokens are merged.
+//
+// The lexers from the template lexer package use this base lexer.
+func DelegatingLexer(root Lexer, language Lexer) Lexer {
+ return &delegatingLexer{
+ root: root,
+ language: language,
+ }
+}
+
+func (d *delegatingLexer) SetTracing(enable bool) {
+ if l, ok := d.language.(TracingLexer); ok {
+ l.SetTracing(enable)
+ }
+ if l, ok := d.root.(TracingLexer); ok {
+ l.SetTracing(enable)
+ }
+}
+
+func (d *delegatingLexer) AnalyseText(text string) float32 {
+ return d.root.AnalyseText(text)
+}
+
+func (d *delegatingLexer) SetAnalyser(analyser func(text string) float32) Lexer {
+ d.root.SetAnalyser(analyser)
+ return d
+}
+
+func (d *delegatingLexer) SetRegistry(r *LexerRegistry) Lexer {
+ d.root.SetRegistry(r)
+ d.language.SetRegistry(r)
+ return d
+}
+
+func (d *delegatingLexer) Config() *Config {
+ return d.language.Config()
+}
+
+// An insertion is the character range where language tokens should be inserted.
+type insertion struct {
+ start, end int
+ tokens []Token
+}
+
+func (d *delegatingLexer) Tokenise(options *TokeniseOptions, text string) (Iterator, error) { // nolint: gocognit
+ tokens, err := Tokenise(Coalesce(d.language), options, text)
+ if err != nil {
+ return nil, err
+ }
+ // Compute insertions and gather "Other" tokens.
+ others := &bytes.Buffer{}
+ insertions := []*insertion{}
+ var insert *insertion
+ offset := 0
+ var last Token
+ for _, t := range tokens {
+ if t.Type == Other {
+ if last != EOF && insert != nil && last.Type != Other {
+ insert.end = offset
+ }
+ others.WriteString(t.Value)
+ } else {
+ if last == EOF || last.Type == Other {
+ insert = &insertion{start: offset}
+ insertions = append(insertions, insert)
+ }
+ insert.tokens = append(insert.tokens, t)
+ }
+ last = t
+ offset += len(t.Value)
+ }
+
+ if len(insertions) == 0 {
+ return d.root.Tokenise(options, text)
+ }
+
+ // Lex the other tokens.
+ rootTokens, err := Tokenise(Coalesce(d.root), options, others.String())
+ if err != nil {
+ return nil, err
+ }
+
+ // Interleave the two sets of tokens.
+ var out []Token
+ offset = 0 // Offset into text.
+ tokenIndex := 0
+ nextToken := func() Token {
+ if tokenIndex >= len(rootTokens) {
+ return EOF
+ }
+ t := rootTokens[tokenIndex]
+ tokenIndex++
+ return t
+ }
+ insertionIndex := 0
+ nextInsertion := func() *insertion {
+ if insertionIndex >= len(insertions) {
+ return nil
+ }
+ i := insertions[insertionIndex]
+ insertionIndex++
+ return i
+ }
+ t := nextToken()
+ i := nextInsertion()
+ for t != EOF || i != nil {
+ // fmt.Printf("%d->%d:%q %d->%d:%q\n", offset, offset+len(t.Value), t.Value, i.start, i.end, Stringify(i.tokens...))
+ if t == EOF || (i != nil && i.start < offset+len(t.Value)) {
+ var l Token
+ l, t = splitToken(t, i.start-offset)
+ if l != EOF {
+ out = append(out, l)
+ offset += len(l.Value)
+ }
+ out = append(out, i.tokens...)
+ offset += i.end - i.start
+ if t == EOF {
+ t = nextToken()
+ }
+ i = nextInsertion()
+ } else {
+ out = append(out, t)
+ offset += len(t.Value)
+ t = nextToken()
+ }
+ }
+ return Literator(out...), nil
+}
+
+func splitToken(t Token, offset int) (l Token, r Token) {
+ if t == EOF {
+ return EOF, EOF
+ }
+ if offset == 0 {
+ return EOF, t
+ }
+ if offset == len(t.Value) {
+ return t, EOF
+ }
+ l = t.Clone()
+ r = t.Clone()
+ l.Value = l.Value[:offset]
+ r.Value = r.Value[offset:]
+ return
+}
diff --git a/vendor/github.com/alecthomas/chroma/v2/doc.go b/vendor/github.com/alecthomas/chroma/v2/doc.go
new file mode 100644
index 0000000000..4dde77c818
--- /dev/null
+++ b/vendor/github.com/alecthomas/chroma/v2/doc.go
@@ -0,0 +1,7 @@
+// Package chroma takes source code and other structured text and converts it into syntax highlighted HTML, ANSI-
+// coloured text, etc.
+//
+// Chroma is based heavily on Pygments, and includes translators for Pygments lexers and styles.
+//
+// For more information, go here: https://github.com/alecthomas/chroma
+package chroma
diff --git a/vendor/github.com/alecthomas/chroma/v2/emitters.go b/vendor/github.com/alecthomas/chroma/v2/emitters.go
new file mode 100644
index 0000000000..1097a75764
--- /dev/null
+++ b/vendor/github.com/alecthomas/chroma/v2/emitters.go
@@ -0,0 +1,233 @@
+package chroma
+
+import (
+ "fmt"
+)
+
+// An Emitter takes group matches and returns tokens.
+type Emitter interface {
+ // Emit tokens for the given regex groups.
+ Emit(groups []string, state *LexerState) Iterator
+}
+
+// ValidatingEmitter is an Emitter that can validate against a compiled rule.
+type ValidatingEmitter interface {
+ Emitter
+ ValidateEmitter(rule *CompiledRule) error
+}
+
+// SerialisableEmitter is an Emitter that can be serialised and deserialised to/from JSON.
+type SerialisableEmitter interface {
+ Emitter
+ EmitterKind() string
+}
+
+// EmitterFunc is a function that is an Emitter.
+type EmitterFunc func(groups []string, state *LexerState) Iterator
+
+// Emit tokens for groups.
+func (e EmitterFunc) Emit(groups []string, state *LexerState) Iterator {
+ return e(groups, state)
+}
+
+type Emitters []Emitter
+
+type byGroupsEmitter struct {
+ Emitters
+}
+
+var _ ValidatingEmitter = (*byGroupsEmitter)(nil)
+
+// ByGroups emits a token for each matching group in the rule's regex.
+func ByGroups(emitters ...Emitter) Emitter {
+ return &byGroupsEmitter{Emitters: emitters}
+}
+
+func (b *byGroupsEmitter) EmitterKind() string { return "bygroups" }
+
+func (b *byGroupsEmitter) ValidateEmitter(rule *CompiledRule) error {
+ if len(rule.Regexp.GetGroupNumbers())-1 != len(b.Emitters) {
+ return fmt.Errorf("number of groups %d does not match number of emitters %d", len(rule.Regexp.GetGroupNumbers())-1, len(b.Emitters))
+ }
+ return nil
+}
+
+func (b *byGroupsEmitter) Emit(groups []string, state *LexerState) Iterator {
+ iterators := make([]Iterator, 0, len(groups)-1)
+ if len(b.Emitters) != len(groups)-1 {
+ iterators = append(iterators, Error.Emit(groups, state))
+ // panic(errors.Errorf("number of groups %q does not match number of emitters %v", groups, emitters))
+ } else {
+ for i, group := range groups[1:] {
+ if b.Emitters[i] != nil {
+ iterators = append(iterators, b.Emitters[i].Emit([]string{group}, state))
+ }
+ }
+ }
+ return Concaterator(iterators...)
+}
+
+// ByGroupNames emits a token for each named matching group in the rule's regex.
+func ByGroupNames(emitters map[string]Emitter) Emitter {
+ return EmitterFunc(func(groups []string, state *LexerState) Iterator {
+ iterators := make([]Iterator, 0, len(state.NamedGroups)-1)
+ if len(state.NamedGroups)-1 == 0 {
+ if emitter, ok := emitters[`0`]; ok {
+ iterators = append(iterators, emitter.Emit(groups, state))
+ } else {
+ iterators = append(iterators, Error.Emit(groups, state))
+ }
+ } else {
+ ruleRegex := state.Rules[state.State][state.Rule].Regexp
+ for i := 1; i < len(state.NamedGroups); i++ {
+ groupName := ruleRegex.GroupNameFromNumber(i)
+ group := state.NamedGroups[groupName]
+ if emitter, ok := emitters[groupName]; ok {
+ if emitter != nil {
+ iterators = append(iterators, emitter.Emit([]string{group}, state))
+ }
+ } else {
+ iterators = append(iterators, Error.Emit([]string{group}, state))
+ }
+ }
+ }
+ return Concaterator(iterators...)
+ })
+}
+
+// UsingByGroup emits tokens for the matched groups in the regex using a
+// sublexer. Used when lexing code blocks where the name of a sublexer is
+// contained within the block, for example on a Markdown text block or SQL
+// language block.
+//
+// An attempt to load the sublexer will be made using the captured value from
+// the text of the matched sublexerNameGroup. If a sublexer matching the
+// sublexerNameGroup is available, then tokens for the matched codeGroup will
+// be emitted using the sublexer. Otherwise, if no sublexer is available, then
+// tokens will be emitted from the passed emitter.
+//
+// Example:
+//
+// var Markdown = internal.Register(MustNewLexer(
+// &Config{
+// Name: "markdown",
+// Aliases: []string{"md", "mkd"},
+// Filenames: []string{"*.md", "*.mkd", "*.markdown"},
+// MimeTypes: []string{"text/x-markdown"},
+// },
+// Rules{
+// "root": {
+// {"^(```)(\\w+)(\\n)([\\w\\W]*?)(^```$)",
+// UsingByGroup(
+// 2, 4,
+// String, String, String, Text, String,
+// ),
+// nil,
+// },
+// },
+// },
+// ))
+//
+// See the lexers/markdown.go for the complete example.
+//
+// Note: panic's if the number of emitters does not equal the number of matched
+// groups in the regex.
+func UsingByGroup(sublexerNameGroup, codeGroup int, emitters ...Emitter) Emitter {
+ return &usingByGroup{
+ SublexerNameGroup: sublexerNameGroup,
+ CodeGroup: codeGroup,
+ Emitters: emitters,
+ }
+}
+
+type usingByGroup struct {
+ SublexerNameGroup int `xml:"sublexer_name_group"`
+ CodeGroup int `xml:"code_group"`
+ Emitters Emitters `xml:"emitters"`
+}
+
+func (u *usingByGroup) EmitterKind() string { return "usingbygroup" }
+func (u *usingByGroup) Emit(groups []string, state *LexerState) Iterator {
+ // bounds check
+ if len(u.Emitters) != len(groups)-1 {
+ panic("UsingByGroup expects number of emitters to be the same as len(groups)-1")
+ }
+
+ // grab sublexer
+ sublexer := state.Registry.Get(groups[u.SublexerNameGroup])
+
+ // build iterators
+ iterators := make([]Iterator, len(groups)-1)
+ for i, group := range groups[1:] {
+ if i == u.CodeGroup-1 && sublexer != nil {
+ var err error
+ iterators[i], err = sublexer.Tokenise(nil, groups[u.CodeGroup])
+ if err != nil {
+ panic(err)
+ }
+ } else if u.Emitters[i] != nil {
+ iterators[i] = u.Emitters[i].Emit([]string{group}, state)
+ }
+ }
+ return Concaterator(iterators...)
+}
+
+// UsingLexer returns an Emitter that uses a given Lexer for parsing and emitting.
+//
+// This Emitter is not serialisable.
+func UsingLexer(lexer Lexer) Emitter {
+ return EmitterFunc(func(groups []string, _ *LexerState) Iterator {
+ it, err := lexer.Tokenise(&TokeniseOptions{State: "root", Nested: true}, groups[0])
+ if err != nil {
+ panic(err)
+ }
+ return it
+ })
+}
+
+type usingEmitter struct {
+ Lexer string `xml:"lexer,attr"`
+}
+
+func (u *usingEmitter) EmitterKind() string { return "using" }
+
+func (u *usingEmitter) Emit(groups []string, state *LexerState) Iterator {
+ if state.Registry == nil {
+ panic(fmt.Sprintf("no LexerRegistry available for Using(%q)", u.Lexer))
+ }
+ lexer := state.Registry.Get(u.Lexer)
+ if lexer == nil {
+ panic(fmt.Sprintf("no such lexer %q", u.Lexer))
+ }
+ it, err := lexer.Tokenise(&TokeniseOptions{State: "root", Nested: true}, groups[0])
+ if err != nil {
+ panic(err)
+ }
+ return it
+}
+
+// Using returns an Emitter that uses a given Lexer reference for parsing and emitting.
+//
+// The referenced lexer must be stored in the same LexerRegistry.
+func Using(lexer string) Emitter {
+ return &usingEmitter{Lexer: lexer}
+}
+
+type usingSelfEmitter struct {
+ State string `xml:"state,attr"`
+}
+
+func (u *usingSelfEmitter) EmitterKind() string { return "usingself" }
+
+func (u *usingSelfEmitter) Emit(groups []string, state *LexerState) Iterator {
+ it, err := state.Lexer.Tokenise(&TokeniseOptions{State: u.State, Nested: true}, groups[0])
+ if err != nil {
+ panic(err)
+ }
+ return it
+}
+
+// UsingSelf is like Using, but uses the current Lexer.
+func UsingSelf(stateName string) Emitter {
+ return &usingSelfEmitter{stateName}
+}
diff --git a/vendor/github.com/alecthomas/chroma/v2/formatter.go b/vendor/github.com/alecthomas/chroma/v2/formatter.go
new file mode 100644
index 0000000000..00dd5d8df8
--- /dev/null
+++ b/vendor/github.com/alecthomas/chroma/v2/formatter.go
@@ -0,0 +1,43 @@
+package chroma
+
+import (
+ "io"
+)
+
+// A Formatter for Chroma lexers.
+type Formatter interface {
+ // Format returns a formatting function for tokens.
+ //
+ // If the iterator panics, the Formatter should recover.
+ Format(w io.Writer, style *Style, iterator Iterator) error
+}
+
+// A FormatterFunc is a Formatter implemented as a function.
+//
+// Guards against iterator panics.
+type FormatterFunc func(w io.Writer, style *Style, iterator Iterator) error
+
+func (f FormatterFunc) Format(w io.Writer, s *Style, it Iterator) (err error) { // nolint
+ defer func() {
+ if perr := recover(); perr != nil {
+ err = perr.(error)
+ }
+ }()
+ return f(w, s, it)
+}
+
+type recoveringFormatter struct {
+ Formatter
+}
+
+func (r recoveringFormatter) Format(w io.Writer, s *Style, it Iterator) (err error) {
+ defer func() {
+ if perr := recover(); perr != nil {
+ err = perr.(error)
+ }
+ }()
+ return r.Formatter.Format(w, s, it)
+}
+
+// RecoveringFormatter wraps a formatter with panic recovery.
+func RecoveringFormatter(formatter Formatter) Formatter { return recoveringFormatter{formatter} }
diff --git a/vendor/github.com/alecthomas/chroma/v2/formatters/api.go b/vendor/github.com/alecthomas/chroma/v2/formatters/api.go
new file mode 100644
index 0000000000..9ca0d01ddc
--- /dev/null
+++ b/vendor/github.com/alecthomas/chroma/v2/formatters/api.go
@@ -0,0 +1,57 @@
+package formatters
+
+import (
+ "io"
+ "sort"
+
+ "github.com/alecthomas/chroma/v2"
+ "github.com/alecthomas/chroma/v2/formatters/html"
+ "github.com/alecthomas/chroma/v2/formatters/svg"
+)
+
+var (
+ // NoOp formatter.
+ NoOp = Register("noop", chroma.FormatterFunc(func(w io.Writer, s *chroma.Style, iterator chroma.Iterator) error {
+ for t := iterator(); t != chroma.EOF; t = iterator() {
+ if _, err := io.WriteString(w, t.Value); err != nil {
+ return err
+ }
+ }
+ return nil
+ }))
+ // Default HTML formatter outputs self-contained HTML.
+ htmlFull = Register("html", html.New(html.Standalone(true), html.WithClasses(true))) // nolint
+ SVG = Register("svg", svg.New(svg.EmbedFont("Liberation Mono", svg.FontLiberationMono, svg.WOFF)))
+)
+
+// Fallback formatter.
+var Fallback = NoOp
+
+// Registry of Formatters.
+var Registry = map[string]chroma.Formatter{}
+
+// Names of registered formatters.
+func Names() []string {
+ out := []string{}
+ for name := range Registry {
+ out = append(out, name)
+ }
+ sort.Strings(out)
+ return out
+}
+
+// Get formatter by name.
+//
+// If the given formatter is not found, the Fallback formatter will be returned.
+func Get(name string) chroma.Formatter {
+ if f, ok := Registry[name]; ok {
+ return f
+ }
+ return Fallback
+}
+
+// Register a named formatter.
+func Register(name string, formatter chroma.Formatter) chroma.Formatter {
+ Registry[name] = formatter
+ return formatter
+}
diff --git a/vendor/github.com/alecthomas/chroma/v2/formatters/html/html.go b/vendor/github.com/alecthomas/chroma/v2/formatters/html/html.go
new file mode 100644
index 0000000000..e876aab758
--- /dev/null
+++ b/vendor/github.com/alecthomas/chroma/v2/formatters/html/html.go
@@ -0,0 +1,692 @@
+package html
+
+import (
+ "fmt"
+ "html"
+ "io"
+ "slices"
+ "sort"
+ "strconv"
+ "strings"
+ "sync"
+
+ "github.com/alecthomas/chroma/v2"
+)
+
+// Option sets an option of the HTML formatter.
+type Option func(f *Formatter)
+
+// Standalone configures the HTML formatter for generating a standalone HTML document.
+func Standalone(b bool) Option { return func(f *Formatter) { f.standalone = b } }
+
+// ClassPrefix sets the CSS class prefix.
+func ClassPrefix(prefix string) Option { return func(f *Formatter) { f.prefix = prefix } }
+
+// WithClasses emits HTML using CSS classes, rather than inline styles.
+func WithClasses(b bool) Option { return func(f *Formatter) { f.Classes = b } }
+
+// WithAllClasses disables an optimisation that omits redundant CSS classes.
+func WithAllClasses(b bool) Option { return func(f *Formatter) { f.allClasses = b } }
+
+// WithCustomCSS sets user's custom CSS styles.
+func WithCustomCSS(css map[chroma.TokenType]string) Option {
+ return func(f *Formatter) {
+ f.customCSS = css
+ }
+}
+
+// WithCSSComments adds prefixe comments to the css classes. Defaults to true.
+func WithCSSComments(b bool) Option { return func(f *Formatter) { f.writeCSSComments = b } }
+
+// TabWidth sets the number of characters for a tab. Defaults to 8.
+func TabWidth(width int) Option { return func(f *Formatter) { f.tabWidth = width } }
+
+// PreventSurroundingPre prevents the surrounding pre tags around the generated code.
+func PreventSurroundingPre(b bool) Option {
+ return func(f *Formatter) {
+ f.preventSurroundingPre = b
+
+ if b {
+ f.preWrapper = nopPreWrapper
+ } else {
+ f.preWrapper = defaultPreWrapper
+ }
+ }
+}
+
+// InlineCode creates inline code wrapped in a code tag.
+func InlineCode(b bool) Option {
+ return func(f *Formatter) {
+ f.inlineCode = b
+ f.preWrapper = preWrapper{
+ start: func(code bool, styleAttr string) string {
+ if code {
+ return fmt.Sprintf(``, styleAttr)
+ }
+
+ return ``
+ },
+ end: func(code bool) string {
+ if code {
+ return ``
+ }
+
+ return ``
+ },
+ }
+ }
+}
+
+// WithPreWrapper allows control of the surrounding pre tags.
+func WithPreWrapper(wrapper PreWrapper) Option {
+ return func(f *Formatter) {
+ f.preWrapper = wrapper
+ }
+}
+
+// WithModeClasses adds the style's mode (eg. "light" or "dark") as a CSS
+// class on wrapper elements and scopes WriteCSS rules by mode. This enables
+// combining light and dark stylesheets and switching themes at runtime.
+func WithModeClasses(b bool) Option { return func(f *Formatter) { f.modeClasses = b } }
+
+// WrapLongLines wraps long lines.
+func WrapLongLines(b bool) Option {
+ return func(f *Formatter) {
+ f.wrapLongLines = b
+ }
+}
+
+// WithLineNumbers formats output with line numbers.
+func WithLineNumbers(b bool) Option {
+ return func(f *Formatter) {
+ f.lineNumbers = b
+ }
+}
+
+// LineNumbersInTable will, when combined with WithLineNumbers, separate the line numbers
+// and code in table td's, which make them copy-and-paste friendly.
+func LineNumbersInTable(b bool) Option {
+ return func(f *Formatter) {
+ f.lineNumbersInTable = b
+ }
+}
+
+// WithLinkableLineNumbers decorates the line numbers HTML elements with an "id"
+// attribute so they can be linked.
+func WithLinkableLineNumbers(b bool, prefix string) Option {
+ return func(f *Formatter) {
+ f.linkableLineNumbers = b
+ f.lineNumbersIDPrefix = prefix
+ }
+}
+
+// HighlightLines higlights the given line ranges with the Highlight style.
+//
+// A range is the beginning and ending of a range as 1-based line numbers, inclusive.
+func HighlightLines(ranges [][2]int) Option {
+ return func(f *Formatter) {
+ f.highlightRanges = ranges
+ sort.Sort(f.highlightRanges)
+ }
+}
+
+// BaseLineNumber sets the initial number to start line numbering at. Defaults to 1.
+func BaseLineNumber(n int) Option {
+ return func(f *Formatter) {
+ f.baseLineNumber = n
+ }
+}
+
+// New HTML formatter.
+func New(options ...Option) *Formatter {
+ f := &Formatter{
+ baseLineNumber: 1,
+ preWrapper: defaultPreWrapper,
+ writeCSSComments: true,
+ }
+ f.styleCache = newStyleCache(f)
+ for _, option := range options {
+ option(f)
+ }
+ return f
+}
+
+// PreWrapper defines the operations supported in WithPreWrapper.
+type PreWrapper interface {
+ // Start is called to write a start
element.
+ // The code flag tells whether this block surrounds
+ // highlighted code. This will be false when surrounding
+ // line numbers.
+ Start(code bool, styleAttr string) string
+
+ // End is called to write the end
+
+1 Missing whitespace after block
+
+2 Missing whitespace after block
+
+
+
+
+
+
+[🔝](#table-of-content)
+
+### `after-decl`
+
+Declaration statements (`var`, `const`, `type`) should be followed by a blank
+line. Consecutive declarations of the same kind are allowed to cuddle, only the
+last one in a run needs the blank line.
+
+
+
Bad
Good
+
+
+
+```go
+var x int // 1
+x = 1
+
+var (
+ a = 1
+ b = 2
+) // 2
+fmt.Println(a, b)
+```
+
+
+
+```go
+var x int
+
+x = 1
+
+var (
+ a = 1
+ b = 2
+)
+
+fmt.Println(a, b)
+
+var a int
+var b int
+
+fmt.Println(a, b)
+```
+
+
+
+
+
+1 Missing whitespace after declaration
+
+2 Missing whitespace after declaration
+
+
+
+
+
+
+[🔝](#table-of-content)
+
+### `after-defer`
+
+`defer` statements should be followed by a blank line. Consecutive `defer`s
+are allowed to cuddle, only the last one in a run needs the blank line.
+
+
+
+[🔝](#table-of-content)
+
+### `after-expr`
+
+Expression statements (e.g. function calls used for their side effects) should
+be followed by a blank line. Consecutive expression statements are allowed to
+cuddle, only the last one in a run needs the blank line.
+
+**Exception:** an expression statement that is immediately followed by a
+`defer` referencing the same variable is exempt (e.g. `mu.Lock()` /
+`defer mu.Unlock()`), since these two statements form a single logical unit.
+
+
+
+[🔝](#table-of-content)
+
+### `after-go`
+
+`go` statements should be followed by a blank line. Consecutive `go`
+statements are allowed to cuddle, only the last one in a run needs the blank
+line.
+
+
+
+[🔝](#table-of-content)
+
+### `assign`
+
+Assign (`foo := bar`) or re-assignments (`foo = bar`) should only be cuddled
+with other assignments or increment/decrement.
+
+
+
+1 Not an assign statement above
+
+2 Not an assign statement above
+
+
+
+
+
+
+[🔝](#table-of-content)
+
+### `branch`
+
+> [!NOTE]
+> Configurable via `branch-max-lines`. See [Configuration](#configuration) for
+> details.
+
+Branch statement (`break`, `continue`, `fallthrough`, `goto`) should only be
+cuddled if the block is less than `n` lines where `n` is the value of
+`branch-max-statements`.
+
+
+
+1 Block is more than 2 lines so should be a blank line above
+
+
+
+
+
+
+[🔝](#table-of-content)
+
+### `decl`
+
+Declarations should never be cuddled. When grouping multiple declarations
+together they should be declared in the same group with parenthesis into a
+single statement. The benefit of this is that it also aligns the declaration or
+assignment increasing readability.
+
+> [!IMPORTANT]
+> The fixer can't do smart adjustments if there are comments on the same line
+> as the declaration.
+
+
+
Bad
Good
+
+
+
+```go
+var a string
+var b int // 1
+
+const a = 1
+const b = 2 // 2
+
+a := 1
+var b string // 3
+
+fmt.Println("hello")
+var a string // 4
+```
+
+
+
+```go
+var (
+ a string
+ b int
+)
+
+const (
+ a = 1
+ b = 2
+)
+
+a := 1
+
+var b string
+
+fmt.Println("hello")
+
+var a string
+```
+
+
+
+
+
+1 Multiple declarations should be grouped to one
+
+2 Multiple declarations should be grouped to one
+
+3 Declaration should always have a whitespace above
+
+4 Declaration should always have a whitespace above
+
+
+
+
+
+
+[🔝](#table-of-content)
+
+### `defer`
+
+Deferring execution should only be used directly in the context of what's being
+deferred and there should only be one statement above.
+
+
+
+1 More than a single statement between `defer` and `closeFn`
+
+2 `a` is not used in expression
+
+3 More than a single statement between `defer` and `f.Close`
+
+
+
+
+
+
+[🔝](#table-of-content)
+
+### `expr`
+
+Expressions can be multiple things and a big part of them are not handled by
+`wsl`. However all function calls are expressions which can be verified.
+
+> [!IMPORTANT]
+> This is one of the few rules with non-configurable exceptions. Given the
+> idiomatic way to acquire and release mutex locks and the fact that the `sync`
+> mutex from the standard library is so widely used, any call to `Lock`,
+> `RWLock`, or `TryLock` can be cuddled above any other statement(s) and
+> similarly `Unlock` and `RWUnlock` can be cuddled below any other
+> statement(s).
+
+
+
+[🔝](#table-of-content)
+
+### `for`
+
+> [!NOTE]
+> Configurable via `allow-first-in-block` to allow cuddling if the variable is
+> used _first_ in the block (enabled by default).
+>
+> Configurable via `allow-whole-block` to allow cuddling if the variable is used
+> _anywhere_ in the following block (disabled by default).
+>
+> Configurable via `cuddle-max-statements` to change the maximum number of
+> cuddled statements allowed (default 1).
+>
+> See [Configuration](#configuration) for details.
+
+
+
+1 `someFunc` is not used in expression
+
+2 `x` is not used in expression
+
+3 `someArg` is not used in expression
+
+
+
+
+
+
+[🔝](#table-of-content)
+
+### `if`
+
+> [!NOTE]
+> Configurable via `allow-first-in-block` to allow cuddling if the variable is
+> used _first_ in the block (enabled by default).
+>
+> Configurable via `allow-whole-block` to allow cuddling if the variable is used
+> _anywhere_ in the following block (disabled by default).
+>
+> Configurable via `cuddle-max-statements` to change the maximum number of
+> cuddled statements allowed (default 1).
+>
+> See [Configuration](#configuration) for details.
+
+`if` statements are one of several block statements (a statement with a block)
+that can have some form of expression or condition. To make block context more
+readable, only one variable is allowed immediately above the `if` statement and
+the variable must be used in the condition (unless configured otherwise).
+
+
+
+1 `x` is not used in expression
+
+2 More than one variable above statement
+
+3 `b` is not used in expression and too many statements
+
+4 No variable in expression
+
+5 More than one variable above statement
+
+
+
+1 Not an assign or inc/dec statement above
+
+2 Not an assign or inc/dec statement above
+
+
+
+
+
+
+[🔝](#table-of-content)
+
+### `label`
+
+Labels should never be cuddled. Labels in itself is often a symptom of big scope
+and split context and because of that should always have an empty line above.
+
+
+
+1 Labels should always have a whitespabe above
+
+
+
+
+
+
+[🔝](#table-of-content)
+
+### `range`
+
+> [!NOTE]
+> Configurable via `allow-first-in-block` to allow cuddling if the variable is
+> used _first_ in the block (enabled by default).
+>
+> Configurable via `allow-whole-block` to allow cuddling if the variable is used
+> _anywhere_ in the following block (disabled by default).
+>
+> Configurable via `cuddle-max-statements` to change the maximum number of
+> cuddled statements allowed (default 1).
+>
+> See [Configuration](#configuration) for details.
+
+
+
+```go
+someRange := []int{1, 2, 3}
+
+for _, i := range thisIsNotSomeRange {
+ fmt.Println(i)
+}
+
+someRange := []int{1, 2, 3}
+for _, i := range someRange {
+ fmt.Println(i)
+}
+
+notARange := 1
+for i := range returnsRange(notARange) {
+ fmt.Println(i)
+}
+
+s1 := []int{1, 2, 3}
+
+s2 := []int{3, 2, 1}
+for _, v := range s2 {
+ fmt.Println(v)
+}
+```
+
+
+
+
+
+1 `someRange` is not used in expression
+
+2 `x` is not used in expression
+
+3 More than one variable above statement
+
+
+
+
+
+
+[🔝](#table-of-content)
+
+### `return`
+
+> [!NOTE]
+> Configurable via `branch-max-lines`. See [Configuration](#configuration) for
+> details.
+
+Return statements is an important statement that is easiy to miss in larger code
+blocks. To better visualize the `return` statement and that the method is
+returning it should always be followed by a blank line unless the scope is as
+small as `branch-max-lines`.
+
+
+
+1 Block is more than 2 lines so should be a blank line above
+
+
+
+
+
+
+[🔝](#table-of-content)
+
+### `select`
+
+Identifiers used in case arms of select statements are allowed to be cuddled.
+
+> [!NOTE]
+> Configurable via `allow-first-in-block` to allow cuddling if the variable is
+> used _first_ in the block (enabled by default).
+>
+> Configurable via `allow-whole-block` to allow cuddling if the variable is used
+> _anywhere_ in the following block (disabled by default).
+>
+> Configurable via `cuddle-max-statements` to change the maximum number of
+> cuddled statements allowed (default 1).
+>
+> See [Configuration](#configuration) for details.
+
+
+
+1 `a` is not used in expression
+
+2 `b` is not used in expression
+
+
+
+
+
+
+[🔝](#table-of-content)
+
+### `switch`
+
+In addition to checking the switch condition, switch statements also checks
+identifiers in all case arms. If a variable is used in one or more of the case
+arms it's allowed to be cuddled.
+
+> [!NOTE]
+> Configurable via `allow-first-in-block` to allow cuddling if the variable is
+> used _first_ in the block (enabled by default).
+>
+> Configurable via `allow-whole-block` to allow cuddling if the variable is used
+> _anywhere_ in the following block (disabled by default).
+>
+> Configurable via `cuddle-max-statements` to change the maximum number of
+> cuddled statements allowed (default 1).
+>
+> See [Configuration](#configuration) for details.
+
+
+
+1 `x` is not used in expression
+
+2 More than one variable above statement
+
+
+
+
+
+
+[🔝](#table-of-content)
+
+### `type-switch`
+
+> [!NOTE]
+> Configurable via `allow-first-in-block` to allow cuddling if the variable is
+> used _first_ in the block (enabled by default).
+>
+> Configurable via `allow-whole-block` to allow cuddling if the variable is used
+> _anywhere_ in the following block (disabled by default).
+>
+> Configurable via `cuddle-max-statements` to change the maximum number of
+> cuddled statements allowed (default 1).
+>
+> See [Configuration](#configuration) for details.
+
+
+
+[🔝](#table-of-content)
+
+### `append`
+
+Append enables strict `append` checking where assignments that are
+re-assignments with `append` (e.g. `x = append(x, y)`) is only allowed to be
+cuddled with other assignments if the `append` uses the variable on the line
+above.
+
+
+
+1 `a` is not a re-assignment
+
+2 `b` is not a new assignment
+
+3 `c` is not a re-assignment
+
+
+
+
+
+
+[🔝](#table-of-content)
+
+### `assign-expr`
+
+Assignments are allowed to be cuddled with expressions, primarily to support
+mixing assignments and function calls which can often make sense in shorter
+flows. By enabling this check `wsl` will ensure assignments are not cuddled with
+expressions.
+
+
+
+1 Whitespace between error assignment and error checking
+
+
+
+
+
+
+[🔝](#table-of-content)
+
+### `cuddle-group`
+
+Treats the cuddled chain above a trigger statement (`if`, `for`, `switch`,
+etc., `go`, `defer`, `send`) as a single unit. The chain stays cuddled with
+the trigger only when _every_ cuddled statement shares a variable with the
+trigger _and_ the number of sharing statements is within
+`cuddle-max-statements`.
+
+Without this check, the same violations are reported on a cuddled statement
+inside the chain, splitting the group between variables.
+
+
+
Bad
Good
+
+
+
+```go
+// With the default cuddle-max-statements: 1
+a := 1
+b := 2
+if a > b { // 1
+ fmt.Println("ok")
+}
+
+// Mid-chain non-sharing
+notUsed := 1
+b := 2
+if b > 0 { // 2
+ fmt.Println("ok")
+}
+```
+
+
+
+```go
+// With the default cuddle-max-statements: 1
+a := 1
+b := 2
+
+if a > b {
+ fmt.Println("ok")
+}
+
+// Without cuddle-group, the same input is fixed by
+// splitting between the cuddled variables instead:
+a := 1
+
+b := 2
+if a > b {
+ fmt.Println("ok")
+}
+
+// Mid-chain non-sharing — group still separated as
+// a unit:
+notUsed := 1
+b := 2
+
+if b > 0 {
+ fmt.Println("ok")
+}
+```
+
+
+
+
+
+1 Two cuddled statements share a variable with `if`; with
+`cuddle-group` enabled the group stays cuddled and the blank line goes above
+the `if` instead of between the variables
+
+2 Only one cuddled statement shares with `if`, but a non-sharing
+stmt (`notUsed`) is in the chain so `cuddle-group` separates the entire group
+from the `if` rather than splitting between `notUsed` and `b`
+
+
+
+[🔝](#table-of-content)
+
+## Configuration
+
+One shared logic across different checks is the logic around statements
+containing a block, i.e. a statement with a following `{}` (e.g. `if`, `for`,
+`switch` etc).
+
+`wsl` only allows one statement immediately above and that statement must also
+be referenced in the expression in the statement with the block. E.g.
+
+```go
+someVariable := true
+if someVariable {
+ // Here `someVariable` used in the `if` expression is the only variable
+ // immediately above the statement.
+}
+```
+
+This can be configured to be more "laxed" by also allowing a single statement
+immediately above if it's used either first in the following block or anywhere
+inside the following block.
+
+### `allow-first-in-block`
+
+By setting this to true (default), the variable doesn't have to be used in the
+expression itself but is also allowed if it's the first statement in the block
+body.
+
+```go
+someVariable := 1
+if anotherVariable {
+ someVariable++
+}
+```
+
+[🔝](#table-of-content)
+
+### `allow-whole-block`
+
+This is similar to `allow-first-in-block` but now allows the lack of whitespace
+if it's used anywhere in the following block.
+
+```go
+someVariable := 1
+if anotherVariable {
+ someFn(yetAnotherVariable)
+
+ if stillNotSomeVariable {
+ someVariable++
+ }
+}
+```
+
+[🔝](#table-of-content)
+
+### `branch-max-lines`
+
+When set to a value greater than 0, `return`, `break`, `continue`, `fallthrough`
+and `goto` statements that appear in a block with more than this many lines will
+require a blank line above them. The default is 2, meaning blocks of 3 or more
+lines require a blank line above the branch statement.
+
+
+
+```go
+// With branch-max-lines: 2 (default)
+func Fn() {
+ a, err := someFn()
+ if err != nil {
+ panic(err)
+ }
+
+ fmt.Println(a)
+
+ return
+}
+
+// Short block: no blank line required
+func ShortFn() int {
+ x := compute()
+ return x
+}
+```
+
+
+
+
+
+1 Block has more than 2 lines, blank line required above
+
+
+
+
+
+
+[🔝](#table-of-content)
+
+### `case-max-lines`
+
+When set to a value greater than 0, case clauses in `switch` and `select`
+statements that exceed this number of lines will require a blank line before the
+next case. Setting this to 1 will make it always enabled.
+
+Comments between case clauses are handled based on their indentation:
+
+- **Indented comments** (deeper than `case`) are treated as trailing comments
+ that belong to the current case body.
+- **Left-aligned comments** (at the same level as `case`) are treated as leading
+ comments that belong to the next case.
+
+The blank line is placed at the transition point between trailing and leading
+content. This means:
+
+- If all comments are indented, the blank line goes before the next `case`.
+- If all comments are left-aligned, the blank line goes after the last
+ statement.
+- If comments transition from indented to left-aligned, the blank line goes at
+ the transition point.
+
+Additionally, left-aligned comments must be flush against the next `case` - no
+blank line is allowed between them. This ensures consistent formatting where
+leading comments are visually attached to the case they describe.
+
+
+
+1 Missing blank line after case body
+
+2 Missing blank line after trailing comment
+
+3 Missing blank line at transition (after trailing comment)
+
+4 Unnecessary blank line before case (after leading comment)
+
+
+
+
+
+
+[🔝](#table-of-content)
+
+### `cuddle-max-statements`
+
+Controls the maximum number of consecutive statements that may be cuddled
+(appear without a blank line) immediately above block statements (`if`, `for`,
+`switch`, etc.), `go`, `defer`, and `send`. The default is 1. Every cuddled
+statement must share at least one variable with the following block (respects
+`allow-first-in-block` and `allow-whole-block`).
+
+Setting it to `0` disallows any cuddling, the trigger always requires a blank
+line above it, even when the variable on the line above is used by the block.
+The recommended way to allow any number of statements is to set a really high
+number such as `9999`.
+
+
+
+```go
+// With cuddle-max-statements: 1 (default)
+a := 1
+
+b := 2
+if a < b {
+ fmt.Println("ok")
+}
+
+// With cuddle-max-statements: 2
+a := 1
+b := 2
+if a < b {
+ fmt.Println("ok")
+}
+
+// With cuddle-max-statements: 0
+a := 1
+
+if a > 0 {
+ fmt.Println("ok")
+}
+```
+
+
+
+
+
+1 Two statements cuddled above `if`, exceeds default limit of 1
+
+2 Three statements cuddled above `if`, exceeds limit of 2
+
+3 One statement cuddled above `if`; with `0` even a single shared
+variable still requires a blank line above the trigger
+
+
+
+
+
+
+[🔝](#table-of-content)
diff --git a/vendor/github.com/bombsimon/wsl/v5/LICENSE b/vendor/github.com/bombsimon/wsl/v5/LICENSE
new file mode 100644
index 0000000000..f881b648ef
--- /dev/null
+++ b/vendor/github.com/bombsimon/wsl/v5/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2018 - 2025 Simon Sawert
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/vendor/github.com/bombsimon/wsl/v5/README.md b/vendor/github.com/bombsimon/wsl/v5/README.md
new file mode 100644
index 0000000000..fefe7ddc7c
--- /dev/null
+++ b/vendor/github.com/bombsimon/wsl/v5/README.md
@@ -0,0 +1,205 @@
+# wsl - whitespace linter
+
+[](https://github.com/bombsimon/wsl/actions/workflows/go.yml)
+[](https://coveralls.io/github/bombsimon/wsl?branch=main)
+
+`wsl` (**w**hite**s**pace **l**inter) is a linter that wants you to use empty
+lines to separate grouping of different types to increase readability. There are
+also a few places where it encourages you to _remove_ whitespaces which is at
+the start and the end of blocks or between assigning and error checking.
+
+## Checks and configuration
+
+Each check can be disabled or enabled individually to the point where no checks
+can be run. The idea with this is to attract more users. Some checks have
+configuration that affect how they work but most of them can only be turned on
+or off.
+
+### Checks
+
+This is an exhaustive list of all the checks that can be enabled or disabled and
+their default value. The names are the same as the Go
+[AST](https://pkg.go.dev/go/ast) type name for built-ins.
+
+The base rule is that statements that has a block (e.g. `for`, `range`,
+`switch`, `if` etc) should only be cuddled with variables that are used in the
+block. By default only a single cuddled statement is allowed, but this can be
+changed with [`cuddle-max-statements`](#configuration).
+
+For more details and examples, see [CHECKS](CHECKS.md).
+
+✅ = enabled by default, ❌ = disabled by default
+
+#### Built-ins and keywords
+
+- ✅ **assign** - Assignments should only be cuddled with other assignments,
+ or increment/decrement
+- ✅ **branch** - Branch statement (`break`, `continue`, `fallthrough`, `goto`)
+ should only be cuddled if the block is less than `n` lines where `n` is the
+ value of [`branch-max-lines`](#configuration)
+- ✅ **decl** - Declarations should never be cuddled
+- ✅ **defer** - Defer should only be cuddled with other `defer`, after error
+ checking or with a single variable used on the line above
+- ✅ **expr** - Expressions are e.g. function calls or index expressions, they
+ should only be cuddled with variables used on the line above
+- ✅ **for** - For loops should only be cuddled with a single variable used on
+ the line above
+- ✅ **go** - Go should only be cuddled with other `go` or a single variable
+ used on the line above
+- ✅ **if** - If should only be cuddled with a single variable used on the line
+ above
+- ✅ **inc-dec** - Increment/decrement (`++/--`) has the same rules as `assign`
+- ✅ **label** - Labels should never be cuddled
+- ✅ **range** - Range should only be cuddled with a single variable used on the
+ line above
+- ✅ **return** - Return should only be cuddled if the block is less than `n`
+ lines where `n` is the value of [`branch-max-lines`](#configuration)
+- ✅ **select** - Select should only be cuddled with a single variable used on
+ the line above
+- ✅ **send** - Send should only be cuddled with a single variable used on the
+ line above
+- ✅ **switch** - Switch should only be cuddled with a single variable used on
+ the line above
+- ✅ **type-switch** - Type switch should only be cuddled with a single variable
+ used on the line above
+
+#### Specific `wsl` cases
+
+- ❌ **after-block** - Require empty line after block statements
+- ❌ **after-decl** - Require empty line after declaration (`var`, `const`,
+ `type`) statements
+- ❌ **after-defer** - Require empty line after `defer` statements
+- ❌ **after-expr** - Require empty line after expression statements
+- ❌ **after-go** - Require empty line after `go` statements
+- ✅ **append** - Only allow re-assigning with `append` if the value being
+ appended exist on the line above
+- ❌ **assign-exclusive** - Only allow cuddling either new variables or
+ re-assigning of existing ones
+- ❌ **assign-expr** - Don't allow assignments to be cuddled with expressions,
+ e.g. function calls
+- ❌ **cuddle-group** - Treat the cuddled chain as a unit; separate the whole
+ group from the block instead of splitting between cuddled variables
+- ✅ **err** - Error checking must follow immediately after the error variable
+ is assigned
+- ✅ **leading-whitespace** - Disallow leading empty lines in blocks
+- ✅ **trailing-whitespace** - Disallow trailing empty lines in blocks
+
+### Configuration
+
+Other than enabling or disabling specific checks some checks can be configured
+in more details. See [CHECKS.md](CHECKS.md#configuration) for details and
+examples.
+
+- ✅ **allow-first-in-block** - Allow cuddling a variable if it's used first in
+ the immediate following block, even if the statement with the block doesn't
+ use the variable
+- ❌ **allow-whole-block** - Same as above, but allows cuddling if the variable
+ is used _anywhere_ in the following (or nested) block
+- **branch-max-lines** - If a block contains more than this number of lines the
+ branch statement (e.g. `return`, `break`, `continue`) need to be separated by
+ a whitespace (default 2)
+- **case-max-lines** - If set to a non negative number, `case` blocks needs to
+ end with a whitespace if exceeding this number (default 0, 0 = off, 1 =
+ always)
+- **cuddle-max-statements** - Max number of cuddled statements allowed above
+ block statements, `go`, `defer` and `send`. Every cuddled statement must have
+ at least one variable used in the block. Respects `allow-first-in-block` and
+ `allow-whole-block`. With `0` no cuddling is allowed at all — every
+ cuddle-checked trigger requires a blank line above it (default 1)
+- ❌ **include-generated** - Include generated files when checking
+
+## Installation
+
+```sh
+# Latest release
+go install github.com/bombsimon/wsl/v5/cmd/wsl@latest
+
+# Main branch
+go install github.com/bombsimon/wsl/v5/cmd/wsl@main
+```
+
+## Usage
+
+> **Note**: This linter provides a fixer that can fix most issues with the
+> `--fix` flag.
+
+`wsl` uses the [analysis] package meaning it will operate on package level with
+the default analysis flags and way of working.
+
+```sh
+wsl --help
+wsl [flags]
+
+wsl --default none --enable branch,return --fix ./...
+```
+
+`wsl` is also integrated in [`golangci-lint`][golangci-lint] but since v5 which
+had a bunch of breaking changes it's renamed to `wsl_v5`. The previous version
+of `wsl` is deprecated and will be removed from `golangci-lint` eventually.
+
+```sh
+golangci-lint run --no-config --enable-only wsl_v5 --fix
+```
+
+This is an exhaustive, default, configuration for `wsl_v5` in `golangci-lint`.
+
+```yaml
+linters:
+ default: none
+ enable:
+ - wsl_v5
+
+ settings:
+ wsl_v5:
+ allow-first-in-block: true
+ allow-whole-block: false
+ branch-max-lines: 2
+ case-max-lines: 0
+ cuddle-max-statements: 1
+ default: ~ # Can be `all`, `none`, `default` or empty
+ enable:
+ - append
+ - assign
+ - branch
+ - decl
+ - defer
+ - err
+ - expr
+ - for
+ - go
+ - if
+ - inc-dec
+ - label
+ - range
+ - return
+ - select
+ - send
+ - switch
+ - type-switch
+ - leading-whitespace
+ - trailing-whitespace
+ disable:
+ - after-block
+ - after-decl
+ - after-defer
+ - after-expr
+ - after-go
+ - assign-exclusive
+ - assign-expr
+ - cuddle-group
+```
+
+## See also
+
+- [`newline-after-block`][newline-after-block] - Require newline after blocks
+- [`nlreturn`][nlreturn] - Use empty lines before `return`
+- [`whitespace`][whitespace] - Don't use a blank newline at the start or end of
+ a block.
+- [`gofumpt`][gofumpt] - Stricter formatter than `gofmt`.
+
+ [analysis]: https://pkg.go.dev/golang.org/x/tools/go/analysis
+ [gofumpt]: https://github.com/mvdan/gofumpt
+ [golangci-lint]: https://golangci-lint.run
+ [newline-after-block]: https://github.com/breml/newline-after-block
+ [nlreturn]: https://github.com/ssgreg/nlreturn
+ [whitespace]: https://github.com/ultraware/whitespace
diff --git a/vendor/github.com/bombsimon/wsl/v5/analyzer.go b/vendor/github.com/bombsimon/wsl/v5/analyzer.go
new file mode 100644
index 0000000000..81a4bc4f10
--- /dev/null
+++ b/vendor/github.com/bombsimon/wsl/v5/analyzer.go
@@ -0,0 +1,199 @@
+package wsl
+
+import (
+ "flag"
+ "fmt"
+ "go/ast"
+ "go/token"
+ "os"
+ "strings"
+ "sync"
+
+ "golang.org/x/tools/go/analysis"
+)
+
+const version = "wsl version v5.9.0"
+
+func NewAnalyzer(config *Configuration) *analysis.Analyzer {
+ wa := &wslAnalyzer{config: config}
+
+ return &analysis.Analyzer{
+ Name: "wsl",
+ Doc: "add or remove empty lines",
+ Flags: wa.flags(),
+ Run: wa.run,
+ RunDespiteErrors: true,
+ }
+}
+
+// wslAnalyzer is a wrapper around the configuration which is used to be able to
+// set the configuration when creating the analyzer and later be able to update
+// flags and running method.
+type wslAnalyzer struct {
+ config *Configuration
+
+ // When we use flags, we need to parse the ones used for checks into
+ // temporary variables so we can create the check set once the flag is being
+ // parsed by the analyzer and we run our analyzer.
+ defaultChecks string
+ enable []string
+ disable []string
+
+ // To only validate and convert the parsed flags once we use a `sync.Once`
+ // to only create a check set once and store the set and potential error. We
+ // also store if we actually had a configuration to ensure we don't
+ // overwrite the checks if the analyzer was created with a proper wsl
+ // config.
+ cfgOnce sync.Once
+ didHaveConfig bool
+ checkSetErr error
+}
+
+func (wa *wslAnalyzer) flags() flag.FlagSet {
+ flags := flag.NewFlagSet("wsl", flag.ExitOnError)
+
+ if wa.config != nil {
+ wa.didHaveConfig = true
+ return *flags
+ }
+
+ wa.config = NewConfig()
+
+ flags.BoolVar(&wa.config.IncludeGenerated, "include-generated", false, "Include generated files")
+ flags.BoolVar(&wa.config.AllowFirstInBlock, "allow-first-in-block", true, "Allow cuddling if variable is used in the first statement in the block")
+ flags.BoolVar(&wa.config.AllowWholeBlock, "allow-whole-block", false, "Allow cuddling if variable is used anywhere in the block")
+ flags.IntVar(&wa.config.BranchMaxLines, "branch-max-lines", 2, "Max lines before requiring newline before branching, e.g. `return`, `break`, `continue`")
+ flags.IntVar(&wa.config.CaseMaxLines, "case-max-lines", 0, "Max lines before requiring a newline at the end of case (0 = never)")
+ flags.IntVar(&wa.config.CuddleMaxStatements, "cuddle-max-statements", 1, "Max number of cuddled statements above statements")
+
+ flags.StringVar(&wa.defaultChecks, "default", "", "Can be 'all' for all checks or 'none' for no checks or empty for default checks")
+ flags.Var(&multiStringValue{slicePtr: &wa.enable}, "enable", "Comma separated list of checks to enable")
+ flags.Var(&multiStringValue{slicePtr: &wa.disable}, "disable", "Comma separated list of checks to disable")
+ flags.Var(new(versionFlag), "V", "print version and exit")
+
+ return *flags
+}
+
+func (wa *wslAnalyzer) run(pass *analysis.Pass) (any, error) {
+ wa.cfgOnce.Do(func() {
+ // No need to update checks if config was passed when creating the
+ // analyzer.
+ if wa.didHaveConfig {
+ return
+ }
+
+ // Parse the check params once if we set our config from flags.
+ wa.config.Checks, wa.checkSetErr = NewCheckSet(wa.defaultChecks, wa.enable, wa.disable)
+ })
+
+ if wa.checkSetErr != nil {
+ return nil, wa.checkSetErr
+ }
+
+ for _, file := range pass.Files {
+ filename := getFilename(pass.Fset, file)
+ if !strings.HasSuffix(filename, ".go") {
+ continue
+ }
+
+ // if the file is related to cgo the filename of the unadjusted position
+ // is a not a '.go' file.
+ unadjustedFilename := pass.Fset.PositionFor(file.Pos(), false).Filename
+
+ // if the file is related to cgo the filename of the unadjusted position
+ // is a not a '.go' file.
+ if !strings.HasSuffix(unadjustedFilename, ".go") {
+ continue
+ }
+
+ // The file is skipped if the "unadjusted" file is a Go file, and it's a
+ // generated file (ex: "_test.go" file). The other non-Go files are
+ // skipped by the first 'if' with the adjusted position.
+ if !wa.config.IncludeGenerated && ast.IsGenerated(file) {
+ continue
+ }
+
+ wsl := New(file, pass, wa.config)
+ wsl.Run()
+
+ for pos, fix := range wsl.issues {
+ textEdits := []analysis.TextEdit{}
+
+ for _, f := range fix.fixRanges {
+ textEdits = append(textEdits, analysis.TextEdit{
+ Pos: f.fixRangeStart,
+ End: f.fixRangeEnd,
+ NewText: f.fix,
+ })
+ }
+
+ pass.Report(analysis.Diagnostic{
+ Pos: pos,
+ Category: "whitespace",
+ Message: fix.message,
+ SuggestedFixes: []analysis.SuggestedFix{
+ {
+ TextEdits: textEdits,
+ },
+ },
+ })
+ }
+ }
+
+ //nolint:nilnil // A pass don't need to return anything.
+ return nil, nil
+}
+
+// multiStringValue is a flag that supports multiple values. It's implemented to
+// contain a pointer to a string slice that will be overwritten when the flag's
+// `Set` method is called.
+type multiStringValue struct {
+ slicePtr *[]string
+}
+
+// Set implements the flag.Value interface and will overwrite the pointer to
+// the
+// slice with a new pointer after splitting the flag by comma.
+func (m *multiStringValue) Set(value string) error {
+ var s []string
+
+ for v := range strings.SplitSeq(value, ",") {
+ s = append(s, strings.TrimSpace(v))
+ }
+
+ *m.slicePtr = s
+
+ return nil
+}
+
+// String implements the flag.Value interface.
+func (m *multiStringValue) String() string {
+ if m.slicePtr == nil {
+ return ""
+ }
+
+ return strings.Join(*m.slicePtr, ", ")
+}
+
+// https://cs.opensource.google/go/x/tools/+/refs/tags/v0.35.0:go/analysis/internal/analysisflags/flags.go;l=188-237;drc=99337ebe7b90918701a41932abf121600b972e34
+type versionFlag string
+
+func (*versionFlag) IsBoolFlag() bool { return true }
+func (*versionFlag) Get() any { return nil }
+func (*versionFlag) String() string { return "" }
+
+func (*versionFlag) Set(_ string) error {
+ fmt.Println(version)
+ os.Exit(0)
+
+ return nil
+}
+
+func getFilename(fset *token.FileSet, file *ast.File) string {
+ filename := fset.PositionFor(file.Pos(), true).Filename
+ if !strings.HasSuffix(filename, ".go") {
+ return fset.PositionFor(file.Pos(), false).Filename
+ }
+
+ return filename
+}
diff --git a/vendor/github.com/bombsimon/wsl/v5/config.go b/vendor/github.com/bombsimon/wsl/v5/config.go
new file mode 100644
index 0000000000..3df689a1de
--- /dev/null
+++ b/vendor/github.com/bombsimon/wsl/v5/config.go
@@ -0,0 +1,335 @@
+package wsl
+
+import (
+ "fmt"
+ "strings"
+)
+
+// CheckSet is a set of checks to run.
+type CheckSet map[CheckType]struct{}
+
+// CheckType is a type that represents a checker to run.
+type CheckType int
+
+// Each checker is represented by a CheckType that is used to enable or disable
+// the check.
+// A check can either be of a specific built-in keyword or custom checks.
+const (
+ CheckInvalid CheckType = iota
+ CheckAssign
+ CheckBranch
+ CheckDecl
+ CheckDefer
+ CheckExpr
+ CheckFor
+ CheckGo
+ CheckIf
+ CheckIncDec
+ CheckLabel
+ CheckRange
+ CheckReturn
+ CheckSelect
+ CheckSend
+ CheckSwitch
+ CheckTypeSwitch
+
+ // CheckAfterBlock ensures there's a newline after each block.
+ CheckAfterBlock
+ // CheckAfterDecl ensures there's a newline after a declaration statement
+ // (`var`, `const`, `type`) unless the following statement is another
+ // declaration.
+ CheckAfterDecl
+ // CheckAfterDefer ensures there's a newline after a `defer` statement
+ // unless the following statement is another `defer`.
+ CheckAfterDefer
+ // CheckAfterExpr ensures there's a newline after an expression statement
+ // unless the following statement is another expression statement.
+ CheckAfterExpr
+ // CheckAfterGo ensures there's a newline after a `go` statement unless the
+ // following statement is another `go`.
+ CheckAfterGo
+ // CheckAppend only allows assignments of `append` to be cuddled with other
+ // assignments if it's a variable used in the append statement, e.g.
+ //
+ // a := 1
+ // x = append(x, a)
+ // .
+ CheckAppend
+ // CheckAssignExclusive only allows assignments of either new variables or
+ // re-assignment of existing ones, e.g.
+ //
+ // a := 1
+ // b := 2
+ //
+ // a = 1
+ // b = 2
+ // .
+ CheckAssignExclusive
+ // CheckAssignExpr will check so assignments are not cuddled with expression
+ // nodes, e.g.
+ //
+ // t1.Fn1()
+ //
+ // x := t1.Fn2()
+ // t1.Fn3()
+ // .
+ CheckAssignExpr
+ // CheckCuddleGroup changes how cuddle-max-statements violations are
+ // reported when more than the configured number of cuddled statements
+ // share a variable with the trigger statement (e.g. `if`, `for`,
+ // `switch`). Instead of pointing at the (N+1)th cuddled statement and
+ // splitting the cuddled group, the diagnostic is placed on the trigger
+ // itself so the entire cuddled group stays together and gets separated
+ // from the trigger by a blank line, e.g.
+ //
+ // a := 1
+ // b := 2
+ //
+ // if a > b {}
+ // .
+ CheckCuddleGroup
+ // CheckErr force error checking to follow immediately after an error
+ // variable is assigned, e.g.
+ //
+ // _, err := someFn()
+ // if err != nil {
+ // panic(err)
+ // }
+ // .
+ CheckErr
+ CheckLeadingWhitespace
+ CheckTrailingWhitespace
+
+ //nolint:godoclint // No need to document
+ // CheckTypes only used for reporting.
+ CheckCaseTrailingNewline
+)
+
+func (c CheckType) String() string {
+ return [...]string{
+ "invalid",
+ "assign",
+ "branch",
+ "decl",
+ "defer",
+ "expr",
+ "for",
+ "go",
+ "if",
+ "inc-dec",
+ "label",
+ "range",
+ "return",
+ "select",
+ "send",
+ "switch",
+ "type-switch",
+ //
+ "after-block",
+ "after-decl",
+ "after-defer",
+ "after-expr",
+ "after-go",
+ "append",
+ "assign-exclusive",
+ "assign-expr",
+ "cuddle-group",
+ "err",
+ "leading-whitespace",
+ "trailing-whitespace",
+ //
+ "case-trailing-newline",
+ }[c]
+}
+
+type Configuration struct {
+ IncludeGenerated bool
+ AllowFirstInBlock bool
+ AllowWholeBlock bool
+ BranchMaxLines int
+ CaseMaxLines int
+ CuddleMaxStatements int
+ Checks CheckSet
+}
+
+func NewConfig() *Configuration {
+ return &Configuration{
+ IncludeGenerated: false,
+ AllowFirstInBlock: true,
+ AllowWholeBlock: false,
+ CaseMaxLines: 0,
+ BranchMaxLines: 2,
+ CuddleMaxStatements: 1,
+ Checks: DefaultChecks(),
+ }
+}
+
+func NewWithChecks(
+ defaultChecks string,
+ enable []string,
+ disable []string,
+) (*Configuration, error) {
+ checks, err := NewCheckSet(defaultChecks, enable, disable)
+ if err != nil {
+ return nil, fmt.Errorf("failed to create config: %w", err)
+ }
+
+ cfg := NewConfig()
+ cfg.Checks = checks
+
+ return cfg, nil
+}
+
+func NewCheckSet(
+ defaultChecks string,
+ enable []string,
+ disable []string,
+) (CheckSet, error) {
+ var cs CheckSet
+
+ switch strings.ToLower(defaultChecks) {
+ case "", "default":
+ cs = DefaultChecks()
+ case "all":
+ cs = AllChecks()
+ case "none":
+ cs = NoChecks()
+ default:
+ return nil, fmt.Errorf("invalid preset '%s', must be `all`, `none` or `` (empty)", defaultChecks)
+ }
+
+ for _, s := range enable {
+ check, err := CheckFromString(s)
+ if err != nil {
+ return nil, fmt.Errorf("invalid check '%s'", s)
+ }
+
+ cs.Add(check)
+ }
+
+ for _, s := range disable {
+ check, err := CheckFromString(s)
+ if err != nil {
+ return nil, fmt.Errorf("invalid check '%s'", s)
+ }
+
+ cs.Remove(check)
+ }
+
+ return cs, nil
+}
+
+func DefaultChecks() CheckSet {
+ return CheckSet{
+ CheckAppend: {},
+ CheckAssign: {},
+ CheckBranch: {},
+ CheckDecl: {},
+ CheckDefer: {},
+ CheckErr: {},
+ CheckExpr: {},
+ CheckFor: {},
+ CheckGo: {},
+ CheckIf: {},
+ CheckIncDec: {},
+ CheckLabel: {},
+ CheckLeadingWhitespace: {},
+ CheckTrailingWhitespace: {},
+ CheckRange: {},
+ CheckReturn: {},
+ CheckSelect: {},
+ CheckSend: {},
+ CheckSwitch: {},
+ CheckTypeSwitch: {},
+ }
+}
+
+func AllChecks() CheckSet {
+ c := DefaultChecks()
+ c.Add(CheckAssignExclusive)
+ c.Add(CheckAssignExpr)
+ c.Add(CheckAfterBlock)
+ c.Add(CheckAfterDecl)
+ c.Add(CheckAfterDefer)
+ c.Add(CheckAfterExpr)
+ c.Add(CheckAfterGo)
+ c.Add(CheckCuddleGroup)
+
+ return c
+}
+
+func NoChecks() CheckSet {
+ return CheckSet{}
+}
+
+func (c CheckSet) Add(check CheckType) {
+ c[check] = struct{}{}
+}
+
+func (c CheckSet) Remove(check CheckType) {
+ delete(c, check)
+}
+
+func CheckFromString(s string) (CheckType, error) {
+ switch strings.ToLower(s) {
+ case "assign":
+ return CheckAssign, nil
+ case "branch":
+ return CheckBranch, nil
+ case "decl":
+ return CheckDecl, nil
+ case "defer":
+ return CheckDefer, nil
+ case "expr":
+ return CheckExpr, nil
+ case "for":
+ return CheckFor, nil
+ case "go":
+ return CheckGo, nil
+ case "if":
+ return CheckIf, nil
+ case "inc-dec":
+ return CheckIncDec, nil
+ case "label":
+ return CheckLabel, nil
+ case "range":
+ return CheckRange, nil
+ case "return":
+ return CheckReturn, nil
+ case "select":
+ return CheckSelect, nil
+ case "send":
+ return CheckSend, nil
+ case "switch":
+ return CheckSwitch, nil
+ case "type-switch":
+ return CheckTypeSwitch, nil
+
+ case "after-block":
+ return CheckAfterBlock, nil
+ case "after-decl":
+ return CheckAfterDecl, nil
+ case "after-defer":
+ return CheckAfterDefer, nil
+ case "after-expr":
+ return CheckAfterExpr, nil
+ case "after-go":
+ return CheckAfterGo, nil
+ case "append":
+ return CheckAppend, nil
+ case "assign-exclusive":
+ return CheckAssignExclusive, nil
+ case "assign-expr":
+ return CheckAssignExpr, nil
+ case "err":
+ return CheckErr, nil
+ case "cuddle-group":
+ return CheckCuddleGroup, nil
+ case "leading-whitespace":
+ return CheckLeadingWhitespace, nil
+ case "trailing-whitespace":
+ return CheckTrailingWhitespace, nil
+ default:
+ return CheckInvalid, fmt.Errorf("invalid check '%s'", s)
+ }
+}
diff --git a/vendor/github.com/bombsimon/wsl/v5/cursor.go b/vendor/github.com/bombsimon/wsl/v5/cursor.go
new file mode 100644
index 0000000000..229a198e51
--- /dev/null
+++ b/vendor/github.com/bombsimon/wsl/v5/cursor.go
@@ -0,0 +1,114 @@
+package wsl
+
+import (
+ "go/ast"
+)
+
+// Cursor holds a list of statements and a pointer to where in the list we are.
+// Each block gets a new cursor and can be used to check previous or coming
+// statements.
+type Cursor struct {
+ currentIdx int
+ statements []ast.Stmt
+ checkType CheckType
+ // rbraceLine is the source line of the enclosing block's closing brace.
+ // It is used to avoid false positives when checking for trailing comments:
+ // an inline comment that sits on the same line as the closing brace belongs
+ // to the brace itself, not to the last statement inside the block.
+ // Zero means the enclosing block boundary is unknown (e.g. case clauses).
+ rbraceLine int
+}
+
+// NewCursor creates a new cursor with a given list of statements.
+func NewCursor(statements []ast.Stmt) *Cursor {
+ return &Cursor{
+ currentIdx: -1,
+ statements: statements,
+ }
+}
+
+// NewBlockCursor creates a cursor for the statements of a known block, recording
+// the source line of the block's closing brace so that trailing-comment checks
+// can ignore inline comments that sit on the brace itself.
+func NewBlockCursor(statements []ast.Stmt, rbraceLine int) *Cursor {
+ return &Cursor{
+ currentIdx: -1,
+ statements: statements,
+ rbraceLine: rbraceLine,
+ }
+}
+
+func (c *Cursor) SetChecker(ct CheckType) {
+ c.checkType = ct
+}
+
+func (c *Cursor) NextNode() ast.Node {
+ defer c.Save()()
+
+ var nextNode ast.Node
+ if c.Next() {
+ nextNode = c.Stmt()
+ }
+
+ return nextNode
+}
+
+func (c *Cursor) Next() bool {
+ if c.currentIdx >= len(c.statements)-1 {
+ return false
+ }
+
+ c.currentIdx++
+
+ return true
+}
+
+func (c *Cursor) Previous() bool {
+ if c.currentIdx <= 0 {
+ return false
+ }
+
+ c.currentIdx--
+
+ return true
+}
+
+func (c *Cursor) PreviousNode() ast.Node {
+ defer c.Save()()
+
+ var previousNode ast.Node
+ if c.Previous() {
+ previousNode = c.Stmt()
+ }
+
+ return previousNode
+}
+
+func (c *Cursor) Stmt() ast.Stmt {
+ return c.statements[c.currentIdx]
+}
+
+func (c *Cursor) Save() func() {
+ idx := c.currentIdx
+
+ return func() {
+ c.currentIdx = idx
+ }
+}
+
+func (c *Cursor) Len() int {
+ return len(c.statements)
+}
+
+func (c *Cursor) Nth(n int) ast.Stmt {
+ return c.statements[n]
+}
+
+func (c *Cursor) NthPrevious(n int) ast.Node {
+ idx := c.currentIdx - n
+ if idx < 0 {
+ return nil
+ }
+
+ return c.statements[idx]
+}
diff --git a/vendor/github.com/bombsimon/wsl/v5/renovate.json b/vendor/github.com/bombsimon/wsl/v5/renovate.json
new file mode 100644
index 0000000000..cc31624f27
--- /dev/null
+++ b/vendor/github.com/bombsimon/wsl/v5/renovate.json
@@ -0,0 +1,4 @@
+{
+ "$schema": "https://docs.renovatebot.com/renovate-schema.json",
+ "extends": ["config:recommended", ":disableDependencyDashboard"]
+}
diff --git a/vendor/github.com/bombsimon/wsl/v5/wsl.go b/vendor/github.com/bombsimon/wsl/v5/wsl.go
new file mode 100644
index 0000000000..d5581fc9ad
--- /dev/null
+++ b/vendor/github.com/bombsimon/wsl/v5/wsl.go
@@ -0,0 +1,1846 @@
+package wsl
+
+import (
+ "bytes"
+ "fmt"
+ "go/ast"
+ "go/format"
+ "go/token"
+ "go/types"
+ "math"
+ "slices"
+
+ "golang.org/x/tools/go/analysis"
+)
+
+const (
+ messageMissingWhitespaceAbove = "missing whitespace above this line"
+ messageMissingWhitespaceBelow = "missing whitespace below this line"
+ messageRemoveWhitespace = "unnecessary whitespace"
+)
+
+type fixRange struct {
+ fixRangeStart token.Pos
+ fixRangeEnd token.Pos
+ fix []byte
+}
+
+type issue struct {
+ message string
+ // We can report multiple fixes at the same position. This happens e.g. when
+ // we force error cuddling but the error assignment is already cuddled.
+ // See `checkError` for examples.
+ fixRanges []fixRange
+}
+
+type WSL struct {
+ file *ast.File
+ fset *token.FileSet
+ typeInfo *types.Info
+ issues map[token.Pos]issue
+ config *Configuration
+}
+
+func New(file *ast.File, pass *analysis.Pass, cfg *Configuration) *WSL {
+ return &WSL{
+ fset: pass.Fset,
+ file: file,
+ typeInfo: pass.TypesInfo,
+ issues: make(map[token.Pos]issue),
+ config: cfg,
+ }
+}
+
+// Run will run analysis on the file and pass passed to the constructor. It's
+// typically only supposed to be used by [analysis.Analyzer].
+func (w *WSL) Run() {
+ ast.Inspect(w.file, func(n ast.Node) bool {
+ switch node := n.(type) {
+ case *ast.FuncDecl:
+ w.checkBlock(node.Body, NewCursor([]ast.Stmt{}))
+ case *ast.FuncLit:
+ w.checkBlock(node.Body, NewCursor([]ast.Stmt{}))
+ }
+
+ return true
+ })
+}
+
+func (w *WSL) checkStmt(stmt ast.Stmt, cursor *Cursor) {
+ //nolint:gocritic // This is not commented out code, it's examples
+ switch s := stmt.(type) {
+ // if a {} else if b {} else {}
+ case *ast.IfStmt:
+ w.checkIf(s, cursor, false)
+ // for {} / for a; b; c {}
+ case *ast.ForStmt:
+ w.checkFor(s, cursor)
+ // for _, _ = range a {}
+ case *ast.RangeStmt:
+ w.checkRange(s, cursor)
+ // switch {} // switch a {}
+ case *ast.SwitchStmt:
+ w.checkSwitch(s, cursor)
+ // switch a.(type) {}
+ case *ast.TypeSwitchStmt:
+ w.checkTypeSwitch(s, cursor)
+ // return a
+ case *ast.ReturnStmt:
+ w.checkReturn(s, cursor)
+ // continue / break
+ case *ast.BranchStmt:
+ w.checkBranch(s, cursor)
+ // var a
+ case *ast.DeclStmt:
+ w.checkDeclStmt(s, cursor)
+ // a := a
+ case *ast.AssignStmt:
+ w.checkAssign(s, cursor)
+ // a++ / a--
+ case *ast.IncDecStmt:
+ w.checkIncDec(s, cursor)
+ // defer func() {}
+ case *ast.DeferStmt:
+ w.checkDefer(s, cursor)
+ // go func() {}
+ case *ast.GoStmt:
+ w.checkGo(s, cursor)
+ // e.g. someFn()
+ case *ast.ExprStmt:
+ w.checkExprStmt(s, cursor)
+ // case:
+ case *ast.CaseClause:
+ w.checkCaseClause(s, cursor)
+ // case:
+ case *ast.CommClause:
+ w.checkCommClause(s, cursor)
+ // { }
+ case *ast.BlockStmt:
+ w.checkBlock(s, cursor)
+ // select { }
+ case *ast.SelectStmt:
+ w.checkSelect(s, cursor)
+ // ch <- ...
+ case *ast.SendStmt:
+ w.checkSend(s, cursor)
+ // LABEL:
+ case *ast.LabeledStmt:
+ w.checkLabel(s, cursor)
+ case *ast.EmptyStmt:
+ default:
+ }
+}
+
+func (w *WSL) checkBodyBlock(block *ast.BlockStmt) {
+ w.walkBody(NewBlockCursor(block.List, w.lineFor(block.Rbrace)))
+}
+
+func (w *WSL) checkBodyStmts(stmts []ast.Stmt) {
+ w.walkBody(NewCursor(stmts))
+}
+
+func (w *WSL) walkBody(cursor *Cursor) {
+ for cursor.Next() {
+ w.checkStmt(cursor.Stmt(), cursor)
+ }
+}
+
+func (w *WSL) checkCuddlingBlock(
+ stmt ast.Node,
+ blockList []ast.Stmt,
+ allowedIdents []*ast.Ident,
+ cursor *Cursor,
+) {
+ var firstBlockStmt ast.Node
+ if len(blockList) > 0 {
+ firstBlockStmt = blockList[0]
+ }
+
+ w.checkCuddlingMaxAllowed(stmt, firstBlockStmt, allowedIdents, cursor, true)
+}
+
+func (w *WSL) checkCuddling(stmt ast.Node, cursor *Cursor, enforceLimit bool) {
+ w.checkCuddlingMaxAllowed(stmt, nil, []*ast.Ident{}, cursor, enforceLimit)
+}
+
+func (w *WSL) checkCuddlingMaxAllowed(
+ stmt ast.Node,
+ firstBlockStmt ast.Node,
+ allowedIdents []*ast.Ident,
+ cursor *Cursor,
+ enforceLimit bool,
+) {
+ if _, ok := cursor.Stmt().(*ast.LabeledStmt); ok {
+ return
+ }
+
+ previousNode := cursor.PreviousNode()
+ previousStmtNode := unlabeledStmt(previousNode)
+ numStmtsAbove := w.numberOfStatementsAbove(cursor)
+ previousIdents := w.identsFromNode(previousStmtNode, true)
+
+ // If we don't have any statements above, we only care about potential error
+ // cuddling (for if statements) so check that.
+ if numStmtsAbove == 0 {
+ w.checkError(numStmtsAbove, stmt, previousNode, cursor)
+ return
+ }
+
+ if w.isLockOrUnlock(stmt, previousStmtNode) {
+ return
+ }
+
+ _, currIsDefer := stmt.(*ast.DeferStmt)
+ _, currIsGo := stmt.(*ast.GoStmt)
+ currRelaxesPrevType := currIsDefer || currIsGo
+
+ // We're cuddled but not with an assign, declare, increment/decrement and
+ // we're not a statement with relaxed check.
+ if !isAssignDeclOrIncDec(previousStmtNode) && !currRelaxesPrevType {
+ w.addErrorInvalidTypeCuddle(cursor.Stmt().Pos(), cursor.checkType)
+ return
+ }
+
+ targetIdents := w.cuddleTargetIdents(stmt, firstBlockStmt, allowedIdents)
+
+ if !identsIntersect(previousIdents, targetIdents) {
+ w.addErrorNoIntersection(stmt.Pos(), cursor.checkType)
+ return
+ }
+
+ if !enforceLimit {
+ return
+ }
+
+ // CheckErr always have precedence, allowing any permutation of max allowed
+ // cuddled statements and CheckCuddleGroup to be configured but still
+ // respect the requirement to use the idiomatic err checking and never
+ // insert a newline between the err and if.
+ _, errEnabled := w.config.Checks[CheckErr]
+ errIdent := w.isErrNotNilCheck(stmt)
+
+ if errEnabled && errIdent != nil && identsIntersect([]*ast.Ident{errIdent}, previousIdents) {
+ if numStmtsAbove > 1 {
+ if errorNode := cursor.NthPrevious(1); errorNode != nil {
+ w.addErrorTooManyStatements(errorNode.Pos(), cursor.checkType)
+ }
+ }
+
+ return
+ }
+
+ if _, ok := w.config.Checks[CheckCuddleGroup]; ok {
+ // Treat the cuddled chain as a unit: any non-sharing stmt or too
+ // many sharing stmts separates the whole group from the trigger.
+ sharedCount, stoppedAtNonIntersection := w.countValidCuddledStatements(
+ targetIdents,
+ cursor,
+ currRelaxesPrevType,
+ math.MaxInt,
+ )
+ if stoppedAtNonIntersection || sharedCount > w.config.CuddleMaxStatements {
+ w.addErrorTooManyStatements(cursor.Stmt().Pos(), cursor.checkType)
+ }
+
+ return
+ }
+
+ allowedCount, stoppedAtNonIntersection := w.countValidCuddledStatements(
+ targetIdents,
+ cursor,
+ currRelaxesPrevType,
+ w.config.CuddleMaxStatements,
+ )
+ if numStmtsAbove <= allowedCount {
+ return
+ }
+
+ errorNode := cursor.NthPrevious(allowedCount)
+ if errorNode == nil {
+ return
+ }
+
+ if stoppedAtNonIntersection {
+ w.addErrorVariableNotShared(errorNode.Pos(), cursor.checkType)
+ } else {
+ w.addErrorTooManyStatements(errorNode.Pos(), cursor.checkType)
+ }
+}
+
+// cuddleTargetIdents builds the combined set of identifiers that a cuddled
+// statement may reference. This respects AllowWholeBlock and AllowFirstInBlock.
+func (w *WSL) cuddleTargetIdents(
+ stmt ast.Node,
+ firstBlockStmt ast.Node,
+ allowedIdents []*ast.Ident,
+) []*ast.Ident {
+ var idents []*ast.Ident
+
+ if w.config.AllowWholeBlock {
+ idents = append(idents, w.identsFromNode(stmt, false)...)
+ } else {
+ idents = append(idents, w.identsFromNode(stmt, true)...)
+
+ if w.config.AllowFirstInBlock {
+ idents = append(idents, w.identsFromNode(firstBlockStmt, true)...)
+ }
+ }
+
+ idents = append(idents, allowedIdents...)
+
+ return idents
+}
+
+// countValidCuddledStatements walks backwards from the cursor and counts how
+// many consecutive cuddled statements have a valid intersection with
+// targetIdents. It stops at the first non-intersecting statement or when the
+// limit is reached. Returns the count and whether the walk stopped because a
+// non-intersecting statement was found (as opposed to the limit).
+//
+// When allowAnyStmtType is true any statement type is accepted as a cuddled
+// neighbor.
+func (w *WSL) countValidCuddledStatements(
+ targetIdents []*ast.Ident,
+ cursor *Cursor,
+ allowAnyStmtType bool,
+ limit int,
+) (int, bool) {
+ defer cursor.Save()()
+
+ currentStmtStartLine := w.lineFor(cursor.Stmt().Pos())
+ count := 0
+
+ for cursor.Previous() {
+ prevEndLine := w.lineFor(cursor.Stmt().End())
+ if prevEndLine != currentStmtStartLine-1 {
+ break
+ }
+
+ if count >= limit {
+ break
+ }
+
+ prevNode := cursor.Stmt()
+ if !isAssignDeclOrIncDec(prevNode) && !allowAnyStmtType {
+ break
+ }
+
+ prevIdents := w.identsFromNode(prevNode, true)
+ if !identsIntersect(prevIdents, targetIdents) {
+ return count, true
+ }
+
+ count++
+ currentStmtStartLine = w.lineFor(cursor.Stmt().Pos())
+ }
+
+ return count, false
+}
+
+func (w *WSL) checkCuddlingWithoutIntersection(stmt ast.Node, cursor *Cursor) {
+ if w.numberOfStatementsAbove(cursor) == 0 {
+ return
+ }
+
+ if _, ok := cursor.Stmt().(*ast.LabeledStmt); ok {
+ return
+ }
+
+ previousNode := cursor.PreviousNode()
+
+ currAssign, currIsAssign := stmt.(*ast.AssignStmt)
+ previousAssign, prevIsAssign := previousNode.(*ast.AssignStmt)
+ _, prevIsDecl := previousNode.(*ast.DeclStmt)
+ _, prevIsIncDec := previousNode.(*ast.IncDecStmt)
+
+ // Cuddling without intersection is allowed for assignments and inc/dec
+ // statements. If however the check for declarations is disabled, we also
+ // allow cuddling with them as well.
+ //
+ // var x string
+ // x := ""
+ // y++
+ if _, ok := w.config.Checks[CheckDecl]; ok {
+ prevIsDecl = false
+ }
+
+ // If we enable exclusive assign checks we only allow new declarations or
+ // new assignments together but not mix and match.
+ //
+ // When this is enabled we also implicitly disable support to cuddle with
+ // anything else.
+ if _, ok := w.config.Checks[CheckAssignExclusive]; ok {
+ prevIsDecl = false
+ prevIsIncDec = false
+
+ if prevIsAssign && currIsAssign {
+ prevIsAssign = previousAssign.Tok == currAssign.Tok
+ }
+ }
+
+ prevIsValidType := previousNode == nil || prevIsAssign || prevIsDecl || prevIsIncDec
+
+ if _, ok := w.config.Checks[CheckAssignExpr]; !ok {
+ if _, ok := previousNode.(*ast.ExprStmt); ok && w.hasIntersection(stmt, previousNode) {
+ prevIsValidType = prevIsValidType || ok
+ }
+ }
+
+ if prevIsValidType {
+ return
+ }
+
+ if w.isLockOrUnlock(stmt, previousNode) {
+ return
+ }
+
+ w.addErrorInvalidTypeCuddle(stmt.Pos(), cursor.checkType)
+}
+
+func (w *WSL) checkBlock(block *ast.BlockStmt, cursor *Cursor) {
+ // Block can be nil for function declarations without a body.
+ if block == nil {
+ return
+ }
+
+ w.checkBlockLeadingNewline(block)
+ w.checkTrailingNewline(block)
+ w.checkNewlineAfterBlock(block, cursor)
+
+ w.checkBodyBlock(block)
+}
+
+func (w *WSL) checkNewlineAfterBlock(block *ast.BlockStmt, cursor *Cursor) {
+ if _, ok := w.config.Checks[CheckAfterBlock]; !ok {
+ return
+ }
+
+ // For function blocks we don't have any statements in our cursor.
+ if cursor.Len() == 0 {
+ return
+ }
+
+ currentStmt := cursor.Stmt()
+
+ w.checkNewlineAfter(
+ block.Rbrace,
+ block,
+ currentStmt,
+ cursor,
+ CheckAfterBlock,
+ func(nextStmt ast.Stmt, previousNode ast.Node) bool {
+ // Exception: if err != nil { } followed by defer that references
+ // a variable assigned above the if block.
+ if w.isErrNotNilCheck(currentStmt) != nil {
+ if deferStmt, ok := nextStmt.(*ast.DeferStmt); ok && previousNode != nil {
+ if w.hasIntersection(previousNode, deferStmt) {
+ return true
+ }
+ }
+ }
+
+ return false
+ },
+ )
+}
+
+// checkNewlineAfter verifies that a blank line separates the current statement
+// (bounded by boundary) from whatever content comes next in its enclosing
+// block. `reportPos` is where the diagnostic is attached, `boundary` is the
+// node whose End() defines the line after which a newline is required, and
+// `currentStmt` is the statement owning the check (used to discriminate
+// comments that still belong to it, e.g. comments inside an else block when
+// checking the if-body). When `checkTrailingComment` is true and currentStmt
+// is the last statement in its block, a trailing comment on the following
+// line (inside the enclosing block) also triggers a diagnostic. If
+// `isException` returns true for the next statement and the previous node, no
+// diagnostic is reported.
+func (w *WSL) checkNewlineAfter(
+ reportPos token.Pos,
+ boundary ast.Node,
+ currentStmt ast.Node,
+ cursor *Cursor,
+ check CheckType,
+ isException func(nextStmt ast.Stmt, previousNode ast.Node) bool,
+) {
+ if _, ok := w.config.Checks[check]; !ok {
+ return
+ }
+
+ if cursor.Len() == 0 {
+ return
+ }
+
+ defer cursor.Save()()
+
+ previousNode := cursor.PreviousNode()
+
+ if !cursor.Next() {
+ // No more statements after this one so check for comments after.
+ // Skip comments that are inside the current statement (e.g., inside an else block).
+ // Also skip comments that appear on the same line as the enclosing block's closing
+ // brace — those are inline comments on the brace itself, not trailing comments
+ // inside the block.
+ if commentPos := w.commentOnLineAfterNodePos(boundary); commentPos != token.NoPos {
+ isAfterStmt := commentPos >= currentStmt.End()
+ isSameLine := w.lineFor(commentPos) == cursor.rbraceLine
+ isUnknownOrNotSameLine := cursor.rbraceLine == 0 || !isSameLine
+
+ if isAfterStmt && isUnknownOrNotSameLine {
+ insertPos := w.lineStartOf(commentPos)
+ w.addError(
+ reportPos,
+ insertPos,
+ insertPos,
+ messageMissingWhitespaceBelow,
+ check,
+ )
+ }
+ }
+
+ return
+ }
+
+ nextStmt := cursor.Stmt()
+ if isException != nil && isException(nextStmt, previousNode) {
+ return
+ }
+
+ boundaryLine := w.lineFor(boundary.End())
+ nextContentPos := nextStmt.Pos()
+ nextContentLine := w.lineFor(nextContentPos)
+
+ // Find the first comment between the boundary and the next statement.
+ for _, cg := range w.file.Comments {
+ if cg.End() <= boundary.End() {
+ continue
+ }
+
+ // Skip comments that are inside the current statement but after the
+ // boundary. This handles cases like comments inside an else block when
+ // checking the if-body.
+ if cg.Pos() < currentStmt.End() {
+ continue
+ }
+
+ if w.lineFor(cg.End()) == boundaryLine {
+ continue
+ }
+
+ commentLine := w.lineFor(cg.Pos())
+ if commentLine > boundaryLine && commentLine < nextContentLine {
+ nextContentPos = cg.Pos()
+ nextContentLine = commentLine
+ }
+
+ break
+ }
+
+ if nextContentLine <= boundaryLine+1 {
+ insertPos := w.lineStartOf(nextContentPos)
+ w.addError(
+ reportPos,
+ insertPos,
+ insertPos,
+ messageMissingWhitespaceBelow,
+ check,
+ )
+ }
+}
+
+func (w *WSL) checkCaseClause(stmt *ast.CaseClause, cursor *Cursor) {
+ w.checkCaseLeadingNewline(stmt)
+
+ if w.config.CaseMaxLines != 0 {
+ w.checkCaseTrailingNewline(stmt.Body, cursor)
+ }
+
+ w.checkBodyStmts(stmt.Body)
+}
+
+func (w *WSL) checkCommClause(stmt *ast.CommClause, cursor *Cursor) {
+ w.checkCommLeadingNewline(stmt)
+
+ if w.config.CaseMaxLines != 0 {
+ w.checkCaseTrailingNewline(stmt.Body, cursor)
+ }
+
+ w.checkBodyStmts(stmt.Body)
+}
+
+func (w *WSL) checkAssign(stmt *ast.AssignStmt, cursor *Cursor) {
+ defer w.checkAppend(stmt, cursor)
+
+ if _, ok := w.config.Checks[CheckAssign]; !ok {
+ return
+ }
+
+ cursor.SetChecker(CheckAssign)
+
+ w.checkCuddlingWithoutIntersection(stmt, cursor)
+}
+
+func (w *WSL) checkAppend(stmt *ast.AssignStmt, cursor *Cursor) {
+ if _, ok := w.config.Checks[CheckAppend]; !ok {
+ return
+ }
+
+ if w.numberOfStatementsAbove(cursor) == 0 {
+ return
+ }
+
+ previousNode := cursor.PreviousNode()
+
+ var appendNode *ast.CallExpr
+
+ for _, expr := range stmt.Rhs {
+ e, ok := expr.(*ast.CallExpr)
+ if !ok {
+ continue
+ }
+
+ if f, ok := e.Fun.(*ast.Ident); ok && f.Name == "append" {
+ appendNode = e
+ break
+ }
+ }
+
+ if appendNode == nil {
+ return
+ }
+
+ if !w.hasIntersection(appendNode, previousNode) {
+ w.addErrorNoIntersection(stmt.Pos(), CheckAppend)
+ }
+}
+
+func (w *WSL) checkBranch(stmt *ast.BranchStmt, cursor *Cursor) {
+ if _, ok := w.config.Checks[CheckBranch]; !ok {
+ return
+ }
+
+ cursor.SetChecker(CheckBranch)
+
+ if w.numberOfStatementsAbove(cursor) == 0 {
+ return
+ }
+
+ lastStmtInBlock := cursor.statements[len(cursor.statements)-1]
+ firstStmts := cursor.Nth(0)
+
+ if w.lineFor(lastStmtInBlock.End())-w.lineFor(firstStmts.Pos()) < w.config.BranchMaxLines {
+ return
+ }
+
+ w.addErrorTooManyLines(stmt.Pos(), cursor.checkType)
+}
+
+func (w *WSL) checkDeclStmt(stmt *ast.DeclStmt, cursor *Cursor) {
+ defer func() {
+ // maybeGroupDecl can advance the cursor past consecutive decls, so
+ // use the cursor's current position at defer-time to get the last
+ // decl in the group.
+ lastDecl, ok := cursor.Stmt().(*ast.DeclStmt)
+ if !ok {
+ lastDecl = stmt
+ }
+
+ w.checkAfterDecl(lastDecl, cursor)
+ }()
+
+ if _, ok := w.config.Checks[CheckDecl]; !ok {
+ return
+ }
+
+ cursor.SetChecker(CheckDecl)
+
+ if w.numberOfStatementsAbove(cursor) == 0 {
+ return
+ }
+
+ // Try to do smart grouping and if we succeed return, otherwise do
+ // line-by-line fixing.
+ if w.maybeGroupDecl(stmt, cursor) {
+ return
+ }
+
+ w.addErrorNeverAllow(stmt.Pos(), cursor.checkType)
+}
+
+func (w *WSL) checkAfterDecl(stmt *ast.DeclStmt, cursor *Cursor) {
+ w.checkNewlineAfter(
+ stmt.End(),
+ stmt,
+ stmt,
+ cursor,
+ CheckAfterDecl,
+ func(nextStmt ast.Stmt, _ ast.Node) bool {
+ nextDecl, ok := nextStmt.(*ast.DeclStmt)
+ if !ok {
+ return false
+ }
+
+ currGen, currOK := stmt.Decl.(*ast.GenDecl)
+ nextGen, nextOK := nextDecl.Decl.(*ast.GenDecl)
+
+ return currOK && nextOK && currGen.Tok == nextGen.Tok
+ },
+ )
+}
+
+func (w *WSL) checkDefer(stmt *ast.DeferStmt, cursor *Cursor) {
+ defer w.checkAfterDefer(stmt, cursor)
+
+ if _, ok := w.config.Checks[CheckDefer]; !ok {
+ return
+ }
+
+ cursor.SetChecker(CheckDefer)
+
+ previousNode := cursor.PreviousNode()
+ _, previousIsDefer := previousNode.(*ast.DeferStmt)
+ _, previousIsIf := previousNode.(*ast.IfStmt)
+
+ // We allow defer as a third node only if we have an if statement
+ // between, e.g.
+ //
+ // f, err := os.Open(file)
+ // if err != nil {
+ // return err
+ // }
+ // defer f.Close()
+ if previousIsIf && w.numberOfStatementsAbove(cursor) >= 2 {
+ defer cursor.Save()()
+
+ cursor.Previous()
+ cursor.Previous()
+
+ if w.hasIntersection(cursor.Stmt(), stmt) {
+ return
+ }
+ }
+
+ // Only check cuddling if previous statement isn't also a defer.
+ if previousIsDefer {
+ return
+ }
+
+ // If calling a function literal, inspect the function body for shared
+ // variables, similar to how block statements inspect their body via
+ // checkCuddlingBlock.
+ if funcLit, ok := stmt.Call.Fun.(*ast.FuncLit); ok {
+ w.checkCuddlingBlock(stmt, funcLit.Body.List, []*ast.Ident{}, cursor)
+ return
+ }
+
+ w.checkCuddling(stmt, cursor, true)
+}
+
+func (w *WSL) checkAfterDefer(stmt *ast.DeferStmt, cursor *Cursor) {
+ w.checkNewlineAfter(
+ stmt.End(),
+ stmt,
+ stmt,
+ cursor,
+ CheckAfterDefer,
+ func(nextStmt ast.Stmt, _ ast.Node) bool {
+ _, ok := nextStmt.(*ast.DeferStmt)
+ return ok
+ },
+ )
+}
+
+func (w *WSL) checkError(
+ stmtsAbove int,
+ ifStmt ast.Node,
+ previousNode ast.Node,
+ cursor *Cursor,
+) {
+ if _, ok := w.config.Checks[CheckErr]; !ok {
+ return
+ }
+
+ if stmtsAbove > 0 {
+ return
+ }
+
+ if _, ok := cursor.Stmt().(*ast.LabeledStmt); ok {
+ return
+ }
+
+ defer cursor.Save()()
+
+ errIdent := w.isErrNotNilCheck(ifStmt)
+ if errIdent == nil {
+ return
+ }
+
+ previousIdents := []*ast.Ident{}
+
+ if assign, ok := previousNode.(*ast.AssignStmt); ok {
+ for _, lhs := range assign.Lhs {
+ previousIdents = append(previousIdents, w.identsFromNode(lhs, true)...)
+ }
+ }
+
+ if decl, ok := previousNode.(*ast.DeclStmt); ok {
+ if genDecl, ok := decl.Decl.(*ast.GenDecl); ok {
+ for _, spec := range genDecl.Specs {
+ if vs, ok := spec.(*ast.ValueSpec); ok {
+ previousIdents = append(previousIdents, vs.Names...)
+ }
+ }
+ }
+ }
+
+ // Ensure that the error checked on this line was assigned or declared in
+ // the previous statement.
+ if !identsIntersect([]*ast.Ident{errIdent}, previousIdents) {
+ return
+ }
+
+ cursor.SetChecker(CheckErr)
+
+ previousEndLine := w.lineFor(previousNode.End())
+
+ // Check for comments on the same line as the previous node (extends effective end line).
+ for _, cg := range w.file.Comments {
+ if cg.Pos() >= ifStmt.Pos() {
+ break
+ }
+
+ if cg.Pos() < previousNode.End() || cg.End() > ifStmt.Pos() {
+ continue
+ }
+
+ // There's a comment between the error variable and the if-statement.
+ // If it's on a different line, we can't do much about this.
+ if w.lineFor(cg.End()) != previousEndLine {
+ return
+ }
+
+ // Comment is on the same line - no need to update since line stays the same.
+ }
+
+ ifStmtLine := w.lineFor(ifStmt.Pos())
+ file := w.fset.File(ifStmt.Pos())
+
+ // Remove blank lines between previous node and if statement.
+ removeStart := file.LineStart(previousEndLine + 1)
+ removeEnd := file.LineStart(ifStmtLine)
+ w.addErrorRemoveNewline(removeStart, removeEnd, cursor.checkType)
+
+ // If we add the error at the same position but with a different fix
+ // range, only the fix range will be updated.
+ //
+ // a := 1
+ // err := fn()
+ //
+ // if err != nil {}
+ //
+ // Should become
+ //
+ // a := 1
+ //
+ // err := fn()
+ // if err != nil {}
+ cursor.Previous()
+
+ // Add whitespace above the error assignment if there's a statement above.
+ if w.numberOfStatementsAbove(cursor) > 0 {
+ insertPos := w.lineStartOf(previousNode.Pos())
+ w.addError(removeStart, insertPos, insertPos, messageMissingWhitespaceAbove, cursor.checkType)
+ }
+}
+
+func (w *WSL) checkExprStmt(stmt *ast.ExprStmt, cursor *Cursor) {
+ defer w.checkAfterExpr(stmt, cursor)
+
+ if _, ok := w.config.Checks[CheckExpr]; !ok {
+ return
+ }
+
+ cursor.SetChecker(CheckExpr)
+
+ // Consecutive expression statements don't need to be separated, so only
+ // check cuddling if the previous statement isn't also an expression.
+ if _, ok := cursor.PreviousNode().(*ast.ExprStmt); !ok {
+ w.checkCuddling(stmt, cursor, false)
+ }
+}
+
+func (w *WSL) checkAfterExpr(stmt *ast.ExprStmt, cursor *Cursor) {
+ w.checkNewlineAfter(
+ stmt.End(),
+ stmt,
+ stmt,
+ cursor,
+ CheckAfterExpr,
+ func(nextStmt ast.Stmt, _ ast.Node) bool {
+ // Consecutive expressions don't need a blank line between them.
+ if _, ok := nextStmt.(*ast.ExprStmt); ok {
+ return true
+ }
+
+ // Exception: expr followed by a defer that references the same
+ // variable (e.g. mu.Lock() / defer mu.Unlock()).
+ if deferStmt, ok := nextStmt.(*ast.DeferStmt); ok {
+ return w.hasIntersection(stmt, deferStmt)
+ }
+
+ return false
+ },
+ )
+}
+
+func (w *WSL) checkFor(stmt *ast.ForStmt, cursor *Cursor) {
+ w.maybeCheckBlock(stmt, stmt.Body, cursor, CheckFor)
+}
+
+func (w *WSL) checkGo(stmt *ast.GoStmt, cursor *Cursor) {
+ defer w.checkAfterGo(stmt, cursor)
+
+ if _, ok := w.config.Checks[CheckGo]; !ok {
+ return
+ }
+
+ cursor.SetChecker(CheckGo)
+
+ // We can cuddle any amount `go` statements so only check cuddling if
+ // the previous one isn't a `go` call.
+ if _, ok := cursor.PreviousNode().(*ast.GoStmt); ok {
+ return
+ }
+
+ // If calling a function literal, inspect the function body for shared
+ // variables, similar to how block statements inspect their body via
+ // checkCuddlingBlock.
+ if funcLit, ok := stmt.Call.Fun.(*ast.FuncLit); ok {
+ w.checkCuddlingBlock(stmt, funcLit.Body.List, []*ast.Ident{}, cursor)
+ return
+ }
+
+ w.checkCuddling(stmt, cursor, true)
+}
+
+func (w *WSL) checkAfterGo(stmt *ast.GoStmt, cursor *Cursor) {
+ w.checkNewlineAfter(
+ stmt.End(),
+ stmt,
+ stmt,
+ cursor,
+ CheckAfterGo,
+ func(nextStmt ast.Stmt, _ ast.Node) bool {
+ _, ok := nextStmt.(*ast.GoStmt)
+ return ok
+ },
+ )
+}
+
+func (w *WSL) checkIf(stmt *ast.IfStmt, cursor *Cursor, isElse bool) {
+ // if
+ w.checkBlock(stmt.Body, cursor)
+
+ switch v := stmt.Else.(type) {
+ // else-if
+ case *ast.IfStmt:
+ w.checkIf(v, cursor, true)
+
+ // else
+ case *ast.BlockStmt:
+ w.checkBlock(v, cursor)
+ }
+
+ if _, ok := w.config.Checks[CheckIf]; !isElse && ok {
+ cursor.SetChecker(CheckIf)
+ w.checkCuddlingBlock(stmt, stmt.Body.List, []*ast.Ident{}, cursor)
+ } else if _, ok := w.config.Checks[CheckErr]; !isElse && ok {
+ previousNode := cursor.PreviousNode()
+
+ w.checkError(
+ w.numberOfStatementsAbove(cursor),
+ stmt,
+ previousNode,
+ cursor,
+ )
+ }
+}
+
+func (w *WSL) checkIncDec(stmt *ast.IncDecStmt, cursor *Cursor) {
+ if _, ok := w.config.Checks[CheckIncDec]; !ok {
+ return
+ }
+
+ cursor.SetChecker(CheckIncDec)
+
+ w.checkCuddlingWithoutIntersection(stmt, cursor)
+}
+
+func (w *WSL) checkLabel(stmt *ast.LabeledStmt, cursor *Cursor) {
+ // We check the statement last because the statement is the same node as the
+ // label (it's a labeled statement). This means that we _first_ want to
+ // check any violations of cuddling the label (never cuddle label) before we
+ // actually check the inner statement.
+ //
+ // It's a subtle difference, but it makes the diagnostic make more sense.
+ // We do this by deferring the statmenet check so it happens last no matter
+ // if we have label checking enabled or not.
+ defer w.checkStmt(stmt.Stmt, cursor)
+
+ if _, ok := w.config.Checks[CheckLabel]; !ok {
+ return
+ }
+
+ cursor.SetChecker(CheckLabel)
+
+ if w.numberOfStatementsAbove(cursor) == 0 {
+ return
+ }
+
+ w.addErrorNeverAllow(stmt.Pos(), cursor.checkType)
+}
+
+func (w *WSL) checkRange(stmt *ast.RangeStmt, cursor *Cursor) {
+ w.maybeCheckBlock(stmt, stmt.Body, cursor, CheckRange)
+}
+
+func (w *WSL) checkReturn(stmt *ast.ReturnStmt, cursor *Cursor) {
+ if _, ok := w.config.Checks[CheckReturn]; !ok {
+ return
+ }
+
+ cursor.SetChecker(CheckReturn)
+
+ // There's only a return statement.
+ if cursor.Len() <= 1 {
+ return
+ }
+
+ if w.numberOfStatementsAbove(cursor) == 0 {
+ return
+ }
+
+ // If the distance between the first statement and the return statement is
+ // less than `n` LOC we're allowed to cuddle.
+ firstStmts := cursor.Nth(0)
+ if w.lineFor(stmt.End())-w.lineFor(firstStmts.Pos()) < w.config.BranchMaxLines {
+ return
+ }
+
+ w.addErrorTooManyLines(stmt.Pos(), cursor.checkType)
+}
+
+func (w *WSL) checkSelect(stmt *ast.SelectStmt, cursor *Cursor) {
+ w.maybeCheckBlock(stmt, stmt.Body, cursor, CheckSelect)
+}
+
+func (w *WSL) checkSend(stmt *ast.SendStmt, cursor *Cursor) {
+ if _, ok := w.config.Checks[CheckSend]; !ok {
+ return
+ }
+
+ cursor.SetChecker(CheckSend)
+
+ var stmts []ast.Stmt
+
+ ast.Inspect(stmt.Value, func(n ast.Node) bool {
+ if b, ok := n.(*ast.BlockStmt); ok {
+ stmts = b.List
+ return false
+ }
+
+ return true
+ })
+
+ w.checkCuddlingBlock(stmt, stmts, []*ast.Ident{}, cursor)
+}
+
+func (w *WSL) checkSwitch(stmt *ast.SwitchStmt, cursor *Cursor) {
+ w.maybeCheckBlock(stmt, stmt.Body, cursor, CheckSwitch)
+}
+
+func (w *WSL) checkTypeSwitch(stmt *ast.TypeSwitchStmt, cursor *Cursor) {
+ w.maybeCheckBlock(stmt, stmt.Body, cursor, CheckTypeSwitch)
+}
+
+func (w *WSL) checkCaseTrailingNewline(body []ast.Stmt, cursor *Cursor) {
+ if len(body) == 0 {
+ return
+ }
+
+ defer cursor.Save()()
+
+ if !cursor.Next() {
+ return
+ }
+
+ var nextCase ast.Node
+
+ switch n := cursor.Stmt().(type) {
+ case *ast.CaseClause:
+ nextCase = n
+ case *ast.CommClause:
+ nextCase = n
+ default:
+ return
+ }
+
+ var (
+ firstStmt = body[0]
+ lastStmt = body[len(body)-1]
+ totalLines = w.lineFor(nextCase.Pos()) - w.lineFor(firstStmt.Pos())
+ )
+
+ if totalLines < w.config.CaseMaxLines {
+ return
+ }
+
+ var (
+ lastStmtEndLine = w.lineFor(lastStmt.End())
+ nextCaseLine = w.lineFor(nextCase.Pos())
+ nextCaseCol = w.fset.PositionFor(nextCase.Pos(), false).Column
+ )
+
+ // Find transition point between trailing content (indented) and leading
+ // content (left-aligned). Trailing comments belong to current case, leading
+ // comments belong to next case. The blank line goes at the transition.
+ var (
+ lastStmtOrCommentEnd = lastStmt.End()
+ nextCaseOrLeftAlignedComment = nextCase.Pos()
+ lastLeftAlignedCommentEnd = token.NoPos
+ )
+
+ for _, commentGroup := range w.file.Comments {
+ if commentGroup.Pos() >= nextCase.Pos() {
+ break
+ }
+
+ if commentGroup.End() <= lastStmt.End() {
+ continue
+ }
+
+ for _, comment := range commentGroup.List {
+ commentLine := w.lineFor(comment.Pos())
+ if commentLine <= lastStmtEndLine || commentLine >= nextCaseLine {
+ continue
+ }
+
+ col := w.fset.PositionFor(comment.Pos(), false).Column
+ if col <= nextCaseCol {
+ // Left-aligned: first one marks transition point
+ if lastLeftAlignedCommentEnd == token.NoPos {
+ nextCaseOrLeftAlignedComment = comment.Pos()
+ }
+
+ lastLeftAlignedCommentEnd = comment.End()
+ } else {
+ // Indented: extend trailing content
+ lastStmtOrCommentEnd = comment.End()
+ }
+ }
+ }
+
+ lastStmtOrCommentLine := w.lineFor(lastStmtOrCommentEnd)
+ nextCaseOrLeadingCommentLine := w.lineFor(nextCaseOrLeftAlignedComment)
+
+ // Check for unnecessary blank line before case (leading comments should be flush).
+ if lastLeftAlignedCommentEnd != token.NoPos {
+ lastLeadingEndLine := w.lineFor(lastLeftAlignedCommentEnd)
+
+ if lastLeadingEndLine < nextCaseLine-1 {
+ file := w.fset.File(nextCase.Pos())
+ w.addErrorRemoveNewline(file.LineStart(lastLeadingEndLine+1), file.LineStart(nextCaseLine), CheckCaseTrailingNewline)
+ }
+ }
+
+ // Already has a blank line at the boundary.
+ if nextCaseOrLeadingCommentLine > lastStmtOrCommentLine+1 {
+ return
+ }
+
+ insertPos := w.lineStartOf(nextCaseOrLeftAlignedComment)
+ w.addError(lastStmtOrCommentEnd, insertPos, insertPos, messageMissingWhitespaceBelow, CheckCaseTrailingNewline)
+}
+
+func (w *WSL) checkBlockLeadingNewline(body *ast.BlockStmt) {
+ w.checkLeadingNewline(body.Lbrace, body.List)
+}
+
+func (w *WSL) checkCaseLeadingNewline(caseClause *ast.CaseClause) {
+ w.checkLeadingNewline(caseClause.Colon, caseClause.Body)
+}
+
+func (w *WSL) checkCommLeadingNewline(commClause *ast.CommClause) {
+ w.checkLeadingNewline(commClause.Colon, commClause.Body)
+}
+
+func (w *WSL) checkLeadingNewline(startPos token.Pos, body []ast.Stmt) {
+ if _, ok := w.config.Checks[CheckLeadingWhitespace]; !ok {
+ return
+ }
+
+ if len(body) == 0 {
+ return
+ }
+
+ var (
+ openLine = w.lineFor(startPos)
+ firstStmtPos = body[0].Pos()
+ firstStmtLine = w.lineFor(firstStmtPos)
+ leadingComments []*ast.CommentGroup
+ )
+
+ for _, cg := range w.file.Comments {
+ if cg.Pos() >= firstStmtPos {
+ break
+ }
+
+ if cg.Pos() > startPos {
+ leadingComments = append(leadingComments, cg)
+ }
+ }
+
+ if len(leadingComments) == 0 {
+ if firstStmtLine := w.lineFor(firstStmtPos); firstStmtLine > openLine+1 {
+ file := w.fset.File(startPos)
+ w.addErrorRemoveNewline(
+ file.LineStart(openLine+1),
+ file.LineStart(firstStmtLine),
+ CheckLeadingWhitespace,
+ )
+ }
+
+ return
+ }
+
+ var (
+ firstContentLine = firstStmtLine
+ lastCommentEndLine = openLine
+ )
+
+ for _, comment := range leadingComments {
+ startLine := w.lineFor(comment.Pos())
+ endLine := w.lineFor(comment.End())
+
+ if startLine > openLine && startLine < firstContentLine {
+ firstContentLine = startLine
+ }
+
+ if endLine > lastCommentEndLine {
+ lastCommentEndLine = endLine
+ }
+ }
+
+ file := w.fset.File(startPos)
+
+ // Empty line after opening brace.
+ if firstContentLine > openLine+1 {
+ w.addErrorRemoveNewline(
+ file.LineStart(openLine+1),
+ file.LineStart(firstContentLine),
+ CheckLeadingWhitespace,
+ )
+ }
+
+ // Empty line between comments and first statement.
+ if lastCommentEndLine > openLine && firstStmtLine > lastCommentEndLine+1 {
+ w.addErrorRemoveNewline(
+ file.LineStart(lastCommentEndLine+1),
+ file.LineStart(firstStmtLine),
+ CheckLeadingWhitespace,
+ )
+ }
+}
+
+func (w *WSL) checkTrailingNewline(body *ast.BlockStmt) {
+ if _, ok := w.config.Checks[CheckTrailingWhitespace]; !ok {
+ return
+ }
+
+ if len(body.List) == 0 {
+ return
+ }
+
+ lastStmt := body.List[len(body.List)-1]
+
+ // We don't want to force removal of the empty line for the last case since
+ // it can be used for consistency and readability.
+ if _, ok := lastStmt.(*ast.CaseClause); ok {
+ return
+ }
+
+ lastContentPos := lastStmt.End()
+
+ // Empty label statements need positional adjustment. #92
+ if l, ok := lastStmt.(*ast.LabeledStmt); ok {
+ if _, ok := l.Stmt.(*ast.EmptyStmt); ok {
+ lastContentPos = lastStmt.Pos()
+ }
+ }
+
+ // Find the last comment after last statement using position comparison.
+ for _, cg := range w.file.Comments {
+ if cg.End() <= lastContentPos {
+ continue
+ }
+
+ if cg.Pos() >= body.Rbrace {
+ break
+ }
+
+ if cg.End() < body.Rbrace {
+ lastContentPos = cg.End()
+ }
+ }
+
+ closingLine := w.lineFor(body.Rbrace)
+ lastContentLine := w.lineFor(lastContentPos)
+
+ if closingLine > lastContentLine+1 {
+ file := w.fset.File(body.Rbrace)
+ removeStart := file.LineStart(lastContentLine + 1)
+ removeEnd := file.LineStart(closingLine)
+ w.addErrorRemoveNewline(removeStart, removeEnd, CheckTrailingWhitespace)
+ }
+}
+
+func (w *WSL) maybeGroupDecl(stmt *ast.DeclStmt, cursor *Cursor) bool {
+ firstNode := asGenDeclWithValueSpecs(cursor.PreviousNode())
+ if firstNode == nil {
+ return false
+ }
+
+ currentNode := asGenDeclWithValueSpecs(stmt)
+ if currentNode == nil {
+ return false
+ }
+
+ // Both are not same type, e.g. `const` or `var`
+ if firstNode.Tok != currentNode.Tok {
+ return false
+ }
+
+ specs := slices.Concat(firstNode.Specs, currentNode.Specs)
+
+ reportNodes := []ast.Node{currentNode}
+ lastNode := currentNode
+
+ for {
+ nextPeeked := cursor.NextNode()
+ if nextPeeked == nil {
+ break
+ }
+
+ if w.lineFor(lastNode.End()) < w.lineFor(nextPeeked.Pos())-1 {
+ break
+ }
+
+ nextNode := asGenDeclWithValueSpecs(nextPeeked)
+ if nextNode == nil {
+ break
+ }
+
+ if nextNode.Tok != firstNode.Tok {
+ break
+ }
+
+ cursor.Next()
+
+ specs = append(specs, nextNode.Specs...)
+ reportNodes = append(reportNodes, nextNode)
+ lastNode = nextNode
+ }
+
+ var buf bytes.Buffer
+ fmt.Fprintf(&buf, "%s (\n", firstNode.Tok)
+
+ for _, spec := range specs {
+ var specBuf bytes.Buffer
+ if err := format.Node(&specBuf, w.fset, spec); err != nil {
+ return false
+ }
+
+ buf.Write(specBuf.Bytes())
+ buf.WriteByte('\n')
+ }
+
+ buf.WriteByte(')')
+
+ // We add a diagnostic to every subsequent statement to properly represent
+ // the violations. Duplicate fixes for the same range is fine.
+ for _, n := range reportNodes {
+ w.addErrorWithMessageAndFix(
+ n.Pos(),
+ firstNode.Pos(),
+ lastNode.End(),
+ fmt.Sprintf("%s (never cuddle %s)", messageMissingWhitespaceAbove, CheckDecl),
+ buf.Bytes(),
+ )
+ }
+
+ return true
+}
+
+func (w *WSL) maybeCheckBlock(
+ node ast.Node,
+ blockStmt *ast.BlockStmt,
+ cursor *Cursor,
+ check CheckType,
+) {
+ w.checkBlock(blockStmt, cursor)
+
+ if _, ok := w.config.Checks[check]; ok {
+ cursor.SetChecker(check)
+
+ var (
+ blockList []ast.Stmt
+ allowedIdents []*ast.Ident
+ )
+
+ if check != CheckSwitch && check != CheckTypeSwitch && check != CheckSelect {
+ blockList = blockStmt.List
+ } else {
+ allowedIdents = w.identsFromCaseArms(node)
+ }
+
+ w.checkCuddlingBlock(node, blockList, allowedIdents, cursor)
+ }
+}
+
+// numberOfStatementsAbove will find out how many lines above the cursor's
+// current statement there is without any newlines between.
+func (w *WSL) numberOfStatementsAbove(cursor *Cursor) int {
+ defer cursor.Save()()
+
+ statementsWithoutNewlines := 0
+ currentStmtStartLine := w.lineFor(cursor.Stmt().Pos())
+
+ for cursor.Previous() {
+ previousStmtEndLine := w.lineFor(cursor.Stmt().End())
+ if previousStmtEndLine != currentStmtStartLine-1 {
+ break
+ }
+
+ currentStmtStartLine = w.lineFor(cursor.Stmt().Pos())
+ statementsWithoutNewlines++
+ }
+
+ return statementsWithoutNewlines
+}
+
+func (w *WSL) lineFor(pos token.Pos) int {
+ return w.fset.PositionFor(pos, false).Line
+}
+
+func (w *WSL) lineStartOf(pos token.Pos) token.Pos {
+ return w.fset.File(pos).LineStart(w.lineFor(pos))
+}
+
+func (w *WSL) implementsErr(node *ast.Ident) bool {
+ typeInfo := w.typeInfo.TypeOf(node)
+ if typeInfo == nil {
+ return false
+ }
+
+ errorType, ok := types.Universe.Lookup("error").Type().Underlying().(*types.Interface)
+ if !ok {
+ return false
+ }
+
+ return types.Implements(typeInfo, errorType)
+}
+
+func (w *WSL) commentOnLineAfterNodePos(node ast.Node) token.Pos {
+ nodeEndLine := w.lineFor(node.End())
+
+ for _, cg := range w.file.Comments {
+ if cg.End() <= node.End() {
+ continue
+ }
+
+ commentLine := w.lineFor(cg.Pos())
+ if commentLine == nodeEndLine {
+ continue
+ }
+
+ if commentLine == nodeEndLine+1 {
+ return cg.Pos()
+ }
+
+ break
+ }
+
+ return token.NoPos
+}
+
+func (w *WSL) addErrorInvalidTypeCuddle(pos token.Pos, ct CheckType) {
+ reportMessage := fmt.Sprintf("%s (invalid statement above %s)", messageMissingWhitespaceAbove, ct)
+ insertPos := w.lineStartOf(pos)
+ w.addErrorWithMessage(pos, insertPos, insertPos, reportMessage)
+}
+
+func (w *WSL) addErrorTooManyStatements(pos token.Pos, ct CheckType) {
+ reportMessage := fmt.Sprintf("%s (too many statements above %s)", messageMissingWhitespaceAbove, ct)
+ insertPos := w.lineStartOf(pos)
+ w.addErrorWithMessage(pos, insertPos, insertPos, reportMessage)
+}
+
+func (w *WSL) addErrorNoIntersection(pos token.Pos, ct CheckType) {
+ reportMessage := fmt.Sprintf("%s (no shared variables above %s)", messageMissingWhitespaceAbove, ct)
+ insertPos := w.lineStartOf(pos)
+ w.addErrorWithMessage(pos, insertPos, insertPos, reportMessage)
+}
+
+func (w *WSL) addErrorVariableNotShared(pos token.Pos, ct CheckType) {
+ reportMessage := fmt.Sprintf("%s (variable not shared with %s)", messageMissingWhitespaceAbove, ct)
+ insertPos := w.lineStartOf(pos)
+ w.addErrorWithMessage(pos, insertPos, insertPos, reportMessage)
+}
+
+func (w *WSL) addErrorTooManyLines(pos token.Pos, ct CheckType) {
+ reportMessage := fmt.Sprintf("%s (too many lines above %s)", messageMissingWhitespaceAbove, ct)
+ insertPos := w.lineStartOf(pos)
+ w.addErrorWithMessage(pos, insertPos, insertPos, reportMessage)
+}
+
+func (w *WSL) addErrorNeverAllow(pos token.Pos, ct CheckType) {
+ reportMessage := fmt.Sprintf("%s (never cuddle %s)", messageMissingWhitespaceAbove, ct)
+ insertPos := w.lineStartOf(pos)
+ w.addErrorWithMessage(pos, insertPos, insertPos, reportMessage)
+}
+
+func (w *WSL) addError(report, start, end token.Pos, message string, ct CheckType) {
+ reportMessage := fmt.Sprintf("%s (%s)", message, ct)
+ w.addErrorWithMessage(report, start, end, reportMessage)
+}
+
+func (w *WSL) addErrorRemoveNewline(start, end token.Pos, ct CheckType) {
+ reportMessage := fmt.Sprintf("%s (%s)", messageRemoveWhitespace, ct)
+ w.addErrorWithMessageAndFix(start, start, end, reportMessage, []byte{})
+}
+
+func (w *WSL) addErrorWithMessage(report, start, end token.Pos, message string) {
+ w.addErrorWithMessageAndFix(report, start, end, message, []byte("\n"))
+}
+
+func (w *WSL) addErrorWithMessageAndFix(report, start, end token.Pos, message string, fix []byte) {
+ iss, ok := w.issues[report]
+ if !ok {
+ iss = issue{
+ message: message,
+ fixRanges: []fixRange{},
+ }
+ }
+
+ // Don't add a fix range that overlaps with an existing one — that would
+ // produce conflicting TextEdits. The existing fix already covers this range,
+ // so the diagnostic is surfaced via the first reporter.
+ for _, existing := range iss.fixRanges {
+ if start < existing.fixRangeEnd && end > existing.fixRangeStart {
+ return
+ }
+ }
+
+ iss.fixRanges = append(iss.fixRanges, fixRange{
+ fixRangeStart: start,
+ fixRangeEnd: end,
+ fix: fix,
+ })
+
+ w.issues[report] = iss
+}
+
+func isAssignDeclOrIncDec(n ast.Node) bool {
+ _, a := n.(*ast.AssignStmt)
+ _, d := n.(*ast.DeclStmt)
+ _, i := n.(*ast.IncDecStmt)
+
+ return a || d || i
+}
+
+func asGenDeclWithValueSpecs(n ast.Node) *ast.GenDecl {
+ decl, ok := n.(*ast.DeclStmt)
+ if !ok {
+ return nil
+ }
+
+ genDecl, ok := decl.Decl.(*ast.GenDecl)
+ if !ok {
+ return nil
+ }
+
+ for _, spec := range genDecl.Specs {
+ // We only care about value specs and not type specs or import
+ // specs. We will never see any import specs but type specs we just
+ // separate with an empty line as usual.
+ valueSpec, ok := spec.(*ast.ValueSpec)
+ if !ok {
+ return nil
+ }
+
+ // It's very hard to get comments right in the ast and with the current
+ // way the ast package works we simply don't support grouping at all if
+ // there are any comments related to the node.
+ if valueSpec.Doc != nil || valueSpec.Comment != nil {
+ return nil
+ }
+ }
+
+ return genDecl
+}
+
+func (w *WSL) hasIntersection(a, b ast.Node) bool {
+ aI := w.identsFromNode(a, true)
+ bI := w.identsFromNode(b, true)
+
+ return identsIntersect(aI, bI)
+}
+
+func identsIntersect(a, b []*ast.Ident) bool {
+ for _, as := range a {
+ for _, bs := range b {
+ if as.Name == bs.Name {
+ return true
+ }
+ }
+ }
+
+ return false
+}
+
+func unlabeledStmt(node ast.Node) ast.Node {
+ for {
+ labeled, ok := node.(*ast.LabeledStmt)
+ if !ok {
+ return node
+ }
+
+ node = labeled.Stmt
+ }
+}
+
+func isTypeOrPredeclConst(obj types.Object) bool {
+ switch o := obj.(type) {
+ case *types.TypeName:
+ // Covers predeclared types ("string", "int", ...) and user types.
+ return true
+ case *types.Const:
+ // true/false/iota are universe consts.
+ return o.Parent() == types.Universe
+ case *types.Nil:
+ return true
+ case *types.PkgName:
+ // Skip package qualifiers like "fmt" in fmt.Println
+ return true
+ default:
+ return false
+ }
+}
+
+// identsFromNode returns all *ast.Ident in a node except:
+// - type names (types.TypeName)
+// - builtin constants from the universe (true, false, iota)
+// - nil (*types.Nil)
+// - package names (types.PkgName)
+// - the blank identifier "_"
+func (w *WSL) identsFromNode(node ast.Node, skipBlock bool) []*ast.Ident {
+ var (
+ idents []*ast.Ident
+ seen = map[string]struct{}{}
+ )
+
+ if node == nil {
+ return idents
+ }
+
+ addIdent := func(ident *ast.Ident) {
+ if ident == nil {
+ return
+ }
+
+ name := ident.Name
+ if name == "" || name == "_" {
+ return
+ }
+
+ if _, ok := seen[name]; ok {
+ return
+ }
+
+ idents = append(idents, ident)
+ seen[name] = struct{}{}
+ }
+
+ ast.Inspect(node, func(n ast.Node) bool {
+ if skipBlock {
+ if _, ok := n.(*ast.BlockStmt); ok {
+ return false
+ }
+ }
+
+ ident, ok := n.(*ast.Ident)
+ if !ok {
+ return true
+ }
+
+ // Prefer Uses over Defs; fall back to Defs if not a use site.
+ var typesObject types.Object
+ if obj := w.typeInfo.Uses[ident]; obj != nil {
+ typesObject = obj
+ } else if obj := w.typeInfo.Defs[ident]; obj != nil {
+ typesObject = obj
+ }
+
+ // Unresolved (could be a build-tag or syntax artifact). Keep it.
+ if typesObject == nil {
+ addIdent(ident)
+ return true
+ }
+
+ if isTypeOrPredeclConst(typesObject) {
+ return true
+ }
+
+ addIdent(ident)
+
+ return true
+ })
+
+ return idents
+}
+
+func (w *WSL) identsFromCaseArms(node ast.Node) []*ast.Ident {
+ var (
+ idents []*ast.Ident
+ nodes []ast.Stmt
+ seen = map[string]struct{}{}
+
+ addUnseen = func(node ast.Node) {
+ for _, ident := range w.identsFromNode(node, true) {
+ if _, ok := seen[ident.Name]; ok {
+ continue
+ }
+
+ seen[ident.Name] = struct{}{}
+ idents = append(idents, ident)
+ }
+ }
+ )
+
+ switch v := node.(type) {
+ case *ast.SwitchStmt:
+ nodes = v.Body.List
+ case *ast.TypeSwitchStmt:
+ nodes = v.Body.List
+ case *ast.SelectStmt:
+ nodes = v.Body.List
+ default:
+ return idents
+ }
+
+ for _, node := range nodes {
+ switch n := node.(type) {
+ case *ast.CommClause:
+ addUnseen(n.Comm)
+ case *ast.CaseClause:
+ for _, n := range n.List {
+ addUnseen(n)
+ }
+ default:
+ continue
+ }
+ }
+
+ return idents
+}
+
+// hasSelectorCall checks if node contains a selector call with one of the given names.
+func hasSelectorCall(node ast.Node, selectorNames []string) bool {
+ var found bool
+
+ ast.Inspect(node, func(n ast.Node) bool {
+ if found {
+ return false // Already found
+ }
+
+ if _, ok := n.(*ast.BlockStmt); ok {
+ return false
+ }
+
+ if sel, ok := n.(*ast.SelectorExpr); ok {
+ found = slices.Contains(selectorNames, sel.Sel.Name)
+ return false
+ }
+
+ return true
+ })
+
+ return found
+}
+
+func (w *WSL) isLockOrUnlock(current, previous ast.Node) bool {
+ // If we're an ExprStmt (e.g. X()), we check if we're calling `Unlock` or
+ // `RWUnlock`. No matter how deep this is or what previous statement was, we
+ // allow this.
+ //
+ // mu.Lock()
+ // [ANY BLOCK]
+ // mu.Unlock()
+ if _, ok := current.(*ast.ExprStmt); ok {
+ return hasSelectorCall(current, []string{"Unlock", "RWUnlock"})
+ }
+
+ if previous != nil {
+ return hasSelectorCall(previous, []string{"Lock", "RWLock", "TryLock"})
+ }
+
+ return false
+}
+
+// isErrNotNilCheck returns the error identifier if stmt is an `if err != nil`
+// or `if err == nil` check without an init statement, nil otherwise.
+func (w *WSL) isErrNotNilCheck(stmt ast.Node) *ast.Ident {
+ ifStmt, ok := stmt.(*ast.IfStmt)
+ if !ok {
+ return nil
+ }
+
+ // If the error checking has an init condition (e.g. if err := f();) we
+ // don't consider it an error check since the error is assigned on this row.
+ if ifStmt.Init != nil {
+ return nil
+ }
+
+ // The condition must be a binary expression (X OP Y)
+ binaryExpr, ok := ifStmt.Cond.(*ast.BinaryExpr)
+ if !ok {
+ return nil
+ }
+
+ // We must do not equal or equal comparison (!= or ==)
+ if binaryExpr.Op != token.NEQ && binaryExpr.Op != token.EQL {
+ return nil
+ }
+
+ xIdent, ok := binaryExpr.X.(*ast.Ident)
+ if !ok {
+ return nil
+ }
+
+ // X is not an error so it's not error checking
+ if !w.implementsErr(xIdent) {
+ return nil
+ }
+
+ yIdent, ok := binaryExpr.Y.(*ast.Ident)
+ if !ok {
+ return nil
+ }
+
+ // Y is not compared with `nil`
+ if yIdent.Name != "nil" {
+ return nil
+ }
+
+ return xIdent
+}
diff --git a/vendor/github.com/butuzov/ireturn/analyzer/analyzer.go b/vendor/github.com/butuzov/ireturn/analyzer/analyzer.go
index ebf2a0dbea..92ab14ba48 100644
--- a/vendor/github.com/butuzov/ireturn/analyzer/analyzer.go
+++ b/vendor/github.com/butuzov/ireturn/analyzer/analyzer.go
@@ -18,18 +18,11 @@ import (
const name string = "ireturn" // linter name
-type validator interface {
- IsValid(types.IFace) bool
-}
-
type analyzer struct {
once sync.Once
- mu sync.RWMutex
- handler validator
+ handler config.Validator
err error
disabledNolint bool
-
- found []analysis.Diagnostic
}
func (a *analyzer) run(pass *analysis.Pass) (interface{}, error) {
@@ -84,27 +77,13 @@ func (a *analyzer) run(pass *analysis.Pass) (interface{}, error) {
}
seen[key] = true
- a.addDiagnostic(issue.ExportDiagnostic())
+ pass.Report(issue.ExportDiagnostic())
}
})
- // 02. Printing reports.
- a.mu.RLock()
- defer a.mu.RUnlock()
- for i := range a.found {
- pass.Report(a.found[i])
- }
-
return nil, nil
}
-func (a *analyzer) addDiagnostic(d analysis.Diagnostic) {
- a.mu.Lock()
- defer a.mu.Unlock()
-
- a.found = append(a.found, d)
-}
-
func (a *analyzer) readConfiguration(fs *flag.FlagSet) {
cnf, err := config.New(fs)
if err != nil {
@@ -118,13 +97,7 @@ func (a *analyzer) readConfiguration(fs *flag.FlagSet) {
a.disabledNolint = fs.Lookup("nonolint").Value.String() == "true"
}
- // Second: validators implementation next
- if validatorImpl, ok := cnf.(validator); ok {
- a.handler = validatorImpl
- return
- }
-
- a.handler = config.DefaultValidatorConfig()
+ a.handler = cnf
}
func NewAnalyzer() *analysis.Analyzer {
@@ -196,13 +169,14 @@ func filterInterfaces(p *analysis.Pass, ft *ast.FuncType, di map[string]struct{}
typeParams := val.String()
prefix, suffix := "interface{", "}"
- if strings.HasPrefix(typeParams, prefix) { //nolint:gosimple
+ if strings.HasPrefix(typeParams, prefix) { //nolint:staticcheck
typeParams = typeParams[len(prefix):]
}
if strings.HasSuffix(typeParams, suffix) {
typeParams = typeParams[:len(typeParams)-1]
}
+ // todo: write test for this (1.18&1.19 only?)
goVersion := runtime.Version()
if strings.HasPrefix(goVersion, "go1.18") || strings.HasPrefix(goVersion, "go1.19") {
typeParams = strings.ReplaceAll(typeParams, "|", " | ")
diff --git a/vendor/github.com/butuzov/ireturn/analyzer/internal/config/new.go b/vendor/github.com/butuzov/ireturn/analyzer/internal/config/new.go
index d6914af862..11c4930b31 100644
--- a/vendor/github.com/butuzov/ireturn/analyzer/internal/config/new.go
+++ b/vendor/github.com/butuzov/ireturn/analyzer/internal/config/new.go
@@ -8,9 +8,13 @@ import (
"github.com/butuzov/ireturn/analyzer/internal/types"
)
+type Validator interface {
+ IsValid(i types.IFace) bool
+}
+
var ErrCollisionOfInterests = errors.New("can't have both `-accept` and `-reject` specified at same time")
-func DefaultValidatorConfig() *allowConfig {
+func defaultValidatorConfig() *allowConfig {
return allowAll([]string{
types.NameEmpty, // "empty": empty interfaces (interface{})
types.NameError, // "error": for all error's
@@ -21,7 +25,7 @@ func DefaultValidatorConfig() *allowConfig {
// New is factory function that return allowConfig or rejectConfig depending
// on provided arguments.
-func New(fs *flag.FlagSet) (interface{}, error) {
+func New(fs *flag.FlagSet) (Validator, error) {
var (
allowList = toSlice(getFlagVal(fs, "allow"))
rejectList = toSlice(getFlagVal(fs, "reject"))
@@ -40,7 +44,7 @@ func New(fs *flag.FlagSet) (interface{}, error) {
}
// can have none (defaults are used) at same time.
- return nil, nil
+ return defaultValidatorConfig(), nil
}
// both constants used to cleanup items provided in comma separated list.
diff --git a/vendor/github.com/butuzov/ireturn/analyzer/std.go b/vendor/github.com/butuzov/ireturn/analyzer/std.go
index cac4646126..d490e8d3ed 100644
--- a/vendor/github.com/butuzov/ireturn/analyzer/std.go
+++ b/vendor/github.com/butuzov/ireturn/analyzer/std.go
@@ -1,4 +1,4 @@
-// Code generated using std.sh; DO NOT EDIT.
+// Code generated using generate-std.sh; DO NOT EDIT.
// We will ignore that fact that some of packages
// were removed from stdlib.
@@ -200,4 +200,21 @@ var std = map[string]struct{}{
// added in Go v1.22 in compare to v1.21 (docker image)
"go/version": {},
"math/rand/v2": {},
+ // added in Go v1.23 in compare to v1.22 (docker image)
+ "iter": {},
+ "structs": {},
+ "unique": {},
+ // added in Go v1.24 in compare to v1.23 (docker image)
+ "crypto/fips140": {},
+ "crypto/hkdf": {},
+ "crypto/mlkem": {},
+ "crypto/pbkdf2": {},
+ "crypto/sha3": {},
+ "weak": {},
+ // added in Go v1.25 in compare to v1.24 (docker image)
+ "testing/synctest": {},
+ // added in Go v1.26 in compare to v1.25 (docker image)
+ "crypto/hpke": {},
+ "crypto/mlkem/mlkemtest": {},
+ "testing/cryptotest": {},
}
diff --git a/vendor/github.com/butuzov/mirror/.editorconfig b/vendor/github.com/butuzov/mirror/.editorconfig
index 4d9c20d8d9..69350a46e6 100644
--- a/vendor/github.com/butuzov/mirror/.editorconfig
+++ b/vendor/github.com/butuzov/mirror/.editorconfig
@@ -16,9 +16,6 @@ trim_trailing_whitespace = true # no extra sapces at the end of lines
indent_style = tab
indent_size = 2
-[{Makefile,makefile}] # CMake
-indent_style = tab
-
[*.md] # Markdown
trim_trailing_whitespace = true
max_line_length = 100
diff --git a/vendor/github.com/butuzov/mirror/.golangci.yaml b/vendor/github.com/butuzov/mirror/.golangci.yaml
new file mode 100644
index 0000000000..34fd5ece8e
--- /dev/null
+++ b/vendor/github.com/butuzov/mirror/.golangci.yaml
@@ -0,0 +1,26 @@
+version: "2"
+
+linters:
+ enable:
+ - nolintlint
+ - testifylint
+ settings:
+ nolintlint:
+ require-specific: true
+ allow-unused: false
+ exclusions:
+ presets:
+ - comments
+ - common-false-positives
+ - std-error-handling
+
+formatters:
+ enable:
+ - gci
+ - gofumpt
+ settings:
+ gci:
+ sections:
+ - standard
+ - default
+ - prefix(github.com/butuzov/mirror)
diff --git a/vendor/github.com/butuzov/mirror/Makefile b/vendor/github.com/butuzov/mirror/Makefile
deleted file mode 100644
index dab6f160ae..0000000000
--- a/vendor/github.com/butuzov/mirror/Makefile
+++ /dev/null
@@ -1,132 +0,0 @@
-# --- Required ----------------------------------------------------------------
-export PATH := $(PWD)/bin:$(PATH) # ./bin to $PATH
-export SHELL := bash # Default Shell
-
-define install_go_bin
- @ which $(1) 2>&1 1>/dev/null || GOBIN=$(PWD)/bin go install $(2)
-endef
-
-.DEFAULT_GOAL := help
-
-# Generate Artifacts ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-generate: ## Generate Assets
- $(MAKE) generate-tests
- $(MAKE) generate-mirror-table
-
-generate-tests: ## Generates Assets at testdata
- go run ./cmd/internal/tests/ "$(PWD)/testdata"
-
-generate-mirror-table: ## Generate Asset MIRROR_FUNCS.md
- go run ./cmd/internal/mirror-table/ > "$(PWD)/MIRROR_FUNCS.md"
-
-
-# Build Artifacts ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-build: ## Build binary
- @ go build -trimpath -ldflags="-w -s" -o bin/mirror ./cmd/mirror/
-
-build-race: ## Build binary with race flag
- @ go build -race -trimpath -ldflags="-w -s" -o bin/mirror ./cmd/mirror/
-
-install: ## Installs binary
- @ go install -trimpath -v -ldflags="-w -s" ./cmd/mirror
-
-# Run Tests ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-tests: ## Run Tests (Summary)
- @ go test -v -count=1 -race \
- -failfast \
- -parallel=2 \
- -timeout=1m \
- -covermode=atomic \
- -coverprofile=coverage.cov ./...
-
-tests-summary: ## Run Tests, but shows summary
-tests-summary: bin/tparse
- @ go test -v -count=1 -race \
- -failfast \
- -parallel=2 \
- -timeout=1m \
- -covermode=atomic \
- -coverprofile=coverage.cov --json ./... | tparse -all
-
-# Linter ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-lints: ## Run golangci-lint
-lints: bin/golangci-lint
-lints:
- golangci-lint run --no-config ./... --exclude-dirs "^(cmd|testdata)"
-
-
-cover: ## Run Coverage
- @ go tool cover -html=coverage.cov
-
-# Other ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-test-release: bin/goreleaser
- goreleaser release --help
- goreleaser release --skip=publish --skip=validate --clean
-
-# Install ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-bin/tparse: ## Installs tparse@v0.13.2 (if not exists)
-bin/tparse: INSTALL_URL=github.com/mfridman/tparse@v0.13.2
-bin/tparse:
- $(call install_go_bin, tparse, $(INSTALL_URL))
-
-bin/golangci-lint: ## Installs golangci-lint@v1.62.0 (if not exists)
-bin/golangci-lint: INSTALL_URL=github.com/golangci/golangci-lint@v1.62.0
-bin/golangci-lint:
- $(call install_go_bin, golangci-lint, $(INSTALL_URL))
-
-bin/goreleaser: ## Installs goreleaser@v1.24.0 (if not exists)
-bin/goreleaser: INSTALL_URL=github.com/goreleaser/goreleaser@v1.24.0
-bin/goreleaser:
- $(call install_go_bin, goreleaser, $(INSTALL_URL))
-
-# Help ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-help: dep-gawk
- @ echo "=============================================================================="
- @ echo " Makefile: github.com/butuzov/mirror "
- @ echo "=============================================================================="
- @ cat $(MAKEFILE_LIST) | \
- grep -E '^# ~~~ .*? [~]+$$|^[a-zA-Z0-9_-]+:.*?## .*$$' | \
- gawk '{if ( $$1=="#" ) { \
- match($$0, /^# ~~~ (.+?) [~]+$$/, a);\
- {print "\n", a[1], ""}\
- } else { \
- match($$0, /^([a-zA-Z/_-]+):.*?## (.*)$$/, a); \
- {printf " - \033[32m%-20s\033[0m %s\n", a[1], a[2]} \
- }}'
- @ echo ""
-
-
-# Helper Methods ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-dep-gawk:
- @ if [ -z "$(shell command -v gawk)" ]; then \
- if [ -x /usr/local/bin/brew ]; then $(MAKE) _brew_gawk_install; exit 0; fi; \
- if [ -x /usr/bin/apt-get ]; then $(MAKE) _ubuntu_gawk_install; exit 0; fi; \
- if [ -x /usr/bin/yum ]; then $(MAKE) _centos_gawk_install; exit 0; fi; \
- if [ -x /sbin/apk ]; then $(MAKE) _alpine_gawk_install; exit 0; fi; \
- echo "GNU Awk Required.";\
- exit 1; \
- fi
-
-_brew_gawk_install:
- @ echo "Installing gawk using brew... "
- @ brew install gawk --quiet
- @ echo "done"
-
-_ubuntu_gawk_install:
- @ echo "Installing gawk using apt-get... "
- @ apt-get -q install gawk -y
- @ echo "done"
-
-_alpine_gawk_install:
- @ echo "Installing gawk using yum... "
- @ apk add --update --no-cache gawk
- @ echo "done"
-
-_centos_gawk_install:
- @ echo "Installing gawk using yum... "
- @ yum install -q -y gawk;
- @ echo "done"
diff --git a/vendor/github.com/butuzov/mirror/Taskfile.yml b/vendor/github.com/butuzov/mirror/Taskfile.yml
index 4bc7cfeda5..6f933af5ee 100644
--- a/vendor/github.com/butuzov/mirror/Taskfile.yml
+++ b/vendor/github.com/butuzov/mirror/Taskfile.yml
@@ -1,4 +1,4 @@
-version: '3'
+version: "3"
tasks:
default: task --list-all
@@ -7,41 +7,56 @@ tasks:
watcher:
desc: watcher
sources:
- - ./**/*.go
+ - ./**/*.go
method: timestamp
cmds:
- - task: lints
- - task: test-summary
- - task: build-race
+ - task: lints
+ - task: test-summary
+ - task: build-race
# Generating assets ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
generate:
desc: Generate Assets
sources:
- - ./checkers_*.go
- - ./cmd/internal/**/*.go
+ - ./checkers_*.go
+ - ./cmd/internal/**/*.go
method: timestamp
cmds:
- - task generate-mirror-table
- - task generate-tests
+ - task generate-mirror-table
+ - task generate-tests
generate-mirror-table:
desc: Generates Assets at testdata
- cmd: make generate-mirror-table
+ cmd: go run ./cmd/internal/mirror-table/ > ./MIRROR_FUNCS.md
generate-tests:
desc: Generate Asset MIRROR_FUNCS.md
- cmd: make generate-tests
+ cmd: go run ./cmd/internal/tests/ ./testdata
# Run Tests ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tests:
desc: Run Tests
- cmd: make tests
+ cmd: |
+ go test -v -count=1 -race \
+ -failfast \
+ -parallel=2 \
+ -timeout=1m \
+ -covermode=atomic \
+ -coverpkg $(go list ./... | grep -v -E "cmd" | tr "\n" ",") \
+ -coverprofile=coverage.cov ./...
+
ignore_error: true
test-summary:
desc: Run Tests (Summary)
- cmd: make tests-summary
+ cmd: |
+ go test -v -count=1 -race \
+ -failfast \
+ -parallel=2 \
+ -timeout=1m \
+ -covermode=atomic \
+ -coverpkg $(go list ./... | grep -v -E "cmd" | tr "\n" ",") \
+ -coverprofile=coverage.cov --json ./... | tparse -all
ignore_error: true
testcase: go test -v -failfast -count=1 -run "TestAll/{{ .Case }}" ./...
@@ -49,25 +64,24 @@ tasks:
# Build Artifacts ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
build:
desc: Build binary
- cmd: make build
+ cmd: go build -trimpath -ldflags="-w -s" -o bin/mirror ./cmd/mirror/
build-race:
desc: Build binary with race flag
- cmd: make build-race
+ cmd: go build -race -trimpath -ldflags="-w -s" -o bin/mirror ./cmd/mirror/
install:
desc: Install binary
- cmd: make install
+ cmd: go install -trimpath -v -ldflags="-w -s" ./cmd/mirror
# Linter ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- lints:
- cmd: make lints
+ lints: golangci-lint run --no-config ./...
# Other
cover:
desc: Run Coverage
- cmd: make cover
+ cmd: go tool cover -html=coverage.cov
test-release:
desc: Testing Release
- cmd: make test-release
+ cmd: goreleaser release --snapshot --clean
diff --git a/vendor/github.com/butuzov/mirror/analyzer.go b/vendor/github.com/butuzov/mirror/analyzer.go
index b15019ce1f..aab8192524 100644
--- a/vendor/github.com/butuzov/mirror/analyzer.go
+++ b/vendor/github.com/butuzov/mirror/analyzer.go
@@ -5,11 +5,11 @@ import (
"go/ast"
"strings"
- "github.com/butuzov/mirror/internal/checker"
-
"golang.org/x/tools/go/analysis"
"golang.org/x/tools/go/analysis/passes/inspect"
"golang.org/x/tools/go/ast/inspector"
+
+ "github.com/butuzov/mirror/internal/checker"
)
func NewAnalyzer() *analysis.Analyzer {
diff --git a/vendor/github.com/butuzov/mirror/internal/checker/checker.go b/vendor/github.com/butuzov/mirror/internal/checker/checker.go
index fb9ba41729..2b1b945450 100644
--- a/vendor/github.com/butuzov/mirror/internal/checker/checker.go
+++ b/vendor/github.com/butuzov/mirror/internal/checker/checker.go
@@ -109,7 +109,7 @@ func (c *Checker) callConverts(ce *ast.CallExpr) bool {
// register violations.
func (c *Checker) register(violations []Violation) {
- for _, v := range violations { // nolint: gocritic
+ for _, v := range violations { //nolint: gocritic
c.Violations = append(c.Violations, v)
if len(v.Struct) > 0 {
c.registerIdxPer(v.Package + "." + v.Struct)
@@ -141,7 +141,7 @@ func WrapType(info *types.Info) func(node ast.Expr) string {
func WrapPrint(fSet *token.FileSet) func(ast.Node) []byte {
return func(node ast.Node) []byte {
var buf bytes.Buffer
- printer.Fprint(&buf, fSet, node)
+ _ = printer.Fprint(&buf, fSet, node)
return buf.Bytes()
}
}
diff --git a/vendor/github.com/butuzov/mirror/internal/checker/violation.go b/vendor/github.com/butuzov/mirror/internal/checker/violation.go
index c2c1492086..1bb6ffe278 100644
--- a/vendor/github.com/butuzov/mirror/internal/checker/violation.go
+++ b/vendor/github.com/butuzov/mirror/internal/checker/violation.go
@@ -104,9 +104,9 @@ func (v *Violation) suggest(fSet *token.FileSet) []byte {
buf.WriteByte('(')
for idx := range v.callExpr.Args {
if arg, ok := v.arguments[idx]; ok {
- printer.Fprint(&buf, fSet, arg)
+ _ = printer.Fprint(&buf, fSet, arg)
} else {
- printer.Fprint(&buf, fSet, v.callExpr.Args[idx])
+ _ = printer.Fprint(&buf, fSet, v.callExpr.Args[idx])
}
if idx != len(v.callExpr.Args)-1 {
@@ -126,7 +126,7 @@ func (v *Violation) Diagnostic(fSet *token.FileSet) analysis.Diagnostic {
}
var buf bytes.Buffer
- printer.Fprint(&buf, fSet, v.callExpr)
+ _ = printer.Fprint(&buf, fSet, v.callExpr)
noNl := bytes.IndexByte(buf.Bytes(), '\n') < 0
// Struct based fix.
@@ -177,7 +177,7 @@ func (v *Violation) Issue(fSet *token.FileSet) GolangIssue {
// original expression (useful for debug & required for replace)
var buf bytes.Buffer
- printer.Fprint(&buf, fSet, v.callExpr)
+ _ = printer.Fprint(&buf, fSet, v.callExpr)
issue.Original = buf.String()
noNl := strings.IndexByte(issue.Original, '\n') < 0
diff --git a/vendor/github.com/butuzov/mirror/readme.md b/vendor/github.com/butuzov/mirror/readme.md
index f5cfa47a68..b34ca11c03 100644
--- a/vendor/github.com/butuzov/mirror/readme.md
+++ b/vendor/github.com/butuzov/mirror/readme.md
@@ -1,14 +1,25 @@
-# `mirror` [](https://u24.gov.ua/) [](https://coveralls.io/github/butuzov/mirror?branch=main) []()
+# `mirror` [](https://u24.gov.ua/) [](https://coveralls.io/github/butuzov/mirror?branch=main) []() [](http://www.opensource.org/licenses/MIT)
-`mirror` suggests use of alternative functions/methods in order to gain performance boosts by avoiding unnecessary `[]byte/string` conversion calls. See [MIRROR_FUNCS.md](MIRROR_FUNCS.md) list of mirror functions you can use in go's stdlib.
+Use right mirror functions for string/[]byte performance bust
---
[](https://u24.gov.ua/)
-[](https://github.com/butuzov)
---
+`mirror` suggests use of alternative functions/methods in order to gain performance boosts by avoiding unnecessary `[]byte/string` conversion calls. See [MIRROR_FUNCS.md](MIRROR_FUNCS.md) list of mirror functions you can use in go's stdlib.
+
+## Install
+
+```
+go install github.com/butuzov/mirror/cmd/mirror@latest
+```
+
+### `golangci-lint`
+
+`golangci-lint` supports `mirror` since `v1.53.0`
+
## Linter Use Cases
### `github.com/argoproj/argo-cd`
@@ -33,16 +44,6 @@ func IsValidHostname(hostname string, fqdn bool) bool {
}
```
-## Install
-
-```
-go install github.com/butuzov/mirror/cmd/mirror@latest
-```
-
-### `golangci-lint`
-`golangci-lint` supports `mirror` since `v1.53.0`
-
-
## How to use
You run `mirror` with [`go vet`](https://pkg.go.dev/cmd/vet):
@@ -56,6 +57,7 @@ pkg/common/net/ssl/ssl.go:166:3: avoid allocations with (*os.File).WriteString
```
Can be called directly:
+
```
mirror ./...
# https://github.com/cosmtrek/air
@@ -89,33 +91,33 @@ util/cert/cert.go:82:10: avoid allocations with (*regexp.Regexp).MatchString (mi
- You can add checks for `_test.go` files with cli option `--with-tests`
### `golangci-lint`
- With `golangci-lint` tests are checked by default and can be can be turned off by using the regular `golangci-lint` ways to do it:
-
- - flag `--tests` (e.g. `--tests=false`)
- - flag `--skip-files` (e.g. `--skip-files="_test.go"`)
- - yaml configuration `run.skip-files`:
- ```yaml
- run:
- skip-files:
- - '(.+)_test\.go'
- ```
- - yaml configuration `issues.exclude-rules`:
- ```yaml
- issues:
- exclude-rules:
- - path: '(.+)_test\.go'
- linters:
- - mirror
- ```
+With `golangci-lint` tests are checked by default and can be can be turned off by using the regular `golangci-lint` ways to do it:
+
+- flag `--tests` (e.g. `--tests=false`)
+- flag `--skip-files` (e.g. `--skip-files="_test.go"`)
+- yaml configuration `run.skip-files`:
+ ```yaml
+ run:
+ skip-files:
+ - '(.+)_test\.go'
+ ```
+- yaml configuration `issues.exclude-rules`:
+ ```yaml
+ issues:
+ exclude-rules:
+ - path: '(.+)_test\.go'
+ linters:
+ - mirror
+ ```
## Contributing
```shell
# Update Assets (testdata/(strings|bytes|os|utf8|maphash|regexp|bufio).go)
-(task|make) generate
+task generate
# Run Tests
-(task|make) tests
+task tests
# Lint Code
-(task|make) lints
+task lints
```
diff --git a/vendor/github.com/catenacyber/perfsprint/analyzer/analyzer.go b/vendor/github.com/catenacyber/perfsprint/analyzer/analyzer.go
index 866d11083a..c44104f5f9 100644
--- a/vendor/github.com/catenacyber/perfsprint/analyzer/analyzer.go
+++ b/vendor/github.com/catenacyber/perfsprint/analyzer/analyzer.go
@@ -1,7 +1,9 @@
+// Package analyzer provides a static analysis tool that checks that fmt.Sprintf can be replaced with a faster alternative.
package analyzer
import (
"bytes"
+ "fmt"
"go/ast"
"go/format"
"go/token"
@@ -33,13 +35,20 @@ type optionStr struct {
strconcat bool
}
+type optionConcatLoop struct {
+ enabled bool
+ otherOps bool
+}
+
type perfSprint struct {
- intFormat optionInt
- errFormat optionErr
- strFormat optionStr
+ intFormat optionInt
+ errFormat optionErr
+ strFormat optionStr
+ concatLoop optionConcatLoop
boolFormat bool
hexFormat bool
+
fiximports bool
}
@@ -48,12 +57,30 @@ func newPerfSprint() *perfSprint {
intFormat: optionInt{enabled: true, intConv: true},
errFormat: optionErr{enabled: true, errError: false, errorf: true},
strFormat: optionStr{enabled: true, sprintf1: true, strconcat: true},
+ concatLoop: optionConcatLoop{enabled: true, otherOps: false},
boolFormat: true,
hexFormat: true,
fiximports: true,
}
}
+const (
+ // checkerErrorFormat checks for error formatting.
+ checkerErrorFormat = "error-format"
+ // checkerIntegerFormat checks for integer formatting.
+ checkerIntegerFormat = "integer-format"
+ // checkerStringFormat checks for string formatting.
+ checkerStringFormat = "string-format"
+ // checkerBoolFormat checks for bool formatting.
+ checkerBoolFormat = "bool-format"
+ // checkerHexFormat checks for hexadecimal formatting.
+ checkerHexFormat = "hex-format"
+ // checkerConcatLoop checks for concatenation in loop.
+ checkerConcatLoop = "concat-loop"
+ // checkerFixImports fix needed imports from other fixes.
+ checkerFixImports = "fiximports"
+)
+
func New() *analysis.Analyzer {
n := newPerfSprint()
r := &analysis.Analyzer{
@@ -63,17 +90,21 @@ func New() *analysis.Analyzer {
Run: n.run,
Requires: []*analysis.Analyzer{inspect.Analyzer},
}
- r.Flags.BoolVar(&n.intFormat.enabled, "integer-format", n.intFormat.enabled, "enable/disable optimization of integer formatting")
+
+ r.Flags.BoolVar(&n.intFormat.enabled, checkerIntegerFormat, n.intFormat.enabled, "enable/disable optimization of integer formatting")
r.Flags.BoolVar(&n.intFormat.intConv, "int-conversion", n.intFormat.intConv, "optimizes even if it requires an int or uint type cast")
- r.Flags.BoolVar(&n.errFormat.enabled, "error-format", n.errFormat.enabled, "enable/disable optimization of error formatting")
+ r.Flags.BoolVar(&n.errFormat.enabled, checkerErrorFormat, n.errFormat.enabled, "enable/disable optimization of error formatting")
r.Flags.BoolVar(&n.errFormat.errError, "err-error", n.errFormat.errError, "optimizes into err.Error() even if it is only equivalent for non-nil errors")
r.Flags.BoolVar(&n.errFormat.errorf, "errorf", n.errFormat.errorf, "optimizes fmt.Errorf")
- r.Flags.BoolVar(&n.boolFormat, "bool-format", n.boolFormat, "enable/disable optimization of bool formatting")
- r.Flags.BoolVar(&n.hexFormat, "hex-format", n.hexFormat, "enable/disable optimization of hex formatting")
- r.Flags.BoolVar(&n.strFormat.enabled, "string-format", n.strFormat.enabled, "enable/disable optimization of string formatting")
+
+ r.Flags.BoolVar(&n.boolFormat, checkerBoolFormat, n.boolFormat, "enable/disable optimization of bool formatting")
+ r.Flags.BoolVar(&n.hexFormat, checkerHexFormat, n.hexFormat, "enable/disable optimization of hex formatting")
+ r.Flags.BoolVar(&n.concatLoop.enabled, checkerConcatLoop, n.concatLoop.enabled, "enable/disable optimization of concat loop")
+ r.Flags.BoolVar(&n.concatLoop.otherOps, "loop-other-ops", n.concatLoop.otherOps, "optimization of concat loop even with other operations")
+ r.Flags.BoolVar(&n.strFormat.enabled, checkerStringFormat, n.strFormat.enabled, "enable/disable optimization of string formatting")
r.Flags.BoolVar(&n.strFormat.sprintf1, "sprintf1", n.strFormat.sprintf1, "optimizes fmt.Sprintf with only one argument")
r.Flags.BoolVar(&n.strFormat.strconcat, "strconcat", n.strFormat.strconcat, "optimizes into strings concatenation")
- r.Flags.BoolVar(&n.fiximports, "fiximports", n.fiximports, "fix needed imports from other fixes")
+ r.Flags.BoolVar(&n.fiximports, checkerFixImports, n.fiximports, "fix needed imports from other fixes")
return r
}
@@ -88,7 +119,347 @@ func isConcatable(verb string) bool {
if strings.Count(verb, "%[1]s") > 1 {
return false
}
- return (hasPrefix || hasSuffix) && !(hasPrefix && hasSuffix)
+ // TODO handle case hasPrefix and hasSuffix
+ return (hasPrefix || hasSuffix) && !(hasPrefix && hasSuffix) //nolint:staticcheck
+}
+
+func isStringAdd(st *ast.AssignStmt, idname string) ast.Expr {
+ // right is one
+ if len(st.Rhs) == 1 {
+ // right is addition
+ add, ok := st.Rhs[0].(*ast.BinaryExpr)
+ if ok && add.Op == token.ADD {
+ // right is addition to same ident name
+ x, ok := add.X.(*ast.Ident)
+ if ok && x.Name == idname {
+ return add.Y
+ }
+ }
+ }
+ return nil
+}
+
+func (n *perfSprint) reportConcatLoop(pass *analysis.Pass, neededPackages map[string]map[string]struct{}, node ast.Node, adds map[string][]*ast.AssignStmt) *analysis.Diagnostic {
+ fname := pass.Fset.File(node.Pos()).Name()
+ if _, ok := neededPackages[fname]; !ok {
+ neededPackages[fname] = make(map[string]struct{})
+ }
+ // note that we will need strings package
+ neededPackages[fname]["strings"] = struct{}{}
+
+ // sort for reproducibility
+ keys := make([]string, 0, len(adds))
+ for k := range adds {
+ keys = append(keys, k)
+ }
+ sort.Strings(keys)
+
+ // use line number to define a unique variable name for the strings Builder
+ loopStartLine := pass.Fset.Position(node.Pos()).Line
+
+ // If the loop does more with the string than concatenations
+ // add a TODO/FIXME comment that the fix is likely incomplete/incorrect
+ addTODO := ""
+ ast.Inspect(node, func(n ast.Node) bool {
+ if len(addTODO) > 0 {
+ // already found one, stop recursing
+ return false
+ }
+ switch x := n.(type) {
+ case *ast.AssignStmt:
+ // skip if this is one string concatenation that we are fixing
+ if (x.Tok == token.ASSIGN || x.Tok == token.ADD_ASSIGN) && len(x.Lhs) == 1 {
+ id, ok := x.Lhs[0].(*ast.Ident)
+ if ok {
+ _, ok = adds[id.Name]
+ if ok {
+ if x.Tok == token.ASSIGN && isStringAdd(x, id.Name) == nil {
+ addTODO = id.Name
+ }
+ return false
+ }
+ }
+ }
+ case *ast.Ident:
+ _, ok := adds[x.Name]
+ if ok {
+ // The variable name is used in some place else
+ addTODO = x.Name
+ return false
+ }
+ }
+ return true
+ })
+
+ prefix := ""
+ suffix := ""
+ if len(addTODO) > 0 {
+ if !n.concatLoop.otherOps {
+ return nil
+ }
+ prefix = fmt.Sprintf("// FIXME check usages of string identifier %s (and mayber others) in loop\n", addTODO)
+ }
+ // The fix contains 3 parts
+ // before the loop: declare the strings Builders
+ // during the loop: replace concatenation with Builder.WriteString
+ // after the loop: use the Builder.String to append to the pre-existing string
+ var prefixSb203 strings.Builder
+ var suffixSb203 strings.Builder
+ for _, k := range keys {
+ // lol
+ prefixSb203.WriteString(fmt.Sprintf("var %sSb%d strings.Builder\n", k, loopStartLine))
+ suffixSb203.WriteString(fmt.Sprintf("\n%s += %sSb%d.String()", k, k, loopStartLine))
+ }
+ prefix += prefixSb203.String()
+ suffix += suffixSb203.String()
+ te := []analysis.TextEdit{
+ {
+ Pos: node.Pos(),
+ End: node.Pos(),
+ NewText: []byte(prefix),
+ },
+ }
+ for _, k := range keys {
+ v := adds[k]
+ for _, st := range v {
+ // s += "x" -> use "x"
+ added := st.Rhs[0]
+ if st.Tok == token.ASSIGN {
+ // s = s + "x" -> use just "x", not `s + "x"`
+ added = isStringAdd(st, k)
+ }
+ te = append(te, analysis.TextEdit{
+ Pos: st.Pos(),
+ End: added.Pos(),
+ NewText: []byte(fmt.Sprintf("%sSb%d.WriteString(", k, loopStartLine)),
+ })
+ te = append(te, analysis.TextEdit{
+ Pos: added.End(),
+ End: added.End(),
+ NewText: []byte(")"),
+ })
+ }
+ }
+ te = append(te, analysis.TextEdit{
+ Pos: node.End(),
+ End: node.End(),
+ NewText: []byte(suffix),
+ })
+
+ return newAnalysisDiagnostic(
+ checkerConcatLoop,
+ adds[keys[0]][0],
+ "string concatenation in a loop",
+ []analysis.SuggestedFix{
+ {
+ Message: "Use a strings.Builder",
+ TextEdits: te,
+ },
+ },
+ )
+}
+
+func (n *perfSprint) runConcatLoop(pass *analysis.Pass, neededPackages map[string]map[string]struct{}) {
+ insp := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
+ // 2 different kinds of loops in go
+ nodeFilter := []ast.Node{
+ (*ast.RangeStmt)(nil),
+ (*ast.ForStmt)(nil),
+ }
+ insp.Preorder(nodeFilter, func(node ast.Node) {
+ // set of variable names declared insied the loop
+ declInLoop := make(map[string]bool)
+ var bl []ast.Stmt
+ // just take the list of instruction of the loop
+ switch ra := node.(type) {
+ case *ast.RangeStmt:
+ bl = ra.Body.List
+ case *ast.ForStmt:
+ bl = ra.Body.List
+ }
+ // set of results : mapping a variable name to a list of statements like `s +=`
+ // one loop may be bad for multiple string variables,
+ // each being concatenated in multiple statements
+ adds := make(map[string][]*ast.AssignStmt)
+ for bs := 0; bs < len(bl); bs++ {
+ switch st := bl[bs].(type) {
+ case *ast.IfStmt:
+ // explore breadth first, but go inside the if/else blocks
+ if st.Body != nil {
+ bl = append(bl, st.Body.List...)
+ }
+ el, ok := st.Else.(*ast.BlockStmt)
+ if ok && el != nil {
+ bl = append(bl, el.List...)
+ }
+ case *ast.DeclStmt:
+ // identifiers defined within loop do not count
+ de, ok := st.Decl.(*ast.GenDecl)
+ if !ok {
+ break
+ }
+ if len(de.Specs) != 1 {
+ break
+ }
+ // is it possible to have len(de.Specs) > 1 for ValueSpec ?
+ vs, ok := de.Specs[0].(*ast.ValueSpec)
+ if !ok {
+ break
+ }
+ for n := range vs.Names {
+ declInLoop[vs.Names[n].Name] = true
+ }
+ case *ast.AssignStmt:
+ for n := range st.Lhs {
+ id, ok := st.Lhs[n].(*ast.Ident)
+ if !ok {
+ break
+ }
+ switch st.Tok {
+ case token.DEFINE:
+ declInLoop[id.Name] = true
+ case token.ASSIGN, token.ADD_ASSIGN:
+ if n > 0 {
+ // do not search bugs for multi-assign
+ break
+ }
+ _, local := declInLoop[id.Name]
+ if local {
+ break
+ }
+ ti, ok := pass.TypesInfo.Types[id]
+ if !ok || ti.Type.String() != "string" {
+ break
+ }
+ if st.Tok == token.ASSIGN {
+ if isStringAdd(st, id.Name) == nil {
+ break
+ }
+ }
+ // found a bad string concat in the loop
+ adds[id.Name] = append(adds[id.Name], st)
+ }
+ }
+ }
+ }
+ if len(adds) > 0 {
+ d := n.reportConcatLoop(pass, neededPackages, node, adds)
+ if d != nil {
+ pass.Report(*d)
+ }
+ }
+ })
+}
+
+func (n *perfSprint) fixImports(pass *analysis.Pass, neededPackages map[string]map[string]struct{}, removedFmtUsages map[string]int) {
+ if !n.fiximports {
+ return
+ }
+ for _, pkg := range pass.Pkg.Imports() {
+ if pkg.Path() == "fmt" {
+ insp := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
+ nodeFilter := []ast.Node{
+ (*ast.SelectorExpr)(nil),
+ }
+ insp.Preorder(nodeFilter, func(node ast.Node) {
+ selec := node.(*ast.SelectorExpr)
+ selecok, ok := selec.X.(*ast.Ident)
+ if ok {
+ pkgname, ok := pass.TypesInfo.ObjectOf(selecok).(*types.PkgName)
+ if ok && pkgname.Name() == pkg.Name() {
+ fname := pass.Fset.File(pkgname.Pos()).Name()
+ removedFmtUsages[fname]--
+ }
+ }
+ })
+ } else if pkg.Path() == "errors" || pkg.Path() == "strconv" || pkg.Path() == "encoding/hex" || pkg.Path() == "strings" {
+ insp := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
+ nodeFilter := []ast.Node{
+ (*ast.ImportSpec)(nil),
+ }
+ insp.Preorder(nodeFilter, func(node ast.Node) {
+ gd := node.(*ast.ImportSpec)
+ if gd.Path.Value == strconv.Quote(pkg.Path()) {
+ fname := pass.Fset.File(gd.Pos()).Name()
+ if _, ok := neededPackages[fname]; ok {
+ delete(neededPackages[fname], pkg.Path())
+ }
+ }
+ })
+ }
+ }
+ insp := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
+ nodeFilter := []ast.Node{
+ (*ast.File)(nil),
+ }
+ insp.Preorder(nodeFilter, func(node ast.Node) {
+ gd := node.(*ast.File)
+ fname := pass.Fset.File(gd.Pos()).Name()
+ removed, hasFmt := removedFmtUsages[fname]
+ if (!hasFmt || removed < 0) && len(neededPackages[fname]) == 0 {
+ return
+ }
+ fix := ""
+ var ar analysis.Range
+ ar = gd.Decls[0]
+ start := gd.Decls[0].Pos()
+ end := gd.Decls[0].Pos()
+ if len(gd.Imports) == 0 {
+ fix += "import (\n"
+ } else {
+ id := gd.Decls[0].(*ast.GenDecl)
+ start = id.Specs[0].Pos()
+ end = id.Specs[0].Pos()
+ if removedFmtUsages[fname] >= 0 {
+ for sp := range id.Specs {
+ is := id.Specs[sp].(*ast.ImportSpec)
+ if is.Path.Value == strconv.Quote("fmt") {
+ ar = is
+ start = is.Pos()
+ end = is.End()
+ break
+ }
+ }
+ }
+ }
+ keys := make([]string, 0, len(neededPackages[fname]))
+ for k := range neededPackages[fname] {
+ keys = append(keys, k)
+ }
+ sort.Strings(keys)
+ for _, k := range keys {
+ already := false
+ knames := strings.Split(k, "/")
+ kname := knames[len(knames)-1]
+ for i := range gd.Imports { // quadratic
+ if (gd.Imports[i].Name != nil && gd.Imports[i].Name.Name == kname) || (gd.Imports[i].Name == nil && strings.HasSuffix(gd.Imports[i].Path.Value, "/"+kname+`"`)) {
+ already = true
+ }
+ }
+ if already {
+ fix = fix + "\t\"" + k + "\" //TODO FIXME\n"
+ } else {
+ fix = fix + "\t\"" + k + "\"\n"
+ }
+ }
+ if len(gd.Imports) == 0 {
+ fix += ")\n"
+ }
+ pass.Report(*newAnalysisDiagnostic(
+ checkerFixImports,
+ ar,
+ "Fix imports",
+ []analysis.SuggestedFix{
+ {
+ Message: "Fix imports",
+ TextEdits: []analysis.TextEdit{{
+ Pos: start,
+ End: end,
+ NewText: []byte(fix),
+ }},
+ },
+ }))
+ })
}
func (n *perfSprint) run(pass *analysis.Pass) (interface{}, error) {
@@ -104,6 +475,11 @@ func (n *perfSprint) run(pass *analysis.Pass) (interface{}, error) {
n.strFormat.strconcat = false
}
+ neededPackages := make(map[string]map[string]struct{})
+ if n.concatLoop.enabled {
+ n.runConcatLoop(pass, neededPackages)
+ }
+ removedFmtUsages := make(map[string]int)
var fmtSprintObj, fmtSprintfObj, fmtErrorfObj types.Object
for _, pkg := range pass.Pkg.Imports() {
if pkg.Path() == "fmt" {
@@ -113,10 +489,11 @@ func (n *perfSprint) run(pass *analysis.Pass) (interface{}, error) {
}
}
if fmtSprintfObj == nil && fmtSprintObj == nil && fmtErrorfObj == nil {
+ if len(neededPackages) > 0 {
+ n.fixImports(pass, neededPackages, removedFmtUsages)
+ }
return nil, nil
}
- removedFmtUsages := make(map[string]int)
- neededPackages := make(map[string]map[string]struct{})
insp := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
nodeFilter := []ast.Node{
@@ -198,7 +575,7 @@ func (n *perfSprint) run(pass *analysis.Pass) (interface{}, error) {
if fn == "fmt.Errorf" && n.errFormat.enabled {
neededPackages[fname]["errors"] = struct{}{}
d = newAnalysisDiagnostic(
- "", // TODO: precise checker
+ checkerErrorFormat,
call,
fn+" can be replaced with errors.New",
[]analysis.SuggestedFix{
@@ -214,7 +591,7 @@ func (n *perfSprint) run(pass *analysis.Pass) (interface{}, error) {
)
} else if fn != "fmt.Errorf" && n.strFormat.enabled {
d = newAnalysisDiagnostic(
- "", // TODO: precise checker
+ checkerStringFormat,
call,
fn+" can be replaced with just using the string",
[]analysis.SuggestedFix{
@@ -236,7 +613,7 @@ func (n *perfSprint) run(pass *analysis.Pass) (interface{}, error) {
fname := pass.Fset.File(call.Pos()).Name()
removedFmtUsages[fname]++
d = newAnalysisDiagnostic(
- "", // TODO: precise checker
+ checkerErrorFormat,
call,
fn+" can be replaced with "+errMethodCall,
[]analysis.SuggestedFix{
@@ -259,7 +636,7 @@ func (n *perfSprint) run(pass *analysis.Pass) (interface{}, error) {
}
neededPackages[fname]["strconv"] = struct{}{}
d = newAnalysisDiagnostic(
- "", // TODO: precise checker
+ checkerBoolFormat,
call,
fn+" can be replaced with faster strconv.FormatBool",
[]analysis.SuggestedFix{
@@ -287,7 +664,7 @@ func (n *perfSprint) run(pass *analysis.Pass) (interface{}, error) {
}
neededPackages[fname]["encoding/hex"] = struct{}{}
d = newAnalysisDiagnostic(
- "", // TODO: precise checker
+ checkerHexFormat,
call,
fn+" can be replaced with faster hex.EncodeToString",
[]analysis.SuggestedFix{
@@ -316,7 +693,7 @@ func (n *perfSprint) run(pass *analysis.Pass) (interface{}, error) {
}
neededPackages[fname]["encoding/hex"] = struct{}{}
d = newAnalysisDiagnostic(
- "", // TODO: precise checker
+ checkerHexFormat,
call,
fn+" can be replaced with faster hex.EncodeToString",
[]analysis.SuggestedFix{
@@ -339,7 +716,7 @@ func (n *perfSprint) run(pass *analysis.Pass) (interface{}, error) {
}
neededPackages[fname]["strconv"] = struct{}{}
d = newAnalysisDiagnostic(
- "", // TODO: precise checker
+ checkerIntegerFormat,
call,
fn+" can be replaced with faster strconv.Itoa",
[]analysis.SuggestedFix{
@@ -368,7 +745,7 @@ func (n *perfSprint) run(pass *analysis.Pass) (interface{}, error) {
}
neededPackages[fname]["strconv"] = struct{}{}
d = newAnalysisDiagnostic(
- "", // TODO: precise checker
+ checkerIntegerFormat,
call,
fn+" can be replaced with faster strconv.Itoa",
[]analysis.SuggestedFix{
@@ -390,7 +767,7 @@ func (n *perfSprint) run(pass *analysis.Pass) (interface{}, error) {
}
neededPackages[fname]["strconv"] = struct{}{}
d = newAnalysisDiagnostic(
- "", // TODO: precise checker
+ checkerIntegerFormat,
call,
fn+" can be replaced with faster strconv.FormatInt",
[]analysis.SuggestedFix{
@@ -424,7 +801,7 @@ func (n *perfSprint) run(pass *analysis.Pass) (interface{}, error) {
}
neededPackages[fname]["strconv"] = struct{}{}
d = newAnalysisDiagnostic(
- "", // TODO: precise checker
+ checkerIntegerFormat,
call,
fn+" can be replaced with faster strconv.FormatUint",
[]analysis.SuggestedFix{
@@ -457,7 +834,7 @@ func (n *perfSprint) run(pass *analysis.Pass) (interface{}, error) {
}
neededPackages[fname]["strconv"] = struct{}{}
d = newAnalysisDiagnostic(
- "", // TODO: precise checker
+ checkerIntegerFormat,
call,
fn+" can be replaced with faster strconv.FormatUint",
[]analysis.SuggestedFix{
@@ -481,18 +858,18 @@ func (n *perfSprint) run(pass *analysis.Pass) (interface{}, error) {
case isBasicType(valueType, types.String) && fn == "fmt.Sprintf" && isConcatable(verb) && n.strFormat.enabled:
var fix string
if strings.HasSuffix(verb, "%s") {
- fix = strconv.Quote(verb[:len(verb)-2]) + "+" + formatNode(pass.Fset, value)
+ fix = strings.ReplaceAll(strconv.Quote(verb[:len(verb)-2]), "%%", "%") + "+" + formatNode(pass.Fset, value)
} else if strings.HasSuffix(verb, "%[1]s") {
- fix = strconv.Quote(verb[:len(verb)-5]) + "+" + formatNode(pass.Fset, value)
+ fix = strings.ReplaceAll(strconv.Quote(verb[:len(verb)-5]), "%%", "%") + "+" + formatNode(pass.Fset, value)
} else if strings.HasPrefix(verb, "%s") {
- fix = formatNode(pass.Fset, value) + "+" + strconv.Quote(verb[2:])
+ fix = formatNode(pass.Fset, value) + "+" + strings.ReplaceAll(strconv.Quote(verb[2:]), "%%", "%")
} else {
- fix = formatNode(pass.Fset, value) + "+" + strconv.Quote(verb[5:])
+ fix = formatNode(pass.Fset, value) + "+" + strings.ReplaceAll(strconv.Quote(verb[5:]), "%%", "%")
}
fname := pass.Fset.File(call.Pos()).Name()
removedFmtUsages[fname]++
d = newAnalysisDiagnostic(
- "", // TODO: precise checker
+ checkerStringFormat,
call,
fn+" can be replaced with string concatenation",
[]analysis.SuggestedFix{
@@ -513,79 +890,8 @@ func (n *perfSprint) run(pass *analysis.Pass) (interface{}, error) {
}
})
- if len(removedFmtUsages) > 0 && n.fiximports {
- for _, pkg := range pass.Pkg.Imports() {
- if pkg.Path() == "fmt" {
- insp = pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
- nodeFilter = []ast.Node{
- (*ast.SelectorExpr)(nil),
- }
- insp.Preorder(nodeFilter, func(node ast.Node) {
- selec := node.(*ast.SelectorExpr)
- selecok, ok := selec.X.(*ast.Ident)
- if ok {
- pkgname, ok := pass.TypesInfo.ObjectOf(selecok).(*types.PkgName)
- if ok && pkgname.Name() == pkg.Name() {
- fname := pass.Fset.File(pkgname.Pos()).Name()
- removedFmtUsages[fname]--
- }
- }
- })
- } else if pkg.Path() == "errors" || pkg.Path() == "strconv" || pkg.Path() == "encoding/hex" {
- insp = pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
- nodeFilter = []ast.Node{
- (*ast.ImportSpec)(nil),
- }
- insp.Preorder(nodeFilter, func(node ast.Node) {
- gd := node.(*ast.ImportSpec)
- if gd.Path.Value == strconv.Quote(pkg.Path()) {
- fname := pass.Fset.File(gd.Pos()).Name()
- if _, ok := neededPackages[fname]; ok {
- delete(neededPackages[fname], pkg.Path())
- }
- }
- })
- }
- }
- insp = pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
- nodeFilter = []ast.Node{
- (*ast.ImportSpec)(nil),
- }
- insp.Preorder(nodeFilter, func(node ast.Node) {
- gd := node.(*ast.ImportSpec)
- if gd.Path.Value == `"fmt"` {
- fix := ""
- fname := pass.Fset.File(gd.Pos()).Name()
- if removedFmtUsages[fname] < 0 {
- fix += `"fmt"`
- if len(neededPackages[fname]) == 0 {
- return
- }
- }
- keys := make([]string, 0, len(neededPackages[fname]))
- for k := range neededPackages[fname] {
- keys = append(keys, k)
- }
- sort.Strings(keys)
- for _, k := range keys {
- fix = fix + "\n\t\"" + k + `"`
- }
- pass.Report(*newAnalysisDiagnostic(
- "", // TODO: precise checker
- gd,
- "Fix imports",
- []analysis.SuggestedFix{
- {
- Message: "Fix imports",
- TextEdits: []analysis.TextEdit{{
- Pos: gd.Pos(),
- End: gd.End(),
- NewText: []byte(fix),
- }},
- },
- }))
- }
- })
+ if len(removedFmtUsages) > 0 || len(neededPackages) > 0 {
+ n.fixImports(pass, neededPackages, removedFmtUsages)
}
return nil, nil
diff --git a/vendor/github.com/ccojocar/zxcvbn-go/.golangci.yml b/vendor/github.com/ccojocar/zxcvbn-go/.golangci.yml
index b54f70092e..765d3b5ea6 100644
--- a/vendor/github.com/ccojocar/zxcvbn-go/.golangci.yml
+++ b/vendor/github.com/ccojocar/zxcvbn-go/.golangci.yml
@@ -1,39 +1,46 @@
+version: "2"
linters:
enable:
- asciicheck
- bodyclose
- dogsled
- durationcheck
- - errcheck
- errorlint
- - exportloopref
- - gci
- ginkgolinter
- - gofmt
- - gofumpt
- - goimports
- - gosimple
- - govet
- importas
- - ineffassign
- - megacheck
- misspell
- nakedret
- nolintlint
- revive
- - staticcheck
- - typecheck
- unconvert
- unparam
- - unused
- wastedassign
-
-linters-settings:
- gci:
- sections:
- - standard
- - default
- - prefix(github.com/ccojocar)
-
-run:
- timeout: 5m
+ exclusions:
+ generated: lax
+ presets:
+ - comments
+ - common-false-positives
+ - legacy
+ - std-error-handling
+ paths:
+ - third_party$
+ - builtin$
+ - examples$
+formatters:
+ enable:
+ - gci
+ - gofmt
+ - gofumpt
+ - goimports
+ settings:
+ gci:
+ sections:
+ - standard
+ - default
+ - prefix(github.com/ccojocar)
+ exclusions:
+ generated: lax
+ paths:
+ - third_party$
+ - builtin$
+ - examples$
diff --git a/vendor/github.com/ccojocar/zxcvbn-go/.goreleaser.yml b/vendor/github.com/ccojocar/zxcvbn-go/.goreleaser.yml
index 2386aeee52..2b786c5d84 100644
--- a/vendor/github.com/ccojocar/zxcvbn-go/.goreleaser.yml
+++ b/vendor/github.com/ccojocar/zxcvbn-go/.goreleaser.yml
@@ -1,4 +1,4 @@
----
+version: 2
project_name: zxcvbn-go
release:
diff --git a/vendor/github.com/ccojocar/zxcvbn-go/matching/dateMatchers.go b/vendor/github.com/ccojocar/zxcvbn-go/matching/dateMatchers.go
index fd7f383320..c3829c925d 100644
--- a/vendor/github.com/ccojocar/zxcvbn-go/matching/dateMatchers.go
+++ b/vendor/github.com/ccojocar/zxcvbn-go/matching/dateMatchers.go
@@ -39,7 +39,8 @@ func checkDate(day, month, year int64) (bool, int64, int64, int64) {
return false, 0, 0, 0
}
- if !((1900 <= year && year <= 2019) || (0 <= year && year <= 99)) {
+ //nolint:staticcheck // Ignore De Morgan's law optimization
+ if !((1900 <= year && year <= 2025) || (0 <= year && year <= 99)) {
return false, 0, 0, 0
}
diff --git a/vendor/github.com/ccojocar/zxcvbn-go/matching/leet.go b/vendor/github.com/ccojocar/zxcvbn-go/matching/leet.go
index 1f303aa6ea..f7fd30420f 100644
--- a/vendor/github.com/ccojocar/zxcvbn-go/matching/leet.go
+++ b/vendor/github.com/ccojocar/zxcvbn-go/matching/leet.go
@@ -191,7 +191,7 @@ func createSubstitutionsMapsFromTable(table map[string][]string) []map[string]st
func createWordForSubstitutionMap(word string, substitutionMap map[string]string) string {
result := word
for key, value := range substitutionMap {
- result = strings.Replace(result, value, key, -1)
+ result = strings.ReplaceAll(result, value, key)
}
return result
@@ -224,7 +224,7 @@ func copyMapRemovingSameValueFromOtherKeys(table map[string][]string, keyToFix s
for key, values := range table {
for _, value := range values {
- if !(value == valueToFix && key != keyToFix) {
+ if value != valueToFix || key == keyToFix {
result[key] = append(result[key], value)
}
}
diff --git a/vendor/github.com/ccojocar/zxcvbn-go/scoring/scoring.go b/vendor/github.com/ccojocar/zxcvbn-go/scoring/scoring.go
index f25606a8d6..7154025a9d 100644
--- a/vendor/github.com/ccojocar/zxcvbn-go/scoring/scoring.go
+++ b/vendor/github.com/ccojocar/zxcvbn-go/scoring/scoring.go
@@ -166,7 +166,7 @@ func displayTime(seconds float64) string {
}
func crackTimeToScore(seconds float64) int {
- if seconds < math.Pow(10, 2) {
+ if seconds < 100 {
return 0
} else if seconds < math.Pow(10, 4) {
return 1
diff --git a/vendor/github.com/charithe/durationcheck/README.md b/vendor/github.com/charithe/durationcheck/README.md
index 6f4279bd38..4aa9558f2b 100644
--- a/vendor/github.com/charithe/durationcheck/README.md
+++ b/vendor/github.com/charithe/durationcheck/README.md
@@ -33,7 +33,7 @@ See the [test cases](testdata/src/a/a.go) for more examples of the types of erro
Installation
-------------
-Requires Go 1.11 or above.
+Requires Go 1.14 or above.
```
go get -u github.com/charithe/durationcheck/cmd/durationcheck
diff --git a/vendor/github.com/charithe/durationcheck/durationcheck.go b/vendor/github.com/charithe/durationcheck/durationcheck.go
index c47b3a7613..5fcb98a890 100644
--- a/vendor/github.com/charithe/durationcheck/durationcheck.go
+++ b/vendor/github.com/charithe/durationcheck/durationcheck.go
@@ -32,6 +32,7 @@ func run(pass *analysis.Pass) (interface{}, error) {
nodeTypes := []ast.Node{
(*ast.BinaryExpr)(nil),
+ (*ast.AssignStmt)(nil),
}
inspect.Preorder(nodeTypes, check(pass))
@@ -52,25 +53,45 @@ func hasImport(pkg *types.Package, importPath string) bool {
// check contains the logic for checking that time.Duration is used correctly in the code being analysed
func check(pass *analysis.Pass) func(ast.Node) {
return func(node ast.Node) {
- expr := node.(*ast.BinaryExpr)
- // we are only interested in multiplication
- if expr.Op != token.MUL {
- return
+ switch expr := node.(type) {
+ case *ast.BinaryExpr:
+ checkBinaryExpr(pass, expr)
+ case *ast.AssignStmt:
+ if expr.Tok != token.MUL_ASSIGN {
+ return
+ }
+ // '*=' assignment requires single-valued expressions
+ if len(expr.Lhs) != 1 || len(expr.Rhs) != 1 {
+ return
+ }
+ checkBinaryExpr(pass, &ast.BinaryExpr{
+ X: expr.Lhs[0],
+ OpPos: expr.TokPos,
+ Op: expr.Tok,
+ Y: expr.Rhs[0],
+ })
}
+ }
+}
- // get the types of the two operands
- x, xOK := pass.TypesInfo.Types[expr.X]
- y, yOK := pass.TypesInfo.Types[expr.Y]
+func checkBinaryExpr(pass *analysis.Pass, expr *ast.BinaryExpr) {
+ // we are only interested in multiplication
+ if expr.Op != token.MUL && expr.Op != token.MUL_ASSIGN {
+ return
+ }
- if !xOK || !yOK {
- return
- }
+ // get the types of the two operands
+ x, xOK := pass.TypesInfo.Types[expr.X]
+ y, yOK := pass.TypesInfo.Types[expr.Y]
- if isDuration(x.Type) && isDuration(y.Type) {
- // check that both sides are acceptable expressions
- if isUnacceptableExpr(pass, expr.X) && isUnacceptableExpr(pass, expr.Y) {
- pass.Reportf(expr.Pos(), "Multiplication of durations: `%s`", formatNode(expr))
- }
+ if !xOK || !yOK {
+ return
+ }
+
+ if isDuration(x.Type) && isDuration(y.Type) {
+ // check that both sides are acceptable expressions
+ if isUnacceptableExpr(pass, expr.X) && isUnacceptableExpr(pass, expr.Y) {
+ pass.Reportf(expr.Pos(), "Multiplication of durations: `%s`", formatNode(expr))
}
}
}
diff --git a/vendor/github.com/charmbracelet/colorprofile/.golangci.yml b/vendor/github.com/charmbracelet/colorprofile/.golangci.yml
new file mode 100644
index 0000000000..c90f031611
--- /dev/null
+++ b/vendor/github.com/charmbracelet/colorprofile/.golangci.yml
@@ -0,0 +1,47 @@
+version: "2"
+run:
+ tests: false
+linters:
+ enable:
+ - bodyclose
+ - exhaustive
+ - goconst
+ - godot
+ - gomoddirectives
+ - goprintffuncname
+ - gosec
+ - misspell
+ - nakedret
+ - nestif
+ - nilerr
+ - noctx
+ - nolintlint
+ - prealloc
+ - revive
+ - rowserrcheck
+ - sqlclosecheck
+ - tparallel
+ - unconvert
+ - unparam
+ - whitespace
+ - wrapcheck
+ exclusions:
+ rules:
+ - text: '(slog|log)\.\w+'
+ linters:
+ - noctx
+ generated: lax
+ presets:
+ - common-false-positives
+ settings:
+ exhaustive:
+ default-signifies-exhaustive: true
+issues:
+ max-issues-per-linter: 0
+ max-same-issues: 0
+formatters:
+ enable:
+ - gofumpt
+ - goimports
+ exclusions:
+ generated: lax
diff --git a/vendor/github.com/charmbracelet/colorprofile/.goreleaser.yml b/vendor/github.com/charmbracelet/colorprofile/.goreleaser.yml
new file mode 100644
index 0000000000..40d9f298db
--- /dev/null
+++ b/vendor/github.com/charmbracelet/colorprofile/.goreleaser.yml
@@ -0,0 +1,6 @@
+includes:
+ - from_url:
+ url: charmbracelet/meta/main/goreleaser-lib.yaml
+
+# yaml-language-server: $schema=https://goreleaser.com/static/schema-pro.json
+
diff --git a/vendor/github.com/charmbracelet/colorprofile/LICENSE b/vendor/github.com/charmbracelet/colorprofile/LICENSE
new file mode 100644
index 0000000000..b7974b0765
--- /dev/null
+++ b/vendor/github.com/charmbracelet/colorprofile/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2020-2024 Charmbracelet, Inc
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/vendor/github.com/charmbracelet/colorprofile/README.md b/vendor/github.com/charmbracelet/colorprofile/README.md
new file mode 100644
index 0000000000..2afffce076
--- /dev/null
+++ b/vendor/github.com/charmbracelet/colorprofile/README.md
@@ -0,0 +1,109 @@
+# Colorprofile
+
+
+
+
+
+
+
+A simple, powerful—and at times magical—package for detecting terminal color
+profiles and performing color (and CSI) degradation.
+
+## Detecting the terminal’s color profile
+
+Detecting the terminal’s color profile is easy.
+
+```go
+import "github.com/charmbracelet/colorprofile"
+
+// Detect the color profile. If you’re planning on writing to stderr you'd want
+// to use os.Stderr instead.
+p := colorprofile.Detect(os.Stdout, os.Environ())
+
+// Comment on the profile.
+fmt.Printf("You know, your colors are quite %s.", func() string {
+ switch p {
+ case colorprofile.TrueColor:
+ return "fancy"
+ case colorprofile.ANSI256:
+ return "1990s fancy"
+ case colorprofile.ANSI:
+ return "normcore"
+ case colorprofile.Ascii:
+ return "ancient"
+ case colorprofile.NoTTY:
+ return "naughty!"
+ }
+ return "...IDK" // this should never happen
+}())
+```
+
+## Downsampling colors
+
+When necessary, colors can be downsampled to a given profile, or manually
+downsampled to a specific profile.
+
+```go
+p := colorprofile.Detect(os.Stdout, os.Environ())
+c := color.RGBA{0x6b, 0x50, 0xff, 0xff} // #6b50ff
+
+// Downsample to the detected profile, when necessary.
+convertedColor := p.Convert(c)
+
+// Or manually convert to a given profile.
+ansi256Color := colorprofile.ANSI256.Convert(c)
+ansiColor := colorprofile.ANSI.Convert(c)
+noColor := colorprofile.Ascii.Convert(c)
+noANSI := colorprofile.NoTTY.Convert(c)
+```
+
+## Automatic downsampling with a Writer
+
+You can also magically downsample colors in ANSI output, when necessary. If
+output is not a TTY ANSI will be dropped entirely.
+
+```go
+myFancyANSI := "\x1b[38;2;107;80;255mCute \x1b[1;3mpuppy!!\x1b[m"
+
+// Automatically downsample for the terminal at stdout.
+w := colorprofile.NewWriter(os.Stdout, os.Environ())
+fmt.Fprintf(w, myFancyANSI)
+
+// Downsample to 4-bit ANSI.
+w.Profile = colorprofile.ANSI
+fmt.Fprintf(w, myFancyANSI)
+
+// Ascii-fy, no colors.
+w.Profile = colorprofile.Ascii
+fmt.Fprintf(w, myFancyANSI)
+
+// Strip ANSI altogether.
+w.Profile = colorprofile.NoTTY
+fmt.Fprintf(w, myFancyANSI) // not as fancy
+```
+
+## Contributing
+
+See [contributing][contribute].
+
+[contribute]: https://github.com/charmbracelet/colorprofile/contribute
+
+## Feedback
+
+We’d love to hear your thoughts on this project. Feel free to drop us a note!
+
+- [Twitter](https://twitter.com/charmcli)
+- [The Fediverse](https://mastodon.social/@charmcli)
+- [Discord](https://charm.sh/chat)
+
+## License
+
+[MIT](https://github.com/charmbracelet/bubbletea/raw/master/LICENSE)
+
+---
+
+Part of [Charm](https://charm.sh).
+
+
+
+Charm热爱开源 • Charm loves open source • نحنُ نحب المصادر المفتوحة
diff --git a/vendor/github.com/charmbracelet/colorprofile/doc.go b/vendor/github.com/charmbracelet/colorprofile/doc.go
new file mode 100644
index 0000000000..bd522e903b
--- /dev/null
+++ b/vendor/github.com/charmbracelet/colorprofile/doc.go
@@ -0,0 +1,4 @@
+// Package colorprofile provides a way to downsample ANSI escape sequence
+// colors and styles automatically based on output, environment variables, and
+// Terminfo databases.
+package colorprofile
diff --git a/vendor/github.com/charmbracelet/colorprofile/env.go b/vendor/github.com/charmbracelet/colorprofile/env.go
new file mode 100644
index 0000000000..3368cf86ab
--- /dev/null
+++ b/vendor/github.com/charmbracelet/colorprofile/env.go
@@ -0,0 +1,294 @@
+package colorprofile
+
+import (
+ "bytes"
+ "context"
+ "io"
+ "os/exec"
+ "runtime"
+ "strconv"
+ "strings"
+
+ "github.com/charmbracelet/x/term"
+ "github.com/xo/terminfo"
+)
+
+const dumbTerm = "dumb"
+
+// Detect returns the color profile based on the terminal output, and
+// environment variables. This respects NO_COLOR, CLICOLOR, and CLICOLOR_FORCE
+// environment variables.
+//
+// The rules as follows:
+// - TERM=dumb is always treated as NoTTY unless CLICOLOR_FORCE=1 is set.
+// - If COLORTERM=truecolor, and the profile is not NoTTY, it gest upgraded to TrueColor.
+// - Using any 256 color terminal (e.g. TERM=xterm-256color) will set the profile to ANSI256.
+// - Using any color terminal (e.g. TERM=xterm-color) will set the profile to ANSI.
+// - Using CLICOLOR=1 without TERM defined should be treated as ANSI if the
+// output is a terminal.
+// - NO_COLOR takes precedence over CLICOLOR/CLICOLOR_FORCE, and will disable
+// colors but not text decoration, i.e. bold, italic, faint, etc.
+//
+// See https://no-color.org/ and https://bixense.com/clicolors/ for more information.
+func Detect(output io.Writer, env []string) Profile {
+ out, ok := output.(term.File)
+ environ := newEnviron(env)
+ isatty := isTTYForced(environ) || (ok && term.IsTerminal(out.Fd()))
+ term, ok := environ.lookup("TERM")
+ isDumb := !ok || term == dumbTerm
+ envp := colorProfile(isatty, environ)
+ if envp == TrueColor || envNoColor(environ) {
+ // We already know we have TrueColor, or NO_COLOR is set.
+ return envp
+ }
+
+ if isatty && !isDumb {
+ tip := Terminfo(term)
+ tmuxp := tmux(environ)
+
+ // Color profile is the maximum of env, terminfo, and tmux.
+ return max(envp, max(tip, tmuxp))
+ }
+
+ return envp
+}
+
+// Env returns the color profile based on the terminal environment variables.
+// This respects NO_COLOR, CLICOLOR, and CLICOLOR_FORCE environment variables.
+//
+// The rules as follows:
+// - TERM=dumb is always treated as NoTTY unless CLICOLOR_FORCE=1 is set.
+// - If COLORTERM=truecolor, and the profile is not NoTTY, it gest upgraded to TrueColor.
+// - Using any 256 color terminal (e.g. TERM=xterm-256color) will set the profile to ANSI256.
+// - Using any color terminal (e.g. TERM=xterm-color) will set the profile to ANSI.
+// - Using CLICOLOR=1 without TERM defined should be treated as ANSI if the
+// output is a terminal.
+// - NO_COLOR takes precedence over CLICOLOR/CLICOLOR_FORCE, and will disable
+// colors but not text decoration, i.e. bold, italic, faint, etc.
+//
+// See https://no-color.org/ and https://bixense.com/clicolors/ for more information.
+func Env(env []string) (p Profile) {
+ return colorProfile(true, newEnviron(env))
+}
+
+func colorProfile(isatty bool, env environ) (p Profile) {
+ term, ok := env.lookup("TERM")
+ isDumb := (!ok && runtime.GOOS != "windows") || term == dumbTerm
+ envp := envColorProfile(env)
+ if !isatty || isDumb {
+ // Check if the output is a terminal.
+ // Treat dumb terminals as NoTTY
+ p = NoTTY
+ } else {
+ p = envp
+ }
+
+ if envNoColor(env) && isatty {
+ if p > ASCII {
+ p = ASCII
+ }
+ return //nolint:nakedret
+ }
+
+ if cliColorForced(env) {
+ if p < ANSI {
+ p = ANSI
+ }
+ if envp > p {
+ p = envp
+ }
+
+ return //nolint:nakedret
+ }
+
+ if cliColor(env) {
+ if isatty && !isDumb && p < ANSI {
+ p = ANSI
+ }
+ }
+
+ return p
+}
+
+// envNoColor returns true if the environment variables explicitly disable color output
+// by setting NO_COLOR (https://no-color.org/).
+func envNoColor(env environ) bool {
+ noColor, _ := strconv.ParseBool(env.get("NO_COLOR"))
+ return noColor
+}
+
+func cliColor(env environ) bool {
+ cliColor, _ := strconv.ParseBool(env.get("CLICOLOR"))
+ return cliColor
+}
+
+func cliColorForced(env environ) bool {
+ cliColorForce, _ := strconv.ParseBool(env.get("CLICOLOR_FORCE"))
+ return cliColorForce
+}
+
+func isTTYForced(env environ) bool {
+ skip, _ := strconv.ParseBool(env.get("TTY_FORCE"))
+ return skip
+}
+
+func colorTerm(env environ) bool {
+ colorTerm := strings.ToLower(env.get("COLORTERM"))
+ return colorTerm == "truecolor" || colorTerm == "24bit" ||
+ colorTerm == "yes" || colorTerm == "true"
+}
+
+// envColorProfile returns infers the color profile from the environment.
+func envColorProfile(env environ) (p Profile) {
+ term, ok := env.lookup("TERM")
+ if !ok || len(term) == 0 || term == dumbTerm {
+ p = NoTTY
+ if runtime.GOOS == "windows" {
+ // Use Windows API to detect color profile. Windows Terminal and
+ // cmd.exe don't define $TERM.
+ if wcp, ok := windowsColorProfile(env); ok {
+ p = wcp
+ }
+ }
+ } else {
+ p = ANSI
+ }
+
+ switch {
+ case strings.Contains(term, "alacritty"),
+ strings.Contains(term, "contour"),
+ strings.Contains(term, "foot"),
+ strings.Contains(term, "ghostty"),
+ strings.Contains(term, "kitty"),
+ strings.Contains(term, "rio"),
+ strings.Contains(term, "st"),
+ strings.Contains(term, "wezterm"):
+ return TrueColor
+ case strings.HasPrefix(term, "tmux"), strings.HasPrefix(term, "screen"):
+ if p < ANSI256 {
+ p = ANSI256
+ }
+ case strings.HasPrefix(term, "xterm"):
+ if p < ANSI {
+ p = ANSI
+ }
+ }
+
+ if len(env["WT_SESSION"]) > 0 {
+ // Windows Terminal supports TrueColor
+ return TrueColor
+ }
+
+ if isCloudShell, _ := strconv.ParseBool(env.get("GOOGLE_CLOUD_SHELL")); isCloudShell {
+ return TrueColor
+ }
+
+ // GNU Screen doesn't support TrueColor
+ // Tmux doesn't support $COLORTERM
+ if colorTerm(env) && !strings.HasPrefix(term, "screen") && !strings.HasPrefix(term, "tmux") {
+ return TrueColor
+ }
+
+ if strings.HasSuffix(term, "256color") && p < ANSI256 {
+ p = ANSI256
+ }
+
+ // Direct color terminals support true colors.
+ if strings.HasSuffix(term, "direct") {
+ return TrueColor
+ }
+
+ return //nolint:nakedret
+}
+
+// Terminfo returns the color profile based on the terminal's terminfo
+// database. This relies on the Tc and RGB capabilities to determine if the
+// terminal supports TrueColor.
+// If term is empty or "dumb", it returns NoTTY.
+func Terminfo(term string) (p Profile) {
+ if len(term) == 0 || term == "dumb" {
+ return NoTTY
+ }
+
+ p = ANSI
+ ti, err := terminfo.Load(term)
+ if err != nil {
+ return
+ }
+
+ extbools := ti.ExtBoolCapsShort()
+ if _, ok := extbools["Tc"]; ok {
+ return TrueColor
+ }
+
+ if _, ok := extbools["RGB"]; ok {
+ return TrueColor
+ }
+
+ return
+}
+
+// Tmux returns the color profile based on `tmux info` output. Tmux supports
+// overriding the terminal's color capabilities, so this function will return
+// the color profile based on the tmux configuration.
+func Tmux(env []string) Profile {
+ return tmux(newEnviron(env))
+}
+
+// tmux returns the color profile based on the tmux environment variables.
+func tmux(env environ) (p Profile) {
+ if tmux, ok := env.lookup("TMUX"); !ok || len(tmux) == 0 {
+ // Not in tmux
+ return NoTTY
+ }
+
+ // Check if tmux has either Tc or RGB capabilities. Otherwise, return
+ // ANSI256.
+ p = ANSI256
+ cmd := exec.CommandContext(context.Background(), "tmux", "info")
+ out, err := cmd.Output()
+ if err != nil {
+ return
+ }
+
+ for line := range bytes.SplitSeq(out, []byte("\n")) {
+ if (bytes.Contains(line, []byte("Tc")) || bytes.Contains(line, []byte("RGB"))) &&
+ bytes.Contains(line, []byte("true")) {
+ return TrueColor
+ }
+ }
+
+ return
+}
+
+// environ is a map of environment variables.
+type environ map[string]string
+
+// newEnviron returns a new environment map from a slice of environment
+// variables.
+func newEnviron(environ []string) environ {
+ m := make(map[string]string, len(environ))
+ for _, e := range environ {
+ parts := strings.SplitN(e, "=", 2)
+ var value string
+ if len(parts) == 2 {
+ value = parts[1]
+ }
+ m[parts[0]] = value
+ }
+ return m
+}
+
+// lookup returns the value of an environment variable and a boolean indicating
+// if it exists.
+func (e environ) lookup(key string) (string, bool) {
+ v, ok := e[key]
+ return v, ok
+}
+
+// get returns the value of an environment variable and empty string if it
+// doesn't exist.
+func (e environ) get(key string) string {
+ v, _ := e.lookup(key)
+ return v
+}
diff --git a/vendor/github.com/charmbracelet/colorprofile/env_other.go b/vendor/github.com/charmbracelet/colorprofile/env_other.go
new file mode 100644
index 0000000000..080994bc1f
--- /dev/null
+++ b/vendor/github.com/charmbracelet/colorprofile/env_other.go
@@ -0,0 +1,8 @@
+//go:build !windows
+// +build !windows
+
+package colorprofile
+
+func windowsColorProfile(map[string]string) (Profile, bool) {
+ return 0, false
+}
diff --git a/vendor/github.com/charmbracelet/colorprofile/env_windows.go b/vendor/github.com/charmbracelet/colorprofile/env_windows.go
new file mode 100644
index 0000000000..c617304ea4
--- /dev/null
+++ b/vendor/github.com/charmbracelet/colorprofile/env_windows.go
@@ -0,0 +1,40 @@
+//go:build windows
+// +build windows
+
+package colorprofile
+
+import (
+ "strconv"
+
+ "golang.org/x/sys/windows"
+)
+
+func windowsColorProfile(env map[string]string) (Profile, bool) {
+ if env["ConEmuANSI"] == "ON" {
+ return TrueColor, true
+ }
+
+ major, _, build := windows.RtlGetNtVersionNumbers()
+ if build < 10586 || major < 10 {
+ // No ANSI support before WindowsNT 10 build 10586
+ if len(env["ANSICON"]) > 0 {
+ ansiconVer := env["ANSICON_VER"]
+ cv, err := strconv.Atoi(ansiconVer)
+ if err != nil || cv < 181 {
+ // No 8 bit color support before ANSICON 1.81
+ return ANSI, true
+ }
+
+ return ANSI256, true
+ }
+
+ return NoTTY, true
+ }
+
+ if build < 14931 {
+ // No true color support before build 14931
+ return ANSI256, true
+ }
+
+ return TrueColor, true
+}
diff --git a/vendor/github.com/charmbracelet/colorprofile/profile.go b/vendor/github.com/charmbracelet/colorprofile/profile.go
new file mode 100644
index 0000000000..4ff7f68978
--- /dev/null
+++ b/vendor/github.com/charmbracelet/colorprofile/profile.go
@@ -0,0 +1,108 @@
+package colorprofile
+
+import (
+ "image/color"
+ "sync"
+
+ "github.com/charmbracelet/x/ansi"
+)
+
+// Profile is a color profile: NoTTY, Ascii, ANSI, ANSI256, or TrueColor.
+type Profile byte
+
+const (
+ // Unknown is a profile that represents the absence of a profile.
+ Unknown Profile = iota
+ // NoTTY is a profile with no terminal support.
+ NoTTY
+ // ASCII is a profile with no color support.
+ ASCII
+ // ANSI is a profile with 16 colors (4-bit).
+ ANSI
+ // ANSI256 is a profile with 256 colors (8-bit).
+ ANSI256
+ // TrueColor is a profile with 16 million colors (24-bit).
+ TrueColor
+)
+
+// Ascii is an alias for the [ASCII] profile for backwards compatibility.
+const Ascii = ASCII //nolint:revive
+
+// String returns the string representation of a Profile.
+func (p Profile) String() string {
+ switch p {
+ case TrueColor:
+ return "TrueColor"
+ case ANSI256:
+ return "ANSI256"
+ case ANSI:
+ return "ANSI"
+ case ASCII:
+ return "Ascii"
+ case NoTTY:
+ return "NoTTY"
+ default:
+ return "Unknown"
+ }
+}
+
+var (
+ cache = map[Profile]map[color.Color]color.Color{
+ ANSI256: {},
+ ANSI: {},
+ }
+ mu sync.RWMutex
+)
+
+// Convert transforms a given Color to a Color supported within the Profile.
+func (p Profile) Convert(c color.Color) (cc color.Color) {
+ if p <= ASCII {
+ return nil
+ }
+ if p == TrueColor {
+ // TrueColor is a passthrough.
+ return c
+ }
+
+ // Do we have a cached color for this profile and color?
+ mu.RLock()
+ if c != nil && cache[p] != nil {
+ if cc, ok := cache[p][c]; ok {
+ mu.RUnlock()
+ return cc
+ }
+ }
+ mu.RUnlock()
+
+ // If we don't have a cached color, we need to convert it and cache it.
+ defer func() {
+ mu.Lock()
+ if cc != nil && cache[p] != nil {
+ if _, ok := cache[p][c]; !ok {
+ cache[p][c] = cc
+ }
+ }
+ mu.Unlock()
+ }()
+
+ switch c.(type) {
+ case ansi.BasicColor:
+ return c
+
+ case ansi.IndexedColor:
+ if p == ANSI {
+ return ansi.Convert16(c)
+ }
+ return c
+
+ default:
+ switch p {
+ case ANSI256:
+ return ansi.Convert256(c)
+ case ANSI:
+ return ansi.Convert16(c)
+ default:
+ return c
+ }
+ }
+}
diff --git a/vendor/github.com/charmbracelet/colorprofile/writer.go b/vendor/github.com/charmbracelet/colorprofile/writer.go
new file mode 100644
index 0000000000..c96e61a956
--- /dev/null
+++ b/vendor/github.com/charmbracelet/colorprofile/writer.go
@@ -0,0 +1,171 @@
+package colorprofile
+
+import (
+ "bytes"
+ "fmt"
+ "image/color"
+ "io"
+ "strconv"
+
+ "github.com/charmbracelet/x/ansi"
+)
+
+// NewWriter creates a new color profile writer that downgrades color sequences
+// based on the detected color profile.
+//
+// If environ is nil, it will use os.Environ() to get the environment variables.
+//
+// It queries the given writer to determine if it supports ANSI escape codes.
+// If it does, along with the given environment variables, it will determine
+// the appropriate color profile to use for color formatting.
+//
+// This respects the NO_COLOR, CLICOLOR, and CLICOLOR_FORCE environment variables.
+func NewWriter(w io.Writer, environ []string) *Writer {
+ return &Writer{
+ Forward: w,
+ Profile: Detect(w, environ),
+ }
+}
+
+// Writer represents a color profile writer that writes ANSI sequences to the
+// underlying writer.
+type Writer struct {
+ Forward io.Writer
+ Profile Profile
+}
+
+// Write writes the given text to the underlying writer.
+func (w *Writer) Write(p []byte) (int, error) {
+ switch {
+ case w.Profile == TrueColor:
+ return w.Forward.Write(p) //nolint:wrapcheck
+ case w.Profile <= NoTTY:
+ _, err := io.WriteString(w.Forward, ansi.Strip(string(p)))
+ return len(p), err
+ case w.Profile == ASCII, w.Profile == ANSI, w.Profile == ANSI256:
+ _, err := w.downsample(p)
+ return len(p), err
+ default:
+ return 0, fmt.Errorf("invalid profile: %v", w.Profile)
+ }
+}
+
+// downsample downgrades the given text to the appropriate color profile.
+func (w *Writer) downsample(p []byte) (int, error) {
+ var buf bytes.Buffer
+ var state byte
+
+ parser := ansi.GetParser()
+ defer ansi.PutParser(parser)
+
+ for len(p) > 0 {
+ parser.Reset()
+ seq, _, read, newState := ansi.DecodeSequence(p, state, parser)
+
+ switch {
+ case ansi.HasCsiPrefix(seq) && parser.Command() == 'm':
+ handleSgr(w, parser, &buf)
+ default:
+ // If we're not a style SGR sequence, just write the bytes.
+ if n, err := buf.Write(seq); err != nil {
+ return n, err //nolint:wrapcheck
+ }
+ }
+
+ p = p[read:]
+ state = newState
+ }
+
+ return w.Forward.Write(buf.Bytes()) //nolint:wrapcheck
+}
+
+// WriteString writes the given text to the underlying writer.
+func (w *Writer) WriteString(s string) (n int, err error) {
+ return w.Write([]byte(s))
+}
+
+func handleSgr(w *Writer, p *ansi.Parser, buf *bytes.Buffer) {
+ var style ansi.Style
+ params := p.Params()
+ for i := 0; i < len(params); i++ {
+ param := params[i]
+
+ switch param := param.Param(0); param {
+ case 0:
+ // SGR default parameter is 0. We use an empty string to reduce the
+ // number of bytes written to the buffer.
+ style = append(style, "")
+ case 30, 31, 32, 33, 34, 35, 36, 37: // 8-bit foreground color
+ if w.Profile < ANSI {
+ continue
+ }
+ style = style.ForegroundColor(
+ w.Profile.Convert(ansi.BasicColor(param - 30))) //nolint:gosec
+ case 38: // 16 or 24-bit foreground color
+ var c color.Color
+ if n := ansi.ReadStyleColor(params[i:], &c); n > 0 {
+ i += n - 1
+ }
+ if w.Profile < ANSI {
+ continue
+ }
+ style = style.ForegroundColor(w.Profile.Convert(c))
+ case 39: // default foreground color
+ if w.Profile < ANSI {
+ continue
+ }
+ style = style.ForegroundColor(nil)
+ case 40, 41, 42, 43, 44, 45, 46, 47: // 8-bit background color
+ if w.Profile < ANSI {
+ continue
+ }
+ style = style.BackgroundColor(
+ w.Profile.Convert(ansi.BasicColor(param - 40))) //nolint:gosec
+ case 48: // 16 or 24-bit background color
+ var c color.Color
+ if n := ansi.ReadStyleColor(params[i:], &c); n > 0 {
+ i += n - 1
+ }
+ if w.Profile < ANSI {
+ continue
+ }
+ style = style.BackgroundColor(w.Profile.Convert(c))
+ case 49: // default background color
+ if w.Profile < ANSI {
+ continue
+ }
+ style = style.BackgroundColor(nil)
+ case 58: // 16 or 24-bit underline color
+ var c color.Color
+ if n := ansi.ReadStyleColor(params[i:], &c); n > 0 {
+ i += n - 1
+ }
+ if w.Profile < ANSI {
+ continue
+ }
+ style = style.UnderlineColor(w.Profile.Convert(c))
+ case 59: // default underline color
+ if w.Profile < ANSI {
+ continue
+ }
+ style = style.UnderlineColor(nil)
+ case 90, 91, 92, 93, 94, 95, 96, 97: // 8-bit bright foreground color
+ if w.Profile < ANSI {
+ continue
+ }
+ style = style.ForegroundColor(
+ w.Profile.Convert(ansi.BasicColor(param - 90 + 8))) //nolint:gosec
+ case 100, 101, 102, 103, 104, 105, 106, 107: // 8-bit bright background color
+ if w.Profile < ANSI {
+ continue
+ }
+ style = style.BackgroundColor(
+ w.Profile.Convert(ansi.BasicColor(param - 100 + 8))) //nolint:gosec
+ default:
+ // If this is not a color attribute, just append it to the style.
+ style = append(style, strconv.Itoa(param))
+ }
+ }
+
+ _, _ = buf.WriteString(style.String())
+}
diff --git a/vendor/github.com/charmbracelet/ultraviolet/.gitattributes b/vendor/github.com/charmbracelet/ultraviolet/.gitattributes
new file mode 100644
index 0000000000..6c929d4803
--- /dev/null
+++ b/vendor/github.com/charmbracelet/ultraviolet/.gitattributes
@@ -0,0 +1 @@
+*.golden -text
diff --git a/vendor/github.com/charmbracelet/ultraviolet/.golangci.yml b/vendor/github.com/charmbracelet/ultraviolet/.golangci.yml
new file mode 100644
index 0000000000..64474889ef
--- /dev/null
+++ b/vendor/github.com/charmbracelet/ultraviolet/.golangci.yml
@@ -0,0 +1,48 @@
+version: "2"
+linters:
+ enable:
+ - bodyclose
+ # - exhaustive
+ # - goconst
+ # - godot
+ # - godox
+ # - gomoddirectives
+ - goprintffuncname
+ # - gosec
+ - misspell
+ # - nakedret
+ # - nestif
+ # - nilerr
+ - noctx
+ - nolintlint
+ # - prealloc
+ # - revive
+ - rowserrcheck
+ - sqlclosecheck
+ - staticcheck
+ - tparallel
+ # - unconvert
+ # - unparam
+ - whitespace
+ # - wrapcheck
+ disable:
+ - errcheck
+ - ineffassign
+ - unused
+ exclusions:
+ generated: lax
+ presets:
+ - common-false-positives
+ rules:
+ - text: '(slog|log)\.\w+'
+ linters:
+ - noctx
+issues:
+ max-issues-per-linter: 0
+ max-same-issues: 0
+formatters:
+ enable:
+ - gofumpt
+ - goimports
+ exclusions:
+ generated: lax
diff --git a/vendor/github.com/charmbracelet/ultraviolet/.goreleaser.yml b/vendor/github.com/charmbracelet/ultraviolet/.goreleaser.yml
new file mode 100644
index 0000000000..3353d02029
--- /dev/null
+++ b/vendor/github.com/charmbracelet/ultraviolet/.goreleaser.yml
@@ -0,0 +1,5 @@
+# yaml-language-server: $schema=https://goreleaser.com/static/schema-pro.json
+version: 2
+includes:
+ - from_url:
+ url: charmbracelet/meta/main/goreleaser-lib.yaml
diff --git a/vendor/github.com/charmbracelet/ultraviolet/LICENSE b/vendor/github.com/charmbracelet/ultraviolet/LICENSE
new file mode 100644
index 0000000000..3217a2fb70
--- /dev/null
+++ b/vendor/github.com/charmbracelet/ultraviolet/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2025 Charmbracelet, Inc
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/vendor/github.com/charmbracelet/ultraviolet/README.md b/vendor/github.com/charmbracelet/ultraviolet/README.md
new file mode 100644
index 0000000000..b28ccdd611
--- /dev/null
+++ b/vendor/github.com/charmbracelet/ultraviolet/README.md
@@ -0,0 +1,161 @@
+# Ultraviolet
+
+
+
+
+
+
+
+
+Ultraviolet is a set of primitives for building terminal user interfaces in Go.
+It provides cell-based rendering, cross-platform input handling, and a diffing
+renderer inspired by [ncurses](https://invisible-island.net/ncurses/)—without
+the need for `terminfo` or `termcap` databases.
+
+Ultraviolet powers [Bubble Tea v2][bbt] and [Lip Gloss v2][lg]. It replaces the
+ad-hoc terminal primitives from earlier versions with a cohesive, imperative API
+that can also be used standalone.
+
+[bbt]: https://github.com/charmbracelet/bubbletea
+[lg]: https://github.com/charmbracelet/lipgloss
+
+## Install
+
+```bash
+go get github.com/charmbracelet/ultraviolet@latest
+```
+
+## Quick Start
+
+```go
+package main
+
+import (
+ "log"
+
+ uv "github.com/charmbracelet/ultraviolet"
+ "github.com/charmbracelet/ultraviolet/screen"
+)
+
+func main() {
+ t := uv.DefaultTerminal()
+ scr := t.Screen()
+
+ scr.EnterAltScreen()
+
+ if err := t.Start(); err != nil {
+ log.Fatalf("failed to start terminal: %v", err)
+ }
+ defer t.Stop()
+
+ ctx := screen.NewContext(scr)
+ text := "Hello, World!"
+ textWidth := scr.StringWidth(text)
+
+ display := func() {
+ screen.Clear(scr)
+ bounds := scr.Bounds()
+ x := (bounds.Dx() - textWidth) / 2
+ y := bounds.Dy() / 2
+ ctx.DrawString(text, x, y)
+ scr.Render()
+ scr.Flush()
+ }
+
+ for ev := range t.Events() {
+ switch ev := ev.(type) {
+ case uv.WindowSizeEvent:
+ scr.Resize(ev.Width, ev.Height)
+ display()
+ case uv.KeyPressEvent:
+ if ev.MatchString("q", "ctrl+c") {
+ return
+ }
+ }
+ }
+}
+```
+
+## Architecture
+
+Ultraviolet is organized as a set of layered primitives:
+
+- **Terminal** — manages the application lifecycle: raw mode, input event loop,
+ start/stop. Create one with `DefaultTerminal()` or `NewTerminal(console, opts)`.
+
+- **TerminalScreen** — the screen state manager. Handles rendering, alternate
+ screen buffer, cursor, mouse modes, keyboard enhancements, bracketed paste,
+ window title, and more. Access it via `terminal.Screen()`.
+
+- **Screen** — a minimal interface (`Bounds`, `CellAt`, `SetCell`,
+ `WidthMethod`) implemented by `TerminalScreen`, `Buffer`, `Window`, and
+ `ScreenBuffer`. Write code against `Screen` to stay decoupled from the
+ terminal.
+
+- **Buffer / Window** — off-screen cell buffers. `Buffer` is a flat grid of
+ cells. `Window` adds parent/child relationships and shared-buffer views.
+ Both implement `Screen` and `Drawable`.
+
+- **screen package** — drawing helpers that operate on any `Screen`: a
+ `Context` for styled text rendering (`Print`, `DrawString`, etc.) and
+ utility functions like `Clear`, `Fill`, `Clone`.
+
+- **layout package** — a constraint-based layout solver built on the
+ [Cassowary algorithm][casso]. Partition screen space with `Len`, `Min`,
+ `Max`, `Percent`, `Ratio`, and `Fill` constraints.
+
+[casso]: https://en.wikipedia.org/wiki/Cassowary_(software)
+
+## Features
+
+- **Cell-based diffing renderer** — only redraws what changed. Optimizes
+ cursor movement, uses ECH/REP/ICH/DCH when available, and supports scroll
+ optimizations. Minimal bandwidth, critical for SSH.
+
+- **Universal input** — unified keyboard and mouse event handling across
+ platforms. Supports legacy encodings, Kitty keyboard protocol, SGR mouse,
+ and Windows Console input.
+
+- **Inline and fullscreen** — works in both alternate screen (fullscreen) and
+ inline mode. Inline TUIs preserve terminal context and scrollback.
+
+- **Cross-platform** — first-class support for Unix (termios + ANSI) and
+ Windows (Console API). Consistent behavior across terminal emulators.
+
+- **Suspend/resume** — `Stop()` and `Start()` can be called repeatedly for
+ suspend/resume cycles, shelling out to editors, or process suspension
+ via `uv.Suspend()`.
+
+## Examples
+
+See the [`examples/`](./examples/) directory for core examples and
+[`examples/advanced/`](./examples/advanced/) for more complex demos.
+
+## Tutorial
+
+See [TUTORIAL.md](./TUTORIAL.md) for a step-by-step guide to building your
+first Ultraviolet application.
+
+> [!NOTE]
+> Ultraviolet is in active development. The API may change.
+
+## Feedback
+
+We'd love to hear your thoughts on this project. Feel free to drop us a note!
+
+- [Twitter](https://twitter.com/charmcli)
+- [Discord](https://charm.land/discord)
+- [Slack](https://charm.land/slack)
+- [The Fediverse](https://mastodon.social/@charmcli)
+
+## License
+
+[MIT](./LICENSE)
+
+---
+
+Part of [Charm](https://charm.land).
+
+
+
+Charm热爱开源 • Charm loves open source • نحنُ نحب المصادر المفتوحة
diff --git a/vendor/github.com/charmbracelet/ultraviolet/TUTORIAL.md b/vendor/github.com/charmbracelet/ultraviolet/TUTORIAL.md
new file mode 100644
index 0000000000..d456d5a490
--- /dev/null
+++ b/vendor/github.com/charmbracelet/ultraviolet/TUTORIAL.md
@@ -0,0 +1,175 @@
+# Tutorial: Hello World
+
+This tutorial walks through building a simple Ultraviolet application that
+displays centered "Hello, World!" text. You'll learn the core concepts:
+creating a terminal, managing a screen, handling input events, and rendering.
+
+## Creating a Terminal
+
+A `Terminal` manages the console, input event loop, and screen state.
+
+```go
+t := uv.DefaultTerminal()
+```
+
+You can also create a terminal with a custom console and options:
+
+```go
+con := uv.NewConsole(os.Stdin, os.Stdout, os.Environ())
+t := uv.NewTerminal(con, &uv.Options{
+ Logger: myLogger, // optional, for debugging I/O
+})
+```
+
+## Getting the Screen
+
+The terminal's screen is where you draw content, manage the alternate screen
+buffer, and set cells.
+
+```go
+scr := t.Screen()
+```
+
+## Alternate Screen
+
+The alternate screen buffer lets your application display content without
+affecting the user's scrollback. Most fullscreen TUIs use it.
+
+```go
+scr.EnterAltScreen()
+```
+
+## Starting the Terminal
+
+Starting puts the console into raw mode (disabling echoing and line buffering
+so we receive individual keypresses like ctrl+c), initializes the
+input event loop, and prepares the screen for rendering.
+
+```go
+if err := t.Start(); err != nil {
+ log.Fatalf("failed to start terminal: %v", err)
+}
+defer t.Stop()
+```
+
+`Stop()` restores the console, exits the alternate screen, and cleans up. It
+is safe to call multiple times and supports suspend/resume cycles.
+
+## Drawing Text
+
+You can set individual cells directly:
+
+```go
+for i, r := range "Hello, World!" {
+ scr.SetCell(i, 0, &uv.Cell{Content: string(r), Width: 1})
+}
+```
+
+Or use the `screen` helper package for convenience:
+
+```go
+ctx := screen.NewContext(scr)
+ctx.DrawString("Hello, World!", 0, 0)
+```
+
+The `Context` supports styled text, links, and wrapping. It implements
+`io.Writer`, so you can use `fmt.Fprint` and friends.
+
+## Rendering
+
+Drawing to the screen is a two-step process:
+
+1. **Render** — computes the minimal diff between the current and new screen
+ state, writing ANSI escape sequences to an internal buffer.
+2. **Flush** — writes the buffer to the terminal. This is the only step that
+ performs real I/O and can return an error.
+
+```go
+scr.Render()
+if err := scr.Flush(); err != nil {
+ log.Fatalf("flush failed: %v", err)
+}
+```
+
+## Handling Events
+
+The terminal provides a channel of input events. Range over it to process
+keyboard, mouse, and resize events:
+
+```go
+for ev := range t.Events() {
+ switch ev := ev.(type) {
+ case uv.WindowSizeEvent:
+ scr.Resize(ev.Width, ev.Height)
+ case uv.KeyPressEvent:
+ if ev.MatchString("q", "ctrl+c") {
+ return
+ }
+ }
+}
+```
+
+`MatchString` accepts key names and modifier combinations like `"ctrl+a"`,
+`"shift+enter"`, or `"alt+tab"`.
+
+## Putting It Together
+
+Here's the complete program—centered "Hello, World!" that redraws on resize
+and exits on `q` or `ctrl+c`:
+
+```go
+package main
+
+import (
+ "log"
+
+ uv "github.com/charmbracelet/ultraviolet"
+ "github.com/charmbracelet/ultraviolet/screen"
+)
+
+func main() {
+ t := uv.DefaultTerminal()
+ scr := t.Screen()
+
+ scr.EnterAltScreen()
+
+ if err := t.Start(); err != nil {
+ log.Fatalf("failed to start terminal: %v", err)
+ }
+ defer t.Stop()
+
+ ctx := screen.NewContext(scr)
+ text := "Hello, World!"
+ textWidth := scr.StringWidth(text)
+
+ display := func() {
+ screen.Clear(scr)
+ bounds := scr.Bounds()
+ x := (bounds.Dx() - textWidth) / 2
+ y := bounds.Dy() / 2
+ ctx.DrawString(text, x, y)
+ scr.Render()
+ scr.Flush()
+ }
+
+ for ev := range t.Events() {
+ switch ev := ev.(type) {
+ case uv.WindowSizeEvent:
+ scr.Resize(ev.Width, ev.Height)
+ display()
+ case uv.KeyPressEvent:
+ if ev.MatchString("q", "ctrl+c") {
+ return
+ }
+ }
+ }
+}
+```
+
+---
+
+Part of [Charm](https://charm.sh).
+
+
+
+Charm热爱开源 • Charm loves open source • نحنُ نحب المصادر المفتوحة
diff --git a/vendor/github.com/charmbracelet/ultraviolet/border.go b/vendor/github.com/charmbracelet/ultraviolet/border.go
new file mode 100644
index 0000000000..e24c9a0605
--- /dev/null
+++ b/vendor/github.com/charmbracelet/ultraviolet/border.go
@@ -0,0 +1,231 @@
+package uv
+
+// NormalBorder returns a standard-type border with a normal weight and 90
+// degree corners.
+func NormalBorder() Border {
+ return Border{
+ Top: Side{Content: "─"},
+ Bottom: Side{Content: "─"},
+ Left: Side{Content: "│"},
+ Right: Side{Content: "│"},
+ TopLeft: Side{Content: "┌"},
+ TopRight: Side{Content: "┐"},
+ BottomLeft: Side{Content: "└"},
+ BottomRight: Side{Content: "┘"},
+ }
+}
+
+// RoundedBorder returns a border with rounded corners.
+func RoundedBorder() Border {
+ return Border{
+ Top: Side{Content: "─"},
+ Bottom: Side{Content: "─"},
+ Left: Side{Content: "│"},
+ Right: Side{Content: "│"},
+ TopLeft: Side{Content: "╭"},
+ TopRight: Side{Content: "╮"},
+ BottomLeft: Side{Content: "╰"},
+ BottomRight: Side{Content: "╯"},
+ }
+}
+
+// BlockBorder returns a border that takes the whole block.
+func BlockBorder() Border {
+ return Border{
+ Top: Side{Content: "█"},
+ Bottom: Side{Content: "█"},
+ Left: Side{Content: "█"},
+ Right: Side{Content: "█"},
+ TopLeft: Side{Content: "█"},
+ TopRight: Side{Content: "█"},
+ BottomLeft: Side{Content: "█"},
+ BottomRight: Side{Content: "█"},
+ }
+}
+
+// OuterHalfBlockBorder returns a half-block border that sits outside the frame.
+func OuterHalfBlockBorder() Border {
+ return Border{
+ Top: Side{Content: "▀"},
+ Bottom: Side{Content: "▄"},
+ Left: Side{Content: "▌"},
+ Right: Side{Content: "▐"},
+ TopLeft: Side{Content: "▛"},
+ TopRight: Side{Content: "▜"},
+ BottomLeft: Side{Content: "▙"},
+ BottomRight: Side{Content: "▟"},
+ }
+}
+
+// InnerHalfBlockBorder returns a half-block border that sits inside the frame.
+func InnerHalfBlockBorder() Border {
+ return Border{
+ Top: Side{Content: "▄"},
+ Bottom: Side{Content: "▀"},
+ Left: Side{Content: "▐"},
+ Right: Side{Content: "▌"},
+ TopLeft: Side{Content: "▗"},
+ TopRight: Side{Content: "▖"},
+ BottomLeft: Side{Content: "▝"},
+ BottomRight: Side{Content: "▘"},
+ }
+}
+
+// ThickBorder returns a border that's thicker than the one returned by
+// NormalBorder.
+func ThickBorder() Border {
+ return Border{
+ Top: Side{Content: "━"},
+ Bottom: Side{Content: "━"},
+ Left: Side{Content: "┃"},
+ Right: Side{Content: "┃"},
+ TopLeft: Side{Content: "┏"},
+ TopRight: Side{Content: "┓"},
+ BottomLeft: Side{Content: "┗"},
+ BottomRight: Side{Content: "┛"},
+ }
+}
+
+// DoubleBorder returns a border comprised of two thin strokes.
+func DoubleBorder() Border {
+ return Border{
+ Top: Side{Content: "═"},
+ Bottom: Side{Content: "═"},
+ Left: Side{Content: "║"},
+ Right: Side{Content: "║"},
+ TopLeft: Side{Content: "╔"},
+ TopRight: Side{Content: "╗"},
+ BottomLeft: Side{Content: "╚"},
+ BottomRight: Side{Content: "╝"},
+ }
+}
+
+// HiddenBorder returns a border that renders as a series of single-cell
+// spaces. It's useful for cases when you want to remove a standard border but
+// maintain layout positioning. This said, you can still apply a background
+// color to a hidden border.
+func HiddenBorder() Border {
+ return Border{
+ Top: Side{Content: " "},
+ Bottom: Side{Content: " "},
+ Left: Side{Content: " "},
+ Right: Side{Content: " "},
+ TopLeft: Side{Content: " "},
+ TopRight: Side{Content: " "},
+ BottomLeft: Side{Content: " "},
+ BottomRight: Side{Content: " "},
+ }
+}
+
+// MarkdownBorder return a table border in markdown style.
+func MarkdownBorder() Border {
+ return Border{
+ Left: Side{Content: "|"},
+ Right: Side{Content: "|"},
+ TopLeft: Side{Content: "|"},
+ TopRight: Side{Content: "|"},
+ BottomLeft: Side{Content: "|"},
+ BottomRight: Side{Content: "|"},
+ }
+}
+
+// ASCIIBorder returns a table border with ASCII characters.
+func ASCIIBorder() Border {
+ return Border{
+ Top: Side{Content: "-"},
+ Bottom: Side{Content: "-"},
+ Left: Side{Content: "|"},
+ Right: Side{Content: "|"},
+ TopLeft: Side{Content: "+"},
+ TopRight: Side{Content: "+"},
+ BottomLeft: Side{Content: "+"},
+ BottomRight: Side{Content: "+"},
+ }
+}
+
+// Side represents a single border side with its properties.
+type Side struct {
+ Content string
+ Style
+ Link
+}
+
+// Border represents a border with its properties.
+type Border struct {
+ Top Side
+ Bottom Side
+ Left Side
+ Right Side
+ TopLeft Side
+ TopRight Side
+ BottomLeft Side
+ BottomRight Side
+}
+
+// Style returns a new [Border] with the given style applied to all [Side]s.
+func (b Border) Style(style Style) Border {
+ b.Top.Style = style
+ b.Bottom.Style = style
+ b.Left.Style = style
+ b.Right.Style = style
+ b.TopLeft.Style = style
+ b.TopRight.Style = style
+ b.BottomLeft.Style = style
+ b.BottomRight.Style = style
+ return b
+}
+
+// Link returns a new [Border] with the given link applied to all [Side]s.
+func (b Border) Link(link Link) Border {
+ b.Top.Link = link
+ b.Bottom.Link = link
+ b.Left.Link = link
+ b.Right.Link = link
+ b.TopLeft.Link = link
+ b.TopRight.Link = link
+ b.BottomLeft.Link = link
+ b.BottomRight.Link = link
+ return b
+}
+
+// Draw draws the border around the given component.
+func (b *Border) Draw(scr Screen, area Rectangle) {
+ for y := area.Min.Y; y < area.Max.Y; y++ {
+ for x := area.Min.X; x < area.Max.X; x++ {
+ var cell *Cell
+ switch {
+ case y == area.Min.Y && x == area.Min.X:
+ cell = borderCell(scr, &b.TopLeft)
+ case y == area.Min.Y && x == area.Max.X-1:
+ cell = borderCell(scr, &b.TopRight)
+ case y == area.Max.Y-1 && x == area.Min.X:
+ cell = borderCell(scr, &b.BottomLeft)
+ case y == area.Max.Y-1 && x == area.Max.X-1:
+ cell = borderCell(scr, &b.BottomRight)
+ case y == area.Min.Y:
+ cell = borderCell(scr, &b.Top)
+ case y == area.Max.Y-1:
+ cell = borderCell(scr, &b.Bottom)
+ case x == area.Min.X:
+ cell = borderCell(scr, &b.Left)
+ case x == area.Max.X-1:
+ cell = borderCell(scr, &b.Right)
+ default:
+ continue
+ }
+ if cell == nil {
+ continue
+ }
+ scr.SetCell(x, y, cell)
+ }
+ }
+}
+
+func borderCell(scr Screen, b *Side) *Cell {
+ c := NewCell(scr.WidthMethod(), b.Content)
+ if c != nil {
+ c.Style = b.Style
+ c.Link = b.Link
+ }
+ return c
+}
diff --git a/vendor/github.com/charmbracelet/ultraviolet/buffer.go b/vendor/github.com/charmbracelet/ultraviolet/buffer.go
new file mode 100644
index 0000000000..5a83fc3757
--- /dev/null
+++ b/vendor/github.com/charmbracelet/ultraviolet/buffer.go
@@ -0,0 +1,834 @@
+package uv
+
+import (
+ "bytes"
+ "image"
+ "io"
+ "strings"
+
+ "github.com/charmbracelet/x/ansi"
+)
+
+// Position represents a position in a coordinate system.
+type Position = image.Point
+
+// Pos is a shorthand for creating a new [Position].
+func Pos(x, y int) Position {
+ return Position{X: x, Y: y}
+}
+
+// Rectangle represents a rectangular area.
+type Rectangle = image.Rectangle
+
+// Rect is a shorthand for creating a new [Rectangle].
+func Rect(x, y, w, h int) Rectangle {
+ return Rectangle{Min: image.Point{X: x, Y: y}, Max: image.Point{X: x + w, Y: y + h}}
+}
+
+// Line represents cells in a line.
+type Line []Cell
+
+// NewLine creates a new line with the given width, filled with empty cells.
+func NewLine(width int) Line {
+ l := make(Line, width)
+ for i := range l {
+ l[i] = EmptyCell
+ }
+ return l
+}
+
+// Set sets the cell at the given x position.
+func (l Line) Set(x int, c *Cell) {
+ lineWidth := len(l)
+ if x < 0 || x >= lineWidth {
+ return
+ }
+
+ // When a wide cell is partially overwritten, we need
+ // to fill the rest of the cell with space cells to
+ // avoid rendering issues.
+ var prev *Cell
+ if prev = l.At(x); prev != nil { //nolint:nestif
+ if pw := prev.Width; pw > 1 {
+ // Writing to the first wide cell
+ for j := 0; j < pw && x+j < lineWidth; j++ {
+ l[x+j] = *prev
+ l[x+j].Empty()
+ }
+ } else if pw == 0 {
+ // Writing to wide cell placeholders
+ for j := 1; x-j >= 0; j++ {
+ if wide := l.At(x - j); wide != nil {
+ if ww := wide.Width; ww > 1 && j < ww {
+ for k := range ww {
+ l[x-j+k] = *wide
+ l[x-j+k].Empty()
+ }
+ break
+ }
+ }
+ }
+ }
+ }
+
+ if c == nil {
+ // Nil cells are treated as blank empty cells.
+ l[x] = EmptyCell
+ return
+ }
+
+ l[x] = *c
+ cw := c.Width
+ if x+cw > lineWidth {
+ // If the cell is too wide, we write blanks with the same style.
+ for i := 0; i < cw && x+i < lineWidth; i++ {
+ l[x+i] = *c
+ l[x+i].Empty()
+ }
+ return
+ }
+
+ if cw > 1 {
+ // Mark wide cells with zero-width placeholder cells.
+ for j := 1; j < cw && x+j < lineWidth; j++ {
+ l[x+j] = Cell{}
+ }
+ }
+}
+
+// At returns the cell at the given x position.
+// If the cell does not exist, it returns nil.
+func (l Line) At(x int) *Cell {
+ if x < 0 || x >= len(l) {
+ return nil
+ }
+
+ return &l[x]
+}
+
+// String returns the string representation of the line. Any trailing spaces
+// are removed.
+func (l Line) String() string {
+ var buf strings.Builder
+ var pending bytes.Buffer
+ for _, c := range l {
+ if c.IsZero() {
+ continue
+ }
+ if c.Equal(&EmptyCell) {
+ pending.WriteByte(' ')
+ continue
+ }
+ if pending.Len() > 0 {
+ buf.WriteString(pending.String())
+ pending.Reset()
+ }
+ buf.WriteString(c.String())
+ }
+
+ return buf.String()
+}
+
+// Render renders the line to a string with all the required attributes and
+// styles.
+func (l Line) Render() string {
+ var buf strings.Builder
+ renderLine(&buf, l)
+ return buf.String()
+}
+
+func renderLine(buf io.StringWriter, l Line) {
+ var pen Style
+ var link Link
+ var pending bytes.Buffer
+
+ for _, c := range l {
+ if c.IsZero() {
+ continue
+ }
+ if c.Equal(&EmptyCell) {
+ if !pen.IsZero() {
+ _, _ = buf.WriteString(ansi.ResetStyle)
+ pen = Style{}
+ }
+ if !link.IsZero() {
+ _, _ = buf.WriteString(ansi.ResetHyperlink())
+ link = Link{}
+ }
+ pending.WriteByte(' ')
+ continue
+ }
+
+ if pending.Len() > 0 {
+ _, _ = buf.WriteString(pending.String())
+ pending.Reset()
+ }
+
+ if c.Style.IsZero() && !pen.IsZero() {
+ _, _ = buf.WriteString(ansi.ResetStyle)
+ pen = Style{}
+ }
+ if !c.Style.Equal(&pen) {
+ seq := c.Style.Diff(&pen)
+ _, _ = buf.WriteString(seq)
+ pen = c.Style
+ }
+
+ // Write the URL escape sequence
+ if c.Link != link && link.URL != "" {
+ _, _ = buf.WriteString(ansi.ResetHyperlink())
+ link = Link{}
+ }
+ if c.Link != link {
+ _, _ = buf.WriteString(ansi.SetHyperlink(c.Link.URL, c.Link.Params))
+ link = c.Link
+ }
+
+ _, _ = buf.WriteString(c.String())
+ }
+
+ if pending.Len() > 0 {
+ _, _ = buf.WriteString(pending.String())
+ }
+ if link.URL != "" {
+ _, _ = buf.WriteString(ansi.ResetHyperlink())
+ }
+ if !pen.IsZero() {
+ _, _ = buf.WriteString(ansi.ResetStyle)
+ }
+}
+
+// Lines represents a slice of lines.
+type Lines []Line
+
+// Height returns the height of the lines.
+func (ls Lines) Height() int {
+ return len(ls)
+}
+
+// Width returns the width of the widest line.
+func (ls Lines) Width() int {
+ maxWidth := 0
+ for _, l := range ls {
+ maxWidth = max(maxWidth, len(l))
+ }
+ return maxWidth
+}
+
+// String returns the string representation of the lines.
+func (ls Lines) String() string {
+ var buf strings.Builder
+ for i, l := range ls {
+ buf.WriteString(l.String())
+ if i < len(ls)-1 {
+ _ = buf.WriteByte('\n')
+ }
+ }
+ return buf.String()
+}
+
+// Render renders the lines to a styled string with all the required attributes
+// and styles.
+func (ls Lines) Render() string {
+ var buf strings.Builder
+ for i, l := range ls {
+ renderLine(&buf, l)
+ if i < len(ls)-1 {
+ _ = buf.WriteByte('\n')
+ }
+ }
+ return buf.String()
+}
+
+// Buffer represents a cell buffer that contains the contents of a screen.
+type Buffer struct {
+ // Lines is a slice of lines that make up the cells of the buffer.
+ Lines []Line
+}
+
+var _ Drawable = (*Buffer)(nil)
+
+// NewBuffer creates a new buffer with the given width and height.
+// This is a convenience function that initializes a new buffer and resizes it.
+func NewBuffer(width int, height int) *Buffer {
+ b := new(Buffer)
+ b.Lines = make([]Line, height)
+ for i := range b.Lines {
+ b.Lines[i] = make(Line, width)
+ for j := range b.Lines[i] {
+ b.Lines[i][j] = EmptyCell
+ }
+ }
+ b.Resize(width, height)
+ return b
+}
+
+// String returns the string representation of the buffer.
+func (b *Buffer) String() string {
+ return Lines(b.Lines).String()
+}
+
+// Render renders the buffer to a styled string with all the required
+// attributes and styles.
+func (b *Buffer) Render() string {
+ return Lines(b.Lines).Render()
+}
+
+// Line returns a pointer to the line at the given y position.
+// If the line does not exist, it returns nil.
+func (b *Buffer) Line(y int) Line {
+ if y < 0 || y >= len(b.Lines) {
+ return nil
+ }
+ return b.Lines[y]
+}
+
+// CellAt returns the cell at the given position. It returns nil if the
+// position is out of bounds.
+func (b *Buffer) CellAt(x int, y int) *Cell {
+ if y < 0 || y >= len(b.Lines) {
+ return nil
+ }
+ return b.Lines[y].At(x)
+}
+
+// SetCell sets the cell at the given x, y position.
+func (b *Buffer) SetCell(x, y int, c *Cell) {
+ if y < 0 || y >= len(b.Lines) {
+ return
+ }
+
+ b.Lines[y].Set(x, c)
+}
+
+// Height implements Screen.
+func (b *Buffer) Height() int {
+ return len(b.Lines)
+}
+
+// Width implements Screen.
+func (b *Buffer) Width() int {
+ if len(b.Lines) == 0 {
+ return 0
+ }
+ return len(b.Lines[0])
+}
+
+// Bounds returns the bounds of the buffer.
+// The origin is always at (0, 0) and the maximum coordinates are determined by
+// the width and height of the buffer.
+func (b *Buffer) Bounds() Rectangle {
+ return Rect(0, 0, b.Width(), b.Height())
+}
+
+// Resize resizes the buffer to the given width and height.
+func (b *Buffer) Resize(width int, height int) {
+ curWidth, curHeight := b.Width(), b.Height()
+ if curWidth == width && curHeight == height {
+ // No need to resize if the dimensions are the same.
+ return
+ }
+
+ if width > curWidth {
+ line := make(Line, width-curWidth)
+ for i := range line {
+ line[i] = EmptyCell
+ }
+ for i := range b.Lines {
+ b.Lines[i] = append(b.Lines[i], line...)
+ }
+ } else if width < curWidth {
+ for i := range b.Lines {
+ b.Lines[i] = b.Lines[i][:width]
+ }
+ }
+
+ if height > len(b.Lines) {
+ for i := len(b.Lines); i < height; i++ {
+ line := make(Line, width)
+ for j := range line {
+ line[j] = EmptyCell
+ }
+ b.Lines = append(b.Lines, line)
+ }
+ } else if height < len(b.Lines) {
+ b.Lines = b.Lines[:height]
+ }
+}
+
+// Fill fills the buffer with the given cell and rectangle.
+func (b *Buffer) Fill(c *Cell) {
+ b.FillArea(c, b.Bounds())
+}
+
+// FillArea fills the buffer with the given cell and rectangle.
+func (b *Buffer) FillArea(c *Cell, area Rectangle) {
+ cellWidth := 1
+ if c != nil && c.Width > 1 {
+ cellWidth = c.Width
+ }
+ for y := area.Min.Y; y < area.Max.Y; y++ {
+ for x := area.Min.X; x < area.Max.X; x += cellWidth {
+ b.SetCell(x, y, c)
+ }
+ }
+}
+
+// Clear clears the buffer with space cells and rectangle.
+func (b *Buffer) Clear() {
+ area := b.Bounds()
+ for y := area.Min.Y; y < area.Max.Y; y++ {
+ for x := area.Min.X; x < area.Max.X; x++ {
+ b.Lines[y][x] = EmptyCell
+ }
+ }
+}
+
+// ClearArea clears the buffer with space cells within the specified
+// rectangles. Only cells within the rectangle's bounds are affected.
+func (b *Buffer) ClearArea(area Rectangle) {
+ b.FillArea(nil, area)
+}
+
+// CloneArea clones the area of the buffer within the specified rectangle. If
+// the area is out of bounds, it returns nil.
+func (b *Buffer) CloneArea(area Rectangle) *Buffer {
+ bounds := b.Bounds()
+ if !area.In(bounds) {
+ return nil
+ }
+ n := NewBuffer(area.Dx(), area.Dy())
+ for y := area.Min.Y; y < area.Max.Y; y++ {
+ for x := area.Min.X; x < area.Max.X; {
+ c := b.CellAt(x, y)
+ if c == nil || c.IsZero() {
+ x++
+ continue
+ }
+ n.SetCell(x-area.Min.X, y-area.Min.Y, c)
+ x += max(c.Width, 1)
+ }
+ }
+ return n
+}
+
+// Clone clones the entire buffer into a new buffer.
+func (b *Buffer) Clone() *Buffer {
+ return b.CloneArea(b.Bounds())
+}
+
+// Draw draws the buffer to the given screen at the specified area.
+// It implements the [Drawable] interface.
+func (b *Buffer) Draw(scr Screen, area Rectangle) {
+ if area.Empty() {
+ return
+ }
+
+ // Ensure the area is within the bounds of the screen.
+ bounds := scr.Bounds()
+ if !area.Overlaps(bounds) {
+ return
+ }
+
+ for y := area.Min.Y; y < area.Max.Y; y++ {
+ for x := area.Min.X; x < area.Max.X; {
+ c := b.CellAt(x-area.Min.X, y-area.Min.Y)
+ if c == nil || c.IsZero() {
+ x++
+ continue
+ }
+ scr.SetCell(x, y, c)
+ width := c.Width
+ if width <= 0 {
+ width = 1
+ }
+ x += width
+ }
+ }
+}
+
+// InsertLine inserts n lines at the given line position, with the given
+// optional cell, within the specified rectangles. If no rectangles are
+// specified, it inserts lines in the entire buffer. Only cells within the
+// rectangle's horizontal bounds are affected. Lines are pushed out of the
+// rectangle bounds and lost. This follows terminal [ansi.IL] behavior.
+// It returns the pushed out lines.
+func (b *Buffer) InsertLine(y, n int, c *Cell) {
+ b.InsertLineArea(y, n, c, b.Bounds())
+}
+
+// InsertLineArea inserts new lines at the given line position, with the
+// given optional cell, within the rectangle bounds. Only cells within the
+// rectangle's horizontal bounds are affected. Lines are pushed out of the
+// rectangle bounds and lost. This follows terminal [ansi.IL] behavior.
+func (b *Buffer) InsertLineArea(y, n int, c *Cell, area Rectangle) {
+ if n <= 0 || y < area.Min.Y || y >= area.Max.Y || y >= b.Height() {
+ return
+ }
+
+ // Limit number of lines to insert to available space
+ if y+n > area.Max.Y {
+ n = area.Max.Y - y
+ }
+
+ // Move existing lines down within the bounds
+ for i := area.Max.Y - 1; i >= y+n; i-- {
+ for x := area.Min.X; x < area.Max.X; x++ {
+ // We don't need to clone c here because we're just moving lines down.
+ b.Lines[i][x] = b.Lines[i-n][x]
+ }
+ }
+
+ // Clear the newly inserted lines within bounds
+ for i := y; i < y+n; i++ {
+ for x := area.Min.X; x < area.Max.X; x++ {
+ b.SetCell(x, i, c)
+ }
+ }
+}
+
+// DeleteLineArea deletes lines at the given line position, with the given
+// optional cell, within the rectangle bounds. Only cells within the
+// rectangle's bounds are affected. Lines are shifted up within the bounds and
+// new blank lines are created at the bottom. This follows terminal [ansi.DL]
+// behavior.
+func (b *Buffer) DeleteLineArea(y, n int, c *Cell, area Rectangle) {
+ if n <= 0 || y < area.Min.Y || y >= area.Max.Y || y >= b.Height() {
+ return
+ }
+
+ // Limit deletion count to available space in scroll region
+ if n > area.Max.Y-y {
+ n = area.Max.Y - y
+ }
+
+ // Shift cells up within the bounds
+ for dst := y; dst < area.Max.Y-n; dst++ {
+ src := dst + n
+ for x := area.Min.X; x < area.Max.X; x++ {
+ // We don't need to clone c here because we're just moving cells up.
+ b.Lines[dst][x] = b.Lines[src][x]
+ }
+ }
+
+ // Fill the bottom n lines with blank cells
+ for i := area.Max.Y - n; i < area.Max.Y; i++ {
+ for x := area.Min.X; x < area.Max.X; x++ {
+ b.SetCell(x, i, c)
+ }
+ }
+}
+
+// DeleteLine deletes n lines at the given line position, with the given
+// optional cell, within the specified rectangles. If no rectangles are
+// specified, it deletes lines in the entire buffer.
+func (b *Buffer) DeleteLine(y, n int, c *Cell) {
+ b.DeleteLineArea(y, n, c, b.Bounds())
+}
+
+// InsertCell inserts new cells at the given position, with the given optional
+// cell, within the specified rectangles. If no rectangles are specified, it
+// inserts cells in the entire buffer. This follows terminal [ansi.ICH]
+// behavior.
+func (b *Buffer) InsertCell(x, y, n int, c *Cell) {
+ b.InsertCellArea(x, y, n, c, b.Bounds())
+}
+
+// InsertCellArea inserts new cells at the given position, with the given
+// optional cell, within the rectangle bounds. Only cells within the
+// rectangle's bounds are affected, following terminal [ansi.ICH] behavior.
+func (b *Buffer) InsertCellArea(x, y, n int, c *Cell, area Rectangle) {
+ if n <= 0 || y < area.Min.Y || y >= area.Max.Y || y >= b.Height() ||
+ x < area.Min.X || x >= area.Max.X || x >= b.Width() {
+ return
+ }
+
+ // Limit number of cells to insert to available space
+ if x+n > area.Max.X {
+ n = area.Max.X - x
+ }
+
+ // Move existing cells within rectangle bounds to the right
+ for i := area.Max.X - 1; i >= x+n && i-n >= area.Min.X; i-- {
+ // We don't need to clone c here because we're just moving cells to the
+ // right.
+ b.Lines[y][i] = b.Lines[y][i-n]
+ }
+
+ // Clear the newly inserted cells within rectangle bounds
+ for i := x; i < x+n && i < area.Max.X; i++ {
+ b.SetCell(i, y, c)
+ }
+}
+
+// DeleteCell deletes cells at the given position, with the given optional
+// cell, within the specified rectangles. If no rectangles are specified, it
+// deletes cells in the entire buffer. This follows terminal [ansi.DCH]
+// behavior.
+func (b *Buffer) DeleteCell(x, y, n int, c *Cell) {
+ b.DeleteCellArea(x, y, n, c, b.Bounds())
+}
+
+// DeleteCellArea deletes cells at the given position, with the given
+// optional cell, within the rectangle bounds. Only cells within the
+// rectangle's bounds are affected, following terminal [ansi.DCH] behavior.
+func (b *Buffer) DeleteCellArea(x, y, n int, c *Cell, area Rectangle) {
+ if n <= 0 || y < area.Min.Y || y >= area.Max.Y || y >= b.Height() ||
+ x < area.Min.X || x >= area.Max.X || x >= b.Width() {
+ return
+ }
+
+ // Calculate how many positions we can actually delete
+ remainingCells := area.Max.X - x
+ if n > remainingCells {
+ n = remainingCells
+ }
+
+ // Shift the remaining cells to the left
+ for i := x; i < area.Max.X-n; i++ {
+ if i+n < area.Max.X {
+ // We need to use SetCell here to ensure we blank out any wide
+ // cells we encounter.
+ b.SetCell(i, y, b.CellAt(i+n, y))
+ }
+ }
+
+ // Fill the vacated positions with the given cell
+ for i := area.Max.X - n; i < area.Max.X; i++ {
+ b.SetCell(i, y, c)
+ }
+}
+
+// ScreenBuffer is a buffer that can be used as a [Screen].
+type ScreenBuffer struct {
+ *RenderBuffer
+ Method ansi.Method
+}
+
+var (
+ _ Screen = ScreenBuffer{}
+ _ Drawable = ScreenBuffer{}
+)
+
+// NewScreenBuffer creates a new ScreenBuffer with the given width and height.
+func NewScreenBuffer(width, height int) ScreenBuffer {
+ return ScreenBuffer{
+ RenderBuffer: NewRenderBuffer(width, height),
+ Method: ansi.WcWidth,
+ }
+}
+
+// WidthMethod returns the width method used by the screen.
+// It defaults to [ansi.WcWidth].
+func (s ScreenBuffer) WidthMethod() WidthMethod {
+ return s.Method
+}
+
+// TrimSpace trims trailing spaces from the end of each line in the given
+// string.
+func TrimSpace(s string) string {
+ lines := strings.Split(s, "\n")
+ for i, line := range lines {
+ // Check if we have a trailing '\r' and preserve it
+ hasCR := strings.HasSuffix(line, "\r")
+ if hasCR {
+ line = strings.TrimSuffix(line, "\r")
+ }
+ line = strings.TrimRight(line, " ")
+ if hasCR {
+ line = line + "\r"
+ }
+ lines[i] = line
+ }
+ return strings.Join(lines, "\n")
+}
+
+// RenderBuffer represents a buffer that keeps track of the current and new
+// state of the screen, allowing for efficient rendering by only updating the
+// parts of the screen that have changed.
+type RenderBuffer struct {
+ *Buffer
+ Touched []*LineData
+}
+
+// NewRenderBuffer creates a new [RenderBuffer] with the given width and height.
+func NewRenderBuffer(width, height int) *RenderBuffer {
+ return &RenderBuffer{
+ Buffer: NewBuffer(width, height),
+ Touched: make([]*LineData, height),
+ }
+}
+
+// TouchLine marks a line n times starting at the given x position as touched.
+func (b *RenderBuffer) TouchLine(x, y, n int) {
+ if y < 0 || y >= len(b.Lines) {
+ return
+ }
+
+ if y >= len(b.Touched) {
+ b.Touched = append(b.Touched, make([]*LineData, y-len(b.Touched)+1)...)
+ }
+
+ // Re-check bounds: a concurrent resize may have cleared Touched
+ if y >= len(b.Touched) {
+ return
+ }
+
+ ch := b.Touched[y]
+ if ch == nil {
+ ch = &LineData{FirstCell: x, LastCell: x + n}
+ } else {
+ ch.FirstCell = min(ch.FirstCell, x)
+ ch.LastCell = max(ch.LastCell, x+n)
+ }
+ b.Touched[y] = ch
+}
+
+// Touch marks the cell at the given x, y position as touched.
+func (b *RenderBuffer) Touch(x, y int) {
+ b.TouchLine(x, y, 0)
+}
+
+// TouchedLines returns the number of touched lines in the buffer.
+func (b *RenderBuffer) TouchedLines() int {
+ if b.Touched == nil {
+ return 0
+ }
+ count := 0
+ for _, t := range b.Touched {
+ if t != nil {
+ count++
+ }
+ }
+ return count
+}
+
+// SetCell sets the cell at the given x, y position and marks the line as
+// touched.
+func (b *RenderBuffer) SetCell(x, y int, c *Cell) {
+ if p := b.CellAt(x, y); !cellEqual(p, c) {
+ width := 1
+ if c != nil && c.Width > 0 {
+ width = c.Width
+ }
+ if p != nil && p.Width > 0 {
+ width = max(width, p.Width)
+ }
+ b.TouchLine(x, y, width)
+ }
+ b.Buffer.SetCell(x, y, c)
+}
+
+// InsertLine inserts n lines at the given line position, with the given
+// optional cell, within the specified rectangles. If no rectangles are
+// specified, it inserts lines in the entire buffer. Only cells within the
+// rectangle's horizontal bounds are affected. Lines are pushed out of the
+// rectangle bounds and lost. This follows terminal [ansi.IL] behavior.
+func (b *RenderBuffer) InsertLine(y, n int, c *Cell) {
+ b.InsertLineArea(y, n, c, b.Bounds())
+}
+
+// InsertLineArea inserts new lines at the given line position, with the given
+// optional cell, within the rectangle bounds. Only cells within the
+// rectangle's horizontal bounds are affected. Lines are pushed out of the
+// rectangle bounds and lost. This follows terminal [ansi.IL] behavior.
+func (b *RenderBuffer) InsertLineArea(y, n int, c *Cell, area Rectangle) {
+ b.Buffer.InsertLineArea(y, n, c, area)
+ for i := area.Min.Y; i < area.Max.Y; i++ {
+ b.TouchLine(area.Min.X, i, area.Max.X-area.Min.X)
+ b.TouchLine(area.Min.X, i-n, area.Max.X-area.Min.X)
+ }
+}
+
+// DeleteLine deletes n lines at the given line position, with the given
+// optional cell, within the specified rectangles. If no rectangles are
+// specified, it deletes lines in the entire buffer.
+func (b *RenderBuffer) DeleteLine(y, n int, c *Cell) {
+ b.DeleteLineArea(y, n, c, b.Bounds())
+}
+
+// DeleteLineArea deletes lines at the given line position, with the given
+// optional cell, within the rectangle bounds. Only cells within the
+// rectangle's bounds are affected. Lines are shifted up within the bounds and
+// new blank lines are created at the bottom. This follows terminal [ansi.DL]
+// behavior.
+func (b *RenderBuffer) DeleteLineArea(y, n int, c *Cell, area Rectangle) {
+ b.Buffer.DeleteLineArea(y, n, c, area)
+ for i := area.Min.Y; i < area.Max.Y; i++ {
+ b.TouchLine(area.Min.X, i, area.Max.X-area.Min.X)
+ b.TouchLine(area.Min.X, i+n, area.Max.X-area.Min.X)
+ }
+}
+
+// InsertCell inserts new cells at the given position, with the given optional
+// cell, within the specified rectangles. If no rectangles are specified, it
+// inserts cells in the entire buffer. This follows terminal [ansi.ICH]
+// behavior.
+func (b *RenderBuffer) InsertCell(x, y, n int, c *Cell) {
+ b.InsertCellArea(x, y, n, c, b.Bounds())
+}
+
+// InsertCellArea inserts new cells at the given position, with the given
+// optional cell, within the rectangle bounds. Only cells within the
+// rectangle's bounds are affected, following terminal [ansi.ICH] behavior.
+func (b *RenderBuffer) InsertCellArea(x, y, n int, c *Cell, area Rectangle) {
+ b.Buffer.InsertCellArea(x, y, n, c, area)
+ if x+n > area.Max.X {
+ n = area.Max.X - x
+ }
+ b.TouchLine(x, y, n)
+}
+
+// DeleteCell deletes cells at the given position, with the given optional
+// cell, within the specified rectangles. If no rectangles are specified, it
+// deletes cells in the entire buffer. This follows terminal [ansi.DCH]
+// behavior.
+func (b *RenderBuffer) DeleteCell(x, y, n int, c *Cell) {
+ b.DeleteCellArea(x, y, n, c, b.Bounds())
+}
+
+// DeleteCellArea deletes cells at the given position, with the given
+// optional cell, within the rectangle bounds. Only cells within the
+// rectangle's bounds are affected, following terminal [ansi.DCH] behavior.
+func (b *RenderBuffer) DeleteCellArea(x, y, n int, c *Cell, area Rectangle) {
+ b.Buffer.DeleteCellArea(x, y, n, c, area)
+ remainingCells := area.Max.X - x
+ if n > remainingCells {
+ n = remainingCells
+ }
+ b.TouchLine(x, y, n)
+}
+
+// Clear clears the buffer with space cells and marks all lines as touched.
+func (b *RenderBuffer) Clear() {
+ b.Buffer.Clear()
+ w := b.Width()
+ for y := range b.Lines {
+ b.TouchLine(0, y, w)
+ }
+}
+
+// ClearArea clears the buffer with space cells within the specified rectangle
+// and marks the affected lines as touched.
+func (b *RenderBuffer) ClearArea(area Rectangle) {
+ b.Buffer.ClearArea(area)
+ w := area.Max.X - area.Min.X
+ for y := area.Min.Y; y < area.Max.Y; y++ {
+ b.TouchLine(area.Min.X, y, w)
+ }
+}
+
+// Fill fills the buffer with the given cell and marks all lines as touched.
+func (b *RenderBuffer) Fill(c *Cell) {
+ b.FillArea(c, b.Bounds())
+}
+
+// FillArea fills the buffer with the given cell within the specified rectangle
+// and marks the affected lines as touched.
+func (b *RenderBuffer) FillArea(c *Cell, area Rectangle) {
+ b.Buffer.FillArea(c, area)
+ w := area.Max.X - area.Min.X
+ for y := area.Min.Y; y < area.Max.Y; y++ {
+ b.TouchLine(area.Min.X, y, w)
+ }
+}
diff --git a/vendor/github.com/charmbracelet/ultraviolet/cancelreader_other.go b/vendor/github.com/charmbracelet/ultraviolet/cancelreader_other.go
new file mode 100644
index 0000000000..3fb3c95ced
--- /dev/null
+++ b/vendor/github.com/charmbracelet/ultraviolet/cancelreader_other.go
@@ -0,0 +1,16 @@
+//go:build !windows
+// +build !windows
+
+package uv
+
+import (
+ "io"
+
+ "github.com/muesli/cancelreader"
+)
+
+// NewCancelReader creates a new [cancelreader.CancelReader] that provides a
+// cancelable reader interface that can be used to cancel reads.
+func NewCancelReader(r io.Reader) (cancelreader.CancelReader, error) {
+ return cancelreader.NewReader(r) //nolint:wrapcheck
+}
diff --git a/vendor/github.com/charmbracelet/ultraviolet/cancelreader_windows.go b/vendor/github.com/charmbracelet/ultraviolet/cancelreader_windows.go
new file mode 100644
index 0000000000..fdc2db584d
--- /dev/null
+++ b/vendor/github.com/charmbracelet/ultraviolet/cancelreader_windows.go
@@ -0,0 +1,139 @@
+//go:build windows
+// +build windows
+
+package uv
+
+import (
+ "fmt"
+ "io"
+ "os"
+ "sync"
+
+ xwindows "github.com/charmbracelet/x/windows"
+ "github.com/muesli/cancelreader"
+ "golang.org/x/sys/windows"
+)
+
+type conInputReader struct {
+ cancelMixin
+ conin windows.Handle
+ originalMode uint32
+ newMode uint32
+}
+
+var _ cancelreader.CancelReader = &conInputReader{}
+
+// NewCancelReader creates a new [cancelreader.CancelReader] that provides a
+// cancelable reader interface that can be used to cancel reads.
+func NewCancelReader(r io.Reader) (cancelreader.CancelReader, error) {
+ fallback := func(io.Reader) (cancelreader.CancelReader, error) {
+ return cancelreader.NewReader(r)
+ }
+
+ var dummy uint32
+ if f, ok := r.(cancelreader.File); !ok || f.Fd() != os.Stdin.Fd() ||
+ // If data was piped to the standard input, it does not emit events
+ // anymore. We can detect this if the console mode cannot be set anymore,
+ // in this case, we fallback to the default cancelreader implementation.
+ windows.GetConsoleMode(windows.Handle(f.Fd()), &dummy) != nil {
+ return fallback(r)
+ }
+
+ conin, err := windows.GetStdHandle(windows.STD_INPUT_HANDLE)
+ if err != nil {
+ return fallback(r)
+ }
+
+ // Discard any pending input events.
+ if err := xwindows.FlushConsoleInputBuffer(conin); err != nil {
+ return fallback(r)
+ }
+
+ modes := []uint32{
+ windows.ENABLE_VIRTUAL_TERMINAL_INPUT,
+ windows.ENABLE_WINDOW_INPUT,
+ windows.ENABLE_EXTENDED_FLAGS,
+ }
+
+ originalMode, newMode, err := prepareConsole(conin, modes...)
+ if err != nil {
+ return nil, fmt.Errorf("failed to prepare console input: %w", err)
+ }
+
+ return &conInputReader{
+ conin: conin,
+ originalMode: originalMode,
+ newMode: newMode,
+ }, nil
+}
+
+// Cancel implements cancelreader.CancelReader.
+func (r *conInputReader) Cancel() bool {
+ r.setCanceled()
+
+ return windows.CancelIoEx(r.conin, nil) == nil || windows.CancelIo(r.conin) == nil
+}
+
+// Close implements cancelreader.CancelReader.
+func (r *conInputReader) Close() error {
+ if r.originalMode != 0 {
+ err := windows.SetConsoleMode(r.conin, r.originalMode)
+ if err != nil {
+ return fmt.Errorf("reset console mode: %w", err)
+ }
+ }
+
+ return nil
+}
+
+// Read implements cancelreader.CancelReader.
+func (r *conInputReader) Read(data []byte) (int, error) {
+ if r.isCanceled() {
+ return 0, cancelreader.ErrCanceled
+ }
+
+ var n uint32
+ if err := windows.ReadFile(r.conin, data, &n, nil); err != nil {
+ return int(n), fmt.Errorf("read console input: %w", err)
+ }
+
+ return int(n), nil
+}
+
+func prepareConsole(input windows.Handle, modes ...uint32) (originalMode, newMode uint32, err error) {
+ err = windows.GetConsoleMode(input, &originalMode)
+ if err != nil {
+ return 0, 0, fmt.Errorf("get console mode: %w", err)
+ }
+
+ for _, mode := range modes {
+ newMode |= mode
+ }
+
+ err = windows.SetConsoleMode(input, newMode)
+ if err != nil {
+ return 0, 0, fmt.Errorf("set console mode: %w", err)
+ }
+
+ return originalMode, newMode, nil
+}
+
+// cancelMixin represents a goroutine-safe cancelation status.
+type cancelMixin struct {
+ unsafeCanceled bool
+ lock sync.Mutex
+}
+
+func (c *cancelMixin) setCanceled() {
+ c.lock.Lock()
+ defer c.lock.Unlock()
+
+ c.unsafeCanceled = true
+}
+
+func (c *cancelMixin) isCanceled() bool {
+ c.lock.Lock()
+ defer c.lock.Unlock()
+
+ return c.unsafeCanceled
+}
diff --git a/vendor/github.com/charmbracelet/ultraviolet/cell.go b/vendor/github.com/charmbracelet/ultraviolet/cell.go
new file mode 100644
index 0000000000..a5d9e823c6
--- /dev/null
+++ b/vendor/github.com/charmbracelet/ultraviolet/cell.go
@@ -0,0 +1,465 @@
+package uv
+
+import (
+ "image/color"
+ "strings"
+
+ "github.com/charmbracelet/colorprofile"
+ "github.com/charmbracelet/x/ansi"
+)
+
+// EmptyCell is a cell with a single space, width of 1, and no style or link.
+var EmptyCell = Cell{Content: " ", Width: 1}
+
+// Cell represents a single cell in the terminal screen.
+type Cell struct {
+ // Content is the [Cell]'s content, which consists of a single grapheme
+ // cluster. Most of the time, this will be a single rune as well, but it
+ // can also be a combination of runes that form a grapheme cluster.
+ Content string
+
+ // The style of the cell. Nil style means no style. Zero value prints a
+ // reset sequence.
+ Style Style
+
+ // Link is the hyperlink of the cell.
+ Link Link
+
+ // Width is the mono-spaced width of the grapheme cluster.
+ Width int
+}
+
+// NewCell creates a new cell from the given string grapheme. It will only use
+// the first grapheme in the string and ignore the rest. The width of the cell
+// is determined using the given width method.
+func NewCell(method WidthMethod, gr string) *Cell {
+ if len(gr) == 0 {
+ return &Cell{}
+ }
+ if gr == " " {
+ return EmptyCell.Clone()
+ }
+ return &Cell{
+ Content: gr,
+ Width: method.StringWidth(gr),
+ }
+}
+
+// String returns the string content of the cell excluding any styles, links,
+// and escape sequences.
+func (c *Cell) String() string {
+ return c.Content
+}
+
+// Equal returns whether the cell is equal to the other cell.
+func (c *Cell) Equal(o *Cell) bool {
+ return o != nil &&
+ c.Width == o.Width &&
+ c.Content == o.Content &&
+ c.Style.Equal(&o.Style) &&
+ c.Link.Equal(&o.Link)
+}
+
+// IsZero returns whether the cell is an empty cell.
+func (c *Cell) IsZero() bool {
+ return *c == Cell{}
+}
+
+// isWidePlaceholder reports whether the cell is the continuation column of a
+// wide cell, marked with a zero display width.
+func (c *Cell) isWidePlaceholder() bool {
+ return c != nil && c.Width == 0
+}
+
+// Clone returns a copy of the cell.
+func (c *Cell) Clone() (n *Cell) {
+ n = new(Cell)
+ *n = *c
+ return
+}
+
+// Empty makes the cell an empty cell by setting its content to a single space
+// and width to 1.
+func (c *Cell) Empty() {
+ c.Content = " "
+ c.Width = 1
+}
+
+// NewLink creates a new hyperlink with the given URL and parameters.
+func NewLink(url string, params ...string) Link {
+ return Link{
+ URL: url,
+ Params: strings.Join(params, ":"),
+ }
+}
+
+// Link represents a hyperlink in the terminal screen.
+type Link struct {
+ URL string
+ Params string
+}
+
+// String returns a string representation of the hyperlink.
+func (h *Link) String() string {
+ return h.URL
+}
+
+// Equal returns whether the hyperlink is equal to the other hyperlink.
+func (h *Link) Equal(o *Link) bool {
+ return o != nil && *h == *o
+}
+
+// IsZero returns whether the hyperlink is empty.
+func (h *Link) IsZero() bool {
+ return *h == Link{}
+}
+
+// These are the available text attributes that can be combined to create
+// different styles.
+const (
+ AttrBold = 1 << iota
+ AttrFaint
+ AttrItalic
+ AttrBlink
+ AttrRapidBlink // Not widely supported
+ AttrReverse
+ AttrConceal
+ AttrStrikethrough
+
+ AttrReset = 0
+)
+
+// AttrSlowBlink is an alias for AttrBlink.
+//
+// Deprecated: Use [AttrBlink] instead.
+const (
+ AttrSlowBlink = AttrBlink
+)
+
+// Underline is the style of underline to use for text.
+type Underline = ansi.Underline
+
+// UnderlineStyle is the style of underline to use for text.
+//
+// Deprecated: Use [Underline] instead.
+type UnderlineStyle = ansi.Underline
+
+// These are the available underline styles.
+const (
+ UnderlineNone = ansi.UnderlineNone
+ UnderlineSingle = ansi.UnderlineSingle
+ UnderlineDouble = ansi.UnderlineDouble
+ UnderlineCurly = ansi.UnderlineCurly
+ UnderlineDotted = ansi.UnderlineDotted
+ UnderlineDashed = ansi.UnderlineDashed
+)
+
+// These are the available underline styles.
+//
+// Deprecated: Use the constants from [Underline] instead.
+const (
+ UnderlineStyleNone = ansi.UnderlineNone
+ UnderlineStyleSingle = ansi.UnderlineSingle
+ UnderlineStyleDouble = ansi.UnderlineDouble
+ UnderlineStyleCurly = ansi.UnderlineCurly
+ UnderlineStyleDotted = ansi.UnderlineDotted
+ UnderlineStyleDashed = ansi.UnderlineDashed
+)
+
+// Style represents the style of a cell.
+type Style struct {
+ Fg color.Color
+ Bg color.Color
+ UnderlineColor color.Color
+ Underline Underline
+ Attrs uint8
+}
+
+// Equal returns true if the style is equal to the other style.
+func (s *Style) Equal(o *Style) bool {
+ return s.Attrs == o.Attrs &&
+ s.Underline == o.Underline &&
+ colorEqual(s.Fg, o.Fg) &&
+ colorEqual(s.Bg, o.Bg) &&
+ colorEqual(s.UnderlineColor, o.UnderlineColor)
+}
+
+// Styled wraps the given string with the style's ANSI sequences and resets.
+func (s *Style) Styled(str string) string {
+ if s.IsZero() {
+ return str
+ }
+ return s.String() + str + ansi.ResetStyle
+}
+
+// String returns the ANSI SGR sequence for the style.
+func (s *Style) String() string {
+ if s.IsZero() {
+ return ansi.ResetStyle
+ }
+
+ var b ansi.Style
+
+ if s.Attrs != 0 { //nolint:nestif
+ if s.Attrs&AttrBold != 0 {
+ b = b.Bold()
+ }
+ if s.Attrs&AttrFaint != 0 {
+ b = b.Faint()
+ }
+ if s.Attrs&AttrItalic != 0 {
+ b = b.Italic(true)
+ }
+ if s.Attrs&AttrBlink != 0 {
+ b = b.Blink(true)
+ }
+ if s.Attrs&AttrRapidBlink != 0 {
+ b = b.RapidBlink(true)
+ }
+ if s.Attrs&AttrReverse != 0 {
+ b = b.Reverse(true)
+ }
+ if s.Attrs&AttrConceal != 0 {
+ b = b.Conceal(true)
+ }
+ if s.Attrs&AttrStrikethrough != 0 {
+ b = b.Strikethrough(true)
+ }
+ }
+ if s.Underline != UnderlineStyleNone {
+ switch s.Underline {
+ case UnderlineStyleSingle:
+ b = b.Underline(true)
+ case UnderlineStyleDouble:
+ b = b.UnderlineStyle(UnderlineStyleDouble)
+ case UnderlineStyleCurly:
+ b = b.UnderlineStyle(UnderlineStyleCurly)
+ case UnderlineStyleDotted:
+ b = b.UnderlineStyle(UnderlineStyleDotted)
+ case UnderlineStyleDashed:
+ b = b.UnderlineStyle(UnderlineStyleDashed)
+ }
+ }
+ if s.Fg != nil {
+ b = b.ForegroundColor(s.Fg)
+ }
+ if s.Bg != nil {
+ b = b.BackgroundColor(s.Bg)
+ }
+ if s.UnderlineColor != nil {
+ b = b.UnderlineColor(s.UnderlineColor)
+ }
+
+ return b.String()
+}
+
+// Diff returns the ANSI sequence that sets the style as a diff from
+// another style.
+func (s *Style) Diff(from *Style) string {
+ return StyleDiff(from, s)
+}
+
+// StyleDiff returns the SGR ANSI sequence necessary to transition from the
+// "from" style to the "to" style.
+func StyleDiff(from, to *Style) string {
+ if from == nil && to == nil {
+ return ""
+ }
+ if from != nil && to != nil && from.Equal(to) {
+ return ""
+ }
+ if from == nil {
+ return to.String()
+ }
+ if to == nil || to.IsZero() {
+ // Resetting all styles is cheaper than calculating diffs.
+ // "\x1b[m" is 3 bytes vs potentially much longer sequences.
+ return ansi.ResetStyle
+ }
+
+ // TODO: Optimize further by checking if a full reset is cheaper than
+ // calculating diffs. Often, it might be cheaper to reset everything and
+ // then set the desired styles rather than calculating diffs. Also more
+ // compatible with terminals that have buggy SGR implementations.
+
+ var b ansi.Style
+
+ if !colorEqual(from.Fg, to.Fg) {
+ b = b.ForegroundColor(to.Fg)
+ }
+
+ if !colorEqual(from.Bg, to.Bg) {
+ b = b.BackgroundColor(to.Bg)
+ }
+
+ if !colorEqual(from.UnderlineColor, to.UnderlineColor) {
+ // TODO: Investigate this. For backward compatibility, we might want to
+ // set this at the end instead. Because on terminals that don't support
+ // underline color, this might mess up some other attributes if set in
+ // the middle.
+ b = b.UnderlineColor(to.UnderlineColor)
+ }
+
+ fromBold := from.Attrs&AttrBold != 0
+ fromFaint := from.Attrs&AttrFaint != 0
+ fromItalic := from.Attrs&AttrItalic != 0
+ fromUnderline := from.Underline != UnderlineStyleNone
+ fromBlink := from.Attrs&AttrBlink != 0
+ fromRapidBlink := from.Attrs&AttrRapidBlink != 0
+ fromReverse := from.Attrs&AttrReverse != 0
+ fromConceal := from.Attrs&AttrConceal != 0
+ fromStrikethrough := from.Attrs&AttrStrikethrough != 0
+ toBold := to.Attrs&AttrBold != 0
+ toFaint := to.Attrs&AttrFaint != 0
+ toItalic := to.Attrs&AttrItalic != 0
+ toUnderline := to.Underline != UnderlineStyleNone
+ toBlink := to.Attrs&AttrBlink != 0
+ toRapidBlink := to.Attrs&AttrRapidBlink != 0
+ toReverse := to.Attrs&AttrReverse != 0
+ toConceal := to.Attrs&AttrConceal != 0
+ toStrikethrough := to.Attrs&AttrStrikethrough != 0
+
+ // We perform the resets first since they are single attributes and
+ // shouldn't interfere with others being set.
+
+ boldChanged := fromBold != toBold
+ faintChanged := fromFaint != toFaint
+ if boldChanged || faintChanged {
+ if fromBold && !toBold || fromFaint && !toFaint {
+ b = b.Normal()
+ boldChanged = true
+ faintChanged = true
+ }
+ }
+
+ italicChanged := fromItalic != toItalic
+ if italicChanged && !toItalic {
+ b = b.Italic(false)
+ }
+
+ underlineChanged := fromUnderline != toUnderline || from.Underline != to.Underline
+ if underlineChanged && !toUnderline {
+ b = b.Underline(false)
+ }
+
+ blinkChanged := fromBlink != toBlink
+ rapidBlinkChanged := fromRapidBlink != toRapidBlink
+ if blinkChanged || rapidBlinkChanged {
+ if fromBlink && !toBlink || fromRapidBlink && !toRapidBlink {
+ b = b.Blink(false)
+ blinkChanged = true
+ rapidBlinkChanged = true
+ }
+ }
+
+ reverseChanged := fromReverse != toReverse
+ if reverseChanged && !toReverse {
+ b = b.Reverse(false)
+ }
+
+ concealChanged := fromConceal != toConceal
+ if concealChanged && !toConceal {
+ b = b.Conceal(false)
+ }
+
+ strikethroughChanged := fromStrikethrough != toStrikethrough
+ if strikethroughChanged && !toStrikethrough {
+ b = b.Strikethrough(false)
+ }
+
+ if boldChanged && toBold {
+ b = b.Bold()
+ }
+
+ if faintChanged && toFaint {
+ b = b.Faint()
+ }
+
+ if italicChanged && toItalic {
+ b = b.Italic(true)
+ }
+
+ if underlineChanged && toUnderline && to.Underline == UnderlineStyleSingle {
+ // We only handle single underline here since others require more
+ // specific handling at the end.
+ b = b.Underline(true)
+ }
+
+ if blinkChanged && toBlink {
+ b = b.Blink(true)
+ }
+
+ if rapidBlinkChanged && toRapidBlink {
+ b = b.RapidBlink(true)
+ }
+
+ if reverseChanged && toReverse {
+ b = b.Reverse(true)
+ }
+
+ if concealChanged && toConceal {
+ b = b.Conceal(true)
+ }
+
+ if strikethroughChanged && toStrikethrough {
+ b = b.Strikethrough(true)
+ }
+
+ // Handle special underline styles.
+ if underlineChanged && toUnderline && to.Underline > UnderlineStyleSingle {
+ b = b.UnderlineStyle(to.Underline)
+ }
+
+ return b.String()
+}
+
+func colorEqual(c, o color.Color) bool {
+ if c == nil && o == nil {
+ return true
+ }
+ if c == nil || o == nil {
+ return false
+ }
+ cr, cg, cb, ca := c.RGBA()
+ or, og, ob, oa := o.RGBA()
+ return cr == or && cg == og && cb == ob && ca == oa
+}
+
+// IsZero returns true if the style is empty.
+func (s *Style) IsZero() bool {
+ return *s == Style{}
+}
+
+// ConvertStyle converts a style to respect the given color profile.
+func ConvertStyle(s Style, p colorprofile.Profile) Style {
+ switch p {
+ case colorprofile.TrueColor:
+ return s
+ case colorprofile.ANSI, colorprofile.ANSI256:
+ case colorprofile.Ascii:
+ s.Fg = nil
+ s.Bg = nil
+ s.UnderlineColor = nil
+ case colorprofile.NoTTY:
+ return Style{}
+ }
+
+ if s.Fg != nil {
+ s.Fg = p.Convert(s.Fg)
+ }
+ if s.Bg != nil {
+ s.Bg = p.Convert(s.Bg)
+ }
+ if s.UnderlineColor != nil {
+ s.UnderlineColor = p.Convert(s.UnderlineColor)
+ }
+ return s
+}
+
+// ConvertLink converts a hyperlink to respect the given color profile.
+func ConvertLink(h Link, p colorprofile.Profile) Link {
+ if p == colorprofile.NoTTY {
+ return Link{}
+ }
+ return h
+}
diff --git a/vendor/github.com/charmbracelet/ultraviolet/console.go b/vendor/github.com/charmbracelet/ultraviolet/console.go
new file mode 100644
index 0000000000..7ef37fd606
--- /dev/null
+++ b/vendor/github.com/charmbracelet/ultraviolet/console.go
@@ -0,0 +1,219 @@
+package uv
+
+import (
+ "io"
+ "os"
+ "runtime"
+
+ "github.com/charmbracelet/x/term"
+)
+
+var isWindows = runtime.GOOS == "windows"
+
+// File is an interface that represents a file with a file descriptor.
+//
+// This is typically an [os.File] like [os.Stdin] and [os.Stdout].
+type File interface {
+ io.ReadWriteCloser
+ term.File
+
+ // Name returns the name of the file.
+ Name() string
+}
+
+// Winsize represents the size of a terminal in cells and pixels.
+//
+// This is the same as [unix.Winsize], but defined here for cross-platform compatibility.
+type Winsize struct {
+ Row uint16
+ Col uint16
+ Xpixel uint16
+ Ypixel uint16
+}
+
+// Console represents a cross-platform console I/O interface.
+type Console interface {
+ io.ReadWriteCloser
+
+ // Environ returns the console's environment variables.
+ Environ() []string
+
+ // Getenv retrieves the value of the environment variable named by the key.
+ Getenv(key string) string
+
+ // LookupEnv retrieves the value of the environment variable named by the key
+ // and a boolean indicating whether the variable is present.
+ LookupEnv(key string) (string, bool)
+
+ // Reader returns the input reader of the console.
+ Reader() io.Reader
+
+ // Writer returns the output writer of the console.
+ Writer() io.Writer
+
+ // MakeRaw puts the console input side into raw mode.
+ MakeRaw() (state *term.State, err error)
+
+ // Restore restores the console to its previous state.
+ Restore() error
+
+ // GetSize returns the current size of the console.
+ GetSize() (width, height int, err error)
+
+ // GetWinsize returns the current size of the console in cells and pixels.
+ GetWinsize() (*Winsize, error)
+}
+
+// TTY represents a Unix TTY device. It implements the [Console] interface.
+type TTY struct {
+ *console
+}
+
+var _ Console = (*TTY)(nil)
+
+// WinCon represents a Windows Console. It implements the [Console] interface.
+type WinCon struct {
+ *console
+}
+
+var _ Console = (*WinCon)(nil)
+
+// Console is a cross-platform console I/O.
+type console struct {
+ input File
+ inputState *term.State
+ output File
+ outputState *term.State
+ environ Environ
+}
+
+// DefaultConsole returns a new default console instance that uses standard I/O
+// [os.Stdin], [os.Stdout], and [os.Environ].
+//
+// To use [os.Stderr] as the output, you can create a new console with
+// [NewConsole] and pass [os.Stderr] as the output parameter.
+func DefaultConsole() Console {
+ return NewConsole(os.Stdin, os.Stdout, os.Environ())
+}
+
+// ControllingConsole returns a new console instance that uses the current
+// controlling terminal's input and output file descriptors.
+func ControllingConsole() (Console, error) {
+ inTty, outTty, err := OpenTTY()
+ if err != nil {
+ return nil, err
+ }
+ return NewConsole(inTty, outTty, os.Environ()), nil
+}
+
+// NewConsole creates a new [Console] with the given input, output, and
+// environment variables.
+//
+// You can use [OpenTTY] to open the current controlling console files and pass
+// them to this function. Use [ControllingConsole] for a convenience function
+// that does this for you.
+//
+// Use this to create a new terminal for PTY processes by passing the PTY slave
+// file as the input and output and any environment variables the process
+// needs.
+func NewConsole(input, output File, environ []string) Console {
+ if input == nil {
+ input = os.Stdin
+ }
+ if output == nil {
+ output = os.Stdout
+ }
+ if environ == nil {
+ environ = os.Environ()
+ }
+ return newConsole(input, output, environ)
+}
+
+// Environ returns the console's environment variables.
+func (t *console) Environ() []string {
+ return t.environ
+}
+
+// Writer returns the output writer of the console.
+func (t *console) Writer() io.Writer {
+ return t.output
+}
+
+// Reader returns the input reader of the console.
+func (t *console) Reader() io.Reader {
+ return t.input
+}
+
+// Write writes data to the console's output.
+func (t *console) Write(p []byte) (n int, err error) {
+ return t.output.Write(p)
+}
+
+// Read reads data from the console's input.
+func (t *console) Read(p []byte) (n int, err error) {
+ return t.input.Read(p)
+}
+
+// Getenv retrieves the value of the environment variable named by the key.
+func (t *console) Getenv(key string) string {
+ return t.environ.Getenv(key)
+}
+
+// LookupEnv retrieves the value of the environment variable named by the key
+// and a boolean indicating whether the variable is present.
+func (t *console) LookupEnv(key string) (string, bool) {
+ return t.environ.LookupEnv(key)
+}
+
+// MakeRaw puts the console input side into raw mode.
+func (t *console) MakeRaw() (state *term.State, err error) {
+ inState, outState, err := makeRaw(t.input, t.output)
+ if err != nil {
+ return nil, err
+ }
+ t.inputState = inState
+ t.outputState = outState
+ if inState != nil {
+ return inState, nil
+ }
+ return outState, nil
+}
+
+// Restore restores the console to its previous state.
+func (t *console) Restore() error {
+ if t.inputState != nil {
+ if err := term.Restore(t.input.Fd(), t.inputState); err != nil {
+ return err
+ }
+ t.inputState = nil
+ }
+ if t.outputState != nil {
+ if err := term.Restore(t.output.Fd(), t.outputState); err != nil {
+ return err
+ }
+ t.outputState = nil
+ }
+ return nil
+}
+
+// Close restores the console to its previous state and releases resources.
+func (t *console) Close() error {
+ if err := t.Restore(); err != nil {
+ return err
+ }
+ return nil
+}
+
+// GetSize returns the current size of the console.
+func (t *console) GetSize() (width, height int, err error) {
+ return getSize(t.input, t.output)
+}
+
+// GetWinsize returns the current size of the console in cells and pixels.
+func (t *console) GetWinsize() (*Winsize, error) {
+ ws, err := getWinsize(t.input, t.output)
+ if err != nil {
+ return nil, err
+ }
+ return &ws, nil
+}
diff --git a/vendor/github.com/charmbracelet/ultraviolet/console_unix.go b/vendor/github.com/charmbracelet/ultraviolet/console_unix.go
new file mode 100644
index 0000000000..5460effff9
--- /dev/null
+++ b/vendor/github.com/charmbracelet/ultraviolet/console_unix.go
@@ -0,0 +1,13 @@
+//go:build !windows
+// +build !windows
+
+package uv
+
+func newConsole(in File, out File, env Environ) *TTY {
+ c := &console{
+ input: in,
+ output: out,
+ environ: env,
+ }
+ return &TTY{console: c}
+}
diff --git a/vendor/github.com/charmbracelet/ultraviolet/console_windows.go b/vendor/github.com/charmbracelet/ultraviolet/console_windows.go
new file mode 100644
index 0000000000..0836f1c38c
--- /dev/null
+++ b/vendor/github.com/charmbracelet/ultraviolet/console_windows.go
@@ -0,0 +1,13 @@
+//go:build windows
+// +build windows
+
+package uv
+
+func newConsole(in File, out File, env Environ) *WinCon {
+ c := &console{
+ input: in,
+ output: out,
+ environ: env,
+ }
+ return &WinCon{console: c}
+}
diff --git a/vendor/github.com/charmbracelet/ultraviolet/cursor.go b/vendor/github.com/charmbracelet/ultraviolet/cursor.go
new file mode 100644
index 0000000000..33a3843a8a
--- /dev/null
+++ b/vendor/github.com/charmbracelet/ultraviolet/cursor.go
@@ -0,0 +1,22 @@
+package uv
+
+// CursorShape represents a terminal cursor shape.
+type CursorShape int
+
+// Cursor shapes.
+const (
+ CursorBlock CursorShape = iota
+ CursorUnderline
+ CursorBar
+)
+
+// Encode returns the encoded value for the cursor shape.
+func (s CursorShape) Encode(blink bool) int {
+ // We're using the ANSI escape sequence values for cursor styles.
+ // We need to map both [style] and [steady] to the correct value.
+ s = (s * 2) + 1 //nolint:mnd
+ if !blink {
+ s++
+ }
+ return int(s)
+}
diff --git a/vendor/github.com/charmbracelet/ultraviolet/decoder.go b/vendor/github.com/charmbracelet/ultraviolet/decoder.go
new file mode 100644
index 0000000000..a891dc27d3
--- /dev/null
+++ b/vendor/github.com/charmbracelet/ultraviolet/decoder.go
@@ -0,0 +1,2102 @@
+package uv
+
+import (
+ "bytes"
+ "encoding/base64"
+ "encoding/hex"
+ "fmt"
+ "image/color"
+ "math"
+ "slices"
+ "strings"
+ "unicode"
+ "unicode/utf8"
+
+ "github.com/charmbracelet/x/ansi"
+ "github.com/charmbracelet/x/ansi/parser"
+ xwindows "github.com/charmbracelet/x/windows"
+ "github.com/rivo/uniseg"
+)
+
+// Flags to control the behavior of the parser.
+const (
+ // When this flag is set, the driver will treat both Ctrl+Space and Ctrl+@
+ // as the same key sequence.
+ //
+ // Historically, the ANSI specs generate NUL (0x00) on both the Ctrl+Space
+ // and Ctrl+@ key sequences. This flag allows the driver to treat both as
+ // the same key sequence.
+ flagCtrlAt = 1 << iota
+
+ // When this flag is set, the driver will treat the Tab key and Ctrl+I as
+ // the same key sequence.
+ //
+ // Historically, the ANSI specs generate HT (0x09) on both the Tab key and
+ // Ctrl+I. This flag allows the driver to treat both as the same key
+ // sequence.
+ flagCtrlI
+
+ // When this flag is set, the driver will treat the Enter key and Ctrl+M as
+ // the same key sequence.
+ //
+ // Historically, the ANSI specs generate CR (0x0D) on both the Enter key
+ // and Ctrl+M. This flag allows the driver to treat both as the same key.
+ flagCtrlM
+
+ // When this flag is set, the driver will treat Escape and Ctrl+[ as
+ // the same key sequence.
+ //
+ // Historically, the ANSI specs generate ESC (0x1B) on both the Escape key
+ // and Ctrl+[. This flag allows the driver to treat both as the same key
+ // sequence.
+ flagCtrlOpenBracket
+
+ // When this flag is set, the driver will send a BS (0x08 byte) character
+ // instead of a DEL (0x7F byte) character when the Backspace key is
+ // pressed.
+ //
+ // The VT100 terminal has both a Backspace and a Delete key. The VT220
+ // terminal dropped the Backspace key and replaced it with the Delete key.
+ // Both terminals send a DEL character when the Delete key is pressed.
+ // Modern terminals and PCs later readded the Delete key but used a
+ // different key sequence, and the Backspace key was standardized to send a
+ // DEL character.
+ flagBackspace
+
+ // When this flag is set, the driver will recognize the Find key instead of
+ // treating it as a Home key.
+ //
+ // The Find key was part of the VT220 keyboard, and is no longer used in
+ // modern day PCs.
+ flagFind
+
+ // When this flag is set, the driver will recognize the Select key instead
+ // of treating it as a End key.
+ //
+ // The Symbol key was part of the VT220 keyboard, and is no longer used in
+ // modern day PCs.
+ flagSelect
+
+ // When this flag is set, the driver will preserve function keys (F13-F63)
+ // as symbols.
+ //
+ // Since these keys are not part of today's standard 20th century keyboard,
+ // we treat them as F1-F12 modifier keys i.e. ctrl/shift/alt + Fn combos.
+ // Key definitions come from Terminfo, this flag is only useful when
+ // FlagTerminfo is not set.
+ flagFKeys
+)
+
+// LegacyKeyEncoding is a set of flags that control the behavior of legacy
+// terminal key encodings. Historically, ctrl+ input events produce
+// control characters (0x00-0x1F) that collide with some special keys like Tab,
+// Enter, and Escape. This controls the expected behavior of encoding these
+// keys.
+//
+// This type has the following default values:
+// - CtrlAt maps 0x00 [ansi.NUL] to ctrl+space instead of ctrl+@.
+// - CtrlI maps 0x09 [ansi.HT] to the tab key instead of ctrl+i.
+// - CtrlM maps 0x0D [ansi.CR] to the enter key instead of ctrl+m.
+// - CtrlOpenBracket maps 0x1B [ansi.ESC] to the escape key instead of ctrl+[.
+// - Backspace maps the backspace key to 0x08 [ansi.BS] instead of 0x7F [ansi.DEL].
+// - Find maps the legacy find key to the home key.
+// - Select maps the legacy select key to the end key.
+// - FKeys maps high function keys instead of treating them as Function+.
+type LegacyKeyEncoding uint32
+
+// CtrlAt returns a [LegacyKeyEncoding] with whether [ansi.NUL] (0x00)
+// is mapped to ctrl+at instead of ctrl+space.
+func (l LegacyKeyEncoding) CtrlAt(v bool) LegacyKeyEncoding {
+ if v {
+ l |= flagCtrlAt
+ } else {
+ l &^= flagCtrlAt
+ }
+ return l
+}
+
+// CtrlI returns a [LegacyKeyEncoding] with whether [ansi.HT] (0x09)
+// is mapped to ctrl+i instead of the tab key.
+func (l LegacyKeyEncoding) CtrlI(v bool) LegacyKeyEncoding {
+ if v {
+ l |= flagCtrlI
+ } else {
+ l &^= flagCtrlI
+ }
+ return l
+}
+
+// CtrlM returns a [LegacyKeyEncoding] with whether [ansi.CR] (0x0D)
+// is mapped to ctrl+m instead of the enter key.
+func (l LegacyKeyEncoding) CtrlM(v bool) LegacyKeyEncoding {
+ if v {
+ l |= flagCtrlM
+ } else {
+ l &^= flagCtrlM
+ }
+ return l
+}
+
+// CtrlOpenBracket returns a [LegacyKeyEncoding] with whether [ansi.ESC] (0x1B)
+// is mapped to ctrl+[ instead of the escape key.
+func (l LegacyKeyEncoding) CtrlOpenBracket(v bool) LegacyKeyEncoding {
+ if v {
+ l |= flagCtrlOpenBracket
+ } else {
+ l &^= flagCtrlOpenBracket
+ }
+ return l
+}
+
+// Backspace returns a [LegacyKeyEncoding] with whether the backspace key is
+// mapped to [ansi.BS] (0x08) instead of [ansi.DEL] (0x7F).
+func (l LegacyKeyEncoding) Backspace(v bool) LegacyKeyEncoding {
+ if v {
+ l |= flagBackspace
+ } else {
+ l &^= flagBackspace
+ }
+ return l
+}
+
+// Find returns a [LegacyKeyEncoding] with whether the legacy find key
+// is mapped to the home key.
+func (l LegacyKeyEncoding) Find(v bool) LegacyKeyEncoding {
+ if v {
+ l |= flagFind
+ } else {
+ l &^= flagFind
+ }
+ return l
+}
+
+// Select returns a [LegacyKeyEncoding] with whether the legacy select key
+// is mapped to the end key.
+func (l LegacyKeyEncoding) Select(v bool) LegacyKeyEncoding {
+ if v {
+ l |= flagSelect
+ } else {
+ l &^= flagSelect
+ }
+ return l
+}
+
+// FKeys returns a [LegacyKeyEncoding] with whether high function keys are
+// mapped to high function keys (beyond F20) instead of treating them as
+// Function+ keys.
+func (l LegacyKeyEncoding) FKeys(v bool) LegacyKeyEncoding {
+ if v {
+ l |= flagFKeys
+ } else {
+ l &^= flagFKeys
+ }
+ return l
+}
+
+// EventDecoder decodes terminal input events from a byte buffer. Terminal
+// input events are typically encoded as Unicode or ASCII characters, control
+// codes, or ANSI escape sequences.
+type EventDecoder struct {
+ // Legacy is the legacy key encoding flags. These flags control the
+ // behavior of legacy terminal key encodings. See [LegacyKeyEncoding] for
+ // more details.
+ Legacy LegacyKeyEncoding
+ // UseTerminfo is a flag that controls whether to use the terminal type
+ // Terminfo database to map escape sequences to key events. This will
+ // override the default key sequences handled by the parser.
+ UseTerminfo bool
+
+ lastCks uint32 // the last control key state for the previous key event record.
+}
+
+// Decode finds the first recognized event sequence and returns it along
+// with its length.
+//
+// It will return zero and nil no sequence is recognized or when the buffer is
+// empty. If a sequence is not supported, an [UnknownEvent] is returned.
+//
+// Example:
+//
+// ```go
+// var decoder EventDecoder
+// var events []Event
+// buf := []byte("\x00" + // Ctrl+Space
+// "\x1b[A" + // Up arrow
+// "Hello") // Text input
+// for len(buf) > 0 {
+// n, ev := decoder.Decode(buf)
+// if ev != nil {
+// events = append(events, ev)
+// }
+// buf = buf[n:]
+// }
+// ```
+func (p *EventDecoder) Decode(buf []byte) (n int, Event Event) {
+ if len(buf) == 0 {
+ return 0, nil
+ }
+
+ switch b := buf[0]; b {
+ case ansi.ESC:
+ if len(buf) == 1 {
+ // Escape key
+ return 1, KeyPressEvent{Code: KeyEscape}
+ }
+
+ switch bPrime := buf[1]; bPrime {
+ case 'O': // Esc-prefixed SS3
+ return p.parseSs3(buf)
+ case 'P': // Esc-prefixed DCS
+ return p.parseDcs(buf)
+ case '[': // Esc-prefixed CSI
+ return p.parseCsi(buf)
+ case ']': // Esc-prefixed OSC
+ return p.parseOsc(buf)
+ case '_': // Esc-prefixed APC
+ return p.parseApc(buf)
+ case '^': // Esc-prefixed PM
+ return p.parseStTerminated(ansi.PM, '^', nil)(buf)
+ case 'X': // Esc-prefixed SOS
+ return p.parseStTerminated(ansi.SOS, 'X', nil)(buf)
+ default:
+ n, e := p.Decode(buf[1:])
+ if k, ok := e.(KeyPressEvent); ok {
+ k.Text = ""
+ k.Mod |= ModAlt
+ return n + 1, k
+ }
+
+ // Not a key sequence, nor an alt modified key sequence. In that
+ // case, just report a single escape key.
+ return 1, KeyPressEvent{Code: KeyEscape}
+ }
+ case ansi.SS3:
+ return p.parseSs3(buf)
+ case ansi.DCS:
+ return p.parseDcs(buf)
+ case ansi.CSI:
+ return p.parseCsi(buf)
+ case ansi.OSC:
+ return p.parseOsc(buf)
+ case ansi.APC:
+ return p.parseApc(buf)
+ case ansi.PM:
+ return p.parseStTerminated(ansi.PM, '^', nil)(buf)
+ case ansi.SOS:
+ return p.parseStTerminated(ansi.SOS, 'X', nil)(buf)
+ default:
+ if b <= ansi.US || b == ansi.DEL || b == ansi.SP {
+ return 1, p.parseControl(b)
+ } else if b >= ansi.PAD && b <= ansi.APC {
+ // C1 control code
+ // UTF-8 never starts with a C1 control code
+ // Encode these as Ctrl+Alt+
+ code := rune(b) - 0x40
+ return 1, KeyPressEvent{Code: code, Mod: ModCtrl | ModAlt}
+ }
+ return p.parseUtf8(buf)
+ }
+}
+
+func (p *EventDecoder) parseCsi(b []byte) (int, Event) {
+ if len(b) == 2 && b[0] == ansi.ESC {
+ // short cut if this is an alt+[ key
+ return 2, KeyPressEvent{Code: rune(b[1]), Mod: ModAlt}
+ }
+
+ var cmd ansi.Cmd
+ var params [parser.MaxParamsSize]ansi.Param
+ var paramsLen int
+
+ var i int
+ if b[i] == ansi.CSI || b[i] == ansi.ESC {
+ i++
+ }
+ if i < len(b) && b[i-1] == ansi.ESC && b[i] == '[' {
+ i++
+ }
+
+ // Initial CSI byte
+ if i < len(b) && b[i] >= '<' && b[i] <= '?' {
+ cmd |= ansi.Cmd(b[i]) << parser.PrefixShift
+ }
+
+ // Scan parameter bytes in the range 0x30-0x3F
+ var j int
+ for j = 0; i < len(b) && paramsLen < len(params) && b[i] >= 0x30 && b[i] <= 0x3F; i, j = i+1, j+1 {
+ if b[i] >= '0' && b[i] <= '9' {
+ if params[paramsLen] == parser.MissingParam {
+ params[paramsLen] = 0
+ }
+ params[paramsLen] *= 10
+ params[paramsLen] += ansi.Param(b[i]) - '0'
+ }
+ if b[i] == ':' {
+ params[paramsLen] |= parser.HasMoreFlag
+ }
+ if b[i] == ';' || b[i] == ':' {
+ paramsLen++
+ if paramsLen < len(params) {
+ // Don't overflow the params slice
+ params[paramsLen] = parser.MissingParam
+ }
+ }
+ }
+
+ if j > 0 && paramsLen < len(params) {
+ // has parameters
+ paramsLen++
+ }
+
+ // Scan intermediate bytes in the range 0x20-0x2F
+ var intermed byte
+ for ; i < len(b) && b[i] >= 0x20 && b[i] <= 0x2F; i++ {
+ intermed = b[i]
+ }
+
+ // Set the intermediate byte
+ cmd |= ansi.Cmd(intermed) << parser.IntermedShift
+
+ // Scan final byte in the range 0x40-0x7E
+ if i >= len(b) || b[i] < 0x40 || b[i] > 0x7E {
+ // Special case for URxvt keys
+ // CSI $ is an invalid sequence, but URxvt uses it for
+ // shift modified keys.
+ if intermed == '$' && b[i-1] == '$' {
+ buf := slices.Clone(b[:i-1])
+ n, ev := p.parseCsi(append(buf, '~'))
+ if k, ok := ev.(KeyPressEvent); ok {
+ k.Mod |= ModShift
+ return n, k
+ }
+ }
+ return i, UnknownEvent(b[:i])
+ }
+
+ // Add the final byte
+ cmd |= ansi.Cmd(b[i])
+ i++
+
+ pa := ansi.Params(params[:paramsLen])
+ switch cmd {
+ case 'y' | '?'<'<'< R (which is modified F3) when the cursor is at the
+ // row 1. In this case, we report both messages.
+ //
+ // For a non ambiguous cursor position report, use
+ // [ansi.RequestExtendedCursorPosition] (DECXCPR) instead.
+ return i, MultiEvent{KeyPressEvent{Code: KeyF3, Mod: KeyMod(col - 1)}, m}
+ }
+
+ return i, m
+ }
+
+ if paramsLen != 0 {
+ break
+ }
+
+ // Unmodified key F3 (CSI R)
+ fallthrough
+ case 'a', 'b', 'c', 'd', 'A', 'B', 'C', 'D', 'E', 'F', 'H', 'P', 'Q', 'S', 'Z':
+ var k KeyPressEvent
+ switch cmd {
+ case 'a', 'b', 'c', 'd':
+ k = KeyPressEvent{Code: KeyUp + rune(cmd-'a'), Mod: ModShift}
+ case 'A', 'B', 'C', 'D':
+ k = KeyPressEvent{Code: KeyUp + rune(cmd-'A')}
+ case 'E':
+ k = KeyPressEvent{Code: KeyBegin}
+ case 'F':
+ k = KeyPressEvent{Code: KeyEnd}
+ case 'H':
+ k = KeyPressEvent{Code: KeyHome}
+ case 'P', 'Q', 'R', 'S':
+ k = KeyPressEvent{Code: KeyF1 + rune(cmd-'P')}
+ case 'Z':
+ k = KeyPressEvent{Code: KeyTab, Mod: ModShift}
+ }
+ id, _, _ := pa.Param(0, 1)
+ mod, _, _ := pa.Param(1, 1)
+ if paramsLen > 2 && !pa[1].HasMore() || id != 1 {
+ break
+ }
+ if paramsLen > 1 && id == 1 && mod != -1 {
+ // CSI 1 ; A
+ k.Mod |= KeyMod(mod - 1)
+ }
+ // Don't forget to handle Kitty keyboard protocol
+ return i, parseKittyKeyboardExt(pa, k)
+ case 'M':
+ // Handle X10 mouse
+ if i+3 > len(b) {
+ return i, UnknownCsiEvent(b[:i])
+ }
+ return i + 3, parseX10MouseEvent(append(b[:i], b[i:i+3]...))
+ case 'y' | '$'< 1 && mod != -1 {
+ k.Mod |= KeyMod(mod - 1)
+ }
+
+ // Handle URxvt weird keys
+ switch cmd {
+ case '~':
+ // Don't forget to handle Kitty keyboard protocol
+ return i, parseKittyKeyboardExt(pa, k)
+ case '^':
+ k.Mod |= ModCtrl
+ case '@':
+ k.Mod |= ModCtrl | ModShift
+ }
+
+ return i, k
+ }
+
+ case 't':
+ param, _, ok := pa.Param(0, 0)
+ if !ok {
+ break
+ }
+
+ switch param {
+ case 4: // Report Terminal window size in pixels.
+ if paramsLen == 3 {
+ height, _, hOk := pa.Param(1, 0)
+ width, _, wOk := pa.Param(2, 0)
+ if !hOk || !wOk {
+ break
+ }
+ return i, PixelSizeEvent{Width: width, Height: height}
+ }
+ case 6: // Report Terminal character cell size.
+ if paramsLen == 3 {
+ height, _, hOk := pa.Param(1, 0)
+ width, _, wOk := pa.Param(2, 0)
+ if !hOk || !wOk {
+ break
+ }
+ return i, CellSizeEvent{Width: width, Height: height}
+ }
+ case 8: // Report Terminal Window size in cells.
+ if paramsLen == 3 {
+ height, _, hOk := pa.Param(1, 0)
+ width, _, wOk := pa.Param(2, 0)
+ if !hOk || !wOk {
+ break
+ }
+ return i, WindowSizeEvent{Width: width, Height: height}
+ }
+ case 48: // In band terminal size report.
+ if paramsLen == 5 {
+ cellHeight, _, chOk := pa.Param(1, 0)
+ cellWidth, _, cwOk := pa.Param(2, 0)
+ pixelHeight, _, phOk := pa.Param(3, 0)
+ pixelWidth, _, pwOk := pa.Param(4, 0)
+ if !chOk || !cwOk || !phOk || !pwOk {
+ break
+ }
+ return i, MultiEvent{
+ WindowSizeEvent{Width: cellWidth, Height: cellHeight},
+ PixelSizeEvent{Width: pixelWidth, Height: pixelHeight},
+ }
+ }
+ }
+
+ // Any other window operation event.
+
+ var winop WindowOpEvent
+ winop.Op = param
+ for j := 1; j < paramsLen; j++ {
+ val, _, ok := pa.Param(j, 0)
+ if ok {
+ winop.Args = append(winop.Args, val)
+ }
+ }
+
+ return i, winop
+ }
+ return i, UnknownCsiEvent(b[:i])
+}
+
+// parseSs3 parses a SS3 sequence.
+// See https://vt100.net/docs/vt220-rm/chapter4.html#S4.4.4.2
+func (p *EventDecoder) parseSs3(b []byte) (int, Event) {
+ if len(b) == 2 && b[0] == ansi.ESC {
+ // short cut if this is an alt+O key
+ return 2, KeyPressEvent{Code: unicode.ToLower(rune(b[1])), Mod: ModShift | ModAlt}
+ }
+
+ var i int
+ if b[i] == ansi.SS3 || b[i] == ansi.ESC {
+ i++
+ }
+ if i < len(b) && b[i-1] == ansi.ESC && b[i] == 'O' {
+ i++
+ }
+
+ // Scan numbers from 0-9
+ var mod int
+ for ; i < len(b) && b[i] >= '0' && b[i] <= '9'; i++ {
+ mod *= 10
+ mod += int(b[i]) - '0'
+ }
+
+ // Scan a GL character
+ // A GL character is a single byte in the range 0x21-0x7E
+ // See https://vt100.net/docs/vt220-rm/chapter2.html#S2.3.2
+ if i >= len(b) || b[i] < 0x21 || b[i] > 0x7E {
+ return i, UnknownEvent(b[:i])
+ }
+
+ // GL character(s)
+ gl := b[i]
+ i++
+
+ var k KeyPressEvent
+ switch gl {
+ case 'a', 'b', 'c', 'd':
+ k = KeyPressEvent{Code: KeyUp + rune(gl-'a'), Mod: ModCtrl}
+ case 'A', 'B', 'C', 'D':
+ k = KeyPressEvent{Code: KeyUp + rune(gl-'A')}
+ case 'E':
+ k = KeyPressEvent{Code: KeyBegin}
+ case 'F':
+ k = KeyPressEvent{Code: KeyEnd}
+ case 'H':
+ k = KeyPressEvent{Code: KeyHome}
+ case 'P', 'Q', 'R', 'S':
+ k = KeyPressEvent{Code: KeyF1 + rune(gl-'P')}
+ case 'M':
+ k = KeyPressEvent{Code: KeyKpEnter}
+ case 'X':
+ k = KeyPressEvent{Code: KeyKpEqual}
+ case 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y':
+ k = KeyPressEvent{Code: KeyKpMultiply + rune(gl-'j')}
+ default:
+ return i, UnknownSs3Event(b[:i])
+ }
+
+ // Handle weird SS3 Func
+ if mod > 0 {
+ k.Mod |= KeyMod(mod - 1)
+ }
+
+ return i, k
+}
+
+func (p *EventDecoder) parseOsc(b []byte) (int, Event) {
+ defaultKey := func() KeyPressEvent {
+ return KeyPressEvent{Code: rune(b[1]), Mod: ModAlt}
+ }
+ if len(b) == 2 && b[0] == ansi.ESC {
+ // short cut if this is an alt+] key
+ return 2, defaultKey()
+ }
+
+ var i int
+ if b[i] == ansi.OSC || b[i] == ansi.ESC {
+ i++
+ }
+ if i < len(b) && b[i-1] == ansi.ESC && b[i] == ']' {
+ i++
+ }
+
+ // Parse OSC command
+ // An OSC sequence is terminated by a BEL, ESC, or ST character
+ var start, end int
+ cmd := -1
+ for ; i < len(b) && b[i] >= '0' && b[i] <= '9'; i++ {
+ if cmd == -1 {
+ cmd = 0
+ } else {
+ cmd *= 10
+ }
+ cmd += int(b[i]) - '0'
+ }
+
+ if i < len(b) && b[i] == ';' {
+ // mark the start of the sequence data
+ i++
+ start = i
+ }
+
+ for ; i < len(b); i++ {
+ // advance to the end of the sequence
+ if slices.Contains([]byte{ansi.BEL, ansi.ESC, ansi.ST, ansi.CAN, ansi.SUB}, b[i]) {
+ break
+ }
+ }
+
+ if i >= len(b) {
+ return i, UnknownEvent(b[:i])
+ }
+
+ end = i // end of the sequence data
+ i++
+
+ // Check 7-bit ST (string terminator) character
+ switch b[i-1] {
+ case ansi.CAN, ansi.SUB:
+ return i, ignoredEvent(b[:i])
+ case ansi.ESC:
+ if i >= len(b) || b[i] != '\\' {
+ if cmd == -1 || (start == 0 && end == 2) {
+ return 2, defaultKey()
+ }
+
+ // If we don't have a valid ST terminator, then this is a
+ // cancelled sequence and should be ignored.
+ return i, ignoredEvent(b[:i])
+ }
+
+ i++
+ }
+
+ if end <= start {
+ return i, UnknownEvent(b[:i])
+ }
+
+ data := string(b[start:end])
+ switch cmd {
+ case 10:
+ return i, ForegroundColorEvent{ansi.XParseColor(data)}
+ case 11:
+ return i, BackgroundColorEvent{ansi.XParseColor(data)}
+ case 12:
+ return i, CursorColorEvent{ansi.XParseColor(data)}
+ case 52:
+ parts := strings.Split(data, ";")
+ if len(parts) != 2 || len(parts[0]) < 1 {
+ return i, ClipboardEvent{}
+ }
+
+ b64 := parts[1]
+ bts, err := base64.StdEncoding.DecodeString(b64)
+ if err != nil {
+ return i, ClipboardEvent{Content: parts[1]}
+ }
+
+ sel := ClipboardSelection(parts[0][0]) //nolint:unconvert
+ return i, ClipboardEvent{Selection: sel, Content: string(bts)}
+ }
+
+ return i, UnknownOscEvent(b[:i])
+}
+
+// parseStTerminated parses a control sequence that gets terminated by a ST character.
+func (p *EventDecoder) parseStTerminated(intro8, intro7 byte, fn func([]byte) Event) func([]byte) (int, Event) {
+ defaultKey := func(b []byte) (int, Event) {
+ switch intro8 {
+ case ansi.SOS:
+ return 2, KeyPressEvent{Code: unicode.ToLower(rune(b[1])), Mod: ModShift | ModAlt}
+ case ansi.PM, ansi.APC:
+ return 2, KeyPressEvent{Code: rune(b[1]), Mod: ModAlt}
+ }
+ return 0, nil
+ }
+ return func(b []byte) (int, Event) {
+ if len(b) == 2 && b[0] == ansi.ESC {
+ return defaultKey(b)
+ }
+
+ var i int
+ if b[i] == intro8 || b[i] == ansi.ESC {
+ i++
+ }
+ if i < len(b) && b[i-1] == ansi.ESC && b[i] == intro7 {
+ i++
+ }
+
+ // Scan control sequence
+ // Most common control sequence is terminated by a ST character
+ // ST is a 7-bit string terminator character is (ESC \)
+ start := i
+ for ; i < len(b); i++ {
+ if slices.Contains([]byte{ansi.ESC, ansi.ST, ansi.CAN, ansi.SUB}, b[i]) {
+ break
+ }
+ }
+
+ if i >= len(b) {
+ return i, UnknownEvent(b[:i])
+ }
+
+ end := i // end of the sequence data
+ i++
+
+ // Check 7-bit ST (string terminator) character
+ switch b[i-1] {
+ case ansi.CAN, ansi.SUB:
+ return i, ignoredEvent(b[:i])
+ case ansi.ESC:
+ if i >= len(b) || b[i] != '\\' {
+ if start == end {
+ return defaultKey(b)
+ }
+
+ // If we don't have a valid ST terminator, then this is a
+ // cancelled sequence and should be ignored.
+ return i, ignoredEvent(b[:i])
+ }
+
+ i++
+ }
+
+ // Call the function to parse the sequence and return the result
+ if fn != nil {
+ if e := fn(b[start:end]); e != nil {
+ return i, e
+ }
+ }
+
+ switch intro8 {
+ case ansi.PM:
+ return i, UnknownPmEvent(b[:i])
+ case ansi.SOS:
+ return i, UnknownSosEvent(b[:i])
+ case ansi.APC:
+ return i, UnknownApcEvent(b[:i])
+ default:
+ return i, UnknownEvent(b[:i])
+ }
+ }
+}
+
+func (p *EventDecoder) parseDcs(b []byte) (int, Event) {
+ if len(b) == 2 && b[0] == ansi.ESC {
+ // short cut if this is an alt+P key
+ return 2, KeyPressEvent{Code: unicode.ToLower(rune(b[1])), Mod: ModShift | ModAlt}
+ }
+
+ var params [16]ansi.Param
+ var paramsLen int
+ var cmd ansi.Cmd
+
+ // DCS sequences are introduced by DCS (0x90) or ESC P (0x1b 0x50)
+ var i int
+ if b[i] == ansi.DCS || b[i] == ansi.ESC {
+ i++
+ }
+ if i < len(b) && b[i-1] == ansi.ESC && b[i] == 'P' {
+ i++
+ }
+
+ // initial DCS byte
+ if i < len(b) && b[i] >= '<' && b[i] <= '?' {
+ cmd |= ansi.Cmd(b[i]) << parser.PrefixShift
+ }
+
+ // Scan parameter bytes in the range 0x30-0x3F
+ var j int
+ for j = 0; i < len(b) && paramsLen < len(params) && b[i] >= 0x30 && b[i] <= 0x3F; i, j = i+1, j+1 {
+ if b[i] >= '0' && b[i] <= '9' {
+ if params[paramsLen] == parser.MissingParam {
+ params[paramsLen] = 0
+ }
+ params[paramsLen] *= 10
+ params[paramsLen] += ansi.Param(b[i]) - '0'
+ }
+ if b[i] == ':' {
+ params[paramsLen] |= parser.HasMoreFlag
+ }
+ if b[i] == ';' || b[i] == ':' {
+ paramsLen++
+ if paramsLen < len(params) {
+ // Don't overflow the params slice
+ params[paramsLen] = parser.MissingParam
+ }
+ }
+ }
+
+ if j > 0 && paramsLen < len(params) {
+ // has parameters
+ paramsLen++
+ }
+
+ // Scan intermediate bytes in the range 0x20-0x2F
+ var intermed byte
+ for j := 0; i < len(b) && b[i] >= 0x20 && b[i] <= 0x2F; i, j = i+1, j+1 {
+ intermed = b[i]
+ }
+
+ // set intermediate byte
+ cmd |= ansi.Cmd(intermed) << parser.IntermedShift
+
+ // Scan final byte in the range 0x40-0x7E
+ if i >= len(b) || b[i] < 0x40 || b[i] > 0x7E {
+ return i, UnknownEvent(b[:i])
+ }
+
+ // Add the final byte
+ cmd |= ansi.Cmd(b[i])
+ i++
+
+ start := i // start of the sequence data
+ for ; i < len(b); i++ {
+ if b[i] == ansi.ST || b[i] == ansi.ESC {
+ break
+ }
+ }
+
+ if i >= len(b) {
+ return i, UnknownEvent(b[:i])
+ }
+
+ end := i // end of the sequence data
+ i++
+
+ // Check 7-bit ST (string terminator) character
+ if i < len(b) && b[i-1] == ansi.ESC && b[i] == '\\' {
+ i++
+ }
+
+ pa := ansi.Params(params[:paramsLen])
+ switch cmd {
+ case 'r' | '+'<'< 1 {
+ g.Payload = parts[1]
+ }
+ return g
+ }
+
+ return nil
+ })(b)
+}
+
+func (p *EventDecoder) parseUtf8(b []byte) (int, Event) {
+ if len(b) == 0 {
+ return 0, nil
+ }
+
+ c := b[0]
+ if c <= ansi.US || c == ansi.DEL {
+ // Control codes get handled by parseControl
+ return 1, p.parseControl(c)
+ } else if c > ansi.US && c < ansi.DEL {
+ // ASCII printable characters
+ code := rune(c)
+ k := KeyPressEvent{Code: code, Text: string(code)}
+ if unicode.IsUpper(code) {
+ // Convert upper case letters to lower case + shift modifier
+ k.Code = unicode.ToLower(code)
+ k.ShiftedCode = code
+ k.Mod |= ModShift
+ }
+
+ return 1, k
+ }
+
+ code, _ := utf8.DecodeRune(b)
+ if code == utf8.RuneError {
+ return 1, UnknownEvent(b[0])
+ }
+
+ cluster, _, _, _ := uniseg.FirstGraphemeCluster(b, -1)
+ text := string(cluster)
+ for i := range text {
+ if i > 0 {
+ // Use [KeyExtended] for multi-rune graphemes
+ code = KeyExtended
+ break
+ }
+ }
+
+ return len(cluster), KeyPressEvent{Code: code, Text: text}
+}
+
+func (p *EventDecoder) parseControl(b byte) Event {
+ switch b {
+ case ansi.NUL:
+ if p.Legacy&flagCtrlAt != 0 {
+ return KeyPressEvent{Code: '@', Mod: ModCtrl}
+ }
+ return KeyPressEvent{Code: KeySpace, Mod: ModCtrl}
+ case ansi.BS:
+ return KeyPressEvent{Code: 'h', Mod: ModCtrl}
+ case ansi.HT:
+ if p.Legacy&flagCtrlI != 0 {
+ return KeyPressEvent{Code: 'i', Mod: ModCtrl}
+ }
+ return KeyPressEvent{Code: KeyTab}
+ case ansi.CR:
+ if p.Legacy&flagCtrlM != 0 {
+ return KeyPressEvent{Code: 'm', Mod: ModCtrl}
+ }
+ return KeyPressEvent{Code: KeyEnter}
+ case ansi.ESC:
+ if p.Legacy&flagCtrlOpenBracket != 0 {
+ return KeyPressEvent{Code: '[', Mod: ModCtrl}
+ }
+ return KeyPressEvent{Code: KeyEscape}
+ case ansi.DEL:
+ if p.Legacy&flagBackspace != 0 {
+ return KeyPressEvent{Code: KeyDelete}
+ }
+ return KeyPressEvent{Code: KeyBackspace}
+ case ansi.SP:
+ return KeyPressEvent{Code: KeySpace, Text: " "}
+ default:
+ if b >= ansi.SOH && b <= ansi.SUB {
+ // Use lower case letters for control codes
+ code := rune(b + 0x60)
+ return KeyPressEvent{Code: code, Mod: ModCtrl}
+ } else if b >= ansi.FS && b <= ansi.US {
+ code := rune(b + 0x40)
+ return KeyPressEvent{Code: code, Mod: ModCtrl}
+ }
+ return UnknownEvent(b)
+ }
+}
+
+func parseXTermModifyOtherKeys(params ansi.Params) Event {
+ // XTerm modify other keys starts with ESC [ 27 ; ; ~
+ xmod, _, _ := params.Param(1, 1)
+ xrune, _, _ := params.Param(2, 1)
+ mod := KeyMod(xmod - 1)
+ r := rune(xrune)
+
+ switch r {
+ case ansi.BS:
+ return KeyPressEvent{Mod: mod, Code: KeyBackspace}
+ case ansi.HT:
+ return KeyPressEvent{Mod: mod, Code: KeyTab}
+ case ansi.CR:
+ return KeyPressEvent{Mod: mod, Code: KeyEnter}
+ case ansi.ESC:
+ return KeyPressEvent{Mod: mod, Code: KeyEscape}
+ case ansi.DEL:
+ return KeyPressEvent{Mod: mod, Code: KeyBackspace}
+ }
+
+ // CSI 27 ; ; ~ keys defined in XTerm modifyOtherKeys
+ k := KeyPressEvent{Code: r, Mod: mod}
+ if k.Mod <= ModShift {
+ k.Text = string(r)
+ }
+
+ return k
+}
+
+// Kitty Clipboard Control Sequences.
+var kittyKeyMap = map[int]Key{
+ ansi.BS: {Code: KeyBackspace},
+ ansi.HT: {Code: KeyTab},
+ ansi.CR: {Code: KeyEnter},
+ ansi.ESC: {Code: KeyEscape},
+ ansi.DEL: {Code: KeyBackspace},
+
+ 57344: {Code: KeyEscape},
+ 57345: {Code: KeyEnter},
+ 57346: {Code: KeyTab},
+ 57347: {Code: KeyBackspace},
+ 57348: {Code: KeyInsert},
+ 57349: {Code: KeyDelete},
+ 57350: {Code: KeyLeft},
+ 57351: {Code: KeyRight},
+ 57352: {Code: KeyUp},
+ 57353: {Code: KeyDown},
+ 57354: {Code: KeyPgUp},
+ 57355: {Code: KeyPgDown},
+ 57356: {Code: KeyHome},
+ 57357: {Code: KeyEnd},
+ 57358: {Code: KeyCapsLock},
+ 57359: {Code: KeyScrollLock},
+ 57360: {Code: KeyNumLock},
+ 57361: {Code: KeyPrintScreen},
+ 57362: {Code: KeyPause},
+ 57363: {Code: KeyMenu},
+ 57364: {Code: KeyF1},
+ 57365: {Code: KeyF2},
+ 57366: {Code: KeyF3},
+ 57367: {Code: KeyF4},
+ 57368: {Code: KeyF5},
+ 57369: {Code: KeyF6},
+ 57370: {Code: KeyF7},
+ 57371: {Code: KeyF8},
+ 57372: {Code: KeyF9},
+ 57373: {Code: KeyF10},
+ 57374: {Code: KeyF11},
+ 57375: {Code: KeyF12},
+ 57376: {Code: KeyF13},
+ 57377: {Code: KeyF14},
+ 57378: {Code: KeyF15},
+ 57379: {Code: KeyF16},
+ 57380: {Code: KeyF17},
+ 57381: {Code: KeyF18},
+ 57382: {Code: KeyF19},
+ 57383: {Code: KeyF20},
+ 57384: {Code: KeyF21},
+ 57385: {Code: KeyF22},
+ 57386: {Code: KeyF23},
+ 57387: {Code: KeyF24},
+ 57388: {Code: KeyF25},
+ 57389: {Code: KeyF26},
+ 57390: {Code: KeyF27},
+ 57391: {Code: KeyF28},
+ 57392: {Code: KeyF29},
+ 57393: {Code: KeyF30},
+ 57394: {Code: KeyF31},
+ 57395: {Code: KeyF32},
+ 57396: {Code: KeyF33},
+ 57397: {Code: KeyF34},
+ 57398: {Code: KeyF35},
+ 57399: {Code: KeyKp0},
+ 57400: {Code: KeyKp1},
+ 57401: {Code: KeyKp2},
+ 57402: {Code: KeyKp3},
+ 57403: {Code: KeyKp4},
+ 57404: {Code: KeyKp5},
+ 57405: {Code: KeyKp6},
+ 57406: {Code: KeyKp7},
+ 57407: {Code: KeyKp8},
+ 57408: {Code: KeyKp9},
+ 57409: {Code: KeyKpDecimal},
+ 57410: {Code: KeyKpDivide},
+ 57411: {Code: KeyKpMultiply},
+ 57412: {Code: KeyKpMinus},
+ 57413: {Code: KeyKpPlus},
+ 57414: {Code: KeyKpEnter},
+ 57415: {Code: KeyKpEqual},
+ 57416: {Code: KeyKpSep},
+ 57417: {Code: KeyKpLeft},
+ 57418: {Code: KeyKpRight},
+ 57419: {Code: KeyKpUp},
+ 57420: {Code: KeyKpDown},
+ 57421: {Code: KeyKpPgUp},
+ 57422: {Code: KeyKpPgDown},
+ 57423: {Code: KeyKpHome},
+ 57424: {Code: KeyKpEnd},
+ 57425: {Code: KeyKpInsert},
+ 57426: {Code: KeyKpDelete},
+ 57427: {Code: KeyKpBegin},
+ 57428: {Code: KeyMediaPlay},
+ 57429: {Code: KeyMediaPause},
+ 57430: {Code: KeyMediaPlayPause},
+ 57431: {Code: KeyMediaReverse},
+ 57432: {Code: KeyMediaStop},
+ 57433: {Code: KeyMediaFastForward},
+ 57434: {Code: KeyMediaRewind},
+ 57435: {Code: KeyMediaNext},
+ 57436: {Code: KeyMediaPrev},
+ 57437: {Code: KeyMediaRecord},
+ 57438: {Code: KeyLowerVol},
+ 57439: {Code: KeyRaiseVol},
+ 57440: {Code: KeyMute},
+ 57441: {Code: KeyLeftShift},
+ 57442: {Code: KeyLeftCtrl},
+ 57443: {Code: KeyLeftAlt},
+ 57444: {Code: KeyLeftSuper},
+ 57445: {Code: KeyLeftHyper},
+ 57446: {Code: KeyLeftMeta},
+ 57447: {Code: KeyRightShift},
+ 57448: {Code: KeyRightCtrl},
+ 57449: {Code: KeyRightAlt},
+ 57450: {Code: KeyRightSuper},
+ 57451: {Code: KeyRightHyper},
+ 57452: {Code: KeyRightMeta},
+ 57453: {Code: KeyIsoLevel3Shift},
+ 57454: {Code: KeyIsoLevel5Shift},
+}
+
+func init() {
+ // These are some faulty C0 mappings some terminals such as WezTerm have
+ // and doesn't follow the specs.
+ kittyKeyMap[ansi.NUL] = Key{Code: KeySpace, Mod: ModCtrl}
+ for i := ansi.SOH; i <= ansi.SUB; i++ {
+ if _, ok := kittyKeyMap[i]; !ok {
+ kittyKeyMap[i] = Key{Code: rune(i + 0x60), Mod: ModCtrl}
+ }
+ }
+ for i := ansi.FS; i <= ansi.US; i++ {
+ if _, ok := kittyKeyMap[i]; !ok {
+ kittyKeyMap[i] = Key{Code: rune(i + 0x40), Mod: ModCtrl}
+ }
+ }
+}
+
+const (
+ kittyShift = 1 << iota
+ kittyAlt
+ kittyCtrl
+ kittySuper
+ kittyHyper
+ kittyMeta
+ kittyCapsLock
+ kittyNumLock
+)
+
+func fromKittyMod(mod int) KeyMod {
+ var m KeyMod
+ if mod&kittyShift != 0 {
+ m |= ModShift
+ }
+ if mod&kittyAlt != 0 {
+ m |= ModAlt
+ }
+ if mod&kittyCtrl != 0 {
+ m |= ModCtrl
+ }
+ if mod&kittySuper != 0 {
+ m |= ModSuper
+ }
+ if mod&kittyHyper != 0 {
+ m |= ModHyper
+ }
+ if mod&kittyMeta != 0 {
+ m |= ModMeta
+ }
+ if mod&kittyCapsLock != 0 {
+ m |= ModCapsLock
+ }
+ if mod&kittyNumLock != 0 {
+ m |= ModNumLock
+ }
+ return m
+}
+
+// parseKittyKeyboard parses a Kitty Keyboard Protocol sequence.
+//
+// In `CSI u`, this is parsed as:
+//
+// CSI codepoint ; modifiers u
+// codepoint: ASCII Dec value
+//
+// The Kitty Keyboard Protocol extends this with optional components that can be
+// enabled progressively. The full sequence is parsed as:
+//
+// CSI unicode-key-code:alternate-key-codes ; modifiers:event-type ; text-as-codepoints u
+//
+// See https://sw.kovidgoyal.net/kitty/keyboard-protocol/
+func parseKittyKeyboard(params ansi.Params) (Event Event) {
+ var isRelease bool
+ var key Key
+
+ // The index of parameters separated by semicolons ';'. Sub parameters are
+ // separated by colons ':'.
+ var paramIdx int
+ var sudIdx int // The sub parameter index
+ for _, p := range params {
+ // Kitty Keyboard Protocol has 3 optional components.
+ switch paramIdx {
+ case 0:
+ switch sudIdx {
+ case 0:
+ var foundKey bool
+ code := p.Param(1) // CSI u has a default value of 1
+ key, foundKey = kittyKeyMap[code]
+ if !foundKey {
+ r := rune(code)
+ if !utf8.ValidRune(r) {
+ r = utf8.RuneError
+ }
+
+ key.Code = r
+ }
+
+ case 2:
+ // shifted key + base key
+ if b := rune(p.Param(1)); unicode.IsPrint(b) {
+ // XXX: When alternate key reporting is enabled, the protocol
+ // can return 3 things, the unicode codepoint of the key,
+ // the shifted codepoint of the key, and the standard
+ // PC-101 key layout codepoint.
+ // This is useful to create an unambiguous mapping of keys
+ // when using a different language layout.
+ key.BaseCode = b
+ }
+ fallthrough
+
+ case 1:
+ // shifted key
+ if s := rune(p.Param(1)); unicode.IsPrint(s) {
+ // XXX: We swap keys here because we want the shifted key
+ // to be the Rune that is returned by the event.
+ // For example, shift+a should produce "A" not "a".
+ // In such a case, we set AltRune to the original key "a"
+ // and Rune to "A".
+ key.ShiftedCode = s
+ }
+ }
+ case 1:
+ switch sudIdx {
+ case 0:
+ mod := p.Param(1)
+ if mod > 1 {
+ key.Mod = fromKittyMod(mod - 1)
+ if key.Mod > ModShift {
+ // XXX: We need to clear the text if we have a modifier key
+ // other than a [ModShift] key.
+ key.Text = ""
+ }
+ }
+
+ case 1:
+ switch p.Param(1) {
+ case 2:
+ key.IsRepeat = true
+ case 3:
+ isRelease = true
+ }
+ case 2:
+ }
+ case 2:
+ if code := p.Param(0); code != 0 {
+ key.Text += string(rune(code))
+ }
+ }
+
+ sudIdx++
+ if !p.HasMore() {
+ paramIdx++
+ sudIdx = 0
+ }
+ }
+
+ keyMod := key.Mod
+
+ // Remove these lock modifiers from now on since they don't affect the text.
+ keyMod &^= ModNumLock
+ // keyMod &^= ModScrollLock // Kitty doesn't support scroll lock
+
+ printMod := keyMod <= ModShift || keyMod == ModCapsLock || keyMod == (ModShift|ModCapsLock)
+ printKeyPad := key.Code >= KeyKpEqual && key.Code <= KeyKpSep
+ if len(key.Text) == 0 && printKeyPad && printMod {
+ switch {
+ case key.Code >= KeyKp0 && key.Code <= KeyKp9:
+ key.Text = string('0' + key.Code - KeyKp0)
+ case key.Code == KeyKpEqual:
+ key.Text = "="
+ case key.Code == KeyKpMultiply:
+ key.Text = "*"
+ case key.Code == KeyKpPlus:
+ key.Text = "+"
+ case key.Code == KeyKpMinus:
+ key.Text = "-"
+ case key.Code == KeyKpDecimal:
+ key.Text = "."
+ case key.Code == KeyKpDivide:
+ key.Text = "/"
+ case key.Code == KeyKpSep:
+ key.Text = ","
+ }
+ }
+
+ //nolint:nestif
+ if len(key.Text) == 0 && unicode.IsPrint(key.Code) && printMod {
+ if keyMod == 0 {
+ key.Text = string(key.Code)
+ } else {
+ desiredCase := unicode.ToLower
+ if keyMod.Contains(ModShift) || keyMod.Contains(ModCapsLock) {
+ desiredCase = unicode.ToUpper
+ }
+ if key.ShiftedCode != 0 {
+ key.Text = string(key.ShiftedCode)
+ } else {
+ key.Text = string(desiredCase(key.Code))
+ }
+ }
+ }
+
+ if isRelease {
+ return KeyReleaseEvent(key)
+ }
+
+ return KeyPressEvent(key)
+}
+
+// parseKittyKeyboardExt parses a Kitty Keyboard Protocol sequence extensions
+// for non CSI u sequences. This includes things like CSI A, SS3 A and others,
+// and CSI ~.
+func parseKittyKeyboardExt(params ansi.Params, k KeyPressEvent) Event {
+ // Handle Kitty keyboard protocol
+ if len(params) > 2 && // We have at least 3 parameters
+ params[1].HasMore() { // The second parameter is a subparameter (separated by a ":")
+ switch params[2].Param(1) { // The third parameter is the event type (defaults to 1)
+ case 2:
+ k.IsRepeat = true
+ case 3:
+ return KeyReleaseEvent(k)
+ }
+ }
+ return k
+}
+
+func parsePrimaryDevAttrs(params ansi.Params) Event {
+ // Primary Device Attributes
+ da1 := make(PrimaryDeviceAttributesEvent, len(params))
+ for i, p := range params {
+ if !p.HasMore() {
+ da1[i] = p.Param(0)
+ }
+ }
+ return da1
+}
+
+func parseSecondaryDevAttrs(params ansi.Params) Event {
+ // Secondary Device Attributes
+ da2 := make(SecondaryDeviceAttributesEvent, len(params))
+ for i, p := range params {
+ if !p.HasMore() {
+ da2[i] = p.Param(0)
+ }
+ }
+ return da2
+}
+
+func parseTertiaryDevAttrs(b []byte) Event {
+ // Tertiary Device Attributes
+ // The response is a 4-digit hexadecimal number.
+ bts, err := hex.DecodeString(string(b))
+ if err != nil {
+ return UnknownDcsEvent(fmt.Sprintf("\x1bP!|%s\x1b\\", b))
+ }
+ return TertiaryDeviceAttributesEvent(bts)
+}
+
+// Parse SGR-encoded mouse events; SGR extended mouse events. SGR mouse events
+// look like:
+//
+// ESC [ < Cb ; Cx ; Cy (M or m)
+//
+// where:
+//
+// Cb is the encoded button code
+// Cx is the x-coordinate of the mouse
+// Cy is the y-coordinate of the mouse
+// M is for button press, m is for button release
+//
+// https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Extended-coordinates
+func parseSGRMouseEvent(cmd ansi.Cmd, params ansi.Params) Event {
+ x, _, ok := params.Param(1, 1)
+ if !ok {
+ x = 1
+ }
+ y, _, ok := params.Param(2, 1)
+ if !ok {
+ y = 1
+ }
+ release := cmd.Final() == 'm'
+ b, _, _ := params.Param(0, 0)
+ mod, btn, _, isMotion := parseMouseButton(b)
+
+ // (1,1) is the upper left. We subtract 1 to normalize it to (0,0).
+ x--
+ y--
+
+ m := Mouse{X: x, Y: y, Button: btn, Mod: mod}
+
+ // Wheel buttons don't have release events
+ // Motion can be reported as a release event in some terminals (Windows Terminal)
+ if isWheel(m.Button) {
+ return MouseWheelEvent(m)
+ } else if !isMotion && release {
+ return MouseReleaseEvent(m)
+ } else if isMotion {
+ return MouseMotionEvent(m)
+ }
+ return MouseClickEvent(m)
+}
+
+const x10MouseByteOffset = 32
+
+// Parse X10-encoded mouse events; the simplest kind. The last release of X10
+// was December 1986, by the way. The original X10 mouse protocol limits the Cx
+// and Cy coordinates to 223 (=255-032).
+//
+// X10 mouse events look like:
+//
+// ESC [M Cb Cx Cy
+//
+// See: http://www.xfree86.org/current/ctlseqs.html#Mouse%20Tracking
+func parseX10MouseEvent(buf []byte) Event {
+ v := buf[3:6]
+ b := int(v[0])
+ if b >= x10MouseByteOffset {
+ // XXX: b < 32 should be impossible, but we're being defensive.
+ b -= x10MouseByteOffset
+ }
+
+ mod, btn, isRelease, isMotion := parseMouseButton(b)
+
+ // (1,1) is the upper left. We subtract 1 to normalize it to (0,0).
+ x := int(v[1]) - x10MouseByteOffset - 1
+ y := int(v[2]) - x10MouseByteOffset - 1
+
+ m := Mouse{X: x, Y: y, Button: btn, Mod: mod}
+ if isWheel(m.Button) {
+ return MouseWheelEvent(m)
+ } else if isMotion {
+ return MouseMotionEvent(m)
+ } else if isRelease {
+ return MouseReleaseEvent(m)
+ }
+ return MouseClickEvent(m)
+}
+
+// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Extended-coordinates
+func parseMouseButton(b int) (mod KeyMod, btn MouseButton, isRelease bool, isMotion bool) {
+ // mouse bit shifts
+ const (
+ bitShift = 0b0000_0100
+ bitAlt = 0b0000_1000
+ bitCtrl = 0b0001_0000
+ bitMotion = 0b0010_0000
+ bitWheel = 0b0100_0000
+ bitAdd = 0b1000_0000 // additional buttons 8-11
+
+ bitsMask = 0b0000_0011
+ )
+
+ // Modifiers
+ if b&bitAlt != 0 {
+ mod |= ModAlt
+ }
+ if b&bitCtrl != 0 {
+ mod |= ModCtrl
+ }
+ if b&bitShift != 0 {
+ mod |= ModShift
+ }
+
+ if b&bitAdd != 0 {
+ btn = MouseBackward + MouseButton(b&bitsMask)
+ } else if b&bitWheel != 0 {
+ btn = MouseWheelUp + MouseButton(b&bitsMask)
+ } else {
+ btn = MouseLeft + MouseButton(b&bitsMask)
+ // X10 reports a button release as 0b0000_0011 (3)
+ if b&bitsMask == bitsMask {
+ btn = MouseNone
+ isRelease = true
+ }
+ }
+
+ // Motion bit doesn't get reported for wheel events.
+ if b&bitMotion != 0 && !isWheel(btn) {
+ isMotion = true
+ }
+
+ return //nolint:nakedret
+}
+
+// isWheel returns true if the mouse event is a wheel event.
+func isWheel(btn MouseButton) bool {
+ return btn >= MouseWheelUp && btn <= MouseWheelRight
+}
+
+type shiftable interface {
+ ~uint | ~uint16 | ~uint32 | ~uint64
+}
+
+func shift[T shiftable](x T) T {
+ if x > 0xff {
+ x >>= 8
+ }
+ return x
+}
+
+func colorToHex(c color.Color) string {
+ if c == nil {
+ return ""
+ }
+ r, g, b, _ := c.RGBA()
+ return fmt.Sprintf("#%02x%02x%02x", shift(r), shift(g), shift(b))
+}
+
+func getMaxMin(a, b, c float64) (ma, mi float64) {
+ if a > b {
+ ma = a
+ mi = b
+ } else {
+ ma = b
+ mi = a
+ }
+ if c > ma {
+ ma = c
+ } else if c < mi {
+ mi = c
+ }
+ return ma, mi
+}
+
+func round(x float64) float64 {
+ return math.Round(x*1000) / 1000
+}
+
+// rgbToHSL converts an RGB triple to an HSL triple.
+func rgbToHSL(r, g, b uint8) (h, s, l float64) {
+ // convert uint32 pre-multiplied value to uint8
+ // The r,g,b values are divided by 255 to change the range from 0..255 to 0..1:
+ Rnot := float64(r) / 255
+ Gnot := float64(g) / 255
+ Bnot := float64(b) / 255
+ Cmax, Cmin := getMaxMin(Rnot, Gnot, Bnot)
+ Δ := Cmax - Cmin
+ // Lightness calculation:
+ l = (Cmax + Cmin) / 2
+ // Hue and Saturation Calculation:
+ if Δ == 0 {
+ h = 0
+ s = 0
+ } else {
+ switch Cmax {
+ case Rnot:
+ h = 60 * (math.Mod((Gnot-Bnot)/Δ, 6))
+ case Gnot:
+ h = 60 * (((Bnot - Rnot) / Δ) + 2)
+ case Bnot:
+ h = 60 * (((Rnot - Gnot) / Δ) + 4)
+ }
+ if h < 0 {
+ h += 360
+ }
+
+ s = Δ / (1 - math.Abs((2*l)-1))
+ }
+
+ return h, round(s), round(l)
+}
+
+// isDarkColor returns whether the given color is dark.
+func isDarkColor(c color.Color) bool {
+ if c == nil {
+ return true
+ }
+
+ r, g, b, _ := c.RGBA()
+ _, _, l := rgbToHSL(uint8(r>>8), uint8(g>>8), uint8(b>>8)) //nolint:gosec
+ return l < 0.5
+}
+
+func parseTermcap(data []byte) CapabilityEvent {
+ // XTGETTCAP
+ if len(data) == 0 {
+ return CapabilityEvent{""}
+ }
+
+ var tc strings.Builder
+ split := bytes.Split(data, []byte{';'})
+ for _, s := range split {
+ parts := bytes.SplitN(s, []byte{'='}, 2)
+ if len(parts) == 0 {
+ return CapabilityEvent{""}
+ }
+
+ name, err := hex.DecodeString(string(parts[0]))
+ if err != nil || len(name) == 0 {
+ continue
+ }
+
+ var value []byte
+ if len(parts) > 1 {
+ value, err = hex.DecodeString(string(parts[1]))
+ if err != nil {
+ continue
+ }
+ }
+
+ if tc.Len() > 0 {
+ tc.WriteByte(';')
+ }
+ tc.WriteString(string(name))
+ if len(value) > 0 {
+ tc.WriteByte('=')
+ tc.WriteString(string(value))
+ }
+ }
+
+ return CapabilityEvent{tc.String()}
+}
+
+// parseWin32InputKeyEvent converts a Windows Input Record Key Event into a
+// KeyPressEvent, KeyReleaseEvent, or MultiEvent including multiple of the
+// former type.
+// A special case is when the key is either part of VtInputMode which produces
+// vkc == 0, or when a key is a UTF-16 surrogate pair. In both of these cases,
+// we need to handle key encoding and properly parse the key event.
+func (p *EventDecoder) parseWin32InputKeyEvent(vkc uint16, _ uint16, r rune, keyDown bool, cks uint32, repeatCount uint16) (event Event) {
+ defer func() {
+ // Respect the repeat count.
+ if repeatCount > 1 {
+ var multi MultiEvent
+ for i := 0; i < int(repeatCount); i++ {
+ multi = append(multi, event)
+ }
+ event = multi
+ }
+ }()
+ defer func() {
+ if vkc != 0 {
+ p.lastCks = cks
+ }
+ }()
+
+ var key Key
+ switch {
+ case vkc == 0:
+ // This is either a UTF-16 encoded pair, or an escape sequence waiting
+ // to be decoded.
+ if keyDown {
+ return KeyPressEvent{Code: 0, BaseCode: r, Mod: translateControlKeyState(cks)}
+ }
+ return KeyReleaseEvent{Code: 0, BaseCode: r, Mod: translateControlKeyState(cks)}
+ case vkc == xwindows.VK_BACK:
+ key.BaseCode = KeyBackspace
+ case vkc == xwindows.VK_TAB:
+ key.BaseCode = KeyTab
+ case vkc == xwindows.VK_RETURN:
+ key.BaseCode = KeyEnter
+ case vkc == xwindows.VK_SHIFT:
+ //nolint:nestif
+ if cks&xwindows.SHIFT_PRESSED != 0 {
+ if cks&xwindows.ENHANCED_KEY != 0 {
+ key.BaseCode = KeyRightShift
+ } else {
+ key.BaseCode = KeyLeftShift
+ }
+ } else if p.lastCks&xwindows.SHIFT_PRESSED != 0 {
+ if p.lastCks&xwindows.ENHANCED_KEY != 0 {
+ key.BaseCode = KeyRightShift
+ } else {
+ key.BaseCode = KeyLeftShift
+ }
+ }
+ case vkc == xwindows.VK_CONTROL:
+ if cks&xwindows.LEFT_CTRL_PRESSED != 0 {
+ key.BaseCode = KeyLeftCtrl
+ } else if cks&xwindows.RIGHT_CTRL_PRESSED != 0 {
+ key.BaseCode = KeyRightCtrl
+ } else if p.lastCks&xwindows.LEFT_CTRL_PRESSED != 0 {
+ key.BaseCode = KeyLeftCtrl
+ } else if p.lastCks&xwindows.RIGHT_CTRL_PRESSED != 0 {
+ key.BaseCode = KeyRightCtrl
+ }
+ case vkc == xwindows.VK_MENU:
+ if cks&xwindows.LEFT_ALT_PRESSED != 0 {
+ key.BaseCode = KeyLeftAlt
+ } else if cks&xwindows.RIGHT_ALT_PRESSED != 0 {
+ key.BaseCode = KeyRightAlt
+ } else if p.lastCks&xwindows.LEFT_ALT_PRESSED != 0 {
+ key.BaseCode = KeyLeftAlt
+ } else if p.lastCks&xwindows.RIGHT_ALT_PRESSED != 0 {
+ key.BaseCode = KeyRightAlt
+ }
+ case vkc == xwindows.VK_PAUSE:
+ key.BaseCode = KeyPause
+ case vkc == xwindows.VK_CAPITAL:
+ key.BaseCode = KeyCapsLock
+ case vkc == xwindows.VK_ESCAPE:
+ key.BaseCode = KeyEscape
+ case vkc == xwindows.VK_SPACE:
+ key.BaseCode = KeySpace
+ case vkc == xwindows.VK_PRIOR:
+ key.BaseCode = KeyPgUp
+ case vkc == xwindows.VK_NEXT:
+ key.BaseCode = KeyPgDown
+ case vkc == xwindows.VK_END:
+ key.BaseCode = KeyEnd
+ case vkc == xwindows.VK_HOME:
+ key.BaseCode = KeyHome
+ case vkc == xwindows.VK_LEFT:
+ key.BaseCode = KeyLeft
+ case vkc == xwindows.VK_UP:
+ key.BaseCode = KeyUp
+ case vkc == xwindows.VK_RIGHT:
+ key.BaseCode = KeyRight
+ case vkc == xwindows.VK_DOWN:
+ key.BaseCode = KeyDown
+ case vkc == xwindows.VK_SELECT:
+ key.BaseCode = KeySelect
+ case vkc == xwindows.VK_SNAPSHOT:
+ key.BaseCode = KeyPrintScreen
+ case vkc == xwindows.VK_INSERT:
+ key.BaseCode = KeyInsert
+ case vkc == xwindows.VK_DELETE:
+ key.BaseCode = KeyDelete
+ case vkc >= '0' && vkc <= '9':
+ key.BaseCode = rune(vkc)
+ case vkc >= 'A' && vkc <= 'Z':
+ // Convert to lowercase.
+ key.BaseCode = rune(vkc) + 32
+ case vkc == xwindows.VK_LWIN:
+ key.BaseCode = KeyLeftSuper
+ case vkc == xwindows.VK_RWIN:
+ key.BaseCode = KeyRightSuper
+ case vkc == xwindows.VK_APPS:
+ key.BaseCode = KeyMenu
+ case vkc >= xwindows.VK_NUMPAD0 && vkc <= xwindows.VK_NUMPAD9:
+ key.BaseCode = rune(vkc-xwindows.VK_NUMPAD0) + KeyKp0
+ key.Text = string('0' + (rune(vkc) - xwindows.VK_NUMPAD0))
+ case vkc == xwindows.VK_MULTIPLY:
+ key.BaseCode = KeyKpMultiply
+ key.Text = "*"
+ case vkc == xwindows.VK_ADD:
+ key.BaseCode = KeyKpPlus
+ key.Text = "+"
+ case vkc == xwindows.VK_SEPARATOR:
+ key.BaseCode = KeyKpComma
+ key.Text = ","
+ case vkc == xwindows.VK_SUBTRACT:
+ key.BaseCode = KeyKpMinus
+ key.Text = "-"
+ case vkc == xwindows.VK_DECIMAL:
+ key.BaseCode = KeyKpDecimal
+ key.Text = "."
+ case vkc == xwindows.VK_DIVIDE:
+ key.BaseCode = KeyKpDivide
+ key.Text = "/"
+ case vkc >= xwindows.VK_F1 && vkc <= xwindows.VK_F24:
+ key.BaseCode = rune(vkc-xwindows.VK_F1) + KeyF1
+ case vkc == xwindows.VK_NUMLOCK:
+ key.BaseCode = KeyNumLock
+ case vkc == xwindows.VK_SCROLL:
+ key.BaseCode = KeyScrollLock
+ case vkc == xwindows.VK_LSHIFT:
+ key.BaseCode = KeyLeftShift
+ case vkc == xwindows.VK_RSHIFT:
+ key.BaseCode = KeyRightShift
+ case vkc == xwindows.VK_LCONTROL:
+ key.BaseCode = KeyLeftCtrl
+ case vkc == xwindows.VK_RCONTROL:
+ key.BaseCode = KeyRightCtrl
+ case vkc == xwindows.VK_LMENU:
+ key.BaseCode = KeyLeftAlt
+ case vkc == xwindows.VK_RMENU:
+ key.BaseCode = KeyRightAlt
+ case vkc == xwindows.VK_VOLUME_MUTE:
+ key.BaseCode = KeyMute
+ case vkc == xwindows.VK_VOLUME_DOWN:
+ key.BaseCode = KeyLowerVol
+ case vkc == xwindows.VK_VOLUME_UP:
+ key.BaseCode = KeyRaiseVol
+ case vkc == xwindows.VK_MEDIA_NEXT_TRACK:
+ key.BaseCode = KeyMediaNext
+ case vkc == xwindows.VK_MEDIA_PREV_TRACK:
+ key.BaseCode = KeyMediaPrev
+ case vkc == xwindows.VK_MEDIA_STOP:
+ key.BaseCode = KeyMediaStop
+ case vkc == xwindows.VK_MEDIA_PLAY_PAUSE:
+ key.BaseCode = KeyMediaPlayPause
+ case vkc == xwindows.VK_OEM_1:
+ key.BaseCode = ';'
+ case vkc == xwindows.VK_OEM_PLUS:
+ key.BaseCode = '+'
+ case vkc == xwindows.VK_OEM_COMMA:
+ key.BaseCode = ','
+ case vkc == xwindows.VK_OEM_MINUS:
+ key.BaseCode = '-'
+ case vkc == xwindows.VK_OEM_PERIOD:
+ key.BaseCode = '.'
+ case vkc == xwindows.VK_OEM_2:
+ key.BaseCode = '/'
+ case vkc == xwindows.VK_OEM_3:
+ key.BaseCode = '`'
+ case vkc == xwindows.VK_OEM_4:
+ key.BaseCode = '['
+ case vkc == xwindows.VK_OEM_5:
+ key.BaseCode = '\\'
+ case vkc == xwindows.VK_OEM_6:
+ key.BaseCode = ']'
+ case vkc == xwindows.VK_OEM_7:
+ key.BaseCode = '\''
+ }
+
+ // AltGr is left ctrl + right alt. On non-US keyboards, this is used to type
+ // special characters and produce printable events.
+ // XXX: Should this be a KeyMod?
+ const altGrPressed = xwindows.LEFT_CTRL_PRESSED | xwindows.RIGHT_ALT_PRESSED
+ altGr := cks&altGrPressed == altGrPressed
+
+ // Remove these lock keys from the control key state from now on.
+ cks &^= xwindows.NUMLOCK_ON
+ cks &^= xwindows.SCROLLLOCK_ON
+ key.Code = key.BaseCode
+ if !unicode.IsControl(r) {
+ key.Code = r
+ if unicode.IsPrint(key.Code) && (cks == 0 || // no modifiers pressed
+ cks == xwindows.SHIFT_PRESSED || // shift pressed
+ cks == xwindows.CAPSLOCK_ON || // caps lock on
+ cks == (xwindows.SHIFT_PRESSED|xwindows.CAPSLOCK_ON) || // Shift + caps lock pressed
+ altGr) { // AltGr pressed
+ // If the control key state is 0, shift is pressed, or caps lock
+ // then the key event is a printable event i.e. [text] is not empty.
+ key.Text = string(key.Code)
+ }
+ }
+
+ key.Mod = translateControlKeyState(cks)
+ key = ensureKeyCase(key, cks)
+ if keyDown {
+ return KeyPressEvent(key)
+ }
+
+ return KeyReleaseEvent(key)
+}
+
+// ensureKeyCase ensures that the key's text is in the correct case based on the
+// control key state.
+func ensureKeyCase(key Key, cks uint32) Key {
+ if len(key.Text) == 0 {
+ return key
+ }
+
+ hasShift := cks&xwindows.SHIFT_PRESSED != 0
+ hasCaps := cks&xwindows.CAPSLOCK_ON != 0
+ if hasShift || hasCaps {
+ if unicode.IsLower(key.Code) {
+ key.ShiftedCode = unicode.ToUpper(key.Code)
+ key.Text = string(key.ShiftedCode)
+ }
+ } else {
+ if unicode.IsUpper(key.Code) {
+ key.ShiftedCode = unicode.ToLower(key.Code)
+ key.Text = string(key.ShiftedCode)
+ }
+ }
+
+ return key
+}
+
+// translateControlKeyState translates the control key state from the Windows
+// Console API into a Mod bitmask.
+func translateControlKeyState(cks uint32) (m KeyMod) {
+ if cks&xwindows.LEFT_CTRL_PRESSED != 0 || cks&xwindows.RIGHT_CTRL_PRESSED != 0 {
+ m |= ModCtrl
+ }
+ if cks&xwindows.LEFT_ALT_PRESSED != 0 || cks&xwindows.RIGHT_ALT_PRESSED != 0 {
+ m |= ModAlt
+ }
+ if cks&xwindows.SHIFT_PRESSED != 0 {
+ m |= ModShift
+ }
+ if cks&xwindows.CAPSLOCK_ON != 0 {
+ m |= ModCapsLock
+ }
+ if cks&xwindows.NUMLOCK_ON != 0 {
+ m |= ModNumLock
+ }
+ if cks&xwindows.SCROLLLOCK_ON != 0 {
+ m |= ModScrollLock
+ }
+ return
+}
diff --git a/vendor/github.com/charmbracelet/ultraviolet/doc.go b/vendor/github.com/charmbracelet/ultraviolet/doc.go
new file mode 100644
index 0000000000..27b8a25c35
--- /dev/null
+++ b/vendor/github.com/charmbracelet/ultraviolet/doc.go
@@ -0,0 +1,46 @@
+// Package uv (Ultraviolet) provides primitives for building terminal user
+// interfaces in Go.
+//
+// It offers cell-based screen buffers, a diffing terminal renderer, cross-platform
+// input decoding (keyboard, mouse, paste, focus, resize), and a windowing model
+// with off-screen buffers. Ultraviolet powers Bubble Tea v2 and Lip Gloss v2.
+//
+// # Getting Started
+//
+// Create a terminal, get its screen, and run an event loop:
+//
+// t := uv.DefaultTerminal()
+// scr := t.Screen()
+// scr.EnterAltScreen()
+//
+// if err := t.Start(); err != nil {
+// log.Fatal(err)
+// }
+// defer t.Stop()
+//
+// for ev := range t.Events() {
+// switch ev := ev.(type) {
+// case uv.WindowSizeEvent:
+// scr.Resize(ev.Width, ev.Height)
+// case uv.KeyPressEvent:
+// if ev.MatchString("q") { return }
+// }
+// }
+//
+// # Rendering
+//
+// Drawing is a two-step process. [TerminalScreen.Render] diffs the screen and
+// writes escape sequences to an internal buffer. [TerminalScreen.Flush] sends
+// the buffer to the terminal—this is the only method that performs real I/O.
+//
+// scr.Render()
+// scr.Flush()
+//
+// Use the screen package for high-level drawing helpers like
+// [screen.Context.DrawString] and [screen.Clear].
+//
+// # Packages
+//
+// - screen — drawing context and screen manipulation helpers
+// - layout — constraint-based layout solver (Cassowary algorithm)
+package uv
diff --git a/vendor/github.com/charmbracelet/ultraviolet/environ.go b/vendor/github.com/charmbracelet/ultraviolet/environ.go
new file mode 100644
index 0000000000..9622b607a6
--- /dev/null
+++ b/vendor/github.com/charmbracelet/ultraviolet/environ.go
@@ -0,0 +1,32 @@
+package uv
+
+import (
+ "strings"
+)
+
+// Environ is a slice of strings that represents the environment variables of
+// the program.
+type Environ []string
+
+// Getenv returns the value of the environment variable named by the key. If
+// the variable is not present in the environment, the value returned will be
+// the empty string.
+func (p Environ) Getenv(key string) (v string) {
+ v, _ = p.LookupEnv(key)
+ return
+}
+
+// LookupEnv retrieves the value of the environment variable named by the key.
+// If the variable is present in the environment the value (which may be empty)
+// is returned and the boolean is true. Otherwise the returned value will be
+// empty and the boolean will be false.
+func (p Environ) LookupEnv(key string) (s string, v bool) {
+ for i := len(p) - 1; i >= 0; i-- {
+ if strings.HasPrefix(p[i], key+"=") {
+ s = strings.TrimPrefix(p[i], key+"=")
+ v = true
+ break
+ }
+ }
+ return
+}
diff --git a/vendor/github.com/charmbracelet/ultraviolet/event.go b/vendor/github.com/charmbracelet/ultraviolet/event.go
new file mode 100644
index 0000000000..2d0d8cf202
--- /dev/null
+++ b/vendor/github.com/charmbracelet/ultraviolet/event.go
@@ -0,0 +1,567 @@
+package uv
+
+import (
+ "context"
+ "fmt"
+ "image"
+ "image/color"
+ "strings"
+
+ "github.com/charmbracelet/x/ansi"
+ "github.com/charmbracelet/x/ansi/kitty"
+)
+
+// Event represents an input event that can be received from an input source.
+type Event interface{}
+
+// EventStreamer is an interface that defines a method to stream events from an
+// input source. It takes a context and a channel to send events to. The
+// streamer should block until the context is done or an error occurs. The
+// channel should never be closed by the streamer, as it is the responsibility
+// of the consumer to close it when done.
+type EventStreamer interface {
+ StreamEvents(ctx context.Context, ch chan<- Event) error
+}
+
+// UnknownEvent represents an unknown event.
+type UnknownEvent string
+
+// String returns a string representation of the unknown event.
+func (e UnknownEvent) String() string {
+ return fmt.Sprintf("%q", string(e))
+}
+
+// UnknownCsiEvent represents an unknown CSI (Control Sequence Introducer) event.
+type UnknownCsiEvent string
+
+// String returns a string representation of the unknown CSI event.
+func (e UnknownCsiEvent) String() string {
+ return fmt.Sprintf("%q", string(e))
+}
+
+// UnknownSs3Event represents an unknown SS3 (Single Shift 3) event.
+type UnknownSs3Event string
+
+// String returns a string representation of the unknown SS3 event.
+func (e UnknownSs3Event) String() string {
+ return fmt.Sprintf("%q", string(e))
+}
+
+// UnknownOscEvent represents an unknown OSC (Operating System Command) event.
+type UnknownOscEvent string
+
+// String returns a string representation of the unknown OSC event.
+func (e UnknownOscEvent) String() string {
+ return fmt.Sprintf("%q", string(e))
+}
+
+// UnknownDcsEvent represents an unknown DCS (Device Control String) event.
+type UnknownDcsEvent string
+
+// String returns a string representation of the unknown DCS event.
+func (e UnknownDcsEvent) String() string {
+ return fmt.Sprintf("%q", string(e))
+}
+
+// UnknownSosEvent represents an unknown SOS (Start of String) event.
+type UnknownSosEvent string
+
+// String returns a string representation of the unknown SOS event.
+func (e UnknownSosEvent) String() string {
+ return fmt.Sprintf("%q", string(e))
+}
+
+// UnknownPmEvent represents an unknown PM (Privacy Message) event.
+type UnknownPmEvent string
+
+// String returns a string representation of the unknown PM event.
+func (e UnknownPmEvent) String() string {
+ return fmt.Sprintf("%q", string(e))
+}
+
+// UnknownApcEvent represents an unknown APC (Application Program Command) event.
+type UnknownApcEvent string
+
+// String returns a string representation of the unknown APC event.
+func (e UnknownApcEvent) String() string {
+ return fmt.Sprintf("%q", string(e))
+}
+
+// MultiEvent represents multiple messages event.
+type MultiEvent []Event
+
+// String returns a string representation of the multiple messages event.
+func (e MultiEvent) String() string {
+ var sb strings.Builder
+ for _, ev := range e {
+ fmt.Fprintf(&sb, "%v\n", ev)
+ }
+ return sb.String()
+}
+
+// Size represents the size of the terminal window.
+type Size struct {
+ Width int
+ Height int
+}
+
+// Bounds returns the bounds corresponding to the size.
+func (s Size) Bounds() Rectangle {
+ return Rectangle{
+ Min: image.Point{X: 0, Y: 0},
+ Max: image.Point{X: s.Width, Y: s.Height},
+ }
+}
+
+// WindowSizeEvent represents the window size in cells.
+type WindowSizeEvent Size
+
+// Bounds returns the bounds corresponding to the size.
+func (s WindowSizeEvent) Bounds() Rectangle {
+ return Size(s).Bounds()
+}
+
+// PixelSizeEvent represents the window size in pixels.
+type PixelSizeEvent Size
+
+// Bounds returns the bounds corresponding to the size.
+func (s PixelSizeEvent) Bounds() Rectangle {
+ return Size(s).Bounds()
+}
+
+// CellSizeEvent represents the cell size in pixels.
+type CellSizeEvent Size
+
+// Bounds returns the bounds corresponding to the size.
+func (s CellSizeEvent) Bounds() Rectangle {
+ return Size(s).Bounds()
+}
+
+// KeyPressEvent represents a key press event.
+type KeyPressEvent Key
+
+// MatchString returns true if the [Key] matches one of the given strings.
+//
+// A string can be a key name like "enter", "tab", "a", or a printable
+// character like "1" or " ". It can also have combinations of modifiers like
+// "ctrl+a", "shift+enter", "alt+tab", "ctrl+shift+enter", etc.
+func (k KeyPressEvent) MatchString(s ...string) bool {
+ return Key(k).MatchString(s...)
+}
+
+// String implements [fmt.Stringer] and is quite useful for matching key
+// events. For details, on what this returns see [Key.String].
+func (k KeyPressEvent) String() string {
+ return Key(k).String()
+}
+
+// Keystroke returns the keystroke representation of the [Key]. While less type
+// safe than looking at the individual fields, it will usually be more
+// convenient and readable to use this method when matching against keys.
+//
+// Note that modifier keys are always printed in the following order:
+// - ctrl
+// - alt
+// - shift
+// - meta
+// - hyper
+// - super
+//
+// For example, you'll always see "ctrl+shift+alt+a" and never
+// "shift+ctrl+alt+a".
+func (k KeyPressEvent) Keystroke() string {
+ return Key(k).Keystroke()
+}
+
+// Key returns the underlying key event. This is a syntactic sugar for casting
+// the key event to a [Key].
+func (k KeyPressEvent) Key() Key {
+ return Key(k)
+}
+
+// KeyReleaseEvent represents a key release event.
+type KeyReleaseEvent Key
+
+// MatchString returns true if the [Key] matches one of the given strings.
+//
+// A string can be a key name like "enter", "tab", "a", or a printable
+// character like "1" or " ". It can also have combinations of modifiers like
+// "ctrl+a", "shift+enter", "alt+tab", "ctrl+shift+enter", etc.
+func (k KeyReleaseEvent) MatchString(s ...string) bool {
+ return Key(k).MatchString(s...)
+}
+
+// String implements [fmt.Stringer] and is quite useful for matching key
+// events. For details, on what this returns see [Key.String].
+func (k KeyReleaseEvent) String() string {
+ return Key(k).String()
+}
+
+// Keystroke returns the keystroke representation of the [Key]. While less type
+// safe than looking at the individual fields, it will usually be more
+// convenient and readable to use this method when matching against keys.
+//
+// Note that modifier keys are always printed in the following order:
+// - ctrl
+// - alt
+// - shift
+// - meta
+// - hyper
+// - super
+//
+// For example, you'll always see "ctrl+shift+alt+a" and never
+// "shift+ctrl+alt+a".
+func (k KeyReleaseEvent) Keystroke() string {
+ return Key(k).Keystroke()
+}
+
+// Key returns the underlying key event. This is a convenience method and
+// syntactic sugar to satisfy the [KeyEvent] interface, and cast the key event to
+// [Key].
+func (k KeyReleaseEvent) Key() Key {
+ return Key(k)
+}
+
+// KeyEvent represents a key event. This can be either a key press or a key
+// release event.
+type KeyEvent interface {
+ fmt.Stringer
+
+ // Key returns the underlying key event.
+ Key() Key
+}
+
+// MouseEvent represents a mouse message. This is a generic mouse message that
+// can represent any kind of mouse event.
+type MouseEvent interface {
+ fmt.Stringer
+
+ // Mouse returns the underlying mouse event.
+ Mouse() Mouse
+}
+
+// MouseClickEvent represents a mouse button click event.
+type MouseClickEvent Mouse
+
+// String returns a string representation of the mouse click event.
+func (e MouseClickEvent) String() string {
+ return Mouse(e).String()
+}
+
+// Mouse returns the underlying mouse event. This is a convenience method and
+// syntactic sugar to satisfy the [MouseEvent] interface, and cast the mouse
+// event to [Mouse].
+func (e MouseClickEvent) Mouse() Mouse {
+ return Mouse(e)
+}
+
+// MouseReleaseEvent represents a mouse button release event.
+type MouseReleaseEvent Mouse
+
+// String returns a string representation of the mouse release event.
+func (e MouseReleaseEvent) String() string {
+ return Mouse(e).String()
+}
+
+// Mouse returns the underlying mouse event. This is a convenience method and
+// syntactic sugar to satisfy the [MouseEvent] interface, and cast the mouse
+// event to [Mouse].
+func (e MouseReleaseEvent) Mouse() Mouse {
+ return Mouse(e)
+}
+
+// MouseWheelEvent represents a mouse wheel message event.
+type MouseWheelEvent Mouse
+
+// String returns a string representation of the mouse wheel event.
+func (e MouseWheelEvent) String() string {
+ return Mouse(e).String()
+}
+
+// Mouse returns the underlying mouse event. This is a convenience method and
+// syntactic sugar to satisfy the [MouseEvent] interface, and cast the mouse
+// event to [Mouse].
+func (e MouseWheelEvent) Mouse() Mouse {
+ return Mouse(e)
+}
+
+// MouseMotionEvent represents a mouse motion event.
+type MouseMotionEvent Mouse
+
+// String returns a string representation of the mouse motion event.
+func (e MouseMotionEvent) String() string {
+ m := Mouse(e)
+ if m.Button != 0 {
+ return m.String() + "+motion"
+ }
+ return m.String() + "motion"
+}
+
+// Mouse returns the underlying mouse event. This is a convenience method and
+// syntactic sugar to satisfy the [MouseEvent] interface, and cast the mouse
+// event to [Mouse].
+func (e MouseMotionEvent) Mouse() Mouse {
+ return Mouse(e)
+}
+
+// CursorPositionEvent represents a cursor position event. Where X is the
+// zero-based column and Y is the zero-based row.
+type CursorPositionEvent struct {
+ X, Y int
+}
+
+// FocusEvent represents a terminal focus event.
+// This occurs when the terminal gains focus.
+type FocusEvent struct{}
+
+// BlurEvent represents a terminal blur event.
+// This occurs when the terminal loses focus.
+type BlurEvent struct{}
+
+// DarkColorSchemeEvent is sent when the operating system is using a dark color
+// scheme. This is typically used to notify applications of the current or new
+// system color scheme.
+type DarkColorSchemeEvent struct{}
+
+// LightColorSchemeEvent is sent when the operating system is using a light color
+// scheme. This is typically used to notify applications of the current or new
+// system color scheme.
+type LightColorSchemeEvent struct{}
+
+// PasteEvent is an message that is emitted when a terminal receives pasted text
+// using bracketed-paste.
+type PasteEvent struct {
+ // Content is the pasted text content.
+ Content string
+}
+
+// String returns the pasted content as a string.
+func (e PasteEvent) String() string {
+ return e.Content
+}
+
+// PasteStartEvent is an message that is emitted when the terminal starts the
+// bracketed-paste text.
+type PasteStartEvent struct{}
+
+// PasteEndEvent is an message that is emitted when the terminal ends the
+// bracketed-paste text.
+type PasteEndEvent struct{}
+
+// TerminalVersionEvent is a message that represents the terminal version.
+type TerminalVersionEvent struct {
+ Name string
+}
+
+// String returns the terminal version as a string.
+func (e TerminalVersionEvent) String() string {
+ return e.Name
+}
+
+// ModifyOtherKeysEvent represents a modifyOtherKeys event.
+//
+// 0: disable
+// 1: enable mode 1
+// 2: enable mode 2
+//
+// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Functions-using-CSI-_-ordered-by-the-final-character_s_
+// See: https://invisible-island.net/xterm/manpage/xterm.html#VT100-Widget-Resources:modifyOtherKeys
+type ModifyOtherKeysEvent struct {
+ Mode int
+}
+
+// KittyGraphicsEvent represents a Kitty Graphics response event.
+//
+// See https://sw.kovidgoyal.net/kitty/graphics-protocol/
+type KittyGraphicsEvent struct {
+ Options kitty.Options
+ Payload []byte
+}
+
+// KeyboardEnhancementsEvent represents a keyboard enhancements report event.
+type KeyboardEnhancementsEvent struct {
+ // Flags are the Kitty Keyboard Enhancement flags.
+ //
+ // Bit values:
+ //
+ // 00000001: Disambiguate escape codes
+ // 00000010: Report event types
+ // 00000100: Report alternate keys
+ // 00001000: Report all keys as escape codes
+ // 00010000: Report associated text
+ //
+ // See: https://sw.kovidgoyal.net/kitty/keyboard-protocol/#keyboard-enhancements
+ Flags int
+}
+
+// Contains reports whether m contains the given enhancements.
+func (e KeyboardEnhancementsEvent) Contains(enhancements int) bool {
+ return e.Flags&enhancements == enhancements
+}
+
+// SupportsKeyDisambiguation returns whether the terminal supports reporting
+// disambiguous keys as escape codes.
+func (e KeyboardEnhancementsEvent) SupportsKeyDisambiguation() bool {
+ return e.Flags&ansi.KittyDisambiguateEscapeCodes != 0
+}
+
+// SupportsKeyReleases returns whether the terminal supports key release
+// events.
+func (e KeyboardEnhancementsEvent) SupportsKeyReleases() bool {
+ return e.Flags&ansi.KittyReportEventTypes != 0
+}
+
+// SupportsUniformKeyLayout returns whether the terminal supports reporting key
+// events as though they were on a PC-101 layout.
+func (e KeyboardEnhancementsEvent) SupportsUniformKeyLayout() bool {
+ return e.SupportsKeyDisambiguation() &&
+ e.Flags&ansi.KittyReportAlternateKeys != 0 &&
+ e.Flags&ansi.KittyReportAllKeysAsEscapeCodes != 0
+}
+
+// PrimaryDeviceAttributesEvent is an event that represents the terminal
+// primary device attributes.
+//
+// Common attributes include:
+// - 1 132 columns
+// - 2 Printer port
+// - 4 Sixel
+// - 6 Selective erase
+// - 7 Soft character set (DRCS)
+// - 8 User-defined keys (UDKs)
+// - 9 National replacement character sets (NRCS) (International terminal only)
+// - 12 Yugoslavian (SCS)
+// - 15 Technical character set
+// - 18 Windowing capability
+// - 21 Horizontal scrolling
+// - 23 Greek
+// - 24 Turkish
+// - 42 ISO Latin-2 character set
+// - 44 PCTerm
+// - 45 Soft key map
+// - 46 ASCII emulation
+//
+// See [ansi.PrimaryDeviceAttributes] for more details.
+type PrimaryDeviceAttributesEvent []int
+
+// SecondaryDeviceAttributesEvent is an event that represents the terminal
+// secondary device attributes.
+//
+// See [ansi.SecondaryDeviceAttributes] for more details.
+type SecondaryDeviceAttributesEvent []int
+
+// TertiaryDeviceAttributesEvent is an event that represents the terminal
+// tertiary device attributes.
+//
+// See [ansi.TertiaryDeviceAttributes] for more details.
+type TertiaryDeviceAttributesEvent string
+
+// ModeReportEvent is a message that represents a mode report event (DECRPM).
+//
+// See: https://vt100.net/docs/vt510-rm/DECRPM.html
+type ModeReportEvent struct {
+ // Mode is the mode number.
+ Mode ansi.Mode
+
+ // Value is the mode value.
+ Value ansi.ModeSetting
+}
+
+// ForegroundColorEvent represents a foreground color event. This event is
+// emitted when the terminal requests the terminal foreground color using
+// [ansi.RequestForegroundColor].
+type ForegroundColorEvent struct{ color.Color }
+
+// String returns the hex representation of the color.
+func (e ForegroundColorEvent) String() string {
+ return colorToHex(e.Color)
+}
+
+// IsDark returns whether the color is dark.
+func (e ForegroundColorEvent) IsDark() bool {
+ return isDarkColor(e.Color)
+}
+
+// BackgroundColorEvent represents a background color event. This event is
+// emitted when the terminal requests the terminal background color using
+// [ansi.RequestBackgroundColor].
+type BackgroundColorEvent struct{ color.Color }
+
+// String returns the hex representation of the color.
+func (e BackgroundColorEvent) String() string {
+ return colorToHex(e)
+}
+
+// IsDark returns whether the color is dark.
+func (e BackgroundColorEvent) IsDark() bool {
+ return isDarkColor(e.Color)
+}
+
+// CursorColorEvent represents a cursor color change event. This event is
+// emitted when the program requests the terminal cursor color using
+// [ansi.RequestCursorColor].
+type CursorColorEvent struct{ color.Color }
+
+// String returns the hex representation of the color.
+func (e CursorColorEvent) String() string {
+ return colorToHex(e)
+}
+
+// IsDark returns whether the color is dark.
+func (e CursorColorEvent) IsDark() bool {
+ return isDarkColor(e)
+}
+
+// WindowOpEvent is a window operation (XTWINOPS) report event. This is used to
+// report various window operations such as reporting the window size or cell
+// size.
+type WindowOpEvent struct {
+ Op int
+ Args []int
+}
+
+// CapabilityEvent represents a Termcap/Terminfo response event. Termcap
+// responses are generated by the terminal in response to RequestTermcap
+// (XTGETTCAP) requests.
+//
+// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Operating-System-Commands
+type CapabilityEvent struct {
+ Content string
+}
+
+// String returns the capability content.
+func (e CapabilityEvent) String() string {
+ return e.Content
+}
+
+// ClipboardSelection represents a clipboard selection. The most common
+// clipboard selections are "system" and "primary" and selections.
+type ClipboardSelection = byte
+
+// Clipboard selections.
+const (
+ SystemClipboard ClipboardSelection = ansi.SystemClipboard
+ PrimaryClipboard ClipboardSelection = ansi.PrimaryClipboard
+)
+
+// ClipboardEvent is a clipboard read message event. This message is emitted when
+// a terminal receives an OSC52 clipboard read message event.
+type ClipboardEvent struct {
+ Content string
+ Selection ClipboardSelection
+}
+
+// String returns the string representation of the clipboard message.
+func (e ClipboardEvent) String() string {
+ return e.Content
+}
+
+// Clipboard returns the clipboard selection. This can be either
+// [SystemClipboard] 'c' or [PrimaryClipboard] 'p'.
+func (e ClipboardEvent) Clipboard() ClipboardSelection {
+ return e.Selection
+}
+
+// ignoredEvent represents a sequence event that is ignored by the terminal
+// reader. This is used to ignore certain sequences that can be canceled.
+type ignoredEvent string
diff --git a/vendor/github.com/charmbracelet/ultraviolet/key.go b/vendor/github.com/charmbracelet/ultraviolet/key.go
new file mode 100644
index 0000000000..f3b5f6a57e
--- /dev/null
+++ b/vendor/github.com/charmbracelet/ultraviolet/key.go
@@ -0,0 +1,762 @@
+package uv
+
+import (
+ "strings"
+ "unicode"
+ "unicode/utf8"
+
+ "github.com/charmbracelet/x/ansi"
+)
+
+// KeyMod represents modifier keys.
+type KeyMod int
+
+// Modifier keys.
+const (
+ ModShift KeyMod = 1 << iota
+ ModAlt
+ ModCtrl
+ ModMeta
+
+ // These modifiers are used with the Kitty protocol.
+ // XXX: Meta and Super are swapped in the Kitty protocol,
+ // this is to preserve compatibility with XTerm modifiers.
+
+ ModHyper
+ ModSuper // Windows/Command keys
+
+ // These are key lock states.
+
+ ModCapsLock
+ ModNumLock
+ ModScrollLock // Defined in Windows API only
+)
+
+// Contains reports whether m contains the given modifiers.
+//
+// Example:
+//
+// m := ModAlt | ModCtrl
+// m.Contains(ModCtrl) // true
+// m.Contains(ModAlt | ModCtrl) // true
+// m.Contains(ModAlt | ModCtrl | ModShift) // false
+func (m KeyMod) Contains(mods KeyMod) bool {
+ return m&mods == mods
+}
+
+const (
+ // KeyExtended is a special key code used to signify that a key event
+ // contains multiple runes.
+ KeyExtended = unicode.MaxRune + 1
+)
+
+// Special key symbols.
+const (
+
+ // Special keys.
+
+ KeyUp rune = KeyExtended + iota + 1
+ KeyDown
+ KeyRight
+ KeyLeft
+ KeyBegin
+ KeyFind
+ KeyInsert
+ KeyDelete
+ KeySelect
+ KeyPgUp
+ KeyPgDown
+ KeyHome
+ KeyEnd
+
+ // Keypad keys.
+
+ KeyKpEnter
+ KeyKpEqual
+ KeyKpMultiply
+ KeyKpPlus
+ KeyKpComma
+ KeyKpMinus
+ KeyKpDecimal
+ KeyKpDivide
+ KeyKp0
+ KeyKp1
+ KeyKp2
+ KeyKp3
+ KeyKp4
+ KeyKp5
+ KeyKp6
+ KeyKp7
+ KeyKp8
+ KeyKp9
+
+ //nolint:godox
+ // The following are keys defined in the Kitty keyboard protocol.
+ // TODO: Investigate the names of these keys.
+
+ KeyKpSep
+ KeyKpUp
+ KeyKpDown
+ KeyKpLeft
+ KeyKpRight
+ KeyKpPgUp
+ KeyKpPgDown
+ KeyKpHome
+ KeyKpEnd
+ KeyKpInsert
+ KeyKpDelete
+ KeyKpBegin
+
+ // Function keys.
+
+ KeyF1
+ KeyF2
+ KeyF3
+ KeyF4
+ KeyF5
+ KeyF6
+ KeyF7
+ KeyF8
+ KeyF9
+ KeyF10
+ KeyF11
+ KeyF12
+ KeyF13
+ KeyF14
+ KeyF15
+ KeyF16
+ KeyF17
+ KeyF18
+ KeyF19
+ KeyF20
+ KeyF21
+ KeyF22
+ KeyF23
+ KeyF24
+ KeyF25
+ KeyF26
+ KeyF27
+ KeyF28
+ KeyF29
+ KeyF30
+ KeyF31
+ KeyF32
+ KeyF33
+ KeyF34
+ KeyF35
+ KeyF36
+ KeyF37
+ KeyF38
+ KeyF39
+ KeyF40
+ KeyF41
+ KeyF42
+ KeyF43
+ KeyF44
+ KeyF45
+ KeyF46
+ KeyF47
+ KeyF48
+ KeyF49
+ KeyF50
+ KeyF51
+ KeyF52
+ KeyF53
+ KeyF54
+ KeyF55
+ KeyF56
+ KeyF57
+ KeyF58
+ KeyF59
+ KeyF60
+ KeyF61
+ KeyF62
+ KeyF63
+
+ //nolint:godox
+ // The following are keys defined in the Kitty keyboard protocol.
+ // TODO: Investigate the names of these keys.
+
+ KeyCapsLock
+ KeyScrollLock
+ KeyNumLock
+ KeyPrintScreen
+ KeyPause
+ KeyMenu
+
+ KeyMediaPlay
+ KeyMediaPause
+ KeyMediaPlayPause
+ KeyMediaReverse
+ KeyMediaStop
+ KeyMediaFastForward
+ KeyMediaRewind
+ KeyMediaNext
+ KeyMediaPrev
+ KeyMediaRecord
+
+ KeyLowerVol
+ KeyRaiseVol
+ KeyMute
+
+ KeyLeftShift
+ KeyLeftAlt
+ KeyLeftCtrl
+ KeyLeftSuper
+ KeyLeftHyper
+ KeyLeftMeta
+ KeyRightShift
+ KeyRightAlt
+ KeyRightCtrl
+ KeyRightSuper
+ KeyRightHyper
+ KeyRightMeta
+ KeyIsoLevel3Shift
+ KeyIsoLevel5Shift
+
+ // Special names in C0.
+
+ KeyBackspace = rune(ansi.DEL)
+ KeyTab = rune(ansi.HT)
+ KeyEnter = rune(ansi.CR)
+ KeyReturn = KeyEnter
+ KeyEscape = rune(ansi.ESC)
+ KeyEsc = KeyEscape
+
+ // Special names in G0.
+
+ KeySpace = rune(ansi.SP)
+)
+
+// Key represents a Key press or release event. It contains information about
+// the Key pressed, like the runes, the type of Key, and the modifiers pressed.
+// There are a couple general patterns you could use to check for key presses
+// or releases:
+//
+// // Switch on the string representation of the key (shorter)
+// switch ev := ev.(type) {
+// case KeyPressEvent:
+// switch ev.String() {
+// case "enter":
+// fmt.Println("you pressed enter!")
+// case "a":
+// fmt.Println("you pressed a!")
+// }
+// }
+//
+// // Switch on the key type (more foolproof)
+// switch ev := ev.(type) {
+// case KeyEvent:
+// // catch both KeyPressEvent and KeyReleaseEvent
+// switch key := ev.Key(); key.Code {
+// case KeyEnter:
+// fmt.Println("you pressed enter!")
+// default:
+// switch key.Text {
+// case "a":
+// fmt.Println("you pressed a!")
+// }
+// }
+// }
+//
+// Note that [Key.Text] will be empty for special keys like [KeyEnter],
+// [KeyTab], and for keys that don't represent printable characters like key
+// combos with modifier keys. In other words, [Key.Text] is populated only for
+// keys that represent printable characters shifted or unshifted (like 'a',
+// 'A', '1', '!', etc.).
+type Key struct {
+ // Text contains the actual characters received. This usually the same as
+ // [Key.Code]. When [Key.Text] is non-empty, it indicates that the key
+ // pressed represents printable character(s).
+ Text string
+
+ // Mod represents modifier keys, like [ModCtrl], [ModAlt], and so on.
+ Mod KeyMod
+
+ // Code represents the key pressed. This is usually a special key like
+ // [KeyTab], [KeyEnter], [KeyF1], or a printable character like 'a'.
+ Code rune
+
+ // ShiftedCode is the actual, shifted key pressed by the user. For example,
+ // if the user presses shift+a, or caps lock is on, [Key.ShiftedCode] will
+ // be 'A' and [Key.Code] will be 'a'.
+ //
+ // In the case of non-latin keyboards, like Arabic, [Key.ShiftedCode] is the
+ // unshifted key on the keyboard.
+ //
+ // This is only available with the Kitty Keyboard Protocol or the Windows
+ // Console API.
+ ShiftedCode rune
+
+ // BaseCode is the key pressed according to the standard PC-101 key layout.
+ // On international keyboards, this is the key that would be pressed if the
+ // keyboard was set to US PC-101 layout.
+ //
+ // For example, if the user presses 'q' on a French AZERTY keyboard,
+ // [Key.BaseCode] will be 'q'.
+ //
+ // This is only available with the Kitty Keyboard Protocol or the Windows
+ // Console API.
+ BaseCode rune
+
+ // IsRepeat indicates whether the key is being held down and sending events
+ // repeatedly.
+ //
+ // This is only available with the Kitty Keyboard Protocol or the Windows
+ // Console API.
+ IsRepeat bool
+}
+
+// MatchString returns true if the [Key] matches one of the given strings.
+//
+// A string can be a key name like "enter", "tab", "a", or a printable
+// character like "1" or " ". It can also have combinations of modifiers like
+// "ctrl+a", "shift+enter", "alt+tab", "ctrl+shift+enter", etc.
+func (k Key) MatchString(s ...string) bool {
+ for _, s := range s {
+ if keyMatchString(k, s) {
+ return true
+ }
+ }
+ return false
+}
+
+func keyMatchString(k Key, s string) bool {
+ var (
+ mod KeyMod
+ code rune
+ text string
+ )
+ parts := strings.Split(s, "+")
+ for _, part := range parts {
+ switch part {
+ case "ctrl":
+ mod |= ModCtrl
+ case "alt":
+ mod |= ModAlt
+ case "shift":
+ mod |= ModShift
+ case "meta":
+ mod |= ModMeta
+ case "hyper":
+ mod |= ModHyper
+ case "super":
+ mod |= ModSuper
+ case "capslock":
+ mod |= ModCapsLock
+ case "scrolllock":
+ mod |= ModScrollLock
+ case "numlock":
+ mod |= ModNumLock
+ default:
+ // Check if the part is a key name.
+ if k, ok := stringKeyType[part]; ok {
+ code = k
+ } else {
+ // Check if the part is a printable character.
+ if utf8.RuneCountInString(part) == 1 {
+ code, _ = utf8.DecodeRuneInString(part)
+ } else {
+ // Multi-rune key.
+ code = KeyExtended
+ text = part
+ }
+ }
+ }
+ }
+
+ // Check if we have a printable character.
+ smod := mod &^ (ModShift | ModCapsLock)
+ if smod == 0 && text == "" && unicode.IsPrint(code) {
+ if mod&ModShift != 0 || mod&ModCapsLock != 0 {
+ // Shifted code we need to use uppercase.
+ text = string(unicode.ToUpper(code))
+ } else {
+ // Otherwise, use the code as is.
+ text = string(code)
+ }
+ }
+
+ // Check if we have a match.
+ return (k.Mod == mod && k.Code == code) ||
+ (k.Text != "" && k.Text == text)
+}
+
+// String implements [fmt.Stringer] and is quite useful for matching key
+// events. It will return the textual representation of the [Key] if there is
+// one, otherwise, it will fallback to [Key.Keystroke].
+//
+// For example, you'll always get "?" and instead of "shift+/" on a US ANSI
+// keyboard.
+func (k Key) String() string {
+ if len(k.Text) > 0 && k.Text != " " {
+ return k.Text
+ }
+ return k.Keystroke()
+}
+
+// Keystroke returns the keystroke representation of the [Key]. While less type
+// safe than looking at the individual fields, it will usually be more
+// convenient and readable to use this method when matching against keys.
+//
+// Note that modifier keys are always printed in the following order:
+// - ctrl
+// - alt
+// - shift
+// - meta
+// - hyper
+// - super
+//
+// For example, you'll always see "ctrl+shift+alt+a" and never
+// "shift+ctrl+alt+a".
+func (k Key) Keystroke() string {
+ var sb strings.Builder
+ if k.Mod.Contains(ModCtrl) && k.Code != KeyLeftCtrl && k.Code != KeyRightCtrl {
+ sb.WriteString("ctrl+")
+ }
+ if k.Mod.Contains(ModAlt) && k.Code != KeyLeftAlt && k.Code != KeyRightAlt {
+ sb.WriteString("alt+")
+ }
+ if k.Mod.Contains(ModShift) && k.Code != KeyLeftShift && k.Code != KeyRightShift {
+ sb.WriteString("shift+")
+ }
+ if k.Mod.Contains(ModMeta) && k.Code != KeyLeftMeta && k.Code != KeyRightMeta {
+ sb.WriteString("meta+")
+ }
+ if k.Mod.Contains(ModHyper) && k.Code != KeyLeftHyper && k.Code != KeyRightHyper {
+ sb.WriteString("hyper+")
+ }
+ if k.Mod.Contains(ModSuper) && k.Code != KeyLeftSuper && k.Code != KeyRightSuper {
+ sb.WriteString("super+")
+ }
+
+ if kt, ok := keyTypeString[k.Code]; ok {
+ sb.WriteString(kt)
+ } else {
+ code := k.Code
+ if k.BaseCode != 0 {
+ // If a [Key.BaseCode] is present, use it to represent a key using the standard
+ // PC-101 key layout.
+ code = k.BaseCode
+ }
+
+ switch code {
+ case KeySpace:
+ // Space is the only invisible printable character.
+ sb.WriteString("space")
+ case KeyExtended:
+ // Write the actual text of the key when the key contains multiple
+ // runes.
+ sb.WriteString(k.Text)
+ default:
+ sb.WriteRune(code)
+ }
+ }
+
+ return sb.String()
+}
+
+var keyTypeString = map[rune]string{
+ KeyEnter: "enter",
+ KeyTab: "tab",
+ KeyBackspace: "backspace",
+ KeyEscape: "esc",
+ KeySpace: "space",
+ KeyUp: "up",
+ KeyDown: "down",
+ KeyLeft: "left",
+ KeyRight: "right",
+ KeyBegin: "begin",
+ KeyFind: "find",
+ KeyInsert: "insert",
+ KeyDelete: "delete",
+ KeySelect: "select",
+ KeyPgUp: "pgup",
+ KeyPgDown: "pgdown",
+ KeyHome: "home",
+ KeyEnd: "end",
+ KeyKpEnter: "enter",
+ KeyKpEqual: "equal",
+ KeyKpMultiply: "mul",
+ KeyKpPlus: "plus",
+ KeyKpComma: "comma",
+ KeyKpMinus: "minus",
+ KeyKpDecimal: "period",
+ KeyKpDivide: "div",
+ KeyKp0: "0",
+ KeyKp1: "1",
+ KeyKp2: "2",
+ KeyKp3: "3",
+ KeyKp4: "4",
+ KeyKp5: "5",
+ KeyKp6: "6",
+ KeyKp7: "7",
+ KeyKp8: "8",
+ KeyKp9: "9",
+
+ // Kitty keyboard extension
+ KeyKpSep: "sep",
+ KeyKpUp: "up",
+ KeyKpDown: "down",
+ KeyKpLeft: "left",
+ KeyKpRight: "right",
+ KeyKpPgUp: "pgup",
+ KeyKpPgDown: "pgdown",
+ KeyKpHome: "home",
+ KeyKpEnd: "end",
+ KeyKpInsert: "insert",
+ KeyKpDelete: "delete",
+ KeyKpBegin: "begin",
+
+ KeyF1: "f1",
+ KeyF2: "f2",
+ KeyF3: "f3",
+ KeyF4: "f4",
+ KeyF5: "f5",
+ KeyF6: "f6",
+ KeyF7: "f7",
+ KeyF8: "f8",
+ KeyF9: "f9",
+ KeyF10: "f10",
+ KeyF11: "f11",
+ KeyF12: "f12",
+ KeyF13: "f13",
+ KeyF14: "f14",
+ KeyF15: "f15",
+ KeyF16: "f16",
+ KeyF17: "f17",
+ KeyF18: "f18",
+ KeyF19: "f19",
+ KeyF20: "f20",
+ KeyF21: "f21",
+ KeyF22: "f22",
+ KeyF23: "f23",
+ KeyF24: "f24",
+ KeyF25: "f25",
+ KeyF26: "f26",
+ KeyF27: "f27",
+ KeyF28: "f28",
+ KeyF29: "f29",
+ KeyF30: "f30",
+ KeyF31: "f31",
+ KeyF32: "f32",
+ KeyF33: "f33",
+ KeyF34: "f34",
+ KeyF35: "f35",
+ KeyF36: "f36",
+ KeyF37: "f37",
+ KeyF38: "f38",
+ KeyF39: "f39",
+ KeyF40: "f40",
+ KeyF41: "f41",
+ KeyF42: "f42",
+ KeyF43: "f43",
+ KeyF44: "f44",
+ KeyF45: "f45",
+ KeyF46: "f46",
+ KeyF47: "f47",
+ KeyF48: "f48",
+ KeyF49: "f49",
+ KeyF50: "f50",
+ KeyF51: "f51",
+ KeyF52: "f52",
+ KeyF53: "f53",
+ KeyF54: "f54",
+ KeyF55: "f55",
+ KeyF56: "f56",
+ KeyF57: "f57",
+ KeyF58: "f58",
+ KeyF59: "f59",
+ KeyF60: "f60",
+ KeyF61: "f61",
+ KeyF62: "f62",
+ KeyF63: "f63",
+
+ // Kitty keyboard extension
+ KeyCapsLock: "capslock",
+ KeyScrollLock: "scrolllock",
+ KeyNumLock: "numlock",
+ KeyPrintScreen: "printscreen",
+ KeyPause: "pause",
+ KeyMenu: "menu",
+ KeyMediaPlay: "mediaplay",
+ KeyMediaPause: "mediapause",
+ KeyMediaPlayPause: "mediaplaypause",
+ KeyMediaReverse: "mediareverse",
+ KeyMediaStop: "mediastop",
+ KeyMediaFastForward: "mediafastforward",
+ KeyMediaRewind: "mediarewind",
+ KeyMediaNext: "medianext",
+ KeyMediaPrev: "mediaprev",
+ KeyMediaRecord: "mediarecord",
+ KeyLowerVol: "lowervol",
+ KeyRaiseVol: "raisevol",
+ KeyMute: "mute",
+ KeyLeftShift: "leftshift",
+ KeyLeftAlt: "leftalt",
+ KeyLeftCtrl: "leftctrl",
+ KeyLeftSuper: "leftsuper",
+ KeyLeftHyper: "lefthyper",
+ KeyLeftMeta: "leftmeta",
+ KeyRightShift: "rightshift",
+ KeyRightAlt: "rightalt",
+ KeyRightCtrl: "rightctrl",
+ KeyRightSuper: "rightsuper",
+ KeyRightHyper: "righthyper",
+ KeyRightMeta: "rightmeta",
+ KeyIsoLevel3Shift: "isolevel3shift",
+ KeyIsoLevel5Shift: "isolevel5shift",
+}
+
+var stringKeyType = map[string]rune{
+ "enter": KeyEnter,
+ "tab": KeyTab,
+ "backspace": KeyBackspace,
+ "escape": KeyEscape,
+ "esc": KeyEscape,
+ "space": KeySpace,
+ "up": KeyUp,
+ "down": KeyDown,
+ "left": KeyLeft,
+ "right": KeyRight,
+ "begin": KeyBegin,
+ "find": KeyFind,
+ "insert": KeyInsert,
+ "delete": KeyDelete,
+ "select": KeySelect,
+ "pgup": KeyPgUp,
+ "pgdown": KeyPgDown,
+ "home": KeyHome,
+ "end": KeyEnd,
+ "kpenter": KeyKpEnter,
+ "kpequal": KeyKpEqual,
+ "kpmul": KeyKpMultiply,
+ "kpplus": KeyKpPlus,
+ "kpcomma": KeyKpComma,
+ "kpminus": KeyKpMinus,
+ "kpperiod": KeyKpDecimal,
+ "kpdiv": KeyKpDivide,
+ "kp0": KeyKp0,
+ "kp1": KeyKp1,
+ "kp2": KeyKp2,
+ "kp3": KeyKp3,
+ "kp4": KeyKp4,
+ "kp5": KeyKp5,
+ "kp6": KeyKp6,
+ "kp7": KeyKp7,
+ "kp8": KeyKp8,
+ "kp9": KeyKp9,
+
+ // Kitty keyboard extension
+ "kpsep": KeyKpSep,
+ "kpup": KeyKpUp,
+ "kpdown": KeyKpDown,
+ "kpleft": KeyKpLeft,
+ "kpright": KeyKpRight,
+ "kppgup": KeyKpPgUp,
+ "kppgdown": KeyKpPgDown,
+ "kphome": KeyKpHome,
+ "kpend": KeyKpEnd,
+ "kpinsert": KeyKpInsert,
+ "kpdelete": KeyKpDelete,
+ "kpbegin": KeyKpBegin,
+
+ "f1": KeyF1,
+ "f2": KeyF2,
+ "f3": KeyF3,
+ "f4": KeyF4,
+ "f5": KeyF5,
+ "f6": KeyF6,
+ "f7": KeyF7,
+ "f8": KeyF8,
+ "f9": KeyF9,
+ "f10": KeyF10,
+ "f11": KeyF11,
+ "f12": KeyF12,
+ "f13": KeyF13,
+ "f14": KeyF14,
+ "f15": KeyF15,
+ "f16": KeyF16,
+ "f17": KeyF17,
+ "f18": KeyF18,
+ "f19": KeyF19,
+ "f20": KeyF20,
+ "f21": KeyF21,
+ "f22": KeyF22,
+ "f23": KeyF23,
+ "f24": KeyF24,
+ "f25": KeyF25,
+ "f26": KeyF26,
+ "f27": KeyF27,
+ "f28": KeyF28,
+ "f29": KeyF29,
+ "f30": KeyF30,
+ "f31": KeyF31,
+ "f32": KeyF32,
+ "f33": KeyF33,
+ "f34": KeyF34,
+ "f35": KeyF35,
+ "f36": KeyF36,
+ "f37": KeyF37,
+ "f38": KeyF38,
+ "f39": KeyF39,
+ "f40": KeyF40,
+ "f41": KeyF41,
+ "f42": KeyF42,
+ "f43": KeyF43,
+ "f44": KeyF44,
+ "f45": KeyF45,
+ "f46": KeyF46,
+ "f47": KeyF47,
+ "f48": KeyF48,
+ "f49": KeyF49,
+ "f50": KeyF50,
+ "f51": KeyF51,
+ "f52": KeyF52,
+ "f53": KeyF53,
+ "f54": KeyF54,
+ "f55": KeyF55,
+ "f56": KeyF56,
+ "f57": KeyF57,
+ "f58": KeyF58,
+ "f59": KeyF59,
+ "f60": KeyF60,
+ "f61": KeyF61,
+ "f62": KeyF62,
+ "f63": KeyF63,
+
+ // Kitty keyboard extension
+ "capslock": KeyCapsLock,
+ "scrolllock": KeyScrollLock,
+ "numlock": KeyNumLock,
+ "printscreen": KeyPrintScreen,
+ "pause": KeyPause,
+ "menu": KeyMenu,
+ "mediaplay": KeyMediaPlay,
+ "mediapause": KeyMediaPause,
+ "mediaplaypause": KeyMediaPlayPause,
+ "mediareverse": KeyMediaReverse,
+ "mediastop": KeyMediaStop,
+ "mediafastforward": KeyMediaFastForward,
+ "mediarewind": KeyMediaRewind,
+ "medianext": KeyMediaNext,
+ "mediaprev": KeyMediaPrev,
+ "mediarecord": KeyMediaRecord,
+ "lowervol": KeyLowerVol,
+ "raisevol": KeyRaiseVol,
+ "mute": KeyMute,
+ "leftshift": KeyLeftShift,
+ "leftalt": KeyLeftAlt,
+ "leftctrl": KeyLeftCtrl,
+ "leftsuper": KeyLeftSuper,
+ "lefthyper": KeyLeftHyper,
+ "leftmeta": KeyLeftMeta,
+ "rightshift": KeyRightShift,
+ "rightalt": KeyRightAlt,
+ "rightctrl": KeyRightCtrl,
+ "rightsuper": KeyRightSuper,
+ "righthyper": KeyRightHyper,
+ "rightmeta": KeyRightMeta,
+ "isolevel3shift": KeyIsoLevel3Shift,
+ "isolevel5shift": KeyIsoLevel5Shift,
+}
diff --git a/vendor/github.com/charmbracelet/ultraviolet/key_table.go b/vendor/github.com/charmbracelet/ultraviolet/key_table.go
new file mode 100644
index 0000000000..285ed70fac
--- /dev/null
+++ b/vendor/github.com/charmbracelet/ultraviolet/key_table.go
@@ -0,0 +1,664 @@
+package uv
+
+import (
+ "strconv"
+ "strings"
+
+ "github.com/charmbracelet/x/ansi"
+ "github.com/xo/terminfo"
+)
+
+// buildKeysTable builds a table of key sequences and their corresponding key
+// events based on the VT100/VT200, XTerm, and Urxvt terminal specs.
+func buildKeysTable(flags LegacyKeyEncoding, term string, useTerminfo bool) map[string]Key {
+ nul := Key{Code: KeySpace, Mod: ModCtrl} // ctrl+@ or ctrl+space
+ if flags&flagCtrlAt != 0 {
+ nul = Key{Code: '@', Mod: ModCtrl}
+ }
+
+ tab := Key{Code: KeyTab} // ctrl+i or tab
+ if flags&flagCtrlI != 0 {
+ tab = Key{Code: 'i', Mod: ModCtrl}
+ }
+
+ enter := Key{Code: KeyEnter} // ctrl+m or enter
+ if flags&flagCtrlM != 0 {
+ enter = Key{Code: 'm', Mod: ModCtrl}
+ }
+
+ esc := Key{Code: KeyEscape} // ctrl+[ or escape
+ if flags&flagCtrlOpenBracket != 0 {
+ esc = Key{Code: '[', Mod: ModCtrl} // ctrl+[ or escape
+ }
+
+ del := Key{Code: KeyBackspace}
+ if flags&flagBackspace != 0 {
+ del.Code = KeyDelete
+ }
+
+ find := Key{Code: KeyHome}
+ if flags&flagFind != 0 {
+ find.Code = KeyFind
+ }
+
+ sel := Key{Code: KeyEnd}
+ if flags&flagSelect != 0 {
+ sel.Code = KeySelect
+ }
+
+ // The following is a table of key sequences and their corresponding key
+ // events based on the VT100/VT200 terminal specs.
+ //
+ // See: https://vt100.net/docs/vt100-ug/chapter3.html#S3.2
+ // See: https://vt100.net/docs/vt220-rm/chapter3.html
+ //
+ // XXX: These keys may be overwritten by other options like XTerm or
+ // Terminfo.
+ table := map[string]Key{
+ // C0 control characters
+ string(byte(ansi.NUL)): nul,
+ string(byte(ansi.SOH)): {Code: 'a', Mod: ModCtrl},
+ string(byte(ansi.STX)): {Code: 'b', Mod: ModCtrl},
+ string(byte(ansi.ETX)): {Code: 'c', Mod: ModCtrl},
+ string(byte(ansi.EOT)): {Code: 'd', Mod: ModCtrl},
+ string(byte(ansi.ENQ)): {Code: 'e', Mod: ModCtrl},
+ string(byte(ansi.ACK)): {Code: 'f', Mod: ModCtrl},
+ string(byte(ansi.BEL)): {Code: 'g', Mod: ModCtrl},
+ string(byte(ansi.BS)): {Code: 'h', Mod: ModCtrl},
+ string(byte(ansi.HT)): tab,
+ string(byte(ansi.LF)): {Code: 'j', Mod: ModCtrl},
+ string(byte(ansi.VT)): {Code: 'k', Mod: ModCtrl},
+ string(byte(ansi.FF)): {Code: 'l', Mod: ModCtrl},
+ string(byte(ansi.CR)): enter,
+ string(byte(ansi.SO)): {Code: 'n', Mod: ModCtrl},
+ string(byte(ansi.SI)): {Code: 'o', Mod: ModCtrl},
+ string(byte(ansi.DLE)): {Code: 'p', Mod: ModCtrl},
+ string(byte(ansi.DC1)): {Code: 'q', Mod: ModCtrl},
+ string(byte(ansi.DC2)): {Code: 'r', Mod: ModCtrl},
+ string(byte(ansi.DC3)): {Code: 's', Mod: ModCtrl},
+ string(byte(ansi.DC4)): {Code: 't', Mod: ModCtrl},
+ string(byte(ansi.NAK)): {Code: 'u', Mod: ModCtrl},
+ string(byte(ansi.SYN)): {Code: 'v', Mod: ModCtrl},
+ string(byte(ansi.ETB)): {Code: 'w', Mod: ModCtrl},
+ string(byte(ansi.CAN)): {Code: 'x', Mod: ModCtrl},
+ string(byte(ansi.EM)): {Code: 'y', Mod: ModCtrl},
+ string(byte(ansi.SUB)): {Code: 'z', Mod: ModCtrl},
+ string(byte(ansi.ESC)): esc,
+ string(byte(ansi.FS)): {Code: '\\', Mod: ModCtrl},
+ string(byte(ansi.GS)): {Code: ']', Mod: ModCtrl},
+ string(byte(ansi.RS)): {Code: '^', Mod: ModCtrl},
+ string(byte(ansi.US)): {Code: '_', Mod: ModCtrl},
+
+ // Special keys in G0
+ string(byte(ansi.SP)): {Code: KeySpace, Text: " "},
+ string(byte(ansi.DEL)): del,
+
+ // Special keys
+
+ "\x1b[Z": {Code: KeyTab, Mod: ModShift},
+
+ "\x1b[1~": find,
+ "\x1b[2~": {Code: KeyInsert},
+ "\x1b[3~": {Code: KeyDelete},
+ "\x1b[4~": sel,
+ "\x1b[5~": {Code: KeyPgUp},
+ "\x1b[6~": {Code: KeyPgDown},
+ "\x1b[7~": {Code: KeyHome},
+ "\x1b[8~": {Code: KeyEnd},
+
+ // Normal mode
+ "\x1b[A": {Code: KeyUp},
+ "\x1b[B": {Code: KeyDown},
+ "\x1b[C": {Code: KeyRight},
+ "\x1b[D": {Code: KeyLeft},
+ "\x1b[E": {Code: KeyBegin},
+ "\x1b[F": {Code: KeyEnd},
+ "\x1b[H": {Code: KeyHome},
+ "\x1b[P": {Code: KeyF1},
+ "\x1b[Q": {Code: KeyF2},
+ "\x1b[R": {Code: KeyF3},
+ "\x1b[S": {Code: KeyF4},
+
+ // Application Cursor Key Mode (DECCKM)
+ "\x1bOA": {Code: KeyUp},
+ "\x1bOB": {Code: KeyDown},
+ "\x1bOC": {Code: KeyRight},
+ "\x1bOD": {Code: KeyLeft},
+ "\x1bOE": {Code: KeyBegin},
+ "\x1bOF": {Code: KeyEnd},
+ "\x1bOH": {Code: KeyHome},
+ "\x1bOP": {Code: KeyF1},
+ "\x1bOQ": {Code: KeyF2},
+ "\x1bOR": {Code: KeyF3},
+ "\x1bOS": {Code: KeyF4},
+
+ // Keypad Application Mode (DECKPAM)
+
+ "\x1bOM": {Code: KeyKpEnter},
+ "\x1bOX": {Code: KeyKpEqual},
+ "\x1bOj": {Code: KeyKpMultiply},
+ "\x1bOk": {Code: KeyKpPlus},
+ "\x1bOl": {Code: KeyKpComma},
+ "\x1bOm": {Code: KeyKpMinus},
+ "\x1bOn": {Code: KeyKpDecimal},
+ "\x1bOo": {Code: KeyKpDivide},
+ "\x1bOp": {Code: KeyKp0},
+ "\x1bOq": {Code: KeyKp1},
+ "\x1bOr": {Code: KeyKp2},
+ "\x1bOs": {Code: KeyKp3},
+ "\x1bOt": {Code: KeyKp4},
+ "\x1bOu": {Code: KeyKp5},
+ "\x1bOv": {Code: KeyKp6},
+ "\x1bOw": {Code: KeyKp7},
+ "\x1bOx": {Code: KeyKp8},
+ "\x1bOy": {Code: KeyKp9},
+
+ // Function keys
+
+ "\x1b[11~": {Code: KeyF1},
+ "\x1b[12~": {Code: KeyF2},
+ "\x1b[13~": {Code: KeyF3},
+ "\x1b[14~": {Code: KeyF4},
+ "\x1b[15~": {Code: KeyF5},
+ "\x1b[17~": {Code: KeyF6},
+ "\x1b[18~": {Code: KeyF7},
+ "\x1b[19~": {Code: KeyF8},
+ "\x1b[20~": {Code: KeyF9},
+ "\x1b[21~": {Code: KeyF10},
+ "\x1b[23~": {Code: KeyF11},
+ "\x1b[24~": {Code: KeyF12},
+ "\x1b[25~": {Code: KeyF13},
+ "\x1b[26~": {Code: KeyF14},
+ "\x1b[28~": {Code: KeyF15},
+ "\x1b[29~": {Code: KeyF16},
+ "\x1b[31~": {Code: KeyF17},
+ "\x1b[32~": {Code: KeyF18},
+ "\x1b[33~": {Code: KeyF19},
+ "\x1b[34~": {Code: KeyF20},
+ }
+
+ // CSI ~ sequence keys
+ csiTildeKeys := map[string]Key{
+ "1": find, "2": {Code: KeyInsert},
+ "3": {Code: KeyDelete}, "4": sel,
+ "5": {Code: KeyPgUp}, "6": {Code: KeyPgDown},
+ "7": {Code: KeyHome}, "8": {Code: KeyEnd},
+ // There are no 9 and 10 keys
+ "11": {Code: KeyF1}, "12": {Code: KeyF2},
+ "13": {Code: KeyF3}, "14": {Code: KeyF4},
+ "15": {Code: KeyF5}, "17": {Code: KeyF6},
+ "18": {Code: KeyF7}, "19": {Code: KeyF8},
+ "20": {Code: KeyF9}, "21": {Code: KeyF10},
+ "23": {Code: KeyF11}, "24": {Code: KeyF12},
+ "25": {Code: KeyF13}, "26": {Code: KeyF14},
+ "28": {Code: KeyF15}, "29": {Code: KeyF16},
+ "31": {Code: KeyF17}, "32": {Code: KeyF18},
+ "33": {Code: KeyF19}, "34": {Code: KeyF20},
+ }
+
+ // URxvt keys
+ // See https://manpages.ubuntu.com/manpages/trusty/man7/urxvt.7.html#key%20codes
+ table["\x1b[a"] = Key{Code: KeyUp, Mod: ModShift}
+ table["\x1b[b"] = Key{Code: KeyDown, Mod: ModShift}
+ table["\x1b[c"] = Key{Code: KeyRight, Mod: ModShift}
+ table["\x1b[d"] = Key{Code: KeyLeft, Mod: ModShift}
+ table["\x1bOa"] = Key{Code: KeyUp, Mod: ModCtrl}
+ table["\x1bOb"] = Key{Code: KeyDown, Mod: ModCtrl}
+ table["\x1bOc"] = Key{Code: KeyRight, Mod: ModCtrl}
+ table["\x1bOd"] = Key{Code: KeyLeft, Mod: ModCtrl}
+ //nolint:godox
+ // TODO: invistigate if shift-ctrl arrow keys collide with DECCKM keys i.e.
+ // "\x1bOA", "\x1bOB", "\x1bOC", "\x1bOD"
+
+ // URxvt modifier CSI ~ keys
+ for k, v := range csiTildeKeys {
+ key := v
+ // Normal (no modifier) already defined part of VT100/VT200
+ // Shift modifier
+ key.Mod = ModShift
+ table["\x1b["+k+"$"] = key
+ // Ctrl modifier
+ key.Mod = ModCtrl
+ table["\x1b["+k+"^"] = key
+ // Shift-Ctrl modifier
+ key.Mod = ModShift | ModCtrl
+ table["\x1b["+k+"@"] = key
+ }
+
+ // URxvt F keys
+ // Note: Shift + F1-F10 generates F11-F20.
+ // This means Shift + F1 and Shift + F2 will generate F11 and F12, the same
+ // applies to Ctrl + Shift F1 & F2.
+ //
+ // P.S. Don't like this? Blame URxvt, configure your terminal to use
+ // different escapes like XTerm, or switch to a better terminal ¯\_(ツ)_/¯
+ //
+ // See https://manpages.ubuntu.com/manpages/trusty/man7/urxvt.7.html#key%20codes
+ table["\x1b[23$"] = Key{Code: KeyF11, Mod: ModShift}
+ table["\x1b[24$"] = Key{Code: KeyF12, Mod: ModShift}
+ table["\x1b[25$"] = Key{Code: KeyF13, Mod: ModShift}
+ table["\x1b[26$"] = Key{Code: KeyF14, Mod: ModShift}
+ table["\x1b[28$"] = Key{Code: KeyF15, Mod: ModShift}
+ table["\x1b[29$"] = Key{Code: KeyF16, Mod: ModShift}
+ table["\x1b[31$"] = Key{Code: KeyF17, Mod: ModShift}
+ table["\x1b[32$"] = Key{Code: KeyF18, Mod: ModShift}
+ table["\x1b[33$"] = Key{Code: KeyF19, Mod: ModShift}
+ table["\x1b[34$"] = Key{Code: KeyF20, Mod: ModShift}
+ table["\x1b[11^"] = Key{Code: KeyF1, Mod: ModCtrl}
+ table["\x1b[12^"] = Key{Code: KeyF2, Mod: ModCtrl}
+ table["\x1b[13^"] = Key{Code: KeyF3, Mod: ModCtrl}
+ table["\x1b[14^"] = Key{Code: KeyF4, Mod: ModCtrl}
+ table["\x1b[15^"] = Key{Code: KeyF5, Mod: ModCtrl}
+ table["\x1b[17^"] = Key{Code: KeyF6, Mod: ModCtrl}
+ table["\x1b[18^"] = Key{Code: KeyF7, Mod: ModCtrl}
+ table["\x1b[19^"] = Key{Code: KeyF8, Mod: ModCtrl}
+ table["\x1b[20^"] = Key{Code: KeyF9, Mod: ModCtrl}
+ table["\x1b[21^"] = Key{Code: KeyF10, Mod: ModCtrl}
+ table["\x1b[23^"] = Key{Code: KeyF11, Mod: ModCtrl}
+ table["\x1b[24^"] = Key{Code: KeyF12, Mod: ModCtrl}
+ table["\x1b[25^"] = Key{Code: KeyF13, Mod: ModCtrl}
+ table["\x1b[26^"] = Key{Code: KeyF14, Mod: ModCtrl}
+ table["\x1b[28^"] = Key{Code: KeyF15, Mod: ModCtrl}
+ table["\x1b[29^"] = Key{Code: KeyF16, Mod: ModCtrl}
+ table["\x1b[31^"] = Key{Code: KeyF17, Mod: ModCtrl}
+ table["\x1b[32^"] = Key{Code: KeyF18, Mod: ModCtrl}
+ table["\x1b[33^"] = Key{Code: KeyF19, Mod: ModCtrl}
+ table["\x1b[34^"] = Key{Code: KeyF20, Mod: ModCtrl}
+ table["\x1b[23@"] = Key{Code: KeyF11, Mod: ModShift | ModCtrl}
+ table["\x1b[24@"] = Key{Code: KeyF12, Mod: ModShift | ModCtrl}
+ table["\x1b[25@"] = Key{Code: KeyF13, Mod: ModShift | ModCtrl}
+ table["\x1b[26@"] = Key{Code: KeyF14, Mod: ModShift | ModCtrl}
+ table["\x1b[28@"] = Key{Code: KeyF15, Mod: ModShift | ModCtrl}
+ table["\x1b[29@"] = Key{Code: KeyF16, Mod: ModShift | ModCtrl}
+ table["\x1b[31@"] = Key{Code: KeyF17, Mod: ModShift | ModCtrl}
+ table["\x1b[32@"] = Key{Code: KeyF18, Mod: ModShift | ModCtrl}
+ table["\x1b[33@"] = Key{Code: KeyF19, Mod: ModShift | ModCtrl}
+ table["\x1b[34@"] = Key{Code: KeyF20, Mod: ModShift | ModCtrl}
+
+ // Register Alt + combinations
+ // XXX: this must come after URxvt but before XTerm keys to register URxvt
+ // keys with alt modifier
+ tmap := map[string]Key{}
+ for seq, key := range table {
+ key := key
+ key.Mod |= ModAlt
+ key.Text = "" // Clear runes
+ tmap["\x1b"+seq] = key
+ }
+ for seq, key := range tmap {
+ table[seq] = key
+ }
+
+ // XTerm modifiers
+ // These are offset by 1 to be compatible with our Mod type.
+ // See https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-PC-Style-Function-Keys
+ modifiers := []KeyMod{
+ ModShift, // 1
+ ModAlt, // 2
+ ModShift | ModAlt, // 3
+ ModCtrl, // 4
+ ModShift | ModCtrl, // 5
+ ModAlt | ModCtrl, // 6
+ ModShift | ModAlt | ModCtrl, // 7
+ ModMeta, // 8
+ ModMeta | ModShift, // 9
+ ModMeta | ModAlt, // 10
+ ModMeta | ModShift | ModAlt, // 11
+ ModMeta | ModCtrl, // 12
+ ModMeta | ModShift | ModCtrl, // 13
+ ModMeta | ModAlt | ModCtrl, // 14
+ ModMeta | ModShift | ModAlt | ModCtrl, // 15
+ }
+
+ // SS3 keypad function keys
+ ss3FuncKeys := map[string]Key{
+ // These are defined in XTerm
+ // Taken from Foot keymap.h and XTerm modifyOtherKeys
+ // https://codeberg.org/dnkl/foot/src/branch/master/keymap.h
+ "M": {Code: KeyKpEnter}, "X": {Code: KeyKpEqual},
+ "j": {Code: KeyKpMultiply}, "k": {Code: KeyKpPlus},
+ "l": {Code: KeyKpComma}, "m": {Code: KeyKpMinus},
+ "n": {Code: KeyKpDecimal}, "o": {Code: KeyKpDivide},
+ "p": {Code: KeyKp0}, "q": {Code: KeyKp1},
+ "r": {Code: KeyKp2}, "s": {Code: KeyKp3},
+ "t": {Code: KeyKp4}, "u": {Code: KeyKp5},
+ "v": {Code: KeyKp6}, "w": {Code: KeyKp7},
+ "x": {Code: KeyKp8}, "y": {Code: KeyKp9},
+ }
+
+ // XTerm keys
+ csiFuncKeys := map[string]Key{
+ "A": {Code: KeyUp}, "B": {Code: KeyDown},
+ "C": {Code: KeyRight}, "D": {Code: KeyLeft},
+ "E": {Code: KeyBegin}, "F": {Code: KeyEnd},
+ "H": {Code: KeyHome}, "P": {Code: KeyF1},
+ "Q": {Code: KeyF2}, "R": {Code: KeyF3},
+ "S": {Code: KeyF4},
+ }
+
+ // CSI 27 ; ; ~ keys defined in XTerm modifyOtherKeys
+ modifyOtherKeys := map[int]Key{
+ ansi.BS: {Code: KeyBackspace},
+ ansi.HT: {Code: KeyTab},
+ ansi.CR: {Code: KeyEnter},
+ ansi.ESC: {Code: KeyEscape},
+ ansi.DEL: {Code: KeyBackspace},
+ }
+
+ for _, m := range modifiers {
+ // XTerm modifier offset +1
+ xtermMod := strconv.Itoa(int(m) + 1)
+
+ // CSI 1 ;
+ for k, v := range csiFuncKeys {
+ // Functions always have a leading 1 param
+ seq := "\x1b[1;" + xtermMod + k
+ key := v
+ key.Mod = m
+ table[seq] = key
+ }
+ // SS3
+ for k, v := range ss3FuncKeys {
+ seq := "\x1bO" + xtermMod + k
+ key := v
+ key.Mod = m
+ table[seq] = key
+ }
+ // CSI ; ~
+ for k, v := range csiTildeKeys {
+ seq := "\x1b[" + k + ";" + xtermMod + "~"
+ key := v
+ key.Mod = m
+ table[seq] = key
+ }
+ // CSI 27 ; ; ~
+ for k, v := range modifyOtherKeys {
+ code := strconv.Itoa(k)
+ seq := "\x1b[27;" + xtermMod + ";" + code + "~"
+ key := v
+ key.Mod = m
+ table[seq] = key
+ }
+ }
+
+ // Register terminfo keys
+ // XXX: this might override keys already registered in table
+ if useTerminfo {
+ titable := buildTerminfoKeys(flags, term)
+ for seq, key := range titable {
+ table[seq] = key
+ }
+ }
+
+ return table
+}
+
+func buildTerminfoKeys(flags LegacyKeyEncoding, term string) map[string]Key {
+ table := make(map[string]Key)
+ ti, _ := terminfo.Load(term)
+ if ti == nil {
+ return table
+ }
+
+ tiTable := defaultTerminfoKeys(flags)
+
+ // Default keys
+ for name, seq := range ti.StringCapsShort() {
+ if !strings.HasPrefix(name, "k") || len(seq) == 0 {
+ continue
+ }
+
+ if k, ok := tiTable[name]; ok {
+ table[string(seq)] = k
+ }
+ }
+
+ // Extended keys
+ for name, seq := range ti.ExtStringCapsShort() {
+ if !strings.HasPrefix(name, "k") || len(seq) == 0 {
+ continue
+ }
+
+ if k, ok := tiTable[name]; ok {
+ table[string(seq)] = k
+ }
+ }
+
+ return table
+}
+
+// This returns a map of terminfo keys to key events. It's a mix of ncurses
+// terminfo default and user-defined key capabilities.
+// Upper-case caps that are defined in the default terminfo database are
+// - kNXT
+// - kPRV
+// - kHOM
+// - kEND
+// - kDC
+// - kIC
+// - kLFT
+// - kRIT
+//
+// See https://man7.org/linux/man-pages/man5/terminfo.5.html
+// See https://github.com/mirror/ncurses/blob/master/include/Caps-ncurses
+func defaultTerminfoKeys(flags LegacyKeyEncoding) map[string]Key {
+ keys := map[string]Key{
+ "kcuu1": {Code: KeyUp},
+ "kUP": {Code: KeyUp, Mod: ModShift},
+ "kUP3": {Code: KeyUp, Mod: ModAlt},
+ "kUP4": {Code: KeyUp, Mod: ModShift | ModAlt},
+ "kUP5": {Code: KeyUp, Mod: ModCtrl},
+ "kUP6": {Code: KeyUp, Mod: ModShift | ModCtrl},
+ "kUP7": {Code: KeyUp, Mod: ModAlt | ModCtrl},
+ "kUP8": {Code: KeyUp, Mod: ModShift | ModAlt | ModCtrl},
+ "kcud1": {Code: KeyDown},
+ "kDN": {Code: KeyDown, Mod: ModShift},
+ "kDN3": {Code: KeyDown, Mod: ModAlt},
+ "kDN4": {Code: KeyDown, Mod: ModShift | ModAlt},
+ "kDN5": {Code: KeyDown, Mod: ModCtrl},
+ "kDN7": {Code: KeyDown, Mod: ModAlt | ModCtrl},
+ "kDN6": {Code: KeyDown, Mod: ModShift | ModCtrl},
+ "kDN8": {Code: KeyDown, Mod: ModShift | ModAlt | ModCtrl},
+ "kcub1": {Code: KeyLeft},
+ "kLFT": {Code: KeyLeft, Mod: ModShift},
+ "kLFT3": {Code: KeyLeft, Mod: ModAlt},
+ "kLFT4": {Code: KeyLeft, Mod: ModShift | ModAlt},
+ "kLFT5": {Code: KeyLeft, Mod: ModCtrl},
+ "kLFT6": {Code: KeyLeft, Mod: ModShift | ModCtrl},
+ "kLFT7": {Code: KeyLeft, Mod: ModAlt | ModCtrl},
+ "kLFT8": {Code: KeyLeft, Mod: ModShift | ModAlt | ModCtrl},
+ "kcuf1": {Code: KeyRight},
+ "kRIT": {Code: KeyRight, Mod: ModShift},
+ "kRIT3": {Code: KeyRight, Mod: ModAlt},
+ "kRIT4": {Code: KeyRight, Mod: ModShift | ModAlt},
+ "kRIT5": {Code: KeyRight, Mod: ModCtrl},
+ "kRIT6": {Code: KeyRight, Mod: ModShift | ModCtrl},
+ "kRIT7": {Code: KeyRight, Mod: ModAlt | ModCtrl},
+ "kRIT8": {Code: KeyRight, Mod: ModShift | ModAlt | ModCtrl},
+ "kich1": {Code: KeyInsert},
+ "kIC": {Code: KeyInsert, Mod: ModShift},
+ "kIC3": {Code: KeyInsert, Mod: ModAlt},
+ "kIC4": {Code: KeyInsert, Mod: ModShift | ModAlt},
+ "kIC5": {Code: KeyInsert, Mod: ModCtrl},
+ "kIC6": {Code: KeyInsert, Mod: ModShift | ModCtrl},
+ "kIC7": {Code: KeyInsert, Mod: ModAlt | ModCtrl},
+ "kIC8": {Code: KeyInsert, Mod: ModShift | ModAlt | ModCtrl},
+ "kdch1": {Code: KeyDelete},
+ "kDC": {Code: KeyDelete, Mod: ModShift},
+ "kDC3": {Code: KeyDelete, Mod: ModAlt},
+ "kDC4": {Code: KeyDelete, Mod: ModShift | ModAlt},
+ "kDC5": {Code: KeyDelete, Mod: ModCtrl},
+ "kDC6": {Code: KeyDelete, Mod: ModShift | ModCtrl},
+ "kDC7": {Code: KeyDelete, Mod: ModAlt | ModCtrl},
+ "kDC8": {Code: KeyDelete, Mod: ModShift | ModAlt | ModCtrl},
+ "khome": {Code: KeyHome},
+ "kHOM": {Code: KeyHome, Mod: ModShift},
+ "kHOM3": {Code: KeyHome, Mod: ModAlt},
+ "kHOM4": {Code: KeyHome, Mod: ModShift | ModAlt},
+ "kHOM5": {Code: KeyHome, Mod: ModCtrl},
+ "kHOM6": {Code: KeyHome, Mod: ModShift | ModCtrl},
+ "kHOM7": {Code: KeyHome, Mod: ModAlt | ModCtrl},
+ "kHOM8": {Code: KeyHome, Mod: ModShift | ModAlt | ModCtrl},
+ "kend": {Code: KeyEnd},
+ "kEND": {Code: KeyEnd, Mod: ModShift},
+ "kEND3": {Code: KeyEnd, Mod: ModAlt},
+ "kEND4": {Code: KeyEnd, Mod: ModShift | ModAlt},
+ "kEND5": {Code: KeyEnd, Mod: ModCtrl},
+ "kEND6": {Code: KeyEnd, Mod: ModShift | ModCtrl},
+ "kEND7": {Code: KeyEnd, Mod: ModAlt | ModCtrl},
+ "kEND8": {Code: KeyEnd, Mod: ModShift | ModAlt | ModCtrl},
+ "kpp": {Code: KeyPgUp},
+ "kprv": {Code: KeyPgUp},
+ "kPRV": {Code: KeyPgUp, Mod: ModShift},
+ "kPRV3": {Code: KeyPgUp, Mod: ModAlt},
+ "kPRV4": {Code: KeyPgUp, Mod: ModShift | ModAlt},
+ "kPRV5": {Code: KeyPgUp, Mod: ModCtrl},
+ "kPRV6": {Code: KeyPgUp, Mod: ModShift | ModCtrl},
+ "kPRV7": {Code: KeyPgUp, Mod: ModAlt | ModCtrl},
+ "kPRV8": {Code: KeyPgUp, Mod: ModShift | ModAlt | ModCtrl},
+ "knp": {Code: KeyPgDown},
+ "knxt": {Code: KeyPgDown},
+ "kNXT": {Code: KeyPgDown, Mod: ModShift},
+ "kNXT3": {Code: KeyPgDown, Mod: ModAlt},
+ "kNXT4": {Code: KeyPgDown, Mod: ModShift | ModAlt},
+ "kNXT5": {Code: KeyPgDown, Mod: ModCtrl},
+ "kNXT6": {Code: KeyPgDown, Mod: ModShift | ModCtrl},
+ "kNXT7": {Code: KeyPgDown, Mod: ModAlt | ModCtrl},
+ "kNXT8": {Code: KeyPgDown, Mod: ModShift | ModAlt | ModCtrl},
+
+ "kbs": {Code: KeyBackspace},
+ "kcbt": {Code: KeyTab, Mod: ModShift},
+
+ // Function keys
+ // This only includes the first 12 function keys. The rest are treated
+ // as modifiers of the first 12.
+ // Take a look at XTerm modifyFunctionKeys
+ //
+ // XXX: To use unambiguous function keys, use fixterms or kitty clipboard.
+ //
+ // See https://invisible-island.net/xterm/manpage/xterm.html#VT100-Widget-Resources:modifyFunctionKeys
+ // See https://invisible-island.net/xterm/terminfo.html
+
+ "kf1": {Code: KeyF1},
+ "kf2": {Code: KeyF2},
+ "kf3": {Code: KeyF3},
+ "kf4": {Code: KeyF4},
+ "kf5": {Code: KeyF5},
+ "kf6": {Code: KeyF6},
+ "kf7": {Code: KeyF7},
+ "kf8": {Code: KeyF8},
+ "kf9": {Code: KeyF9},
+ "kf10": {Code: KeyF10},
+ "kf11": {Code: KeyF11},
+ "kf12": {Code: KeyF12},
+ "kf13": {Code: KeyF1, Mod: ModShift},
+ "kf14": {Code: KeyF2, Mod: ModShift},
+ "kf15": {Code: KeyF3, Mod: ModShift},
+ "kf16": {Code: KeyF4, Mod: ModShift},
+ "kf17": {Code: KeyF5, Mod: ModShift},
+ "kf18": {Code: KeyF6, Mod: ModShift},
+ "kf19": {Code: KeyF7, Mod: ModShift},
+ "kf20": {Code: KeyF8, Mod: ModShift},
+ "kf21": {Code: KeyF9, Mod: ModShift},
+ "kf22": {Code: KeyF10, Mod: ModShift},
+ "kf23": {Code: KeyF11, Mod: ModShift},
+ "kf24": {Code: KeyF12, Mod: ModShift},
+ "kf25": {Code: KeyF1, Mod: ModCtrl},
+ "kf26": {Code: KeyF2, Mod: ModCtrl},
+ "kf27": {Code: KeyF3, Mod: ModCtrl},
+ "kf28": {Code: KeyF4, Mod: ModCtrl},
+ "kf29": {Code: KeyF5, Mod: ModCtrl},
+ "kf30": {Code: KeyF6, Mod: ModCtrl},
+ "kf31": {Code: KeyF7, Mod: ModCtrl},
+ "kf32": {Code: KeyF8, Mod: ModCtrl},
+ "kf33": {Code: KeyF9, Mod: ModCtrl},
+ "kf34": {Code: KeyF10, Mod: ModCtrl},
+ "kf35": {Code: KeyF11, Mod: ModCtrl},
+ "kf36": {Code: KeyF12, Mod: ModCtrl},
+ "kf37": {Code: KeyF1, Mod: ModShift | ModCtrl},
+ "kf38": {Code: KeyF2, Mod: ModShift | ModCtrl},
+ "kf39": {Code: KeyF3, Mod: ModShift | ModCtrl},
+ "kf40": {Code: KeyF4, Mod: ModShift | ModCtrl},
+ "kf41": {Code: KeyF5, Mod: ModShift | ModCtrl},
+ "kf42": {Code: KeyF6, Mod: ModShift | ModCtrl},
+ "kf43": {Code: KeyF7, Mod: ModShift | ModCtrl},
+ "kf44": {Code: KeyF8, Mod: ModShift | ModCtrl},
+ "kf45": {Code: KeyF9, Mod: ModShift | ModCtrl},
+ "kf46": {Code: KeyF10, Mod: ModShift | ModCtrl},
+ "kf47": {Code: KeyF11, Mod: ModShift | ModCtrl},
+ "kf48": {Code: KeyF12, Mod: ModShift | ModCtrl},
+ "kf49": {Code: KeyF1, Mod: ModAlt},
+ "kf50": {Code: KeyF2, Mod: ModAlt},
+ "kf51": {Code: KeyF3, Mod: ModAlt},
+ "kf52": {Code: KeyF4, Mod: ModAlt},
+ "kf53": {Code: KeyF5, Mod: ModAlt},
+ "kf54": {Code: KeyF6, Mod: ModAlt},
+ "kf55": {Code: KeyF7, Mod: ModAlt},
+ "kf56": {Code: KeyF8, Mod: ModAlt},
+ "kf57": {Code: KeyF9, Mod: ModAlt},
+ "kf58": {Code: KeyF10, Mod: ModAlt},
+ "kf59": {Code: KeyF11, Mod: ModAlt},
+ "kf60": {Code: KeyF12, Mod: ModAlt},
+ "kf61": {Code: KeyF1, Mod: ModShift | ModAlt},
+ "kf62": {Code: KeyF2, Mod: ModShift | ModAlt},
+ "kf63": {Code: KeyF3, Mod: ModShift | ModAlt},
+ }
+
+ // Preserve F keys from F13 to F63 instead of using them for F-keys
+ // modifiers.
+ if flags&flagFKeys != 0 {
+ keys["kf13"] = Key{Code: KeyF13}
+ keys["kf14"] = Key{Code: KeyF14}
+ keys["kf15"] = Key{Code: KeyF15}
+ keys["kf16"] = Key{Code: KeyF16}
+ keys["kf17"] = Key{Code: KeyF17}
+ keys["kf18"] = Key{Code: KeyF18}
+ keys["kf19"] = Key{Code: KeyF19}
+ keys["kf20"] = Key{Code: KeyF20}
+ keys["kf21"] = Key{Code: KeyF21}
+ keys["kf22"] = Key{Code: KeyF22}
+ keys["kf23"] = Key{Code: KeyF23}
+ keys["kf24"] = Key{Code: KeyF24}
+ keys["kf25"] = Key{Code: KeyF25}
+ keys["kf26"] = Key{Code: KeyF26}
+ keys["kf27"] = Key{Code: KeyF27}
+ keys["kf28"] = Key{Code: KeyF28}
+ keys["kf29"] = Key{Code: KeyF29}
+ keys["kf30"] = Key{Code: KeyF30}
+ keys["kf31"] = Key{Code: KeyF31}
+ keys["kf32"] = Key{Code: KeyF32}
+ keys["kf33"] = Key{Code: KeyF33}
+ keys["kf34"] = Key{Code: KeyF34}
+ keys["kf35"] = Key{Code: KeyF35}
+ keys["kf36"] = Key{Code: KeyF36}
+ keys["kf37"] = Key{Code: KeyF37}
+ keys["kf38"] = Key{Code: KeyF38}
+ keys["kf39"] = Key{Code: KeyF39}
+ keys["kf40"] = Key{Code: KeyF40}
+ keys["kf41"] = Key{Code: KeyF41}
+ keys["kf42"] = Key{Code: KeyF42}
+ keys["kf43"] = Key{Code: KeyF43}
+ keys["kf44"] = Key{Code: KeyF44}
+ keys["kf45"] = Key{Code: KeyF45}
+ keys["kf46"] = Key{Code: KeyF46}
+ keys["kf47"] = Key{Code: KeyF47}
+ keys["kf48"] = Key{Code: KeyF48}
+ keys["kf49"] = Key{Code: KeyF49}
+ keys["kf50"] = Key{Code: KeyF50}
+ keys["kf51"] = Key{Code: KeyF51}
+ keys["kf52"] = Key{Code: KeyF52}
+ keys["kf53"] = Key{Code: KeyF53}
+ keys["kf54"] = Key{Code: KeyF54}
+ keys["kf55"] = Key{Code: KeyF55}
+ keys["kf56"] = Key{Code: KeyF56}
+ keys["kf57"] = Key{Code: KeyF57}
+ keys["kf58"] = Key{Code: KeyF58}
+ keys["kf59"] = Key{Code: KeyF59}
+ keys["kf60"] = Key{Code: KeyF60}
+ keys["kf61"] = Key{Code: KeyF61}
+ keys["kf62"] = Key{Code: KeyF62}
+ keys["kf63"] = Key{Code: KeyF63}
+ }
+
+ return keys
+}
diff --git a/vendor/github.com/charmbracelet/ultraviolet/logger.go b/vendor/github.com/charmbracelet/ultraviolet/logger.go
new file mode 100644
index 0000000000..abfd86e7ad
--- /dev/null
+++ b/vendor/github.com/charmbracelet/ultraviolet/logger.go
@@ -0,0 +1,6 @@
+package uv
+
+// Logger is a simple logger interface.
+type Logger interface {
+ Printf(format string, v ...interface{})
+}
diff --git a/vendor/github.com/charmbracelet/ultraviolet/mouse.go b/vendor/github.com/charmbracelet/ultraviolet/mouse.go
new file mode 100644
index 0000000000..a74cdf992a
--- /dev/null
+++ b/vendor/github.com/charmbracelet/ultraviolet/mouse.go
@@ -0,0 +1,150 @@
+package uv
+
+import (
+ "github.com/charmbracelet/x/ansi"
+)
+
+// MouseMode represents the mouse tracking mode for the terminal.
+type MouseMode uint8
+
+// Mouse tracking modes.
+//
+// These determine which mouse events the terminal reports.
+const (
+ MouseModeNone MouseMode = iota // Disable mouse tracking.
+ MouseModePress // Press only (DEC mode 9). Reports button press events.
+ MouseModeClick // Click tracking (DEC mode 1000). Reports button press and release.
+ MouseModeDrag // Drag tracking (DEC mode 1002). Reports press, release, and drag.
+ MouseModeMotion // Motion tracking (DEC mode 1003). Reports all mouse events including motion.
+)
+
+// MouseEncoding represents the encoding used for mouse events.
+type MouseEncoding uint8
+
+// Mouse encodings.
+//
+// These determine how mouse coordinates and buttons are encoded in the
+// terminal's escape sequences. The encoding is only meaningful when mouse
+// tracking is enabled via [MouseMode].
+const (
+ MouseEncodingLegacy MouseEncoding = iota // Legacy X10-compatible encoding. Coordinates limited to 223.
+ MouseEncodingSGR // SGR encoding (DEC mode 1006). No coordinate limit, distinguishes press/release.
+ MouseEncodingSGRPixel // SGR-pixel encoding (DEC mode 1016). Reports pixel coordinates.
+
+ // TODO: support these additional encodings in the future.
+ // MouseEncodingUTF8 // UTF-8 encoding (DEC mode 1005). Coordinates limited to 223.
+ // MouseEncodingUrxvt // urxvt encoding (DEC mode 1015). No coordinate limit.
+ // MouseEncodingSGRPixel // SGR-pixel encoding (DEC mode 1016). Reports pixel coordinates.
+)
+
+// MouseButton represents the button that was pressed during a mouse message.
+type MouseButton = ansi.MouseButton
+
+// Mouse event buttons
+//
+// This is based on X11 mouse button codes.
+//
+// 1 = left button
+// 2 = middle button (pressing the scroll wheel)
+// 3 = right button
+// 4 = turn scroll wheel up
+// 5 = turn scroll wheel down
+// 6 = push scroll wheel left
+// 7 = push scroll wheel right
+// 8 = 4th button (aka browser backward button)
+// 9 = 5th button (aka browser forward button)
+// 10
+// 11
+//
+// Other buttons are not supported.
+const (
+ MouseNone = ansi.MouseNone
+ MouseLeft = ansi.MouseLeft
+ MouseMiddle = ansi.MouseMiddle
+ MouseRight = ansi.MouseRight
+ MouseWheelUp = ansi.MouseWheelUp
+ MouseWheelDown = ansi.MouseWheelDown
+ MouseWheelLeft = ansi.MouseWheelLeft
+ MouseWheelRight = ansi.MouseWheelRight
+ MouseBackward = ansi.MouseBackward
+ MouseForward = ansi.MouseForward
+ MouseButton10 = ansi.MouseButton10
+ MouseButton11 = ansi.MouseButton11
+)
+
+// Mouse represents a Mouse message. Use [MouseEvent] to represent all mouse
+// messages.
+//
+// The X and Y coordinates are zero-based, with (0,0) being the upper left
+// corner of the terminal. When using [MouseEncodingSGRPixel] (DEC mode 1016),
+// X and Y are in pixel coordinates; otherwise they are in cell coordinates.
+//
+// // Catch all mouse events
+// switch Event := Event.(type) {
+// case MouseEvent:
+// m := Event.Mouse()
+// fmt.Println("Mouse event:", m.X, m.Y, m)
+// }
+//
+// // Only catch mouse click events
+// switch Event := Event.(type) {
+// case MouseClickEvent:
+// fmt.Println("Mouse click event:", Event.X, Event.Y, Event)
+// }
+type Mouse struct {
+ X, Y int
+ Button MouseButton
+ Mod KeyMod
+}
+
+// String returns a string representation of the mouse message.
+func (m Mouse) String() (s string) {
+ if m.Mod.Contains(ModCtrl) {
+ s += "ctrl+"
+ }
+ if m.Mod.Contains(ModAlt) {
+ s += "alt+"
+ }
+ if m.Mod.Contains(ModShift) {
+ s += "shift+"
+ }
+
+ str := m.Button.String()
+ if str == "" {
+ s += "unknown"
+ } else if str != "none" { // motion events don't have a button
+ s += str
+ }
+
+ return s
+}
+
+// MousePixelToCell converts a mouse event with pixel coordinates to cell
+// coordinates.
+//
+// This is only meaningful when using [MouseEncodingSGRPixel] encoding, which
+// reports mouse coordinates in pixels rather than cell units. The conversion
+// is based on the terminal's reported pixel dimensions and cell dimensions.
+//
+// On Windows, or other platforms where [Terminal.GetWinsize] doesn't report
+// pixel dimensions, you can query for the terminal window pixel dimensions via
+// [ansi.WindowOp](4) and get back a [PixelSizeEvent] with the pixel
+// dimensions. You can then construct a [Winsize] struct with the pixel
+// dimensions and the cell dimensions from [Terminal.GetWinsize] and pass it to
+// this function.
+func MousePixelToCell(m Mouse, ws *Winsize) Mouse {
+ var col, row int
+ if ws.Xpixel > 0 {
+ col = m.X * int(ws.Col) / int(ws.Xpixel)
+ }
+ if ws.Ypixel > 0 {
+ row = m.Y * int(ws.Row) / int(ws.Ypixel)
+ }
+
+ return Mouse{
+ X: col,
+ Y: row,
+ Button: m.Button,
+ Mod: m.Mod,
+ }
+}
diff --git a/vendor/github.com/charmbracelet/ultraviolet/poll.go b/vendor/github.com/charmbracelet/ultraviolet/poll.go
new file mode 100644
index 0000000000..209211f58e
--- /dev/null
+++ b/vendor/github.com/charmbracelet/ultraviolet/poll.go
@@ -0,0 +1,38 @@
+package uv
+
+import (
+ "fmt"
+ "time"
+)
+
+// pollReader reads data from an [io.Reader] using different native poll APIs
+// depending on the operating system.
+//
+// On Linux, it uses the epoll API.
+// On Windows, it uses The Windows I/O and Console APIs.
+// On macOS and other BSD-based systems, it will try to use the kqueue API and
+// fall back to Unix select if kqueue is not available (e.g., on TTY).
+// On other Unix-like systems, it uses the select API.
+// On all other systems, it falls back to a simple read loop with a timeout.
+type pollReader interface {
+ // Read reads data from the underlying [io.Reader]. It blocks until data is
+ // available or an error occurs.
+ //
+ // Use [pollReader] to check for data availability before calling Read to
+ // avoid blocking.
+ Read(p []byte) (n int, err error)
+
+ // Poll notifies when data is available to read with the given timeout. Use
+ // a negative duration to wait indefinitely.
+ Poll(timeout time.Duration) (ready bool, err error)
+
+ // Cancel cancels any ongoing poll or read operations. It returns true if
+ // an operation was canceled, false otherwise.
+ Cancel() bool
+
+ // Close closes the reader and releases any resources associated with it.
+ Close() error
+}
+
+// ErrCanceled is returned when a poll or read operation is canceled.
+var ErrCanceled = fmt.Errorf("poll canceled")
diff --git a/vendor/github.com/charmbracelet/ultraviolet/poll_bsd.go b/vendor/github.com/charmbracelet/ultraviolet/poll_bsd.go
new file mode 100644
index 0000000000..947448750a
--- /dev/null
+++ b/vendor/github.com/charmbracelet/ultraviolet/poll_bsd.go
@@ -0,0 +1,165 @@
+//go:build darwin || freebsd || netbsd || openbsd || dragonfly
+// +build darwin freebsd netbsd openbsd dragonfly
+
+package uv
+
+import (
+ "errors"
+ "fmt"
+ "io"
+ "os"
+ "strings"
+ "sync"
+ "time"
+
+ "golang.org/x/sys/unix"
+)
+
+// newPollReader creates a new pollReader for the given io.Reader.
+func newPollReader(reader io.Reader) (pollReader, error) {
+ file, ok := reader.(File)
+ if !ok {
+ return newFallbackReader(reader)
+ }
+
+ // kqueue returns instantly when polling /dev/tty so fallback to select
+ if file.Name() == "/dev/tty" {
+ return newSelectPollReader(reader)
+ }
+
+ kQueue, err := unix.Kqueue()
+ if err != nil {
+ return nil, fmt.Errorf("create kqueue: %w", err)
+ }
+
+ r := &kqueueReader{
+ reader: reader,
+ file: file,
+ kQueue: kQueue,
+ }
+
+ r.cancelSignalReader, r.cancelSignalWriter, err = os.Pipe()
+ if err != nil {
+ _ = unix.Close(kQueue)
+ return nil, err
+ }
+
+ unix.SetKevent(&r.kQueueEvents[0], int(file.Fd()), unix.EVFILT_READ, unix.EV_ADD)
+ unix.SetKevent(&r.kQueueEvents[1], int(r.cancelSignalReader.Fd()), unix.EVFILT_READ, unix.EV_ADD)
+
+ return r, nil
+}
+
+// kqueueReader implements pollReader using the BSD kqueue API.
+type kqueueReader struct {
+ reader io.Reader
+ file File
+ cancelSignalReader *os.File
+ cancelSignalWriter *os.File
+ kQueue int
+ kQueueEvents [2]unix.Kevent_t
+ mu sync.Mutex
+ canceled bool
+}
+
+// Read reads data from the underlying reader.
+func (r *kqueueReader) Read(p []byte) (int, error) {
+ r.mu.Lock()
+ if r.canceled {
+ r.mu.Unlock()
+ return 0, ErrCanceled
+ }
+ r.mu.Unlock()
+
+ return r.reader.Read(p)
+}
+
+// Poll waits for data to be available to read with the given timeout.
+func (r *kqueueReader) Poll(timeout time.Duration) (bool, error) {
+ r.mu.Lock()
+ if r.canceled {
+ r.mu.Unlock()
+ return false, ErrCanceled
+ }
+ r.mu.Unlock()
+
+ events := make([]unix.Kevent_t, 1)
+
+ var ts *unix.Timespec
+ if timeout >= 0 {
+ t := unix.NsecToTimespec(timeout.Nanoseconds())
+ ts = &t
+ }
+
+ for {
+ n, err := unix.Kevent(r.kQueue, r.kQueueEvents[:], events, ts)
+ if errors.Is(err, unix.EINTR) {
+ continue // try again if the syscall was interrupted
+ }
+
+ if err != nil {
+ return false, fmt.Errorf("kevent: %w", err)
+ }
+
+ if n == 0 {
+ return false, nil // timeout
+ }
+
+ break
+ }
+
+ ident := uint64(events[0].Ident)
+ switch ident {
+ case uint64(r.file.Fd()):
+ return true, nil
+ case uint64(r.cancelSignalReader.Fd()):
+ // remove signal from pipe
+ var b [1]byte
+ _, errRead := r.cancelSignalReader.Read(b[:])
+ if errRead != nil {
+ return false, fmt.Errorf("reading cancel signal: %w", errRead)
+ }
+ return false, ErrCanceled
+ }
+
+ return false, fmt.Errorf("unknown error")
+}
+
+// Cancel cancels any ongoing poll or read operations.
+func (r *kqueueReader) Cancel() bool {
+ r.mu.Lock()
+ r.canceled = true
+ r.mu.Unlock()
+
+ // send cancel signal
+ _, err := r.cancelSignalWriter.Write([]byte{'c'})
+ return err == nil
+}
+
+// Close closes the reader and releases any resources.
+func (r *kqueueReader) Close() error {
+ var errMsgs []string
+
+ // close kqueue
+ err := unix.Close(r.kQueue)
+ if err != nil {
+ errMsgs = append(errMsgs, fmt.Sprintf("closing kqueue: %v", err))
+ }
+
+ // close pipe
+ err = r.cancelSignalWriter.Close()
+ if err != nil {
+ errMsgs = append(errMsgs, fmt.Sprintf("closing cancel signal writer: %v", err))
+ }
+
+ err = r.cancelSignalReader.Close()
+ if err != nil {
+ errMsgs = append(errMsgs, fmt.Sprintf("closing cancel signal reader: %v", err))
+ }
+
+ if len(errMsgs) > 0 {
+ return fmt.Errorf("%s", strings.Join(errMsgs, ", "))
+ }
+
+ return nil
+}
diff --git a/vendor/github.com/charmbracelet/ultraviolet/poll_default.go b/vendor/github.com/charmbracelet/ultraviolet/poll_default.go
new file mode 100644
index 0000000000..464c70fb60
--- /dev/null
+++ b/vendor/github.com/charmbracelet/ultraviolet/poll_default.go
@@ -0,0 +1,12 @@
+//go:build !linux && !windows && !darwin && !freebsd && !netbsd && !openbsd && !dragonfly && !solaris
+// +build !linux,!windows,!darwin,!freebsd,!netbsd,!openbsd,!dragonfly,!solaris
+
+package uv
+
+import "io"
+
+// newPollReader creates a new pollReader for the given io.Reader.
+// This is the default implementation for unsupported platforms.
+func newPollReader(reader io.Reader) (pollReader, error) {
+ return newFallbackReader(reader)
+}
diff --git a/vendor/github.com/charmbracelet/ultraviolet/poll_fallback.go b/vendor/github.com/charmbracelet/ultraviolet/poll_fallback.go
new file mode 100644
index 0000000000..187a1ed85a
--- /dev/null
+++ b/vendor/github.com/charmbracelet/ultraviolet/poll_fallback.go
@@ -0,0 +1,158 @@
+package uv
+
+import (
+ "bufio"
+ "io"
+ "sync"
+ "time"
+)
+
+// newFallbackReader creates a new fallbackReader for the given io.Reader.
+func newFallbackReader(reader io.Reader) (pollReader, error) {
+ return &fallbackReader{
+ reader: bufio.NewReader(reader),
+ cancelChan: make(chan struct{}),
+ dataChan: make(chan struct{}, 1),
+ }, nil
+}
+
+// fallbackReader implements pollReader using goroutines and buffered I/O.
+// This is a fallback implementation that works on all platforms.
+type fallbackReader struct {
+ reader *bufio.Reader
+ cancelChan chan struct{}
+ dataChan chan struct{}
+ mu sync.Mutex
+ canceled bool
+ started bool
+}
+
+// Read reads data from the underlying reader.
+func (r *fallbackReader) Read(p []byte) (int, error) {
+ r.mu.Lock()
+ if r.canceled {
+ r.mu.Unlock()
+ return 0, ErrCanceled
+ }
+ r.mu.Unlock()
+
+ n, err := r.reader.Read(p)
+ // If we get an error during a concurrent cancel, prefer ErrCanceled
+ if err != nil {
+ r.mu.Lock()
+ if r.canceled {
+ r.mu.Unlock()
+ return 0, ErrCanceled
+ }
+ r.mu.Unlock()
+ }
+ return n, err
+}
+
+// Poll waits for data to be available to read with the given timeout.
+// This implementation starts a background goroutine to check for buffered
+// data availability.
+func (r *fallbackReader) Poll(timeout time.Duration) (bool, error) {
+ r.mu.Lock()
+ if r.canceled {
+ r.mu.Unlock()
+ return false, ErrCanceled
+ }
+
+ // Start the background reader goroutine if not already started
+ if !r.started {
+ r.started = true
+ go r.checkBuffered()
+ }
+ r.mu.Unlock()
+
+ if timeout < 0 {
+ // Wait indefinitely
+ select {
+ case <-r.dataChan:
+ // Put it back for next poll/read
+ select {
+ case r.dataChan <- struct{}{}:
+ default:
+ }
+ return true, nil
+ case <-r.cancelChan:
+ return false, ErrCanceled
+ }
+ }
+
+ // Wait with timeout
+ timer := time.NewTimer(timeout)
+ defer timer.Stop()
+
+ select {
+ case <-r.dataChan:
+ // Put it back for next poll/read
+ select {
+ case r.dataChan <- struct{}{}:
+ default:
+ }
+ return true, nil
+ case <-timer.C:
+ return false, nil
+ case <-r.cancelChan:
+ return false, ErrCanceled
+ }
+}
+
+// checkBuffered runs in a background goroutine to signal when data is available.
+func (r *fallbackReader) checkBuffered() {
+ for {
+ select {
+ case <-r.cancelChan:
+ return
+ default:
+ }
+
+ // Check if data is buffered
+ r.mu.Lock()
+ if r.canceled {
+ r.mu.Unlock()
+ return
+ }
+ r.mu.Unlock()
+
+ // Peek at one byte to check if data is available
+ // This will block until data arrives
+ _, err := r.reader.Peek(1)
+ if err != nil {
+ // If error (including EOF), stop the goroutine
+ return
+ }
+
+ // Signal that data is available
+ select {
+ case r.dataChan <- struct{}{}:
+ case <-r.cancelChan:
+ return
+ }
+
+ // Wait a bit before checking again to avoid busy loop
+ time.Sleep(10 * time.Millisecond)
+ }
+}
+
+// Cancel cancels any ongoing poll or read operations.
+func (r *fallbackReader) Cancel() bool {
+ r.mu.Lock()
+ if r.canceled {
+ r.mu.Unlock()
+ return false
+ }
+ r.canceled = true
+ r.mu.Unlock()
+
+ close(r.cancelChan)
+ return true
+}
+
+// Close closes the reader and releases any resources.
+func (r *fallbackReader) Close() error {
+ r.Cancel()
+ return nil
+}
diff --git a/vendor/github.com/charmbracelet/ultraviolet/poll_linux.go b/vendor/github.com/charmbracelet/ultraviolet/poll_linux.go
new file mode 100644
index 0000000000..bbe2c9fa45
--- /dev/null
+++ b/vendor/github.com/charmbracelet/ultraviolet/poll_linux.go
@@ -0,0 +1,175 @@
+//go:build linux
+// +build linux
+
+package uv
+
+import (
+ "errors"
+ "fmt"
+ "io"
+ "os"
+ "sync"
+ "time"
+
+ "golang.org/x/sys/unix"
+)
+
+// newPollReader creates a new pollReader for the given io.Reader.
+func newPollReader(reader io.Reader) (pollReader, error) {
+ file, ok := reader.(File)
+ if !ok {
+ return newFallbackReader(reader)
+ }
+
+ epoll, err := unix.EpollCreate1(0)
+ if err != nil {
+ return nil, fmt.Errorf("create epoll: %w", err)
+ }
+
+ r := &epollReader{
+ reader: reader,
+ file: file,
+ epoll: epoll,
+ }
+
+ r.cancelSignalReader, r.cancelSignalWriter, err = os.Pipe()
+ if err != nil {
+ _ = unix.Close(epoll)
+ return nil, err
+ }
+
+ err = unix.EpollCtl(epoll, unix.EPOLL_CTL_ADD, int(file.Fd()), &unix.EpollEvent{
+ Events: unix.EPOLLIN,
+ Fd: int32(file.Fd()),
+ })
+ if err != nil {
+ _ = unix.Close(epoll)
+ _ = r.cancelSignalReader.Close()
+ _ = r.cancelSignalWriter.Close()
+ return nil, fmt.Errorf("add reader to epoll interest list: %w", err)
+ }
+
+ err = unix.EpollCtl(epoll, unix.EPOLL_CTL_ADD, int(r.cancelSignalReader.Fd()), &unix.EpollEvent{
+ Events: unix.EPOLLIN,
+ Fd: int32(r.cancelSignalReader.Fd()),
+ })
+ if err != nil {
+ _ = unix.Close(epoll)
+ _ = r.cancelSignalReader.Close()
+ _ = r.cancelSignalWriter.Close()
+ return nil, fmt.Errorf("add cancel signal to epoll interest list: %w", err)
+ }
+
+ return r, nil
+}
+
+// epollReader implements pollReader using the Linux epoll API.
+type epollReader struct {
+ reader io.Reader
+ file File
+ cancelSignalReader *os.File
+ cancelSignalWriter *os.File
+ epoll int
+ mu sync.Mutex
+ canceled bool
+}
+
+// Read reads data from the underlying reader.
+func (r *epollReader) Read(p []byte) (int, error) {
+ r.mu.Lock()
+ if r.canceled {
+ r.mu.Unlock()
+ return 0, ErrCanceled
+ }
+ r.mu.Unlock()
+
+ return r.reader.Read(p)
+}
+
+// Poll waits for data to be available to read with the given timeout.
+func (r *epollReader) Poll(timeout time.Duration) (bool, error) {
+ r.mu.Lock()
+ if r.canceled {
+ r.mu.Unlock()
+ return false, ErrCanceled
+ }
+ r.mu.Unlock()
+
+ events := make([]unix.EpollEvent, 1)
+
+ timeoutMs := -1
+ if timeout >= 0 {
+ timeoutMs = int(timeout.Milliseconds())
+ }
+
+ for {
+ n, err := unix.EpollWait(r.epoll, events, timeoutMs)
+ if errors.Is(err, unix.EINTR) {
+ continue // try again if the syscall was interrupted
+ }
+
+ if err != nil {
+ return false, fmt.Errorf("epoll wait: %w", err)
+ }
+
+ if n == 0 {
+ return false, nil // timeout
+ }
+
+ break
+ }
+
+ switch events[0].Fd {
+ case int32(r.file.Fd()):
+ return true, nil
+ case int32(r.cancelSignalReader.Fd()):
+ // remove signal from pipe
+ var b [1]byte
+ _, readErr := r.cancelSignalReader.Read(b[:])
+ if readErr != nil {
+ return false, fmt.Errorf("reading cancel signal: %w", readErr)
+ }
+ return false, ErrCanceled
+ }
+
+ return false, fmt.Errorf("unknown error")
+}
+
+// Cancel cancels any ongoing poll or read operations.
+func (r *epollReader) Cancel() bool {
+ r.mu.Lock()
+ r.canceled = true
+ r.mu.Unlock()
+
+ // send cancel signal
+ _, err := r.cancelSignalWriter.Write([]byte{'c'})
+ return err == nil
+}
+
+// Close closes the reader and releases any resources.
+func (r *epollReader) Close() error {
+ var errMsgs []error
+
+ // close epoll
+ err := unix.Close(r.epoll)
+ if err != nil {
+ errMsgs = append(errMsgs, fmt.Errorf("closing epoll: %w", err))
+ }
+
+ // close pipe
+ err = r.cancelSignalWriter.Close()
+ if err != nil {
+ errMsgs = append(errMsgs, fmt.Errorf("closing cancel signal writer: %w", err))
+ }
+
+ err = r.cancelSignalReader.Close()
+ if err != nil {
+ errMsgs = append(errMsgs, fmt.Errorf("closing cancel signal reader: %w", err))
+ }
+
+ if len(errMsgs) > 0 {
+ return errors.Join(errMsgs...)
+ }
+
+ return nil
+}
diff --git a/vendor/github.com/charmbracelet/ultraviolet/poll_select.go b/vendor/github.com/charmbracelet/ultraviolet/poll_select.go
new file mode 100644
index 0000000000..ff7756a142
--- /dev/null
+++ b/vendor/github.com/charmbracelet/ultraviolet/poll_select.go
@@ -0,0 +1,156 @@
+//go:build solaris || darwin || freebsd || netbsd || openbsd || dragonfly
+// +build solaris darwin freebsd netbsd openbsd dragonfly
+
+package uv
+
+import (
+ "errors"
+ "fmt"
+ "io"
+ "os"
+ "strings"
+ "sync"
+ "time"
+
+ "golang.org/x/sys/unix"
+)
+
+// newSelectPollReader creates a new SelectReader for the given io.Reader.
+func newSelectPollReader(reader io.Reader) (pollReader, error) {
+ file, ok := reader.(File)
+ if !ok || file.Fd() >= unix.FD_SETSIZE {
+ return newFallbackReader(reader)
+ }
+
+ r := &selectReader{
+ reader: reader,
+ file: file,
+ }
+
+ var err error
+ r.cancelSignalReader, r.cancelSignalWriter, err = os.Pipe()
+ if err != nil {
+ return nil, err
+ }
+
+ return r, nil
+}
+
+// selectReader implements pollReader using the POSIX select API.
+type selectReader struct {
+ reader io.Reader
+ file File
+ cancelSignalReader *os.File
+ cancelSignalWriter *os.File
+ mu sync.Mutex
+ canceled bool
+}
+
+// Read reads data from the underlying reader.
+func (r *selectReader) Read(p []byte) (int, error) {
+ r.mu.Lock()
+ if r.canceled {
+ r.mu.Unlock()
+ return 0, ErrCanceled
+ }
+ r.mu.Unlock()
+
+ return r.reader.Read(p)
+}
+
+// Poll waits for data to be available to read with the given timeout.
+func (r *selectReader) Poll(timeout time.Duration) (bool, error) {
+ r.mu.Lock()
+ if r.canceled {
+ r.mu.Unlock()
+ return false, ErrCanceled
+ }
+ r.mu.Unlock()
+
+ for {
+ readerFd := int(r.file.Fd())
+ abortFd := int(r.cancelSignalReader.Fd())
+
+ maxFd := readerFd
+ if abortFd > maxFd {
+ maxFd = abortFd
+ }
+
+ // this is a limitation of the select syscall
+ if maxFd >= unix.FD_SETSIZE {
+ return false, fmt.Errorf("cannot select on file descriptor %d which is larger than %d", maxFd, unix.FD_SETSIZE)
+ }
+
+ fdSet := &unix.FdSet{}
+ fdSet.Set(readerFd)
+ fdSet.Set(abortFd)
+
+ var tv *unix.Timeval
+ if timeout >= 0 {
+ t := unix.NsecToTimeval(timeout.Nanoseconds())
+ tv = &t
+ }
+
+ n, err := unix.Select(maxFd+1, fdSet, nil, nil, tv)
+ if errors.Is(err, unix.EINTR) {
+ continue // try again if the syscall was interrupted
+ }
+
+ if err != nil {
+ return false, fmt.Errorf("select: %w", err)
+ }
+
+ if n == 0 {
+ return false, nil // timeout
+ }
+
+ if fdSet.IsSet(abortFd) {
+ // remove signal from pipe
+ var b [1]byte
+ _, readErr := r.cancelSignalReader.Read(b[:])
+ if readErr != nil {
+ return false, fmt.Errorf("reading cancel signal: %w", readErr)
+ }
+ return false, ErrCanceled
+ }
+
+ if fdSet.IsSet(readerFd) {
+ return true, nil
+ }
+
+ return false, fmt.Errorf("select returned without setting a file descriptor")
+ }
+}
+
+// Cancel cancels any ongoing poll or read operations.
+func (r *selectReader) Cancel() bool {
+ r.mu.Lock()
+ r.canceled = true
+ r.mu.Unlock()
+
+ // send cancel signal
+ _, err := r.cancelSignalWriter.Write([]byte{'c'})
+ return err == nil
+}
+
+// Close closes the reader and releases any resources.
+func (r *selectReader) Close() error {
+ var errMsgs []string
+
+ // close pipe
+ err := r.cancelSignalWriter.Close()
+ if err != nil {
+ errMsgs = append(errMsgs, fmt.Sprintf("closing cancel signal writer: %v", err))
+ }
+
+ err = r.cancelSignalReader.Close()
+ if err != nil {
+ errMsgs = append(errMsgs, fmt.Sprintf("closing cancel signal reader: %v", err))
+ }
+
+ if len(errMsgs) > 0 {
+ return fmt.Errorf("%s", strings.Join(errMsgs, ", "))
+ }
+
+ return nil
+}
diff --git a/vendor/github.com/charmbracelet/ultraviolet/poll_solaris.go b/vendor/github.com/charmbracelet/ultraviolet/poll_solaris.go
new file mode 100644
index 0000000000..7a753da45b
--- /dev/null
+++ b/vendor/github.com/charmbracelet/ultraviolet/poll_solaris.go
@@ -0,0 +1,12 @@
+//go:build solaris
+// +build solaris
+
+package uv
+
+import "io"
+
+// newPollReader creates a new pollReader for the given io.Reader.
+// On Solaris, we use the select API.
+func newPollReader(reader io.Reader) (pollReader, error) {
+ return newSelectPollReader(reader)
+}
diff --git a/vendor/github.com/charmbracelet/ultraviolet/poll_windows.go b/vendor/github.com/charmbracelet/ultraviolet/poll_windows.go
new file mode 100644
index 0000000000..2e1922eb2c
--- /dev/null
+++ b/vendor/github.com/charmbracelet/ultraviolet/poll_windows.go
@@ -0,0 +1,217 @@
+//go:build windows
+// +build windows
+
+package uv
+
+import (
+ "fmt"
+ "io"
+ "os"
+ "sync"
+ "time"
+
+ "golang.org/x/sys/windows"
+)
+
+var fileShareValidFlags uint32 = windows.FILE_SHARE_DELETE | windows.FILE_SHARE_WRITE | windows.FILE_SHARE_READ
+
+// newPollReader creates a new pollReader for the given io.Reader.
+func newPollReader(reader io.Reader) (pollReader, error) {
+ f, ok := reader.(File)
+ if !ok || f.Fd() != os.Stdin.Fd() {
+ return newFallbackReader(reader)
+ }
+
+ // it is necessary to open CONIN$ (NOT windows.STD_INPUT_HANDLE) in
+ // overlapped mode to be able to use it with WaitForMultipleObjects.
+ coninPath, err := windows.UTF16PtrFromString("CONIN$")
+ if err != nil {
+ return nil, fmt.Errorf("convert CONIN$ to UTF16: %w", err)
+ }
+
+ conin, err := windows.CreateFile(
+ coninPath,
+ windows.GENERIC_READ|windows.GENERIC_WRITE,
+ fileShareValidFlags,
+ nil,
+ windows.OPEN_EXISTING,
+ windows.FILE_FLAG_OVERLAPPED,
+ 0)
+ if err != nil {
+ return nil, fmt.Errorf("open CONIN$ in overlapping mode: %w", err)
+ }
+
+ resetConsole, err := preparePollConsole(conin)
+ if err != nil {
+ _ = windows.CloseHandle(conin)
+ return nil, fmt.Errorf("prepare console: %w", err)
+ }
+
+ // flush input, otherwise it can contain events which trigger
+ // WaitForMultipleObjects but which ReadFile cannot read, resulting in an
+ // un-cancelable read
+ err = windows.FlushConsoleInputBuffer(conin)
+ if err != nil {
+ _ = windows.CloseHandle(conin)
+ return nil, fmt.Errorf("flush console input buffer: %w", err)
+ }
+
+ cancelEvent, err := windows.CreateEvent(nil, 0, 0, nil)
+ if err != nil {
+ _ = windows.CloseHandle(conin)
+ return nil, fmt.Errorf("create cancel event: %w", err)
+ }
+
+ return &conReader{
+ reader: reader,
+ conin: conin,
+ cancelEvent: cancelEvent,
+ resetConsole: resetConsole,
+ blockingReadSignal: make(chan struct{}, 1),
+ }, nil
+}
+
+// conReader implements pollReader using Windows I/O and Console APIs.
+type conReader struct {
+ reader io.Reader
+ conin windows.Handle
+ cancelEvent windows.Handle
+ resetConsole func() error
+ blockingReadSignal chan struct{}
+ mu sync.Mutex
+ canceled bool
+}
+
+// Read reads data from the underlying reader.
+func (r *conReader) Read(p []byte) (int, error) {
+ r.mu.Lock()
+ if r.canceled {
+ r.mu.Unlock()
+ return 0, ErrCanceled
+ }
+ r.mu.Unlock()
+
+ return r.reader.Read(p)
+}
+
+// Poll waits for data to be available to read with the given timeout.
+func (r *conReader) Poll(timeout time.Duration) (bool, error) {
+ r.mu.Lock()
+ if r.canceled {
+ r.mu.Unlock()
+ return false, ErrCanceled
+ }
+ r.mu.Unlock()
+
+ timeoutMs := uint32(windows.INFINITE)
+ if timeout >= 0 {
+ timeoutMs = uint32(timeout.Milliseconds())
+ }
+
+ event, err := windows.WaitForMultipleObjects([]windows.Handle{r.conin, r.cancelEvent}, false, timeoutMs)
+ switch {
+ case windows.WAIT_OBJECT_0 <= event && event < windows.WAIT_OBJECT_0+2:
+ if event == windows.WAIT_OBJECT_0+1 {
+ return false, ErrCanceled
+ }
+
+ if event == windows.WAIT_OBJECT_0 {
+ return true, nil
+ }
+
+ return false, fmt.Errorf("unexpected wait object is ready: %d", event-windows.WAIT_OBJECT_0)
+ case windows.WAIT_ABANDONED <= event && event < windows.WAIT_ABANDONED+2:
+ return false, fmt.Errorf("abandoned")
+ case event == uint32(windows.WAIT_TIMEOUT):
+ return false, nil
+ case event == windows.WAIT_FAILED:
+ return false, fmt.Errorf("failed")
+ default:
+ return false, fmt.Errorf("unexpected error: %w", error(err))
+ }
+}
+
+// Cancel cancels any ongoing poll or read operations.
+// On Windows Terminal, WaitForMultipleObjects sometimes immediately returns
+// without input being available. In this case, graceful cancelation is not
+// possible and Cancel() returns false.
+func (r *conReader) Cancel() bool {
+ r.mu.Lock()
+ r.canceled = true
+ r.mu.Unlock()
+
+ select {
+ case r.blockingReadSignal <- struct{}{}:
+ err := windows.SetEvent(r.cancelEvent)
+ if err != nil {
+ return false
+ }
+ <-r.blockingReadSignal
+ case <-time.After(100 * time.Millisecond):
+ // Read() hangs in a GetOverlappedResult which is likely due to
+ // WaitForMultipleObjects returning without input being available
+ // so we cannot cancel this ongoing read.
+ return false
+ }
+
+ return true
+}
+
+// Close closes the reader and releases any resources.
+func (r *conReader) Close() error {
+ err := windows.CloseHandle(r.cancelEvent)
+ if err != nil {
+ return fmt.Errorf("closing cancel event handle: %w", err)
+ }
+
+ err = r.resetConsole()
+ if err != nil {
+ return err
+ }
+
+ err = windows.CloseHandle(r.conin)
+ if err != nil {
+ return fmt.Errorf("closing CONIN$: %w", err)
+ }
+
+ return nil
+}
+
+func preparePollConsole(input windows.Handle) (reset func() error, err error) {
+ var originalMode uint32
+
+ err = windows.GetConsoleMode(input, &originalMode)
+ if err != nil {
+ return nil, fmt.Errorf("get console mode: %w", err)
+ }
+
+ var newMode uint32
+ newMode &^= windows.ENABLE_ECHO_INPUT
+ newMode &^= windows.ENABLE_LINE_INPUT
+ newMode &^= windows.ENABLE_MOUSE_INPUT
+ newMode &^= windows.ENABLE_PROCESSED_INPUT
+
+ newMode |= windows.ENABLE_EXTENDED_FLAGS
+ newMode |= windows.ENABLE_INSERT_MODE
+ newMode |= windows.ENABLE_QUICK_EDIT_MODE
+ newMode |= windows.ENABLE_WINDOW_INPUT // Enable window input events
+
+ // Enabling virtual terminal input is necessary for processing certain
+ // types of input like X10 mouse events and arrows keys with the current
+ // bytes-based input reader.
+ newMode |= windows.ENABLE_VIRTUAL_TERMINAL_INPUT
+
+ err = windows.SetConsoleMode(input, newMode)
+ if err != nil {
+ return nil, fmt.Errorf("set console mode: %w", err)
+ }
+
+ return func() error {
+ err := windows.SetConsoleMode(input, originalMode)
+ if err != nil {
+ return fmt.Errorf("reset console mode: %w", err)
+ }
+
+ return nil
+ }, nil
+}
diff --git a/vendor/github.com/charmbracelet/ultraviolet/styled.go b/vendor/github.com/charmbracelet/ultraviolet/styled.go
new file mode 100644
index 0000000000..83b0962135
--- /dev/null
+++ b/vendor/github.com/charmbracelet/ultraviolet/styled.go
@@ -0,0 +1,374 @@
+package uv
+
+import (
+ "bytes"
+ "image/color"
+ "strings"
+
+ "github.com/charmbracelet/x/ansi"
+)
+
+// StyledString is a string that can be decomposed into a series of styled
+// lines and cells. It is used to disassemble a rendered string with ANSI
+// escape codes into a series of cells that can be used in a [Buffer].
+// A StyledString supports reading [ansi.SGR] and [ansi.Hyperlink] escape
+// codes.
+type StyledString struct {
+ // Text is the original string that was used to create the styled string.
+ Text string
+ // Wrap determines whether the styled string should wrap to the next line.
+ Wrap bool
+ // Tail is the string that will be appended to the end of the line when the
+ // string is truncated i.e. when [StyledString.Wrap] is false.
+ Tail string
+}
+
+var _ Drawable = (*StyledString)(nil)
+
+// NewStyledString creates a new [StyledString] for the given method and styled
+// string. The method is used to calculate the width of each line.
+func NewStyledString(str string) *StyledString {
+ ss := new(StyledString)
+ ss.Text = str
+ return ss
+}
+
+// String returns the text of the styled string.
+//
+// It implements the [fmt.Stringer] interface.
+func (s *StyledString) String() string {
+ return s.Text
+}
+
+// Lines returns the styled string decomposed into a slice of [Line]s.
+func (s *StyledString) Lines(m ansi.Method) []Line {
+ return printString(nil, m, 0, 0, Rectangle{}, s.Text, false, "")
+}
+
+// Draw renders the styled string to the given buffer at the
+// specified area.
+func (s *StyledString) Draw(buf Screen, area Rectangle) {
+ // Clear the area before drawing.
+ for y := area.Min.Y; y < area.Max.Y; y++ {
+ for x := area.Min.X; x < area.Max.X; x++ {
+ buf.SetCell(x, y, nil)
+ }
+ }
+ str := s.Text
+ // We need to normalize newlines "\n" to "\r\n" to emulate a raw terminal
+ // output.
+ str = strings.ReplaceAll(str, "\r\n", "\n")
+ printString(buf, buf.WidthMethod(), area.Min.X, area.Min.Y, area, str, !s.Wrap, s.Tail)
+}
+
+// Height returns the number of lines in the styled string. This is the number
+// of lines that the styled string will occupy when rendered to the screen.
+func (s *StyledString) Height() int {
+ return strings.Count(s.Text, "\n") + 1
+}
+
+// UnicodeWidth returns the cells width of the widest line in the styled string
+// using the [ansi.GraphemeWidth] method.
+func (s *StyledString) UnicodeWidth() int {
+ w, _ := s.widthHeight(ansi.GraphemeWidth)
+ return w
+}
+
+// WcWidth returns the cells width of the widest line in the styled string
+// using the [ansi.WcWidth] method.
+func (s *StyledString) WcWidth() int {
+ w, _ := s.widthHeight(ansi.WcWidth)
+ return w
+}
+
+func (s *StyledString) widthHeight(m ansi.Method) (w, h int) {
+ lines := strings.Split(s.Text, "\n")
+ h = len(lines)
+ for _, l := range lines {
+ w = max(w, m.StringWidth(l))
+ }
+ return
+}
+
+// Bounds returns the minimum area that can contain the whole styled string.
+func (s *StyledString) Bounds() Rectangle {
+ w, h := s.widthHeight(ansi.GraphemeWidth)
+ return Rect(0, 0, w, h)
+}
+
+// printString draws a string starting at the given position. If s is nil, it
+// will build and return a slice of [Line]s instead (unwrapped, ignoring bounds).
+func printString[T []byte | string](
+ s Screen,
+ m WidthMethod,
+ x, y int,
+ bounds Rectangle, str T,
+ truncate bool, tail string,
+) (lines []Line) {
+ p := ansi.GetParser()
+ defer ansi.PutParser(p)
+
+ var tailc Cell
+ if truncate && len(tail) > 0 {
+ tailc = *NewCell(m, tail)
+ }
+
+ // A [WidthMethod] the ansi package doesn't know about falls back to
+ // wcwidth, so the segmenter below always agrees with the decoder.
+ decoder, method := ansi.DecodeSequenceWc[T], ansi.WcWidth
+ if m == ansi.GraphemeWidth {
+ decoder, method = ansi.DecodeSequence[T], ansi.GraphemeWidth
+ }
+
+ if s == nil {
+ lines = []Line{}
+ }
+
+ var cell Cell
+ var style Style
+ var link Link
+ var state byte
+ lastX, lastY := -1, -1 // last cell written, for folding in combining marks
+ for len(str) > 0 {
+ seq, width, n, newState := decoder(str, state, p)
+ // The decoder's ASCII fast path doesn't check for trailing combining
+ // sequences, so re-decode as a full cluster when one starts here.
+ // The str[1] >= 0xc0 check skips the segmenter for plain ASCII.
+ if n == 1 && seq[0] > 0x1f && seq[0] < 0x7f && len(str) > 1 && str[1] >= 0xc0 {
+ if cluster, cw := ansi.FirstGraphemeCluster(str, method); len(cluster) > 1 {
+ seq, width, n = cluster, cw, len(cluster)
+ }
+ }
+ switch {
+ // Any positive width is a printable grapheme cluster. Wcwidth measures
+ // a cluster per codepoint, so this is not bounded by how wide a glyph
+ // can be: a ZWJ emoji sequence such as "👨👩👧👦" is eight columns,
+ // and capping the width here would fall through to the escape sequence
+ // branch and drop the cluster from the screen.
+ case width > 0:
+ cell.Width = width
+ cell.Content = string(seq)
+ cell.Style = style
+ cell.Link = link
+
+ if s == nil {
+ // Building lines: unwrapped, no bounds
+ if y >= len(lines) {
+ lines = append(lines, Line{})
+ }
+ lines[y] = append(lines[y], cell)
+ lastX, lastY = len(lines[y])-1, y
+ x += width
+ } else {
+ // Drawing to screen: handle wrapping, truncation, and bounds
+ if !truncate && x+cell.Width > bounds.Max.X && y+1 < bounds.Max.Y {
+ // Wrap the string to the width of the window
+ x = bounds.Min.X
+ y++
+ }
+
+ pos := Pos(x, y)
+ if pos.In(bounds) {
+ if truncate && tailc.Width > 0 && x+cell.Width > bounds.Max.X-tailc.Width {
+ // Truncate the string and append the tail if any.
+ cell = tailc
+ cell.Style = style
+ cell.Link = link
+ s.SetCell(x, y, &cell)
+ lastX, lastY = x, y
+ x += tailc.Width
+ } else {
+ // Print the cell to the screen
+ s.SetCell(x, y, &cell)
+ lastX, lastY = x, y
+ x += width
+ }
+ }
+ }
+
+ // Reset cell for next iteration
+ cell = Cell{}
+ default:
+ // Valid sequences always have a non-zero Cmd.
+ // TODO: Handle cursor movement and other sequences
+ switch {
+ case ansi.HasCsiPrefix(seq) && p.Command() == 'm':
+ // SGR - Select Graphic Rendition
+ ReadStyle(p.Params(), &style)
+ case ansi.HasOscPrefix(seq) && p.Command() == 8:
+ // Hyperlinks
+ ReadLink(p.Data(), &link)
+ case ansi.Equal(seq, T("\n")):
+ if s == nil {
+ // When building lines, we need to ensure empty lines are represented.
+ if y >= len(lines) {
+ lines = append(lines, Line{})
+ }
+ }
+ y++
+ // Always treat a NL as CR-LF similar to Termios ONLCR.
+ fallthrough
+ case ansi.Equal(seq, T("\r")):
+ if s == nil {
+ x = 0
+ } else {
+ x = bounds.Min.X
+ }
+ case len(seq) > 0 && seq[0] >= 0xc0:
+ // A zero-width grapheme, i.e. a combining mark the re-decode
+ // above couldn't fold because an escape sequence sits between
+ // it and its base, as in "a\x1b[31m\u0301". Every escape
+ // introducer is a C0 or C1 byte, so a UTF-8 lead byte here is
+ // always text. The mark belongs to the cell we last wrote; the
+ // accumulator below would let the next glyph clobber it.
+ if s == nil {
+ if lastY >= 0 && lastY < len(lines) && lastX < len(lines[lastY]) {
+ lines[lastY][lastX].Content += string(seq)
+ }
+ } else if lastX >= 0 {
+ if prev := s.CellAt(lastX, lastY); prev != nil {
+ folded := *prev
+ folded.Content += string(seq)
+ s.SetCell(lastX, lastY, &folded)
+ }
+ }
+ default:
+ cell.Content += string(seq)
+ }
+ }
+
+ // Advance the state and data
+ state = newState
+ str = str[n:]
+
+ if y >= bounds.Max.Y {
+ // We've reached the bottom of the bounds, stop processing further
+ // lines.
+ break
+ }
+ }
+
+ // Make sure to set the last cell if it's not empty.
+ if !cell.IsZero() && s != nil {
+ s.SetCell(x, y, &cell)
+ }
+
+ return lines
+}
+
+// ReadStyle reads a Select Graphic Rendition (SGR) escape sequences from a
+// list of parameters into pen.
+func ReadStyle(params ansi.Params, pen *Style) {
+ if len(params) == 0 {
+ *pen = Style{}
+ return
+ }
+
+ for i := 0; i < len(params); i++ {
+ param, hasMore, _ := params.Param(i, 0)
+ switch param {
+ case 0: // Reset
+ *pen = Style{}
+ case 1: // Bold
+ pen.Attrs |= AttrBold
+ case 2: // Dim/Faint
+ pen.Attrs |= AttrFaint
+ case 3: // Italic
+ pen.Attrs |= AttrItalic
+ case 4: // Underline
+ nextParam, _, ok := params.Param(i+1, 0)
+ if hasMore && ok { // Only accept subparameters i.e. separated by ":"
+ switch nextParam {
+ case 0, 1, 2, 3, 4, 5:
+ i++
+ switch nextParam {
+ case 0: // No Underline
+ pen.Underline = UnderlineStyleNone
+ case 1: // Single Underline
+ pen.Underline = UnderlineStyleSingle
+ case 2: // Double Underline
+ pen.Underline = UnderlineStyleDouble
+ case 3: // Curly Underline
+ pen.Underline = UnderlineStyleCurly
+ case 4: // Dotted Underline
+ pen.Underline = UnderlineStyleDotted
+ case 5: // Dashed Underline
+ pen.Underline = UnderlineStyleDashed
+ }
+ }
+ } else {
+ // Single Underline
+ pen.Underline = UnderlineStyleSingle
+ }
+ case 5: // Slow Blink
+ pen.Attrs |= AttrBlink
+ case 6: // Rapid Blink
+ pen.Attrs |= AttrRapidBlink
+ case 7: // Reverse
+ pen.Attrs |= AttrReverse
+ case 8: // Conceal
+ pen.Attrs |= AttrConceal
+ case 9: // Crossed-out/Strikethrough
+ pen.Attrs |= AttrStrikethrough
+ case 22: // Normal Intensity (not bold or faint)
+ pen.Attrs &^= (AttrBold | AttrFaint)
+ case 23: // Not italic, not Fraktur
+ pen.Attrs &^= AttrItalic
+ case 24: // Not underlined
+ pen.Underline = UnderlineStyleNone
+ case 25: // Blink off
+ pen.Attrs &^= (AttrBlink | AttrRapidBlink)
+ case 27: // Positive (not reverse)
+ pen.Attrs &^= AttrReverse
+ case 28: // Reveal
+ pen.Attrs &^= AttrConceal
+ case 29: // Not crossed out
+ pen.Attrs &^= AttrStrikethrough
+ case 30, 31, 32, 33, 34, 35, 36, 37: // Set foreground
+ pen.Fg = ansi.Black + ansi.BasicColor(param-30) //nolint:gosec
+ case 38: // Set foreground 256 or truecolor
+ var c color.Color
+ n := ansi.ReadStyleColor(params[i:], &c)
+ if n > 0 {
+ pen.Fg = c
+ i += n - 1
+ }
+ case 39: // Default foreground
+ pen.Fg = nil
+ case 40, 41, 42, 43, 44, 45, 46, 47: // Set background
+ pen.Bg = ansi.Black + ansi.BasicColor(param-40) //nolint:gosec
+ case 48: // Set background 256 or truecolor
+ var c color.Color
+ n := ansi.ReadStyleColor(params[i:], &c)
+ if n > 0 {
+ pen.Bg = c
+ i += n - 1
+ }
+ case 49: // Default Background
+ pen.Bg = nil
+ case 58: // Set underline color
+ var c color.Color
+ n := ansi.ReadStyleColor(params[i:], &c)
+ if n > 0 {
+ pen.UnderlineColor = c
+ i += n - 1
+ }
+ case 59: // Default underline color
+ pen.UnderlineColor = nil
+ case 90, 91, 92, 93, 94, 95, 96, 97: // Set bright foreground
+ pen.Fg = ansi.BrightBlack + ansi.BasicColor(param-90) //nolint:gosec
+ case 100, 101, 102, 103, 104, 105, 106, 107: // Set bright background
+ pen.Bg = ansi.BrightBlack + ansi.BasicColor(param-100) //nolint:gosec
+ }
+ }
+}
+
+// ReadLink reads a hyperlink escape sequence from a data buffer into link.
+func ReadLink(p []byte, link *Link) {
+ params := bytes.Split(p, []byte{';'})
+ if len(params) != 3 {
+ return
+ }
+ link.Params = string(params[1])
+ link.URL = string(params[2])
+}
diff --git a/vendor/github.com/charmbracelet/ultraviolet/tabstop.go b/vendor/github.com/charmbracelet/ultraviolet/tabstop.go
new file mode 100644
index 0000000000..ce13814bcf
--- /dev/null
+++ b/vendor/github.com/charmbracelet/ultraviolet/tabstop.go
@@ -0,0 +1,142 @@
+package uv
+
+// DefaultTabInterval is the default tab interval.
+const DefaultTabInterval = 8
+
+// TabStops represents horizontal line tab stops.
+type TabStops struct {
+ stops []int
+ interval int
+ width int
+}
+
+// NewTabStops creates a new set of tab stops from a number of columns and an
+// interval.
+func NewTabStops(width, interval int) *TabStops {
+ ts := new(TabStops)
+ ts.interval = interval
+ ts.width = width
+ ts.stops = make([]int, (width+(interval-1))/interval)
+ ts.init(0, width)
+ return ts
+}
+
+// DefaultTabStops creates a new set of tab stops with the default interval.
+func DefaultTabStops(cols int) *TabStops {
+ return NewTabStops(cols, DefaultTabInterval)
+}
+
+// Resize resizes the tab stops to the given width.
+func (ts *TabStops) Resize(width int) {
+ if width == ts.width {
+ return
+ }
+
+ if width < ts.width {
+ size := (width + (ts.interval - 1)) / ts.interval
+ ts.stops = ts.stops[:size]
+ } else {
+ size := (width - ts.width + (ts.interval - 1)) / ts.interval
+ ts.stops = append(ts.stops, make([]int, size)...)
+ }
+
+ ts.init(ts.width, width)
+ ts.width = width
+}
+
+// Width returns the width of the screen that the tab stops are set for.
+func (ts *TabStops) Width() int {
+ return ts.width
+}
+
+// IsStop returns true if the given column is a tab stop.
+func (ts TabStops) IsStop(col int) bool {
+ mask := ts.mask(col)
+ i := col >> 3
+ if i < 0 || i >= len(ts.stops) {
+ return false
+ }
+ return ts.stops[i]&mask != 0
+}
+
+// Next returns the next tab stop after the given column.
+func (ts TabStops) Next(col int) int {
+ return ts.Find(col, 1)
+}
+
+// Prev returns the previous tab stop before the given column.
+func (ts TabStops) Prev(col int) int {
+ return ts.Find(col, -1)
+}
+
+// Find returns the prev/next tab stop before/after the given column and delta.
+// If delta is positive, it returns the next tab stop after the given column.
+// If delta is negative, it returns the previous tab stop before the given column.
+// If delta is zero, it returns the given column.
+func (ts TabStops) Find(col, delta int) int {
+ if delta == 0 {
+ return col
+ }
+
+ var prev bool
+ count := delta
+ if count < 0 {
+ count = -count
+ prev = true
+ }
+
+ for count > 0 {
+ if !prev {
+ if col >= ts.width-1 {
+ return col
+ }
+
+ col++
+ } else {
+ if col < 1 {
+ return col
+ }
+
+ col--
+ }
+
+ if ts.IsStop(col) {
+ count--
+ }
+ }
+
+ return col
+}
+
+// Set adds a tab stop at the given column.
+func (ts *TabStops) Set(col int) {
+ mask := ts.mask(col)
+ ts.stops[col>>3] |= mask
+}
+
+// Reset removes the tab stop at the given column.
+func (ts *TabStops) Reset(col int) {
+ mask := ts.mask(col)
+ ts.stops[col>>3] &= ^mask
+}
+
+// Clear removes all tab stops.
+func (ts *TabStops) Clear() {
+ ts.stops = make([]int, len(ts.stops))
+}
+
+// mask returns the mask for the given column.
+func (ts *TabStops) mask(col int) int {
+ return 1 << (col & (ts.interval - 1))
+}
+
+// init initializes the tab stops starting from col until width.
+func (ts *TabStops) init(col, width int) {
+ for x := col; x < width; x++ {
+ if x%ts.interval == 0 {
+ ts.Set(x)
+ } else {
+ ts.Reset(x)
+ }
+ }
+}
diff --git a/vendor/github.com/charmbracelet/ultraviolet/terminal.go b/vendor/github.com/charmbracelet/ultraviolet/terminal.go
new file mode 100644
index 0000000000..a9fb453806
--- /dev/null
+++ b/vendor/github.com/charmbracelet/ultraviolet/terminal.go
@@ -0,0 +1,394 @@
+package uv
+
+import (
+ "fmt"
+ "os"
+ "os/signal"
+ "time"
+
+ "github.com/charmbracelet/x/ansi"
+ "golang.org/x/sync/errgroup"
+)
+
+// DefaultBufferSize is the default size of the input buffer used for reading
+// terminal events.
+const DefaultBufferSize = 4096
+
+// DefaultEventTimeout is the default duration to wait for input events before
+// timing out.
+const DefaultEventTimeout = 100 * time.Millisecond
+
+// Options represents options for creating a new [Terminal].
+type Options struct {
+ // BufferSize is the size of the input buffer used for reading terminal
+ // events. If zero, [DefaultBufferSize] is used.
+ BufferSize int
+
+ // EventTimeout is the duration to wait for input events before timing out.
+ // If zero, a default of 100 milliseconds is used.
+ EventTimeout time.Duration
+
+ // LegacyKeyEncoding represents any legacy key encoding ambiguities. By
+ // default, the terminal will use its preferred key encoding settings.
+ LegacyKeyEncoding LegacyKeyEncoding
+
+ // LookupKeys whether to use a lookup table for common key sequences. If
+ // true, the terminal will use a lookup table to quickly identify common
+ // key sequences, reducing the need for more complex decoding logic. This
+ // can improve performance for common key sequences at the cost of
+ // increased memory usage.
+ //
+ // This is enabled by default.
+ LookupKeys bool
+
+ // UseTerminfoKeys whether to use terminfo databases key definitions to
+ // build up the keys lookup table. If true, the terminal will use terminfo
+ // databases key definitions to build up the keys lookup table, which can
+ // provide more accurate key mappings for legacy non-xterm like terminals.
+ //
+ // This won't take effect if [TerminalOptions.LookupKeys] is false, since
+ // the lookup table won't be used.
+ //
+ // This is disabled by default.
+ UseTerminfoKeys bool
+
+ // Logger is an optional logger for tracing terminal I/O operations.
+ // If nil, no logging is performed.
+ Logger Logger
+}
+
+// DefaultOptions returns the default [Terminal] options.
+func DefaultOptions() *Options {
+ return &Options{
+ BufferSize: DefaultBufferSize,
+ EventTimeout: DefaultEventTimeout,
+ LookupKeys: true,
+ }
+}
+
+// Terminal represents an interactive terminal application.
+type Terminal struct {
+ con Console
+ opts *Options
+ scr *TerminalScreen
+ pr pollReader
+ buf []byte
+ evc chan Event
+ errg errgroup.Group
+ winch chan os.Signal
+ donec chan struct{}
+}
+
+// DefaultTerminal creates a new [Terminal] instance using the default standard
+// console and the given options. Options can be nil to use the default
+// options.
+//
+// This is a convenience function for creating a terminal that uses the
+// standard input and output file descriptors.
+func DefaultTerminal() *Terminal {
+ return NewTerminal(nil, nil)
+}
+
+// ControllingTerminal creates a new [Terminal] instance using the controlling
+// terminal's input and output file descriptors.
+// Options can be nil to use the default options.
+//
+// This is a convenience function for creating a terminal that uses the
+// controlling TTY of the current process.
+func ControllingTerminal() (*Terminal, error) {
+ con, err := ControllingConsole()
+ if err != nil {
+ return nil, err
+ }
+ return NewTerminal(con, nil), nil
+}
+
+// NewTerminal creates a new [Terminal] instance with the given console and
+// options.
+// Options can be nil to use the default options.
+func NewTerminal(con Console, opts *Options) *Terminal {
+ t := &Terminal{}
+ if con == nil {
+ con = DefaultConsole()
+ }
+ if opts == nil {
+ opts = DefaultOptions()
+ }
+ if opts.BufferSize <= 0 {
+ opts.BufferSize = DefaultBufferSize
+ }
+ if opts.EventTimeout <= 0 {
+ opts.EventTimeout = DefaultEventTimeout
+ }
+ t.con = con
+ t.opts = opts
+ t.scr = NewTerminalScreen(t.con.Writer(), t.con.Environ())
+ t.buf = make([]byte, opts.BufferSize)
+ // These channels never close during the terminal's lifetime.
+ t.evc = make(chan Event)
+ t.winch = make(chan os.Signal, 1) // buffered to avoid missing signals
+ if opts.Logger != nil {
+ t.scr.rend.SetLogger(opts.Logger)
+ }
+ return t
+}
+
+// GetSize returns the current size of the terminal in characters and pixels.
+func (t *Terminal) GetSize() (width, height int, err error) {
+ w, h, err := t.con.GetSize()
+ if err != nil {
+ return 0, 0, fmt.Errorf("getting terminal size: %w", err)
+ }
+ return int(w), int(h), nil
+}
+
+// GetWinsize returns the current size of the terminal as a [Winsize] struct.
+// This includes both character dimensions (columns and rows) and pixel
+// dimensions (xpixel and ypixel).
+//
+// Note that this only returns the pixel dimensions on Unix-like systems that
+// support the TIOCGWINSZ ioctl. On other platforms, the pixel dimensions may
+// be zero or not available.
+func (t *Terminal) GetWinsize() (*Winsize, error) {
+ ws, err := t.con.GetWinsize()
+ if err != nil {
+ return nil, fmt.Errorf("getting terminal winsize: %w", err)
+ }
+ return ws, nil
+}
+
+// Screen returns the terminal's screen.
+func (t *Terminal) Screen() *TerminalScreen {
+ return t.scr
+}
+
+// Events returns the terminal's event channel.
+func (t *Terminal) Events() <-chan Event {
+ return t.evc
+}
+
+// Start starts the terminal application event loop. This is a non-blocking
+// call. Use [Terminal.Wait] to wait for the terminal to exit.
+func (t *Terminal) Start() error {
+ _, err := t.con.MakeRaw()
+ if err != nil {
+ return fmt.Errorf("failed to set terminal to raw mode: %w", err)
+ }
+
+ evs := newEventScanner()
+ evs.lookup = t.opts.LookupKeys
+ if evs.lookup {
+ evs.table = buildKeysTable(t.opts.LegacyKeyEncoding, t.con.Getenv("TERM"), t.opts.UseTerminfoKeys)
+ }
+ if t.opts.Logger != nil {
+ evs.setLogger(t.opts.Logger)
+ }
+ bufc := make(chan []byte)
+ t.donec = make(chan struct{})
+ t.pr, err = newPollReader(t.con.Reader())
+ if err != nil {
+ return fmt.Errorf("failed to create poll reader: %w", err)
+ }
+
+ // input loop
+ t.errg.Go(func() error {
+ for {
+ n, err := t.pr.Read(t.buf)
+ if err != nil {
+ return fmt.Errorf("reading terminal input: %w", err)
+ }
+ select {
+ case bufc <- t.buf[:n]:
+ case <-t.donec:
+ return nil
+ }
+ }
+ })
+
+ // event loop
+ sendEvents := func(buf []byte, expired bool) int {
+ n, events := evs.scanEvents(buf, expired)
+ for _, ev := range events {
+ t.handleEvent(ev)
+ t.SendEvent(ev)
+ }
+ return n
+ }
+ t.errg.Go(func() error {
+ var buf []byte
+ timer := time.NewTimer(t.opts.EventTimeout)
+ timeout := time.Now().Add(t.opts.EventTimeout)
+
+ for {
+ select {
+ case <-t.donec:
+ return nil
+ case <-timer.C:
+ expired := len(buf) > 0 && time.Now().After(timeout)
+ n := sendEvents(buf, expired)
+ if n > 0 {
+ buf = buf[min(n, len(buf)):]
+ }
+ if len(buf) > 0 {
+ timer.Reset(t.opts.EventTimeout)
+ }
+ case data := <-bufc:
+ buf = append(buf, data...)
+ n := sendEvents(buf, false)
+ timeout = time.Now().Add(t.opts.EventTimeout)
+ timer.Stop()
+ if n > 0 {
+ buf = buf[min(n, len(buf)):]
+ }
+ if len(buf) > 0 {
+ timer.Reset(t.opts.EventTimeout)
+ }
+ }
+ }
+ })
+
+ sendWinsize := func() error {
+ ws, err := t.con.GetWinsize()
+ if err != nil {
+ return fmt.Errorf("getting terminal size: %w", err)
+ }
+ if ws.Col > 0 && ws.Row > 0 {
+ t.SendEvent(WindowSizeEvent{
+ Width: int(ws.Col),
+ Height: int(ws.Row),
+ })
+ }
+ if ws.Xpixel > 0 && ws.Ypixel > 0 {
+ t.SendEvent(PixelSizeEvent{
+ Width: int(ws.Xpixel),
+ Height: int(ws.Ypixel),
+ })
+ }
+ return nil
+ }
+
+ // winch handler
+ NotifyWinch(t.winch)
+ t.errg.Go(func() error {
+ for {
+ select {
+ case <-t.donec:
+ return nil
+ case <-t.winch:
+ if err := sendWinsize(); err != nil {
+ return err
+ }
+ }
+ }
+ })
+
+ // init window size
+ t.errg.Go(func() error {
+ if err := sendWinsize(); err != nil {
+ return err
+ }
+ return nil
+ })
+
+ // Restore any previous screen state.
+ t.scr.Restore()
+ // Query whether the terminal supports Unicode core mode (DEC mode 2027) so
+ // we can negotiate grapheme-cluster width. The response is handled in the
+ // event loop.
+ t.scr.requestGraphemeWidth()
+ if err := t.scr.Flush(); err != nil {
+ return fmt.Errorf("failed to flush terminal screen: %w", err)
+ }
+
+ return nil
+}
+
+// handleEvent reacts to internal events before they are forwarded to the
+// application. It negotiates Unicode core mode (DEC mode 2027): when the
+// terminal reports the mode is in a settable or active state, it enables
+// grapheme-cluster width so wide-glyph measurement matches the terminal. The
+// event is still forwarded to the application.
+//
+// The mode is only enabled for settable/active states (mode set, reset but
+// settable, or permanently set). It is explicitly not enabled when the mode is
+// not recognized or permanently reset, since those terminals cannot honor it.
+// Enabling goes through the screen's locked write path so it cannot race with
+// the application's Render/Flush.
+func (t *Terminal) handleEvent(ev Event) {
+ if mr, ok := ev.(ModeReportEvent); ok {
+ if mr.Mode == ansi.ModeUnicodeCore &&
+ (mr.Value.IsSet() || mr.Value == ansi.ModeReset) {
+ t.scr.enableGraphemeWidth()
+ }
+ }
+}
+
+// Wait waits for the terminal event loop to exit and returns any error that
+// occurred.
+func (t *Terminal) Wait() error {
+ if err := t.errg.Wait(); err != nil {
+ return fmt.Errorf("terminal event loop error: %w", err)
+ }
+ return nil
+}
+
+// Stop stops the terminal event loop. It is safe to call Stop without a
+// prior [Terminal.Start], and safe to call Stop multiple times in a row.
+// After Stop returns, [Terminal.Start] may be called again to resume.
+func (t *Terminal) Stop() error {
+ if t.donec != nil {
+ select {
+ case <-t.donec:
+ // Already closed.
+ default:
+ close(t.donec)
+ }
+ }
+ if t.winch != nil {
+ signal.Stop(t.winch)
+ }
+ if t.pr != nil {
+ t.pr.Cancel()
+ _ = t.pr.Close()
+ t.pr = nil
+ }
+ t.scr.Reset()
+ if err := t.scr.Flush(); err != nil {
+ _ = t.con.Restore()
+ return fmt.Errorf("failed to flush terminal screen: %w", err)
+ }
+ if err := t.con.Restore(); err != nil {
+ return fmt.Errorf("failed to restore terminal state: %w", err)
+ }
+ return nil
+}
+
+// SendEvent sends an event to the terminal's event channel.
+//
+// This can be used to inject custom events into the terminal's event loop,
+// such as timer events, signals, or application-specific events.
+func (t *Terminal) SendEvent(e Event) {
+ select {
+ case t.evc <- e:
+ case <-t.donec:
+ }
+}
+
+// Write writes data directly to the terminal's console output.
+//
+// This is a low-level operation that bypasses the terminal screen buffering
+// and writes directly to the console output handler, usually [os.Stdout] or
+// the controlling TTY.
+func (t *Terminal) Write(p []byte) (n int, err error) {
+ return t.con.Write(p)
+}
+
+// Read reads data from the terminal's console input.
+//
+// This is a low-level operation that bypasses the terminal event processing
+// and reads directly from the console input handler, usually [os.Stdin] or the
+// controlling TTY. Use this method with caution, as it may interfere with the
+// terminal's event loop and screen management.
+func (t *Terminal) Read(p []byte) (n int, err error) {
+ return t.con.Read(p)
+}
diff --git a/vendor/github.com/charmbracelet/ultraviolet/terminal_bsdly.go b/vendor/github.com/charmbracelet/ultraviolet/terminal_bsdly.go
new file mode 100644
index 0000000000..6f64e65668
--- /dev/null
+++ b/vendor/github.com/charmbracelet/ultraviolet/terminal_bsdly.go
@@ -0,0 +1,10 @@
+//go:build darwin || linux || aix
+// +build darwin linux aix
+
+package uv
+
+import "golang.org/x/sys/unix"
+
+func supportsBackspace(lflag uint64) bool {
+ return lflag&unix.BSDLY == unix.BS0
+}
diff --git a/vendor/github.com/charmbracelet/ultraviolet/terminal_bsdly_other.go b/vendor/github.com/charmbracelet/ultraviolet/terminal_bsdly_other.go
new file mode 100644
index 0000000000..24bb50d766
--- /dev/null
+++ b/vendor/github.com/charmbracelet/ultraviolet/terminal_bsdly_other.go
@@ -0,0 +1,8 @@
+//go:build !darwin && !linux && !aix && !windows
+// +build !darwin,!linux,!aix,!windows
+
+package uv
+
+func supportsBackspace(uint64) bool {
+ return false
+}
diff --git a/vendor/github.com/charmbracelet/ultraviolet/terminal_other.go b/vendor/github.com/charmbracelet/ultraviolet/terminal_other.go
new file mode 100644
index 0000000000..9130fcc4c1
--- /dev/null
+++ b/vendor/github.com/charmbracelet/ultraviolet/terminal_other.go
@@ -0,0 +1,22 @@
+//go:build !darwin && !dragonfly && !freebsd && !linux && !netbsd && !openbsd && !solaris && !aix && !windows
+// +build !darwin,!dragonfly,!freebsd,!linux,!netbsd,!openbsd,!solaris,!aix,!windows
+
+package uv
+
+import "github.com/charmbracelet/x/term"
+
+func makeRaw(_, _ term.File) (inTtyState, outTtyState *term.State, err error) {
+ return nil, nil, ErrPlatformNotSupported
+}
+
+func getSize(_, _ term.File) (w, h int, err error) {
+ return 0, 0, ErrPlatformNotSupported
+}
+
+func getWinsize(_, _ term.File) (ws Winsize, err error) {
+ return Winsize{}, ErrPlatformNotSupported
+}
+
+func optimizeMovements(*term.State) (useTabs, useBspace bool) {
+ return false, false
+}
diff --git a/vendor/github.com/charmbracelet/ultraviolet/terminal_reader.go b/vendor/github.com/charmbracelet/ultraviolet/terminal_reader.go
new file mode 100644
index 0000000000..b3b79cd008
--- /dev/null
+++ b/vendor/github.com/charmbracelet/ultraviolet/terminal_reader.go
@@ -0,0 +1,503 @@
+package uv
+
+import (
+ "bytes"
+ "context"
+ "errors"
+ "fmt"
+ "io"
+ "strconv"
+ "strings"
+ "sync"
+ "time"
+ "unicode"
+ "unicode/utf16"
+ "unicode/utf8"
+
+ "github.com/charmbracelet/x/ansi"
+ "github.com/muesli/cancelreader"
+ "github.com/rivo/uniseg"
+)
+
+// ErrReaderNotStarted is returned when the reader has not been started yet.
+var ErrReaderNotStarted = fmt.Errorf("reader not started")
+
+// DefaultEscTimeout is the default timeout at which the [TerminalReader] will
+// process ESC sequences. It is set to 50 milliseconds.
+const DefaultEscTimeout = 50 * time.Millisecond
+
+// TerminalReader represents an input event loop that reads input events from
+// a reader and parses them into human-readable events. It supports
+// reading escape sequences, mouse events, and bracketed paste mode.
+type TerminalReader struct {
+ EventDecoder
+
+ // MouseMode determines whether mouse events are enabled or not. This is a
+ // platform-specific feature and is only available on Windows. When this is
+ // true, the reader will be initialized to read mouse events using the
+ // Windows Console API.
+ MouseMode *MouseMode
+
+ // EscTimeout is the escape character timeout duration. Most escape
+ // sequences start with an escape character [ansi.ESC] and are followed by
+ // one or more characters. If the next character is not received within
+ // this timeout, the reader will assume that the escape sequence is
+ // complete and will process the received characters as a complete escape
+ // sequence.
+ //
+ // By default, this is set to [DefaultEscTimeout] (50 milliseconds).
+ EscTimeout time.Duration
+
+ r io.Reader
+ table map[string]Key // table is a lookup table for key sequences.
+
+ term string // term is the terminal name $TERM.
+
+ // paste is the bracketed paste mode buffer.
+ // When nil, bracketed paste mode is disabled.
+ paste []byte
+
+ lookup bool // lookup indicates whether to use the lookup table for key sequences.
+
+ // vtInput indicates whether we're using Windows Console API VT input mode.
+ //nolint:unused,nolintlint
+ vtInput bool
+
+ eventScanner *eventScanner
+
+ // We use these buffers to decode UTF-16 sequences and graphemes from the
+ // Windows Console API and Win32-Input-Mode events.
+ utf16Half [2]bool // 0 key up, 1 key down
+ utf16Buf [2][2]rune // 0 key up, 1 key down
+ graphemeBuf [2][]rune // 0 key up, 1 key down
+ //nolint:unused,nolintlint
+ lastMouseBtns uint32 // the last mouse button state for the previous event
+ //nolint:unused,nolintlint
+ lastWinsizeX, lastWinsizeY int16 // the last window size for the previous event to prevent multiple size events from firing
+
+ logger Logger // The logger to use for debugging.
+}
+
+// NewTerminalReader returns a new input event reader. The reader streams input
+// events from the terminal and parses escape sequences into human-readable
+// events. It supports reading Terminfo databases.
+//
+// Use [TerminalReader.UseTerminfo] to use Terminfo defined key sequences.
+// Use [TerminalReader.Legacy] to control legacy key encoding behavior.
+//
+// Example:
+//
+// ```go
+// var cr cancelreader.CancelReader
+// var evc chan Event
+// sc := NewTerminalReader(cr, os.Getenv("TERM"))
+// go sc.StreamEvents(ctx, evc)
+// ```
+func NewTerminalReader(r io.Reader, termType string) *TerminalReader {
+ d := &TerminalReader{
+ EscTimeout: DefaultEscTimeout,
+ r: r,
+ term: termType,
+ lookup: true, // Use lookup table by default.
+ }
+ d.r = r
+ if d.table == nil {
+ d.table = buildKeysTable(d.Legacy, d.term, d.UseTerminfo)
+ }
+ evs := newEventScanner()
+ evs.EventDecoder = d.EventDecoder
+ evs.table = d.table
+ evs.lookup = d.lookup
+ evs.setLogger(d.logger)
+ d.eventScanner = evs
+ return d
+}
+
+// readBufSize is the size of the read buffer used to read input events at a time.
+const readBufSize = 4096
+
+// sendBytes reads data from the reader and sends it to the provided channel.
+// It stops when an error occurs or when the context is closed.
+func (d *TerminalReader) sendBytes(ctx context.Context, readc chan []byte) error {
+ for {
+ var readBuf [readBufSize]byte
+ n, err := d.r.Read(readBuf[:])
+ if err != nil {
+ return err //nolint:wrapcheck
+ }
+
+ select {
+ case <-ctx.Done():
+ return nil
+ case readc <- readBuf[:n]:
+ }
+ }
+}
+
+// StreamEvents sends events to the provided channel. It stops when the context
+// is closed or when an error occurs.
+func (d *TerminalReader) StreamEvents(ctx context.Context, eventc chan<- Event) error {
+ var buf bytes.Buffer
+ errc := make(chan error, 1)
+ readc := make(chan []byte)
+ timeout := time.NewTimer(d.EscTimeout)
+ ttimeout := time.Now().Add(d.EscTimeout)
+
+ var wg sync.WaitGroup
+ wg.Add(1)
+
+ go func() {
+ defer wg.Done()
+ if err := d.streamData(ctx, readc); err != nil {
+ if errors.Is(err, io.EOF) || errors.Is(err, cancelreader.ErrCanceled) {
+ errc <- nil
+ return
+ }
+ errc <- err
+ return
+ }
+ }()
+
+ for {
+ select {
+ case <-ctx.Done():
+ d.sendEvents(eventc, buf.Bytes(), true)
+ wg.Wait()
+ return nil
+ case err := <-errc:
+ d.sendEvents(eventc, buf.Bytes(), true)
+ wg.Wait()
+ return err // return the first error encountered
+ case <-timeout.C:
+ d.logf("timeout reached")
+
+ // Timeout reached process the buffer including any incomplete sequences.
+ var n int // n is the number of bytes processed
+ timedout := time.Now().After(ttimeout)
+ if buf.Len() > 0 && timedout {
+ d.logf("timeout expired, processing buffer")
+ n = d.sendEvents(eventc, buf.Bytes(), true)
+ }
+
+ if n > 0 {
+ buf.Next(n)
+ }
+
+ if buf.Len() > 0 {
+ if !timeout.Stop() {
+ // drain the channel if it was already running
+ select {
+ case <-timeout.C:
+ default:
+ }
+ }
+
+ d.logf("resetting timeout for remaining buffer")
+ timeout.Reset(d.EscTimeout)
+ }
+
+ case read := <-readc:
+ d.logf("input: %q", read)
+ buf.Write(read)
+ ttimeout = time.Now().Add(d.EscTimeout)
+ n := d.sendEvents(eventc, buf.Bytes(), false)
+ if !timeout.Stop() {
+ // drain the channel if it was already running
+ select {
+ case <-timeout.C:
+ default:
+ }
+ }
+
+ if n > 0 {
+ d.logf("processed %d bytes from buffer", n)
+ buf.Next(n)
+ }
+
+ if buf.Len() > 0 {
+ d.logf("resetting timeout for remaining buffer after parse")
+ timeout.Reset(d.EscTimeout)
+ }
+ }
+ }
+}
+
+// SetLogger sets the logger to use for debugging. If nil, no logging will be
+// performed.
+func (d *TerminalReader) SetLogger(logger Logger) {
+ d.logger = logger
+}
+
+func (d *TerminalReader) sendEvents(eventc chan<- Event, buf []byte, expired bool) int {
+ n, events := d.eventScanner.scanEvents(buf, expired)
+ for _, event := range events {
+ eventc <- event
+ }
+ return n
+}
+
+// eventScanner scans the buffer for events and sends them to the event channel.
+type eventScanner struct {
+ EventDecoder
+
+ utf16Half [2]bool // 0 key up, 1 key down
+ utf16Buf [2][2]rune // 0 key up, 1 key down
+ graphemeBuf [2][]rune // 0 key up, 1 key down
+ paste []byte
+ table map[string]Key
+ lookup bool
+ logger Logger
+}
+
+// newEventScanner creates a new event scanner.
+func newEventScanner() *eventScanner {
+ return &eventScanner{}
+}
+
+// setLogger sets the logger to use for debugging. If nil, no logging will be
+// performed.
+func (d *eventScanner) setLogger(logger Logger) {
+ d.logger = logger
+}
+
+func (d *eventScanner) logf(format string, v ...interface{}) {
+ logf(d.logger, format, v...)
+}
+
+func (d *eventScanner) scanEvents(buf []byte, expired bool) (total int, events []Event) {
+ if len(buf) == 0 {
+ return 0, nil
+ }
+
+ var dn int
+ d.logf("processing buf %d %q", len(buf), buf)
+ dn, buf = d.deserializeWin32Input(buf)
+ total += dn
+
+ // Lookup table first
+ if d.lookup && len(buf) > 2 && buf[0] == ansi.ESC {
+ if k, ok := d.table[string(buf)]; ok {
+ return len(buf), []Event{KeyPressEvent(k)}
+ }
+ }
+
+ // total is the total number of bytes processed
+ for len(buf) > 0 {
+ esc := buf[0] == ansi.ESC
+ n, event := d.Decode(buf)
+
+ // Handle bracketed-paste
+ if d.paste != nil { //nolint:nestif
+ if _, ok := event.(PasteEndEvent); !ok {
+ switch event := event.(type) {
+ case KeyPressEvent:
+ if len(event.Text) > 0 {
+ d.paste = append(d.paste, event.Text...)
+ } else {
+ seq := string(buf[:n])
+ isWin32 := strings.HasPrefix(seq, "\x1b[") && strings.HasSuffix(seq, "_")
+ switch {
+ case isWin32 && event.Code == KeyEnter && event.Code == event.BaseCode:
+ // This handles special cases where
+ // win32-input-mode encodes newlines and other keys
+ // as keypress events. We need to encode them as
+ // their respective values.
+ d.paste = append(d.paste, '\n')
+ case isWin32 && unicode.IsControl(event.Code) && event.Code == event.BaseCode:
+ // This handles other cases such as tabs, escapes, etc.
+ d.paste = append(d.paste, string(event.Code)...)
+ case !isWin32:
+ // We ignore all other non-text win32-input-mode events.
+ if esc && n <= 2 && !expired {
+ // If the event is an escape sequence and we
+ // are not expired, we need to wait for more
+ // input.
+ return total, events
+ }
+ d.paste = append(d.paste, seq...)
+ }
+ }
+ case UnknownEvent:
+ if !expired {
+ // If the event is unknown and we are not expired, we
+ // return need to try to decode the buffer again.
+ return total, events
+ }
+ default:
+ // Everything else is ignored...
+ }
+ buf = buf[n:]
+ total += n
+ continue
+ }
+ }
+
+ var isUnknown bool
+ switch event.(type) {
+ case ignoredEvent:
+ // ignore this event
+ event = nil
+ case UnknownEvent:
+ isUnknown = true
+ // Try to look up the event in the table.
+ if !expired {
+ return total, events
+ }
+
+ if k, ok := d.table[string(buf[:n])]; ok {
+ events = append(events, KeyPressEvent(k))
+ return total + n, events
+ }
+
+ events = append(events, event)
+ case PasteStartEvent:
+ d.paste = []byte{} // reset the paste buffer
+ case PasteEndEvent:
+ var paste []rune
+ for len(d.paste) > 0 {
+ r, w := utf8.DecodeRune(d.paste)
+ if r != utf8.RuneError {
+ paste = append(paste, r)
+ }
+ d.paste = d.paste[w:]
+ }
+ d.paste = nil // reset the paste buffer
+ events = append(events, PasteEvent{string(paste)})
+ }
+
+ if !isUnknown && event != nil {
+ if esc && n <= 2 && !expired {
+ // Wait for more input
+ return total, events
+ }
+
+ if m, ok := event.(MultiEvent); ok {
+ // If the event is a MultiEvent, append all events to the queue.
+ events = append(events, m...)
+ } else {
+ // Otherwise, just append the event to the queue.
+ events = append(events, event)
+ }
+ }
+
+ buf = buf[n:]
+ total += n
+ }
+
+ return total, events
+}
+
+func (d *eventScanner) encodeGraphemeBufs() []byte {
+ var b []byte
+ for kd := range d.graphemeBuf {
+ if len(d.graphemeBuf[kd]) > 0 {
+ switch kd {
+ case 1:
+ b = append(b, string(d.graphemeBuf[kd])...)
+ case 0:
+ // Encode the release grapheme as Kitty Keyboard to get the release event.
+ grs := uniseg.NewGraphemes(string(d.graphemeBuf[kd]))
+ for grs.Next() {
+ var codepoints string
+ gr := grs.Str()
+ for i, r := range gr {
+ if r == 0 {
+ continue
+ }
+ if i > 0 {
+ codepoints += ":"
+ }
+ codepoints += strconv.FormatInt(int64(r), 10)
+ }
+ // This is dark :)
+ // During serializing/deserializing of win32 input events, the
+ // API will split a grapheme into runes and send them as a
+ // keydown/keyup sequences. We collect the runes, decoded them
+ // from UTF-16 just fine. However, [EventDecoder.Decode] will
+ // always decode graphemes as [KeyPressEvent]s. Thus, to
+ // workaround that and the existing API, while we are
+ // intercepting win32 input events, we encode the grapheme
+ // release events as Kitty Keyboard sequences so that
+ // [EventDecoder.Decode] can properly decode them as
+ // [KeyReleaseEvent]s.
+ seq := fmt.Sprintf("\x1b[%d;1:3;%su", d.graphemeBuf[kd][0], codepoints)
+ b = append(b, seq...)
+ }
+ }
+ d.graphemeBuf[kd] = d.graphemeBuf[kd][:0] // reset the buffer
+ }
+ }
+ return b
+}
+
+func (d *eventScanner) storeGraphemeRune(kd int, r rune) {
+ if d.utf16Half[kd] {
+ // We have a half pair that needs to be decoded.
+ d.utf16Half[kd] = false
+ d.utf16Buf[kd][1] = r
+ r := utf16.DecodeRune(d.utf16Buf[kd][0], d.utf16Buf[kd][1])
+ d.graphemeBuf[kd] = append(d.graphemeBuf[kd], r)
+ } else if utf16.IsSurrogate(r) {
+ // This is the first half of a UTF-16 surrogate pair.
+ d.utf16Half[kd] = true
+ d.utf16Buf[kd][0] = r
+ } else {
+ // This should be a single UTF-16 that can be converted
+ // to UTF-8.
+ d.graphemeBuf[kd] = append(d.graphemeBuf[kd], r)
+ }
+}
+
+// deserializeWin32Input deserializes the Win32 input events converting
+// KeyEventRecrods to bytes. Before returning the bytes, it will also try to
+// decode any UTF-16 pairs that might be present in the input buffer.
+func (d *eventScanner) deserializeWin32Input(buf []byte) (int, []byte) {
+ p := ansi.GetParser()
+ defer ansi.PutParser(p)
+
+ var processed int
+ var state byte
+ des := make([]byte, 0, len(buf))
+
+ for len(buf) > 0 {
+ seq, width, n, newState := ansi.DecodeSequence(buf, state, p)
+ switch width {
+ case 0:
+ if p.Command() == '_' { // Win32 Input Mode
+ vk, _ := p.Param(0, 0)
+ if vk == 0 {
+ // This is either a serialized KeyEventRecord or a UTF-16
+ // pair.
+ uc, _ := p.Param(2, 0)
+ kd, _ := p.Param(3, 0)
+ kd = clamp(kd, 0, 1) // kd is the key down state (0 or 1)
+ d.storeGraphemeRune(kd, rune(uc))
+ processed += n
+ break
+ }
+ }
+ fallthrough
+ default:
+ des = append(des, d.encodeGraphemeBufs()...)
+ des = append(des, seq...)
+ }
+
+ state = newState
+ buf = buf[n:]
+ }
+
+ des = append(des, d.encodeGraphemeBufs()...)
+
+ return processed, des
+}
+
+func (d *TerminalReader) logf(format string, v ...interface{}) {
+ logf(d.logger, format, v...)
+}
+
+func logf(logger Logger, format string, v ...interface{}) {
+ if logger == nil {
+ return
+ }
+ logger.Printf(format, v...)
+}
diff --git a/vendor/github.com/charmbracelet/ultraviolet/terminal_reader_other.go b/vendor/github.com/charmbracelet/ultraviolet/terminal_reader_other.go
new file mode 100644
index 0000000000..ca2e9e7249
--- /dev/null
+++ b/vendor/github.com/charmbracelet/ultraviolet/terminal_reader_other.go
@@ -0,0 +1,13 @@
+//go:build !windows
+// +build !windows
+
+package uv
+
+import (
+ "context"
+)
+
+// streamData sends data from the input stream to the event channel.
+func (d *TerminalReader) streamData(ctx context.Context, readc chan []byte) error {
+ return d.sendBytes(ctx, readc)
+}
diff --git a/vendor/github.com/charmbracelet/ultraviolet/terminal_reader_windows.go b/vendor/github.com/charmbracelet/ultraviolet/terminal_reader_windows.go
new file mode 100644
index 0000000000..8a526b9567
--- /dev/null
+++ b/vendor/github.com/charmbracelet/ultraviolet/terminal_reader_windows.go
@@ -0,0 +1,336 @@
+//go:build windows
+// +build windows
+
+package uv
+
+import (
+ "bytes"
+ "context"
+ "fmt"
+ "strings"
+ "time"
+ "unicode/utf16"
+
+ "github.com/charmbracelet/x/ansi"
+ xwindows "github.com/charmbracelet/x/windows"
+ "github.com/muesli/cancelreader"
+ "golang.org/x/sys/windows"
+)
+
+// streamData sends data from the input stream to the event channel.
+func (d *TerminalReader) streamData(ctx context.Context, readc chan []byte) error {
+ cc, ok := d.r.(*conInputReader)
+ if !ok {
+ d.logf("streamData: reader is not a conInputReader, falling back to default implementation")
+ return d.sendBytes(ctx, readc)
+ }
+
+ // Store the value of VT Input Mode for later use.
+ d.vtInput = cc.newMode&windows.ENABLE_VIRTUAL_TERMINAL_INPUT != 0
+
+ var buf bytes.Buffer
+ var records []xwindows.InputRecord
+ var err error
+ for {
+ for {
+ records, err = peekNConsoleInputs(cc.conin, readBufSize)
+ if cc.isCanceled() {
+ return cancelreader.ErrCanceled
+ }
+ if err != nil {
+ return err
+ }
+ if len(records) > 0 {
+ break
+ }
+
+ // Sleep for a bit to avoid busy waiting.
+ time.Sleep(10 * time.Millisecond)
+ }
+
+ records, err = readNConsoleInputs(cc.conin, uint32(len(records))) //nolint:gosec
+ if cc.isCanceled() {
+ return cancelreader.ErrCanceled
+ }
+ if err != nil {
+ return err
+ }
+
+ // We convert Windows Input Records to VT input sequences for easier
+ // processing especially when dealing with UTF-16 decoding and
+ // Win32-Input-Mode processing.
+ d.serializeWin32InputRecords(records, &buf)
+
+ select {
+ case <-ctx.Done():
+ return nil
+ case readc <- buf.Bytes():
+ }
+
+ buf.Reset()
+ }
+}
+
+// serializeWin32InputRecords serializes the Win32 input events converting them
+// to valid VT input sequences. It will also encode any UTF-16 pairs that might
+// be present in the input buffer. The resulting byte slice can be sent to the
+// terminal as input.
+func (d *TerminalReader) serializeWin32InputRecords(records []xwindows.InputRecord, buf *bytes.Buffer) {
+ for _, record := range records {
+ switch record.EventType {
+ case xwindows.KEY_EVENT:
+ kevent := record.KeyEvent()
+ // d.logf("key event: %s", keyEventString(kevent.VirtualKeyCode, kevent.VirtualScanCode, kevent.Char, kevent.KeyDown, kevent.ControlKeyState, kevent.RepeatCount))
+
+ var kd int
+ if kevent.KeyDown {
+ kd = 1
+ }
+ if d.vtInput { //nolint:nestif
+ // In VT Input Mode, we only capture the Unicode characters
+ // decoding them along the way.
+ // This is similar to [TerminalReader.storeGraphemeRune] except
+ // that we need to write the events directly to the buffer.
+ if d.utf16Half[kd] {
+ // We have a half pair that needs to be decoded.
+ d.utf16Half[kd] = false
+ d.utf16Buf[kd][1] = kevent.Char
+ r := utf16.DecodeRune(d.utf16Buf[kd][0], d.utf16Buf[kd][1])
+ buf.WriteRune(r)
+ } else if utf16.IsSurrogate(kevent.Char) {
+ // This is the first half of a UTF-16 surrogate pair.
+ d.utf16Half[kd] = true
+ d.utf16Buf[kd][0] = kevent.Char
+ } else if kevent.KeyDown {
+ // Just a regular key press character encoded in VT.
+ buf.WriteRune(kevent.Char)
+ }
+ } else {
+ // We encode the key to Win32 Input Mode if it is a known key.
+ if kevent.VirtualKeyCode == 0 {
+ d.eventScanner.storeGraphemeRune(kd, kevent.Char)
+ } else {
+ buf.Write(d.eventScanner.encodeGraphemeBufs())
+ fmt.Fprintf(buf,
+ "\x1b[%d;%d;%d;%d;%d;%d_",
+ kevent.VirtualKeyCode,
+ kevent.VirtualScanCode,
+ kevent.Char,
+ kd,
+ kevent.ControlKeyState,
+ kevent.RepeatCount)
+ }
+ }
+
+ case xwindows.MOUSE_EVENT:
+ if d.MouseMode == nil || *d.MouseMode == 0 {
+ continue
+ }
+ mouseMode := *d.MouseMode
+ mevent := record.MouseEvent()
+
+ var isRelease bool
+ var isMotion bool
+ var button MouseButton
+ alt := mevent.ControlKeyState&(xwindows.LEFT_ALT_PRESSED|xwindows.RIGHT_ALT_PRESSED) != 0
+ ctrl := mevent.ControlKeyState&(xwindows.LEFT_CTRL_PRESSED|xwindows.RIGHT_CTRL_PRESSED) != 0
+ shift := mevent.ControlKeyState&(xwindows.SHIFT_PRESSED) != 0
+ wheelDirection := int16(highWord(mevent.ButtonState)) //nolint:gosec
+ switch mevent.EventFlags {
+ case 0, xwindows.DOUBLE_CLICK:
+ button, isRelease = mouseEventButton(d.lastMouseBtns, mevent.ButtonState)
+ case xwindows.MOUSE_WHEELED:
+ if wheelDirection > 0 {
+ button = MouseWheelUp
+ } else {
+ button = MouseWheelDown
+ }
+ case xwindows.MOUSE_HWHEELED:
+ if wheelDirection > 0 {
+ button = MouseWheelRight
+ } else {
+ button = MouseWheelLeft
+ }
+ case xwindows.MOUSE_MOVED:
+ button, _ = mouseEventButton(d.lastMouseBtns, mevent.ButtonState)
+ isMotion = true
+ }
+
+ // We emulate mouse mode levels on Windows. This is because Windows
+ // doesn't have a concept of different mouse modes. We use the mouse mode to determine
+ if button == MouseNone && mouseMode&MouseModeMotion == 0 ||
+ (button != MouseNone && mouseMode&MouseModeDrag == 0) {
+ continue
+ }
+
+ // Encode mouse events as SGR mouse sequences that can be read by [EventDecoder].
+ buf.WriteString(ansi.MouseSgr(
+ ansi.EncodeMouseButton(button, isMotion, shift, alt, ctrl),
+ int(mevent.MousePositon.X), int(mevent.MousePositon.Y), isRelease,
+ ))
+
+ d.lastMouseBtns = mevent.ButtonState
+
+ case xwindows.WINDOW_BUFFER_SIZE_EVENT:
+ wevent := record.WindowBufferSizeEvent()
+ if wevent.Size.X != d.lastWinsizeX || wevent.Size.Y != d.lastWinsizeY {
+ d.lastWinsizeX, d.lastWinsizeY = wevent.Size.X, wevent.Size.Y
+ // We encode window resize events as CSI 4 ; height ; width t
+ // sequence which the [EventDecoder] understands.
+ buf.WriteString(
+ ansi.WindowOp(
+ 8, // Terminal window size in cells
+ int(wevent.Size.Y), // height
+ int(wevent.Size.X), // width
+ ),
+ )
+ }
+
+ case xwindows.FOCUS_EVENT:
+ fevent := record.FocusEvent()
+ if fevent.SetFocus {
+ buf.WriteString(ansi.Focus)
+ } else {
+ buf.WriteString(ansi.Blur)
+ }
+
+ case xwindows.MENU_EVENT:
+ // ignore
+ }
+ }
+
+ // Flush any remaining grapheme buffers.
+ buf.Write(d.eventScanner.encodeGraphemeBufs())
+}
+
+func mouseEventButton(p, s uint32) (MouseButton, bool) {
+ var isRelease bool
+ button := MouseNone
+ btn := p ^ s
+ if btn&s == 0 {
+ isRelease = true
+ }
+
+ if btn == 0 {
+ switch {
+ case s&xwindows.FROM_LEFT_1ST_BUTTON_PRESSED > 0:
+ button = MouseLeft
+ case s&xwindows.FROM_LEFT_2ND_BUTTON_PRESSED > 0:
+ button = MouseMiddle
+ case s&xwindows.RIGHTMOST_BUTTON_PRESSED > 0:
+ button = MouseRight
+ case s&xwindows.FROM_LEFT_3RD_BUTTON_PRESSED > 0:
+ button = MouseBackward
+ case s&xwindows.FROM_LEFT_4TH_BUTTON_PRESSED > 0:
+ button = MouseForward
+ }
+ return button, isRelease
+ }
+
+ switch btn {
+ case xwindows.FROM_LEFT_1ST_BUTTON_PRESSED: // left button
+ button = MouseLeft
+ case xwindows.RIGHTMOST_BUTTON_PRESSED: // right button
+ button = MouseRight
+ case xwindows.FROM_LEFT_2ND_BUTTON_PRESSED: // middle button
+ button = MouseMiddle
+ case xwindows.FROM_LEFT_3RD_BUTTON_PRESSED: // unknown (possibly mouse backward)
+ button = MouseBackward
+ case xwindows.FROM_LEFT_4TH_BUTTON_PRESSED: // unknown (possibly mouse forward)
+ button = MouseForward
+ }
+
+ return button, isRelease
+}
+
+func highWord(data uint32) uint16 {
+ return uint16((data & 0xFFFF0000) >> 16) //nolint:gosec
+}
+
+func readNConsoleInputs(console windows.Handle, maxEvents uint32) ([]xwindows.InputRecord, error) {
+ if maxEvents == 0 {
+ return nil, fmt.Errorf("maxEvents cannot be zero")
+ }
+
+ records := make([]xwindows.InputRecord, maxEvents)
+ n, err := readConsoleInput(console, records)
+ return records[:n], err
+}
+
+func readConsoleInput(console windows.Handle, inputRecords []xwindows.InputRecord) (uint32, error) {
+ if len(inputRecords) == 0 {
+ return 0, fmt.Errorf("size of input record buffer cannot be zero")
+ }
+
+ var read uint32
+
+ err := xwindows.ReadConsoleInput(console, &inputRecords[0], uint32(len(inputRecords)), &read) //nolint:gosec
+
+ return read, err //nolint:wrapcheck
+}
+
+func peekConsoleInput(console windows.Handle, inputRecords []xwindows.InputRecord) (uint32, error) {
+ if len(inputRecords) == 0 {
+ return 0, fmt.Errorf("size of input record buffer cannot be zero")
+ }
+
+ var read uint32
+
+ err := xwindows.PeekConsoleInput(console, &inputRecords[0], uint32(len(inputRecords)), &read) //nolint:gosec
+
+ return read, err //nolint:wrapcheck
+}
+
+func peekNConsoleInputs(console windows.Handle, maxEvents uint32) ([]xwindows.InputRecord, error) {
+ if maxEvents == 0 {
+ return nil, fmt.Errorf("maxEvents cannot be zero")
+ }
+
+ records := make([]xwindows.InputRecord, maxEvents)
+ n, err := peekConsoleInput(console, records)
+ return records[:n], err
+}
+
+//nolint:unused
+func keyEventString(vkc, sc uint16, r rune, keyDown bool, cks uint32, repeatCount uint16) string {
+ var s strings.Builder
+ s.WriteString("vkc: ")
+ fmt.Fprintf(&s, "%d, 0x%02x", vkc, vkc)
+ s.WriteString(", sc: ")
+ fmt.Fprintf(&s, "%d, 0x%02x", sc, sc)
+ s.WriteString(", r: ")
+ fmt.Fprintf(&s, "%q 0x%x", r, r)
+ s.WriteString(", down: ")
+ fmt.Fprintf(&s, "%v", keyDown)
+ s.WriteString(", cks: [")
+ if cks&xwindows.LEFT_ALT_PRESSED != 0 {
+ s.WriteString("left alt, ")
+ }
+ if cks&xwindows.RIGHT_ALT_PRESSED != 0 {
+ s.WriteString("right alt, ")
+ }
+ if cks&xwindows.LEFT_CTRL_PRESSED != 0 {
+ s.WriteString("left ctrl, ")
+ }
+ if cks&xwindows.RIGHT_CTRL_PRESSED != 0 {
+ s.WriteString("right ctrl, ")
+ }
+ if cks&xwindows.SHIFT_PRESSED != 0 {
+ s.WriteString("shift, ")
+ }
+ if cks&xwindows.CAPSLOCK_ON != 0 {
+ s.WriteString("caps lock, ")
+ }
+ if cks&xwindows.NUMLOCK_ON != 0 {
+ s.WriteString("num lock, ")
+ }
+ if cks&xwindows.SCROLLLOCK_ON != 0 {
+ s.WriteString("scroll lock, ")
+ }
+ if cks&xwindows.ENHANCED_KEY != 0 {
+ s.WriteString("enhanced key, ")
+ }
+ s.WriteString("], repeat count: ")
+ fmt.Fprintf(&s, "%d", repeatCount)
+ return s.String()
+}
diff --git a/vendor/github.com/charmbracelet/ultraviolet/terminal_renderer.go b/vendor/github.com/charmbracelet/ultraviolet/terminal_renderer.go
new file mode 100644
index 0000000000..41ba8eb624
--- /dev/null
+++ b/vendor/github.com/charmbracelet/ultraviolet/terminal_renderer.go
@@ -0,0 +1,1726 @@
+package uv
+
+import (
+ "bytes"
+ "errors"
+ "hash/maphash"
+ "io"
+ "strings"
+
+ "github.com/charmbracelet/colorprofile"
+ "github.com/charmbracelet/x/ansi"
+)
+
+// ErrInvalidDimensions is returned when the dimensions of a window are invalid
+// for the operation.
+var ErrInvalidDimensions = errors.New("invalid dimensions")
+
+// capabilities represents a mask of supported ANSI escape sequences.
+type capabilities uint
+
+const (
+ // Vertical Position Absolute [ansi.VPA].
+ capVPA capabilities = 1 << iota
+ // Horizontal Position Absolute [ansi.HPA].
+ capHPA
+ // Cursor Horizontal Absolute [ansi.CHA].
+ capCHA
+ // Cursor Horizontal Tab [ansi.CHT].
+ capCHT
+ // Cursor Backward Tab [ansi.CBT].
+ capCBT
+ // Repeat Previous Character [ansi.REP].
+ capREP
+ // Erase Character [ansi.ECH].
+ capECH
+ // Insert Character [ansi.ICH].
+ capICH
+ // Scroll Down [ansi.SD].
+ capSD
+ // Scroll Up [ansi.SU].
+ capSU
+ // These capabilities depend on the tty termios settings and are not
+ // enabled by default.
+ // Tabulation [ansi.HT].
+ capHT
+ // Backspace [ansi.BS].
+ capBS
+
+ noCaps capabilities = 0
+ allCaps = capVPA | capHPA | capCHA | capCHT | capCBT | capREP | capECH | capICH | capSD | capSU
+)
+
+// Set sets the given capabilities.
+func (v *capabilities) Set(c capabilities) {
+ *v |= c
+}
+
+// Reset resets the given capabilities.
+func (v *capabilities) Reset(c capabilities) {
+ *v &^= c
+}
+
+// Contains returns whether the capabilities contains the given capability.
+func (v capabilities) Contains(c capabilities) bool {
+ return v&c == c
+}
+
+// cursor represents a terminal cursor.
+type cursor struct {
+ Cell
+ Position
+}
+
+// LineData represents the metadata for a line.
+type LineData struct {
+ // First and last changed cell indices.
+ FirstCell, LastCell int
+ // Old index used for scrolling
+ oldIndex int //nolint:unused
+}
+
+// tFlag is a bitmask of terminal flags.
+type tFlag uint
+
+// Terminal writer flags.
+const (
+ tRelativeCursor tFlag = 1 << iota
+ tFullscreen
+ tMapNewline
+ tScrollOptim
+ // tGraphemeWidth indicates the terminal measures cell width using Unicode
+ // grapheme clustering (DEC mode 2027 / Unicode core).
+ tGraphemeWidth
+)
+
+// Set sets the given flags.
+func (v *tFlag) Set(c tFlag) {
+ *v |= c
+}
+
+// Reset resets the given flags.
+func (v *tFlag) Reset(c tFlag) {
+ *v &^= c
+}
+
+// Contains returns whether the terminal flags contains the given flags.
+func (v tFlag) Contains(c tFlag) bool {
+ return v&c == c
+}
+
+// TerminalRenderer is a terminal screen render and lazy writer that buffers
+// the output until it is flushed. It handles rendering a screen from a
+// [Buffer] to the terminal with the minimal necessary escape sequences to
+// transition the terminal to the new buffer state. It uses various escape
+// sequence optimizations to reduce the number of bytes sent to the terminal.
+// It's designed to be lazy and only flush the output when necessary by calling
+// the [TerminalRenderer.Flush] method.
+//
+// The renderer handles the terminal's alternate screen and cursor visibility
+// via the [TerminalRenderer.EnterAltScreen], [TerminalRenderer.ExitAltScreen],
+// [TerminalRenderer.ShowCursor] and [TerminalRenderer.HideCursor] methods.
+// Using these methods will queue the appropriate escape sequences to enter or
+// exit the alternate screen and show or hide the cursor respectively to be
+// flushed to the terminal.
+//
+// Use the [io.Writer] and [io.StringWriter] interfaces to queue custom
+// commands the renderer.
+//
+// The renderer is not thread-safe, the caller must protect the renderer when
+// using it from multiple goroutines.
+type TerminalRenderer struct {
+ w io.Writer
+ buf *bytes.Buffer // buffer for writing to the screen
+ curbuf *RenderBuffer // the current buffer
+ tabs *TabStops
+ hasher maphash.Hash
+ oldhash, newhash []uint64 // the old and new hash values for each line
+ hashtab []hashmap // the hashmap table
+ oldnum []int // old indices from previous hash
+ cur, saved cursor // the current and saved cursors
+ flags tFlag // terminal writer flags.
+ method ansi.Method // the width method used to measure cell width
+ term string // the terminal type
+ clear bool // whether to force clear the screen
+ caps capabilities // terminal control sequence capabilities
+ atPhantom bool // whether the cursor is out of bounds and at a phantom cell
+ lineHadWide bool // whether the line currently being transformed contained a wide cell
+ logger Logger // The logger used for debugging.
+
+ // profile is the color profile to use when downsampling colors. This is
+ // used to determine the appropriate color the terminal can display.
+ profile colorprofile.Profile
+}
+
+// NewTerminalRenderer returns a new [TerminalRenderer] that uses the given
+// writer, terminal type, and initializes the width of the terminal. The
+// terminal type is used to determine the capabilities of the terminal and
+// should be set to the value of the TERM environment variable.
+//
+// The renderer will try to detect the color profile from the output and the
+// given environment variables. Use [TerminalRenderer.SetColorProfile] method
+// to set a specific color profile for downsampling.
+//
+// See [TerminalRenderer] for more information on how to use the renderer.
+func NewTerminalRenderer(w io.Writer, env []string) (s *TerminalRenderer) {
+ s = new(TerminalRenderer)
+ s.w = w
+ s.profile = colorprofile.Detect(w, env)
+ s.buf = new(bytes.Buffer)
+ s.term = Environ(env).Getenv("TERM")
+ s.caps = xtermCaps(s.term)
+ s.cur = cursor{Cell: EmptyCell, Position: Pos(-1, -1)} // start at -1 to force a move
+ s.saved = s.cur
+ s.oldhash, s.newhash = nil, nil
+ return
+}
+
+// SetLogger sets the logger to use for debugging. If nil, no logging will be
+// performed.
+func (s *TerminalRenderer) SetLogger(logger Logger) {
+ s.logger = logger
+}
+
+// SetColorProfile sets the color profile to use for downsampling colors. This
+// is used to determine the appropriate color the terminal can display.
+func (s *TerminalRenderer) SetColorProfile(profile colorprofile.Profile) {
+ s.profile = profile
+}
+
+// SetScrollOptim sets whether to use hard scroll optimizations.
+func (s *TerminalRenderer) SetScrollOptim(v bool) {
+ if v {
+ s.flags.Set(tScrollOptim)
+ } else {
+ s.flags.Reset(tScrollOptim)
+ }
+}
+
+// SetMapNewline sets whether the terminal is currently mapping newlines to
+// CRLF or carriage return and line feed. This is used to correctly determine
+// how to move the cursor when writing to the screen.
+func (s *TerminalRenderer) SetMapNewline(v bool) {
+ if v {
+ s.flags.Set(tMapNewline)
+ } else {
+ s.flags.Reset(tMapNewline)
+ }
+}
+
+// SetWidthMethod sets the width method the renderer uses to measure the
+// display width of strings. This should match the width method configured on
+// the screen so that the renderer doesn't disagree with the cell widths it is
+// asked to draw.
+func (s *TerminalRenderer) SetWidthMethod(method ansi.Method) {
+ s.method = method
+}
+
+// SetGraphemeWidth sets whether the terminal measures cell width using Unicode
+// grapheme clustering (DEC mode 2027 / Unicode core). When enabled, the
+// renderer measures string width using [ansi.GraphemeWidth]; otherwise it
+// falls back to [ansi.WcWidth].
+func (s *TerminalRenderer) SetGraphemeWidth(v bool) {
+ if v {
+ s.flags.Set(tGraphemeWidth)
+ s.method = ansi.GraphemeWidth
+ } else {
+ s.flags.Reset(tGraphemeWidth)
+ s.method = ansi.WcWidth
+ }
+}
+
+// SetBackspace sets whether to use backspace as a movement optimization.
+func (s *TerminalRenderer) SetBackspace(v bool) {
+ if v {
+ s.caps.Set(capBS)
+ } else {
+ s.caps.Reset(capBS)
+ }
+}
+
+// SetTabStops sets the tab stops for the terminal and enables hard tabs
+// movement optimizations. Use -1 to disable hard tabs. This option is ignored
+// when the terminal type is "linux" as it does not support hard tabs.
+func (s *TerminalRenderer) SetTabStops(width int) {
+ if width < 0 || strings.HasPrefix(s.term, "linux") {
+ // Linux terminal does not support hard tabs.
+ s.caps.Reset(capHT)
+ } else {
+ s.caps.Set(capHT)
+ s.tabs = DefaultTabStops(width)
+ }
+}
+
+// SetFullscreen sets whether whole screen is being used. This is usually
+// paired with the alternate screen mode, and used to control cursor movements
+// and optimizations when the terminal is occupying the whole screen.
+func (s *TerminalRenderer) SetFullscreen(v bool) {
+ if v {
+ s.flags.Set(tFullscreen)
+ } else {
+ s.flags.Reset(tFullscreen)
+ }
+}
+
+// Fullscreen returns whether whole screen is being used. This is usually
+// paired with the alternate screen mode, and used to control cursor movements
+// and optimizations when the terminal is occupying the whole screen.
+func (s *TerminalRenderer) Fullscreen() bool {
+ return s.flags.Contains(tFullscreen)
+}
+
+// SetRelativeCursor sets whether to use relative cursor movements.
+func (s *TerminalRenderer) SetRelativeCursor(v bool) {
+ if v {
+ s.flags.Set(tRelativeCursor)
+ } else {
+ s.flags.Reset(tRelativeCursor)
+ }
+}
+
+// SaveCursor saves the current cursor position and styles. This can be used
+// when a program enters the alternate screen buffer mode using DECSET 1049
+// [ansi.ModeAltScreenSaveCursor] and wants to restore the cursor position and
+// styles later.
+func (s *TerminalRenderer) SaveCursor() {
+ s.saved = s.cur
+}
+
+// RestoreCursor restores the saved cursor position and styles. This can be
+// used when a program exits the alternate screen buffer mode using DECRST 1049
+// [ansi.ModeAltScreenSaveCursor] and wants to restore the cursor position and
+// styles saved earlier.
+func (s *TerminalRenderer) RestoreCursor() {
+ s.cur = s.saved
+}
+
+// EnterAltScreen is a helper that queues the [ansi.ModeAltScreenSaveCursor]
+// escape sequence to enter the alternate screen buffer and save cursor mode.
+//
+// It saves the current cursor properties, enables
+// [TerminalRenderer.SetFullscreen] flag, and disables
+// [TerminalRenderer.SetRelativeCursor] flag. On the next call to
+// [TerminalRenderer.Render], it will move the cursor home and clear the screen
+// to prepare for rendering the new buffer.
+//
+// Note: you might want to reapply the cursor visibility state after calling
+// this method, as some terminals reset the cursor visibility when switching to
+// the alternate screen.
+func (s *TerminalRenderer) EnterAltScreen() {
+ s.SaveCursor()
+ s.buf.WriteString(ansi.SetModeAltScreenSaveCursor)
+ s.SetFullscreen(true)
+ s.SetRelativeCursor(false)
+ s.Erase()
+}
+
+// ExitAltScreen is a helper that queues the [ansi.ModeAltScreenSaveCursor]
+// escape sequence to exit the alternate screen buffer and restore cursor mode.
+//
+// It restores the saved cursor properties, disables
+// [TerminalRenderer.SetFullscreen] flag, and enables
+// [TerminalRenderer.SetRelativeCursor] flag. On the next call to
+// [TerminalRenderer.Render], it will move the cursor to the first line and
+// clear everything below the cursor to prepare for rendering the new buffer.
+//
+// Note: you might want to reapply the cursor visibility state after calling
+// this method, as some terminals reset the cursor visibility when switching to
+// the alternate screen.
+func (s *TerminalRenderer) ExitAltScreen() {
+ s.Erase()
+ s.SetRelativeCursor(true)
+ s.SetFullscreen(false)
+ s.buf.WriteString(ansi.ResetModeAltScreenSaveCursor)
+ s.RestoreCursor()
+}
+
+// PrependString adds the lines of the given string to the top of the terminal
+// screen. The lines prepended are not managed by the renderer and will not be
+// cleared or updated by the renderer.
+//
+// Using this when the terminal is using the alternate screen or when occupying
+// the whole screen may not produce any visible effects. This is because
+// once the terminal writes the prepended lines, they will get overwritten
+// by the next frame.
+func (s *TerminalRenderer) PrependString(newbuf *RenderBuffer, str string) {
+ if len(str) == 0 {
+ return
+ }
+
+ // TODO: Use scrolling region if available.
+ // TODO: Use [Screen.Write] [io.Writer] interface.
+
+ // We need to scroll the screen up by the number of lines in the queue.
+ // We can't use [ansi.SU] because we want the cursor to move down until
+ // it reaches the bottom of the screen.
+ w, h := newbuf.Width(), newbuf.Height()
+ s.move(newbuf, 0, h-1)
+ lines := strings.Split(str, "\n")
+ offset := 0
+ for _, line := range lines {
+ lineWidth := s.method.StringWidth(line)
+ if w > 0 && lineWidth > w {
+ offset += (lineWidth / w)
+ }
+ if lineWidth == 0 || lineWidth%w != 0 {
+ offset++
+ }
+ }
+
+ s.buf.WriteString(strings.Repeat("\n", offset))
+ s.cur.Y += offset
+ // XXX: Now go to the top of the screen, insert new lines, and write
+ // the queued strings. It is important to use [Screen.moveCursor]
+ // instead of [Screen.move] because we don't want to perform any checks
+ // on the cursor position.
+ s.moveCursor(newbuf, 0, 0, false)
+ s.buf.WriteString(ansi.InsertLine(offset))
+ for _, line := range lines {
+ s.buf.WriteString(line)
+ s.buf.WriteString("\r\n")
+ }
+}
+
+// moveCursor moves the cursor to the specified position.
+//
+// It is safe to call this function with a nil [Buffer], in that case, it won't
+// be using any optimizations that depend on the buffer.
+func (s *TerminalRenderer) moveCursor(newbuf *RenderBuffer, x, y int, overwrite bool) {
+ if !s.flags.Contains(tFullscreen) && s.flags.Contains(tRelativeCursor) &&
+ s.cur.X == -1 && s.cur.Y == -1 {
+ // First cursor movement in inline mode, move the cursor to the first
+ // column before moving to the target position.
+ _ = s.buf.WriteByte('\r')
+ s.cur.X, s.cur.Y = 0, 0
+ }
+ seq := moveCursor(s, newbuf, x, y, overwrite)
+ _, _ = s.buf.WriteString(seq)
+ s.cur.X, s.cur.Y = x, y
+}
+
+// move moves the cursor to the specified position in the buffer.
+//
+// It is safe to call this function with a nil [Buffer], in that case, it won't
+// be using any optimizations that depend on the buffer.
+func (s *TerminalRenderer) move(newbuf *RenderBuffer, x, y int) {
+ // XXX: Make sure we use the max height and width of the buffer in case
+ // we're in the middle of a resize operation.
+ var width, height int
+ if s.curbuf != nil {
+ width, height = s.curbuf.Width(), s.curbuf.Height()
+ }
+ if newbuf != nil {
+ width = max(newbuf.Width(), width)
+ height = max(newbuf.Height(), height)
+ }
+
+ if width > 0 && x >= width {
+ // Handle autowrap
+ y += (x / width)
+ x %= width
+ }
+
+ // XXX: Disable styles if there's any
+ // Some move operations such as [ansi.LF] can apply styles to the new
+ // cursor position, thus, we need to reset the styles before moving the
+ // cursor.
+ blank := s.clearBlank()
+ resetPen := y != s.cur.Y && !blank.Equal(&EmptyCell)
+ if resetPen {
+ s.updatePen(nil)
+ }
+
+ // Reset wrap around (phantom cursor) state
+ if s.atPhantom {
+ s.cur.X = 0
+ _ = s.buf.WriteByte('\r')
+ s.atPhantom = false // reset phantom cell state
+ }
+
+ // TODO: Investigate if we need to handle this case and/or if we need the
+ // following code.
+ //
+ // if width > 0 && s.cur.X >= width {
+ // l := (s.cur.X + 1) / width
+ //
+ // s.cur.Y += l
+ // if height > 0 && s.cur.Y >= height {
+ // l -= s.cur.Y - height - 1
+ // }
+ //
+ // if l > 0 {
+ // s.cur.X = 0
+ // s.buf.WriteString("\r" + strings.Repeat("\n", l)) //nolint:errcheck
+ // }
+ // }
+
+ if height > 0 {
+ if s.cur.Y > height-1 {
+ s.cur.Y = height - 1
+ }
+ if y > height-1 {
+ y = height - 1
+ }
+ }
+
+ if x == s.cur.X && y == s.cur.Y {
+ // We give up later because we need to run checks for the phantom cell
+ // and others before we can determine if we can give up.
+ return
+ }
+
+ // We set the new cursor in tscreen.moveCursor].
+ s.moveCursor(newbuf, x, y, true) // Overwrite cells if possible
+}
+
+// cellEqual returns whether the two cells are equal. A nil cell is considered
+// a [EmptyCell].
+func cellEqual(a, b *Cell) bool {
+ if a == b {
+ return true
+ }
+ // TODO: This is needed to handle empty lines correctly when scroll
+ // optimizations are enabled. Instead, a nil check should be equivalent to
+ // checking for an [EmptyCell], should it?
+ // Investigate why when we assign the pointers to &[EmptyCell], this causes
+ // scroll optimization related artifacts where excess lines are left behind
+ // in empty lines after scrolling.
+ if a == nil || b == nil {
+ return false
+ }
+ return a.Equal(b)
+}
+
+// putCell draws a cell at the current cursor position.
+func (s *TerminalRenderer) putCell(newbuf *RenderBuffer, cell *Cell) {
+ width, height := newbuf.Width(), newbuf.Height()
+ if s.flags.Contains(tFullscreen) && s.cur.X == width-1 && s.cur.Y == height-1 {
+ s.putCellLR(newbuf, cell)
+ } else {
+ s.putAttrCell(newbuf, cell)
+ }
+}
+
+// wrapCursor wraps the cursor to the next line.
+func (s *TerminalRenderer) wrapCursor() {
+ const autoRightMargin = true
+ if autoRightMargin {
+ // Assume we have auto wrap mode enabled.
+ s.cur.X = 0
+ s.cur.Y++
+ } else {
+ s.cur.X--
+ }
+}
+
+func (s *TerminalRenderer) putAttrCell(newbuf *RenderBuffer, cell *Cell) {
+ if cell != nil && cell.Width == 0 {
+ // XXX: Zero width cells are special and should not be written to the
+ // screen no matter what other attributes they have.
+ // Zero width cells are used for wide characters that are split into
+ // multiple cells.
+ return
+ }
+
+ // We're at pending wrap state (phantom cell), incoming cell should
+ // wrap.
+ if s.atPhantom {
+ s.wrapCursor()
+ s.atPhantom = false
+ }
+
+ s.updatePen(cell)
+ cellWidth := 1
+ if cell == nil {
+ _ = s.buf.WriteByte(' ')
+ } else {
+ _, _ = s.buf.WriteString(cell.Content)
+ cellWidth = cell.Width
+ }
+
+ s.cur.X += cellWidth
+ if s.cur.X >= newbuf.Width() {
+ s.atPhantom = true
+ }
+
+ if cellWidth > 1 {
+ s.lineHadWide = true
+ }
+}
+
+// putCellLR draws a cell at the lower right corner of the screen.
+func (s *TerminalRenderer) putCellLR(newbuf *RenderBuffer, cell *Cell) {
+ // Optimize for the lower right corner cell.
+ curX := s.cur.X
+ if !cell.isWidePlaceholder() {
+ _, _ = s.buf.WriteString(ansi.ResetModeAutoWrap)
+ s.putAttrCell(newbuf, cell)
+ // Writing to lower-right corner cell should not wrap.
+ s.atPhantom = false
+ s.cur.X = curX
+ _, _ = s.buf.WriteString(ansi.SetModeAutoWrap)
+ }
+}
+
+// updatePen updates the cursor pen styles.
+func (s *TerminalRenderer) updatePen(cell *Cell) {
+ if cell == nil {
+ if !s.cur.Style.IsZero() {
+ _, _ = s.buf.WriteString(ansi.ResetStyle)
+ s.cur.Style = Style{} // Reset style
+ }
+ if !s.cur.Link.IsZero() {
+ _, _ = s.buf.WriteString(ansi.ResetHyperlink())
+ }
+ return
+ }
+
+ // Downsample pen when we don't have a [colorprofile.TrueColor],
+ // otherwise, use the original style.
+ newStyle := ConvertStyle(cell.Style, s.profile)
+ newLink := ConvertLink(cell.Link, s.profile)
+ oldStyle := ConvertStyle(s.cur.Style, s.profile)
+ oldLink := ConvertLink(s.cur.Link, s.profile)
+
+ if !newStyle.Equal(&oldStyle) {
+ seq := newStyle.Diff(&oldStyle)
+ if newStyle.IsZero() && len(seq) > len(ansi.ResetStyle) {
+ seq = ansi.ResetStyle
+ }
+ _, _ = s.buf.WriteString(seq)
+ s.cur.Style = cell.Style // Copy the original style
+ }
+ if !newLink.Equal(&oldLink) {
+ _, _ = s.buf.WriteString(ansi.SetHyperlink(newLink.URL, newLink.Params))
+ s.cur.Link = cell.Link // Copy the original link
+ }
+}
+
+// canClearWith checks whether the given cell can be used by clearing commands
+// like [ansi.EL] to clear the screen. It tests if a cell is empty i.e. space
+// or blank and doesn't include any bad style attributes such as [AttrReverse].
+func canClearWith(c *Cell) bool {
+ if c == nil {
+ return true
+ }
+ if c.Width != 1 || len(c.Content) != 1 || c.Content != " " {
+ return false
+ }
+ // NOTE: This assumes that the terminal supports bce terminfo capability
+ // which all xterm-compatible terminals and terminals that use xterm*
+ // terminal types do.
+ return c.Style.Underline == UnderlineNone &&
+ c.Style.Attrs&^(AttrBold|AttrFaint|AttrItalic|AttrBlink|AttrRapidBlink) == 0 &&
+ c.Link.IsZero()
+}
+
+// emitRange emits a range of cells to the buffer. It it equivalent to calling
+// tscreen.putCell] for each cell in the range. This is optimized to use
+// [ansi.ECH] and [ansi.REP].
+// Returns whether the cursor is at the end of interval or somewhere in the
+// middle.
+func (s *TerminalRenderer) emitRange(newbuf *RenderBuffer, line Line, n int) (eoi bool) {
+ hasECH := s.caps.Contains(capECH)
+ hasREP := s.caps.Contains(capREP)
+ if hasECH || hasREP { //nolint:nestif
+ for n > 0 {
+ var count int
+ for n > 1 && !cellEqual(line.At(0), line.At(1)) {
+ s.putCell(newbuf, line.At(0))
+ line = line[1:]
+ n--
+ }
+
+ cell0 := line[0]
+ if n == 1 {
+ s.putCell(newbuf, &cell0)
+ return false
+ }
+
+ count = 2
+ for count < n && cellEqual(line.At(count), &cell0) {
+ count++
+ }
+
+ ech := ansi.EraseCharacter(count)
+ cup := ansi.CursorPosition(s.cur.X+count, s.cur.Y)
+ rep := ansi.RepeatPreviousCharacter(count)
+ if hasECH && count > len(ech)+len(cup) && canClearWith(&cell0) {
+ s.updatePen(&cell0)
+ _, _ = s.buf.WriteString(ech)
+
+ // If this is the last cell, we don't need to move the cursor.
+ if count < n {
+ s.move(newbuf, s.cur.X+count, s.cur.Y)
+ } else {
+ return true // cursor in the middle
+ }
+ } else if hasREP && count > len(rep) &&
+ (len(cell0.Content) == 1 && cell0.Content[0] >= ansi.US && cell0.Content[0] < ansi.DEL) {
+ // We only support ASCII characters. Most terminals will handle
+ // non-ASCII characters correctly, but some might not, ahem xterm.
+ //
+ // NOTE: [ansi.REP] only repeats the last rune and won't work
+ // if the last cell contains multiple runes.
+
+ wrapPossible := s.cur.X+count >= newbuf.Width()
+ repCount := count
+ if wrapPossible {
+ repCount--
+ }
+
+ s.updatePen(&cell0)
+ s.putCell(newbuf, &cell0)
+ repCount-- // cell0 is a single width cell ASCII character
+
+ _, _ = s.buf.WriteString(ansi.RepeatPreviousCharacter(repCount))
+ s.cur.X += repCount
+ if wrapPossible {
+ s.putCell(newbuf, &cell0)
+ }
+ } else {
+ for i := 0; i < count; i++ {
+ s.putCell(newbuf, line.At(i))
+ }
+ }
+
+ line = line[clamp(count, 0, len(line)):]
+ n -= count
+ }
+
+ return false
+ }
+
+ for i := 0; i < n; i++ {
+ s.putCell(newbuf, line.At(i))
+ }
+
+ return false
+}
+
+// putRange puts a range of cells from the old line to the new line.
+// Returns whether the cursor is at the end of interval or somewhere in the
+// middle.
+func (s *TerminalRenderer) putRange(newbuf *RenderBuffer, oldLine, newLine Line, y, start, end int) (eoi bool) {
+ inline := min(len(ansi.CursorPosition(start+1, y+1)),
+ min(len(ansi.HorizontalPositionAbsolute(start+1)),
+ len(ansi.CursorForward(start+1))))
+ if (end - start + 1) > inline { //nolint:nestif
+ var j, same int
+ for j, same = start, 0; j <= end; j++ {
+ oldCell, newCell := oldLine.At(j), newLine.At(j)
+ if same == 0 && oldCell.isWidePlaceholder() && newCell.isWidePlaceholder() {
+ continue
+ }
+ if cellEqual(oldCell, newCell) {
+ same++
+ } else {
+ if same > end-start {
+ s.emitRange(newbuf, newLine[start:], j-same-start)
+ s.move(newbuf, j, y)
+ start = j
+ }
+ same = 0
+ }
+ }
+
+ i := s.emitRange(newbuf, newLine[start:], j-same-start)
+
+ // Always return 1 for the next [tScreen.move] after a
+ // [tScreen.putRange] if we found identical characters at end of
+ // interval.
+ if same == 0 {
+ return i
+ }
+ return true
+ }
+
+ return s.emitRange(newbuf, newLine[start:], end-start+1)
+}
+
+// clearToEnd clears the screen from the current cursor position to the end of
+// line.
+func (s *TerminalRenderer) clearToEnd(newbuf *RenderBuffer, blank *Cell, force bool) {
+ if s.cur.Y >= 0 {
+ curline := s.curbuf.Line(s.cur.Y)
+ // We use the newbuf width because the current buffer might be smaller
+ // than the new buffer during a resize operation and we want to detect
+ // that.
+ for j := s.cur.X; j < newbuf.Width(); j++ {
+ if j >= 0 {
+ c := curline.At(j)
+ if !cellEqual(c, blank) {
+ curline.Set(j, blank)
+ force = true
+ }
+ }
+ }
+ }
+
+ if force {
+ s.updatePen(blank)
+ count := newbuf.Width() - s.cur.X
+ if s.el0Cost() <= count {
+ _, _ = s.buf.WriteString(ansi.EraseLineRight)
+ } else {
+ for i := 0; i < count; i++ {
+ s.putCell(newbuf, blank)
+ }
+ }
+ }
+}
+
+// clearBlank returns a blank cell based on the current cursor background color.
+func (s *TerminalRenderer) clearBlank() *Cell {
+ return &s.cur.Cell
+}
+
+// insertCells inserts the count cells pointed by the given line at the current
+// cursor position.
+func (s *TerminalRenderer) insertCells(newbuf *RenderBuffer, line Line, count int) {
+ supportsICH := s.caps.Contains(capICH)
+ if supportsICH {
+ // Use [ansi.ICH] as an optimization.
+ _, _ = s.buf.WriteString(ansi.InsertCharacter(count))
+ } else {
+ // Otherwise, use [ansi.IRM] mode.
+ _, _ = s.buf.WriteString(ansi.SetModeInsertReplace)
+ }
+
+ for i := 0; count > 0; i++ {
+ s.putAttrCell(newbuf, line.At(i))
+ count--
+ }
+
+ if !supportsICH {
+ _, _ = s.buf.WriteString(ansi.ResetModeInsertReplace)
+ }
+}
+
+// el0Cost returns the cost of using [ansi.EL] 0 i.e. [ansi.EraseLineRight]. If
+// this terminal supports background color erase, it can be cheaper to use
+// [ansi.EL] 0 i.e. [ansi.EraseLineRight] to clear
+// trailing spaces.
+func (s *TerminalRenderer) el0Cost() int {
+ if s.caps != noCaps {
+ return 0
+ }
+ return len(ansi.EraseLineRight)
+}
+
+// lineHasDrift reports whether the line contains a cell that a cell-level
+// diff cannot safely reposition across: a wide cell (width > 1), or a cell
+// whose width the terminal may measure differently than the model. Wide cells
+// occupy several columns, so a diff that lands on a continuation column splits
+// the character; and a width disagreement means the model cannot know which
+// column each glyph landed on.
+func lineHasDrift(m ansi.Method, line Line) bool {
+ for i := 0; i < len(line); i++ {
+ c := line.At(i)
+ if c == nil || c.Width == 0 || len(c.Content) == 0 {
+ continue
+ }
+ if c.Width > 1 || m.StringWidth(c.Content) != ansi.StringWidth(c.Content) {
+ return true
+ }
+ }
+ return false
+}
+
+// repaintLine repaints a line from scratch. Unlike
+// [TerminalRenderer.transformLine] it does not diff against the previous
+// frame: it erases the whole line from column 0 with [ansi.EraseLineRight]
+// and then writes the new frame's cells. Erasing from column 0 removes the
+// entire line including any wide cells the terminal painted at a different
+// width than the model measured, whose real extent the model cannot know.
+// The repaint then starts from a known-empty line and an absolute cursor
+// position, so the result does not depend on where the previous frame left
+// the cursor.
+func (s *TerminalRenderer) repaintLine(newbuf *RenderBuffer, y int) {
+ oldLine := s.curbuf.Line(y)
+ newLine := newbuf.Line(y)
+
+ s.move(newbuf, 0, y)
+ blank := s.clearBlank()
+ s.updatePen(blank)
+ _, _ = s.buf.WriteString(ansi.EraseLineRight)
+ s.cur.X = 0
+
+ // Write the content cells. The line was just erased, so trailing blanks
+ // need no write, and writing them would risk wrapping past the right
+ // margin if the terminal painted a wide cell wider than the model
+ // measured.
+ last := -1
+ for x := 0; x < newbuf.Width(); x++ {
+ if c := newLine.At(x); c != nil && !c.isWidePlaceholder() && !cellEqual(c, blank) {
+ last = x
+ }
+ }
+ for x := 0; x <= last; x++ {
+ s.putCell(newbuf, newLine.At(x))
+ }
+
+ // Adopt the new line as the model of what is on screen.
+ if len(oldLine) == len(newLine) {
+ copy(oldLine, newLine)
+ }
+}
+
+// transformLine transforms the given line in the current window to the
+// corresponding line in the new window. It uses [ansi.ICH] and [ansi.DCH] to
+// insert or delete characters.
+func (s *TerminalRenderer) transformLine(newbuf *RenderBuffer, y int) {
+ var firstCell, oLastCell, nLastCell int // first, old last, new last index
+ oldLine := s.curbuf.Line(y)
+ newLine := newbuf.Line(y)
+
+ s.lineHadWide = false
+ defer s.reanchorWideLine(newbuf)
+
+ // If either frame's line holds a cell that a cell-level diff cannot
+ // safely reposition across, repaint the whole line instead. A wide cell
+ // (width > 1) occupies several columns, so a diff that lands on a
+ // continuation column splits the character, and per DEC semantics (also
+ // implemented by ghostty and x/vt) an erase that splits a multi-cell
+ // character erases the whole character, including a head cell that
+ // belongs to the new frame. A cell whose width the terminal measures
+ // differently than the model (an emoji cluster, a keycap) leaves the
+ // real cursor at a column the model cannot predict, so a later erase in
+ // the same transform fires at the wrong column. Repainting depends only
+ // on an absolute cursor position and a known-empty line.
+ if lineHasDrift(s.method, oldLine) || lineHasDrift(s.method, newLine) {
+ s.repaintLine(newbuf, y)
+ return
+ }
+
+ // Find the first changed cell in the line
+ blank := newLine.At(0)
+
+ // It might be cheaper to clear leading spaces with [ansi.EL] 1 i.e.
+ // [ansi.EraseLineLeft].
+ if canClearWith(blank) { //nolint:nestif
+ var oFirstCell, nFirstCell int
+ for oFirstCell = 0; oFirstCell < s.curbuf.Width(); oFirstCell++ {
+ if !cellEqual(oldLine.At(oFirstCell), blank) {
+ break
+ }
+ }
+ for nFirstCell = 0; nFirstCell < newbuf.Width(); nFirstCell++ {
+ if !cellEqual(newLine.At(nFirstCell), blank) {
+ break
+ }
+ }
+
+ if nFirstCell == oFirstCell {
+ firstCell = nFirstCell
+
+ // Find the first differing cell
+ for firstCell < newbuf.Width() &&
+ cellEqual(oldLine.At(firstCell), newLine.At(firstCell)) {
+ firstCell++
+ }
+ } else if oFirstCell > nFirstCell {
+ firstCell = nFirstCell
+ } else if oFirstCell < nFirstCell {
+ firstCell = oFirstCell
+ el1Cost := len(ansi.EraseLineLeft)
+ if el1Cost < nFirstCell-oFirstCell {
+ if nFirstCell >= newbuf.Width() {
+ s.move(newbuf, 0, y)
+ s.updatePen(blank)
+ _, _ = s.buf.WriteString(ansi.EraseLineRight)
+ } else {
+ s.move(newbuf, nFirstCell-1, y)
+ s.updatePen(blank)
+ _, _ = s.buf.WriteString(ansi.EraseLineLeft)
+ }
+
+ for firstCell < nFirstCell {
+ oldLine.Set(firstCell, blank)
+ firstCell++
+ }
+ }
+ }
+ } else {
+ // Find the first differing cell
+ for firstCell < newbuf.Width() && cellEqual(newLine.At(firstCell), oldLine.At(firstCell)) {
+ firstCell++
+ }
+ }
+
+ // If we didn't find one, we're done
+ if firstCell >= newbuf.Width() {
+ return
+ }
+
+ blank = newLine.At(newbuf.Width() - 1)
+ if blank != nil && !canClearWith(blank) {
+ // Find the last differing cell
+ nLastCell = newbuf.Width() - 1
+ for nLastCell > firstCell && cellEqual(newLine.At(nLastCell), oldLine.At(nLastCell)) {
+ nLastCell--
+ }
+
+ if nLastCell >= firstCell {
+ s.move(newbuf, firstCell, y)
+ s.putRange(newbuf, oldLine, newLine, y, firstCell, nLastCell)
+ if firstCell < len(oldLine) && firstCell < len(newLine) {
+ copy(oldLine[firstCell:], newLine[firstCell:])
+ } else {
+ copy(oldLine, newLine)
+ }
+ }
+
+ return
+ }
+
+ // Find last non-blank cell in the old line.
+ // We always use the newbuf width to detect new cell changes.
+ oLastCell = newbuf.Width() - 1
+ for oLastCell > firstCell && cellEqual(oldLine.At(oLastCell), blank) {
+ oLastCell--
+ }
+
+ // Find last non-blank cell in the new line.
+ // We always use the newbuf width to detect new cell changes.
+ nLastCell = newbuf.Width() - 1
+ for nLastCell > firstCell && cellEqual(newLine.At(nLastCell), blank) {
+ nLastCell--
+ }
+
+ if nLastCell == firstCell && s.el0Cost() < oLastCell-nLastCell { //nolint:nestif
+ s.move(newbuf, firstCell, y)
+ if !cellEqual(newLine.At(firstCell), blank) {
+ s.putCell(newbuf, newLine.At(firstCell))
+ }
+ s.clearToEnd(newbuf, blank, false)
+ } else if nLastCell != oLastCell &&
+ !cellEqual(newLine.At(nLastCell), oldLine.At(oLastCell)) {
+ s.move(newbuf, firstCell, y)
+ if oLastCell-nLastCell > s.el0Cost() {
+ if s.putRange(newbuf, oldLine, newLine, y, firstCell, nLastCell) {
+ s.move(newbuf, nLastCell+1, y)
+ }
+ s.clearToEnd(newbuf, blank, false)
+ } else {
+ n := max(nLastCell, oLastCell)
+ s.putRange(newbuf, oldLine, newLine, y, firstCell, n)
+ }
+ } else {
+ nLastNonBlank := nLastCell
+ oLastNonBlank := oLastCell
+
+ // Find the last cells that really differ.
+ // Can be -1 if no cells differ.
+ for cellEqual(newLine.At(nLastCell), oldLine.At(oLastCell)) {
+ if !cellEqual(newLine.At(nLastCell-1), oldLine.At(oLastCell-1)) {
+ break
+ }
+ nLastCell--
+ oLastCell--
+ if nLastCell == -1 || oLastCell == -1 {
+ break
+ }
+ }
+
+ n := min(oLastCell, nLastCell)
+ if n >= firstCell {
+ s.move(newbuf, firstCell, y)
+ s.putRange(newbuf, oldLine, newLine, y, firstCell, n)
+ }
+
+ if oLastCell < nLastCell {
+ m := max(nLastNonBlank, oLastNonBlank)
+ if n != 0 {
+ for n > 0 {
+ wide := newLine.At(n + 1)
+ if !wide.isWidePlaceholder() {
+ break
+ }
+ n--
+ oLastCell--
+ }
+ } else if n >= firstCell && newLine.At(n) != nil && newLine.At(n).Width > 1 {
+ next := newLine.At(n + 1)
+ for next.isWidePlaceholder() {
+ n++
+ oLastCell++
+ next = newLine.At(n + 1)
+ }
+ }
+
+ // TODO: This can sometimes send unnecessary cursor movements with
+ // negative or zero ranges. This could happen on a screen resize
+ // where oLastCell < nLastCell and oLastCell is -1 or less.
+ // Investigate and fix.
+ s.move(newbuf, n+1, y)
+ ichCost := 3 + nLastCell - oLastCell
+ if s.caps.Contains(capICH) && (nLastCell < nLastNonBlank || ichCost > (m-n)) {
+ s.putRange(newbuf, oldLine, newLine, y, n+1, m)
+ } else {
+ s.insertCells(newbuf, newLine[n+1:], nLastCell-oLastCell)
+ }
+ } else if oLastCell > nLastCell {
+ s.move(newbuf, n+1, y)
+ dchCost := 3 + oLastCell - nLastCell
+ if dchCost > len(ansi.EraseLineRight)+nLastNonBlank-(n+1) {
+ if s.putRange(newbuf, oldLine, newLine, y, n+1, nLastNonBlank) {
+ s.move(newbuf, nLastNonBlank+1, y)
+ }
+ s.clearToEnd(newbuf, blank, false)
+ } else {
+ s.updatePen(blank)
+ s.deleteCells(oLastCell - nLastCell)
+ }
+ }
+ }
+
+ // Update the old line with the new line
+ if firstCell < len(oldLine) && firstCell < len(newLine) {
+ copy(oldLine[firstCell:], newLine[firstCell:])
+ } else {
+ copy(oldLine, newLine)
+ }
+}
+
+// reanchorWideLine re-anchors the cursor with a single absolute horizontal
+// move after a line that contained a wide cell. This is a best-effort fallback
+// that bounds cursor desync to one line on terminals whose width model
+// disagrees with ours. When the terminal negotiated Unicode grapheme width
+// (mode 2027) the models agree, so no re-anchor is needed.
+func (s *TerminalRenderer) reanchorWideLine(newbuf *RenderBuffer) {
+ if !s.lineHadWide || s.flags.Contains(tGraphemeWidth) {
+ return
+ }
+ s.lineHadWide = false
+ if s.atPhantom || s.cur.X < 0 || s.cur.X >= newbuf.Width() {
+ return
+ }
+ _, _ = s.buf.WriteString(ansi.CursorHorizontalAbsolute(s.cur.X + 1))
+}
+
+// deleteCells deletes the count cells at the current cursor position and moves
+// the rest of the line to the left. This is equivalent to [ansi.DCH].
+func (s *TerminalRenderer) deleteCells(count int) {
+ // [ansi.DCH] will shift in cells from the right margin so we need to
+ // ensure that they are the right style.
+ _, _ = s.buf.WriteString(ansi.DeleteCharacter(count))
+}
+
+// clearToBottom clears the screen from the current cursor position to the end
+// of the screen.
+func (s *TerminalRenderer) clearToBottom(blank *Cell) {
+ row, col := s.cur.Y, s.cur.X
+ if row < 0 {
+ row = 0
+ }
+
+ s.updatePen(blank)
+ _, _ = s.buf.WriteString(ansi.EraseScreenBelow)
+ // Clear the rest of the current line
+ s.curbuf.ClearArea(Rect(col, row, s.curbuf.Width()-col, 1))
+ // Clear everything below the current line
+ s.curbuf.ClearArea(Rect(0, row+1, s.curbuf.Width(), s.curbuf.Height()-row-1))
+}
+
+// clearBottom tests if clearing the end of the screen would satisfy part of
+// the screen update. Scan backwards through lines in the screen checking if
+// each is blank and one or more are changed.
+// It returns the top line.
+func (s *TerminalRenderer) clearBottom(newbuf *RenderBuffer, total int) (top int) {
+ if total <= 0 {
+ return 0
+ }
+
+ top = total
+ last := min(s.curbuf.Width(), newbuf.Width())
+ blank := s.clearBlank()
+ canClearWithBlank := canClearWith(blank)
+
+ if canClearWithBlank { //nolint:nestif
+ var row int
+ for row = total - 1; row >= 0; row-- {
+ oldLine := s.curbuf.Line(row)
+ newLine := newbuf.Line(row)
+
+ var col int
+ ok := true
+ for col = 0; ok && col < last; col++ {
+ ok = cellEqual(newLine.At(col), blank)
+ }
+ if !ok {
+ break
+ }
+
+ for col = 0; ok && col < last; col++ {
+ ok = cellEqual(oldLine.At(col), blank)
+ }
+ if !ok {
+ top = row
+ }
+ }
+
+ if top < total {
+ s.move(newbuf, 0, max(0, top-1)) // top is 1-based
+ s.clearToBottom(blank)
+ if s.oldhash != nil && s.newhash != nil &&
+ row < len(s.oldhash) && row < len(s.newhash) {
+ for row := top; row < newbuf.Height(); row++ {
+ s.oldhash[row] = s.newhash[row]
+ }
+ }
+ }
+ }
+
+ return top
+}
+
+// clearScreen clears the screen and put cursor at home.
+func (s *TerminalRenderer) clearScreen(blank *Cell) {
+ s.updatePen(blank)
+ _, _ = s.buf.WriteString(ansi.CursorHomePosition)
+ _, _ = s.buf.WriteString(ansi.EraseEntireScreen)
+ s.cur.X, s.cur.Y = 0, 0
+ s.curbuf.Fill(blank)
+}
+
+// clearBelow clears everything below and including the row.
+func (s *TerminalRenderer) clearBelow(newbuf *RenderBuffer, blank *Cell, row int) {
+ s.move(newbuf, 0, row)
+ s.clearToBottom(blank)
+}
+
+// clearUpdate forces a screen redraw.
+func (s *TerminalRenderer) clearUpdate(newbuf *RenderBuffer) {
+ blank := s.clearBlank()
+ var nonEmpty int
+ if s.flags.Contains(tFullscreen) {
+ // XXX: We're using the maximum height of the two buffers to ensure we
+ // write newly added lines to the screen in
+ // [terminalWriter.transformLine].
+ nonEmpty = max(s.curbuf.Height(), newbuf.Height())
+ s.clearScreen(blank)
+ } else {
+ nonEmpty = newbuf.Height()
+ // FIXME: Investigate the double [ansi.ClearScreenBelow] call.
+ // Commenting the line below out seems to work but it might cause other
+ // bugs.
+ s.clearBelow(newbuf, blank, 0)
+ }
+ nonEmpty = s.clearBottom(newbuf, nonEmpty)
+ for i := 0; i < nonEmpty && i < newbuf.Height(); i++ {
+ s.transformLine(newbuf, i)
+ }
+}
+
+func (s *TerminalRenderer) logf(format string, args ...any) {
+ if s.logger == nil {
+ return
+ }
+ s.logger.Printf(format, args...)
+}
+
+// Buffered returns the number of bytes buffered for the next flush.
+func (s *TerminalRenderer) Buffered() int {
+ return s.buf.Len()
+}
+
+// Flush flushes the buffer to the screen.
+func (s *TerminalRenderer) Flush() (err error) {
+ // Write the buffer
+ if n := s.buf.Len(); n > 0 {
+ bts := s.buf.Bytes()
+ if s.logger != nil {
+ s.logf("output: %q", bts)
+ }
+ _, err = s.w.Write(bts)
+ s.buf.Reset()
+ }
+ return
+}
+
+// Redraw forces a full redraw of the screen. It's equivalent to calling
+// [TerminalRenderer.Erase] and [TerminalRenderer.Render].
+func (s *TerminalRenderer) Redraw(newbuf *RenderBuffer) {
+ s.clear = true
+ s.Render(newbuf)
+}
+
+// Render renders changes of the screen to the internal buffer. Call
+// [terminalWriter.Flush] to flush pending changes to the screen.
+func (s *TerminalRenderer) Render(newbuf *RenderBuffer) {
+ // Do we need to render anything?
+ touchedLines := newbuf.TouchedLines()
+ if !s.clear && touchedLines == 0 {
+ return
+ }
+
+ if s.curbuf == nil || s.curbuf.Bounds().Empty() {
+ // Initialize the current buffer
+ s.curbuf = NewRenderBuffer(newbuf.Width(), newbuf.Height())
+ }
+
+ newWidth, newHeight := newbuf.Width(), newbuf.Height()
+ curWidth, curHeight := s.curbuf.Width(), s.curbuf.Height()
+
+ if curWidth != newWidth || curHeight != newHeight {
+ s.oldhash, s.newhash = nil, nil
+ // A shrink makes the terminal reflow in emulator-defined ways the
+ // incremental model cannot predict; force a full repaint. Only in
+ // fullscreen, where the renderer owns every cell it is about to
+ // clear. Inline mode shares the screen with whatever came before,
+ // so it uses the narrower partial clear below instead.
+ if s.flags.Contains(tFullscreen) && (newWidth < curWidth || newHeight < curHeight) {
+ s.clear = true
+ }
+ }
+
+ // TODO: Investigate whether this is necessary. Theoretically, terminals
+ // can add/remove tab stops and we should be able to handle that. We could
+ // use [ansi.DECTABSR] to read the tab stops, but that's not implemented in
+ // most terminals :/
+ // // Are we using hard tabs? If so, ensure tabs are using the
+ // // default interval using [ansi.DECST8C].
+ // if s.opts.HardTabs && !s.initTabs {
+ // s.buf.WriteString(ansi.SetTabEvery8Columns)
+ // s.initTabs = true
+ // }
+
+ var nonEmpty int
+
+ // XXX: In inline mode, after a screen resize, we need to clear the extra
+ // lines at the bottom of the screen. This is because in inline mode, we
+ // don't use the full screen height and the current buffer size might be
+ // larger than the new buffer size.
+ partialClear := !s.flags.Contains(tFullscreen) && s.cur.X != -1 && s.cur.Y != -1 &&
+ curWidth == newWidth &&
+ curHeight > 0 &&
+ curHeight > newHeight
+
+ if !s.clear && partialClear {
+ s.clearBelow(newbuf, nil, newHeight-1)
+ }
+
+ // Resize the model before diffing so the loop below walks every row
+ // of the new screen, including rows added by a grow.
+ if curWidth != newWidth || curHeight != newHeight {
+ s.curbuf.Resize(newWidth, newHeight)
+ }
+
+ if s.clear { //nolint:nestif
+ s.clearUpdate(newbuf)
+ s.clear = false
+ } else if touchedLines > 0 {
+ // On Windows, there's a bug with Windows Terminal where [ansi.DECSTBM]
+ // misbehaves and moves the cursor outside of the scrolling region. For
+ // now, we disable the optimizations completely on Windows.
+ // See https://github.com/microsoft/terminal/issues/19016
+ if s.flags.Contains(tScrollOptim) && s.flags.Contains(tFullscreen) {
+ // Optimize scrolling for the alternate screen buffer.
+ // TODO: Should we optimize for inline mode as well? If so, we need
+ // to know the actual cursor position to use [ansi.DECSTBM].
+ s.scrollOptimize(newbuf)
+ }
+
+ var changedLines int
+ var i int
+
+ nonEmpty = newHeight
+
+ nonEmpty = s.clearBottom(newbuf, nonEmpty)
+ for i = 0; i < nonEmpty; i++ {
+ if newbuf.Touched == nil || i >= len(newbuf.Touched) || (newbuf.Touched[i] != nil &&
+ (newbuf.Touched[i].FirstCell != -1 || newbuf.Touched[i].LastCell != -1)) {
+ s.transformLine(newbuf, i)
+ changedLines++
+ }
+
+ // Mark line changed successfully.
+ if i < len(newbuf.Touched) && i <= newbuf.Height()-1 {
+ newbuf.Touched[i] = &LineData{
+ FirstCell: -1, LastCell: -1,
+ }
+ }
+ if i < len(s.curbuf.Touched) && i < s.curbuf.Height()-1 {
+ s.curbuf.Touched[i] = &LineData{
+ FirstCell: -1, LastCell: -1,
+ }
+ }
+ }
+ }
+
+ if !s.flags.Contains(tFullscreen) && (curWidth != newWidth || curHeight != newHeight) {
+ s.move(newbuf, 0, newHeight-1)
+ }
+
+ // Sync windows and screen
+ newbuf.Touched = make([]*LineData, newHeight)
+ for i := range newbuf.Touched {
+ newbuf.Touched[i] = &LineData{
+ FirstCell: -1, LastCell: -1,
+ }
+ }
+ for i := range s.curbuf.Touched {
+ s.curbuf.Touched[i] = &LineData{
+ FirstCell: -1, LastCell: -1,
+ }
+ }
+
+ s.updatePen(nil) // nil indicates a blank cell with no styles
+}
+
+// Erase marks the screen to be fully erased on the next render.
+func (s *TerminalRenderer) Erase() {
+ s.clear = true
+}
+
+// Resize updates the terminal screen tab stops. This is used to calculate
+// terminal tab stops for hard tab optimizations.
+//
+// Resize also invalidates the cursor model when the renderer can recover
+// from it: a terminal may move the cursor on any resize, so the remembered
+// position no longer matches reality, and the next move will be absolute.
+//
+// In relative cursor mode there is no absolute move to fall back on, and
+// -1 there means "first move, assume the origin" rather than "unknown", so
+// invalidating would assert a position instead of forgetting one. Keep the
+// old model in that mode and let the next render diff against it.
+func (s *TerminalRenderer) Resize(width, _ int) {
+ if s.tabs != nil {
+ s.tabs.Resize(width)
+ }
+ if !s.flags.Contains(tRelativeCursor) {
+ s.cur.X, s.cur.Y = -1, -1
+ }
+}
+
+// Position returns the cursor position in the screen buffer after applying any
+// pending transformations from the underlying buffer.
+func (s *TerminalRenderer) Position() (x, y int) {
+ return s.cur.X, s.cur.Y
+}
+
+// SetPosition changes the logical cursor position. This can be used when we
+// change the cursor position outside of the screen and need to update the
+// screen cursor position.
+// This changes the cursor position for both normal and alternate screen
+// buffers.
+func (s *TerminalRenderer) SetPosition(x, y int) {
+ s.cur.X, s.cur.Y = x, y
+}
+
+// WriteString writes the given string to the underlying buffer.
+func (s *TerminalRenderer) WriteString(str string) (int, error) {
+ return s.buf.WriteString(str) //nolint:wrapcheck
+}
+
+// Write writes the given bytes to the underlying buffer.
+func (s *TerminalRenderer) Write(b []byte) (int, error) {
+ return s.buf.Write(b) //nolint:wrapcheck
+}
+
+// MoveTo calculates and writes the shortest sequence to move the cursor to the
+// given position. It uses the current cursor position and the new position to
+// calculate the shortest amount of sequences to move the cursor.
+func (s *TerminalRenderer) MoveTo(x, y int) {
+ s.move(nil, x, y)
+}
+
+// notLocal returns whether the coordinates are not considered local movement
+// using the defined thresholds.
+// This takes the number of columns, and the coordinates of the current and
+// target positions.
+func notLocal(cols, fx, fy, tx, ty int) bool {
+ // The typical distance for a [ansi.CUP] sequence. Anything less than this
+ // is considered local movement.
+ const longDist = 8 - 1
+ return (tx > longDist) &&
+ (tx < cols-1-longDist) &&
+ (abs(ty-fy)+abs(tx-fx) > longDist)
+}
+
+// relativeCursorMove returns the relative cursor movement sequence using one or two
+// of the following sequences [ansi.CUU], [ansi.CUD], [ansi.CUF], [ansi.CUB],
+// [ansi.VPA], [ansi.HPA].
+// When overwrite is true, this will try to optimize the sequence by using the
+// screen cells values to move the cursor instead of using escape sequences.
+//
+// It is safe to call this function with a nil [Buffer]. In that case, it won't
+// use any optimizations that require the new buffer such as overwrite.
+func relativeCursorMove(s *TerminalRenderer, newbuf *RenderBuffer, fx, fy, tx, ty int, overwrite, useTabs, useBackspace bool) string {
+ var seq strings.Builder
+ if newbuf == nil {
+ overwrite = false // We can't overwrite the current buffer.
+ }
+
+ if ty != fy { //nolint:nestif
+ var yseq string
+ if s.caps.Contains(capVPA) && !s.flags.Contains(tRelativeCursor) {
+ yseq = ansi.VerticalPositionAbsolute(ty + 1)
+ }
+
+ if ty > fy {
+ n := ty - fy
+ if cud := ansi.CursorDown(n); yseq == "" || len(cud) < len(yseq) {
+ yseq = cud
+ }
+ if !s.flags.Contains(tFullscreen) || n < len(yseq) { // n is the cost of using newline characters
+ yseq = strings.Repeat("\n", n)
+ if s.flags.Contains(tMapNewline) {
+ fx = 0
+ }
+ }
+ } else if ty < fy {
+ n := fy - ty
+ if cuu := ansi.CursorUp(n); yseq == "" || len(cuu) < len(yseq) {
+ yseq = cuu
+ }
+ if n == 1 && fy-1 > 0 {
+ // TODO: Ensure we're not unintentionally scrolling the screen up.
+ yseq = ansi.ReverseIndex
+ }
+ }
+
+ seq.WriteString(yseq)
+ }
+
+ if tx != fx { //nolint:nestif
+ var xseq string
+ if !s.flags.Contains(tRelativeCursor) {
+ if s.caps.Contains(capHPA) {
+ xseq = ansi.HorizontalPositionAbsolute(tx + 1)
+ } else if s.caps.Contains(capCHA) {
+ xseq = ansi.CursorHorizontalAbsolute(tx + 1)
+ }
+ }
+
+ if tx > fx {
+ n := tx - fx
+ if useTabs && s.tabs != nil {
+ var tabs int
+ var col int
+ for col = fx; s.tabs.Next(col) <= tx; col = s.tabs.Next(col) {
+ tabs++
+ if col == s.tabs.Next(col) || col >= s.tabs.Width()-1 {
+ break
+ }
+ }
+
+ if tabs > 0 {
+ cht := ansi.CursorHorizontalForwardTab(tabs)
+ tab := strings.Repeat("\t", tabs)
+ if false && s.caps.Contains(capCHT) && len(cht) < len(tab) {
+ // TODO: The linux console and some terminals such as
+ // Alacritty don't support [ansi.CHT]. Enable this when
+ // we have a way to detect this, or after 5 years when
+ // we're sure everyone has updated their terminals :P
+ seq.WriteString(cht)
+ } else {
+ seq.WriteString(tab)
+ }
+
+ n = tx - col
+ fx = col
+ }
+ }
+
+ if cuf := ansi.CursorForward(n); xseq == "" || len(cuf) < len(xseq) {
+ xseq = cuf
+ }
+
+ // If we have no attribute and style changes, overwrite is cheaper.
+ var ovw string
+ if overwrite && ty >= 0 {
+ for i := 0; i < n; i++ {
+ cell := newbuf.CellAt(fx+i, ty)
+ if cell != nil && cell.Width > 0 {
+ i += cell.Width - 1
+ if !cell.Style.Equal(&s.cur.Style) || !cell.Link.Equal(&s.cur.Link) {
+ overwrite = false
+ break
+ }
+ }
+ }
+ }
+
+ if overwrite && ty >= 0 {
+ for i := 0; i < n; i++ {
+ cell := newbuf.CellAt(fx+i, ty)
+ if cell != nil && cell.Width > 0 {
+ ovw += cell.String()
+ i += cell.Width - 1
+ }
+ }
+ }
+
+ if overwrite && len(ovw) < len(xseq) {
+ xseq = ovw
+ }
+ } else if tx < fx {
+ n := fx - tx
+ if useTabs && s.tabs != nil && s.caps.Contains(capCBT) {
+ // VT100 does not support backward tabs [ansi.CBT].
+
+ col := fx
+
+ var cbt int // cursor backward tabs count
+ for s.tabs.Prev(col) >= tx {
+ col = s.tabs.Prev(col)
+ cbt++
+ if col == s.tabs.Prev(col) || col <= 0 {
+ break
+ }
+ }
+
+ if cbt > 0 {
+ seq.WriteString(ansi.CursorBackwardTab(cbt))
+ n = col - tx
+ }
+ }
+
+ if cub := ansi.CursorBackward(n); xseq == "" || len(cub) < len(xseq) {
+ xseq = cub
+ }
+
+ if useBackspace && n < len(xseq) {
+ xseq = strings.Repeat("\b", n)
+ }
+ }
+
+ seq.WriteString(xseq)
+ }
+
+ return seq.String()
+}
+
+// moveCursor moves and returns the cursor movement sequence to move the cursor
+// to the specified position.
+// When overwrite is true, this will try to optimize the sequence by using the
+// screen cells values to move the cursor instead of using escape sequences.
+//
+// It is safe to call this function with a nil [Buffer]. In that case, it won't
+// use any optimizations that require the new buffer such as overwrite.
+func moveCursor(s *TerminalRenderer, newbuf *RenderBuffer, x, y int, overwrite bool) (seq string) {
+ fx, fy := s.cur.X, s.cur.Y
+
+ if !s.flags.Contains(tRelativeCursor) {
+ width := -1 // Use -1 to indicate that we don't know the width of the screen.
+ if s.tabs != nil {
+ width = s.tabs.Width()
+ }
+ if newbuf != nil && width == -1 {
+ // Even though this might not be accurate, we can use the new
+ // buffer width as a fallback. Technically, if the new buffer
+ // didn't have the width of the terminal, this would give us a
+ // wrong result from [notLocal].
+ width = newbuf.Width()
+ }
+ // Method #0: Use [ansi.CUP] if the distance is long.
+ seq = ansi.CursorPosition(x+1, y+1)
+ if fx == -1 || fy == -1 || width == -1 || notLocal(width, fx, fy, x, y) {
+ return seq
+ }
+ }
+
+ // Optimize based on options.
+ trials := 0
+ if s.caps.Contains(capHT) {
+ trials |= 2 // 0b10 in binary
+ }
+ if s.caps.Contains(capBS) {
+ trials |= 1 // 0b01 in binary
+ }
+
+ // Try all possible combinations of hard tabs and backspace optimizations.
+ for i := 0; i <= trials; i++ {
+ // Skip combinations that are not enabled.
+ if i & ^trials != 0 {
+ continue
+ }
+
+ useHardTabs := i&2 != 0
+ useBackspace := i&1 != 0
+
+ // Method #1: Use local movement sequences.
+ nseq1 := relativeCursorMove(s, newbuf, fx, fy, x, y, overwrite, useHardTabs, useBackspace)
+ if (i == 0 && len(seq) == 0) || len(nseq1) < len(seq) {
+ seq = nseq1
+ }
+
+ // Method #2: Use [ansi.CR] and local movement sequences.
+ nseq2 := relativeCursorMove(s, newbuf, 0, fy, x, y, overwrite, useHardTabs, useBackspace)
+ nseq2 = "\r" + nseq2
+ if len(nseq2) < len(seq) {
+ seq = nseq2
+ }
+
+ if !s.flags.Contains(tRelativeCursor) {
+ // Method #3: Use [ansi.CursorHomePosition] and local movement sequences.
+ nseq3 := relativeCursorMove(s, newbuf, 0, 0, x, y, overwrite, useHardTabs, useBackspace)
+ nseq3 = ansi.CursorHomePosition + nseq3
+ if len(nseq3) < len(seq) {
+ seq = nseq3
+ }
+ }
+ }
+
+ return seq
+}
+
+// xtermCaps returns whether the terminal is xterm-like. This means that the
+// terminal supports ECMA-48 and ANSI X3.64 escape sequences.
+// xtermCaps returns a list of control sequence capabilities for the given
+// terminal type. This only supports a subset of sequences that can
+// be different among terminals.
+// NOTE: A hybrid approach would be to support Terminfo databases for a full
+// set of capabilities.
+func xtermCaps(termtype string) (v capabilities) {
+ parts := strings.Split(termtype, "-")
+ if len(parts) == 0 {
+ return v
+ }
+
+ switch parts[0] {
+ case
+ "contour",
+ "foot",
+ "ghostty",
+ "kitty",
+ "rio",
+ "st",
+ "tmux",
+ "wezterm":
+ v = allCaps
+ case "xterm":
+ switch {
+ case len(parts) > 1 && parts[1] == "ghostty":
+ fallthrough
+ case len(parts) > 1 && parts[1] == "kitty":
+ fallthrough
+ case len(parts) > 1 && parts[1] == "rio":
+ // These terminals can be defined as xterm- variants for
+ // compatibility with applications that check for xterm.
+ v = allCaps
+ default:
+ // NOTE: We exclude capHPA from allCaps because terminals like
+ // Konsole don't support it. Xterm terminfo defines HPA as CHA
+ // which means we can use CHA instead of HPA.
+ v = allCaps
+ v &^= capHPA
+ v &^= capCHT
+ v &^= capREP
+ }
+ case "alacritty":
+ v = allCaps
+ v &^= capCHT // NOTE: alacritty added support for [ansi.CHT] in 2024-12-28 #62d5b13.
+ case "screen":
+ // See https://www.gnu.org/software/screen/manual/screen.html#Control-Sequences-1
+ v = allCaps
+ v &^= capREP
+ case "linux":
+ // See https://man7.org/linux/man-pages/man4/console_codes.4.html
+ v = capVPA | capCHA | capHPA | capECH | capICH
+ }
+
+ return v
+}
diff --git a/vendor/github.com/charmbracelet/ultraviolet/terminal_renderer_hardscroll.go b/vendor/github.com/charmbracelet/ultraviolet/terminal_renderer_hardscroll.go
new file mode 100644
index 0000000000..3b7eb00e49
--- /dev/null
+++ b/vendor/github.com/charmbracelet/ultraviolet/terminal_renderer_hardscroll.go
@@ -0,0 +1,243 @@
+package uv
+
+import (
+ "strings"
+
+ "github.com/charmbracelet/x/ansi"
+)
+
+// scrollOptimize optimizes the screen to transform the old buffer into the new
+// buffer.
+func (s *TerminalRenderer) scrollOptimize(newbuf *RenderBuffer) {
+ height := newbuf.Height()
+ if s.oldnum == nil || len(s.oldnum) < height {
+ s.oldnum = append(s.oldnum, make([]int, height-len(s.oldnum))...)
+ }
+
+ // Calculate the indices
+ s.updateHashmap(newbuf)
+ if len(s.hashtab) < height {
+ return
+ }
+
+ // Pass 1 - from top to bottom scrolling up
+ for i := 0; i < height; {
+ for i < height && (s.oldnum[i] == newIndex || s.oldnum[i] <= i) {
+ i++
+ }
+ if i >= height {
+ break
+ }
+
+ shift := s.oldnum[i] - i // shift > 0
+ start := i
+
+ i++
+ for i < height && s.oldnum[i] != newIndex && s.oldnum[i]-i == shift {
+ i++
+ }
+ end := i - 1 + shift
+
+ if !s.scrolln(newbuf, shift, start, end, height-1) {
+ continue
+ }
+ }
+
+ // Pass 2 - from bottom to top scrolling down
+ for i := height - 1; i >= 0; {
+ for i >= 0 && (s.oldnum[i] == newIndex || s.oldnum[i] >= i) {
+ i--
+ }
+ if i < 0 {
+ break
+ }
+
+ shift := s.oldnum[i] - i // shift < 0
+ end := i
+
+ i--
+ for i >= 0 && s.oldnum[i] != newIndex && s.oldnum[i]-i == shift {
+ i--
+ }
+
+ start := i + 1 - (-shift)
+ if !s.scrolln(newbuf, shift, start, end, height-1) {
+ continue
+ }
+ }
+}
+
+// scrolln scrolls the screen up by n lines.
+func (s *TerminalRenderer) scrolln(newbuf *RenderBuffer, n, top, bot, maxY int) (v bool) { //nolint:unparam
+ blank := s.clearBlank()
+ if n > 0 { //nolint:nestif
+ // Scroll up (forward)
+ v = s.scrollUp(newbuf, n, top, bot, 0, maxY, blank)
+ if !v {
+ s.buf.WriteString(ansi.SetTopBottomMargins(top+1, bot+1))
+
+ // XXX: How should we handle this in inline mode when not using alternate screen?
+ s.cur.X, s.cur.Y = -1, -1
+ v = s.scrollUp(newbuf, n, top, bot, top, bot, blank)
+ s.buf.WriteString(ansi.SetTopBottomMargins(1, maxY+1))
+ s.cur.X, s.cur.Y = -1, -1
+ }
+
+ if !v {
+ v = s.scrollIdl(newbuf, n, top, bot-n+1, blank)
+ }
+ } else if n < 0 {
+ // Scroll down (backward)
+ v = s.scrollDown(newbuf, -n, top, bot, 0, maxY, blank)
+ if !v {
+ s.buf.WriteString(ansi.SetTopBottomMargins(top+1, bot+1))
+
+ // XXX: How should we handle this in inline mode when not using alternate screen?
+ s.cur.X, s.cur.Y = -1, -1
+ v = s.scrollDown(newbuf, -n, top, bot, top, bot, blank)
+ s.buf.WriteString(ansi.SetTopBottomMargins(1, maxY+1))
+ s.cur.X, s.cur.Y = -1, -1
+
+ if !v {
+ v = s.scrollIdl(newbuf, -n, bot+n+1, top, blank)
+ }
+ }
+ }
+
+ if !v {
+ return false
+ }
+
+ s.scrollBuffer(s.curbuf, n, top, bot, blank)
+
+ // shift hash values too, they can be reused
+ s.scrollOldhash(n, top, bot)
+
+ return true
+}
+
+// scrollBuffer scrolls the buffer by n lines.
+func (s *TerminalRenderer) scrollBuffer(b *RenderBuffer, n, top, bot int, blank *Cell) {
+ if top < 0 || bot < top || bot >= b.Height() {
+ // Nothing to scroll
+ return
+ }
+
+ if n < 0 {
+ // shift n lines downwards
+ limit := top - n
+ for line := bot; line >= limit && line >= 0 && line >= top; line-- {
+ copy(b.Lines[line], b.Lines[line+n])
+ }
+ for line := top; line < limit && line <= b.Height()-1 && line <= bot; line++ {
+ b.FillArea(blank, Rect(0, line, b.Width(), 1))
+ }
+ }
+
+ if n > 0 {
+ // shift n lines upwards
+ limit := bot - n
+ for line := top; line <= limit && line <= b.Height()-1 && line <= bot; line++ {
+ copy(b.Lines[line], b.Lines[line+n])
+ }
+ for line := bot; line > limit && line >= 0 && line >= top; line-- {
+ b.FillArea(blank, Rect(0, line, b.Width(), 1))
+ }
+ }
+
+ s.touchLine(b, top, bot-top+1, true)
+}
+
+// touchLine marks the line as touched.
+func (s *TerminalRenderer) touchLine(newbuf *RenderBuffer, y, n int, changed bool) {
+ height := newbuf.Height()
+ if n < 0 || y < 0 || y >= height || newbuf.Touched == nil || len(newbuf.Touched) < height {
+ return // Nothing to touch
+ }
+
+ width := newbuf.Width()
+ for i := y; i < y+n && i < height && i < len(newbuf.Touched); i++ {
+ if changed {
+ newbuf.TouchLine(0, i, width)
+ } else {
+ newbuf.Touched[i] = nil
+ }
+ }
+}
+
+// scrollUp scrolls the screen up by n lines.
+func (s *TerminalRenderer) scrollUp(newbuf *RenderBuffer, n, top, bot, minY, maxY int, blank *Cell) bool {
+ if n == 1 && top == minY && bot == maxY { //nolint:nestif
+ s.move(newbuf, 0, bot)
+ s.updatePen(blank)
+ s.buf.WriteByte('\n')
+ } else if n == 1 && bot == maxY {
+ s.move(newbuf, 0, top)
+ s.updatePen(blank)
+ s.buf.WriteString(ansi.DeleteLine(1))
+ } else if top == minY && bot == maxY {
+ supportsSU := s.caps.Contains(capSU)
+ s.move(newbuf, 0, bot)
+ s.updatePen(blank)
+ if supportsSU {
+ s.buf.WriteString(ansi.ScrollUp(n))
+ } else {
+ s.buf.WriteString(strings.Repeat("\n", n))
+ }
+ } else if bot == maxY {
+ s.move(newbuf, 0, top)
+ s.updatePen(blank)
+ s.buf.WriteString(ansi.DeleteLine(n))
+ } else {
+ return false
+ }
+ return true
+}
+
+// scrollDown scrolls the screen down by n lines.
+func (s *TerminalRenderer) scrollDown(newbuf *RenderBuffer, n, top, bot, minY, maxY int, blank *Cell) bool {
+ if n == 1 && top == minY && bot == maxY { //nolint:nestif
+ s.move(newbuf, 0, top)
+ s.updatePen(blank)
+ s.buf.WriteString(ansi.ReverseIndex)
+ } else if n == 1 && bot == maxY {
+ s.move(newbuf, 0, top)
+ s.updatePen(blank)
+ s.buf.WriteString(ansi.InsertLine(1))
+ } else if top == minY && bot == maxY {
+ s.move(newbuf, 0, top)
+ s.updatePen(blank)
+ if s.caps.Contains(capSD) {
+ s.buf.WriteString(ansi.ScrollDown(n))
+ } else {
+ s.buf.WriteString(strings.Repeat(ansi.ReverseIndex, n))
+ }
+ } else if bot == maxY {
+ s.move(newbuf, 0, top)
+ s.updatePen(blank)
+ s.buf.WriteString(ansi.InsertLine(n))
+ } else {
+ return false
+ }
+ return true
+}
+
+// scrollIdl scrolls the screen n lines by using [ansi.DL] at del and using
+// [ansi.IL] at ins.
+func (s *TerminalRenderer) scrollIdl(newbuf *RenderBuffer, n, del, ins int, blank *Cell) bool {
+ if n < 0 {
+ return false
+ }
+
+ // Delete lines
+ s.move(newbuf, 0, del)
+ s.updatePen(blank)
+ s.buf.WriteString(ansi.DeleteLine(n))
+
+ // Insert lines
+ s.move(newbuf, 0, ins)
+ s.updatePen(blank)
+ s.buf.WriteString(ansi.InsertLine(n))
+
+ return true
+}
diff --git a/vendor/github.com/charmbracelet/ultraviolet/terminal_renderer_hashmap.go b/vendor/github.com/charmbracelet/ultraviolet/terminal_renderer_hashmap.go
new file mode 100644
index 0000000000..ad776ff83c
--- /dev/null
+++ b/vendor/github.com/charmbracelet/ultraviolet/terminal_renderer_hashmap.go
@@ -0,0 +1,298 @@
+package uv
+
+import "hash/maphash"
+
+// hash returns the hash value of a [Line].
+func hash(h *maphash.Hash, l Line) uint64 {
+ h.Reset()
+ for _, c := range l {
+ // maphash writes can not fail
+ _, _ = h.WriteString(c.Content)
+ }
+
+ return h.Sum64()
+}
+
+// hashmap represents a single [Line] hash.
+type hashmap struct {
+ value uint64
+ oldcount, newcount int
+ oldindex, newindex int
+}
+
+// The value used to indicate lines created by insertions and scrolls.
+const newIndex = -1
+
+// updateHashmap updates the hashmap with the new hash value.
+func (s *TerminalRenderer) updateHashmap(newbuf *RenderBuffer) {
+ height := newbuf.Height()
+
+ if len(s.oldhash) >= height && len(s.newhash) >= height {
+ // rehash changed lines
+ for i := range height {
+ if newbuf.Touched == nil || newbuf.Touched[i] != nil {
+ // TODO: Investigate why this is needed. If we remove this
+ // line, scroll optimization does not work correctly. This
+ // should happen else where.
+ s.oldhash[i] = hash(&s.hasher, s.curbuf.Line(i))
+ s.newhash[i] = hash(&s.hasher, newbuf.Line(i))
+ }
+ }
+ } else {
+ // rehash all
+ if len(s.oldhash) != height {
+ s.oldhash = make([]uint64, height)
+ }
+ if len(s.newhash) != height {
+ s.newhash = make([]uint64, height)
+ }
+ for i := range height {
+ s.oldhash[i] = hash(&s.hasher, s.curbuf.Line(i))
+ s.newhash[i] = hash(&s.hasher, newbuf.Line(i))
+ }
+ }
+
+ s.hashtab = make([]hashmap, (height+1)*2)
+ for i := range height {
+ hashval := s.oldhash[i]
+
+ // Find matching hash or empty slot
+ var idx int
+ for idx = 0; idx < len(s.hashtab) && s.hashtab[idx].value != 0; idx++ {
+ if s.hashtab[idx].value == hashval {
+ break
+ }
+ }
+
+ s.hashtab[idx].value = hashval // in case this is a new hash
+ s.hashtab[idx].oldcount++
+ s.hashtab[idx].oldindex = i
+ }
+ for i := range height {
+ hashval := s.newhash[i]
+
+ // Find matching hash or empty slot
+ var idx int
+ for idx = 0; idx < len(s.hashtab) && s.hashtab[idx].value != 0; idx++ {
+ if s.hashtab[idx].value == hashval {
+ break
+ }
+ }
+
+ s.hashtab[idx].value = hashval // in case this is a new hash
+ s.hashtab[idx].newcount++
+ s.hashtab[idx].newindex = i
+ s.oldnum[i] = newIndex // init old indices slice
+ }
+
+ // Mark line pair corresponding to unique hash pairs.
+ for i := 0; i < len(s.hashtab) && s.hashtab[i].value != 0; i++ {
+ hsp := &s.hashtab[i]
+ if hsp.oldcount == 1 && hsp.newcount == 1 && hsp.oldindex != hsp.newindex {
+ s.oldnum[hsp.newindex] = hsp.oldindex
+ }
+ }
+
+ s.growHunks(newbuf)
+
+ // Eliminate bad or impossible shifts. This includes removing those hunks
+ // which could not grow because of conflicts, as well those which are to be
+ // moved too far, they are likely to destroy more than carry.
+ for i := 0; i < height; {
+ var start, shift, size int
+ for i < height && s.oldnum[i] == newIndex {
+ i++
+ }
+ if i >= height {
+ break
+ }
+ start = i
+ shift = s.oldnum[i] - i
+ i++
+ for i < height && s.oldnum[i] != newIndex && s.oldnum[i]-i == shift {
+ i++
+ }
+ size = i - start
+ if size < 3 || size+min(size/8, 2) < abs(shift) {
+ for start < i {
+ s.oldnum[start] = newIndex
+ start++
+ }
+ }
+ }
+
+ // After clearing invalid hunks, try grow the rest.
+ s.growHunks(newbuf)
+}
+
+// scrollOldhash scrolls the oldhash slice by 'n' lines between 'top' and 'bot'.
+func (s *TerminalRenderer) scrollOldhash(n, top, bot int) {
+ if len(s.oldhash) == 0 {
+ return
+ }
+
+ size := bot - top + 1 - abs(n)
+ if n > 0 {
+ // Move existing hashes up
+ copy(s.oldhash[top:], s.oldhash[top+n:top+n+size])
+ // Recalculate hashes for newly shifted-in lines
+ for i := bot; i > bot-n; i-- {
+ s.oldhash[i] = hash(&s.hasher, s.curbuf.Line(i))
+ }
+ } else {
+ // Move existing hashes down
+ copy(s.oldhash[top-n:], s.oldhash[top:top+size])
+ // Recalculate hashes for newly shifted-in lines
+ for i := top; i < top-n; i++ {
+ s.oldhash[i] = hash(&s.hasher, s.curbuf.Line(i))
+ }
+ }
+}
+
+func (s *TerminalRenderer) growHunks(newbuf *RenderBuffer) {
+ var (
+ backLimit int // limits for cells to fill
+ backRefLimit int // limit for references
+ i int
+ nextHunk int
+ )
+
+ height := newbuf.Height()
+ for i < height && s.oldnum[i] == newIndex {
+ i++
+ }
+ for ; i < height; i = nextHunk {
+ var (
+ forwardLimit int
+ forwardRefLimit int
+ end int
+ start = i
+ shift = s.oldnum[i] - i
+ )
+
+ // get forward limit
+ i = start + 1
+ for i < height &&
+ s.oldnum[i] != newIndex &&
+ s.oldnum[i]-i == shift {
+ i++
+ }
+
+ end = i
+ for i < height && s.oldnum[i] == newIndex {
+ i++
+ }
+
+ nextHunk = i
+ forwardLimit = i
+ if i >= height || s.oldnum[i] >= i {
+ forwardRefLimit = i
+ } else {
+ forwardRefLimit = s.oldnum[i]
+ }
+
+ i = start - 1
+
+ // grow back
+ if shift < 0 {
+ backLimit = backRefLimit + (-shift)
+ }
+ for i >= backLimit {
+ if s.newhash[i] == s.oldhash[i+shift] ||
+ s.costEffective(newbuf, i+shift, i, shift < 0) {
+ s.oldnum[i] = i + shift
+ } else {
+ break
+ }
+ i--
+ }
+
+ i = end
+ // grow forward
+ if shift > 0 {
+ forwardLimit = forwardRefLimit - shift
+ }
+ for i < forwardLimit {
+ if s.newhash[i] == s.oldhash[i+shift] ||
+ s.costEffective(newbuf, i+shift, i, shift > 0) {
+ s.oldnum[i] = i + shift
+ } else {
+ break
+ }
+ i++
+ }
+
+ backLimit = i
+ backRefLimit = backLimit
+ if shift > 0 {
+ backRefLimit += shift
+ }
+ }
+}
+
+// costEffective returns true if the cost of moving line 'from' to line 'to' seems to be
+// cost effective. 'blank' indicates whether the line 'to' would become blank.
+func (s *TerminalRenderer) costEffective(newbuf *RenderBuffer, from, to int, blank bool) bool {
+ if from == to {
+ return false
+ }
+
+ newFrom := s.oldnum[from]
+ if newFrom == newIndex {
+ newFrom = from
+ }
+
+ // On the left side of >= is the cost before moving. On the right side --
+ // cost after moving.
+
+ // Calculate costs before moving.
+ var costBeforeMove int
+ if blank {
+ // Cost of updating blank line at destination.
+ costBeforeMove = s.updateCostBlank(newbuf, newbuf.Line(to))
+ } else {
+ // Cost of updating exiting line at destination.
+ costBeforeMove = s.updateCost(newbuf, s.curbuf.Line(to), newbuf.Line(to))
+ }
+
+ // Add cost of updating source line
+ costBeforeMove += s.updateCost(newbuf, s.curbuf.Line(newFrom), newbuf.Line(from))
+
+ // Calculate costs after moving.
+ var costAfterMove int
+ if newFrom == from {
+ // Source becomes blank after move
+ costAfterMove = s.updateCostBlank(newbuf, newbuf.Line(from))
+ } else {
+ // Source gets updated from another line
+ costAfterMove = s.updateCost(newbuf, s.curbuf.Line(newFrom), newbuf.Line(from))
+ }
+
+ // Add cost of moving source line to destination
+ costAfterMove += s.updateCost(newbuf, s.curbuf.Line(from), newbuf.Line(to))
+
+ // Return true if moving is cost effective (costs less or equal)
+ return costBeforeMove >= costAfterMove
+}
+
+func (s *TerminalRenderer) updateCost(_ *RenderBuffer, from, to Line) (cost int) {
+ var fidx, tidx int
+ for i := s.curbuf.Width(); i > 0; i, fidx, tidx = i-1, fidx+1, tidx+1 {
+ if !cellEqual(from.At(fidx), to.At(tidx)) {
+ cost++
+ }
+ }
+ return
+}
+
+func (s *TerminalRenderer) updateCostBlank(_ *RenderBuffer, to Line) (cost int) {
+ // This assumes bce capability.
+ blank := s.clearBlank()
+ var tidx int
+ for i := s.curbuf.Width(); i > 0; i, tidx = i-1, tidx+1 {
+ if !cellEqual(blank, to.At(tidx)) {
+ cost++
+ }
+ }
+ return
+}
diff --git a/vendor/github.com/charmbracelet/ultraviolet/terminal_screen.go b/vendor/github.com/charmbracelet/ultraviolet/terminal_screen.go
new file mode 100644
index 0000000000..4078ce3e8b
--- /dev/null
+++ b/vendor/github.com/charmbracelet/ultraviolet/terminal_screen.go
@@ -0,0 +1,837 @@
+package uv
+
+import (
+ "bytes"
+ "image/color"
+ "io"
+ "log"
+ "os"
+ "strings"
+ "sync"
+
+ "github.com/charmbracelet/colorprofile"
+ "github.com/charmbracelet/x/ansi"
+ "github.com/charmbracelet/x/term"
+)
+
+// TerminalScreen represents a terminal screen, providing methods for managing
+// the screen state and rendering content.
+type TerminalScreen struct {
+ win *Window
+ w io.Writer
+ buf *bytes.Buffer
+ rend *TerminalRenderer
+ rbuf *RenderBuffer
+ env Environ
+ profile colorprofile.Profile
+
+ // Terminal state
+ altScreen bool
+ keyboardEnhancements *KeyboardEnhancements
+ bracketedPaste bool
+ mouseMode MouseMode
+ mouseEncoding MouseEncoding
+ cursor *Cursor // initial state is cursor hidden
+ backgroundColor color.Color
+ foregroundColor color.Color
+ progressBar *ProgressBar
+ windowTitle string
+ syncUpdates bool // mode 2026
+ resetTabs bool // DECST8C - reset terminal tabs on start
+
+ // mu serializes access to the render buffer, output buffer, and
+ // width-method state so the terminal event loop (which negotiates
+ // grapheme-cluster width) cannot race with the application's own
+ // Render/Flush goroutine.
+ mu sync.Mutex
+ // widthMethodOverride is set when the application explicitly calls
+ // [TerminalScreen.SetWidthMethod]. An explicit override suppresses the
+ // automatic mode-2027 width-method negotiation.
+ widthMethodOverride bool
+}
+
+var _ Screen = (*TerminalScreen)(nil)
+
+// NewTerminalScreen creates a new [TerminalScreen] with the given writer and environment.
+func NewTerminalScreen(w io.Writer, env Environ) *TerminalScreen {
+ s := &TerminalScreen{}
+ s.buf = &bytes.Buffer{}
+ s.win = NewWindow(0, 0, nil)
+ s.w = w
+ s.profile = colorprofile.Detect(w, env)
+ s.rend = NewTerminalRenderer(s.buf, env)
+ s.rend.SetFullscreen(false) // by default, we start in inline mode
+ s.rend.SetRelativeCursor(true) // by default, we start in inline mode
+ s.rend.SetColorProfile(s.profile)
+ s.rbuf = NewRenderBuffer(0, 0)
+ s.env = env
+
+ if debugFile := env.Getenv("UV_DEBUG"); debugFile != "" {
+ if f, err := os.OpenFile(debugFile, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0o644); err == nil {
+ log.SetOutput(f)
+ s.rend.SetLogger(log.Default())
+ }
+ }
+
+ // Configure renderer optimizations based on console settings.
+ f, ok := w.(term.File)
+ if ok {
+ state, err := term.GetState(f.Fd())
+ if err == nil || isWindows { // Windows supports tabs and backspace by default, so we can ignore errors here.
+ useTabs, useBspace := optimizeMovements(state)
+ if useTabs {
+ s.rend.SetTabStops(0) // the width will be set after calling [TerminalScreen.Resize]
+ } else {
+ s.rend.SetTabStops(-1)
+ }
+ s.rend.SetBackspace(useBspace)
+ s.resetTabs = useTabs
+ }
+ }
+ // XXX: Do we still need map nl to crlf handling in the renderer?
+ s.rend.SetMapNewline(false)
+ return s
+}
+
+// CellAt returns the cell at the specified x and y coordinates.
+func (s *TerminalScreen) CellAt(x, y int) *Cell {
+ return s.win.CellAt(x, y)
+}
+
+// SetCell sets the cell at the specified x and y coordinates.
+func (s *TerminalScreen) SetCell(x, y int, cell *Cell) {
+ s.win.SetCell(x, y, cell)
+}
+
+// Bounds returns the bounds of the terminal screen as a rectangle.
+func (s *TerminalScreen) Bounds() Rectangle {
+ return s.win.Bounds()
+}
+
+// Width returns the width of the terminal screen.
+//
+// Note that this is not the actual width of the terminal window, but rather
+// the width of the screen we're managing. The actual width of the terminal
+// window can be obtained using [Terminal.GetSize] or by reading the "COLUMNS"
+// environment variable.
+func (s *TerminalScreen) Width() int {
+ return s.win.Width()
+}
+
+// Height returns the height of the terminal screen.
+//
+// Note that this is not the actual height of the terminal window, but rather
+// the height of the screen we're managing. The actual height of the terminal
+// window can be obtained using [Terminal.GetSize] or by reading the "LINES"
+// environment variable.
+func (s *TerminalScreen) Height() int {
+ return s.win.Height()
+}
+
+// StringWidth returns the cell width of the given string using the terminal
+// screen's width method. This accounts for the configured [WidthMethod]
+// (e.g. wcwidth vs grapheme width) so callers don't need to import ansi
+// directly.
+func (s *TerminalScreen) StringWidth(str string) int {
+ return s.win.WidthMethod().StringWidth(str)
+}
+
+// WidthMethod returns the width method used by the terminal screen.
+func (s *TerminalScreen) WidthMethod() WidthMethod {
+ return s.win.WidthMethod()
+}
+
+// SetWidthMethod sets the width method for the terminal screen. This is an
+// override that propagates to the window/buffer and the renderer so that all
+// width measurements use the same method. Calling this marks the width method
+// as explicitly overridden, which disables automatic mode-2027 negotiation.
+func (s *TerminalScreen) SetWidthMethod(method ansi.Method) {
+ s.mu.Lock()
+ defer s.mu.Unlock()
+ s.widthMethodOverride = true
+ s.setWidthMethod(method)
+}
+
+// setWidthMethod propagates the width method to the window/buffer and the
+// renderer. Callers must hold s.mu.
+func (s *TerminalScreen) setWidthMethod(method ansi.Method) {
+ s.win.SetWidthMethod(method)
+ s.rend.SetWidthMethod(method)
+}
+
+// requestGraphemeWidth queues a DECRQM request for Unicode core mode (DEC mode
+// 2027) so the terminal reports whether it measures cell width using grapheme
+// clustering. The response arrives as a [ModeReportEvent].
+func (s *TerminalScreen) requestGraphemeWidth() {
+ s.mu.Lock()
+ defer s.mu.Unlock()
+ s.buf.WriteString(ansi.RequestMode(ansi.ModeUnicodeCore))
+}
+
+// enableGraphemeWidth enables Unicode core mode (DEC mode 2027) on the terminal
+// and switches the screen's width method to [ansi.GraphemeWidth] so wide-glyph
+// measurement matches the terminal. The change propagates to the
+// window/buffer and renderer.
+//
+// If the application has explicitly set a width method via
+// [TerminalScreen.SetWidthMethod], the explicit choice is preserved and this is
+// a no-op. The change is committed to the underlying writer through the
+// screen's normal locked write path so it cannot race with Render/Flush.
+func (s *TerminalScreen) enableGraphemeWidth() {
+ s.mu.Lock()
+ if s.widthMethodOverride {
+ s.mu.Unlock()
+ return
+ }
+ s.buf.WriteString(ansi.SetMode(ansi.ModeUnicodeCore))
+ s.setWidthMethod(ansi.GraphemeWidth)
+ s.rend.SetGraphemeWidth(true)
+ s.mu.Unlock()
+ _ = s.Flush()
+}
+
+// SetColorProfile sets the color profile for the terminal screen.
+// This is automatically detected when creating the terminal screen. However,
+// you can override it using this method.
+func (s *TerminalScreen) SetColorProfile(profile colorprofile.Profile) {
+ s.profile = profile
+ s.rend.SetColorProfile(profile)
+}
+
+// Resize resizes the terminal screen to the specified width and height,
+// updating the render buffer and renderer accordingly.
+func (s *TerminalScreen) Resize(width, height int) {
+ s.win.Resize(width, height)
+ s.rbuf.Resize(width, height)
+ s.rend.Resize(width, height)
+ s.rend.Erase()
+ s.rbuf.Touched = nil
+}
+
+// Display clears the screen and draws the given [Drawable] onto the terminal
+// screen and flushes the changes to the underlying writer.
+//
+// This is a convenience method that combines [TerminalScreen.Render] and
+// [TerminalScreen.Flush].
+func (s *TerminalScreen) Display(d Drawable) error {
+ if d != nil {
+ s.win.Clear()
+ d.Draw(s, s.win.Bounds())
+ }
+ s.Render()
+ return s.Flush()
+}
+
+// Render renders changes that transform the screen from its current state to
+// the state represented by the [TerminalScreen].
+//
+// The changes can be committed to the underlying writer by calling the
+// [TerminalScreen.Flush] method.
+func (s *TerminalScreen) Render() {
+ s.mu.Lock()
+ defer s.mu.Unlock()
+ for y := 0; y < s.win.Height(); y++ {
+ for x := 0; x < s.win.Width(); {
+ cell := s.win.CellAt(x, y)
+ if cell == nil || cell.IsZero() {
+ x++
+ continue
+ }
+ s.rbuf.SetCell(x, y, cell)
+ width := cell.Width
+ if width <= 0 {
+ width = 1
+ }
+ x += width
+ }
+ }
+ s.rend.Render(s.rbuf)
+ _ = s.rend.Flush()
+}
+
+// Flush writes any pending output to the underlying writer.
+func (s *TerminalScreen) Flush() error {
+ s.mu.Lock()
+ defer s.mu.Unlock()
+ if s.cursor != nil && !s.cursor.Hidden && s.cursor.X >= 0 && s.cursor.Y >= 0 {
+ s.rend.MoveTo(s.cursor.X, s.cursor.Y)
+ } else if !s.altScreen {
+ // We don't want the cursor to be dangling at the end of the line in
+ // inline mode because it can cause unwanted line wraps in some
+ // terminals. So we move it to the beginning of the next line if
+ // necessary.
+ // This is only needed when the cursor is hidden because when it's
+ // visible, we already set its position above.
+ x, y := s.rend.Position()
+ if x >= s.win.Width()-1 {
+ s.rend.MoveTo(0, y)
+ }
+ }
+
+ var buf bytes.Buffer
+ buf.Grow(s.buf.Len())
+
+ if s.buf.Len() > 0 {
+ if s.syncUpdates {
+ buf.Grow(len(ansi.SetModeSynchronizedOutput) + len(ansi.ResetModeSynchronizedOutput))
+
+ // If synchronized updates are enabled, we need to wrap the output in
+ // the appropriate control sequences to ensure that the terminal treats
+ // it as a single atomic update. This is necessary to prevent flickering
+ // and other visual artifacts that can occur when multiple updates are sent
+ // separately.
+ buf.WriteString(ansi.SetModeSynchronizedOutput)
+ } else if s.cursor != nil && !s.cursor.Hidden {
+ buf.Grow(len(ansi.HideCursor) + len(ansi.ShowCursor))
+
+ // If synchronized updates are not enabled, we need to ensure that
+ // the cursor is hidden before writing any output to prevent
+ // unwanted cursor visual artifacts.
+ buf.WriteString(ansi.HideCursor)
+ }
+
+ buf.Write(s.buf.Bytes())
+
+ if s.syncUpdates {
+ buf.WriteString(ansi.ResetModeSynchronizedOutput)
+ } else if s.cursor != nil && !s.cursor.Hidden {
+ buf.WriteString(ansi.ShowCursor)
+ }
+ }
+
+ _, err := s.w.Write(buf.Bytes())
+ if err != nil {
+ return err
+ }
+ s.buf.Reset()
+ return nil
+}
+
+// EnterAltScreen switches the terminal to the alternate screen buffer, allowing
+// applications to use a separate screen for their output without affecting the
+// main screen.
+//
+// The changes can be committed to the underlying writer by calling the
+// [TerminalScreen.Flush] method.
+func (s *TerminalScreen) EnterAltScreen() {
+ var sb strings.Builder
+ sb.WriteString(ansi.SetModeAltScreenSaveCursor)
+ if s.cursor == nil || s.cursor.Hidden {
+ sb.WriteString(ansi.HideCursor)
+ } else if s.cursor != nil && !s.cursor.Hidden {
+ sb.WriteString(ansi.ShowCursor)
+ }
+ if s.keyboardEnhancements != nil {
+ EncodeKeyboardEnhancements(&sb, s.keyboardEnhancements)
+ }
+ s.buf.WriteString(sb.String())
+
+ if !s.altScreen {
+ s.rend.SaveCursor()
+ s.rend.Erase()
+ s.rend.SetFullscreen(true)
+ s.rend.SetRelativeCursor(false)
+ s.altScreen = true
+ }
+}
+
+// ExitAltScreen switches the terminal back to the main screen buffer, restoring
+// the previous screen state.
+//
+// The changes can be committed to the underlying writer by calling the
+// [TerminalScreen.Flush] method.
+func (s *TerminalScreen) ExitAltScreen() {
+ var sb strings.Builder
+ sb.WriteString(ansi.ResetModeAltScreenSaveCursor)
+ if s.cursor == nil || s.cursor.Hidden {
+ sb.WriteString(ansi.HideCursor)
+ } else if s.cursor != nil && !s.cursor.Hidden {
+ sb.WriteString(ansi.ShowCursor)
+ }
+ if s.keyboardEnhancements != nil {
+ EncodeKeyboardEnhancements(&sb, s.keyboardEnhancements)
+ }
+ s.buf.WriteString(sb.String())
+
+ if s.altScreen {
+ s.rend.RestoreCursor()
+ s.rend.Erase()
+ s.rend.SetFullscreen(false)
+ s.rend.SetRelativeCursor(true)
+ s.altScreen = false
+ }
+}
+
+// AltScreen returns whether the terminal is currently in the alternate screen
+// buffer.
+func (s *TerminalScreen) AltScreen() bool {
+ return s.altScreen
+}
+
+// HideCursor hides the terminal cursor.
+//
+// The changes can be committed to the underlying writer by calling the
+// [TerminalScreen.Flush] method.
+func (s *TerminalScreen) HideCursor() {
+ s.buf.WriteString(ansi.HideCursor)
+ if s.cursor != nil {
+ s.cursor.Hidden = true
+ }
+}
+
+// ShowCursor shows the terminal cursor.
+//
+// The changes can be committed to the underlying writer by calling the
+// [TerminalScreen.Flush] method.
+func (s *TerminalScreen) ShowCursor() {
+ s.buf.WriteString(ansi.ShowCursor)
+ if s.cursor != nil {
+ s.cursor.Hidden = false
+ } else {
+ s.cursor = NewCursor(-1, -1)
+ }
+}
+
+// CursorVisible returns whether the terminal cursor is currently visible.
+func (s *TerminalScreen) CursorVisible() bool {
+ return s.cursor != nil && !s.cursor.Hidden
+}
+
+// SetCursorPosition sets the position of the terminal cursor to the specified
+// coordinates.
+//
+// The changes can be committed to the underlying writer by calling the
+// [TerminalScreen.Flush] method.
+func (s *TerminalScreen) SetCursorPosition(x, y int) {
+ if s.cursor == nil {
+ s.cursor = NewCursor(x, y)
+ s.cursor.Hidden = true
+ } else {
+ s.cursor.X = x
+ s.cursor.Y = y
+ }
+}
+
+// CursorPosition returns the last set cursor position of the terminal. If the
+// cursor position is not set, it returns (-1, -1).
+//
+// This can be affected by [TerminalScreen.Render] and
+// [TerminalScreen.SetCursorPosition] calls.
+func (s *TerminalScreen) CursorPosition() (x, y int) {
+ if s.cursor != nil {
+ return s.cursor.X, s.cursor.Y
+ }
+ return -1, -1
+}
+
+// SetCursorStyle sets the style of the terminal cursor.
+//
+// The changes can be committed to the underlying writer by calling the
+// [TerminalScreen.Flush] method.
+func (s *TerminalScreen) SetCursorStyle(shape CursorShape, blink bool) {
+ EncodeCursorStyle(s.buf, shape, blink)
+ if s.cursor == nil {
+ s.cursor = NewCursor(-1, -1)
+ }
+ s.cursor.Shape = shape
+ s.cursor.Blink = blink
+}
+
+// CursorStyle returns the current style of the terminal cursor.
+func (s *TerminalScreen) CursorStyle() (shape CursorShape, blink bool) {
+ if s.cursor != nil {
+ return s.cursor.Shape, s.cursor.Blink
+ }
+ return CursorBlock, true
+}
+
+// SetCursorColor sets the color of the terminal cursor.
+//
+// The changes can be committed to the underlying writer by calling the
+// [TerminalScreen.Flush] method.
+func (s *TerminalScreen) SetCursorColor(c color.Color) {
+ EncodeCursorColor(s.buf, c)
+ if s.cursor == nil {
+ s.cursor = NewCursor(-1, -1)
+ }
+ s.cursor.Color = c
+}
+
+// CursorColor returns the current color of the terminal cursor.
+//
+// A nil color indicates that the cursor color is the default terminal cursor
+// color.
+func (s *TerminalScreen) CursorColor() color.Color {
+ if s.cursor != nil {
+ return s.cursor.Color
+ }
+ return nil
+}
+
+// SetBackgroundColor sets the background color of the terminal.
+//
+// The changes can be committed to the underlying writer by calling the
+// [TerminalScreen.Flush] method.
+func (s *TerminalScreen) SetBackgroundColor(c color.Color) {
+ EncodeBackgroundColor(s.buf, c)
+ s.backgroundColor = c
+}
+
+// BackgroundColor returns the current background color of the terminal.
+//
+// A nil color indicates that the background color is the default terminal
+// background color.
+func (s *TerminalScreen) BackgroundColor() color.Color {
+ return s.backgroundColor
+}
+
+// SetForegroundColor sets the foreground color of the terminal.
+//
+// The changes can be committed to the underlying writer by calling the
+// [TerminalScreen.Flush] method.
+func (s *TerminalScreen) SetForegroundColor(c color.Color) {
+ EncodeForegroundColor(s.buf, c)
+ s.foregroundColor = c
+}
+
+// ForegroundColor returns the current foreground color of the terminal.
+//
+// A nil color indicates that the foreground color is the default terminal
+// foreground color.
+func (s *TerminalScreen) ForegroundColor() color.Color {
+ return s.foregroundColor
+}
+
+// EnableBracketedPaste enables bracketed paste mode, allowing the terminal to
+// distinguish between pasted content and user input.
+//
+// The changes can be committed to the underlying writer by calling the
+// [TerminalScreen.Flush] method.
+func (s *TerminalScreen) EnableBracketedPaste() {
+ s.buf.WriteString(ansi.SetModeBracketedPaste)
+ s.bracketedPaste = true
+}
+
+// DisableBracketedPaste disables bracketed paste mode.
+//
+// The changes can be committed to the underlying writer by calling the
+// [TerminalScreen.Flush] method.
+func (s *TerminalScreen) DisableBracketedPaste() {
+ s.buf.WriteString(ansi.ResetModeBracketedPaste)
+ s.bracketedPaste = false
+}
+
+// BracketedPaste returns whether bracketed paste mode is currently enabled.
+func (s *TerminalScreen) BracketedPaste() bool {
+ return s.bracketedPaste
+}
+
+// SetSynchronizedUpdates sets whether to use synchronized updates (mode 2026),
+// which allows applications to batch updates to the terminal screen and flush
+// them all at once for improved performance.
+//
+// The changes can be committed to the underlying writer by calling the
+// [TerminalScreen.Flush] method.
+func (s *TerminalScreen) SetSynchronizedUpdates(enabled bool) {
+ s.syncUpdates = enabled
+}
+
+// SynchronizedUpdates returns whether synchronized updates (mode 2026) are
+// currently enabled.
+func (s *TerminalScreen) SynchronizedUpdates() bool {
+ return s.syncUpdates
+}
+
+// SetMouseMode sets the mouse tracking mode for the terminal, allowing
+// applications to receive mouse events.
+//
+// The changes can be committed to the underlying writer by calling the
+// [TerminalScreen.Flush] method.
+func (s *TerminalScreen) SetMouseMode(mode MouseMode) {
+ EncodeMouseMode(s.buf, mode)
+ s.mouseMode = mode
+}
+
+// MouseMode returns the current mouse tracking mode of the terminal.
+func (s *TerminalScreen) MouseMode() MouseMode {
+ return s.mouseMode
+}
+
+// SetMouseEncoding sets the mouse encoding for the terminal.
+// The encoding determines how mouse coordinates and buttons are reported.
+// This is only meaningful when mouse tracking is enabled via [TerminalScreen.SetMouseMode].
+//
+// The changes can be committed to the underlying writer by calling the
+// [TerminalScreen.Flush] method.
+func (s *TerminalScreen) SetMouseEncoding(enc MouseEncoding) {
+ EncodeMouseEncoding(s.buf, enc)
+ s.mouseEncoding = enc
+}
+
+// MouseEncoding returns the current mouse encoding of the terminal.
+func (s *TerminalScreen) MouseEncoding() MouseEncoding {
+ return s.mouseEncoding
+}
+
+// SetWindowTitle sets the title of the terminal window.
+//
+// The changes can be committed to the underlying writer by calling the
+// [TerminalScreen.Flush] method.
+func (s *TerminalScreen) SetWindowTitle(title string) {
+ EncodeWindowTitle(s.buf, title)
+ s.windowTitle = title
+}
+
+// WindowTitle returns the current title of the terminal window.
+func (s *TerminalScreen) WindowTitle() string {
+ return s.windowTitle
+}
+
+// SetKeyboardEnhancements sets the keyboard enhancements for the terminal,
+// allowing applications to receive enhanced keyboard input.
+//
+// The changes can be committed to the underlying writer by calling the
+// [TerminalScreen.Flush] method.
+func (s *TerminalScreen) SetKeyboardEnhancements(enh *KeyboardEnhancements) {
+ EncodeKeyboardEnhancements(s.buf, enh)
+ s.keyboardEnhancements = enh
+}
+
+// KeyboardEnhancements returns the current keyboard enhancements of the terminal.
+//
+// A nil value indicates that no keyboard enhancements are currently enabled.
+func (s *TerminalScreen) KeyboardEnhancements() *KeyboardEnhancements {
+ return s.keyboardEnhancements
+}
+
+// SetProgressBar sets the progress bar for the terminal, allowing applications
+// to display progress information.
+//
+// The changes can be committed to the underlying writer by calling the
+// [TerminalScreen.Flush] method.
+func (s *TerminalScreen) SetProgressBar(pb *ProgressBar) {
+ EncodeProgressBar(s.buf, pb)
+ s.progressBar = pb
+}
+
+// ProgressBar returns the current progress bar of the terminal.
+//
+// A nil value indicates that no progress bar is currently set.
+func (s *TerminalScreen) ProgressBar() *ProgressBar {
+ return s.progressBar
+}
+
+// Reset resets the terminal screen to its default state, clearing the screen,
+// switching back to the main screen buffer if necessary, and resetting all
+// terminal settings to their defaults.
+//
+// The changes can be committed to the underlying writer by calling the
+// [TerminalScreen.Flush] method.
+func (s *TerminalScreen) Reset() {
+ var sb strings.Builder
+
+ hasKeyboardEnhancements := s.keyboardEnhancements != nil
+
+ if s.altScreen {
+ if hasKeyboardEnhancements {
+ sb.WriteString(ansi.KittyKeyboard(0, 1))
+ }
+ sb.WriteString(ansi.ResetModeAltScreenSaveCursor)
+ }
+ if hasKeyboardEnhancements {
+ sb.WriteString(ansi.KittyKeyboard(0, 1))
+ }
+ if s.mouseMode != MouseModeNone {
+ EncodeMouseMode(&sb, MouseModeNone)
+ }
+ if s.mouseEncoding != MouseEncodingLegacy {
+ EncodeMouseEncoding(&sb, MouseEncodingLegacy)
+ }
+
+ if s.cursor == nil || !s.cursor.Hidden {
+ sb.WriteString(ansi.ShowCursor)
+ }
+ if s.cursor != nil {
+ if s.cursor.Shape != CursorBlock || !s.cursor.Blink {
+ sb.WriteString(ansi.SetCursorStyle(0))
+ }
+ if s.cursor.Color != nil {
+ sb.WriteString(ansi.ResetCursorColor)
+ }
+ }
+ if s.backgroundColor != nil {
+ sb.WriteString(ansi.ResetBackgroundColor)
+ }
+ if s.foregroundColor != nil {
+ sb.WriteString(ansi.ResetForegroundColor)
+ }
+ if s.bracketedPaste {
+ sb.WriteString(ansi.ResetModeBracketedPaste)
+ }
+ if s.windowTitle != "" {
+ sb.WriteString(ansi.SetWindowTitle(""))
+ }
+ if s.progressBar != nil && s.progressBar.State != ProgressBarNone {
+ sb.WriteString(ansi.ResetProgressBar)
+ }
+
+ s.buf.WriteString(sb.String())
+
+ // Go to the bottom of the screen.
+ // We need to go to the bottom of the screen regardless of whether
+ // we're in alt screen mode or not to avoid leaving the cursor in the
+ // middle in terminals that don't support alt screen mode.
+ //
+ // This comes after resetting the screen state to ensure that moving the
+ // cursor is the last thing we do, preventing any unwanted cursor movements
+ // after resetting the screen.
+ //
+ // Note that both [TerminalScreen.rend] writes to [TerminalScreen.buf].
+ s.rend.MoveTo(0, s.win.Height()-1)
+}
+
+// Restore restores the terminal screen to its previous state, applying any
+// previous settings and state that were reset by the [TerminalScreen.Reset] method.
+//
+// The changes can be committed to the underlying writer by calling the
+// [TerminalScreen.Flush] method.
+func (s *TerminalScreen) Restore() {
+ var sb strings.Builder
+
+ if s.resetTabs {
+ sb.WriteString(ansi.SetTabEvery8Columns)
+ }
+ if s.altScreen {
+ sb.WriteString(ansi.SetModeAltScreenSaveCursor)
+ }
+ if s.cursor != nil && !s.cursor.Hidden {
+ sb.WriteString(ansi.ShowCursor)
+ } else {
+ // Hide the cursor by default.
+ sb.WriteString(ansi.HideCursor)
+ }
+ if s.keyboardEnhancements != nil {
+ EncodeKeyboardEnhancements(&sb, s.keyboardEnhancements)
+ }
+ if s.mouseMode != MouseModeNone {
+ EncodeMouseMode(&sb, s.mouseMode)
+ }
+ if s.mouseEncoding != MouseEncodingLegacy {
+ EncodeMouseEncoding(&sb, s.mouseEncoding)
+ }
+ if s.cursor != nil {
+ if s.cursor.Shape != CursorBlock || !s.cursor.Blink {
+ EncodeCursorStyle(&sb, s.cursor.Shape, s.cursor.Blink)
+ }
+ if s.cursor.Color != nil {
+ EncodeCursorColor(&sb, s.cursor.Color)
+ }
+ }
+ if s.backgroundColor != nil {
+ EncodeBackgroundColor(&sb, s.backgroundColor)
+ }
+ if s.foregroundColor != nil {
+ EncodeForegroundColor(&sb, s.foregroundColor)
+ }
+ if s.bracketedPaste {
+ sb.WriteString(ansi.SetModeBracketedPaste)
+ }
+ if s.windowTitle != "" {
+ EncodeWindowTitle(&sb, s.windowTitle)
+ }
+ if s.progressBar != nil && s.progressBar.State != ProgressBarNone {
+ EncodeProgressBar(&sb, s.progressBar)
+ }
+
+ s.buf.WriteString(sb.String())
+
+ // This needs to be called after restoring the screen state and writing to
+ // the buffer.
+ //
+ // [TerminalScreen.Render] will write to [TerminalScreen.buf], so we need
+ // to call it after writing the restore commands to the buffer to ensure
+ // that the restore commands are included in the render output. This
+ // ensures that the screen is properly restored before rendering any
+ // changes.
+ s.Render()
+
+ // Cursor position will be restored by the caller after calling
+ // [TerminalScreen.Flush].
+}
+
+// Write writes data to the underlying buffer queuing it for output.
+//
+// The changes can be committed to the underlying writer by calling the
+// [TerminalScreen.Flush] method.
+func (s *TerminalScreen) Write(p []byte) (n int, err error) {
+ return s.buf.Write(p)
+}
+
+// WriteString writes a string to the underlying buffer queuing it for output.
+//
+// The changes can be committed to the underlying writer by calling the
+// [TerminalScreen.Flush] method.
+func (s *TerminalScreen) WriteString(str string) (n int, err error) {
+ return s.buf.WriteString(str)
+}
+
+// InsertAbove inserts content above the screen pushing the current content
+// down.
+//
+// This is useful for inserting content above the current screen content
+// without affecting the current cursor position or screen state.
+//
+// Note that this won't have any visible effect if the screen is in alt screen
+// mode, as the content will be inserted above the alt screen buffer, which is
+// not visible. However, if the screen is in inline mode, the content will be
+// inserted above and will not be managed by the renderer.
+//
+// Unlike other methods that modify the screen state, this method writes
+// directly to the underlying writer, so there is no need to call
+// [TerminalScreen.Flush] after calling this method.
+func (s *TerminalScreen) InsertAbove(content string) error {
+ if len(content) == 0 {
+ return nil
+ }
+
+ var sb strings.Builder
+ w, h := s.win.Width(), s.win.Height()
+ _, y := s.rend.Position()
+
+ // We need to scroll the screen up by the number of lines in the queue.
+ sb.WriteByte('\r')
+ down := h - y - 1
+ if down > 0 {
+ sb.WriteString(ansi.CursorDown(down))
+ }
+
+ lines := strings.Split(content, "\n")
+ offset := len(lines)
+ for _, line := range lines {
+ lineWidth := s.win.WidthMethod().StringWidth(line)
+ if w > 0 && lineWidth > w {
+ offset += (lineWidth / w)
+ }
+ }
+
+ // Scroll the screen up by the offset to make room for the new lines.
+ sb.WriteString(strings.Repeat("\n", offset))
+
+ // XXX: Now go to the top of the screen, insert new lines, and write
+ // the queued strings. It is important to use [Screen.moveCursor]
+ // instead of [Screen.move] because we don't want to perform any checks
+ // on the cursor position.
+ up := offset + h - 1
+ sb.WriteString(ansi.CursorUp(up))
+ sb.WriteString(ansi.InsertLine(offset))
+ for _, line := range lines {
+ sb.WriteString(line)
+ sb.WriteString(ansi.EraseLineRight)
+ sb.WriteString("\r\n")
+ }
+
+ s.rend.SetPosition(0, 0)
+
+ _, err := io.WriteString(s.w, sb.String())
+ return err
+}
diff --git a/vendor/github.com/charmbracelet/ultraviolet/terminal_tabdly.go b/vendor/github.com/charmbracelet/ultraviolet/terminal_tabdly.go
new file mode 100644
index 0000000000..52c47a225b
--- /dev/null
+++ b/vendor/github.com/charmbracelet/ultraviolet/terminal_tabdly.go
@@ -0,0 +1,10 @@
+//go:build darwin || linux || freebsd || solaris || aix
+// +build darwin linux freebsd solaris aix
+
+package uv
+
+import "golang.org/x/sys/unix"
+
+func supportsHardTabs(oflag uint64) bool {
+ return oflag&unix.TABDLY == unix.TAB0
+}
diff --git a/vendor/github.com/charmbracelet/ultraviolet/terminal_tabdly_other.go b/vendor/github.com/charmbracelet/ultraviolet/terminal_tabdly_other.go
new file mode 100644
index 0000000000..30b1914c60
--- /dev/null
+++ b/vendor/github.com/charmbracelet/ultraviolet/terminal_tabdly_other.go
@@ -0,0 +1,8 @@
+//go:build !darwin && !linux && !freebsd && !solaris && !aix && !windows
+// +build !darwin,!linux,!freebsd,!solaris,!aix,!windows
+
+package uv
+
+func supportsHardTabs(uint64) bool {
+ return false
+}
diff --git a/vendor/github.com/charmbracelet/ultraviolet/terminal_unix.go b/vendor/github.com/charmbracelet/ultraviolet/terminal_unix.go
new file mode 100644
index 0000000000..04ed3e3f61
--- /dev/null
+++ b/vendor/github.com/charmbracelet/ultraviolet/terminal_unix.go
@@ -0,0 +1,56 @@
+//go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || aix
+// +build darwin dragonfly freebsd linux netbsd openbsd solaris aix
+
+package uv
+
+import (
+ "github.com/charmbracelet/x/term"
+ "github.com/charmbracelet/x/termios"
+)
+
+func makeRaw(inTty, outTty term.File) (inTtyState, outTtyState *term.State, err error) {
+ if inTty == nil && outTty == nil {
+ return nil, nil, ErrNotTerminal
+ }
+
+ // Check if we have a terminal.
+ for _, f := range []term.File{inTty, outTty} {
+ if f == nil {
+ continue
+ }
+ inTtyState, err = term.MakeRaw(f.Fd())
+ if err == nil {
+ break
+ }
+ }
+
+ if err != nil {
+ return nil, nil, err //nolint:wrapcheck
+ }
+
+ return inTtyState, outTtyState, nil
+}
+
+func getWinsize(inTty, outTty term.File) (ws Winsize, err error) {
+ // Try both inTty and outTty to get the size.
+ err = ErrNotTerminal
+ for _, f := range []term.File{inTty, outTty} {
+ if f == nil {
+ continue
+ }
+ size, err := termios.GetWinsize(int(f.Fd()))
+ if err == nil {
+ return Winsize(*size), nil
+ }
+ }
+ return
+}
+
+func getSize(inTty, outTty term.File) (w, h int, err error) {
+ ws, err := getWinsize(inTty, outTty)
+ return int(ws.Col), int(ws.Row), err
+}
+
+func optimizeMovements(state *term.State) (useTabs, useBspace bool) {
+ return supportsHardTabs(uint64(state.Oflag)), supportsBackspace(uint64(state.Lflag)) //nolint:unconvert,nolintlint
+}
diff --git a/vendor/github.com/charmbracelet/ultraviolet/terminal_windows.go b/vendor/github.com/charmbracelet/ultraviolet/terminal_windows.go
new file mode 100644
index 0000000000..a899ba4868
--- /dev/null
+++ b/vendor/github.com/charmbracelet/ultraviolet/terminal_windows.go
@@ -0,0 +1,77 @@
+//go:build windows
+// +build windows
+
+package uv
+
+import (
+ "fmt"
+
+ "github.com/charmbracelet/x/term"
+ "golang.org/x/sys/windows"
+)
+
+func makeRaw(inTty, outTty term.File) (inTtyState, outTtyState *term.State, err error) {
+ if inTty == nil || outTty == nil || !term.IsTerminal(inTty.Fd()) || !term.IsTerminal(outTty.Fd()) {
+ return nil, nil, ErrNotTerminal
+ }
+
+ // Save stdin state and enable VT inpu
+ // We also need to enable VT input here.
+ inTtyState, err = term.MakeRaw(inTty.Fd())
+ if err != nil {
+ return nil, nil, fmt.Errorf("error making terminal raw: %w", err)
+ }
+
+ // Enable VT input
+ var imode uint32
+ if err := windows.GetConsoleMode(windows.Handle(inTty.Fd()), &imode); err != nil {
+ return nil, nil, fmt.Errorf("error getting console mode: %w", err)
+ }
+
+ if err := windows.SetConsoleMode(windows.Handle(inTty.Fd()), imode|windows.ENABLE_VIRTUAL_TERMINAL_INPUT); err != nil {
+ return nil, nil, fmt.Errorf("error setting console mode: %w", err)
+ }
+
+ // Save output screen buffer state and enable VT processing.
+ outTtyState, err = term.GetState(outTty.Fd())
+ if err != nil {
+ return nil, nil, fmt.Errorf("error getting terminal state: %w", err)
+ }
+
+ var omode uint32
+ if err := windows.GetConsoleMode(windows.Handle(outTty.Fd()), &omode); err != nil {
+ return nil, nil, fmt.Errorf("error getting console mode: %w", err)
+ }
+
+ if err := windows.SetConsoleMode(windows.Handle(outTty.Fd()),
+ omode|windows.ENABLE_VIRTUAL_TERMINAL_PROCESSING|
+ windows.DISABLE_NEWLINE_AUTO_RETURN); err != nil {
+ return nil, nil, fmt.Errorf("error setting console mode: %w", err)
+ }
+
+ return inTtyState, outTtyState, nil
+}
+
+func getSize(_, outTty term.File) (w, h int, err error) {
+ if outTty != nil {
+ return term.GetSize(outTty.Fd()) //nolint:wrapcheck
+ }
+ return 0, 0, ErrNotTerminal
+}
+
+func getWinsize(inTty, outTty term.File) (ws Winsize, err error) {
+ w, h, err := getSize(inTty, outTty)
+ return Winsize{Col: uint16(w), Row: uint16(h)}, err
+}
+
+func optimizeMovements(*term.State) (useTabs, useBspace bool) {
+ return supportsBackspace(0), supportsHardTabs(0)
+}
+
+func supportsBackspace(uint64) bool {
+ return true
+}
+
+func supportsHardTabs(uint64) bool {
+ return true
+}
diff --git a/vendor/github.com/charmbracelet/ultraviolet/tty.go b/vendor/github.com/charmbracelet/ultraviolet/tty.go
new file mode 100644
index 0000000000..7e7bd99458
--- /dev/null
+++ b/vendor/github.com/charmbracelet/ultraviolet/tty.go
@@ -0,0 +1,42 @@
+package uv
+
+import (
+ "context"
+ "os"
+)
+
+// OpenTTY opens the terminal's input and output file descriptors.
+// It returns the input and output files, or an error if the terminal is not
+// available.
+//
+// This is useful for applications that need to interact with the terminal
+// directly while piping or redirecting input/output.
+func OpenTTY() (inTty, outTty *os.File, err error) {
+ return openTTY()
+}
+
+// Suspend suspends the current process group.
+func Suspend() error {
+ return suspend()
+}
+
+// NotifyWinch sets up a channel to receive window size change signals and any
+// other signals needed. This is a drop-in replacement for os/signal.Notify to
+// ensure that SIGWINCH is included.
+//
+// On Windows, this will be a no-op for SIGWINCH, but other signals may still
+// be handled.
+func NotifyWinch(c chan os.Signal, sigs ...os.Signal) {
+ notifyWinch(c, sigs...)
+}
+
+// NotifyWinchContext sets up a channel to receive window size change signals
+// and any other signals needed, with context cancellation support. This is a
+// drop-in replacement for os/signal.NotifyContext to ensure that SIGWINCH is
+// included.
+//
+// On Windows, this will be a no-op for SIGWINCH, but other signals may still
+// be handled.
+func NotifyWinchContext(ctx context.Context, sigs ...os.Signal) (context.Context, context.CancelFunc) {
+ return notifyWinchContext(ctx, sigs...)
+}
diff --git a/vendor/github.com/charmbracelet/ultraviolet/tty_other.go b/vendor/github.com/charmbracelet/ultraviolet/tty_other.go
new file mode 100644
index 0000000000..c4c986ce98
--- /dev/null
+++ b/vendor/github.com/charmbracelet/ultraviolet/tty_other.go
@@ -0,0 +1,26 @@
+//go:build !darwin && !dragonfly && !freebsd && !linux && !netbsd && !openbsd && !solaris && !aix && !windows
+// +build !darwin,!dragonfly,!freebsd,!linux,!netbsd,!openbsd,!solaris,!aix,!windows
+
+package uv
+
+import (
+ "context"
+ "os"
+ "os/signal"
+)
+
+func openTTY() (*os.File, *os.File, error) {
+ return nil, nil, ErrPlatformNotSupported
+}
+
+func suspend() error {
+ return ErrPlatformNotSupported
+}
+
+func notifyWinch(c chan os.Signal, sigs ...os.Signal) {
+ signal.Notify(c, sigs...)
+}
+
+func notifyWinchContext(ctx context.Context, sigs ...os.Signal) (context.Context, context.CancelFunc) {
+ return signal.NotifyContext(ctx, sigs...)
+}
diff --git a/vendor/github.com/charmbracelet/ultraviolet/tty_unix.go b/vendor/github.com/charmbracelet/ultraviolet/tty_unix.go
new file mode 100644
index 0000000000..328552cb18
--- /dev/null
+++ b/vendor/github.com/charmbracelet/ultraviolet/tty_unix.go
@@ -0,0 +1,39 @@
+//go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || aix
+// +build darwin dragonfly freebsd linux netbsd openbsd solaris aix
+
+package uv
+
+import (
+ "context"
+ "os"
+ "os/signal"
+ "syscall"
+
+ "golang.org/x/sys/unix"
+)
+
+func openTTY() (inTty, outTty *os.File, err error) {
+ f, err := os.OpenFile("/dev/tty", os.O_RDWR, 0)
+ if err != nil {
+ return nil, nil, err //nolint:wrapcheck
+ }
+ return f, f, nil
+}
+
+func suspend() (err error) {
+ // Send SIGTSTP to the entire process group.
+ c := make(chan os.Signal, 1)
+ signal.Notify(c, syscall.SIGCONT)
+ err = syscall.Kill(0, syscall.SIGTSTP)
+ // blocks until a CONT happens...
+ <-c
+ return
+}
+
+func notifyWinch(c chan os.Signal, sigs ...os.Signal) {
+ signal.Notify(c, append(sigs, unix.SIGWINCH)...)
+}
+
+func notifyWinchContext(ctx context.Context, sigs ...os.Signal) (context.Context, context.CancelFunc) {
+ return signal.NotifyContext(ctx, append(sigs, unix.SIGWINCH)...)
+}
diff --git a/vendor/github.com/charmbracelet/ultraviolet/tty_windows.go b/vendor/github.com/charmbracelet/ultraviolet/tty_windows.go
new file mode 100644
index 0000000000..4ad0ecb802
--- /dev/null
+++ b/vendor/github.com/charmbracelet/ultraviolet/tty_windows.go
@@ -0,0 +1,39 @@
+//go:build windows
+// +build windows
+
+package uv
+
+import (
+ "context"
+ "os"
+ "os/signal"
+)
+
+func openTTY() (inTty, outTty *os.File, err error) {
+ // On Windows, when the input/output is redirected or piped, we need to
+ // open the console explicitly.
+ // See https://learn.microsoft.com/en-us/windows/console/getstdhandle#remarks
+ inTty, err = os.OpenFile("CONIN$", os.O_RDWR, 0o644) //nolint:gosec
+ if err != nil {
+ return nil, nil, err //nolint:wrapcheck
+ }
+ outTty, err = os.OpenFile("CONOUT$", os.O_RDWR, 0o644) //nolint:gosec
+ if err != nil {
+ return nil, nil, err //nolint:wrapcheck
+ }
+ return inTty, outTty, nil
+}
+
+func suspend() (err error) {
+ // On Windows, suspending the process group is not supported in the same
+ // way as Unix-like systems.
+ return nil
+}
+
+func notifyWinch(c chan os.Signal, sigs ...os.Signal) {
+ signal.Notify(c, sigs...)
+}
+
+func notifyWinchContext(ctx context.Context, sigs ...os.Signal) (context.Context, context.CancelFunc) {
+ return signal.NotifyContext(ctx, sigs...)
+}
diff --git a/vendor/github.com/charmbracelet/ultraviolet/utils.go b/vendor/github.com/charmbracelet/ultraviolet/utils.go
new file mode 100644
index 0000000000..6616ebc97b
--- /dev/null
+++ b/vendor/github.com/charmbracelet/ultraviolet/utils.go
@@ -0,0 +1,15 @@
+package uv
+
+func abs(x int) int {
+ if x < 0 {
+ return -x
+ }
+ return x
+}
+
+func clamp(v, low, high int) int {
+ if high < low {
+ low, high = high, low
+ }
+ return min(high, max(low, v))
+}
diff --git a/vendor/github.com/charmbracelet/ultraviolet/uv.go b/vendor/github.com/charmbracelet/ultraviolet/uv.go
new file mode 100644
index 0000000000..dac088a9c8
--- /dev/null
+++ b/vendor/github.com/charmbracelet/ultraviolet/uv.go
@@ -0,0 +1,406 @@
+package uv
+
+import (
+ "fmt"
+ "image/color"
+ "io"
+
+ "github.com/charmbracelet/x/ansi"
+ "github.com/lucasb-eyer/go-colorful"
+)
+
+var (
+ // ErrNotTerminal is an error that indicates that the file is not a terminal.
+ ErrNotTerminal = fmt.Errorf("not a terminal")
+ // ErrPlatformNotSupported is an error that indicates that the platform is not supported.
+ ErrPlatformNotSupported = fmt.Errorf("platform not supported")
+)
+
+// Drawable represents a drawable component on a [Screen].
+type Drawable interface {
+ // Draw renders the component on the screen for the given area.
+ Draw(scr Screen, area Rectangle)
+}
+
+// DrawableFunc is a function that implements the [Drawable] interface.
+type DrawableFunc func(scr Screen, rect Rectangle)
+
+var _ Drawable = (DrawableFunc)(nil)
+
+// Draw implements the [Drawable] interface.
+func (f DrawableFunc) Draw(scr Screen, rect Rectangle) {
+ f(scr, rect)
+}
+
+// WidthMethod determines how many columns a grapheme occupies on the screen.
+type WidthMethod interface {
+ StringWidth(s string) int
+}
+
+// Screen represents a screen that can be drawn to.
+type Screen interface {
+ // Bounds returns the bounds of the screen. This is the rectangle that
+ // includes the start and end points of the screen.
+ Bounds() Rectangle
+
+ // CellAt returns the cell at the given position. If the position is out of
+ // bounds, it returns nil. Otherwise, it always returns a cell, even if it
+ // is empty (i.e., a cell with a space character and a width of 1).
+ CellAt(x, y int) *Cell
+
+ // SetCell sets the cell at the given position. A nil cell is treated as an
+ // empty cell with a space character and a width of 1.
+ SetCell(x, y int, c *Cell)
+
+ // WidthMethod returns the width method used by the screen.
+ WidthMethod() WidthMethod
+}
+
+// Cursor represents a cursor on the terminal screen.
+type Cursor struct {
+ // Position is a [Position] that determines the cursor's position on the
+ // screen relative to the top left corner of the frame.
+ Position
+
+ // Color is a [color.Color] that determines the cursor's color.
+ Color color.Color
+
+ // Shape is a [CursorShape] that determines the cursor's shape.
+ Shape CursorShape
+
+ // Blink is a boolean that determines whether the cursor should blink.
+ Blink bool
+
+ // Hidden is a boolean that determines whether the cursor is hidden. You
+ // can use this if you want to hide the cursor but still want to change its
+ // position.
+ Hidden bool
+}
+
+// NewCursor returns a new cursor with the default settings and the given
+// position.
+func NewCursor(x, y int) *Cursor {
+ return &Cursor{
+ Position: Position{X: x, Y: y},
+ Color: nil,
+ Shape: CursorBlock,
+ Blink: true,
+ }
+}
+
+// ProgressBarState represents the state of the progress bar.
+type ProgressBarState int
+
+// Progress bar states.
+const (
+ ProgressBarNone ProgressBarState = iota
+ ProgressBarDefault
+ ProgressBarError
+ ProgressBarIndeterminate
+ ProgressBarWarning
+)
+
+// String return a human-readable value for the given [ProgressBarState].
+func (s ProgressBarState) String() string {
+ return [...]string{
+ "None",
+ "Default",
+ "Error",
+ "Indeterminate",
+ "Warning",
+ }[s]
+}
+
+// ProgressBar represents the terminal progress bar.
+//
+// Support depends on the terminal.
+//
+// See https://learn.microsoft.com/en-us/windows/terminal/tutorials/progress-bar-sequences
+type ProgressBar struct {
+ // State is the current state of the progress bar. It can be one of
+ // [ProgressBarNone], [ProgressBarDefault], [ProgressBarError],
+ // [ProgressBarIndeterminate], and [ProgressBarWarning].
+ State ProgressBarState
+ // Value is the current value of the progress bar. It should be between
+ // 0 and 100.
+ Value int
+}
+
+// NewProgressBar returns a new progress bar with the given state and value.
+// The value is ignored if the state is [ProgressBarNone] or
+// [ProgressBarIndeterminate].
+func NewProgressBar(state ProgressBarState, value int) *ProgressBar {
+ return &ProgressBar{
+ State: state,
+ Value: min(max(value, 0), 100),
+ }
+}
+
+// KeyboardEnhancements defines different keyboard enhancement features that
+// can be requested from the terminal.
+type KeyboardEnhancements struct {
+ // DisambiguateEscapeCodes requests the terminal to report ambiguous keys
+ // such as Ctrl+i and Tab, and Ctrl+m and Enter, and others as distinct key
+ // code sequences.
+ // If supported, your program will receive distinct [KeyPressEvent]s for
+ // these keys.
+ DisambiguateEscapeCodes bool
+
+ // ReportEventTypes requests the terminal to report key repeat and release
+ // events.
+ // If supported, your program will receive [KeyReleaseEvent]s and
+ // [KeyPressEvent] with the [Key.IsRepeat] field set indicating that this
+ // is a it's part of a key repeat sequence.
+ ReportEventTypes bool
+
+ // ReportAlternateKeys requests the terminal to report alternate key values
+ // in addition to the main ones.
+ // Note that only key events represented as escape codes will affected by
+ // this enhancement.
+ ReportAlternateKeys bool
+
+ // ReportAllKeysAsEscapeCodes requests the terminal to report all key
+ // events, including plain text keys, as escape codes.
+ // When this is enabled, text won't be sent as plain text but instead as
+ // escape codes that encode the key value and modifiers.
+ ReportAllKeysAsEscapeCodes bool
+
+ // ReportAssociatedText requests the terminal to report the text associated
+ // with key events.
+ // Note that this is an enhancement to
+ // [KeyboardEnhancements.ReportAllKeysAsEscapeCodes] and only has an effect
+ // if that is enabled.
+ ReportAssociatedText bool
+}
+
+// NewKeyboardEnhancements returns a new [KeyboardEnhancements] with the given
+// options as flags.
+//
+// A zero, or negative, flags value is treated as no enhancements.
+//
+// See [ansi.KittyKeyboard] for more details on the supported keyboard enhancements.
+func NewKeyboardEnhancements(flags int) *KeyboardEnhancements {
+ if flags <= 0 {
+ return &KeyboardEnhancements{}
+ }
+
+ return &KeyboardEnhancements{
+ DisambiguateEscapeCodes: flags&ansi.KittyDisambiguateEscapeCodes != 0,
+ ReportEventTypes: flags&ansi.KittyReportEventTypes != 0,
+ }
+}
+
+// Flags returns the keyboard enhancements as bits that can be used to set the
+// appropriate terminal modes.
+func (ke KeyboardEnhancements) Flags() int {
+ bits := 0
+ if ke.DisambiguateEscapeCodes {
+ bits |= ansi.KittyDisambiguateEscapeCodes
+ }
+ if ke.ReportEventTypes {
+ bits |= ansi.KittyReportEventTypes
+ }
+ if ke.ReportAlternateKeys {
+ bits |= ansi.KittyReportAlternateKeys
+ }
+ if ke.ReportAllKeysAsEscapeCodes {
+ bits |= ansi.KittyReportAllKeysAsEscapeCodes
+ }
+ if ke.ReportAssociatedText {
+ bits |= ansi.KittyReportAssociatedKeys
+ }
+
+ return bits
+}
+
+// EncodeBackgroundColor encodes the background color to the given writer. Use
+// nil to reset the background color to the default.
+func EncodeBackgroundColor(w io.Writer, c color.Color) error {
+ var seq string
+ if c == nil {
+ seq = ansi.ResetBackgroundColor
+ } else if col, ok := colorful.MakeColor(c); ok {
+ seq = ansi.SetBackgroundColor(col.Hex())
+ } else {
+ return fmt.Errorf("invalid color: %v", c)
+ }
+
+ _, err := io.WriteString(w, seq)
+ if err != nil {
+ return fmt.Errorf("failed to set background color: %w", err)
+ }
+
+ return nil
+}
+
+// EncodeForegroundColor encodes the foreground color to the given writer. Use
+// nil to reset the foreground color to the default.
+func EncodeForegroundColor(w io.Writer, c color.Color) error {
+ var seq string
+ if c == nil {
+ seq = ansi.ResetForegroundColor
+ } else if col, ok := colorful.MakeColor(c); ok {
+ seq = ansi.SetForegroundColor(col.Hex())
+ } else {
+ return fmt.Errorf("invalid color: %v", c)
+ }
+
+ _, err := io.WriteString(w, seq)
+ if err != nil {
+ return fmt.Errorf("failed to set foreground color: %w", err)
+ }
+
+ return nil
+}
+
+// EncodeCursorColor encodes the cursor color to the given writer. Use nil to
+// reset the cursor color to the default.
+func EncodeCursorColor(w io.Writer, c color.Color) error {
+ var seq string
+ if c == nil {
+ seq = ansi.ResetCursorColor
+ } else if col, ok := colorful.MakeColor(c); ok {
+ seq = ansi.SetCursorColor(col.Hex())
+ } else {
+ return fmt.Errorf("invalid color: %v", c)
+ }
+
+ _, err := io.WriteString(w, seq)
+ if err != nil {
+ return fmt.Errorf("failed to set cursor color: %w", err)
+ }
+
+ return nil
+}
+
+// EncodeCursorStyle encodes the cursor style to the given writer.
+func EncodeCursorStyle(w io.Writer, shape CursorShape, blink bool) error {
+ seq := ansi.SetCursorStyle(shape.Encode(blink))
+ _, err := io.WriteString(w, seq)
+ if err != nil {
+ return fmt.Errorf("failed to set cursor style: %w", err)
+ }
+
+ return nil
+}
+
+// EncodeBracketedPaste encodes the bracketed paste mode to the given writer.
+func EncodeBracketedPaste(w io.Writer, enable bool) error {
+ var seq string
+ if enable {
+ seq = ansi.SetModeBracketedPaste
+ } else {
+ seq = ansi.ResetModeBracketedPaste
+ }
+
+ _, err := io.WriteString(w, seq)
+ if err != nil {
+ return fmt.Errorf("failed to set bracketed paste mode: %w", err)
+ }
+
+ return nil
+}
+
+// EncodeMouseMode encodes the mouse tracking mode to the given writer.
+func EncodeMouseMode(w io.Writer, mode MouseMode) error {
+ var seq string
+ switch mode {
+ case MouseModeNone:
+ seq = ansi.ResetModeMouseX10 +
+ ansi.ResetModeMouseNormal +
+ ansi.ResetModeMouseButtonEvent +
+ ansi.ResetModeMouseAnyEvent
+ case MouseModePress:
+ seq = ansi.SetModeMouseX10
+ case MouseModeClick:
+ seq = ansi.SetModeMouseNormal
+ case MouseModeDrag:
+ seq = ansi.SetModeMouseButtonEvent
+ case MouseModeMotion:
+ seq = ansi.SetModeMouseAnyEvent
+ }
+
+ _, err := io.WriteString(w, seq) //nolint:errcheck
+ if err != nil {
+ return fmt.Errorf("failed to set mouse mode: %w", err)
+ }
+
+ return nil
+}
+
+// EncodeMouseEncoding encodes the mouse encoding mode to the given writer.
+// When enc is [MouseEncodingLegacy], all extended encodings are reset.
+func EncodeMouseEncoding(w io.Writer, enc MouseEncoding) error {
+ var seq string
+ switch enc {
+ case MouseEncodingLegacy:
+ seq = ansi.ResetModeMouseExtSgr +
+ ansi.ResetModeMouseExtUrxvt +
+ ansi.ResetModeMouseExtSgrPixel
+ case MouseEncodingSGR:
+ seq = ansi.SetModeMouseExtSgr
+ case MouseEncodingSGRPixel:
+ seq = ansi.SetModeMouseExtSgrPixel
+ }
+
+ _, err := io.WriteString(w, seq) //nolint:errcheck
+ if err != nil {
+ return fmt.Errorf("failed to set mouse encoding: %w", err)
+ }
+
+ return nil
+}
+
+// EncodeProgressBar encodes the progress bar to the given writer.
+func EncodeProgressBar(w io.Writer, pb *ProgressBar) error {
+ if pb == nil {
+ pb = &ProgressBar{State: ProgressBarNone}
+ }
+
+ var seq string
+ percent := clamp(pb.Value, 0, 100)
+ switch pb.State {
+ case ProgressBarNone:
+ seq = ansi.ResetProgressBar
+ case ProgressBarDefault:
+ seq = ansi.SetProgressBar(percent)
+ case ProgressBarError:
+ seq = ansi.SetErrorProgressBar(percent)
+ case ProgressBarIndeterminate:
+ seq = ansi.SetIndeterminateProgressBar
+ case ProgressBarWarning:
+ seq = ansi.SetWarningProgressBar(percent)
+ default:
+ return fmt.Errorf("invalid progress bar state: %d", pb.State)
+ }
+
+ _, err := io.WriteString(w, seq)
+ if err != nil {
+ return fmt.Errorf("failed to set progress bar: %w", err)
+ }
+
+ return nil
+}
+
+// EncodeKeyboardEnhancements encodes the keyboard enhancements to the given
+// writer.
+func EncodeKeyboardEnhancements(w io.Writer, ke *KeyboardEnhancements) error {
+ var flags int
+ if ke != nil {
+ flags = ke.Flags()
+ }
+ _, err := io.WriteString(w, ansi.KittyKeyboard(flags, 1))
+ if err != nil {
+ return fmt.Errorf("failed to set keyboard enhancements: %w", err)
+ }
+ return nil
+}
+
+// EncodeWindowTitle encodes the window title to the given writer.
+func EncodeWindowTitle(w io.Writer, title string) error {
+ _, err := io.WriteString(w, ansi.SetWindowTitle(title))
+ if err != nil {
+ return fmt.Errorf("failed to set window title: %w", err)
+ }
+ return nil
+}
diff --git a/vendor/github.com/charmbracelet/ultraviolet/winch.go b/vendor/github.com/charmbracelet/ultraviolet/winch.go
new file mode 100644
index 0000000000..77533f1cdf
--- /dev/null
+++ b/vendor/github.com/charmbracelet/ultraviolet/winch.go
@@ -0,0 +1,62 @@
+package uv
+
+import (
+ "os"
+ "sync"
+
+ "github.com/charmbracelet/x/term"
+)
+
+// SizeNotifier represents a notifier that listens for window size
+// changes using the SIGWINCH signal and notifies the given channel.
+type SizeNotifier struct {
+ // Channel that receives terminal size change notifications.
+ C <-chan os.Signal
+
+ f term.File
+ sig chan os.Signal
+ m sync.Mutex
+}
+
+// NewSizeNotifier creates a new [SizeNotifier] that listens for window size
+// changes on the given TTY file through SIGWINCH signals.
+func NewSizeNotifier(f term.File) *SizeNotifier {
+ if f == nil {
+ panic("no file set")
+ }
+ sig := make(chan os.Signal)
+ return &SizeNotifier{
+ f: f,
+ sig: sig,
+ C: sig,
+ }
+}
+
+// Start starts listening for window size changes and notifies [SizeNotifier.C]
+// about any changes.
+func (n *SizeNotifier) Start() error {
+ return n.start()
+}
+
+// Stop stops the notifier and cleans up resources.
+func (n *SizeNotifier) Stop() error {
+ return n.stop()
+}
+
+// GetWindowSize returns the current size of the terminal window.
+func (n *SizeNotifier) GetWindowSize() (cells Size, pixels Size, err error) {
+ return n.getWindowSize()
+}
+
+// GetSize returns the current cell size of the terminal window.
+func (n *SizeNotifier) GetSize() (width, height int, err error) {
+ n.m.Lock()
+ defer n.m.Unlock()
+
+ width, height, err = term.GetSize(n.f.Fd())
+ if err != nil {
+ return 0, 0, err //nolint:wrapcheck
+ }
+
+ return width, height, nil
+}
diff --git a/vendor/github.com/charmbracelet/ultraviolet/winch_other.go b/vendor/github.com/charmbracelet/ultraviolet/winch_other.go
new file mode 100644
index 0000000000..8022687805
--- /dev/null
+++ b/vendor/github.com/charmbracelet/ultraviolet/winch_other.go
@@ -0,0 +1,17 @@
+//go:build !darwin && !dragonfly && !freebsd && !linux && !netbsd && !openbsd && !solaris
+// +build !darwin,!dragonfly,!freebsd,!linux,!netbsd,!openbsd,!solaris
+
+package uv
+
+func (n *SizeNotifier) start() error {
+ return ErrPlatformNotSupported
+}
+
+func (n *SizeNotifier) stop() error {
+ return ErrPlatformNotSupported
+}
+
+func (n *SizeNotifier) getWindowSize() (cells Size, pixels Size, err error) {
+ cells.Width, cells.Height, err = n.GetSize()
+ return cells, pixels, err
+}
diff --git a/vendor/github.com/charmbracelet/ultraviolet/winch_unix.go b/vendor/github.com/charmbracelet/ultraviolet/winch_unix.go
new file mode 100644
index 0000000000..efe0ce5099
--- /dev/null
+++ b/vendor/github.com/charmbracelet/ultraviolet/winch_unix.go
@@ -0,0 +1,50 @@
+//go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos
+// +build darwin dragonfly freebsd linux netbsd openbsd solaris zos
+
+package uv
+
+import (
+ "os/signal"
+ "syscall"
+
+ "github.com/charmbracelet/x/term"
+ "github.com/charmbracelet/x/termios"
+)
+
+func (n *SizeNotifier) start() error {
+ n.m.Lock()
+ defer n.m.Unlock()
+ if n.f == nil || !term.IsTerminal(n.f.Fd()) {
+ return ErrNotTerminal
+ }
+
+ signal.Notify(n.sig, syscall.SIGWINCH)
+ return nil
+}
+
+func (n *SizeNotifier) stop() error {
+ n.m.Lock()
+ signal.Stop(n.sig)
+ n.m.Unlock()
+ return nil
+}
+
+func (n *SizeNotifier) getWindowSize() (cells Size, pixels Size, err error) {
+ n.m.Lock()
+ defer n.m.Unlock()
+
+ winsize, err := termios.GetWinsize(int(n.f.Fd()))
+ if err != nil {
+ return Size{}, Size{}, err //nolint:wrapcheck
+ }
+
+ cells = Size{
+ Width: int(winsize.Col),
+ Height: int(winsize.Row),
+ }
+ pixels = Size{
+ Width: int(winsize.Xpixel),
+ Height: int(winsize.Ypixel),
+ }
+ return cells, pixels, nil
+}
diff --git a/vendor/github.com/charmbracelet/ultraviolet/window.go b/vendor/github.com/charmbracelet/ultraviolet/window.go
new file mode 100644
index 0000000000..e90bef28b3
--- /dev/null
+++ b/vendor/github.com/charmbracelet/ultraviolet/window.go
@@ -0,0 +1,147 @@
+package uv
+
+import "github.com/charmbracelet/x/ansi"
+
+// Window represents a rectangular area on the screen. It can be a root window
+// with no parent, or a sub-window with a parent window. A window can have its
+// own buffer or share the buffer of its parent window (view).
+type Window struct {
+ *Buffer
+
+ method *WidthMethod
+ parent *Window
+ bounds Rectangle
+}
+
+var (
+ _ Screen = (*Window)(nil)
+ _ Drawable = (*Window)(nil)
+)
+
+// HasParent returns whether the window has a parent window. This can be used
+// to determine if the window is a root window or a sub-window.
+func (w *Window) HasParent() bool {
+ return w.parent != nil
+}
+
+// Parent returns the parent window of the current window.
+// If the window does not have a parent, it returns nil.
+func (w *Window) Parent() *Window {
+ return w.parent
+}
+
+// MoveTo moves the window to the specified x and y coordinates.
+func (w *Window) MoveTo(x, y int) {
+ size := w.bounds.Size()
+ w.bounds.Min.X = x
+ w.bounds.Min.Y = y
+ w.bounds.Max.X = x + size.X
+ w.bounds.Max.Y = y + size.Y
+}
+
+// MoveBy moves the window by the specified delta x and delta y.
+func (w *Window) MoveBy(dx, dy int) {
+ w.bounds.Min.X += dx
+ w.bounds.Min.Y += dy
+ w.bounds.Max.X += dx
+ w.bounds.Max.Y += dy
+}
+
+// Clone creates an exact copy of the window, including its buffer and values.
+// The cloned window will have the same parent and method as the original
+// window.
+func (w *Window) Clone() *Window {
+ return w.CloneArea(w.Buffer.Bounds())
+}
+
+// CloneArea creates an exact copy of the window, including its buffer and
+// values, but only within the specified area. The cloned window will have the
+// same parent and method as the original window, but its bounds will be
+// limited to the specified area.
+func (w *Window) CloneArea(area Rectangle) *Window {
+ clone := new(Window)
+ clone.Buffer = w.Buffer.CloneArea(area)
+ clone.parent = w.parent
+ clone.method = w.method
+ clone.bounds = area
+ return clone
+}
+
+// Resize resizes the window to the specified width and height.
+func (w *Window) Resize(width, height int) {
+ // Only resize the buffer if this window owns its buffer.
+ if w.parent == nil || w.Buffer != w.parent.Buffer {
+ w.Buffer.Resize(width, height)
+ }
+ w.bounds.Max.X = w.bounds.Min.X + width
+ w.bounds.Max.Y = w.bounds.Min.Y + height
+}
+
+// WidthMethod returns the method used to calculate the width of characters in
+// the window.
+func (w *Window) WidthMethod() WidthMethod {
+ return *w.method
+}
+
+// Bounds returns the bounds of the window as a rectangle.
+func (w *Window) Bounds() Rectangle {
+ return w.bounds
+}
+
+// NewWindow creates a new window with its own buffer relative to the parent
+// window at the specified position and size.
+//
+// This will panic if width or height is negative.
+func (w *Window) NewWindow(x, y, width, height int) *Window {
+ return newWindow(w, x, y, width, height, w.method, false)
+}
+
+// NewView creates a new view into the parent window at the specified position
+// and size. Unlike [Window.NewWindow], this view shares the same buffer as the
+// parent window.
+func (w *Window) NewView(x, y, width, height int) *Window {
+ return newWindow(w, x, y, width, height, w.method, true)
+}
+
+// NewWindow creates a new root [Window] with the given size and width method.
+// If the method is nil, it defaults to [ansi.WcWidth].
+//
+// The [WidthMethod] is used to calculate the width of characters in the
+// window, which is important for correctly rendering text, especially when
+// dealing with wide characters, combining characters, emojis, and other
+// Unicode characters that may have varying widths.
+//
+// Use [ansi.WcWidth] as the default width method, which is a common
+// implementation that handles a wide range of Unicode characters according to
+// the Unicode Standard. Use [ansi.GraphemeWidth] if you know that your
+// terminal supports grapheme clusters and proper rendering of combining
+// characters and emojis, and you want to ensure that the width calculations
+// are based on grapheme clusters rather than individual code points.
+//
+// This will panic if width or height is negative.
+func NewWindow(width, height int, method WidthMethod) *Window {
+ if method == nil {
+ method = ansi.WcWidth
+ }
+ return newWindow(nil, 0, 0, width, height, &method, false)
+}
+
+// SetWidthMethod sets the width method for the window.
+func (w *Window) SetWidthMethod(method WidthMethod) {
+ w.method = &method
+}
+
+// newWindow creates a new [Window] with the specified parent, position,
+// method, and size.
+func newWindow(parent *Window, x, y, width, height int, method *WidthMethod, view bool) *Window {
+ w := new(Window)
+ if view {
+ w.Buffer = parent.Buffer
+ } else {
+ w.Buffer = NewBuffer(width, height)
+ }
+ w.parent = parent
+ w.method = method
+ w.bounds = Rect(x, y, width, height)
+ return w
+}
diff --git a/vendor/github.com/charmbracelet/x/ansi/LICENSE b/vendor/github.com/charmbracelet/x/ansi/LICENSE
new file mode 100644
index 0000000000..65a5654e20
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/ansi/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2023 Charmbracelet, Inc.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/vendor/github.com/charmbracelet/x/ansi/ansi.go b/vendor/github.com/charmbracelet/x/ansi/ansi.go
new file mode 100644
index 0000000000..d5a2f2519e
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/ansi/ansi.go
@@ -0,0 +1,11 @@
+package ansi
+
+import "io"
+
+// Execute is a function that "execute" the given escape sequence by writing it
+// to the provided output writter.
+//
+// This is a syntactic sugar over [io.WriteString].
+func Execute(w io.Writer, s string) (int, error) {
+ return io.WriteString(w, s) //nolint:wrapcheck
+}
diff --git a/vendor/github.com/charmbracelet/x/ansi/ascii.go b/vendor/github.com/charmbracelet/x/ansi/ascii.go
new file mode 100644
index 0000000000..188582f7e6
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/ansi/ascii.go
@@ -0,0 +1,8 @@
+package ansi
+
+const (
+ // SP is the space character (Char: \x20).
+ SP = 0x20
+ // DEL is the delete character (Caret: ^?, Char: \x7f).
+ DEL = 0x7F
+)
diff --git a/vendor/github.com/charmbracelet/x/ansi/background.go b/vendor/github.com/charmbracelet/x/ansi/background.go
new file mode 100644
index 0000000000..46f8214254
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/ansi/background.go
@@ -0,0 +1,178 @@
+package ansi
+
+import (
+ "fmt"
+ "image/color"
+
+ "github.com/lucasb-eyer/go-colorful"
+)
+
+// HexColor is a [color.Color] that can be formatted as a hex string.
+type HexColor string
+
+// RGBA returns the RGBA values of the color.
+func (h HexColor) RGBA() (r, g, b, a uint32) {
+ hex := h.color()
+ if hex == nil {
+ return 0, 0, 0, 0
+ }
+ return hex.RGBA()
+}
+
+// Hex returns the hex representation of the color. If the color is invalid, it
+// returns an empty string.
+func (h HexColor) Hex() string {
+ hex := h.color()
+ if hex == nil {
+ return ""
+ }
+ return hex.Hex()
+}
+
+// String returns the color as a hex string. If the color is nil, an empty
+// string is returned.
+func (h HexColor) String() string {
+ return h.Hex()
+}
+
+// color returns the underlying color of the HexColor.
+func (h HexColor) color() *colorful.Color {
+ hex, err := colorful.Hex(string(h))
+ if err != nil {
+ return nil
+ }
+ return &hex
+}
+
+// XRGBColor is a [color.Color] that can be formatted as an XParseColor
+// rgb: string.
+//
+// See: https://linux.die.net/man/3/xparsecolor
+type XRGBColor struct {
+ color.Color
+}
+
+// RGBA returns the RGBA values of the color.
+func (x XRGBColor) RGBA() (r, g, b, a uint32) {
+ if x.Color == nil {
+ return 0, 0, 0, 0
+ }
+ return x.Color.RGBA()
+}
+
+// String returns the color as an XParseColor rgb: string. If the color is nil,
+// an empty string is returned.
+func (x XRGBColor) String() string {
+ if x.Color == nil {
+ return ""
+ }
+ r, g, b, _ := x.Color.RGBA()
+ // Get the lower 8 bits
+ return fmt.Sprintf("rgb:%04x/%04x/%04x", r, g, b)
+}
+
+// XRGBAColor is a [color.Color] that can be formatted as an XParseColor
+// rgba: string.
+//
+// See: https://linux.die.net/man/3/xparsecolor
+type XRGBAColor struct {
+ color.Color
+}
+
+// RGBA returns the RGBA values of the color.
+func (x XRGBAColor) RGBA() (r, g, b, a uint32) {
+ if x.Color == nil {
+ return 0, 0, 0, 0
+ }
+ return x.Color.RGBA()
+}
+
+// String returns the color as an XParseColor rgba: string. If the color is nil,
+// an empty string is returned.
+func (x XRGBAColor) String() string {
+ if x.Color == nil {
+ return ""
+ }
+ r, g, b, a := x.RGBA()
+ // Get the lower 8 bits
+ return fmt.Sprintf("rgba:%04x/%04x/%04x/%04x", r, g, b, a)
+}
+
+// SetForegroundColor returns a sequence that sets the default terminal
+// foreground color.
+//
+// OSC 10 ; color ST
+// OSC 10 ; color BEL
+//
+// Where color is the encoded color number. Most terminals support hex,
+// XParseColor rgb: and rgba: strings. You could use [HexColor], [XRGBColor],
+// or [XRGBAColor] to format the color.
+//
+// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Operating-System-Commands
+func SetForegroundColor(s string) string {
+ return "\x1b]10;" + s + "\x07"
+}
+
+// RequestForegroundColor is a sequence that requests the current default
+// terminal foreground color.
+//
+// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Operating-System-Commands
+const RequestForegroundColor = "\x1b]10;?\x07"
+
+// ResetForegroundColor is a sequence that resets the default terminal
+// foreground color.
+//
+// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Operating-System-Commands
+const ResetForegroundColor = "\x1b]110\x07"
+
+// SetBackgroundColor returns a sequence that sets the default terminal
+// background color.
+//
+// OSC 11 ; color ST
+// OSC 11 ; color BEL
+//
+// Where color is the encoded color number. Most terminals support hex,
+// XParseColor rgb: and rgba: strings. You could use [HexColor], [XRGBColor],
+// or [XRGBAColor] to format the color.
+//
+// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Operating-System-Commands
+func SetBackgroundColor(s string) string {
+ return "\x1b]11;" + s + "\x07"
+}
+
+// RequestBackgroundColor is a sequence that requests the current default
+// terminal background color.
+//
+// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Operating-System-Commands
+const RequestBackgroundColor = "\x1b]11;?\x07"
+
+// ResetBackgroundColor is a sequence that resets the default terminal
+// background color.
+//
+// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Operating-System-Commands
+const ResetBackgroundColor = "\x1b]111\x07"
+
+// SetCursorColor returns a sequence that sets the terminal cursor color.
+//
+// OSC 12 ; color ST
+// OSC 12 ; color BEL
+//
+// Where color is the encoded color number. Most terminals support hex,
+// XParseColor rgb: and rgba: strings. You could use [HexColor], [XRGBColor],
+// or [XRGBAColor] to format the color.
+//
+// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Operating-System-Commands
+func SetCursorColor(s string) string {
+ return "\x1b]12;" + s + "\x07"
+}
+
+// RequestCursorColor is a sequence that requests the current terminal cursor
+// color.
+//
+// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Operating-System-Commands
+const RequestCursorColor = "\x1b]12;?\x07"
+
+// ResetCursorColor is a sequence that resets the terminal cursor color.
+//
+// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Operating-System-Commands
+const ResetCursorColor = "\x1b]112\x07"
diff --git a/vendor/github.com/charmbracelet/x/ansi/c0.go b/vendor/github.com/charmbracelet/x/ansi/c0.go
new file mode 100644
index 0000000000..28ff7c2a3a
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/ansi/c0.go
@@ -0,0 +1,79 @@
+package ansi
+
+// C0 control characters.
+//
+// These range from (0x00-0x1F) as defined in ISO 646 (ASCII).
+// See: https://en.wikipedia.org/wiki/C0_and_C1_control_codes
+const (
+ // NUL is the null character (Caret: ^@, Char: \0).
+ NUL = 0x00
+ // SOH is the start of heading character (Caret: ^A).
+ SOH = 0x01
+ // STX is the start of text character (Caret: ^B).
+ STX = 0x02
+ // ETX is the end of text character (Caret: ^C).
+ ETX = 0x03
+ // EOT is the end of transmission character (Caret: ^D).
+ EOT = 0x04
+ // ENQ is the enquiry character (Caret: ^E).
+ ENQ = 0x05
+ // ACK is the acknowledge character (Caret: ^F).
+ ACK = 0x06
+ // BEL is the bell character (Caret: ^G, Char: \a).
+ BEL = 0x07
+ // BS is the backspace character (Caret: ^H, Char: \b).
+ BS = 0x08
+ // HT is the horizontal tab character (Caret: ^I, Char: \t).
+ HT = 0x09
+ // LF is the line feed character (Caret: ^J, Char: \n).
+ LF = 0x0A
+ // VT is the vertical tab character (Caret: ^K, Char: \v).
+ VT = 0x0B
+ // FF is the form feed character (Caret: ^L, Char: \f).
+ FF = 0x0C
+ // CR is the carriage return character (Caret: ^M, Char: \r).
+ CR = 0x0D
+ // SO is the shift out character (Caret: ^N).
+ SO = 0x0E
+ // SI is the shift in character (Caret: ^O).
+ SI = 0x0F
+ // DLE is the data link escape character (Caret: ^P).
+ DLE = 0x10
+ // DC1 is the device control 1 character (Caret: ^Q).
+ DC1 = 0x11
+ // DC2 is the device control 2 character (Caret: ^R).
+ DC2 = 0x12
+ // DC3 is the device control 3 character (Caret: ^S).
+ DC3 = 0x13
+ // DC4 is the device control 4 character (Caret: ^T).
+ DC4 = 0x14
+ // NAK is the negative acknowledge character (Caret: ^U).
+ NAK = 0x15
+ // SYN is the synchronous idle character (Caret: ^V).
+ SYN = 0x16
+ // ETB is the end of transmission block character (Caret: ^W).
+ ETB = 0x17
+ // CAN is the cancel character (Caret: ^X).
+ CAN = 0x18
+ // EM is the end of medium character (Caret: ^Y).
+ EM = 0x19
+ // SUB is the substitute character (Caret: ^Z).
+ SUB = 0x1A
+ // ESC is the escape character (Caret: ^[, Char: \e).
+ ESC = 0x1B
+ // FS is the file separator character (Caret: ^\).
+ FS = 0x1C
+ // GS is the group separator character (Caret: ^]).
+ GS = 0x1D
+ // RS is the record separator character (Caret: ^^).
+ RS = 0x1E
+ // US is the unit separator character (Caret: ^_).
+ US = 0x1F
+
+ // LS0 is the locking shift 0 character.
+ // This is an alias for [SI].
+ LS0 = SI
+ // LS1 is the locking shift 1 character.
+ // This is an alias for [SO].
+ LS1 = SO
+)
diff --git a/vendor/github.com/charmbracelet/x/ansi/c1.go b/vendor/github.com/charmbracelet/x/ansi/c1.go
new file mode 100644
index 0000000000..71058f5399
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/ansi/c1.go
@@ -0,0 +1,72 @@
+package ansi
+
+// C1 control characters.
+//
+// These range from (0x80-0x9F) as defined in ISO 6429 (ECMA-48).
+// See: https://en.wikipedia.org/wiki/C0_and_C1_control_codes
+const (
+ // PAD is the padding character.
+ PAD = 0x80
+ // HOP is the high octet preset character.
+ HOP = 0x81
+ // BPH is the break permitted here character.
+ BPH = 0x82
+ // NBH is the no break here character.
+ NBH = 0x83
+ // IND is the index character.
+ IND = 0x84
+ // NEL is the next line character.
+ NEL = 0x85
+ // SSA is the start of selected area character.
+ SSA = 0x86
+ // ESA is the end of selected area character.
+ ESA = 0x87
+ // HTS is the horizontal tab set character.
+ HTS = 0x88
+ // HTJ is the horizontal tab with justification character.
+ HTJ = 0x89
+ // VTS is the vertical tab set character.
+ VTS = 0x8A
+ // PLD is the partial line forward character.
+ PLD = 0x8B
+ // PLU is the partial line backward character.
+ PLU = 0x8C
+ // RI is the reverse index character.
+ RI = 0x8D
+ // SS2 is the single shift 2 character.
+ SS2 = 0x8E
+ // SS3 is the single shift 3 character.
+ SS3 = 0x8F
+ // DCS is the device control string character.
+ DCS = 0x90
+ // PU1 is the private use 1 character.
+ PU1 = 0x91
+ // PU2 is the private use 2 character.
+ PU2 = 0x92
+ // STS is the set transmit state character.
+ STS = 0x93
+ // CCH is the cancel character.
+ CCH = 0x94
+ // MW is the message waiting character.
+ MW = 0x95
+ // SPA is the start of guarded area character.
+ SPA = 0x96
+ // EPA is the end of guarded area character.
+ EPA = 0x97
+ // SOS is the start of string character.
+ SOS = 0x98
+ // SGCI is the single graphic character introducer character.
+ SGCI = 0x99
+ // SCI is the single character introducer character.
+ SCI = 0x9A
+ // CSI is the control sequence introducer character.
+ CSI = 0x9B
+ // ST is the string terminator character.
+ ST = 0x9C
+ // OSC is the operating system command character.
+ OSC = 0x9D
+ // PM is the privacy message character.
+ PM = 0x9E
+ // APC is the application program command character.
+ APC = 0x9F
+)
diff --git a/vendor/github.com/charmbracelet/x/ansi/charset.go b/vendor/github.com/charmbracelet/x/ansi/charset.go
new file mode 100644
index 0000000000..02edfe7ad0
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/ansi/charset.go
@@ -0,0 +1,55 @@
+package ansi
+
+// SelectCharacterSet sets the G-set character designator to the specified
+// character set.
+//
+// ESC Ps Pd
+//
+// Where Ps is the G-set character designator, and Pd is the identifier.
+// For 94-character sets, the designator can be one of:
+// - ( G0
+// - ) G1
+// - * G2
+// - + G3
+//
+// For 96-character sets, the designator can be one of:
+// - - G1
+// - . G2
+// - / G3
+//
+// Some common 94-character sets are:
+// - 0 DEC Special Drawing Set
+// - A United Kingdom (UK)
+// - B United States (USASCII)
+//
+// Examples:
+//
+// ESC ( B Select character set G0 = United States (USASCII)
+// ESC ( 0 Select character set G0 = Special Character and Line Drawing Set
+// ESC ) 0 Select character set G1 = Special Character and Line Drawing Set
+// ESC * A Select character set G2 = United Kingdom (UK)
+//
+// See: https://vt100.net/docs/vt510-rm/SCS.html
+func SelectCharacterSet(gset byte, charset byte) string {
+ return "\x1b" + string(gset) + string(charset)
+}
+
+// SCS is an alias for SelectCharacterSet.
+func SCS(gset byte, charset byte) string {
+ return SelectCharacterSet(gset, charset)
+}
+
+// LS1R (Locking Shift 1 Right) shifts G1 into GR character set.
+const LS1R = "\x1b~"
+
+// LS2 (Locking Shift 2) shifts G2 into GL character set.
+const LS2 = "\x1bn"
+
+// LS2R (Locking Shift 2 Right) shifts G2 into GR character set.
+const LS2R = "\x1b}"
+
+// LS3 (Locking Shift 3) shifts G3 into GL character set.
+const LS3 = "\x1bo"
+
+// LS3R (Locking Shift 3 Right) shifts G3 into GR character set.
+const LS3R = "\x1b|"
diff --git a/vendor/github.com/charmbracelet/x/ansi/clipboard.go b/vendor/github.com/charmbracelet/x/ansi/clipboard.go
new file mode 100644
index 0000000000..94d26c366d
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/ansi/clipboard.go
@@ -0,0 +1,75 @@
+package ansi
+
+import "encoding/base64"
+
+// Clipboard names.
+const (
+ SystemClipboard = 'c'
+ PrimaryClipboard = 'p'
+)
+
+// SetClipboard returns a sequence for manipulating the clipboard.
+//
+// OSC 52 ; Pc ; Pd ST
+// OSC 52 ; Pc ; Pd BEL
+//
+// Where Pc is the clipboard name and Pd is the base64 encoded data.
+// Empty data or invalid base64 data will reset the clipboard.
+//
+// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Operating-System-Commands
+func SetClipboard(c byte, d string) string {
+ if d != "" {
+ d = base64.StdEncoding.EncodeToString([]byte(d))
+ }
+ return "\x1b]52;" + string(c) + ";" + d + "\x07"
+}
+
+// SetSystemClipboard returns a sequence for setting the system clipboard.
+//
+// This is equivalent to SetClipboard(SystemClipboard, d).
+func SetSystemClipboard(d string) string {
+ return SetClipboard(SystemClipboard, d)
+}
+
+// SetPrimaryClipboard returns a sequence for setting the primary clipboard.
+//
+// This is equivalent to SetClipboard(PrimaryClipboard, d).
+func SetPrimaryClipboard(d string) string {
+ return SetClipboard(PrimaryClipboard, d)
+}
+
+// ResetClipboard returns a sequence for resetting the clipboard.
+//
+// This is equivalent to SetClipboard(c, "").
+//
+// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Operating-System-Commands
+func ResetClipboard(c byte) string {
+ return SetClipboard(c, "")
+}
+
+// ResetSystemClipboard is a sequence for resetting the system clipboard.
+//
+// This is equivalent to ResetClipboard(SystemClipboard).
+const ResetSystemClipboard = "\x1b]52;c;\x07"
+
+// ResetPrimaryClipboard is a sequence for resetting the primary clipboard.
+//
+// This is equivalent to ResetClipboard(PrimaryClipboard).
+const ResetPrimaryClipboard = "\x1b]52;p;\x07"
+
+// RequestClipboard returns a sequence for requesting the clipboard.
+//
+// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Operating-System-Commands
+func RequestClipboard(c byte) string {
+ return "\x1b]52;" + string(c) + ";?\x07"
+}
+
+// RequestSystemClipboard is a sequence for requesting the system clipboard.
+//
+// This is equivalent to RequestClipboard(SystemClipboard).
+const RequestSystemClipboard = "\x1b]52;c;?\x07"
+
+// RequestPrimaryClipboard is a sequence for requesting the primary clipboard.
+//
+// This is equivalent to RequestClipboard(PrimaryClipboard).
+const RequestPrimaryClipboard = "\x1b]52;p;?\x07"
diff --git a/vendor/github.com/charmbracelet/x/ansi/color.go b/vendor/github.com/charmbracelet/x/ansi/color.go
new file mode 100644
index 0000000000..eacca595b1
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/ansi/color.go
@@ -0,0 +1,784 @@
+package ansi
+
+import (
+ "image/color"
+
+ "github.com/lucasb-eyer/go-colorful"
+)
+
+// Color is a color that can be used in a terminal. ANSI (including
+// ANSI256) and 24-bit "true colors" fall under this category.
+type Color interface {
+ color.Color
+}
+
+// BasicColor is an ANSI 3-bit or 4-bit color with a value from 0 to 15.
+type BasicColor uint8
+
+var _ Color = BasicColor(0)
+
+const (
+ // Black is the ANSI black color.
+ Black BasicColor = iota
+
+ // Red is the ANSI red color.
+ Red
+
+ // Green is the ANSI green color.
+ Green
+
+ // Yellow is the ANSI yellow color.
+ Yellow
+
+ // Blue is the ANSI blue color.
+ Blue
+
+ // Magenta is the ANSI magenta color.
+ Magenta
+
+ // Cyan is the ANSI cyan color.
+ Cyan
+
+ // White is the ANSI white color.
+ White
+
+ // BrightBlack is the ANSI bright black color.
+ BrightBlack
+
+ // BrightRed is the ANSI bright red color.
+ BrightRed
+
+ // BrightGreen is the ANSI bright green color.
+ BrightGreen
+
+ // BrightYellow is the ANSI bright yellow color.
+ BrightYellow
+
+ // BrightBlue is the ANSI bright blue color.
+ BrightBlue
+
+ // BrightMagenta is the ANSI bright magenta color.
+ BrightMagenta
+
+ // BrightCyan is the ANSI bright cyan color.
+ BrightCyan
+
+ // BrightWhite is the ANSI bright white color.
+ BrightWhite
+)
+
+// RGBA returns the red, green, blue and alpha components of the color. It
+// satisfies the color.Color interface.
+func (c BasicColor) RGBA() (uint32, uint32, uint32, uint32) {
+ ansi := uint32(c)
+ if ansi > 15 {
+ return 0, 0, 0, 0xffff
+ }
+
+ return ansiToRGB(byte(ansi)).RGBA()
+}
+
+// IndexedColor is an ANSI 256 (8-bit) color with a value from 0 to 255.
+type IndexedColor uint8
+
+var _ Color = IndexedColor(0)
+
+// RGBA returns the red, green, blue and alpha components of the color. It
+// satisfies the color.Color interface.
+func (c IndexedColor) RGBA() (uint32, uint32, uint32, uint32) {
+ return ansiToRGB(byte(c)).RGBA()
+}
+
+// ExtendedColor is an ANSI 256 (8-bit) color with a value from 0 to 255.
+//
+// Deprecated: use [IndexedColor] instead.
+type ExtendedColor = IndexedColor
+
+// TrueColor is a 24-bit color that can be used in the terminal.
+// This can be used to represent RGB colors.
+//
+// For example, the color red can be represented as:
+//
+// TrueColor(0xff0000)
+//
+// Deprecated: use [RGBColor] instead.
+type TrueColor uint32
+
+var _ Color = TrueColor(0)
+
+// RGBA returns the red, green, blue and alpha components of the color. It
+// satisfies the color.Color interface.
+func (c TrueColor) RGBA() (uint32, uint32, uint32, uint32) {
+ r, g, b := hexToRGB(uint32(c))
+ return toRGBA(r, g, b)
+}
+
+// RGBColor is a 24-bit color that can be used in the terminal.
+// This can be used to represent RGB colors.
+type RGBColor struct {
+ R uint8
+ G uint8
+ B uint8
+}
+
+// RGBA returns the red, green, blue and alpha components of the color. It
+// satisfies the color.Color interface.
+func (c RGBColor) RGBA() (uint32, uint32, uint32, uint32) {
+ return toRGBA(uint32(c.R), uint32(c.G), uint32(c.B))
+}
+
+// ansiToRGB converts an ANSI color to a 24-bit RGB color.
+//
+// r, g, b := ansiToRGB(57)
+func ansiToRGB(ansi byte) color.Color {
+ return ansiHex[ansi]
+}
+
+// hexToRGB converts a number in hexadecimal format to red, green, and blue
+// values.
+//
+// r, g, b := hexToRGB(0x0000FF)
+func hexToRGB(hex uint32) (uint32, uint32, uint32) {
+ return hex >> 16 & 0xff, hex >> 8 & 0xff, hex & 0xff
+}
+
+// toRGBA converts an RGB 8-bit color values to 32-bit color values suitable
+// for color.Color.
+//
+// color.Color requires 16-bit color values, so we duplicate the 8-bit values
+// to fill the 16-bit values.
+//
+// This always returns 0xffff (opaque) for the alpha channel.
+func toRGBA(r, g, b uint32) (uint32, uint32, uint32, uint32) {
+ r |= r << 8
+ g |= g << 8
+ b |= b << 8
+ return r, g, b, 0xffff
+}
+
+//nolint:unused
+func distSq(r1, g1, b1, r2, g2, b2 int) int {
+ return ((r1-r2)*(r1-r2) + (g1-g2)*(g1-g2) + (b1-b2)*(b1-b2))
+}
+
+func to6Cube[T int | float64](v T) int {
+ if v < 48 {
+ return 0
+ }
+ if v < 115 {
+ return 1
+ }
+ return int((v - 35) / 40)
+}
+
+// Convert256 converts a [color.Color], usually a 24-bit color, to xterm(1) 256
+// color palette.
+//
+// xterm provides a 6x6x6 color cube (16 - 231) and 24 greys (232 - 255). We
+// map our RGB color to the closest in the cube, also work out the closest
+// grey, and use the nearest of the two based on the lightness of the color.
+//
+// Note that the xterm has much lower resolution for darker colors (they are
+// not evenly spread out), so our 6 levels are not evenly spread: 0x0, 0x5f
+// (95), 0x87 (135), 0xaf (175), 0xd7 (215) and 0xff (255). Greys are more
+// evenly spread (8, 18, 28 ... 238).
+func Convert256(c color.Color) IndexedColor {
+ // If the color is already an IndexedColor, return it.
+ if i, ok := c.(IndexedColor); ok {
+ return i
+ }
+
+ // Note: this is mostly ported from tmux/colour.c.
+ col, ok := colorful.MakeColor(c)
+ if !ok {
+ return IndexedColor(0)
+ }
+
+ r := col.R * 255
+ g := col.G * 255
+ b := col.B * 255
+
+ q2c := [6]int{0x00, 0x5f, 0x87, 0xaf, 0xd7, 0xff}
+
+ // Map RGB to 6x6x6 cube.
+ qr := to6Cube(r)
+ cr := q2c[qr]
+ qg := to6Cube(g)
+ cg := q2c[qg]
+ qb := to6Cube(b)
+ cb := q2c[qb]
+
+ // If we have hit the color exactly, return early.
+ ci := (36 * qr) + (6 * qg) + qb
+ if cr == int(r) && cg == int(g) && cb == int(b) {
+ return IndexedColor(16 + ci) //nolint:gosec
+ }
+
+ // Work out the closest grey (average of RGB).
+ greyAvg := int(r+g+b) / 3
+ var greyIdx int
+ if greyAvg > 238 {
+ greyIdx = 23
+ } else {
+ greyIdx = (greyAvg - 3) / 10
+ }
+ grey := 8 + (10 * greyIdx)
+
+ // Return the one which is nearer to the original input rgb value
+ // XXX: This is where it differs from tmux's implementation, we prefer the
+ // closer color to the original in terms of light distances rather than the
+ // cube distance.
+ c2 := colorful.Color{R: float64(cr) / 255.0, G: float64(cg) / 255.0, B: float64(cb) / 255.0}
+ g2 := colorful.Color{R: float64(grey) / 255.0, G: float64(grey) / 255.0, B: float64(grey) / 255.0}
+ colorDist := col.DistanceHSLuv(c2)
+ grayDist := col.DistanceHSLuv(g2)
+
+ if colorDist <= grayDist {
+ return IndexedColor(16 + ci) //nolint:gosec
+ }
+ return IndexedColor(232 + greyIdx)
+
+ // // Is grey or 6x6x6 color closest?
+ // d := distSq(cr, cg, cb, int(r), int(g), int(b))
+ // if distSq(grey, grey, grey, int(r), int(g), int(b)) < d {
+ // return IndexedColor(232 + greyIdx) //nolint:gosec
+ // }
+ // return IndexedColor(16 + ci) //nolint:gosec
+}
+
+// Convert16 converts a [color.Color] to a 16-color ANSI color. It will first
+// try to find a match in the 256 xterm(1) color palette, and then map that to
+// the 16-color ANSI palette.
+func Convert16(c color.Color) BasicColor {
+ switch c := c.(type) {
+ case BasicColor:
+ // If the color is already a BasicColor, return it.
+ return c
+ case IndexedColor:
+ // If the color is already an IndexedColor, return the corresponding
+ // BasicColor.
+ return ansi256To16[c]
+ default:
+ c256 := Convert256(c)
+ return ansi256To16[c256]
+ }
+}
+
+// RGB values of ANSI colors (0-255).
+var ansiHex = [...]color.RGBA{
+ 0: {R: 0x00, G: 0x00, B: 0x00, A: 0xff}, // "#000000"
+ 1: {R: 0x80, G: 0x00, B: 0x00, A: 0xff}, // "#800000"
+ 2: {R: 0x00, G: 0x80, B: 0x00, A: 0xff}, // "#008000"
+ 3: {R: 0x80, G: 0x80, B: 0x00, A: 0xff}, // "#808000"
+ 4: {R: 0x00, G: 0x00, B: 0x80, A: 0xff}, // "#000080"
+ 5: {R: 0x80, G: 0x00, B: 0x80, A: 0xff}, // "#800080"
+ 6: {R: 0x00, G: 0x80, B: 0x80, A: 0xff}, // "#008080"
+ 7: {R: 0xc0, G: 0xc0, B: 0xc0, A: 0xff}, // "#c0c0c0"
+ 8: {R: 0x80, G: 0x80, B: 0x80, A: 0xff}, // "#808080"
+ 9: {R: 0xff, G: 0x00, B: 0x00, A: 0xff}, // "#ff0000"
+ 10: {R: 0x00, G: 0xff, B: 0x00, A: 0xff}, // "#00ff00"
+ 11: {R: 0xff, G: 0xff, B: 0x00, A: 0xff}, // "#ffff00"
+ 12: {R: 0x00, G: 0x00, B: 0xff, A: 0xff}, // "#0000ff"
+ 13: {R: 0xff, G: 0x00, B: 0xff, A: 0xff}, // "#ff00ff"
+ 14: {R: 0x00, G: 0xff, B: 0xff, A: 0xff}, // "#00ffff"
+ 15: {R: 0xff, G: 0xff, B: 0xff, A: 0xff}, // "#ffffff"
+ 16: {R: 0x00, G: 0x00, B: 0x00, A: 0xff}, // "#000000"
+ 17: {R: 0x00, G: 0x00, B: 0x5f, A: 0xff}, // "#00005f"
+ 18: {R: 0x00, G: 0x00, B: 0x87, A: 0xff}, // "#000087"
+ 19: {R: 0x00, G: 0x00, B: 0xaf, A: 0xff}, // "#0000af"
+ 20: {R: 0x00, G: 0x00, B: 0xd7, A: 0xff}, // "#0000d7"
+ 21: {R: 0x00, G: 0x00, B: 0xff, A: 0xff}, // "#0000ff"
+ 22: {R: 0x00, G: 0x5f, B: 0x00, A: 0xff}, // "#005f00"
+ 23: {R: 0x00, G: 0x5f, B: 0x5f, A: 0xff}, // "#005f5f"
+ 24: {R: 0x00, G: 0x5f, B: 0x87, A: 0xff}, // "#005f87"
+ 25: {R: 0x00, G: 0x5f, B: 0xaf, A: 0xff}, // "#005faf"
+ 26: {R: 0x00, G: 0x5f, B: 0xd7, A: 0xff}, // "#005fd7"
+ 27: {R: 0x00, G: 0x5f, B: 0xff, A: 0xff}, // "#005fff"
+ 28: {R: 0x00, G: 0x87, B: 0x00, A: 0xff}, // "#008700"
+ 29: {R: 0x00, G: 0x87, B: 0x5f, A: 0xff}, // "#00875f"
+ 30: {R: 0x00, G: 0x87, B: 0x87, A: 0xff}, // "#008787"
+ 31: {R: 0x00, G: 0x87, B: 0xaf, A: 0xff}, // "#0087af"
+ 32: {R: 0x00, G: 0x87, B: 0xd7, A: 0xff}, // "#0087d7"
+ 33: {R: 0x00, G: 0x87, B: 0xff, A: 0xff}, // "#0087ff"
+ 34: {R: 0x00, G: 0xaf, B: 0x00, A: 0xff}, // "#00af00"
+ 35: {R: 0x00, G: 0xaf, B: 0x5f, A: 0xff}, // "#00af5f"
+ 36: {R: 0x00, G: 0xaf, B: 0x87, A: 0xff}, // "#00af87"
+ 37: {R: 0x00, G: 0xaf, B: 0xaf, A: 0xff}, // "#00afaf"
+ 38: {R: 0x00, G: 0xaf, B: 0xd7, A: 0xff}, // "#00afd7"
+ 39: {R: 0x00, G: 0xaf, B: 0xff, A: 0xff}, // "#00afff"
+ 40: {R: 0x00, G: 0xd7, B: 0x00, A: 0xff}, // "#00d700"
+ 41: {R: 0x00, G: 0xd7, B: 0x5f, A: 0xff}, // "#00d75f"
+ 42: {R: 0x00, G: 0xd7, B: 0x87, A: 0xff}, // "#00d787"
+ 43: {R: 0x00, G: 0xd7, B: 0xaf, A: 0xff}, // "#00d7af"
+ 44: {R: 0x00, G: 0xd7, B: 0xd7, A: 0xff}, // "#00d7d7"
+ 45: {R: 0x00, G: 0xd7, B: 0xff, A: 0xff}, // "#00d7ff"
+ 46: {R: 0x00, G: 0xff, B: 0x00, A: 0xff}, // "#00ff00"
+ 47: {R: 0x00, G: 0xff, B: 0x5f, A: 0xff}, // "#00ff5f"
+ 48: {R: 0x00, G: 0xff, B: 0x87, A: 0xff}, // "#00ff87"
+ 49: {R: 0x00, G: 0xff, B: 0xaf, A: 0xff}, // "#00ffaf"
+ 50: {R: 0x00, G: 0xff, B: 0xd7, A: 0xff}, // "#00ffd7"
+ 51: {R: 0x00, G: 0xff, B: 0xff, A: 0xff}, // "#00ffff"
+ 52: {R: 0x5f, G: 0x00, B: 0x00, A: 0xff}, // "#5f0000"
+ 53: {R: 0x5f, G: 0x00, B: 0x5f, A: 0xff}, // "#5f005f"
+ 54: {R: 0x5f, G: 0x00, B: 0x87, A: 0xff}, // "#5f0087"
+ 55: {R: 0x5f, G: 0x00, B: 0xaf, A: 0xff}, // "#5f00af"
+ 56: {R: 0x5f, G: 0x00, B: 0xd7, A: 0xff}, // "#5f00d7"
+ 57: {R: 0x5f, G: 0x00, B: 0xff, A: 0xff}, // "#5f00ff"
+ 58: {R: 0x5f, G: 0x5f, B: 0x00, A: 0xff}, // "#5f5f00"
+ 59: {R: 0x5f, G: 0x5f, B: 0x5f, A: 0xff}, // "#5f5f5f"
+ 60: {R: 0x5f, G: 0x5f, B: 0x87, A: 0xff}, // "#5f5f87"
+ 61: {R: 0x5f, G: 0x5f, B: 0xaf, A: 0xff}, // "#5f5faf"
+ 62: {R: 0x5f, G: 0x5f, B: 0xd7, A: 0xff}, // "#5f5fd7"
+ 63: {R: 0x5f, G: 0x5f, B: 0xff, A: 0xff}, // "#5f5fff"
+ 64: {R: 0x5f, G: 0x87, B: 0x00, A: 0xff}, // "#5f8700"
+ 65: {R: 0x5f, G: 0x87, B: 0x5f, A: 0xff}, // "#5f875f"
+ 66: {R: 0x5f, G: 0x87, B: 0x87, A: 0xff}, // "#5f8787"
+ 67: {R: 0x5f, G: 0x87, B: 0xaf, A: 0xff}, // "#5f87af"
+ 68: {R: 0x5f, G: 0x87, B: 0xd7, A: 0xff}, // "#5f87d7"
+ 69: {R: 0x5f, G: 0x87, B: 0xff, A: 0xff}, // "#5f87ff"
+ 70: {R: 0x5f, G: 0xaf, B: 0x00, A: 0xff}, // "#5faf00"
+ 71: {R: 0x5f, G: 0xaf, B: 0x5f, A: 0xff}, // "#5faf5f"
+ 72: {R: 0x5f, G: 0xaf, B: 0x87, A: 0xff}, // "#5faf87"
+ 73: {R: 0x5f, G: 0xaf, B: 0xaf, A: 0xff}, // "#5fafaf"
+ 74: {R: 0x5f, G: 0xaf, B: 0xd7, A: 0xff}, // "#5fafd7"
+ 75: {R: 0x5f, G: 0xaf, B: 0xff, A: 0xff}, // "#5fafff"
+ 76: {R: 0x5f, G: 0xd7, B: 0x00, A: 0xff}, // "#5fd700"
+ 77: {R: 0x5f, G: 0xd7, B: 0x5f, A: 0xff}, // "#5fd75f"
+ 78: {R: 0x5f, G: 0xd7, B: 0x87, A: 0xff}, // "#5fd787"
+ 79: {R: 0x5f, G: 0xd7, B: 0xaf, A: 0xff}, // "#5fd7af"
+ 80: {R: 0x5f, G: 0xd7, B: 0xd7, A: 0xff}, // "#5fd7d7"
+ 81: {R: 0x5f, G: 0xd7, B: 0xff, A: 0xff}, // "#5fd7ff"
+ 82: {R: 0x5f, G: 0xff, B: 0x00, A: 0xff}, // "#5fff00"
+ 83: {R: 0x5f, G: 0xff, B: 0x5f, A: 0xff}, // "#5fff5f"
+ 84: {R: 0x5f, G: 0xff, B: 0x87, A: 0xff}, // "#5fff87"
+ 85: {R: 0x5f, G: 0xff, B: 0xaf, A: 0xff}, // "#5fffaf"
+ 86: {R: 0x5f, G: 0xff, B: 0xd7, A: 0xff}, // "#5fffd7"
+ 87: {R: 0x5f, G: 0xff, B: 0xff, A: 0xff}, // "#5fffff"
+ 88: {R: 0x87, G: 0x00, B: 0x00, A: 0xff}, // "#870000"
+ 89: {R: 0x87, G: 0x00, B: 0x5f, A: 0xff}, // "#87005f"
+ 90: {R: 0x87, G: 0x00, B: 0x87, A: 0xff}, // "#870087"
+ 91: {R: 0x87, G: 0x00, B: 0xaf, A: 0xff}, // "#8700af"
+ 92: {R: 0x87, G: 0x00, B: 0xd7, A: 0xff}, // "#8700d7"
+ 93: {R: 0x87, G: 0x00, B: 0xff, A: 0xff}, // "#8700ff"
+ 94: {R: 0x87, G: 0x5f, B: 0x00, A: 0xff}, // "#875f00"
+ 95: {R: 0x87, G: 0x5f, B: 0x5f, A: 0xff}, // "#875f5f"
+ 96: {R: 0x87, G: 0x5f, B: 0x87, A: 0xff}, // "#875f87"
+ 97: {R: 0x87, G: 0x5f, B: 0xaf, A: 0xff}, // "#875faf"
+ 98: {R: 0x87, G: 0x5f, B: 0xd7, A: 0xff}, // "#875fd7"
+ 99: {R: 0x87, G: 0x5f, B: 0xff, A: 0xff}, // "#875fff"
+ 100: {R: 0x87, G: 0x87, B: 0x00, A: 0xff}, // "#878700"
+ 101: {R: 0x87, G: 0x87, B: 0x5f, A: 0xff}, // "#87875f"
+ 102: {R: 0x87, G: 0x87, B: 0x87, A: 0xff}, // "#878787"
+ 103: {R: 0x87, G: 0x87, B: 0xaf, A: 0xff}, // "#8787af"
+ 104: {R: 0x87, G: 0x87, B: 0xd7, A: 0xff}, // "#8787d7"
+ 105: {R: 0x87, G: 0x87, B: 0xff, A: 0xff}, // "#8787ff"
+ 106: {R: 0x87, G: 0xaf, B: 0x00, A: 0xff}, // "#87af00"
+ 107: {R: 0x87, G: 0xaf, B: 0x5f, A: 0xff}, // "#87af5f"
+ 108: {R: 0x87, G: 0xaf, B: 0x87, A: 0xff}, // "#87af87"
+ 109: {R: 0x87, G: 0xaf, B: 0xaf, A: 0xff}, // "#87afaf"
+ 110: {R: 0x87, G: 0xaf, B: 0xd7, A: 0xff}, // "#87afd7"
+ 111: {R: 0x87, G: 0xaf, B: 0xff, A: 0xff}, // "#87afff"
+ 112: {R: 0x87, G: 0xd7, B: 0x00, A: 0xff}, // "#87d700"
+ 113: {R: 0x87, G: 0xd7, B: 0x5f, A: 0xff}, // "#87d75f"
+ 114: {R: 0x87, G: 0xd7, B: 0x87, A: 0xff}, // "#87d787"
+ 115: {R: 0x87, G: 0xd7, B: 0xaf, A: 0xff}, // "#87d7af"
+ 116: {R: 0x87, G: 0xd7, B: 0xd7, A: 0xff}, // "#87d7d7"
+ 117: {R: 0x87, G: 0xd7, B: 0xff, A: 0xff}, // "#87d7ff"
+ 118: {R: 0x87, G: 0xff, B: 0x00, A: 0xff}, // "#87ff00"
+ 119: {R: 0x87, G: 0xff, B: 0x5f, A: 0xff}, // "#87ff5f"
+ 120: {R: 0x87, G: 0xff, B: 0x87, A: 0xff}, // "#87ff87"
+ 121: {R: 0x87, G: 0xff, B: 0xaf, A: 0xff}, // "#87ffaf"
+ 122: {R: 0x87, G: 0xff, B: 0xd7, A: 0xff}, // "#87ffd7"
+ 123: {R: 0x87, G: 0xff, B: 0xff, A: 0xff}, // "#87ffff"
+ 124: {R: 0xaf, G: 0x00, B: 0x00, A: 0xff}, // "#af0000"
+ 125: {R: 0xaf, G: 0x00, B: 0x5f, A: 0xff}, // "#af005f"
+ 126: {R: 0xaf, G: 0x00, B: 0x87, A: 0xff}, // "#af0087"
+ 127: {R: 0xaf, G: 0x00, B: 0xaf, A: 0xff}, // "#af00af"
+ 128: {R: 0xaf, G: 0x00, B: 0xd7, A: 0xff}, // "#af00d7"
+ 129: {R: 0xaf, G: 0x00, B: 0xff, A: 0xff}, // "#af00ff"
+ 130: {R: 0xaf, G: 0x5f, B: 0x00, A: 0xff}, // "#af5f00"
+ 131: {R: 0xaf, G: 0x5f, B: 0x5f, A: 0xff}, // "#af5f5f"
+ 132: {R: 0xaf, G: 0x5f, B: 0x87, A: 0xff}, // "#af5f87"
+ 133: {R: 0xaf, G: 0x5f, B: 0xaf, A: 0xff}, // "#af5faf"
+ 134: {R: 0xaf, G: 0x5f, B: 0xd7, A: 0xff}, // "#af5fd7"
+ 135: {R: 0xaf, G: 0x5f, B: 0xff, A: 0xff}, // "#af5fff"
+ 136: {R: 0xaf, G: 0x87, B: 0x00, A: 0xff}, // "#af8700"
+ 137: {R: 0xaf, G: 0x87, B: 0x5f, A: 0xff}, // "#af875f"
+ 138: {R: 0xaf, G: 0x87, B: 0x87, A: 0xff}, // "#af8787"
+ 139: {R: 0xaf, G: 0x87, B: 0xaf, A: 0xff}, // "#af87af"
+ 140: {R: 0xaf, G: 0x87, B: 0xd7, A: 0xff}, // "#af87d7"
+ 141: {R: 0xaf, G: 0x87, B: 0xff, A: 0xff}, // "#af87ff"
+ 142: {R: 0xaf, G: 0xaf, B: 0x00, A: 0xff}, // "#afaf00"
+ 143: {R: 0xaf, G: 0xaf, B: 0x5f, A: 0xff}, // "#afaf5f"
+ 144: {R: 0xaf, G: 0xaf, B: 0x87, A: 0xff}, // "#afaf87"
+ 145: {R: 0xaf, G: 0xaf, B: 0xaf, A: 0xff}, // "#afafaf"
+ 146: {R: 0xaf, G: 0xaf, B: 0xd7, A: 0xff}, // "#afafd7"
+ 147: {R: 0xaf, G: 0xaf, B: 0xff, A: 0xff}, // "#afafff"
+ 148: {R: 0xaf, G: 0xd7, B: 0x00, A: 0xff}, // "#afd700"
+ 149: {R: 0xaf, G: 0xd7, B: 0x5f, A: 0xff}, // "#afd75f"
+ 150: {R: 0xaf, G: 0xd7, B: 0x87, A: 0xff}, // "#afd787"
+ 151: {R: 0xaf, G: 0xd7, B: 0xaf, A: 0xff}, // "#afd7af"
+ 152: {R: 0xaf, G: 0xd7, B: 0xd7, A: 0xff}, // "#afd7d7"
+ 153: {R: 0xaf, G: 0xd7, B: 0xff, A: 0xff}, // "#afd7ff"
+ 154: {R: 0xaf, G: 0xff, B: 0x00, A: 0xff}, // "#afff00"
+ 155: {R: 0xaf, G: 0xff, B: 0x5f, A: 0xff}, // "#afff5f"
+ 156: {R: 0xaf, G: 0xff, B: 0x87, A: 0xff}, // "#afff87"
+ 157: {R: 0xaf, G: 0xff, B: 0xaf, A: 0xff}, // "#afffaf"
+ 158: {R: 0xaf, G: 0xff, B: 0xd7, A: 0xff}, // "#afffd7"
+ 159: {R: 0xaf, G: 0xff, B: 0xff, A: 0xff}, // "#afffff"
+ 160: {R: 0xd7, G: 0x00, B: 0x00, A: 0xff}, // "#d70000"
+ 161: {R: 0xd7, G: 0x00, B: 0x5f, A: 0xff}, // "#d7005f"
+ 162: {R: 0xd7, G: 0x00, B: 0x87, A: 0xff}, // "#d70087"
+ 163: {R: 0xd7, G: 0x00, B: 0xaf, A: 0xff}, // "#d700af"
+ 164: {R: 0xd7, G: 0x00, B: 0xd7, A: 0xff}, // "#d700d7"
+ 165: {R: 0xd7, G: 0x00, B: 0xff, A: 0xff}, // "#d700ff"
+ 166: {R: 0xd7, G: 0x5f, B: 0x00, A: 0xff}, // "#d75f00"
+ 167: {R: 0xd7, G: 0x5f, B: 0x5f, A: 0xff}, // "#d75f5f"
+ 168: {R: 0xd7, G: 0x5f, B: 0x87, A: 0xff}, // "#d75f87"
+ 169: {R: 0xd7, G: 0x5f, B: 0xaf, A: 0xff}, // "#d75faf"
+ 170: {R: 0xd7, G: 0x5f, B: 0xd7, A: 0xff}, // "#d75fd7"
+ 171: {R: 0xd7, G: 0x5f, B: 0xff, A: 0xff}, // "#d75fff"
+ 172: {R: 0xd7, G: 0x87, B: 0x00, A: 0xff}, // "#d78700"
+ 173: {R: 0xd7, G: 0x87, B: 0x5f, A: 0xff}, // "#d7875f"
+ 174: {R: 0xd7, G: 0x87, B: 0x87, A: 0xff}, // "#d78787"
+ 175: {R: 0xd7, G: 0x87, B: 0xaf, A: 0xff}, // "#d787af"
+ 176: {R: 0xd7, G: 0x87, B: 0xd7, A: 0xff}, // "#d787d7"
+ 177: {R: 0xd7, G: 0x87, B: 0xff, A: 0xff}, // "#d787ff"
+ 178: {R: 0xd7, G: 0xaf, B: 0x00, A: 0xff}, // "#d7af00"
+ 179: {R: 0xd7, G: 0xaf, B: 0x5f, A: 0xff}, // "#d7af5f"
+ 180: {R: 0xd7, G: 0xaf, B: 0x87, A: 0xff}, // "#d7af87"
+ 181: {R: 0xd7, G: 0xaf, B: 0xaf, A: 0xff}, // "#d7afaf"
+ 182: {R: 0xd7, G: 0xaf, B: 0xd7, A: 0xff}, // "#d7afd7"
+ 183: {R: 0xd7, G: 0xaf, B: 0xff, A: 0xff}, // "#d7afff"
+ 184: {R: 0xd7, G: 0xd7, B: 0x00, A: 0xff}, // "#d7d700"
+ 185: {R: 0xd7, G: 0xd7, B: 0x5f, A: 0xff}, // "#d7d75f"
+ 186: {R: 0xd7, G: 0xd7, B: 0x87, A: 0xff}, // "#d7d787"
+ 187: {R: 0xd7, G: 0xd7, B: 0xaf, A: 0xff}, // "#d7d7af"
+ 188: {R: 0xd7, G: 0xd7, B: 0xd7, A: 0xff}, // "#d7d7d7"
+ 189: {R: 0xd7, G: 0xd7, B: 0xff, A: 0xff}, // "#d7d7ff"
+ 190: {R: 0xd7, G: 0xff, B: 0x00, A: 0xff}, // "#d7ff00"
+ 191: {R: 0xd7, G: 0xff, B: 0x5f, A: 0xff}, // "#d7ff5f"
+ 192: {R: 0xd7, G: 0xff, B: 0x87, A: 0xff}, // "#d7ff87"
+ 193: {R: 0xd7, G: 0xff, B: 0xaf, A: 0xff}, // "#d7ffaf"
+ 194: {R: 0xd7, G: 0xff, B: 0xd7, A: 0xff}, // "#d7ffd7"
+ 195: {R: 0xd7, G: 0xff, B: 0xff, A: 0xff}, // "#d7ffff"
+ 196: {R: 0xff, G: 0x00, B: 0x00, A: 0xff}, // "#ff0000"
+ 197: {R: 0xff, G: 0x00, B: 0x5f, A: 0xff}, // "#ff005f"
+ 198: {R: 0xff, G: 0x00, B: 0x87, A: 0xff}, // "#ff0087"
+ 199: {R: 0xff, G: 0x00, B: 0xaf, A: 0xff}, // "#ff00af"
+ 200: {R: 0xff, G: 0x00, B: 0xd7, A: 0xff}, // "#ff00d7"
+ 201: {R: 0xff, G: 0x00, B: 0xff, A: 0xff}, // "#ff00ff"
+ 202: {R: 0xff, G: 0x5f, B: 0x00, A: 0xff}, // "#ff5f00"
+ 203: {R: 0xff, G: 0x5f, B: 0x5f, A: 0xff}, // "#ff5f5f"
+ 204: {R: 0xff, G: 0x5f, B: 0x87, A: 0xff}, // "#ff5f87"
+ 205: {R: 0xff, G: 0x5f, B: 0xaf, A: 0xff}, // "#ff5faf"
+ 206: {R: 0xff, G: 0x5f, B: 0xd7, A: 0xff}, // "#ff5fd7"
+ 207: {R: 0xff, G: 0x5f, B: 0xff, A: 0xff}, // "#ff5fff"
+ 208: {R: 0xff, G: 0x87, B: 0x00, A: 0xff}, // "#ff8700"
+ 209: {R: 0xff, G: 0x87, B: 0x5f, A: 0xff}, // "#ff875f"
+ 210: {R: 0xff, G: 0x87, B: 0x87, A: 0xff}, // "#ff8787"
+ 211: {R: 0xff, G: 0x87, B: 0xaf, A: 0xff}, // "#ff87af"
+ 212: {R: 0xff, G: 0x87, B: 0xd7, A: 0xff}, // "#ff87d7"
+ 213: {R: 0xff, G: 0x87, B: 0xff, A: 0xff}, // "#ff87ff"
+ 214: {R: 0xff, G: 0xaf, B: 0x00, A: 0xff}, // "#ffaf00"
+ 215: {R: 0xff, G: 0xaf, B: 0x5f, A: 0xff}, // "#ffaf5f"
+ 216: {R: 0xff, G: 0xaf, B: 0x87, A: 0xff}, // "#ffaf87"
+ 217: {R: 0xff, G: 0xaf, B: 0xaf, A: 0xff}, // "#ffafaf"
+ 218: {R: 0xff, G: 0xaf, B: 0xd7, A: 0xff}, // "#ffafd7"
+ 219: {R: 0xff, G: 0xaf, B: 0xff, A: 0xff}, // "#ffafff"
+ 220: {R: 0xff, G: 0xd7, B: 0x00, A: 0xff}, // "#ffd700"
+ 221: {R: 0xff, G: 0xd7, B: 0x5f, A: 0xff}, // "#ffd75f"
+ 222: {R: 0xff, G: 0xd7, B: 0x87, A: 0xff}, // "#ffd787"
+ 223: {R: 0xff, G: 0xd7, B: 0xaf, A: 0xff}, // "#ffd7af"
+ 224: {R: 0xff, G: 0xd7, B: 0xd7, A: 0xff}, // "#ffd7d7"
+ 225: {R: 0xff, G: 0xd7, B: 0xff, A: 0xff}, // "#ffd7ff"
+ 226: {R: 0xff, G: 0xff, B: 0x00, A: 0xff}, // "#ffff00"
+ 227: {R: 0xff, G: 0xff, B: 0x5f, A: 0xff}, // "#ffff5f"
+ 228: {R: 0xff, G: 0xff, B: 0x87, A: 0xff}, // "#ffff87"
+ 229: {R: 0xff, G: 0xff, B: 0xaf, A: 0xff}, // "#ffffaf"
+ 230: {R: 0xff, G: 0xff, B: 0xd7, A: 0xff}, // "#ffffd7"
+ 231: {R: 0xff, G: 0xff, B: 0xff, A: 0xff}, // "#ffffff"
+ 232: {R: 0x08, G: 0x08, B: 0x08, A: 0xff}, // "#080808"
+ 233: {R: 0x12, G: 0x12, B: 0x12, A: 0xff}, // "#121212"
+ 234: {R: 0x1c, G: 0x1c, B: 0x1c, A: 0xff}, // "#1c1c1c"
+ 235: {R: 0x26, G: 0x26, B: 0x26, A: 0xff}, // "#262626"
+ 236: {R: 0x30, G: 0x30, B: 0x30, A: 0xff}, // "#303030"
+ 237: {R: 0x3a, G: 0x3a, B: 0x3a, A: 0xff}, // "#3a3a3a"
+ 238: {R: 0x44, G: 0x44, B: 0x44, A: 0xff}, // "#444444"
+ 239: {R: 0x4e, G: 0x4e, B: 0x4e, A: 0xff}, // "#4e4e4e"
+ 240: {R: 0x58, G: 0x58, B: 0x58, A: 0xff}, // "#585858"
+ 241: {R: 0x62, G: 0x62, B: 0x62, A: 0xff}, // "#626262"
+ 242: {R: 0x6c, G: 0x6c, B: 0x6c, A: 0xff}, // "#6c6c6c"
+ 243: {R: 0x76, G: 0x76, B: 0x76, A: 0xff}, // "#767676"
+ 244: {R: 0x80, G: 0x80, B: 0x80, A: 0xff}, // "#808080"
+ 245: {R: 0x8a, G: 0x8a, B: 0x8a, A: 0xff}, // "#8a8a8a"
+ 246: {R: 0x94, G: 0x94, B: 0x94, A: 0xff}, // "#949494"
+ 247: {R: 0x9e, G: 0x9e, B: 0x9e, A: 0xff}, // "#9e9e9e"
+ 248: {R: 0xa8, G: 0xa8, B: 0xa8, A: 0xff}, // "#a8a8a8"
+ 249: {R: 0xb2, G: 0xb2, B: 0xb2, A: 0xff}, // "#b2b2b2"
+ 250: {R: 0xbc, G: 0xbc, B: 0xbc, A: 0xff}, // "#bcbcbc"
+ 251: {R: 0xc6, G: 0xc6, B: 0xc6, A: 0xff}, // "#c6c6c6"
+ 252: {R: 0xd0, G: 0xd0, B: 0xd0, A: 0xff}, // "#d0d0d0"
+ 253: {R: 0xda, G: 0xda, B: 0xda, A: 0xff}, // "#dadada"
+ 254: {R: 0xe4, G: 0xe4, B: 0xe4, A: 0xff}, // "#e4e4e4"
+ 255: {R: 0xee, G: 0xee, B: 0xee, A: 0xff}, // "#eeeeee"
+}
+
+var ansi256To16 = [...]BasicColor{
+ 0: 0,
+ 1: 1,
+ 2: 2,
+ 3: 3,
+ 4: 4,
+ 5: 5,
+ 6: 6,
+ 7: 7,
+ 8: 8,
+ 9: 9,
+ 10: 10,
+ 11: 11,
+ 12: 12,
+ 13: 13,
+ 14: 14,
+ 15: 15,
+ 16: 0,
+ 17: 4,
+ 18: 4,
+ 19: 4,
+ 20: 12,
+ 21: 12,
+ 22: 2,
+ 23: 6,
+ 24: 4,
+ 25: 4,
+ 26: 12,
+ 27: 12,
+ 28: 2,
+ 29: 2,
+ 30: 6,
+ 31: 4,
+ 32: 12,
+ 33: 12,
+ 34: 2,
+ 35: 2,
+ 36: 2,
+ 37: 6,
+ 38: 12,
+ 39: 12,
+ 40: 10,
+ 41: 10,
+ 42: 10,
+ 43: 10,
+ 44: 14,
+ 45: 12,
+ 46: 10,
+ 47: 10,
+ 48: 10,
+ 49: 10,
+ 50: 10,
+ 51: 14,
+ 52: 1,
+ 53: 5,
+ 54: 4,
+ 55: 4,
+ 56: 12,
+ 57: 12,
+ 58: 3,
+ 59: 8,
+ 60: 4,
+ 61: 4,
+ 62: 12,
+ 63: 12,
+ 64: 2,
+ 65: 2,
+ 66: 6,
+ 67: 4,
+ 68: 12,
+ 69: 12,
+ 70: 2,
+ 71: 2,
+ 72: 2,
+ 73: 6,
+ 74: 12,
+ 75: 12,
+ 76: 10,
+ 77: 10,
+ 78: 10,
+ 79: 10,
+ 80: 14,
+ 81: 12,
+ 82: 10,
+ 83: 10,
+ 84: 10,
+ 85: 10,
+ 86: 10,
+ 87: 14,
+ 88: 1,
+ 89: 1,
+ 90: 5,
+ 91: 4,
+ 92: 12,
+ 93: 12,
+ 94: 1,
+ 95: 1,
+ 96: 5,
+ 97: 4,
+ 98: 12,
+ 99: 12,
+ 100: 3,
+ 101: 3,
+ 102: 8,
+ 103: 4,
+ 104: 12,
+ 105: 12,
+ 106: 2,
+ 107: 2,
+ 108: 2,
+ 109: 6,
+ 110: 12,
+ 111: 12,
+ 112: 10,
+ 113: 10,
+ 114: 10,
+ 115: 10,
+ 116: 14,
+ 117: 12,
+ 118: 10,
+ 119: 10,
+ 120: 10,
+ 121: 10,
+ 122: 10,
+ 123: 14,
+ 124: 1,
+ 125: 1,
+ 126: 1,
+ 127: 5,
+ 128: 12,
+ 129: 12,
+ 130: 1,
+ 131: 1,
+ 132: 1,
+ 133: 5,
+ 134: 12,
+ 135: 12,
+ 136: 1,
+ 137: 1,
+ 138: 1,
+ 139: 5,
+ 140: 12,
+ 141: 12,
+ 142: 3,
+ 143: 3,
+ 144: 3,
+ 145: 7,
+ 146: 12,
+ 147: 12,
+ 148: 10,
+ 149: 10,
+ 150: 10,
+ 151: 10,
+ 152: 14,
+ 153: 12,
+ 154: 10,
+ 155: 10,
+ 156: 10,
+ 157: 10,
+ 158: 10,
+ 159: 14,
+ 160: 9,
+ 161: 9,
+ 162: 9,
+ 163: 9,
+ 164: 13,
+ 165: 12,
+ 166: 9,
+ 167: 9,
+ 168: 9,
+ 169: 9,
+ 170: 13,
+ 171: 12,
+ 172: 9,
+ 173: 9,
+ 174: 9,
+ 175: 9,
+ 176: 13,
+ 177: 12,
+ 178: 9,
+ 179: 9,
+ 180: 9,
+ 181: 9,
+ 182: 13,
+ 183: 12,
+ 184: 11,
+ 185: 11,
+ 186: 11,
+ 187: 11,
+ 188: 7,
+ 189: 12,
+ 190: 10,
+ 191: 10,
+ 192: 10,
+ 193: 10,
+ 194: 10,
+ 195: 14,
+ 196: 9,
+ 197: 9,
+ 198: 9,
+ 199: 9,
+ 200: 9,
+ 201: 13,
+ 202: 9,
+ 203: 9,
+ 204: 9,
+ 205: 9,
+ 206: 9,
+ 207: 13,
+ 208: 9,
+ 209: 9,
+ 210: 9,
+ 211: 9,
+ 212: 9,
+ 213: 13,
+ 214: 9,
+ 215: 9,
+ 216: 9,
+ 217: 9,
+ 218: 9,
+ 219: 13,
+ 220: 9,
+ 221: 9,
+ 222: 9,
+ 223: 9,
+ 224: 9,
+ 225: 13,
+ 226: 11,
+ 227: 11,
+ 228: 11,
+ 229: 11,
+ 230: 11,
+ 231: 15,
+ 232: 0,
+ 233: 0,
+ 234: 0,
+ 235: 0,
+ 236: 0,
+ 237: 0,
+ 238: 8,
+ 239: 8,
+ 240: 8,
+ 241: 8,
+ 242: 8,
+ 243: 8,
+ 244: 7,
+ 245: 7,
+ 246: 7,
+ 247: 7,
+ 248: 7,
+ 249: 7,
+ 250: 15,
+ 251: 15,
+ 252: 15,
+ 253: 15,
+ 254: 15,
+ 255: 15,
+}
diff --git a/vendor/github.com/charmbracelet/x/ansi/ctrl.go b/vendor/github.com/charmbracelet/x/ansi/ctrl.go
new file mode 100644
index 0000000000..64bcf1136d
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/ansi/ctrl.go
@@ -0,0 +1,156 @@
+package ansi
+
+import (
+ "strconv"
+ "strings"
+)
+
+// RequestNameVersion (XTVERSION) is a control sequence that requests the
+// terminal's name and version. It responds with a DSR sequence identifying the
+// terminal.
+//
+// CSI > 0 q
+// DCS > | text ST
+//
+// See https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-PC-Style-Function-Keys
+const (
+ RequestNameVersion = "\x1b[>q"
+ XTVERSION = RequestNameVersion
+)
+
+// RequestXTVersion is a control sequence that requests the terminal's XTVERSION. It responds with a DSR sequence identifying the version.
+//
+// CSI > Ps q
+// DCS > | text ST
+//
+// See https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-PC-Style-Function-Keys
+//
+// Deprecated: use [RequestNameVersion] instead.
+const RequestXTVersion = RequestNameVersion
+
+// PrimaryDeviceAttributes (DA1) is a control sequence that reports the
+// terminal's primary device attributes.
+//
+// CSI c
+// CSI 0 c
+// CSI ? Ps ; ... c
+//
+// If no attributes are given, or if the attribute is 0, this function returns
+// the request sequence. Otherwise, it returns the response sequence.
+//
+// Common attributes include:
+// - 1 132 columns
+// - 2 Printer port
+// - 4 Sixel
+// - 6 Selective erase
+// - 7 Soft character set (DRCS)
+// - 8 User-defined keys (UDKs)
+// - 9 National replacement character sets (NRCS) (International terminal only)
+// - 12 Yugoslavian (SCS)
+// - 15 Technical character set
+// - 18 Windowing capability
+// - 21 Horizontal scrolling
+// - 23 Greek
+// - 24 Turkish
+// - 42 ISO Latin-2 character set
+// - 44 PCTerm
+// - 45 Soft key map
+// - 46 ASCII emulation
+//
+// See https://vt100.net/docs/vt510-rm/DA1.html
+func PrimaryDeviceAttributes(attrs ...int) string {
+ if len(attrs) == 0 {
+ return RequestPrimaryDeviceAttributes
+ } else if len(attrs) == 1 && attrs[0] == 0 {
+ return "\x1b[0c"
+ }
+
+ as := make([]string, len(attrs))
+ for i, a := range attrs {
+ as[i] = strconv.Itoa(a)
+ }
+ return "\x1b[?" + strings.Join(as, ";") + "c"
+}
+
+// DA1 is an alias for [PrimaryDeviceAttributes].
+func DA1(attrs ...int) string {
+ return PrimaryDeviceAttributes(attrs...)
+}
+
+// RequestPrimaryDeviceAttributes is a control sequence that requests the
+// terminal's primary device attributes (DA1).
+//
+// CSI c
+//
+// See https://vt100.net/docs/vt510-rm/DA1.html
+const RequestPrimaryDeviceAttributes = "\x1b[c"
+
+// SecondaryDeviceAttributes (DA2) is a control sequence that reports the
+// terminal's secondary device attributes.
+//
+// CSI > c
+// CSI > 0 c
+// CSI > Ps ; ... c
+//
+// See https://vt100.net/docs/vt510-rm/DA2.html
+func SecondaryDeviceAttributes(attrs ...int) string {
+ if len(attrs) == 0 {
+ return RequestSecondaryDeviceAttributes
+ }
+
+ as := make([]string, len(attrs))
+ for i, a := range attrs {
+ as[i] = strconv.Itoa(a)
+ }
+ return "\x1b[>" + strings.Join(as, ";") + "c"
+}
+
+// DA2 is an alias for [SecondaryDeviceAttributes].
+func DA2(attrs ...int) string {
+ return SecondaryDeviceAttributes(attrs...)
+}
+
+// RequestSecondaryDeviceAttributes is a control sequence that requests the
+// terminal's secondary device attributes (DA2).
+//
+// CSI > c
+//
+// See https://vt100.net/docs/vt510-rm/DA2.html
+const RequestSecondaryDeviceAttributes = "\x1b[>c"
+
+// TertiaryDeviceAttributes (DA3) is a control sequence that reports the
+// terminal's tertiary device attributes.
+//
+// CSI = c
+// CSI = 0 c
+// DCS ! | Text ST
+//
+// Where Text is the unit ID for the terminal.
+//
+// If no unit ID is given, or if the unit ID is 0, this function returns the
+// request sequence. Otherwise, it returns the response sequence.
+//
+// See https://vt100.net/docs/vt510-rm/DA3.html
+func TertiaryDeviceAttributes(unitID string) string {
+ switch unitID {
+ case "":
+ return RequestTertiaryDeviceAttributes
+ case "0":
+ return "\x1b[=0c"
+ }
+
+ return "\x1bP!|" + unitID + "\x1b\\"
+}
+
+// DA3 is an alias for [TertiaryDeviceAttributes].
+func DA3(unitID string) string {
+ return TertiaryDeviceAttributes(unitID)
+}
+
+// RequestTertiaryDeviceAttributes is a control sequence that requests the
+// terminal's tertiary device attributes (DA3).
+//
+// CSI = c
+//
+// See https://vt100.net/docs/vt510-rm/DA3.html
+const RequestTertiaryDeviceAttributes = "\x1b[=c"
diff --git a/vendor/github.com/charmbracelet/x/ansi/cursor.go b/vendor/github.com/charmbracelet/x/ansi/cursor.go
new file mode 100644
index 0000000000..3c0f8912ef
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/ansi/cursor.go
@@ -0,0 +1,637 @@
+package ansi
+
+import (
+ "strconv"
+)
+
+// SaveCursor (DECSC) is an escape sequence that saves the current cursor
+// position.
+//
+// ESC 7
+//
+// See: https://vt100.net/docs/vt510-rm/DECSC.html
+const (
+ SaveCursor = "\x1b7"
+ DECSC = SaveCursor
+)
+
+// RestoreCursor (DECRC) is an escape sequence that restores the cursor
+// position.
+//
+// ESC 8
+//
+// See: https://vt100.net/docs/vt510-rm/DECRC.html
+const (
+ RestoreCursor = "\x1b8"
+ DECRC = RestoreCursor
+)
+
+// RequestCursorPosition is an escape sequence that requests the current cursor
+// position.
+//
+// CSI 6 n
+//
+// The terminal will report the cursor position as a CSI sequence in the
+// following format:
+//
+// CSI Pl ; Pc R
+//
+// Where Pl is the line number and Pc is the column number.
+// See: https://vt100.net/docs/vt510-rm/CPR.html
+//
+// Deprecated: use [RequestCursorPositionReport] instead.
+const RequestCursorPosition = "\x1b[6n"
+
+// RequestExtendedCursorPosition (DECXCPR) is a sequence for requesting the
+// cursor position report including the current page number.
+//
+// CSI ? 6 n
+//
+// The terminal will report the cursor position as a CSI sequence in the
+// following format:
+//
+// CSI ? Pl ; Pc ; Pp R
+//
+// Where Pl is the line number, Pc is the column number, and Pp is the page
+// number.
+// See: https://vt100.net/docs/vt510-rm/DECXCPR.html
+//
+// Deprecated: use [RequestExtendedCursorPositionReport] instead.
+const RequestExtendedCursorPosition = "\x1b[?6n"
+
+// CursorUp (CUU) returns a sequence for moving the cursor up n cells.
+//
+// CSI n A
+//
+// See: https://vt100.net/docs/vt510-rm/CUU.html
+func CursorUp(n int) string {
+ var s string
+ if n > 1 {
+ s = strconv.Itoa(n)
+ }
+ return "\x1b[" + s + "A"
+}
+
+// CUU is an alias for [CursorUp].
+func CUU(n int) string {
+ return CursorUp(n)
+}
+
+// CUU1 is a sequence for moving the cursor up one cell.
+const CUU1 = "\x1b[A"
+
+// CursorUp1 is a sequence for moving the cursor up one cell.
+//
+// This is equivalent to CursorUp(1).
+//
+// Deprecated: use [CUU1] instead.
+const CursorUp1 = "\x1b[A"
+
+// CursorDown (CUD) returns a sequence for moving the cursor down n cells.
+//
+// CSI n B
+//
+// See: https://vt100.net/docs/vt510-rm/CUD.html
+func CursorDown(n int) string {
+ var s string
+ if n > 1 {
+ s = strconv.Itoa(n)
+ }
+ return "\x1b[" + s + "B"
+}
+
+// CUD is an alias for [CursorDown].
+func CUD(n int) string {
+ return CursorDown(n)
+}
+
+// CUD1 is a sequence for moving the cursor down one cell.
+const CUD1 = "\x1b[B"
+
+// CursorDown1 is a sequence for moving the cursor down one cell.
+//
+// This is equivalent to CursorDown(1).
+//
+// Deprecated: use [CUD1] instead.
+const CursorDown1 = "\x1b[B"
+
+// CursorForward (CUF) returns a sequence for moving the cursor right n cells.
+//
+// # CSI n C
+//
+// See: https://vt100.net/docs/vt510-rm/CUF.html
+func CursorForward(n int) string {
+ var s string
+ if n > 1 {
+ s = strconv.Itoa(n)
+ }
+ return "\x1b[" + s + "C"
+}
+
+// CUF is an alias for [CursorForward].
+func CUF(n int) string {
+ return CursorForward(n)
+}
+
+// CUF1 is a sequence for moving the cursor right one cell.
+const CUF1 = "\x1b[C"
+
+// CursorRight (CUF) returns a sequence for moving the cursor right n cells.
+//
+// CSI n C
+//
+// See: https://vt100.net/docs/vt510-rm/CUF.html
+//
+// Deprecated: use [CursorForward] instead.
+func CursorRight(n int) string {
+ return CursorForward(n)
+}
+
+// CursorRight1 is a sequence for moving the cursor right one cell.
+//
+// This is equivalent to CursorRight(1).
+//
+// Deprecated: use [CUF1] instead.
+const CursorRight1 = CUF1
+
+// CursorBackward (CUB) returns a sequence for moving the cursor left n cells.
+//
+// # CSI n D
+//
+// See: https://vt100.net/docs/vt510-rm/CUB.html
+func CursorBackward(n int) string {
+ var s string
+ if n > 1 {
+ s = strconv.Itoa(n)
+ }
+ return "\x1b[" + s + "D"
+}
+
+// CUB is an alias for [CursorBackward].
+func CUB(n int) string {
+ return CursorBackward(n)
+}
+
+// CUB1 is a sequence for moving the cursor left one cell.
+const CUB1 = "\x1b[D"
+
+// CursorLeft (CUB) returns a sequence for moving the cursor left n cells.
+//
+// CSI n D
+//
+// See: https://vt100.net/docs/vt510-rm/CUB.html
+//
+// Deprecated: use [CursorBackward] instead.
+func CursorLeft(n int) string {
+ return CursorBackward(n)
+}
+
+// CursorLeft1 is a sequence for moving the cursor left one cell.
+//
+// This is equivalent to CursorLeft(1).
+//
+// Deprecated: use [CUB1] instead.
+const CursorLeft1 = CUB1
+
+// CursorNextLine (CNL) returns a sequence for moving the cursor to the
+// beginning of the next line n times.
+//
+// CSI n E
+//
+// See: https://vt100.net/docs/vt510-rm/CNL.html
+func CursorNextLine(n int) string {
+ var s string
+ if n > 1 {
+ s = strconv.Itoa(n)
+ }
+ return "\x1b[" + s + "E"
+}
+
+// CNL is an alias for [CursorNextLine].
+func CNL(n int) string {
+ return CursorNextLine(n)
+}
+
+// CursorPreviousLine (CPL) returns a sequence for moving the cursor to the
+// beginning of the previous line n times.
+//
+// CSI n F
+//
+// See: https://vt100.net/docs/vt510-rm/CPL.html
+func CursorPreviousLine(n int) string {
+ var s string
+ if n > 1 {
+ s = strconv.Itoa(n)
+ }
+ return "\x1b[" + s + "F"
+}
+
+// CPL is an alias for [CursorPreviousLine].
+func CPL(n int) string {
+ return CursorPreviousLine(n)
+}
+
+// CursorHorizontalAbsolute (CHA) returns a sequence for moving the cursor to
+// the given column.
+//
+// Default is 1.
+//
+// CSI n G
+//
+// See: https://vt100.net/docs/vt510-rm/CHA.html
+func CursorHorizontalAbsolute(col int) string {
+ var s string
+ if col > 0 {
+ s = strconv.Itoa(col)
+ }
+ return "\x1b[" + s + "G"
+}
+
+// CHA is an alias for [CursorHorizontalAbsolute].
+func CHA(col int) string {
+ return CursorHorizontalAbsolute(col)
+}
+
+// CursorPosition (CUP) returns a sequence for setting the cursor to the
+// given row and column.
+//
+// Default is 1,1.
+//
+// CSI n ; m H
+//
+// See: https://vt100.net/docs/vt510-rm/CUP.html
+func CursorPosition(col, row int) string {
+ if row <= 1 && col <= 1 {
+ return CursorHomePosition
+ }
+
+ var r, c string
+ if row > 0 {
+ r = strconv.Itoa(row)
+ }
+ if col > 0 {
+ c = strconv.Itoa(col)
+ }
+ return "\x1b[" + r + ";" + c + "H"
+}
+
+// CUP is an alias for [CursorPosition].
+func CUP(col, row int) string {
+ return CursorPosition(col, row)
+}
+
+// CursorHomePosition is a sequence for moving the cursor to the upper left
+// corner of the scrolling region.
+//
+// This is equivalent to [CursorPosition](1, 1).
+const CursorHomePosition = "\x1b[H"
+
+// SetCursorPosition (CUP) returns a sequence for setting the cursor to the
+// given row and column.
+//
+// CSI n ; m H
+//
+// See: https://vt100.net/docs/vt510-rm/CUP.html
+//
+// Deprecated: use [CursorPosition] instead.
+func SetCursorPosition(col, row int) string {
+ if row <= 0 && col <= 0 {
+ return HomeCursorPosition
+ }
+
+ var r, c string
+ if row > 0 {
+ r = strconv.Itoa(row)
+ }
+ if col > 0 {
+ c = strconv.Itoa(col)
+ }
+ return "\x1b[" + r + ";" + c + "H"
+}
+
+// HomeCursorPosition is a sequence for moving the cursor to the upper left
+// corner of the scrolling region. This is equivalent to `SetCursorPosition(1, 1)`.
+//
+// Deprecated: use [CursorHomePosition] instead.
+const HomeCursorPosition = CursorHomePosition
+
+// MoveCursor (CUP) returns a sequence for setting the cursor to the
+// given row and column.
+//
+// CSI n ; m H
+//
+// See: https://vt100.net/docs/vt510-rm/CUP.html
+//
+// Deprecated: use [CursorPosition] instead.
+func MoveCursor(col, row int) string {
+ return SetCursorPosition(col, row)
+}
+
+// CursorOrigin is a sequence for moving the cursor to the upper left corner of
+// the display. This is equivalent to `SetCursorPosition(1, 1)`.
+//
+// Deprecated: use [CursorHomePosition] instead.
+const CursorOrigin = "\x1b[1;1H"
+
+// MoveCursorOrigin is a sequence for moving the cursor to the upper left
+// corner of the display. This is equivalent to `SetCursorPosition(1, 1)`.
+//
+// Deprecated: use [CursorHomePosition] instead.
+const MoveCursorOrigin = CursorOrigin
+
+// CursorHorizontalForwardTab (CHT) returns a sequence for moving the cursor to
+// the next tab stop n times.
+//
+// Default is 1.
+//
+// CSI n I
+//
+// See: https://vt100.net/docs/vt510-rm/CHT.html
+func CursorHorizontalForwardTab(n int) string {
+ var s string
+ if n > 1 {
+ s = strconv.Itoa(n)
+ }
+ return "\x1b[" + s + "I"
+}
+
+// CHT is an alias for [CursorHorizontalForwardTab].
+func CHT(n int) string {
+ return CursorHorizontalForwardTab(n)
+}
+
+// EraseCharacter (ECH) returns a sequence for erasing n characters from the
+// screen. This doesn't affect other cell attributes.
+//
+// Default is 1.
+//
+// CSI n X
+//
+// See: https://vt100.net/docs/vt510-rm/ECH.html
+func EraseCharacter(n int) string {
+ var s string
+ if n > 1 {
+ s = strconv.Itoa(n)
+ }
+ return "\x1b[" + s + "X"
+}
+
+// ECH is an alias for [EraseCharacter].
+func ECH(n int) string {
+ return EraseCharacter(n)
+}
+
+// CursorBackwardTab (CBT) returns a sequence for moving the cursor to the
+// previous tab stop n times.
+//
+// Default is 1.
+//
+// CSI n Z
+//
+// See: https://vt100.net/docs/vt510-rm/CBT.html
+func CursorBackwardTab(n int) string {
+ var s string
+ if n > 1 {
+ s = strconv.Itoa(n)
+ }
+ return "\x1b[" + s + "Z"
+}
+
+// CBT is an alias for [CursorBackwardTab].
+func CBT(n int) string {
+ return CursorBackwardTab(n)
+}
+
+// VerticalPositionAbsolute (VPA) returns a sequence for moving the cursor to
+// the given row.
+//
+// Default is 1.
+//
+// CSI n d
+//
+// See: https://vt100.net/docs/vt510-rm/VPA.html
+func VerticalPositionAbsolute(row int) string {
+ var s string
+ if row > 0 {
+ s = strconv.Itoa(row)
+ }
+ return "\x1b[" + s + "d"
+}
+
+// VPA is an alias for [VerticalPositionAbsolute].
+func VPA(row int) string {
+ return VerticalPositionAbsolute(row)
+}
+
+// VerticalPositionRelative (VPR) returns a sequence for moving the cursor down
+// n rows relative to the current position.
+//
+// Default is 1.
+//
+// CSI n e
+//
+// See: https://vt100.net/docs/vt510-rm/VPR.html
+func VerticalPositionRelative(n int) string {
+ var s string
+ if n > 1 {
+ s = strconv.Itoa(n)
+ }
+ return "\x1b[" + s + "e"
+}
+
+// VPR is an alias for [VerticalPositionRelative].
+func VPR(n int) string {
+ return VerticalPositionRelative(n)
+}
+
+// HorizontalVerticalPosition (HVP) returns a sequence for moving the cursor to
+// the given row and column.
+//
+// Default is 1,1.
+//
+// CSI n ; m f
+//
+// This has the same effect as [CursorPosition].
+//
+// See: https://vt100.net/docs/vt510-rm/HVP.html
+func HorizontalVerticalPosition(col, row int) string {
+ var r, c string
+ if row > 0 {
+ r = strconv.Itoa(row)
+ }
+ if col > 0 {
+ c = strconv.Itoa(col)
+ }
+ return "\x1b[" + r + ";" + c + "f"
+}
+
+// HVP is an alias for [HorizontalVerticalPosition].
+func HVP(col, row int) string {
+ return HorizontalVerticalPosition(col, row)
+}
+
+// HorizontalVerticalHomePosition is a sequence for moving the cursor to the
+// upper left corner of the scrolling region. This is equivalent to
+// `HorizontalVerticalPosition(1, 1)`.
+const HorizontalVerticalHomePosition = "\x1b[f"
+
+// SaveCurrentCursorPosition (SCOSC) is a sequence for saving the current cursor
+// position for SCO console mode.
+//
+// CSI s
+//
+// This acts like [DECSC], except the page number where the cursor is located
+// is not saved.
+//
+// See: https://vt100.net/docs/vt510-rm/SCOSC.html
+const (
+ SaveCurrentCursorPosition = "\x1b[s"
+ SCOSC = SaveCurrentCursorPosition
+)
+
+// SaveCursorPosition (SCP or SCOSC) is a sequence for saving the cursor
+// position.
+//
+// CSI s
+//
+// This acts like Save, except the page number where the cursor is located is
+// not saved.
+//
+// See: https://vt100.net/docs/vt510-rm/SCOSC.html
+//
+// Deprecated: use [SaveCurrentCursorPosition] instead.
+const SaveCursorPosition = "\x1b[s"
+
+// RestoreCurrentCursorPosition (SCORC) is a sequence for restoring the current
+// cursor position for SCO console mode.
+//
+// CSI u
+//
+// This acts like [DECRC], except the page number where the cursor was saved is
+// not restored.
+//
+// See: https://vt100.net/docs/vt510-rm/SCORC.html
+const (
+ RestoreCurrentCursorPosition = "\x1b[u"
+ SCORC = RestoreCurrentCursorPosition
+)
+
+// RestoreCursorPosition (RCP or SCORC) is a sequence for restoring the cursor
+// position.
+//
+// CSI u
+//
+// This acts like Restore, except the cursor stays on the same page where the
+// cursor was saved.
+//
+// See: https://vt100.net/docs/vt510-rm/SCORC.html
+//
+// Deprecated: use [RestoreCurrentCursorPosition] instead.
+const RestoreCursorPosition = "\x1b[u"
+
+// SetCursorStyle (DECSCUSR) returns a sequence for changing the cursor style.
+//
+// Default is 1.
+//
+// CSI Ps SP q
+//
+// Where Ps is the cursor style:
+//
+// 0: Blinking block
+// 1: Blinking block (default)
+// 2: Steady block
+// 3: Blinking underline
+// 4: Steady underline
+// 5: Blinking bar (xterm)
+// 6: Steady bar (xterm)
+//
+// See: https://vt100.net/docs/vt510-rm/DECSCUSR.html
+// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h4-Functions-using-CSI-_-ordered-by-the-final-character-lparen-s-rparen:CSI-Ps-SP-q.1D81
+func SetCursorStyle(style int) string {
+ if style < 0 {
+ style = 0
+ }
+ return "\x1b[" + strconv.Itoa(style) + " q"
+}
+
+// DECSCUSR is an alias for [SetCursorStyle].
+func DECSCUSR(style int) string {
+ return SetCursorStyle(style)
+}
+
+// SetPointerShape returns a sequence for changing the mouse pointer cursor
+// shape. Use "default" for the default pointer shape.
+//
+// OSC 22 ; Pt ST
+// OSC 22 ; Pt BEL
+//
+// Where Pt is the pointer shape name. The name can be anything that the
+// operating system can understand. Some common names are:
+//
+// - copy
+// - crosshair
+// - default
+// - ew-resize
+// - n-resize
+// - text
+// - wait
+//
+// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-Operating-System-Commands
+func SetPointerShape(shape string) string {
+ return "\x1b]22;" + shape + "\x07"
+}
+
+// ReverseIndex (RI) is an escape sequence for moving the cursor up one line in
+// the same column. If the cursor is at the top margin, the screen scrolls
+// down.
+//
+// This has the same effect as [RI].
+const ReverseIndex = "\x1bM"
+
+// HorizontalPositionAbsolute (HPA) returns a sequence for moving the cursor to
+// the given column. This has the same effect as [CUP].
+//
+// Default is 1.
+//
+// CSI n \`
+//
+// See: https://vt100.net/docs/vt510-rm/HPA.html
+func HorizontalPositionAbsolute(col int) string {
+ var s string
+ if col > 0 {
+ s = strconv.Itoa(col)
+ }
+ return "\x1b[" + s + "`"
+}
+
+// HPA is an alias for [HorizontalPositionAbsolute].
+func HPA(col int) string {
+ return HorizontalPositionAbsolute(col)
+}
+
+// HorizontalPositionRelative (HPR) returns a sequence for moving the cursor
+// right n columns relative to the current position. This has the same effect
+// as [CUP].
+//
+// Default is 1.
+//
+// CSI n a
+//
+// See: https://vt100.net/docs/vt510-rm/HPR.html
+func HorizontalPositionRelative(n int) string {
+ var s string
+ if n > 0 {
+ s = strconv.Itoa(n)
+ }
+ return "\x1b[" + s + "a"
+}
+
+// HPR is an alias for [HorizontalPositionRelative].
+func HPR(n int) string {
+ return HorizontalPositionRelative(n)
+}
+
+// Index (IND) is an escape sequence for moving the cursor down one line in the
+// same column. If the cursor is at the bottom margin, the screen scrolls up.
+// This has the same effect as [IND].
+const Index = "\x1bD"
diff --git a/vendor/github.com/charmbracelet/x/ansi/cwd.go b/vendor/github.com/charmbracelet/x/ansi/cwd.go
new file mode 100644
index 0000000000..b03ac1bb99
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/ansi/cwd.go
@@ -0,0 +1,26 @@
+package ansi
+
+import (
+ "net/url"
+ "path"
+)
+
+// NotifyWorkingDirectory returns a sequence that notifies the terminal
+// of the current working directory.
+//
+// OSC 7 ; Pt BEL
+//
+// Where Pt is a URL in the format "file://[host]/[path]".
+// Set host to "localhost" if this is a path on the local computer.
+//
+// See: https://wezfurlong.org/wezterm/shell-integration.html#osc-7-escape-sequence-to-set-the-working-directory
+// See: https://iterm2.com/documentation-escape-codes.html#:~:text=RemoteHost%20and%20CurrentDir%3A-,OSC%207,-%3B%20%5BPs%5D%20ST
+func NotifyWorkingDirectory(host string, paths ...string) string {
+ path := path.Join(paths...)
+ u := &url.URL{
+ Scheme: "file",
+ Host: host,
+ Path: path,
+ }
+ return "\x1b]7;" + u.String() + "\x07"
+}
diff --git a/vendor/github.com/charmbracelet/x/ansi/doc.go b/vendor/github.com/charmbracelet/x/ansi/doc.go
new file mode 100644
index 0000000000..e955e9f1b7
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/ansi/doc.go
@@ -0,0 +1,7 @@
+// Package ansi defines common ANSI escape sequences based on the ECMA-48
+// specs.
+//
+// All sequences use 7-bit C1 control codes, which are supported by most
+// terminal emulators. OSC sequences are terminated by a BEL for wider
+// compatibility with terminals.
+package ansi
diff --git a/vendor/github.com/charmbracelet/x/ansi/finalterm.go b/vendor/github.com/charmbracelet/x/ansi/finalterm.go
new file mode 100644
index 0000000000..2c28347284
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/ansi/finalterm.go
@@ -0,0 +1,67 @@
+package ansi
+
+import "strings"
+
+// FinalTerm returns an escape sequence that is used for shell integrations.
+// Originally, FinalTerm designed the protocol hence the name.
+//
+// OSC 133 ; Ps ; Pm ST
+// OSC 133 ; Ps ; Pm BEL
+//
+// See: https://iterm2.com/documentation-shell-integration.html
+func FinalTerm(pm ...string) string {
+ return "\x1b]133;" + strings.Join(pm, ";") + "\x07"
+}
+
+// FinalTermPrompt returns an escape sequence that is used for shell
+// integrations prompt marks. This is sent just before the start of the shell
+// prompt.
+//
+// This is an alias for FinalTerm("A").
+func FinalTermPrompt(pm ...string) string {
+ if len(pm) == 0 {
+ return FinalTerm("A")
+ }
+ return FinalTerm(append([]string{"A"}, pm...)...)
+}
+
+// FinalTermCmdStart returns an escape sequence that is used for shell
+// integrations command start marks. This is sent just after the end of the
+// shell prompt, before the user enters a command.
+//
+// This is an alias for FinalTerm("B").
+func FinalTermCmdStart(pm ...string) string {
+ if len(pm) == 0 {
+ return FinalTerm("B")
+ }
+ return FinalTerm(append([]string{"B"}, pm...)...)
+}
+
+// FinalTermCmdExecuted returns an escape sequence that is used for shell
+// integrations command executed marks. This is sent just before the start of
+// the command output.
+//
+// This is an alias for FinalTerm("C").
+func FinalTermCmdExecuted(pm ...string) string {
+ if len(pm) == 0 {
+ return FinalTerm("C")
+ }
+ return FinalTerm(append([]string{"C"}, pm...)...)
+}
+
+// FinalTermCmdFinished returns an escape sequence that is used for shell
+// integrations command finished marks.
+//
+// If the command was sent after
+// [FinalTermCmdStart], it indicates that the command was aborted. If the
+// command was sent after [FinalTermCmdExecuted], it indicates the end of the
+// command output. If neither was sent, [FinalTermCmdFinished] should be
+// ignored.
+//
+// This is an alias for FinalTerm("D").
+func FinalTermCmdFinished(pm ...string) string {
+ if len(pm) == 0 {
+ return FinalTerm("D")
+ }
+ return FinalTerm(append([]string{"D"}, pm...)...)
+}
diff --git a/vendor/github.com/charmbracelet/x/ansi/focus.go b/vendor/github.com/charmbracelet/x/ansi/focus.go
new file mode 100644
index 0000000000..4e0207cebb
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/ansi/focus.go
@@ -0,0 +1,9 @@
+package ansi
+
+// Focus is an escape sequence to notify the terminal that it has focus.
+// This is used with [FocusEventMode].
+const Focus = "\x1b[I"
+
+// Blur is an escape sequence to notify the terminal that it has lost focus.
+// This is used with [FocusEventMode].
+const Blur = "\x1b[O"
diff --git a/vendor/github.com/charmbracelet/x/ansi/graphics.go b/vendor/github.com/charmbracelet/x/ansi/graphics.go
new file mode 100644
index 0000000000..d4a693b725
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/ansi/graphics.go
@@ -0,0 +1,62 @@
+package ansi
+
+import (
+ "bytes"
+ "strconv"
+ "strings"
+)
+
+// SixelGraphics returns a sequence that encodes the given sixel image payload to
+// a DCS sixel sequence.
+//
+// DCS p1; p2; p3; q [sixel payload] ST
+//
+// p1 = pixel aspect ratio, deprecated and replaced by pixel metrics in the payload
+//
+// p2 = This is supposed to be 0 for transparency, but terminals don't seem to
+// to use it properly. Value 0 leaves an unsightly black bar on all terminals
+// I've tried and looks correct with value 1.
+//
+// p3 = Horizontal grid size parameter. Everyone ignores this and uses a fixed grid
+// size, as far as I can tell.
+//
+// See https://shuford.invisible-island.net/all_about_sixels.txt
+func SixelGraphics(p1, p2, p3 int, payload []byte) string {
+ var buf bytes.Buffer
+
+ buf.WriteString("\x1bP")
+ if p1 >= 0 {
+ buf.WriteString(strconv.Itoa(p1))
+ }
+ buf.WriteByte(';')
+ if p2 >= 0 {
+ buf.WriteString(strconv.Itoa(p2))
+ }
+ if p3 > 0 {
+ buf.WriteByte(';')
+ buf.WriteString(strconv.Itoa(p3))
+ }
+ buf.WriteByte('q')
+ buf.Write(payload)
+ buf.WriteString("\x1b\\")
+
+ return buf.String()
+}
+
+// KittyGraphics returns a sequence that encodes the given image in the Kitty
+// graphics protocol.
+//
+// APC G [comma separated options] ; [base64 encoded payload] ST
+//
+// See https://sw.kovidgoyal.net/kitty/graphics-protocol/
+func KittyGraphics(payload []byte, opts ...string) string {
+ var buf bytes.Buffer
+ buf.WriteString("\x1b_G")
+ buf.WriteString(strings.Join(opts, ","))
+ if len(payload) > 0 {
+ buf.WriteString(";")
+ buf.Write(payload)
+ }
+ buf.WriteString("\x1b\\")
+ return buf.String()
+}
diff --git a/vendor/github.com/charmbracelet/x/ansi/hyperlink.go b/vendor/github.com/charmbracelet/x/ansi/hyperlink.go
new file mode 100644
index 0000000000..323bfe932a
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/ansi/hyperlink.go
@@ -0,0 +1,28 @@
+package ansi
+
+import "strings"
+
+// SetHyperlink returns a sequence for starting a hyperlink.
+//
+// OSC 8 ; Params ; Uri ST
+// OSC 8 ; Params ; Uri BEL
+//
+// To reset the hyperlink, omit the URI.
+//
+// See: https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda
+func SetHyperlink(uri string, params ...string) string {
+ var p string
+ if len(params) > 0 {
+ p = strings.Join(params, ":")
+ }
+ return "\x1b]8;" + p + ";" + uri + "\x07"
+}
+
+// ResetHyperlink returns a sequence for resetting the hyperlink.
+//
+// This is equivalent to SetHyperlink("", params...).
+//
+// See: https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda
+func ResetHyperlink(params ...string) string {
+ return SetHyperlink("", params...)
+}
diff --git a/vendor/github.com/charmbracelet/x/ansi/inband.go b/vendor/github.com/charmbracelet/x/ansi/inband.go
new file mode 100644
index 0000000000..cf29b24857
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/ansi/inband.go
@@ -0,0 +1,24 @@
+package ansi
+
+import "fmt"
+
+// InBandResize encodes an in-band terminal resize event sequence.
+//
+// CSI 48 ; height_cells ; widht_cells ; height_pixels ; width_pixels t
+//
+// See https://gist.github.com/rockorager/e695fb2924d36b2bcf1fff4a3704bd83
+func InBandResize(heightCells, widthCells, heightPixels, widthPixels int) string {
+ if heightCells < 0 {
+ heightCells = 0
+ }
+ if widthCells < 0 {
+ widthCells = 0
+ }
+ if heightPixels < 0 {
+ heightPixels = 0
+ }
+ if widthPixels < 0 {
+ widthPixels = 0
+ }
+ return fmt.Sprintf("\x1b[48;%d;%d;%d;%dt", heightCells, widthCells, heightPixels, widthPixels)
+}
diff --git a/vendor/github.com/charmbracelet/x/ansi/iterm2.go b/vendor/github.com/charmbracelet/x/ansi/iterm2.go
new file mode 100644
index 0000000000..0ecb336da1
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/ansi/iterm2.go
@@ -0,0 +1,18 @@
+package ansi
+
+import "fmt"
+
+// ITerm2 returns a sequence that uses the iTerm2 proprietary protocol. Use the
+// iterm2 package for a more convenient API.
+//
+// OSC 1337 ; key = value ST
+//
+// Example:
+//
+// ITerm2(iterm2.File{...})
+//
+// See https://iterm2.com/documentation-escape-codes.html
+// See https://iterm2.com/documentation-images.html
+func ITerm2(data any) string {
+ return "\x1b]1337;" + fmt.Sprint(data) + "\x07"
+}
diff --git a/vendor/github.com/charmbracelet/x/ansi/keypad.go b/vendor/github.com/charmbracelet/x/ansi/keypad.go
new file mode 100644
index 0000000000..9183c6a7ec
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/ansi/keypad.go
@@ -0,0 +1,28 @@
+package ansi
+
+// Keypad Application Mode (DECKPAM) is a mode that determines whether the
+// keypad sends application sequences or ANSI sequences.
+//
+// This works like enabling [DECNKM].
+// Use [NumericKeypadMode] to set the numeric keypad mode.
+//
+// ESC =
+//
+// See: https://vt100.net/docs/vt510-rm/DECKPAM.html
+const (
+ KeypadApplicationMode = "\x1b="
+ DECKPAM = KeypadApplicationMode
+)
+
+// Keypad Numeric Mode (DECKPNM) is a mode that determines whether the keypad
+// sends application sequences or ANSI sequences.
+//
+// This works the same as disabling [DECNKM].
+//
+// ESC >
+//
+// See: https://vt100.net/docs/vt510-rm/DECKPNM.html
+const (
+ KeypadNumericMode = "\x1b>"
+ DECKPNM = KeypadNumericMode
+)
diff --git a/vendor/github.com/charmbracelet/x/ansi/kitty.go b/vendor/github.com/charmbracelet/x/ansi/kitty.go
new file mode 100644
index 0000000000..124ab839e2
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/ansi/kitty.go
@@ -0,0 +1,90 @@
+package ansi
+
+import "strconv"
+
+// Kitty keyboard protocol progressive enhancement flags.
+// See: https://sw.kovidgoyal.net/kitty/keyboard-protocol/#progressive-enhancement
+const (
+ KittyDisambiguateEscapeCodes = 1 << iota
+ KittyReportEventTypes
+ KittyReportAlternateKeys
+ KittyReportAllKeysAsEscapeCodes
+ KittyReportAssociatedKeys
+
+ KittyAllFlags = KittyDisambiguateEscapeCodes | KittyReportEventTypes |
+ KittyReportAlternateKeys | KittyReportAllKeysAsEscapeCodes | KittyReportAssociatedKeys
+)
+
+// RequestKittyKeyboard is a sequence to request the terminal Kitty keyboard
+// protocol enabled flags.
+//
+// See: https://sw.kovidgoyal.net/kitty/keyboard-protocol/
+const RequestKittyKeyboard = "\x1b[?u"
+
+// KittyKeyboard returns a sequence to request keyboard enhancements from the terminal.
+// The flags argument is a bitmask of the Kitty keyboard protocol flags. While
+// mode specifies how the flags should be interpreted.
+//
+// Possible values for flags mask:
+//
+// 1: Disambiguate escape codes
+// 2: Report event types
+// 4: Report alternate keys
+// 8: Report all keys as escape codes
+// 16: Report associated text
+//
+// Possible values for mode:
+//
+// 1: Set given flags and unset all others
+// 2: Set given flags and keep existing flags unchanged
+// 3: Unset given flags and keep existing flags unchanged
+//
+// See https://sw.kovidgoyal.net/kitty/keyboard-protocol/#progressive-enhancement
+func KittyKeyboard(flags, mode int) string {
+ return "\x1b[=" + strconv.Itoa(flags) + ";" + strconv.Itoa(mode) + "u"
+}
+
+// PushKittyKeyboard returns a sequence to push the given flags to the terminal
+// Kitty Keyboard stack.
+//
+// Possible values for flags mask:
+//
+// 0: Disable all features
+// 1: Disambiguate escape codes
+// 2: Report event types
+// 4: Report alternate keys
+// 8: Report all keys as escape codes
+// 16: Report associated text
+//
+// CSI > flags u
+//
+// See https://sw.kovidgoyal.net/kitty/keyboard-protocol/#progressive-enhancement
+func PushKittyKeyboard(flags int) string {
+ var f string
+ if flags > 0 {
+ f = strconv.Itoa(flags)
+ }
+
+ return "\x1b[>" + f + "u"
+}
+
+// DisableKittyKeyboard is a sequence to push zero into the terminal Kitty
+// Keyboard stack to disable the protocol.
+//
+// This is equivalent to PushKittyKeyboard(0).
+const DisableKittyKeyboard = "\x1b[>u"
+
+// PopKittyKeyboard returns a sequence to pop n number of flags from the
+// terminal Kitty Keyboard stack.
+//
+// CSI < flags u
+//
+// See https://sw.kovidgoyal.net/kitty/keyboard-protocol/#progressive-enhancement
+func PopKittyKeyboard(n int) string {
+ var num string
+ if n > 0 {
+ num = strconv.Itoa(n)
+ }
+
+ return "\x1b[<" + num + "u"
+}
diff --git a/vendor/github.com/charmbracelet/x/ansi/kitty/decoder.go b/vendor/github.com/charmbracelet/x/ansi/kitty/decoder.go
new file mode 100644
index 0000000000..7db15156ed
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/ansi/kitty/decoder.go
@@ -0,0 +1,86 @@
+// Package kitty provides Kitty terminal graphics protocol functionality.
+package kitty
+
+import (
+ "compress/zlib"
+ "fmt"
+ "image"
+ "image/color"
+ "image/png"
+ "io"
+)
+
+// Decoder is a decoder for the Kitty graphics protocol. It supports decoding
+// images in the 24-bit [RGB], 32-bit [RGBA], and [PNG] formats. It can also
+// decompress data using zlib.
+// The default format is 32-bit [RGBA].
+type Decoder struct {
+ // Uses zlib decompression.
+ Decompress bool
+
+ // Can be one of [RGB], [RGBA], or [PNG].
+ Format int
+
+ // Width of the image in pixels. This can be omitted if the image is [PNG]
+ // formatted.
+ Width int
+
+ // Height of the image in pixels. This can be omitted if the image is [PNG]
+ // formatted.
+ Height int
+}
+
+// Decode decodes the image data from r in the specified format.
+func (d *Decoder) Decode(r io.Reader) (image.Image, error) {
+ if d.Decompress {
+ zr, err := zlib.NewReader(r)
+ if err != nil {
+ return nil, fmt.Errorf("failed to create zlib reader: %w", err)
+ }
+
+ defer zr.Close() //nolint:errcheck
+ r = zr
+ }
+
+ if d.Format == 0 {
+ d.Format = RGBA
+ }
+
+ switch d.Format {
+ case RGBA, RGB:
+ return d.decodeRGBA(r, d.Format == RGBA)
+
+ case PNG:
+ return png.Decode(r) //nolint:wrapcheck
+
+ default:
+ return nil, fmt.Errorf("unsupported format: %d", d.Format)
+ }
+}
+
+// decodeRGBA decodes the image data in 32-bit RGBA or 24-bit RGB formats.
+func (d *Decoder) decodeRGBA(r io.Reader, alpha bool) (image.Image, error) {
+ m := image.NewRGBA(image.Rect(0, 0, d.Width, d.Height))
+
+ var buf []byte
+ if alpha {
+ buf = make([]byte, 4)
+ } else {
+ buf = make([]byte, 3)
+ }
+
+ for y := range d.Height {
+ for x := range d.Width {
+ if _, err := io.ReadFull(r, buf[:]); err != nil {
+ return nil, fmt.Errorf("failed to read pixel data: %w", err)
+ }
+ if alpha {
+ m.SetRGBA(x, y, color.RGBA{buf[0], buf[1], buf[2], buf[3]})
+ } else {
+ m.SetRGBA(x, y, color.RGBA{buf[0], buf[1], buf[2], 0xff})
+ }
+ }
+ }
+
+ return m, nil
+}
diff --git a/vendor/github.com/charmbracelet/x/ansi/kitty/encoder.go b/vendor/github.com/charmbracelet/x/ansi/kitty/encoder.go
new file mode 100644
index 0000000000..7f7efe8366
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/ansi/kitty/encoder.go
@@ -0,0 +1,64 @@
+package kitty
+
+import (
+ "compress/zlib"
+ "fmt"
+ "image"
+ "image/png"
+ "io"
+)
+
+// Encoder is an encoder for the Kitty graphics protocol. It supports encoding
+// images in the 24-bit [RGB], 32-bit [RGBA], and [PNG] formats, and
+// compressing the data using zlib.
+// The default format is 32-bit [RGBA].
+type Encoder struct {
+ // Uses zlib compression.
+ Compress bool
+
+ // Can be one of [RGBA], [RGB], or [PNG].
+ Format int
+}
+
+// Encode encodes the image data in the specified format and writes it to w.
+func (e *Encoder) Encode(w io.Writer, m image.Image) error {
+ if m == nil {
+ return nil
+ }
+
+ if e.Compress {
+ zw := zlib.NewWriter(w)
+ defer zw.Close() //nolint:errcheck
+ w = zw
+ }
+
+ if e.Format == 0 {
+ e.Format = RGBA
+ }
+
+ switch e.Format {
+ case RGBA, RGB:
+ bounds := m.Bounds()
+ for y := bounds.Min.Y; y < bounds.Max.Y; y++ {
+ for x := bounds.Min.X; x < bounds.Max.X; x++ {
+ r, g, b, a := m.At(x, y).RGBA()
+ switch e.Format {
+ case RGBA:
+ w.Write([]byte{byte(r >> 8), byte(g >> 8), byte(b >> 8), byte(a >> 8)}) //nolint:errcheck,gosec
+ case RGB:
+ w.Write([]byte{byte(r >> 8), byte(g >> 8), byte(b >> 8)}) //nolint:errcheck,gosec
+ }
+ }
+ }
+
+ case PNG:
+ if err := png.Encode(w, m); err != nil {
+ return fmt.Errorf("failed to encode PNG: %w", err)
+ }
+
+ default:
+ return fmt.Errorf("unsupported format: %d", e.Format)
+ }
+
+ return nil
+}
diff --git a/vendor/github.com/charmbracelet/x/ansi/kitty/graphics.go b/vendor/github.com/charmbracelet/x/ansi/kitty/graphics.go
new file mode 100644
index 0000000000..10862be87d
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/ansi/kitty/graphics.go
@@ -0,0 +1,414 @@
+package kitty
+
+import "errors"
+
+// ErrMissingFile is returned when the file path is missing.
+var ErrMissingFile = errors.New("missing file path")
+
+// MaxChunkSize is the maximum chunk size for the image data.
+const MaxChunkSize = 1024 * 4
+
+// Placeholder is a special Unicode character that can be used as a placeholder
+// for an image.
+const Placeholder = '\U0010EEEE'
+
+// Graphics image format.
+const (
+ // 32-bit RGBA format.
+ RGBA = 32
+
+ // 24-bit RGB format.
+ RGB = 24
+
+ // PNG format.
+ PNG = 100
+)
+
+// Compression types.
+const (
+ Zlib = 'z'
+)
+
+// Transmission types.
+const (
+ // The data transmitted directly in the escape sequence.
+ Direct = 'd'
+
+ // The data transmitted in a regular file.
+ File = 'f'
+
+ // A temporary file is used and deleted after transmission.
+ TempFile = 't'
+
+ // A shared memory object.
+ // For POSIX see https://pubs.opengroup.org/onlinepubs/9699919799/functions/shm_open.html
+ // For Windows see https://docs.microsoft.com/en-us/windows/win32/memory/creating-named-shared-memory
+ SharedMemory = 's'
+)
+
+// Action types.
+const (
+ // Transmit image data.
+ Transmit = 't'
+ // TransmitAndPut transmit image data and display (put) it.
+ TransmitAndPut = 'T'
+ // Query terminal for image info.
+ Query = 'q'
+ // Put (display) previously transmitted image.
+ Put = 'p'
+ // Delete image.
+ Delete = 'd'
+ // Frame transmits data for animation frames.
+ Frame = 'f'
+ // Animate controls animation.
+ Animate = 'a'
+ // Compose composes animation frames.
+ Compose = 'c'
+)
+
+// Delete types.
+const (
+ // Delete all placements visible on screen.
+ DeleteAll = 'a'
+ // Delete all images with the specified id, specified using the i key. If
+ // you specify a p key for the placement id as well, then only the
+ // placement with the specified image id and placement id will be deleted.
+ DeleteID = 'i'
+ // Delete newest image with the specified number, specified using the I
+ // key. If you specify a p key for the placement id as well, then only the
+ // placement with the specified number and placement id will be deleted.
+ DeleteNumber = 'n'
+ // Delete all placements that intersect with the current cursor position.
+ DeleteCursor = 'c'
+ // Delete animation frames.
+ DeleteFrames = 'f'
+ // Delete all placements that intersect a specific cell, the cell is
+ // specified using the x and y keys.
+ DeleteCell = 'p'
+ // Delete all placements that intersect a specific cell having a specific
+ // z-index. The cell and z-index is specified using the x, y and z keys.
+ DeleteCellZ = 'q'
+ // Delete all images whose id is greater than or equal to the value of the x
+ // key and less than or equal to the value of the y.
+ DeleteRange = 'r'
+ // Delete all placements that intersect the specified column, specified using
+ // the x key.
+ DeleteColumn = 'x'
+ // Delete all placements that intersect the specified row, specified using
+ // the y key.
+ DeleteRow = 'y'
+ // Delete all placements that have the specified z-index, specified using the
+ // z key.
+ DeleteZ = 'z'
+)
+
+// Diacritic returns the diacritic rune at the specified index. If the index is
+// out of bounds, the first diacritic rune is returned.
+func Diacritic(i int) rune {
+ if i < 0 || i >= len(diacritics) {
+ return diacritics[0]
+ }
+ return diacritics[i]
+}
+
+// From https://sw.kovidgoyal.net/kitty/_downloads/f0a0de9ec8d9ff4456206db8e0814937/rowcolumn-diacritics.txt
+// See https://sw.kovidgoyal.net/kitty/graphics-protocol/#unicode-placeholders for further explanation.
+var diacritics = []rune{
+ '\u0305',
+ '\u030D',
+ '\u030E',
+ '\u0310',
+ '\u0312',
+ '\u033D',
+ '\u033E',
+ '\u033F',
+ '\u0346',
+ '\u034A',
+ '\u034B',
+ '\u034C',
+ '\u0350',
+ '\u0351',
+ '\u0352',
+ '\u0357',
+ '\u035B',
+ '\u0363',
+ '\u0364',
+ '\u0365',
+ '\u0366',
+ '\u0367',
+ '\u0368',
+ '\u0369',
+ '\u036A',
+ '\u036B',
+ '\u036C',
+ '\u036D',
+ '\u036E',
+ '\u036F',
+ '\u0483',
+ '\u0484',
+ '\u0485',
+ '\u0486',
+ '\u0487',
+ '\u0592',
+ '\u0593',
+ '\u0594',
+ '\u0595',
+ '\u0597',
+ '\u0598',
+ '\u0599',
+ '\u059C',
+ '\u059D',
+ '\u059E',
+ '\u059F',
+ '\u05A0',
+ '\u05A1',
+ '\u05A8',
+ '\u05A9',
+ '\u05AB',
+ '\u05AC',
+ '\u05AF',
+ '\u05C4',
+ '\u0610',
+ '\u0611',
+ '\u0612',
+ '\u0613',
+ '\u0614',
+ '\u0615',
+ '\u0616',
+ '\u0617',
+ '\u0657',
+ '\u0658',
+ '\u0659',
+ '\u065A',
+ '\u065B',
+ '\u065D',
+ '\u065E',
+ '\u06D6',
+ '\u06D7',
+ '\u06D8',
+ '\u06D9',
+ '\u06DA',
+ '\u06DB',
+ '\u06DC',
+ '\u06DF',
+ '\u06E0',
+ '\u06E1',
+ '\u06E2',
+ '\u06E4',
+ '\u06E7',
+ '\u06E8',
+ '\u06EB',
+ '\u06EC',
+ '\u0730',
+ '\u0732',
+ '\u0733',
+ '\u0735',
+ '\u0736',
+ '\u073A',
+ '\u073D',
+ '\u073F',
+ '\u0740',
+ '\u0741',
+ '\u0743',
+ '\u0745',
+ '\u0747',
+ '\u0749',
+ '\u074A',
+ '\u07EB',
+ '\u07EC',
+ '\u07ED',
+ '\u07EE',
+ '\u07EF',
+ '\u07F0',
+ '\u07F1',
+ '\u07F3',
+ '\u0816',
+ '\u0817',
+ '\u0818',
+ '\u0819',
+ '\u081B',
+ '\u081C',
+ '\u081D',
+ '\u081E',
+ '\u081F',
+ '\u0820',
+ '\u0821',
+ '\u0822',
+ '\u0823',
+ '\u0825',
+ '\u0826',
+ '\u0827',
+ '\u0829',
+ '\u082A',
+ '\u082B',
+ '\u082C',
+ '\u082D',
+ '\u0951',
+ '\u0953',
+ '\u0954',
+ '\u0F82',
+ '\u0F83',
+ '\u0F86',
+ '\u0F87',
+ '\u135D',
+ '\u135E',
+ '\u135F',
+ '\u17DD',
+ '\u193A',
+ '\u1A17',
+ '\u1A75',
+ '\u1A76',
+ '\u1A77',
+ '\u1A78',
+ '\u1A79',
+ '\u1A7A',
+ '\u1A7B',
+ '\u1A7C',
+ '\u1B6B',
+ '\u1B6D',
+ '\u1B6E',
+ '\u1B6F',
+ '\u1B70',
+ '\u1B71',
+ '\u1B72',
+ '\u1B73',
+ '\u1CD0',
+ '\u1CD1',
+ '\u1CD2',
+ '\u1CDA',
+ '\u1CDB',
+ '\u1CE0',
+ '\u1DC0',
+ '\u1DC1',
+ '\u1DC3',
+ '\u1DC4',
+ '\u1DC5',
+ '\u1DC6',
+ '\u1DC7',
+ '\u1DC8',
+ '\u1DC9',
+ '\u1DCB',
+ '\u1DCC',
+ '\u1DD1',
+ '\u1DD2',
+ '\u1DD3',
+ '\u1DD4',
+ '\u1DD5',
+ '\u1DD6',
+ '\u1DD7',
+ '\u1DD8',
+ '\u1DD9',
+ '\u1DDA',
+ '\u1DDB',
+ '\u1DDC',
+ '\u1DDD',
+ '\u1DDE',
+ '\u1DDF',
+ '\u1DE0',
+ '\u1DE1',
+ '\u1DE2',
+ '\u1DE3',
+ '\u1DE4',
+ '\u1DE5',
+ '\u1DE6',
+ '\u1DFE',
+ '\u20D0',
+ '\u20D1',
+ '\u20D4',
+ '\u20D5',
+ '\u20D6',
+ '\u20D7',
+ '\u20DB',
+ '\u20DC',
+ '\u20E1',
+ '\u20E7',
+ '\u20E9',
+ '\u20F0',
+ '\u2CEF',
+ '\u2CF0',
+ '\u2CF1',
+ '\u2DE0',
+ '\u2DE1',
+ '\u2DE2',
+ '\u2DE3',
+ '\u2DE4',
+ '\u2DE5',
+ '\u2DE6',
+ '\u2DE7',
+ '\u2DE8',
+ '\u2DE9',
+ '\u2DEA',
+ '\u2DEB',
+ '\u2DEC',
+ '\u2DED',
+ '\u2DEE',
+ '\u2DEF',
+ '\u2DF0',
+ '\u2DF1',
+ '\u2DF2',
+ '\u2DF3',
+ '\u2DF4',
+ '\u2DF5',
+ '\u2DF6',
+ '\u2DF7',
+ '\u2DF8',
+ '\u2DF9',
+ '\u2DFA',
+ '\u2DFB',
+ '\u2DFC',
+ '\u2DFD',
+ '\u2DFE',
+ '\u2DFF',
+ '\uA66F',
+ '\uA67C',
+ '\uA67D',
+ '\uA6F0',
+ '\uA6F1',
+ '\uA8E0',
+ '\uA8E1',
+ '\uA8E2',
+ '\uA8E3',
+ '\uA8E4',
+ '\uA8E5',
+ '\uA8E6',
+ '\uA8E7',
+ '\uA8E8',
+ '\uA8E9',
+ '\uA8EA',
+ '\uA8EB',
+ '\uA8EC',
+ '\uA8ED',
+ '\uA8EE',
+ '\uA8EF',
+ '\uA8F0',
+ '\uA8F1',
+ '\uAAB0',
+ '\uAAB2',
+ '\uAAB3',
+ '\uAAB7',
+ '\uAAB8',
+ '\uAABE',
+ '\uAABF',
+ '\uAAC1',
+ '\uFE20',
+ '\uFE21',
+ '\uFE22',
+ '\uFE23',
+ '\uFE24',
+ '\uFE25',
+ '\uFE26',
+ '\U00010A0F',
+ '\U00010A38',
+ '\U0001D185',
+ '\U0001D186',
+ '\U0001D187',
+ '\U0001D188',
+ '\U0001D189',
+ '\U0001D1AA',
+ '\U0001D1AB',
+ '\U0001D1AC',
+ '\U0001D1AD',
+ '\U0001D242',
+ '\U0001D243',
+ '\U0001D244',
+}
diff --git a/vendor/github.com/charmbracelet/x/ansi/kitty/options.go b/vendor/github.com/charmbracelet/x/ansi/kitty/options.go
new file mode 100644
index 0000000000..bf3f8f0662
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/ansi/kitty/options.go
@@ -0,0 +1,386 @@
+package kitty
+
+import (
+ "encoding"
+ "fmt"
+ "strconv"
+ "strings"
+)
+
+var (
+ _ encoding.TextMarshaler = Options{}
+ _ encoding.TextUnmarshaler = &Options{}
+)
+
+// Stringish is a type constraint for types that are either a string or a
+// byte slice.
+type Stringish interface{ string | []byte }
+
+// Options represents a Kitty Graphics Protocol options.
+type Options struct {
+ // Common options.
+
+ // Action (a=t) is the action to be performed on the image. Can be one of
+ // [Transmit], [TransmitDisplay], [Query], [Put], [Delete], [Frame],
+ // [Animate], [Compose].
+ Action byte
+
+ // Quite is the kitty graphics quiet mode.
+ //
+ // Deprecated: misspelled field, use [Options.Quiet] instead. Any non-zero
+ // Quite overrides Quiet.
+ Quite byte
+
+ // Quiet mode (q=0) is the quiet mode. Can be either zero, one, or two
+ // where zero is the default, 1 suppresses OK responses, and 2 suppresses
+ // both OK and error responses.
+ Quiet byte
+
+ // Transmission options.
+
+ // ID (i=) is the image ID. The ID is a unique identifier for the image.
+ // Must be a positive integer up to [math.MaxUint32].
+ ID int
+
+ // PlacementID (p=) is the placement ID. The placement ID is a unique
+ // identifier for the placement of the image. Must be a positive integer up
+ // to [math.MaxUint32].
+ PlacementID int
+
+ // Number (I=0) is the number of images to be transmitted.
+ Number int
+
+ // Format (f=32) is the image format. One of [RGBA], [RGB], [PNG].
+ Format int
+
+ // ImageWidth (s=0) is the transmitted image width.
+ ImageWidth int
+
+ // ImageHeight (v=0) is the transmitted image height.
+ ImageHeight int
+
+ // Compression (o=) is the image compression type. Can be [Zlib] or zero.
+ Compression byte
+
+ // Transmission (t=d) is the image transmission type. Can be [Direct], [File],
+ // [TempFile], or[SharedMemory].
+ Transmission byte
+
+ // File is the file path to be used when the transmission type is [File].
+ // If [Options.Transmission] is omitted i.e. zero and this is non-empty,
+ // the transmission type is set to [File].
+ File string
+
+ // Size (S=0) is the size to be read from the transmission medium.
+ Size int
+
+ // Offset (O=0) is the offset byte to start reading from the transmission
+ // medium.
+ Offset int
+
+ // Chunk (m=) whether the image is transmitted in chunks. Can be either
+ // zero or one. When true, the image is transmitted in chunks. Each chunk
+ // must be a multiple of 4, and up to [MaxChunkSize] bytes. Each chunk must
+ // have the m=1 option except for the last chunk which must have m=0.
+ Chunk bool
+
+ // ChunkFormatter is the function used to format each chunk when
+ // [Options.Chunk] is true. If nil, the chunks are sent as is.
+ ChunkFormatter func(chunk string) string
+
+ // Display options.
+
+ // X (x=0) is the pixel X coordinate of the image to start displaying.
+ X int
+
+ // Y (y=0) is the pixel Y coordinate of the image to start displaying.
+ Y int
+
+ // Z (z=0) is the Z coordinate of the image to display.
+ Z int
+
+ // Width (w=0) is the width of the image to display.
+ Width int
+
+ // Height (h=0) is the height of the image to display.
+ Height int
+
+ // OffsetX (X=0) is the OffsetX coordinate of the cursor cell to start
+ // displaying the image. OffsetX=0 is the leftmost cell. This must be
+ // smaller than the terminal cell width.
+ OffsetX int
+
+ // OffsetY (Y=0) is the OffsetY coordinate of the cursor cell to start
+ // displaying the image. OffsetY=0 is the topmost cell. This must be
+ // smaller than the terminal cell height.
+ OffsetY int
+
+ // Columns (c=0) is the number of columns to display the image. The image
+ // will be scaled to fit the number of columns.
+ Columns int
+
+ // Rows (r=0) is the number of rows to display the image. The image will be
+ // scaled to fit the number of rows.
+ Rows int
+
+ // VirtualPlacement (U=0) whether to use virtual placement. This is used
+ // with Unicode [Placeholder] to display images.
+ VirtualPlacement bool
+
+ // DoNotMoveCursor (C=0) whether to move the cursor after displaying the
+ // image.
+ DoNotMoveCursor bool
+
+ // ParentID (P=0) is the parent image ID. The parent ID is the ID of the
+ // image that is the parent of the current image. This is used with Unicode
+ // [Placeholder] to display images relative to the parent image.
+ ParentID int
+
+ // ParentPlacementID (Q=0) is the parent placement ID. The parent placement
+ // ID is the ID of the placement of the parent image. This is used with
+ // Unicode [Placeholder] to display images relative to the parent image.
+ ParentPlacementID int
+
+ // Delete options.
+
+ // Delete (d=a) is the delete action. Can be one of [DeleteAll],
+ // [DeleteID], [DeleteNumber], [DeleteCursor], [DeleteFrames],
+ // [DeleteCell], [DeleteCellZ], [DeleteRange], [DeleteColumn], [DeleteRow],
+ // [DeleteZ].
+ Delete byte
+
+ // DeleteResources indicates whether to delete the resources associated
+ // with the image.
+ DeleteResources bool
+}
+
+// Options returns the options as a slice of a key-value pairs.
+func (o *Options) Options() (opts []string) {
+ opts = []string{}
+ if o.Format == 0 {
+ o.Format = RGBA
+ }
+
+ if o.Action == 0 {
+ o.Action = Transmit
+ }
+
+ if o.Delete == 0 {
+ o.Delete = DeleteAll
+ }
+
+ if o.Transmission == 0 {
+ if len(o.File) > 0 {
+ o.Transmission = File
+ } else {
+ o.Transmission = Direct
+ }
+ }
+
+ if o.Format != RGBA {
+ opts = append(opts, fmt.Sprintf("f=%d", o.Format))
+ }
+
+ quiet := o.Quiet
+ if o.Quite > 0 {
+ // handle deprecated Quite field.
+ quiet = o.Quite
+ }
+ if quiet > 0 {
+ opts = append(opts, fmt.Sprintf("q=%d", quiet))
+ }
+
+ if o.ID > 0 {
+ opts = append(opts, fmt.Sprintf("i=%d", o.ID))
+ }
+
+ if o.PlacementID > 0 {
+ opts = append(opts, fmt.Sprintf("p=%d", o.PlacementID))
+ }
+
+ if o.Number > 0 {
+ opts = append(opts, fmt.Sprintf("I=%d", o.Number))
+ }
+
+ if o.ImageWidth > 0 {
+ opts = append(opts, fmt.Sprintf("s=%d", o.ImageWidth))
+ }
+
+ if o.ImageHeight > 0 {
+ opts = append(opts, fmt.Sprintf("v=%d", o.ImageHeight))
+ }
+
+ if o.Transmission != Direct {
+ opts = append(opts, fmt.Sprintf("t=%c", o.Transmission))
+ }
+
+ if o.Size > 0 {
+ opts = append(opts, fmt.Sprintf("S=%d", o.Size))
+ }
+
+ if o.Offset > 0 {
+ opts = append(opts, fmt.Sprintf("O=%d", o.Offset))
+ }
+
+ if o.Compression == Zlib {
+ opts = append(opts, fmt.Sprintf("o=%c", o.Compression))
+ }
+
+ if o.VirtualPlacement {
+ opts = append(opts, "U=1")
+ }
+
+ if o.DoNotMoveCursor {
+ opts = append(opts, "C=1")
+ }
+
+ if o.ParentID > 0 {
+ opts = append(opts, fmt.Sprintf("P=%d", o.ParentID))
+ }
+
+ if o.ParentPlacementID > 0 {
+ opts = append(opts, fmt.Sprintf("Q=%d", o.ParentPlacementID))
+ }
+
+ if o.X > 0 {
+ opts = append(opts, fmt.Sprintf("x=%d", o.X))
+ }
+
+ if o.Y > 0 {
+ opts = append(opts, fmt.Sprintf("y=%d", o.Y))
+ }
+
+ if o.Z > 0 {
+ opts = append(opts, fmt.Sprintf("z=%d", o.Z))
+ }
+
+ if o.Width > 0 {
+ opts = append(opts, fmt.Sprintf("w=%d", o.Width))
+ }
+
+ if o.Height > 0 {
+ opts = append(opts, fmt.Sprintf("h=%d", o.Height))
+ }
+
+ if o.OffsetX > 0 {
+ opts = append(opts, fmt.Sprintf("X=%d", o.OffsetX))
+ }
+
+ if o.OffsetY > 0 {
+ opts = append(opts, fmt.Sprintf("Y=%d", o.OffsetY))
+ }
+
+ if o.Columns > 0 {
+ opts = append(opts, fmt.Sprintf("c=%d", o.Columns))
+ }
+
+ if o.Rows > 0 {
+ opts = append(opts, fmt.Sprintf("r=%d", o.Rows))
+ }
+
+ if o.Delete != DeleteAll || o.DeleteResources {
+ da := o.Delete
+ if o.DeleteResources {
+ da = da - ' ' // to uppercase
+ }
+
+ opts = append(opts, fmt.Sprintf("d=%c", da))
+ }
+
+ if o.Action != Transmit {
+ opts = append(opts, fmt.Sprintf("a=%c", o.Action))
+ }
+
+ return opts // complex function with multiple returns
+}
+
+// String returns the string representation of the options.
+func (o Options) String() string {
+ return strings.Join(o.Options(), ",")
+}
+
+// MarshalText returns the string representation of the options.
+func (o Options) MarshalText() ([]byte, error) {
+ return []byte(o.String()), nil
+}
+
+// UnmarshalText parses the options from the given string.
+func (o *Options) UnmarshalText(text []byte) error {
+ opts := strings.Split(string(text), ",")
+ for _, opt := range opts {
+ ps := strings.SplitN(opt, "=", 2)
+ if len(ps) != 2 || len(ps[1]) == 0 {
+ continue
+ }
+
+ switch ps[0] {
+ case "a":
+ o.Action = ps[1][0]
+ case "o":
+ o.Compression = ps[1][0]
+ case "t":
+ o.Transmission = ps[1][0]
+ case "d":
+ d := ps[1][0]
+ if d >= 'A' && d <= 'Z' {
+ o.DeleteResources = true
+ d = d + ' ' // to lowercase
+ }
+ o.Delete = d
+ case "i", "q", "p", "I", "f", "s", "v", "S", "O", "m", "x", "y", "z", "w", "h", "X", "Y", "c", "r", "U", "P", "Q":
+ v, err := strconv.Atoi(ps[1])
+ if err != nil {
+ continue
+ }
+
+ switch ps[0] {
+ case "i":
+ o.ID = v
+ case "q":
+ o.Quiet = byte(v) //nolint:gosec
+ case "p":
+ o.PlacementID = v
+ case "I":
+ o.Number = v
+ case "f":
+ o.Format = v
+ case "s":
+ o.ImageWidth = v
+ case "v":
+ o.ImageHeight = v
+ case "S":
+ o.Size = v
+ case "O":
+ o.Offset = v
+ case "m":
+ o.Chunk = v == 0 || v == 1
+ case "x":
+ o.X = v
+ case "y":
+ o.Y = v
+ case "z":
+ o.Z = v
+ case "w":
+ o.Width = v
+ case "h":
+ o.Height = v
+ case "X":
+ o.OffsetX = v
+ case "Y":
+ o.OffsetY = v
+ case "c":
+ o.Columns = v
+ case "r":
+ o.Rows = v
+ case "U":
+ o.VirtualPlacement = v == 1
+ case "P":
+ o.ParentID = v
+ case "Q":
+ o.ParentPlacementID = v
+ }
+ }
+ }
+
+ return nil
+}
diff --git a/vendor/github.com/charmbracelet/x/ansi/kitty/writer.go b/vendor/github.com/charmbracelet/x/ansi/kitty/writer.go
new file mode 100644
index 0000000000..6093b95b00
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/ansi/kitty/writer.go
@@ -0,0 +1,192 @@
+package kitty
+
+import (
+ "bytes"
+ "encoding/base64"
+ "errors"
+ "fmt"
+ "image"
+ "io"
+ "os"
+
+ "github.com/charmbracelet/x/ansi"
+)
+
+var (
+ // GraphicsTempDir is the directory where temporary files are stored.
+ // This is used in [WriteKittyGraphics] along with [os.CreateTemp].
+ GraphicsTempDir = ""
+
+ // GraphicsTempPattern is the pattern used to create temporary files.
+ // This is used in [WriteKittyGraphics] along with [os.CreateTemp].
+ // The Kitty Graphics protocol requires the file path to contain the
+ // substring "tty-graphics-protocol".
+ GraphicsTempPattern = "tty-graphics-protocol-*"
+)
+
+// EncodeGraphics writes an image using the Kitty Graphics protocol with the
+// given options to w. It chunks the written data if o.Chunk is true.
+//
+// You can omit m and use nil when rendering an image from a file. In this
+// case, you must provide a file path in o.File and use o.Transmission =
+// [File]. You can also use o.Transmission = [TempFile] to write
+// the image to a temporary file. In that case, the file path is ignored, and
+// the image is written to a temporary file that is automatically deleted by
+// the terminal.
+//
+// See https://sw.kovidgoyal.net/kitty/graphics-protocol/
+func EncodeGraphics(w io.Writer, m image.Image, o *Options) error {
+ if o == nil {
+ o = &Options{}
+ }
+
+ if o.Transmission == 0 && len(o.File) != 0 {
+ o.Transmission = File
+ }
+
+ var data bytes.Buffer // the data to be encoded into base64
+ e := &Encoder{
+ Compress: o.Compression == Zlib,
+ Format: o.Format,
+ }
+
+ switch o.Transmission {
+ case Direct:
+ if err := e.Encode(&data, m); err != nil {
+ return fmt.Errorf("failed to encode direct image: %w", err)
+ }
+
+ case SharedMemory:
+ //nolint:godox
+ // TODO: Implement shared memory
+ return fmt.Errorf("shared memory transmission is not yet implemented")
+
+ case File:
+ if len(o.File) == 0 {
+ return ErrMissingFile
+ }
+
+ f, err := os.Open(o.File)
+ if err != nil {
+ return fmt.Errorf("failed to open file: %w", err)
+ }
+
+ defer f.Close() //nolint:errcheck
+
+ stat, err := f.Stat()
+ if err != nil {
+ return fmt.Errorf("failed to get file info: %w", err)
+ }
+
+ mode := stat.Mode()
+ if !mode.IsRegular() {
+ return fmt.Errorf("file is not a regular file")
+ }
+
+ // Write the file path to the buffer
+ if _, err := data.WriteString(f.Name()); err != nil {
+ return fmt.Errorf("failed to write file path to buffer: %w", err)
+ }
+
+ case TempFile:
+ f, err := os.CreateTemp(GraphicsTempDir, GraphicsTempPattern)
+ if err != nil {
+ return fmt.Errorf("failed to create file: %w", err)
+ }
+
+ defer f.Close() //nolint:errcheck
+
+ if err := e.Encode(f, m); err != nil {
+ return fmt.Errorf("failed to encode image to file: %w", err)
+ }
+
+ // Write the file path to the buffer
+ if _, err := data.WriteString(f.Name()); err != nil {
+ return fmt.Errorf("failed to write file path to buffer: %w", err)
+ }
+ }
+
+ // Encode image to base64
+ var payload bytes.Buffer // the base64 encoded image to be written to w
+ b64 := base64.NewEncoder(base64.StdEncoding, &payload)
+ if _, err := data.WriteTo(b64); err != nil {
+ return fmt.Errorf("failed to write base64 encoded image to payload: %w", err)
+ }
+ if err := b64.Close(); err != nil {
+ return err //nolint:wrapcheck
+ }
+
+ // If not chunking, write all at once
+ if !o.Chunk {
+ _, err := io.WriteString(w, ansi.KittyGraphics(payload.Bytes(), o.Options()...))
+ return err //nolint:wrapcheck
+ }
+
+ // Write in chunks
+ var (
+ err error
+ n int
+ )
+ chunk := make([]byte, MaxChunkSize)
+ isFirstChunk := true
+ chunkFormatter := o.ChunkFormatter
+ if chunkFormatter == nil {
+ // Default to no formatting
+ chunkFormatter = func(s string) string { return s }
+ }
+
+ for {
+ // Stop if we read less than the chunk size [MaxChunkSize].
+ n, err = io.ReadFull(&payload, chunk)
+ if errors.Is(err, io.ErrUnexpectedEOF) || errors.Is(err, io.EOF) {
+ break
+ }
+ if err != nil {
+ return fmt.Errorf("failed to read chunk: %w", err)
+ }
+
+ opts := buildChunkOptions(o, isFirstChunk, false)
+ if _, err := io.WriteString(w,
+ chunkFormatter(ansi.KittyGraphics(chunk[:n], opts...))); err != nil {
+ return err //nolint:wrapcheck
+ }
+
+ isFirstChunk = false
+ }
+
+ // Write the last chunk
+ opts := buildChunkOptions(o, isFirstChunk, true)
+ _, err = io.WriteString(w, chunkFormatter(ansi.KittyGraphics(chunk[:n], opts...)))
+ return err //nolint:wrapcheck
+}
+
+// buildChunkOptions creates the options slice for a chunk.
+func buildChunkOptions(o *Options, isFirstChunk, isLastChunk bool) []string {
+ var opts []string
+ if isFirstChunk {
+ opts = o.Options()
+ } else {
+ // These options are allowed in subsequent chunks
+ quiet := o.Quiet
+ if o.Quite > 0 {
+ // handle deprecated Quite field.
+ quiet = o.Quite
+ }
+ if quiet > 0 {
+ opts = append(opts, fmt.Sprintf("q=%d", quiet))
+ }
+ if o.Action == Frame {
+ opts = append(opts, "a=f")
+ }
+ }
+
+ if !isFirstChunk || !isLastChunk {
+ // We don't need to encode the (m=) option when we only have one chunk.
+ if isLastChunk {
+ opts = append(opts, "m=0")
+ } else {
+ opts = append(opts, "m=1")
+ }
+ }
+ return opts
+}
diff --git a/vendor/github.com/charmbracelet/x/ansi/method.go b/vendor/github.com/charmbracelet/x/ansi/method.go
new file mode 100644
index 0000000000..5d2d4092fe
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/ansi/method.go
@@ -0,0 +1,196 @@
+package ansi
+
+import (
+ "os"
+ "strconv"
+
+ "github.com/clipperhouse/displaywidth"
+ "github.com/mattn/go-runewidth"
+)
+
+var wcOptions = &runewidth.Condition{
+ EastAsianWidth: false,
+ StrictEmojiNeutral: true,
+}
+
+var dwOptions = &displaywidth.Options{
+ EastAsianWidth: false,
+}
+
+func init() {
+ if ea, err := strconv.ParseBool(os.Getenv("RUNEWIDTH_EASTASIAN")); err == nil && ea {
+ wcOptions.EastAsianWidth = true
+ dwOptions.EastAsianWidth = true
+ }
+}
+
+// Method is a type that represents the how the renderer should calculate the
+// display width of cells.
+type Method uint8
+
+// Display width modes.
+const (
+ WcWidth Method = iota
+ GraphemeWidth
+)
+
+// StringWidth returns the width of a string in cells. This is the number of
+// cells that the string will occupy when printed in a terminal. ANSI escape
+// codes are ignored and wide characters (such as East Asians and emojis) are
+// accounted for.
+func (m Method) StringWidth(s string) int {
+ return stringWidth(m, s)
+}
+
+// Truncate truncates a string to a given length, adding a tail to the end if
+// the string is longer than the given length. This function is aware of ANSI
+// escape codes and will not break them, and accounts for wide-characters (such
+// as East-Asian characters and emojis).
+func (m Method) Truncate(s string, length int, tail string) string {
+ return truncate(m, s, length, tail)
+}
+
+// TruncateLeft truncates a string to a given length, adding a prefix to the
+// beginning if the string is longer than the given length. This function is
+// aware of ANSI escape codes and will not break them, and accounts for
+// wide-characters (such as East-Asian characters and emojis).
+func (m Method) TruncateLeft(s string, length int, prefix string) string {
+ return truncateLeft(m, s, length, prefix)
+}
+
+// Cut the string, without adding any prefix or tail strings. This function is
+// aware of ANSI escape codes and will not break them, and accounts for
+// wide-characters (such as East-Asian characters and emojis). Note that the
+// [left] parameter is inclusive, while [right] isn't.
+func (m Method) Cut(s string, left, right int) string {
+ return cut(m, s, left, right)
+}
+
+// Hardwrap wraps a string or a block of text to a given line length, breaking
+// word boundaries. This will preserve ANSI escape codes and will account for
+// wide-characters in the string.
+// When preserveSpace is true, spaces at the beginning of a line will be
+// preserved.
+// This treats the text as a sequence of graphemes.
+func (m Method) Hardwrap(s string, length int, preserveSpace bool) string {
+ return hardwrap(m, s, length, preserveSpace)
+}
+
+// Wordwrap wraps a string or a block of text to a given line length, not
+// breaking word boundaries. This will preserve ANSI escape codes and will
+// account for wide-characters in the string.
+// The breakpoints string is a list of characters that are considered
+// breakpoints for word wrapping. A hyphen (-) is always considered a
+// breakpoint.
+//
+// Note: breakpoints must be a string of 1-cell wide rune characters.
+func (m Method) Wordwrap(s string, length int, breakpoints string) string {
+ return wordwrap(m, s, length, breakpoints)
+}
+
+// Wrap wraps a string or a block of text to a given line length, breaking word
+// boundaries if necessary. This will preserve ANSI escape codes and will
+// account for wide-characters in the string. The breakpoints string is a list
+// of characters that are considered breakpoints for word wrapping. A hyphen
+// (-) is always considered a breakpoint.
+//
+// Note: breakpoints must be a string of 1-cell wide rune characters.
+func (m Method) Wrap(s string, length int, breakpoints string) string {
+ return wrap(m, s, length, breakpoints)
+}
+
+// DecodeSequence decodes the first ANSI escape sequence or a printable
+// grapheme from the given data. It returns the sequence slice, the number of
+// bytes read, the cell width for each sequence, and the new state.
+//
+// The cell width will always be 0 for control and escape sequences, 1 for
+// ASCII printable characters, and the number of cells other Unicode characters
+// occupy. It uses the uniseg package to calculate the width of Unicode
+// graphemes and characters. This means it will always do grapheme clustering
+// (mode 2027).
+//
+// Passing a non-nil [*Parser] as the last argument will allow the decoder to
+// collect sequence parameters, data, and commands. The parser cmd will have
+// the packed command value that contains intermediate and prefix characters.
+// In the case of a OSC sequence, the cmd will be the OSC command number. Use
+// [Cmd] and [Param] types to unpack command intermediates and prefixes as well
+// as parameters.
+//
+// Zero [Cmd] means the CSI, DCS, or ESC sequence is invalid. Moreover, checking the
+// validity of other data sequences, OSC, DCS, etc, will require checking for
+// the returned sequence terminator bytes such as ST (ESC \\) and BEL).
+//
+// We store the command byte in [Cmd] in the most significant byte, the
+// prefix byte in the next byte, and the intermediate byte in the least
+// significant byte. This is done to avoid using a struct to store the command
+// and its intermediates and prefixes. The command byte is always the least
+// significant byte i.e. [Cmd & 0xff]. Use the [Cmd] type to unpack the
+// command, intermediate, and prefix bytes. Note that we only collect the last
+// prefix character and intermediate byte.
+//
+// The [p.Params] slice will contain the parameters of the sequence. Any
+// sub-parameter will have the [parser.HasMoreFlag] set. Use the [Param] type
+// to unpack the parameters.
+//
+// Example:
+//
+// var state byte // the initial state is always zero [NormalState]
+// p := NewParser(32, 1024) // create a new parser with a 32 params buffer and 1024 data buffer (optional)
+// input := []byte("\x1b[31mHello, World!\x1b[0m")
+// for len(input) > 0 {
+// seq, width, n, newState := DecodeSequence(input, state, p)
+// log.Printf("seq: %q, width: %d", seq, width)
+// state = newState
+// input = input[n:]
+// }
+func (m Method) DecodeSequence(data []byte, state byte, p *Parser) (seq []byte, width, n int, newState byte) {
+ return decodeSequence(m, data, state, p)
+}
+
+// DecodeSequenceInString decodes the first ANSI escape sequence or a printable
+// grapheme from the given data. It returns the sequence slice, the number of
+// bytes read, the cell width for each sequence, and the new state.
+//
+// The cell width will always be 0 for control and escape sequences, 1 for
+// ASCII printable characters, and the number of cells other Unicode characters
+// occupy. It uses the uniseg package to calculate the width of Unicode
+// graphemes and characters. This means it will always do grapheme clustering
+// (mode 2027).
+//
+// Passing a non-nil [*Parser] as the last argument will allow the decoder to
+// collect sequence parameters, data, and commands. The parser cmd will have
+// the packed command value that contains intermediate and prefix characters.
+// In the case of a OSC sequence, the cmd will be the OSC command number. Use
+// [Cmd] and [Param] types to unpack command intermediates and prefixes as well
+// as parameters.
+//
+// Zero [Cmd] means the CSI, DCS, or ESC sequence is invalid. Moreover, checking the
+// validity of other data sequences, OSC, DCS, etc, will require checking for
+// the returned sequence terminator bytes such as ST (ESC \\) and BEL).
+//
+// We store the command byte in [Cmd] in the most significant byte, the
+// prefix byte in the next byte, and the intermediate byte in the least
+// significant byte. This is done to avoid using a struct to store the command
+// and its intermediates and prefixes. The command byte is always the least
+// significant byte i.e. [Cmd & 0xff]. Use the [Cmd] type to unpack the
+// command, intermediate, and prefix bytes. Note that we only collect the last
+// prefix character and intermediate byte.
+//
+// The [p.Params] slice will contain the parameters of the sequence. Any
+// sub-parameter will have the [parser.HasMoreFlag] set. Use the [Param] type
+// to unpack the parameters.
+//
+// Example:
+//
+// var state byte // the initial state is always zero [NormalState]
+// p := NewParser(32, 1024) // create a new parser with a 32 params buffer and 1024 data buffer (optional)
+// input := []byte("\x1b[31mHello, World!\x1b[0m")
+// for len(input) > 0 {
+// seq, width, n, newState := DecodeSequenceInString(input, state, p)
+// log.Printf("seq: %q, width: %d", seq, width)
+// state = newState
+// input = input[n:]
+// }
+func (m Method) DecodeSequenceInString(data string, state byte, p *Parser) (seq string, width, n int, newState byte) {
+ return decodeSequence(m, data, state, p)
+}
diff --git a/vendor/github.com/charmbracelet/x/ansi/mode.go b/vendor/github.com/charmbracelet/x/ansi/mode.go
new file mode 100644
index 0000000000..1c21a61fb4
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/ansi/mode.go
@@ -0,0 +1,690 @@
+package ansi
+
+import (
+ "strconv"
+ "strings"
+)
+
+// ModeSetting represents a mode setting.
+type ModeSetting byte
+
+// ModeSetting constants.
+const (
+ ModeNotRecognized ModeSetting = iota
+ ModeSet
+ ModeReset
+ ModePermanentlySet
+ ModePermanentlyReset
+)
+
+// IsNotRecognized returns true if the mode is not recognized.
+func (m ModeSetting) IsNotRecognized() bool {
+ return m == ModeNotRecognized
+}
+
+// IsSet returns true if the mode is set or permanently set.
+func (m ModeSetting) IsSet() bool {
+ return m == ModeSet || m == ModePermanentlySet
+}
+
+// IsReset returns true if the mode is reset or permanently reset.
+func (m ModeSetting) IsReset() bool {
+ return m == ModeReset || m == ModePermanentlyReset
+}
+
+// IsPermanentlySet returns true if the mode is permanently set.
+func (m ModeSetting) IsPermanentlySet() bool {
+ return m == ModePermanentlySet
+}
+
+// IsPermanentlyReset returns true if the mode is permanently reset.
+func (m ModeSetting) IsPermanentlyReset() bool {
+ return m == ModePermanentlyReset
+}
+
+// Mode represents an interface for terminal modes.
+// Modes can be set, reset, and requested.
+type Mode interface {
+ Mode() int
+}
+
+// SetMode (SM) or (DECSET) returns a sequence to set a mode.
+// The mode arguments are a list of modes to set.
+//
+// If one of the modes is a [DECMode], the function will returns two escape
+// sequences.
+//
+// ANSI format:
+//
+// CSI Pd ; ... ; Pd h
+//
+// DEC format:
+//
+// CSI ? Pd ; ... ; Pd h
+//
+// See: https://vt100.net/docs/vt510-rm/SM.html
+func SetMode(modes ...Mode) string {
+ return setMode(false, modes...)
+}
+
+// SM is an alias for [SetMode].
+func SM(modes ...Mode) string {
+ return SetMode(modes...)
+}
+
+// DECSET is an alias for [SetMode].
+func DECSET(modes ...Mode) string {
+ return SetMode(modes...)
+}
+
+// ResetMode (RM) or (DECRST) returns a sequence to reset a mode.
+// The mode arguments are a list of modes to reset.
+//
+// If one of the modes is a [DECMode], the function will returns two escape
+// sequences.
+//
+// ANSI format:
+//
+// CSI Pd ; ... ; Pd l
+//
+// DEC format:
+//
+// CSI ? Pd ; ... ; Pd l
+//
+// See: https://vt100.net/docs/vt510-rm/RM.html
+func ResetMode(modes ...Mode) string {
+ return setMode(true, modes...)
+}
+
+// RM is an alias for [ResetMode].
+func RM(modes ...Mode) string {
+ return ResetMode(modes...)
+}
+
+// DECRST is an alias for [ResetMode].
+func DECRST(modes ...Mode) string {
+ return ResetMode(modes...)
+}
+
+func setMode(reset bool, modes ...Mode) (s string) {
+ if len(modes) == 0 {
+ return s
+ }
+
+ cmd := "h"
+ if reset {
+ cmd = "l"
+ }
+
+ seq := "\x1b["
+ if len(modes) == 1 {
+ switch modes[0].(type) {
+ case DECMode:
+ seq += "?"
+ }
+ return seq + strconv.Itoa(modes[0].Mode()) + cmd
+ }
+
+ dec := make([]string, 0, len(modes)/2)
+ ansi := make([]string, 0, len(modes)/2)
+ for _, m := range modes {
+ switch m.(type) {
+ case DECMode:
+ dec = append(dec, strconv.Itoa(m.Mode()))
+ case ANSIMode:
+ ansi = append(ansi, strconv.Itoa(m.Mode()))
+ }
+ }
+
+ if len(ansi) > 0 {
+ s += seq + strings.Join(ansi, ";") + cmd
+ }
+ if len(dec) > 0 {
+ s += seq + "?" + strings.Join(dec, ";") + cmd
+ }
+ return s
+}
+
+// RequestMode (DECRQM) returns a sequence to request a mode from the terminal.
+// The terminal responds with a report mode function [DECRPM].
+//
+// ANSI format:
+//
+// CSI Pa $ p
+//
+// DEC format:
+//
+// CSI ? Pa $ p
+//
+// See: https://vt100.net/docs/vt510-rm/DECRQM.html
+func RequestMode(m Mode) string {
+ seq := "\x1b["
+ switch m.(type) {
+ case DECMode:
+ seq += "?"
+ }
+ return seq + strconv.Itoa(m.Mode()) + "$p"
+}
+
+// DECRQM is an alias for [RequestMode].
+func DECRQM(m Mode) string {
+ return RequestMode(m)
+}
+
+// ReportMode (DECRPM) returns a sequence that the terminal sends to the host
+// in response to a mode request [DECRQM].
+//
+// ANSI format:
+//
+// CSI Pa ; Ps ; $ y
+//
+// DEC format:
+//
+// CSI ? Pa ; Ps $ y
+//
+// Where Pa is the mode number, and Ps is the mode value.
+//
+// 0: Not recognized
+// 1: Set
+// 2: Reset
+// 3: Permanent set
+// 4: Permanent reset
+//
+// See: https://vt100.net/docs/vt510-rm/DECRPM.html
+func ReportMode(mode Mode, value ModeSetting) string {
+ if value > 4 {
+ value = 0
+ }
+ switch mode.(type) {
+ case DECMode:
+ return "\x1b[?" + strconv.Itoa(mode.Mode()) + ";" + strconv.Itoa(int(value)) + "$y"
+ }
+ return "\x1b[" + strconv.Itoa(mode.Mode()) + ";" + strconv.Itoa(int(value)) + "$y"
+}
+
+// DECRPM is an alias for [ReportMode].
+func DECRPM(mode Mode, value ModeSetting) string {
+ return ReportMode(mode, value)
+}
+
+// ANSIMode represents an ANSI terminal mode.
+type ANSIMode int //nolint:revive
+
+// Mode returns the ANSI mode as an integer.
+func (m ANSIMode) Mode() int {
+ return int(m)
+}
+
+// DECMode represents a private DEC terminal mode.
+type DECMode int
+
+// Mode returns the DEC mode as an integer.
+func (m DECMode) Mode() int {
+ return int(m)
+}
+
+// Keyboard Action Mode (KAM) is a mode that controls locking of the keyboard.
+// When the keyboard is locked, it cannot send data to the terminal.
+//
+// See: https://vt100.net/docs/vt510-rm/KAM.html
+const (
+ ModeKeyboardAction = ANSIMode(2)
+ KAM = ModeKeyboardAction
+
+ SetModeKeyboardAction = "\x1b[2h"
+ ResetModeKeyboardAction = "\x1b[2l"
+ RequestModeKeyboardAction = "\x1b[2$p"
+)
+
+// Insert/Replace Mode (IRM) is a mode that determines whether characters are
+// inserted or replaced when typed.
+//
+// When enabled, characters are inserted at the cursor position pushing the
+// characters to the right. When disabled, characters replace the character at
+// the cursor position.
+//
+// See: https://vt100.net/docs/vt510-rm/IRM.html
+const (
+ ModeInsertReplace = ANSIMode(4)
+ IRM = ModeInsertReplace
+
+ SetModeInsertReplace = "\x1b[4h"
+ ResetModeInsertReplace = "\x1b[4l"
+ RequestModeInsertReplace = "\x1b[4$p"
+)
+
+// BiDirectional Support Mode (BDSM) is a mode that determines whether the
+// terminal supports bidirectional text. When enabled, the terminal supports
+// bidirectional text and is set to implicit bidirectional mode. When disabled,
+// the terminal does not support bidirectional text.
+//
+// See ECMA-48 7.2.1.
+const (
+ ModeBiDirectionalSupport = ANSIMode(8)
+ BDSM = ModeBiDirectionalSupport
+
+ SetModeBiDirectionalSupport = "\x1b[8h"
+ ResetModeBiDirectionalSupport = "\x1b[8l"
+ RequestModeBiDirectionalSupport = "\x1b[8$p"
+)
+
+// Send Receive Mode (SRM) or Local Echo Mode is a mode that determines whether
+// the terminal echoes characters back to the host. When enabled, the terminal
+// sends characters to the host as they are typed.
+//
+// See: https://vt100.net/docs/vt510-rm/SRM.html
+const (
+ ModeSendReceive = ANSIMode(12)
+ ModeLocalEcho = ModeSendReceive
+ SRM = ModeSendReceive
+
+ SetModeSendReceive = "\x1b[12h"
+ ResetModeSendReceive = "\x1b[12l"
+ RequestModeSendReceive = "\x1b[12$p"
+
+ SetModeLocalEcho = "\x1b[12h"
+ ResetModeLocalEcho = "\x1b[12l"
+ RequestModeLocalEcho = "\x1b[12$p"
+)
+
+// Line Feed/New Line Mode (LNM) is a mode that determines whether the terminal
+// interprets the line feed character as a new line.
+//
+// When enabled, the terminal interprets the line feed character as a new line.
+// When disabled, the terminal interprets the line feed character as a line feed.
+//
+// A new line moves the cursor to the first position of the next line.
+// A line feed moves the cursor down one line without changing the column
+// scrolling the screen if necessary.
+//
+// See: https://vt100.net/docs/vt510-rm/LNM.html
+const (
+ ModeLineFeedNewLine = ANSIMode(20)
+ LNM = ModeLineFeedNewLine
+
+ SetModeLineFeedNewLine = "\x1b[20h"
+ ResetModeLineFeedNewLine = "\x1b[20l"
+ RequestModeLineFeedNewLine = "\x1b[20$p"
+)
+
+// Cursor Keys Mode (DECCKM) is a mode that determines whether the cursor keys
+// send ANSI cursor sequences or application sequences.
+//
+// See: https://vt100.net/docs/vt510-rm/DECCKM.html
+const (
+ ModeCursorKeys = DECMode(1)
+ DECCKM = ModeCursorKeys
+
+ SetModeCursorKeys = "\x1b[?1h"
+ ResetModeCursorKeys = "\x1b[?1l"
+ RequestModeCursorKeys = "\x1b[?1$p"
+)
+
+// Origin Mode (DECOM) is a mode that determines whether the cursor moves to the
+// home position or the margin position.
+//
+// See: https://vt100.net/docs/vt510-rm/DECOM.html
+const (
+ ModeOrigin = DECMode(6)
+ DECOM = ModeOrigin
+
+ SetModeOrigin = "\x1b[?6h"
+ ResetModeOrigin = "\x1b[?6l"
+ RequestModeOrigin = "\x1b[?6$p"
+)
+
+// Auto Wrap Mode (DECAWM) is a mode that determines whether the cursor wraps
+// to the next line when it reaches the right margin.
+//
+// See: https://vt100.net/docs/vt510-rm/DECAWM.html
+const (
+ ModeAutoWrap = DECMode(7)
+ DECAWM = ModeAutoWrap
+
+ SetModeAutoWrap = "\x1b[?7h"
+ ResetModeAutoWrap = "\x1b[?7l"
+ RequestModeAutoWrap = "\x1b[?7$p"
+)
+
+// X10 Mouse Mode is a mode that determines whether the mouse reports on button
+// presses.
+//
+// The terminal responds with the following encoding:
+//
+// CSI M CbCxCy
+//
+// Where Cb is the button-1, where it can be 1, 2, or 3.
+// Cx and Cy are the x and y coordinates of the mouse event.
+//
+// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-Mouse-Tracking
+const (
+ ModeMouseX10 = DECMode(9)
+
+ SetModeMouseX10 = "\x1b[?9h"
+ ResetModeMouseX10 = "\x1b[?9l"
+ RequestModeMouseX10 = "\x1b[?9$p"
+)
+
+// Text Cursor Enable Mode (DECTCEM) is a mode that shows/hides the cursor.
+//
+// See: https://vt100.net/docs/vt510-rm/DECTCEM.html
+const (
+ ModeTextCursorEnable = DECMode(25)
+ DECTCEM = ModeTextCursorEnable
+
+ SetModeTextCursorEnable = "\x1b[?25h"
+ ResetModeTextCursorEnable = "\x1b[?25l"
+ RequestModeTextCursorEnable = "\x1b[?25$p"
+)
+
+// These are aliases for [SetModeTextCursorEnable] and [ResetModeTextCursorEnable].
+const (
+ ShowCursor = SetModeTextCursorEnable
+ HideCursor = ResetModeTextCursorEnable
+)
+
+// Numeric Keypad Mode (DECNKM) is a mode that determines whether the keypad
+// sends application sequences or numeric sequences.
+//
+// This works like [DECKPAM] and [DECKPNM], but uses different sequences.
+//
+// See: https://vt100.net/docs/vt510-rm/DECNKM.html
+const (
+ ModeNumericKeypad = DECMode(66)
+ DECNKM = ModeNumericKeypad
+
+ SetModeNumericKeypad = "\x1b[?66h"
+ ResetModeNumericKeypad = "\x1b[?66l"
+ RequestModeNumericKeypad = "\x1b[?66$p"
+)
+
+// Backarrow Key Mode (DECBKM) is a mode that determines whether the backspace
+// key sends a backspace or delete character. Disabled by default.
+//
+// See: https://vt100.net/docs/vt510-rm/DECBKM.html
+const (
+ ModeBackarrowKey = DECMode(67)
+ DECBKM = ModeBackarrowKey
+
+ SetModeBackarrowKey = "\x1b[?67h"
+ ResetModeBackarrowKey = "\x1b[?67l"
+ RequestModeBackarrowKey = "\x1b[?67$p"
+)
+
+// Left Right Margin Mode (DECLRMM) is a mode that determines whether the left
+// and right margins can be set with [DECSLRM].
+//
+// See: https://vt100.net/docs/vt510-rm/DECLRMM.html
+const (
+ ModeLeftRightMargin = DECMode(69)
+ DECLRMM = ModeLeftRightMargin
+
+ SetModeLeftRightMargin = "\x1b[?69h"
+ ResetModeLeftRightMargin = "\x1b[?69l"
+ RequestModeLeftRightMargin = "\x1b[?69$p"
+)
+
+// Normal Mouse Mode is a mode that determines whether the mouse reports on
+// button presses and releases. It will also report modifier keys, wheel
+// events, and extra buttons.
+//
+// It uses the same encoding as [ModeMouseX10] with a few differences:
+//
+// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-Mouse-Tracking
+const (
+ ModeMouseNormal = DECMode(1000)
+
+ SetModeMouseNormal = "\x1b[?1000h"
+ ResetModeMouseNormal = "\x1b[?1000l"
+ RequestModeMouseNormal = "\x1b[?1000$p"
+)
+
+// Highlight Mouse Tracking is a mode that determines whether the mouse reports
+// on button presses, releases, and highlighted cells.
+//
+// It uses the same encoding as [ModeMouseNormal] with a few differences:
+//
+// On highlight events, the terminal responds with the following encoding:
+//
+// CSI t CxCy
+// CSI T CxCyCxCyCxCy
+//
+// Where the parameters are startx, starty, endx, endy, mousex, and mousey.
+const (
+ ModeMouseHighlight = DECMode(1001)
+
+ SetModeMouseHighlight = "\x1b[?1001h"
+ ResetModeMouseHighlight = "\x1b[?1001l"
+ RequestModeMouseHighlight = "\x1b[?1001$p"
+)
+
+// VT Hilite Mouse Tracking is a mode that determines whether the mouse reports on
+// button presses, releases, and highlighted cells.
+//
+// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-Mouse-Tracking
+//
+
+// Button Event Mouse Tracking is essentially the same as [ModeMouseNormal],
+// but it also reports button-motion events when a button is pressed.
+//
+// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-Mouse-Tracking
+const (
+ ModeMouseButtonEvent = DECMode(1002)
+
+ SetModeMouseButtonEvent = "\x1b[?1002h"
+ ResetModeMouseButtonEvent = "\x1b[?1002l"
+ RequestModeMouseButtonEvent = "\x1b[?1002$p"
+)
+
+// Any Event Mouse Tracking is the same as [ModeMouseButtonEvent], except that
+// all motion events are reported even if no mouse buttons are pressed.
+//
+// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-Mouse-Tracking
+const (
+ ModeMouseAnyEvent = DECMode(1003)
+
+ SetModeMouseAnyEvent = "\x1b[?1003h"
+ ResetModeMouseAnyEvent = "\x1b[?1003l"
+ RequestModeMouseAnyEvent = "\x1b[?1003$p"
+)
+
+// Focus Event Mode is a mode that determines whether the terminal reports focus
+// and blur events.
+//
+// The terminal sends the following encoding:
+//
+// CSI I // Focus In
+// CSI O // Focus Out
+//
+// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-Focus-Tracking
+const (
+ ModeFocusEvent = DECMode(1004)
+
+ SetModeFocusEvent = "\x1b[?1004h"
+ ResetModeFocusEvent = "\x1b[?1004l"
+ RequestModeFocusEvent = "\x1b[?1004$p"
+)
+
+// SGR Extended Mouse Mode is a mode that changes the mouse tracking encoding
+// to use SGR parameters.
+//
+// The terminal responds with the following encoding:
+//
+// CSI < Cb ; Cx ; Cy M
+//
+// Where Cb is the same as [ModeMouseNormal], and Cx and Cy are the x and y.
+//
+// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-Mouse-Tracking
+const (
+ ModeMouseExtSgr = DECMode(1006)
+
+ SetModeMouseExtSgr = "\x1b[?1006h"
+ ResetModeMouseExtSgr = "\x1b[?1006l"
+ RequestModeMouseExtSgr = "\x1b[?1006$p"
+)
+
+// UTF-8 Extended Mouse Mode is a mode that changes the mouse tracking encoding
+// to use UTF-8 parameters.
+//
+// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-Mouse-Tracking
+const (
+ ModeMouseExtUtf8 = DECMode(1005)
+
+ SetModeMouseExtUtf8 = "\x1b[?1005h"
+ ResetModeMouseExtUtf8 = "\x1b[?1005l"
+ RequestModeMouseExtUtf8 = "\x1b[?1005$p"
+)
+
+// URXVT Extended Mouse Mode is a mode that changes the mouse tracking encoding
+// to use an alternate encoding.
+//
+// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-Mouse-Tracking
+const (
+ ModeMouseExtUrxvt = DECMode(1015)
+
+ SetModeMouseExtUrxvt = "\x1b[?1015h"
+ ResetModeMouseExtUrxvt = "\x1b[?1015l"
+ RequestModeMouseExtUrxvt = "\x1b[?1015$p"
+)
+
+// SGR Pixel Extended Mouse Mode is a mode that changes the mouse tracking
+// encoding to use SGR parameters with pixel coordinates.
+//
+// This is similar to [ModeMouseExtSgr], but also reports pixel coordinates.
+//
+// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-Mouse-Tracking
+const (
+ ModeMouseExtSgrPixel = DECMode(1016)
+
+ SetModeMouseExtSgrPixel = "\x1b[?1016h"
+ ResetModeMouseExtSgrPixel = "\x1b[?1016l"
+ RequestModeMouseExtSgrPixel = "\x1b[?1016$p"
+)
+
+// Alternate Screen Mode is a mode that determines whether the alternate screen
+// buffer is active. When this mode is enabled, the alternate screen buffer is
+// cleared.
+//
+// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-The-Alternate-Screen-Buffer
+const (
+ ModeAltScreen = DECMode(1047)
+
+ SetModeAltScreen = "\x1b[?1047h"
+ ResetModeAltScreen = "\x1b[?1047l"
+ RequestModeAltScreen = "\x1b[?1047$p"
+)
+
+// Save Cursor Mode is a mode that saves the cursor position.
+// This is equivalent to [SaveCursor] and [RestoreCursor].
+//
+// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-The-Alternate-Screen-Buffer
+const (
+ ModeSaveCursor = DECMode(1048)
+
+ SetModeSaveCursor = "\x1b[?1048h"
+ ResetModeSaveCursor = "\x1b[?1048l"
+ RequestModeSaveCursor = "\x1b[?1048$p"
+)
+
+// Alternate Screen Save Cursor Mode is a mode that saves the cursor position as in
+// [ModeSaveCursor], switches to the alternate screen buffer as in [ModeAltScreen],
+// and clears the screen on switch.
+//
+// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-The-Alternate-Screen-Buffer
+const (
+ ModeAltScreenSaveCursor = DECMode(1049)
+
+ SetModeAltScreenSaveCursor = "\x1b[?1049h"
+ ResetModeAltScreenSaveCursor = "\x1b[?1049l"
+ RequestModeAltScreenSaveCursor = "\x1b[?1049$p"
+)
+
+// Bracketed Paste Mode is a mode that determines whether pasted text is
+// bracketed with escape sequences.
+//
+// See: https://cirw.in/blog/bracketed-paste
+// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-Bracketed-Paste-Mode
+const (
+ ModeBracketedPaste = DECMode(2004)
+
+ SetModeBracketedPaste = "\x1b[?2004h"
+ ResetModeBracketedPaste = "\x1b[?2004l"
+ RequestModeBracketedPaste = "\x1b[?2004$p"
+)
+
+// Synchronized Output Mode is a mode that determines whether output is
+// synchronized with the terminal.
+//
+// See: https://gist.github.com/christianparpart/d8a62cc1ab659194337d73e399004036
+const (
+ ModeSynchronizedOutput = DECMode(2026)
+
+ SetModeSynchronizedOutput = "\x1b[?2026h"
+ ResetModeSynchronizedOutput = "\x1b[?2026l"
+ RequestModeSynchronizedOutput = "\x1b[?2026$p"
+)
+
+// Unicode Core Mode is a mode that determines whether the terminal should use
+// Unicode grapheme clustering to calculate the width of glyphs for each
+// terminal cell.
+//
+// See: https://github.com/contour-terminal/terminal-unicode-core
+const (
+ ModeUnicodeCore = DECMode(2027)
+
+ SetModeUnicodeCore = "\x1b[?2027h"
+ ResetModeUnicodeCore = "\x1b[?2027l"
+ RequestModeUnicodeCore = "\x1b[?2027$p"
+)
+
+//
+
+// ModeLightDark is a mode that enables reporting the operating system's color
+// scheme (light or dark) preference. It reports the color scheme as a [DSR]
+// and [LightDarkReport] escape sequences encoded as follows:
+//
+// CSI ? 997 ; 1 n for dark mode
+// CSI ? 997 ; 2 n for light mode
+//
+// The color preference can also be requested via the following [DSR] and
+// [RequestLightDarkReport] escape sequences:
+//
+// CSI ? 996 n
+//
+// See: https://contour-terminal.org/vt-extensions/color-palette-update-notifications/
+const (
+ ModeLightDark = DECMode(2031)
+
+ SetModeLightDark = "\x1b[?2031h"
+ ResetModeLightDark = "\x1b[?2031l"
+ RequestModeLightDark = "\x1b[?2031$p"
+)
+
+// ModeInBandResize is a mode that reports terminal resize events as escape
+// sequences. This is useful for systems that do not support [SIGWINCH] like
+// Windows.
+//
+// The terminal then sends the following encoding:
+//
+// CSI 48 ; cellsHeight ; cellsWidth ; pixelHeight ; pixelWidth t
+//
+// See: https://gist.github.com/rockorager/e695fb2924d36b2bcf1fff4a3704bd83
+const (
+ ModeInBandResize = DECMode(2048)
+
+ SetModeInBandResize = "\x1b[?2048h"
+ ResetModeInBandResize = "\x1b[?2048l"
+ RequestModeInBandResize = "\x1b[?2048$p"
+)
+
+// Win32Input is a mode that determines whether input is processed by the
+// Win32 console and Conpty.
+//
+// See: https://github.com/microsoft/terminal/blob/main/doc/specs/%234999%20-%20Improved%20keyboard%20handling%20in%20Conpty.md
+const (
+ ModeWin32Input = DECMode(9001)
+
+ SetModeWin32Input = "\x1b[?9001h"
+ ResetModeWin32Input = "\x1b[?9001l"
+ RequestModeWin32Input = "\x1b[?9001$p"
+)
diff --git a/vendor/github.com/charmbracelet/x/ansi/mode_deprecated.go b/vendor/github.com/charmbracelet/x/ansi/mode_deprecated.go
new file mode 100644
index 0000000000..323d5fb53b
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/ansi/mode_deprecated.go
@@ -0,0 +1,495 @@
+package ansi
+
+// Keyboard Action Mode (KAM) controls locking of the keyboard.
+//
+// Deprecated: use [ModeKeyboardAction] instead.
+const (
+ KeyboardActionMode = ANSIMode(2)
+
+ SetKeyboardActionMode = "\x1b[2h"
+ ResetKeyboardActionMode = "\x1b[2l"
+ RequestKeyboardActionMode = "\x1b[2$p"
+)
+
+// Insert/Replace Mode (IRM) determines whether characters are inserted or replaced.
+//
+// Deprecated: use [ModeInsertReplace] instead.
+const (
+ InsertReplaceMode = ANSIMode(4)
+
+ SetInsertReplaceMode = "\x1b[4h"
+ ResetInsertReplaceMode = "\x1b[4l"
+ RequestInsertReplaceMode = "\x1b[4$p"
+)
+
+// BiDirectional Support Mode (BDSM) determines whether the terminal supports bidirectional text.
+//
+// Deprecated: use [ModeBiDirectionalSupport] instead.
+const (
+ BiDirectionalSupportMode = ANSIMode(8)
+
+ SetBiDirectionalSupportMode = "\x1b[8h"
+ ResetBiDirectionalSupportMode = "\x1b[8l"
+ RequestBiDirectionalSupportMode = "\x1b[8$p"
+)
+
+// Send Receive Mode (SRM) or Local Echo Mode determines whether the terminal echoes characters.
+//
+// Deprecated: use [ModeSendReceive] instead.
+const (
+ SendReceiveMode = ANSIMode(12)
+ LocalEchoMode = SendReceiveMode
+
+ SetSendReceiveMode = "\x1b[12h"
+ ResetSendReceiveMode = "\x1b[12l"
+ RequestSendReceiveMode = "\x1b[12$p"
+
+ SetLocalEchoMode = "\x1b[12h"
+ ResetLocalEchoMode = "\x1b[12l"
+ RequestLocalEchoMode = "\x1b[12$p"
+)
+
+// Line Feed/New Line Mode (LNM) determines whether the terminal interprets line feed as new line.
+//
+// Deprecated: use [ModeLineFeedNewLine] instead.
+const (
+ LineFeedNewLineMode = ANSIMode(20)
+
+ SetLineFeedNewLineMode = "\x1b[20h"
+ ResetLineFeedNewLineMode = "\x1b[20l"
+ RequestLineFeedNewLineMode = "\x1b[20$p"
+)
+
+// Cursor Keys Mode (DECCKM) determines whether cursor keys send ANSI or application sequences.
+//
+// Deprecated: use [ModeCursorKeys] instead.
+const (
+ CursorKeysMode = DECMode(1)
+
+ SetCursorKeysMode = "\x1b[?1h"
+ ResetCursorKeysMode = "\x1b[?1l"
+ RequestCursorKeysMode = "\x1b[?1$p"
+)
+
+// Cursor Keys mode.
+//
+// Deprecated: use [SetModeCursorKeys] and [ResetModeCursorKeys] instead.
+const (
+ EnableCursorKeys = "\x1b[?1h"
+ DisableCursorKeys = "\x1b[?1l"
+)
+
+// Origin Mode (DECOM) determines whether the cursor moves to home or margin position.
+//
+// Deprecated: use [ModeOrigin] instead.
+const (
+ OriginMode = DECMode(6)
+
+ SetOriginMode = "\x1b[?6h"
+ ResetOriginMode = "\x1b[?6l"
+ RequestOriginMode = "\x1b[?6$p"
+)
+
+// Auto Wrap Mode (DECAWM) determines whether the cursor wraps to the next line.
+//
+// Deprecated: use [ModeAutoWrap] instead.
+const (
+ AutoWrapMode = DECMode(7)
+
+ SetAutoWrapMode = "\x1b[?7h"
+ ResetAutoWrapMode = "\x1b[?7l"
+ RequestAutoWrapMode = "\x1b[?7$p"
+)
+
+// X10 Mouse Mode determines whether the mouse reports on button presses.
+//
+// Deprecated: use [ModeMouseX10] instead.
+const (
+ X10MouseMode = DECMode(9)
+
+ SetX10MouseMode = "\x1b[?9h"
+ ResetX10MouseMode = "\x1b[?9l"
+ RequestX10MouseMode = "\x1b[?9$p"
+)
+
+// Text Cursor Enable Mode (DECTCEM) shows/hides the cursor.
+//
+// Deprecated: use [ModeTextCursorEnable] instead.
+const (
+ TextCursorEnableMode = DECMode(25)
+
+ SetTextCursorEnableMode = "\x1b[?25h"
+ ResetTextCursorEnableMode = "\x1b[?25l"
+ RequestTextCursorEnableMode = "\x1b[?25$p"
+)
+
+// Text Cursor Enable mode.
+//
+// Deprecated: use [SetModeTextCursorEnable] and [ResetModeTextCursorEnable] instead.
+const (
+ CursorEnableMode = DECMode(25)
+ RequestCursorVisibility = "\x1b[?25$p"
+)
+
+// Numeric Keypad Mode (DECNKM) determines whether the keypad sends application or numeric sequences.
+//
+// Deprecated: use [ModeNumericKeypad] instead.
+const (
+ NumericKeypadMode = DECMode(66)
+
+ SetNumericKeypadMode = "\x1b[?66h"
+ ResetNumericKeypadMode = "\x1b[?66l"
+ RequestNumericKeypadMode = "\x1b[?66$p"
+)
+
+// Backarrow Key Mode (DECBKM) determines whether the backspace key sends backspace or delete.
+//
+// Deprecated: use [ModeBackarrowKey] instead.
+const (
+ BackarrowKeyMode = DECMode(67)
+
+ SetBackarrowKeyMode = "\x1b[?67h"
+ ResetBackarrowKeyMode = "\x1b[?67l"
+ RequestBackarrowKeyMode = "\x1b[?67$p"
+)
+
+// Left Right Margin Mode (DECLRMM) determines whether left and right margins can be set.
+//
+// Deprecated: use [ModeLeftRightMargin] instead.
+const (
+ LeftRightMarginMode = DECMode(69)
+
+ SetLeftRightMarginMode = "\x1b[?69h"
+ ResetLeftRightMarginMode = "\x1b[?69l"
+ RequestLeftRightMarginMode = "\x1b[?69$p"
+)
+
+// Normal Mouse Mode determines whether the mouse reports on button presses and releases.
+//
+// Deprecated: use [ModeMouseNormal] instead.
+const (
+ NormalMouseMode = DECMode(1000)
+
+ SetNormalMouseMode = "\x1b[?1000h"
+ ResetNormalMouseMode = "\x1b[?1000l"
+ RequestNormalMouseMode = "\x1b[?1000$p"
+)
+
+// VT Mouse Tracking mode.
+//
+// Deprecated: use [ModeMouseNormal] instead.
+const (
+ MouseMode = DECMode(1000)
+
+ EnableMouse = "\x1b[?1000h"
+ DisableMouse = "\x1b[?1000l"
+ RequestMouse = "\x1b[?1000$p"
+)
+
+// Highlight Mouse Tracking determines whether the mouse reports on button presses and highlighted cells.
+//
+// Deprecated: use [ModeMouseHighlight] instead.
+const (
+ HighlightMouseMode = DECMode(1001)
+
+ SetHighlightMouseMode = "\x1b[?1001h"
+ ResetHighlightMouseMode = "\x1b[?1001l"
+ RequestHighlightMouseMode = "\x1b[?1001$p"
+)
+
+// VT Hilite Mouse Tracking mode.
+//
+// Deprecated: use [ModeMouseHighlight] instead.
+const (
+ MouseHiliteMode = DECMode(1001)
+
+ EnableMouseHilite = "\x1b[?1001h"
+ DisableMouseHilite = "\x1b[?1001l"
+ RequestMouseHilite = "\x1b[?1001$p"
+)
+
+// Button Event Mouse Tracking reports button-motion events when a button is pressed.
+//
+// Deprecated: use [ModeMouseButtonEvent] instead.
+const (
+ ButtonEventMouseMode = DECMode(1002)
+
+ SetButtonEventMouseMode = "\x1b[?1002h"
+ ResetButtonEventMouseMode = "\x1b[?1002l"
+ RequestButtonEventMouseMode = "\x1b[?1002$p"
+)
+
+// Cell Motion Mouse Tracking mode.
+//
+// Deprecated: use [ModeMouseButtonEvent] instead.
+const (
+ MouseCellMotionMode = DECMode(1002)
+
+ EnableMouseCellMotion = "\x1b[?1002h"
+ DisableMouseCellMotion = "\x1b[?1002l"
+ RequestMouseCellMotion = "\x1b[?1002$p"
+)
+
+// Any Event Mouse Tracking reports all motion events.
+//
+// Deprecated: use [ModeMouseAnyEvent] instead.
+const (
+ AnyEventMouseMode = DECMode(1003)
+
+ SetAnyEventMouseMode = "\x1b[?1003h"
+ ResetAnyEventMouseMode = "\x1b[?1003l"
+ RequestAnyEventMouseMode = "\x1b[?1003$p"
+)
+
+// All Mouse Tracking mode.
+//
+// Deprecated: use [ModeMouseAnyEvent] instead.
+const (
+ MouseAllMotionMode = DECMode(1003)
+
+ EnableMouseAllMotion = "\x1b[?1003h"
+ DisableMouseAllMotion = "\x1b[?1003l"
+ RequestMouseAllMotion = "\x1b[?1003$p"
+)
+
+// Focus Event Mode determines whether the terminal reports focus and blur events.
+//
+// Deprecated: use [ModeFocusEvent] instead.
+const (
+ FocusEventMode = DECMode(1004)
+
+ SetFocusEventMode = "\x1b[?1004h"
+ ResetFocusEventMode = "\x1b[?1004l"
+ RequestFocusEventMode = "\x1b[?1004$p"
+)
+
+// Focus reporting mode.
+//
+// Deprecated: use [SetModeFocusEvent], [ResetModeFocusEvent], and
+// [RequestModeFocusEvent] instead.
+const (
+ ReportFocusMode = DECMode(1004)
+
+ EnableReportFocus = "\x1b[?1004h"
+ DisableReportFocus = "\x1b[?1004l"
+ RequestReportFocus = "\x1b[?1004$p"
+)
+
+// UTF-8 Extended Mouse Mode changes the mouse tracking encoding to use UTF-8 parameters.
+//
+// Deprecated: use [ModeMouseExtUtf8] instead.
+const (
+ Utf8ExtMouseMode = DECMode(1005)
+
+ SetUtf8ExtMouseMode = "\x1b[?1005h"
+ ResetUtf8ExtMouseMode = "\x1b[?1005l"
+ RequestUtf8ExtMouseMode = "\x1b[?1005$p"
+)
+
+// SGR Extended Mouse Mode changes the mouse tracking encoding to use SGR parameters.
+//
+// Deprecated: use [ModeMouseExtSgr] instead.
+const (
+ SgrExtMouseMode = DECMode(1006)
+
+ SetSgrExtMouseMode = "\x1b[?1006h"
+ ResetSgrExtMouseMode = "\x1b[?1006l"
+ RequestSgrExtMouseMode = "\x1b[?1006$p"
+)
+
+// Mouse SGR Extended mode.
+//
+// Deprecated: use [ModeMouseExtSgr], [SetModeMouseExtSgr],
+// [ResetModeMouseExtSgr], and [RequestModeMouseExtSgr] instead.
+const (
+ MouseSgrExtMode = DECMode(1006)
+ EnableMouseSgrExt = "\x1b[?1006h"
+ DisableMouseSgrExt = "\x1b[?1006l"
+ RequestMouseSgrExt = "\x1b[?1006$p"
+)
+
+// URXVT Extended Mouse Mode changes the mouse tracking encoding to use an alternate encoding.
+//
+// Deprecated: use [ModeMouseUrxvtExt] instead.
+const (
+ UrxvtExtMouseMode = DECMode(1015)
+
+ SetUrxvtExtMouseMode = "\x1b[?1015h"
+ ResetUrxvtExtMouseMode = "\x1b[?1015l"
+ RequestUrxvtExtMouseMode = "\x1b[?1015$p"
+)
+
+// SGR Pixel Extended Mouse Mode changes the mouse tracking encoding to use SGR parameters with pixel coordinates.
+//
+// Deprecated: use [ModeMouseExtSgrPixel] instead.
+const (
+ SgrPixelExtMouseMode = DECMode(1016)
+
+ SetSgrPixelExtMouseMode = "\x1b[?1016h"
+ ResetSgrPixelExtMouseMode = "\x1b[?1016l"
+ RequestSgrPixelExtMouseMode = "\x1b[?1016$p"
+)
+
+// Alternate Screen Mode determines whether the alternate screen buffer is active.
+//
+// Deprecated: use [ModeAltScreen] instead.
+const (
+ AltScreenMode = DECMode(1047)
+
+ SetAltScreenMode = "\x1b[?1047h"
+ ResetAltScreenMode = "\x1b[?1047l"
+ RequestAltScreenMode = "\x1b[?1047$p"
+)
+
+// Save Cursor Mode saves the cursor position.
+//
+// Deprecated: use [ModeSaveCursor] instead.
+const (
+ SaveCursorMode = DECMode(1048)
+
+ SetSaveCursorMode = "\x1b[?1048h"
+ ResetSaveCursorMode = "\x1b[?1048l"
+ RequestSaveCursorMode = "\x1b[?1048$p"
+)
+
+// Alternate Screen Save Cursor Mode saves the cursor position and switches to alternate screen.
+//
+// Deprecated: use [ModeAltScreenSaveCursor] instead.
+const (
+ AltScreenSaveCursorMode = DECMode(1049)
+
+ SetAltScreenSaveCursorMode = "\x1b[?1049h"
+ ResetAltScreenSaveCursorMode = "\x1b[?1049l"
+ RequestAltScreenSaveCursorMode = "\x1b[?1049$p"
+)
+
+// Alternate Screen Buffer mode.
+//
+// Deprecated: use [ModeAltScreenSaveCursor] instead.
+const (
+ AltScreenBufferMode = DECMode(1049)
+
+ SetAltScreenBufferMode = "\x1b[?1049h"
+ ResetAltScreenBufferMode = "\x1b[?1049l"
+ RequestAltScreenBufferMode = "\x1b[?1049$p"
+
+ EnableAltScreenBuffer = "\x1b[?1049h"
+ DisableAltScreenBuffer = "\x1b[?1049l"
+ RequestAltScreenBuffer = "\x1b[?1049$p"
+)
+
+// Bracketed Paste Mode determines whether pasted text is bracketed with escape sequences.
+//
+// Deprecated: use [ModeBracketedPaste] instead.
+const (
+ BracketedPasteMode = DECMode(2004)
+
+ SetBracketedPasteMode = "\x1b[?2004h"
+ ResetBracketedPasteMode = "\x1b[?2004l"
+ RequestBracketedPasteMode = "\x1b[?2004$p"
+)
+
+// Deprecated: use [SetModeBracketedPaste], [ResetModeBracketedPaste], and
+// [RequestModeBracketedPaste] instead.
+const (
+ EnableBracketedPaste = "\x1b[?2004h" //nolint:revive
+ DisableBracketedPaste = "\x1b[?2004l"
+ RequestBracketedPaste = "\x1b[?2004$p"
+)
+
+// Synchronized Output Mode determines whether output is synchronized with the terminal.
+//
+// Deprecated: use [ModeSynchronizedOutput] instead.
+const (
+ SynchronizedOutputMode = DECMode(2026)
+
+ SetSynchronizedOutputMode = "\x1b[?2026h"
+ ResetSynchronizedOutputMode = "\x1b[?2026l"
+ RequestSynchronizedOutputMode = "\x1b[?2026$p"
+)
+
+// Synchronized output mode.
+//
+// Deprecated: use [ModeSynchronizedOutput], [SetModeSynchronizedOutput],
+// [ResetModeSynchronizedOutput], and [RequestModeSynchronizedOutput] instead.
+const (
+ SyncdOutputMode = DECMode(2026)
+
+ EnableSyncdOutput = "\x1b[?2026h"
+ DisableSyncdOutput = "\x1b[?2026l"
+ RequestSyncdOutput = "\x1b[?2026$p"
+)
+
+// Unicode Core Mode determines whether the terminal uses Unicode grapheme clustering.
+//
+// Deprecated: use [ModeUnicodeCore] instead.
+const (
+ UnicodeCoreMode = DECMode(2027)
+
+ SetUnicodeCoreMode = "\x1b[?2027h"
+ ResetUnicodeCoreMode = "\x1b[?2027l"
+ RequestUnicodeCoreMode = "\x1b[?2027$p"
+)
+
+// Grapheme Clustering Mode determines whether the terminal looks for grapheme clusters.
+//
+// Deprecated: use [ModeUnicodeCore], [SetModeUnicodeCore],
+// [ResetModeUnicodeCore], and [RequestModeUnicodeCore] instead.
+const (
+ GraphemeClusteringMode = DECMode(2027)
+
+ SetGraphemeClusteringMode = "\x1b[?2027h"
+ ResetGraphemeClusteringMode = "\x1b[?2027l"
+ RequestGraphemeClusteringMode = "\x1b[?2027$p"
+)
+
+// Unicode Core mode.
+//
+// Deprecated: use [SetModeUnicodeCore], [ResetModeUnicodeCore], and
+// [RequestModeUnicodeCore] instead.
+const (
+ EnableGraphemeClustering = "\x1b[?2027h"
+ DisableGraphemeClustering = "\x1b[?2027l"
+ RequestGraphemeClustering = "\x1b[?2027$p"
+)
+
+// Light Dark Mode enables reporting the operating system's color scheme preference.
+//
+// Deprecated: use [ModeLightDark] instead.
+const (
+ LightDarkMode = DECMode(2031)
+
+ SetLightDarkMode = "\x1b[?2031h"
+ ResetLightDarkMode = "\x1b[?2031l"
+ RequestLightDarkMode = "\x1b[?2031$p"
+)
+
+// In Band Resize Mode reports terminal resize events as escape sequences.
+//
+// Deprecated: use [ModeInBandResize] instead.
+const (
+ InBandResizeMode = DECMode(2048)
+
+ SetInBandResizeMode = "\x1b[?2048h"
+ ResetInBandResizeMode = "\x1b[?2048l"
+ RequestInBandResizeMode = "\x1b[?2048$p"
+)
+
+// Win32Input determines whether input is processed by the Win32 console and Conpty.
+//
+// Deprecated: use [ModeWin32Input] instead.
+const (
+ Win32InputMode = DECMode(9001)
+
+ SetWin32InputMode = "\x1b[?9001h"
+ ResetWin32InputMode = "\x1b[?9001l"
+ RequestWin32InputMode = "\x1b[?9001$p"
+)
+
+// Deprecated: use [SetModeWin32Input], [ResetModeWin32Input], and
+// [RequestModeWin32Input] instead.
+const (
+ EnableWin32Input = "\x1b[?9001h" //nolint:revive
+ DisableWin32Input = "\x1b[?9001l"
+ RequestWin32Input = "\x1b[?9001$p"
+)
diff --git a/vendor/github.com/charmbracelet/x/ansi/modes.go b/vendor/github.com/charmbracelet/x/ansi/modes.go
new file mode 100644
index 0000000000..6856d35e48
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/ansi/modes.go
@@ -0,0 +1,65 @@
+package ansi
+
+// Modes represents the terminal modes that can be set or reset. By default,
+// all modes are [ModeNotRecognized].
+type Modes map[Mode]ModeSetting
+
+// Get returns the setting of a terminal mode. If the mode is not set, it
+// returns [ModeNotRecognized].
+func (m Modes) Get(mode Mode) ModeSetting {
+ return m[mode]
+}
+
+// Delete deletes a terminal mode. This has the same effect as setting the mode
+// to [ModeNotRecognized].
+func (m Modes) Delete(mode Mode) {
+ delete(m, mode)
+}
+
+// Set sets a terminal mode to [ModeSet].
+func (m Modes) Set(modes ...Mode) {
+ for _, mode := range modes {
+ m[mode] = ModeSet
+ }
+}
+
+// PermanentlySet sets a terminal mode to [ModePermanentlySet].
+func (m Modes) PermanentlySet(modes ...Mode) {
+ for _, mode := range modes {
+ m[mode] = ModePermanentlySet
+ }
+}
+
+// Reset sets a terminal mode to [ModeReset].
+func (m Modes) Reset(modes ...Mode) {
+ for _, mode := range modes {
+ m[mode] = ModeReset
+ }
+}
+
+// PermanentlyReset sets a terminal mode to [ModePermanentlyReset].
+func (m Modes) PermanentlyReset(modes ...Mode) {
+ for _, mode := range modes {
+ m[mode] = ModePermanentlyReset
+ }
+}
+
+// IsSet returns true if the mode is set to [ModeSet] or [ModePermanentlySet].
+func (m Modes) IsSet(mode Mode) bool {
+ return m[mode].IsSet()
+}
+
+// IsPermanentlySet returns true if the mode is set to [ModePermanentlySet].
+func (m Modes) IsPermanentlySet(mode Mode) bool {
+ return m[mode].IsPermanentlySet()
+}
+
+// IsReset returns true if the mode is set to [ModeReset] or [ModePermanentlyReset].
+func (m Modes) IsReset(mode Mode) bool {
+ return m[mode].IsReset()
+}
+
+// IsPermanentlyReset returns true if the mode is set to [ModePermanentlyReset].
+func (m Modes) IsPermanentlyReset(mode Mode) bool {
+ return m[mode].IsPermanentlyReset()
+}
diff --git a/vendor/github.com/charmbracelet/x/ansi/mouse.go b/vendor/github.com/charmbracelet/x/ansi/mouse.go
new file mode 100644
index 0000000000..bac4620fd4
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/ansi/mouse.go
@@ -0,0 +1,172 @@
+package ansi
+
+import (
+ "fmt"
+)
+
+// MouseButton represents the button that was pressed during a mouse message.
+type MouseButton byte
+
+// Mouse event buttons
+//
+// This is based on X11 mouse button codes.
+//
+// 1 = left button
+// 2 = middle button (pressing the scroll wheel)
+// 3 = right button
+// 4 = turn scroll wheel up
+// 5 = turn scroll wheel down
+// 6 = push scroll wheel left
+// 7 = push scroll wheel right
+// 8 = 4th button (aka browser backward button)
+// 9 = 5th button (aka browser forward button)
+// 10
+// 11
+//
+// Other buttons are not supported.
+const (
+ MouseNone MouseButton = iota
+ MouseButton1
+ MouseButton2
+ MouseButton3
+ MouseButton4
+ MouseButton5
+ MouseButton6
+ MouseButton7
+ MouseButton8
+ MouseButton9
+ MouseButton10
+ MouseButton11
+
+ MouseLeft = MouseButton1
+ MouseMiddle = MouseButton2
+ MouseRight = MouseButton3
+ MouseWheelUp = MouseButton4
+ MouseWheelDown = MouseButton5
+ MouseWheelLeft = MouseButton6
+ MouseWheelRight = MouseButton7
+ MouseBackward = MouseButton8
+ MouseForward = MouseButton9
+ MouseRelease = MouseNone
+)
+
+var mouseButtons = map[MouseButton]string{
+ MouseNone: "none",
+ MouseLeft: "left",
+ MouseMiddle: "middle",
+ MouseRight: "right",
+ MouseWheelUp: "wheelup",
+ MouseWheelDown: "wheeldown",
+ MouseWheelLeft: "wheelleft",
+ MouseWheelRight: "wheelright",
+ MouseBackward: "backward",
+ MouseForward: "forward",
+ MouseButton10: "button10",
+ MouseButton11: "button11",
+}
+
+// String returns a string representation of the mouse button.
+func (b MouseButton) String() string {
+ return mouseButtons[b]
+}
+
+// EncodeMouseButton returns a byte representing a mouse button.
+// The button is a bitmask of the following leftmost values:
+//
+// - The first two bits are the button number:
+// 0 = left button, wheel up, or button no. 8 aka (backwards)
+// 1 = middle button, wheel down, or button no. 9 aka (forwards)
+// 2 = right button, wheel left, or button no. 10
+// 3 = release event, wheel right, or button no. 11
+//
+// - The third bit indicates whether the shift key was pressed.
+//
+// - The fourth bit indicates the alt key was pressed.
+//
+// - The fifth bit indicates the control key was pressed.
+//
+// - The sixth bit indicates motion events. Combined with button number 3, i.e.
+// release event, it represents a drag event.
+//
+// - The seventh bit indicates a wheel event.
+//
+// - The eighth bit indicates additional buttons.
+//
+// If button is [MouseNone], and motion is false, this returns a release event.
+// If button is undefined, this function returns 0xff.
+func EncodeMouseButton(b MouseButton, motion, shift, alt, ctrl bool) (m byte) {
+ // mouse bit shifts
+ const (
+ bitShift = 0b0000_0100
+ bitAlt = 0b0000_1000
+ bitCtrl = 0b0001_0000
+ bitMotion = 0b0010_0000
+ bitWheel = 0b0100_0000
+ bitAdd = 0b1000_0000 // additional buttons 8-11
+
+ bitsMask = 0b0000_0011
+ )
+
+ if b == MouseNone {
+ m = bitsMask
+ } else if b >= MouseLeft && b <= MouseRight {
+ m = byte(b - MouseLeft)
+ } else if b >= MouseWheelUp && b <= MouseWheelRight {
+ m = byte(b - MouseWheelUp)
+ m |= bitWheel
+ } else if b >= MouseBackward && b <= MouseButton11 {
+ m = byte(b - MouseBackward)
+ m |= bitAdd
+ } else {
+ m = 0xff // invalid button
+ }
+
+ if shift {
+ m |= bitShift
+ }
+ if alt {
+ m |= bitAlt
+ }
+ if ctrl {
+ m |= bitCtrl
+ }
+ if motion {
+ m |= bitMotion
+ }
+
+ return m
+}
+
+// x10Offset is the offset for X10 mouse events.
+// See https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#Mouse%20Tracking
+const x10Offset = 32
+
+// MouseX10 returns an escape sequence representing a mouse event in X10 mode.
+// Note that this requires the terminal support X10 mouse modes.
+//
+// CSI M Cb Cx Cy
+//
+// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#Mouse%20Tracking
+func MouseX10(b byte, x, y int) string {
+ return "\x1b[M" + string(b+x10Offset) + string(byte(x)+x10Offset+1) + string(byte(y)+x10Offset+1) //nolint:gosec
+}
+
+// MouseSgr returns an escape sequence representing a mouse event in SGR mode.
+//
+// CSI < Cb ; Cx ; Cy M
+// CSI < Cb ; Cx ; Cy m (release)
+//
+// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#Mouse%20Tracking
+func MouseSgr(b byte, x, y int, release bool) string {
+ s := 'M'
+ if release {
+ s = 'm'
+ }
+ if x < 0 {
+ x = -x
+ }
+ if y < 0 {
+ y = -y
+ }
+ return fmt.Sprintf("\x1b[<%d;%d;%d%c", b, x+1, y+1, s)
+}
diff --git a/vendor/github.com/charmbracelet/x/ansi/notification.go b/vendor/github.com/charmbracelet/x/ansi/notification.go
new file mode 100644
index 0000000000..fd6221d24d
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/ansi/notification.go
@@ -0,0 +1,32 @@
+package ansi
+
+import (
+ "fmt"
+ "strings"
+)
+
+// Notify sends a desktop notification using iTerm's OSC 9.
+//
+// OSC 9 ; Mc ST
+// OSC 9 ; Mc BEL
+//
+// Where Mc is the notification body.
+//
+// See: https://iterm2.com/documentation-escape-codes.html
+func Notify(s string) string {
+ return "\x1b]9;" + s + "\x07"
+}
+
+// DesktopNotification sends a desktop notification based on the extensible OSC
+// 99 escape code.
+//
+// OSC 99 ; ; ST
+// OSC 99 ; ; BEL
+//
+// Where is a colon-separated list of key-value pairs, and
+// is the notification body.
+//
+// See: https://sw.kovidgoyal.net/kitty/desktop-notifications/
+func DesktopNotification(payload string, metadata ...string) string {
+ return fmt.Sprintf("\x1b]99;%s;%s\x07", strings.Join(metadata, ":"), payload)
+}
diff --git a/vendor/github.com/charmbracelet/x/ansi/palette.go b/vendor/github.com/charmbracelet/x/ansi/palette.go
new file mode 100644
index 0000000000..cc4519b81a
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/ansi/palette.go
@@ -0,0 +1,34 @@
+package ansi
+
+import (
+ "fmt"
+ "image/color"
+)
+
+// SetPalette sets the palette color for the given index. The index is a 16
+// color index between 0 and 15. The color is a 24-bit RGB color.
+//
+// OSC P n rrggbb BEL
+//
+// Where n is the color index in hex (0-f), and rrggbb is the color in
+// hexadecimal format (e.g., ff0000 for red).
+//
+// This sequence is specific to the Linux Console and may not work in other
+// terminal emulators.
+//
+// See https://man7.org/linux/man-pages/man4/console_codes.4.html
+func SetPalette(i int, c color.Color) string {
+ if c == nil || i < 0 || i > 15 {
+ return ""
+ }
+ r, g, b, _ := c.RGBA()
+ return fmt.Sprintf("\x1b]P%x%02x%02x%02x\x07", i, r>>8, g>>8, b>>8)
+}
+
+// ResetPalette resets the color palette to the default values.
+//
+// This sequence is specific to the Linux Console and may not work in other
+// terminal emulators.
+//
+// See https://man7.org/linux/man-pages/man4/console_codes.4.html
+const ResetPalette = "\x1b]R\x07"
diff --git a/vendor/github.com/charmbracelet/x/ansi/parser.go b/vendor/github.com/charmbracelet/x/ansi/parser.go
new file mode 100644
index 0000000000..e770c15f9a
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/ansi/parser.go
@@ -0,0 +1,417 @@
+package ansi
+
+import (
+ "unicode/utf8"
+ "unsafe"
+
+ "github.com/charmbracelet/x/ansi/parser"
+)
+
+// Parser represents a DEC ANSI compatible sequence parser.
+//
+// It uses a state machine to parse ANSI escape sequences and control
+// characters. The parser is designed to be used with a terminal emulator or
+// similar application that needs to parse ANSI escape sequences and control
+// characters.
+// See package [parser] for more information.
+//
+//go:generate go run ./gen.go
+type Parser struct {
+ handler Handler
+
+ // params contains the raw parameters of the sequence.
+ // These parameters used when constructing CSI and DCS sequences.
+ params []int
+
+ // data contains the raw data of the sequence.
+ // These data used when constructing OSC, DCS, SOS, PM, and APC sequences.
+ data []byte
+
+ // dataLen keeps track of the length of the data buffer.
+ // If dataLen is -1, the data buffer is unlimited and will grow as needed.
+ // Otherwise, dataLen is limited by the size of the data buffer.
+ dataLen int
+
+ // paramsLen keeps track of the number of parameters.
+ // This is limited by the size of the params buffer.
+ //
+ // This is also used when collecting UTF-8 runes to keep track of the
+ // number of rune bytes collected.
+ paramsLen int
+
+ // cmd contains the raw command along with the private prefix and
+ // intermediate bytes of the sequence.
+ // The first lower byte contains the command byte, the next byte contains
+ // the private prefix, and the next byte contains the intermediate byte.
+ //
+ // This is also used when collecting UTF-8 runes treating it as a slice of
+ // 4 bytes.
+ cmd int
+
+ // state is the current state of the parser.
+ state byte
+}
+
+// NewParser returns a new parser with the default settings.
+// The [Parser] uses a default size of 32 for the parameters and 64KB for the
+// data buffer. Use [Parser.SetParamsSize] and [Parser.SetDataSize] to set the
+// size of the parameters and data buffer respectively.
+func NewParser() *Parser {
+ p := new(Parser)
+ p.SetParamsSize(parser.MaxParamsSize)
+ p.SetDataSize(1024 * 64) // 64KB data buffer
+ return p
+}
+
+// SetParamsSize sets the size of the parameters buffer.
+// This is used when constructing CSI and DCS sequences.
+func (p *Parser) SetParamsSize(size int) {
+ p.params = make([]int, size)
+}
+
+// SetDataSize sets the size of the data buffer.
+// This is used when constructing OSC, DCS, SOS, PM, and APC sequences.
+// If size is less than or equal to 0, the data buffer is unlimited and will
+// grow as needed.
+func (p *Parser) SetDataSize(size int) {
+ if size <= 0 {
+ size = 0
+ p.dataLen = -1
+ }
+ p.data = make([]byte, size)
+}
+
+// Params returns the list of parsed packed parameters.
+func (p *Parser) Params() Params {
+ return unsafe.Slice((*Param)(unsafe.Pointer(&p.params[0])), p.paramsLen)
+}
+
+// Param returns the parameter at the given index and falls back to the default
+// value if the parameter is missing. If the index is out of bounds, it returns
+// the default value and false.
+func (p *Parser) Param(i, def int) (int, bool) {
+ if i < 0 || i >= p.paramsLen {
+ return def, false
+ }
+ return Param(p.params[i]).Param(def), true
+}
+
+// Command returns the packed command of the last dispatched sequence. Use
+// [Cmd] to unpack the command.
+func (p *Parser) Command() int {
+ return p.cmd
+}
+
+// Rune returns the last dispatched sequence as a rune.
+func (p *Parser) Rune() rune {
+ rw := utf8ByteLen(byte(p.cmd & 0xff))
+ if rw == -1 {
+ return utf8.RuneError
+ }
+ r, _ := utf8.DecodeRune((*[utf8.UTFMax]byte)(unsafe.Pointer(&p.cmd))[:rw])
+ return r
+}
+
+// Control returns the last dispatched sequence as a control code.
+func (p *Parser) Control() byte {
+ return byte(p.cmd & 0xff)
+}
+
+// Data returns the raw data of the last dispatched sequence.
+func (p *Parser) Data() []byte {
+ return p.data[:p.dataLen]
+}
+
+// Reset resets the parser to its initial state.
+func (p *Parser) Reset() {
+ p.clear()
+ p.state = parser.GroundState
+}
+
+// clear clears the parser parameters and command.
+func (p *Parser) clear() {
+ if len(p.params) > 0 {
+ p.params[0] = parser.MissingParam
+ }
+ p.paramsLen = 0
+ p.cmd = 0
+}
+
+// State returns the current state of the parser.
+func (p *Parser) State() parser.State {
+ return p.state
+}
+
+// StateName returns the name of the current state.
+func (p *Parser) StateName() string {
+ return parser.StateNames[p.state]
+}
+
+// Parse parses the given dispatcher and byte buffer.
+// Deprecated: Loop over the buffer and call [Parser.Advance] instead.
+func (p *Parser) Parse(b []byte) {
+ for i := range b {
+ p.Advance(b[i])
+ }
+}
+
+// Advance advances the parser using the given byte. It returns the action
+// performed by the parser.
+func (p *Parser) Advance(b byte) parser.Action {
+ switch p.state {
+ case parser.Utf8State:
+ // We handle UTF-8 here.
+ return p.advanceUtf8(b)
+ default:
+ return p.advance(b)
+ }
+}
+
+func (p *Parser) collectRune(b byte) {
+ if p.paramsLen >= utf8.UTFMax {
+ return
+ }
+
+ shift := p.paramsLen * 8
+ p.cmd &^= 0xff << shift
+ p.cmd |= int(b) << shift
+ p.paramsLen++
+}
+
+func (p *Parser) advanceUtf8(b byte) parser.Action {
+ // Collect UTF-8 rune bytes.
+ p.collectRune(b)
+ rw := utf8ByteLen(byte(p.cmd & 0xff))
+ if rw == -1 {
+ // We panic here because the first byte comes from the state machine,
+ // if this panics, it means there is a bug in the state machine!
+ panic("invalid rune") // unreachable
+ }
+
+ if p.paramsLen < rw {
+ return parser.CollectAction
+ }
+
+ // We have enough bytes to decode the rune using unsafe
+ if p.handler.Print != nil {
+ p.handler.Print(p.Rune())
+ }
+
+ p.state = parser.GroundState
+ p.paramsLen = 0
+
+ return parser.PrintAction
+}
+
+func (p *Parser) advance(b byte) parser.Action {
+ state, action := parser.Table.Transition(p.state, b)
+
+ // We need to clear the parser state if the state changes from EscapeState.
+ // This is because when we enter the EscapeState, we don't get a chance to
+ // clear the parser state. For example, when a sequence terminates with a
+ // ST (\x1b\\ or \x9c), we dispatch the current sequence and transition to
+ // EscapeState. However, the parser state is not cleared in this case and
+ // we need to clear it here before dispatching the esc sequence.
+ if p.state != state {
+ if p.state == parser.EscapeState {
+ p.performAction(parser.ClearAction, state, b)
+ }
+ if action == parser.PutAction &&
+ p.state == parser.DcsEntryState && state == parser.DcsStringState {
+ // XXX: This is a special case where we need to start collecting
+ // non-string parameterized data i.e. doesn't follow the ECMA-48 §
+ // 5.4.1 string parameters format.
+ p.performAction(parser.StartAction, state, 0)
+ }
+ }
+
+ // Handle special cases
+ switch {
+ case b == ESC && p.state == parser.EscapeState:
+ // Two ESCs in a row
+ p.performAction(parser.ExecuteAction, state, b)
+ default:
+ p.performAction(action, state, b)
+ }
+
+ p.state = state
+
+ return action
+}
+
+func (p *Parser) parseStringCmd() {
+ // Try to parse the command
+ datalen := len(p.data)
+ if p.dataLen >= 0 {
+ datalen = p.dataLen
+ }
+ for i := range datalen {
+ d := p.data[i]
+ if d < '0' || d > '9' {
+ break
+ }
+ if p.cmd == parser.MissingCommand {
+ p.cmd = 0
+ }
+ p.cmd *= 10
+ p.cmd += int(d - '0')
+ }
+}
+
+func (p *Parser) performAction(action parser.Action, state parser.State, b byte) {
+ switch action {
+ case parser.IgnoreAction:
+ break
+
+ case parser.ClearAction:
+ p.clear()
+
+ case parser.PrintAction:
+ p.cmd = int(b)
+ if p.handler.Print != nil {
+ p.handler.Print(rune(b))
+ }
+
+ case parser.ExecuteAction:
+ p.cmd = int(b)
+ if p.handler.Execute != nil {
+ p.handler.Execute(b)
+ }
+
+ case parser.PrefixAction:
+ // Collect private prefix
+ // we only store the last prefix
+ p.cmd &^= 0xff << parser.PrefixShift
+ p.cmd |= int(b) << parser.PrefixShift
+
+ case parser.CollectAction:
+ if state == parser.Utf8State {
+ // Reset the UTF-8 counter
+ p.paramsLen = 0
+ p.collectRune(b)
+ } else {
+ // Collect intermediate bytes
+ // we only store the last intermediate byte
+ p.cmd &^= 0xff << parser.IntermedShift
+ p.cmd |= int(b) << parser.IntermedShift
+ }
+
+ case parser.ParamAction:
+ // Collect parameters
+ if p.paramsLen >= len(p.params) {
+ break
+ }
+
+ if b >= '0' && b <= '9' {
+ if p.params[p.paramsLen] == parser.MissingParam {
+ p.params[p.paramsLen] = 0
+ }
+
+ p.params[p.paramsLen] *= 10
+ p.params[p.paramsLen] += int(b - '0')
+ }
+
+ if b == ':' {
+ p.params[p.paramsLen] |= parser.HasMoreFlag
+ }
+
+ if b == ';' || b == ':' {
+ p.paramsLen++
+ if p.paramsLen < len(p.params) {
+ p.params[p.paramsLen] = parser.MissingParam
+ }
+ }
+
+ case parser.StartAction:
+ if p.dataLen < 0 && p.data != nil {
+ p.data = p.data[:0]
+ } else {
+ p.dataLen = 0
+ }
+ if p.state >= parser.DcsEntryState && p.state <= parser.DcsStringState {
+ // Collect the command byte for DCS
+ p.cmd |= int(b)
+ } else {
+ p.cmd = parser.MissingCommand
+ }
+
+ case parser.PutAction:
+ switch p.state {
+ case parser.OscStringState:
+ if b == ';' && p.cmd == parser.MissingCommand {
+ p.parseStringCmd()
+ }
+ }
+
+ if p.dataLen < 0 {
+ p.data = append(p.data, b)
+ } else {
+ if p.dataLen < len(p.data) {
+ p.data[p.dataLen] = b
+ p.dataLen++
+ }
+ }
+
+ case parser.DispatchAction:
+ // Increment the last parameter
+ if p.paramsLen > 0 && p.paramsLen < len(p.params)-1 ||
+ p.paramsLen == 0 && len(p.params) > 0 && p.params[0] != parser.MissingParam {
+ p.paramsLen++
+ }
+
+ if p.state == parser.OscStringState && p.cmd == parser.MissingCommand {
+ // Ensure we have a command for OSC
+ p.parseStringCmd()
+ }
+
+ data := p.data
+ if p.dataLen >= 0 {
+ data = data[:p.dataLen]
+ }
+ switch p.state {
+ case parser.CsiEntryState, parser.CsiParamState, parser.CsiIntermediateState:
+ p.cmd |= int(b)
+ if p.handler.HandleCsi != nil {
+ p.handler.HandleCsi(Cmd(p.cmd), p.Params())
+ }
+ case parser.EscapeState, parser.EscapeIntermediateState:
+ p.cmd |= int(b)
+ if p.handler.HandleEsc != nil {
+ p.handler.HandleEsc(Cmd(p.cmd))
+ }
+ case parser.DcsEntryState, parser.DcsParamState, parser.DcsIntermediateState, parser.DcsStringState:
+ if p.handler.HandleDcs != nil {
+ p.handler.HandleDcs(Cmd(p.cmd), p.Params(), data)
+ }
+ case parser.OscStringState:
+ if p.handler.HandleOsc != nil {
+ p.handler.HandleOsc(p.cmd, data)
+ }
+ case parser.SosStringState:
+ if p.handler.HandleSos != nil {
+ p.handler.HandleSos(data)
+ }
+ case parser.PmStringState:
+ if p.handler.HandlePm != nil {
+ p.handler.HandlePm(data)
+ }
+ case parser.ApcStringState:
+ if p.handler.HandleApc != nil {
+ p.handler.HandleApc(data)
+ }
+ }
+ }
+}
+
+func utf8ByteLen(b byte) int {
+ if b <= 0b0111_1111 { // 0x00-0x7F
+ return 1
+ } else if b >= 0b1100_0000 && b <= 0b1101_1111 { // 0xC0-0xDF
+ return 2
+ } else if b >= 0b1110_0000 && b <= 0b1110_1111 { // 0xE0-0xEF
+ return 3
+ } else if b >= 0b1111_0000 && b <= 0b1111_0111 { // 0xF0-0xF7
+ return 4
+ }
+ return -1
+}
diff --git a/vendor/github.com/charmbracelet/x/ansi/parser/const.go b/vendor/github.com/charmbracelet/x/ansi/parser/const.go
new file mode 100644
index 0000000000..85c90869c3
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/ansi/parser/const.go
@@ -0,0 +1,79 @@
+// Package parser provides ANSI escape sequence parsing functionality.
+package parser
+
+// Action is a DEC ANSI parser action.
+type Action = byte
+
+// These are the actions that the parser can take.
+const (
+ NoneAction Action = iota
+ ClearAction
+ CollectAction
+ PrefixAction
+ DispatchAction
+ ExecuteAction
+ StartAction // Start of a data string
+ PutAction // Put into the data string
+ ParamAction
+ PrintAction
+
+ IgnoreAction = NoneAction
+)
+
+// ActionNames provides string names for parser actions.
+var ActionNames = []string{
+ "NoneAction",
+ "ClearAction",
+ "CollectAction",
+ "PrefixAction",
+ "DispatchAction",
+ "ExecuteAction",
+ "StartAction",
+ "PutAction",
+ "ParamAction",
+ "PrintAction",
+}
+
+// State is a DEC ANSI parser state.
+type State = byte
+
+// These are the states that the parser can be in.
+const (
+ GroundState State = iota
+ CsiEntryState
+ CsiIntermediateState
+ CsiParamState
+ DcsEntryState
+ DcsIntermediateState
+ DcsParamState
+ DcsStringState
+ EscapeState
+ EscapeIntermediateState
+ OscStringState
+ SosStringState
+ PmStringState
+ ApcStringState
+
+ // Utf8State is not part of the DEC ANSI standard. It is used to handle
+ // UTF-8 sequences.
+ Utf8State
+)
+
+// StateNames provides string names for parser states.
+var StateNames = []string{
+ "GroundState",
+ "CsiEntryState",
+ "CsiIntermediateState",
+ "CsiParamState",
+ "DcsEntryState",
+ "DcsIntermediateState",
+ "DcsParamState",
+ "DcsStringState",
+ "EscapeState",
+ "EscapeIntermediateState",
+ "OscStringState",
+ "SosStringState",
+ "PmStringState",
+ "ApcStringState",
+ "Utf8State",
+}
diff --git a/vendor/github.com/charmbracelet/x/ansi/parser/seq.go b/vendor/github.com/charmbracelet/x/ansi/parser/seq.go
new file mode 100644
index 0000000000..de7e15e688
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/ansi/parser/seq.go
@@ -0,0 +1,136 @@
+package parser
+
+import "math"
+
+// Shift and masks for sequence parameters and intermediates.
+const (
+ PrefixShift = 8
+ IntermedShift = 16
+ FinalMask = 0xff
+ HasMoreFlag = math.MinInt32
+ ParamMask = ^HasMoreFlag
+ MissingParam = ParamMask
+ MissingCommand = MissingParam
+ MaxParam = math.MaxUint16 // the maximum value a parameter can have
+)
+
+const (
+ // MaxParamsSize is the maximum number of parameters a sequence can have.
+ MaxParamsSize = 32
+
+ // DefaultParamValue is the default value used for missing parameters.
+ DefaultParamValue = 0
+)
+
+// Prefix returns the prefix byte of the sequence.
+// This is always gonna be one of the following '<' '=' '>' '?' and in the
+// range of 0x3C-0x3F.
+// Zero is returned if the sequence does not have a prefix.
+func Prefix(cmd int) int {
+ return (cmd >> PrefixShift) & FinalMask
+}
+
+// Intermediate returns the intermediate byte of the sequence.
+// An intermediate byte is in the range of 0x20-0x2F. This includes these
+// characters from ' ', '!', '"', '#', '$', '%', '&', ”', '(', ')', '*', '+',
+// ',', '-', '.', '/'.
+// Zero is returned if the sequence does not have an intermediate byte.
+func Intermediate(cmd int) int {
+ return (cmd >> IntermedShift) & FinalMask
+}
+
+// Command returns the command byte of the CSI sequence.
+func Command(cmd int) int {
+ return cmd & FinalMask
+}
+
+// Param returns the parameter at the given index.
+// It returns -1 if the parameter does not exist.
+func Param(params []int, i int) int {
+ if len(params) == 0 || i < 0 || i >= len(params) {
+ return -1
+ }
+
+ p := params[i] & ParamMask
+ if p == MissingParam {
+ return -1
+ }
+
+ return p
+}
+
+// HasMore returns true if the parameter has more sub-parameters.
+func HasMore(params []int, i int) bool {
+ if len(params) == 0 || i >= len(params) {
+ return false
+ }
+
+ return params[i]&HasMoreFlag != 0
+}
+
+// Subparams returns the sub-parameters of the given parameter.
+// It returns nil if the parameter does not exist.
+func Subparams(params []int, i int) []int {
+ if len(params) == 0 || i < 0 || i >= len(params) {
+ return nil
+ }
+
+ // Count the number of parameters before the given parameter index.
+ var count int
+ var j int
+ for j = range params {
+ if count == i {
+ break
+ }
+ if !HasMore(params, j) {
+ count++
+ }
+ }
+
+ if count > i || j >= len(params) {
+ return nil
+ }
+
+ var subs []int
+ for ; j < len(params); j++ {
+ if !HasMore(params, j) {
+ break
+ }
+ p := Param(params, j)
+ if p == -1 {
+ p = DefaultParamValue
+ }
+ subs = append(subs, p)
+ }
+
+ p := Param(params, j)
+ if p == -1 {
+ p = DefaultParamValue
+ }
+
+ return append(subs, p)
+}
+
+// Len returns the number of parameters in the sequence.
+// This will return the number of parameters in the sequence, excluding any
+// sub-parameters.
+func Len(params []int) int {
+ var n int
+ for i := range params {
+ if !HasMore(params, i) {
+ n++
+ }
+ }
+ return n
+}
+
+// Range iterates over the parameters of the sequence and calls the given
+// function for each parameter.
+// The function should return false to stop the iteration.
+func Range(params []int, fn func(i int, param int, hasMore bool) bool) {
+ for i := range params {
+ if !fn(i, Param(params, i), HasMore(params, i)) {
+ break
+ }
+ }
+}
diff --git a/vendor/github.com/charmbracelet/x/ansi/parser/transition_table.go b/vendor/github.com/charmbracelet/x/ansi/parser/transition_table.go
new file mode 100644
index 0000000000..14daaf51ff
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/ansi/parser/transition_table.go
@@ -0,0 +1,273 @@
+package parser
+
+// Table values are generated like this:
+//
+// index: currentState << IndexStateShift | charCode
+// value: action << TransitionActionShift | nextState
+const (
+ TransitionActionShift = 4
+ TransitionStateMask = 15
+ IndexStateShift = 8
+
+ // DefaultTableSize is the default size of the transition table.
+ DefaultTableSize = 4096
+)
+
+// Table is a DEC ANSI transition table.
+var Table = GenerateTransitionTable()
+
+// TransitionTable is a DEC ANSI transition table.
+// https://vt100.net/emu/dec_ansi_parser
+type TransitionTable []byte
+
+// NewTransitionTable returns a new DEC ANSI transition table.
+func NewTransitionTable(size int) TransitionTable {
+ if size <= 0 {
+ size = DefaultTableSize
+ }
+ return TransitionTable(make([]byte, size))
+}
+
+// SetDefault sets default transition.
+func (t TransitionTable) SetDefault(action Action, state State) {
+ for i := range t {
+ t[i] = action<> TransitionActionShift
+}
+
+// byte range macro.
+func r(start, end byte) []byte {
+ var a []byte
+ for i := int(start); i <= int(end); i++ {
+ a = append(a, byte(i)) //nolint:gosec
+ }
+ return a
+}
+
+// GenerateTransitionTable generates a DEC ANSI transition table compatible
+// with the VT500-series of terminals. This implementation includes a few
+// modifications that include:
+// - A new Utf8State is introduced to handle UTF8 sequences.
+// - Osc and Dcs data accept UTF8 sequences by extending the printable range
+// to 0xFF and 0xFE respectively.
+// - We don't ignore 0x3A (':') when building Csi and Dcs parameters and
+// instead use it to denote sub-parameters.
+// - Support dispatching SosPmApc sequences.
+// - The DEL (0x7F) character is executed in the Ground state.
+// - The DEL (0x7F) character is collected in the DcsPassthrough string state.
+// - The ST C1 control character (0x9C) is executed and not ignored.
+func GenerateTransitionTable() TransitionTable {
+ table := NewTransitionTable(DefaultTableSize)
+ table.SetDefault(NoneAction, GroundState)
+
+ // Anywhere
+ for _, state := range r(GroundState, Utf8State) {
+ // Anywhere -> Ground
+ table.AddMany([]byte{0x18, 0x1a, 0x99, 0x9a}, state, ExecuteAction, GroundState)
+ table.AddRange(0x80, 0x8F, state, ExecuteAction, GroundState)
+ table.AddRange(0x90, 0x97, state, ExecuteAction, GroundState)
+ table.AddOne(0x9C, state, ExecuteAction, GroundState)
+ // Anywhere -> Escape
+ table.AddOne(0x1B, state, ClearAction, EscapeState)
+ // Anywhere -> SosStringState
+ table.AddOne(0x98, state, StartAction, SosStringState)
+ // Anywhere -> PmStringState
+ table.AddOne(0x9E, state, StartAction, PmStringState)
+ // Anywhere -> ApcStringState
+ table.AddOne(0x9F, state, StartAction, ApcStringState)
+ // Anywhere -> CsiEntry
+ table.AddOne(0x9B, state, ClearAction, CsiEntryState)
+ // Anywhere -> DcsEntry
+ table.AddOne(0x90, state, ClearAction, DcsEntryState)
+ // Anywhere -> OscString
+ table.AddOne(0x9D, state, StartAction, OscStringState)
+ // Anywhere -> Utf8
+ table.AddRange(0xC2, 0xDF, state, CollectAction, Utf8State) // UTF8 2 byte sequence
+ table.AddRange(0xE0, 0xEF, state, CollectAction, Utf8State) // UTF8 3 byte sequence
+ table.AddRange(0xF0, 0xF4, state, CollectAction, Utf8State) // UTF8 4 byte sequence
+ }
+
+ // Ground
+ table.AddRange(0x00, 0x17, GroundState, ExecuteAction, GroundState)
+ table.AddOne(0x19, GroundState, ExecuteAction, GroundState)
+ table.AddRange(0x1C, 0x1F, GroundState, ExecuteAction, GroundState)
+ table.AddRange(0x20, 0x7E, GroundState, PrintAction, GroundState)
+ table.AddOne(0x7F, GroundState, ExecuteAction, GroundState)
+
+ // EscapeIntermediate
+ table.AddRange(0x00, 0x17, EscapeIntermediateState, ExecuteAction, EscapeIntermediateState)
+ table.AddOne(0x19, EscapeIntermediateState, ExecuteAction, EscapeIntermediateState)
+ table.AddRange(0x1C, 0x1F, EscapeIntermediateState, ExecuteAction, EscapeIntermediateState)
+ table.AddRange(0x20, 0x2F, EscapeIntermediateState, CollectAction, EscapeIntermediateState)
+ table.AddOne(0x7F, EscapeIntermediateState, IgnoreAction, EscapeIntermediateState)
+ // EscapeIntermediate -> Ground
+ table.AddRange(0x30, 0x7E, EscapeIntermediateState, DispatchAction, GroundState)
+
+ // Escape
+ table.AddRange(0x00, 0x17, EscapeState, ExecuteAction, EscapeState)
+ table.AddOne(0x19, EscapeState, ExecuteAction, EscapeState)
+ table.AddRange(0x1C, 0x1F, EscapeState, ExecuteAction, EscapeState)
+ table.AddOne(0x7F, EscapeState, IgnoreAction, EscapeState)
+ // Escape -> Ground
+ table.AddRange(0x30, 0x4F, EscapeState, DispatchAction, GroundState)
+ table.AddRange(0x51, 0x57, EscapeState, DispatchAction, GroundState)
+ table.AddOne(0x59, EscapeState, DispatchAction, GroundState)
+ table.AddOne(0x5A, EscapeState, DispatchAction, GroundState)
+ table.AddOne(0x5C, EscapeState, DispatchAction, GroundState)
+ table.AddRange(0x60, 0x7E, EscapeState, DispatchAction, GroundState)
+ // Escape -> Escape_intermediate
+ table.AddRange(0x20, 0x2F, EscapeState, CollectAction, EscapeIntermediateState)
+ // Escape -> Sos_pm_apc_string
+ table.AddOne('X', EscapeState, StartAction, SosStringState) // SOS
+ table.AddOne('^', EscapeState, StartAction, PmStringState) // PM
+ table.AddOne('_', EscapeState, StartAction, ApcStringState) // APC
+ // Escape -> Dcs_entry
+ table.AddOne('P', EscapeState, ClearAction, DcsEntryState)
+ // Escape -> Csi_entry
+ table.AddOne('[', EscapeState, ClearAction, CsiEntryState)
+ // Escape -> Osc_string
+ table.AddOne(']', EscapeState, StartAction, OscStringState)
+
+ // Sos_pm_apc_string
+ for _, state := range r(SosStringState, ApcStringState) {
+ table.AddRange(0x00, 0x17, state, PutAction, state)
+ table.AddOne(0x19, state, PutAction, state)
+ table.AddRange(0x1C, 0x1F, state, PutAction, state)
+ table.AddRange(0x20, 0x7F, state, PutAction, state)
+ // ESC, ST, CAN, and SUB terminate the sequence
+ table.AddOne(0x1B, state, DispatchAction, EscapeState)
+ table.AddOne(0x9C, state, DispatchAction, GroundState)
+ table.AddMany([]byte{0x18, 0x1A}, state, IgnoreAction, GroundState)
+ }
+
+ // Dcs_entry
+ table.AddRange(0x00, 0x07, DcsEntryState, IgnoreAction, DcsEntryState)
+ table.AddRange(0x0E, 0x17, DcsEntryState, IgnoreAction, DcsEntryState)
+ table.AddOne(0x19, DcsEntryState, IgnoreAction, DcsEntryState)
+ table.AddRange(0x1C, 0x1F, DcsEntryState, IgnoreAction, DcsEntryState)
+ table.AddOne(0x7F, DcsEntryState, IgnoreAction, DcsEntryState)
+ // Dcs_entry -> Dcs_intermediate
+ table.AddRange(0x20, 0x2F, DcsEntryState, CollectAction, DcsIntermediateState)
+ // Dcs_entry -> Dcs_param
+ table.AddRange(0x30, 0x3B, DcsEntryState, ParamAction, DcsParamState)
+ table.AddRange(0x3C, 0x3F, DcsEntryState, PrefixAction, DcsParamState)
+ // Dcs_entry -> Dcs_passthrough
+ table.AddRange(0x08, 0x0D, DcsEntryState, PutAction, DcsStringState) // Follows ECMA-48 § 8.3.27
+ // XXX: allows passing ESC (not a ECMA-48 standard) this to allow for
+ // passthrough of ANSI sequences like in Screen or Tmux passthrough mode.
+ table.AddOne(0x1B, DcsEntryState, PutAction, DcsStringState)
+ table.AddRange(0x40, 0x7E, DcsEntryState, StartAction, DcsStringState)
+
+ // Dcs_intermediate
+ table.AddRange(0x00, 0x17, DcsIntermediateState, IgnoreAction, DcsIntermediateState)
+ table.AddOne(0x19, DcsIntermediateState, IgnoreAction, DcsIntermediateState)
+ table.AddRange(0x1C, 0x1F, DcsIntermediateState, IgnoreAction, DcsIntermediateState)
+ table.AddRange(0x20, 0x2F, DcsIntermediateState, CollectAction, DcsIntermediateState)
+ table.AddOne(0x7F, DcsIntermediateState, IgnoreAction, DcsIntermediateState)
+ // Dcs_intermediate -> Dcs_passthrough
+ table.AddRange(0x30, 0x3F, DcsIntermediateState, StartAction, DcsStringState)
+ table.AddRange(0x40, 0x7E, DcsIntermediateState, StartAction, DcsStringState)
+
+ // Dcs_param
+ table.AddRange(0x00, 0x17, DcsParamState, IgnoreAction, DcsParamState)
+ table.AddOne(0x19, DcsParamState, IgnoreAction, DcsParamState)
+ table.AddRange(0x1C, 0x1F, DcsParamState, IgnoreAction, DcsParamState)
+ table.AddRange(0x30, 0x3B, DcsParamState, ParamAction, DcsParamState)
+ table.AddOne(0x7F, DcsParamState, IgnoreAction, DcsParamState)
+ table.AddRange(0x3C, 0x3F, DcsParamState, IgnoreAction, DcsParamState)
+ // Dcs_param -> Dcs_intermediate
+ table.AddRange(0x20, 0x2F, DcsParamState, CollectAction, DcsIntermediateState)
+ // Dcs_param -> Dcs_passthrough
+ table.AddRange(0x40, 0x7E, DcsParamState, StartAction, DcsStringState)
+
+ // Dcs_passthrough
+ table.AddRange(0x00, 0x17, DcsStringState, PutAction, DcsStringState)
+ table.AddOne(0x19, DcsStringState, PutAction, DcsStringState)
+ table.AddRange(0x1C, 0x1F, DcsStringState, PutAction, DcsStringState)
+ table.AddRange(0x20, 0x7E, DcsStringState, PutAction, DcsStringState)
+ table.AddOne(0x7F, DcsStringState, PutAction, DcsStringState)
+ table.AddRange(0x80, 0xFF, DcsStringState, PutAction, DcsStringState) // Allow Utf8 characters by extending the printable range from 0x7F to 0xFF
+ // ST, CAN, SUB, and ESC terminate the sequence
+ table.AddOne(0x1B, DcsStringState, DispatchAction, EscapeState)
+ table.AddOne(0x9C, DcsStringState, DispatchAction, GroundState)
+ table.AddMany([]byte{0x18, 0x1A}, DcsStringState, IgnoreAction, GroundState)
+
+ // Csi_param
+ table.AddRange(0x00, 0x17, CsiParamState, ExecuteAction, CsiParamState)
+ table.AddOne(0x19, CsiParamState, ExecuteAction, CsiParamState)
+ table.AddRange(0x1C, 0x1F, CsiParamState, ExecuteAction, CsiParamState)
+ table.AddRange(0x30, 0x3B, CsiParamState, ParamAction, CsiParamState)
+ table.AddOne(0x7F, CsiParamState, IgnoreAction, CsiParamState)
+ table.AddRange(0x3C, 0x3F, CsiParamState, IgnoreAction, CsiParamState)
+ // Csi_param -> Ground
+ table.AddRange(0x40, 0x7E, CsiParamState, DispatchAction, GroundState)
+ // Csi_param -> Csi_intermediate
+ table.AddRange(0x20, 0x2F, CsiParamState, CollectAction, CsiIntermediateState)
+
+ // Csi_intermediate
+ table.AddRange(0x00, 0x17, CsiIntermediateState, ExecuteAction, CsiIntermediateState)
+ table.AddOne(0x19, CsiIntermediateState, ExecuteAction, CsiIntermediateState)
+ table.AddRange(0x1C, 0x1F, CsiIntermediateState, ExecuteAction, CsiIntermediateState)
+ table.AddRange(0x20, 0x2F, CsiIntermediateState, CollectAction, CsiIntermediateState)
+ table.AddOne(0x7F, CsiIntermediateState, IgnoreAction, CsiIntermediateState)
+ // Csi_intermediate -> Ground
+ table.AddRange(0x40, 0x7E, CsiIntermediateState, DispatchAction, GroundState)
+ // Csi_intermediate -> Csi_ignore
+ table.AddRange(0x30, 0x3F, CsiIntermediateState, IgnoreAction, GroundState)
+
+ // Csi_entry
+ table.AddRange(0x00, 0x17, CsiEntryState, ExecuteAction, CsiEntryState)
+ table.AddOne(0x19, CsiEntryState, ExecuteAction, CsiEntryState)
+ table.AddRange(0x1C, 0x1F, CsiEntryState, ExecuteAction, CsiEntryState)
+ table.AddOne(0x7F, CsiEntryState, IgnoreAction, CsiEntryState)
+ // Csi_entry -> Ground
+ table.AddRange(0x40, 0x7E, CsiEntryState, DispatchAction, GroundState)
+ // Csi_entry -> Csi_intermediate
+ table.AddRange(0x20, 0x2F, CsiEntryState, CollectAction, CsiIntermediateState)
+ // Csi_entry -> Csi_param
+ table.AddRange(0x30, 0x3B, CsiEntryState, ParamAction, CsiParamState)
+ table.AddRange(0x3C, 0x3F, CsiEntryState, PrefixAction, CsiParamState)
+
+ // Osc_string
+ table.AddRange(0x00, 0x06, OscStringState, IgnoreAction, OscStringState)
+ table.AddRange(0x08, 0x17, OscStringState, IgnoreAction, OscStringState)
+ table.AddOne(0x19, OscStringState, IgnoreAction, OscStringState)
+ table.AddRange(0x1C, 0x1F, OscStringState, IgnoreAction, OscStringState)
+ table.AddRange(0x20, 0xFF, OscStringState, PutAction, OscStringState) // Allow Utf8 characters by extending the printable range from 0x7F to 0xFF
+
+ // ST, CAN, SUB, ESC, and BEL terminate the sequence
+ table.AddOne(0x1B, OscStringState, DispatchAction, EscapeState)
+ table.AddOne(0x07, OscStringState, DispatchAction, GroundState)
+ table.AddOne(0x9C, OscStringState, DispatchAction, GroundState)
+ table.AddMany([]byte{0x18, 0x1A}, OscStringState, IgnoreAction, GroundState)
+
+ return table
+}
diff --git a/vendor/github.com/charmbracelet/x/ansi/parser_decode.go b/vendor/github.com/charmbracelet/x/ansi/parser_decode.go
new file mode 100644
index 0000000000..486135b726
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/ansi/parser_decode.go
@@ -0,0 +1,525 @@
+package ansi
+
+import (
+ "unicode/utf8"
+
+ "github.com/charmbracelet/x/ansi/parser"
+ "github.com/clipperhouse/uax29/v2/graphemes"
+)
+
+// State represents the state of the ANSI escape sequence parser used by
+// [DecodeSequence].
+type State = byte
+
+// ANSI escape sequence states used by [DecodeSequence].
+const (
+ NormalState State = iota
+ PrefixState
+ ParamsState
+ IntermedState
+ EscapeState
+ StringState
+)
+
+// DecodeSequence decodes the first ANSI escape sequence or a printable
+// grapheme from the given data. It returns the sequence slice, the number of
+// bytes read, the cell width for each sequence, and the new state.
+//
+// The cell width will always be 0 for control and escape sequences, 1 for
+// ASCII printable characters, and the number of cells other Unicode characters
+// occupy. It uses the uniseg package to calculate the width of Unicode
+// graphemes and characters. This means it will always do grapheme clustering
+// (mode 2027).
+//
+// Passing a non-nil [*Parser] as the last argument will allow the decoder to
+// collect sequence parameters, data, and commands. The parser cmd will have
+// the packed command value that contains intermediate and prefix characters.
+// In the case of a OSC sequence, the cmd will be the OSC command number. Use
+// [Cmd] and [Param] types to unpack command intermediates and prefixes as well
+// as parameters.
+//
+// Zero [Cmd] means the CSI, DCS, or ESC sequence is invalid. Moreover, checking the
+// validity of other data sequences, OSC, DCS, etc, will require checking for
+// the returned sequence terminator bytes such as ST (ESC \\) and BEL).
+//
+// We store the command byte in [Cmd] in the most significant byte, the
+// prefix byte in the next byte, and the intermediate byte in the least
+// significant byte. This is done to avoid using a struct to store the command
+// and its intermediates and prefixes. The command byte is always the least
+// significant byte i.e. [Cmd & 0xff]. Use the [Cmd] type to unpack the
+// command, intermediate, and prefix bytes. Note that we only collect the last
+// prefix character and intermediate byte.
+//
+// The [p.Params] slice will contain the parameters of the sequence. Any
+// sub-parameter will have the [parser.HasMoreFlag] set. Use the [Param] type
+// to unpack the parameters.
+//
+// Example:
+//
+// var state byte // the initial state is always zero [NormalState]
+// p := NewParser(32, 1024) // create a new parser with a 32 params buffer and 1024 data buffer (optional)
+// input := []byte("\x1b[31mHello, World!\x1b[0m")
+// for len(input) > 0 {
+// seq, width, n, newState := DecodeSequence(input, state, p)
+// log.Printf("seq: %q, width: %d", seq, width)
+// state = newState
+// input = input[n:]
+// }
+//
+// This function treats the text as a sequence of grapheme clusters.
+func DecodeSequence[T string | []byte](b T, state byte, p *Parser) (seq T, width int, n int, newState byte) {
+ return decodeSequence(GraphemeWidth, b, state, p)
+}
+
+// DecodeSequenceWc decodes the first ANSI escape sequence or a printable
+// grapheme from the given data. It returns the sequence slice, the number of
+// bytes read, the cell width for each sequence, and the new state.
+//
+// The cell width will always be 0 for control and escape sequences, 1 for
+// ASCII printable characters, and the number of cells other Unicode characters
+// occupy. It uses the uniseg package to calculate the width of Unicode
+// graphemes and characters. This means it will always do grapheme clustering
+// (mode 2027).
+//
+// Passing a non-nil [*Parser] as the last argument will allow the decoder to
+// collect sequence parameters, data, and commands. The parser cmd will have
+// the packed command value that contains intermediate and prefix characters.
+// In the case of a OSC sequence, the cmd will be the OSC command number. Use
+// [Cmd] and [Param] types to unpack command intermediates and prefixes as well
+// as parameters.
+//
+// Zero [Cmd] means the CSI, DCS, or ESC sequence is invalid. Moreover, checking the
+// validity of other data sequences, OSC, DCS, etc, will require checking for
+// the returned sequence terminator bytes such as ST (ESC \\) and BEL).
+//
+// We store the command byte in [Cmd] in the most significant byte, the
+// prefix byte in the next byte, and the intermediate byte in the least
+// significant byte. This is done to avoid using a struct to store the command
+// and its intermediates and prefixes. The command byte is always the least
+// significant byte i.e. [Cmd & 0xff]. Use the [Cmd] type to unpack the
+// command, intermediate, and prefix bytes. Note that we only collect the last
+// prefix character and intermediate byte.
+//
+// The [p.Params] slice will contain the parameters of the sequence. Any
+// sub-parameter will have the [parser.HasMoreFlag] set. Use the [Param] type
+// to unpack the parameters.
+//
+// Example:
+//
+// var state byte // the initial state is always zero [NormalState]
+// p := NewParser(32, 1024) // create a new parser with a 32 params buffer and 1024 data buffer (optional)
+// input := []byte("\x1b[31mHello, World!\x1b[0m")
+// for len(input) > 0 {
+// seq, width, n, newState := DecodeSequenceWc(input, state, p)
+// log.Printf("seq: %q, width: %d", seq, width)
+// state = newState
+// input = input[n:]
+// }
+//
+// This function treats the text as a sequence of wide characters and runes.
+func DecodeSequenceWc[T string | []byte](b T, state byte, p *Parser) (seq T, width int, n int, newState byte) {
+ return decodeSequence(WcWidth, b, state, p)
+}
+
+func decodeSequence[T string | []byte](m Method, b T, state State, p *Parser) (seq T, width int, n int, newState byte) {
+ for i := 0; i < len(b); i++ {
+ c := b[i]
+
+ switch state {
+ case NormalState:
+ switch c {
+ case ESC:
+ if p != nil {
+ if len(p.params) > 0 {
+ p.params[0] = parser.MissingParam
+ }
+ p.cmd = 0
+ p.paramsLen = 0
+ p.dataLen = 0
+ }
+ state = EscapeState
+ continue
+ case CSI, DCS:
+ if p != nil {
+ if len(p.params) > 0 {
+ p.params[0] = parser.MissingParam
+ }
+ p.cmd = 0
+ p.paramsLen = 0
+ p.dataLen = 0
+ }
+ state = PrefixState
+ continue
+ case OSC, APC, SOS, PM:
+ if p != nil {
+ p.cmd = parser.MissingCommand
+ p.dataLen = 0
+ }
+ state = StringState
+ continue
+ }
+
+ if p != nil {
+ p.dataLen = 0
+ p.paramsLen = 0
+ p.cmd = 0
+ }
+ if c > US && c < DEL {
+ // ASCII printable characters
+ return b[i : i+1], 1, 1, NormalState
+ }
+
+ if c <= US || c == DEL || c < 0xC0 {
+ // C0 & C1 control characters & DEL
+ return b[i : i+1], 0, 1, NormalState
+ }
+
+ if utf8.RuneStart(c) {
+ seq, width = FirstGraphemeCluster(b, m)
+ i += len(seq)
+ return b[:i], width, i, NormalState
+ }
+
+ // Invalid UTF-8 sequence
+ return b[:i], 0, i, NormalState
+ case PrefixState:
+ if c >= '<' && c <= '?' {
+ if p != nil {
+ // We only collect the last prefix character.
+ p.cmd &^= 0xff << parser.PrefixShift
+ p.cmd |= int(c) << parser.PrefixShift
+ }
+ break
+ }
+
+ state = ParamsState
+ fallthrough
+ case ParamsState:
+ if c >= '0' && c <= '9' {
+ if p != nil {
+ if p.params[p.paramsLen] == parser.MissingParam {
+ p.params[p.paramsLen] = 0
+ }
+
+ p.params[p.paramsLen] *= 10
+ p.params[p.paramsLen] += int(c - '0')
+ }
+ break
+ }
+
+ if c == ':' {
+ if p != nil {
+ p.params[p.paramsLen] |= parser.HasMoreFlag
+ }
+ }
+
+ if c == ';' || c == ':' {
+ if p != nil {
+ p.paramsLen++
+ if p.paramsLen < len(p.params) {
+ p.params[p.paramsLen] = parser.MissingParam
+ }
+ }
+ break
+ }
+
+ state = IntermedState
+ fallthrough
+ case IntermedState:
+ if c >= ' ' && c <= '/' {
+ if p != nil {
+ p.cmd &^= 0xff << parser.IntermedShift
+ p.cmd |= int(c) << parser.IntermedShift
+ }
+ break
+ }
+
+ if p != nil {
+ // Increment the last parameter
+ if p.paramsLen > 0 && p.paramsLen < len(p.params)-1 ||
+ p.paramsLen == 0 && len(p.params) > 0 && p.params[0] != parser.MissingParam {
+ p.paramsLen++
+ }
+ }
+
+ if c >= '@' && c <= '~' {
+ if p != nil {
+ p.cmd &^= 0xff
+ p.cmd |= int(c)
+ }
+
+ if HasDcsPrefix(b) {
+ // Continue to collect DCS data
+ if p != nil {
+ p.dataLen = 0
+ }
+ state = StringState
+ continue
+ }
+
+ return b[:i+1], 0, i + 1, NormalState
+ }
+
+ // Invalid CSI/DCS sequence
+ return b[:i], 0, i, NormalState
+ case EscapeState:
+ switch c {
+ case '[', 'P':
+ if p != nil {
+ if len(p.params) > 0 {
+ p.params[0] = parser.MissingParam
+ }
+ p.paramsLen = 0
+ p.cmd = 0
+ }
+ state = PrefixState
+ continue
+ case ']', 'X', '^', '_':
+ if p != nil {
+ p.cmd = parser.MissingCommand
+ p.dataLen = 0
+ }
+ state = StringState
+ continue
+ }
+
+ if c >= ' ' && c <= '/' {
+ if p != nil {
+ p.cmd &^= 0xff << parser.IntermedShift
+ p.cmd |= int(c) << parser.IntermedShift
+ }
+ continue
+ } else if c >= '0' && c <= '~' {
+ if p != nil {
+ p.cmd &^= 0xff
+ p.cmd |= int(c)
+ }
+ return b[:i+1], 0, i + 1, NormalState
+ }
+
+ // Invalid escape sequence
+ return b[:i], 0, i, NormalState
+ case StringState:
+ switch c {
+ case BEL:
+ if HasOscPrefix(b) {
+ parseOscCmd(p)
+ return b[:i+1], 0, i + 1, NormalState
+ }
+ case CAN, SUB:
+ if HasOscPrefix(b) {
+ // Ensure we parse the OSC command number
+ parseOscCmd(p)
+ }
+
+ // Cancel the sequence
+ return b[:i], 0, i, NormalState
+ case ST:
+ if HasOscPrefix(b) {
+ // Ensure we parse the OSC command number
+ parseOscCmd(p)
+ }
+
+ return b[:i+1], 0, i + 1, NormalState
+ case ESC:
+ if HasStPrefix(b[i:]) {
+ if HasOscPrefix(b) {
+ // Ensure we parse the OSC command number
+ parseOscCmd(p)
+ }
+
+ // End of string 7-bit (ST)
+ return b[:i+2], 0, i + 2, NormalState
+ }
+
+ // Otherwise, cancel the sequence
+ return b[:i], 0, i, NormalState
+ }
+
+ if p != nil && p.dataLen < len(p.data) {
+ p.data[p.dataLen] = c
+ p.dataLen++
+
+ // Parse the OSC command number
+ if c == ';' && HasOscPrefix(b) {
+ parseOscCmd(p)
+ }
+ }
+ }
+ }
+
+ return b, 0, len(b), state
+}
+
+func parseOscCmd(p *Parser) {
+ if p == nil || p.cmd != parser.MissingCommand {
+ return
+ }
+ for j := range p.dataLen {
+ d := p.data[j]
+ if d < '0' || d > '9' {
+ break
+ }
+ if p.cmd == parser.MissingCommand {
+ p.cmd = 0
+ }
+ p.cmd *= 10
+ p.cmd += int(d - '0')
+ }
+}
+
+// Equal returns true if the given byte slices are equal.
+func Equal[T string | []byte](a, b T) bool {
+ return string(a) == string(b)
+}
+
+// HasPrefix returns true if the given byte slice has prefix.
+func HasPrefix[T string | []byte](b, prefix T) bool {
+ return len(b) >= len(prefix) && Equal(b[0:len(prefix)], prefix)
+}
+
+// HasSuffix returns true if the given byte slice has suffix.
+func HasSuffix[T string | []byte](b, suffix T) bool {
+ return len(b) >= len(suffix) && Equal(b[len(b)-len(suffix):], suffix)
+}
+
+// HasCsiPrefix returns true if the given byte slice has a CSI prefix.
+func HasCsiPrefix[T string | []byte](b T) bool {
+ return (len(b) > 0 && b[0] == CSI) ||
+ (len(b) > 1 && b[0] == ESC && b[1] == '[')
+}
+
+// HasOscPrefix returns true if the given byte slice has an OSC prefix.
+func HasOscPrefix[T string | []byte](b T) bool {
+ return (len(b) > 0 && b[0] == OSC) ||
+ (len(b) > 1 && b[0] == ESC && b[1] == ']')
+}
+
+// HasApcPrefix returns true if the given byte slice has an APC prefix.
+func HasApcPrefix[T string | []byte](b T) bool {
+ return (len(b) > 0 && b[0] == APC) ||
+ (len(b) > 1 && b[0] == ESC && b[1] == '_')
+}
+
+// HasDcsPrefix returns true if the given byte slice has a DCS prefix.
+func HasDcsPrefix[T string | []byte](b T) bool {
+ return (len(b) > 0 && b[0] == DCS) ||
+ (len(b) > 1 && b[0] == ESC && b[1] == 'P')
+}
+
+// HasSosPrefix returns true if the given byte slice has a SOS prefix.
+func HasSosPrefix[T string | []byte](b T) bool {
+ return (len(b) > 0 && b[0] == SOS) ||
+ (len(b) > 1 && b[0] == ESC && b[1] == 'X')
+}
+
+// HasPmPrefix returns true if the given byte slice has a PM prefix.
+func HasPmPrefix[T string | []byte](b T) bool {
+ return (len(b) > 0 && b[0] == PM) ||
+ (len(b) > 1 && b[0] == ESC && b[1] == '^')
+}
+
+// HasStPrefix returns true if the given byte slice has a ST prefix.
+func HasStPrefix[T string | []byte](b T) bool {
+ return (len(b) > 0 && b[0] == ST) ||
+ (len(b) > 1 && b[0] == ESC && b[1] == '\\')
+}
+
+// HasEscPrefix returns true if the given byte slice has an ESC prefix.
+func HasEscPrefix[T string | []byte](b T) bool {
+ return len(b) > 0 && b[0] == ESC
+}
+
+// FirstGraphemeCluster returns the first grapheme cluster in the given string
+// or byte slice, and its monospace display width.
+func FirstGraphemeCluster[T string | []byte](b T, m Method) (T, int) {
+ switch b := any(b).(type) {
+ case string:
+ cluster := graphemes.FromString(b).First()
+ if m == WcWidth {
+ return T(cluster), wcClusterWidth(cluster)
+ }
+ return T(cluster), dwOptions.String(cluster)
+ case []byte:
+ cluster := graphemes.FromBytes(b).First()
+ if m == WcWidth {
+ return T(cluster), wcClusterWidth(cluster)
+ }
+ return T(cluster), dwOptions.Bytes(cluster)
+ }
+ panic("unreachable")
+}
+
+// Cmd represents a sequence command. This is used to pack/unpack a sequence
+// command with its intermediate and prefix characters. Those are commonly
+// found in CSI and DCS sequences.
+type Cmd int
+
+// Prefix returns the unpacked prefix byte of the CSI sequence.
+// This is always gonna be one of the following '<' '=' '>' '?' and in the
+// range of 0x3C-0x3F.
+// Zero is returned if the sequence does not have a prefix.
+func (c Cmd) Prefix() byte {
+ return byte(parser.Prefix(int(c))) //nolint:gosec
+}
+
+// Intermediate returns the unpacked intermediate byte of the CSI sequence.
+// An intermediate byte is in the range of 0x20-0x2F. This includes these
+// characters from ' ', '!', '"', '#', '$', '%', '&', ”', '(', ')', '*', '+',
+// ',', '-', '.', '/'.
+// Zero is returned if the sequence does not have an intermediate byte.
+func (c Cmd) Intermediate() byte {
+ return byte(parser.Intermediate(int(c))) //nolint:gosec
+}
+
+// Final returns the unpacked command byte of the CSI sequence.
+func (c Cmd) Final() byte {
+ return byte(parser.Command(int(c))) //nolint:gosec
+}
+
+// Command packs a command with the given prefix, intermediate, and final. A
+// zero byte means the sequence does not have a prefix or intermediate.
+//
+// Prefixes are in the range of 0x3C-0x3F that is one of `<=>?`.
+//
+// Intermediates are in the range of 0x20-0x2F that is anything in
+// `!"#$%&'()*+,-./`.
+//
+// Final bytes are in the range of 0x40-0x7E that is anything in the range
+// `@A–Z[\]^_`a–z{|}~`.
+func Command(prefix, inter, final byte) (c int) {
+ c = int(final)
+ c |= int(prefix) << parser.PrefixShift
+ c |= int(inter) << parser.IntermedShift
+ return c
+}
+
+// Param represents a sequence parameter. Sequence parameters with
+// sub-parameters are packed with the HasMoreFlag set. This is used to unpack
+// the parameters from a CSI and DCS sequences.
+type Param int
+
+// Param returns the unpacked parameter at the given index.
+// It returns the default value if the parameter is missing.
+func (s Param) Param(def int) int {
+ p := int(s) & parser.ParamMask
+ if p == parser.MissingParam {
+ return def
+ }
+ return p
+}
+
+// HasMore unpacks the HasMoreFlag from the parameter.
+func (s Param) HasMore() bool {
+ return s&parser.HasMoreFlag != 0
+}
+
+// Parameter packs an escape code parameter with the given parameter and
+// whether this parameter has following sub-parameters.
+func Parameter(p int, hasMore bool) (s int) {
+ s = p & parser.ParamMask
+ if hasMore {
+ s |= parser.HasMoreFlag
+ }
+ return s
+}
diff --git a/vendor/github.com/charmbracelet/x/ansi/parser_handler.go b/vendor/github.com/charmbracelet/x/ansi/parser_handler.go
new file mode 100644
index 0000000000..03f9ed4cbd
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/ansi/parser_handler.go
@@ -0,0 +1,60 @@
+package ansi
+
+import "unsafe"
+
+// Params represents a list of packed parameters.
+type Params []Param
+
+// Param returns the parameter at the given index and if it is part of a
+// sub-parameters. It falls back to the default value if the parameter is
+// missing. If the index is out of bounds, it returns the default value and
+// false.
+func (p Params) Param(i, def int) (int, bool, bool) {
+ if i < 0 || i >= len(p) {
+ return def, false, false
+ }
+ return p[i].Param(def), p[i].HasMore(), true
+}
+
+// ForEach iterates over the parameters and calls the given function for each
+// parameter. If a parameter is part of a sub-parameter, it will be called with
+// hasMore set to true.
+// Use def to set a default value for missing parameters.
+func (p Params) ForEach(def int, f func(i, param int, hasMore bool)) {
+ for i := range p {
+ f(i, p[i].Param(def), p[i].HasMore())
+ }
+}
+
+// ToParams converts a list of integers to a list of parameters.
+func ToParams(params []int) Params {
+ return unsafe.Slice((*Param)(unsafe.Pointer(¶ms[0])), len(params))
+}
+
+// Handler handles actions performed by the parser.
+// It is used to handle ANSI escape sequences, control characters, and runes.
+type Handler struct {
+ // Print is called when a printable rune is encountered.
+ Print func(r rune)
+ // Execute is called when a control character is encountered.
+ Execute func(b byte)
+ // HandleCsi is called when a CSI sequence is encountered.
+ HandleCsi func(cmd Cmd, params Params)
+ // HandleEsc is called when an ESC sequence is encountered.
+ HandleEsc func(cmd Cmd)
+ // HandleDcs is called when a DCS sequence is encountered.
+ HandleDcs func(cmd Cmd, params Params, data []byte)
+ // HandleOsc is called when an OSC sequence is encountered.
+ HandleOsc func(cmd int, data []byte)
+ // HandlePm is called when a PM sequence is encountered.
+ HandlePm func(data []byte)
+ // HandleApc is called when an APC sequence is encountered.
+ HandleApc func(data []byte)
+ // HandleSos is called when a SOS sequence is encountered.
+ HandleSos func(data []byte)
+}
+
+// SetHandler sets the handler for the parser.
+func (p *Parser) SetHandler(h Handler) {
+ p.handler = h
+}
diff --git a/vendor/github.com/charmbracelet/x/ansi/parser_sync.go b/vendor/github.com/charmbracelet/x/ansi/parser_sync.go
new file mode 100644
index 0000000000..7a099d0801
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/ansi/parser_sync.go
@@ -0,0 +1,29 @@
+package ansi
+
+import (
+ "sync"
+
+ "github.com/charmbracelet/x/ansi/parser"
+)
+
+var parserPool = sync.Pool{
+ New: func() any {
+ p := NewParser()
+ p.SetParamsSize(parser.MaxParamsSize)
+ p.SetDataSize(1024 * 4) // 4KB of data buffer
+ return p
+ },
+}
+
+// GetParser returns a parser from a sync pool.
+func GetParser() *Parser {
+ return parserPool.Get().(*Parser)
+}
+
+// PutParser returns a parser to a sync pool. The parser is reset
+// automatically.
+func PutParser(p *Parser) {
+ p.Reset()
+ p.dataLen = 0
+ parserPool.Put(p)
+}
diff --git a/vendor/github.com/charmbracelet/x/ansi/passthrough.go b/vendor/github.com/charmbracelet/x/ansi/passthrough.go
new file mode 100644
index 0000000000..7ac7cef159
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/ansi/passthrough.go
@@ -0,0 +1,60 @@
+package ansi
+
+import (
+ "bytes"
+)
+
+// ScreenPassthrough wraps the given ANSI sequence in a DCS passthrough
+// sequence to be sent to the outer terminal. This is used to send raw escape
+// sequences to the outer terminal when running inside GNU Screen.
+//
+// DCS ST
+//
+// Note: Screen limits the length of string sequences to 768 bytes (since 2014).
+// Use zero to indicate no limit, otherwise, this will chunk the returned
+// string into limit sized chunks.
+//
+// See: https://www.gnu.org/software/screen/manual/screen.html#String-Escapes
+// See: https://git.savannah.gnu.org/cgit/screen.git/tree/src/screen.h?id=c184c6ec27683ff1a860c45be5cf520d896fd2ef#n44
+func ScreenPassthrough(seq string, limit int) string {
+ var b bytes.Buffer
+ b.WriteString("\x1bP")
+ if limit > 0 {
+ for i := 0; i < len(seq); i += limit {
+ end := min(i+limit, len(seq))
+ b.WriteString(seq[i:end])
+ if end < len(seq) {
+ b.WriteString("\x1b\\\x1bP")
+ }
+ }
+ } else {
+ b.WriteString(seq)
+ }
+ b.WriteString("\x1b\\")
+ return b.String()
+}
+
+// TmuxPassthrough wraps the given ANSI sequence in a special DCS passthrough
+// sequence to be sent to the outer terminal. This is used to send raw escape
+// sequences to the outer terminal when running inside Tmux.
+//
+// DCS tmux ; ST
+//
+// Where is the given sequence in which all occurrences of ESC
+// (0x1b) are doubled i.e. replaced with ESC ESC (0x1b 0x1b).
+//
+// Note: this needs the `allow-passthrough` option to be set to `on`.
+//
+// See: https://github.com/tmux/tmux/wiki/FAQ#what-is-the-passthrough-escape-sequence-and-how-do-i-use-it
+func TmuxPassthrough(seq string) string {
+ var b bytes.Buffer
+ b.WriteString("\x1bPtmux;")
+ for i := range len(seq) {
+ if seq[i] == ESC {
+ b.WriteByte(ESC)
+ }
+ b.WriteByte(seq[i])
+ }
+ b.WriteString("\x1b\\")
+ return b.String()
+}
diff --git a/vendor/github.com/charmbracelet/x/ansi/paste.go b/vendor/github.com/charmbracelet/x/ansi/paste.go
new file mode 100644
index 0000000000..2f9ea6f79e
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/ansi/paste.go
@@ -0,0 +1,7 @@
+package ansi
+
+// BracketedPasteStart is the control sequence to enable bracketed paste mode.
+const BracketedPasteStart = "\x1b[200~"
+
+// BracketedPasteEnd is the control sequence to disable bracketed paste mode.
+const BracketedPasteEnd = "\x1b[201~"
diff --git a/vendor/github.com/charmbracelet/x/ansi/progress.go b/vendor/github.com/charmbracelet/x/ansi/progress.go
new file mode 100644
index 0000000000..19441d1eb0
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/ansi/progress.go
@@ -0,0 +1,49 @@
+package ansi
+
+import "strconv"
+
+// ResetProgressBar is a sequence that resets the progress bar to its default
+// state (hidden).
+//
+// OSC 9 ; 4 ; 0 BEL
+//
+// See: https://learn.microsoft.com/en-us/windows/terminal/tutorials/progress-bar-sequences
+const ResetProgressBar = "\x1b]9;4;0\x07"
+
+// SetProgressBar returns a sequence for setting the progress bar to a specific
+// percentage (0-100) in the "default" state.
+//
+// OSC 9 ; 4 ; 1 Percentage BEL
+//
+// See: https://learn.microsoft.com/en-us/windows/terminal/tutorials/progress-bar-sequences
+func SetProgressBar(percentage int) string {
+ return "\x1b]9;4;1;" + strconv.Itoa(min(max(0, percentage), 100)) + "\x07"
+}
+
+// SetErrorProgressBar returns a sequence for setting the progress bar to a
+// specific percentage (0-100) in the "Error" state..
+//
+// OSC 9 ; 4 ; 2 Percentage BEL
+//
+// See: https://learn.microsoft.com/en-us/windows/terminal/tutorials/progress-bar-sequences
+func SetErrorProgressBar(percentage int) string {
+ return "\x1b]9;4;2;" + strconv.Itoa(min(max(0, percentage), 100)) + "\x07"
+}
+
+// SetIndeterminateProgressBar is a sequence that sets the progress bar to the
+// indeterminate state.
+//
+// OSC 9 ; 4 ; 3 BEL
+//
+// See: https://learn.microsoft.com/en-us/windows/terminal/tutorials/progress-bar-sequences
+const SetIndeterminateProgressBar = "\x1b]9;4;3\x07"
+
+// SetWarningProgressBar is a sequence that sets the progress bar to the
+// "Warning" state.
+//
+// OSC 9 ; 4 ; 4 Percentage BEL
+//
+// See: https://learn.microsoft.com/en-us/windows/terminal/tutorials/progress-bar-sequences
+func SetWarningProgressBar(percentage int) string {
+ return "\x1b]9;4;4;" + strconv.Itoa(min(max(0, percentage), 100)) + "\x07"
+}
diff --git a/vendor/github.com/charmbracelet/x/ansi/reset.go b/vendor/github.com/charmbracelet/x/ansi/reset.go
new file mode 100644
index 0000000000..c1b89ea493
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/ansi/reset.go
@@ -0,0 +1,11 @@
+package ansi
+
+// ResetInitialState (RIS) resets the terminal to its initial state.
+//
+// ESC c
+//
+// See: https://vt100.net/docs/vt510-rm/RIS.html
+const (
+ ResetInitialState = "\x1bc"
+ RIS = ResetInitialState
+)
diff --git a/vendor/github.com/charmbracelet/x/ansi/screen.go b/vendor/github.com/charmbracelet/x/ansi/screen.go
new file mode 100644
index 0000000000..e2027dff93
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/ansi/screen.go
@@ -0,0 +1,410 @@
+package ansi
+
+import (
+ "strconv"
+ "strings"
+)
+
+// EraseDisplay (ED) clears the display or parts of the display. A screen is
+// the shown part of the terminal display excluding the scrollback buffer.
+// Possible values:
+//
+// Default is 0.
+//
+// 0: Clear from cursor to end of screen.
+// 1: Clear from cursor to beginning of the screen.
+// 2: Clear entire screen (and moves cursor to upper left on DOS).
+// 3: Clear entire display which delete all lines saved in the scrollback buffer (xterm).
+//
+// CSI J
+//
+// See: https://vt100.net/docs/vt510-rm/ED.html
+func EraseDisplay(n int) string {
+ var s string
+ if n > 0 {
+ s = strconv.Itoa(n)
+ }
+ return "\x1b[" + s + "J"
+}
+
+// ED is an alias for [EraseDisplay].
+func ED(n int) string {
+ return EraseDisplay(n)
+}
+
+// EraseDisplay constants.
+// These are the possible values for the EraseDisplay function.
+const (
+ EraseScreenBelow = "\x1b[J"
+ EraseScreenAbove = "\x1b[1J"
+ EraseEntireScreen = "\x1b[2J"
+ EraseEntireDisplay = "\x1b[3J"
+)
+
+// EraseLine (EL) clears the current line or parts of the line. Possible values:
+//
+// 0: Clear from cursor to end of line.
+// 1: Clear from cursor to beginning of the line.
+// 2: Clear entire line.
+//
+// The cursor position is not affected.
+//
+// CSI K
+//
+// See: https://vt100.net/docs/vt510-rm/EL.html
+func EraseLine(n int) string {
+ var s string
+ if n > 0 {
+ s = strconv.Itoa(n)
+ }
+ return "\x1b[" + s + "K"
+}
+
+// EL is an alias for [EraseLine].
+func EL(n int) string {
+ return EraseLine(n)
+}
+
+// EraseLine constants.
+// These are the possible values for the EraseLine function.
+const (
+ EraseLineRight = "\x1b[K"
+ EraseLineLeft = "\x1b[1K"
+ EraseEntireLine = "\x1b[2K"
+)
+
+// ScrollUp (SU) scrolls the screen up n lines. New lines are added at the
+// bottom of the screen.
+//
+// CSI Pn S
+//
+// See: https://vt100.net/docs/vt510-rm/SU.html
+func ScrollUp(n int) string {
+ var s string
+ if n > 1 {
+ s = strconv.Itoa(n)
+ }
+ return "\x1b[" + s + "S"
+}
+
+// PanDown is an alias for [ScrollUp].
+func PanDown(n int) string {
+ return ScrollUp(n)
+}
+
+// SU is an alias for [ScrollUp].
+func SU(n int) string {
+ return ScrollUp(n)
+}
+
+// ScrollDown (SD) scrolls the screen down n lines. New lines are added at the
+// top of the screen.
+//
+// CSI Pn T
+//
+// See: https://vt100.net/docs/vt510-rm/SD.html
+func ScrollDown(n int) string {
+ var s string
+ if n > 1 {
+ s = strconv.Itoa(n)
+ }
+ return "\x1b[" + s + "T"
+}
+
+// PanUp is an alias for [ScrollDown].
+func PanUp(n int) string {
+ return ScrollDown(n)
+}
+
+// SD is an alias for [ScrollDown].
+func SD(n int) string {
+ return ScrollDown(n)
+}
+
+// InsertLine (IL) inserts n blank lines at the current cursor position.
+// Existing lines are moved down.
+//
+// CSI Pn L
+//
+// See: https://vt100.net/docs/vt510-rm/IL.html
+func InsertLine(n int) string {
+ var s string
+ if n > 1 {
+ s = strconv.Itoa(n)
+ }
+ return "\x1b[" + s + "L"
+}
+
+// IL is an alias for [InsertLine].
+func IL(n int) string {
+ return InsertLine(n)
+}
+
+// DeleteLine (DL) deletes n lines at the current cursor position. Existing
+// lines are moved up.
+//
+// CSI Pn M
+//
+// See: https://vt100.net/docs/vt510-rm/DL.html
+func DeleteLine(n int) string {
+ var s string
+ if n > 1 {
+ s = strconv.Itoa(n)
+ }
+ return "\x1b[" + s + "M"
+}
+
+// DL is an alias for [DeleteLine].
+func DL(n int) string {
+ return DeleteLine(n)
+}
+
+// SetTopBottomMargins (DECSTBM) sets the top and bottom margins for the scrolling
+// region. The default is the entire screen.
+//
+// Default is 1 and the bottom of the screen.
+//
+// CSI Pt ; Pb r
+//
+// See: https://vt100.net/docs/vt510-rm/DECSTBM.html
+func SetTopBottomMargins(top, bot int) string {
+ var t, b string
+ if top > 0 {
+ t = strconv.Itoa(top)
+ }
+ if bot > 0 {
+ b = strconv.Itoa(bot)
+ }
+ return "\x1b[" + t + ";" + b + "r"
+}
+
+// DECSTBM is an alias for [SetTopBottomMargins].
+func DECSTBM(top, bot int) string {
+ return SetTopBottomMargins(top, bot)
+}
+
+// SetLeftRightMargins (DECSLRM) sets the left and right margins for the scrolling
+// region.
+//
+// Default is 1 and the right of the screen.
+//
+// CSI Pl ; Pr s
+//
+// See: https://vt100.net/docs/vt510-rm/DECSLRM.html
+func SetLeftRightMargins(left, right int) string {
+ var l, r string
+ if left > 0 {
+ l = strconv.Itoa(left)
+ }
+ if right > 0 {
+ r = strconv.Itoa(right)
+ }
+ return "\x1b[" + l + ";" + r + "s"
+}
+
+// DECSLRM is an alias for [SetLeftRightMargins].
+func DECSLRM(left, right int) string {
+ return SetLeftRightMargins(left, right)
+}
+
+// SetScrollingRegion (DECSTBM) sets the top and bottom margins for the scrolling
+// region. The default is the entire screen.
+//
+// CSI ; r
+//
+// See: https://vt100.net/docs/vt510-rm/DECSTBM.html
+//
+// Deprecated: use [SetTopBottomMargins] instead.
+func SetScrollingRegion(t, b int) string {
+ if t < 0 {
+ t = 0
+ }
+ if b < 0 {
+ b = 0
+ }
+ return "\x1b[" + strconv.Itoa(t) + ";" + strconv.Itoa(b) + "r"
+}
+
+// InsertCharacter (ICH) inserts n blank characters at the current cursor
+// position. Existing characters move to the right. Characters moved past the
+// right margin are lost. ICH has no effect outside the scrolling margins.
+//
+// Default is 1.
+//
+// CSI Pn @
+//
+// See: https://vt100.net/docs/vt510-rm/ICH.html
+func InsertCharacter(n int) string {
+ var s string
+ if n > 1 {
+ s = strconv.Itoa(n)
+ }
+ return "\x1b[" + s + "@"
+}
+
+// ICH is an alias for [InsertCharacter].
+func ICH(n int) string {
+ return InsertCharacter(n)
+}
+
+// DeleteCharacter (DCH) deletes n characters at the current cursor position.
+// As the characters are deleted, the remaining characters move to the left and
+// the cursor remains at the same position.
+//
+// Default is 1.
+//
+// CSI Pn P
+//
+// See: https://vt100.net/docs/vt510-rm/DCH.html
+func DeleteCharacter(n int) string {
+ var s string
+ if n > 1 {
+ s = strconv.Itoa(n)
+ }
+ return "\x1b[" + s + "P"
+}
+
+// DCH is an alias for [DeleteCharacter].
+func DCH(n int) string {
+ return DeleteCharacter(n)
+}
+
+// SetTabEvery8Columns (DECST8C) sets the tab stops at every 8 columns.
+//
+// CSI ? 5 W
+//
+// See: https://vt100.net/docs/vt510-rm/DECST8C.html
+const (
+ SetTabEvery8Columns = "\x1b[?5W"
+ DECST8C = SetTabEvery8Columns
+)
+
+// HorizontalTabSet (HTS) sets a horizontal tab stop at the current cursor
+// column.
+//
+// This is equivalent to [HTS].
+//
+// ESC H
+//
+// See: https://vt100.net/docs/vt510-rm/HTS.html
+const HorizontalTabSet = "\x1bH"
+
+// TabClear (TBC) clears tab stops.
+//
+// Default is 0.
+//
+// Possible values:
+// 0: Clear tab stop at the current column. (default)
+// 3: Clear all tab stops.
+//
+// CSI Pn g
+//
+// See: https://vt100.net/docs/vt510-rm/TBC.html
+func TabClear(n int) string {
+ var s string
+ if n > 0 {
+ s = strconv.Itoa(n)
+ }
+ return "\x1b[" + s + "g"
+}
+
+// TBC is an alias for [TabClear].
+func TBC(n int) string {
+ return TabClear(n)
+}
+
+// RequestPresentationStateReport (DECRQPSR) requests the terminal to send a
+// report of the presentation state. This includes the cursor information [DECCIR],
+// and tab stop [DECTABSR] reports.
+//
+// Default is 0.
+//
+// Possible values:
+// 0: Error, request ignored.
+// 1: Cursor information report [DECCIR].
+// 2: Tab stop report [DECTABSR].
+//
+// CSI Ps $ w
+//
+// See: https://vt100.net/docs/vt510-rm/DECRQPSR.html
+func RequestPresentationStateReport(n int) string {
+ var s string
+ if n > 0 {
+ s = strconv.Itoa(n)
+ }
+ return "\x1b[" + s + "$w"
+}
+
+// DECRQPSR is an alias for [RequestPresentationStateReport].
+func DECRQPSR(n int) string {
+ return RequestPresentationStateReport(n)
+}
+
+// TabStopReport (DECTABSR) is the response to a tab stop report request.
+// It reports the tab stops set in the terminal.
+//
+// The response is a list of tab stops separated by a slash (/) character.
+//
+// DCS 2 $ u D ... D ST
+//
+// Where D is a decimal number representing a tab stop.
+//
+// See: https://vt100.net/docs/vt510-rm/DECTABSR.html
+func TabStopReport(stops ...int) string {
+ var s []string //nolint:prealloc
+ for _, v := range stops {
+ s = append(s, strconv.Itoa(v))
+ }
+ return "\x1bP2$u" + strings.Join(s, "/") + "\x1b\\"
+}
+
+// DECTABSR is an alias for [TabStopReport].
+func DECTABSR(stops ...int) string {
+ return TabStopReport(stops...)
+}
+
+// CursorInformationReport (DECCIR) is the response to a cursor information
+// report request. It reports the cursor position, visual attributes, and
+// character protection attributes. It also reports the status of origin mode
+// [DECOM] and the current active character set.
+//
+// The response is a list of values separated by a semicolon (;) character.
+//
+// DCS 1 $ u D ... D ST
+//
+// Where D is a decimal number representing a value.
+//
+// See: https://vt100.net/docs/vt510-rm/DECCIR.html
+func CursorInformationReport(values ...int) string {
+ var s []string //nolint:prealloc
+ for _, v := range values {
+ s = append(s, strconv.Itoa(v))
+ }
+ return "\x1bP1$u" + strings.Join(s, ";") + "\x1b\\"
+}
+
+// DECCIR is an alias for [CursorInformationReport].
+func DECCIR(values ...int) string {
+ return CursorInformationReport(values...)
+}
+
+// RepeatPreviousCharacter (REP) repeats the previous character n times.
+// This is identical to typing the same character n times.
+//
+// Default is 1.
+//
+// CSI Pn b
+//
+// See: ECMA-48 § 8.3.103.
+func RepeatPreviousCharacter(n int) string {
+ var s string
+ if n > 1 {
+ s = strconv.Itoa(n)
+ }
+ return "\x1b[" + s + "b"
+}
+
+// REP is an alias for [RepeatPreviousCharacter].
+func REP(n int) string {
+ return RepeatPreviousCharacter(n)
+}
diff --git a/vendor/github.com/charmbracelet/x/ansi/sgr.go b/vendor/github.com/charmbracelet/x/ansi/sgr.go
new file mode 100644
index 0000000000..b3481a9aaf
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/ansi/sgr.go
@@ -0,0 +1,79 @@
+package ansi
+
+// SelectGraphicRendition (SGR) is a command that sets display attributes.
+//
+// Default is 0.
+//
+// CSI Ps ; Ps ... m
+//
+// See: https://vt100.net/docs/vt510-rm/SGR.html
+func SelectGraphicRendition(ps ...Attr) string {
+ if len(ps) == 0 {
+ return ResetStyle
+ }
+
+ return NewStyle(ps...).String()
+}
+
+// SGR is an alias for [SelectGraphicRendition].
+func SGR(ps ...Attr) string {
+ return SelectGraphicRendition(ps...)
+}
+
+var attrStrings = map[int]string{
+ AttrReset: attrReset,
+ AttrBold: attrBold,
+ AttrFaint: attrFaint,
+ AttrItalic: attrItalic,
+ AttrUnderline: attrUnderline,
+ AttrBlink: attrBlink,
+ AttrRapidBlink: attrRapidBlink,
+ AttrReverse: attrReverse,
+ AttrConceal: attrConceal,
+ AttrStrikethrough: attrStrikethrough,
+ AttrNormalIntensity: attrNormalIntensity,
+ AttrNoItalic: attrNoItalic,
+ AttrNoUnderline: attrNoUnderline,
+ AttrNoBlink: attrNoBlink,
+ AttrNoReverse: attrNoReverse,
+ AttrNoConceal: attrNoConceal,
+ AttrNoStrikethrough: attrNoStrikethrough,
+ AttrBlackForegroundColor: attrBlackForegroundColor,
+ AttrRedForegroundColor: attrRedForegroundColor,
+ AttrGreenForegroundColor: attrGreenForegroundColor,
+ AttrYellowForegroundColor: attrYellowForegroundColor,
+ AttrBlueForegroundColor: attrBlueForegroundColor,
+ AttrMagentaForegroundColor: attrMagentaForegroundColor,
+ AttrCyanForegroundColor: attrCyanForegroundColor,
+ AttrWhiteForegroundColor: attrWhiteForegroundColor,
+ AttrExtendedForegroundColor: attrExtendedForegroundColor,
+ AttrDefaultForegroundColor: attrDefaultForegroundColor,
+ AttrBlackBackgroundColor: attrBlackBackgroundColor,
+ AttrRedBackgroundColor: attrRedBackgroundColor,
+ AttrGreenBackgroundColor: attrGreenBackgroundColor,
+ AttrYellowBackgroundColor: attrYellowBackgroundColor,
+ AttrBlueBackgroundColor: attrBlueBackgroundColor,
+ AttrMagentaBackgroundColor: attrMagentaBackgroundColor,
+ AttrCyanBackgroundColor: attrCyanBackgroundColor,
+ AttrWhiteBackgroundColor: attrWhiteBackgroundColor,
+ AttrExtendedBackgroundColor: attrExtendedBackgroundColor,
+ AttrDefaultBackgroundColor: attrDefaultBackgroundColor,
+ AttrExtendedUnderlineColor: attrExtendedUnderlineColor,
+ AttrDefaultUnderlineColor: attrDefaultUnderlineColor,
+ AttrBrightBlackForegroundColor: attrBrightBlackForegroundColor,
+ AttrBrightRedForegroundColor: attrBrightRedForegroundColor,
+ AttrBrightGreenForegroundColor: attrBrightGreenForegroundColor,
+ AttrBrightYellowForegroundColor: attrBrightYellowForegroundColor,
+ AttrBrightBlueForegroundColor: attrBrightBlueForegroundColor,
+ AttrBrightMagentaForegroundColor: attrBrightMagentaForegroundColor,
+ AttrBrightCyanForegroundColor: attrBrightCyanForegroundColor,
+ AttrBrightWhiteForegroundColor: attrBrightWhiteForegroundColor,
+ AttrBrightBlackBackgroundColor: attrBrightBlackBackgroundColor,
+ AttrBrightRedBackgroundColor: attrBrightRedBackgroundColor,
+ AttrBrightGreenBackgroundColor: attrBrightGreenBackgroundColor,
+ AttrBrightYellowBackgroundColor: attrBrightYellowBackgroundColor,
+ AttrBrightBlueBackgroundColor: attrBrightBlueBackgroundColor,
+ AttrBrightMagentaBackgroundColor: attrBrightMagentaBackgroundColor,
+ AttrBrightCyanBackgroundColor: attrBrightCyanBackgroundColor,
+ AttrBrightWhiteBackgroundColor: attrBrightWhiteBackgroundColor,
+}
diff --git a/vendor/github.com/charmbracelet/x/ansi/status.go b/vendor/github.com/charmbracelet/x/ansi/status.go
new file mode 100644
index 0000000000..3adfb028ec
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/ansi/status.go
@@ -0,0 +1,168 @@
+package ansi
+
+import (
+ "strconv"
+ "strings"
+)
+
+// StatusReport represents a terminal status report.
+type StatusReport interface {
+ // StatusReport returns the status report identifier.
+ StatusReport() int
+}
+
+// ANSIStatusReport represents an ANSI terminal status report.
+type ANSIStatusReport int //nolint:revive
+
+// StatusReport returns the status report identifier.
+func (s ANSIStatusReport) StatusReport() int {
+ return int(s)
+}
+
+// DECStatusReport represents a DEC terminal status report.
+type DECStatusReport int
+
+// StatusReport returns the status report identifier.
+func (s DECStatusReport) StatusReport() int {
+ return int(s)
+}
+
+// DeviceStatusReport (DSR) is a control sequence that reports the terminal's
+// status.
+// The terminal responds with a DSR sequence.
+//
+// CSI Ps n
+// CSI ? Ps n
+//
+// If one of the statuses is a [DECStatus], the sequence will use the DEC
+// format.
+//
+// See also https://vt100.net/docs/vt510-rm/DSR.html
+func DeviceStatusReport(statues ...StatusReport) string {
+ var dec bool
+ list := make([]string, len(statues))
+ seq := "\x1b["
+ for i, status := range statues {
+ list[i] = strconv.Itoa(status.StatusReport())
+ switch status.(type) {
+ case DECStatusReport:
+ dec = true
+ }
+ }
+ if dec {
+ seq += "?"
+ }
+ return seq + strings.Join(list, ";") + "n"
+}
+
+// DSR is an alias for [DeviceStatusReport].
+func DSR(status StatusReport) string {
+ return DeviceStatusReport(status)
+}
+
+// RequestCursorPositionReport is an escape sequence that requests the current
+// cursor position.
+//
+// CSI 6 n
+//
+// The terminal will report the cursor position as a CSI sequence in the
+// following format:
+//
+// CSI Pl ; Pc R
+//
+// Where Pl is the line number and Pc is the column number.
+// See: https://vt100.net/docs/vt510-rm/CPR.html
+const RequestCursorPositionReport = "\x1b[6n"
+
+// RequestExtendedCursorPositionReport (DECXCPR) is a sequence for requesting
+// the cursor position report including the current page number.
+//
+// CSI ? 6 n
+//
+// The terminal will report the cursor position as a CSI sequence in the
+// following format:
+//
+// CSI ? Pl ; Pc ; Pp R
+//
+// Where Pl is the line number, Pc is the column number, and Pp is the page
+// number.
+// See: https://vt100.net/docs/vt510-rm/DECXCPR.html
+const RequestExtendedCursorPositionReport = "\x1b[?6n"
+
+// RequestLightDarkReport is a control sequence that requests the terminal to
+// report its operating system light/dark color preference. Supported terminals
+// should respond with a [LightDarkReport] sequence as follows:
+//
+// CSI ? 997 ; 1 n for dark mode
+// CSI ? 997 ; 2 n for light mode
+//
+// See: https://contour-terminal.org/vt-extensions/color-palette-update-notifications/
+const RequestLightDarkReport = "\x1b[?996n"
+
+// CursorPositionReport (CPR) is a control sequence that reports the cursor's
+// position.
+//
+// CSI Pl ; Pc R
+//
+// Where Pl is the line number and Pc is the column number.
+//
+// See also https://vt100.net/docs/vt510-rm/CPR.html
+func CursorPositionReport(line, column int) string {
+ if line < 1 {
+ line = 1
+ }
+ if column < 1 {
+ column = 1
+ }
+ return "\x1b[" + strconv.Itoa(line) + ";" + strconv.Itoa(column) + "R"
+}
+
+// CPR is an alias for [CursorPositionReport].
+func CPR(line, column int) string {
+ return CursorPositionReport(line, column)
+}
+
+// ExtendedCursorPositionReport (DECXCPR) is a control sequence that reports the
+// cursor's position along with the page number (optional).
+//
+// CSI ? Pl ; Pc R
+// CSI ? Pl ; Pc ; Pv R
+//
+// Where Pl is the line number, Pc is the column number, and Pv is the page
+// number.
+//
+// If the page number is zero or negative, the returned sequence won't include
+// the page number.
+//
+// See also https://vt100.net/docs/vt510-rm/DECXCPR.html
+func ExtendedCursorPositionReport(line, column, page int) string {
+ if line < 1 {
+ line = 1
+ }
+ if column < 1 {
+ column = 1
+ }
+ if page < 1 {
+ return "\x1b[?" + strconv.Itoa(line) + ";" + strconv.Itoa(column) + "R"
+ }
+ return "\x1b[?" + strconv.Itoa(line) + ";" + strconv.Itoa(column) + ";" + strconv.Itoa(page) + "R"
+}
+
+// DECXCPR is an alias for [ExtendedCursorPositionReport].
+func DECXCPR(line, column, page int) string {
+ return ExtendedCursorPositionReport(line, column, page)
+}
+
+// LightDarkReport is a control sequence that reports the terminal's operating
+// system light/dark color preference.
+//
+// CSI ? 997 ; 1 n for dark mode
+// CSI ? 997 ; 2 n for light mode
+//
+// See: https://contour-terminal.org/vt-extensions/color-palette-update-notifications/
+func LightDarkReport(dark bool) string {
+ if dark {
+ return "\x1b[?997;1n"
+ }
+ return "\x1b[?997;2n"
+}
diff --git a/vendor/github.com/charmbracelet/x/ansi/style.go b/vendor/github.com/charmbracelet/x/ansi/style.go
new file mode 100644
index 0000000000..44649b42ae
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/ansi/style.go
@@ -0,0 +1,819 @@
+package ansi
+
+import (
+ "image/color"
+ "strconv"
+ "strings"
+)
+
+// ResetStyle is a SGR (Select Graphic Rendition) style sequence that resets
+// all attributes.
+// See: https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_(Select_Graphic_Rendition)_parameters
+const ResetStyle = "\x1b[m"
+
+// Attr is a SGR (Select Graphic Rendition) style attribute.
+type Attr = int
+
+// Style represents an ANSI SGR (Select Graphic Rendition) style.
+type Style []string
+
+// NewStyle returns a new style with the given attributes. Attributes are SGR
+// (Select Graphic Rendition) codes that control text formatting like bold,
+// italic, colors, etc.
+func NewStyle(attrs ...Attr) Style {
+ if len(attrs) == 0 {
+ return Style{}
+ }
+ s := make(Style, 0, len(attrs))
+ for _, a := range attrs {
+ attr, ok := attrStrings[a]
+ if ok {
+ s = append(s, attr)
+ } else {
+ if a < 0 {
+ a = 0
+ }
+ s = append(s, strconv.Itoa(a))
+ }
+ }
+ return s
+}
+
+// String returns the ANSI SGR (Select Graphic Rendition) style sequence for
+// the given style.
+func (s Style) String() string {
+ if len(s) == 0 {
+ return ResetStyle
+ }
+ return "\x1b[" + strings.Join(s, ";") + "m"
+}
+
+// Styled returns a styled string with the given style applied. The style is
+// applied at the beginning and reset at the end of the string.
+func (s Style) Styled(str string) string {
+ if len(s) == 0 {
+ return str
+ }
+ return s.String() + str + ResetStyle
+}
+
+// Reset appends the reset style attribute to the style. This resets all
+// formatting attributes to their defaults.
+func (s Style) Reset() Style {
+ return append(s, attrReset)
+}
+
+// Bold appends the bold or normal intensity style attribute to the style.
+// You can use [Style.Normal] to reset to normal intensity.
+func (s Style) Bold() Style {
+ return append(s, attrBold)
+}
+
+// Faint appends the faint or normal intensity style attribute to the style.
+// You can use [Style.Normal] to reset to normal intensity.
+func (s Style) Faint() Style {
+ return append(s, attrFaint)
+}
+
+// Italic appends the italic or no italic style attribute to the style.
+// When v is true, text is rendered in italic. When false, italic is disabled.
+func (s Style) Italic(v bool) Style {
+ if v {
+ return append(s, attrItalic)
+ }
+ return append(s, attrNoItalic)
+}
+
+// Underline appends the underline or no underline style attribute to the style.
+// When v is true, text is underlined. When false, underline is disabled.
+func (s Style) Underline(v bool) Style {
+ if v {
+ return append(s, attrUnderline)
+ }
+ return append(s, attrNoUnderline)
+}
+
+// UnderlineStyle appends the underline style attribute to the style.
+// Supports various underline styles including single, double, curly, dotted,
+// and dashed.
+func (s Style) UnderlineStyle(u Underline) Style {
+ switch u {
+ case UnderlineNone:
+ return s.Underline(false)
+ case UnderlineSingle:
+ return s.Underline(true)
+ case UnderlineDouble:
+ return append(s, underlineDouble)
+ case UnderlineCurly:
+ return append(s, underlineCurly)
+ case UnderlineDotted:
+ return append(s, underlineDotted)
+ case UnderlineDashed:
+ return append(s, underlineDashed)
+ }
+ return s
+}
+
+// Blink appends the slow blink or no blink style attribute to the style.
+// When v is true, text blinks slowly (less than 150 per minute). When false,
+// blinking is disabled.
+func (s Style) Blink(v bool) Style {
+ if v {
+ return append(s, attrBlink)
+ }
+ return append(s, attrNoBlink)
+}
+
+// RapidBlink appends the rapid blink or no blink style attribute to the style.
+// When v is true, text blinks rapidly (150+ per minute). When false, blinking
+// is disabled.
+//
+// Note that this is not widely supported in terminal emulators.
+func (s Style) RapidBlink(v bool) Style {
+ if v {
+ return append(s, attrRapidBlink)
+ }
+ return append(s, attrNoBlink)
+}
+
+// Reverse appends the reverse or no reverse style attribute to the style.
+// When v is true, foreground and background colors are swapped. When false,
+// reverse video is disabled.
+func (s Style) Reverse(v bool) Style {
+ if v {
+ return append(s, attrReverse)
+ }
+ return append(s, attrNoReverse)
+}
+
+// Conceal appends the conceal or no conceal style attribute to the style.
+// When v is true, text is hidden/concealed. When false, concealment is
+// disabled.
+func (s Style) Conceal(v bool) Style {
+ if v {
+ return append(s, attrConceal)
+ }
+ return append(s, attrNoConceal)
+}
+
+// Strikethrough appends the strikethrough or no strikethrough style attribute
+// to the style. When v is true, text is rendered with a horizontal line through
+// it. When false, strikethrough is disabled.
+func (s Style) Strikethrough(v bool) Style {
+ if v {
+ return append(s, attrStrikethrough)
+ }
+ return append(s, attrNoStrikethrough)
+}
+
+// Normal appends the normal intensity style attribute to the style. This
+// resets [Style.Bold] and [Style.Faint] attributes.
+func (s Style) Normal() Style {
+ return append(s, attrNormalIntensity)
+}
+
+// NoItalic appends the no italic style attribute to the style.
+//
+// Deprecated: use [Style.Italic](false) instead.
+func (s Style) NoItalic() Style {
+ return append(s, attrNoItalic)
+}
+
+// NoUnderline appends the no underline style attribute to the style.
+//
+// Deprecated: use [Style.Underline](false) instead.
+func (s Style) NoUnderline() Style {
+ return append(s, attrNoUnderline)
+}
+
+// NoBlink appends the no blink style attribute to the style.
+//
+// Deprecated: use [Style.Blink](false) or [Style.RapidBlink](false) instead.
+func (s Style) NoBlink() Style {
+ return append(s, attrNoBlink)
+}
+
+// NoReverse appends the no reverse style attribute to the style.
+//
+// Deprecated: use [Style.Reverse](false) instead.
+func (s Style) NoReverse() Style {
+ return append(s, attrNoReverse)
+}
+
+// NoConceal appends the no conceal style attribute to the style.
+//
+// Deprecated: use [Style.Conceal](false) instead.
+func (s Style) NoConceal() Style {
+ return append(s, attrNoConceal)
+}
+
+// NoStrikethrough appends the no strikethrough style attribute to the style.
+//
+// Deprecated: use [Style.Strikethrough](false) instead.
+func (s Style) NoStrikethrough() Style {
+ return append(s, attrNoStrikethrough)
+}
+
+// DefaultForegroundColor appends the default foreground color style attribute to the style.
+//
+// Deprecated: use [Style.ForegroundColor](nil) instead.
+func (s Style) DefaultForegroundColor() Style {
+ return append(s, attrDefaultForegroundColor)
+}
+
+// DefaultBackgroundColor appends the default background color style attribute to the style.
+//
+// Deprecated: use [Style.BackgroundColor](nil) instead.
+func (s Style) DefaultBackgroundColor() Style {
+ return append(s, attrDefaultBackgroundColor)
+}
+
+// DefaultUnderlineColor appends the default underline color style attribute to the style.
+//
+// Deprecated: use [Style.UnderlineColor](nil) instead.
+func (s Style) DefaultUnderlineColor() Style {
+ return append(s, attrDefaultUnderlineColor)
+}
+
+// ForegroundColor appends the foreground color style attribute to the style.
+// If c is nil, the default foreground color is used. Supports [BasicColor],
+// [IndexedColor] (256-color), and [color.Color] (24-bit RGB).
+func (s Style) ForegroundColor(c Color) Style {
+ if c == nil {
+ return append(s, attrDefaultForegroundColor)
+ }
+ return append(s, foregroundColorString(c))
+}
+
+// BackgroundColor appends the background color style attribute to the style.
+// If c is nil, the default background color is used. Supports [BasicColor],
+// [IndexedColor] (256-color), and [color.Color] (24-bit RGB).
+func (s Style) BackgroundColor(c Color) Style {
+ if c == nil {
+ return append(s, attrDefaultBackgroundColor)
+ }
+ return append(s, backgroundColorString(c))
+}
+
+// UnderlineColor appends the underline color style attribute to the style.
+// If c is nil, the default underline color is used. Supports [BasicColor],
+// [IndexedColor] (256-color), and [color.Color] (24-bit RGB).
+func (s Style) UnderlineColor(c Color) Style {
+ if c == nil {
+ return append(s, attrDefaultUnderlineColor)
+ }
+ return append(s, underlineColorString(c))
+}
+
+// Underline represents an ANSI SGR (Select Graphic Rendition) underline style.
+type Underline = byte
+
+// UnderlineStyle represents an ANSI SGR (Select Graphic Rendition) underline
+// style.
+//
+// Deprecated: use [Underline] instead.
+type UnderlineStyle = byte
+
+const (
+ underlineDouble = "4:2"
+ underlineCurly = "4:3"
+ underlineDotted = "4:4"
+ underlineDashed = "4:5"
+)
+
+// Underline styles constants.
+const (
+ UnderlineNone Underline = iota
+ UnderlineSingle
+ UnderlineDouble
+ UnderlineCurly
+ UnderlineDotted
+ UnderlineDashed
+)
+
+// Underline styles constants.
+//
+// Deprecated: use [UnderlineNone], [UnderlineSingle], etc. instead.
+const (
+ NoUnderlineStyle Underline = iota
+ SingleUnderlineStyle
+ DoubleUnderlineStyle
+ CurlyUnderlineStyle
+ DottedUnderlineStyle
+ DashedUnderlineStyle
+)
+
+// Underline styles constants.
+//
+// Deprecated: use [UnderlineNone], [UnderlineSingle], etc. instead.
+const (
+ UnderlineStyleNone Underline = iota
+ UnderlineStyleSingle
+ UnderlineStyleDouble
+ UnderlineStyleCurly
+ UnderlineStyleDotted
+ UnderlineStyleDashed
+)
+
+// SGR (Select Graphic Rendition) style attributes.
+// See: https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_(Select_Graphic_Rendition)_parameters
+const (
+ AttrReset Attr = 0
+ AttrBold Attr = 1
+ AttrFaint Attr = 2
+ AttrItalic Attr = 3
+ AttrUnderline Attr = 4
+ AttrBlink Attr = 5
+ AttrRapidBlink Attr = 6
+ AttrReverse Attr = 7
+ AttrConceal Attr = 8
+ AttrStrikethrough Attr = 9
+ AttrNormalIntensity Attr = 22
+ AttrNoItalic Attr = 23
+ AttrNoUnderline Attr = 24
+ AttrNoBlink Attr = 25
+ AttrNoReverse Attr = 27
+ AttrNoConceal Attr = 28
+ AttrNoStrikethrough Attr = 29
+ AttrBlackForegroundColor Attr = 30
+ AttrRedForegroundColor Attr = 31
+ AttrGreenForegroundColor Attr = 32
+ AttrYellowForegroundColor Attr = 33
+ AttrBlueForegroundColor Attr = 34
+ AttrMagentaForegroundColor Attr = 35
+ AttrCyanForegroundColor Attr = 36
+ AttrWhiteForegroundColor Attr = 37
+ AttrExtendedForegroundColor Attr = 38
+ AttrDefaultForegroundColor Attr = 39
+ AttrBlackBackgroundColor Attr = 40
+ AttrRedBackgroundColor Attr = 41
+ AttrGreenBackgroundColor Attr = 42
+ AttrYellowBackgroundColor Attr = 43
+ AttrBlueBackgroundColor Attr = 44
+ AttrMagentaBackgroundColor Attr = 45
+ AttrCyanBackgroundColor Attr = 46
+ AttrWhiteBackgroundColor Attr = 47
+ AttrExtendedBackgroundColor Attr = 48
+ AttrDefaultBackgroundColor Attr = 49
+ AttrExtendedUnderlineColor Attr = 58
+ AttrDefaultUnderlineColor Attr = 59
+ AttrBrightBlackForegroundColor Attr = 90
+ AttrBrightRedForegroundColor Attr = 91
+ AttrBrightGreenForegroundColor Attr = 92
+ AttrBrightYellowForegroundColor Attr = 93
+ AttrBrightBlueForegroundColor Attr = 94
+ AttrBrightMagentaForegroundColor Attr = 95
+ AttrBrightCyanForegroundColor Attr = 96
+ AttrBrightWhiteForegroundColor Attr = 97
+ AttrBrightBlackBackgroundColor Attr = 100
+ AttrBrightRedBackgroundColor Attr = 101
+ AttrBrightGreenBackgroundColor Attr = 102
+ AttrBrightYellowBackgroundColor Attr = 103
+ AttrBrightBlueBackgroundColor Attr = 104
+ AttrBrightMagentaBackgroundColor Attr = 105
+ AttrBrightCyanBackgroundColor Attr = 106
+ AttrBrightWhiteBackgroundColor Attr = 107
+
+ AttrRGBColorIntroducer Attr = 2
+ AttrExtendedColorIntroducer Attr = 5
+)
+
+// SGR (Select Graphic Rendition) style attributes.
+//
+// Deprecated: use Attr* constants instead.
+const (
+ ResetAttr = AttrReset
+ BoldAttr = AttrBold
+ FaintAttr = AttrFaint
+ ItalicAttr = AttrItalic
+ UnderlineAttr = AttrUnderline
+ SlowBlinkAttr = AttrBlink
+ RapidBlinkAttr = AttrRapidBlink
+ ReverseAttr = AttrReverse
+ ConcealAttr = AttrConceal
+ StrikethroughAttr = AttrStrikethrough
+ NormalIntensityAttr = AttrNormalIntensity
+ NoItalicAttr = AttrNoItalic
+ NoUnderlineAttr = AttrNoUnderline
+ NoBlinkAttr = AttrNoBlink
+ NoReverseAttr = AttrNoReverse
+ NoConcealAttr = AttrNoConceal
+ NoStrikethroughAttr = AttrNoStrikethrough
+ BlackForegroundColorAttr = AttrBlackForegroundColor
+ RedForegroundColorAttr = AttrRedForegroundColor
+ GreenForegroundColorAttr = AttrGreenForegroundColor
+ YellowForegroundColorAttr = AttrYellowForegroundColor
+ BlueForegroundColorAttr = AttrBlueForegroundColor
+ MagentaForegroundColorAttr = AttrMagentaForegroundColor
+ CyanForegroundColorAttr = AttrCyanForegroundColor
+ WhiteForegroundColorAttr = AttrWhiteForegroundColor
+ ExtendedForegroundColorAttr = AttrExtendedForegroundColor
+ DefaultForegroundColorAttr = AttrDefaultForegroundColor
+ BlackBackgroundColorAttr = AttrBlackBackgroundColor
+ RedBackgroundColorAttr = AttrRedBackgroundColor
+ GreenBackgroundColorAttr = AttrGreenBackgroundColor
+ YellowBackgroundColorAttr = AttrYellowBackgroundColor
+ BlueBackgroundColorAttr = AttrBlueBackgroundColor
+ MagentaBackgroundColorAttr = AttrMagentaBackgroundColor
+ CyanBackgroundColorAttr = AttrCyanBackgroundColor
+ WhiteBackgroundColorAttr = AttrWhiteBackgroundColor
+ ExtendedBackgroundColorAttr = AttrExtendedBackgroundColor
+ DefaultBackgroundColorAttr = AttrDefaultBackgroundColor
+ ExtendedUnderlineColorAttr = AttrExtendedUnderlineColor
+ DefaultUnderlineColorAttr = AttrDefaultUnderlineColor
+ BrightBlackForegroundColorAttr = AttrBrightBlackForegroundColor
+ BrightRedForegroundColorAttr = AttrBrightRedForegroundColor
+ BrightGreenForegroundColorAttr = AttrBrightGreenForegroundColor
+ BrightYellowForegroundColorAttr = AttrBrightYellowForegroundColor
+ BrightBlueForegroundColorAttr = AttrBrightBlueForegroundColor
+ BrightMagentaForegroundColorAttr = AttrBrightMagentaForegroundColor
+ BrightCyanForegroundColorAttr = AttrBrightCyanForegroundColor
+ BrightWhiteForegroundColorAttr = AttrBrightWhiteForegroundColor
+ BrightBlackBackgroundColorAttr = AttrBrightBlackBackgroundColor
+ BrightRedBackgroundColorAttr = AttrBrightRedBackgroundColor
+ BrightGreenBackgroundColorAttr = AttrBrightGreenBackgroundColor
+ BrightYellowBackgroundColorAttr = AttrBrightYellowBackgroundColor
+ BrightBlueBackgroundColorAttr = AttrBrightBlueBackgroundColor
+ BrightMagentaBackgroundColorAttr = AttrBrightMagentaBackgroundColor
+ BrightCyanBackgroundColorAttr = AttrBrightCyanBackgroundColor
+ BrightWhiteBackgroundColorAttr = AttrBrightWhiteBackgroundColor
+ RGBColorIntroducerAttr = AttrRGBColorIntroducer
+ ExtendedColorIntroducerAttr = AttrExtendedColorIntroducer
+)
+
+const (
+ attrReset = "0"
+ attrBold = "1"
+ attrFaint = "2"
+ attrItalic = "3"
+ attrUnderline = "4"
+ attrBlink = "5"
+ attrRapidBlink = "6"
+ attrReverse = "7"
+ attrConceal = "8"
+ attrStrikethrough = "9"
+ attrNormalIntensity = "22"
+ attrNoItalic = "23"
+ attrNoUnderline = "24"
+ attrNoBlink = "25"
+ attrNoReverse = "27"
+ attrNoConceal = "28"
+ attrNoStrikethrough = "29"
+ attrBlackForegroundColor = "30"
+ attrRedForegroundColor = "31"
+ attrGreenForegroundColor = "32"
+ attrYellowForegroundColor = "33"
+ attrBlueForegroundColor = "34"
+ attrMagentaForegroundColor = "35"
+ attrCyanForegroundColor = "36"
+ attrWhiteForegroundColor = "37"
+ attrExtendedForegroundColor = "38"
+ attrDefaultForegroundColor = "39"
+ attrBlackBackgroundColor = "40"
+ attrRedBackgroundColor = "41"
+ attrGreenBackgroundColor = "42"
+ attrYellowBackgroundColor = "43"
+ attrBlueBackgroundColor = "44"
+ attrMagentaBackgroundColor = "45"
+ attrCyanBackgroundColor = "46"
+ attrWhiteBackgroundColor = "47"
+ attrExtendedBackgroundColor = "48"
+ attrDefaultBackgroundColor = "49"
+ attrExtendedUnderlineColor = "58"
+ attrDefaultUnderlineColor = "59"
+ attrBrightBlackForegroundColor = "90"
+ attrBrightRedForegroundColor = "91"
+ attrBrightGreenForegroundColor = "92"
+ attrBrightYellowForegroundColor = "93"
+ attrBrightBlueForegroundColor = "94"
+ attrBrightMagentaForegroundColor = "95"
+ attrBrightCyanForegroundColor = "96"
+ attrBrightWhiteForegroundColor = "97"
+ attrBrightBlackBackgroundColor = "100"
+ attrBrightRedBackgroundColor = "101"
+ attrBrightGreenBackgroundColor = "102"
+ attrBrightYellowBackgroundColor = "103"
+ attrBrightBlueBackgroundColor = "104"
+ attrBrightMagentaBackgroundColor = "105"
+ attrBrightCyanBackgroundColor = "106"
+ attrBrightWhiteBackgroundColor = "107"
+)
+
+// foregroundColorString returns the style SGR attribute for the given
+// foreground color.
+// See: https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_(Select_Graphic_Rendition)_parameters
+func foregroundColorString(c Color) string {
+ switch c := c.(type) {
+ case nil:
+ return attrDefaultForegroundColor
+ case BasicColor:
+ // 3-bit or 4-bit ANSI foreground
+ // "3" or "9" where n is the color number from 0 to 7
+ switch c {
+ case Black:
+ return attrBlackForegroundColor
+ case Red:
+ return attrRedForegroundColor
+ case Green:
+ return attrGreenForegroundColor
+ case Yellow:
+ return attrYellowForegroundColor
+ case Blue:
+ return attrBlueForegroundColor
+ case Magenta:
+ return attrMagentaForegroundColor
+ case Cyan:
+ return attrCyanForegroundColor
+ case White:
+ return attrWhiteForegroundColor
+ case BrightBlack:
+ return attrBrightBlackForegroundColor
+ case BrightRed:
+ return attrBrightRedForegroundColor
+ case BrightGreen:
+ return attrBrightGreenForegroundColor
+ case BrightYellow:
+ return attrBrightYellowForegroundColor
+ case BrightBlue:
+ return attrBrightBlueForegroundColor
+ case BrightMagenta:
+ return attrBrightMagentaForegroundColor
+ case BrightCyan:
+ return attrBrightCyanForegroundColor
+ case BrightWhite:
+ return attrBrightWhiteForegroundColor
+ }
+ case ExtendedColor:
+ // 256-color ANSI foreground
+ // "38;5;"
+ return "38;5;" + strconv.FormatUint(uint64(c), 10)
+ case TrueColor, color.Color:
+ // 24-bit "true color" foreground
+ // "38;2;;;"
+ r, g, b, _ := c.RGBA()
+ return "38;2;" +
+ strconv.FormatUint(uint64(shift(r)), 10) + ";" +
+ strconv.FormatUint(uint64(shift(g)), 10) + ";" +
+ strconv.FormatUint(uint64(shift(b)), 10)
+ }
+ return attrDefaultForegroundColor
+}
+
+// backgroundColorString returns the style SGR attribute for the given
+// background color.
+// See: https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_(Select_Graphic_Rendition)_parameters
+func backgroundColorString(c Color) string {
+ switch c := c.(type) {
+ case nil:
+ return attrDefaultBackgroundColor
+ case BasicColor:
+ // 3-bit or 4-bit ANSI foreground
+ // "4" or "10" where n is the color number from 0 to 7
+ switch c {
+ case Black:
+ return attrBlackBackgroundColor
+ case Red:
+ return attrRedBackgroundColor
+ case Green:
+ return attrGreenBackgroundColor
+ case Yellow:
+ return attrYellowBackgroundColor
+ case Blue:
+ return attrBlueBackgroundColor
+ case Magenta:
+ return attrMagentaBackgroundColor
+ case Cyan:
+ return attrCyanBackgroundColor
+ case White:
+ return attrWhiteBackgroundColor
+ case BrightBlack:
+ return attrBrightBlackBackgroundColor
+ case BrightRed:
+ return attrBrightRedBackgroundColor
+ case BrightGreen:
+ return attrBrightGreenBackgroundColor
+ case BrightYellow:
+ return attrBrightYellowBackgroundColor
+ case BrightBlue:
+ return attrBrightBlueBackgroundColor
+ case BrightMagenta:
+ return attrBrightMagentaBackgroundColor
+ case BrightCyan:
+ return attrBrightCyanBackgroundColor
+ case BrightWhite:
+ return attrBrightWhiteBackgroundColor
+ }
+ case ExtendedColor:
+ // 256-color ANSI foreground
+ // "48;5;"
+ return "48;5;" + strconv.FormatUint(uint64(c), 10)
+ case TrueColor, color.Color:
+ // 24-bit "true color" foreground
+ // "38;2;;;"
+ r, g, b, _ := c.RGBA()
+ return "48;2;" +
+ strconv.FormatUint(uint64(shift(r)), 10) + ";" +
+ strconv.FormatUint(uint64(shift(g)), 10) + ";" +
+ strconv.FormatUint(uint64(shift(b)), 10)
+ }
+ return attrDefaultBackgroundColor
+}
+
+// underlineColorString returns the style SGR attribute for the given underline
+// color.
+// See: https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_(Select_Graphic_Rendition)_parameters
+func underlineColorString(c Color) string {
+ switch c := c.(type) {
+ case nil:
+ return attrDefaultUnderlineColor
+ // NOTE: we can't use 3-bit and 4-bit ANSI color codes with underline
+ // color, use 256-color instead.
+ //
+ // 256-color ANSI underline color
+ // "58;5;"
+ case BasicColor:
+ return "58;5;" + strconv.FormatUint(uint64(c), 10)
+ case ExtendedColor:
+ return "58;5;" + strconv.FormatUint(uint64(c), 10)
+ case TrueColor, color.Color:
+ // 24-bit "true color" foreground
+ // "38;2;;;"
+ r, g, b, _ := c.RGBA()
+ return "58;2;" +
+ strconv.FormatUint(uint64(shift(r)), 10) + ";" +
+ strconv.FormatUint(uint64(shift(g)), 10) + ";" +
+ strconv.FormatUint(uint64(shift(b)), 10)
+ }
+ return attrDefaultUnderlineColor
+}
+
+// ReadStyleColor decodes a color from a slice of parameters. It returns the
+// number of parameters read and the color. This function is used to read SGR
+// color parameters following the ITU T.416 standard.
+//
+// It supports reading the following color types:
+// - 0: implementation defined
+// - 1: transparent
+// - 2: RGB direct color
+// - 3: CMY direct color
+// - 4: CMYK direct color
+// - 5: indexed color
+// - 6: RGBA direct color (WezTerm extension)
+//
+// The parameters can be separated by semicolons (;) or colons (:). Mixing
+// separators is not allowed.
+//
+// The specs supports defining a color space id, a color tolerance value, and a
+// tolerance color space id. However, these values have no effect on the
+// returned color and will be ignored.
+//
+// This implementation includes a few modifications to the specs:
+// 1. Support for legacy color values separated by semicolons (;) with respect to RGB, and indexed colors
+// 2. Support ignoring and omitting the color space id (second parameter) with respect to RGB colors
+// 3. Support ignoring and omitting the 6th parameter with respect to RGB and CMY colors
+// 4. Support reading RGBA colors
+func ReadStyleColor(params Params, co *color.Color) int {
+ if len(params) < 2 { // Need at least SGR type and color type
+ return 0
+ }
+
+ // First parameter indicates one of 38, 48, or 58 (foreground, background, or underline)
+ s := params[0]
+ p := params[1]
+ colorType := p.Param(0)
+ n := 2
+
+ paramsfn := func() (p1, p2, p3, p4 int) {
+ // Where should we start reading the color?
+ switch {
+ case s.HasMore() && p.HasMore() && len(params) > 8 && params[2].HasMore() && params[3].HasMore() && params[4].HasMore() && params[5].HasMore() && params[6].HasMore() && params[7].HasMore():
+ // We have color space id, a 6th parameter, a tolerance value, and a tolerance color space
+ n += 7
+ return params[3].Param(0), params[4].Param(0), params[5].Param(0), params[6].Param(0)
+ case s.HasMore() && p.HasMore() && len(params) > 7 && params[2].HasMore() && params[3].HasMore() && params[4].HasMore() && params[5].HasMore() && params[6].HasMore():
+ // We have color space id, a 6th parameter, and a tolerance value
+ n += 6
+ return params[3].Param(0), params[4].Param(0), params[5].Param(0), params[6].Param(0)
+ case s.HasMore() && p.HasMore() && len(params) > 6 && params[2].HasMore() && params[3].HasMore() && params[4].HasMore() && params[5].HasMore():
+ // We have color space id and a 6th parameter
+ // 48 : 4 : : 1 : 2 : 3 :4
+ n += 5
+ return params[3].Param(0), params[4].Param(0), params[5].Param(0), params[6].Param(0)
+ case s.HasMore() && p.HasMore() && len(params) > 5 && params[2].HasMore() && params[3].HasMore() && params[4].HasMore() && !params[5].HasMore():
+ // We have color space
+ // 48 : 3 : : 1 : 2 : 3
+ n += 4
+ return params[3].Param(0), params[4].Param(0), params[5].Param(0), -1
+ case s.HasMore() && p.HasMore() && p.Param(0) == 2 && params[2].HasMore() && params[3].HasMore() && !params[4].HasMore():
+ // We have color values separated by colons (:)
+ // 48 : 2 : 1 : 2 : 3
+ fallthrough
+ case !s.HasMore() && !p.HasMore() && p.Param(0) == 2 && !params[2].HasMore() && !params[3].HasMore() && !params[4].HasMore():
+ // Support legacy color values separated by semicolons (;)
+ // 48 ; 2 ; 1 ; 2 ; 3
+ n += 3
+ return params[2].Param(0), params[3].Param(0), params[4].Param(0), -1
+ }
+ // Ambiguous SGR color
+ return -1, -1, -1, -1
+ }
+
+ switch colorType {
+ case 0: // implementation defined
+ return 2
+ case 1: // transparent
+ *co = color.Transparent
+ return 2
+ case 2: // RGB direct color
+ if len(params) < 5 {
+ return 0
+ }
+
+ r, g, b, _ := paramsfn()
+ if r == -1 || g == -1 || b == -1 {
+ return 0
+ }
+
+ *co = color.RGBA{
+ R: uint8(r), //nolint:gosec
+ G: uint8(g), //nolint:gosec
+ B: uint8(b), //nolint:gosec
+ A: 0xff,
+ }
+ return n
+
+ case 3: // CMY direct color
+ if len(params) < 5 {
+ return 0
+ }
+
+ c, m, y, _ := paramsfn()
+ if c == -1 || m == -1 || y == -1 {
+ return 0
+ }
+
+ *co = color.CMYK{
+ C: uint8(c), //nolint:gosec
+ M: uint8(m), //nolint:gosec
+ Y: uint8(y), //nolint:gosec
+ K: 0,
+ }
+ return n
+
+ case 4: // CMYK direct color
+ if len(params) < 6 {
+ return 0
+ }
+
+ c, m, y, k := paramsfn()
+ if c == -1 || m == -1 || y == -1 || k == -1 {
+ return 0
+ }
+
+ *co = color.CMYK{
+ C: uint8(c), //nolint:gosec
+ M: uint8(m), //nolint:gosec
+ Y: uint8(y), //nolint:gosec
+ K: uint8(k), //nolint:gosec
+ }
+ return n
+
+ case 5: // indexed color
+ if len(params) < 3 {
+ return 0
+ }
+ switch {
+ case s.HasMore() && p.HasMore() && !params[2].HasMore():
+ // Colon separated indexed color
+ // 38 : 5 : 234
+ case !s.HasMore() && !p.HasMore() && !params[2].HasMore():
+ // Legacy semicolon indexed color
+ // 38 ; 5 ; 234
+ default:
+ return 0
+ }
+ *co = ExtendedColor(params[2].Param(0)) //nolint:gosec
+ return 3
+
+ case 6: // RGBA direct color
+ if len(params) < 6 {
+ return 0
+ }
+
+ r, g, b, a := paramsfn()
+ if r == -1 || g == -1 || b == -1 || a == -1 {
+ return 0
+ }
+
+ *co = color.RGBA{
+ R: uint8(r), //nolint:gosec
+ G: uint8(g), //nolint:gosec
+ B: uint8(b), //nolint:gosec
+ A: uint8(a), //nolint:gosec
+ }
+ return n
+
+ default:
+ return 0
+ }
+}
diff --git a/vendor/github.com/charmbracelet/x/ansi/termcap.go b/vendor/github.com/charmbracelet/x/ansi/termcap.go
new file mode 100644
index 0000000000..b59aa4203d
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/ansi/termcap.go
@@ -0,0 +1,41 @@
+package ansi
+
+import (
+ "encoding/hex"
+ "strings"
+)
+
+// XTGETTCAP (RequestTermcap) requests Termcap/Terminfo strings.
+//
+// DCS + q ST
+//
+// Where is a list of Termcap/Terminfo capabilities, encoded in 2-digit
+// hexadecimals, separated by semicolons.
+//
+// See: https://man7.org/linux/man-pages/man5/terminfo.5.html
+// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Operating-System-Commands
+func XTGETTCAP(caps ...string) string {
+ if len(caps) == 0 {
+ return ""
+ }
+
+ s := "\x1bP+q"
+ for i, c := range caps {
+ if i > 0 {
+ s += ";"
+ }
+ s += strings.ToUpper(hex.EncodeToString([]byte(c)))
+ }
+
+ return s + "\x1b\\"
+}
+
+// RequestTermcap is an alias for [XTGETTCAP].
+func RequestTermcap(caps ...string) string {
+ return XTGETTCAP(caps...)
+}
+
+// RequestTerminfo is an alias for [XTGETTCAP].
+func RequestTerminfo(caps ...string) string {
+ return XTGETTCAP(caps...)
+}
diff --git a/vendor/github.com/charmbracelet/x/ansi/title.go b/vendor/github.com/charmbracelet/x/ansi/title.go
new file mode 100644
index 0000000000..54ef942355
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/ansi/title.go
@@ -0,0 +1,48 @@
+package ansi
+
+// SetIconNameWindowTitle returns a sequence for setting the icon name and
+// window title.
+//
+// OSC 0 ; title ST
+// OSC 0 ; title BEL
+//
+// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-Operating-System-Commands
+func SetIconNameWindowTitle(s string) string {
+ return "\x1b]0;" + s + "\x07"
+}
+
+// SetIconName returns a sequence for setting the icon name.
+//
+// OSC 1 ; title ST
+// OSC 1 ; title BEL
+//
+// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-Operating-System-Commands
+func SetIconName(s string) string {
+ return "\x1b]1;" + s + "\x07"
+}
+
+// SetWindowTitle returns a sequence for setting the window title.
+//
+// OSC 2 ; title ST
+// OSC 2 ; title BEL
+//
+// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-Operating-System-Commands
+func SetWindowTitle(s string) string {
+ return "\x1b]2;" + s + "\x07"
+}
+
+// DECSWT is a sequence for setting the window title.
+//
+// This is an alias for [SetWindowTitle]("1;").
+// See: EK-VT520-RM 5–156 https://vt100.net/dec/ek-vt520-rm.pdf
+func DECSWT(name string) string {
+ return SetWindowTitle("1;" + name)
+}
+
+// DECSIN is a sequence for setting the icon name.
+//
+// This is an alias for [SetWindowTitle]("L;").
+// See: EK-VT520-RM 5–134 https://vt100.net/dec/ek-vt520-rm.pdf
+func DECSIN(name string) string {
+ return SetWindowTitle("L;" + name)
+}
diff --git a/vendor/github.com/charmbracelet/x/ansi/truncate.go b/vendor/github.com/charmbracelet/x/ansi/truncate.go
new file mode 100644
index 0000000000..f95f829309
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/ansi/truncate.go
@@ -0,0 +1,290 @@
+package ansi
+
+import (
+ "strings"
+
+ "github.com/charmbracelet/x/ansi/parser"
+ "github.com/clipperhouse/displaywidth"
+ "github.com/clipperhouse/uax29/v2/graphemes"
+)
+
+// Cut the string, without adding any prefix or tail strings. This function is
+// aware of ANSI escape codes and will not break them, and accounts for
+// wide-characters (such as East-Asian characters and emojis).
+// This treats the text as a sequence of graphemes.
+func Cut(s string, left, right int) string {
+ return cut(GraphemeWidth, s, left, right)
+}
+
+// CutWc the string, without adding any prefix or tail strings. This function is
+// aware of ANSI escape codes and will not break them, and accounts for
+// wide-characters (such as East-Asian characters and emojis).
+// Note that the [left] parameter is inclusive, while [right] isn't,
+// which is to say it'll return `[left, right)`.
+//
+// This treats the text as a sequence of wide characters and runes.
+func CutWc(s string, left, right int) string {
+ return cut(WcWidth, s, left, right)
+}
+
+func cut(m Method, s string, left, right int) string {
+ if right <= left {
+ return ""
+ }
+
+ truncate := Truncate
+ truncateLeft := TruncateLeft
+ if m == WcWidth {
+ truncate = TruncateWc
+ truncateLeft = TruncateWc
+ }
+
+ if left == 0 {
+ return truncate(s, right, "")
+ }
+ return truncateLeft(truncate(s, right, ""), left, "")
+}
+
+// Truncate truncates a string to a given length, adding a tail to the end if
+// the string is longer than the given length. This function is aware of ANSI
+// escape codes and will not break them, and accounts for wide-characters (such
+// as East-Asian characters and emojis).
+// This treats the text as a sequence of graphemes.
+func Truncate(s string, length int, tail string) string {
+ return truncate(GraphemeWidth, s, length, tail)
+}
+
+// TruncateWc truncates a string to a given length, adding a tail to the end if
+// the string is longer than the given length. This function is aware of ANSI
+// escape codes and will not break them, and accounts for wide-characters (such
+// as East-Asian characters and emojis).
+// This treats the text as a sequence of wide characters and runes.
+func TruncateWc(s string, length int, tail string) string {
+ return truncate(WcWidth, s, length, tail)
+}
+
+func truncate(m Method, s string, length int, tail string) string {
+ if sw := StringWidth(s); sw <= length {
+ return s
+ }
+
+ tw := StringWidth(tail)
+ length -= tw
+ if length < 0 {
+ return ""
+ }
+
+ var cluster string
+ var buf strings.Builder
+ curWidth := 0
+ ignoring := false
+ pstate := parser.GroundState // initial state
+ i := 0
+
+ // Here we iterate over the bytes of the string and collect printable
+ // characters and runes. We also keep track of the width of the string
+ // in cells.
+ //
+ // Once we reach the given length, we start ignoring characters and only
+ // collect ANSI escape codes until we reach the end of string.
+ for i < len(s) {
+ state, action := parser.Table.Transition(pstate, s[i])
+ if state == parser.Utf8State {
+ // This action happens when we transition to the Utf8State.
+ var width int
+ cluster, width = FirstGraphemeCluster(s[i:], m)
+ // increment the index by the length of the cluster
+ i += len(cluster)
+ curWidth += width
+
+ // Are we ignoring? Skip to the next byte
+ if ignoring {
+ continue
+ }
+
+ // Is this gonna be too wide?
+ // If so write the tail and stop collecting.
+ if curWidth > length && !ignoring {
+ ignoring = true
+ buf.WriteString(tail)
+ }
+
+ if curWidth > length {
+ continue
+ }
+
+ buf.WriteString(cluster)
+
+ // Done collecting, now we're back in the ground state.
+ pstate = parser.GroundState
+ continue
+ }
+
+ switch action {
+ case parser.PrintAction:
+ // Is this gonna be too wide?
+ // If so write the tail and stop collecting.
+ if curWidth >= length && !ignoring {
+ ignoring = true
+ buf.WriteString(tail)
+ }
+
+ // Skip to the next byte if we're ignoring
+ if ignoring {
+ i++
+ continue
+ }
+
+ // collects printable ASCII
+ curWidth++
+ fallthrough
+ case parser.ExecuteAction:
+ // execute action will be things like \n, which, if outside the cut,
+ // should be ignored.
+ if ignoring {
+ i++
+ continue
+ }
+ fallthrough
+ default:
+ buf.WriteByte(s[i])
+ i++
+ }
+
+ // Transition to the next state.
+ pstate = state
+
+ // Once we reach the given length, we start ignoring runes and write
+ // the tail to the buffer.
+ if curWidth > length && !ignoring {
+ ignoring = true
+ buf.WriteString(tail)
+ }
+ }
+
+ return buf.String()
+}
+
+// TruncateLeft truncates a string from the left side by removing n characters,
+// adding a prefix to the beginning if the string is longer than n.
+// This function is aware of ANSI escape codes and will not break them, and
+// accounts for wide-characters (such as East-Asian characters and emojis).
+// This treats the text as a sequence of graphemes.
+func TruncateLeft(s string, n int, prefix string) string {
+ return truncateLeft(GraphemeWidth, s, n, prefix)
+}
+
+// TruncateLeftWc truncates a string from the left side by removing n characters,
+// adding a prefix to the beginning if the string is longer than n.
+// This function is aware of ANSI escape codes and will not break them, and
+// accounts for wide-characters (such as East-Asian characters and emojis).
+// This treats the text as a sequence of wide characters and runes.
+func TruncateLeftWc(s string, n int, prefix string) string {
+ return truncateLeft(WcWidth, s, n, prefix)
+}
+
+func truncateLeft(m Method, s string, n int, prefix string) string {
+ if n <= 0 {
+ return s
+ }
+
+ var cluster string
+ var buf strings.Builder
+ curWidth := 0
+ ignoring := true
+ pstate := parser.GroundState
+ i := 0
+
+ for i < len(s) {
+ if !ignoring {
+ buf.WriteString(s[i:])
+ break
+ }
+
+ state, action := parser.Table.Transition(pstate, s[i])
+ if state == parser.Utf8State {
+ var width int
+ cluster, width = FirstGraphemeCluster(s[i:], m)
+
+ i += len(cluster)
+ curWidth += width
+
+ if curWidth > n && ignoring {
+ ignoring = false
+ buf.WriteString(prefix)
+ }
+
+ if curWidth > n {
+ buf.WriteString(cluster)
+ }
+
+ if ignoring {
+ continue
+ }
+
+ pstate = parser.GroundState
+ continue
+ }
+
+ switch action {
+ case parser.PrintAction:
+ curWidth++
+
+ if curWidth > n && ignoring {
+ ignoring = false
+ buf.WriteString(prefix)
+ }
+
+ if ignoring {
+ i++
+ continue
+ }
+
+ fallthrough
+ case parser.ExecuteAction:
+ // execute action will be things like \n, which, if outside the cut,
+ // should be ignored.
+ if ignoring {
+ i++
+ continue
+ }
+ fallthrough
+ default:
+ buf.WriteByte(s[i])
+ i++
+ }
+
+ pstate = state
+ if curWidth > n && ignoring {
+ ignoring = false
+ buf.WriteString(prefix)
+ }
+ }
+
+ return buf.String()
+}
+
+// ByteToGraphemeRange takes start and stop byte positions and converts them to
+// grapheme-aware char positions.
+// You can use this with [Truncate], [TruncateLeft], and [Cut].
+func ByteToGraphemeRange(str string, byteStart, byteStop int) (charStart, charStop int) {
+ bytePos, charPos := 0, 0
+ gr := graphemes.FromString(str)
+ for byteStart > bytePos {
+ if !gr.Next() {
+ break
+ }
+ bytePos += len(gr.Value())
+ charPos += max(1, displaywidth.String(gr.Value()))
+ }
+ charStart = charPos
+ for byteStop > bytePos {
+ if !gr.Next() {
+ break
+ }
+ bytePos += len(gr.Value())
+ charPos += max(1, displaywidth.String(gr.Value()))
+ }
+ charStop = charPos
+ return charStart, charStop
+}
diff --git a/vendor/github.com/charmbracelet/x/ansi/urxvt.go b/vendor/github.com/charmbracelet/x/ansi/urxvt.go
new file mode 100644
index 0000000000..b9e86281d9
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/ansi/urxvt.go
@@ -0,0 +1,17 @@
+package ansi
+
+import (
+ "fmt"
+ "strings"
+)
+
+// URxvtExt returns an escape sequence for calling a URxvt perl extension with
+// the given name and parameters.
+//
+// OSC 777 ; extension_name ; param1 ; param2 ; ... ST
+// OSC 777 ; extension_name ; param1 ; param2 ; ... BEL
+//
+// See: https://man.archlinux.org/man/extra/rxvt-unicode/urxvt.7.en#XTerm_Operating_System_Commands
+func URxvtExt(extension string, params ...string) string {
+ return fmt.Sprintf("\x1b]777;%s;%s\x07", extension, strings.Join(params, ";"))
+}
diff --git a/vendor/github.com/charmbracelet/x/ansi/util.go b/vendor/github.com/charmbracelet/x/ansi/util.go
new file mode 100644
index 0000000000..103f452bb8
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/ansi/util.go
@@ -0,0 +1,92 @@
+package ansi
+
+import (
+ "fmt"
+ "image/color"
+ "strconv"
+ "strings"
+
+ "github.com/lucasb-eyer/go-colorful"
+)
+
+// colorToHexString returns a hex string representation of a color.
+func colorToHexString(c color.Color) string { //nolint:unused
+ if c == nil {
+ return ""
+ }
+ shift := func(v uint32) uint32 {
+ if v > 0xff {
+ return v >> 8
+ }
+ return v
+ }
+ r, g, b, _ := c.RGBA()
+ r, g, b = shift(r), shift(g), shift(b)
+ return fmt.Sprintf("#%02x%02x%02x", r, g, b)
+}
+
+// rgbToHex converts red, green, and blue values to a hexadecimal value.
+//
+// hex := rgbToHex(0, 0, 255) // 0x0000FF
+func rgbToHex(r, g, b uint32) uint32 { //nolint:unused
+ return r<<16 + g<<8 + b
+}
+
+type shiftable interface {
+ ~uint | ~uint16 | ~uint32 | ~uint64
+}
+
+func shift[T shiftable](x T) T {
+ if x > 0xff {
+ x >>= 8
+ }
+ return x
+}
+
+// XParseColor is a helper function that parses a string into a color.Color. It
+// provides a similar interface to the XParseColor function in Xlib. It
+// supports the following formats:
+//
+// - #RGB
+// - #RRGGBB
+// - rgb:RRRR/GGGG/BBBB
+// - rgba:RRRR/GGGG/BBBB/AAAA
+//
+// If the string is not a valid color, nil is returned.
+//
+// See: https://linux.die.net/man/3/xparsecolor
+func XParseColor(s string) color.Color {
+ switch {
+ case strings.HasPrefix(s, "#"):
+ c, err := colorful.Hex(s)
+ if err != nil {
+ return nil
+ }
+
+ return c
+ case strings.HasPrefix(s, "rgb:"):
+ parts := strings.Split(s[4:], "/")
+ if len(parts) != 3 {
+ return nil
+ }
+
+ r, _ := strconv.ParseUint(parts[0], 16, 32)
+ g, _ := strconv.ParseUint(parts[1], 16, 32)
+ b, _ := strconv.ParseUint(parts[2], 16, 32)
+
+ return color.RGBA{uint8(shift(r)), uint8(shift(g)), uint8(shift(b)), 255} //nolint:gosec
+ case strings.HasPrefix(s, "rgba:"):
+ parts := strings.Split(s[5:], "/")
+ if len(parts) != 4 {
+ return nil
+ }
+
+ r, _ := strconv.ParseUint(parts[0], 16, 32)
+ g, _ := strconv.ParseUint(parts[1], 16, 32)
+ b, _ := strconv.ParseUint(parts[2], 16, 32)
+ a, _ := strconv.ParseUint(parts[3], 16, 32)
+
+ return color.RGBA{uint8(shift(r)), uint8(shift(g)), uint8(shift(b)), uint8(shift(a))} //nolint:gosec
+ }
+ return nil
+}
diff --git a/vendor/github.com/charmbracelet/x/ansi/wcwidth.go b/vendor/github.com/charmbracelet/x/ansi/wcwidth.go
new file mode 100644
index 0000000000..642a4f6f95
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/ansi/wcwidth.go
@@ -0,0 +1,100 @@
+package ansi
+
+import (
+ "slices"
+ "unicode"
+ "unicode/utf8"
+)
+
+// zeroWidthTables are the categories whose runes don't advance the cursor:
+// nonspacing and enclosing marks, and format characters such as ZWJ and the
+// variation selectors.
+var zeroWidthTables = []*unicode.RangeTable{unicode.Mn, unicode.Me, unicode.Cf}
+
+// zeroWidthBMP is a bitset of the [zeroWidthTables] runes in the basic
+// multilingual plane. Measuring runs a lookup per rune, and a bit test is a
+// good deal cheaper than searching three range tables. Runes above the BMP are
+// rare enough in terminal output to leave on the slow path.
+var zeroWidthBMP [0x10000 / 64]uint64
+
+// zeroWidthHigh holds the [zeroWidthTables] runes above the BMP, expanded and
+// sorted so a lookup is one binary search.
+var zeroWidthHigh []rune
+
+func init() {
+ for _, t := range zeroWidthTables {
+ for _, r := range t.R16 {
+ for c := rune(r.Lo); c <= rune(r.Hi); c += rune(r.Stride) {
+ zeroWidthBMP[c>>6] |= 1 << (c & 63)
+ }
+ }
+ for _, r := range t.R32 {
+ // R32 range bounds are always valid runes.
+ for c := rune(r.Lo); c <= rune(r.Hi); c += rune(r.Stride) { //nolint:gosec
+ zeroWidthHigh = append(zeroWidthHigh, c)
+ }
+ }
+ }
+ slices.Sort(zeroWidthHigh)
+}
+
+// isZeroWidthHigh reports whether a rune above the BMP is zero width.
+func isZeroWidthHigh(r rune) bool {
+ _, ok := slices.BinarySearch(zeroWidthHigh, r)
+ return ok
+}
+
+// wcRuneWidth returns the number of columns a single rune advances the cursor,
+// i.e. wcwidth(3).
+//
+// Nonspacing and enclosing marks, along with format characters such as ZWJ and
+// the variation selectors, never advance the cursor. [runewidth] reports some
+// of them, most notably the Indic combining marks, as single width, so they're
+// classified here instead.
+func wcRuneWidth(r rune) int {
+ switch {
+ case r < 0x20, r >= 0x7f && r < 0xa0:
+ // C0 and C1 controls, and DEL, don't print.
+ return 0
+ case r < 0x7f:
+ // Printable ASCII. Everything above it can be East Asian Ambiguous,
+ // so it has to go through runewidth.
+ return 1
+ case r < 0x10000:
+ if zeroWidthBMP[r>>6]&(1<<(r&63)) != 0 {
+ return 0
+ }
+ case isZeroWidthHigh(r):
+ return 0
+ }
+ return wcOptions.RuneWidth(r)
+}
+
+// wcClusterWidth returns the number of columns a grapheme cluster occupies
+// under [WcWidth], which is the sum of the widths of its codepoints.
+//
+// Terminals that don't implement Unicode core mode (DEC mode 2027) advance the
+// cursor once per codepoint and know nothing about cluster boundaries. So a
+// cluster can be wider than the glyph it draws: Unicode 15.1 merged Indic
+// conjuncts into single clusters, and a terminal still puts "स्ते" in two
+// columns, one per consonant. ZWJ emoji sequences behave the same way, with
+// "👨👩👧👦" taking the eight columns of the four emoji it's built from.
+//
+// Measuring the cluster as a unit is [GraphemeWidth]'s job.
+func wcClusterWidth[T string | []byte](cluster T) int {
+ var width int
+ switch c := any(cluster).(type) {
+ case string:
+ for _, r := range c {
+ width += wcRuneWidth(r)
+ }
+ case []byte:
+ // Ranging over string(c) would copy the slice, so decode in place.
+ for len(c) > 0 {
+ r, size := utf8.DecodeRune(c)
+ width += wcRuneWidth(r)
+ c = c[size:]
+ }
+ }
+ return width
+}
diff --git a/vendor/github.com/charmbracelet/x/ansi/width.go b/vendor/github.com/charmbracelet/x/ansi/width.go
new file mode 100644
index 0000000000..30c7caa097
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/ansi/width.go
@@ -0,0 +1,119 @@
+package ansi
+
+import (
+ "bytes"
+ "unicode/utf8"
+
+ "github.com/charmbracelet/x/ansi/parser"
+)
+
+// Strip removes ANSI escape codes from a string.
+func Strip(s string) string {
+ var (
+ buf bytes.Buffer // buffer for collecting printable characters
+ ri int // rune index
+ rw int // rune width
+ pstate = parser.GroundState // initial state
+ )
+
+ // This implements a subset of the Parser to only collect runes and
+ // printable characters.
+ for i := range len(s) {
+ if pstate == parser.Utf8State {
+ // During this state, collect rw bytes to form a valid rune in the
+ // buffer. After getting all the rune bytes into the buffer,
+ // transition to GroundState and reset the counters.
+ buf.WriteByte(s[i])
+ ri++
+ if ri < rw {
+ continue
+ }
+ pstate = parser.GroundState
+ ri = 0
+ rw = 0
+ continue
+ }
+
+ state, action := parser.Table.Transition(pstate, s[i])
+ switch action {
+ case parser.CollectAction:
+ if state == parser.Utf8State {
+ // This action happens when we transition to the Utf8State.
+ rw = utf8ByteLen(s[i])
+ buf.WriteByte(s[i])
+ ri++
+ }
+ case parser.PrintAction, parser.ExecuteAction:
+ // collects printable ASCII and non-printable characters
+ buf.WriteByte(s[i])
+ }
+
+ // Transition to the next state.
+ // The Utf8State is managed separately above.
+ if pstate != parser.Utf8State {
+ pstate = state
+ }
+ }
+
+ return buf.String()
+}
+
+// StringWidth returns the width of a string in cells. This is the number of
+// cells that the string will occupy when printed in a terminal. ANSI escape
+// codes are ignored and wide characters (such as East Asians and emojis) are
+// accounted for.
+// This treats the text as a sequence of grapheme clusters.
+func StringWidth(s string) int {
+ return stringWidth(GraphemeWidth, s)
+}
+
+// StringWidthWc returns the width of a string in cells. This is the number of
+// cells that the string will occupy when printed in a terminal. ANSI escape
+// codes are ignored and wide characters (such as East Asians and emojis) are
+// accounted for.
+// This treats the text as a sequence of wide characters and runes.
+func StringWidthWc(s string) int {
+ return stringWidth(WcWidth, s)
+}
+
+func stringWidth(m Method, s string) int {
+ if s == "" {
+ return 0
+ }
+
+ var (
+ pstate = parser.GroundState // initial state
+ width int
+ )
+
+ for i := 0; i < len(s); i++ {
+ state, action := parser.Table.Transition(pstate, s[i])
+ if action == parser.PrintAction || state == parser.Utf8State {
+ if m == WcWidth {
+ // Wcwidth sums codepoints, so where the cluster boundaries
+ // fall makes no difference to the total. Skipping the
+ // segmentation is a good deal cheaper.
+ r, size := utf8.DecodeRuneInString(s[i:])
+ width += wcRuneWidth(r)
+ i += size - 1
+ pstate = parser.GroundState
+ continue
+ }
+
+ cluster, w := FirstGraphemeCluster(s[i:], m)
+ width += w
+
+ i += len(cluster) - 1
+ pstate = parser.GroundState
+ continue
+ }
+
+ if action == parser.PrintAction {
+ width++
+ }
+
+ pstate = state
+ }
+
+ return width
+}
diff --git a/vendor/github.com/charmbracelet/x/ansi/winop.go b/vendor/github.com/charmbracelet/x/ansi/winop.go
new file mode 100644
index 0000000000..8487178b16
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/ansi/winop.go
@@ -0,0 +1,59 @@
+package ansi
+
+import (
+ "strconv"
+ "strings"
+)
+
+const (
+ // ResizeWindowWinOp is a window operation that resizes the terminal
+ // window.
+ //
+ // Deprecated: Use constant number directly with [WindowOp].
+ ResizeWindowWinOp = 4
+
+ // RequestWindowSizeWinOp is a window operation that requests a report of
+ // the size of the terminal window in pixels. The response is in the form:
+ // CSI 4 ; height ; width t
+ //
+ // Deprecated: Use constant number directly with [WindowOp].
+ RequestWindowSizeWinOp = 14
+
+ // RequestCellSizeWinOp is a window operation that requests a report of
+ // the size of the terminal cell size in pixels. The response is in the form:
+ // CSI 6 ; height ; width t
+ //
+ // Deprecated: Use constant number directly with [WindowOp].
+ RequestCellSizeWinOp = 16
+)
+
+// WindowOp (XTWINOPS) is a sequence that manipulates the terminal window.
+//
+// CSI Ps ; Ps ; Ps t
+//
+// Ps is a semicolon-separated list of parameters.
+// See https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h4-Functions-using-CSI-_-ordered-by-the-final-character-lparen-s-rparen:CSI-Ps;Ps;Ps-t.1EB0
+func WindowOp(p int, ps ...int) string {
+ if p <= 0 {
+ return ""
+ }
+
+ if len(ps) == 0 {
+ return "\x1b[" + strconv.Itoa(p) + "t"
+ }
+
+ params := make([]string, 0, len(ps)+1)
+ params = append(params, strconv.Itoa(p))
+ for _, p := range ps {
+ if p >= 0 {
+ params = append(params, strconv.Itoa(p))
+ }
+ }
+
+ return "\x1b[" + strings.Join(params, ";") + "t"
+}
+
+// XTWINOPS is an alias for [WindowOp].
+func XTWINOPS(p int, ps ...int) string {
+ return WindowOp(p, ps...)
+}
diff --git a/vendor/github.com/charmbracelet/x/ansi/wrap.go b/vendor/github.com/charmbracelet/x/ansi/wrap.go
new file mode 100644
index 0000000000..530be6caee
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/ansi/wrap.go
@@ -0,0 +1,472 @@
+package ansi
+
+import (
+ "bytes"
+ "strings"
+ "unicode"
+ "unicode/utf8"
+
+ "github.com/charmbracelet/x/ansi/parser"
+)
+
+// nbsp is a non-breaking space.
+const nbsp = 0xA0
+
+// Hardwrap wraps a string or a block of text to a given line length, breaking
+// word boundaries. This will preserve ANSI escape codes and will account for
+// wide-characters in the string.
+// When preserveSpace is true, spaces at the beginning of a line will be
+// preserved.
+// This treats the text as a sequence of graphemes.
+func Hardwrap(s string, limit int, preserveSpace bool) string {
+ return hardwrap(GraphemeWidth, s, limit, preserveSpace)
+}
+
+// HardwrapWc wraps a string or a block of text to a given line length, breaking
+// word boundaries. This will preserve ANSI escape codes and will account for
+// wide-characters in the string.
+// When preserveSpace is true, spaces at the beginning of a line will be
+// preserved.
+// This treats the text as a sequence of wide characters and runes.
+func HardwrapWc(s string, limit int, preserveSpace bool) string {
+ return hardwrap(WcWidth, s, limit, preserveSpace)
+}
+
+func hardwrap(m Method, s string, limit int, preserveSpace bool) string {
+ if limit < 1 {
+ return s
+ }
+
+ var (
+ cluster []byte
+ buf bytes.Buffer
+ curWidth int
+ forceNewline bool
+ pstate = parser.GroundState // initial state
+ b = []byte(s)
+ )
+
+ addNewline := func() {
+ buf.WriteByte('\n')
+ curWidth = 0
+ }
+
+ i := 0
+ for i < len(b) {
+ state, action := parser.Table.Transition(pstate, b[i])
+ if state == parser.Utf8State {
+ var width int
+ cluster, width = FirstGraphemeCluster(b[i:], m)
+ i += len(cluster)
+
+ if curWidth+width > limit {
+ addNewline()
+ }
+ if !preserveSpace && curWidth == 0 && len(cluster) <= 4 {
+ // Skip spaces at the beginning of a line
+ if r, _ := utf8.DecodeRune(cluster); r != utf8.RuneError && unicode.IsSpace(r) {
+ pstate = parser.GroundState
+ continue
+ }
+ }
+
+ buf.Write(cluster)
+ curWidth += width
+ pstate = parser.GroundState
+ continue
+ }
+
+ switch action {
+ case parser.PrintAction, parser.ExecuteAction:
+ if b[i] == '\n' {
+ addNewline()
+ forceNewline = false
+ break
+ }
+
+ if curWidth+1 > limit {
+ addNewline()
+ forceNewline = true
+ }
+
+ // Skip spaces at the beginning of a line
+ if curWidth == 0 {
+ if !preserveSpace && forceNewline && unicode.IsSpace(rune(b[i])) {
+ break
+ }
+ forceNewline = false
+ }
+
+ buf.WriteByte(b[i])
+ if action == parser.PrintAction {
+ curWidth++
+ }
+ default:
+ buf.WriteByte(b[i])
+ }
+
+ // We manage the UTF8 state separately manually above.
+ if pstate != parser.Utf8State {
+ pstate = state
+ }
+ i++
+ }
+
+ return buf.String()
+}
+
+// Wordwrap wraps a string or a block of text to a given line length, not
+// breaking word boundaries. This will preserve ANSI escape codes and will
+// account for wide-characters in the string.
+// The breakpoints string is a list of characters that are considered
+// breakpoints for word wrapping. A hyphen (-) is always considered a
+// breakpoint.
+//
+// Note: breakpoints must be a string of 1-cell wide rune characters.
+//
+// This treats the text as a sequence of graphemes.
+func Wordwrap(s string, limit int, breakpoints string) string {
+ return wordwrap(GraphemeWidth, s, limit, breakpoints)
+}
+
+// WordwrapWc wraps a string or a block of text to a given line length, not
+// breaking word boundaries. This will preserve ANSI escape codes and will
+// account for wide-characters in the string.
+// The breakpoints string is a list of characters that are considered
+// breakpoints for word wrapping. A hyphen (-) is always considered a
+// breakpoint.
+//
+// Note: breakpoints must be a string of 1-cell wide rune characters.
+//
+// This treats the text as a sequence of wide characters and runes.
+func WordwrapWc(s string, limit int, breakpoints string) string {
+ return wordwrap(WcWidth, s, limit, breakpoints)
+}
+
+func wordwrap(m Method, s string, limit int, breakpoints string) string {
+ if limit < 1 {
+ return s
+ }
+
+ var (
+ cluster []byte
+ buf bytes.Buffer
+ word bytes.Buffer
+ space bytes.Buffer
+ curWidth int
+ wordLen int
+ pstate = parser.GroundState // initial state
+ b = []byte(s)
+ )
+
+ addSpace := func() {
+ curWidth += space.Len()
+ buf.Write(space.Bytes())
+ space.Reset()
+ }
+
+ addWord := func() {
+ if word.Len() == 0 {
+ return
+ }
+
+ addSpace()
+ curWidth += wordLen
+ buf.Write(word.Bytes())
+ word.Reset()
+ wordLen = 0
+ }
+
+ addNewline := func() {
+ buf.WriteByte('\n')
+ curWidth = 0
+ space.Reset()
+ }
+
+ i := 0
+ for i < len(b) {
+ state, action := parser.Table.Transition(pstate, b[i])
+ if state == parser.Utf8State { //nolint:nestif
+ var width int
+ cluster, width = FirstGraphemeCluster(b[i:], m)
+ i += len(cluster)
+
+ r, _ := utf8.DecodeRune(cluster)
+ if r != utf8.RuneError && unicode.IsSpace(r) && r != nbsp {
+ addWord()
+ space.WriteRune(r)
+ } else if bytes.ContainsAny(cluster, breakpoints) {
+ addSpace()
+ addWord()
+ buf.Write(cluster)
+ curWidth++
+ } else {
+ word.Write(cluster)
+ wordLen += width
+ if curWidth+space.Len()+wordLen > limit &&
+ wordLen < limit {
+ addNewline()
+ }
+ }
+
+ pstate = parser.GroundState
+ continue
+ }
+
+ switch action {
+ case parser.PrintAction, parser.ExecuteAction:
+ r := rune(b[i])
+ switch {
+ case r == '\n':
+ if wordLen == 0 {
+ if curWidth+space.Len() > limit {
+ curWidth = 0
+ } else {
+ buf.Write(space.Bytes())
+ }
+ space.Reset()
+ }
+
+ addWord()
+ addNewline()
+ case unicode.IsSpace(r):
+ addWord()
+ space.WriteByte(b[i])
+ case r == '-':
+ fallthrough
+ case runeContainsAny(r, breakpoints):
+ addSpace()
+ addWord()
+ buf.WriteByte(b[i])
+ curWidth++
+ default:
+ word.WriteByte(b[i])
+ wordLen++
+ if curWidth+space.Len()+wordLen > limit &&
+ wordLen < limit {
+ addNewline()
+ }
+ }
+
+ default:
+ word.WriteByte(b[i])
+ }
+
+ // We manage the UTF8 state separately manually above.
+ if pstate != parser.Utf8State {
+ pstate = state
+ }
+ i++
+ }
+
+ addWord()
+
+ return buf.String()
+}
+
+// Wrap wraps a string or a block of text to a given line length, breaking word
+// boundaries if necessary. This will preserve ANSI escape codes and will
+// account for wide-characters in the string. The breakpoints string is a list
+// of characters that are considered breakpoints for word wrapping. A hyphen
+// (-) is always considered a breakpoint.
+//
+// Note: breakpoints must be a string of 1-cell wide rune characters.
+//
+// This treats the text as a sequence of graphemes.
+func Wrap(s string, limit int, breakpoints string) string {
+ return wrap(GraphemeWidth, s, limit, breakpoints)
+}
+
+// WrapWc wraps a string or a block of text to a given line length, breaking word
+// boundaries if necessary. This will preserve ANSI escape codes and will
+// account for wide-characters in the string. The breakpoints string is a list
+// of characters that are considered breakpoints for word wrapping. A hyphen
+// (-) is always considered a breakpoint.
+//
+// Note: breakpoints must be a string of 1-cell wide rune characters.
+//
+// This treats the text as a sequence of wide characters and runes.
+func WrapWc(s string, limit int, breakpoints string) string {
+ return wrap(WcWidth, s, limit, breakpoints)
+}
+
+func wrap(m Method, s string, limit int, breakpoints string) string {
+ if limit < 1 {
+ return s
+ }
+
+ var (
+ cluster string
+ buf bytes.Buffer
+ word bytes.Buffer
+ space bytes.Buffer
+ spaceWidth int // width of the space buffer
+ curWidth int // written width of the line
+ wordLen int // word buffer len without ANSI escape codes
+ pstate = parser.GroundState // initial state
+ )
+
+ addSpace := func() {
+ if spaceWidth == 0 && space.Len() == 0 {
+ return
+ }
+ curWidth += spaceWidth
+ buf.Write(space.Bytes())
+ space.Reset()
+ spaceWidth = 0
+ }
+
+ addWord := func() {
+ if word.Len() == 0 {
+ return
+ }
+
+ addSpace()
+ curWidth += wordLen
+ buf.Write(word.Bytes())
+ word.Reset()
+ wordLen = 0
+ }
+
+ addNewline := func() {
+ buf.WriteByte('\n')
+ curWidth = 0
+ space.Reset()
+ spaceWidth = 0
+ }
+
+ i := 0
+ for i < len(s) {
+ state, action := parser.Table.Transition(pstate, s[i])
+ if state == parser.Utf8State { //nolint:nestif
+ var width int
+ cluster, width = FirstGraphemeCluster(s[i:], m)
+ i += len(cluster)
+
+ r, _ := utf8.DecodeRuneInString(cluster)
+ switch {
+ case r != utf8.RuneError && unicode.IsSpace(r) && r != nbsp: // nbsp is a non-breaking space
+ addWord()
+ space.WriteRune(r)
+ spaceWidth += width
+ case strings.ContainsAny(cluster, breakpoints):
+ addSpace()
+ if curWidth+wordLen+width > limit {
+ word.WriteString(cluster)
+ wordLen += width
+ } else {
+ addWord()
+ buf.WriteString(cluster)
+ curWidth += width
+ }
+ default:
+ if wordLen+width > limit {
+ // Hardwrap the word if it's too long
+ addWord()
+ }
+
+ word.WriteString(cluster)
+ wordLen += width
+
+ if curWidth+wordLen+spaceWidth > limit {
+ addNewline()
+ }
+
+ if wordLen == limit {
+ // Hardwrap the word if it's too long
+ addWord()
+ }
+ }
+
+ pstate = parser.GroundState
+ continue
+ }
+
+ switch action {
+ case parser.PrintAction, parser.ExecuteAction:
+ switch r := rune(s[i]); {
+ case r == '\n':
+ if wordLen == 0 {
+ if curWidth+spaceWidth > limit {
+ curWidth = 0
+ } else {
+ // preserve whitespaces
+ buf.Write(space.Bytes())
+ }
+ space.Reset()
+ spaceWidth = 0
+ }
+
+ addWord()
+ addNewline()
+ case unicode.IsSpace(r):
+ addWord()
+ space.WriteRune(r)
+ spaceWidth++
+ case r == '-':
+ fallthrough
+ case runeContainsAny(r, breakpoints):
+ addSpace()
+ if curWidth+wordLen >= limit {
+ // We can't fit the breakpoint in the current line, treat
+ // it as part of the word.
+ word.WriteRune(r)
+ wordLen++
+ } else {
+ addWord()
+ buf.WriteRune(r)
+ curWidth++
+ }
+ default:
+ if curWidth == limit {
+ addNewline()
+ }
+
+ word.WriteRune(r)
+ wordLen++
+
+ if wordLen == limit {
+ // Hardwrap the word if it's too long
+ addWord()
+ }
+
+ if curWidth+wordLen+spaceWidth > limit {
+ addNewline()
+ }
+ }
+
+ default:
+ word.WriteByte(s[i])
+ }
+
+ // We manage the UTF8 state separately manually above.
+ if pstate != parser.Utf8State {
+ pstate = state
+ }
+ i++
+ }
+
+ if wordLen == 0 {
+ if curWidth+spaceWidth > limit {
+ curWidth = 0
+ } else {
+ // preserve whitespaces
+ buf.Write(space.Bytes())
+ }
+ space.Reset()
+ spaceWidth = 0
+ }
+
+ addWord()
+
+ return buf.String()
+}
+
+func runeContainsAny(r rune, s string) bool {
+ for _, c := range s {
+ if c == r {
+ return true
+ }
+ }
+ return false
+}
diff --git a/vendor/github.com/charmbracelet/x/ansi/xterm.go b/vendor/github.com/charmbracelet/x/ansi/xterm.go
new file mode 100644
index 0000000000..83fd4bdc4e
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/ansi/xterm.go
@@ -0,0 +1,138 @@
+package ansi
+
+import "strconv"
+
+// KeyModifierOptions (XTMODKEYS) sets/resets xterm key modifier options.
+//
+// Default is 0.
+//
+// CSI > Pp m
+// CSI > Pp ; Pv m
+//
+// If Pv is omitted, the resource is reset to its initial value.
+//
+// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Functions-using-CSI-_-ordered-by-the-final-character_s_
+func KeyModifierOptions(p int, vs ...int) string {
+ var pp, pv string
+ if p > 0 {
+ pp = strconv.Itoa(p)
+ }
+
+ if len(vs) == 0 {
+ return "\x1b[>" + strconv.Itoa(p) + "m"
+ }
+
+ v := vs[0]
+ if v > 0 {
+ pv = strconv.Itoa(v)
+ return "\x1b[>" + pp + ";" + pv + "m"
+ }
+
+ return "\x1b[>" + pp + "m"
+}
+
+// XTMODKEYS is an alias for [KeyModifierOptions].
+func XTMODKEYS(p int, vs ...int) string {
+ return KeyModifierOptions(p, vs...)
+}
+
+// SetKeyModifierOptions sets xterm key modifier options.
+// This is an alias for [KeyModifierOptions].
+func SetKeyModifierOptions(pp int, pv int) string {
+ return KeyModifierOptions(pp, pv)
+}
+
+// ResetKeyModifierOptions resets xterm key modifier options.
+// This is an alias for [KeyModifierOptions].
+func ResetKeyModifierOptions(pp int) string {
+ return KeyModifierOptions(pp)
+}
+
+// QueryKeyModifierOptions (XTQMODKEYS) requests xterm key modifier options.
+//
+// Default is 0.
+//
+// CSI ? Pp m
+//
+// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Functions-using-CSI-_-ordered-by-the-final-character_s_
+func QueryKeyModifierOptions(pp int) string {
+ var p string
+ if pp > 0 {
+ p = strconv.Itoa(pp)
+ }
+ return "\x1b[?" + p + "m"
+}
+
+// XTQMODKEYS is an alias for [QueryKeyModifierOptions].
+func XTQMODKEYS(pp int) string {
+ return QueryKeyModifierOptions(pp)
+}
+
+// Modify Other Keys (modifyOtherKeys) is an xterm feature that allows the
+// terminal to modify the behavior of certain keys to send different escape
+// sequences when pressed.
+//
+// See: https://invisible-island.net/xterm/manpage/xterm.html#VT100-Widget-Resources:modifyOtherKeys
+const (
+ SetModifyOtherKeys1 = "\x1b[>4;1m"
+ SetModifyOtherKeys2 = "\x1b[>4;2m"
+ ResetModifyOtherKeys = "\x1b[>4m"
+ QueryModifyOtherKeys = "\x1b[?4m"
+)
+
+// ModifyOtherKeys returns a sequence that sets XTerm modifyOtherKeys mode.
+// The mode argument specifies the mode to set.
+//
+// 0: Disable modifyOtherKeys mode.
+// 1: Enable modifyOtherKeys mode 1.
+// 2: Enable modifyOtherKeys mode 2.
+//
+// CSI > 4 ; mode m
+//
+// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Functions-using-CSI-_-ordered-by-the-final-character_s_
+// See: https://invisible-island.net/xterm/manpage/xterm.html#VT100-Widget-Resources:modifyOtherKeys
+//
+// Deprecated: use [SetModifyOtherKeys1] or [SetModifyOtherKeys2] instead.
+func ModifyOtherKeys(mode int) string {
+ return "\x1b[>4;" + strconv.Itoa(mode) + "m"
+}
+
+// DisableModifyOtherKeys disables the modifyOtherKeys mode.
+//
+// CSI > 4 ; 0 m
+//
+// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Functions-using-CSI-_-ordered-by-the-final-character_s_
+// See: https://invisible-island.net/xterm/manpage/xterm.html#VT100-Widget-Resources:modifyOtherKeys
+//
+// Deprecated: use [ResetModifyOtherKeys] instead.
+const DisableModifyOtherKeys = "\x1b[>4;0m"
+
+// EnableModifyOtherKeys1 enables the modifyOtherKeys mode 1.
+//
+// CSI > 4 ; 1 m
+//
+// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Functions-using-CSI-_-ordered-by-the-final-character_s_
+// See: https://invisible-island.net/xterm/manpage/xterm.html#VT100-Widget-Resources:modifyOtherKeys
+//
+// Deprecated: use [SetModifyOtherKeys1] instead.
+const EnableModifyOtherKeys1 = "\x1b[>4;1m"
+
+// EnableModifyOtherKeys2 enables the modifyOtherKeys mode 2.
+//
+// CSI > 4 ; 2 m
+//
+// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Functions-using-CSI-_-ordered-by-the-final-character_s_
+// See: https://invisible-island.net/xterm/manpage/xterm.html#VT100-Widget-Resources:modifyOtherKeys
+//
+// Deprecated: use [SetModifyOtherKeys2] instead.
+const EnableModifyOtherKeys2 = "\x1b[>4;2m"
+
+// RequestModifyOtherKeys requests the modifyOtherKeys mode.
+//
+// CSI ? 4 m
+//
+// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Functions-using-CSI-_-ordered-by-the-final-character_s_
+// See: https://invisible-island.net/xterm/manpage/xterm.html#VT100-Widget-Resources:modifyOtherKeys
+//
+// Deprecated: use [QueryModifyOtherKeys] instead.
+const RequestModifyOtherKeys = "\x1b[?4m"
diff --git a/vendor/github.com/charmbracelet/x/term/LICENSE b/vendor/github.com/charmbracelet/x/term/LICENSE
new file mode 100644
index 0000000000..65a5654e20
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/term/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2023 Charmbracelet, Inc.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/vendor/github.com/charmbracelet/x/term/term.go b/vendor/github.com/charmbracelet/x/term/term.go
new file mode 100644
index 0000000000..151e475828
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/term/term.go
@@ -0,0 +1,51 @@
+// Package term provides a platform-independent interfaces for interacting with
+// Terminal and TTY devices.
+package term
+
+// State contains platform-specific state of a terminal.
+type State struct {
+ state
+}
+
+// IsTerminal returns whether the given file descriptor is a terminal.
+func IsTerminal(fd uintptr) bool {
+ return isTerminal(fd)
+}
+
+// MakeRaw puts the terminal connected to the given file descriptor into raw
+// mode and returns the previous state of the terminal so that it can be
+// restored.
+func MakeRaw(fd uintptr) (*State, error) {
+ return makeRaw(fd)
+}
+
+// GetState returns the current state of a terminal which may be useful to
+// restore the terminal after a signal.
+func GetState(fd uintptr) (*State, error) {
+ return getState(fd)
+}
+
+// SetState sets the given state of the terminal.
+func SetState(fd uintptr, state *State) error {
+ return setState(fd, state)
+}
+
+// Restore restores the terminal connected to the given file descriptor to a
+// previous state.
+func Restore(fd uintptr, oldState *State) error {
+ return restore(fd, oldState)
+}
+
+// GetSize returns the visible dimensions of the given terminal.
+//
+// These dimensions don't include any scrollback buffer height.
+func GetSize(fd uintptr) (width, height int, err error) {
+ return getSize(fd)
+}
+
+// ReadPassword reads a line of input from a terminal without local echo. This
+// is commonly used for inputting passwords and other sensitive data. The slice
+// returned does not include the \n.
+func ReadPassword(fd uintptr) ([]byte, error) {
+ return readPassword(fd)
+}
diff --git a/vendor/github.com/charmbracelet/x/term/term_other.go b/vendor/github.com/charmbracelet/x/term/term_other.go
new file mode 100644
index 0000000000..092c7e9d9b
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/term/term_other.go
@@ -0,0 +1,39 @@
+//go:build !aix && !darwin && !dragonfly && !freebsd && !linux && !netbsd && !openbsd && !zos && !windows && !solaris && !plan9
+// +build !aix,!darwin,!dragonfly,!freebsd,!linux,!netbsd,!openbsd,!zos,!windows,!solaris,!plan9
+
+package term
+
+import (
+ "fmt"
+ "runtime"
+)
+
+type state struct{}
+
+func isTerminal(fd uintptr) bool {
+ return false
+}
+
+func makeRaw(fd uintptr) (*State, error) {
+ return nil, fmt.Errorf("terminal: MakeRaw not implemented on %s/%s", runtime.GOOS, runtime.GOARCH)
+}
+
+func getState(fd uintptr) (*State, error) {
+ return nil, fmt.Errorf("terminal: GetState not implemented on %s/%s", runtime.GOOS, runtime.GOARCH)
+}
+
+func restore(fd uintptr, state *State) error {
+ return fmt.Errorf("terminal: Restore not implemented on %s/%s", runtime.GOOS, runtime.GOARCH)
+}
+
+func getSize(fd uintptr) (width, height int, err error) {
+ return 0, 0, fmt.Errorf("terminal: GetSize not implemented on %s/%s", runtime.GOOS, runtime.GOARCH)
+}
+
+func setState(fd uintptr, state *State) error {
+ return fmt.Errorf("terminal: SetState not implemented on %s/%s", runtime.GOOS, runtime.GOARCH)
+}
+
+func readPassword(fd uintptr) ([]byte, error) {
+ return nil, fmt.Errorf("terminal: ReadPassword not implemented on %s/%s", runtime.GOOS, runtime.GOARCH)
+}
diff --git a/vendor/github.com/charmbracelet/x/term/term_plan9.go b/vendor/github.com/charmbracelet/x/term/term_plan9.go
new file mode 100644
index 0000000000..eba3bdf7fa
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/term/term_plan9.go
@@ -0,0 +1,118 @@
+package term
+
+import (
+ "fmt"
+ "os"
+ "path/filepath"
+ "strings"
+)
+
+type state struct {
+ termName string
+ raw bool
+ ctl *os.File
+}
+
+// termName returns the name of the terminal or os.ErrNotExist if there is no terminal.
+func termName(fd uintptr) (string, error) {
+ ctl, err := os.ReadFile(filepath.Join("/fd", fmt.Sprintf("%dctl", fd)))
+ if err != nil {
+ return "", err
+ }
+ f := strings.Fields(string(ctl))
+ if len(f) == 0 {
+ return "", os.ErrNotExist
+ }
+ return f[len(f)-1], nil
+}
+
+func isTerminal(fd uintptr) bool {
+ ctl, err := os.ReadFile(filepath.Join("/fd", fmt.Sprintf("%dctl", fd)))
+ if err != nil {
+ return false
+ }
+ if strings.Contains(string(ctl), "/dev/cons") {
+ return true
+ }
+ return false
+}
+
+func makeRaw(fd uintptr) (*State, error) {
+ t, err := termName(fd)
+ if err != nil {
+ return nil, err
+ }
+ ctl, err := os.OpenFile(t, os.O_RDWR, 0)
+ if err != nil {
+ return nil, err
+ }
+ if _, err := ctl.Write([]byte("rawon")); err != nil {
+ return nil, err
+ }
+ return &State{state: state{termName: t, raw: true, ctl: ctl}}, nil
+}
+
+func getState(fd uintptr) (*State, error) {
+ t, err := termName(fd)
+ if err != nil {
+ return nil, err
+ }
+ ctl, err := os.OpenFile(t, os.O_RDWR, 0)
+ if err != nil {
+ return nil, err
+ }
+ return &State{state: state{termName: t, raw: false, ctl: ctl}}, nil
+
+}
+
+func restore(_ uintptr, state *State) error {
+ if _, err := state.ctl.Write([]byte("rawoff")); err != nil {
+ return err
+ }
+ return nil
+}
+
+// getSize returns the size. This will only work if you are running
+// under a window manager in Plan 9. Else, the only option
+// is to return a reasonable default.
+func getSize(fd uintptr) (int, int, error) {
+ w, h := 80, 40
+ b, err := os.ReadFile("/dev/wctl")
+ if err != nil {
+ return w, h, err
+ }
+ f := strings.Fields(string(b))
+ if len(f) != 4 {
+ return w, h, fmt.Errorf("%q only has %d of 4 needed fields:%w", f, len(f), os.ErrInvalid)
+ }
+ // The contents of wctl, as defined in the driver, are
+ // 4 12-char fields: upper left x, y; and lower-right x, y
+ var ulx, uly, lrx, lry int
+ if n, err := fmt.Sscanf(string(b[:48]), "%d%d%d%d", &ulx, &uly, &lrx, &lry); n != 4 || err != nil {
+ return w, h, fmt.Errorf("scanning %q:%d of 4 items scanned:%w", string(b[:48]), n, err)
+ }
+
+ w, h = lrx-lrx, lry-uly
+ return w, h, nil
+}
+
+func setState(_ uintptr, state *State) error {
+ raw := "rawoff"
+ if state.raw {
+ raw = "rawon"
+ }
+ if _, err := state.ctl.Write([]byte(raw)); err != nil {
+ return err
+ }
+ return nil
+}
+
+func readPassword(fd uintptr) ([]byte, error) {
+ f := os.NewFile(fd, "cons")
+ var b [128]byte
+ n, err := f.Read(b[:])
+ if err != nil {
+ return nil, err
+ }
+ return b[:n], nil
+}
diff --git a/vendor/github.com/charmbracelet/x/term/term_unix.go b/vendor/github.com/charmbracelet/x/term/term_unix.go
new file mode 100644
index 0000000000..77706d48e9
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/term/term_unix.go
@@ -0,0 +1,96 @@
+//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos
+// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris zos
+
+package term
+
+import (
+ "golang.org/x/sys/unix"
+)
+
+type state struct {
+ unix.Termios
+}
+
+func isTerminal(fd uintptr) bool {
+ _, err := unix.IoctlGetTermios(int(fd), ioctlReadTermios)
+ return err == nil
+}
+
+func makeRaw(fd uintptr) (*State, error) {
+ termios, err := unix.IoctlGetTermios(int(fd), ioctlReadTermios)
+ if err != nil {
+ return nil, err //nolint:wrapcheck
+ }
+
+ oldState := State{state{Termios: *termios}}
+
+ // This attempts to replicate the behaviour documented for cfmakeraw in
+ // the termios(3) manpage.
+ termios.Iflag &^= unix.IGNBRK | unix.BRKINT | unix.PARMRK | unix.ISTRIP | unix.INLCR | unix.IGNCR | unix.ICRNL | unix.IXON
+ termios.Oflag &^= unix.OPOST
+ termios.Lflag &^= unix.ECHO | unix.ECHONL | unix.ICANON | unix.ISIG | unix.IEXTEN
+ termios.Cflag &^= unix.CSIZE | unix.PARENB
+ termios.Cflag |= unix.CS8
+ termios.Cc[unix.VMIN] = 1
+ termios.Cc[unix.VTIME] = 0
+ if err := unix.IoctlSetTermios(int(fd), ioctlWriteTermios, termios); err != nil {
+ return nil, err //nolint:wrapcheck
+ }
+
+ return &oldState, nil
+}
+
+func setState(fd uintptr, state *State) error {
+ var termios *unix.Termios
+ if state != nil {
+ termios = &state.Termios
+ }
+ return unix.IoctlSetTermios(int(fd), ioctlWriteTermios, termios) //nolint:wrapcheck
+}
+
+func getState(fd uintptr) (*State, error) {
+ termios, err := unix.IoctlGetTermios(int(fd), ioctlReadTermios)
+ if err != nil {
+ return nil, err //nolint:wrapcheck
+ }
+
+ return &State{state{Termios: *termios}}, nil
+}
+
+func restore(fd uintptr, state *State) error {
+ return unix.IoctlSetTermios(int(fd), ioctlWriteTermios, &state.Termios) //nolint:wrapcheck
+}
+
+func getSize(fd uintptr) (width, height int, err error) {
+ ws, err := unix.IoctlGetWinsize(int(fd), unix.TIOCGWINSZ)
+ if err != nil {
+ return 0, 0, err //nolint:wrapcheck
+ }
+ return int(ws.Col), int(ws.Row), nil
+}
+
+// passwordReader is an io.Reader that reads from a specific file descriptor.
+type passwordReader int
+
+func (r passwordReader) Read(buf []byte) (int, error) {
+ return unix.Read(int(r), buf) //nolint:wrapcheck
+}
+
+func readPassword(fd uintptr) ([]byte, error) {
+ termios, err := unix.IoctlGetTermios(int(fd), ioctlReadTermios)
+ if err != nil {
+ return nil, err //nolint:wrapcheck
+ }
+
+ newState := *termios
+ newState.Lflag &^= unix.ECHO
+ newState.Lflag |= unix.ICANON | unix.ISIG
+ newState.Iflag |= unix.ICRNL
+ if err := unix.IoctlSetTermios(int(fd), ioctlWriteTermios, &newState); err != nil {
+ return nil, err //nolint:wrapcheck
+ }
+
+ defer unix.IoctlSetTermios(int(fd), ioctlWriteTermios, termios) //nolint:errcheck
+
+ return readPasswordLine(passwordReader(fd))
+}
diff --git a/vendor/github.com/charmbracelet/x/term/term_unix_bsd.go b/vendor/github.com/charmbracelet/x/term/term_unix_bsd.go
new file mode 100644
index 0000000000..b435031aa5
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/term/term_unix_bsd.go
@@ -0,0 +1,11 @@
+//go:build darwin || dragonfly || freebsd || netbsd || openbsd
+// +build darwin dragonfly freebsd netbsd openbsd
+
+package term
+
+import "golang.org/x/sys/unix"
+
+const (
+ ioctlReadTermios = unix.TIOCGETA
+ ioctlWriteTermios = unix.TIOCSETA
+)
diff --git a/vendor/github.com/charmbracelet/x/term/term_unix_other.go b/vendor/github.com/charmbracelet/x/term/term_unix_other.go
new file mode 100644
index 0000000000..ee2a29eb19
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/term/term_unix_other.go
@@ -0,0 +1,11 @@
+//go:build aix || linux || solaris || zos
+// +build aix linux solaris zos
+
+package term
+
+import "golang.org/x/sys/unix"
+
+const (
+ ioctlReadTermios = unix.TCGETS
+ ioctlWriteTermios = unix.TCSETS
+)
diff --git a/vendor/github.com/charmbracelet/x/term/term_windows.go b/vendor/github.com/charmbracelet/x/term/term_windows.go
new file mode 100644
index 0000000000..d94f684550
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/term/term_windows.go
@@ -0,0 +1,87 @@
+//go:build windows
+// +build windows
+
+package term
+
+import (
+ "os"
+
+ "golang.org/x/sys/windows"
+)
+
+type state struct {
+ Mode uint32
+}
+
+func isTerminal(fd uintptr) bool {
+ var st uint32
+ err := windows.GetConsoleMode(windows.Handle(fd), &st)
+ return err == nil
+}
+
+func makeRaw(fd uintptr) (*State, error) {
+ var st uint32
+ if err := windows.GetConsoleMode(windows.Handle(fd), &st); err != nil {
+ return nil, err
+ }
+ raw := st &^ (windows.ENABLE_ECHO_INPUT | windows.ENABLE_PROCESSED_INPUT | windows.ENABLE_LINE_INPUT)
+ raw |= windows.ENABLE_VIRTUAL_TERMINAL_INPUT
+ if err := windows.SetConsoleMode(windows.Handle(fd), raw); err != nil {
+ return nil, err
+ }
+ return &State{state{st}}, nil
+}
+
+func setState(fd uintptr, state *State) error {
+ var mode uint32
+ if state != nil {
+ mode = state.Mode
+ }
+ return windows.SetConsoleMode(windows.Handle(fd), mode)
+}
+
+func getState(fd uintptr) (*State, error) {
+ var st uint32
+ if err := windows.GetConsoleMode(windows.Handle(fd), &st); err != nil {
+ return nil, err
+ }
+ return &State{state{st}}, nil
+}
+
+func restore(fd uintptr, state *State) error {
+ return windows.SetConsoleMode(windows.Handle(fd), state.Mode)
+}
+
+func getSize(fd uintptr) (width, height int, err error) {
+ var info windows.ConsoleScreenBufferInfo
+ if err := windows.GetConsoleScreenBufferInfo(windows.Handle(fd), &info); err != nil {
+ return 0, 0, err
+ }
+ return int(info.Window.Right - info.Window.Left + 1), int(info.Window.Bottom - info.Window.Top + 1), nil
+}
+
+func readPassword(fd uintptr) ([]byte, error) {
+ var st uint32
+ if err := windows.GetConsoleMode(windows.Handle(fd), &st); err != nil {
+ return nil, err
+ }
+ old := st
+
+ st &^= (windows.ENABLE_ECHO_INPUT | windows.ENABLE_LINE_INPUT)
+ st |= (windows.ENABLE_PROCESSED_OUTPUT | windows.ENABLE_PROCESSED_INPUT)
+ if err := windows.SetConsoleMode(windows.Handle(fd), st); err != nil {
+ return nil, err
+ }
+
+ defer windows.SetConsoleMode(windows.Handle(fd), old)
+
+ var h windows.Handle
+ p, _ := windows.GetCurrentProcess()
+ if err := windows.DuplicateHandle(p, windows.Handle(fd), p, &h, 0, false, windows.DUPLICATE_SAME_ACCESS); err != nil {
+ return nil, err
+ }
+
+ f := os.NewFile(uintptr(h), "stdin")
+ defer f.Close()
+ return readPasswordLine(f)
+}
diff --git a/vendor/github.com/charmbracelet/x/term/terminal.go b/vendor/github.com/charmbracelet/x/term/terminal.go
new file mode 100644
index 0000000000..8963163f85
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/term/terminal.go
@@ -0,0 +1,12 @@
+package term
+
+import (
+ "io"
+)
+
+// File represents a file that has a file descriptor and can be read from,
+// written to, and closed.
+type File interface {
+ io.ReadWriteCloser
+ Fd() uintptr
+}
diff --git a/vendor/github.com/charmbracelet/x/term/util.go b/vendor/github.com/charmbracelet/x/term/util.go
new file mode 100644
index 0000000000..9c2b628bb8
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/term/util.go
@@ -0,0 +1,47 @@
+package term
+
+import (
+ "io"
+ "runtime"
+)
+
+// readPasswordLine reads from reader until it finds \n or io.EOF.
+// The slice returned does not include the \n.
+// readPasswordLine also ignores any \r it finds.
+// Windows uses \r as end of line. So, on Windows, readPasswordLine
+// reads until it finds \r and ignores any \n it finds during processing.
+func readPasswordLine(reader io.Reader) ([]byte, error) {
+ var buf [1]byte
+ var ret []byte
+
+ for {
+ n, err := reader.Read(buf[:])
+ if n > 0 {
+ switch buf[0] {
+ case '\b':
+ if len(ret) > 0 {
+ ret = ret[:len(ret)-1]
+ }
+ case '\n':
+ if runtime.GOOS != "windows" {
+ return ret, nil
+ }
+ // otherwise ignore \n
+ case '\r':
+ if runtime.GOOS == "windows" {
+ return ret, nil
+ }
+ // otherwise ignore \r
+ default:
+ ret = append(ret, buf[0])
+ }
+ continue
+ }
+ if err != nil {
+ if err == io.EOF && len(ret) > 0 {
+ return ret, nil
+ }
+ return ret, err //nolint:wrapcheck
+ }
+ }
+}
diff --git a/vendor/github.com/charmbracelet/x/termios/LICENSE b/vendor/github.com/charmbracelet/x/termios/LICENSE
new file mode 100644
index 0000000000..65a5654e20
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/termios/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2023 Charmbracelet, Inc.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/vendor/github.com/charmbracelet/x/termios/bit_bsd.go b/vendor/github.com/charmbracelet/x/termios/bit_bsd.go
new file mode 100644
index 0000000000..8dc1eeddfc
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/termios/bit_bsd.go
@@ -0,0 +1,7 @@
+//go:build netbsd || openbsd
+// +build netbsd openbsd
+
+package termios
+
+func speed(b uint32) int32 { return int32(b) }
+func bit(b uint32) uint32 { return b }
diff --git a/vendor/github.com/charmbracelet/x/termios/bit_darwin.go b/vendor/github.com/charmbracelet/x/termios/bit_darwin.go
new file mode 100644
index 0000000000..de5d5c4bb5
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/termios/bit_darwin.go
@@ -0,0 +1,7 @@
+//go:build darwin
+// +build darwin
+
+package termios
+
+func speed(b uint32) uint64 { return uint64(b) }
+func bit(b uint32) uint64 { return uint64(b) }
diff --git a/vendor/github.com/charmbracelet/x/termios/bit_other.go b/vendor/github.com/charmbracelet/x/termios/bit_other.go
new file mode 100644
index 0000000000..afdf58fd9d
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/termios/bit_other.go
@@ -0,0 +1,7 @@
+//go:build !darwin && !netbsd && !openbsd
+// +build !darwin,!netbsd,!openbsd
+
+package termios
+
+func speed(b uint32) uint32 { return b }
+func bit(b uint32) uint32 { return b }
diff --git a/vendor/github.com/charmbracelet/x/termios/syscalls_bsd.go b/vendor/github.com/charmbracelet/x/termios/syscalls_bsd.go
new file mode 100644
index 0000000000..8ee014bd62
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/termios/syscalls_bsd.go
@@ -0,0 +1,11 @@
+//go:build darwin && netbsd && freebsd && netbsd
+// +build darwin,netbsd,freebsd,netbsd
+
+package term
+
+import "syscall"
+
+func init() {
+ allCcOpts[STATUS] = syscall.VSTATUS
+ allCcOpts[DSUSP] = syscall.VDSUSP
+}
diff --git a/vendor/github.com/charmbracelet/x/termios/syscalls_darwin.go b/vendor/github.com/charmbracelet/x/termios/syscalls_darwin.go
new file mode 100644
index 0000000000..560c8a2b0f
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/termios/syscalls_darwin.go
@@ -0,0 +1,10 @@
+//go:build darwin
+// +build darwin
+
+package termios
+
+import "syscall"
+
+func init() {
+ allLineOpts[IUTF8] = syscall.IUTF8
+}
diff --git a/vendor/github.com/charmbracelet/x/termios/syscalls_linux.go b/vendor/github.com/charmbracelet/x/termios/syscalls_linux.go
new file mode 100644
index 0000000000..7aee0ae77c
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/termios/syscalls_linux.go
@@ -0,0 +1,14 @@
+//go:build linux
+// +build linux
+
+package termios
+
+import "syscall"
+
+func init() {
+ allCcOpts[SWTCH] = syscall.VSWTC
+ allInputOpts[IUCLC] = syscall.IUCLC
+ allLineOpts[IUTF8] = syscall.IUTF8
+ allLineOpts[XCASE] = syscall.XCASE
+ allOutputOpts[OLCUC] = syscall.OLCUC
+}
diff --git a/vendor/github.com/charmbracelet/x/termios/termios.go b/vendor/github.com/charmbracelet/x/termios/termios.go
new file mode 100644
index 0000000000..07cdacf22a
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/termios/termios.go
@@ -0,0 +1,249 @@
+//go:build darwin || netbsd || freebsd || openbsd || linux || dragonfly || solaris
+// +build darwin netbsd freebsd openbsd linux dragonfly solaris
+
+package termios
+
+import (
+ "syscall"
+
+ "golang.org/x/sys/unix"
+)
+
+// SetWinsize sets window size for an fd from a Winsize.
+func SetWinsize(fd int, w *unix.Winsize) error {
+ return unix.IoctlSetWinsize(fd, ioctlSetWinSize, w)
+}
+
+// GetWinsize gets window size for an fd.
+func GetWinsize(fd int) (*unix.Winsize, error) {
+ return unix.IoctlGetWinsize(fd, ioctlGetWinSize)
+}
+
+// GetTermios gets the termios of the given fd.
+func GetTermios(fd int) (*unix.Termios, error) {
+ return unix.IoctlGetTermios(fd, ioctlGets)
+}
+
+// SetTermios sets the given termios over the given fd's current termios.
+func SetTermios(
+ fd int,
+ ispeed uint32,
+ ospeed uint32,
+ cc map[CC]uint8,
+ iflag map[I]bool,
+ oflag map[O]bool,
+ cflag map[C]bool,
+ lflag map[L]bool,
+) error {
+ term, err := unix.IoctlGetTermios(fd, ioctlGets)
+ if err != nil {
+ return err
+ }
+ setSpeed(term, ispeed, ospeed)
+
+ for key, value := range cc {
+ call, ok := allCcOpts[key]
+ if !ok {
+ continue
+ }
+ term.Cc[call] = value
+ }
+
+ for key, value := range iflag {
+ mask, ok := allInputOpts[key]
+ if ok {
+ if value {
+ term.Iflag |= bit(mask)
+ } else {
+ term.Iflag &= ^bit(mask)
+ }
+ }
+ }
+ for key, value := range oflag {
+ mask, ok := allOutputOpts[key]
+ if ok {
+ if value {
+ term.Oflag |= bit(mask)
+ } else {
+ term.Oflag &= ^bit(mask)
+ }
+ }
+ }
+ for key, value := range cflag {
+ mask, ok := allControlOpts[key]
+ if ok {
+ if value {
+ term.Cflag |= bit(mask)
+ } else {
+ term.Cflag &= ^bit(mask)
+ }
+ }
+ }
+ for key, value := range lflag {
+ mask, ok := allLineOpts[key]
+ if ok {
+ if value {
+ term.Lflag |= bit(mask)
+ } else {
+ term.Lflag &= ^bit(mask)
+ }
+ }
+ }
+ return unix.IoctlSetTermios(fd, ioctlSets, term)
+}
+
+// CC is the termios cc field.
+//
+// It stores an array of special characters related to terminal I/O.
+type CC uint8
+
+// CC possible values.
+const (
+ INTR CC = iota
+ QUIT
+ ERASE
+ KILL
+ EOF
+ EOL
+ EOL2
+ START
+ STOP
+ SUSP
+ WERASE
+ RPRNT
+ LNEXT
+ DISCARD
+ STATUS
+ SWTCH
+ DSUSP
+ FLUSH
+)
+
+// https://www.man7.org/linux/man-pages/man3/termios.3.html
+var allCcOpts = map[CC]int{
+ INTR: syscall.VINTR,
+ QUIT: syscall.VQUIT,
+ ERASE: syscall.VERASE,
+ KILL: syscall.VQUIT,
+ EOF: syscall.VEOF,
+ EOL: syscall.VEOL,
+ EOL2: syscall.VEOL2,
+ START: syscall.VSTART,
+ STOP: syscall.VSTOP,
+ SUSP: syscall.VSUSP,
+ WERASE: syscall.VWERASE,
+ RPRNT: syscall.VREPRINT,
+ LNEXT: syscall.VLNEXT,
+ DISCARD: syscall.VDISCARD,
+
+ // XXX: these syscalls don't exist for any OS
+ // FLUSH: syscall.VFLUSH,
+}
+
+// Input Controls
+type I uint8
+
+// Input possible values.
+const (
+ IGNPAR I = iota
+ PARMRK
+ INPCK
+ ISTRIP
+ INLCR
+ IGNCR
+ ICRNL
+ IXON
+ IXANY
+ IXOFF
+ IMAXBEL
+ IUCLC
+)
+
+var allInputOpts = map[I]uint32{
+ IGNPAR: syscall.IGNPAR,
+ PARMRK: syscall.PARMRK,
+ INPCK: syscall.INPCK,
+ ISTRIP: syscall.ISTRIP,
+ INLCR: syscall.INLCR,
+ IGNCR: syscall.IGNCR,
+ ICRNL: syscall.ICRNL,
+ IXON: syscall.IXON,
+ IXANY: syscall.IXANY,
+ IXOFF: syscall.IXOFF,
+ IMAXBEL: syscall.IMAXBEL,
+}
+
+// Output Controls
+type O uint8
+
+// Output possible values.
+const (
+ OPOST O = iota
+ ONLCR
+ OCRNL
+ ONOCR
+ ONLRET
+ OLCUC
+)
+
+var allOutputOpts = map[O]uint32{
+ OPOST: syscall.OPOST,
+ ONLCR: syscall.ONLCR,
+ OCRNL: syscall.OCRNL,
+ ONOCR: syscall.ONOCR,
+ ONLRET: syscall.ONLRET,
+}
+
+// Control
+type C uint8
+
+// Control possible values.
+const (
+ CS7 C = iota
+ CS8
+ PARENB
+ PARODD
+)
+
+var allControlOpts = map[C]uint32{
+ CS7: syscall.CS7,
+ CS8: syscall.CS8,
+ PARENB: syscall.PARENB,
+ PARODD: syscall.PARODD,
+}
+
+// Line Controls.
+type L uint8
+
+// Line possible values.
+const (
+ ISIG L = iota
+ ICANON
+ ECHO
+ ECHOE
+ ECHOK
+ ECHONL
+ NOFLSH
+ TOSTOP
+ IEXTEN
+ ECHOCTL
+ ECHOKE
+ PENDIN
+ IUTF8
+ XCASE
+)
+
+var allLineOpts = map[L]uint32{
+ ISIG: syscall.ISIG,
+ ICANON: syscall.ICANON,
+ ECHO: syscall.ECHO,
+ ECHOE: syscall.ECHOE,
+ ECHOK: syscall.ECHOK,
+ ECHONL: syscall.ECHONL,
+ NOFLSH: syscall.NOFLSH,
+ TOSTOP: syscall.TOSTOP,
+ IEXTEN: syscall.IEXTEN,
+ ECHOCTL: syscall.ECHOCTL,
+ ECHOKE: syscall.ECHOKE,
+ PENDIN: syscall.PENDIN,
+}
diff --git a/vendor/github.com/charmbracelet/x/termios/termios_bsd.go b/vendor/github.com/charmbracelet/x/termios/termios_bsd.go
new file mode 100644
index 0000000000..ef62f19754
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/termios/termios_bsd.go
@@ -0,0 +1,13 @@
+//go:build darwin || netbsd || freebsd || openbsd || dragonfly
+// +build darwin netbsd freebsd openbsd dragonfly
+
+package termios
+
+import "golang.org/x/sys/unix"
+
+const (
+ ioctlGets = unix.TIOCGETA
+ ioctlSets = unix.TIOCSETA
+ ioctlGetWinSize = unix.TIOCGWINSZ
+ ioctlSetWinSize = unix.TIOCSWINSZ
+)
diff --git a/vendor/github.com/charmbracelet/x/termios/termios_linux.go b/vendor/github.com/charmbracelet/x/termios/termios_linux.go
new file mode 100644
index 0000000000..c785575882
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/termios/termios_linux.go
@@ -0,0 +1,13 @@
+//go:build linux
+// +build linux
+
+package termios
+
+import "golang.org/x/sys/unix"
+
+const (
+ ioctlGets = unix.TCGETS
+ ioctlSets = unix.TCSETS
+ ioctlGetWinSize = unix.TIOCGWINSZ
+ ioctlSetWinSize = unix.TIOCSWINSZ
+)
diff --git a/vendor/github.com/charmbracelet/x/termios/termios_other.go b/vendor/github.com/charmbracelet/x/termios/termios_other.go
new file mode 100644
index 0000000000..129dfcee9e
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/termios/termios_other.go
@@ -0,0 +1,15 @@
+//go:build darwin || netbsd || freebsd || openbsd || linux || dragonfly
+// +build darwin netbsd freebsd openbsd linux dragonfly
+
+package termios
+
+import "golang.org/x/sys/unix"
+
+func setSpeed(term *unix.Termios, ispeed, ospeed uint32) {
+ term.Ispeed = speed(ispeed)
+ term.Ospeed = speed(ospeed)
+}
+
+func getSpeed(term *unix.Termios) (uint32, uint32) {
+ return uint32(term.Ispeed), uint32(term.Ospeed)
+}
diff --git a/vendor/github.com/charmbracelet/x/termios/termios_solaris.go b/vendor/github.com/charmbracelet/x/termios/termios_solaris.go
new file mode 100644
index 0000000000..129a381908
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/termios/termios_solaris.go
@@ -0,0 +1,26 @@
+//go:build solaris
+// +build solaris
+
+package termios
+
+import "golang.org/x/sys/unix"
+
+// see https://src.illumos.org/source/xref/illumos-gate/usr/src/lib/libc/port/gen/isatty.c
+// see https://github.com/omniti-labs/illumos-omnios/blob/master/usr/src/uts/common/sys/termios.h
+const (
+ ioctlSets = unix.TCSETA
+ ioctlGets = unix.TCGETA
+ ioctlSetWinSize = (int('T') << 8) | 103
+ ioctlGetWinSize = (int('T') << 8) | 104
+)
+
+func setSpeed(*unix.Termios, uint32, uint32) {
+ // TODO: support setting speed on Solaris?
+ // see cfgetospeed(3C) and cfsetospeed(3C)
+ // see cfgetispeed(3C) and cfsetispeed(3C)
+ // https://github.com/omniti-labs/illumos-omnios/blob/master/usr/src/uts/common/sys/termios.h#L103
+}
+
+func getSpeed(*unix.Termios) (uint32, uint32) {
+ return 0, 0
+}
diff --git a/vendor/github.com/charmbracelet/x/windows/LICENSE b/vendor/github.com/charmbracelet/x/windows/LICENSE
new file mode 100644
index 0000000000..65a5654e20
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/windows/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2023 Charmbracelet, Inc.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/vendor/github.com/charmbracelet/x/windows/doc.go b/vendor/github.com/charmbracelet/x/windows/doc.go
new file mode 100644
index 0000000000..e993990845
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/windows/doc.go
@@ -0,0 +1,4 @@
+// Package windows provides Windows-specific system utilities.
+package windows
+
+//go:generate go run golang.org/x/sys/windows/mkwinsyscall -output zsyscall_windows.go syscall_windows.go
diff --git a/vendor/github.com/charmbracelet/x/windows/syscall_windows.go b/vendor/github.com/charmbracelet/x/windows/syscall_windows.go
new file mode 100644
index 0000000000..48c9b307dc
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/windows/syscall_windows.go
@@ -0,0 +1,14 @@
+package windows
+
+import "golang.org/x/sys/windows"
+
+// NewLazySystemDLL is a type alias for windows.NewLazySystemDLL.
+var NewLazySystemDLL = windows.NewLazySystemDLL
+
+// Handle is a type alias for windows.Handle.
+type Handle = windows.Handle
+
+//sys ReadConsoleInput(console Handle, buf *InputRecord, toread uint32, read *uint32) (err error) = kernel32.ReadConsoleInputW
+//sys PeekConsoleInput(console Handle, buf *InputRecord, toread uint32, read *uint32) (err error) = kernel32.PeekConsoleInputW
+//sys GetNumberOfConsoleInputEvents(console Handle, numevents *uint32) (err error) = kernel32.GetNumberOfConsoleInputEvents
+//sys FlushConsoleInputBuffer(console Handle) (err error) = kernel32.FlushConsoleInputBuffer
diff --git a/vendor/github.com/charmbracelet/x/windows/types.go b/vendor/github.com/charmbracelet/x/windows/types.go
new file mode 100644
index 0000000000..0fd93c9497
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/windows/types.go
@@ -0,0 +1,221 @@
+package windows
+
+// Virtual Key codes
+// https://docs.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes
+//
+//nolint:revive
+const (
+ VK_LBUTTON = 0x01
+ VK_RBUTTON = 0x02
+ VK_CANCEL = 0x03
+ VK_MBUTTON = 0x04
+ VK_XBUTTON1 = 0x05
+ VK_XBUTTON2 = 0x06
+ VK_BACK = 0x08
+ VK_TAB = 0x09
+ VK_CLEAR = 0x0C
+ VK_RETURN = 0x0D
+ VK_SHIFT = 0x10
+ VK_CONTROL = 0x11
+ VK_MENU = 0x12
+ VK_PAUSE = 0x13
+ VK_CAPITAL = 0x14
+ VK_KANA = 0x15
+ VK_HANGEUL = 0x15
+ VK_HANGUL = 0x15
+ VK_IME_ON = 0x16
+ VK_JUNJA = 0x17
+ VK_FINAL = 0x18
+ VK_HANJA = 0x19
+ VK_KANJI = 0x19
+ VK_IME_OFF = 0x1A
+ VK_ESCAPE = 0x1B
+ VK_CONVERT = 0x1C
+ VK_NONCONVERT = 0x1D
+ VK_ACCEPT = 0x1E
+ VK_MODECHANGE = 0x1F
+ VK_SPACE = 0x20
+ VK_PRIOR = 0x21
+ VK_NEXT = 0x22
+ VK_END = 0x23
+ VK_HOME = 0x24
+ VK_LEFT = 0x25
+ VK_UP = 0x26
+ VK_RIGHT = 0x27
+ VK_DOWN = 0x28
+ VK_SELECT = 0x29
+ VK_PRINT = 0x2A
+ VK_EXECUTE = 0x2B
+ VK_SNAPSHOT = 0x2C
+ VK_INSERT = 0x2D
+ VK_DELETE = 0x2E
+ VK_HELP = 0x2F
+ VK_LWIN = 0x5B
+ VK_RWIN = 0x5C
+ VK_APPS = 0x5D
+ VK_SLEEP = 0x5F
+ VK_NUMPAD0 = 0x60
+ VK_NUMPAD1 = 0x61
+ VK_NUMPAD2 = 0x62
+ VK_NUMPAD3 = 0x63
+ VK_NUMPAD4 = 0x64
+ VK_NUMPAD5 = 0x65
+ VK_NUMPAD6 = 0x66
+ VK_NUMPAD7 = 0x67
+ VK_NUMPAD8 = 0x68
+ VK_NUMPAD9 = 0x69
+ VK_MULTIPLY = 0x6A
+ VK_ADD = 0x6B
+ VK_SEPARATOR = 0x6C
+ VK_SUBTRACT = 0x6D
+ VK_DECIMAL = 0x6E
+ VK_DIVIDE = 0x6F
+ VK_F1 = 0x70
+ VK_F2 = 0x71
+ VK_F3 = 0x72
+ VK_F4 = 0x73
+ VK_F5 = 0x74
+ VK_F6 = 0x75
+ VK_F7 = 0x76
+ VK_F8 = 0x77
+ VK_F9 = 0x78
+ VK_F10 = 0x79
+ VK_F11 = 0x7A
+ VK_F12 = 0x7B
+ VK_F13 = 0x7C
+ VK_F14 = 0x7D
+ VK_F15 = 0x7E
+ VK_F16 = 0x7F
+ VK_F17 = 0x80
+ VK_F18 = 0x81
+ VK_F19 = 0x82
+ VK_F20 = 0x83
+ VK_F21 = 0x84
+ VK_F22 = 0x85
+ VK_F23 = 0x86
+ VK_F24 = 0x87
+ VK_NUMLOCK = 0x90
+ VK_SCROLL = 0x91
+ VK_OEM_NEC_EQUAL = 0x92
+ VK_OEM_FJ_JISHO = 0x92
+ VK_OEM_FJ_MASSHOU = 0x93
+ VK_OEM_FJ_TOUROKU = 0x94
+ VK_OEM_FJ_LOYA = 0x95
+ VK_OEM_FJ_ROYA = 0x96
+ VK_LSHIFT = 0xA0
+ VK_RSHIFT = 0xA1
+ VK_LCONTROL = 0xA2
+ VK_RCONTROL = 0xA3
+ VK_LMENU = 0xA4
+ VK_RMENU = 0xA5
+ VK_BROWSER_BACK = 0xA6
+ VK_BROWSER_FORWARD = 0xA7
+ VK_BROWSER_REFRESH = 0xA8
+ VK_BROWSER_STOP = 0xA9
+ VK_BROWSER_SEARCH = 0xAA
+ VK_BROWSER_FAVORITES = 0xAB
+ VK_BROWSER_HOME = 0xAC
+ VK_VOLUME_MUTE = 0xAD
+ VK_VOLUME_DOWN = 0xAE
+ VK_VOLUME_UP = 0xAF
+ VK_MEDIA_NEXT_TRACK = 0xB0
+ VK_MEDIA_PREV_TRACK = 0xB1
+ VK_MEDIA_STOP = 0xB2
+ VK_MEDIA_PLAY_PAUSE = 0xB3
+ VK_LAUNCH_MAIL = 0xB4
+ VK_LAUNCH_MEDIA_SELECT = 0xB5
+ VK_LAUNCH_APP1 = 0xB6
+ VK_LAUNCH_APP2 = 0xB7
+ VK_OEM_1 = 0xBA
+ VK_OEM_PLUS = 0xBB
+ VK_OEM_COMMA = 0xBC
+ VK_OEM_MINUS = 0xBD
+ VK_OEM_PERIOD = 0xBE
+ VK_OEM_2 = 0xBF
+ VK_OEM_3 = 0xC0
+ VK_OEM_4 = 0xDB
+ VK_OEM_5 = 0xDC
+ VK_OEM_6 = 0xDD
+ VK_OEM_7 = 0xDE
+ VK_OEM_8 = 0xDF
+ VK_OEM_AX = 0xE1
+ VK_OEM_102 = 0xE2
+ VK_ICO_HELP = 0xE3
+ VK_ICO_00 = 0xE4
+ VK_PROCESSKEY = 0xE5
+ VK_ICO_CLEAR = 0xE6
+ VK_OEM_RESET = 0xE9
+ VK_OEM_JUMP = 0xEA
+ VK_OEM_PA1 = 0xEB
+ VK_OEM_PA2 = 0xEC
+ VK_OEM_PA3 = 0xED
+ VK_OEM_WSCTRL = 0xEE
+ VK_OEM_CUSEL = 0xEF
+ VK_OEM_ATTN = 0xF0
+ VK_OEM_FINISH = 0xF1
+ VK_OEM_COPY = 0xF2
+ VK_OEM_AUTO = 0xF3
+ VK_OEM_ENLW = 0xF4
+ VK_OEM_BACKTAB = 0xF5
+ VK_ATTN = 0xF6
+ VK_CRSEL = 0xF7
+ VK_EXSEL = 0xF8
+ VK_EREOF = 0xF9
+ VK_PLAY = 0xFA
+ VK_ZOOM = 0xFB
+ VK_NONAME = 0xFC
+ VK_PA1 = 0xFD
+ VK_OEM_CLEAR = 0xFE
+)
+
+// Mouse button constants.
+// https://docs.microsoft.com/en-us/windows/console/mouse-event-record-str
+//
+//nolint:revive
+const (
+ FROM_LEFT_1ST_BUTTON_PRESSED = 0x0001
+ RIGHTMOST_BUTTON_PRESSED = 0x0002
+ FROM_LEFT_2ND_BUTTON_PRESSED = 0x0004
+ FROM_LEFT_3RD_BUTTON_PRESSED = 0x0008
+ FROM_LEFT_4TH_BUTTON_PRESSED = 0x0010
+)
+
+// Control key state constraints.
+// https://docs.microsoft.com/en-us/windows/console/key-event-record-str
+// https://docs.microsoft.com/en-us/windows/console/mouse-event-record-str
+//
+//nolint:revive
+const (
+ CAPSLOCK_ON = 0x0080
+ ENHANCED_KEY = 0x0100
+ LEFT_ALT_PRESSED = 0x0002
+ LEFT_CTRL_PRESSED = 0x0008
+ NUMLOCK_ON = 0x0020
+ RIGHT_ALT_PRESSED = 0x0001
+ RIGHT_CTRL_PRESSED = 0x0004
+ SCROLLLOCK_ON = 0x0040
+ SHIFT_PRESSED = 0x0010
+)
+
+// Mouse event record event flags.
+// https://docs.microsoft.com/en-us/windows/console/mouse-event-record-str
+//
+//nolint:revive
+const (
+ MOUSE_MOVED = 0x0001
+ DOUBLE_CLICK = 0x0002
+ MOUSE_WHEELED = 0x0004
+ MOUSE_HWHEELED = 0x0008
+)
+
+// Input Record Event Types
+// https://learn.microsoft.com/en-us/windows/console/input-record-str
+//
+//nolint:revive
+const (
+ FOCUS_EVENT = 0x0010
+ KEY_EVENT = 0x0001
+ MENU_EVENT = 0x0008
+ MOUSE_EVENT = 0x0002
+ WINDOW_BUFFER_SIZE_EVENT = 0x0004
+)
diff --git a/vendor/github.com/charmbracelet/x/windows/types_windows.go b/vendor/github.com/charmbracelet/x/windows/types_windows.go
new file mode 100644
index 0000000000..272eeaab57
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/windows/types_windows.go
@@ -0,0 +1,142 @@
+//nolint:gosec
+package windows
+
+import (
+ "encoding/binary"
+
+ "golang.org/x/sys/windows"
+)
+
+// FocusEventRecord corresponds to the FocusEventRecord structure from the
+// Windows console API.
+// https://docs.microsoft.com/en-us/windows/console/focus-event-record-str
+type FocusEventRecord struct {
+ // SetFocus is reserved and should not be used.
+ SetFocus bool
+}
+
+// KeyEventRecord corresponds to the KeyEventRecord structure from the Windows
+// console API.
+// https://docs.microsoft.com/en-us/windows/console/key-event-record-str
+type KeyEventRecord struct {
+ // KeyDown specified whether the key is pressed or released.
+ KeyDown bool
+
+ // RepeatCount indicates that a key is being held down. For example, when a
+ // key is held down, five events with RepeatCount equal to 1 may be
+ // generated, one event with RepeatCount equal to 5, or multiple events
+ // with RepeatCount greater than or equal to 1.
+ RepeatCount uint16
+
+ // VirtualKeyCode identifies the given key in a device-independent manner
+ // (see
+ // https://docs.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes).
+ VirtualKeyCode uint16
+
+ // VirtualScanCode represents the device-dependent value generated by the
+ // keyboard hardware.
+ VirtualScanCode uint16
+
+ // Char is the character that corresponds to the pressed key. Char can be
+ // zero for some keys.
+ Char rune
+
+ // ControlKeyState holds the state of the control keys.
+ ControlKeyState uint32
+}
+
+// MenuEventRecord corresponds to the MenuEventRecord structure from the
+// Windows console API.
+// https://docs.microsoft.com/en-us/windows/console/menu-event-record-str
+type MenuEventRecord struct {
+ CommandID uint32
+}
+
+// MouseEventRecord corresponds to the MouseEventRecord structure from the
+// Windows console API.
+// https://docs.microsoft.com/en-us/windows/console/mouse-event-record-str
+type MouseEventRecord struct {
+ // MousePosition contains the location of the cursor, in terms of the
+ // console screen buffer's character-cell coordinates.
+ MousePositon windows.Coord
+
+ // ButtonState holds the status of the mouse buttons.
+ ButtonState uint32
+
+ // ControlKeyState holds the state of the control keys.
+ ControlKeyState uint32
+
+ // EventFlags specify the type of mouse event.
+ EventFlags uint32
+}
+
+// WindowBufferSizeRecord corresponds to the WindowBufferSizeRecord structure
+// from the Windows console API.
+// https://docs.microsoft.com/en-us/windows/console/window-buffer-size-record-str
+type WindowBufferSizeRecord struct {
+ // Size contains the size of the console screen buffer, in character cell
+ // columns and rows.
+ Size windows.Coord
+}
+
+// InputRecord corresponds to the INPUT_RECORD structure from the Windows
+// console API.
+//
+// https://docs.microsoft.com/en-us/windows/console/input-record-str
+type InputRecord struct {
+ // EventType specifies the type of event that helt in Event.
+ EventType uint16
+
+ // Padding of the 16-bit EventType to a whole 32-bit dword.
+ _ [2]byte
+
+ // Event holds the actual event data.
+ Event [16]byte
+}
+
+// FocusEvent returns the event as a FOCUS_EVENT_RECORD.
+func (ir InputRecord) FocusEvent() FocusEventRecord {
+ return FocusEventRecord{SetFocus: ir.Event[0] > 0}
+}
+
+// KeyEvent returns the event as a KEY_EVENT_RECORD.
+func (ir InputRecord) KeyEvent() KeyEventRecord {
+ return KeyEventRecord{
+ KeyDown: binary.LittleEndian.Uint32(ir.Event[0:4]) > 0,
+ RepeatCount: binary.LittleEndian.Uint16(ir.Event[4:6]),
+ VirtualKeyCode: binary.LittleEndian.Uint16(ir.Event[6:8]),
+ VirtualScanCode: binary.LittleEndian.Uint16(ir.Event[8:10]),
+ Char: rune(binary.LittleEndian.Uint16(ir.Event[10:12])),
+ ControlKeyState: binary.LittleEndian.Uint32(ir.Event[12:16]),
+ }
+}
+
+// MouseEvent returns the event as a MOUSE_EVENT_RECORD.
+func (ir InputRecord) MouseEvent() MouseEventRecord {
+ return MouseEventRecord{
+ MousePositon: windows.Coord{
+ X: int16(binary.LittleEndian.Uint16(ir.Event[0:2])),
+ Y: int16(binary.LittleEndian.Uint16(ir.Event[2:4])),
+ },
+ ButtonState: binary.LittleEndian.Uint32(ir.Event[4:8]),
+ ControlKeyState: binary.LittleEndian.Uint32(ir.Event[8:12]),
+ EventFlags: binary.LittleEndian.Uint32(ir.Event[12:16]),
+ }
+}
+
+// WindowBufferSizeEvent returns the event as a WINDOW_BUFFER_SIZE_RECORD.
+func (ir InputRecord) WindowBufferSizeEvent() WindowBufferSizeRecord {
+ return WindowBufferSizeRecord{
+ Size: windows.Coord{
+ X: int16(binary.LittleEndian.Uint16(ir.Event[0:2])),
+ Y: int16(binary.LittleEndian.Uint16(ir.Event[2:4])),
+ },
+ }
+}
+
+// MenuEvent returns the event as a MENU_EVENT_RECORD.
+func (ir InputRecord) MenuEvent() MenuEventRecord {
+ return MenuEventRecord{
+ CommandID: binary.LittleEndian.Uint32(ir.Event[0:4]),
+ }
+}
diff --git a/vendor/github.com/charmbracelet/x/windows/zsyscall_windows.go b/vendor/github.com/charmbracelet/x/windows/zsyscall_windows.go
new file mode 100644
index 0000000000..43412b84f9
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/windows/zsyscall_windows.go
@@ -0,0 +1,77 @@
+// Code generated by 'go generate'; DO NOT EDIT.
+
+package windows
+
+import (
+ "syscall"
+ "unsafe"
+)
+
+var _ unsafe.Pointer
+
+// Do the interface allocations only once for common
+// Errno values.
+const (
+ errnoERROR_IO_PENDING = 997
+)
+
+var (
+ errERROR_IO_PENDING error = syscall.Errno(errnoERROR_IO_PENDING)
+ errERROR_EINVAL error = syscall.EINVAL
+)
+
+// errnoErr returns common boxed Errno values, to prevent
+// allocations at runtime.
+func errnoErr(e syscall.Errno) error {
+ switch e {
+ case 0:
+ return errERROR_EINVAL
+ case errnoERROR_IO_PENDING:
+ return errERROR_IO_PENDING
+ }
+ // TODO: add more here, after collecting data on the common
+ // error values see on Windows. (perhaps when running
+ // all.bat?)
+ return e
+}
+
+var (
+ modkernel32 = NewLazySystemDLL("kernel32.dll")
+
+ procFlushConsoleInputBuffer = modkernel32.NewProc("FlushConsoleInputBuffer")
+ procGetNumberOfConsoleInputEvents = modkernel32.NewProc("GetNumberOfConsoleInputEvents")
+ procPeekConsoleInputW = modkernel32.NewProc("PeekConsoleInputW")
+ procReadConsoleInputW = modkernel32.NewProc("ReadConsoleInputW")
+)
+
+func FlushConsoleInputBuffer(console Handle) (err error) {
+ r1, _, e1 := syscall.Syscall(procFlushConsoleInputBuffer.Addr(), 1, uintptr(console), 0, 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func GetNumberOfConsoleInputEvents(console Handle, numevents *uint32) (err error) {
+ r1, _, e1 := syscall.Syscall(procGetNumberOfConsoleInputEvents.Addr(), 2, uintptr(console), uintptr(unsafe.Pointer(numevents)), 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func PeekConsoleInput(console Handle, buf *InputRecord, toread uint32, read *uint32) (err error) {
+ r1, _, e1 := syscall.Syscall6(procPeekConsoleInputW.Addr(), 4, uintptr(console), uintptr(unsafe.Pointer(buf)), uintptr(toread), uintptr(unsafe.Pointer(read)), 0, 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func ReadConsoleInput(console Handle, buf *InputRecord, toread uint32, read *uint32) (err error) {
+ r1, _, e1 := syscall.Syscall6(procReadConsoleInputW.Addr(), 4, uintptr(console), uintptr(unsafe.Pointer(buf)), uintptr(toread), uintptr(unsafe.Pointer(read)), 0, 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
diff --git a/vendor/github.com/chavacava/garif/README.md b/vendor/github.com/chavacava/garif/README.md
deleted file mode 100644
index 6a19c61473..0000000000
--- a/vendor/github.com/chavacava/garif/README.md
+++ /dev/null
@@ -1,52 +0,0 @@
-# garif
-
-A GO package to create and manipulate SARIF logs.
-
-SARIF, from _Static Analysis Results Interchange Format_, is a standard JSON-based format for the output of static analysis tools defined and promoted by [OASIS](https://www.oasis-open.org/).
-
-Current supported version of the standard is [SARIF-v2.1.0](https://docs.oasis-open.org/sarif/sarif/v2.1.0/csprd01/sarif-v2.1.0-csprd01.html
-).
-
-## Usage
-
-The package provides access to every element of the SARIF model, therefore you are free to manipulate it at every detail.
-
-The package also provides constructors functions (`New...`) and decorators methods (`With...`) that simplify the creation of SARIF files for common use cases.
-
-Using these constructors and decorators we can easily create the example SARIF file of the [Microsoft SARIF pages](https://github.com/microsoft/sarif-tutorials/blob/master/docs/1-Introduction.md)
-
-
-```go
-import to `github.com/chavacava/garif`
-
-// ...
-
-rule := garif.NewRule("no-unused-vars").
- WithHelpUri("https://eslint.org/docs/rules/no-unused-vars").
- WithShortDescription("disallow unused variables").
- WithProperties("category", "Variables")
-
-driver := garif.NewDriver("ESLint").
- WithInformationUri("https://eslint.org").
- WithRules(rule)
-
-run := garif.NewRun(NewTool(driver)).
- WithArtifactsURIs("file:///C:/dev/sarif/sarif-tutorials/samples/Introduction/simple-example.js")
-
-run.WithResult(rule.Id, "'x' is assigned a value but never used.", "file:///C:/dev/sarif/sarif-tutorials/samples/Introduction/simple-example.js", 1, 5)
-
-logFile := garif.NewLogFile([]*Run{run}, Version210)
-
-logFile.Write(os.Stdout)
-```
-
-## Why this package?
-This package was initiated during my works on adding to [`revive`](https://github.com/mgechev/revive) a SARIF output formatter.
-I've tried to use [go-sarif](https://github.com/owenrumney/go-sarif) by [Owen Rumney](https://github.com/owenrumney) but it is too focused in the use case of the static analyzer [tfsec](https://tfsec.dev) so I've decided to create a package flexible enough to generate SARIF files in broader cases.
-
-## More information about SARIF
-For more information about SARIF, you can visit the [Oasis Open](https://www.oasis-open.org/committees/tc_home.php?wg_abbrev=sarif) site.
-
-
-## Contributing
-Of course, contributions are welcome!
\ No newline at end of file
diff --git a/vendor/github.com/chavacava/garif/doc.go b/vendor/github.com/chavacava/garif/doc.go
deleted file mode 100644
index 50fa6dfe5b..0000000000
--- a/vendor/github.com/chavacava/garif/doc.go
+++ /dev/null
@@ -1,11 +0,0 @@
-// Package garif defines all the GO structures required to model a SARIF log file.
-// These structures were created using the JSON-schema sarif-schema-2.1.0.json of SARIF logfiles
-// available at https://github.com/oasis-tcs/sarif-spec/tree/master/Schemata.
-//
-// The package provides constructors for all structures (see constructors.go) These constructors
-// ensure that the returned structure instantiation is valid with respect to the JSON schema and
-// should be used in place of plain structure instantiation.
-// The root structure is LogFile.
-//
-// The package provides utility decorators for the most commonly used structures (see decorators.go)
-package garif
diff --git a/vendor/github.com/ckaznocha/intrange/.golangci.yml b/vendor/github.com/ckaznocha/intrange/.golangci.yml
index b240f85ce9..74a80105ca 100644
--- a/vendor/github.com/ckaznocha/intrange/.golangci.yml
+++ b/vendor/github.com/ckaznocha/intrange/.golangci.yml
@@ -15,6 +15,7 @@ linters-settings:
local-prefixes: github.com/ckaznocha/intrange
govet:
enable:
+ - appends
- asmdecl
- assign
- atomic
@@ -22,10 +23,11 @@ linters-settings:
- bools
- buildtag
- cgocall
- - composite
- - copylock
- - copyloopvar
+ - composites
+ - copylocks
- deepequalerrors
+ - defers
+ - directive
- errorsas
- fieldalignment
- findcall
@@ -37,18 +39,25 @@ linters-settings:
- nilfunc
- nilness
- printf
+ - reflectvaluecompare
- shadow
- shift
+ - sigchanyzer
+ - slog
- sortslice
- stdmethods
+ - stdversion
- stringintconv
- structtag
- testinggoroutine
- tests
+ - timeformat
- unmarshal
- unreachable
- unsafeptr
- unusedresult
+ - unusedwrite
+ - waitgroup
misspell:
locale: US
linters:
diff --git a/vendor/github.com/ckaznocha/intrange/go.work b/vendor/github.com/ckaznocha/intrange/go.work
index 3814c99f95..b7e127dcb6 100644
--- a/vendor/github.com/ckaznocha/intrange/go.work
+++ b/vendor/github.com/ckaznocha/intrange/go.work
@@ -1,4 +1,6 @@
-go 1.22
+go 1.23.0
+
+toolchain go1.23.4
use (
.
diff --git a/vendor/github.com/ckaznocha/intrange/intrange.go b/vendor/github.com/ckaznocha/intrange/intrange.go
index 229c847d5a..79aca7973a 100644
--- a/vendor/github.com/ckaznocha/intrange/intrange.go
+++ b/vendor/github.com/ckaznocha/intrange/intrange.go
@@ -265,6 +265,15 @@ func checkForStmt(pass *analysis.Pass, forStmt *ast.ForStmt) {
replacement = fmt.Sprintf("range %s", rangeX)
}
+ if isFunctionOrMethodCall(operand) {
+ pass.Report(analysis.Diagnostic{
+ Pos: forStmt.Pos(),
+ Message: msg + "\nBecause the key is returned by a function or method, take care to consider side effects.",
+ })
+
+ return
+ }
+
pass.Report(analysis.Diagnostic{
Pos: forStmt.Pos(),
Message: msg,
@@ -315,12 +324,11 @@ func checkRangeStmt(pass *analysis.Pass, rangeStmt *ast.RangeStmt) {
return
}
- fn, ok := x.Fun.(*ast.Ident)
- if !ok {
+ if _, ok = x.Fun.(*ast.Ident); !ok {
return
}
- if fn.Name != "len" || len(x.Args) != 1 {
+ if !isLen(x) {
return
}
@@ -385,7 +393,7 @@ func checkRangeStmt(pass *analysis.Pass, rangeStmt *ast.RangeStmt) {
func findNExpr(expr ast.Expr) ast.Expr {
switch e := expr.(type) {
case *ast.CallExpr:
- if fun, ok := e.Fun.(*ast.Ident); ok && fun.Name == "len" && len(e.Args) == 1 {
+ if isLen(e) {
return findNExpr(e.Args[0])
}
@@ -439,6 +447,8 @@ func recursiveOperandToString(
return recursiveOperandToString(e.X, false) + "[" + recursiveOperandToString(e.Index, false) + "]"
case *ast.BinaryExpr:
return recursiveOperandToString(e.X, false) + " " + e.Op.String() + " " + recursiveOperandToString(e.Y, false)
+ case *ast.StarExpr:
+ return "*" + recursiveOperandToString(e.X, false)
default:
return ""
}
@@ -526,19 +536,7 @@ func isNumberLit(exp ast.Expr) bool {
case *ast.CallExpr:
switch fun := lit.Fun.(type) {
case *ast.Ident:
- switch fun.Name {
- case
- "int",
- "int8",
- "int16",
- "int32",
- "int64",
- "uint",
- "uint8",
- "uint16",
- "uint32",
- "uint64":
- default:
+ if !isIntCast(fun) {
return false
}
default:
@@ -573,19 +571,7 @@ func compareNumberLit(exp ast.Expr, val int) bool {
case *ast.CallExpr:
switch fun := lit.Fun.(type) {
case *ast.Ident:
- switch fun.Name {
- case
- "int",
- "int8",
- "int16",
- "int32",
- "int64",
- "uint",
- "uint8",
- "uint16",
- "uint32",
- "uint64":
- default:
+ if !isIntCast(fun) {
return false
}
default:
@@ -623,5 +609,58 @@ func operandToString(
return s
}
+ if operandIdent, ok := operand.(*ast.Ident); ok {
+ if operandType := pass.TypesInfo.TypeOf(operandIdent); operandType != nil &&
+ operandType == t {
+ return s
+ }
+ }
+
return t.String() + "(" + s + ")"
}
+
+func isFunctionOrMethodCall(expr ast.Expr) bool {
+ e, ok := expr.(*ast.CallExpr)
+ if !ok {
+ return false
+ }
+
+ fun, ok := e.Fun.(*ast.Ident)
+ if !ok {
+ return true
+ }
+
+ if isLen(e) || isIntCast(fun) {
+ return false
+ }
+
+ return true
+}
+
+func isIntCast(ident *ast.Ident) bool {
+ switch ident.Name {
+ case
+ "int",
+ "int8",
+ "int16",
+ "int32",
+ "int64",
+ "uint",
+ "uint8",
+ "uint16",
+ "uint32",
+ "uint64":
+ return true
+ default:
+ return false
+ }
+}
+
+func isLen(exp *ast.CallExpr) bool {
+ fun, ok := exp.Fun.(*ast.Ident)
+ if !ok {
+ return false
+ }
+
+ return fun.Name == "len" && len(exp.Args) == 1
+}
diff --git a/vendor/github.com/clipperhouse/displaywidth/.gitignore b/vendor/github.com/clipperhouse/displaywidth/.gitignore
new file mode 100644
index 0000000000..b356d43c6f
--- /dev/null
+++ b/vendor/github.com/clipperhouse/displaywidth/.gitignore
@@ -0,0 +1,3 @@
+.DS_Store
+*.out
+*.test
diff --git a/vendor/github.com/clipperhouse/displaywidth/AGENTS.md b/vendor/github.com/clipperhouse/displaywidth/AGENTS.md
new file mode 100644
index 0000000000..9ae951b25a
--- /dev/null
+++ b/vendor/github.com/clipperhouse/displaywidth/AGENTS.md
@@ -0,0 +1,51 @@
+The goals and overview of this package can be found in the README.md file,
+start by reading that.
+
+The goal of this package is to determine the display (column) width of a
+string, UTF-8 bytes, or runes, as would happen in a monospace font, especially
+in a terminal.
+
+When troubleshooting, write Go unit tests instead of executing debug scripts.
+The tests can return whatever logs or output you need. If those tests are
+only for temporary troubleshooting, clean up the tests after the debugging is
+done.
+
+(Separate executable debugging scripts are messy, tend to have conflicting
+dependencies and are hard to cleanup.)
+
+If you make changes to the trie generation in internal/gen, it can be invoked
+by running `go generate` from the top package directory.
+
+## Pull Requests and branches
+
+For PRs (pull requests), you can use the gh CLI tool. Compare the current branch with main. Reviewing a PR and reviewing a branch are about the same, but the PR may add context.
+
+Understand the goals of the PR. Note any API changes, especially breaking changes.
+
+Look for thoroughness of tests, as well as GoDoc comments.
+
+Retrieve and consider the comments on the PR, which may have come from GitHub Copilot or Cursor BugBot. Think like GitHub Copilot or Cursor BugBot.
+
+Offer to optionally post a brief summary of the review to the PR, via the gh CLI tool.
+
+## Tagged Go releases
+
+If I ask you whether we are ready to release, this means a tagged Go release on the main branch. Go releases are git tagged with a version number.
+
+Review the changes since the last release, i.e. the previous git tag. Ensure that the changes are complete and correct. Identify new features, bug fixes, and performance improvements.
+
+Identify breaking changes, especially API changes.
+
+Ensure good test coverage. Look for performance changes, especially performance regressions, by running benchmarks against the previous release.
+
+Ensure that the documentation in READMEs and GoDocs are complete, correct and consistent.
+
+## Comparisons to go-runewidth
+
+We originally attempted to make this package compatible with go-runewidth.
+However, we found that there were too many differences in the handling of
+certain characters and properties.
+
+We believe, preliminarily, that our choices are more correct and complete,
+by using more complete categories such as Unicode Cf (format) for zero-width
+and Mn (Nonspacing_Mark) for combining marks.
diff --git a/vendor/github.com/clipperhouse/displaywidth/CHANGELOG.md b/vendor/github.com/clipperhouse/displaywidth/CHANGELOG.md
new file mode 100644
index 0000000000..8c6efc10d0
--- /dev/null
+++ b/vendor/github.com/clipperhouse/displaywidth/CHANGELOG.md
@@ -0,0 +1,129 @@
+# Changelog
+
+## [0.11.0]
+
+[Compare](https://github.com/clipperhouse/displaywidth/compare/v0.10.0...v0.11.0)
+
+### Added
+- New `ControlSequences8Bit` option to treat 8-bit ECMA-48 (C1) escape sequences as zero-width. (#22)
+
+### Changed
+- Upgraded uax29 dependency to v2.7.0 for 8-bit escape sequence support in the grapheme iterator.
+- Truncation now validates that preserved trailing escape sequences are zero-width, preventing edge cases where non-zero-width sequences could leak into output.
+
+### Note
+- `ControlSequences8Bit` is deliberately ignored by `TruncateString` and `TruncateBytes`, because C1 byte values (0x80–0x9F) overlap with UTF-8 multi-byte encoding.
+
+## [0.10.0]
+
+[Compare](https://github.com/clipperhouse/displaywidth/compare/v0.9.0...v0.10.0)
+
+### Added
+- New `ControlSequences` option to treat ECMA-48/ANSI escape sequences as zero-width. (#20)
+- `TruncateString` and `TruncateBytes` now preserve trailing ANSI escape sequences (such as SGR resets) when `ControlSequences` is true, preventing color bleed in terminal output.
+
+### Changed
+- Removed `stringish` dependency; generic type constraints are now inline `~string | []byte`.
+- Upgraded uax29 dependency to v2.6.0 for ANSI escape sequence support in the grapheme iterator.
+
+## [0.9.0]
+
+[Compare](https://github.com/clipperhouse/displaywidth/compare/v0.8.0...v0.9.0)
+
+### Changed
+- Unicode 17 support: East Asian Width and emoji data updated to Unicode 17.0.0. (#18)
+- Upgraded uax29 dependency to v2.5.0 (Unicode 17 grapheme segmentation).
+
+## [0.8.0]
+
+[Compare](https://github.com/clipperhouse/displaywidth/compare/v0.7.0...v0.8.0)
+
+### Changed
+- Performance: ASCII fast path that applies to any run of printable
+ ASCII. 2x-10x faster for ASCII text vs v0.7.0. (#16)
+- Upgraded uax29 dependency to v2.4.0 for Unicode 16 support. Text that includes
+ Indic_Conjunct_Break may segment differently (and more correctly). (#15)
+
+## [0.7.0]
+
+[Compare](https://github.com/clipperhouse/displaywidth/compare/v0.6.2...v0.7.0)
+
+### Added
+- New `TruncateString` and `TruncateBytes` methods to truncate strings to a
+ maximum display width, with optional tail (like an ellipsis). (#13)
+
+## [0.6.2]
+
+[Compare](https://github.com/clipperhouse/displaywidth/compare/v0.6.1...v0.6.2)
+
+### Changed
+- Internal: reduced property categories for simpler trie.
+
+## [0.6.1]
+
+[Compare](https://github.com/clipperhouse/displaywidth/compare/v0.6.0...v0.6.1)
+
+### Changed
+- Perf improvements: replaced the ASCII lookup table with a simple
+ function. A bit more cache-friendly. More inlining.
+- Bug fix: single regional indicators are now treated as width 2, since that
+ is what actual terminals do.
+
+## [0.6.0]
+
+[Compare](https://github.com/clipperhouse/displaywidth/compare/v0.5.0...v0.6.0)
+
+### Added
+- New `StringGraphemes` and `BytesGraphemes` methods, for iterating over the
+widths of grapheme clusters.
+
+### Changed
+- Fast ASCII lookups
+
+## [0.5.0]
+
+[Compare](https://github.com/clipperhouse/displaywidth/compare/v0.4.1...v0.5.0)
+
+### Added
+- Unicode 16 support
+- Improved emoji presentation handling per Unicode TR51
+
+### Changed
+- Corrected VS15 (U+FE0E) handling: now preserves base character width (no-op) per Unicode TR51
+- Performance optimizations: reduced property lookups
+
+### Fixed
+- VS15 variation selector now correctly preserves base character width instead of forcing width 1
+
+## [0.4.1]
+
+[Compare](https://github.com/clipperhouse/displaywidth/compare/v0.4.0...v0.4.1)
+
+### Changed
+- Updated uax29 dependency
+- Improved flag handling
+
+## [0.4.0]
+
+[Compare](https://github.com/clipperhouse/displaywidth/compare/v0.3.1...v0.4.0)
+
+### Added
+- Support for variation selectors (VS15, VS16) and regional indicator pairs (flags)
+
+## [0.3.1]
+
+[Compare](https://github.com/clipperhouse/displaywidth/compare/v0.3.0...v0.3.1)
+
+### Added
+- Fuzz testing support
+
+### Changed
+- Updated stringish dependency
+
+## [0.3.0]
+
+[Compare](https://github.com/clipperhouse/displaywidth/compare/v0.2.0...v0.3.0)
+
+### Changed
+- Dropped compatibility with go-runewidth
+- Trie implementation cleanup
diff --git a/vendor/github.com/clipperhouse/displaywidth/LICENSE b/vendor/github.com/clipperhouse/displaywidth/LICENSE
new file mode 100644
index 0000000000..4b8064eb37
--- /dev/null
+++ b/vendor/github.com/clipperhouse/displaywidth/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2025 Matt Sherman
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/vendor/github.com/clipperhouse/displaywidth/README.md b/vendor/github.com/clipperhouse/displaywidth/README.md
new file mode 100644
index 0000000000..506822b023
--- /dev/null
+++ b/vendor/github.com/clipperhouse/displaywidth/README.md
@@ -0,0 +1,190 @@
+# displaywidth
+
+A high-performance Go package for measuring the monospace display width of strings, UTF-8 bytes, and runes.
+
+[](https://pkg.go.dev/github.com/clipperhouse/displaywidth)
+[](https://github.com/clipperhouse/displaywidth/actions/workflows/gotest.yml)
+[](https://github.com/clipperhouse/displaywidth/actions/workflows/gofuzz.yml)
+
+## Install
+```bash
+go get github.com/clipperhouse/displaywidth
+```
+
+## Usage
+
+```go
+package main
+
+import (
+ "fmt"
+ "github.com/clipperhouse/displaywidth"
+)
+
+func main() {
+ width := displaywidth.String("Hello, 世界!")
+ fmt.Println(width)
+
+ width = displaywidth.Bytes([]byte("🌍"))
+ fmt.Println(width)
+
+ width = displaywidth.Rune('🌍')
+ fmt.Println(width)
+}
+```
+
+For most purposes, you should use the `String` or `Bytes` methods. They sum
+the widths of grapheme clusters in the string or byte slice.
+
+> Note: in your application, iterating over runes to measure width is likely incorrect;
+the smallest unit of display is a grapheme, not a rune.
+
+### Iterating over graphemes
+
+If you need the individual graphemes:
+
+```go
+import (
+ "fmt"
+ "github.com/clipperhouse/displaywidth"
+)
+
+func main() {
+ g := displaywidth.StringGraphemes("Hello, 世界!")
+ for g.Next() {
+ width := g.Width()
+ value := g.Value()
+ // do something with the width or value
+ }
+}
+```
+
+### Options
+
+Create the options you need, and then use methods on the options struct.
+
+```go
+var myOptions = displaywidth.Options{
+ EastAsianWidth: true,
+ ControlSequences: true,
+}
+
+width := myOptions.String("Hello, 世界!")
+```
+
+#### ControlSequences
+
+`ControlSequences` specifies whether to ignore ECMA-48 escape sequences
+when calculating the display width. When `false` (default), ANSI escape
+sequences are treated as just a series of characters. When `true`, they are
+treated as a single zero-width unit.
+
+#### ControlSequences8Bit
+
+`ControlSequences8Bit` specifies whether to ignore 8-bit ECMA-48 escape sequences
+when calculating the display width. When `false` (default), these are treated
+as just a series of characters. When `true`, they are treated as a single
+zero-width unit.
+
+Note: this option is ignored by the `Truncate` methods, as the concatenation
+can lead to unintended UTF-8 semantics.
+
+#### EastAsianWidth
+
+`EastAsianWidth` defines how
+[East Asian Ambiguous characters](https://www.unicode.org/reports/tr11/#Ambiguous)
+are treated.
+
+When `false` (default), East Asian Ambiguous characters are treated as width 1.
+When `true`, they are treated as width 2.
+
+You may wish to configure this based on environment variables or locale.
+ `go-runewidth`, for example, does so
+ [during package initialization](https://github.com/mattn/go-runewidth/blob/master/runewidth.go#L26C1-L45C2). `displaywidth` does not do this automatically, we prefer to leave it to you.
+
+
+## Technical standards and compatibility
+
+This package implements the Unicode East Asian Width standard
+([UAX #11](https://www.unicode.org/reports/tr11/tr11-43.html)), and handles
+[version selectors](https://en.wikipedia.org/wiki/Variation_Selectors_(Unicode_block)),
+and [regional indicator pairs](https://en.wikipedia.org/wiki/Regional_indicator_symbol)
+(flags). We implement [Unicode TR51](https://www.unicode.org/reports/tr51/tr51-27.html)
+for emojis. We are keeping an eye on
+[emerging standards](https://www.jeffquast.com/post/state-of-terminal-emulation-2025/).
+
+For control sequences, we implement the [ECMA-48](https://ecma-international.org/publications-and-standards/standards/ecma-48/) standard for 7-bit and 8-bit control sequences.
+
+`clipperhouse/displaywidth`, `mattn/go-runewidth`, and `rivo/uniseg` will
+give the same outputs for most real-world text. Extensive details are in the
+[compatibility analysis](comparison/COMPATIBILITY_ANALYSIS.md).
+
+## Invalid UTF-8
+
+This package does not validate UTF-8. If you pass invalid UTF-8, the results
+are undefined. We fuzz against invalid UTF-8 to ensure we don't panic or
+loop indefinitely.
+
+The `ControlSequences8Bit` option means that we will segment valid 8-bit
+control sequences, which are typically _not_ valid UTF-8. 8-bit control bytes
+happen to also be UTF-8 continuation bytes. Use with caution.
+
+## Prior Art
+
+[mattn/go-runewidth](https://github.com/mattn/go-runewidth)
+
+[rivo/uniseg](https://github.com/rivo/uniseg)
+
+[x/text/width](https://pkg.go.dev/golang.org/x/text/width)
+
+[x/text/internal/triegen](https://pkg.go.dev/golang.org/x/text/internal/triegen)
+
+## Benchmarks
+
+```bash
+cd comparison
+go test -bench=. -benchmem
+```
+
+```
+goos: darwin
+goarch: arm64
+pkg: github.com/clipperhouse/displaywidth/comparison
+cpu: Apple M2
+
+BenchmarkString_Mixed/clipperhouse/displaywidth-8 5784 ns/op 291.69 MB/s 0 B/op 0 allocs/op
+BenchmarkString_Mixed/mattn/go-runewidth-8 14751 ns/op 114.36 MB/s 0 B/op 0 allocs/op
+BenchmarkString_Mixed/rivo/uniseg-8 19360 ns/op 87.14 MB/s 0 B/op 0 allocs/op
+
+BenchmarkString_ASCII/clipperhouse/displaywidth-8 54.60 ns/op 2344.32 MB/s 0 B/op 0 allocs/op
+BenchmarkString_ASCII/mattn/go-runewidth-8 1195 ns/op 107.08 MB/s 0 B/op 0 allocs/op
+BenchmarkString_ASCII/rivo/uniseg-8 1578 ns/op 81.13 MB/s 0 B/op 0 allocs/op
+
+BenchmarkString_EastAsian/clipperhouse/displaywidth-8 5837 ns/op 289.01 MB/s 0 B/op 0 allocs/op
+BenchmarkString_EastAsian/mattn/go-runewidth-8 24418 ns/op 69.09 MB/s 0 B/op 0 allocs/op
+BenchmarkString_EastAsian/rivo/uniseg-8 19339 ns/op 87.23 MB/s 0 B/op 0 allocs/op
+
+BenchmarkString_Emoji/clipperhouse/displaywidth-8 3225 ns/op 224.51 MB/s 0 B/op 0 allocs/op
+BenchmarkString_Emoji/mattn/go-runewidth-8 4851 ns/op 149.25 MB/s 0 B/op 0 allocs/op
+BenchmarkString_Emoji/rivo/uniseg-8 6591 ns/op 109.85 MB/s 0 B/op 0 allocs/op
+
+BenchmarkRune_Mixed/clipperhouse/displaywidth-8 3385 ns/op 498.34 MB/s 0 B/op 0 allocs/op
+BenchmarkRune_Mixed/mattn/go-runewidth-8 5354 ns/op 315.07 MB/s 0 B/op 0 allocs/op
+
+BenchmarkRune_EastAsian/clipperhouse/displaywidth-8 3397 ns/op 496.56 MB/s 0 B/op 0 allocs/op
+BenchmarkRune_EastAsian/mattn/go-runewidth-8 15673 ns/op 107.64 MB/s 0 B/op 0 allocs/op
+
+BenchmarkRune_ASCII/clipperhouse/displaywidth-8 255.7 ns/op 500.53 MB/s 0 B/op 0 allocs/op
+BenchmarkRune_ASCII/mattn/go-runewidth-8 261.5 ns/op 489.55 MB/s 0 B/op 0 allocs/op
+
+BenchmarkRune_Emoji/clipperhouse/displaywidth-8 1371 ns/op 528.22 MB/s 0 B/op 0 allocs/op
+BenchmarkRune_Emoji/mattn/go-runewidth-8 2267 ns/op 319.43 MB/s 0 B/op 0 allocs/op
+
+BenchmarkTruncateWithTail/clipperhouse/displaywidth-8 3229 ns/op 54.82 MB/s 192 B/op 14 allocs/op
+BenchmarkTruncateWithTail/mattn/go-runewidth-8 8408 ns/op 21.05 MB/s 192 B/op 14 allocs/op
+
+BenchmarkTruncateWithoutTail/clipperhouse/displaywidth-8 3554 ns/op 64.43 MB/s 0 B/op 0 allocs/op
+BenchmarkTruncateWithoutTail/mattn/go-runewidth-8 11189 ns/op 20.47 MB/s 0 B/op 0 allocs/op
+```
+
+Here are some notes on [how to make Unicode things fast](https://clipperhouse.com/go-unicode/).
diff --git a/vendor/github.com/clipperhouse/displaywidth/gen.go b/vendor/github.com/clipperhouse/displaywidth/gen.go
new file mode 100644
index 0000000000..52e1085bcd
--- /dev/null
+++ b/vendor/github.com/clipperhouse/displaywidth/gen.go
@@ -0,0 +1,3 @@
+package displaywidth
+
+//go:generate go run -C internal/gen .
diff --git a/vendor/github.com/clipperhouse/displaywidth/graphemes.go b/vendor/github.com/clipperhouse/displaywidth/graphemes.go
new file mode 100644
index 0000000000..14a52788b5
--- /dev/null
+++ b/vendor/github.com/clipperhouse/displaywidth/graphemes.go
@@ -0,0 +1,73 @@
+package displaywidth
+
+import (
+ "github.com/clipperhouse/uax29/v2/graphemes"
+)
+
+// Graphemes is an iterator over grapheme clusters.
+//
+// Iterate using the Next method, and get the width of the current grapheme
+// using the Width method.
+type Graphemes[T ~string | []byte] struct {
+ iter *graphemes.Iterator[T]
+ options Options
+}
+
+// Next advances the iterator to the next grapheme cluster.
+func (g *Graphemes[T]) Next() bool {
+ return g.iter.Next()
+}
+
+// Value returns the current grapheme cluster.
+func (g *Graphemes[T]) Value() T {
+ return g.iter.Value()
+}
+
+// Width returns the display width of the current grapheme cluster.
+func (g *Graphemes[T]) Width() int {
+ return graphemeWidth(g.Value(), g.options)
+}
+
+// StringGraphemes returns an iterator over grapheme clusters for the given
+// string.
+//
+// Iterate using the Next method, and get the width of the current grapheme
+// using the Width method.
+func StringGraphemes(s string) Graphemes[string] {
+ return DefaultOptions.StringGraphemes(s)
+}
+
+// StringGraphemes returns an iterator over grapheme clusters for the given
+// string, with the given options.
+//
+// Iterate using the Next method, and get the width of the current grapheme
+// using the Width method.
+func (options Options) StringGraphemes(s string) Graphemes[string] {
+ g := graphemes.FromString(s)
+ g.AnsiEscapeSequences = options.ControlSequences
+ g.AnsiEscapeSequences8Bit = options.ControlSequences8Bit
+
+ return Graphemes[string]{iter: g, options: options}
+}
+
+// BytesGraphemes returns an iterator over grapheme clusters for the given
+// []byte.
+//
+// Iterate using the Next method, and get the width of the current grapheme
+// using the Width method.
+func BytesGraphemes(s []byte) Graphemes[[]byte] {
+ return DefaultOptions.BytesGraphemes(s)
+}
+
+// BytesGraphemes returns an iterator over grapheme clusters for the given
+// []byte, with the given options.
+//
+// Iterate using the Next method, and get the width of the current grapheme
+// using the Width method.
+func (options Options) BytesGraphemes(s []byte) Graphemes[[]byte] {
+ g := graphemes.FromBytes(s)
+ g.AnsiEscapeSequences = options.ControlSequences
+ g.AnsiEscapeSequences8Bit = options.ControlSequences8Bit
+
+ return Graphemes[[]byte]{iter: g, options: options}
+}
diff --git a/vendor/github.com/clipperhouse/displaywidth/options.go b/vendor/github.com/clipperhouse/displaywidth/options.go
new file mode 100644
index 0000000000..b63b585aa1
--- /dev/null
+++ b/vendor/github.com/clipperhouse/displaywidth/options.go
@@ -0,0 +1,30 @@
+package displaywidth
+
+// Options allows you to specify the treatment of ambiguous East Asian
+// characters and ANSI escape sequences.
+type Options struct {
+ // EastAsianWidth specifies whether to treat ambiguous East Asian characters
+ // as width 1 or 2. When false (default), ambiguous East Asian characters
+ // are treated as width 1. When true, they are width 2.
+ EastAsianWidth bool
+
+ // ControlSequences specifies whether to ignore 7-bit ECMA-48 escape sequences
+ // when calculating the display width. When false (default), ANSI escape
+ // sequences are treated as just a series of characters. When true, they are
+ // treated as a single zero-width unit.
+ ControlSequences bool
+ // ControlSequences8Bit specifies whether to ignore 8-bit ECMA-48 escape sequences
+ // when calculating the display width. When false (default), these are treated
+ // as just a series of characters. When true, they are treated as a single
+ // zero-width unit.
+ ControlSequences8Bit bool
+}
+
+// DefaultOptions is the default options for the display width
+// calculation, which is EastAsianWidth false, ControlSequences false, and
+// ControlSequences8Bit false.
+var DefaultOptions = Options{
+ EastAsianWidth: false,
+ ControlSequences: false,
+ ControlSequences8Bit: false,
+}
diff --git a/vendor/github.com/clipperhouse/displaywidth/trie.go b/vendor/github.com/clipperhouse/displaywidth/trie.go
new file mode 100644
index 0000000000..1d3a983005
--- /dev/null
+++ b/vendor/github.com/clipperhouse/displaywidth/trie.go
@@ -0,0 +1,1699 @@
+// Code generated by internal/gen/main.go. DO NOT EDIT.
+
+package displaywidth
+
+// property is an enum representing the properties of a character
+type property uint8
+
+const (
+ // Always 0 width, includes combining marks, control characters, non-printable, etc
+ _Zero_Width property = iota + 1
+ // Always 2 wide (East Asian Wide F/W, Emoji, Regional Indicator)
+ _Wide
+ // Width depends on EastAsianWidth option
+ _East_Asian_Ambiguous
+)
+
+// lookup returns the trie value for the first UTF-8 encoding in s and
+// the width in bytes of this encoding. The size will be 0 if s does not
+// hold enough bytes to complete the encoding. len(s) must be greater than 0.
+func lookup[T ~string | []byte](s T) (v uint8, sz int) {
+ c0 := s[0]
+ switch {
+ case c0 < 0x80: // is ASCII
+ return stringWidthValues[c0], 1
+ case c0 < 0xC2:
+ return 0, 1 // Illegal UTF-8: not a starter, not ASCII.
+ case c0 < 0xE0: // 2-byte UTF-8
+ if len(s) < 2 {
+ return 0, 0
+ }
+ i := stringWidthIndex[c0]
+ c1 := s[1]
+ if c1 < 0x80 || 0xC0 <= c1 {
+ return 0, 1 // Illegal UTF-8: not a continuation byte.
+ }
+ return lookupValue(uint32(i), c1), 2
+ case c0 < 0xF0: // 3-byte UTF-8
+ if len(s) < 3 {
+ return 0, 0
+ }
+ i := stringWidthIndex[c0]
+ c1 := s[1]
+ if c1 < 0x80 || 0xC0 <= c1 {
+ return 0, 1 // Illegal UTF-8: not a continuation byte.
+ }
+ o := uint32(i)<<6 + uint32(c1)
+ i = stringWidthIndex[o]
+ c2 := s[2]
+ if c2 < 0x80 || 0xC0 <= c2 {
+ return 0, 2 // Illegal UTF-8: not a continuation byte.
+ }
+ return lookupValue(uint32(i), c2), 3
+ case c0 < 0xF8: // 4-byte UTF-8
+ if len(s) < 4 {
+ return 0, 0
+ }
+ i := stringWidthIndex[c0]
+ c1 := s[1]
+ if c1 < 0x80 || 0xC0 <= c1 {
+ return 0, 1 // Illegal UTF-8: not a continuation byte.
+ }
+ o := uint32(i)<<6 + uint32(c1)
+ i = stringWidthIndex[o]
+ c2 := s[2]
+ if c2 < 0x80 || 0xC0 <= c2 {
+ return 0, 2 // Illegal UTF-8: not a continuation byte.
+ }
+ o = uint32(i)<<6 + uint32(c2)
+ i = stringWidthIndex[o]
+ c3 := s[3]
+ if c3 < 0x80 || 0xC0 <= c3 {
+ return 0, 3 // Illegal UTF-8: not a continuation byte.
+ }
+ return lookupValue(uint32(i), c3), 4
+ }
+ // Illegal rune
+ return 0, 1
+}
+
+// stringWidthTrie. Total size: 17664 bytes (17.25 KiB). Checksum: 220983462f26d765.
+// type stringWidthTrie struct { }
+
+// func newStringWidthTrie(i int) *stringWidthTrie {
+// return &stringWidthTrie{}
+// }
+
+// lookupValue determines the type of block n and looks up the value for b.
+func lookupValue(n uint32, b byte) uint8 {
+ switch {
+ default:
+ return uint8(stringWidthValues[n<<6+uint32(b)])
+ }
+}
+
+// stringWidthValues: 246 blocks, 15744 entries, 15744 bytes
+// The third block is the zero block.
+var stringWidthValues = [15744]uint8{
+ // Block 0x0, offset 0x0
+ // Block 0x1, offset 0x40
+ // Block 0x2, offset 0x80
+ // Block 0x3, offset 0xc0
+ 0xc0: 0x0001, 0xc1: 0x0001, 0xc2: 0x0001, 0xc3: 0x0001, 0xc4: 0x0001, 0xc5: 0x0001,
+ 0xc6: 0x0001, 0xc7: 0x0001, 0xc8: 0x0001, 0xc9: 0x0001, 0xca: 0x0001, 0xcb: 0x0001,
+ 0xcc: 0x0001, 0xcd: 0x0001, 0xce: 0x0001, 0xcf: 0x0001, 0xd0: 0x0001, 0xd1: 0x0001,
+ 0xd2: 0x0001, 0xd3: 0x0001, 0xd4: 0x0001, 0xd5: 0x0001, 0xd6: 0x0001, 0xd7: 0x0001,
+ 0xd8: 0x0001, 0xd9: 0x0001, 0xda: 0x0001, 0xdb: 0x0001, 0xdc: 0x0001, 0xdd: 0x0001,
+ 0xde: 0x0001, 0xdf: 0x0001, 0xe1: 0x0003,
+ 0xe4: 0x0003, 0xe7: 0x0003, 0xe8: 0x0003,
+ 0xea: 0x0003, 0xed: 0x0001, 0xee: 0x0003,
+ 0xf0: 0x0003, 0xf1: 0x0003, 0xf2: 0x0003, 0xf3: 0x0003, 0xf4: 0x0003,
+ 0xf6: 0x0003, 0xf7: 0x0003, 0xf8: 0x0003, 0xf9: 0x0003, 0xfa: 0x0003,
+ 0xfc: 0x0003, 0xfd: 0x0003, 0xfe: 0x0003, 0xff: 0x0003,
+ // Block 0x4, offset 0x100
+ 0x106: 0x0003,
+ 0x110: 0x0003,
+ 0x117: 0x0003,
+ 0x118: 0x0003,
+ 0x11e: 0x0003, 0x11f: 0x0003, 0x120: 0x0003, 0x121: 0x0003,
+ 0x126: 0x0003, 0x128: 0x0003, 0x129: 0x0003,
+ 0x12a: 0x0003, 0x12c: 0x0003, 0x12d: 0x0003,
+ 0x130: 0x0003, 0x132: 0x0003, 0x133: 0x0003,
+ 0x137: 0x0003, 0x138: 0x0003, 0x139: 0x0003, 0x13a: 0x0003,
+ 0x13c: 0x0003, 0x13e: 0x0003,
+ // Block 0x5, offset 0x140
+ 0x141: 0x0003,
+ 0x151: 0x0003,
+ 0x153: 0x0003,
+ 0x15b: 0x0003,
+ 0x166: 0x0003, 0x167: 0x0003,
+ 0x16b: 0x0003,
+ 0x171: 0x0003, 0x172: 0x0003, 0x173: 0x0003,
+ 0x178: 0x0003,
+ 0x17f: 0x0003,
+ // Block 0x6, offset 0x180
+ 0x180: 0x0003, 0x181: 0x0003, 0x182: 0x0003, 0x184: 0x0003,
+ 0x188: 0x0003, 0x189: 0x0003, 0x18a: 0x0003, 0x18b: 0x0003,
+ 0x18d: 0x0003,
+ 0x192: 0x0003, 0x193: 0x0003,
+ 0x1a6: 0x0003, 0x1a7: 0x0003,
+ 0x1ab: 0x0003,
+ // Block 0x7, offset 0x1c0
+ 0x1ce: 0x0003, 0x1d0: 0x0003,
+ 0x1d2: 0x0003, 0x1d4: 0x0003, 0x1d6: 0x0003,
+ 0x1d8: 0x0003, 0x1da: 0x0003, 0x1dc: 0x0003,
+ // Block 0x8, offset 0x200
+ 0x211: 0x0003,
+ 0x221: 0x0003,
+ // Block 0x9, offset 0x240
+ 0x244: 0x0003,
+ 0x247: 0x0003, 0x249: 0x0003, 0x24a: 0x0003, 0x24b: 0x0003,
+ 0x24d: 0x0003, 0x250: 0x0003,
+ 0x258: 0x0003, 0x259: 0x0003, 0x25a: 0x0003, 0x25b: 0x0003, 0x25d: 0x0003,
+ 0x25f: 0x0003,
+ // Block 0xa, offset 0x280
+ 0x280: 0x0001, 0x281: 0x0001, 0x282: 0x0001, 0x283: 0x0001, 0x284: 0x0001, 0x285: 0x0001,
+ 0x286: 0x0001, 0x287: 0x0001, 0x288: 0x0001, 0x289: 0x0001, 0x28a: 0x0001, 0x28b: 0x0001,
+ 0x28c: 0x0001, 0x28d: 0x0001, 0x28e: 0x0001, 0x28f: 0x0001, 0x290: 0x0001, 0x291: 0x0001,
+ 0x292: 0x0001, 0x293: 0x0001, 0x294: 0x0001, 0x295: 0x0001, 0x296: 0x0001, 0x297: 0x0001,
+ 0x298: 0x0001, 0x299: 0x0001, 0x29a: 0x0001, 0x29b: 0x0001, 0x29c: 0x0001, 0x29d: 0x0001,
+ 0x29e: 0x0001, 0x29f: 0x0001, 0x2a0: 0x0001, 0x2a1: 0x0001, 0x2a2: 0x0001, 0x2a3: 0x0001,
+ 0x2a4: 0x0001, 0x2a5: 0x0001, 0x2a6: 0x0001, 0x2a7: 0x0001, 0x2a8: 0x0001, 0x2a9: 0x0001,
+ 0x2aa: 0x0001, 0x2ab: 0x0001, 0x2ac: 0x0001, 0x2ad: 0x0001, 0x2ae: 0x0001, 0x2af: 0x0001,
+ 0x2b0: 0x0001, 0x2b1: 0x0001, 0x2b2: 0x0001, 0x2b3: 0x0001, 0x2b4: 0x0001, 0x2b5: 0x0001,
+ 0x2b6: 0x0001, 0x2b7: 0x0001, 0x2b8: 0x0001, 0x2b9: 0x0001, 0x2ba: 0x0001, 0x2bb: 0x0001,
+ 0x2bc: 0x0001, 0x2bd: 0x0001, 0x2be: 0x0001, 0x2bf: 0x0001,
+ // Block 0xb, offset 0x2c0
+ 0x2c0: 0x0001, 0x2c1: 0x0001, 0x2c2: 0x0001, 0x2c3: 0x0001, 0x2c4: 0x0001, 0x2c5: 0x0001,
+ 0x2c6: 0x0001, 0x2c7: 0x0001, 0x2c8: 0x0001, 0x2c9: 0x0001, 0x2ca: 0x0001, 0x2cb: 0x0001,
+ 0x2cc: 0x0001, 0x2cd: 0x0001, 0x2ce: 0x0001, 0x2cf: 0x0001, 0x2d0: 0x0001, 0x2d1: 0x0001,
+ 0x2d2: 0x0001, 0x2d3: 0x0001, 0x2d4: 0x0001, 0x2d5: 0x0001, 0x2d6: 0x0001, 0x2d7: 0x0001,
+ 0x2d8: 0x0001, 0x2d9: 0x0001, 0x2da: 0x0001, 0x2db: 0x0001, 0x2dc: 0x0001, 0x2dd: 0x0001,
+ 0x2de: 0x0001, 0x2df: 0x0001, 0x2e0: 0x0001, 0x2e1: 0x0001, 0x2e2: 0x0001, 0x2e3: 0x0001,
+ 0x2e4: 0x0001, 0x2e5: 0x0001, 0x2e6: 0x0001, 0x2e7: 0x0001, 0x2e8: 0x0001, 0x2e9: 0x0001,
+ 0x2ea: 0x0001, 0x2eb: 0x0001, 0x2ec: 0x0001, 0x2ed: 0x0001, 0x2ee: 0x0001, 0x2ef: 0x0001,
+ // Block 0xc, offset 0x300
+ 0x311: 0x0003,
+ 0x312: 0x0003, 0x313: 0x0003, 0x314: 0x0003, 0x315: 0x0003, 0x316: 0x0003, 0x317: 0x0003,
+ 0x318: 0x0003, 0x319: 0x0003, 0x31a: 0x0003, 0x31b: 0x0003, 0x31c: 0x0003, 0x31d: 0x0003,
+ 0x31e: 0x0003, 0x31f: 0x0003, 0x320: 0x0003, 0x321: 0x0003, 0x323: 0x0003,
+ 0x324: 0x0003, 0x325: 0x0003, 0x326: 0x0003, 0x327: 0x0003, 0x328: 0x0003, 0x329: 0x0003,
+ 0x331: 0x0003, 0x332: 0x0003, 0x333: 0x0003, 0x334: 0x0003, 0x335: 0x0003,
+ 0x336: 0x0003, 0x337: 0x0003, 0x338: 0x0003, 0x339: 0x0003, 0x33a: 0x0003, 0x33b: 0x0003,
+ 0x33c: 0x0003, 0x33d: 0x0003, 0x33e: 0x0003, 0x33f: 0x0003,
+ // Block 0xd, offset 0x340
+ 0x340: 0x0003, 0x341: 0x0003, 0x343: 0x0003, 0x344: 0x0003, 0x345: 0x0003,
+ 0x346: 0x0003, 0x347: 0x0003, 0x348: 0x0003, 0x349: 0x0003,
+ // Block 0xe, offset 0x380
+ 0x381: 0x0003,
+ 0x390: 0x0003, 0x391: 0x0003,
+ 0x392: 0x0003, 0x393: 0x0003, 0x394: 0x0003, 0x395: 0x0003, 0x396: 0x0003, 0x397: 0x0003,
+ 0x398: 0x0003, 0x399: 0x0003, 0x39a: 0x0003, 0x39b: 0x0003, 0x39c: 0x0003, 0x39d: 0x0003,
+ 0x39e: 0x0003, 0x39f: 0x0003, 0x3a0: 0x0003, 0x3a1: 0x0003, 0x3a2: 0x0003, 0x3a3: 0x0003,
+ 0x3a4: 0x0003, 0x3a5: 0x0003, 0x3a6: 0x0003, 0x3a7: 0x0003, 0x3a8: 0x0003, 0x3a9: 0x0003,
+ 0x3aa: 0x0003, 0x3ab: 0x0003, 0x3ac: 0x0003, 0x3ad: 0x0003, 0x3ae: 0x0003, 0x3af: 0x0003,
+ 0x3b0: 0x0003, 0x3b1: 0x0003, 0x3b2: 0x0003, 0x3b3: 0x0003, 0x3b4: 0x0003, 0x3b5: 0x0003,
+ 0x3b6: 0x0003, 0x3b7: 0x0003, 0x3b8: 0x0003, 0x3b9: 0x0003, 0x3ba: 0x0003, 0x3bb: 0x0003,
+ 0x3bc: 0x0003, 0x3bd: 0x0003, 0x3be: 0x0003, 0x3bf: 0x0003,
+ // Block 0xf, offset 0x3c0
+ 0x3c0: 0x0003, 0x3c1: 0x0003, 0x3c2: 0x0003, 0x3c3: 0x0003, 0x3c4: 0x0003, 0x3c5: 0x0003,
+ 0x3c6: 0x0003, 0x3c7: 0x0003, 0x3c8: 0x0003, 0x3c9: 0x0003, 0x3ca: 0x0003, 0x3cb: 0x0003,
+ 0x3cc: 0x0003, 0x3cd: 0x0003, 0x3ce: 0x0003, 0x3cf: 0x0003, 0x3d1: 0x0003,
+ // Block 0x10, offset 0x400
+ 0x403: 0x0001, 0x404: 0x0001, 0x405: 0x0001,
+ 0x406: 0x0001, 0x407: 0x0001, 0x408: 0x0001, 0x409: 0x0001,
+ // Block 0x11, offset 0x440
+ 0x451: 0x0001,
+ 0x452: 0x0001, 0x453: 0x0001, 0x454: 0x0001, 0x455: 0x0001, 0x456: 0x0001, 0x457: 0x0001,
+ 0x458: 0x0001, 0x459: 0x0001, 0x45a: 0x0001, 0x45b: 0x0001, 0x45c: 0x0001, 0x45d: 0x0001,
+ 0x45e: 0x0001, 0x45f: 0x0001, 0x460: 0x0001, 0x461: 0x0001, 0x462: 0x0001, 0x463: 0x0001,
+ 0x464: 0x0001, 0x465: 0x0001, 0x466: 0x0001, 0x467: 0x0001, 0x468: 0x0001, 0x469: 0x0001,
+ 0x46a: 0x0001, 0x46b: 0x0001, 0x46c: 0x0001, 0x46d: 0x0001, 0x46e: 0x0001, 0x46f: 0x0001,
+ 0x470: 0x0001, 0x471: 0x0001, 0x472: 0x0001, 0x473: 0x0001, 0x474: 0x0001, 0x475: 0x0001,
+ 0x476: 0x0001, 0x477: 0x0001, 0x478: 0x0001, 0x479: 0x0001, 0x47a: 0x0001, 0x47b: 0x0001,
+ 0x47c: 0x0001, 0x47d: 0x0001, 0x47f: 0x0001,
+ // Block 0x12, offset 0x480
+ 0x481: 0x0001, 0x482: 0x0001, 0x484: 0x0001, 0x485: 0x0001,
+ 0x487: 0x0001,
+ // Block 0x13, offset 0x4c0
+ 0x4c0: 0x0001, 0x4c1: 0x0001, 0x4c2: 0x0001, 0x4c3: 0x0001, 0x4c4: 0x0001, 0x4c5: 0x0001,
+ 0x4d0: 0x0001, 0x4d1: 0x0001,
+ 0x4d2: 0x0001, 0x4d3: 0x0001, 0x4d4: 0x0001, 0x4d5: 0x0001, 0x4d6: 0x0001, 0x4d7: 0x0001,
+ 0x4d8: 0x0001, 0x4d9: 0x0001, 0x4da: 0x0001, 0x4dc: 0x0001,
+ // Block 0x14, offset 0x500
+ 0x50b: 0x0001,
+ 0x50c: 0x0001, 0x50d: 0x0001, 0x50e: 0x0001, 0x50f: 0x0001, 0x510: 0x0001, 0x511: 0x0001,
+ 0x512: 0x0001, 0x513: 0x0001, 0x514: 0x0001, 0x515: 0x0001, 0x516: 0x0001, 0x517: 0x0001,
+ 0x518: 0x0001, 0x519: 0x0001, 0x51a: 0x0001, 0x51b: 0x0001, 0x51c: 0x0001, 0x51d: 0x0001,
+ 0x51e: 0x0001, 0x51f: 0x0001,
+ 0x530: 0x0001,
+ // Block 0x15, offset 0x540
+ 0x556: 0x0001, 0x557: 0x0001,
+ 0x558: 0x0001, 0x559: 0x0001, 0x55a: 0x0001, 0x55b: 0x0001, 0x55c: 0x0001, 0x55d: 0x0001,
+ 0x55f: 0x0001, 0x560: 0x0001, 0x561: 0x0001, 0x562: 0x0001, 0x563: 0x0001,
+ 0x564: 0x0001, 0x567: 0x0001, 0x568: 0x0001,
+ 0x56a: 0x0001, 0x56b: 0x0001, 0x56c: 0x0001, 0x56d: 0x0001,
+ // Block 0x16, offset 0x580
+ 0x58f: 0x0001, 0x591: 0x0001,
+ 0x5b0: 0x0001, 0x5b1: 0x0001, 0x5b2: 0x0001, 0x5b3: 0x0001, 0x5b4: 0x0001, 0x5b5: 0x0001,
+ 0x5b6: 0x0001, 0x5b7: 0x0001, 0x5b8: 0x0001, 0x5b9: 0x0001, 0x5ba: 0x0001, 0x5bb: 0x0001,
+ 0x5bc: 0x0001, 0x5bd: 0x0001, 0x5be: 0x0001, 0x5bf: 0x0001,
+ // Block 0x17, offset 0x5c0
+ 0x5c0: 0x0001, 0x5c1: 0x0001, 0x5c2: 0x0001, 0x5c3: 0x0001, 0x5c4: 0x0001, 0x5c5: 0x0001,
+ 0x5c6: 0x0001, 0x5c7: 0x0001, 0x5c8: 0x0001, 0x5c9: 0x0001, 0x5ca: 0x0001,
+ // Block 0x18, offset 0x600
+ 0x626: 0x0001, 0x627: 0x0001, 0x628: 0x0001, 0x629: 0x0001,
+ 0x62a: 0x0001, 0x62b: 0x0001, 0x62c: 0x0001, 0x62d: 0x0001, 0x62e: 0x0001, 0x62f: 0x0001,
+ 0x630: 0x0001,
+ // Block 0x19, offset 0x640
+ 0x66b: 0x0001, 0x66c: 0x0001, 0x66d: 0x0001, 0x66e: 0x0001, 0x66f: 0x0001,
+ 0x670: 0x0001, 0x671: 0x0001, 0x672: 0x0001, 0x673: 0x0001,
+ 0x67d: 0x0001,
+ // Block 0x1a, offset 0x680
+ 0x696: 0x0001, 0x697: 0x0001,
+ 0x698: 0x0001, 0x699: 0x0001, 0x69b: 0x0001, 0x69c: 0x0001, 0x69d: 0x0001,
+ 0x69e: 0x0001, 0x69f: 0x0001, 0x6a0: 0x0001, 0x6a1: 0x0001, 0x6a2: 0x0001, 0x6a3: 0x0001,
+ 0x6a5: 0x0001, 0x6a6: 0x0001, 0x6a7: 0x0001, 0x6a9: 0x0001,
+ 0x6aa: 0x0001, 0x6ab: 0x0001, 0x6ac: 0x0001, 0x6ad: 0x0001,
+ // Block 0x1b, offset 0x6c0
+ 0x6d9: 0x0001, 0x6da: 0x0001, 0x6db: 0x0001,
+ // Block 0x1c, offset 0x700
+ 0x710: 0x0001, 0x711: 0x0001,
+ 0x718: 0x0001, 0x719: 0x0001, 0x71a: 0x0001, 0x71b: 0x0001, 0x71c: 0x0001, 0x71d: 0x0001,
+ 0x71e: 0x0001, 0x71f: 0x0001,
+ // Block 0x1d, offset 0x740
+ 0x74a: 0x0001, 0x74b: 0x0001,
+ 0x74c: 0x0001, 0x74d: 0x0001, 0x74e: 0x0001, 0x74f: 0x0001, 0x750: 0x0001, 0x751: 0x0001,
+ 0x752: 0x0001, 0x753: 0x0001, 0x754: 0x0001, 0x755: 0x0001, 0x756: 0x0001, 0x757: 0x0001,
+ 0x758: 0x0001, 0x759: 0x0001, 0x75a: 0x0001, 0x75b: 0x0001, 0x75c: 0x0001, 0x75d: 0x0001,
+ 0x75e: 0x0001, 0x75f: 0x0001, 0x760: 0x0001, 0x761: 0x0001, 0x762: 0x0001, 0x763: 0x0001,
+ 0x764: 0x0001, 0x765: 0x0001, 0x766: 0x0001, 0x767: 0x0001, 0x768: 0x0001, 0x769: 0x0001,
+ 0x76a: 0x0001, 0x76b: 0x0001, 0x76c: 0x0001, 0x76d: 0x0001, 0x76e: 0x0001, 0x76f: 0x0001,
+ 0x770: 0x0001, 0x771: 0x0001, 0x772: 0x0001, 0x773: 0x0001, 0x774: 0x0001, 0x775: 0x0001,
+ 0x776: 0x0001, 0x777: 0x0001, 0x778: 0x0001, 0x779: 0x0001, 0x77a: 0x0001, 0x77b: 0x0001,
+ 0x77c: 0x0001, 0x77d: 0x0001, 0x77e: 0x0001, 0x77f: 0x0001,
+ // Block 0x1e, offset 0x780
+ 0x780: 0x0001, 0x781: 0x0001, 0x782: 0x0001,
+ 0x7ba: 0x0001,
+ 0x7bc: 0x0001,
+ // Block 0x1f, offset 0x7c0
+ 0x7c1: 0x0001, 0x7c2: 0x0001, 0x7c3: 0x0001, 0x7c4: 0x0001, 0x7c5: 0x0001,
+ 0x7c6: 0x0001, 0x7c7: 0x0001, 0x7c8: 0x0001,
+ 0x7cd: 0x0001, 0x7d1: 0x0001,
+ 0x7d2: 0x0001, 0x7d3: 0x0001, 0x7d4: 0x0001, 0x7d5: 0x0001, 0x7d6: 0x0001, 0x7d7: 0x0001,
+ 0x7e2: 0x0001, 0x7e3: 0x0001,
+ // Block 0x20, offset 0x800
+ 0x801: 0x0001,
+ 0x83c: 0x0001,
+ // Block 0x21, offset 0x840
+ 0x841: 0x0001, 0x842: 0x0001, 0x843: 0x0001, 0x844: 0x0001,
+ 0x84d: 0x0001,
+ 0x862: 0x0001, 0x863: 0x0001,
+ 0x87e: 0x0001,
+ // Block 0x22, offset 0x880
+ 0x881: 0x0001, 0x882: 0x0001,
+ 0x8bc: 0x0001,
+ // Block 0x23, offset 0x8c0
+ 0x8c1: 0x0001, 0x8c2: 0x0001,
+ 0x8c7: 0x0001, 0x8c8: 0x0001, 0x8cb: 0x0001,
+ 0x8cc: 0x0001, 0x8cd: 0x0001, 0x8d1: 0x0001,
+ 0x8f0: 0x0001, 0x8f1: 0x0001, 0x8f5: 0x0001,
+ // Block 0x24, offset 0x900
+ 0x901: 0x0001, 0x902: 0x0001, 0x903: 0x0001, 0x904: 0x0001, 0x905: 0x0001,
+ 0x907: 0x0001, 0x908: 0x0001,
+ 0x90d: 0x0001,
+ 0x922: 0x0001, 0x923: 0x0001,
+ 0x93a: 0x0001, 0x93b: 0x0001,
+ 0x93c: 0x0001, 0x93d: 0x0001, 0x93e: 0x0001, 0x93f: 0x0001,
+ // Block 0x25, offset 0x940
+ 0x941: 0x0001,
+ 0x97c: 0x0001, 0x97f: 0x0001,
+ // Block 0x26, offset 0x980
+ 0x981: 0x0001, 0x982: 0x0001, 0x983: 0x0001, 0x984: 0x0001,
+ 0x98d: 0x0001,
+ 0x995: 0x0001, 0x996: 0x0001,
+ 0x9a2: 0x0001, 0x9a3: 0x0001,
+ // Block 0x27, offset 0x9c0
+ 0x9c2: 0x0001,
+ // Block 0x28, offset 0xa00
+ 0xa00: 0x0001,
+ 0xa0d: 0x0001,
+ // Block 0x29, offset 0xa40
+ 0xa40: 0x0001, 0xa44: 0x0001,
+ 0xa7c: 0x0001, 0xa7e: 0x0001, 0xa7f: 0x0001,
+ // Block 0x2a, offset 0xa80
+ 0xa80: 0x0001,
+ 0xa86: 0x0001, 0xa87: 0x0001, 0xa88: 0x0001, 0xa8a: 0x0001, 0xa8b: 0x0001,
+ 0xa8c: 0x0001, 0xa8d: 0x0001,
+ 0xa95: 0x0001, 0xa96: 0x0001,
+ 0xaa2: 0x0001, 0xaa3: 0x0001,
+ // Block 0x2b, offset 0xac0
+ 0xac6: 0x0001,
+ 0xacc: 0x0001, 0xacd: 0x0001,
+ 0xae2: 0x0001, 0xae3: 0x0001,
+ // Block 0x2c, offset 0xb00
+ 0xb00: 0x0001, 0xb01: 0x0001,
+ 0xb3b: 0x0001,
+ 0xb3c: 0x0001,
+ // Block 0x2d, offset 0xb40
+ 0xb41: 0x0001, 0xb42: 0x0001, 0xb43: 0x0001, 0xb44: 0x0001,
+ 0xb4d: 0x0001,
+ 0xb62: 0x0001, 0xb63: 0x0001,
+ // Block 0x2e, offset 0xb80
+ 0xb81: 0x0001,
+ // Block 0x2f, offset 0xbc0
+ 0xbca: 0x0001,
+ 0xbd2: 0x0001, 0xbd3: 0x0001, 0xbd4: 0x0001, 0xbd6: 0x0001,
+ // Block 0x30, offset 0xc00
+ 0xc31: 0x0001, 0xc34: 0x0001, 0xc35: 0x0001,
+ 0xc36: 0x0001, 0xc37: 0x0001, 0xc38: 0x0001, 0xc39: 0x0001, 0xc3a: 0x0001,
+ // Block 0x31, offset 0xc40
+ 0xc47: 0x0001, 0xc48: 0x0001, 0xc49: 0x0001, 0xc4a: 0x0001, 0xc4b: 0x0001,
+ 0xc4c: 0x0001, 0xc4d: 0x0001, 0xc4e: 0x0001,
+ // Block 0x32, offset 0xc80
+ 0xcb1: 0x0001, 0xcb4: 0x0001, 0xcb5: 0x0001,
+ 0xcb6: 0x0001, 0xcb7: 0x0001, 0xcb8: 0x0001, 0xcb9: 0x0001, 0xcba: 0x0001, 0xcbb: 0x0001,
+ 0xcbc: 0x0001,
+ // Block 0x33, offset 0xcc0
+ 0xcc8: 0x0001, 0xcc9: 0x0001, 0xcca: 0x0001, 0xccb: 0x0001,
+ 0xccc: 0x0001, 0xccd: 0x0001, 0xcce: 0x0001,
+ // Block 0x34, offset 0xd00
+ 0xd18: 0x0001, 0xd19: 0x0001,
+ 0xd35: 0x0001,
+ 0xd37: 0x0001, 0xd39: 0x0001,
+ // Block 0x35, offset 0xd40
+ 0xd71: 0x0001, 0xd72: 0x0001, 0xd73: 0x0001, 0xd74: 0x0001, 0xd75: 0x0001,
+ 0xd76: 0x0001, 0xd77: 0x0001, 0xd78: 0x0001, 0xd79: 0x0001, 0xd7a: 0x0001, 0xd7b: 0x0001,
+ 0xd7c: 0x0001, 0xd7d: 0x0001, 0xd7e: 0x0001,
+ // Block 0x36, offset 0xd80
+ 0xd80: 0x0001, 0xd81: 0x0001, 0xd82: 0x0001, 0xd83: 0x0001, 0xd84: 0x0001,
+ 0xd86: 0x0001, 0xd87: 0x0001,
+ 0xd8d: 0x0001, 0xd8e: 0x0001, 0xd8f: 0x0001, 0xd90: 0x0001, 0xd91: 0x0001,
+ 0xd92: 0x0001, 0xd93: 0x0001, 0xd94: 0x0001, 0xd95: 0x0001, 0xd96: 0x0001, 0xd97: 0x0001,
+ 0xd99: 0x0001, 0xd9a: 0x0001, 0xd9b: 0x0001, 0xd9c: 0x0001, 0xd9d: 0x0001,
+ 0xd9e: 0x0001, 0xd9f: 0x0001, 0xda0: 0x0001, 0xda1: 0x0001, 0xda2: 0x0001, 0xda3: 0x0001,
+ 0xda4: 0x0001, 0xda5: 0x0001, 0xda6: 0x0001, 0xda7: 0x0001, 0xda8: 0x0001, 0xda9: 0x0001,
+ 0xdaa: 0x0001, 0xdab: 0x0001, 0xdac: 0x0001, 0xdad: 0x0001, 0xdae: 0x0001, 0xdaf: 0x0001,
+ 0xdb0: 0x0001, 0xdb1: 0x0001, 0xdb2: 0x0001, 0xdb3: 0x0001, 0xdb4: 0x0001, 0xdb5: 0x0001,
+ 0xdb6: 0x0001, 0xdb7: 0x0001, 0xdb8: 0x0001, 0xdb9: 0x0001, 0xdba: 0x0001, 0xdbb: 0x0001,
+ 0xdbc: 0x0001,
+ // Block 0x37, offset 0xdc0
+ 0xdc6: 0x0001,
+ // Block 0x38, offset 0xe00
+ 0xe2d: 0x0001, 0xe2e: 0x0001, 0xe2f: 0x0001,
+ 0xe30: 0x0001, 0xe32: 0x0001, 0xe33: 0x0001, 0xe34: 0x0001, 0xe35: 0x0001,
+ 0xe36: 0x0001, 0xe37: 0x0001, 0xe39: 0x0001, 0xe3a: 0x0001,
+ 0xe3d: 0x0001, 0xe3e: 0x0001,
+ // Block 0x39, offset 0xe40
+ 0xe58: 0x0001, 0xe59: 0x0001,
+ 0xe5e: 0x0001, 0xe5f: 0x0001, 0xe60: 0x0001,
+ 0xe71: 0x0001, 0xe72: 0x0001, 0xe73: 0x0001, 0xe74: 0x0001,
+ // Block 0x3a, offset 0xe80
+ 0xe82: 0x0001, 0xe85: 0x0001,
+ 0xe86: 0x0001,
+ 0xe8d: 0x0001,
+ 0xe9d: 0x0001,
+ // Block 0x3b, offset 0xec0
+ 0xec0: 0x0002, 0xec1: 0x0002, 0xec2: 0x0002, 0xec3: 0x0002, 0xec4: 0x0002, 0xec5: 0x0002,
+ 0xec6: 0x0002, 0xec7: 0x0002, 0xec8: 0x0002, 0xec9: 0x0002, 0xeca: 0x0002, 0xecb: 0x0002,
+ 0xecc: 0x0002, 0xecd: 0x0002, 0xece: 0x0002, 0xecf: 0x0002, 0xed0: 0x0002, 0xed1: 0x0002,
+ 0xed2: 0x0002, 0xed3: 0x0002, 0xed4: 0x0002, 0xed5: 0x0002, 0xed6: 0x0002, 0xed7: 0x0002,
+ 0xed8: 0x0002, 0xed9: 0x0002, 0xeda: 0x0002, 0xedb: 0x0002, 0xedc: 0x0002, 0xedd: 0x0002,
+ 0xede: 0x0002, 0xedf: 0x0002, 0xee0: 0x0002, 0xee1: 0x0002, 0xee2: 0x0002, 0xee3: 0x0002,
+ 0xee4: 0x0002, 0xee5: 0x0002, 0xee6: 0x0002, 0xee7: 0x0002, 0xee8: 0x0002, 0xee9: 0x0002,
+ 0xeea: 0x0002, 0xeeb: 0x0002, 0xeec: 0x0002, 0xeed: 0x0002, 0xeee: 0x0002, 0xeef: 0x0002,
+ 0xef0: 0x0002, 0xef1: 0x0002, 0xef2: 0x0002, 0xef3: 0x0002, 0xef4: 0x0002, 0xef5: 0x0002,
+ 0xef6: 0x0002, 0xef7: 0x0002, 0xef8: 0x0002, 0xef9: 0x0002, 0xefa: 0x0002, 0xefb: 0x0002,
+ 0xefc: 0x0002, 0xefd: 0x0002, 0xefe: 0x0002, 0xeff: 0x0002,
+ // Block 0x3c, offset 0xf00
+ 0xf00: 0x0002, 0xf01: 0x0002, 0xf02: 0x0002, 0xf03: 0x0002, 0xf04: 0x0002, 0xf05: 0x0002,
+ 0xf06: 0x0002, 0xf07: 0x0002, 0xf08: 0x0002, 0xf09: 0x0002, 0xf0a: 0x0002, 0xf0b: 0x0002,
+ 0xf0c: 0x0002, 0xf0d: 0x0002, 0xf0e: 0x0002, 0xf0f: 0x0002, 0xf10: 0x0002, 0xf11: 0x0002,
+ 0xf12: 0x0002, 0xf13: 0x0002, 0xf14: 0x0002, 0xf15: 0x0002, 0xf16: 0x0002, 0xf17: 0x0002,
+ 0xf18: 0x0002, 0xf19: 0x0002, 0xf1a: 0x0002, 0xf1b: 0x0002, 0xf1c: 0x0002, 0xf1d: 0x0002,
+ 0xf1e: 0x0002, 0xf1f: 0x0002,
+ // Block 0x3d, offset 0xf40
+ 0xf5d: 0x0001,
+ 0xf5e: 0x0001, 0xf5f: 0x0001,
+ // Block 0x3e, offset 0xf80
+ 0xf92: 0x0001, 0xf93: 0x0001, 0xf94: 0x0001,
+ 0xfb2: 0x0001, 0xfb3: 0x0001,
+ // Block 0x3f, offset 0xfc0
+ 0xfd2: 0x0001, 0xfd3: 0x0001,
+ 0xff2: 0x0001, 0xff3: 0x0001,
+ // Block 0x40, offset 0x1000
+ 0x1034: 0x0001, 0x1035: 0x0001,
+ 0x1037: 0x0001, 0x1038: 0x0001, 0x1039: 0x0001, 0x103a: 0x0001, 0x103b: 0x0001,
+ 0x103c: 0x0001, 0x103d: 0x0001,
+ // Block 0x41, offset 0x1040
+ 0x1046: 0x0001, 0x1049: 0x0001, 0x104a: 0x0001, 0x104b: 0x0001,
+ 0x104c: 0x0001, 0x104d: 0x0001, 0x104e: 0x0001, 0x104f: 0x0001, 0x1050: 0x0001, 0x1051: 0x0001,
+ 0x1052: 0x0001, 0x1053: 0x0001,
+ 0x105d: 0x0001,
+ // Block 0x42, offset 0x1080
+ 0x108b: 0x0001,
+ 0x108c: 0x0001, 0x108d: 0x0001, 0x108e: 0x0001, 0x108f: 0x0001,
+ // Block 0x43, offset 0x10c0
+ 0x10c5: 0x0001,
+ 0x10c6: 0x0001,
+ 0x10e9: 0x0001,
+ // Block 0x44, offset 0x1100
+ 0x1120: 0x0001, 0x1121: 0x0001, 0x1122: 0x0001,
+ 0x1127: 0x0001, 0x1128: 0x0001,
+ 0x1132: 0x0001,
+ 0x1139: 0x0001, 0x113a: 0x0001, 0x113b: 0x0001,
+ // Block 0x45, offset 0x1140
+ 0x1157: 0x0001,
+ 0x1158: 0x0001, 0x115b: 0x0001,
+ // Block 0x46, offset 0x1180
+ 0x1196: 0x0001,
+ 0x1198: 0x0001, 0x1199: 0x0001, 0x119a: 0x0001, 0x119b: 0x0001, 0x119c: 0x0001, 0x119d: 0x0001,
+ 0x119e: 0x0001, 0x11a0: 0x0001, 0x11a2: 0x0001,
+ 0x11a5: 0x0001, 0x11a6: 0x0001, 0x11a7: 0x0001, 0x11a8: 0x0001, 0x11a9: 0x0001,
+ 0x11aa: 0x0001, 0x11ab: 0x0001, 0x11ac: 0x0001,
+ 0x11b3: 0x0001, 0x11b4: 0x0001, 0x11b5: 0x0001,
+ 0x11b6: 0x0001, 0x11b7: 0x0001, 0x11b8: 0x0001, 0x11b9: 0x0001, 0x11ba: 0x0001, 0x11bb: 0x0001,
+ 0x11bc: 0x0001, 0x11bf: 0x0001,
+ // Block 0x47, offset 0x11c0
+ 0x11f0: 0x0001, 0x11f1: 0x0001, 0x11f2: 0x0001, 0x11f3: 0x0001, 0x11f4: 0x0001, 0x11f5: 0x0001,
+ 0x11f6: 0x0001, 0x11f7: 0x0001, 0x11f8: 0x0001, 0x11f9: 0x0001, 0x11fa: 0x0001, 0x11fb: 0x0001,
+ 0x11fc: 0x0001, 0x11fd: 0x0001, 0x11fe: 0x0001, 0x11ff: 0x0001,
+ // Block 0x48, offset 0x1200
+ 0x1200: 0x0001, 0x1201: 0x0001, 0x1202: 0x0001, 0x1203: 0x0001, 0x1204: 0x0001, 0x1205: 0x0001,
+ 0x1206: 0x0001, 0x1207: 0x0001, 0x1208: 0x0001, 0x1209: 0x0001, 0x120a: 0x0001, 0x120b: 0x0001,
+ 0x120c: 0x0001, 0x120d: 0x0001, 0x120e: 0x0001,
+ // Block 0x49, offset 0x1240
+ 0x1240: 0x0001, 0x1241: 0x0001, 0x1242: 0x0001, 0x1243: 0x0001,
+ 0x1274: 0x0001,
+ 0x1276: 0x0001, 0x1277: 0x0001, 0x1278: 0x0001, 0x1279: 0x0001, 0x127a: 0x0001,
+ 0x127c: 0x0001,
+ // Block 0x4a, offset 0x1280
+ 0x1282: 0x0001,
+ 0x12ab: 0x0001, 0x12ac: 0x0001, 0x12ad: 0x0001, 0x12ae: 0x0001, 0x12af: 0x0001,
+ 0x12b0: 0x0001, 0x12b1: 0x0001, 0x12b2: 0x0001, 0x12b3: 0x0001,
+ // Block 0x4b, offset 0x12c0
+ 0x12c0: 0x0001, 0x12c1: 0x0001,
+ 0x12e2: 0x0001, 0x12e3: 0x0001,
+ 0x12e4: 0x0001, 0x12e5: 0x0001, 0x12e8: 0x0001, 0x12e9: 0x0001,
+ 0x12eb: 0x0001, 0x12ec: 0x0001, 0x12ed: 0x0001,
+ // Block 0x4c, offset 0x1300
+ 0x1326: 0x0001, 0x1328: 0x0001, 0x1329: 0x0001,
+ 0x132d: 0x0001, 0x132f: 0x0001,
+ 0x1330: 0x0001, 0x1331: 0x0001,
+ // Block 0x4d, offset 0x1340
+ 0x136c: 0x0001, 0x136d: 0x0001, 0x136e: 0x0001, 0x136f: 0x0001,
+ 0x1370: 0x0001, 0x1371: 0x0001, 0x1372: 0x0001, 0x1373: 0x0001,
+ 0x1376: 0x0001, 0x1377: 0x0001,
+ // Block 0x4e, offset 0x1380
+ 0x1390: 0x0001, 0x1391: 0x0001,
+ 0x1392: 0x0001, 0x1394: 0x0001, 0x1395: 0x0001, 0x1396: 0x0001, 0x1397: 0x0001,
+ 0x1398: 0x0001, 0x1399: 0x0001, 0x139a: 0x0001, 0x139b: 0x0001, 0x139c: 0x0001, 0x139d: 0x0001,
+ 0x139e: 0x0001, 0x139f: 0x0001, 0x13a0: 0x0001, 0x13a2: 0x0001, 0x13a3: 0x0001,
+ 0x13a4: 0x0001, 0x13a5: 0x0001, 0x13a6: 0x0001, 0x13a7: 0x0001, 0x13a8: 0x0001,
+ 0x13ad: 0x0001,
+ 0x13b4: 0x0001,
+ 0x13b8: 0x0001, 0x13b9: 0x0001,
+ // Block 0x4f, offset 0x13c0
+ 0x13cb: 0x0001,
+ 0x13cc: 0x0001, 0x13cd: 0x0001, 0x13ce: 0x0001, 0x13cf: 0x0001, 0x13d0: 0x0003,
+ 0x13d3: 0x0003, 0x13d4: 0x0003, 0x13d5: 0x0003, 0x13d6: 0x0003,
+ 0x13d8: 0x0003, 0x13d9: 0x0003, 0x13dc: 0x0003, 0x13dd: 0x0003,
+ 0x13e0: 0x0003, 0x13e1: 0x0003, 0x13e2: 0x0003,
+ 0x13e4: 0x0003, 0x13e5: 0x0003, 0x13e6: 0x0003, 0x13e7: 0x0003, 0x13e8: 0x0001, 0x13e9: 0x0001,
+ 0x13ea: 0x0001, 0x13eb: 0x0001, 0x13ec: 0x0001, 0x13ed: 0x0001, 0x13ee: 0x0001,
+ 0x13f0: 0x0003, 0x13f2: 0x0003, 0x13f3: 0x0003, 0x13f5: 0x0003,
+ 0x13fb: 0x0003,
+ 0x13fe: 0x0003,
+ // Block 0x50, offset 0x1400
+ 0x1420: 0x0001, 0x1421: 0x0001, 0x1422: 0x0001, 0x1423: 0x0001,
+ 0x1424: 0x0001, 0x1426: 0x0001, 0x1427: 0x0001, 0x1428: 0x0001, 0x1429: 0x0001,
+ 0x142a: 0x0001, 0x142b: 0x0001, 0x142c: 0x0001, 0x142d: 0x0001, 0x142e: 0x0001, 0x142f: 0x0001,
+ 0x1434: 0x0003,
+ 0x143f: 0x0003,
+ // Block 0x51, offset 0x1440
+ 0x1441: 0x0003, 0x1442: 0x0003, 0x1443: 0x0003, 0x1444: 0x0003,
+ 0x146c: 0x0003,
+ // Block 0x52, offset 0x1480
+ 0x1490: 0x0001, 0x1491: 0x0001,
+ 0x1492: 0x0001, 0x1493: 0x0001, 0x1494: 0x0001, 0x1495: 0x0001, 0x1496: 0x0001, 0x1497: 0x0001,
+ 0x1498: 0x0001, 0x1499: 0x0001, 0x149a: 0x0001, 0x149b: 0x0001, 0x149c: 0x0001, 0x149d: 0x0001,
+ 0x149e: 0x0001, 0x149f: 0x0001, 0x14a0: 0x0001, 0x14a1: 0x0001, 0x14a2: 0x0001, 0x14a3: 0x0001,
+ 0x14a4: 0x0001, 0x14a5: 0x0001, 0x14a6: 0x0001, 0x14a7: 0x0001, 0x14a8: 0x0001, 0x14a9: 0x0001,
+ 0x14aa: 0x0001, 0x14ab: 0x0001, 0x14ac: 0x0001, 0x14ad: 0x0001, 0x14ae: 0x0001, 0x14af: 0x0001,
+ 0x14b0: 0x0001,
+ // Block 0x53, offset 0x14c0
+ 0x14c3: 0x0003, 0x14c5: 0x0003,
+ 0x14c9: 0x0003,
+ 0x14d3: 0x0003, 0x14d6: 0x0003,
+ 0x14e1: 0x0003, 0x14e2: 0x0003,
+ 0x14e6: 0x0003,
+ 0x14eb: 0x0003,
+ // Block 0x54, offset 0x1500
+ 0x1513: 0x0003, 0x1514: 0x0003,
+ 0x151b: 0x0003, 0x151c: 0x0003, 0x151d: 0x0003,
+ 0x151e: 0x0003, 0x1520: 0x0003, 0x1521: 0x0003, 0x1522: 0x0003, 0x1523: 0x0003,
+ 0x1524: 0x0003, 0x1525: 0x0003, 0x1526: 0x0003, 0x1527: 0x0003, 0x1528: 0x0003, 0x1529: 0x0003,
+ 0x152a: 0x0003, 0x152b: 0x0003,
+ 0x1530: 0x0003, 0x1531: 0x0003, 0x1532: 0x0003, 0x1533: 0x0003, 0x1534: 0x0003, 0x1535: 0x0003,
+ 0x1536: 0x0003, 0x1537: 0x0003, 0x1538: 0x0003, 0x1539: 0x0003,
+ // Block 0x55, offset 0x1540
+ 0x1549: 0x0003,
+ 0x1550: 0x0003, 0x1551: 0x0003,
+ 0x1552: 0x0003, 0x1553: 0x0003, 0x1554: 0x0003, 0x1555: 0x0003, 0x1556: 0x0003, 0x1557: 0x0003,
+ 0x1558: 0x0003, 0x1559: 0x0003,
+ 0x1578: 0x0003, 0x1579: 0x0003,
+ // Block 0x56, offset 0x1580
+ 0x1592: 0x0003, 0x1594: 0x0003,
+ 0x15a7: 0x0003,
+ // Block 0x57, offset 0x15c0
+ 0x15c0: 0x0003, 0x15c2: 0x0003, 0x15c3: 0x0003,
+ 0x15c7: 0x0003, 0x15c8: 0x0003, 0x15cb: 0x0003,
+ 0x15cf: 0x0003, 0x15d1: 0x0003,
+ 0x15d5: 0x0003,
+ 0x15da: 0x0003, 0x15dd: 0x0003,
+ 0x15de: 0x0003, 0x15df: 0x0003, 0x15e0: 0x0003, 0x15e3: 0x0003,
+ 0x15e5: 0x0003, 0x15e7: 0x0003, 0x15e8: 0x0003, 0x15e9: 0x0003,
+ 0x15ea: 0x0003, 0x15eb: 0x0003, 0x15ec: 0x0003, 0x15ee: 0x0003,
+ 0x15f4: 0x0003, 0x15f5: 0x0003,
+ 0x15f6: 0x0003, 0x15f7: 0x0003,
+ 0x15fc: 0x0003, 0x15fd: 0x0003,
+ // Block 0x58, offset 0x1600
+ 0x1608: 0x0003,
+ 0x160c: 0x0003,
+ 0x1612: 0x0003,
+ 0x1620: 0x0003, 0x1621: 0x0003,
+ 0x1624: 0x0003, 0x1625: 0x0003, 0x1626: 0x0003, 0x1627: 0x0003,
+ 0x162a: 0x0003, 0x162b: 0x0003, 0x162e: 0x0003, 0x162f: 0x0003,
+ // Block 0x59, offset 0x1640
+ 0x1642: 0x0003, 0x1643: 0x0003,
+ 0x1646: 0x0003, 0x1647: 0x0003,
+ 0x1655: 0x0003,
+ 0x1659: 0x0003,
+ 0x1665: 0x0003,
+ 0x167f: 0x0003,
+ // Block 0x5a, offset 0x1680
+ 0x1692: 0x0003,
+ 0x169a: 0x0002, 0x169b: 0x0002,
+ 0x16a9: 0x0002,
+ 0x16aa: 0x0002,
+ // Block 0x5b, offset 0x16c0
+ 0x16e9: 0x0002,
+ 0x16ea: 0x0002, 0x16eb: 0x0002, 0x16ec: 0x0002,
+ 0x16f0: 0x0002, 0x16f3: 0x0002,
+ // Block 0x5c, offset 0x1700
+ 0x1720: 0x0003, 0x1721: 0x0003, 0x1722: 0x0003, 0x1723: 0x0003,
+ 0x1724: 0x0003, 0x1725: 0x0003, 0x1726: 0x0003, 0x1727: 0x0003, 0x1728: 0x0003, 0x1729: 0x0003,
+ 0x172a: 0x0003, 0x172b: 0x0003, 0x172c: 0x0003, 0x172d: 0x0003, 0x172e: 0x0003, 0x172f: 0x0003,
+ 0x1730: 0x0003, 0x1731: 0x0003, 0x1732: 0x0003, 0x1733: 0x0003, 0x1734: 0x0003, 0x1735: 0x0003,
+ 0x1736: 0x0003, 0x1737: 0x0003, 0x1738: 0x0003, 0x1739: 0x0003, 0x173a: 0x0003, 0x173b: 0x0003,
+ 0x173c: 0x0003, 0x173d: 0x0003, 0x173e: 0x0003, 0x173f: 0x0003,
+ // Block 0x5d, offset 0x1740
+ 0x1740: 0x0003, 0x1741: 0x0003, 0x1742: 0x0003, 0x1743: 0x0003, 0x1744: 0x0003, 0x1745: 0x0003,
+ 0x1746: 0x0003, 0x1747: 0x0003, 0x1748: 0x0003, 0x1749: 0x0003, 0x174a: 0x0003, 0x174b: 0x0003,
+ 0x174c: 0x0003, 0x174d: 0x0003, 0x174e: 0x0003, 0x174f: 0x0003, 0x1750: 0x0003, 0x1751: 0x0003,
+ 0x1752: 0x0003, 0x1753: 0x0003, 0x1754: 0x0003, 0x1755: 0x0003, 0x1756: 0x0003, 0x1757: 0x0003,
+ 0x1758: 0x0003, 0x1759: 0x0003, 0x175a: 0x0003, 0x175b: 0x0003, 0x175c: 0x0003, 0x175d: 0x0003,
+ 0x175e: 0x0003, 0x175f: 0x0003, 0x1760: 0x0003, 0x1761: 0x0003, 0x1762: 0x0003, 0x1763: 0x0003,
+ 0x1764: 0x0003, 0x1765: 0x0003, 0x1766: 0x0003, 0x1767: 0x0003, 0x1768: 0x0003, 0x1769: 0x0003,
+ 0x176a: 0x0003, 0x176b: 0x0003, 0x176c: 0x0003, 0x176d: 0x0003, 0x176e: 0x0003, 0x176f: 0x0003,
+ 0x1770: 0x0003, 0x1771: 0x0003, 0x1772: 0x0003, 0x1773: 0x0003, 0x1774: 0x0003, 0x1775: 0x0003,
+ 0x1776: 0x0003, 0x1777: 0x0003, 0x1778: 0x0003, 0x1779: 0x0003, 0x177a: 0x0003, 0x177b: 0x0003,
+ 0x177c: 0x0003, 0x177d: 0x0003, 0x177e: 0x0003, 0x177f: 0x0003,
+ // Block 0x5e, offset 0x1780
+ 0x1780: 0x0003, 0x1781: 0x0003, 0x1782: 0x0003, 0x1783: 0x0003, 0x1784: 0x0003, 0x1785: 0x0003,
+ 0x1786: 0x0003, 0x1787: 0x0003, 0x1788: 0x0003, 0x1789: 0x0003, 0x178a: 0x0003, 0x178b: 0x0003,
+ 0x178c: 0x0003, 0x178d: 0x0003, 0x178e: 0x0003, 0x178f: 0x0003, 0x1790: 0x0003, 0x1791: 0x0003,
+ 0x1792: 0x0003, 0x1793: 0x0003, 0x1794: 0x0003, 0x1795: 0x0003, 0x1796: 0x0003, 0x1797: 0x0003,
+ 0x1798: 0x0003, 0x1799: 0x0003, 0x179a: 0x0003, 0x179b: 0x0003, 0x179c: 0x0003, 0x179d: 0x0003,
+ 0x179e: 0x0003, 0x179f: 0x0003, 0x17a0: 0x0003, 0x17a1: 0x0003, 0x17a2: 0x0003, 0x17a3: 0x0003,
+ 0x17a4: 0x0003, 0x17a5: 0x0003, 0x17a6: 0x0003, 0x17a7: 0x0003, 0x17a8: 0x0003, 0x17a9: 0x0003,
+ 0x17ab: 0x0003, 0x17ac: 0x0003, 0x17ad: 0x0003, 0x17ae: 0x0003, 0x17af: 0x0003,
+ 0x17b0: 0x0003, 0x17b1: 0x0003, 0x17b2: 0x0003, 0x17b3: 0x0003, 0x17b4: 0x0003, 0x17b5: 0x0003,
+ 0x17b6: 0x0003, 0x17b7: 0x0003, 0x17b8: 0x0003, 0x17b9: 0x0003, 0x17ba: 0x0003, 0x17bb: 0x0003,
+ 0x17bc: 0x0003, 0x17bd: 0x0003, 0x17be: 0x0003, 0x17bf: 0x0003,
+ // Block 0x5f, offset 0x17c0
+ 0x17c0: 0x0003, 0x17c1: 0x0003, 0x17c2: 0x0003, 0x17c3: 0x0003, 0x17c4: 0x0003, 0x17c5: 0x0003,
+ 0x17c6: 0x0003, 0x17c7: 0x0003, 0x17c8: 0x0003, 0x17c9: 0x0003, 0x17ca: 0x0003, 0x17cb: 0x0003,
+ 0x17d0: 0x0003, 0x17d1: 0x0003,
+ 0x17d2: 0x0003, 0x17d3: 0x0003, 0x17d4: 0x0003, 0x17d5: 0x0003, 0x17d6: 0x0003, 0x17d7: 0x0003,
+ 0x17d8: 0x0003, 0x17d9: 0x0003, 0x17da: 0x0003, 0x17db: 0x0003, 0x17dc: 0x0003, 0x17dd: 0x0003,
+ 0x17de: 0x0003, 0x17df: 0x0003, 0x17e0: 0x0003, 0x17e1: 0x0003, 0x17e2: 0x0003, 0x17e3: 0x0003,
+ 0x17e4: 0x0003, 0x17e5: 0x0003, 0x17e6: 0x0003, 0x17e7: 0x0003, 0x17e8: 0x0003, 0x17e9: 0x0003,
+ 0x17ea: 0x0003, 0x17eb: 0x0003, 0x17ec: 0x0003, 0x17ed: 0x0003, 0x17ee: 0x0003, 0x17ef: 0x0003,
+ 0x17f0: 0x0003, 0x17f1: 0x0003, 0x17f2: 0x0003, 0x17f3: 0x0003,
+ // Block 0x60, offset 0x1800
+ 0x1800: 0x0003, 0x1801: 0x0003, 0x1802: 0x0003, 0x1803: 0x0003, 0x1804: 0x0003, 0x1805: 0x0003,
+ 0x1806: 0x0003, 0x1807: 0x0003, 0x1808: 0x0003, 0x1809: 0x0003, 0x180a: 0x0003, 0x180b: 0x0003,
+ 0x180c: 0x0003, 0x180d: 0x0003, 0x180e: 0x0003, 0x180f: 0x0003,
+ 0x1812: 0x0003, 0x1813: 0x0003, 0x1814: 0x0003, 0x1815: 0x0003,
+ 0x1820: 0x0003, 0x1821: 0x0003, 0x1823: 0x0003,
+ 0x1824: 0x0003, 0x1825: 0x0003, 0x1826: 0x0003, 0x1827: 0x0003, 0x1828: 0x0003, 0x1829: 0x0003,
+ 0x1832: 0x0003, 0x1833: 0x0003,
+ 0x1836: 0x0003, 0x1837: 0x0003,
+ 0x183c: 0x0003, 0x183d: 0x0003,
+ // Block 0x61, offset 0x1840
+ 0x1840: 0x0003, 0x1841: 0x0003,
+ 0x1846: 0x0003, 0x1847: 0x0003, 0x1848: 0x0003, 0x184b: 0x0003,
+ 0x184e: 0x0003, 0x184f: 0x0003, 0x1850: 0x0003, 0x1851: 0x0003,
+ 0x1862: 0x0003, 0x1863: 0x0003,
+ 0x1864: 0x0003, 0x1865: 0x0003,
+ 0x186f: 0x0003,
+ 0x187d: 0x0002, 0x187e: 0x0002,
+ // Block 0x62, offset 0x1880
+ 0x1885: 0x0003,
+ 0x1886: 0x0003, 0x1889: 0x0003,
+ 0x188e: 0x0003, 0x188f: 0x0003,
+ 0x1894: 0x0002, 0x1895: 0x0002,
+ 0x189c: 0x0003,
+ 0x189e: 0x0003,
+ 0x18b0: 0x0002, 0x18b1: 0x0002, 0x18b2: 0x0002, 0x18b3: 0x0002, 0x18b4: 0x0002, 0x18b5: 0x0002,
+ 0x18b6: 0x0002, 0x18b7: 0x0002,
+ // Block 0x63, offset 0x18c0
+ 0x18c0: 0x0003, 0x18c2: 0x0003,
+ 0x18c8: 0x0002, 0x18c9: 0x0002, 0x18ca: 0x0002, 0x18cb: 0x0002,
+ 0x18cc: 0x0002, 0x18cd: 0x0002, 0x18ce: 0x0002, 0x18cf: 0x0002, 0x18d0: 0x0002, 0x18d1: 0x0002,
+ 0x18d2: 0x0002, 0x18d3: 0x0002,
+ 0x18e0: 0x0003, 0x18e1: 0x0003, 0x18e3: 0x0003,
+ 0x18e4: 0x0003, 0x18e5: 0x0003, 0x18e7: 0x0003, 0x18e8: 0x0003, 0x18e9: 0x0003,
+ 0x18ea: 0x0003, 0x18ec: 0x0003, 0x18ed: 0x0003, 0x18ef: 0x0003,
+ 0x18ff: 0x0002,
+ // Block 0x64, offset 0x1900
+ 0x190a: 0x0002, 0x190b: 0x0002,
+ 0x190c: 0x0002, 0x190d: 0x0002, 0x190e: 0x0002, 0x190f: 0x0002,
+ 0x1913: 0x0002,
+ 0x191e: 0x0003, 0x191f: 0x0003, 0x1921: 0x0002,
+ 0x192a: 0x0002, 0x192b: 0x0002,
+ 0x193d: 0x0002, 0x193e: 0x0002, 0x193f: 0x0003,
+ // Block 0x65, offset 0x1940
+ 0x1944: 0x0002, 0x1945: 0x0002,
+ 0x1946: 0x0003, 0x1947: 0x0003, 0x1948: 0x0003, 0x1949: 0x0003, 0x194a: 0x0003, 0x194b: 0x0003,
+ 0x194c: 0x0003, 0x194d: 0x0003, 0x194e: 0x0002, 0x194f: 0x0003, 0x1950: 0x0003, 0x1951: 0x0003,
+ 0x1952: 0x0003, 0x1953: 0x0003, 0x1954: 0x0002, 0x1955: 0x0003, 0x1956: 0x0003, 0x1957: 0x0003,
+ 0x1958: 0x0003, 0x1959: 0x0003, 0x195a: 0x0003, 0x195b: 0x0003, 0x195c: 0x0003, 0x195d: 0x0003,
+ 0x195e: 0x0003, 0x195f: 0x0003, 0x1960: 0x0003, 0x1961: 0x0003, 0x1963: 0x0003,
+ 0x1968: 0x0003, 0x1969: 0x0003,
+ 0x196a: 0x0002, 0x196b: 0x0003, 0x196c: 0x0003, 0x196d: 0x0003, 0x196e: 0x0003, 0x196f: 0x0003,
+ 0x1970: 0x0003, 0x1971: 0x0003, 0x1972: 0x0002, 0x1973: 0x0002, 0x1974: 0x0003, 0x1975: 0x0002,
+ 0x1976: 0x0003, 0x1977: 0x0003, 0x1978: 0x0003, 0x1979: 0x0003, 0x197a: 0x0002, 0x197b: 0x0003,
+ 0x197c: 0x0003, 0x197d: 0x0002, 0x197e: 0x0003, 0x197f: 0x0003,
+ // Block 0x66, offset 0x1980
+ 0x1985: 0x0002,
+ 0x198a: 0x0002, 0x198b: 0x0002,
+ 0x19a8: 0x0002,
+ 0x19bd: 0x0003,
+ // Block 0x67, offset 0x19c0
+ 0x19cc: 0x0002, 0x19ce: 0x0002,
+ 0x19d3: 0x0002, 0x19d4: 0x0002, 0x19d5: 0x0002, 0x19d7: 0x0002,
+ 0x19f6: 0x0003, 0x19f7: 0x0003, 0x19f8: 0x0003, 0x19f9: 0x0003, 0x19fa: 0x0003, 0x19fb: 0x0003,
+ 0x19fc: 0x0003, 0x19fd: 0x0003, 0x19fe: 0x0003, 0x19ff: 0x0003,
+ // Block 0x68, offset 0x1a00
+ 0x1a15: 0x0002, 0x1a16: 0x0002, 0x1a17: 0x0002,
+ 0x1a30: 0x0002,
+ 0x1a3f: 0x0002,
+ // Block 0x69, offset 0x1a40
+ 0x1a5b: 0x0002, 0x1a5c: 0x0002,
+ // Block 0x6a, offset 0x1a80
+ 0x1a90: 0x0002,
+ 0x1a95: 0x0002, 0x1a96: 0x0003, 0x1a97: 0x0003,
+ 0x1a98: 0x0003, 0x1a99: 0x0003,
+ // Block 0x6b, offset 0x1ac0
+ 0x1aef: 0x0001,
+ 0x1af0: 0x0001, 0x1af1: 0x0001,
+ // Block 0x6c, offset 0x1b00
+ 0x1b3f: 0x0001,
+ // Block 0x6d, offset 0x1b40
+ 0x1b60: 0x0001, 0x1b61: 0x0001, 0x1b62: 0x0001, 0x1b63: 0x0001,
+ 0x1b64: 0x0001, 0x1b65: 0x0001, 0x1b66: 0x0001, 0x1b67: 0x0001, 0x1b68: 0x0001, 0x1b69: 0x0001,
+ 0x1b6a: 0x0001, 0x1b6b: 0x0001, 0x1b6c: 0x0001, 0x1b6d: 0x0001, 0x1b6e: 0x0001, 0x1b6f: 0x0001,
+ 0x1b70: 0x0001, 0x1b71: 0x0001, 0x1b72: 0x0001, 0x1b73: 0x0001, 0x1b74: 0x0001, 0x1b75: 0x0001,
+ 0x1b76: 0x0001, 0x1b77: 0x0001, 0x1b78: 0x0001, 0x1b79: 0x0001, 0x1b7a: 0x0001, 0x1b7b: 0x0001,
+ 0x1b7c: 0x0001, 0x1b7d: 0x0001, 0x1b7e: 0x0001, 0x1b7f: 0x0001,
+ // Block 0x6e, offset 0x1b80
+ 0x1b80: 0x0002, 0x1b81: 0x0002, 0x1b82: 0x0002, 0x1b83: 0x0002, 0x1b84: 0x0002, 0x1b85: 0x0002,
+ 0x1b86: 0x0002, 0x1b87: 0x0002, 0x1b88: 0x0002, 0x1b89: 0x0002, 0x1b8a: 0x0002, 0x1b8b: 0x0002,
+ 0x1b8c: 0x0002, 0x1b8d: 0x0002, 0x1b8e: 0x0002, 0x1b8f: 0x0002, 0x1b90: 0x0002, 0x1b91: 0x0002,
+ 0x1b92: 0x0002, 0x1b93: 0x0002, 0x1b94: 0x0002, 0x1b95: 0x0002, 0x1b96: 0x0002, 0x1b97: 0x0002,
+ 0x1b98: 0x0002, 0x1b99: 0x0002, 0x1b9b: 0x0002, 0x1b9c: 0x0002, 0x1b9d: 0x0002,
+ 0x1b9e: 0x0002, 0x1b9f: 0x0002, 0x1ba0: 0x0002, 0x1ba1: 0x0002, 0x1ba2: 0x0002, 0x1ba3: 0x0002,
+ 0x1ba4: 0x0002, 0x1ba5: 0x0002, 0x1ba6: 0x0002, 0x1ba7: 0x0002, 0x1ba8: 0x0002, 0x1ba9: 0x0002,
+ 0x1baa: 0x0002, 0x1bab: 0x0002, 0x1bac: 0x0002, 0x1bad: 0x0002, 0x1bae: 0x0002, 0x1baf: 0x0002,
+ 0x1bb0: 0x0002, 0x1bb1: 0x0002, 0x1bb2: 0x0002, 0x1bb3: 0x0002, 0x1bb4: 0x0002, 0x1bb5: 0x0002,
+ 0x1bb6: 0x0002, 0x1bb7: 0x0002, 0x1bb8: 0x0002, 0x1bb9: 0x0002, 0x1bba: 0x0002, 0x1bbb: 0x0002,
+ 0x1bbc: 0x0002, 0x1bbd: 0x0002, 0x1bbe: 0x0002, 0x1bbf: 0x0002,
+ // Block 0x6f, offset 0x1bc0
+ 0x1bc0: 0x0002, 0x1bc1: 0x0002, 0x1bc2: 0x0002, 0x1bc3: 0x0002, 0x1bc4: 0x0002, 0x1bc5: 0x0002,
+ 0x1bc6: 0x0002, 0x1bc7: 0x0002, 0x1bc8: 0x0002, 0x1bc9: 0x0002, 0x1bca: 0x0002, 0x1bcb: 0x0002,
+ 0x1bcc: 0x0002, 0x1bcd: 0x0002, 0x1bce: 0x0002, 0x1bcf: 0x0002, 0x1bd0: 0x0002, 0x1bd1: 0x0002,
+ 0x1bd2: 0x0002, 0x1bd3: 0x0002, 0x1bd4: 0x0002, 0x1bd5: 0x0002, 0x1bd6: 0x0002, 0x1bd7: 0x0002,
+ 0x1bd8: 0x0002, 0x1bd9: 0x0002, 0x1bda: 0x0002, 0x1bdb: 0x0002, 0x1bdc: 0x0002, 0x1bdd: 0x0002,
+ 0x1bde: 0x0002, 0x1bdf: 0x0002, 0x1be0: 0x0002, 0x1be1: 0x0002, 0x1be2: 0x0002, 0x1be3: 0x0002,
+ 0x1be4: 0x0002, 0x1be5: 0x0002, 0x1be6: 0x0002, 0x1be7: 0x0002, 0x1be8: 0x0002, 0x1be9: 0x0002,
+ 0x1bea: 0x0002, 0x1beb: 0x0002, 0x1bec: 0x0002, 0x1bed: 0x0002, 0x1bee: 0x0002, 0x1bef: 0x0002,
+ 0x1bf0: 0x0002, 0x1bf1: 0x0002, 0x1bf2: 0x0002, 0x1bf3: 0x0002,
+ // Block 0x70, offset 0x1c00
+ 0x1c00: 0x0002, 0x1c01: 0x0002, 0x1c02: 0x0002, 0x1c03: 0x0002, 0x1c04: 0x0002, 0x1c05: 0x0002,
+ 0x1c06: 0x0002, 0x1c07: 0x0002, 0x1c08: 0x0002, 0x1c09: 0x0002, 0x1c0a: 0x0002, 0x1c0b: 0x0002,
+ 0x1c0c: 0x0002, 0x1c0d: 0x0002, 0x1c0e: 0x0002, 0x1c0f: 0x0002, 0x1c10: 0x0002, 0x1c11: 0x0002,
+ 0x1c12: 0x0002, 0x1c13: 0x0002, 0x1c14: 0x0002, 0x1c15: 0x0002,
+ 0x1c30: 0x0002, 0x1c31: 0x0002, 0x1c32: 0x0002, 0x1c33: 0x0002, 0x1c34: 0x0002, 0x1c35: 0x0002,
+ 0x1c36: 0x0002, 0x1c37: 0x0002, 0x1c38: 0x0002, 0x1c39: 0x0002, 0x1c3a: 0x0002, 0x1c3b: 0x0002,
+ 0x1c3c: 0x0002, 0x1c3d: 0x0002, 0x1c3e: 0x0002, 0x1c3f: 0x0002,
+ // Block 0x71, offset 0x1c40
+ 0x1c40: 0x0002, 0x1c41: 0x0002, 0x1c42: 0x0002, 0x1c43: 0x0002, 0x1c44: 0x0002, 0x1c45: 0x0002,
+ 0x1c46: 0x0002, 0x1c47: 0x0002, 0x1c48: 0x0002, 0x1c49: 0x0002, 0x1c4a: 0x0002, 0x1c4b: 0x0002,
+ 0x1c4c: 0x0002, 0x1c4d: 0x0002, 0x1c4e: 0x0002, 0x1c4f: 0x0002, 0x1c50: 0x0002, 0x1c51: 0x0002,
+ 0x1c52: 0x0002, 0x1c53: 0x0002, 0x1c54: 0x0002, 0x1c55: 0x0002, 0x1c56: 0x0002, 0x1c57: 0x0002,
+ 0x1c58: 0x0002, 0x1c59: 0x0002, 0x1c5a: 0x0002, 0x1c5b: 0x0002, 0x1c5c: 0x0002, 0x1c5d: 0x0002,
+ 0x1c5e: 0x0002, 0x1c5f: 0x0002, 0x1c60: 0x0002, 0x1c61: 0x0002, 0x1c62: 0x0002, 0x1c63: 0x0002,
+ 0x1c64: 0x0002, 0x1c65: 0x0002, 0x1c66: 0x0002, 0x1c67: 0x0002, 0x1c68: 0x0002, 0x1c69: 0x0002,
+ 0x1c6a: 0x0001, 0x1c6b: 0x0001, 0x1c6c: 0x0001, 0x1c6d: 0x0001, 0x1c6e: 0x0002, 0x1c6f: 0x0002,
+ 0x1c70: 0x0002, 0x1c71: 0x0002, 0x1c72: 0x0002, 0x1c73: 0x0002, 0x1c74: 0x0002, 0x1c75: 0x0002,
+ 0x1c76: 0x0002, 0x1c77: 0x0002, 0x1c78: 0x0002, 0x1c79: 0x0002, 0x1c7a: 0x0002, 0x1c7b: 0x0002,
+ 0x1c7c: 0x0002, 0x1c7d: 0x0002, 0x1c7e: 0x0002,
+ // Block 0x72, offset 0x1c80
+ 0x1c81: 0x0002, 0x1c82: 0x0002, 0x1c83: 0x0002, 0x1c84: 0x0002, 0x1c85: 0x0002,
+ 0x1c86: 0x0002, 0x1c87: 0x0002, 0x1c88: 0x0002, 0x1c89: 0x0002, 0x1c8a: 0x0002, 0x1c8b: 0x0002,
+ 0x1c8c: 0x0002, 0x1c8d: 0x0002, 0x1c8e: 0x0002, 0x1c8f: 0x0002, 0x1c90: 0x0002, 0x1c91: 0x0002,
+ 0x1c92: 0x0002, 0x1c93: 0x0002, 0x1c94: 0x0002, 0x1c95: 0x0002, 0x1c96: 0x0002, 0x1c97: 0x0002,
+ 0x1c98: 0x0002, 0x1c99: 0x0002, 0x1c9a: 0x0002, 0x1c9b: 0x0002, 0x1c9c: 0x0002, 0x1c9d: 0x0002,
+ 0x1c9e: 0x0002, 0x1c9f: 0x0002, 0x1ca0: 0x0002, 0x1ca1: 0x0002, 0x1ca2: 0x0002, 0x1ca3: 0x0002,
+ 0x1ca4: 0x0002, 0x1ca5: 0x0002, 0x1ca6: 0x0002, 0x1ca7: 0x0002, 0x1ca8: 0x0002, 0x1ca9: 0x0002,
+ 0x1caa: 0x0002, 0x1cab: 0x0002, 0x1cac: 0x0002, 0x1cad: 0x0002, 0x1cae: 0x0002, 0x1caf: 0x0002,
+ 0x1cb0: 0x0002, 0x1cb1: 0x0002, 0x1cb2: 0x0002, 0x1cb3: 0x0002, 0x1cb4: 0x0002, 0x1cb5: 0x0002,
+ 0x1cb6: 0x0002, 0x1cb7: 0x0002, 0x1cb8: 0x0002, 0x1cb9: 0x0002, 0x1cba: 0x0002, 0x1cbb: 0x0002,
+ 0x1cbc: 0x0002, 0x1cbd: 0x0002, 0x1cbe: 0x0002, 0x1cbf: 0x0002,
+ // Block 0x73, offset 0x1cc0
+ 0x1cc0: 0x0002, 0x1cc1: 0x0002, 0x1cc2: 0x0002, 0x1cc3: 0x0002, 0x1cc4: 0x0002, 0x1cc5: 0x0002,
+ 0x1cc6: 0x0002, 0x1cc7: 0x0002, 0x1cc8: 0x0002, 0x1cc9: 0x0002, 0x1cca: 0x0002, 0x1ccb: 0x0002,
+ 0x1ccc: 0x0002, 0x1ccd: 0x0002, 0x1cce: 0x0002, 0x1ccf: 0x0002, 0x1cd0: 0x0002, 0x1cd1: 0x0002,
+ 0x1cd2: 0x0002, 0x1cd3: 0x0002, 0x1cd4: 0x0002, 0x1cd5: 0x0002, 0x1cd6: 0x0002,
+ 0x1cd9: 0x0001, 0x1cda: 0x0001, 0x1cdb: 0x0002, 0x1cdc: 0x0002, 0x1cdd: 0x0002,
+ 0x1cde: 0x0002, 0x1cdf: 0x0002, 0x1ce0: 0x0002, 0x1ce1: 0x0002, 0x1ce2: 0x0002, 0x1ce3: 0x0002,
+ 0x1ce4: 0x0002, 0x1ce5: 0x0002, 0x1ce6: 0x0002, 0x1ce7: 0x0002, 0x1ce8: 0x0002, 0x1ce9: 0x0002,
+ 0x1cea: 0x0002, 0x1ceb: 0x0002, 0x1cec: 0x0002, 0x1ced: 0x0002, 0x1cee: 0x0002, 0x1cef: 0x0002,
+ 0x1cf0: 0x0002, 0x1cf1: 0x0002, 0x1cf2: 0x0002, 0x1cf3: 0x0002, 0x1cf4: 0x0002, 0x1cf5: 0x0002,
+ 0x1cf6: 0x0002, 0x1cf7: 0x0002, 0x1cf8: 0x0002, 0x1cf9: 0x0002, 0x1cfa: 0x0002, 0x1cfb: 0x0002,
+ 0x1cfc: 0x0002, 0x1cfd: 0x0002, 0x1cfe: 0x0002, 0x1cff: 0x0002,
+ // Block 0x74, offset 0x1d00
+ 0x1d05: 0x0002,
+ 0x1d06: 0x0002, 0x1d07: 0x0002, 0x1d08: 0x0002, 0x1d09: 0x0002, 0x1d0a: 0x0002, 0x1d0b: 0x0002,
+ 0x1d0c: 0x0002, 0x1d0d: 0x0002, 0x1d0e: 0x0002, 0x1d0f: 0x0002, 0x1d10: 0x0002, 0x1d11: 0x0002,
+ 0x1d12: 0x0002, 0x1d13: 0x0002, 0x1d14: 0x0002, 0x1d15: 0x0002, 0x1d16: 0x0002, 0x1d17: 0x0002,
+ 0x1d18: 0x0002, 0x1d19: 0x0002, 0x1d1a: 0x0002, 0x1d1b: 0x0002, 0x1d1c: 0x0002, 0x1d1d: 0x0002,
+ 0x1d1e: 0x0002, 0x1d1f: 0x0002, 0x1d20: 0x0002, 0x1d21: 0x0002, 0x1d22: 0x0002, 0x1d23: 0x0002,
+ 0x1d24: 0x0002, 0x1d25: 0x0002, 0x1d26: 0x0002, 0x1d27: 0x0002, 0x1d28: 0x0002, 0x1d29: 0x0002,
+ 0x1d2a: 0x0002, 0x1d2b: 0x0002, 0x1d2c: 0x0002, 0x1d2d: 0x0002, 0x1d2e: 0x0002, 0x1d2f: 0x0002,
+ 0x1d31: 0x0002, 0x1d32: 0x0002, 0x1d33: 0x0002, 0x1d34: 0x0002, 0x1d35: 0x0002,
+ 0x1d36: 0x0002, 0x1d37: 0x0002, 0x1d38: 0x0002, 0x1d39: 0x0002, 0x1d3a: 0x0002, 0x1d3b: 0x0002,
+ 0x1d3c: 0x0002, 0x1d3d: 0x0002, 0x1d3e: 0x0002, 0x1d3f: 0x0002,
+ // Block 0x75, offset 0x1d40
+ 0x1d40: 0x0002, 0x1d41: 0x0002, 0x1d42: 0x0002, 0x1d43: 0x0002, 0x1d44: 0x0002, 0x1d45: 0x0002,
+ 0x1d46: 0x0002, 0x1d47: 0x0002, 0x1d48: 0x0002, 0x1d49: 0x0002, 0x1d4a: 0x0002, 0x1d4b: 0x0002,
+ 0x1d4c: 0x0002, 0x1d4d: 0x0002, 0x1d4e: 0x0002, 0x1d50: 0x0002, 0x1d51: 0x0002,
+ 0x1d52: 0x0002, 0x1d53: 0x0002, 0x1d54: 0x0002, 0x1d55: 0x0002, 0x1d56: 0x0002, 0x1d57: 0x0002,
+ 0x1d58: 0x0002, 0x1d59: 0x0002, 0x1d5a: 0x0002, 0x1d5b: 0x0002, 0x1d5c: 0x0002, 0x1d5d: 0x0002,
+ 0x1d5e: 0x0002, 0x1d5f: 0x0002, 0x1d60: 0x0002, 0x1d61: 0x0002, 0x1d62: 0x0002, 0x1d63: 0x0002,
+ 0x1d64: 0x0002, 0x1d65: 0x0002, 0x1d66: 0x0002, 0x1d67: 0x0002, 0x1d68: 0x0002, 0x1d69: 0x0002,
+ 0x1d6a: 0x0002, 0x1d6b: 0x0002, 0x1d6c: 0x0002, 0x1d6d: 0x0002, 0x1d6e: 0x0002, 0x1d6f: 0x0002,
+ 0x1d70: 0x0002, 0x1d71: 0x0002, 0x1d72: 0x0002, 0x1d73: 0x0002, 0x1d74: 0x0002, 0x1d75: 0x0002,
+ 0x1d76: 0x0002, 0x1d77: 0x0002, 0x1d78: 0x0002, 0x1d79: 0x0002, 0x1d7a: 0x0002, 0x1d7b: 0x0002,
+ 0x1d7c: 0x0002, 0x1d7d: 0x0002, 0x1d7e: 0x0002, 0x1d7f: 0x0002,
+ // Block 0x76, offset 0x1d80
+ 0x1d80: 0x0002, 0x1d81: 0x0002, 0x1d82: 0x0002, 0x1d83: 0x0002, 0x1d84: 0x0002, 0x1d85: 0x0002,
+ 0x1d86: 0x0002, 0x1d87: 0x0002, 0x1d88: 0x0002, 0x1d89: 0x0002, 0x1d8a: 0x0002, 0x1d8b: 0x0002,
+ 0x1d8c: 0x0002, 0x1d8d: 0x0002, 0x1d8e: 0x0002, 0x1d8f: 0x0002, 0x1d90: 0x0002, 0x1d91: 0x0002,
+ 0x1d92: 0x0002, 0x1d93: 0x0002, 0x1d94: 0x0002, 0x1d95: 0x0002, 0x1d96: 0x0002, 0x1d97: 0x0002,
+ 0x1d98: 0x0002, 0x1d99: 0x0002, 0x1d9a: 0x0002, 0x1d9b: 0x0002, 0x1d9c: 0x0002, 0x1d9d: 0x0002,
+ 0x1d9e: 0x0002, 0x1d9f: 0x0002, 0x1da0: 0x0002, 0x1da1: 0x0002, 0x1da2: 0x0002, 0x1da3: 0x0002,
+ 0x1da4: 0x0002, 0x1da5: 0x0002,
+ 0x1daf: 0x0002,
+ 0x1db0: 0x0002, 0x1db1: 0x0002, 0x1db2: 0x0002, 0x1db3: 0x0002, 0x1db4: 0x0002, 0x1db5: 0x0002,
+ 0x1db6: 0x0002, 0x1db7: 0x0002, 0x1db8: 0x0002, 0x1db9: 0x0002, 0x1dba: 0x0002, 0x1dbb: 0x0002,
+ 0x1dbc: 0x0002, 0x1dbd: 0x0002, 0x1dbe: 0x0002, 0x1dbf: 0x0002,
+ // Block 0x77, offset 0x1dc0
+ 0x1dc0: 0x0002, 0x1dc1: 0x0002, 0x1dc2: 0x0002, 0x1dc3: 0x0002, 0x1dc4: 0x0002, 0x1dc5: 0x0002,
+ 0x1dc6: 0x0002, 0x1dc7: 0x0002, 0x1dc8: 0x0002, 0x1dc9: 0x0002, 0x1dca: 0x0002, 0x1dcb: 0x0002,
+ 0x1dcc: 0x0002, 0x1dcd: 0x0002, 0x1dce: 0x0002, 0x1dcf: 0x0002, 0x1dd0: 0x0002, 0x1dd1: 0x0002,
+ 0x1dd2: 0x0002, 0x1dd3: 0x0002, 0x1dd4: 0x0002, 0x1dd5: 0x0002, 0x1dd6: 0x0002, 0x1dd7: 0x0002,
+ 0x1dd8: 0x0002, 0x1dd9: 0x0002, 0x1dda: 0x0002, 0x1ddb: 0x0002, 0x1ddc: 0x0002, 0x1ddd: 0x0002,
+ 0x1dde: 0x0002, 0x1de0: 0x0002, 0x1de1: 0x0002, 0x1de2: 0x0002, 0x1de3: 0x0002,
+ 0x1de4: 0x0002, 0x1de5: 0x0002, 0x1de6: 0x0002, 0x1de7: 0x0002, 0x1de8: 0x0002, 0x1de9: 0x0002,
+ 0x1dea: 0x0002, 0x1deb: 0x0002, 0x1dec: 0x0002, 0x1ded: 0x0002, 0x1dee: 0x0002, 0x1def: 0x0002,
+ 0x1df0: 0x0002, 0x1df1: 0x0002, 0x1df2: 0x0002, 0x1df3: 0x0002, 0x1df4: 0x0002, 0x1df5: 0x0002,
+ 0x1df6: 0x0002, 0x1df7: 0x0002, 0x1df8: 0x0002, 0x1df9: 0x0002, 0x1dfa: 0x0002, 0x1dfb: 0x0002,
+ 0x1dfc: 0x0002, 0x1dfd: 0x0002, 0x1dfe: 0x0002, 0x1dff: 0x0002,
+ // Block 0x78, offset 0x1e00
+ 0x1e00: 0x0002, 0x1e01: 0x0002, 0x1e02: 0x0002, 0x1e03: 0x0002, 0x1e04: 0x0002, 0x1e05: 0x0002,
+ 0x1e06: 0x0002, 0x1e07: 0x0002, 0x1e08: 0x0003, 0x1e09: 0x0003, 0x1e0a: 0x0003, 0x1e0b: 0x0003,
+ 0x1e0c: 0x0003, 0x1e0d: 0x0003, 0x1e0e: 0x0003, 0x1e0f: 0x0003, 0x1e10: 0x0002, 0x1e11: 0x0002,
+ 0x1e12: 0x0002, 0x1e13: 0x0002, 0x1e14: 0x0002, 0x1e15: 0x0002, 0x1e16: 0x0002, 0x1e17: 0x0002,
+ 0x1e18: 0x0002, 0x1e19: 0x0002, 0x1e1a: 0x0002, 0x1e1b: 0x0002, 0x1e1c: 0x0002, 0x1e1d: 0x0002,
+ 0x1e1e: 0x0002, 0x1e1f: 0x0002, 0x1e20: 0x0002, 0x1e21: 0x0002, 0x1e22: 0x0002, 0x1e23: 0x0002,
+ 0x1e24: 0x0002, 0x1e25: 0x0002, 0x1e26: 0x0002, 0x1e27: 0x0002, 0x1e28: 0x0002, 0x1e29: 0x0002,
+ 0x1e2a: 0x0002, 0x1e2b: 0x0002, 0x1e2c: 0x0002, 0x1e2d: 0x0002, 0x1e2e: 0x0002, 0x1e2f: 0x0002,
+ 0x1e30: 0x0002, 0x1e31: 0x0002, 0x1e32: 0x0002, 0x1e33: 0x0002, 0x1e34: 0x0002, 0x1e35: 0x0002,
+ 0x1e36: 0x0002, 0x1e37: 0x0002, 0x1e38: 0x0002, 0x1e39: 0x0002, 0x1e3a: 0x0002, 0x1e3b: 0x0002,
+ 0x1e3c: 0x0002, 0x1e3d: 0x0002, 0x1e3e: 0x0002, 0x1e3f: 0x0002,
+ // Block 0x79, offset 0x1e40
+ 0x1e40: 0x0002, 0x1e41: 0x0002, 0x1e42: 0x0002, 0x1e43: 0x0002, 0x1e44: 0x0002, 0x1e45: 0x0002,
+ 0x1e46: 0x0002, 0x1e47: 0x0002, 0x1e48: 0x0002, 0x1e49: 0x0002, 0x1e4a: 0x0002, 0x1e4b: 0x0002,
+ 0x1e4c: 0x0002, 0x1e50: 0x0002, 0x1e51: 0x0002,
+ 0x1e52: 0x0002, 0x1e53: 0x0002, 0x1e54: 0x0002, 0x1e55: 0x0002, 0x1e56: 0x0002, 0x1e57: 0x0002,
+ 0x1e58: 0x0002, 0x1e59: 0x0002, 0x1e5a: 0x0002, 0x1e5b: 0x0002, 0x1e5c: 0x0002, 0x1e5d: 0x0002,
+ 0x1e5e: 0x0002, 0x1e5f: 0x0002, 0x1e60: 0x0002, 0x1e61: 0x0002, 0x1e62: 0x0002, 0x1e63: 0x0002,
+ 0x1e64: 0x0002, 0x1e65: 0x0002, 0x1e66: 0x0002, 0x1e67: 0x0002, 0x1e68: 0x0002, 0x1e69: 0x0002,
+ 0x1e6a: 0x0002, 0x1e6b: 0x0002, 0x1e6c: 0x0002, 0x1e6d: 0x0002, 0x1e6e: 0x0002, 0x1e6f: 0x0002,
+ 0x1e70: 0x0002, 0x1e71: 0x0002, 0x1e72: 0x0002, 0x1e73: 0x0002, 0x1e74: 0x0002, 0x1e75: 0x0002,
+ 0x1e76: 0x0002, 0x1e77: 0x0002, 0x1e78: 0x0002, 0x1e79: 0x0002, 0x1e7a: 0x0002, 0x1e7b: 0x0002,
+ 0x1e7c: 0x0002, 0x1e7d: 0x0002, 0x1e7e: 0x0002, 0x1e7f: 0x0002,
+ // Block 0x7a, offset 0x1e80
+ 0x1e80: 0x0002, 0x1e81: 0x0002, 0x1e82: 0x0002, 0x1e83: 0x0002, 0x1e84: 0x0002, 0x1e85: 0x0002,
+ 0x1e86: 0x0002,
+ // Block 0x7b, offset 0x1ec0
+ 0x1eef: 0x0001,
+ 0x1ef0: 0x0001, 0x1ef1: 0x0001, 0x1ef2: 0x0001, 0x1ef4: 0x0001, 0x1ef5: 0x0001,
+ 0x1ef6: 0x0001, 0x1ef7: 0x0001, 0x1ef8: 0x0001, 0x1ef9: 0x0001, 0x1efa: 0x0001, 0x1efb: 0x0001,
+ 0x1efc: 0x0001, 0x1efd: 0x0001,
+ // Block 0x7c, offset 0x1f00
+ 0x1f1e: 0x0001, 0x1f1f: 0x0001,
+ // Block 0x7d, offset 0x1f40
+ 0x1f70: 0x0001, 0x1f71: 0x0001,
+ // Block 0x7e, offset 0x1f80
+ 0x1f82: 0x0001,
+ 0x1f86: 0x0001, 0x1f8b: 0x0001,
+ 0x1fa5: 0x0001, 0x1fa6: 0x0001,
+ 0x1fac: 0x0001,
+ // Block 0x7f, offset 0x1fc0
+ 0x1fc4: 0x0001, 0x1fc5: 0x0001,
+ 0x1fe0: 0x0001, 0x1fe1: 0x0001, 0x1fe2: 0x0001, 0x1fe3: 0x0001,
+ 0x1fe4: 0x0001, 0x1fe5: 0x0001, 0x1fe6: 0x0001, 0x1fe7: 0x0001, 0x1fe8: 0x0001, 0x1fe9: 0x0001,
+ 0x1fea: 0x0001, 0x1feb: 0x0001, 0x1fec: 0x0001, 0x1fed: 0x0001, 0x1fee: 0x0001, 0x1fef: 0x0001,
+ 0x1ff0: 0x0001, 0x1ff1: 0x0001,
+ 0x1fff: 0x0001,
+ // Block 0x80, offset 0x2000
+ 0x2026: 0x0001, 0x2027: 0x0001, 0x2028: 0x0001, 0x2029: 0x0001,
+ 0x202a: 0x0001, 0x202b: 0x0001, 0x202c: 0x0001, 0x202d: 0x0001,
+ // Block 0x81, offset 0x2040
+ 0x2047: 0x0001, 0x2048: 0x0001, 0x2049: 0x0001, 0x204a: 0x0001, 0x204b: 0x0001,
+ 0x204c: 0x0001, 0x204d: 0x0001, 0x204e: 0x0001, 0x204f: 0x0001, 0x2050: 0x0001, 0x2051: 0x0001,
+ 0x2060: 0x0002, 0x2061: 0x0002, 0x2062: 0x0002, 0x2063: 0x0002,
+ 0x2064: 0x0002, 0x2065: 0x0002, 0x2066: 0x0002, 0x2067: 0x0002, 0x2068: 0x0002, 0x2069: 0x0002,
+ 0x206a: 0x0002, 0x206b: 0x0002, 0x206c: 0x0002, 0x206d: 0x0002, 0x206e: 0x0002, 0x206f: 0x0002,
+ 0x2070: 0x0002, 0x2071: 0x0002, 0x2072: 0x0002, 0x2073: 0x0002, 0x2074: 0x0002, 0x2075: 0x0002,
+ 0x2076: 0x0002, 0x2077: 0x0002, 0x2078: 0x0002, 0x2079: 0x0002, 0x207a: 0x0002, 0x207b: 0x0002,
+ 0x207c: 0x0002,
+ // Block 0x82, offset 0x2080
+ 0x2080: 0x0001, 0x2081: 0x0001, 0x2082: 0x0001,
+ 0x20b3: 0x0001,
+ 0x20b6: 0x0001, 0x20b7: 0x0001, 0x20b8: 0x0001, 0x20b9: 0x0001,
+ 0x20bc: 0x0001, 0x20bd: 0x0001,
+ // Block 0x83, offset 0x20c0
+ 0x20e5: 0x0001,
+ // Block 0x84, offset 0x2100
+ 0x2129: 0x0001,
+ 0x212a: 0x0001, 0x212b: 0x0001, 0x212c: 0x0001, 0x212d: 0x0001, 0x212e: 0x0001,
+ 0x2131: 0x0001, 0x2132: 0x0001, 0x2135: 0x0001,
+ 0x2136: 0x0001,
+ // Block 0x85, offset 0x2140
+ 0x2143: 0x0001,
+ 0x214c: 0x0001,
+ 0x217c: 0x0001,
+ // Block 0x86, offset 0x2180
+ 0x21b0: 0x0001, 0x21b2: 0x0001, 0x21b3: 0x0001, 0x21b4: 0x0001,
+ 0x21b7: 0x0001, 0x21b8: 0x0001,
+ 0x21be: 0x0001, 0x21bf: 0x0001,
+ // Block 0x87, offset 0x21c0
+ 0x21c1: 0x0001,
+ 0x21ec: 0x0001, 0x21ed: 0x0001,
+ 0x21f6: 0x0001,
+ // Block 0x88, offset 0x2200
+ 0x2225: 0x0001, 0x2228: 0x0001,
+ 0x222d: 0x0001,
+ // Block 0x89, offset 0x2240
+ 0x2240: 0x0002, 0x2241: 0x0002, 0x2242: 0x0002, 0x2243: 0x0002, 0x2244: 0x0002, 0x2245: 0x0002,
+ 0x2246: 0x0002, 0x2247: 0x0002, 0x2248: 0x0002, 0x2249: 0x0002, 0x224a: 0x0002, 0x224b: 0x0002,
+ 0x224c: 0x0002, 0x224d: 0x0002, 0x224e: 0x0002, 0x224f: 0x0002, 0x2250: 0x0002, 0x2251: 0x0002,
+ 0x2252: 0x0002, 0x2253: 0x0002, 0x2254: 0x0002, 0x2255: 0x0002, 0x2256: 0x0002, 0x2257: 0x0002,
+ 0x2258: 0x0002, 0x2259: 0x0002, 0x225a: 0x0002, 0x225b: 0x0002, 0x225c: 0x0002, 0x225d: 0x0002,
+ 0x225e: 0x0002, 0x225f: 0x0002, 0x2260: 0x0002, 0x2261: 0x0002, 0x2262: 0x0002, 0x2263: 0x0002,
+ // Block 0x8a, offset 0x2280
+ 0x229e: 0x0001,
+ // Block 0x8b, offset 0x22c0
+ 0x22c0: 0x0001, 0x22c1: 0x0001, 0x22c2: 0x0001, 0x22c3: 0x0001, 0x22c4: 0x0001, 0x22c5: 0x0001,
+ 0x22c6: 0x0001, 0x22c7: 0x0001, 0x22c8: 0x0001, 0x22c9: 0x0001, 0x22ca: 0x0001, 0x22cb: 0x0001,
+ 0x22cc: 0x0001, 0x22cd: 0x0001, 0x22ce: 0x0001, 0x22cf: 0x0001, 0x22d0: 0x0002, 0x22d1: 0x0002,
+ 0x22d2: 0x0002, 0x22d3: 0x0002, 0x22d4: 0x0002, 0x22d5: 0x0002, 0x22d6: 0x0002, 0x22d7: 0x0002,
+ 0x22d8: 0x0002, 0x22d9: 0x0002,
+ 0x22e0: 0x0001, 0x22e1: 0x0001, 0x22e2: 0x0001, 0x22e3: 0x0001,
+ 0x22e4: 0x0001, 0x22e5: 0x0001, 0x22e6: 0x0001, 0x22e7: 0x0001, 0x22e8: 0x0001, 0x22e9: 0x0001,
+ 0x22ea: 0x0001, 0x22eb: 0x0001, 0x22ec: 0x0001, 0x22ed: 0x0001, 0x22ee: 0x0001, 0x22ef: 0x0001,
+ 0x22f0: 0x0002, 0x22f1: 0x0002, 0x22f2: 0x0002, 0x22f3: 0x0002, 0x22f4: 0x0002, 0x22f5: 0x0002,
+ 0x22f6: 0x0002, 0x22f7: 0x0002, 0x22f8: 0x0002, 0x22f9: 0x0002, 0x22fa: 0x0002, 0x22fb: 0x0002,
+ 0x22fc: 0x0002, 0x22fd: 0x0002, 0x22fe: 0x0002, 0x22ff: 0x0002,
+ // Block 0x8c, offset 0x2300
+ 0x2300: 0x0002, 0x2301: 0x0002, 0x2302: 0x0002, 0x2303: 0x0002, 0x2304: 0x0002, 0x2305: 0x0002,
+ 0x2306: 0x0002, 0x2307: 0x0002, 0x2308: 0x0002, 0x2309: 0x0002, 0x230a: 0x0002, 0x230b: 0x0002,
+ 0x230c: 0x0002, 0x230d: 0x0002, 0x230e: 0x0002, 0x230f: 0x0002, 0x2310: 0x0002, 0x2311: 0x0002,
+ 0x2312: 0x0002, 0x2314: 0x0002, 0x2315: 0x0002, 0x2316: 0x0002, 0x2317: 0x0002,
+ 0x2318: 0x0002, 0x2319: 0x0002, 0x231a: 0x0002, 0x231b: 0x0002, 0x231c: 0x0002, 0x231d: 0x0002,
+ 0x231e: 0x0002, 0x231f: 0x0002, 0x2320: 0x0002, 0x2321: 0x0002, 0x2322: 0x0002, 0x2323: 0x0002,
+ 0x2324: 0x0002, 0x2325: 0x0002, 0x2326: 0x0002, 0x2328: 0x0002, 0x2329: 0x0002,
+ 0x232a: 0x0002, 0x232b: 0x0002,
+ // Block 0x8d, offset 0x2340
+ 0x2340: 0x0002, 0x2341: 0x0002, 0x2342: 0x0002, 0x2343: 0x0002, 0x2344: 0x0002, 0x2345: 0x0002,
+ 0x2346: 0x0002, 0x2347: 0x0002, 0x2348: 0x0002, 0x2349: 0x0002, 0x234a: 0x0002, 0x234b: 0x0002,
+ 0x234c: 0x0002, 0x234d: 0x0002, 0x234e: 0x0002, 0x234f: 0x0002, 0x2350: 0x0002, 0x2351: 0x0002,
+ 0x2352: 0x0002, 0x2353: 0x0002, 0x2354: 0x0002, 0x2355: 0x0002, 0x2356: 0x0002, 0x2357: 0x0002,
+ 0x2358: 0x0002, 0x2359: 0x0002, 0x235a: 0x0002, 0x235b: 0x0002, 0x235c: 0x0002, 0x235d: 0x0002,
+ 0x235e: 0x0002, 0x235f: 0x0002, 0x2360: 0x0002,
+ // Block 0x8e, offset 0x2380
+ 0x23a0: 0x0002, 0x23a1: 0x0002, 0x23a2: 0x0002, 0x23a3: 0x0002,
+ 0x23a4: 0x0002, 0x23a5: 0x0002, 0x23a6: 0x0002,
+ 0x23b9: 0x0001, 0x23ba: 0x0001, 0x23bb: 0x0001,
+ 0x23be: 0x0001, 0x23bf: 0x0001,
+ // Block 0x8f, offset 0x23c0
+ 0x23fd: 0x0001,
+ // Block 0x90, offset 0x2400
+ 0x2420: 0x0001,
+ // Block 0x91, offset 0x2440
+ 0x2476: 0x0001, 0x2477: 0x0001, 0x2478: 0x0001, 0x2479: 0x0001, 0x247a: 0x0001,
+ // Block 0x92, offset 0x2480
+ 0x2481: 0x0001, 0x2482: 0x0001, 0x2483: 0x0001, 0x2485: 0x0001,
+ 0x2486: 0x0001,
+ 0x248c: 0x0001, 0x248d: 0x0001, 0x248e: 0x0001, 0x248f: 0x0001,
+ 0x24b8: 0x0001, 0x24b9: 0x0001, 0x24ba: 0x0001,
+ 0x24bf: 0x0001,
+ // Block 0x93, offset 0x24c0
+ 0x24e5: 0x0001, 0x24e6: 0x0001,
+ // Block 0x94, offset 0x2500
+ 0x2524: 0x0001, 0x2525: 0x0001, 0x2526: 0x0001, 0x2527: 0x0001,
+ // Block 0x95, offset 0x2540
+ 0x256b: 0x0001, 0x256c: 0x0001,
+ // Block 0x96, offset 0x2580
+ 0x25bd: 0x0001, 0x25be: 0x0001, 0x25bf: 0x0001,
+ // Block 0x97, offset 0x25c0
+ 0x25c6: 0x0001, 0x25c7: 0x0001, 0x25c8: 0x0001, 0x25c9: 0x0001, 0x25ca: 0x0001, 0x25cb: 0x0001,
+ 0x25cc: 0x0001, 0x25cd: 0x0001, 0x25ce: 0x0001, 0x25cf: 0x0001, 0x25d0: 0x0001,
+ // Block 0x98, offset 0x2600
+ 0x2602: 0x0001, 0x2603: 0x0001, 0x2604: 0x0001, 0x2605: 0x0001,
+ // Block 0x99, offset 0x2640
+ 0x2641: 0x0001,
+ 0x2678: 0x0001, 0x2679: 0x0001, 0x267a: 0x0001, 0x267b: 0x0001,
+ 0x267c: 0x0001, 0x267d: 0x0001, 0x267e: 0x0001, 0x267f: 0x0001,
+ // Block 0x9a, offset 0x2680
+ 0x2680: 0x0001, 0x2681: 0x0001, 0x2682: 0x0001, 0x2683: 0x0001, 0x2684: 0x0001, 0x2685: 0x0001,
+ 0x2686: 0x0001,
+ 0x26b0: 0x0001, 0x26b3: 0x0001, 0x26b4: 0x0001,
+ 0x26bf: 0x0001,
+ // Block 0x9b, offset 0x26c0
+ 0x26c0: 0x0001, 0x26c1: 0x0001,
+ 0x26f3: 0x0001, 0x26f4: 0x0001, 0x26f5: 0x0001,
+ 0x26f6: 0x0001, 0x26f9: 0x0001, 0x26fa: 0x0001,
+ 0x26fd: 0x0001,
+ // Block 0x9c, offset 0x2700
+ 0x2702: 0x0001,
+ 0x270d: 0x0001,
+ // Block 0x9d, offset 0x2740
+ 0x2740: 0x0001, 0x2741: 0x0001, 0x2742: 0x0001,
+ 0x2767: 0x0001, 0x2768: 0x0001, 0x2769: 0x0001,
+ 0x276a: 0x0001, 0x276b: 0x0001, 0x276d: 0x0001, 0x276e: 0x0001, 0x276f: 0x0001,
+ 0x2770: 0x0001, 0x2771: 0x0001, 0x2772: 0x0001, 0x2773: 0x0001, 0x2774: 0x0001,
+ // Block 0x9e, offset 0x2780
+ 0x27b3: 0x0001,
+ // Block 0x9f, offset 0x27c0
+ 0x27c0: 0x0001, 0x27c1: 0x0001,
+ 0x27f6: 0x0001, 0x27f7: 0x0001, 0x27f8: 0x0001, 0x27f9: 0x0001, 0x27fa: 0x0001, 0x27fb: 0x0001,
+ 0x27fc: 0x0001, 0x27fd: 0x0001, 0x27fe: 0x0001,
+ // Block 0xa0, offset 0x2800
+ 0x2809: 0x0001, 0x280a: 0x0001, 0x280b: 0x0001,
+ 0x280c: 0x0001, 0x280f: 0x0001,
+ // Block 0xa1, offset 0x2840
+ 0x286f: 0x0001,
+ 0x2870: 0x0001, 0x2871: 0x0001, 0x2874: 0x0001,
+ 0x2876: 0x0001, 0x2877: 0x0001,
+ 0x287e: 0x0001,
+ // Block 0xa2, offset 0x2880
+ 0x289f: 0x0001, 0x28a3: 0x0001,
+ 0x28a4: 0x0001, 0x28a5: 0x0001, 0x28a6: 0x0001, 0x28a7: 0x0001, 0x28a8: 0x0001, 0x28a9: 0x0001,
+ 0x28aa: 0x0001,
+ // Block 0xa3, offset 0x28c0
+ 0x28c0: 0x0001,
+ 0x28e6: 0x0001, 0x28e7: 0x0001, 0x28e8: 0x0001, 0x28e9: 0x0001,
+ 0x28ea: 0x0001, 0x28eb: 0x0001, 0x28ec: 0x0001,
+ 0x28f0: 0x0001, 0x28f1: 0x0001, 0x28f2: 0x0001, 0x28f3: 0x0001, 0x28f4: 0x0001,
+ // Block 0xa4, offset 0x2900
+ 0x2938: 0x0001, 0x2939: 0x0001, 0x293a: 0x0001, 0x293b: 0x0001,
+ 0x293c: 0x0001, 0x293d: 0x0001, 0x293e: 0x0001, 0x293f: 0x0001,
+ // Block 0xa5, offset 0x2940
+ 0x2942: 0x0001, 0x2943: 0x0001, 0x2944: 0x0001,
+ 0x2946: 0x0001,
+ 0x295e: 0x0001,
+ // Block 0xa6, offset 0x2980
+ 0x29b3: 0x0001, 0x29b4: 0x0001, 0x29b5: 0x0001,
+ 0x29b6: 0x0001, 0x29b7: 0x0001, 0x29b8: 0x0001, 0x29ba: 0x0001,
+ 0x29bf: 0x0001,
+ // Block 0xa7, offset 0x29c0
+ 0x29c0: 0x0001, 0x29c2: 0x0001, 0x29c3: 0x0001,
+ // Block 0xa8, offset 0x2a00
+ 0x2a32: 0x0001, 0x2a33: 0x0001, 0x2a34: 0x0001, 0x2a35: 0x0001,
+ 0x2a3c: 0x0001, 0x2a3d: 0x0001, 0x2a3f: 0x0001,
+ // Block 0xa9, offset 0x2a40
+ 0x2a40: 0x0001,
+ 0x2a5c: 0x0001, 0x2a5d: 0x0001,
+ // Block 0xaa, offset 0x2a80
+ 0x2ab3: 0x0001, 0x2ab4: 0x0001, 0x2ab5: 0x0001,
+ 0x2ab6: 0x0001, 0x2ab7: 0x0001, 0x2ab8: 0x0001, 0x2ab9: 0x0001, 0x2aba: 0x0001,
+ 0x2abd: 0x0001, 0x2abf: 0x0001,
+ // Block 0xab, offset 0x2ac0
+ 0x2ac0: 0x0001,
+ // Block 0xac, offset 0x2b00
+ 0x2b2b: 0x0001, 0x2b2d: 0x0001,
+ 0x2b30: 0x0001, 0x2b31: 0x0001, 0x2b32: 0x0001, 0x2b33: 0x0001, 0x2b34: 0x0001, 0x2b35: 0x0001,
+ 0x2b37: 0x0001,
+ // Block 0xad, offset 0x2b40
+ 0x2b5d: 0x0001,
+ 0x2b5e: 0x0001, 0x2b5f: 0x0001, 0x2b62: 0x0001, 0x2b63: 0x0001,
+ 0x2b64: 0x0001, 0x2b65: 0x0001, 0x2b67: 0x0001, 0x2b68: 0x0001, 0x2b69: 0x0001,
+ 0x2b6a: 0x0001, 0x2b6b: 0x0001,
+ // Block 0xae, offset 0x2b80
+ 0x2baf: 0x0001,
+ 0x2bb0: 0x0001, 0x2bb1: 0x0001, 0x2bb2: 0x0001, 0x2bb3: 0x0001, 0x2bb4: 0x0001, 0x2bb5: 0x0001,
+ 0x2bb6: 0x0001, 0x2bb7: 0x0001, 0x2bb9: 0x0001, 0x2bba: 0x0001,
+ // Block 0xaf, offset 0x2bc0
+ 0x2bfb: 0x0001,
+ 0x2bfc: 0x0001, 0x2bfe: 0x0001,
+ // Block 0xb0, offset 0x2c00
+ 0x2c03: 0x0001,
+ // Block 0xb1, offset 0x2c40
+ 0x2c54: 0x0001, 0x2c55: 0x0001, 0x2c56: 0x0001, 0x2c57: 0x0001,
+ 0x2c5a: 0x0001, 0x2c5b: 0x0001,
+ 0x2c60: 0x0001,
+ // Block 0xb2, offset 0x2c80
+ 0x2c81: 0x0001, 0x2c82: 0x0001, 0x2c83: 0x0001, 0x2c84: 0x0001, 0x2c85: 0x0001,
+ 0x2c86: 0x0001, 0x2c87: 0x0001, 0x2c88: 0x0001, 0x2c89: 0x0001, 0x2c8a: 0x0001,
+ 0x2cb3: 0x0001, 0x2cb4: 0x0001, 0x2cb5: 0x0001,
+ 0x2cb6: 0x0001, 0x2cb7: 0x0001, 0x2cb8: 0x0001, 0x2cbb: 0x0001,
+ 0x2cbc: 0x0001, 0x2cbd: 0x0001, 0x2cbe: 0x0001,
+ // Block 0xb3, offset 0x2cc0
+ 0x2cc7: 0x0001,
+ 0x2cd1: 0x0001,
+ 0x2cd2: 0x0001, 0x2cd3: 0x0001, 0x2cd4: 0x0001, 0x2cd5: 0x0001, 0x2cd6: 0x0001,
+ 0x2cd9: 0x0001, 0x2cda: 0x0001, 0x2cdb: 0x0001,
+ // Block 0xb4, offset 0x2d00
+ 0x2d0a: 0x0001, 0x2d0b: 0x0001,
+ 0x2d0c: 0x0001, 0x2d0d: 0x0001, 0x2d0e: 0x0001, 0x2d0f: 0x0001, 0x2d10: 0x0001, 0x2d11: 0x0001,
+ 0x2d12: 0x0001, 0x2d13: 0x0001, 0x2d14: 0x0001, 0x2d15: 0x0001, 0x2d16: 0x0001,
+ 0x2d18: 0x0001, 0x2d19: 0x0001,
+ // Block 0xb5, offset 0x2d40
+ 0x2d70: 0x0001, 0x2d71: 0x0001, 0x2d72: 0x0001, 0x2d73: 0x0001, 0x2d74: 0x0001, 0x2d75: 0x0001,
+ 0x2d76: 0x0001, 0x2d78: 0x0001, 0x2d79: 0x0001, 0x2d7a: 0x0001, 0x2d7b: 0x0001,
+ 0x2d7c: 0x0001, 0x2d7d: 0x0001, 0x2d7f: 0x0001,
+ // Block 0xb6, offset 0x2d80
+ 0x2d92: 0x0001, 0x2d93: 0x0001, 0x2d94: 0x0001, 0x2d95: 0x0001, 0x2d96: 0x0001, 0x2d97: 0x0001,
+ 0x2d98: 0x0001, 0x2d99: 0x0001, 0x2d9a: 0x0001, 0x2d9b: 0x0001, 0x2d9c: 0x0001, 0x2d9d: 0x0001,
+ 0x2d9e: 0x0001, 0x2d9f: 0x0001, 0x2da0: 0x0001, 0x2da1: 0x0001, 0x2da2: 0x0001, 0x2da3: 0x0001,
+ 0x2da4: 0x0001, 0x2da5: 0x0001, 0x2da6: 0x0001, 0x2da7: 0x0001,
+ 0x2daa: 0x0001, 0x2dab: 0x0001, 0x2dac: 0x0001, 0x2dad: 0x0001, 0x2dae: 0x0001, 0x2daf: 0x0001,
+ 0x2db0: 0x0001, 0x2db2: 0x0001, 0x2db3: 0x0001, 0x2db5: 0x0001,
+ 0x2db6: 0x0001,
+ // Block 0xb7, offset 0x2dc0
+ 0x2df1: 0x0001, 0x2df2: 0x0001, 0x2df3: 0x0001, 0x2df4: 0x0001, 0x2df5: 0x0001,
+ 0x2df6: 0x0001, 0x2dfa: 0x0001,
+ 0x2dfc: 0x0001, 0x2dfd: 0x0001, 0x2dff: 0x0001,
+ // Block 0xb8, offset 0x2e00
+ 0x2e00: 0x0001, 0x2e01: 0x0001, 0x2e02: 0x0001, 0x2e03: 0x0001, 0x2e04: 0x0001, 0x2e05: 0x0001,
+ 0x2e07: 0x0001,
+ // Block 0xb9, offset 0x2e40
+ 0x2e50: 0x0001, 0x2e51: 0x0001,
+ 0x2e55: 0x0001, 0x2e57: 0x0001,
+ // Block 0xba, offset 0x2e80
+ 0x2eb3: 0x0001, 0x2eb4: 0x0001,
+ // Block 0xbb, offset 0x2ec0
+ 0x2ec0: 0x0001, 0x2ec1: 0x0001,
+ 0x2ef6: 0x0001, 0x2ef7: 0x0001, 0x2ef8: 0x0001, 0x2ef9: 0x0001, 0x2efa: 0x0001,
+ // Block 0xbc, offset 0x2f00
+ 0x2f00: 0x0001, 0x2f02: 0x0001,
+ // Block 0xbd, offset 0x2f40
+ 0x2f40: 0x0001,
+ 0x2f47: 0x0001, 0x2f48: 0x0001, 0x2f49: 0x0001, 0x2f4a: 0x0001, 0x2f4b: 0x0001,
+ 0x2f4c: 0x0001, 0x2f4d: 0x0001, 0x2f4e: 0x0001, 0x2f4f: 0x0001, 0x2f50: 0x0001, 0x2f51: 0x0001,
+ 0x2f52: 0x0001, 0x2f53: 0x0001, 0x2f54: 0x0001, 0x2f55: 0x0001,
+ // Block 0xbe, offset 0x2f80
+ 0x2fb0: 0x0001, 0x2fb1: 0x0001, 0x2fb2: 0x0001, 0x2fb3: 0x0001, 0x2fb4: 0x0001,
+ // Block 0xbf, offset 0x2fc0
+ 0x2ff0: 0x0001, 0x2ff1: 0x0001, 0x2ff2: 0x0001, 0x2ff3: 0x0001, 0x2ff4: 0x0001, 0x2ff5: 0x0001,
+ 0x2ff6: 0x0001,
+ // Block 0xc0, offset 0x3000
+ 0x300f: 0x0001,
+ // Block 0xc1, offset 0x3040
+ 0x304f: 0x0001, 0x3050: 0x0001, 0x3051: 0x0001,
+ 0x3052: 0x0001,
+ // Block 0xc2, offset 0x3080
+ 0x30a0: 0x0002, 0x30a1: 0x0002, 0x30a2: 0x0002, 0x30a3: 0x0002,
+ 0x30a4: 0x0001,
+ 0x30b0: 0x0002, 0x30b1: 0x0002, 0x30b2: 0x0002, 0x30b3: 0x0002, 0x30b4: 0x0002, 0x30b5: 0x0002,
+ 0x30b6: 0x0002,
+ // Block 0xc3, offset 0x30c0
+ 0x30c0: 0x0002, 0x30c1: 0x0002, 0x30c2: 0x0002, 0x30c3: 0x0002, 0x30c4: 0x0002, 0x30c5: 0x0002,
+ 0x30c6: 0x0002, 0x30c7: 0x0002, 0x30c8: 0x0002, 0x30c9: 0x0002, 0x30ca: 0x0002, 0x30cb: 0x0002,
+ 0x30cc: 0x0002, 0x30cd: 0x0002, 0x30ce: 0x0002, 0x30cf: 0x0002, 0x30d0: 0x0002, 0x30d1: 0x0002,
+ 0x30d2: 0x0002, 0x30d3: 0x0002, 0x30d4: 0x0002, 0x30d5: 0x0002,
+ 0x30ff: 0x0002,
+ // Block 0xc4, offset 0x3100
+ 0x3100: 0x0002, 0x3101: 0x0002, 0x3102: 0x0002, 0x3103: 0x0002, 0x3104: 0x0002, 0x3105: 0x0002,
+ 0x3106: 0x0002, 0x3107: 0x0002, 0x3108: 0x0002, 0x3109: 0x0002, 0x310a: 0x0002, 0x310b: 0x0002,
+ 0x310c: 0x0002, 0x310d: 0x0002, 0x310e: 0x0002, 0x310f: 0x0002, 0x3110: 0x0002, 0x3111: 0x0002,
+ 0x3112: 0x0002, 0x3113: 0x0002, 0x3114: 0x0002, 0x3115: 0x0002, 0x3116: 0x0002, 0x3117: 0x0002,
+ 0x3118: 0x0002, 0x3119: 0x0002, 0x311a: 0x0002, 0x311b: 0x0002, 0x311c: 0x0002, 0x311d: 0x0002,
+ 0x311e: 0x0002,
+ // Block 0xc5, offset 0x3140
+ 0x3140: 0x0002, 0x3141: 0x0002, 0x3142: 0x0002, 0x3143: 0x0002, 0x3144: 0x0002, 0x3145: 0x0002,
+ 0x3146: 0x0002, 0x3147: 0x0002, 0x3148: 0x0002, 0x3149: 0x0002, 0x314a: 0x0002, 0x314b: 0x0002,
+ 0x314c: 0x0002, 0x314d: 0x0002, 0x314e: 0x0002, 0x314f: 0x0002, 0x3150: 0x0002, 0x3151: 0x0002,
+ 0x3152: 0x0002, 0x3153: 0x0002, 0x3154: 0x0002, 0x3155: 0x0002, 0x3156: 0x0002, 0x3157: 0x0002,
+ 0x3158: 0x0002, 0x3159: 0x0002, 0x315a: 0x0002, 0x315b: 0x0002, 0x315c: 0x0002, 0x315d: 0x0002,
+ 0x315e: 0x0002, 0x315f: 0x0002, 0x3160: 0x0002, 0x3161: 0x0002, 0x3162: 0x0002, 0x3163: 0x0002,
+ 0x3164: 0x0002, 0x3165: 0x0002, 0x3166: 0x0002, 0x3167: 0x0002, 0x3168: 0x0002, 0x3169: 0x0002,
+ 0x316a: 0x0002, 0x316b: 0x0002, 0x316c: 0x0002, 0x316d: 0x0002, 0x316e: 0x0002, 0x316f: 0x0002,
+ 0x3170: 0x0002, 0x3171: 0x0002, 0x3172: 0x0002,
+ // Block 0xc6, offset 0x3180
+ 0x31b0: 0x0002, 0x31b1: 0x0002, 0x31b2: 0x0002, 0x31b3: 0x0002, 0x31b5: 0x0002,
+ 0x31b6: 0x0002, 0x31b7: 0x0002, 0x31b8: 0x0002, 0x31b9: 0x0002, 0x31ba: 0x0002, 0x31bb: 0x0002,
+ 0x31bd: 0x0002, 0x31be: 0x0002,
+ // Block 0xc7, offset 0x31c0
+ 0x31c0: 0x0002, 0x31c1: 0x0002, 0x31c2: 0x0002, 0x31c3: 0x0002, 0x31c4: 0x0002, 0x31c5: 0x0002,
+ 0x31c6: 0x0002, 0x31c7: 0x0002, 0x31c8: 0x0002, 0x31c9: 0x0002, 0x31ca: 0x0002, 0x31cb: 0x0002,
+ 0x31cc: 0x0002, 0x31cd: 0x0002, 0x31ce: 0x0002, 0x31cf: 0x0002, 0x31d0: 0x0002, 0x31d1: 0x0002,
+ 0x31d2: 0x0002, 0x31d3: 0x0002, 0x31d4: 0x0002, 0x31d5: 0x0002, 0x31d6: 0x0002, 0x31d7: 0x0002,
+ 0x31d8: 0x0002, 0x31d9: 0x0002, 0x31da: 0x0002, 0x31db: 0x0002, 0x31dc: 0x0002, 0x31dd: 0x0002,
+ 0x31de: 0x0002, 0x31df: 0x0002, 0x31e0: 0x0002, 0x31e1: 0x0002, 0x31e2: 0x0002,
+ 0x31f2: 0x0002,
+ // Block 0xc8, offset 0x3200
+ 0x3210: 0x0002, 0x3211: 0x0002,
+ 0x3212: 0x0002, 0x3215: 0x0002,
+ 0x3224: 0x0002, 0x3225: 0x0002, 0x3226: 0x0002, 0x3227: 0x0002,
+ 0x3230: 0x0002, 0x3231: 0x0002, 0x3232: 0x0002, 0x3233: 0x0002, 0x3234: 0x0002, 0x3235: 0x0002,
+ 0x3236: 0x0002, 0x3237: 0x0002, 0x3238: 0x0002, 0x3239: 0x0002, 0x323a: 0x0002, 0x323b: 0x0002,
+ 0x323c: 0x0002, 0x323d: 0x0002, 0x323e: 0x0002, 0x323f: 0x0002,
+ // Block 0xc9, offset 0x3240
+ 0x3240: 0x0002, 0x3241: 0x0002, 0x3242: 0x0002, 0x3243: 0x0002, 0x3244: 0x0002, 0x3245: 0x0002,
+ 0x3246: 0x0002, 0x3247: 0x0002, 0x3248: 0x0002, 0x3249: 0x0002, 0x324a: 0x0002, 0x324b: 0x0002,
+ 0x324c: 0x0002, 0x324d: 0x0002, 0x324e: 0x0002, 0x324f: 0x0002, 0x3250: 0x0002, 0x3251: 0x0002,
+ 0x3252: 0x0002, 0x3253: 0x0002, 0x3254: 0x0002, 0x3255: 0x0002, 0x3256: 0x0002, 0x3257: 0x0002,
+ 0x3258: 0x0002, 0x3259: 0x0002, 0x325a: 0x0002, 0x325b: 0x0002, 0x325c: 0x0002, 0x325d: 0x0002,
+ 0x325e: 0x0002, 0x325f: 0x0002, 0x3260: 0x0002, 0x3261: 0x0002, 0x3262: 0x0002, 0x3263: 0x0002,
+ 0x3264: 0x0002, 0x3265: 0x0002, 0x3266: 0x0002, 0x3267: 0x0002, 0x3268: 0x0002, 0x3269: 0x0002,
+ 0x326a: 0x0002, 0x326b: 0x0002, 0x326c: 0x0002, 0x326d: 0x0002, 0x326e: 0x0002, 0x326f: 0x0002,
+ 0x3270: 0x0002, 0x3271: 0x0002, 0x3272: 0x0002, 0x3273: 0x0002, 0x3274: 0x0002, 0x3275: 0x0002,
+ 0x3276: 0x0002, 0x3277: 0x0002, 0x3278: 0x0002, 0x3279: 0x0002, 0x327a: 0x0002, 0x327b: 0x0002,
+ // Block 0xca, offset 0x3280
+ 0x329d: 0x0001,
+ 0x329e: 0x0001, 0x32a0: 0x0001, 0x32a1: 0x0001, 0x32a2: 0x0001, 0x32a3: 0x0001,
+ // Block 0xcb, offset 0x32c0
+ 0x32c0: 0x0001, 0x32c1: 0x0001, 0x32c2: 0x0001, 0x32c3: 0x0001, 0x32c4: 0x0001, 0x32c5: 0x0001,
+ 0x32c6: 0x0001, 0x32c7: 0x0001, 0x32c8: 0x0001, 0x32c9: 0x0001, 0x32ca: 0x0001, 0x32cb: 0x0001,
+ 0x32cc: 0x0001, 0x32cd: 0x0001, 0x32ce: 0x0001, 0x32cf: 0x0001, 0x32d0: 0x0001, 0x32d1: 0x0001,
+ 0x32d2: 0x0001, 0x32d3: 0x0001, 0x32d4: 0x0001, 0x32d5: 0x0001, 0x32d6: 0x0001, 0x32d7: 0x0001,
+ 0x32d8: 0x0001, 0x32d9: 0x0001, 0x32da: 0x0001, 0x32db: 0x0001, 0x32dc: 0x0001, 0x32dd: 0x0001,
+ 0x32de: 0x0001, 0x32df: 0x0001, 0x32e0: 0x0001, 0x32e1: 0x0001, 0x32e2: 0x0001, 0x32e3: 0x0001,
+ 0x32e4: 0x0001, 0x32e5: 0x0001, 0x32e6: 0x0001, 0x32e7: 0x0001, 0x32e8: 0x0001, 0x32e9: 0x0001,
+ 0x32ea: 0x0001, 0x32eb: 0x0001, 0x32ec: 0x0001, 0x32ed: 0x0001,
+ 0x32f0: 0x0001, 0x32f1: 0x0001, 0x32f2: 0x0001, 0x32f3: 0x0001, 0x32f4: 0x0001, 0x32f5: 0x0001,
+ 0x32f6: 0x0001, 0x32f7: 0x0001, 0x32f8: 0x0001, 0x32f9: 0x0001, 0x32fa: 0x0001, 0x32fb: 0x0001,
+ 0x32fc: 0x0001, 0x32fd: 0x0001, 0x32fe: 0x0001, 0x32ff: 0x0001,
+ // Block 0xcc, offset 0x3300
+ 0x3300: 0x0001, 0x3301: 0x0001, 0x3302: 0x0001, 0x3303: 0x0001, 0x3304: 0x0001, 0x3305: 0x0001,
+ 0x3306: 0x0001,
+ // Block 0xcd, offset 0x3340
+ 0x3367: 0x0001, 0x3368: 0x0001, 0x3369: 0x0001,
+ 0x3373: 0x0001, 0x3374: 0x0001, 0x3375: 0x0001,
+ 0x3376: 0x0001, 0x3377: 0x0001, 0x3378: 0x0001, 0x3379: 0x0001, 0x337a: 0x0001, 0x337b: 0x0001,
+ 0x337c: 0x0001, 0x337d: 0x0001, 0x337e: 0x0001, 0x337f: 0x0001,
+ // Block 0xce, offset 0x3380
+ 0x3380: 0x0001, 0x3381: 0x0001, 0x3382: 0x0001, 0x3385: 0x0001,
+ 0x3386: 0x0001, 0x3387: 0x0001, 0x3388: 0x0001, 0x3389: 0x0001, 0x338a: 0x0001, 0x338b: 0x0001,
+ 0x33aa: 0x0001, 0x33ab: 0x0001, 0x33ac: 0x0001, 0x33ad: 0x0001,
+ // Block 0xcf, offset 0x33c0
+ 0x33c2: 0x0001, 0x33c3: 0x0001, 0x33c4: 0x0001,
+ // Block 0xd0, offset 0x3400
+ 0x3400: 0x0002, 0x3401: 0x0002, 0x3402: 0x0002, 0x3403: 0x0002, 0x3404: 0x0002, 0x3405: 0x0002,
+ 0x3406: 0x0002, 0x3407: 0x0002, 0x3408: 0x0002, 0x3409: 0x0002, 0x340a: 0x0002, 0x340b: 0x0002,
+ 0x340c: 0x0002, 0x340d: 0x0002, 0x340e: 0x0002, 0x340f: 0x0002, 0x3410: 0x0002, 0x3411: 0x0002,
+ 0x3412: 0x0002, 0x3413: 0x0002, 0x3414: 0x0002, 0x3415: 0x0002, 0x3416: 0x0002,
+ 0x3420: 0x0002, 0x3421: 0x0002, 0x3422: 0x0002, 0x3423: 0x0002,
+ 0x3424: 0x0002, 0x3425: 0x0002, 0x3426: 0x0002, 0x3427: 0x0002, 0x3428: 0x0002, 0x3429: 0x0002,
+ 0x342a: 0x0002, 0x342b: 0x0002, 0x342c: 0x0002, 0x342d: 0x0002, 0x342e: 0x0002, 0x342f: 0x0002,
+ 0x3430: 0x0002, 0x3431: 0x0002, 0x3432: 0x0002, 0x3433: 0x0002, 0x3434: 0x0002, 0x3435: 0x0002,
+ 0x3436: 0x0002,
+ // Block 0xd1, offset 0x3440
+ 0x3440: 0x0001, 0x3441: 0x0001, 0x3442: 0x0001, 0x3443: 0x0001, 0x3444: 0x0001, 0x3445: 0x0001,
+ 0x3446: 0x0001, 0x3447: 0x0001, 0x3448: 0x0001, 0x3449: 0x0001, 0x344a: 0x0001, 0x344b: 0x0001,
+ 0x344c: 0x0001, 0x344d: 0x0001, 0x344e: 0x0001, 0x344f: 0x0001, 0x3450: 0x0001, 0x3451: 0x0001,
+ 0x3452: 0x0001, 0x3453: 0x0001, 0x3454: 0x0001, 0x3455: 0x0001, 0x3456: 0x0001, 0x3457: 0x0001,
+ 0x3458: 0x0001, 0x3459: 0x0001, 0x345a: 0x0001, 0x345b: 0x0001, 0x345c: 0x0001, 0x345d: 0x0001,
+ 0x345e: 0x0001, 0x345f: 0x0001, 0x3460: 0x0001, 0x3461: 0x0001, 0x3462: 0x0001, 0x3463: 0x0001,
+ 0x3464: 0x0001, 0x3465: 0x0001, 0x3466: 0x0001, 0x3467: 0x0001, 0x3468: 0x0001, 0x3469: 0x0001,
+ 0x346a: 0x0001, 0x346b: 0x0001, 0x346c: 0x0001, 0x346d: 0x0001, 0x346e: 0x0001, 0x346f: 0x0001,
+ 0x3470: 0x0001, 0x3471: 0x0001, 0x3472: 0x0001, 0x3473: 0x0001, 0x3474: 0x0001, 0x3475: 0x0001,
+ 0x3476: 0x0001, 0x347b: 0x0001,
+ 0x347c: 0x0001, 0x347d: 0x0001, 0x347e: 0x0001, 0x347f: 0x0001,
+ // Block 0xd2, offset 0x3480
+ 0x3480: 0x0001, 0x3481: 0x0001, 0x3482: 0x0001, 0x3483: 0x0001, 0x3484: 0x0001, 0x3485: 0x0001,
+ 0x3486: 0x0001, 0x3487: 0x0001, 0x3488: 0x0001, 0x3489: 0x0001, 0x348a: 0x0001, 0x348b: 0x0001,
+ 0x348c: 0x0001, 0x348d: 0x0001, 0x348e: 0x0001, 0x348f: 0x0001, 0x3490: 0x0001, 0x3491: 0x0001,
+ 0x3492: 0x0001, 0x3493: 0x0001, 0x3494: 0x0001, 0x3495: 0x0001, 0x3496: 0x0001, 0x3497: 0x0001,
+ 0x3498: 0x0001, 0x3499: 0x0001, 0x349a: 0x0001, 0x349b: 0x0001, 0x349c: 0x0001, 0x349d: 0x0001,
+ 0x349e: 0x0001, 0x349f: 0x0001, 0x34a0: 0x0001, 0x34a1: 0x0001, 0x34a2: 0x0001, 0x34a3: 0x0001,
+ 0x34a4: 0x0001, 0x34a5: 0x0001, 0x34a6: 0x0001, 0x34a7: 0x0001, 0x34a8: 0x0001, 0x34a9: 0x0001,
+ 0x34aa: 0x0001, 0x34ab: 0x0001, 0x34ac: 0x0001,
+ 0x34b5: 0x0001,
+ // Block 0xd3, offset 0x34c0
+ 0x34c4: 0x0001,
+ 0x34db: 0x0001, 0x34dc: 0x0001, 0x34dd: 0x0001,
+ 0x34de: 0x0001, 0x34df: 0x0001, 0x34e1: 0x0001, 0x34e2: 0x0001, 0x34e3: 0x0001,
+ 0x34e4: 0x0001, 0x34e5: 0x0001, 0x34e6: 0x0001, 0x34e7: 0x0001, 0x34e8: 0x0001, 0x34e9: 0x0001,
+ 0x34ea: 0x0001, 0x34eb: 0x0001, 0x34ec: 0x0001, 0x34ed: 0x0001, 0x34ee: 0x0001, 0x34ef: 0x0001,
+ // Block 0xd4, offset 0x3500
+ 0x3500: 0x0001, 0x3501: 0x0001, 0x3502: 0x0001, 0x3503: 0x0001, 0x3504: 0x0001, 0x3505: 0x0001,
+ 0x3506: 0x0001, 0x3508: 0x0001, 0x3509: 0x0001, 0x350a: 0x0001, 0x350b: 0x0001,
+ 0x350c: 0x0001, 0x350d: 0x0001, 0x350e: 0x0001, 0x350f: 0x0001, 0x3510: 0x0001, 0x3511: 0x0001,
+ 0x3512: 0x0001, 0x3513: 0x0001, 0x3514: 0x0001, 0x3515: 0x0001, 0x3516: 0x0001, 0x3517: 0x0001,
+ 0x3518: 0x0001, 0x351b: 0x0001, 0x351c: 0x0001, 0x351d: 0x0001,
+ 0x351e: 0x0001, 0x351f: 0x0001, 0x3520: 0x0001, 0x3521: 0x0001, 0x3523: 0x0001,
+ 0x3524: 0x0001, 0x3526: 0x0001, 0x3527: 0x0001, 0x3528: 0x0001, 0x3529: 0x0001,
+ 0x352a: 0x0001,
+ // Block 0xd5, offset 0x3540
+ 0x356e: 0x0001,
+ // Block 0xd6, offset 0x3580
+ 0x35ac: 0x0001, 0x35ad: 0x0001, 0x35ae: 0x0001, 0x35af: 0x0001,
+ // Block 0xd7, offset 0x35c0
+ 0x35d0: 0x0001, 0x35d1: 0x0001,
+ 0x35d2: 0x0001, 0x35d3: 0x0001, 0x35d4: 0x0001, 0x35d5: 0x0001, 0x35d6: 0x0001,
+ // Block 0xd8, offset 0x3600
+ 0x3604: 0x0001, 0x3605: 0x0001,
+ 0x3606: 0x0001, 0x3607: 0x0001, 0x3608: 0x0001, 0x3609: 0x0001, 0x360a: 0x0001,
+ // Block 0xd9, offset 0x3640
+ 0x3644: 0x0002,
+ // Block 0xda, offset 0x3680
+ 0x368f: 0x0002,
+ // Block 0xdb, offset 0x36c0
+ 0x36c0: 0x0003, 0x36c1: 0x0003, 0x36c2: 0x0003, 0x36c3: 0x0003, 0x36c4: 0x0003, 0x36c5: 0x0003,
+ 0x36c6: 0x0003, 0x36c7: 0x0003, 0x36c8: 0x0003, 0x36c9: 0x0003, 0x36ca: 0x0003,
+ 0x36d0: 0x0003, 0x36d1: 0x0003,
+ 0x36d2: 0x0003, 0x36d3: 0x0003, 0x36d4: 0x0003, 0x36d5: 0x0003, 0x36d6: 0x0003, 0x36d7: 0x0003,
+ 0x36d8: 0x0003, 0x36d9: 0x0003, 0x36da: 0x0003, 0x36db: 0x0003, 0x36dc: 0x0003, 0x36dd: 0x0003,
+ 0x36de: 0x0003, 0x36df: 0x0003, 0x36e0: 0x0003, 0x36e1: 0x0003, 0x36e2: 0x0003, 0x36e3: 0x0003,
+ 0x36e4: 0x0003, 0x36e5: 0x0003, 0x36e6: 0x0003, 0x36e7: 0x0003, 0x36e8: 0x0003, 0x36e9: 0x0003,
+ 0x36ea: 0x0003, 0x36eb: 0x0003, 0x36ec: 0x0003, 0x36ed: 0x0003,
+ 0x36f0: 0x0003, 0x36f1: 0x0003, 0x36f2: 0x0003, 0x36f3: 0x0003, 0x36f4: 0x0003, 0x36f5: 0x0003,
+ 0x36f6: 0x0003, 0x36f7: 0x0003, 0x36f8: 0x0003, 0x36f9: 0x0003, 0x36fa: 0x0003, 0x36fb: 0x0003,
+ 0x36fc: 0x0003, 0x36fd: 0x0003, 0x36fe: 0x0003, 0x36ff: 0x0003,
+ // Block 0xdc, offset 0x3700
+ 0x3700: 0x0003, 0x3701: 0x0003, 0x3702: 0x0003, 0x3703: 0x0003, 0x3704: 0x0003, 0x3705: 0x0003,
+ 0x3706: 0x0003, 0x3707: 0x0003, 0x3708: 0x0003, 0x3709: 0x0003, 0x370a: 0x0003, 0x370b: 0x0003,
+ 0x370c: 0x0003, 0x370d: 0x0003, 0x370e: 0x0003, 0x370f: 0x0003, 0x3710: 0x0003, 0x3711: 0x0003,
+ 0x3712: 0x0003, 0x3713: 0x0003, 0x3714: 0x0003, 0x3715: 0x0003, 0x3716: 0x0003, 0x3717: 0x0003,
+ 0x3718: 0x0003, 0x3719: 0x0003, 0x371a: 0x0003, 0x371b: 0x0003, 0x371c: 0x0003, 0x371d: 0x0003,
+ 0x371e: 0x0003, 0x371f: 0x0003, 0x3720: 0x0003, 0x3721: 0x0003, 0x3722: 0x0003, 0x3723: 0x0003,
+ 0x3724: 0x0003, 0x3725: 0x0003, 0x3726: 0x0003, 0x3727: 0x0003, 0x3728: 0x0003, 0x3729: 0x0003,
+ 0x3730: 0x0003, 0x3731: 0x0003, 0x3732: 0x0003, 0x3733: 0x0003, 0x3734: 0x0003, 0x3735: 0x0003,
+ 0x3736: 0x0003, 0x3737: 0x0003, 0x3738: 0x0003, 0x3739: 0x0003, 0x373a: 0x0003, 0x373b: 0x0003,
+ 0x373c: 0x0003, 0x373d: 0x0003, 0x373e: 0x0003, 0x373f: 0x0003,
+ // Block 0xdd, offset 0x3740
+ 0x3740: 0x0003, 0x3741: 0x0003, 0x3742: 0x0003, 0x3743: 0x0003, 0x3744: 0x0003, 0x3745: 0x0003,
+ 0x3746: 0x0003, 0x3747: 0x0003, 0x3748: 0x0003, 0x3749: 0x0003, 0x374a: 0x0003, 0x374b: 0x0003,
+ 0x374c: 0x0003, 0x374d: 0x0003, 0x374e: 0x0002, 0x374f: 0x0003, 0x3750: 0x0003, 0x3751: 0x0002,
+ 0x3752: 0x0002, 0x3753: 0x0002, 0x3754: 0x0002, 0x3755: 0x0002, 0x3756: 0x0002, 0x3757: 0x0002,
+ 0x3758: 0x0002, 0x3759: 0x0002, 0x375a: 0x0002, 0x375b: 0x0003, 0x375c: 0x0003, 0x375d: 0x0003,
+ 0x375e: 0x0003, 0x375f: 0x0003, 0x3760: 0x0003, 0x3761: 0x0003, 0x3762: 0x0003, 0x3763: 0x0003,
+ 0x3764: 0x0003, 0x3765: 0x0003, 0x3766: 0x0003, 0x3767: 0x0003, 0x3768: 0x0003, 0x3769: 0x0003,
+ 0x376a: 0x0003, 0x376b: 0x0003, 0x376c: 0x0003,
+ // Block 0xde, offset 0x3780
+ 0x37a6: 0x0002, 0x37a7: 0x0002, 0x37a8: 0x0002, 0x37a9: 0x0002,
+ 0x37aa: 0x0002, 0x37ab: 0x0002, 0x37ac: 0x0002, 0x37ad: 0x0002, 0x37ae: 0x0002, 0x37af: 0x0002,
+ 0x37b0: 0x0002, 0x37b1: 0x0002, 0x37b2: 0x0002, 0x37b3: 0x0002, 0x37b4: 0x0002, 0x37b5: 0x0002,
+ 0x37b6: 0x0002, 0x37b7: 0x0002, 0x37b8: 0x0002, 0x37b9: 0x0002, 0x37ba: 0x0002, 0x37bb: 0x0002,
+ 0x37bc: 0x0002, 0x37bd: 0x0002, 0x37be: 0x0002, 0x37bf: 0x0002,
+ // Block 0xdf, offset 0x37c0
+ 0x37c0: 0x0002, 0x37c1: 0x0002, 0x37c2: 0x0002,
+ 0x37d0: 0x0002, 0x37d1: 0x0002,
+ 0x37d2: 0x0002, 0x37d3: 0x0002, 0x37d4: 0x0002, 0x37d5: 0x0002, 0x37d6: 0x0002, 0x37d7: 0x0002,
+ 0x37d8: 0x0002, 0x37d9: 0x0002, 0x37da: 0x0002, 0x37db: 0x0002, 0x37dc: 0x0002, 0x37dd: 0x0002,
+ 0x37de: 0x0002, 0x37df: 0x0002, 0x37e0: 0x0002, 0x37e1: 0x0002, 0x37e2: 0x0002, 0x37e3: 0x0002,
+ 0x37e4: 0x0002, 0x37e5: 0x0002, 0x37e6: 0x0002, 0x37e7: 0x0002, 0x37e8: 0x0002, 0x37e9: 0x0002,
+ 0x37ea: 0x0002, 0x37eb: 0x0002, 0x37ec: 0x0002, 0x37ed: 0x0002, 0x37ee: 0x0002, 0x37ef: 0x0002,
+ 0x37f0: 0x0002, 0x37f1: 0x0002, 0x37f2: 0x0002, 0x37f3: 0x0002, 0x37f4: 0x0002, 0x37f5: 0x0002,
+ 0x37f6: 0x0002, 0x37f7: 0x0002, 0x37f8: 0x0002, 0x37f9: 0x0002, 0x37fa: 0x0002, 0x37fb: 0x0002,
+ // Block 0xe0, offset 0x3800
+ 0x3800: 0x0002, 0x3801: 0x0002, 0x3802: 0x0002, 0x3803: 0x0002, 0x3804: 0x0002, 0x3805: 0x0002,
+ 0x3806: 0x0002, 0x3807: 0x0002, 0x3808: 0x0002,
+ 0x3810: 0x0002, 0x3811: 0x0002,
+ 0x3820: 0x0002, 0x3821: 0x0002, 0x3822: 0x0002, 0x3823: 0x0002,
+ 0x3824: 0x0002, 0x3825: 0x0002,
+ // Block 0xe1, offset 0x3840
+ 0x3840: 0x0002, 0x3841: 0x0002, 0x3842: 0x0002, 0x3843: 0x0002, 0x3844: 0x0002, 0x3845: 0x0002,
+ 0x3846: 0x0002, 0x3847: 0x0002, 0x3848: 0x0002, 0x3849: 0x0002, 0x384a: 0x0002, 0x384b: 0x0002,
+ 0x384c: 0x0002, 0x384d: 0x0002, 0x384e: 0x0002, 0x384f: 0x0002, 0x3850: 0x0002, 0x3851: 0x0002,
+ 0x3852: 0x0002, 0x3853: 0x0002, 0x3854: 0x0002, 0x3855: 0x0002, 0x3856: 0x0002, 0x3857: 0x0002,
+ 0x3858: 0x0002, 0x3859: 0x0002, 0x385a: 0x0002, 0x385b: 0x0002, 0x385c: 0x0002, 0x385d: 0x0002,
+ 0x385e: 0x0002, 0x385f: 0x0002, 0x3860: 0x0002,
+ 0x386d: 0x0002, 0x386e: 0x0002, 0x386f: 0x0002,
+ 0x3870: 0x0002, 0x3871: 0x0002, 0x3872: 0x0002, 0x3873: 0x0002, 0x3874: 0x0002, 0x3875: 0x0002,
+ 0x3877: 0x0002, 0x3878: 0x0002, 0x3879: 0x0002, 0x387a: 0x0002, 0x387b: 0x0002,
+ 0x387c: 0x0002, 0x387d: 0x0002, 0x387e: 0x0002, 0x387f: 0x0002,
+ // Block 0xe2, offset 0x3880
+ 0x3880: 0x0002, 0x3881: 0x0002, 0x3882: 0x0002, 0x3883: 0x0002, 0x3884: 0x0002, 0x3885: 0x0002,
+ 0x3886: 0x0002, 0x3887: 0x0002, 0x3888: 0x0002, 0x3889: 0x0002, 0x388a: 0x0002, 0x388b: 0x0002,
+ 0x388c: 0x0002, 0x388d: 0x0002, 0x388e: 0x0002, 0x388f: 0x0002, 0x3890: 0x0002, 0x3891: 0x0002,
+ 0x3892: 0x0002, 0x3893: 0x0002, 0x3894: 0x0002, 0x3895: 0x0002, 0x3896: 0x0002, 0x3897: 0x0002,
+ 0x3898: 0x0002, 0x3899: 0x0002, 0x389a: 0x0002, 0x389b: 0x0002, 0x389c: 0x0002, 0x389d: 0x0002,
+ 0x389e: 0x0002, 0x389f: 0x0002, 0x38a0: 0x0002, 0x38a1: 0x0002, 0x38a2: 0x0002, 0x38a3: 0x0002,
+ 0x38a4: 0x0002, 0x38a5: 0x0002, 0x38a6: 0x0002, 0x38a7: 0x0002, 0x38a8: 0x0002, 0x38a9: 0x0002,
+ 0x38aa: 0x0002, 0x38ab: 0x0002, 0x38ac: 0x0002, 0x38ad: 0x0002, 0x38ae: 0x0002, 0x38af: 0x0002,
+ 0x38b0: 0x0002, 0x38b1: 0x0002, 0x38b2: 0x0002, 0x38b3: 0x0002, 0x38b4: 0x0002, 0x38b5: 0x0002,
+ 0x38b6: 0x0002, 0x38b7: 0x0002, 0x38b8: 0x0002, 0x38b9: 0x0002, 0x38ba: 0x0002, 0x38bb: 0x0002,
+ 0x38bc: 0x0002, 0x38be: 0x0002, 0x38bf: 0x0002,
+ // Block 0xe3, offset 0x38c0
+ 0x38c0: 0x0002, 0x38c1: 0x0002, 0x38c2: 0x0002, 0x38c3: 0x0002, 0x38c4: 0x0002, 0x38c5: 0x0002,
+ 0x38c6: 0x0002, 0x38c7: 0x0002, 0x38c8: 0x0002, 0x38c9: 0x0002, 0x38ca: 0x0002, 0x38cb: 0x0002,
+ 0x38cc: 0x0002, 0x38cd: 0x0002, 0x38ce: 0x0002, 0x38cf: 0x0002, 0x38d0: 0x0002, 0x38d1: 0x0002,
+ 0x38d2: 0x0002, 0x38d3: 0x0002,
+ 0x38e0: 0x0002, 0x38e1: 0x0002, 0x38e2: 0x0002, 0x38e3: 0x0002,
+ 0x38e4: 0x0002, 0x38e5: 0x0002, 0x38e6: 0x0002, 0x38e7: 0x0002, 0x38e8: 0x0002, 0x38e9: 0x0002,
+ 0x38ea: 0x0002, 0x38eb: 0x0002, 0x38ec: 0x0002, 0x38ed: 0x0002, 0x38ee: 0x0002, 0x38ef: 0x0002,
+ 0x38f0: 0x0002, 0x38f1: 0x0002, 0x38f2: 0x0002, 0x38f3: 0x0002, 0x38f4: 0x0002, 0x38f5: 0x0002,
+ 0x38f6: 0x0002, 0x38f7: 0x0002, 0x38f8: 0x0002, 0x38f9: 0x0002, 0x38fa: 0x0002, 0x38fb: 0x0002,
+ 0x38fc: 0x0002, 0x38fd: 0x0002, 0x38fe: 0x0002, 0x38ff: 0x0002,
+ // Block 0xe4, offset 0x3900
+ 0x3900: 0x0002, 0x3901: 0x0002, 0x3902: 0x0002, 0x3903: 0x0002, 0x3904: 0x0002, 0x3905: 0x0002,
+ 0x3906: 0x0002, 0x3907: 0x0002, 0x3908: 0x0002, 0x3909: 0x0002, 0x390a: 0x0002,
+ 0x390f: 0x0002, 0x3910: 0x0002, 0x3911: 0x0002,
+ 0x3912: 0x0002, 0x3913: 0x0002,
+ 0x3920: 0x0002, 0x3921: 0x0002, 0x3922: 0x0002, 0x3923: 0x0002,
+ 0x3924: 0x0002, 0x3925: 0x0002, 0x3926: 0x0002, 0x3927: 0x0002, 0x3928: 0x0002, 0x3929: 0x0002,
+ 0x392a: 0x0002, 0x392b: 0x0002, 0x392c: 0x0002, 0x392d: 0x0002, 0x392e: 0x0002, 0x392f: 0x0002,
+ 0x3930: 0x0002, 0x3934: 0x0002,
+ 0x3938: 0x0002, 0x3939: 0x0002, 0x393a: 0x0002, 0x393b: 0x0002,
+ 0x393c: 0x0002, 0x393d: 0x0002, 0x393e: 0x0002, 0x393f: 0x0002,
+ // Block 0xe5, offset 0x3940
+ 0x3940: 0x0002, 0x3941: 0x0002, 0x3942: 0x0002, 0x3943: 0x0002, 0x3944: 0x0002, 0x3945: 0x0002,
+ 0x3946: 0x0002, 0x3947: 0x0002, 0x3948: 0x0002, 0x3949: 0x0002, 0x394a: 0x0002, 0x394b: 0x0002,
+ 0x394c: 0x0002, 0x394d: 0x0002, 0x394e: 0x0002, 0x394f: 0x0002, 0x3950: 0x0002, 0x3951: 0x0002,
+ 0x3952: 0x0002, 0x3953: 0x0002, 0x3954: 0x0002, 0x3955: 0x0002, 0x3956: 0x0002, 0x3957: 0x0002,
+ 0x3958: 0x0002, 0x3959: 0x0002, 0x395a: 0x0002, 0x395b: 0x0002, 0x395c: 0x0002, 0x395d: 0x0002,
+ 0x395e: 0x0002, 0x395f: 0x0002, 0x3960: 0x0002, 0x3961: 0x0002, 0x3962: 0x0002, 0x3963: 0x0002,
+ 0x3964: 0x0002, 0x3965: 0x0002, 0x3966: 0x0002, 0x3967: 0x0002, 0x3968: 0x0002, 0x3969: 0x0002,
+ 0x396a: 0x0002, 0x396b: 0x0002, 0x396c: 0x0002, 0x396d: 0x0002, 0x396e: 0x0002, 0x396f: 0x0002,
+ 0x3970: 0x0002, 0x3971: 0x0002, 0x3972: 0x0002, 0x3973: 0x0002, 0x3974: 0x0002, 0x3975: 0x0002,
+ 0x3976: 0x0002, 0x3977: 0x0002, 0x3978: 0x0002, 0x3979: 0x0002, 0x397a: 0x0002, 0x397b: 0x0002,
+ 0x397c: 0x0002, 0x397d: 0x0002, 0x397e: 0x0002,
+ // Block 0xe6, offset 0x3980
+ 0x3980: 0x0002, 0x3982: 0x0002, 0x3983: 0x0002, 0x3984: 0x0002, 0x3985: 0x0002,
+ 0x3986: 0x0002, 0x3987: 0x0002, 0x3988: 0x0002, 0x3989: 0x0002, 0x398a: 0x0002, 0x398b: 0x0002,
+ 0x398c: 0x0002, 0x398d: 0x0002, 0x398e: 0x0002, 0x398f: 0x0002, 0x3990: 0x0002, 0x3991: 0x0002,
+ 0x3992: 0x0002, 0x3993: 0x0002, 0x3994: 0x0002, 0x3995: 0x0002, 0x3996: 0x0002, 0x3997: 0x0002,
+ 0x3998: 0x0002, 0x3999: 0x0002, 0x399a: 0x0002, 0x399b: 0x0002, 0x399c: 0x0002, 0x399d: 0x0002,
+ 0x399e: 0x0002, 0x399f: 0x0002, 0x39a0: 0x0002, 0x39a1: 0x0002, 0x39a2: 0x0002, 0x39a3: 0x0002,
+ 0x39a4: 0x0002, 0x39a5: 0x0002, 0x39a6: 0x0002, 0x39a7: 0x0002, 0x39a8: 0x0002, 0x39a9: 0x0002,
+ 0x39aa: 0x0002, 0x39ab: 0x0002, 0x39ac: 0x0002, 0x39ad: 0x0002, 0x39ae: 0x0002, 0x39af: 0x0002,
+ 0x39b0: 0x0002, 0x39b1: 0x0002, 0x39b2: 0x0002, 0x39b3: 0x0002, 0x39b4: 0x0002, 0x39b5: 0x0002,
+ 0x39b6: 0x0002, 0x39b7: 0x0002, 0x39b8: 0x0002, 0x39b9: 0x0002, 0x39ba: 0x0002, 0x39bb: 0x0002,
+ 0x39bc: 0x0002, 0x39bd: 0x0002, 0x39be: 0x0002, 0x39bf: 0x0002,
+ // Block 0xe7, offset 0x39c0
+ 0x39c0: 0x0002, 0x39c1: 0x0002, 0x39c2: 0x0002, 0x39c3: 0x0002, 0x39c4: 0x0002, 0x39c5: 0x0002,
+ 0x39c6: 0x0002, 0x39c7: 0x0002, 0x39c8: 0x0002, 0x39c9: 0x0002, 0x39ca: 0x0002, 0x39cb: 0x0002,
+ 0x39cc: 0x0002, 0x39cd: 0x0002, 0x39ce: 0x0002, 0x39cf: 0x0002, 0x39d0: 0x0002, 0x39d1: 0x0002,
+ 0x39d2: 0x0002, 0x39d3: 0x0002, 0x39d4: 0x0002, 0x39d5: 0x0002, 0x39d6: 0x0002, 0x39d7: 0x0002,
+ 0x39d8: 0x0002, 0x39d9: 0x0002, 0x39da: 0x0002, 0x39db: 0x0002, 0x39dc: 0x0002, 0x39dd: 0x0002,
+ 0x39de: 0x0002, 0x39df: 0x0002, 0x39e0: 0x0002, 0x39e1: 0x0002, 0x39e2: 0x0002, 0x39e3: 0x0002,
+ 0x39e4: 0x0002, 0x39e5: 0x0002, 0x39e6: 0x0002, 0x39e7: 0x0002, 0x39e8: 0x0002, 0x39e9: 0x0002,
+ 0x39ea: 0x0002, 0x39eb: 0x0002, 0x39ec: 0x0002, 0x39ed: 0x0002, 0x39ee: 0x0002, 0x39ef: 0x0002,
+ 0x39f0: 0x0002, 0x39f1: 0x0002, 0x39f2: 0x0002, 0x39f3: 0x0002, 0x39f4: 0x0002, 0x39f5: 0x0002,
+ 0x39f6: 0x0002, 0x39f7: 0x0002, 0x39f8: 0x0002, 0x39f9: 0x0002, 0x39fa: 0x0002, 0x39fb: 0x0002,
+ 0x39fc: 0x0002, 0x39ff: 0x0002,
+ // Block 0xe8, offset 0x3a00
+ 0x3a00: 0x0002, 0x3a01: 0x0002, 0x3a02: 0x0002, 0x3a03: 0x0002, 0x3a04: 0x0002, 0x3a05: 0x0002,
+ 0x3a06: 0x0002, 0x3a07: 0x0002, 0x3a08: 0x0002, 0x3a09: 0x0002, 0x3a0a: 0x0002, 0x3a0b: 0x0002,
+ 0x3a0c: 0x0002, 0x3a0d: 0x0002, 0x3a0e: 0x0002, 0x3a0f: 0x0002, 0x3a10: 0x0002, 0x3a11: 0x0002,
+ 0x3a12: 0x0002, 0x3a13: 0x0002, 0x3a14: 0x0002, 0x3a15: 0x0002, 0x3a16: 0x0002, 0x3a17: 0x0002,
+ 0x3a18: 0x0002, 0x3a19: 0x0002, 0x3a1a: 0x0002, 0x3a1b: 0x0002, 0x3a1c: 0x0002, 0x3a1d: 0x0002,
+ 0x3a1e: 0x0002, 0x3a1f: 0x0002, 0x3a20: 0x0002, 0x3a21: 0x0002, 0x3a22: 0x0002, 0x3a23: 0x0002,
+ 0x3a24: 0x0002, 0x3a25: 0x0002, 0x3a26: 0x0002, 0x3a27: 0x0002, 0x3a28: 0x0002, 0x3a29: 0x0002,
+ 0x3a2a: 0x0002, 0x3a2b: 0x0002, 0x3a2c: 0x0002, 0x3a2d: 0x0002, 0x3a2e: 0x0002, 0x3a2f: 0x0002,
+ 0x3a30: 0x0002, 0x3a31: 0x0002, 0x3a32: 0x0002, 0x3a33: 0x0002, 0x3a34: 0x0002, 0x3a35: 0x0002,
+ 0x3a36: 0x0002, 0x3a37: 0x0002, 0x3a38: 0x0002, 0x3a39: 0x0002, 0x3a3a: 0x0002, 0x3a3b: 0x0002,
+ 0x3a3c: 0x0002, 0x3a3d: 0x0002,
+ // Block 0xe9, offset 0x3a40
+ 0x3a4b: 0x0002,
+ 0x3a4c: 0x0002, 0x3a4d: 0x0002, 0x3a4e: 0x0002, 0x3a50: 0x0002, 0x3a51: 0x0002,
+ 0x3a52: 0x0002, 0x3a53: 0x0002, 0x3a54: 0x0002, 0x3a55: 0x0002, 0x3a56: 0x0002, 0x3a57: 0x0002,
+ 0x3a58: 0x0002, 0x3a59: 0x0002, 0x3a5a: 0x0002, 0x3a5b: 0x0002, 0x3a5c: 0x0002, 0x3a5d: 0x0002,
+ 0x3a5e: 0x0002, 0x3a5f: 0x0002, 0x3a60: 0x0002, 0x3a61: 0x0002, 0x3a62: 0x0002, 0x3a63: 0x0002,
+ 0x3a64: 0x0002, 0x3a65: 0x0002, 0x3a66: 0x0002, 0x3a67: 0x0002,
+ 0x3a7a: 0x0002,
+ // Block 0xea, offset 0x3a80
+ 0x3a95: 0x0002, 0x3a96: 0x0002,
+ 0x3aa4: 0x0002,
+ // Block 0xeb, offset 0x3ac0
+ 0x3afb: 0x0002,
+ 0x3afc: 0x0002, 0x3afd: 0x0002, 0x3afe: 0x0002, 0x3aff: 0x0002,
+ // Block 0xec, offset 0x3b00
+ 0x3b00: 0x0002, 0x3b01: 0x0002, 0x3b02: 0x0002, 0x3b03: 0x0002, 0x3b04: 0x0002, 0x3b05: 0x0002,
+ 0x3b06: 0x0002, 0x3b07: 0x0002, 0x3b08: 0x0002, 0x3b09: 0x0002, 0x3b0a: 0x0002, 0x3b0b: 0x0002,
+ 0x3b0c: 0x0002, 0x3b0d: 0x0002, 0x3b0e: 0x0002, 0x3b0f: 0x0002,
+ // Block 0xed, offset 0x3b40
+ 0x3b40: 0x0002, 0x3b41: 0x0002, 0x3b42: 0x0002, 0x3b43: 0x0002, 0x3b44: 0x0002, 0x3b45: 0x0002,
+ 0x3b4c: 0x0002, 0x3b50: 0x0002, 0x3b51: 0x0002,
+ 0x3b52: 0x0002, 0x3b55: 0x0002, 0x3b56: 0x0002, 0x3b57: 0x0002,
+ 0x3b58: 0x0002, 0x3b5c: 0x0002, 0x3b5d: 0x0002,
+ 0x3b5e: 0x0002, 0x3b5f: 0x0002,
+ 0x3b6b: 0x0002, 0x3b6c: 0x0002,
+ 0x3b74: 0x0002, 0x3b75: 0x0002,
+ 0x3b76: 0x0002, 0x3b77: 0x0002, 0x3b78: 0x0002, 0x3b79: 0x0002, 0x3b7a: 0x0002, 0x3b7b: 0x0002,
+ 0x3b7c: 0x0002,
+ // Block 0xee, offset 0x3b80
+ 0x3ba0: 0x0002, 0x3ba1: 0x0002, 0x3ba2: 0x0002, 0x3ba3: 0x0002,
+ 0x3ba4: 0x0002, 0x3ba5: 0x0002, 0x3ba6: 0x0002, 0x3ba7: 0x0002, 0x3ba8: 0x0002, 0x3ba9: 0x0002,
+ 0x3baa: 0x0002, 0x3bab: 0x0002,
+ 0x3bb0: 0x0002,
+ // Block 0xef, offset 0x3bc0
+ 0x3bcc: 0x0002, 0x3bcd: 0x0002, 0x3bce: 0x0002, 0x3bcf: 0x0002, 0x3bd0: 0x0002, 0x3bd1: 0x0002,
+ 0x3bd2: 0x0002, 0x3bd3: 0x0002, 0x3bd4: 0x0002, 0x3bd5: 0x0002, 0x3bd6: 0x0002, 0x3bd7: 0x0002,
+ 0x3bd8: 0x0002, 0x3bd9: 0x0002, 0x3bda: 0x0002, 0x3bdb: 0x0002, 0x3bdc: 0x0002, 0x3bdd: 0x0002,
+ 0x3bde: 0x0002, 0x3bdf: 0x0002, 0x3be0: 0x0002, 0x3be1: 0x0002, 0x3be2: 0x0002, 0x3be3: 0x0002,
+ 0x3be4: 0x0002, 0x3be5: 0x0002, 0x3be6: 0x0002, 0x3be7: 0x0002, 0x3be8: 0x0002, 0x3be9: 0x0002,
+ 0x3bea: 0x0002, 0x3beb: 0x0002, 0x3bec: 0x0002, 0x3bed: 0x0002, 0x3bee: 0x0002, 0x3bef: 0x0002,
+ 0x3bf0: 0x0002, 0x3bf1: 0x0002, 0x3bf2: 0x0002, 0x3bf3: 0x0002, 0x3bf4: 0x0002, 0x3bf5: 0x0002,
+ 0x3bf6: 0x0002, 0x3bf7: 0x0002, 0x3bf8: 0x0002, 0x3bf9: 0x0002, 0x3bfa: 0x0002,
+ 0x3bfc: 0x0002, 0x3bfd: 0x0002, 0x3bfe: 0x0002, 0x3bff: 0x0002,
+ // Block 0xf0, offset 0x3c00
+ 0x3c00: 0x0002, 0x3c01: 0x0002, 0x3c02: 0x0002, 0x3c03: 0x0002, 0x3c04: 0x0002, 0x3c05: 0x0002,
+ 0x3c07: 0x0002, 0x3c08: 0x0002, 0x3c09: 0x0002, 0x3c0a: 0x0002, 0x3c0b: 0x0002,
+ 0x3c0c: 0x0002, 0x3c0d: 0x0002, 0x3c0e: 0x0002, 0x3c0f: 0x0002, 0x3c10: 0x0002, 0x3c11: 0x0002,
+ 0x3c12: 0x0002, 0x3c13: 0x0002, 0x3c14: 0x0002, 0x3c15: 0x0002, 0x3c16: 0x0002, 0x3c17: 0x0002,
+ 0x3c18: 0x0002, 0x3c19: 0x0002, 0x3c1a: 0x0002, 0x3c1b: 0x0002, 0x3c1c: 0x0002, 0x3c1d: 0x0002,
+ 0x3c1e: 0x0002, 0x3c1f: 0x0002, 0x3c20: 0x0002, 0x3c21: 0x0002, 0x3c22: 0x0002, 0x3c23: 0x0002,
+ 0x3c24: 0x0002, 0x3c25: 0x0002, 0x3c26: 0x0002, 0x3c27: 0x0002, 0x3c28: 0x0002, 0x3c29: 0x0002,
+ 0x3c2a: 0x0002, 0x3c2b: 0x0002, 0x3c2c: 0x0002, 0x3c2d: 0x0002, 0x3c2e: 0x0002, 0x3c2f: 0x0002,
+ 0x3c30: 0x0002, 0x3c31: 0x0002, 0x3c32: 0x0002, 0x3c33: 0x0002, 0x3c34: 0x0002, 0x3c35: 0x0002,
+ 0x3c36: 0x0002, 0x3c37: 0x0002, 0x3c38: 0x0002, 0x3c39: 0x0002, 0x3c3a: 0x0002, 0x3c3b: 0x0002,
+ 0x3c3c: 0x0002, 0x3c3d: 0x0002, 0x3c3e: 0x0002, 0x3c3f: 0x0002,
+ // Block 0xf1, offset 0x3c40
+ 0x3c70: 0x0002, 0x3c71: 0x0002, 0x3c72: 0x0002, 0x3c73: 0x0002, 0x3c74: 0x0002, 0x3c75: 0x0002,
+ 0x3c76: 0x0002, 0x3c77: 0x0002, 0x3c78: 0x0002, 0x3c79: 0x0002, 0x3c7a: 0x0002, 0x3c7b: 0x0002,
+ 0x3c7c: 0x0002,
+ // Block 0xf2, offset 0x3c80
+ 0x3c80: 0x0002, 0x3c81: 0x0002, 0x3c82: 0x0002, 0x3c83: 0x0002, 0x3c84: 0x0002, 0x3c85: 0x0002,
+ 0x3c86: 0x0002, 0x3c87: 0x0002, 0x3c88: 0x0002, 0x3c89: 0x0002, 0x3c8a: 0x0002,
+ 0x3c8e: 0x0002, 0x3c8f: 0x0002, 0x3c90: 0x0002, 0x3c91: 0x0002,
+ 0x3c92: 0x0002, 0x3c93: 0x0002, 0x3c94: 0x0002, 0x3c95: 0x0002, 0x3c96: 0x0002, 0x3c97: 0x0002,
+ 0x3c98: 0x0002, 0x3c99: 0x0002, 0x3c9a: 0x0002, 0x3c9b: 0x0002, 0x3c9c: 0x0002, 0x3c9d: 0x0002,
+ 0x3c9e: 0x0002, 0x3c9f: 0x0002, 0x3ca0: 0x0002, 0x3ca1: 0x0002, 0x3ca2: 0x0002, 0x3ca3: 0x0002,
+ 0x3ca4: 0x0002, 0x3ca5: 0x0002, 0x3ca6: 0x0002, 0x3ca7: 0x0002, 0x3ca8: 0x0002, 0x3ca9: 0x0002,
+ 0x3caa: 0x0002, 0x3cab: 0x0002, 0x3cac: 0x0002, 0x3cad: 0x0002, 0x3cae: 0x0002, 0x3caf: 0x0002,
+ 0x3cb0: 0x0002, 0x3cb1: 0x0002, 0x3cb2: 0x0002, 0x3cb3: 0x0002, 0x3cb4: 0x0002, 0x3cb5: 0x0002,
+ 0x3cb6: 0x0002, 0x3cb7: 0x0002, 0x3cb8: 0x0002, 0x3cb9: 0x0002, 0x3cba: 0x0002, 0x3cbb: 0x0002,
+ 0x3cbc: 0x0002, 0x3cbd: 0x0002, 0x3cbe: 0x0002, 0x3cbf: 0x0002,
+ // Block 0xf3, offset 0x3cc0
+ 0x3cc0: 0x0002, 0x3cc1: 0x0002, 0x3cc2: 0x0002, 0x3cc3: 0x0002, 0x3cc4: 0x0002, 0x3cc5: 0x0002,
+ 0x3cc6: 0x0002, 0x3cc8: 0x0002,
+ 0x3ccd: 0x0002, 0x3cce: 0x0002, 0x3ccf: 0x0002, 0x3cd0: 0x0002, 0x3cd1: 0x0002,
+ 0x3cd2: 0x0002, 0x3cd3: 0x0002, 0x3cd4: 0x0002, 0x3cd5: 0x0002, 0x3cd6: 0x0002, 0x3cd7: 0x0002,
+ 0x3cd8: 0x0002, 0x3cd9: 0x0002, 0x3cda: 0x0002, 0x3cdb: 0x0002, 0x3cdc: 0x0002,
+ 0x3cdf: 0x0002, 0x3ce0: 0x0002, 0x3ce1: 0x0002, 0x3ce2: 0x0002, 0x3ce3: 0x0002,
+ 0x3ce4: 0x0002, 0x3ce5: 0x0002, 0x3ce6: 0x0002, 0x3ce7: 0x0002, 0x3ce8: 0x0002, 0x3ce9: 0x0002,
+ 0x3cea: 0x0002, 0x3cef: 0x0002,
+ 0x3cf0: 0x0002, 0x3cf1: 0x0002, 0x3cf2: 0x0002, 0x3cf3: 0x0002, 0x3cf4: 0x0002, 0x3cf5: 0x0002,
+ 0x3cf6: 0x0002, 0x3cf7: 0x0002, 0x3cf8: 0x0002,
+ // Block 0xf4, offset 0x3d00
+ 0x3d01: 0x0001,
+ 0x3d20: 0x0001, 0x3d21: 0x0001, 0x3d22: 0x0001, 0x3d23: 0x0001,
+ 0x3d24: 0x0001, 0x3d25: 0x0001, 0x3d26: 0x0001, 0x3d27: 0x0001, 0x3d28: 0x0001, 0x3d29: 0x0001,
+ 0x3d2a: 0x0001, 0x3d2b: 0x0001, 0x3d2c: 0x0001, 0x3d2d: 0x0001, 0x3d2e: 0x0001, 0x3d2f: 0x0001,
+ 0x3d30: 0x0001, 0x3d31: 0x0001, 0x3d32: 0x0001, 0x3d33: 0x0001, 0x3d34: 0x0001, 0x3d35: 0x0001,
+ 0x3d36: 0x0001, 0x3d37: 0x0001, 0x3d38: 0x0001, 0x3d39: 0x0001, 0x3d3a: 0x0001, 0x3d3b: 0x0001,
+ 0x3d3c: 0x0001, 0x3d3d: 0x0001, 0x3d3e: 0x0001, 0x3d3f: 0x0001,
+ // Block 0xf5, offset 0x3d40
+ 0x3d40: 0x0003, 0x3d41: 0x0003, 0x3d42: 0x0003, 0x3d43: 0x0003, 0x3d44: 0x0003, 0x3d45: 0x0003,
+ 0x3d46: 0x0003, 0x3d47: 0x0003, 0x3d48: 0x0003, 0x3d49: 0x0003, 0x3d4a: 0x0003, 0x3d4b: 0x0003,
+ 0x3d4c: 0x0003, 0x3d4d: 0x0003, 0x3d4e: 0x0003, 0x3d4f: 0x0003, 0x3d50: 0x0003, 0x3d51: 0x0003,
+ 0x3d52: 0x0003, 0x3d53: 0x0003, 0x3d54: 0x0003, 0x3d55: 0x0003, 0x3d56: 0x0003, 0x3d57: 0x0003,
+ 0x3d58: 0x0003, 0x3d59: 0x0003, 0x3d5a: 0x0003, 0x3d5b: 0x0003, 0x3d5c: 0x0003, 0x3d5d: 0x0003,
+ 0x3d5e: 0x0003, 0x3d5f: 0x0003, 0x3d60: 0x0003, 0x3d61: 0x0003, 0x3d62: 0x0003, 0x3d63: 0x0003,
+ 0x3d64: 0x0003, 0x3d65: 0x0003, 0x3d66: 0x0003, 0x3d67: 0x0003, 0x3d68: 0x0003, 0x3d69: 0x0003,
+ 0x3d6a: 0x0003, 0x3d6b: 0x0003, 0x3d6c: 0x0003, 0x3d6d: 0x0003, 0x3d6e: 0x0003, 0x3d6f: 0x0003,
+ 0x3d70: 0x0003, 0x3d71: 0x0003, 0x3d72: 0x0003, 0x3d73: 0x0003, 0x3d74: 0x0003, 0x3d75: 0x0003,
+ 0x3d76: 0x0003, 0x3d77: 0x0003, 0x3d78: 0x0003, 0x3d79: 0x0003, 0x3d7a: 0x0003, 0x3d7b: 0x0003,
+ 0x3d7c: 0x0003, 0x3d7d: 0x0003,
+}
+
+// stringWidthIndex: 30 blocks, 1920 entries, 1920 bytes
+// Block 0 is the zero block.
+var stringWidthIndex = [1920]uint8{
+ // Block 0x0, offset 0x0
+ // Block 0x1, offset 0x40
+ // Block 0x2, offset 0x80
+ // Block 0x3, offset 0xc0
+ 0xc2: 0x01, 0xc3: 0x02, 0xc4: 0x03, 0xc5: 0x04, 0xc7: 0x05,
+ 0xc9: 0x06, 0xcb: 0x07, 0xcc: 0x08, 0xcd: 0x09, 0xce: 0x0a, 0xcf: 0x0b,
+ 0xd0: 0x0c, 0xd1: 0x0d, 0xd2: 0x0e, 0xd6: 0x0f, 0xd7: 0x10,
+ 0xd8: 0x11, 0xd9: 0x12, 0xdb: 0x13, 0xdc: 0x14, 0xdd: 0x15, 0xde: 0x16, 0xdf: 0x17,
+ 0xe0: 0x02, 0xe1: 0x03, 0xe2: 0x04, 0xe3: 0x05, 0xe4: 0x06, 0xe5: 0x06, 0xe6: 0x06, 0xe7: 0x06,
+ 0xe8: 0x06, 0xe9: 0x06, 0xea: 0x07, 0xeb: 0x06, 0xec: 0x06, 0xed: 0x08, 0xee: 0x09, 0xef: 0x0a,
+ 0xf0: 0x17, 0xf3: 0x1a, 0xf4: 0x1b,
+ // Block 0x4, offset 0x100
+ 0x120: 0x18, 0x121: 0x19, 0x122: 0x1a, 0x123: 0x1b, 0x124: 0x1c, 0x125: 0x1d, 0x126: 0x1e, 0x127: 0x1f,
+ 0x128: 0x20, 0x129: 0x21, 0x12a: 0x20, 0x12b: 0x22, 0x12c: 0x23, 0x12d: 0x24, 0x12e: 0x25, 0x12f: 0x26,
+ 0x130: 0x27, 0x131: 0x28, 0x132: 0x23, 0x133: 0x29, 0x134: 0x2a, 0x135: 0x2b, 0x136: 0x2c, 0x137: 0x2d,
+ 0x138: 0x2e, 0x139: 0x2f, 0x13a: 0x30, 0x13b: 0x31, 0x13c: 0x32, 0x13d: 0x33, 0x13e: 0x34, 0x13f: 0x35,
+ // Block 0x5, offset 0x140
+ 0x140: 0x36, 0x141: 0x37, 0x142: 0x38, 0x144: 0x39, 0x145: 0x3a,
+ 0x14d: 0x3b,
+ 0x15c: 0x3c, 0x15d: 0x3d, 0x15e: 0x3e, 0x15f: 0x3f,
+ 0x160: 0x40, 0x162: 0x41, 0x164: 0x42,
+ 0x168: 0x43, 0x169: 0x44, 0x16a: 0x45, 0x16b: 0x46, 0x16c: 0x47, 0x16d: 0x48, 0x16e: 0x49, 0x16f: 0x4a,
+ 0x170: 0x4b, 0x173: 0x4c, 0x177: 0x08,
+ // Block 0x6, offset 0x180
+ 0x180: 0x4d, 0x181: 0x4e, 0x182: 0x4f, 0x183: 0x50, 0x184: 0x51, 0x185: 0x52, 0x186: 0x53, 0x187: 0x54,
+ 0x188: 0x55, 0x189: 0x56, 0x18a: 0x57, 0x18c: 0x58, 0x18f: 0x59,
+ 0x191: 0x5a, 0x192: 0x5b, 0x193: 0x5c, 0x194: 0x5b, 0x195: 0x5d, 0x196: 0x5e, 0x197: 0x5f,
+ 0x198: 0x60, 0x199: 0x61, 0x19a: 0x62, 0x19b: 0x63, 0x19c: 0x64, 0x19d: 0x65, 0x19e: 0x66,
+ 0x1ac: 0x67, 0x1ad: 0x68,
+ 0x1b3: 0x69, 0x1b5: 0x6a, 0x1b7: 0x6b,
+ 0x1ba: 0x6c, 0x1bb: 0x6d, 0x1bc: 0x39, 0x1bd: 0x39, 0x1be: 0x39, 0x1bf: 0x6e,
+ // Block 0x7, offset 0x1c0
+ 0x1c0: 0x6f, 0x1c1: 0x70, 0x1c2: 0x71, 0x1c3: 0x39, 0x1c4: 0x72, 0x1c5: 0x39, 0x1c6: 0x73, 0x1c7: 0x74,
+ 0x1c8: 0x75, 0x1c9: 0x76, 0x1ca: 0x39, 0x1cb: 0x39, 0x1cc: 0x39, 0x1cd: 0x39, 0x1ce: 0x39, 0x1cf: 0x39,
+ 0x1d0: 0x39, 0x1d1: 0x39, 0x1d2: 0x39, 0x1d3: 0x39, 0x1d4: 0x39, 0x1d5: 0x39, 0x1d6: 0x39, 0x1d7: 0x39,
+ 0x1d8: 0x39, 0x1d9: 0x39, 0x1da: 0x39, 0x1db: 0x39, 0x1dc: 0x39, 0x1dd: 0x39, 0x1de: 0x39, 0x1df: 0x39,
+ 0x1e0: 0x39, 0x1e1: 0x39, 0x1e2: 0x39, 0x1e3: 0x39, 0x1e4: 0x39, 0x1e5: 0x39, 0x1e6: 0x39, 0x1e7: 0x39,
+ 0x1e8: 0x39, 0x1e9: 0x39, 0x1ea: 0x39, 0x1eb: 0x39, 0x1ec: 0x39, 0x1ed: 0x39, 0x1ee: 0x39, 0x1ef: 0x39,
+ 0x1f0: 0x39, 0x1f1: 0x39, 0x1f2: 0x39, 0x1f3: 0x39, 0x1f4: 0x39, 0x1f5: 0x39, 0x1f6: 0x39, 0x1f7: 0x39,
+ 0x1f8: 0x39, 0x1f9: 0x39, 0x1fa: 0x39, 0x1fb: 0x39, 0x1fc: 0x39, 0x1fd: 0x39, 0x1fe: 0x39, 0x1ff: 0x39,
+ // Block 0x8, offset 0x200
+ 0x200: 0x39, 0x201: 0x39, 0x202: 0x39, 0x203: 0x39, 0x204: 0x39, 0x205: 0x39, 0x206: 0x39, 0x207: 0x39,
+ 0x208: 0x39, 0x209: 0x39, 0x20a: 0x39, 0x20b: 0x39, 0x20c: 0x39, 0x20d: 0x39, 0x20e: 0x39, 0x20f: 0x39,
+ 0x210: 0x39, 0x211: 0x39, 0x212: 0x39, 0x213: 0x39, 0x214: 0x39, 0x215: 0x39, 0x216: 0x39, 0x217: 0x39,
+ 0x218: 0x39, 0x219: 0x39, 0x21a: 0x39, 0x21b: 0x39, 0x21c: 0x39, 0x21d: 0x39, 0x21e: 0x39, 0x21f: 0x39,
+ 0x220: 0x39, 0x221: 0x39, 0x222: 0x39, 0x223: 0x39, 0x224: 0x39, 0x225: 0x39, 0x226: 0x39, 0x227: 0x39,
+ 0x228: 0x39, 0x229: 0x39, 0x22a: 0x39, 0x22b: 0x39, 0x22c: 0x39, 0x22d: 0x39, 0x22e: 0x39, 0x22f: 0x39,
+ 0x230: 0x39, 0x231: 0x39, 0x232: 0x39, 0x233: 0x39, 0x234: 0x39, 0x235: 0x39, 0x236: 0x39, 0x237: 0x39,
+ 0x238: 0x39, 0x239: 0x39, 0x23a: 0x39, 0x23b: 0x39, 0x23c: 0x39, 0x23d: 0x39, 0x23e: 0x39, 0x23f: 0x39,
+ // Block 0x9, offset 0x240
+ 0x240: 0x39, 0x241: 0x39, 0x242: 0x39, 0x243: 0x39, 0x244: 0x39, 0x245: 0x39, 0x246: 0x39, 0x247: 0x39,
+ 0x248: 0x39, 0x249: 0x39, 0x24a: 0x39, 0x24b: 0x39, 0x24c: 0x39, 0x24d: 0x39, 0x24e: 0x39, 0x24f: 0x39,
+ 0x250: 0x39, 0x251: 0x39, 0x252: 0x77, 0x253: 0x78,
+ 0x259: 0x79, 0x25a: 0x7a, 0x25b: 0x7b,
+ 0x260: 0x7c, 0x263: 0x7d, 0x264: 0x7e, 0x265: 0x7f, 0x266: 0x80, 0x267: 0x81,
+ 0x268: 0x82, 0x269: 0x83, 0x26a: 0x84, 0x26b: 0x85, 0x26f: 0x86,
+ 0x270: 0x39, 0x271: 0x39, 0x272: 0x39, 0x273: 0x39, 0x274: 0x39, 0x275: 0x39, 0x276: 0x39, 0x277: 0x39,
+ 0x278: 0x39, 0x279: 0x39, 0x27a: 0x39, 0x27b: 0x39, 0x27c: 0x39, 0x27d: 0x39, 0x27e: 0x39, 0x27f: 0x39,
+ // Block 0xa, offset 0x280
+ 0x280: 0x39, 0x281: 0x39, 0x282: 0x39, 0x283: 0x39, 0x284: 0x39, 0x285: 0x39, 0x286: 0x39, 0x287: 0x39,
+ 0x288: 0x39, 0x289: 0x39, 0x28a: 0x39, 0x28b: 0x39, 0x28c: 0x39, 0x28d: 0x39, 0x28e: 0x39, 0x28f: 0x39,
+ 0x290: 0x39, 0x291: 0x39, 0x292: 0x39, 0x293: 0x39, 0x294: 0x39, 0x295: 0x39, 0x296: 0x39, 0x297: 0x39,
+ 0x298: 0x39, 0x299: 0x39, 0x29a: 0x39, 0x29b: 0x39, 0x29c: 0x39, 0x29d: 0x39, 0x29e: 0x87,
+ // Block 0xb, offset 0x2c0
+ 0x2c0: 0x5b, 0x2c1: 0x5b, 0x2c2: 0x5b, 0x2c3: 0x5b, 0x2c4: 0x5b, 0x2c5: 0x5b, 0x2c6: 0x5b, 0x2c7: 0x5b,
+ 0x2c8: 0x5b, 0x2c9: 0x5b, 0x2ca: 0x5b, 0x2cb: 0x5b, 0x2cc: 0x5b, 0x2cd: 0x5b, 0x2ce: 0x5b, 0x2cf: 0x5b,
+ 0x2d0: 0x5b, 0x2d1: 0x5b, 0x2d2: 0x5b, 0x2d3: 0x5b, 0x2d4: 0x5b, 0x2d5: 0x5b, 0x2d6: 0x5b, 0x2d7: 0x5b,
+ 0x2d8: 0x5b, 0x2d9: 0x5b, 0x2da: 0x5b, 0x2db: 0x5b, 0x2dc: 0x5b, 0x2dd: 0x5b, 0x2de: 0x5b, 0x2df: 0x5b,
+ 0x2e0: 0x5b, 0x2e1: 0x5b, 0x2e2: 0x5b, 0x2e3: 0x5b, 0x2e4: 0x5b, 0x2e5: 0x5b, 0x2e6: 0x5b, 0x2e7: 0x5b,
+ 0x2e8: 0x5b, 0x2e9: 0x5b, 0x2ea: 0x5b, 0x2eb: 0x5b, 0x2ec: 0x5b, 0x2ed: 0x5b, 0x2ee: 0x5b, 0x2ef: 0x5b,
+ 0x2f0: 0x5b, 0x2f1: 0x5b, 0x2f2: 0x5b, 0x2f3: 0x5b, 0x2f4: 0x5b, 0x2f5: 0x5b, 0x2f6: 0x5b, 0x2f7: 0x5b,
+ 0x2f8: 0x5b, 0x2f9: 0x5b, 0x2fa: 0x5b, 0x2fb: 0x5b, 0x2fc: 0x5b, 0x2fd: 0x5b, 0x2fe: 0x5b, 0x2ff: 0x5b,
+ // Block 0xc, offset 0x300
+ 0x300: 0x5b, 0x301: 0x5b, 0x302: 0x5b, 0x303: 0x5b, 0x304: 0x5b, 0x305: 0x5b, 0x306: 0x5b, 0x307: 0x5b,
+ 0x308: 0x5b, 0x309: 0x5b, 0x30a: 0x5b, 0x30b: 0x5b, 0x30c: 0x5b, 0x30d: 0x5b, 0x30e: 0x5b, 0x30f: 0x5b,
+ 0x310: 0x5b, 0x311: 0x5b, 0x312: 0x5b, 0x313: 0x5b, 0x314: 0x5b, 0x315: 0x5b, 0x316: 0x5b, 0x317: 0x5b,
+ 0x318: 0x5b, 0x319: 0x5b, 0x31a: 0x5b, 0x31b: 0x5b, 0x31c: 0x5b, 0x31d: 0x5b, 0x31e: 0x5b, 0x31f: 0x5b,
+ 0x320: 0x5b, 0x321: 0x5b, 0x322: 0x5b, 0x323: 0x5b, 0x324: 0x39, 0x325: 0x39, 0x326: 0x39, 0x327: 0x39,
+ 0x328: 0x39, 0x329: 0x39, 0x32a: 0x39, 0x32b: 0x39, 0x32c: 0x88,
+ 0x338: 0x89, 0x339: 0x8a, 0x33b: 0x6a, 0x33c: 0x70, 0x33d: 0x8b, 0x33f: 0x8c,
+ // Block 0xd, offset 0x340
+ 0x347: 0x8d,
+ 0x34b: 0x8e, 0x34d: 0x8f,
+ 0x368: 0x90, 0x36b: 0x91,
+ 0x374: 0x92,
+ 0x37a: 0x93, 0x37b: 0x94, 0x37d: 0x95, 0x37e: 0x96,
+ // Block 0xe, offset 0x380
+ 0x380: 0x97, 0x381: 0x98, 0x382: 0x99, 0x383: 0x9a, 0x384: 0x9b, 0x385: 0x9c, 0x386: 0x9d, 0x387: 0x9e,
+ 0x388: 0x9f, 0x389: 0x2c, 0x38b: 0xa0, 0x38c: 0x2a, 0x38d: 0xa1,
+ 0x390: 0xa2, 0x391: 0xa3, 0x392: 0xa4, 0x393: 0xa5, 0x396: 0xa6, 0x397: 0xa7,
+ 0x398: 0xa8, 0x399: 0xa9, 0x39a: 0xaa, 0x39c: 0xab,
+ 0x3a0: 0xac, 0x3a4: 0xad, 0x3a5: 0xae, 0x3a7: 0xaf,
+ 0x3a8: 0xb0, 0x3a9: 0xb1, 0x3aa: 0xb2,
+ 0x3b0: 0xb3, 0x3b2: 0xb4, 0x3b4: 0xb5, 0x3b5: 0xb6, 0x3b6: 0xb7,
+ 0x3bb: 0xb8, 0x3bc: 0xb9, 0x3bd: 0xba,
+ // Block 0xf, offset 0x3c0
+ 0x3d0: 0x45, 0x3d1: 0xbb,
+ // Block 0x10, offset 0x400
+ 0x42b: 0xbc, 0x42c: 0xbd,
+ 0x43d: 0xbe, 0x43e: 0xbf, 0x43f: 0xc0,
+ // Block 0x11, offset 0x440
+ 0x440: 0x39, 0x441: 0x39, 0x442: 0x39, 0x443: 0x39, 0x444: 0x39, 0x445: 0x39, 0x446: 0x39, 0x447: 0x39,
+ 0x448: 0x39, 0x449: 0x39, 0x44a: 0x39, 0x44b: 0x39, 0x44c: 0x39, 0x44d: 0x39, 0x44e: 0x39, 0x44f: 0x39,
+ 0x450: 0x39, 0x451: 0x39, 0x452: 0x39, 0x453: 0x39, 0x454: 0x39, 0x455: 0x39, 0x456: 0x39, 0x457: 0x39,
+ 0x458: 0x39, 0x459: 0x39, 0x45a: 0x39, 0x45b: 0x39, 0x45c: 0x39, 0x45d: 0x39, 0x45e: 0x39, 0x45f: 0x39,
+ 0x460: 0x39, 0x461: 0x39, 0x462: 0x39, 0x463: 0x39, 0x464: 0x39, 0x465: 0x39, 0x466: 0x39, 0x467: 0x39,
+ 0x468: 0x39, 0x469: 0x39, 0x46a: 0x39, 0x46b: 0x39, 0x46c: 0x39, 0x46d: 0x39, 0x46e: 0x39, 0x46f: 0x39,
+ 0x470: 0x39, 0x471: 0x39, 0x472: 0x39, 0x473: 0xc1, 0x474: 0xc2, 0x476: 0x39, 0x477: 0xc3,
+ // Block 0x12, offset 0x480
+ 0x4bf: 0xc4,
+ // Block 0x13, offset 0x4c0
+ 0x4c0: 0x39, 0x4c1: 0x39, 0x4c2: 0x39, 0x4c3: 0x39, 0x4c4: 0xc5, 0x4c5: 0xc6, 0x4c6: 0x39, 0x4c7: 0x39,
+ 0x4c8: 0x39, 0x4c9: 0x39, 0x4ca: 0x39, 0x4cb: 0xc7,
+ 0x4f2: 0xc8,
+ // Block 0x14, offset 0x500
+ 0x53c: 0xc9, 0x53d: 0xca,
+ // Block 0x15, offset 0x540
+ 0x545: 0xcb, 0x546: 0xcc,
+ 0x549: 0xcd, 0x54c: 0x39, 0x54d: 0xce,
+ 0x568: 0xcf, 0x569: 0xd0, 0x56a: 0xd1,
+ // Block 0x16, offset 0x580
+ 0x580: 0xd2, 0x582: 0xbe, 0x584: 0xbd,
+ 0x58a: 0xd3, 0x58b: 0xd4,
+ 0x593: 0xd4,
+ 0x5a3: 0xd5, 0x5a5: 0xd6,
+ // Block 0x17, offset 0x5c0
+ 0x5c0: 0xd7, 0x5c3: 0xd8, 0x5c4: 0xd9, 0x5c5: 0xda, 0x5c6: 0xdb, 0x5c7: 0xdc,
+ 0x5c8: 0xdd, 0x5c9: 0xde, 0x5cc: 0xdf, 0x5cd: 0xe0, 0x5ce: 0xe1, 0x5cf: 0xe2,
+ 0x5d0: 0xe3, 0x5d1: 0xe4, 0x5d2: 0x39, 0x5d3: 0xe5, 0x5d4: 0xe6, 0x5d5: 0xe7, 0x5d6: 0xe8, 0x5d7: 0xe9,
+ 0x5d8: 0x39, 0x5d9: 0xea, 0x5da: 0x39, 0x5db: 0xeb, 0x5df: 0xec,
+ 0x5e4: 0xed, 0x5e5: 0xee, 0x5e6: 0x39, 0x5e7: 0x39,
+ 0x5e9: 0xef, 0x5ea: 0xf0, 0x5eb: 0xf1,
+ // Block 0x18, offset 0x600
+ 0x600: 0x39, 0x601: 0x39, 0x602: 0x39, 0x603: 0x39, 0x604: 0x39, 0x605: 0x39, 0x606: 0x39, 0x607: 0x39,
+ 0x608: 0x39, 0x609: 0x39, 0x60a: 0x39, 0x60b: 0x39, 0x60c: 0x39, 0x60d: 0x39, 0x60e: 0x39, 0x60f: 0x39,
+ 0x610: 0x39, 0x611: 0x39, 0x612: 0x39, 0x613: 0x39, 0x614: 0x39, 0x615: 0x39, 0x616: 0x39, 0x617: 0x39,
+ 0x618: 0x39, 0x619: 0x39, 0x61a: 0x39, 0x61b: 0x39, 0x61c: 0x39, 0x61d: 0x39, 0x61e: 0x39, 0x61f: 0x39,
+ 0x620: 0x39, 0x621: 0x39, 0x622: 0x39, 0x623: 0x39, 0x624: 0x39, 0x625: 0x39, 0x626: 0x39, 0x627: 0x39,
+ 0x628: 0x39, 0x629: 0x39, 0x62a: 0x39, 0x62b: 0x39, 0x62c: 0x39, 0x62d: 0x39, 0x62e: 0x39, 0x62f: 0x39,
+ 0x630: 0x39, 0x631: 0x39, 0x632: 0x39, 0x633: 0x39, 0x634: 0x39, 0x635: 0x39, 0x636: 0x39, 0x637: 0x39,
+ 0x638: 0x39, 0x639: 0x39, 0x63a: 0x39, 0x63b: 0x39, 0x63c: 0x39, 0x63d: 0x39, 0x63e: 0x39, 0x63f: 0xe6,
+ // Block 0x19, offset 0x640
+ 0x650: 0x0b, 0x651: 0x0c, 0x653: 0x0d, 0x656: 0x0e, 0x657: 0x06,
+ 0x658: 0x0f, 0x65a: 0x10, 0x65b: 0x11, 0x65c: 0x12, 0x65d: 0x13, 0x65e: 0x14, 0x65f: 0x15,
+ 0x660: 0x06, 0x661: 0x06, 0x662: 0x06, 0x663: 0x06, 0x664: 0x06, 0x665: 0x06, 0x666: 0x06, 0x667: 0x06,
+ 0x668: 0x06, 0x669: 0x06, 0x66a: 0x06, 0x66b: 0x06, 0x66c: 0x06, 0x66d: 0x06, 0x66e: 0x06, 0x66f: 0x16,
+ 0x670: 0x06, 0x671: 0x06, 0x672: 0x06, 0x673: 0x06, 0x674: 0x06, 0x675: 0x06, 0x676: 0x06, 0x677: 0x06,
+ 0x678: 0x06, 0x679: 0x06, 0x67a: 0x06, 0x67b: 0x06, 0x67c: 0x06, 0x67d: 0x06, 0x67e: 0x06, 0x67f: 0x16,
+ // Block 0x1a, offset 0x680
+ 0x680: 0xf2, 0x681: 0x08, 0x684: 0x08, 0x685: 0x08, 0x686: 0x08, 0x687: 0x09,
+ // Block 0x1b, offset 0x6c0
+ 0x6c0: 0x5b, 0x6c1: 0x5b, 0x6c2: 0x5b, 0x6c3: 0x5b, 0x6c4: 0x5b, 0x6c5: 0x5b, 0x6c6: 0x5b, 0x6c7: 0x5b,
+ 0x6c8: 0x5b, 0x6c9: 0x5b, 0x6ca: 0x5b, 0x6cb: 0x5b, 0x6cc: 0x5b, 0x6cd: 0x5b, 0x6ce: 0x5b, 0x6cf: 0x5b,
+ 0x6d0: 0x5b, 0x6d1: 0x5b, 0x6d2: 0x5b, 0x6d3: 0x5b, 0x6d4: 0x5b, 0x6d5: 0x5b, 0x6d6: 0x5b, 0x6d7: 0x5b,
+ 0x6d8: 0x5b, 0x6d9: 0x5b, 0x6da: 0x5b, 0x6db: 0x5b, 0x6dc: 0x5b, 0x6dd: 0x5b, 0x6de: 0x5b, 0x6df: 0x5b,
+ 0x6e0: 0x5b, 0x6e1: 0x5b, 0x6e2: 0x5b, 0x6e3: 0x5b, 0x6e4: 0x5b, 0x6e5: 0x5b, 0x6e6: 0x5b, 0x6e7: 0x5b,
+ 0x6e8: 0x5b, 0x6e9: 0x5b, 0x6ea: 0x5b, 0x6eb: 0x5b, 0x6ec: 0x5b, 0x6ed: 0x5b, 0x6ee: 0x5b, 0x6ef: 0x5b,
+ 0x6f0: 0x5b, 0x6f1: 0x5b, 0x6f2: 0x5b, 0x6f3: 0x5b, 0x6f4: 0x5b, 0x6f5: 0x5b, 0x6f6: 0x5b, 0x6f7: 0x5b,
+ 0x6f8: 0x5b, 0x6f9: 0x5b, 0x6fa: 0x5b, 0x6fb: 0x5b, 0x6fc: 0x5b, 0x6fd: 0x5b, 0x6fe: 0x5b, 0x6ff: 0xf3,
+ // Block 0x1c, offset 0x700
+ 0x720: 0x18,
+ 0x730: 0x09, 0x731: 0x09, 0x732: 0x09, 0x733: 0x09, 0x734: 0x09, 0x735: 0x09, 0x736: 0x09, 0x737: 0x09,
+ 0x738: 0x09, 0x739: 0x09, 0x73a: 0x09, 0x73b: 0x09, 0x73c: 0x09, 0x73d: 0x09, 0x73e: 0x09, 0x73f: 0x19,
+ // Block 0x1d, offset 0x740
+ 0x740: 0x09, 0x741: 0x09, 0x742: 0x09, 0x743: 0x09, 0x744: 0x09, 0x745: 0x09, 0x746: 0x09, 0x747: 0x09,
+ 0x748: 0x09, 0x749: 0x09, 0x74a: 0x09, 0x74b: 0x09, 0x74c: 0x09, 0x74d: 0x09, 0x74e: 0x09, 0x74f: 0x19,
+}
diff --git a/vendor/github.com/clipperhouse/displaywidth/truncate.go b/vendor/github.com/clipperhouse/displaywidth/truncate.go
new file mode 100644
index 0000000000..b3e696f49b
--- /dev/null
+++ b/vendor/github.com/clipperhouse/displaywidth/truncate.go
@@ -0,0 +1,149 @@
+package displaywidth
+
+import (
+ "strings"
+
+ "github.com/clipperhouse/uax29/v2/graphemes"
+)
+
+// TruncateString truncates a string to the given maxWidth, and appends the
+// given tail if the string is truncated.
+//
+// It ensures the visible width, including the width of the tail, is less than or
+// equal to maxWidth.
+//
+// When [Options.ControlSequences] is true, 7-bit ANSI escape sequences that
+// appear after the truncation point are preserved in the output. This ensures
+// that escape sequences such as SGR resets are not lost, preventing color
+// bleed in terminal output.
+//
+// [Options.ControlSequences8Bit] is ignored by truncation. 8-bit C1 byte values
+// (0x80-0x9F) overlap with UTF-8 multi-byte encoding, so manipulating them
+// during truncation can shift byte boundaries and form unintended visible
+// characters. Use [Options.String] or [Options.Bytes] for 8-bit-aware width
+// measurement.
+func (options Options) TruncateString(s string, maxWidth int, tail string) string {
+ // We deliberately ignore ControlSequences8Bit for truncation, see above.
+ options.ControlSequences8Bit = false
+
+ maxWidthWithoutTail := maxWidth - options.String(tail)
+
+ var pos, total int
+ g := graphemes.FromString(s)
+ g.AnsiEscapeSequences = options.ControlSequences
+
+ for g.Next() {
+ gw := graphemeWidth(g.Value(), options)
+ if total+gw <= maxWidthWithoutTail {
+ pos = g.End()
+ }
+ total += gw
+ if total > maxWidth {
+ if options.ControlSequences {
+ // Build result with trailing 7-bit ANSI escape sequences preserved
+ var b strings.Builder
+ b.Grow(len(s) + len(tail)) // at most original + tail
+ b.WriteString(s[:pos])
+ b.WriteString(tail)
+
+ rem := graphemes.FromString(s[pos:])
+ rem.AnsiEscapeSequences = options.ControlSequences
+
+ for rem.Next() {
+ v := rem.Value()
+ // Only preserve 7-bit escapes (ESC = 0x1B) that measure
+ // as zero-width on their own; some sequences (e.g. SOS)
+ // are only valid in their original context.
+ if len(v) > 0 && v[0] == 0x1B && options.String(v) == 0 {
+ b.WriteString(v)
+ }
+ }
+ return b.String()
+ }
+ return s[:pos] + tail
+ }
+ }
+ // No truncation
+ return s
+}
+
+// TruncateString truncates a string to the given maxWidth, and appends the
+// given tail if the string is truncated.
+//
+// It ensures the total width, including the width of the tail, is less than or
+// equal to maxWidth.
+func TruncateString(s string, maxWidth int, tail string) string {
+ return DefaultOptions.TruncateString(s, maxWidth, tail)
+}
+
+// TruncateBytes truncates a []byte to the given maxWidth, and appends the
+// given tail if the []byte is truncated.
+//
+// It ensures the visible width, including the width of the tail, is less than or
+// equal to maxWidth.
+//
+// When [Options.ControlSequences] is true, 7-bit ANSI escape sequences that
+// appear after the truncation point are preserved in the output. This ensures
+// that escape sequences such as SGR resets are not lost, preventing color
+// bleed in terminal output.
+//
+// [Options.ControlSequences8Bit] is ignored by truncation. 8-bit C1 byte values
+// (0x80-0x9F) overlap with UTF-8 multi-byte encoding, so manipulating them
+// during truncation can shift byte boundaries and form unintended visible
+// characters. Use [Options.String] or [Options.Bytes] for 8-bit-aware width
+// measurement.
+func (options Options) TruncateBytes(s []byte, maxWidth int, tail []byte) []byte {
+ // We deliberately ignore ControlSequences8Bit for truncation, see above.
+ options.ControlSequences8Bit = false
+
+ maxWidthWithoutTail := maxWidth - options.Bytes(tail)
+
+ var pos, total int
+ g := graphemes.FromBytes(s)
+ g.AnsiEscapeSequences = options.ControlSequences
+
+ for g.Next() {
+ gw := graphemeWidth(g.Value(), options)
+ if total+gw <= maxWidthWithoutTail {
+ pos = g.End()
+ }
+ total += gw
+ if total > maxWidth {
+ if options.ControlSequences {
+ // Build result with trailing 7-bit ANSI escape sequences preserved
+ result := make([]byte, 0, len(s)+len(tail)) // at most original + tail
+ result = append(result, s[:pos]...)
+ result = append(result, tail...)
+
+ rem := graphemes.FromBytes(s[pos:])
+ rem.AnsiEscapeSequences = options.ControlSequences
+
+ for rem.Next() {
+ v := rem.Value()
+ // Only preserve 7-bit escapes (ESC = 0x1B) that measure
+ // as zero-width on their own; some sequences (e.g. SOS)
+ // are only valid in their original context.
+ if len(v) > 0 && v[0] == 0x1B && options.Bytes(v) == 0 {
+ result = append(result, v...)
+ }
+ }
+ return result
+ }
+ result := make([]byte, 0, pos+len(tail))
+ result = append(result, s[:pos]...)
+ result = append(result, tail...)
+ return result
+ }
+ }
+ // No truncation
+ return s
+}
+
+// TruncateBytes truncates a []byte to the given maxWidth, and appends the
+// given tail if the []byte is truncated.
+//
+// It ensures the total width, including the width of the tail, is less than or
+// equal to maxWidth.
+func TruncateBytes(s []byte, maxWidth int, tail []byte) []byte {
+ return DefaultOptions.TruncateBytes(s, maxWidth, tail)
+}
diff --git a/vendor/github.com/clipperhouse/displaywidth/width.go b/vendor/github.com/clipperhouse/displaywidth/width.go
new file mode 100644
index 0000000000..f6e0ab7fd1
--- /dev/null
+++ b/vendor/github.com/clipperhouse/displaywidth/width.go
@@ -0,0 +1,239 @@
+package displaywidth
+
+import (
+ "unicode/utf8"
+
+ "github.com/clipperhouse/uax29/v2/graphemes"
+)
+
+// String calculates the display width of a string,
+// by iterating over grapheme clusters in the string
+// and summing their widths.
+func String(s string) int {
+ return DefaultOptions.String(s)
+}
+
+// String calculates the display width of a string, for the given options, by
+// iterating over grapheme clusters in the string and summing their widths.
+func (options Options) String(s string) int {
+ width := 0
+ pos := 0
+
+ for pos < len(s) {
+ // Try ASCII optimization
+ asciiLen := printableASCIILength(s[pos:])
+ if asciiLen > 0 {
+ width += asciiLen
+ pos += asciiLen
+ continue
+ }
+
+ // Not ASCII, use grapheme parsing
+ g := graphemes.FromString(s[pos:])
+ g.AnsiEscapeSequences = options.ControlSequences
+ g.AnsiEscapeSequences8Bit = options.ControlSequences8Bit
+
+ start := pos
+
+ for g.Next() {
+ v := g.Value()
+ width += graphemeWidth(v, options)
+ pos += len(v)
+
+ // Quick check: if remaining might have printable ASCII, break to outer loop
+ if pos < len(s) && s[pos] >= 0x20 && s[pos] <= 0x7E {
+ break
+ }
+ }
+
+ // Defensive, should not happen: if no progress was made,
+ // skip a byte to prevent infinite loop. Only applies if
+ // the grapheme parser misbehaves.
+ if pos == start {
+ pos++
+ }
+ }
+
+ return width
+}
+
+// Bytes calculates the display width of a []byte,
+// by iterating over grapheme clusters in the byte slice
+// and summing their widths.
+func Bytes(s []byte) int {
+ return DefaultOptions.Bytes(s)
+}
+
+// Bytes calculates the display width of a []byte, for the given options, by
+// iterating over grapheme clusters in the slice and summing their widths.
+func (options Options) Bytes(s []byte) int {
+ width := 0
+ pos := 0
+
+ for pos < len(s) {
+ // Try ASCII optimization
+ asciiLen := printableASCIILength(s[pos:])
+ if asciiLen > 0 {
+ width += asciiLen
+ pos += asciiLen
+ continue
+ }
+
+ // Not ASCII, use grapheme parsing
+ g := graphemes.FromBytes(s[pos:])
+ g.AnsiEscapeSequences = options.ControlSequences
+ g.AnsiEscapeSequences8Bit = options.ControlSequences8Bit
+
+ start := pos
+
+ for g.Next() {
+ v := g.Value()
+ width += graphemeWidth(v, options)
+ pos += len(v)
+
+ // Quick check: if remaining might have printable ASCII, break to outer loop
+ if pos < len(s) && s[pos] >= 0x20 && s[pos] <= 0x7E {
+ break
+ }
+ }
+
+ // Defensive, should not happen: if no progress was made,
+ // skip a byte to prevent infinite loop. Only applies if
+ // the grapheme parser misbehaves.
+ if pos == start {
+ pos++
+ }
+ }
+
+ return width
+}
+
+// Rune calculates the display width of a rune. You
+// should almost certainly use [String] or [Bytes] for
+// most purposes.
+//
+// The smallest unit of display width is a grapheme
+// cluster, not a rune. Iterating over runes to measure
+// width is incorrect in many cases.
+func Rune(r rune) int {
+ return DefaultOptions.Rune(r)
+}
+
+// Rune calculates the display width of a rune, for the given options.
+//
+// You should almost certainly use [String] or [Bytes] for most purposes.
+//
+// The smallest unit of display width is a grapheme cluster, not a rune.
+// Iterating over runes to measure width is incorrect in many cases.
+func (options Options) Rune(r rune) int {
+ if r < utf8.RuneSelf {
+ return asciiWidth(byte(r))
+ }
+
+ // Surrogates (U+D800-U+DFFF) are invalid UTF-8.
+ if r >= 0xD800 && r <= 0xDFFF {
+ return 0
+ }
+
+ var buf [4]byte
+ n := utf8.EncodeRune(buf[:], r)
+
+ // Skip the grapheme iterator
+ return graphemeWidth(buf[:n], options)
+}
+
+const _Default property = 0
+
+// graphemeWidth returns the display width of a grapheme cluster.
+// The passed string must be a single grapheme cluster.
+func graphemeWidth[T ~string | []byte](s T, options Options) int {
+ if len(s) == 0 {
+ return 0
+ }
+
+ // C1 controls (0x80-0x9F) are zero-width when 8-bit control sequences
+ // are enabled. This must be checked before the single-byte optimization
+ // below, which would otherwise return width 1 for these bytes.
+ if options.ControlSequences8Bit && s[0] >= 0x80 && s[0] <= 0x9F {
+ return 0
+ }
+
+ // Optimization: single-byte graphemes need no property lookup
+ if len(s) == 1 {
+ return asciiWidth(s[0])
+ }
+
+ // Multi-byte grapheme clusters led by a C0 control (0x00-0x1F)
+ if s[0] <= 0x1F {
+ return 0
+ }
+
+ p, sz := lookup(s)
+ prop := property(p)
+
+ // Variation Selector 16 (VS16) requests emoji presentation
+ if prop != _Wide && sz > 0 && len(s) >= sz+3 {
+ vs := s[sz : sz+3]
+ if isVS16(vs) {
+ prop = _Wide
+ }
+ // VS15 (0x8E) requests text presentation but does not affect width,
+ // in my reading of Unicode TR51. Falls through to return the base
+ // character's property.
+ }
+
+ if options.EastAsianWidth && prop == _East_Asian_Ambiguous {
+ prop = _Wide
+ }
+
+ if prop > upperBound {
+ prop = _Default
+ }
+
+ return propertyWidths[prop]
+}
+
+func asciiWidth(b byte) int {
+ if b <= 0x1F || b == 0x7F {
+ return 0
+ }
+ return 1
+}
+
+// printableASCIILength returns the length of consecutive printable ASCII bytes
+// starting at the beginning of s.
+func printableASCIILength[T string | []byte](s T) int {
+ i := 0
+ for ; i < len(s); i++ {
+ b := s[i]
+ // Printable ASCII is 0x20-0x7E (space through tilde)
+ if b < 0x20 || b > 0x7E {
+ break
+ }
+ }
+
+ // If the next byte is non-ASCII (>= 0x80), back off by 1. The grapheme
+ // parser may group the last ASCII byte with subsequent non-ASCII bytes,
+ // such as combining marks.
+ if i > 0 && i < len(s) && s[i] >= 0x80 {
+ i--
+ }
+
+ return i
+}
+
+// isVS16 checks if the slice matches VS16 (U+FE0F) UTF-8 encoding
+// (EF B8 8F). It assumes len(s) >= 3.
+func isVS16[T ~string | []byte](s T) bool {
+ return s[0] == 0xEF && s[1] == 0xB8 && s[2] == 0x8F
+}
+
+// propertyWidths is a jump table of sorts, instead of a switch
+var propertyWidths = [4]int{
+ _Default: 1,
+ _Zero_Width: 0,
+ _Wide: 2,
+ _East_Asian_Ambiguous: 1,
+}
+
+const upperBound = property(len(propertyWidths) - 1)
diff --git a/vendor/github.com/daixiang0/gci/pkg/config/config.go b/vendor/github.com/daixiang0/gci/pkg/config/config.go
index 814201a006..643a313f0d 100644
--- a/vendor/github.com/daixiang0/gci/pkg/config/config.go
+++ b/vendor/github.com/daixiang0/gci/pkg/config/config.go
@@ -2,7 +2,6 @@ package config
import (
"sort"
- "strings"
"gopkg.in/yaml.v3"
@@ -64,11 +63,11 @@ func (g YamlConfig) Parse() (*Config, error) {
sort.Slice(sections, func(i, j int) bool {
sectionI, sectionJ := sections[i].Type(), sections[j].Type()
- if g.Cfg.NoLexOrder || strings.Compare(sectionI, sectionJ) != 0 {
+ if g.Cfg.NoLexOrder || sectionI != sectionJ {
return defaultOrder[sectionI] < defaultOrder[sectionJ]
}
- return strings.Compare(sections[i].String(), sections[j].String()) < 0
+ return sections[i].String() < sections[j].String()
})
}
diff --git a/vendor/github.com/daixiang0/gci/pkg/section/standard_list.go b/vendor/github.com/daixiang0/gci/pkg/section/standard_list.go
index 5a2dcdc899..34cf38cec5 100644
--- a/vendor/github.com/daixiang0/gci/pkg/section/standard_list.go
+++ b/vendor/github.com/daixiang0/gci/pkg/section/standard_list.go
@@ -1,175 +1,185 @@
package section
-// Code generated based on go1.23.0 X:boringcrypto,arenas. DO NOT EDIT.
+// Code generated based on go1.25rc1 X:boringcrypto,arenas,synctest,jsonv2. DO NOT EDIT.
var standardPackages = map[string]struct{}{
- "archive/tar": {},
- "archive/zip": {},
- "arena": {},
- "bufio": {},
- "bytes": {},
- "cmp": {},
- "compress/bzip2": {},
- "compress/flate": {},
- "compress/gzip": {},
- "compress/lzw": {},
- "compress/zlib": {},
- "container/heap": {},
- "container/list": {},
- "container/ring": {},
- "context": {},
- "crypto": {},
- "crypto/aes": {},
- "crypto/boring": {},
- "crypto/cipher": {},
- "crypto/des": {},
- "crypto/dsa": {},
- "crypto/ecdh": {},
- "crypto/ecdsa": {},
- "crypto/ed25519": {},
- "crypto/elliptic": {},
- "crypto/hmac": {},
- "crypto/md5": {},
- "crypto/rand": {},
- "crypto/rc4": {},
- "crypto/rsa": {},
- "crypto/sha1": {},
- "crypto/sha256": {},
- "crypto/sha512": {},
- "crypto/subtle": {},
- "crypto/tls": {},
- "crypto/tls/fipsonly": {},
- "crypto/x509": {},
- "crypto/x509/pkix": {},
- "database/sql": {},
- "database/sql/driver": {},
- "debug/buildinfo": {},
- "debug/dwarf": {},
- "debug/elf": {},
- "debug/gosym": {},
- "debug/macho": {},
- "debug/pe": {},
- "debug/plan9obj": {},
- "embed": {},
- "encoding": {},
- "encoding/ascii85": {},
- "encoding/asn1": {},
- "encoding/base32": {},
- "encoding/base64": {},
- "encoding/binary": {},
- "encoding/csv": {},
- "encoding/gob": {},
- "encoding/hex": {},
- "encoding/json": {},
- "encoding/pem": {},
- "encoding/xml": {},
- "errors": {},
- "expvar": {},
- "flag": {},
- "fmt": {},
- "go/ast": {},
- "go/build": {},
- "go/build/constraint": {},
- "go/constant": {},
- "go/doc": {},
- "go/doc/comment": {},
- "go/format": {},
- "go/importer": {},
- "go/parser": {},
- "go/printer": {},
- "go/scanner": {},
- "go/token": {},
- "go/types": {},
- "go/version": {},
- "hash": {},
- "hash/adler32": {},
- "hash/crc32": {},
- "hash/crc64": {},
- "hash/fnv": {},
- "hash/maphash": {},
- "html": {},
- "html/template": {},
- "image": {},
- "image/color": {},
- "image/color/palette": {},
- "image/draw": {},
- "image/gif": {},
- "image/jpeg": {},
- "image/png": {},
- "index/suffixarray": {},
- "io": {},
- "io/fs": {},
- "io/ioutil": {},
- "iter": {},
- "log": {},
- "log/slog": {},
- "log/syslog": {},
- "maps": {},
- "math": {},
- "math/big": {},
- "math/bits": {},
- "math/cmplx": {},
- "math/rand": {},
- "math/rand/v2": {},
- "mime": {},
- "mime/multipart": {},
- "mime/quotedprintable": {},
- "net": {},
- "net/http": {},
- "net/http/cgi": {},
- "net/http/cookiejar": {},
- "net/http/fcgi": {},
- "net/http/httptest": {},
- "net/http/httptrace": {},
- "net/http/httputil": {},
- "net/http/pprof": {},
- "net/mail": {},
- "net/netip": {},
- "net/rpc": {},
- "net/rpc/jsonrpc": {},
- "net/smtp": {},
- "net/textproto": {},
- "net/url": {},
- "os": {},
- "os/exec": {},
- "os/signal": {},
- "os/user": {},
- "path": {},
- "path/filepath": {},
- "plugin": {},
- "reflect": {},
- "regexp": {},
- "regexp/syntax": {},
- "runtime": {},
- "runtime/cgo": {},
- "runtime/coverage": {},
- "runtime/debug": {},
- "runtime/metrics": {},
- "runtime/pprof": {},
- "runtime/race": {},
- "runtime/trace": {},
- "slices": {},
- "sort": {},
- "strconv": {},
- "strings": {},
- "structs": {},
- "sync": {},
- "sync/atomic": {},
- "syscall": {},
- "testing": {},
- "testing/fstest": {},
- "testing/iotest": {},
- "testing/quick": {},
- "testing/slogtest": {},
- "text/scanner": {},
- "text/tabwriter": {},
- "text/template": {},
- "text/template/parse": {},
- "time": {},
- "time/tzdata": {},
- "unicode": {},
- "unicode/utf16": {},
- "unicode/utf8": {},
- "unique": {},
- "unsafe": {},
+ "archive/tar": {},
+ "archive/zip": {},
+ "arena": {},
+ "bufio": {},
+ "bytes": {},
+ "cmp": {},
+ "compress/bzip2": {},
+ "compress/flate": {},
+ "compress/gzip": {},
+ "compress/lzw": {},
+ "compress/zlib": {},
+ "container/heap": {},
+ "container/list": {},
+ "container/ring": {},
+ "context": {},
+ "crypto": {},
+ "crypto/aes": {},
+ "crypto/boring": {},
+ "crypto/cipher": {},
+ "crypto/des": {},
+ "crypto/dsa": {},
+ "crypto/ecdh": {},
+ "crypto/ecdsa": {},
+ "crypto/ed25519": {},
+ "crypto/elliptic": {},
+ "crypto/fips140": {},
+ "crypto/hkdf": {},
+ "crypto/hmac": {},
+ "crypto/md5": {},
+ "crypto/mlkem": {},
+ "crypto/pbkdf2": {},
+ "crypto/rand": {},
+ "crypto/rc4": {},
+ "crypto/rsa": {},
+ "crypto/sha1": {},
+ "crypto/sha256": {},
+ "crypto/sha3": {},
+ "crypto/sha512": {},
+ "crypto/subtle": {},
+ "crypto/tls": {},
+ "crypto/tls/fipsonly": {},
+ "crypto/x509": {},
+ "crypto/x509/pkix": {},
+ "database/sql": {},
+ "database/sql/driver": {},
+ "debug/buildinfo": {},
+ "debug/dwarf": {},
+ "debug/elf": {},
+ "debug/gosym": {},
+ "debug/macho": {},
+ "debug/pe": {},
+ "debug/plan9obj": {},
+ "embed": {},
+ "encoding": {},
+ "encoding/ascii85": {},
+ "encoding/asn1": {},
+ "encoding/base32": {},
+ "encoding/base64": {},
+ "encoding/binary": {},
+ "encoding/csv": {},
+ "encoding/gob": {},
+ "encoding/hex": {},
+ "encoding/json": {},
+ "encoding/json/jsontext": {},
+ "encoding/json/v2": {},
+ "encoding/pem": {},
+ "encoding/xml": {},
+ "errors": {},
+ "expvar": {},
+ "flag": {},
+ "fmt": {},
+ "go/ast": {},
+ "go/build": {},
+ "go/build/constraint": {},
+ "go/constant": {},
+ "go/doc": {},
+ "go/doc/comment": {},
+ "go/format": {},
+ "go/importer": {},
+ "go/parser": {},
+ "go/printer": {},
+ "go/scanner": {},
+ "go/token": {},
+ "go/types": {},
+ "go/version": {},
+ "hash": {},
+ "hash/adler32": {},
+ "hash/crc32": {},
+ "hash/crc64": {},
+ "hash/fnv": {},
+ "hash/maphash": {},
+ "html": {},
+ "html/template": {},
+ "image": {},
+ "image/color": {},
+ "image/color/palette": {},
+ "image/draw": {},
+ "image/gif": {},
+ "image/jpeg": {},
+ "image/png": {},
+ "index/suffixarray": {},
+ "io": {},
+ "io/fs": {},
+ "io/ioutil": {},
+ "iter": {},
+ "log": {},
+ "log/slog": {},
+ "log/syslog": {},
+ "maps": {},
+ "math": {},
+ "math/big": {},
+ "math/bits": {},
+ "math/cmplx": {},
+ "math/rand": {},
+ "math/rand/v2": {},
+ "mime": {},
+ "mime/multipart": {},
+ "mime/quotedprintable": {},
+ "net": {},
+ "net/http": {},
+ "net/http/cgi": {},
+ "net/http/cookiejar": {},
+ "net/http/fcgi": {},
+ "net/http/httptest": {},
+ "net/http/httptrace": {},
+ "net/http/httputil": {},
+ "net/http/pprof": {},
+ "net/mail": {},
+ "net/netip": {},
+ "net/rpc": {},
+ "net/rpc/jsonrpc": {},
+ "net/smtp": {},
+ "net/textproto": {},
+ "net/url": {},
+ "os": {},
+ "os/exec": {},
+ "os/signal": {},
+ "os/user": {},
+ "path": {},
+ "path/filepath": {},
+ "plugin": {},
+ "reflect": {},
+ "regexp": {},
+ "regexp/syntax": {},
+ "runtime": {},
+ "runtime/cgo": {},
+ "runtime/coverage": {},
+ "runtime/debug": {},
+ "runtime/metrics": {},
+ "runtime/pprof": {},
+ "runtime/race": {},
+ "runtime/trace": {},
+ "slices": {},
+ "sort": {},
+ "strconv": {},
+ "strings": {},
+ "structs": {},
+ "sync": {},
+ "sync/atomic": {},
+ "syscall": {},
+ "syscall/js": {},
+ "testing": {},
+ "testing/fstest": {},
+ "testing/iotest": {},
+ "testing/quick": {},
+ "testing/slogtest": {},
+ "testing/synctest": {},
+ "text/scanner": {},
+ "text/tabwriter": {},
+ "text/template": {},
+ "text/template/parse": {},
+ "time": {},
+ "time/tzdata": {},
+ "unicode": {},
+ "unicode/utf16": {},
+ "unicode/utf8": {},
+ "unique": {},
+ "unsafe": {},
+ "weak": {},
}
diff --git a/vendor/github.com/dave/dst/.gitignore b/vendor/github.com/dave/dst/.gitignore
new file mode 100644
index 0000000000..5a391e10f6
--- /dev/null
+++ b/vendor/github.com/dave/dst/.gitignore
@@ -0,0 +1,4 @@
+*.iml
+.DS_Store
+.idea/
+coverage.out
diff --git a/vendor/github.com/dave/dst/LICENSE b/vendor/github.com/dave/dst/LICENSE
new file mode 100644
index 0000000000..95bfa5bed1
--- /dev/null
+++ b/vendor/github.com/dave/dst/LICENSE
@@ -0,0 +1,51 @@
+MIT License
+
+Copyright (c) 2018 David Brophy
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+
+This package was forked from https://github.com/golang/go/tree/master/src/go/ast - original license:
+
+Copyright (c) 2009 The Go Authors. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+ * Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+copyright notice, this list of conditions and the following disclaimer
+in the documentation and/or other materials provided with the
+distribution.
+ * Neither the name of Google Inc. nor the names of its
+contributors may be used to endorse or promote products derived from
+this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\ No newline at end of file
diff --git a/vendor/github.com/dave/dst/README.md b/vendor/github.com/dave/dst/README.md
new file mode 100644
index 0000000000..164b46c217
--- /dev/null
+++ b/vendor/github.com/dave/dst/README.md
@@ -0,0 +1,706 @@
+[](https://github.com/dave/dst/actions/workflows/ci.yml)
+[](https://godoc.org/github.com/dave/dst/decorator)
+[](https://codecov.io/gh/dave/dst)
+
+[](https://sourcegraph.com/github.com/dave/dst?badge)
+
+# Decorated Syntax Tree
+
+The `dst` package enables manipulation of a Go syntax tree with high fidelity. Decorations (e.g.
+comments and line spacing) remain attached to the correct nodes as the tree is modified.
+
+## Where does `go/ast` break?
+
+The `go/ast` package wasn't created with source manipulation as an intended use-case. Comments are
+stored by their byte offset instead of attached to nodes, so re-arranging nodes breaks the output.
+See [this Go issue](https://github.com/golang/go/issues/20744) for more information.
+
+Consider this example where we want to reverse the order of the two statements. As you can see the
+comments don't remain attached to the correct nodes:
+
+```go
+code := `package a
+
+func main(){
+ var a int // foo
+ var b string // bar
+}
+`
+fset := token.NewFileSet()
+f, err := parser.ParseFile(fset, "", code, parser.ParseComments)
+if err != nil {
+ panic(err)
+}
+
+list := f.Decls[0].(*ast.FuncDecl).Body.List
+list[0], list[1] = list[1], list[0]
+
+if err := format.Node(os.Stdout, fset, f); err != nil {
+ panic(err)
+}
+
+//Output:
+//package a
+//
+//func main() {
+// // foo
+// var b string
+// var a int
+// // bar
+//}
+```
+
+Here's the same example using `dst`:
+
+```go
+code := `package a
+
+func main(){
+ var a int // foo
+ var b string // bar
+}
+`
+f, err := decorator.Parse(code)
+if err != nil {
+ panic(err)
+}
+
+list := f.Decls[0].(*dst.FuncDecl).Body.List
+list[0], list[1] = list[1], list[0]
+
+if err := decorator.Print(f); err != nil {
+ panic(err)
+}
+
+//Output:
+//package a
+//
+//func main() {
+// var b string // bar
+// var a int // foo
+//}
+```
+
+## Usage
+
+Parsing a source file to `dst` and printing the results after modification can be accomplished with
+several `Parse` and `Print` convenience functions in the [decorator](https://godoc.org/github.com/dave/dst/decorator)
+package.
+
+For more fine-grained control you can use [Decorator](https://godoc.org/github.com/dave/dst/decorator#Decorator)
+to convert from `ast` to `dst`, and [Restorer](https://godoc.org/github.com/dave/dst/decorator#Restorer)
+to convert back again.
+
+### Comments
+
+Comments are added at decoration attachment points. [See here](https://github.com/dave/dst/blob/master/decorations-types-generated.go)
+for a full list of these points, along with demonstration code of where they are rendered in the
+output.
+
+The decoration attachment points have convenience functions `Append`, `Prepend`, `Replace`, `Clear`
+and `All` to accomplish common tasks. Use the full text of your comment including the `//` or `/**/`
+markers. When adding a line comment, a newline is automatically rendered.
+
+```go
+code := `package main
+
+func main() {
+ println("Hello World!")
+}`
+f, err := decorator.Parse(code)
+if err != nil {
+ panic(err)
+}
+
+call := f.Decls[0].(*dst.FuncDecl).Body.List[0].(*dst.ExprStmt).X.(*dst.CallExpr)
+
+call.Decs.Start.Append("// you can add comments at the start...")
+call.Decs.Fun.Append("/* ...in the middle... */")
+call.Decs.End.Append("// or at the end.")
+
+if err := decorator.Print(f); err != nil {
+ panic(err)
+}
+
+//Output:
+//package main
+//
+//func main() {
+// // you can add comments at the start...
+// println /* ...in the middle... */ ("Hello World!") // or at the end.
+//}
+```
+
+### Spacing
+
+The `Before` property marks the node as having a line space (new line or empty line) before the node.
+These spaces are rendered before any decorations attached to the `Start` decoration point. The `After`
+property is similar but rendered after the node (and after any `End` decorations).
+
+```go
+code := `package main
+
+func main() {
+ println(a, b, c)
+}`
+f, err := decorator.Parse(code)
+if err != nil {
+ panic(err)
+}
+
+call := f.Decls[0].(*dst.FuncDecl).Body.List[0].(*dst.ExprStmt).X.(*dst.CallExpr)
+
+call.Decs.Before = dst.EmptyLine
+call.Decs.After = dst.EmptyLine
+
+for _, v := range call.Args {
+ v := v.(*dst.Ident)
+ v.Decs.Before = dst.NewLine
+ v.Decs.After = dst.NewLine
+}
+
+if err := decorator.Print(f); err != nil {
+ panic(err)
+}
+
+//Output:
+//package main
+//
+//func main() {
+//
+// println(
+// a,
+// b,
+// c,
+// )
+//
+//}
+```
+
+### Decorations
+
+The common decoration properties (`Start`, `End`, `Before` and `After`) occur on all nodes, and can be
+accessed with the `Decorations()` method on the `Node` interface:
+
+```go
+code := `package main
+
+func main() {
+ var i int
+ i++
+ println(i)
+}`
+f, err := decorator.Parse(code)
+if err != nil {
+ panic(err)
+}
+
+list := f.Decls[0].(*dst.FuncDecl).Body.List
+
+list[0].Decorations().Before = dst.EmptyLine
+list[0].Decorations().End.Append("// the Decorations method allows access to the common")
+list[1].Decorations().End.Append("// decoration properties (Before, Start, End and After)")
+list[2].Decorations().End.Append("// for all nodes.")
+list[2].Decorations().After = dst.EmptyLine
+
+if err := decorator.Print(f); err != nil {
+ panic(err)
+}
+
+//Output:
+//package main
+//
+//func main() {
+//
+// var i int // the Decorations method allows access to the common
+// i++ // decoration properties (Before, Start, End and After)
+// println(i) // for all nodes.
+//
+//}
+```
+
+#### dstutil.Decorations
+
+While debugging, it is often useful to have a list of all decorations attached to a node. The
+[dstutil](https://github.com/dave/dst/tree/master/dstutil) package provides a helper function `Decorations` which
+returns a list of the attachment points and all decorations for any node:
+
+```go
+code := `package main
+
+// main comment
+// is multi line
+func main() {
+
+ if true {
+
+ // foo
+ println( /* foo inline */ "foo")
+ } else if false {
+ println /* bar inline */ ("bar")
+
+ // bar after
+
+ } else {
+ // empty block
+ }
+}`
+
+f, err := decorator.Parse(code)
+if err != nil {
+ panic(err)
+}
+
+dst.Inspect(f, func(node dst.Node) bool {
+ if node == nil {
+ return false
+ }
+ before, after, points := dstutil.Decorations(node)
+ var info string
+ if before != dst.None {
+ info += fmt.Sprintf("- Before: %s\n", before)
+ }
+ for _, point := range points {
+ if len(point.Decs) == 0 {
+ continue
+ }
+ info += fmt.Sprintf("- %s: [", point.Name)
+ for i, dec := range point.Decs {
+ if i > 0 {
+ info += ", "
+ }
+ info += fmt.Sprintf("%q", dec)
+ }
+ info += "]\n"
+ }
+ if after != dst.None {
+ info += fmt.Sprintf("- After: %s\n", after)
+ }
+ if info != "" {
+ fmt.Printf("%T\n%s\n", node, info)
+ }
+ return true
+})
+
+//Output:
+//*dst.FuncDecl
+//- Before: NewLine
+//- Start: ["// main comment", "// is multi line"]
+//
+//*dst.IfStmt
+//- Before: NewLine
+//- After: NewLine
+//
+//*dst.ExprStmt
+//- Before: NewLine
+//- Start: ["// foo"]
+//- After: NewLine
+//
+//*dst.CallExpr
+//- Lparen: ["/* foo inline */"]
+//
+//*dst.ExprStmt
+//- Before: NewLine
+//- End: ["\n", "\n", "// bar after"]
+//- After: NewLine
+//
+//*dst.CallExpr
+//- Fun: ["/* bar inline */"]
+//
+//*dst.BlockStmt
+//- Lbrace: ["\n", "// empty block"]
+```
+
+### Newlines
+
+The `Before` and `After` properties cover the majority of cases, but occasionally a newline needs to
+be rendered inside a node. Simply add a `\n` decoration to accomplish this.
+
+### Clone
+
+Re-using an existing node elsewhere in the tree will panic when the tree is restored to `ast`. Instead,
+use the `Clone` function to make a deep copy of the node before re-use:
+
+```go
+code := `package main
+
+var i /* a */ int`
+
+f, err := decorator.Parse(code)
+if err != nil {
+ panic(err)
+}
+
+cloned := dst.Clone(f.Decls[0]).(*dst.GenDecl)
+
+cloned.Decs.Before = dst.NewLine
+cloned.Specs[0].(*dst.ValueSpec).Names[0].Name = "j"
+cloned.Specs[0].(*dst.ValueSpec).Names[0].Decs.End.Replace("/* b */")
+
+f.Decls = append(f.Decls, cloned)
+
+if err := decorator.Print(f); err != nil {
+ panic(err)
+}
+
+//Output:
+//package main
+//
+//var i /* a */ int
+//var j /* b */ int
+```
+
+### Apply
+
+The [dstutil](https://github.com/dave/dst/tree/master/dstutil) package is a fork of `golang.org/x/tools/go/ast/astutil`,
+and provides the `Apply` function with similar semantics.
+
+### Imports
+
+The decorator can automatically manage the `import` block, which is a non-trivial task.
+
+Use [NewDecoratorWithImports](https://godoc.org/github.com/dave/dst/decorator#NewDecoratorWithImports)
+and [NewRestorerWithImports](https://godoc.org/github.com/dave/dst/decorator#NewRestorerWithImports)
+to create an import aware decorator / restorer.
+
+During decoration, remote identifiers are normalised - `*ast.SelectorExpr` nodes that represent
+qualified identifiers are replaced with `*dst.Ident` nodes with the `Path` field set to the path of
+the imported package.
+
+When adding a qualified identifier node, there is no need to use `*dst.SelectorExpr` - just add a
+`*dst.Ident` and set `Path` to the imported package path. The restorer will wrap it in a
+`*ast.SelectorExpr` where appropriate when converting back to ast, and also update the import
+block.
+
+To enable import management, the decorator must be able to resolve the imported package for
+selector expressions and identifiers, and the restorer must be able to resolve the name of a
+package given it's path. Several implementations for these resolvers are provided, and the best
+method will depend on the environment. [See below](#resolvers) for more details.
+
+### Load
+
+The [Load](https://godoc.org/github.com/dave/dst/decorator#Load) convenience function uses
+`go/packages` to load packages and decorate all loaded ast files, with import management enabled:
+
+```go
+// Create a simple module in a temporary directory
+dir, err := tempDir(map[string]string{
+ "go.mod": "module root",
+ "main.go": "package main \n\n func main() {}",
+})
+defer os.RemoveAll(dir)
+if err != nil {
+ panic(err)
+}
+
+// Use the Load convenience function that calls go/packages to load the package. All loaded
+// ast files are decorated to dst.
+pkgs, err := decorator.Load(&packages.Config{Dir: dir, Mode: packages.LoadSyntax}, "root")
+if err != nil {
+ panic(err)
+}
+p := pkgs[0]
+f := p.Syntax[0]
+
+// Add a call expression. Note we don't have to use a SelectorExpr - just adding an Ident with
+// the imported package path will do. The restorer will add SelectorExpr where appropriate when
+// converting back to ast. Note the new Path field on *dst.Ident. Set this to the package path
+// of the imported package, and the restorer will automatically add the import to the import
+// block.
+b := f.Decls[0].(*dst.FuncDecl).Body
+b.List = append(b.List, &dst.ExprStmt{
+ X: &dst.CallExpr{
+ Fun: &dst.Ident{Path: "fmt", Name: "Println"},
+ Args: []dst.Expr{
+ &dst.BasicLit{Kind: token.STRING, Value: strconv.Quote("Hello, World!")},
+ },
+ },
+})
+
+// Create a restorer with the import manager enabled, and print the result. As you can see, the
+// import block is automatically managed, and the Println ident is converted to a SelectorExpr:
+r := decorator.NewRestorerWithImports("root", gopackages.New(dir))
+if err := r.Print(p.Syntax[0]); err != nil {
+ panic(err)
+}
+
+//Output:
+//package main
+//
+//import "fmt"
+//
+//func main() { fmt.Println("Hello, World!") }
+```
+
+### Mappings
+
+The decorator exposes `Dst.Nodes` and `Ast.Nodes` which map between `ast.Node` and `dst.Node`. This
+enables systems that refer to `ast` nodes (such as `go/types`) to be used:
+
+```go
+code := `package main
+
+func main() {
+ var i int
+ i++
+ println(i)
+}`
+
+// Parse the code to AST
+fset := token.NewFileSet()
+astFile, err := parser.ParseFile(fset, "", code, parser.ParseComments)
+if err != nil {
+ panic(err)
+}
+
+// Invoke the type checker using AST as input
+typesInfo := types.Info{
+ Defs: make(map[*ast.Ident]types.Object),
+ Uses: make(map[*ast.Ident]types.Object),
+}
+conf := &types.Config{}
+if _, err := conf.Check("", fset, []*ast.File{astFile}, &typesInfo); err != nil {
+ panic(err)
+}
+
+// Create a new decorator, which will track the mapping between ast and dst nodes
+dec := decorator.NewDecorator(fset)
+
+// Decorate the *ast.File to give us a *dst.File
+f, err := dec.DecorateFile(astFile)
+if err != nil {
+ panic(err)
+}
+
+// Find the *dst.Ident for the definition of "i"
+dstDef := f.Decls[0].(*dst.FuncDecl).Body.List[0].(*dst.DeclStmt).Decl.(*dst.GenDecl).Specs[0].(*dst.ValueSpec).Names[0]
+
+// Find the *ast.Ident using the Ast.Nodes mapping
+astDef := dec.Ast.Nodes[dstDef].(*ast.Ident)
+
+// Find the types.Object corresponding to "i"
+obj := typesInfo.Defs[astDef]
+
+// Find all the uses of that object
+var astUses []*ast.Ident
+for id, ob := range typesInfo.Uses {
+ if ob != obj {
+ continue
+ }
+ astUses = append(astUses, id)
+}
+
+// Find each *dst.Ident in the Dst.Nodes mapping
+var dstUses []*dst.Ident
+for _, id := range astUses {
+ dstUses = append(dstUses, dec.Dst.Nodes[id].(*dst.Ident))
+}
+
+// Change the name of the original definition and all uses
+dstDef.Name = "foo"
+for _, id := range dstUses {
+ id.Name = "foo"
+}
+
+// Print the DST
+if err := decorator.Print(f); err != nil {
+ panic(err)
+}
+
+//Output:
+//package main
+//
+//func main() {
+// var foo int
+// foo++
+// println(foo)
+//}
+```
+
+## Resolvers
+
+There are two separate interfaces defined by the [resolver package](https://github.com/dave/dst/tree/master/decorator/resolver)
+which allow the decorator and restorer to automatically manage the imports block.
+
+The decorator uses a `DecoratorResolver` which resolves the package path of any `*ast.Ident`. This is
+complicated by dot-import syntax ([see below](#dot-imports)).
+
+The restorer uses a `RestorerResolver` which resolves the name of any package given the path. This
+is complicated by vendoring and Go modules.
+
+When `Resolver` is set on `Decorator` or `Restorer`, the `Path` property must be set to the local
+package path.
+
+Several implementations of both interfaces that are suitable for different environments are
+provided:
+
+### DecoratorResolver
+
+#### gotypes
+
+The [gotypes](https://github.com/dave/dst/blob/master/decorator/resolver/gotypes/resolver.go)
+package provides a `DecoratorResolver` with full dot-import compatibility. However it requires full
+export data for all imported packages, so the `Uses` map from `go/types.Info` is required. There
+are several methods of generating `go/types.Info`. Using `golang.org/x/tools/go/packages.Load` is
+recommended for full Go modules compatibility. See the [decorator.Load](https://godoc.org/github.com/dave/dst/decorator#Load)
+convenience function to automate this.
+
+#### goast
+
+The [goast](https://github.com/dave/dst/blob/master/decorator/resolver/goast/resolver.go) package
+provides a simplified `DecoratorResolver` that only needs to scan a single ast file. This is unable
+to resolve identifiers from dot-imported packages, so will panic if a dot-import is encountered in
+the import block. It uses the provided `RestorerResolver` to resolve the names of all imported
+packages. If no `RestorerResolver` is provided, the [guess](#guess-and-simple) implementation is used.
+
+### RestorerResolver
+
+#### gopackages
+
+The [gopackages](https://github.com/dave/dst/blob/master/decorator/resolver/gopackages/resolver.go)
+package provides a `RestorerResolver` with full compatibility with Go modules. It uses
+`golang.org/x/tools/go/packages` to load the package data. This may be very slow, and uses the `go`
+command line tool to query package data, so may not be compatible with some environments.
+
+#### gobuild
+
+The [gobuild](https://github.com/dave/dst/blob/master/decorator/resolver/gobuild/resolver.go)
+package provides an alternative `RestorerResolver` that uses the legacy `go/build` system to load
+the imported package data. This may be needed in some circumstances and provides better performance
+than `go/packages`. However, this is not Go modules aware.
+
+#### guess and simple
+
+The [guess](https://github.com/dave/dst/blob/master/decorator/resolver/guess/resolver.go) and
+[simple](https://github.com/dave/dst/blob/master/decorator/resolver/simple/resolver.go) packages
+provide simple `RestorerResolver` implementations that may be useful in certain circumstances, or
+where performance is critical. `simple` resolves paths only if they occur in a provided map.
+`guess` guesses the package name based on the last part of the path.
+
+### Example
+
+Here's an example of supplying resolvers for the decorator and restorer:
+
+```go
+code := `package main
+
+ import "fmt"
+
+ func main() {
+ fmt.Println("a")
+ }`
+
+dec := decorator.NewDecoratorWithImports(token.NewFileSet(), "main", goast.New())
+
+f, err := dec.Parse(code)
+if err != nil {
+ panic(err)
+}
+
+f.Decls[1].(*dst.FuncDecl).Body.List[0].(*dst.ExprStmt).X.(*dst.CallExpr).Args = []dst.Expr{
+ &dst.CallExpr{
+ Fun: &dst.Ident{Name: "A", Path: "foo.bar/baz"},
+ },
+}
+
+res := decorator.NewRestorerWithImports("main", guess.New())
+if err := res.Print(f); err != nil {
+ panic(err)
+}
+
+//Output:
+//package main
+//
+//import (
+// "fmt"
+//
+// "foo.bar/baz"
+//)
+//
+//func main() {
+// fmt.Println(baz.A())
+//}
+```
+
+### Alias
+
+To control the alias of imports, use a `FileRestorer`:
+
+```go
+code := `package main
+
+ import "fmt"
+
+ func main() {
+ fmt.Println("a")
+ }`
+
+dec := decorator.NewDecoratorWithImports(token.NewFileSet(), "main", goast.New())
+
+f, err := dec.Parse(code)
+if err != nil {
+ panic(err)
+}
+
+res := decorator.NewRestorerWithImports("main", guess.New())
+
+fr := res.FileRestorer()
+fr.Alias["fmt"] = "fmt1"
+
+if err := fr.Print(f); err != nil {
+ panic(err)
+}
+
+//Output:
+//package main
+//
+//import fmt1 "fmt"
+//
+//func main() {
+// fmt1.Println("a")
+//}
+```
+
+### Details
+
+For more information on exactly how the imports block is managed, read through the [test
+cases](https://github.com/dave/dst/blob/master/decorator/restorer_resolver_test.go).
+
+### Dot-imports
+
+Consider this file...
+
+```go
+package main
+
+import (
+ . "a"
+)
+
+func main() {
+ B()
+ C()
+}
+```
+
+`B` and `C` could be local identifiers from a different file in this package,
+or from the imported package `a`. If only one is from `a` and it is removed, we should remove the
+import when we restore to `ast`. Thus the resolver needs to be able to resolve the package using
+the full info from `go/types`.
+
+## Status
+
+This package is well tested and used in many projects. The API should be considered stable going forward.
+
+## Chat?
+
+Feel free to create an [issue](https://github.com/dave/dst/issues) or chat in the
+[#dst](https://gophers.slack.com/messages/CCVL24MTQ) Gophers Slack channel.
+
+## Contributing
+
+For further developing or contributing to `dst`, check out [these notes](https://github.com/dave/dst/blob/master/contributing.md).
+
+## Special thanks
+
+Thanks very much to [hawkinsw](https://github.com/hawkinsw) for taking on the task of adding generics compatibility to `dst`.
\ No newline at end of file
diff --git a/vendor/github.com/dave/dst/README.md.tpl b/vendor/github.com/dave/dst/README.md.tpl
new file mode 100644
index 0000000000..36bc572caa
--- /dev/null
+++ b/vendor/github.com/dave/dst/README.md.tpl
@@ -0,0 +1,239 @@
+[](https://github.com/dave/dst/actions/workflows/ci.yml)
+[](https://godoc.org/github.com/dave/dst/decorator)
+[](https://codecov.io/gh/dave/dst)
+
+[](https://sourcegraph.com/github.com/dave/dst?badge)
+
+# Decorated Syntax Tree
+
+The `dst` package enables manipulation of a Go syntax tree with high fidelity. Decorations (e.g.
+comments and line spacing) remain attached to the correct nodes as the tree is modified.
+
+## Where does `go/ast` break?
+
+The `go/ast` package wasn't created with source manipulation as an intended use-case. Comments are
+stored by their byte offset instead of attached to nodes, so re-arranging nodes breaks the output.
+See [this Go issue](https://github.com/golang/go/issues/20744) for more information.
+
+Consider this example where we want to reverse the order of the two statements. As you can see the
+comments don't remain attached to the correct nodes:
+
+{{ "Example_astBroken" | example }}
+
+Here's the same example using `dst`:
+
+{{ "Example_dstFixed" | example }}
+
+## Usage
+
+Parsing a source file to `dst` and printing the results after modification can be accomplished with
+several `Parse` and `Print` convenience functions in the [decorator](https://godoc.org/github.com/dave/dst/decorator)
+package.
+
+For more fine-grained control you can use [Decorator](https://godoc.org/github.com/dave/dst/decorator#Decorator)
+to convert from `ast` to `dst`, and [Restorer](https://godoc.org/github.com/dave/dst/decorator#Restorer)
+to convert back again.
+
+### Comments
+
+Comments are added at decoration attachment points. [See here](https://github.com/dave/dst/blob/master/decorations-types-generated.go)
+for a full list of these points, along with demonstration code of where they are rendered in the
+output.
+
+The decoration attachment points have convenience functions `Append`, `Prepend`, `Replace`, `Clear`
+and `All` to accomplish common tasks. Use the full text of your comment including the `//` or `/**/`
+markers. When adding a line comment, a newline is automatically rendered.
+
+{{ "ExampleComment" | example }}
+
+### Spacing
+
+The `Before` property marks the node as having a line space (new line or empty line) before the node.
+These spaces are rendered before any decorations attached to the `Start` decoration point. The `After`
+property is similar but rendered after the node (and after any `End` decorations).
+
+{{ "Example_space" | example }}
+
+### Decorations
+
+The common decoration properties (`Start`, `End`, `Before` and `After`) occur on all nodes, and can be
+accessed with the `Decorations()` method on the `Node` interface:
+
+{{ "Example_decorated" | example }}
+
+#### dstutil.Decorations
+
+While debugging, it is often useful to have a list of all decorations attached to a node. The
+[dstutil](https://github.com/dave/dst/tree/master/dstutil) package provides a helper function `Decorations` which
+returns a list of the attachment points and all decorations for any node:
+
+{{ "Example_decorationPoints" | example }}
+
+### Newlines
+
+The `Before` and `After` properties cover the majority of cases, but occasionally a newline needs to
+be rendered inside a node. Simply add a `\n` decoration to accomplish this.
+
+### Clone
+
+Re-using an existing node elsewhere in the tree will panic when the tree is restored to `ast`. Instead,
+use the `Clone` function to make a deep copy of the node before re-use:
+
+{{ "ExampleClone" | example }}
+
+### Apply
+
+The [dstutil](https://github.com/dave/dst/tree/master/dstutil) package is a fork of `golang.org/x/tools/go/ast/astutil`,
+and provides the `Apply` function with similar semantics.
+
+### Imports
+
+The decorator can automatically manage the `import` block, which is a non-trivial task.
+
+Use [NewDecoratorWithImports](https://godoc.org/github.com/dave/dst/decorator#NewDecoratorWithImports)
+and [NewRestorerWithImports](https://godoc.org/github.com/dave/dst/decorator#NewRestorerWithImports)
+to create an import aware decorator / restorer.
+
+During decoration, remote identifiers are normalised - `*ast.SelectorExpr` nodes that represent
+qualified identifiers are replaced with `*dst.Ident` nodes with the `Path` field set to the path of
+the imported package.
+
+When adding a qualified identifier node, there is no need to use `*dst.SelectorExpr` - just add a
+`*dst.Ident` and set `Path` to the imported package path. The restorer will wrap it in a
+`*ast.SelectorExpr` where appropriate when converting back to ast, and also update the import
+block.
+
+To enable import management, the decorator must be able to resolve the imported package for
+selector expressions and identifiers, and the restorer must be able to resolve the name of a
+package given it's path. Several implementations for these resolvers are provided, and the best
+method will depend on the environment. [See below](#resolvers) for more details.
+
+### Load
+
+The [Load](https://godoc.org/github.com/dave/dst/decorator#Load) convenience function uses
+`go/packages` to load packages and decorate all loaded ast files, with import management enabled:
+
+{{ "Example_imports" | example }}
+
+### Mappings
+
+The decorator exposes `Dst.Nodes` and `Ast.Nodes` which map between `ast.Node` and `dst.Node`. This
+enables systems that refer to `ast` nodes (such as `go/types`) to be used:
+
+{{ "Example_types" | example }}
+
+## Resolvers
+
+There are two separate interfaces defined by the [resolver package](https://github.com/dave/dst/tree/master/decorator/resolver)
+which allow the decorator and restorer to automatically manage the imports block.
+
+The decorator uses a `DecoratorResolver` which resolves the package path of any `*ast.Ident`. This is
+complicated by dot-import syntax ([see below](#dot-imports)).
+
+The restorer uses a `RestorerResolver` which resolves the name of any package given the path. This
+is complicated by vendoring and Go modules.
+
+When `Resolver` is set on `Decorator` or `Restorer`, the `Path` property must be set to the local
+package path.
+
+Several implementations of both interfaces that are suitable for different environments are
+provided:
+
+### DecoratorResolver
+
+#### gotypes
+
+The [gotypes](https://github.com/dave/dst/blob/master/decorator/resolver/gotypes/resolver.go)
+package provides a `DecoratorResolver` with full dot-import compatibility. However it requires full
+export data for all imported packages, so the `Uses` map from `go/types.Info` is required. There
+are several methods of generating `go/types.Info`. Using `golang.org/x/tools/go/packages.Load` is
+recommended for full Go modules compatibility. See the [decorator.Load](https://godoc.org/github.com/dave/dst/decorator#Load)
+convenience function to automate this.
+
+#### goast
+
+The [goast](https://github.com/dave/dst/blob/master/decorator/resolver/goast/resolver.go) package
+provides a simplified `DecoratorResolver` that only needs to scan a single ast file. This is unable
+to resolve identifiers from dot-imported packages, so will panic if a dot-import is encountered in
+the import block. It uses the provided `RestorerResolver` to resolve the names of all imported
+packages. If no `RestorerResolver` is provided, the [guess](#guess-and-simple) implementation is used.
+
+### RestorerResolver
+
+#### gopackages
+
+The [gopackages](https://github.com/dave/dst/blob/master/decorator/resolver/gopackages/resolver.go)
+package provides a `RestorerResolver` with full compatibility with Go modules. It uses
+`golang.org/x/tools/go/packages` to load the package data. This may be very slow, and uses the `go`
+command line tool to query package data, so may not be compatible with some environments.
+
+#### gobuild
+
+The [gobuild](https://github.com/dave/dst/blob/master/decorator/resolver/gobuild/resolver.go)
+package provides an alternative `RestorerResolver` that uses the legacy `go/build` system to load
+the imported package data. This may be needed in some circumstances and provides better performance
+than `go/packages`. However, this is not Go modules aware.
+
+#### guess and simple
+
+The [guess](https://github.com/dave/dst/blob/master/decorator/resolver/guess/resolver.go) and
+[simple](https://github.com/dave/dst/blob/master/decorator/resolver/simple/resolver.go) packages
+provide simple `RestorerResolver` implementations that may be useful in certain circumstances, or
+where performance is critical. `simple` resolves paths only if they occur in a provided map.
+`guess` guesses the package name based on the last part of the path.
+
+### Example
+
+Here's an example of supplying resolvers for the decorator and restorer:
+
+{{ "Example_manualImports" | example }}
+
+### Alias
+
+To control the alias of imports, use a `FileRestorer`:
+
+{{ "ExampleAlias" | example }}
+
+### Details
+
+For more information on exactly how the imports block is managed, read through the [test
+cases](https://github.com/dave/dst/blob/master/decorator/restorer_resolver_test.go).
+
+### Dot-imports
+
+Consider this file...
+
+```go
+package main
+
+import (
+ . "a"
+)
+
+func main() {
+ B()
+ C()
+}
+```
+
+`B` and `C` could be local identifiers from a different file in this package,
+or from the imported package `a`. If only one is from `a` and it is removed, we should remove the
+import when we restore to `ast`. Thus the resolver needs to be able to resolve the package using
+the full info from `go/types`.
+
+## Status
+
+This package is well tested and used in many projects. The API should be considered stable going forward.
+
+## Chat?
+
+Feel free to create an [issue](https://github.com/dave/dst/issues) or chat in the
+[#dst](https://gophers.slack.com/messages/CCVL24MTQ) Gophers Slack channel.
+
+## Contributing
+
+For further developing or contributing to `dst`, check out [these notes](https://github.com/dave/dst/blob/master/contributing.md).
+
+## Special thanks
+
+Thanks very much to [hawkinsw](https://github.com/hawkinsw) for taking on the task of adding generics compatibility to `dst`.
\ No newline at end of file
diff --git a/vendor/github.com/dave/dst/clone-generated.go b/vendor/github.com/dave/dst/clone-generated.go
new file mode 100644
index 0000000000..993eeb1e73
--- /dev/null
+++ b/vendor/github.com/dave/dst/clone-generated.go
@@ -0,0 +1,1631 @@
+package dst
+
+import "fmt"
+
+// Clone returns a deep copy of the node, ready to be re-used elsewhere in the tree.
+func Clone(n Node) Node {
+ switch n := n.(type) {
+ case *ArrayType:
+ out := &ArrayType{}
+
+ out.Decs.Before = n.Decs.Before
+
+ // Decoration: Start
+ out.Decs.Start = append(out.Decs.Start, n.Decs.Start...)
+
+ // Decoration: Lbrack
+ out.Decs.Lbrack = append(out.Decs.Lbrack, n.Decs.Lbrack...)
+
+ // Node: Len
+ if n.Len != nil {
+ out.Len = Clone(n.Len).(Expr)
+ }
+
+ // Decoration: Len
+ out.Decs.Len = append(out.Decs.Len, n.Decs.Len...)
+
+ // Node: Elt
+ if n.Elt != nil {
+ out.Elt = Clone(n.Elt).(Expr)
+ }
+
+ // Decoration: End
+ out.Decs.End = append(out.Decs.End, n.Decs.End...)
+
+ out.Decs.After = n.Decs.After
+
+ return out
+ case *AssignStmt:
+ out := &AssignStmt{}
+
+ out.Decs.Before = n.Decs.Before
+
+ // Decoration: Start
+ out.Decs.Start = append(out.Decs.Start, n.Decs.Start...)
+
+ // List: Lhs
+ for _, v := range n.Lhs {
+ out.Lhs = append(out.Lhs, Clone(v).(Expr))
+ }
+
+ // Token: Tok
+ out.Tok = n.Tok
+
+ // Decoration: Tok
+ out.Decs.Tok = append(out.Decs.Tok, n.Decs.Tok...)
+
+ // List: Rhs
+ for _, v := range n.Rhs {
+ out.Rhs = append(out.Rhs, Clone(v).(Expr))
+ }
+
+ // Decoration: End
+ out.Decs.End = append(out.Decs.End, n.Decs.End...)
+
+ out.Decs.After = n.Decs.After
+
+ return out
+ case *BadDecl:
+ out := &BadDecl{}
+
+ out.Decs.Before = n.Decs.Before
+
+ // Decoration: Start
+ out.Decs.Start = append(out.Decs.Start, n.Decs.Start...)
+
+ // Bad
+ out.Length = n.Length
+
+ // Decoration: End
+ out.Decs.End = append(out.Decs.End, n.Decs.End...)
+
+ out.Decs.After = n.Decs.After
+
+ return out
+ case *BadExpr:
+ out := &BadExpr{}
+
+ out.Decs.Before = n.Decs.Before
+
+ // Decoration: Start
+ out.Decs.Start = append(out.Decs.Start, n.Decs.Start...)
+
+ // Bad
+ out.Length = n.Length
+
+ // Decoration: End
+ out.Decs.End = append(out.Decs.End, n.Decs.End...)
+
+ out.Decs.After = n.Decs.After
+
+ return out
+ case *BadStmt:
+ out := &BadStmt{}
+
+ out.Decs.Before = n.Decs.Before
+
+ // Decoration: Start
+ out.Decs.Start = append(out.Decs.Start, n.Decs.Start...)
+
+ // Bad
+ out.Length = n.Length
+
+ // Decoration: End
+ out.Decs.End = append(out.Decs.End, n.Decs.End...)
+
+ out.Decs.After = n.Decs.After
+
+ return out
+ case *BasicLit:
+ out := &BasicLit{}
+
+ out.Decs.Before = n.Decs.Before
+
+ // Decoration: Start
+ out.Decs.Start = append(out.Decs.Start, n.Decs.Start...)
+
+ // String: Value
+ out.Value = n.Value
+
+ // Decoration: End
+ out.Decs.End = append(out.Decs.End, n.Decs.End...)
+
+ // Value: Kind
+ out.Kind = n.Kind
+
+ out.Decs.After = n.Decs.After
+
+ return out
+ case *BinaryExpr:
+ out := &BinaryExpr{}
+
+ out.Decs.Before = n.Decs.Before
+
+ // Decoration: Start
+ out.Decs.Start = append(out.Decs.Start, n.Decs.Start...)
+
+ // Node: X
+ if n.X != nil {
+ out.X = Clone(n.X).(Expr)
+ }
+
+ // Decoration: X
+ out.Decs.X = append(out.Decs.X, n.Decs.X...)
+
+ // Token: Op
+ out.Op = n.Op
+
+ // Decoration: Op
+ out.Decs.Op = append(out.Decs.Op, n.Decs.Op...)
+
+ // Node: Y
+ if n.Y != nil {
+ out.Y = Clone(n.Y).(Expr)
+ }
+
+ // Decoration: End
+ out.Decs.End = append(out.Decs.End, n.Decs.End...)
+
+ out.Decs.After = n.Decs.After
+
+ return out
+ case *BlockStmt:
+ out := &BlockStmt{}
+
+ out.Decs.Before = n.Decs.Before
+
+ // Decoration: Start
+ out.Decs.Start = append(out.Decs.Start, n.Decs.Start...)
+
+ // Decoration: Lbrace
+ out.Decs.Lbrace = append(out.Decs.Lbrace, n.Decs.Lbrace...)
+
+ // List: List
+ for _, v := range n.List {
+ out.List = append(out.List, Clone(v).(Stmt))
+ }
+
+ // Token: Rbrace
+ out.RbraceHasNoPos = n.RbraceHasNoPos
+
+ // Decoration: End
+ out.Decs.End = append(out.Decs.End, n.Decs.End...)
+
+ out.Decs.After = n.Decs.After
+
+ return out
+ case *BranchStmt:
+ out := &BranchStmt{}
+
+ out.Decs.Before = n.Decs.Before
+
+ // Decoration: Start
+ out.Decs.Start = append(out.Decs.Start, n.Decs.Start...)
+
+ // Token: Tok
+ out.Tok = n.Tok
+
+ // Decoration: Tok
+ out.Decs.Tok = append(out.Decs.Tok, n.Decs.Tok...)
+
+ // Node: Label
+ if n.Label != nil {
+ out.Label = Clone(n.Label).(*Ident)
+ }
+
+ // Decoration: End
+ out.Decs.End = append(out.Decs.End, n.Decs.End...)
+
+ out.Decs.After = n.Decs.After
+
+ return out
+ case *CallExpr:
+ out := &CallExpr{}
+
+ out.Decs.Before = n.Decs.Before
+
+ // Decoration: Start
+ out.Decs.Start = append(out.Decs.Start, n.Decs.Start...)
+
+ // Node: Fun
+ if n.Fun != nil {
+ out.Fun = Clone(n.Fun).(Expr)
+ }
+
+ // Decoration: Fun
+ out.Decs.Fun = append(out.Decs.Fun, n.Decs.Fun...)
+
+ // Decoration: Lparen
+ out.Decs.Lparen = append(out.Decs.Lparen, n.Decs.Lparen...)
+
+ // List: Args
+ for _, v := range n.Args {
+ out.Args = append(out.Args, Clone(v).(Expr))
+ }
+
+ // Token: Ellipsis
+ out.Ellipsis = n.Ellipsis
+
+ // Decoration: Ellipsis
+ out.Decs.Ellipsis = append(out.Decs.Ellipsis, n.Decs.Ellipsis...)
+
+ // Decoration: End
+ out.Decs.End = append(out.Decs.End, n.Decs.End...)
+
+ out.Decs.After = n.Decs.After
+
+ return out
+ case *CaseClause:
+ out := &CaseClause{}
+
+ out.Decs.Before = n.Decs.Before
+
+ // Decoration: Start
+ out.Decs.Start = append(out.Decs.Start, n.Decs.Start...)
+
+ // Decoration: Case
+ out.Decs.Case = append(out.Decs.Case, n.Decs.Case...)
+
+ // List: List
+ for _, v := range n.List {
+ out.List = append(out.List, Clone(v).(Expr))
+ }
+
+ // Decoration: Colon
+ out.Decs.Colon = append(out.Decs.Colon, n.Decs.Colon...)
+
+ // List: Body
+ for _, v := range n.Body {
+ out.Body = append(out.Body, Clone(v).(Stmt))
+ }
+
+ // Decoration: End
+ out.Decs.End = append(out.Decs.End, n.Decs.End...)
+
+ out.Decs.After = n.Decs.After
+
+ return out
+ case *ChanType:
+ out := &ChanType{}
+
+ out.Decs.Before = n.Decs.Before
+
+ // Decoration: Start
+ out.Decs.Start = append(out.Decs.Start, n.Decs.Start...)
+
+ // Decoration: Begin
+ out.Decs.Begin = append(out.Decs.Begin, n.Decs.Begin...)
+
+ // Decoration: Arrow
+ out.Decs.Arrow = append(out.Decs.Arrow, n.Decs.Arrow...)
+
+ // Node: Value
+ if n.Value != nil {
+ out.Value = Clone(n.Value).(Expr)
+ }
+
+ // Decoration: End
+ out.Decs.End = append(out.Decs.End, n.Decs.End...)
+
+ // Value: Dir
+ out.Dir = n.Dir
+
+ out.Decs.After = n.Decs.After
+
+ return out
+ case *CommClause:
+ out := &CommClause{}
+
+ out.Decs.Before = n.Decs.Before
+
+ // Decoration: Start
+ out.Decs.Start = append(out.Decs.Start, n.Decs.Start...)
+
+ // Decoration: Case
+ out.Decs.Case = append(out.Decs.Case, n.Decs.Case...)
+
+ // Node: Comm
+ if n.Comm != nil {
+ out.Comm = Clone(n.Comm).(Stmt)
+ }
+
+ // Decoration: Comm
+ out.Decs.Comm = append(out.Decs.Comm, n.Decs.Comm...)
+
+ // Decoration: Colon
+ out.Decs.Colon = append(out.Decs.Colon, n.Decs.Colon...)
+
+ // List: Body
+ for _, v := range n.Body {
+ out.Body = append(out.Body, Clone(v).(Stmt))
+ }
+
+ // Decoration: End
+ out.Decs.End = append(out.Decs.End, n.Decs.End...)
+
+ out.Decs.After = n.Decs.After
+
+ return out
+ case *CompositeLit:
+ out := &CompositeLit{}
+
+ out.Decs.Before = n.Decs.Before
+
+ // Decoration: Start
+ out.Decs.Start = append(out.Decs.Start, n.Decs.Start...)
+
+ // Node: Type
+ if n.Type != nil {
+ out.Type = Clone(n.Type).(Expr)
+ }
+
+ // Decoration: Type
+ out.Decs.Type = append(out.Decs.Type, n.Decs.Type...)
+
+ // Decoration: Lbrace
+ out.Decs.Lbrace = append(out.Decs.Lbrace, n.Decs.Lbrace...)
+
+ // List: Elts
+ for _, v := range n.Elts {
+ out.Elts = append(out.Elts, Clone(v).(Expr))
+ }
+
+ // Decoration: End
+ out.Decs.End = append(out.Decs.End, n.Decs.End...)
+
+ // Value: Incomplete
+ out.Incomplete = n.Incomplete
+
+ out.Decs.After = n.Decs.After
+
+ return out
+ case *DeclStmt:
+ out := &DeclStmt{}
+
+ out.Decs.Before = n.Decs.Before
+
+ // Decoration: Start
+ out.Decs.Start = append(out.Decs.Start, n.Decs.Start...)
+
+ // Node: Decl
+ if n.Decl != nil {
+ out.Decl = Clone(n.Decl).(Decl)
+ }
+
+ // Decoration: End
+ out.Decs.End = append(out.Decs.End, n.Decs.End...)
+
+ out.Decs.After = n.Decs.After
+
+ return out
+ case *DeferStmt:
+ out := &DeferStmt{}
+
+ out.Decs.Before = n.Decs.Before
+
+ // Decoration: Start
+ out.Decs.Start = append(out.Decs.Start, n.Decs.Start...)
+
+ // Decoration: Defer
+ out.Decs.Defer = append(out.Decs.Defer, n.Decs.Defer...)
+
+ // Node: Call
+ if n.Call != nil {
+ out.Call = Clone(n.Call).(*CallExpr)
+ }
+
+ // Decoration: End
+ out.Decs.End = append(out.Decs.End, n.Decs.End...)
+
+ out.Decs.After = n.Decs.After
+
+ return out
+ case *Ellipsis:
+ out := &Ellipsis{}
+
+ out.Decs.Before = n.Decs.Before
+
+ // Decoration: Start
+ out.Decs.Start = append(out.Decs.Start, n.Decs.Start...)
+
+ // Decoration: Ellipsis
+ out.Decs.Ellipsis = append(out.Decs.Ellipsis, n.Decs.Ellipsis...)
+
+ // Node: Elt
+ if n.Elt != nil {
+ out.Elt = Clone(n.Elt).(Expr)
+ }
+
+ // Decoration: End
+ out.Decs.End = append(out.Decs.End, n.Decs.End...)
+
+ out.Decs.After = n.Decs.After
+
+ return out
+ case *EmptyStmt:
+ out := &EmptyStmt{}
+
+ out.Decs.Before = n.Decs.Before
+
+ // Decoration: Start
+ out.Decs.Start = append(out.Decs.Start, n.Decs.Start...)
+
+ // Decoration: End
+ out.Decs.End = append(out.Decs.End, n.Decs.End...)
+
+ // Value: Implicit
+ out.Implicit = n.Implicit
+
+ out.Decs.After = n.Decs.After
+
+ return out
+ case *ExprStmt:
+ out := &ExprStmt{}
+
+ out.Decs.Before = n.Decs.Before
+
+ // Decoration: Start
+ out.Decs.Start = append(out.Decs.Start, n.Decs.Start...)
+
+ // Node: X
+ if n.X != nil {
+ out.X = Clone(n.X).(Expr)
+ }
+
+ // Decoration: End
+ out.Decs.End = append(out.Decs.End, n.Decs.End...)
+
+ out.Decs.After = n.Decs.After
+
+ return out
+ case *Field:
+ out := &Field{}
+
+ out.Decs.Before = n.Decs.Before
+
+ // Decoration: Start
+ out.Decs.Start = append(out.Decs.Start, n.Decs.Start...)
+
+ // List: Names
+ for _, v := range n.Names {
+ out.Names = append(out.Names, Clone(v).(*Ident))
+ }
+
+ // Node: Type
+ if n.Type != nil {
+ out.Type = Clone(n.Type).(Expr)
+ }
+
+ // Decoration: Type
+ out.Decs.Type = append(out.Decs.Type, n.Decs.Type...)
+
+ // Node: Tag
+ if n.Tag != nil {
+ out.Tag = Clone(n.Tag).(*BasicLit)
+ }
+
+ // Decoration: End
+ out.Decs.End = append(out.Decs.End, n.Decs.End...)
+
+ out.Decs.After = n.Decs.After
+
+ return out
+ case *FieldList:
+ out := &FieldList{}
+
+ out.Decs.Before = n.Decs.Before
+
+ // Decoration: Start
+ out.Decs.Start = append(out.Decs.Start, n.Decs.Start...)
+
+ // Token: Opening
+ out.Opening = n.Opening
+
+ // Decoration: Opening
+ out.Decs.Opening = append(out.Decs.Opening, n.Decs.Opening...)
+
+ // List: List
+ for _, v := range n.List {
+ out.List = append(out.List, Clone(v).(*Field))
+ }
+
+ // Token: Closing
+ out.Closing = n.Closing
+
+ // Decoration: End
+ out.Decs.End = append(out.Decs.End, n.Decs.End...)
+
+ out.Decs.After = n.Decs.After
+
+ return out
+ case *File:
+ out := &File{}
+
+ out.Decs.Before = n.Decs.Before
+
+ // Decoration: Start
+ out.Decs.Start = append(out.Decs.Start, n.Decs.Start...)
+
+ // Decoration: Package
+ out.Decs.Package = append(out.Decs.Package, n.Decs.Package...)
+
+ // Node: Name
+ if n.Name != nil {
+ out.Name = Clone(n.Name).(*Ident)
+ }
+
+ // Decoration: Name
+ out.Decs.Name = append(out.Decs.Name, n.Decs.Name...)
+
+ // List: Decls
+ for _, v := range n.Decls {
+ out.Decls = append(out.Decls, Clone(v).(Decl))
+ }
+
+ // Decoration: End
+ out.Decs.End = append(out.Decs.End, n.Decs.End...)
+
+ // Scope: Scope
+ out.Scope = CloneScope(n.Scope)
+
+ // List: Imports
+ for _, v := range n.Imports {
+ out.Imports = append(out.Imports, Clone(v).(*ImportSpec))
+ }
+
+ // Value: GoVersion
+ out.GoVersion = n.GoVersion
+
+ out.Decs.After = n.Decs.After
+
+ return out
+ case *ForStmt:
+ out := &ForStmt{}
+
+ out.Decs.Before = n.Decs.Before
+
+ // Decoration: Start
+ out.Decs.Start = append(out.Decs.Start, n.Decs.Start...)
+
+ // Decoration: For
+ out.Decs.For = append(out.Decs.For, n.Decs.For...)
+
+ // Node: Init
+ if n.Init != nil {
+ out.Init = Clone(n.Init).(Stmt)
+ }
+
+ // Decoration: Init
+ out.Decs.Init = append(out.Decs.Init, n.Decs.Init...)
+
+ // Node: Cond
+ if n.Cond != nil {
+ out.Cond = Clone(n.Cond).(Expr)
+ }
+
+ // Decoration: Cond
+ out.Decs.Cond = append(out.Decs.Cond, n.Decs.Cond...)
+
+ // Node: Post
+ if n.Post != nil {
+ out.Post = Clone(n.Post).(Stmt)
+ }
+
+ // Decoration: Post
+ out.Decs.Post = append(out.Decs.Post, n.Decs.Post...)
+
+ // Node: Body
+ if n.Body != nil {
+ out.Body = Clone(n.Body).(*BlockStmt)
+ }
+
+ // Decoration: End
+ out.Decs.End = append(out.Decs.End, n.Decs.End...)
+
+ out.Decs.After = n.Decs.After
+
+ return out
+ case *FuncDecl:
+ out := &FuncDecl{}
+
+ out.Decs.Before = n.Decs.Before
+
+ // Init: Type
+ out.Type = &FuncType{}
+
+ // Decoration: Start
+ out.Decs.Start = append(out.Decs.Start, n.Decs.Start...)
+
+ // Token: Func
+ out.Type.Func = n.Type.Func
+
+ // Decoration: Func
+ out.Decs.Func = append(out.Decs.Func, n.Decs.Func...)
+
+ // Node: Recv
+ if n.Recv != nil {
+ out.Recv = Clone(n.Recv).(*FieldList)
+ }
+
+ // Decoration: Recv
+ out.Decs.Recv = append(out.Decs.Recv, n.Decs.Recv...)
+
+ // Node: Name
+ if n.Name != nil {
+ out.Name = Clone(n.Name).(*Ident)
+ }
+
+ // Decoration: Name
+ out.Decs.Name = append(out.Decs.Name, n.Decs.Name...)
+
+ // Node: TypeParams
+ if n.Type.TypeParams != nil {
+ out.Type.TypeParams = Clone(n.Type.TypeParams).(*FieldList)
+ }
+
+ // Decoration: TypeParams
+ out.Decs.TypeParams = append(out.Decs.TypeParams, n.Decs.TypeParams...)
+
+ // Node: Params
+ if n.Type.Params != nil {
+ out.Type.Params = Clone(n.Type.Params).(*FieldList)
+ }
+
+ // Decoration: Params
+ out.Decs.Params = append(out.Decs.Params, n.Decs.Params...)
+
+ // Node: Results
+ if n.Type.Results != nil {
+ out.Type.Results = Clone(n.Type.Results).(*FieldList)
+ }
+
+ // Decoration: Results
+ out.Decs.Results = append(out.Decs.Results, n.Decs.Results...)
+
+ // Node: Body
+ if n.Body != nil {
+ out.Body = Clone(n.Body).(*BlockStmt)
+ }
+
+ // Decoration: End
+ out.Decs.End = append(out.Decs.End, n.Decs.End...)
+
+ out.Decs.After = n.Decs.After
+
+ return out
+ case *FuncLit:
+ out := &FuncLit{}
+
+ out.Decs.Before = n.Decs.Before
+
+ // Decoration: Start
+ out.Decs.Start = append(out.Decs.Start, n.Decs.Start...)
+
+ // Node: Type
+ if n.Type != nil {
+ out.Type = Clone(n.Type).(*FuncType)
+ }
+
+ // Decoration: Type
+ out.Decs.Type = append(out.Decs.Type, n.Decs.Type...)
+
+ // Node: Body
+ if n.Body != nil {
+ out.Body = Clone(n.Body).(*BlockStmt)
+ }
+
+ // Decoration: End
+ out.Decs.End = append(out.Decs.End, n.Decs.End...)
+
+ out.Decs.After = n.Decs.After
+
+ return out
+ case *FuncType:
+ out := &FuncType{}
+
+ out.Decs.Before = n.Decs.Before
+
+ // Decoration: Start
+ out.Decs.Start = append(out.Decs.Start, n.Decs.Start...)
+
+ // Token: Func
+ out.Func = n.Func
+
+ // Decoration: Func
+ out.Decs.Func = append(out.Decs.Func, n.Decs.Func...)
+
+ // Node: TypeParams
+ if n.TypeParams != nil {
+ out.TypeParams = Clone(n.TypeParams).(*FieldList)
+ }
+
+ // Decoration: TypeParams
+ out.Decs.TypeParams = append(out.Decs.TypeParams, n.Decs.TypeParams...)
+
+ // Node: Params
+ if n.Params != nil {
+ out.Params = Clone(n.Params).(*FieldList)
+ }
+
+ // Decoration: Params
+ out.Decs.Params = append(out.Decs.Params, n.Decs.Params...)
+
+ // Node: Results
+ if n.Results != nil {
+ out.Results = Clone(n.Results).(*FieldList)
+ }
+
+ // Decoration: End
+ out.Decs.End = append(out.Decs.End, n.Decs.End...)
+
+ out.Decs.After = n.Decs.After
+
+ return out
+ case *GenDecl:
+ out := &GenDecl{}
+
+ out.Decs.Before = n.Decs.Before
+
+ // Decoration: Start
+ out.Decs.Start = append(out.Decs.Start, n.Decs.Start...)
+
+ // Token: Tok
+ out.Tok = n.Tok
+
+ // Decoration: Tok
+ out.Decs.Tok = append(out.Decs.Tok, n.Decs.Tok...)
+
+ // Token: Lparen
+ out.Lparen = n.Lparen
+
+ // Decoration: Lparen
+ out.Decs.Lparen = append(out.Decs.Lparen, n.Decs.Lparen...)
+
+ // List: Specs
+ for _, v := range n.Specs {
+ out.Specs = append(out.Specs, Clone(v).(Spec))
+ }
+
+ // Token: Rparen
+ out.Rparen = n.Rparen
+
+ // Decoration: End
+ out.Decs.End = append(out.Decs.End, n.Decs.End...)
+
+ out.Decs.After = n.Decs.After
+
+ return out
+ case *GoStmt:
+ out := &GoStmt{}
+
+ out.Decs.Before = n.Decs.Before
+
+ // Decoration: Start
+ out.Decs.Start = append(out.Decs.Start, n.Decs.Start...)
+
+ // Decoration: Go
+ out.Decs.Go = append(out.Decs.Go, n.Decs.Go...)
+
+ // Node: Call
+ if n.Call != nil {
+ out.Call = Clone(n.Call).(*CallExpr)
+ }
+
+ // Decoration: End
+ out.Decs.End = append(out.Decs.End, n.Decs.End...)
+
+ out.Decs.After = n.Decs.After
+
+ return out
+ case *Ident:
+ out := &Ident{}
+
+ out.Decs.Before = n.Decs.Before
+
+ // Decoration: Start
+ out.Decs.Start = append(out.Decs.Start, n.Decs.Start...)
+
+ // Decoration: X
+ out.Decs.X = append(out.Decs.X, n.Decs.X...)
+
+ // String: Name
+ out.Name = n.Name
+
+ // Decoration: End
+ out.Decs.End = append(out.Decs.End, n.Decs.End...)
+
+ // Object: Obj
+ out.Obj = CloneObject(n.Obj)
+
+ // Path: Path
+ out.Path = n.Path
+
+ out.Decs.After = n.Decs.After
+
+ return out
+ case *IfStmt:
+ out := &IfStmt{}
+
+ out.Decs.Before = n.Decs.Before
+
+ // Decoration: Start
+ out.Decs.Start = append(out.Decs.Start, n.Decs.Start...)
+
+ // Decoration: If
+ out.Decs.If = append(out.Decs.If, n.Decs.If...)
+
+ // Node: Init
+ if n.Init != nil {
+ out.Init = Clone(n.Init).(Stmt)
+ }
+
+ // Decoration: Init
+ out.Decs.Init = append(out.Decs.Init, n.Decs.Init...)
+
+ // Node: Cond
+ if n.Cond != nil {
+ out.Cond = Clone(n.Cond).(Expr)
+ }
+
+ // Decoration: Cond
+ out.Decs.Cond = append(out.Decs.Cond, n.Decs.Cond...)
+
+ // Node: Body
+ if n.Body != nil {
+ out.Body = Clone(n.Body).(*BlockStmt)
+ }
+
+ // Decoration: Else
+ out.Decs.Else = append(out.Decs.Else, n.Decs.Else...)
+
+ // Node: Else
+ if n.Else != nil {
+ out.Else = Clone(n.Else).(Stmt)
+ }
+
+ // Decoration: End
+ out.Decs.End = append(out.Decs.End, n.Decs.End...)
+
+ out.Decs.After = n.Decs.After
+
+ return out
+ case *ImportSpec:
+ out := &ImportSpec{}
+
+ out.Decs.Before = n.Decs.Before
+
+ // Decoration: Start
+ out.Decs.Start = append(out.Decs.Start, n.Decs.Start...)
+
+ // Node: Name
+ if n.Name != nil {
+ out.Name = Clone(n.Name).(*Ident)
+ }
+
+ // Decoration: Name
+ out.Decs.Name = append(out.Decs.Name, n.Decs.Name...)
+
+ // Node: Path
+ if n.Path != nil {
+ out.Path = Clone(n.Path).(*BasicLit)
+ }
+
+ // Decoration: End
+ out.Decs.End = append(out.Decs.End, n.Decs.End...)
+
+ out.Decs.After = n.Decs.After
+
+ return out
+ case *IncDecStmt:
+ out := &IncDecStmt{}
+
+ out.Decs.Before = n.Decs.Before
+
+ // Decoration: Start
+ out.Decs.Start = append(out.Decs.Start, n.Decs.Start...)
+
+ // Node: X
+ if n.X != nil {
+ out.X = Clone(n.X).(Expr)
+ }
+
+ // Decoration: X
+ out.Decs.X = append(out.Decs.X, n.Decs.X...)
+
+ // Token: Tok
+ out.Tok = n.Tok
+
+ // Decoration: End
+ out.Decs.End = append(out.Decs.End, n.Decs.End...)
+
+ out.Decs.After = n.Decs.After
+
+ return out
+ case *IndexExpr:
+ out := &IndexExpr{}
+
+ out.Decs.Before = n.Decs.Before
+
+ // Decoration: Start
+ out.Decs.Start = append(out.Decs.Start, n.Decs.Start...)
+
+ // Node: X
+ if n.X != nil {
+ out.X = Clone(n.X).(Expr)
+ }
+
+ // Decoration: X
+ out.Decs.X = append(out.Decs.X, n.Decs.X...)
+
+ // Decoration: Lbrack
+ out.Decs.Lbrack = append(out.Decs.Lbrack, n.Decs.Lbrack...)
+
+ // Node: Index
+ if n.Index != nil {
+ out.Index = Clone(n.Index).(Expr)
+ }
+
+ // Decoration: Index
+ out.Decs.Index = append(out.Decs.Index, n.Decs.Index...)
+
+ // Decoration: End
+ out.Decs.End = append(out.Decs.End, n.Decs.End...)
+
+ out.Decs.After = n.Decs.After
+
+ return out
+ case *IndexListExpr:
+ out := &IndexListExpr{}
+
+ out.Decs.Before = n.Decs.Before
+
+ // Decoration: Start
+ out.Decs.Start = append(out.Decs.Start, n.Decs.Start...)
+
+ // Node: X
+ if n.X != nil {
+ out.X = Clone(n.X).(Expr)
+ }
+
+ // Decoration: X
+ out.Decs.X = append(out.Decs.X, n.Decs.X...)
+
+ // Decoration: Lbrack
+ out.Decs.Lbrack = append(out.Decs.Lbrack, n.Decs.Lbrack...)
+
+ // List: Indices
+ for _, v := range n.Indices {
+ out.Indices = append(out.Indices, Clone(v).(Expr))
+ }
+
+ // Decoration: Indices
+ out.Decs.Indices = append(out.Decs.Indices, n.Decs.Indices...)
+
+ // Decoration: End
+ out.Decs.End = append(out.Decs.End, n.Decs.End...)
+
+ out.Decs.After = n.Decs.After
+
+ return out
+ case *InterfaceType:
+ out := &InterfaceType{}
+
+ out.Decs.Before = n.Decs.Before
+
+ // Decoration: Start
+ out.Decs.Start = append(out.Decs.Start, n.Decs.Start...)
+
+ // Decoration: Interface
+ out.Decs.Interface = append(out.Decs.Interface, n.Decs.Interface...)
+
+ // Node: Methods
+ if n.Methods != nil {
+ out.Methods = Clone(n.Methods).(*FieldList)
+ }
+
+ // Decoration: End
+ out.Decs.End = append(out.Decs.End, n.Decs.End...)
+
+ // Value: Incomplete
+ out.Incomplete = n.Incomplete
+
+ out.Decs.After = n.Decs.After
+
+ return out
+ case *KeyValueExpr:
+ out := &KeyValueExpr{}
+
+ out.Decs.Before = n.Decs.Before
+
+ // Decoration: Start
+ out.Decs.Start = append(out.Decs.Start, n.Decs.Start...)
+
+ // Node: Key
+ if n.Key != nil {
+ out.Key = Clone(n.Key).(Expr)
+ }
+
+ // Decoration: Key
+ out.Decs.Key = append(out.Decs.Key, n.Decs.Key...)
+
+ // Decoration: Colon
+ out.Decs.Colon = append(out.Decs.Colon, n.Decs.Colon...)
+
+ // Node: Value
+ if n.Value != nil {
+ out.Value = Clone(n.Value).(Expr)
+ }
+
+ // Decoration: End
+ out.Decs.End = append(out.Decs.End, n.Decs.End...)
+
+ out.Decs.After = n.Decs.After
+
+ return out
+ case *LabeledStmt:
+ out := &LabeledStmt{}
+
+ out.Decs.Before = n.Decs.Before
+
+ // Decoration: Start
+ out.Decs.Start = append(out.Decs.Start, n.Decs.Start...)
+
+ // Node: Label
+ if n.Label != nil {
+ out.Label = Clone(n.Label).(*Ident)
+ }
+
+ // Decoration: Label
+ out.Decs.Label = append(out.Decs.Label, n.Decs.Label...)
+
+ // Decoration: Colon
+ out.Decs.Colon = append(out.Decs.Colon, n.Decs.Colon...)
+
+ // Node: Stmt
+ if n.Stmt != nil {
+ out.Stmt = Clone(n.Stmt).(Stmt)
+ }
+
+ // Decoration: End
+ out.Decs.End = append(out.Decs.End, n.Decs.End...)
+
+ out.Decs.After = n.Decs.After
+
+ return out
+ case *MapType:
+ out := &MapType{}
+
+ out.Decs.Before = n.Decs.Before
+
+ // Decoration: Start
+ out.Decs.Start = append(out.Decs.Start, n.Decs.Start...)
+
+ // Decoration: Map
+ out.Decs.Map = append(out.Decs.Map, n.Decs.Map...)
+
+ // Node: Key
+ if n.Key != nil {
+ out.Key = Clone(n.Key).(Expr)
+ }
+
+ // Decoration: Key
+ out.Decs.Key = append(out.Decs.Key, n.Decs.Key...)
+
+ // Node: Value
+ if n.Value != nil {
+ out.Value = Clone(n.Value).(Expr)
+ }
+
+ // Decoration: End
+ out.Decs.End = append(out.Decs.End, n.Decs.End...)
+
+ out.Decs.After = n.Decs.After
+
+ return out
+ case *Package:
+ out := &Package{}
+
+ // Value: Name
+ out.Name = n.Name
+
+ // Scope: Scope
+ out.Scope = CloneScope(n.Scope)
+
+ // Map: Imports
+ out.Imports = map[string]*Object{}
+ for k, v := range n.Imports {
+ out.Imports[k] = CloneObject(v)
+ }
+
+ // Map: Files
+ out.Files = map[string]*File{}
+ for k, v := range n.Files {
+ out.Files[k] = Clone(v).(*File)
+ }
+
+ return out
+ case *ParenExpr:
+ out := &ParenExpr{}
+
+ out.Decs.Before = n.Decs.Before
+
+ // Decoration: Start
+ out.Decs.Start = append(out.Decs.Start, n.Decs.Start...)
+
+ // Decoration: Lparen
+ out.Decs.Lparen = append(out.Decs.Lparen, n.Decs.Lparen...)
+
+ // Node: X
+ if n.X != nil {
+ out.X = Clone(n.X).(Expr)
+ }
+
+ // Decoration: X
+ out.Decs.X = append(out.Decs.X, n.Decs.X...)
+
+ // Decoration: End
+ out.Decs.End = append(out.Decs.End, n.Decs.End...)
+
+ out.Decs.After = n.Decs.After
+
+ return out
+ case *RangeStmt:
+ out := &RangeStmt{}
+
+ out.Decs.Before = n.Decs.Before
+
+ // Decoration: Start
+ out.Decs.Start = append(out.Decs.Start, n.Decs.Start...)
+
+ // Decoration: For
+ out.Decs.For = append(out.Decs.For, n.Decs.For...)
+
+ // Node: Key
+ if n.Key != nil {
+ out.Key = Clone(n.Key).(Expr)
+ }
+
+ // Decoration: Key
+ out.Decs.Key = append(out.Decs.Key, n.Decs.Key...)
+
+ // Node: Value
+ if n.Value != nil {
+ out.Value = Clone(n.Value).(Expr)
+ }
+
+ // Decoration: Value
+ out.Decs.Value = append(out.Decs.Value, n.Decs.Value...)
+
+ // Token: Tok
+ out.Tok = n.Tok
+
+ // Decoration: Range
+ out.Decs.Range = append(out.Decs.Range, n.Decs.Range...)
+
+ // Node: X
+ if n.X != nil {
+ out.X = Clone(n.X).(Expr)
+ }
+
+ // Decoration: X
+ out.Decs.X = append(out.Decs.X, n.Decs.X...)
+
+ // Node: Body
+ if n.Body != nil {
+ out.Body = Clone(n.Body).(*BlockStmt)
+ }
+
+ // Decoration: End
+ out.Decs.End = append(out.Decs.End, n.Decs.End...)
+
+ out.Decs.After = n.Decs.After
+
+ return out
+ case *ReturnStmt:
+ out := &ReturnStmt{}
+
+ out.Decs.Before = n.Decs.Before
+
+ // Decoration: Start
+ out.Decs.Start = append(out.Decs.Start, n.Decs.Start...)
+
+ // Decoration: Return
+ out.Decs.Return = append(out.Decs.Return, n.Decs.Return...)
+
+ // List: Results
+ for _, v := range n.Results {
+ out.Results = append(out.Results, Clone(v).(Expr))
+ }
+
+ // Decoration: End
+ out.Decs.End = append(out.Decs.End, n.Decs.End...)
+
+ out.Decs.After = n.Decs.After
+
+ return out
+ case *SelectStmt:
+ out := &SelectStmt{}
+
+ out.Decs.Before = n.Decs.Before
+
+ // Decoration: Start
+ out.Decs.Start = append(out.Decs.Start, n.Decs.Start...)
+
+ // Decoration: Select
+ out.Decs.Select = append(out.Decs.Select, n.Decs.Select...)
+
+ // Node: Body
+ if n.Body != nil {
+ out.Body = Clone(n.Body).(*BlockStmt)
+ }
+
+ // Decoration: End
+ out.Decs.End = append(out.Decs.End, n.Decs.End...)
+
+ out.Decs.After = n.Decs.After
+
+ return out
+ case *SelectorExpr:
+ out := &SelectorExpr{}
+
+ out.Decs.Before = n.Decs.Before
+
+ // Decoration: Start
+ out.Decs.Start = append(out.Decs.Start, n.Decs.Start...)
+
+ // Node: X
+ if n.X != nil {
+ out.X = Clone(n.X).(Expr)
+ }
+
+ // Decoration: X
+ out.Decs.X = append(out.Decs.X, n.Decs.X...)
+
+ // Node: Sel
+ if n.Sel != nil {
+ out.Sel = Clone(n.Sel).(*Ident)
+ }
+
+ // Decoration: End
+ out.Decs.End = append(out.Decs.End, n.Decs.End...)
+
+ out.Decs.After = n.Decs.After
+
+ return out
+ case *SendStmt:
+ out := &SendStmt{}
+
+ out.Decs.Before = n.Decs.Before
+
+ // Decoration: Start
+ out.Decs.Start = append(out.Decs.Start, n.Decs.Start...)
+
+ // Node: Chan
+ if n.Chan != nil {
+ out.Chan = Clone(n.Chan).(Expr)
+ }
+
+ // Decoration: Chan
+ out.Decs.Chan = append(out.Decs.Chan, n.Decs.Chan...)
+
+ // Decoration: Arrow
+ out.Decs.Arrow = append(out.Decs.Arrow, n.Decs.Arrow...)
+
+ // Node: Value
+ if n.Value != nil {
+ out.Value = Clone(n.Value).(Expr)
+ }
+
+ // Decoration: End
+ out.Decs.End = append(out.Decs.End, n.Decs.End...)
+
+ out.Decs.After = n.Decs.After
+
+ return out
+ case *SliceExpr:
+ out := &SliceExpr{}
+
+ out.Decs.Before = n.Decs.Before
+
+ // Decoration: Start
+ out.Decs.Start = append(out.Decs.Start, n.Decs.Start...)
+
+ // Node: X
+ if n.X != nil {
+ out.X = Clone(n.X).(Expr)
+ }
+
+ // Decoration: X
+ out.Decs.X = append(out.Decs.X, n.Decs.X...)
+
+ // Decoration: Lbrack
+ out.Decs.Lbrack = append(out.Decs.Lbrack, n.Decs.Lbrack...)
+
+ // Node: Low
+ if n.Low != nil {
+ out.Low = Clone(n.Low).(Expr)
+ }
+
+ // Decoration: Low
+ out.Decs.Low = append(out.Decs.Low, n.Decs.Low...)
+
+ // Node: High
+ if n.High != nil {
+ out.High = Clone(n.High).(Expr)
+ }
+
+ // Decoration: High
+ out.Decs.High = append(out.Decs.High, n.Decs.High...)
+
+ // Node: Max
+ if n.Max != nil {
+ out.Max = Clone(n.Max).(Expr)
+ }
+
+ // Decoration: Max
+ out.Decs.Max = append(out.Decs.Max, n.Decs.Max...)
+
+ // Decoration: End
+ out.Decs.End = append(out.Decs.End, n.Decs.End...)
+
+ // Value: Slice3
+ out.Slice3 = n.Slice3
+
+ out.Decs.After = n.Decs.After
+
+ return out
+ case *StarExpr:
+ out := &StarExpr{}
+
+ out.Decs.Before = n.Decs.Before
+
+ // Decoration: Start
+ out.Decs.Start = append(out.Decs.Start, n.Decs.Start...)
+
+ // Decoration: Star
+ out.Decs.Star = append(out.Decs.Star, n.Decs.Star...)
+
+ // Node: X
+ if n.X != nil {
+ out.X = Clone(n.X).(Expr)
+ }
+
+ // Decoration: End
+ out.Decs.End = append(out.Decs.End, n.Decs.End...)
+
+ out.Decs.After = n.Decs.After
+
+ return out
+ case *StructType:
+ out := &StructType{}
+
+ out.Decs.Before = n.Decs.Before
+
+ // Decoration: Start
+ out.Decs.Start = append(out.Decs.Start, n.Decs.Start...)
+
+ // Decoration: Struct
+ out.Decs.Struct = append(out.Decs.Struct, n.Decs.Struct...)
+
+ // Node: Fields
+ if n.Fields != nil {
+ out.Fields = Clone(n.Fields).(*FieldList)
+ }
+
+ // Decoration: End
+ out.Decs.End = append(out.Decs.End, n.Decs.End...)
+
+ // Value: Incomplete
+ out.Incomplete = n.Incomplete
+
+ out.Decs.After = n.Decs.After
+
+ return out
+ case *SwitchStmt:
+ out := &SwitchStmt{}
+
+ out.Decs.Before = n.Decs.Before
+
+ // Decoration: Start
+ out.Decs.Start = append(out.Decs.Start, n.Decs.Start...)
+
+ // Decoration: Switch
+ out.Decs.Switch = append(out.Decs.Switch, n.Decs.Switch...)
+
+ // Node: Init
+ if n.Init != nil {
+ out.Init = Clone(n.Init).(Stmt)
+ }
+
+ // Decoration: Init
+ out.Decs.Init = append(out.Decs.Init, n.Decs.Init...)
+
+ // Node: Tag
+ if n.Tag != nil {
+ out.Tag = Clone(n.Tag).(Expr)
+ }
+
+ // Decoration: Tag
+ out.Decs.Tag = append(out.Decs.Tag, n.Decs.Tag...)
+
+ // Node: Body
+ if n.Body != nil {
+ out.Body = Clone(n.Body).(*BlockStmt)
+ }
+
+ // Decoration: End
+ out.Decs.End = append(out.Decs.End, n.Decs.End...)
+
+ out.Decs.After = n.Decs.After
+
+ return out
+ case *TypeAssertExpr:
+ out := &TypeAssertExpr{}
+
+ out.Decs.Before = n.Decs.Before
+
+ // Decoration: Start
+ out.Decs.Start = append(out.Decs.Start, n.Decs.Start...)
+
+ // Node: X
+ if n.X != nil {
+ out.X = Clone(n.X).(Expr)
+ }
+
+ // Decoration: X
+ out.Decs.X = append(out.Decs.X, n.Decs.X...)
+
+ // Decoration: Lparen
+ out.Decs.Lparen = append(out.Decs.Lparen, n.Decs.Lparen...)
+
+ // Node: Type
+ if n.Type != nil {
+ out.Type = Clone(n.Type).(Expr)
+ }
+
+ // Decoration: Type
+ out.Decs.Type = append(out.Decs.Type, n.Decs.Type...)
+
+ // Decoration: End
+ out.Decs.End = append(out.Decs.End, n.Decs.End...)
+
+ out.Decs.After = n.Decs.After
+
+ return out
+ case *TypeSpec:
+ out := &TypeSpec{}
+
+ out.Decs.Before = n.Decs.Before
+
+ // Decoration: Start
+ out.Decs.Start = append(out.Decs.Start, n.Decs.Start...)
+
+ // Node: Name
+ if n.Name != nil {
+ out.Name = Clone(n.Name).(*Ident)
+ }
+
+ // Token: Assign
+ out.Assign = n.Assign
+
+ // Decoration: Name
+ out.Decs.Name = append(out.Decs.Name, n.Decs.Name...)
+
+ // Node: TypeParams
+ if n.TypeParams != nil {
+ out.TypeParams = Clone(n.TypeParams).(*FieldList)
+ }
+
+ // Decoration: TypeParams
+ out.Decs.TypeParams = append(out.Decs.TypeParams, n.Decs.TypeParams...)
+
+ // Node: Type
+ if n.Type != nil {
+ out.Type = Clone(n.Type).(Expr)
+ }
+
+ // Decoration: End
+ out.Decs.End = append(out.Decs.End, n.Decs.End...)
+
+ out.Decs.After = n.Decs.After
+
+ return out
+ case *TypeSwitchStmt:
+ out := &TypeSwitchStmt{}
+
+ out.Decs.Before = n.Decs.Before
+
+ // Decoration: Start
+ out.Decs.Start = append(out.Decs.Start, n.Decs.Start...)
+
+ // Decoration: Switch
+ out.Decs.Switch = append(out.Decs.Switch, n.Decs.Switch...)
+
+ // Node: Init
+ if n.Init != nil {
+ out.Init = Clone(n.Init).(Stmt)
+ }
+
+ // Decoration: Init
+ out.Decs.Init = append(out.Decs.Init, n.Decs.Init...)
+
+ // Node: Assign
+ if n.Assign != nil {
+ out.Assign = Clone(n.Assign).(Stmt)
+ }
+
+ // Decoration: Assign
+ out.Decs.Assign = append(out.Decs.Assign, n.Decs.Assign...)
+
+ // Node: Body
+ if n.Body != nil {
+ out.Body = Clone(n.Body).(*BlockStmt)
+ }
+
+ // Decoration: End
+ out.Decs.End = append(out.Decs.End, n.Decs.End...)
+
+ out.Decs.After = n.Decs.After
+
+ return out
+ case *UnaryExpr:
+ out := &UnaryExpr{}
+
+ out.Decs.Before = n.Decs.Before
+
+ // Decoration: Start
+ out.Decs.Start = append(out.Decs.Start, n.Decs.Start...)
+
+ // Token: Op
+ out.Op = n.Op
+
+ // Decoration: Op
+ out.Decs.Op = append(out.Decs.Op, n.Decs.Op...)
+
+ // Node: X
+ if n.X != nil {
+ out.X = Clone(n.X).(Expr)
+ }
+
+ // Decoration: End
+ out.Decs.End = append(out.Decs.End, n.Decs.End...)
+
+ out.Decs.After = n.Decs.After
+
+ return out
+ case *ValueSpec:
+ out := &ValueSpec{}
+
+ out.Decs.Before = n.Decs.Before
+
+ // Decoration: Start
+ out.Decs.Start = append(out.Decs.Start, n.Decs.Start...)
+
+ // List: Names
+ for _, v := range n.Names {
+ out.Names = append(out.Names, Clone(v).(*Ident))
+ }
+
+ // Node: Type
+ if n.Type != nil {
+ out.Type = Clone(n.Type).(Expr)
+ }
+
+ // Decoration: Assign
+ out.Decs.Assign = append(out.Decs.Assign, n.Decs.Assign...)
+
+ // List: Values
+ for _, v := range n.Values {
+ out.Values = append(out.Values, Clone(v).(Expr))
+ }
+
+ // Decoration: End
+ out.Decs.End = append(out.Decs.End, n.Decs.End...)
+
+ out.Decs.After = n.Decs.After
+
+ return out
+ default:
+ panic(fmt.Sprintf("%T", n))
+ }
+}
diff --git a/vendor/github.com/dave/dst/clone.go b/vendor/github.com/dave/dst/clone.go
new file mode 100644
index 0000000000..3f1e5f8292
--- /dev/null
+++ b/vendor/github.com/dave/dst/clone.go
@@ -0,0 +1,11 @@
+package dst
+
+// CloneObject returns nil: After cloning a node, it should not be attached to the same object / scope.
+func CloneObject(o *Object) *Object {
+ return nil
+}
+
+// CloneScope returns nil: After cloning a node, it should not be attached to the same object / scope.
+func CloneScope(s *Scope) *Scope {
+ return nil
+}
diff --git a/vendor/github.com/dave/dst/contributing.md b/vendor/github.com/dave/dst/contributing.md
new file mode 100644
index 0000000000..dc0240605f
--- /dev/null
+++ b/vendor/github.com/dave/dst/contributing.md
@@ -0,0 +1,78 @@
+# Building / Developing / Contributing
+
+The `dst` package relies heavily on code generation. So heavily, in fact, that `README.md` is
+itself generated by a preprocessor! Here are a few tips/tricks to get started developing `dst`.
+
+## Adding Features, Fixing Bugs
+
+Generally speaking, code handling node annotation is generated from the files in the `gendst` directory.
+In order to add/change decorations, edit the `gendst/data.go` file. Once you have made your edits, you can
+regenerate the library's source code based on those changes by
+
+1. `go run github.com/dave/dst/gendst`: This command will build and run a program generated from the
+ source code in the `gendst` folder that regenerates all the dst source fiels to reflect the changes
+ that you just made in the `gendst/data.go` file.
+
+Whenever you make a change to the `gendst/data.go` file, you must perform the aforementioned step.
+
+If you add a Node to the `gendst/data.go` file, you will need to make corresponding additions to non-generated
+files as well. Those files include, but are not limited to,:
+
+- `dst.go`
+- `walk.go`
+- `dstutil/rewrite.go`
+
+Depending on the changes that you have made to the description of the decorated Nodes, you may have to change some, none,
+or all of those files listed above (or even others that are not listed!).
+
+## Adding/Running Tests
+
+Any changes to the decorations of Nodes (or the addition of new Nodes) should be accompanied
+by an entry in `gendst/positions.go`.
+
+The format of the file is ...
+
+```
+//
+// startLine {
+ for i := startLine; i < endLine; i++ {
+ // we avoid the lines that follow the lines in the comment
+ avoid[i+1] = true
+ }
+ }
+ }
+ }
+ }
+
+ // avoid newlines inside multi-line (back-quoted) strings or bad nodes
+ for _, frag := range f.fragments {
+ switch frag := frag.(type) {
+ case *stringFragment:
+ if !strings.HasPrefix(frag.String, "`") {
+ continue
+ }
+
+ startLine := f.Fset.Position(frag.Pos).Line
+ endLine := f.Fset.Position(frag.Pos + token.Pos(len(frag.String))).Line
+
+ // multi line string
+ if endLine > startLine {
+ for i := startLine; i < endLine; i++ {
+ // we avoid the lines that follow the lines in the string
+ avoid[i+1] = true
+ }
+ }
+
+ case *badFragment:
+
+ // Newlines inside bad nodes are not printed by the formatter, so there is no
+ // need to reconstruct them in the restorer.
+
+ startLine := f.Fset.Position(frag.Pos).Line
+ endLine := f.Fset.Position(frag.Pos + token.Pos(frag.Length)).Line
+
+ if endLine > startLine {
+ for i := startLine; i < endLine; i++ {
+ // we avoid the lines that follow the lines in the node
+ avoid[i+1] = true
+ }
+ }
+ }
+ }
+
+ // Finding the positions of each newline is not easy. We step through the file one byte
+ // at a time and get the line number from the FileSet. As the line number increments,
+ // we know where the newlines are.
+ line := 1
+ tokenf := f.Fset.File(astf.Pos())
+ max := tokenf.Base() + tokenf.Size()
+ for i := tokenf.Base(); i < max; i++ {
+ pos := f.Fset.Position(token.Pos(i))
+ if pos.Line != line {
+
+ // if the line number has changed, we're on a new line
+
+ line = pos.Line
+
+ if avoid[line] {
+ // ignore if it's in the avoid list - e.g. inside a comment or multi-line
+ // string
+ continue
+ }
+
+ // peek ahead to the next position in the fset. If we're on another new line,
+ // we have an empty line:
+ nextLine := line
+ if i < max-1 {
+ // can't peek forward at the end of the file
+ nextLine = f.Fset.Position(token.Pos(i + 1)).Line
+ }
+
+ if nextLine != line {
+ // add an empty line fragment
+ f.addNewlineFragment(token.Pos(i-1), true)
+
+ // for empty lines, increment past the second "\n" manually:
+ line = nextLine
+ i++
+
+ } else {
+ // add a new line fragment
+ f.addNewlineFragment(token.Pos(i-1), false)
+ }
+
+ }
+ }
+ }
+
+ switch val := node.(type) {
+ case *ast.File:
+ processFile(val)
+ case *ast.Package:
+ for _, file := range val.Files {
+ processFile(file)
+ }
+ }
+
+ }
+
+ // the comments and newline fragments will be after the node fragments, so we sort the entire
+ // list by fset position, ensuring that fragments with equal position stay in the original
+ // order. This ensures that decorations get added to the correct attachment points (which may
+ // occur at the same fset position).
+ sort.SliceStable(f.fragments, func(i, j int) bool {
+ return f.fragments[i].Position() < f.fragments[j].Position()
+ })
+
+ // We calculate the indent of the start and end of each node and comment. This is used to
+ // during the decoration attachment algorithm to correctly attach hanging indent comments. See
+ // issues 9 and 18 for more info.
+ currentIndent := 0
+ for i, frag := range f.fragments {
+ if i == 0 || f.fragments[i-1].Newline() {
+ currentIndent = f.Fset.Position(frag.Position()).Column
+ }
+ switch frag := frag.(type) {
+ case *decorationFragment:
+ switch frag.Name {
+ case "Start":
+ f.startIndents[frag.Node] = currentIndent
+ case "End":
+ f.endIndents[frag.Node] = currentIndent
+ }
+ case *commentFragment:
+ frag.Indent = currentIndent
+ }
+ }
+}
+
+func (f *fileDecorator) link() {
+
+ // Pass 1: associate comment groups with decorations. Sweep up any other comments / new-lines /
+ // empty-lines and associate with the same decoration.
+ for i, frag := range f.fragments {
+ switch frag := frag.(type) {
+ case *decorationFragment:
+
+ // Special case for hanging indent (See https://github.com/dave/dst/issues/18)
+ //
+ // If we're on the End decoration of a Stmt or Decl, and indents: end == start+1 (OR
+ // it's a case / comm clause), then search forward over empty lines for all comments
+ // with the same indent as the End decoration.
+ //
+ // These should be attached to the end node. We also search for subsequent comments that
+ // have the same indent as the Start. If the next decoration node is the start of a Stmt
+ // or Decl with the same indent as the original node, these are attached there.
+
+ if frag.Name != "End" {
+ continue
+ }
+ _, stmt := frag.Node.(ast.Stmt)
+ _, decl := frag.Node.(ast.Decl)
+ if !stmt && !decl {
+ continue
+ }
+
+ if _, labeledStmt := frag.Node.(*ast.LabeledStmt); labeledStmt {
+ // Special case: labeled statements shouldn't be treated in the same way.
+ continue
+ }
+
+ start := f.startIndents[frag.Node]
+ end := f.endIndents[frag.Node]
+
+ _, caseClause := frag.Node.(*ast.CaseClause)
+ _, commClause := frag.Node.(*ast.CommClause)
+ if start == end && (caseClause || commClause) {
+ // special case for case / comm clause with no items... the clause node starts and
+ // ends on the same line, but comments can still be hanging. We spoof an indented
+ // end position:
+ end++
+ }
+
+ if end != start+1 {
+ continue
+ }
+
+ frags, next := f.findIndentedComments(i+1, [2]int{end, start})
+ endFrags := frags[0]
+ nextFrags := frags[1]
+ if len(endFrags) > 0 {
+ // if endFrags ends with a newline, don't attach it because it was in between the
+ // two groups, so should be left unattached so we can attach it as spacing in the
+ // second pass
+ _, nl := endFrags[len(endFrags)-1].(*newlineFragment)
+ if nl {
+ f.attachToDecoration(endFrags[0:len(endFrags)-1], f.decorations, frag)
+ } else {
+ f.attachToDecoration(endFrags, f.decorations, frag)
+ }
+ }
+ if len(nextFrags) > 0 && next != nil {
+ _, nextStmt := next.Node.(ast.Stmt)
+ _, nextDecl := next.Node.(ast.Decl)
+ nextStart := f.startIndents[next.Node]
+ if (nextStmt || nextDecl) && nextStart == start {
+ f.attachToDecoration(nextFrags, f.decorations, next)
+ }
+ }
+
+ case *commentFragment:
+
+ if frag.Attached != nil {
+ continue
+ }
+
+ // Comments (or comment groups) attach to decoration points in this precedence:
+ //
+ // 1) Before the comment on the same line
+ // 2) After the comment on the same line
+ // 3) After the comment on subsequent lines (but stopping at empty lines)
+ // 4) Before the comment on previous lines (but stopping at empty lines)
+ // 5) After the comment on subsequent lines
+ // 6) Before the comment on previous lines
+ //
+ // We always stop at tokens, strings. If we get to the end without finding a decoration point we panic.
+
+ var frags []fragment // comment / new-line / empty-line
+ var dec *decorationFragment
+ var found bool
+ var try int
+ for !found {
+ try++
+ switch try {
+ case 1:
+ // Before the comment on the same line (search backwards and stop at any newline)
+ frags, dec, found = f.findDecoration(true, true, i, -1, false)
+ case 2:
+ // After the comment on the same line
+ // After the comment on line+1 (search forwards and stop at any empty line)
+ frags, dec, found = f.findDecoration(false, true, i, 1, false)
+ case 3:
+ // Before the comment on line-1 (search backwards and stop at any empty line)
+ frags, dec, found = f.findDecoration(false, true, i, -1, false)
+ case 4:
+ // After the comment on line+2 (search forwards)
+ frags, dec, found = f.findDecoration(false, false, i, 1, false)
+ case 5:
+ // After the comment on line-2 (search backwards)
+ frags, dec, found = f.findDecoration(false, false, i, -1, false)
+ default:
+ panic("no decoration found for " + frag.Text)
+ }
+ }
+ f.attachToDecoration(frags, f.decorations, dec)
+ }
+ }
+
+ // Pass 2: associate any new-lines / empty-lines that have not been added to decorations to node
+ // spacing. If they can't be attached as node spacing, attach them as decorations.
+ for i, frag := range f.fragments {
+ switch frag := frag.(type) {
+ case *newlineFragment:
+
+ if frag.Attached != nil {
+ continue
+ }
+
+ // If the newline is directly before / after a node, we can set the Before / After spacing
+ // of the node decoration instead of adding the newline as a decoration.
+ nodeBefore, _, foundBefore := f.findNode(i, 1)
+ nodeAfter, _, foundAfter := f.findNode(i, -1)
+ if foundBefore || foundAfter {
+ spaceType := dst.NewLine
+ if frag.Empty {
+ spaceType = dst.EmptyLine
+ }
+ // Several newline fragments can resolve to the same node - e.g. a run of two
+ // blank lines is an empty-line fragment followed by a new-line fragment, and both
+ // find the same node. Only ever increase the spacing, so the new-line doesn't
+ // downgrade the empty-line we already found. See #81.
+ if foundBefore && spaceType > f.before[nodeBefore] {
+ f.before[nodeBefore] = spaceType
+ }
+ if foundAfter && spaceType > f.after[nodeAfter] {
+ f.after[nodeAfter] = spaceType
+ }
+ continue
+ }
+
+ // If this newline can't be associated with a node, attach it to the next / previous
+ // decoration location:
+ var dec *decorationFragment
+ var found bool
+ var try int
+ for !found {
+ try++
+ switch try {
+ case 1:
+ // search backwards but stop at any token
+ _, dec, found = f.findDecoration(false, false, i, -1, false)
+ case 2:
+ // search forwards but stop at any token
+ _, dec, found = f.findDecoration(false, false, i, 1, false)
+ default:
+ panic("no decoration found for newline")
+ }
+ }
+ appendNewLine(f.decorations, dec.Node, dec.Name, frag.Empty)
+ }
+ }
+
+ return
+}
+
+func appendDecoration(m map[ast.Node]map[string][]string, n ast.Node, pos, text string) {
+ if m[n] == nil {
+ m[n] = map[string][]string{}
+ }
+ m[n][pos] = append(m[n][pos], text)
+}
+
+func appendNewLine(m map[ast.Node]map[string][]string, n ast.Node, pos string, empty bool) {
+ if m[n] == nil {
+ m[n] = map[string][]string{}
+ }
+ num := 1
+ if empty {
+ num = 2
+ }
+ decs := m[n][pos]
+ if len(decs) > 0 && strings.HasPrefix(decs[len(decs)-1], "//") {
+ num--
+ }
+ for i := 0; i < num; i++ {
+ m[n][pos] = append(m[n][pos], "\n")
+ }
+}
+
+func (f *fileDecorator) attachToDecoration(frags []fragment, decorations map[ast.Node]map[string][]string, dec *decorationFragment) {
+ for _, fr := range frags {
+ switch fr := fr.(type) {
+ case *commentFragment:
+ appendDecoration(decorations, dec.Node, dec.Name, fr.Text)
+ fr.Attached = dec
+ case *newlineFragment:
+ appendNewLine(decorations, dec.Node, dec.Name, fr.Empty)
+ fr.Attached = dec
+ }
+ }
+}
+
+func (f *fileDecorator) findDecoration(stopAtNewline, stopAtEmptyLine bool, from int, direction int, onlyClause bool) (swept []fragment, dec *decorationFragment, found bool) {
+ var frags []fragment
+ for i := from; i < len(f.fragments) && i >= 0; i += direction {
+ switch current := f.fragments[i].(type) {
+ case *decorationFragment:
+ if onlyClause {
+ switch current.Node.(type) {
+ case *ast.CommClause, *ast.CaseClause:
+ if current.Name == "Start" {
+ return frags, current, true
+ }
+ return
+ default:
+ return
+ }
+ }
+ return frags, current, true
+ case *newlineFragment:
+ if stopAtNewline {
+ return
+ }
+ if stopAtEmptyLine && current.Empty {
+ return
+ }
+ if current.Attached != nil {
+ continue
+ }
+ if direction == 1 {
+ frags = append(frags, current)
+ } else {
+ frags = append([]fragment{current}, frags...)
+ }
+ case *commentFragment:
+ if current.Attached != nil {
+ continue
+ }
+ if direction == 1 {
+ frags = append(frags, current)
+ } else {
+ frags = append([]fragment{current}, frags...)
+ }
+ case *tokenFragment, *stringFragment:
+ return
+ }
+ }
+ return
+}
+
+func (f *fileDecorator) findNode(from int, direction int) (node ast.Node, dec *decorationFragment, found bool) {
+
+ var name string
+ switch direction {
+ case 1:
+ name = "Start"
+ case -1:
+ name = "End"
+ }
+
+ for i := from; i < len(f.fragments) && i >= 0; i += direction {
+ switch frag := f.fragments[i].(type) {
+ case *decorationFragment:
+ if frag.Name == name {
+ return frag.Node, frag, true
+ }
+ return
+ case *commentFragment:
+ if frag.Attached != nil && frag.Attached.Name == name {
+ return frag.Attached.Node, frag.Attached, true
+ }
+ case *newlineFragment:
+ if frag.Attached != nil && frag.Attached.Name == name {
+ return frag.Attached.Node, frag.Attached, true
+ }
+ case *tokenFragment, *stringFragment:
+ return
+ }
+ }
+ return
+}
+
+func (f *fileDecorator) findIndentedComments(from int, indents [2]int) (frags [2][]fragment, nextDecoration *decorationFragment) {
+ var stage int
+ var pastNewline bool // while this is false, we're on the same line that the stmt ended, so we accept all comments regardless of the indent (e.g. empty clauses) - see "hanging-indent-same-line" test case.
+ for i := from; i < len(f.fragments); i++ {
+ switch current := f.fragments[i].(type) {
+ case *decorationFragment:
+ return frags, current
+ case *newlineFragment:
+ pastNewline = true
+ frags[stage] = append(frags[stage], current)
+ case *commentFragment:
+ if !pastNewline {
+ frags[stage] = append(frags[stage], current)
+ continue
+ }
+ if stage == 0 {
+ // Check indent matches. If not, move to second stage or exit if that doesn't match.
+ if current.Indent != indents[0] {
+ if current.Indent == indents[1] {
+ stage = 1
+ } else {
+ return
+ }
+ }
+ } else if stage == 1 {
+ if current.Indent != indents[1] {
+ return
+ }
+ }
+ frags[stage] = append(frags[stage], current)
+ case *tokenFragment, *stringFragment:
+ return
+ }
+ }
+ return
+}
+
+type fragment interface {
+ Position() token.Pos
+ Newline() bool // True if the fragment ends in a newline ("\n" or "//...")
+}
+
+type tokenFragment struct {
+ Node ast.Node
+ Token token.Token
+ Pos token.Pos
+}
+
+type stringFragment struct {
+ Node ast.Node
+ String string
+ Pos token.Pos
+}
+
+type badFragment struct {
+ Node ast.Node
+ Pos token.Pos
+ Length int
+}
+
+type commentFragment struct {
+ Text string
+ Pos token.Pos
+ Attached *decorationFragment // where did we attach this comment in pass 1?
+ Indent int // indent if this comment follows a newline
+}
+
+type newlineFragment struct {
+ Pos token.Pos
+ Empty bool // true if this newline is an empty line (e.g. follows a "//" comment or "\n")
+ Attached *decorationFragment // where did we attach this comment in pass 1?
+}
+
+type decorationFragment struct {
+ Node ast.Node
+ Name string
+ Pos token.Pos
+}
+
+func (v *tokenFragment) Position() token.Pos { return v.Pos }
+func (v *stringFragment) Position() token.Pos { return v.Pos }
+func (v *commentFragment) Position() token.Pos { return v.Pos }
+func (v *newlineFragment) Position() token.Pos { return v.Pos }
+func (v *decorationFragment) Position() token.Pos { return v.Pos }
+func (v *badFragment) Position() token.Pos { return v.Pos }
+
+func (v *tokenFragment) Newline() bool { return false }
+func (v *stringFragment) Newline() bool { return false }
+func (v *commentFragment) Newline() bool { return strings.HasPrefix(v.Text, "//") }
+func (v *newlineFragment) Newline() bool { return true }
+func (v *decorationFragment) Newline() bool { return false }
+func (v *badFragment) Newline() bool { return false }
+
+func (f fileDecorator) debug(w io.Writer) {
+ formatPos := func(s token.Position) string {
+ return s.String()[strings.Index(s.String(), ":")+1:]
+ }
+ nodeType := func(n ast.Node) string {
+ return strings.Replace(fmt.Sprintf("%T", n), "*ast.", "", -1)
+ }
+ for _, v := range f.fragments {
+ switch v := v.(type) {
+ case *newlineFragment:
+ if v.Empty {
+ fmt.Fprintf(w, "Empty line %s\n", formatPos(f.Fset.Position(v.Pos)))
+ } else {
+ fmt.Fprintf(w, "New line %s\n", formatPos(f.Fset.Position(v.Pos)))
+ }
+ case *tokenFragment:
+ fmt.Fprintf(w, "%s %q %s\n", nodeType(v.Node), v.Token, formatPos(f.Fset.Position(v.Pos)))
+ case *stringFragment:
+ fmt.Fprintf(w, "%s %q %s\n", nodeType(v.Node), v.String, formatPos(f.Fset.Position(v.Pos)))
+ case *decorationFragment:
+ fmt.Fprintf(w, "%s %s %s\n", nodeType(v.Node), v.Name, formatPos(f.Fset.Position(v.Pos)))
+ case *commentFragment:
+ fmt.Fprintf(w, "%q %s\n", v.Text, formatPos(f.Fset.Position(v.Pos)))
+ case *badFragment:
+ fmt.Fprintf(w, "%s %d %s\n", nodeType(v.Node), v.Length, formatPos(f.Fset.Position(v.Pos)))
+ default:
+ fmt.Fprintf(w, "%T %s\n", v, formatPos(f.Fset.Position(v.Position())))
+ }
+ }
+}
diff --git a/vendor/github.com/dave/dst/decorator/decorator-node-generated.go b/vendor/github.com/dave/dst/decorator/decorator-node-generated.go
new file mode 100644
index 0000000000..06a6a76ca4
--- /dev/null
+++ b/vendor/github.com/dave/dst/decorator/decorator-node-generated.go
@@ -0,0 +1,2382 @@
+package decorator
+
+import (
+ "github.com/dave/dst"
+ "go/ast"
+ "go/token"
+)
+
+func (f *fileDecorator) decorateNode(parent ast.Node, parentName, parentField, parentFieldType string, n ast.Node) (dst.Node, error) {
+ if dn, ok := f.Dst.Nodes[n]; ok {
+ return dn, nil
+ }
+ switch n := n.(type) {
+ case *ast.ArrayType:
+ out := &dst.ArrayType{}
+ f.Dst.Nodes[n] = out
+ f.Ast.Nodes[out] = n
+
+ out.Decs.Before = f.before[n]
+ out.Decs.After = f.after[n]
+
+ // Token: Lbrack
+
+ // Node: Len
+ if n.Len != nil {
+ child, err := f.decorateNode(n, "ArrayType", "Len", "Expr", n.Len)
+ if err != nil {
+ return nil, err
+ }
+ out.Len = child.(dst.Expr)
+ }
+
+ // Token: Rbrack
+
+ // Node: Elt
+ if n.Elt != nil {
+ child, err := f.decorateNode(n, "ArrayType", "Elt", "Expr", n.Elt)
+ if err != nil {
+ return nil, err
+ }
+ out.Elt = child.(dst.Expr)
+ }
+
+ if nd, ok := f.decorations[n]; ok {
+ if decs, ok := nd["Start"]; ok {
+ out.Decs.Start = decs
+ }
+ if decs, ok := nd["Lbrack"]; ok {
+ out.Decs.Lbrack = decs
+ }
+ if decs, ok := nd["Len"]; ok {
+ out.Decs.Len = decs
+ }
+ if decs, ok := nd["End"]; ok {
+ out.Decs.End = decs
+ }
+ }
+
+ return out, nil
+ case *ast.AssignStmt:
+ out := &dst.AssignStmt{}
+ f.Dst.Nodes[n] = out
+ f.Ast.Nodes[out] = n
+
+ out.Decs.Before = f.before[n]
+ out.Decs.After = f.after[n]
+
+ // List: Lhs
+ for _, v := range n.Lhs {
+ child, err := f.decorateNode(n, "AssignStmt", "Lhs", "Expr", v)
+ if err != nil {
+ return nil, err
+ }
+ out.Lhs = append(out.Lhs, child.(dst.Expr))
+ }
+
+ // Token: Tok
+ out.Tok = n.Tok
+
+ // List: Rhs
+ for _, v := range n.Rhs {
+ child, err := f.decorateNode(n, "AssignStmt", "Rhs", "Expr", v)
+ if err != nil {
+ return nil, err
+ }
+ out.Rhs = append(out.Rhs, child.(dst.Expr))
+ }
+
+ if nd, ok := f.decorations[n]; ok {
+ if decs, ok := nd["Start"]; ok {
+ out.Decs.Start = decs
+ }
+ if decs, ok := nd["Tok"]; ok {
+ out.Decs.Tok = decs
+ }
+ if decs, ok := nd["End"]; ok {
+ out.Decs.End = decs
+ }
+ }
+
+ return out, nil
+ case *ast.BadDecl:
+ out := &dst.BadDecl{}
+ f.Dst.Nodes[n] = out
+ f.Ast.Nodes[out] = n
+
+ out.Decs.Before = f.before[n]
+ out.Decs.After = f.after[n]
+
+ // Bad
+ out.Length = int(n.To - n.From)
+
+ if nd, ok := f.decorations[n]; ok {
+ if decs, ok := nd["Start"]; ok {
+ out.Decs.Start = decs
+ }
+ if decs, ok := nd["End"]; ok {
+ out.Decs.End = decs
+ }
+ }
+
+ return out, nil
+ case *ast.BadExpr:
+ out := &dst.BadExpr{}
+ f.Dst.Nodes[n] = out
+ f.Ast.Nodes[out] = n
+
+ out.Decs.Before = f.before[n]
+ out.Decs.After = f.after[n]
+
+ // Bad
+ out.Length = int(n.To - n.From)
+
+ if nd, ok := f.decorations[n]; ok {
+ if decs, ok := nd["Start"]; ok {
+ out.Decs.Start = decs
+ }
+ if decs, ok := nd["End"]; ok {
+ out.Decs.End = decs
+ }
+ }
+
+ return out, nil
+ case *ast.BadStmt:
+ out := &dst.BadStmt{}
+ f.Dst.Nodes[n] = out
+ f.Ast.Nodes[out] = n
+
+ out.Decs.Before = f.before[n]
+ out.Decs.After = f.after[n]
+
+ // Bad
+ out.Length = int(n.To - n.From)
+
+ if nd, ok := f.decorations[n]; ok {
+ if decs, ok := nd["Start"]; ok {
+ out.Decs.Start = decs
+ }
+ if decs, ok := nd["End"]; ok {
+ out.Decs.End = decs
+ }
+ }
+
+ return out, nil
+ case *ast.BasicLit:
+ out := &dst.BasicLit{}
+ f.Dst.Nodes[n] = out
+ f.Ast.Nodes[out] = n
+
+ out.Decs.Before = f.before[n]
+ out.Decs.After = f.after[n]
+
+ // String: Value
+ out.Value = n.Value
+
+ // Value: Kind
+ out.Kind = n.Kind
+
+ if nd, ok := f.decorations[n]; ok {
+ if decs, ok := nd["Start"]; ok {
+ out.Decs.Start = decs
+ }
+ if decs, ok := nd["End"]; ok {
+ out.Decs.End = decs
+ }
+ }
+
+ return out, nil
+ case *ast.BinaryExpr:
+ out := &dst.BinaryExpr{}
+ f.Dst.Nodes[n] = out
+ f.Ast.Nodes[out] = n
+
+ out.Decs.Before = f.before[n]
+ out.Decs.After = f.after[n]
+
+ // Node: X
+ if n.X != nil {
+ child, err := f.decorateNode(n, "BinaryExpr", "X", "Expr", n.X)
+ if err != nil {
+ return nil, err
+ }
+ out.X = child.(dst.Expr)
+ }
+
+ // Token: Op
+ out.Op = n.Op
+
+ // Node: Y
+ if n.Y != nil {
+ child, err := f.decorateNode(n, "BinaryExpr", "Y", "Expr", n.Y)
+ if err != nil {
+ return nil, err
+ }
+ out.Y = child.(dst.Expr)
+ }
+
+ if nd, ok := f.decorations[n]; ok {
+ if decs, ok := nd["Start"]; ok {
+ out.Decs.Start = decs
+ }
+ if decs, ok := nd["X"]; ok {
+ out.Decs.X = decs
+ }
+ if decs, ok := nd["Op"]; ok {
+ out.Decs.Op = decs
+ }
+ if decs, ok := nd["End"]; ok {
+ out.Decs.End = decs
+ }
+ }
+
+ return out, nil
+ case *ast.BlockStmt:
+ out := &dst.BlockStmt{}
+ f.Dst.Nodes[n] = out
+ f.Ast.Nodes[out] = n
+
+ out.Decs.Before = f.before[n]
+ out.Decs.After = f.after[n]
+
+ // Token: Lbrace
+
+ // List: List
+ for _, v := range n.List {
+ child, err := f.decorateNode(n, "BlockStmt", "List", "Stmt", v)
+ if err != nil {
+ return nil, err
+ }
+ out.List = append(out.List, child.(dst.Stmt))
+ }
+
+ // Token: Rbrace
+ if n.Rbrace == token.NoPos {
+ out.RbraceHasNoPos = true
+ }
+
+ if nd, ok := f.decorations[n]; ok {
+ if decs, ok := nd["Start"]; ok {
+ out.Decs.Start = decs
+ }
+ if decs, ok := nd["Lbrace"]; ok {
+ out.Decs.Lbrace = decs
+ }
+ if decs, ok := nd["End"]; ok {
+ out.Decs.End = decs
+ }
+ }
+
+ return out, nil
+ case *ast.BranchStmt:
+ out := &dst.BranchStmt{}
+ f.Dst.Nodes[n] = out
+ f.Ast.Nodes[out] = n
+
+ out.Decs.Before = f.before[n]
+ out.Decs.After = f.after[n]
+
+ // Token: Tok
+ out.Tok = n.Tok
+
+ // Node: Label
+ if n.Label != nil {
+ child, err := f.decorateNode(n, "BranchStmt", "Label", "Ident", n.Label)
+ if err != nil {
+ return nil, err
+ }
+ out.Label = child.(*dst.Ident)
+ }
+
+ if nd, ok := f.decorations[n]; ok {
+ if decs, ok := nd["Start"]; ok {
+ out.Decs.Start = decs
+ }
+ if decs, ok := nd["Tok"]; ok {
+ out.Decs.Tok = decs
+ }
+ if decs, ok := nd["End"]; ok {
+ out.Decs.End = decs
+ }
+ }
+
+ return out, nil
+ case *ast.CallExpr:
+ out := &dst.CallExpr{}
+ f.Dst.Nodes[n] = out
+ f.Ast.Nodes[out] = n
+
+ out.Decs.Before = f.before[n]
+ out.Decs.After = f.after[n]
+
+ // Node: Fun
+ if n.Fun != nil {
+ child, err := f.decorateNode(n, "CallExpr", "Fun", "Expr", n.Fun)
+ if err != nil {
+ return nil, err
+ }
+ out.Fun = child.(dst.Expr)
+ }
+
+ // Token: Lparen
+
+ // List: Args
+ for _, v := range n.Args {
+ child, err := f.decorateNode(n, "CallExpr", "Args", "Expr", v)
+ if err != nil {
+ return nil, err
+ }
+ out.Args = append(out.Args, child.(dst.Expr))
+ }
+
+ // Token: Ellipsis
+ out.Ellipsis = n.Ellipsis.IsValid()
+
+ // Token: Rparen
+
+ if nd, ok := f.decorations[n]; ok {
+ if decs, ok := nd["Start"]; ok {
+ out.Decs.Start = decs
+ }
+ if decs, ok := nd["Fun"]; ok {
+ out.Decs.Fun = decs
+ }
+ if decs, ok := nd["Lparen"]; ok {
+ out.Decs.Lparen = decs
+ }
+ if decs, ok := nd["Ellipsis"]; ok {
+ out.Decs.Ellipsis = decs
+ }
+ if decs, ok := nd["End"]; ok {
+ out.Decs.End = decs
+ }
+ }
+
+ return out, nil
+ case *ast.CaseClause:
+ out := &dst.CaseClause{}
+ f.Dst.Nodes[n] = out
+ f.Ast.Nodes[out] = n
+
+ out.Decs.Before = f.before[n]
+ out.Decs.After = f.after[n]
+
+ // Token: Case
+
+ // List: List
+ for _, v := range n.List {
+ child, err := f.decorateNode(n, "CaseClause", "List", "Expr", v)
+ if err != nil {
+ return nil, err
+ }
+ out.List = append(out.List, child.(dst.Expr))
+ }
+
+ // Token: Colon
+
+ // List: Body
+ for _, v := range n.Body {
+ child, err := f.decorateNode(n, "CaseClause", "Body", "Stmt", v)
+ if err != nil {
+ return nil, err
+ }
+ out.Body = append(out.Body, child.(dst.Stmt))
+ }
+
+ if nd, ok := f.decorations[n]; ok {
+ if decs, ok := nd["Start"]; ok {
+ out.Decs.Start = decs
+ }
+ if decs, ok := nd["Case"]; ok {
+ out.Decs.Case = decs
+ }
+ if decs, ok := nd["Colon"]; ok {
+ out.Decs.Colon = decs
+ }
+ if decs, ok := nd["End"]; ok {
+ out.Decs.End = decs
+ }
+ }
+
+ return out, nil
+ case *ast.ChanType:
+ out := &dst.ChanType{}
+ f.Dst.Nodes[n] = out
+ f.Ast.Nodes[out] = n
+
+ out.Decs.Before = f.before[n]
+ out.Decs.After = f.after[n]
+
+ // Token: Begin
+
+ // Token: Chan
+
+ // Token: Arrow
+
+ // Node: Value
+ if n.Value != nil {
+ child, err := f.decorateNode(n, "ChanType", "Value", "Expr", n.Value)
+ if err != nil {
+ return nil, err
+ }
+ out.Value = child.(dst.Expr)
+ }
+
+ // Value: Dir
+ out.Dir = dst.ChanDir(n.Dir)
+
+ if nd, ok := f.decorations[n]; ok {
+ if decs, ok := nd["Start"]; ok {
+ out.Decs.Start = decs
+ }
+ if decs, ok := nd["Begin"]; ok {
+ out.Decs.Begin = decs
+ }
+ if decs, ok := nd["Arrow"]; ok {
+ out.Decs.Arrow = decs
+ }
+ if decs, ok := nd["End"]; ok {
+ out.Decs.End = decs
+ }
+ }
+
+ return out, nil
+ case *ast.CommClause:
+ out := &dst.CommClause{}
+ f.Dst.Nodes[n] = out
+ f.Ast.Nodes[out] = n
+
+ out.Decs.Before = f.before[n]
+ out.Decs.After = f.after[n]
+
+ // Token: Case
+
+ // Node: Comm
+ if n.Comm != nil {
+ child, err := f.decorateNode(n, "CommClause", "Comm", "Stmt", n.Comm)
+ if err != nil {
+ return nil, err
+ }
+ out.Comm = child.(dst.Stmt)
+ }
+
+ // Token: Colon
+
+ // List: Body
+ for _, v := range n.Body {
+ child, err := f.decorateNode(n, "CommClause", "Body", "Stmt", v)
+ if err != nil {
+ return nil, err
+ }
+ out.Body = append(out.Body, child.(dst.Stmt))
+ }
+
+ if nd, ok := f.decorations[n]; ok {
+ if decs, ok := nd["Start"]; ok {
+ out.Decs.Start = decs
+ }
+ if decs, ok := nd["Case"]; ok {
+ out.Decs.Case = decs
+ }
+ if decs, ok := nd["Comm"]; ok {
+ out.Decs.Comm = decs
+ }
+ if decs, ok := nd["Colon"]; ok {
+ out.Decs.Colon = decs
+ }
+ if decs, ok := nd["End"]; ok {
+ out.Decs.End = decs
+ }
+ }
+
+ return out, nil
+ case *ast.CompositeLit:
+ out := &dst.CompositeLit{}
+ f.Dst.Nodes[n] = out
+ f.Ast.Nodes[out] = n
+
+ out.Decs.Before = f.before[n]
+ out.Decs.After = f.after[n]
+
+ // Node: Type
+ if n.Type != nil {
+ child, err := f.decorateNode(n, "CompositeLit", "Type", "Expr", n.Type)
+ if err != nil {
+ return nil, err
+ }
+ out.Type = child.(dst.Expr)
+ }
+
+ // Token: Lbrace
+
+ // List: Elts
+ for _, v := range n.Elts {
+ child, err := f.decorateNode(n, "CompositeLit", "Elts", "Expr", v)
+ if err != nil {
+ return nil, err
+ }
+ out.Elts = append(out.Elts, child.(dst.Expr))
+ }
+
+ // Token: Rbrace
+
+ // Value: Incomplete
+ out.Incomplete = n.Incomplete
+
+ if nd, ok := f.decorations[n]; ok {
+ if decs, ok := nd["Start"]; ok {
+ out.Decs.Start = decs
+ }
+ if decs, ok := nd["Type"]; ok {
+ out.Decs.Type = decs
+ }
+ if decs, ok := nd["Lbrace"]; ok {
+ out.Decs.Lbrace = decs
+ }
+ if decs, ok := nd["End"]; ok {
+ out.Decs.End = decs
+ }
+ }
+
+ return out, nil
+ case *ast.DeclStmt:
+ out := &dst.DeclStmt{}
+ f.Dst.Nodes[n] = out
+ f.Ast.Nodes[out] = n
+
+ out.Decs.Before = f.before[n]
+ out.Decs.After = f.after[n]
+
+ // Node: Decl
+ if n.Decl != nil {
+ child, err := f.decorateNode(n, "DeclStmt", "Decl", "Decl", n.Decl)
+ if err != nil {
+ return nil, err
+ }
+ out.Decl = child.(dst.Decl)
+ }
+
+ if nd, ok := f.decorations[n]; ok {
+ if decs, ok := nd["Start"]; ok {
+ out.Decs.Start = decs
+ }
+ if decs, ok := nd["End"]; ok {
+ out.Decs.End = decs
+ }
+ }
+
+ return out, nil
+ case *ast.DeferStmt:
+ out := &dst.DeferStmt{}
+ f.Dst.Nodes[n] = out
+ f.Ast.Nodes[out] = n
+
+ out.Decs.Before = f.before[n]
+ out.Decs.After = f.after[n]
+
+ // Token: Defer
+
+ // Node: Call
+ if n.Call != nil {
+ child, err := f.decorateNode(n, "DeferStmt", "Call", "CallExpr", n.Call)
+ if err != nil {
+ return nil, err
+ }
+ out.Call = child.(*dst.CallExpr)
+ }
+
+ if nd, ok := f.decorations[n]; ok {
+ if decs, ok := nd["Start"]; ok {
+ out.Decs.Start = decs
+ }
+ if decs, ok := nd["Defer"]; ok {
+ out.Decs.Defer = decs
+ }
+ if decs, ok := nd["End"]; ok {
+ out.Decs.End = decs
+ }
+ }
+
+ return out, nil
+ case *ast.Ellipsis:
+ out := &dst.Ellipsis{}
+ f.Dst.Nodes[n] = out
+ f.Ast.Nodes[out] = n
+
+ out.Decs.Before = f.before[n]
+ out.Decs.After = f.after[n]
+
+ // Token: Ellipsis
+
+ // Node: Elt
+ if n.Elt != nil {
+ child, err := f.decorateNode(n, "Ellipsis", "Elt", "Expr", n.Elt)
+ if err != nil {
+ return nil, err
+ }
+ out.Elt = child.(dst.Expr)
+ }
+
+ if nd, ok := f.decorations[n]; ok {
+ if decs, ok := nd["Start"]; ok {
+ out.Decs.Start = decs
+ }
+ if decs, ok := nd["Ellipsis"]; ok {
+ out.Decs.Ellipsis = decs
+ }
+ if decs, ok := nd["End"]; ok {
+ out.Decs.End = decs
+ }
+ }
+
+ return out, nil
+ case *ast.EmptyStmt:
+ out := &dst.EmptyStmt{}
+ f.Dst.Nodes[n] = out
+ f.Ast.Nodes[out] = n
+
+ out.Decs.Before = f.before[n]
+ out.Decs.After = f.after[n]
+
+ // Token: Semicolon
+
+ // Value: Implicit
+ out.Implicit = n.Implicit
+
+ if nd, ok := f.decorations[n]; ok {
+ if decs, ok := nd["Start"]; ok {
+ out.Decs.Start = decs
+ }
+ if decs, ok := nd["End"]; ok {
+ out.Decs.End = decs
+ }
+ }
+
+ return out, nil
+ case *ast.ExprStmt:
+ out := &dst.ExprStmt{}
+ f.Dst.Nodes[n] = out
+ f.Ast.Nodes[out] = n
+
+ out.Decs.Before = f.before[n]
+ out.Decs.After = f.after[n]
+
+ // Node: X
+ if n.X != nil {
+ child, err := f.decorateNode(n, "ExprStmt", "X", "Expr", n.X)
+ if err != nil {
+ return nil, err
+ }
+ out.X = child.(dst.Expr)
+ }
+
+ if nd, ok := f.decorations[n]; ok {
+ if decs, ok := nd["Start"]; ok {
+ out.Decs.Start = decs
+ }
+ if decs, ok := nd["End"]; ok {
+ out.Decs.End = decs
+ }
+ }
+
+ return out, nil
+ case *ast.Field:
+ out := &dst.Field{}
+ f.Dst.Nodes[n] = out
+ f.Ast.Nodes[out] = n
+
+ out.Decs.Before = f.before[n]
+ out.Decs.After = f.after[n]
+
+ // List: Names
+ for _, v := range n.Names {
+ child, err := f.decorateNode(n, "Field", "Names", "Ident", v)
+ if err != nil {
+ return nil, err
+ }
+ out.Names = append(out.Names, child.(*dst.Ident))
+ }
+
+ // Node: Type
+ if n.Type != nil {
+ child, err := f.decorateNode(n, "Field", "Type", "Expr", n.Type)
+ if err != nil {
+ return nil, err
+ }
+ out.Type = child.(dst.Expr)
+ }
+
+ // Node: Tag
+ if n.Tag != nil {
+ child, err := f.decorateNode(n, "Field", "Tag", "BasicLit", n.Tag)
+ if err != nil {
+ return nil, err
+ }
+ out.Tag = child.(*dst.BasicLit)
+ }
+
+ if nd, ok := f.decorations[n]; ok {
+ if decs, ok := nd["Start"]; ok {
+ out.Decs.Start = decs
+ }
+ if decs, ok := nd["Type"]; ok {
+ out.Decs.Type = decs
+ }
+ if decs, ok := nd["End"]; ok {
+ out.Decs.End = decs
+ }
+ }
+
+ return out, nil
+ case *ast.FieldList:
+ out := &dst.FieldList{}
+ f.Dst.Nodes[n] = out
+ f.Ast.Nodes[out] = n
+
+ out.Decs.Before = f.before[n]
+ out.Decs.After = f.after[n]
+
+ // Token: Opening
+ out.Opening = n.Opening.IsValid()
+
+ // List: List
+ for _, v := range n.List {
+ child, err := f.decorateNode(n, "FieldList", "List", "Field", v)
+ if err != nil {
+ return nil, err
+ }
+ out.List = append(out.List, child.(*dst.Field))
+ }
+
+ // Token: Closing
+ out.Closing = n.Closing.IsValid()
+
+ if nd, ok := f.decorations[n]; ok {
+ if decs, ok := nd["Start"]; ok {
+ out.Decs.Start = decs
+ }
+ if decs, ok := nd["Opening"]; ok {
+ out.Decs.Opening = decs
+ }
+ if decs, ok := nd["End"]; ok {
+ out.Decs.End = decs
+ }
+ }
+
+ return out, nil
+ case *ast.File:
+ out := &dst.File{}
+ f.Dst.Nodes[n] = out
+ f.Ast.Nodes[out] = n
+
+ out.Decs.Before = f.before[n]
+ out.Decs.After = f.after[n]
+
+ // Token: Package
+
+ // Node: Name
+ if n.Name != nil {
+ child, err := f.decorateNode(n, "File", "Name", "Ident", n.Name)
+ if err != nil {
+ return nil, err
+ }
+ out.Name = child.(*dst.Ident)
+ }
+
+ // List: Decls
+ for _, v := range n.Decls {
+ child, err := f.decorateNode(n, "File", "Decls", "Decl", v)
+ if err != nil {
+ return nil, err
+ }
+ out.Decls = append(out.Decls, child.(dst.Decl))
+ }
+
+ // Scope: Scope
+ scope, err := f.decorateScope(n.Scope)
+ if err != nil {
+ return nil, err
+ }
+ out.Scope = scope
+
+ // List: Imports
+ for _, v := range n.Imports {
+ child, err := f.decorateNode(n, "File", "Imports", "ImportSpec", v)
+ if err != nil {
+ return nil, err
+ }
+ out.Imports = append(out.Imports, child.(*dst.ImportSpec))
+ }
+
+ // Value: GoVersion
+ out.GoVersion = n.GoVersion
+
+ if nd, ok := f.decorations[n]; ok {
+ if decs, ok := nd["Start"]; ok {
+ out.Decs.Start = decs
+ }
+ if decs, ok := nd["Package"]; ok {
+ out.Decs.Package = decs
+ }
+ if decs, ok := nd["Name"]; ok {
+ out.Decs.Name = decs
+ }
+ if decs, ok := nd["End"]; ok {
+ out.Decs.End = decs
+ }
+ }
+
+ return out, nil
+ case *ast.ForStmt:
+ out := &dst.ForStmt{}
+ f.Dst.Nodes[n] = out
+ f.Ast.Nodes[out] = n
+
+ out.Decs.Before = f.before[n]
+ out.Decs.After = f.after[n]
+
+ // Token: For
+
+ // Node: Init
+ if n.Init != nil {
+ child, err := f.decorateNode(n, "ForStmt", "Init", "Stmt", n.Init)
+ if err != nil {
+ return nil, err
+ }
+ out.Init = child.(dst.Stmt)
+ }
+
+ // Token: InitSemicolon
+
+ // Node: Cond
+ if n.Cond != nil {
+ child, err := f.decorateNode(n, "ForStmt", "Cond", "Expr", n.Cond)
+ if err != nil {
+ return nil, err
+ }
+ out.Cond = child.(dst.Expr)
+ }
+
+ // Token: CondSemicolon
+
+ // Node: Post
+ if n.Post != nil {
+ child, err := f.decorateNode(n, "ForStmt", "Post", "Stmt", n.Post)
+ if err != nil {
+ return nil, err
+ }
+ out.Post = child.(dst.Stmt)
+ }
+
+ // Node: Body
+ if n.Body != nil {
+ child, err := f.decorateNode(n, "ForStmt", "Body", "BlockStmt", n.Body)
+ if err != nil {
+ return nil, err
+ }
+ out.Body = child.(*dst.BlockStmt)
+ }
+
+ if nd, ok := f.decorations[n]; ok {
+ if decs, ok := nd["Start"]; ok {
+ out.Decs.Start = decs
+ }
+ if decs, ok := nd["For"]; ok {
+ out.Decs.For = decs
+ }
+ if decs, ok := nd["Init"]; ok {
+ out.Decs.Init = decs
+ }
+ if decs, ok := nd["Cond"]; ok {
+ out.Decs.Cond = decs
+ }
+ if decs, ok := nd["Post"]; ok {
+ out.Decs.Post = decs
+ }
+ if decs, ok := nd["End"]; ok {
+ out.Decs.End = decs
+ }
+ }
+
+ return out, nil
+ case *ast.FuncDecl:
+ out := &dst.FuncDecl{}
+ f.Dst.Nodes[n] = out
+ f.Ast.Nodes[out] = n
+
+ out.Decs.Before = f.before[n]
+ out.Decs.After = f.after[n]
+
+ // Init: Type
+ out.Type = &dst.FuncType{}
+ f.Dst.Nodes[n.Type] = out.Type
+ f.Ast.Nodes[out.Type] = n.Type
+
+ // Token: Func
+ out.Type.Func = true
+
+ // Node: Recv
+ if n.Recv != nil {
+ child, err := f.decorateNode(n, "FuncDecl", "Recv", "FieldList", n.Recv)
+ if err != nil {
+ return nil, err
+ }
+ out.Recv = child.(*dst.FieldList)
+ }
+
+ // Node: Name
+ if n.Name != nil {
+ child, err := f.decorateNode(n, "FuncDecl", "Name", "Ident", n.Name)
+ if err != nil {
+ return nil, err
+ }
+ out.Name = child.(*dst.Ident)
+ }
+
+ // Node: TypeParams
+ if n.Type.TypeParams != nil {
+ child, err := f.decorateNode(n, "FuncDecl", "TypeParams", "FieldList", n.Type.TypeParams)
+ if err != nil {
+ return nil, err
+ }
+ out.Type.TypeParams = child.(*dst.FieldList)
+ }
+
+ // Node: Params
+ if n.Type.Params != nil {
+ child, err := f.decorateNode(n, "FuncDecl", "Params", "FieldList", n.Type.Params)
+ if err != nil {
+ return nil, err
+ }
+ out.Type.Params = child.(*dst.FieldList)
+ }
+
+ // Node: Results
+ if n.Type.Results != nil {
+ child, err := f.decorateNode(n, "FuncDecl", "Results", "FieldList", n.Type.Results)
+ if err != nil {
+ return nil, err
+ }
+ out.Type.Results = child.(*dst.FieldList)
+ }
+
+ // Node: Body
+ if n.Body != nil {
+ child, err := f.decorateNode(n, "FuncDecl", "Body", "BlockStmt", n.Body)
+ if err != nil {
+ return nil, err
+ }
+ out.Body = child.(*dst.BlockStmt)
+ }
+
+ if nd, ok := f.decorations[n]; ok {
+ if decs, ok := nd["Start"]; ok {
+ out.Decs.Start = decs
+ }
+ if decs, ok := nd["Func"]; ok {
+ out.Decs.Func = decs
+ }
+ if decs, ok := nd["Recv"]; ok {
+ out.Decs.Recv = decs
+ }
+ if decs, ok := nd["Name"]; ok {
+ out.Decs.Name = decs
+ }
+ if decs, ok := nd["TypeParams"]; ok {
+ out.Decs.TypeParams = decs
+ }
+ if decs, ok := nd["Params"]; ok {
+ out.Decs.Params = decs
+ }
+ if decs, ok := nd["Results"]; ok {
+ out.Decs.Results = decs
+ }
+ if decs, ok := nd["End"]; ok {
+ out.Decs.End = decs
+ }
+ }
+
+ return out, nil
+ case *ast.FuncLit:
+ out := &dst.FuncLit{}
+ f.Dst.Nodes[n] = out
+ f.Ast.Nodes[out] = n
+
+ out.Decs.Before = f.before[n]
+ out.Decs.After = f.after[n]
+
+ // Node: Type
+ if n.Type != nil {
+ child, err := f.decorateNode(n, "FuncLit", "Type", "FuncType", n.Type)
+ if err != nil {
+ return nil, err
+ }
+ out.Type = child.(*dst.FuncType)
+ }
+
+ // Node: Body
+ if n.Body != nil {
+ child, err := f.decorateNode(n, "FuncLit", "Body", "BlockStmt", n.Body)
+ if err != nil {
+ return nil, err
+ }
+ out.Body = child.(*dst.BlockStmt)
+ }
+
+ if nd, ok := f.decorations[n]; ok {
+ if decs, ok := nd["Start"]; ok {
+ out.Decs.Start = decs
+ }
+ if decs, ok := nd["Type"]; ok {
+ out.Decs.Type = decs
+ }
+ if decs, ok := nd["End"]; ok {
+ out.Decs.End = decs
+ }
+ }
+
+ return out, nil
+ case *ast.FuncType:
+ out := &dst.FuncType{}
+ f.Dst.Nodes[n] = out
+ f.Ast.Nodes[out] = n
+
+ out.Decs.Before = f.before[n]
+ out.Decs.After = f.after[n]
+
+ // Token: Func
+ out.Func = n.Func.IsValid()
+
+ // Node: TypeParams
+ if n.TypeParams != nil {
+ child, err := f.decorateNode(n, "FuncType", "TypeParams", "FieldList", n.TypeParams)
+ if err != nil {
+ return nil, err
+ }
+ out.TypeParams = child.(*dst.FieldList)
+ }
+
+ // Node: Params
+ if n.Params != nil {
+ child, err := f.decorateNode(n, "FuncType", "Params", "FieldList", n.Params)
+ if err != nil {
+ return nil, err
+ }
+ out.Params = child.(*dst.FieldList)
+ }
+
+ // Node: Results
+ if n.Results != nil {
+ child, err := f.decorateNode(n, "FuncType", "Results", "FieldList", n.Results)
+ if err != nil {
+ return nil, err
+ }
+ out.Results = child.(*dst.FieldList)
+ }
+
+ if nd, ok := f.decorations[n]; ok {
+ if decs, ok := nd["Start"]; ok {
+ out.Decs.Start = decs
+ }
+ if decs, ok := nd["Func"]; ok {
+ out.Decs.Func = decs
+ }
+ if decs, ok := nd["TypeParams"]; ok {
+ out.Decs.TypeParams = decs
+ }
+ if decs, ok := nd["Params"]; ok {
+ out.Decs.Params = decs
+ }
+ if decs, ok := nd["End"]; ok {
+ out.Decs.End = decs
+ }
+ }
+
+ return out, nil
+ case *ast.GenDecl:
+ out := &dst.GenDecl{}
+ f.Dst.Nodes[n] = out
+ f.Ast.Nodes[out] = n
+
+ out.Decs.Before = f.before[n]
+ out.Decs.After = f.after[n]
+
+ // Token: Tok
+ out.Tok = n.Tok
+
+ // Token: Lparen
+ out.Lparen = n.Lparen.IsValid()
+
+ // List: Specs
+ for _, v := range n.Specs {
+ child, err := f.decorateNode(n, "GenDecl", "Specs", "Spec", v)
+ if err != nil {
+ return nil, err
+ }
+ out.Specs = append(out.Specs, child.(dst.Spec))
+ }
+
+ // Token: Rparen
+ out.Rparen = n.Rparen.IsValid()
+
+ if nd, ok := f.decorations[n]; ok {
+ if decs, ok := nd["Start"]; ok {
+ out.Decs.Start = decs
+ }
+ if decs, ok := nd["Tok"]; ok {
+ out.Decs.Tok = decs
+ }
+ if decs, ok := nd["Lparen"]; ok {
+ out.Decs.Lparen = decs
+ }
+ if decs, ok := nd["End"]; ok {
+ out.Decs.End = decs
+ }
+ }
+
+ return out, nil
+ case *ast.GoStmt:
+ out := &dst.GoStmt{}
+ f.Dst.Nodes[n] = out
+ f.Ast.Nodes[out] = n
+
+ out.Decs.Before = f.before[n]
+ out.Decs.After = f.after[n]
+
+ // Token: Go
+
+ // Node: Call
+ if n.Call != nil {
+ child, err := f.decorateNode(n, "GoStmt", "Call", "CallExpr", n.Call)
+ if err != nil {
+ return nil, err
+ }
+ out.Call = child.(*dst.CallExpr)
+ }
+
+ if nd, ok := f.decorations[n]; ok {
+ if decs, ok := nd["Start"]; ok {
+ out.Decs.Start = decs
+ }
+ if decs, ok := nd["Go"]; ok {
+ out.Decs.Go = decs
+ }
+ if decs, ok := nd["End"]; ok {
+ out.Decs.End = decs
+ }
+ }
+
+ return out, nil
+ case *ast.Ident:
+ out := &dst.Ident{}
+ f.Dst.Nodes[n] = out
+ f.Ast.Nodes[out] = n
+
+ out.Decs.Before = f.before[n]
+ out.Decs.After = f.after[n]
+
+ // String: Name
+ out.Name = n.Name
+
+ // Object: Obj
+ ob, err := f.decorateObject(n.Obj)
+ if err != nil {
+ return nil, err
+ }
+ out.Obj = ob
+
+ // Path: Path
+ if f.Resolver != nil {
+ path, err := f.resolvePath(false, parent, parentName, parentField, parentFieldType, n)
+ if err != nil {
+ return nil, err
+ }
+ out.Path = path
+ }
+
+ if nd, ok := f.decorations[n]; ok {
+ if decs, ok := nd["Start"]; ok {
+ out.Decs.Start = decs
+ }
+ if decs, ok := nd["X"]; ok {
+ out.Decs.X = decs
+ }
+ if decs, ok := nd["End"]; ok {
+ out.Decs.End = decs
+ }
+ }
+
+ return out, nil
+ case *ast.IfStmt:
+ out := &dst.IfStmt{}
+ f.Dst.Nodes[n] = out
+ f.Ast.Nodes[out] = n
+
+ out.Decs.Before = f.before[n]
+ out.Decs.After = f.after[n]
+
+ // Token: If
+
+ // Node: Init
+ if n.Init != nil {
+ child, err := f.decorateNode(n, "IfStmt", "Init", "Stmt", n.Init)
+ if err != nil {
+ return nil, err
+ }
+ out.Init = child.(dst.Stmt)
+ }
+
+ // Node: Cond
+ if n.Cond != nil {
+ child, err := f.decorateNode(n, "IfStmt", "Cond", "Expr", n.Cond)
+ if err != nil {
+ return nil, err
+ }
+ out.Cond = child.(dst.Expr)
+ }
+
+ // Node: Body
+ if n.Body != nil {
+ child, err := f.decorateNode(n, "IfStmt", "Body", "BlockStmt", n.Body)
+ if err != nil {
+ return nil, err
+ }
+ out.Body = child.(*dst.BlockStmt)
+ }
+
+ // Token: ElseTok
+
+ // Node: Else
+ if n.Else != nil {
+ child, err := f.decorateNode(n, "IfStmt", "Else", "Stmt", n.Else)
+ if err != nil {
+ return nil, err
+ }
+ out.Else = child.(dst.Stmt)
+ }
+
+ if nd, ok := f.decorations[n]; ok {
+ if decs, ok := nd["Start"]; ok {
+ out.Decs.Start = decs
+ }
+ if decs, ok := nd["If"]; ok {
+ out.Decs.If = decs
+ }
+ if decs, ok := nd["Init"]; ok {
+ out.Decs.Init = decs
+ }
+ if decs, ok := nd["Cond"]; ok {
+ out.Decs.Cond = decs
+ }
+ if decs, ok := nd["Else"]; ok {
+ out.Decs.Else = decs
+ }
+ if decs, ok := nd["End"]; ok {
+ out.Decs.End = decs
+ }
+ }
+
+ return out, nil
+ case *ast.ImportSpec:
+ out := &dst.ImportSpec{}
+ f.Dst.Nodes[n] = out
+ f.Ast.Nodes[out] = n
+
+ out.Decs.Before = f.before[n]
+ out.Decs.After = f.after[n]
+
+ // Node: Name
+ if n.Name != nil {
+ child, err := f.decorateNode(n, "ImportSpec", "Name", "Ident", n.Name)
+ if err != nil {
+ return nil, err
+ }
+ out.Name = child.(*dst.Ident)
+ }
+
+ // Node: Path
+ if n.Path != nil {
+ child, err := f.decorateNode(n, "ImportSpec", "Path", "BasicLit", n.Path)
+ if err != nil {
+ return nil, err
+ }
+ out.Path = child.(*dst.BasicLit)
+ }
+
+ if nd, ok := f.decorations[n]; ok {
+ if decs, ok := nd["Start"]; ok {
+ out.Decs.Start = decs
+ }
+ if decs, ok := nd["Name"]; ok {
+ out.Decs.Name = decs
+ }
+ if decs, ok := nd["End"]; ok {
+ out.Decs.End = decs
+ }
+ }
+
+ return out, nil
+ case *ast.IncDecStmt:
+ out := &dst.IncDecStmt{}
+ f.Dst.Nodes[n] = out
+ f.Ast.Nodes[out] = n
+
+ out.Decs.Before = f.before[n]
+ out.Decs.After = f.after[n]
+
+ // Node: X
+ if n.X != nil {
+ child, err := f.decorateNode(n, "IncDecStmt", "X", "Expr", n.X)
+ if err != nil {
+ return nil, err
+ }
+ out.X = child.(dst.Expr)
+ }
+
+ // Token: Tok
+ out.Tok = n.Tok
+
+ if nd, ok := f.decorations[n]; ok {
+ if decs, ok := nd["Start"]; ok {
+ out.Decs.Start = decs
+ }
+ if decs, ok := nd["X"]; ok {
+ out.Decs.X = decs
+ }
+ if decs, ok := nd["End"]; ok {
+ out.Decs.End = decs
+ }
+ }
+
+ return out, nil
+ case *ast.IndexExpr:
+ out := &dst.IndexExpr{}
+ f.Dst.Nodes[n] = out
+ f.Ast.Nodes[out] = n
+
+ out.Decs.Before = f.before[n]
+ out.Decs.After = f.after[n]
+
+ // Node: X
+ if n.X != nil {
+ child, err := f.decorateNode(n, "IndexExpr", "X", "Expr", n.X)
+ if err != nil {
+ return nil, err
+ }
+ out.X = child.(dst.Expr)
+ }
+
+ // Token: Lbrack
+
+ // Node: Index
+ if n.Index != nil {
+ child, err := f.decorateNode(n, "IndexExpr", "Index", "Expr", n.Index)
+ if err != nil {
+ return nil, err
+ }
+ out.Index = child.(dst.Expr)
+ }
+
+ // Token: Rbrack
+
+ if nd, ok := f.decorations[n]; ok {
+ if decs, ok := nd["Start"]; ok {
+ out.Decs.Start = decs
+ }
+ if decs, ok := nd["X"]; ok {
+ out.Decs.X = decs
+ }
+ if decs, ok := nd["Lbrack"]; ok {
+ out.Decs.Lbrack = decs
+ }
+ if decs, ok := nd["Index"]; ok {
+ out.Decs.Index = decs
+ }
+ if decs, ok := nd["End"]; ok {
+ out.Decs.End = decs
+ }
+ }
+
+ return out, nil
+ case *ast.IndexListExpr:
+ out := &dst.IndexListExpr{}
+ f.Dst.Nodes[n] = out
+ f.Ast.Nodes[out] = n
+
+ out.Decs.Before = f.before[n]
+ out.Decs.After = f.after[n]
+
+ // Node: X
+ if n.X != nil {
+ child, err := f.decorateNode(n, "IndexListExpr", "X", "Expr", n.X)
+ if err != nil {
+ return nil, err
+ }
+ out.X = child.(dst.Expr)
+ }
+
+ // Token: Lbrack
+
+ // List: Indices
+ for _, v := range n.Indices {
+ child, err := f.decorateNode(n, "IndexListExpr", "Indices", "Expr", v)
+ if err != nil {
+ return nil, err
+ }
+ out.Indices = append(out.Indices, child.(dst.Expr))
+ }
+
+ // Token: Rbrack
+
+ if nd, ok := f.decorations[n]; ok {
+ if decs, ok := nd["Start"]; ok {
+ out.Decs.Start = decs
+ }
+ if decs, ok := nd["X"]; ok {
+ out.Decs.X = decs
+ }
+ if decs, ok := nd["Lbrack"]; ok {
+ out.Decs.Lbrack = decs
+ }
+ if decs, ok := nd["Indices"]; ok {
+ out.Decs.Indices = decs
+ }
+ if decs, ok := nd["End"]; ok {
+ out.Decs.End = decs
+ }
+ }
+
+ return out, nil
+ case *ast.InterfaceType:
+ out := &dst.InterfaceType{}
+ f.Dst.Nodes[n] = out
+ f.Ast.Nodes[out] = n
+
+ out.Decs.Before = f.before[n]
+ out.Decs.After = f.after[n]
+
+ // Token: Interface
+
+ // Node: Methods
+ if n.Methods != nil {
+ child, err := f.decorateNode(n, "InterfaceType", "Methods", "FieldList", n.Methods)
+ if err != nil {
+ return nil, err
+ }
+ out.Methods = child.(*dst.FieldList)
+ }
+
+ // Value: Incomplete
+ out.Incomplete = n.Incomplete
+
+ if nd, ok := f.decorations[n]; ok {
+ if decs, ok := nd["Start"]; ok {
+ out.Decs.Start = decs
+ }
+ if decs, ok := nd["Interface"]; ok {
+ out.Decs.Interface = decs
+ }
+ if decs, ok := nd["End"]; ok {
+ out.Decs.End = decs
+ }
+ }
+
+ return out, nil
+ case *ast.KeyValueExpr:
+ out := &dst.KeyValueExpr{}
+ f.Dst.Nodes[n] = out
+ f.Ast.Nodes[out] = n
+
+ out.Decs.Before = f.before[n]
+ out.Decs.After = f.after[n]
+
+ // Node: Key
+ if n.Key != nil {
+ child, err := f.decorateNode(n, "KeyValueExpr", "Key", "Expr", n.Key)
+ if err != nil {
+ return nil, err
+ }
+ out.Key = child.(dst.Expr)
+ }
+
+ // Token: Colon
+
+ // Node: Value
+ if n.Value != nil {
+ child, err := f.decorateNode(n, "KeyValueExpr", "Value", "Expr", n.Value)
+ if err != nil {
+ return nil, err
+ }
+ out.Value = child.(dst.Expr)
+ }
+
+ if nd, ok := f.decorations[n]; ok {
+ if decs, ok := nd["Start"]; ok {
+ out.Decs.Start = decs
+ }
+ if decs, ok := nd["Key"]; ok {
+ out.Decs.Key = decs
+ }
+ if decs, ok := nd["Colon"]; ok {
+ out.Decs.Colon = decs
+ }
+ if decs, ok := nd["End"]; ok {
+ out.Decs.End = decs
+ }
+ }
+
+ return out, nil
+ case *ast.LabeledStmt:
+ out := &dst.LabeledStmt{}
+ f.Dst.Nodes[n] = out
+ f.Ast.Nodes[out] = n
+
+ out.Decs.Before = f.before[n]
+ out.Decs.After = f.after[n]
+
+ // Node: Label
+ if n.Label != nil {
+ child, err := f.decorateNode(n, "LabeledStmt", "Label", "Ident", n.Label)
+ if err != nil {
+ return nil, err
+ }
+ out.Label = child.(*dst.Ident)
+ }
+
+ // Token: Colon
+
+ // Node: Stmt
+ if n.Stmt != nil {
+ child, err := f.decorateNode(n, "LabeledStmt", "Stmt", "Stmt", n.Stmt)
+ if err != nil {
+ return nil, err
+ }
+ out.Stmt = child.(dst.Stmt)
+ }
+
+ if nd, ok := f.decorations[n]; ok {
+ if decs, ok := nd["Start"]; ok {
+ out.Decs.Start = decs
+ }
+ if decs, ok := nd["Label"]; ok {
+ out.Decs.Label = decs
+ }
+ if decs, ok := nd["Colon"]; ok {
+ out.Decs.Colon = decs
+ }
+ if decs, ok := nd["End"]; ok {
+ out.Decs.End = decs
+ }
+ }
+
+ return out, nil
+ case *ast.MapType:
+ out := &dst.MapType{}
+ f.Dst.Nodes[n] = out
+ f.Ast.Nodes[out] = n
+
+ out.Decs.Before = f.before[n]
+ out.Decs.After = f.after[n]
+
+ // Token: Map
+
+ // Token: Lbrack
+
+ // Node: Key
+ if n.Key != nil {
+ child, err := f.decorateNode(n, "MapType", "Key", "Expr", n.Key)
+ if err != nil {
+ return nil, err
+ }
+ out.Key = child.(dst.Expr)
+ }
+
+ // Token: Rbrack
+
+ // Node: Value
+ if n.Value != nil {
+ child, err := f.decorateNode(n, "MapType", "Value", "Expr", n.Value)
+ if err != nil {
+ return nil, err
+ }
+ out.Value = child.(dst.Expr)
+ }
+
+ if nd, ok := f.decorations[n]; ok {
+ if decs, ok := nd["Start"]; ok {
+ out.Decs.Start = decs
+ }
+ if decs, ok := nd["Map"]; ok {
+ out.Decs.Map = decs
+ }
+ if decs, ok := nd["Key"]; ok {
+ out.Decs.Key = decs
+ }
+ if decs, ok := nd["End"]; ok {
+ out.Decs.End = decs
+ }
+ }
+
+ return out, nil
+ case *ast.Package:
+ out := &dst.Package{}
+ f.Dst.Nodes[n] = out
+ f.Ast.Nodes[out] = n
+
+ // Value: Name
+ out.Name = n.Name
+
+ // Scope: Scope
+ scope, err := f.decorateScope(n.Scope)
+ if err != nil {
+ return nil, err
+ }
+ out.Scope = scope
+
+ // Map: Imports
+ out.Imports = map[string]*dst.Object{}
+ for k, v := range n.Imports {
+ ob, err := f.decorateObject(v)
+ if err != nil {
+ return nil, err
+ }
+ out.Imports[k] = ob
+ }
+
+ // Map: Files
+ out.Files = map[string]*dst.File{}
+ for k, v := range n.Files {
+ child, err := f.decorateNode(n, "Package", "Files", "File", v)
+ if err != nil {
+ return nil, err
+ }
+ out.Files[k] = child.(*dst.File)
+ }
+
+ return out, nil
+ case *ast.ParenExpr:
+ out := &dst.ParenExpr{}
+ f.Dst.Nodes[n] = out
+ f.Ast.Nodes[out] = n
+
+ out.Decs.Before = f.before[n]
+ out.Decs.After = f.after[n]
+
+ // Token: Lparen
+
+ // Node: X
+ if n.X != nil {
+ child, err := f.decorateNode(n, "ParenExpr", "X", "Expr", n.X)
+ if err != nil {
+ return nil, err
+ }
+ out.X = child.(dst.Expr)
+ }
+
+ // Token: Rparen
+
+ if nd, ok := f.decorations[n]; ok {
+ if decs, ok := nd["Start"]; ok {
+ out.Decs.Start = decs
+ }
+ if decs, ok := nd["Lparen"]; ok {
+ out.Decs.Lparen = decs
+ }
+ if decs, ok := nd["X"]; ok {
+ out.Decs.X = decs
+ }
+ if decs, ok := nd["End"]; ok {
+ out.Decs.End = decs
+ }
+ }
+
+ return out, nil
+ case *ast.RangeStmt:
+ out := &dst.RangeStmt{}
+ f.Dst.Nodes[n] = out
+ f.Ast.Nodes[out] = n
+
+ out.Decs.Before = f.before[n]
+ out.Decs.After = f.after[n]
+
+ // Token: For
+
+ // Node: Key
+ if n.Key != nil {
+ child, err := f.decorateNode(n, "RangeStmt", "Key", "Expr", n.Key)
+ if err != nil {
+ return nil, err
+ }
+ out.Key = child.(dst.Expr)
+ }
+
+ // Token: Comma
+
+ // Node: Value
+ if n.Value != nil {
+ child, err := f.decorateNode(n, "RangeStmt", "Value", "Expr", n.Value)
+ if err != nil {
+ return nil, err
+ }
+ out.Value = child.(dst.Expr)
+ }
+
+ // Token: Tok
+ out.Tok = n.Tok
+
+ // Token: Range
+
+ // Node: X
+ if n.X != nil {
+ child, err := f.decorateNode(n, "RangeStmt", "X", "Expr", n.X)
+ if err != nil {
+ return nil, err
+ }
+ out.X = child.(dst.Expr)
+ }
+
+ // Node: Body
+ if n.Body != nil {
+ child, err := f.decorateNode(n, "RangeStmt", "Body", "BlockStmt", n.Body)
+ if err != nil {
+ return nil, err
+ }
+ out.Body = child.(*dst.BlockStmt)
+ }
+
+ if nd, ok := f.decorations[n]; ok {
+ if decs, ok := nd["Start"]; ok {
+ out.Decs.Start = decs
+ }
+ if decs, ok := nd["For"]; ok {
+ out.Decs.For = decs
+ }
+ if decs, ok := nd["Key"]; ok {
+ out.Decs.Key = decs
+ }
+ if decs, ok := nd["Value"]; ok {
+ out.Decs.Value = decs
+ }
+ if decs, ok := nd["Range"]; ok {
+ out.Decs.Range = decs
+ }
+ if decs, ok := nd["X"]; ok {
+ out.Decs.X = decs
+ }
+ if decs, ok := nd["End"]; ok {
+ out.Decs.End = decs
+ }
+ }
+
+ return out, nil
+ case *ast.ReturnStmt:
+ out := &dst.ReturnStmt{}
+ f.Dst.Nodes[n] = out
+ f.Ast.Nodes[out] = n
+
+ out.Decs.Before = f.before[n]
+ out.Decs.After = f.after[n]
+
+ // Token: Return
+
+ // List: Results
+ for _, v := range n.Results {
+ child, err := f.decorateNode(n, "ReturnStmt", "Results", "Expr", v)
+ if err != nil {
+ return nil, err
+ }
+ out.Results = append(out.Results, child.(dst.Expr))
+ }
+
+ if nd, ok := f.decorations[n]; ok {
+ if decs, ok := nd["Start"]; ok {
+ out.Decs.Start = decs
+ }
+ if decs, ok := nd["Return"]; ok {
+ out.Decs.Return = decs
+ }
+ if decs, ok := nd["End"]; ok {
+ out.Decs.End = decs
+ }
+ }
+
+ return out, nil
+ case *ast.SelectStmt:
+ out := &dst.SelectStmt{}
+ f.Dst.Nodes[n] = out
+ f.Ast.Nodes[out] = n
+
+ out.Decs.Before = f.before[n]
+ out.Decs.After = f.after[n]
+
+ // Token: Select
+
+ // Node: Body
+ if n.Body != nil {
+ child, err := f.decorateNode(n, "SelectStmt", "Body", "BlockStmt", n.Body)
+ if err != nil {
+ return nil, err
+ }
+ out.Body = child.(*dst.BlockStmt)
+ }
+
+ if nd, ok := f.decorations[n]; ok {
+ if decs, ok := nd["Start"]; ok {
+ out.Decs.Start = decs
+ }
+ if decs, ok := nd["Select"]; ok {
+ out.Decs.Select = decs
+ }
+ if decs, ok := nd["End"]; ok {
+ out.Decs.End = decs
+ }
+ }
+
+ return out, nil
+ case *ast.SelectorExpr:
+
+ // Special case for *ast.SelectorExpr - replace with Ident if needed
+ id, err := f.decorateSelectorExpr(parent, parentName, parentField, parentFieldType, n)
+ if err != nil {
+ return nil, err
+ }
+ if id != nil {
+ return id, nil
+ }
+
+ out := &dst.SelectorExpr{}
+ f.Dst.Nodes[n] = out
+ f.Ast.Nodes[out] = n
+
+ out.Decs.Before = f.before[n]
+ out.Decs.After = f.after[n]
+
+ // Node: X
+ if n.X != nil {
+ child, err := f.decorateNode(n, "SelectorExpr", "X", "Expr", n.X)
+ if err != nil {
+ return nil, err
+ }
+ out.X = child.(dst.Expr)
+ }
+
+ // Token: Period
+
+ // Node: Sel
+ if n.Sel != nil {
+ child, err := f.decorateNode(n, "SelectorExpr", "Sel", "Ident", n.Sel)
+ if err != nil {
+ return nil, err
+ }
+ out.Sel = child.(*dst.Ident)
+ }
+
+ if nd, ok := f.decorations[n]; ok {
+ if decs, ok := nd["Start"]; ok {
+ out.Decs.Start = decs
+ }
+ if decs, ok := nd["X"]; ok {
+ out.Decs.X = decs
+ }
+ if decs, ok := nd["End"]; ok {
+ out.Decs.End = decs
+ }
+ }
+
+ return out, nil
+ case *ast.SendStmt:
+ out := &dst.SendStmt{}
+ f.Dst.Nodes[n] = out
+ f.Ast.Nodes[out] = n
+
+ out.Decs.Before = f.before[n]
+ out.Decs.After = f.after[n]
+
+ // Node: Chan
+ if n.Chan != nil {
+ child, err := f.decorateNode(n, "SendStmt", "Chan", "Expr", n.Chan)
+ if err != nil {
+ return nil, err
+ }
+ out.Chan = child.(dst.Expr)
+ }
+
+ // Token: Arrow
+
+ // Node: Value
+ if n.Value != nil {
+ child, err := f.decorateNode(n, "SendStmt", "Value", "Expr", n.Value)
+ if err != nil {
+ return nil, err
+ }
+ out.Value = child.(dst.Expr)
+ }
+
+ if nd, ok := f.decorations[n]; ok {
+ if decs, ok := nd["Start"]; ok {
+ out.Decs.Start = decs
+ }
+ if decs, ok := nd["Chan"]; ok {
+ out.Decs.Chan = decs
+ }
+ if decs, ok := nd["Arrow"]; ok {
+ out.Decs.Arrow = decs
+ }
+ if decs, ok := nd["End"]; ok {
+ out.Decs.End = decs
+ }
+ }
+
+ return out, nil
+ case *ast.SliceExpr:
+ out := &dst.SliceExpr{}
+ f.Dst.Nodes[n] = out
+ f.Ast.Nodes[out] = n
+
+ out.Decs.Before = f.before[n]
+ out.Decs.After = f.after[n]
+
+ // Node: X
+ if n.X != nil {
+ child, err := f.decorateNode(n, "SliceExpr", "X", "Expr", n.X)
+ if err != nil {
+ return nil, err
+ }
+ out.X = child.(dst.Expr)
+ }
+
+ // Token: Lbrack
+
+ // Node: Low
+ if n.Low != nil {
+ child, err := f.decorateNode(n, "SliceExpr", "Low", "Expr", n.Low)
+ if err != nil {
+ return nil, err
+ }
+ out.Low = child.(dst.Expr)
+ }
+
+ // Token: Colon1
+
+ // Node: High
+ if n.High != nil {
+ child, err := f.decorateNode(n, "SliceExpr", "High", "Expr", n.High)
+ if err != nil {
+ return nil, err
+ }
+ out.High = child.(dst.Expr)
+ }
+
+ // Token: Colon2
+
+ // Node: Max
+ if n.Max != nil {
+ child, err := f.decorateNode(n, "SliceExpr", "Max", "Expr", n.Max)
+ if err != nil {
+ return nil, err
+ }
+ out.Max = child.(dst.Expr)
+ }
+
+ // Token: Rbrack
+
+ // Value: Slice3
+ out.Slice3 = n.Slice3
+
+ if nd, ok := f.decorations[n]; ok {
+ if decs, ok := nd["Start"]; ok {
+ out.Decs.Start = decs
+ }
+ if decs, ok := nd["X"]; ok {
+ out.Decs.X = decs
+ }
+ if decs, ok := nd["Lbrack"]; ok {
+ out.Decs.Lbrack = decs
+ }
+ if decs, ok := nd["Low"]; ok {
+ out.Decs.Low = decs
+ }
+ if decs, ok := nd["High"]; ok {
+ out.Decs.High = decs
+ }
+ if decs, ok := nd["Max"]; ok {
+ out.Decs.Max = decs
+ }
+ if decs, ok := nd["End"]; ok {
+ out.Decs.End = decs
+ }
+ }
+
+ return out, nil
+ case *ast.StarExpr:
+ out := &dst.StarExpr{}
+ f.Dst.Nodes[n] = out
+ f.Ast.Nodes[out] = n
+
+ out.Decs.Before = f.before[n]
+ out.Decs.After = f.after[n]
+
+ // Token: Star
+
+ // Node: X
+ if n.X != nil {
+ child, err := f.decorateNode(n, "StarExpr", "X", "Expr", n.X)
+ if err != nil {
+ return nil, err
+ }
+ out.X = child.(dst.Expr)
+ }
+
+ if nd, ok := f.decorations[n]; ok {
+ if decs, ok := nd["Start"]; ok {
+ out.Decs.Start = decs
+ }
+ if decs, ok := nd["Star"]; ok {
+ out.Decs.Star = decs
+ }
+ if decs, ok := nd["End"]; ok {
+ out.Decs.End = decs
+ }
+ }
+
+ return out, nil
+ case *ast.StructType:
+ out := &dst.StructType{}
+ f.Dst.Nodes[n] = out
+ f.Ast.Nodes[out] = n
+
+ out.Decs.Before = f.before[n]
+ out.Decs.After = f.after[n]
+
+ // Token: Struct
+
+ // Node: Fields
+ if n.Fields != nil {
+ child, err := f.decorateNode(n, "StructType", "Fields", "FieldList", n.Fields)
+ if err != nil {
+ return nil, err
+ }
+ out.Fields = child.(*dst.FieldList)
+ }
+
+ // Value: Incomplete
+ out.Incomplete = n.Incomplete
+
+ if nd, ok := f.decorations[n]; ok {
+ if decs, ok := nd["Start"]; ok {
+ out.Decs.Start = decs
+ }
+ if decs, ok := nd["Struct"]; ok {
+ out.Decs.Struct = decs
+ }
+ if decs, ok := nd["End"]; ok {
+ out.Decs.End = decs
+ }
+ }
+
+ return out, nil
+ case *ast.SwitchStmt:
+ out := &dst.SwitchStmt{}
+ f.Dst.Nodes[n] = out
+ f.Ast.Nodes[out] = n
+
+ out.Decs.Before = f.before[n]
+ out.Decs.After = f.after[n]
+
+ // Token: Switch
+
+ // Node: Init
+ if n.Init != nil {
+ child, err := f.decorateNode(n, "SwitchStmt", "Init", "Stmt", n.Init)
+ if err != nil {
+ return nil, err
+ }
+ out.Init = child.(dst.Stmt)
+ }
+
+ // Node: Tag
+ if n.Tag != nil {
+ child, err := f.decorateNode(n, "SwitchStmt", "Tag", "Expr", n.Tag)
+ if err != nil {
+ return nil, err
+ }
+ out.Tag = child.(dst.Expr)
+ }
+
+ // Node: Body
+ if n.Body != nil {
+ child, err := f.decorateNode(n, "SwitchStmt", "Body", "BlockStmt", n.Body)
+ if err != nil {
+ return nil, err
+ }
+ out.Body = child.(*dst.BlockStmt)
+ }
+
+ if nd, ok := f.decorations[n]; ok {
+ if decs, ok := nd["Start"]; ok {
+ out.Decs.Start = decs
+ }
+ if decs, ok := nd["Switch"]; ok {
+ out.Decs.Switch = decs
+ }
+ if decs, ok := nd["Init"]; ok {
+ out.Decs.Init = decs
+ }
+ if decs, ok := nd["Tag"]; ok {
+ out.Decs.Tag = decs
+ }
+ if decs, ok := nd["End"]; ok {
+ out.Decs.End = decs
+ }
+ }
+
+ return out, nil
+ case *ast.TypeAssertExpr:
+ out := &dst.TypeAssertExpr{}
+ f.Dst.Nodes[n] = out
+ f.Ast.Nodes[out] = n
+
+ out.Decs.Before = f.before[n]
+ out.Decs.After = f.after[n]
+
+ // Node: X
+ if n.X != nil {
+ child, err := f.decorateNode(n, "TypeAssertExpr", "X", "Expr", n.X)
+ if err != nil {
+ return nil, err
+ }
+ out.X = child.(dst.Expr)
+ }
+
+ // Token: Period
+
+ // Token: Lparen
+
+ // Node: Type
+ if n.Type != nil {
+ child, err := f.decorateNode(n, "TypeAssertExpr", "Type", "Expr", n.Type)
+ if err != nil {
+ return nil, err
+ }
+ out.Type = child.(dst.Expr)
+ }
+
+ // Token: TypeToken
+
+ // Token: Rparen
+
+ if nd, ok := f.decorations[n]; ok {
+ if decs, ok := nd["Start"]; ok {
+ out.Decs.Start = decs
+ }
+ if decs, ok := nd["X"]; ok {
+ out.Decs.X = decs
+ }
+ if decs, ok := nd["Lparen"]; ok {
+ out.Decs.Lparen = decs
+ }
+ if decs, ok := nd["Type"]; ok {
+ out.Decs.Type = decs
+ }
+ if decs, ok := nd["End"]; ok {
+ out.Decs.End = decs
+ }
+ }
+
+ return out, nil
+ case *ast.TypeSpec:
+ out := &dst.TypeSpec{}
+ f.Dst.Nodes[n] = out
+ f.Ast.Nodes[out] = n
+
+ out.Decs.Before = f.before[n]
+ out.Decs.After = f.after[n]
+
+ // Node: Name
+ if n.Name != nil {
+ child, err := f.decorateNode(n, "TypeSpec", "Name", "Ident", n.Name)
+ if err != nil {
+ return nil, err
+ }
+ out.Name = child.(*dst.Ident)
+ }
+
+ // Token: Assign
+ out.Assign = n.Assign.IsValid()
+
+ // Node: TypeParams
+ if n.TypeParams != nil {
+ child, err := f.decorateNode(n, "TypeSpec", "TypeParams", "FieldList", n.TypeParams)
+ if err != nil {
+ return nil, err
+ }
+ out.TypeParams = child.(*dst.FieldList)
+ }
+
+ // Node: Type
+ if n.Type != nil {
+ child, err := f.decorateNode(n, "TypeSpec", "Type", "Expr", n.Type)
+ if err != nil {
+ return nil, err
+ }
+ out.Type = child.(dst.Expr)
+ }
+
+ if nd, ok := f.decorations[n]; ok {
+ if decs, ok := nd["Start"]; ok {
+ out.Decs.Start = decs
+ }
+ if decs, ok := nd["Name"]; ok {
+ out.Decs.Name = decs
+ }
+ if decs, ok := nd["TypeParams"]; ok {
+ out.Decs.TypeParams = decs
+ }
+ if decs, ok := nd["End"]; ok {
+ out.Decs.End = decs
+ }
+ }
+
+ return out, nil
+ case *ast.TypeSwitchStmt:
+ out := &dst.TypeSwitchStmt{}
+ f.Dst.Nodes[n] = out
+ f.Ast.Nodes[out] = n
+
+ out.Decs.Before = f.before[n]
+ out.Decs.After = f.after[n]
+
+ // Token: Switch
+
+ // Node: Init
+ if n.Init != nil {
+ child, err := f.decorateNode(n, "TypeSwitchStmt", "Init", "Stmt", n.Init)
+ if err != nil {
+ return nil, err
+ }
+ out.Init = child.(dst.Stmt)
+ }
+
+ // Node: Assign
+ if n.Assign != nil {
+ child, err := f.decorateNode(n, "TypeSwitchStmt", "Assign", "Stmt", n.Assign)
+ if err != nil {
+ return nil, err
+ }
+ out.Assign = child.(dst.Stmt)
+ }
+
+ // Node: Body
+ if n.Body != nil {
+ child, err := f.decorateNode(n, "TypeSwitchStmt", "Body", "BlockStmt", n.Body)
+ if err != nil {
+ return nil, err
+ }
+ out.Body = child.(*dst.BlockStmt)
+ }
+
+ if nd, ok := f.decorations[n]; ok {
+ if decs, ok := nd["Start"]; ok {
+ out.Decs.Start = decs
+ }
+ if decs, ok := nd["Switch"]; ok {
+ out.Decs.Switch = decs
+ }
+ if decs, ok := nd["Init"]; ok {
+ out.Decs.Init = decs
+ }
+ if decs, ok := nd["Assign"]; ok {
+ out.Decs.Assign = decs
+ }
+ if decs, ok := nd["End"]; ok {
+ out.Decs.End = decs
+ }
+ }
+
+ return out, nil
+ case *ast.UnaryExpr:
+ out := &dst.UnaryExpr{}
+ f.Dst.Nodes[n] = out
+ f.Ast.Nodes[out] = n
+
+ out.Decs.Before = f.before[n]
+ out.Decs.After = f.after[n]
+
+ // Token: Op
+ out.Op = n.Op
+
+ // Node: X
+ if n.X != nil {
+ child, err := f.decorateNode(n, "UnaryExpr", "X", "Expr", n.X)
+ if err != nil {
+ return nil, err
+ }
+ out.X = child.(dst.Expr)
+ }
+
+ if nd, ok := f.decorations[n]; ok {
+ if decs, ok := nd["Start"]; ok {
+ out.Decs.Start = decs
+ }
+ if decs, ok := nd["Op"]; ok {
+ out.Decs.Op = decs
+ }
+ if decs, ok := nd["End"]; ok {
+ out.Decs.End = decs
+ }
+ }
+
+ return out, nil
+ case *ast.ValueSpec:
+ out := &dst.ValueSpec{}
+ f.Dst.Nodes[n] = out
+ f.Ast.Nodes[out] = n
+
+ out.Decs.Before = f.before[n]
+ out.Decs.After = f.after[n]
+
+ // List: Names
+ for _, v := range n.Names {
+ child, err := f.decorateNode(n, "ValueSpec", "Names", "Ident", v)
+ if err != nil {
+ return nil, err
+ }
+ out.Names = append(out.Names, child.(*dst.Ident))
+ }
+
+ // Node: Type
+ if n.Type != nil {
+ child, err := f.decorateNode(n, "ValueSpec", "Type", "Expr", n.Type)
+ if err != nil {
+ return nil, err
+ }
+ out.Type = child.(dst.Expr)
+ }
+
+ // Token: Assign
+
+ // List: Values
+ for _, v := range n.Values {
+ child, err := f.decorateNode(n, "ValueSpec", "Values", "Expr", v)
+ if err != nil {
+ return nil, err
+ }
+ out.Values = append(out.Values, child.(dst.Expr))
+ }
+
+ if nd, ok := f.decorations[n]; ok {
+ if decs, ok := nd["Start"]; ok {
+ out.Decs.Start = decs
+ }
+ if decs, ok := nd["Assign"]; ok {
+ out.Decs.Assign = decs
+ }
+ if decs, ok := nd["End"]; ok {
+ out.Decs.End = decs
+ }
+ }
+
+ return out, nil
+ }
+ return nil, nil
+}
diff --git a/vendor/github.com/dave/dst/decorator/decorator.go b/vendor/github.com/dave/dst/decorator/decorator.go
new file mode 100644
index 0000000000..cd36a36c56
--- /dev/null
+++ b/vendor/github.com/dave/dst/decorator/decorator.go
@@ -0,0 +1,567 @@
+package decorator
+
+import (
+ "fmt"
+ "go/ast"
+ "go/parser"
+ "go/token"
+ "io"
+ "os"
+ "strings"
+
+ "github.com/dave/dst"
+ "github.com/dave/dst/decorator/resolver"
+ "github.com/dave/dst/decorator/resolver/gotypes"
+ "github.com/dave/dst/dstutil"
+ "golang.org/x/tools/go/packages"
+)
+
+// NewDecorator returns a new decorator. If fset is nil, a new FileSet is created.
+func NewDecorator(fset *token.FileSet) *Decorator {
+ if fset == nil {
+ fset = token.NewFileSet()
+ }
+ return &Decorator{
+ Map: newMap(),
+ Filenames: map[*dst.File]string{},
+ Fset: fset,
+ }
+}
+
+// NewDecoratorWithImports returns a new decorator with import management enabled.
+func NewDecoratorWithImports(fset *token.FileSet, path string, resolver resolver.DecoratorResolver) *Decorator {
+ dec := NewDecorator(fset)
+ dec.Path = path
+ dec.Resolver = resolver
+ return dec
+}
+
+// NewDecoratorFromPackage returns a new decorator configured to decorate files in pkg.
+func NewDecoratorFromPackage(pkg *packages.Package) *Decorator {
+ return NewDecoratorWithImports(pkg.Fset, pkg.PkgPath, gotypes.New(pkg.TypesInfo.Uses))
+}
+
+// Decorator converts ast nodes into dst nodes, and converts decoration info from the ast fileset
+// to the dst nodes. Create a new Decorator for each package you need to decorate.
+type Decorator struct {
+ Map // Mapping between ast and dst Nodes, Objects and Scopes
+ Filenames map[*dst.File]string // Source file names
+ Fset *token.FileSet // The ast FileSet containing ast decoration info for the files
+
+ // If a Resolver is provided, it is used to resolve remote identifiers from *ast.Ident and
+ // *ast.SelectorExpr nodes. Usually a remote identifier is a SelectorExpr qualified identifier,
+ // but in the case of dot-imports they can be simply Ident nodes. During decoration, remote
+ // identifiers are replaced with *dst.Ident with Path set to the path of imported package.
+ Resolver resolver.DecoratorResolver
+ // Local package path - required if Resolver is set.
+ Path string
+ // By default local idents are left with an empty Path, so they stay local if the local package
+ // is renamed. Setting ResolveLocalPath to true prevents this, so all idents will have the
+ // package path added.
+ ResolveLocalPath bool
+}
+
+// Parse uses parser.ParseFile to parse and decorate a Go source file. The src parameter should
+// be string, []byte, or io.Reader.
+func (d *Decorator) Parse(src interface{}) (*dst.File, error) {
+ return d.ParseFile("", src, parser.ParseComments)
+}
+
+// ParseFile uses parser.ParseFile to parse and decorate a Go source file. The ParseComments flag
+// is added to mode if it doesn't exist.
+func (d *Decorator) ParseFile(filename string, src interface{}, mode parser.Mode) (*dst.File, error) {
+
+ // If ParseFile returns an error and also a non-nil file, the errors were just parse errors so
+ // we should continue decorating the file and return the error.
+ f, perr := parser.ParseFile(d.Fset, filename, src, mode|parser.ParseComments)
+ if perr != nil && f == nil {
+ return nil, perr
+ }
+
+ // If the file has no valid position information, we can't safely decorate it.
+ // This happens when the source is so malformed that the parser couldn't
+ // produce a usable AST (e.g., "pkg main" or empty input).
+ if f.Pos() == token.NoPos {
+ return nil, perr
+ }
+
+ file, err := d.DecorateFile(f)
+ if err != nil {
+ return nil, err
+ }
+
+ return file, perr
+}
+
+// ParseDir uses parser.ParseDir to parse and decorate a directory containing Go source. The
+// ParseComments flag is added to mode if it doesn't exist.
+func (d *Decorator) ParseDir(dir string, filter func(os.FileInfo) bool, mode parser.Mode) (map[string]*dst.Package, error) {
+ pkgs, err := parser.ParseDir(d.Fset, dir, filter, mode|parser.ParseComments)
+ if err != nil {
+ return nil, err
+ }
+ out := map[string]*dst.Package{}
+ for k, v := range pkgs {
+ pkg, err := d.DecorateNode(v)
+ if err != nil {
+ return nil, err
+ }
+ out[k] = pkg.(*dst.Package)
+ }
+ return out, nil
+}
+
+// DecorateFile decorates *ast.File and returns *dst.File
+func (d *Decorator) DecorateFile(f *ast.File) (*dst.File, error) {
+ file, err := d.DecorateNode(f)
+ if err != nil {
+ return nil, err
+ }
+ return file.(*dst.File), nil
+}
+
+// DecorateNode decorates ast.Node and returns dst.Node
+func (d *Decorator) DecorateNode(n ast.Node) (dst.Node, error) {
+
+ if d.Resolver == nil && d.Path != "" {
+ panic("Decorator Path should be empty when Resolver is nil")
+ }
+
+ if d.Resolver != nil && d.Path == "" {
+ panic("Decorator Path should be set when Resolver is set")
+ }
+
+ fd := d.newFileDecorator()
+ if f, ok := n.(*ast.File); ok {
+ fd.file = f
+ }
+ fd.fragment(n)
+ fd.link()
+
+ out, err := fd.decorateNode(nil, "", "", "", n)
+ if err != nil {
+ return nil, err
+ }
+
+ //fmt.Println("\nFragments:")
+ //fd.debug(os.Stdout)
+
+ //fmt.Println("\nDecorator:")
+ //debug(os.Stdout, out)
+
+ // Populate Info with filenames if we're decorating a File or Package.
+ switch n := n.(type) {
+ case *ast.Package:
+ for k, v := range n.Files {
+ d.Filenames[d.Dst.Nodes[v].(*dst.File)] = k
+ }
+ case *ast.File:
+ d.Filenames[out.(*dst.File)] = d.Fset.File(n.Pos()).Name()
+ }
+
+ return out, nil
+}
+
+func (pd *Decorator) newFileDecorator() *fileDecorator {
+ return &fileDecorator{
+ Decorator: pd,
+ startIndents: map[ast.Node]int{},
+ endIndents: map[ast.Node]int{},
+ before: map[ast.Node]dst.SpaceType{},
+ after: map[ast.Node]dst.SpaceType{},
+ decorations: map[ast.Node]map[string][]string{},
+ }
+}
+
+type fileDecorator struct {
+ *Decorator
+ file *ast.File // file we're decorating in for import name resolution - can be nil if we're just decorating an isolated node
+ cursor int
+ fragments []fragment
+ startIndents map[ast.Node]int
+ endIndents map[ast.Node]int
+ before, after map[ast.Node]dst.SpaceType
+ decorations map[ast.Node]map[string][]string
+}
+
+// We never need to resolve idents that are in these fields (decorateSelectorExpr will override
+// this check with the force parameter for SelectorExpr.Sel when needed).
+var avoid = map[string]bool{
+ "Field.Names": true,
+ "LabeledStmt.Label": true,
+ "BranchStmt.Label": true,
+ "ImportSpec.Name": true,
+ "ValueSpec.Names": true,
+ "TypeSpec.Name": true,
+ "FuncDecl.Name": true,
+ "File.Name": true,
+ "SelectorExpr.Sel": true,
+}
+
+// decorateSelectorExpr is a special case for decorating a SelectorExpr, which might return an
+// Ident if the resolver determines that the SelectorExpr represents a qualified ident.
+func (f *fileDecorator) decorateSelectorExpr(parent ast.Node, parentName, parentField, parentFieldType string, n *ast.SelectorExpr) (dst.Node, error) {
+
+ if f.Resolver == nil {
+ // continue to default logic in decorateNode
+ return nil, nil
+ }
+
+ // resolve the path with force == true, so we skip the tests that would normally prevent the
+ // Sel field of SelectorExpr from being resolved.
+ path, err := f.resolvePath(true, n, "SelectorExpr", "Sel", "Ident", n.Sel)
+ if err != nil {
+ return nil, err
+ }
+
+ if path == "" {
+ // path == "" -> not a qualified ident -> continue to default logic in decorateNode
+ return nil, nil
+ }
+
+ // replace *ast.SelectorExpr with *dst.Ident and merge decorations
+ out := &dst.Ident{}
+ f.Dst.Nodes[n] = out
+ f.Dst.Nodes[n.X] = out
+ f.Dst.Nodes[n.Sel] = out
+ f.Ast.Nodes[out] = n
+
+ // String: Name
+ out.Name = n.Sel.Name
+
+ // Object: Obj
+ ob, err := f.decorateObject(n.Sel.Obj)
+ if err != nil {
+ return nil, err
+ }
+ out.Obj = ob
+
+ // Path: Path
+ out.Path = path
+
+ /*
+ We must merge the SelectorExpr decorations into an Ident. The Ident has an X decoration
+ attachment point, but we don't have a simple place to store the decorations and line
+ spacing from the X / Sel child nodes. This is rather an edge case, but we can fix it by
+ merging the line-spacing with decorations (line spacing becomes "\n" decorations) and
+ adding these to the Ident decorations. This will mean that decorated / restored code with
+ no mutations should be byte-perfect, which is essential.
+
+ Here's a list of the decorations / line spacings we're merging:
+
+ {1}{2}{3}{4}[ X ].{5}{6}{7}{8}{9}[ Sel ]{10}{11}{12}{13}
+
+ 1: SelectorExpr Before Space - f.before[n]
+
+ 2: SelectorExpr Start Decoration - f.decorations[n]["Start"]
+ 3: X Before Space - f.before[n.X]
+ 4: X Start Decoration - f.decorations[n.X]["Start"]
+
+ 5: X End Decoration - f.decorations[n.X]["End"]
+ 6: X After Space - f.after[n.X]
+ 7: SelectorExpr X Decoration - f.decorations[n]["X"]
+ 8: Sel Before Space - f.before[n.Sel]
+ 9: Sel Start Decoration - f.decorations[n.Sel]["Start"]
+
+ 10: Sel End decoration - f.decorations[n.Sel]["End"]
+ 11: Sel After Space - f.after[n.Sel]
+ 12: SelectorExpr End Decoration - f.decorations[n]["End"]
+
+ 13: SelectorExpr After Space - f.after[n]
+
+ 1: set Ident.Before
+ 2-4: merge into Ident.Start
+ 5-9: merge into Ident.X
+ 10-12: merge into Ident.End
+ 13: set Ident.After
+ */
+
+ out.Decs.Before = f.before[n]
+ out.Decs.After = f.after[n]
+
+ var nStart, xBefore, xStart, xEnd, xAfter, nX, sBefore, sStart, sEnd, sAfter, nEnd interface{}
+
+ xBefore = f.before[n.X]
+ xAfter = f.after[n.X]
+
+ sBefore = f.before[n.Sel]
+ sAfter = f.after[n.Sel]
+
+ if decs, ok := f.decorations[n]; ok {
+ nStart = decs["Start"]
+ nX = decs["X"]
+ nEnd = decs["End"]
+ }
+ if decs, ok := f.decorations[n.X]; ok {
+ xStart = decs["Start"]
+ xEnd = decs["End"]
+ }
+ if decs, ok := f.decorations[n.Sel]; ok {
+ sStart = decs["Start"]
+ sEnd = decs["End"]
+ }
+
+ if iStart := mergeDecorations(nStart, xBefore, xStart); len(iStart) > 0 {
+ out.Decs.Start.Append(iStart...)
+ }
+
+ if iX := mergeDecorations(xEnd, xAfter, nX, sBefore, sStart); len(iX) > 0 {
+ out.Decs.X.Append(iX...)
+ }
+
+ if iEnd := mergeDecorations(sEnd, sAfter, nEnd); len(iEnd) > 0 {
+ out.Decs.End.Append(iEnd...)
+ }
+
+ return out, nil
+
+}
+
+func (f *fileDecorator) resolvePath(force bool, parent ast.Node, parentName, parentField, parentFieldType string, id *ast.Ident) (string, error) {
+
+ if f.Resolver == nil {
+ panic("resolvePath needs a Resolver")
+ }
+
+ if !force {
+ if avoid[parentName+"."+parentField] {
+ return "", nil
+ }
+ if parentFieldType != "Expr" {
+ panic(fmt.Sprintf("decorateIdent: unsupported parentName %s, parentField %s, parentFieldType %s", parentName, parentField, parentFieldType))
+ }
+ }
+
+ path, err := f.Resolver.ResolveIdent(f.file, parent, parentField, id)
+ if err != nil {
+ return "", err
+ }
+
+ path = stripVendor(path)
+
+ if !f.ResolveLocalPath && path == stripVendor(f.Path) {
+ return "", nil
+ }
+
+ return path, nil
+}
+
+func stripVendor(path string) string {
+ findVendor := func(path string) (index int, ok bool) {
+ // Two cases, depending on internal at start of string or not.
+ // The order matters: we must return the index of the final element,
+ // because the final one is where the effective import path starts.
+ switch {
+ case strings.Contains(path, "/vendor/"):
+ return strings.LastIndex(path, "/vendor/") + 1, true
+ case strings.HasPrefix(path, "vendor/"):
+ return 0, true
+ }
+ return 0, false
+ }
+ i, ok := findVendor(path)
+ if !ok {
+ return path
+ }
+ return path[i+len("vendor/"):]
+}
+
+func (f *fileDecorator) decorateObject(o *ast.Object) (*dst.Object, error) {
+
+ if o == nil {
+ return nil, nil
+ }
+
+ if do, ok := f.Dst.Objects[o]; ok {
+ return do, nil
+ }
+
+ /*
+ // An Object describes a named language entity such as a package,
+ // constant, type, variable, function (incl. methods), or label.
+ //
+ // The Data fields contains object-specific data:
+ //
+ // Kind Data type Data value
+ // Pkg *Scope package scope
+ // Con int iota for the respective declaration
+ //
+ type Object struct {
+ Kind ObjKind
+ Name string // declared name
+ Decl interface{} // corresponding Field, XxxSpec, FuncDecl, LabeledStmt, AssignStmt, Scope; or nil
+ Data interface{} // object-specific data; or nil
+ Type interface{} // placeholder for type information; may be nil
+ }
+ */
+
+ out := &dst.Object{}
+ f.Dst.Objects[o] = out
+ f.Ast.Objects[out] = o
+ out.Kind = dst.ObjKind(o.Kind)
+ out.Name = o.Name
+
+ switch decl := o.Decl.(type) {
+ case *ast.Scope:
+ s, err := f.decorateScope(decl)
+ if err != nil {
+ return nil, err
+ }
+ out.Decl = s
+ case ast.Node:
+ n, err := f.decorateNode(nil, "", "", "", decl)
+ if err != nil {
+ return nil, err
+ }
+ out.Decl = n
+ case nil:
+ default:
+ panic(fmt.Sprintf("o.Decl is %T", o.Data))
+ }
+
+ switch data := o.Data.(type) {
+ case int:
+ out.Data = data
+ case *ast.Scope:
+ s, err := f.decorateScope(data)
+ if err != nil {
+ return nil, err
+ }
+ out.Data = s
+ case ast.Node:
+ n, err := f.decorateNode(nil, "", "", "", data)
+ if err != nil {
+ return nil, err
+ }
+ out.Data = n
+ case nil:
+ default:
+ panic(fmt.Sprintf("o.Data is %T", o.Data))
+ }
+
+ return out, nil
+}
+
+func (f *fileDecorator) decorateScope(s *ast.Scope) (*dst.Scope, error) {
+
+ if s == nil {
+ return nil, nil
+ }
+
+ if ds, ok := f.Dst.Scopes[s]; ok {
+ return ds, nil
+ }
+
+ /*
+ // A Scope maintains the set of named language entities declared
+ // in the scope and a link to the immediately surrounding (outer)
+ // scope.
+ //
+ type Scope struct {
+ Outer *Scope
+ Objects map[string]*Object
+ }
+ */
+
+ out := &dst.Scope{}
+ f.Dst.Scopes[s] = out
+ f.Ast.Scopes[out] = s
+
+ outer, err := f.decorateScope(s.Outer)
+ if err != nil {
+ return nil, err
+ }
+ out.Outer = outer
+ out.Objects = map[string]*dst.Object{}
+
+ for k, v := range s.Objects {
+ ob, err := f.decorateObject(v)
+ if err != nil {
+ return nil, err
+ }
+ out.Objects[k] = ob
+ }
+
+ return out, nil
+}
+
+func debug(w io.Writer, file dst.Node) {
+ var result string
+ nodeType := func(n dst.Node) string {
+ return strings.Replace(fmt.Sprintf("%T", n), "*dst.", "", -1)
+ }
+ dst.Inspect(file, func(n dst.Node) bool {
+ if n == nil {
+ return false
+ }
+ var out string
+ before, after, points := dstutil.Decorations(n)
+ switch before {
+ case dst.NewLine:
+ out += " [New line before]"
+ case dst.EmptyLine:
+ out += " [Empty line before]"
+ }
+ for _, point := range points {
+ if len(point.Decs) > 0 {
+ var values string
+ for i, dec := range point.Decs {
+ if i > 0 {
+ values += " "
+ }
+ values += fmt.Sprintf("%q", dec)
+ }
+ out += fmt.Sprintf(" [%s %s]", point.Name, values)
+ }
+ }
+ switch after {
+ case dst.NewLine:
+ out += " [New line after]"
+ case dst.EmptyLine:
+ out += " [Empty line after]"
+ }
+ if out != "" {
+ result += nodeType(n) + out + "\n"
+ }
+ return true
+ })
+ fmt.Fprint(w, result)
+}
+
+// mergeDecorations merges several decoration lists and line spaces into a single decoration list
+func mergeDecorations(decorationsOrLineSpace ...interface{}) []string {
+ var endsWithNewLine bool
+ var out []string
+ for _, v := range decorationsOrLineSpace {
+ switch v := v.(type) {
+ case nil:
+ // nothing
+ case []string:
+ if len(v) == 0 {
+ continue
+ }
+ out = append(out, v...)
+ endsWithNewLine = v[len(v)-1] == "\n" || strings.HasPrefix(v[len(v)-1], "//")
+ case dst.SpaceType:
+ switch v {
+ case dst.NewLine:
+ if endsWithNewLine {
+ // nothing to do
+ } else {
+ out = append(out, "\n")
+ }
+ endsWithNewLine = true
+ case dst.EmptyLine:
+ if endsWithNewLine {
+ out = append(out, "\n")
+ } else {
+ out = append(out, "\n", "\n")
+ }
+ endsWithNewLine = true
+ }
+ default:
+ panic(fmt.Sprintf("%T", v))
+ }
+ }
+ return out
+}
diff --git a/vendor/github.com/dave/dst/decorator/helpers.go b/vendor/github.com/dave/dst/decorator/helpers.go
new file mode 100644
index 0000000000..679b6e701d
--- /dev/null
+++ b/vendor/github.com/dave/dst/decorator/helpers.go
@@ -0,0 +1,64 @@
+package decorator
+
+import (
+ "go/ast"
+ "go/format"
+ "go/parser"
+ "go/token"
+ "io"
+ "os"
+
+ "github.com/dave/dst"
+)
+
+// Parse uses parser.ParseFile to parse and decorate a Go source file. The src parameter should
+// be string, []byte, or io.Reader.
+func Parse(src interface{}) (*dst.File, error) {
+ return NewDecorator(token.NewFileSet()).Parse(src)
+}
+
+// ParseFile uses parser.ParseFile to parse and decorate a Go source file. The ParseComments flag is
+// added to mode if it doesn't exist.
+func ParseFile(fset *token.FileSet, filename string, src interface{}, mode parser.Mode) (*dst.File, error) {
+ return NewDecorator(fset).ParseFile(filename, src, mode)
+}
+
+// ParseDir uses parser.ParseDir to parse and decorate a directory containing Go source. The
+// ParseComments flag is added to mode if it doesn't exist.
+func ParseDir(fset *token.FileSet, dir string, filter func(os.FileInfo) bool, mode parser.Mode) (map[string]*dst.Package, error) {
+ return NewDecorator(fset).ParseDir(dir, filter, mode)
+}
+
+// Decorate decorates an ast.Node and returns a dst.Node.
+func Decorate(fset *token.FileSet, n ast.Node) (dst.Node, error) {
+ return NewDecorator(fset).DecorateNode(n)
+}
+
+// Decorate decorates a *ast.File and returns a *dst.File.
+func DecorateFile(fset *token.FileSet, f *ast.File) (*dst.File, error) {
+ return NewDecorator(fset).DecorateFile(f)
+}
+
+// Print uses format.Node to print a *dst.File to stdout
+func Print(f *dst.File) error {
+ return Fprint(os.Stdout, f)
+}
+
+// Fprint uses format.Node to print a *dst.File to a writer
+func Fprint(w io.Writer, f *dst.File) error {
+ fset, af, err := RestoreFile(f)
+ if err != nil {
+ return err
+ }
+ return format.Node(w, fset, af)
+}
+
+// RestoreFile restores a *dst.File to a *token.FileSet and a *ast.File
+func RestoreFile(file *dst.File) (*token.FileSet, *ast.File, error) {
+ r := NewRestorer()
+ f, err := r.RestoreFile(file)
+ if err != nil {
+ return nil, nil, err
+ }
+ return r.Fset, f, nil
+}
diff --git a/vendor/github.com/dave/dst/decorator/load.go b/vendor/github.com/dave/dst/decorator/load.go
new file mode 100644
index 0000000000..3e109f118a
--- /dev/null
+++ b/vendor/github.com/dave/dst/decorator/load.go
@@ -0,0 +1,119 @@
+package decorator
+
+import (
+ "bytes"
+ "errors"
+ "io/ioutil"
+ "os"
+ "path/filepath"
+
+ "github.com/dave/dst"
+ "github.com/dave/dst/decorator/resolver"
+ "github.com/dave/dst/decorator/resolver/gopackages"
+ "golang.org/x/tools/go/packages"
+)
+
+func Load(cfg *packages.Config, patterns ...string) ([]*Package, error) {
+
+ if cfg == nil {
+ cfg = &packages.Config{Mode: packages.LoadSyntax}
+ }
+
+ if cfg.Mode&packages.NeedSyntax == 0 {
+ return nil, errors.New("config mode should include NeedSyntax")
+ }
+
+ pkgs, err := packages.Load(cfg, patterns...)
+ if err != nil {
+ return nil, err
+ }
+
+ dpkgs := map[*packages.Package]*Package{}
+
+ var convert func(p *packages.Package) (*Package, error)
+ convert = func(pkg *packages.Package) (*Package, error) {
+ if dp, ok := dpkgs[pkg]; ok {
+ return dp, nil
+ }
+ p := &Package{
+ Package: pkg,
+ Imports: map[string]*Package{},
+ }
+ dpkgs[pkg] = p
+ if len(pkg.Syntax) > 0 {
+
+ // Only decorate files in the GoFiles list. Syntax also has preprocessed cgo files which
+ // break things.
+ goFiles := make(map[string]bool, len(pkg.GoFiles))
+ for _, fpath := range pkg.GoFiles {
+ goFiles[fpath] = true
+ }
+
+ p.Decorator = NewDecoratorFromPackage(pkg)
+ for _, f := range pkg.Syntax {
+ fpath := pkg.Fset.File(f.Pos()).Name()
+ if !goFiles[fpath] {
+ continue
+ }
+ file, err := p.Decorator.DecorateFile(f)
+ if err != nil {
+ return nil, err
+ }
+ p.Syntax = append(p.Syntax, file)
+ }
+
+ dir, _ := filepath.Split(pkg.Fset.File(pkg.Syntax[0].Pos()).Name())
+ p.Dir = dir
+
+ for path, imp := range pkg.Imports {
+ dimp, err := convert(imp)
+ if err != nil {
+ return nil, err
+ }
+ p.Imports[path] = dimp
+ }
+ }
+ return p, nil
+ }
+
+ var out []*Package
+ for _, pkg := range pkgs {
+ p, err := convert(pkg)
+ if err != nil {
+ return nil, err
+ }
+ out = append(out, p)
+ }
+
+ return out, nil
+}
+
+type Package struct {
+ *packages.Package
+ Dir string
+ Decorator *Decorator
+ Imports map[string]*Package
+ Syntax []*dst.File
+}
+
+func (p *Package) Save() error {
+ return p.save(gopackages.New(p.Dir), ioutil.WriteFile)
+}
+
+func (p *Package) SaveWithResolver(resolver resolver.RestorerResolver) error {
+ return p.save(resolver, ioutil.WriteFile)
+}
+
+func (p *Package) save(resolver resolver.RestorerResolver, writeFile func(filename string, data []byte, perm os.FileMode) error) error {
+ r := NewRestorerWithImports(p.PkgPath, resolver)
+ for _, file := range p.Syntax {
+ buf := &bytes.Buffer{}
+ if err := r.Fprint(buf, file); err != nil {
+ return err
+ }
+ if err := writeFile(p.Decorator.Filenames[file], buf.Bytes(), 0666); err != nil {
+ return err
+ }
+ }
+ return nil
+}
diff --git a/vendor/github.com/dave/dst/decorator/map.go b/vendor/github.com/dave/dst/decorator/map.go
new file mode 100644
index 0000000000..48d4adfe53
--- /dev/null
+++ b/vendor/github.com/dave/dst/decorator/map.go
@@ -0,0 +1,42 @@
+package decorator
+
+import (
+ "go/ast"
+
+ "github.com/dave/dst"
+)
+
+func newMap() Map {
+ return Map{
+ Ast: AstMap{
+ Nodes: map[dst.Node]ast.Node{},
+ Scopes: map[*dst.Scope]*ast.Scope{},
+ Objects: map[*dst.Object]*ast.Object{},
+ },
+ Dst: DstMap{
+ Nodes: map[ast.Node]dst.Node{},
+ Scopes: map[*ast.Scope]*dst.Scope{},
+ Objects: map[*ast.Object]*dst.Object{},
+ },
+ }
+}
+
+// Map holds a record of the mapping between ast and dst nodes, objects and scopes.
+type Map struct {
+ Ast AstMap
+ Dst DstMap
+}
+
+// AstMap holds a record of the mapping from dst to ast nodes, objects and scopes.
+type AstMap struct {
+ Nodes map[dst.Node]ast.Node // Mapping from dst to ast Nodes
+ Objects map[*dst.Object]*ast.Object // Mapping from dst to ast Objects
+ Scopes map[*dst.Scope]*ast.Scope // Mapping from dst to ast Scopes
+}
+
+// DstMap holds a record of the mapping from ast to dst nodes, objects and scopes.
+type DstMap struct {
+ Nodes map[ast.Node]dst.Node // Mapping from ast to dst Nodes
+ Objects map[*ast.Object]*dst.Object // Mapping from ast to dst Objects
+ Scopes map[*ast.Scope]*dst.Scope // Mapping from ast to dst Scopes
+}
diff --git a/vendor/github.com/dave/dst/decorator/resolver/gopackages/resolver.go b/vendor/github.com/dave/dst/decorator/resolver/gopackages/resolver.go
new file mode 100644
index 0000000000..7295d7df6c
--- /dev/null
+++ b/vendor/github.com/dave/dst/decorator/resolver/gopackages/resolver.go
@@ -0,0 +1,61 @@
+package gopackages
+
+import (
+ "fmt"
+
+ "github.com/dave/dst/decorator/resolver"
+ "golang.org/x/tools/go/packages"
+)
+
+func New(dir string) *RestorerResolver {
+ return &RestorerResolver{Dir: dir}
+}
+
+func WithConfig(dir string, config packages.Config) *RestorerResolver {
+ return &RestorerResolver{Config: config, Dir: dir}
+}
+
+func WithHints(dir string, hints map[string]string) *RestorerResolver {
+ return &RestorerResolver{Dir: dir, Hints: hints}
+}
+
+type RestorerResolver struct {
+ Dir string
+ Config packages.Config
+
+ // Hints (package path -> name) is first checked before asking the packages package
+ Hints map[string]string
+}
+
+func (r *RestorerResolver) ResolvePackage(path string) (string, error) {
+
+ if name, ok := r.Hints[path]; ok {
+ return name, nil
+ }
+
+ if r.Dir != "" {
+ r.Config.Dir = r.Dir
+ }
+ r.Config.Mode = packages.LoadTypes
+ r.Config.Tests = false
+
+ pkgs, err := packages.Load(&r.Config, "pattern="+path)
+ if err != nil {
+ return "", err
+ }
+
+ if len(pkgs) > 1 {
+ return "", fmt.Errorf("%d packages found for %s, %s", len(pkgs), path, r.Config.Dir)
+ }
+ if len(pkgs) == 0 {
+ return "", resolver.ErrPackageNotFound
+ }
+
+ p := pkgs[0]
+
+ if len(p.Errors) > 0 {
+ return "", p.Errors[0]
+ }
+
+ return p.Name, nil
+}
diff --git a/vendor/github.com/dave/dst/decorator/resolver/gotypes/resolver.go b/vendor/github.com/dave/dst/decorator/resolver/gotypes/resolver.go
new file mode 100644
index 0000000000..b79e56219c
--- /dev/null
+++ b/vendor/github.com/dave/dst/decorator/resolver/gotypes/resolver.go
@@ -0,0 +1,64 @@
+package gotypes
+
+import (
+ "errors"
+ "go/ast"
+ "go/types"
+)
+
+func New(uses map[*ast.Ident]types.Object) *DecoratorResolver {
+ return &DecoratorResolver{Uses: uses}
+}
+
+type DecoratorResolver struct {
+ Uses map[*ast.Ident]types.Object // Types info - must include Uses
+}
+
+func (r *DecoratorResolver) ResolveIdent(file *ast.File, parent ast.Node, parentField string, id *ast.Ident) (string, error) {
+
+ if r.Uses == nil {
+ return "", errors.New("gotypes.DecoratorResolver needs Uses in types info")
+ }
+
+ if se, ok := parent.(*ast.SelectorExpr); ok && parentField == "Sel" {
+
+ // if the parent is a SelectorExpr and this Ident is in the Sel field, only resolve the path
+ // if X is a package identifier
+
+ xid, ok := se.X.(*ast.Ident)
+ if !ok {
+ // x is not an ident -> not a qualified identifier
+ return "", nil
+ }
+ obj, ok := r.Uses[xid]
+ if !ok {
+ // not found in uses -> not a qualified identifier
+ return "", nil
+ }
+ pn, ok := obj.(*types.PkgName)
+ if !ok {
+ // not a pkgname -> not a remote identifier
+ return "", nil
+ }
+ return pn.Imported().Path(), nil
+ }
+
+ obj, ok := r.Uses[id]
+ if !ok {
+ // not found in uses -> not a remote identifier
+ return "", nil
+ }
+
+ if v, ok := obj.(*types.Var); ok && v.IsField() {
+ // field ident (e.g. name of a field in a composite literal) -> doesn't need qualified ident
+ return "", nil
+ }
+
+ pkg := obj.Pkg()
+ if pkg == nil {
+ // pre-defined idents in the universe scope - e.g. "byte"
+ return "", nil
+ }
+
+ return pkg.Path(), nil
+}
diff --git a/vendor/github.com/dave/dst/decorator/resolver/resolver.go b/vendor/github.com/dave/dst/decorator/resolver/resolver.go
new file mode 100644
index 0000000000..ccda191933
--- /dev/null
+++ b/vendor/github.com/dave/dst/decorator/resolver/resolver.go
@@ -0,0 +1,26 @@
+package resolver
+
+import (
+ "errors"
+ "go/ast"
+)
+
+// RestorerResolver resolves a package path to a package name.
+type RestorerResolver interface {
+ ResolvePackage(path string) (string, error)
+}
+
+// DecoratorResolver resolves an identifier to a local or remote reference.
+//
+// Returns path == "" if the node is not a local or remote reference (e.g. a field in a composite
+// literal, the selector in a selector expression etc.).
+//
+// Returns path == "" is the node is a local reference.
+//
+// Returns path != "" is the node is a remote reference.
+type DecoratorResolver interface {
+ ResolveIdent(file *ast.File, parent ast.Node, parentField string, id *ast.Ident) (path string, err error)
+}
+
+// ErrPackageNotFound means the package is not found
+var ErrPackageNotFound = errors.New("package not found")
diff --git a/vendor/github.com/dave/dst/decorator/restorer-generated.go b/vendor/github.com/dave/dst/decorator/restorer-generated.go
new file mode 100644
index 0000000000..62b95be59d
--- /dev/null
+++ b/vendor/github.com/dave/dst/decorator/restorer-generated.go
@@ -0,0 +1,1958 @@
+package decorator
+
+import (
+ "fmt"
+ "github.com/dave/dst"
+ "go/ast"
+ "go/token"
+)
+
+func (r *FileRestorer) restoreNode(n dst.Node, parentName, parentField, parentFieldType string, allowDuplicate bool) ast.Node {
+ if an, ok := r.Ast.Nodes[n]; ok {
+ if allowDuplicate {
+ return an
+ } else {
+ panic(fmt.Sprintf("duplicate node: %#v", n))
+ }
+ }
+ switch n := n.(type) {
+ case *dst.ArrayType:
+ out := &ast.ArrayType{}
+ r.Ast.Nodes[n] = out
+ r.Dst.Nodes[out] = n
+ r.applySpace(n, "Before", n.Decs.Before)
+
+ // Decoration: Start
+ r.applyDecorations(out, "Start", n.Decs.Start, false)
+
+ // Token: Lbrack
+ out.Lbrack = r.cursor
+ r.cursor += token.Pos(len(token.LBRACK.String()))
+
+ // Decoration: Lbrack
+ r.applyDecorations(out, "Lbrack", n.Decs.Lbrack, false)
+
+ // Node: Len
+ if n.Len != nil {
+ out.Len = r.restoreNode(n.Len, "ArrayType", "Len", "Expr", allowDuplicate).(ast.Expr)
+ }
+
+ // Token: Rbrack
+ r.cursor += token.Pos(len(token.RBRACK.String()))
+
+ // Decoration: Len
+ r.applyDecorations(out, "Len", n.Decs.Len, false)
+
+ // Node: Elt
+ if n.Elt != nil {
+ out.Elt = r.restoreNode(n.Elt, "ArrayType", "Elt", "Expr", allowDuplicate).(ast.Expr)
+ }
+
+ // Decoration: End
+ r.applyDecorations(out, "End", n.Decs.End, true)
+ r.applySpace(n, "After", n.Decs.After)
+
+ return out
+ case *dst.AssignStmt:
+ out := &ast.AssignStmt{}
+ r.Ast.Nodes[n] = out
+ r.Dst.Nodes[out] = n
+ r.applySpace(n, "Before", n.Decs.Before)
+
+ // Decoration: Start
+ r.applyDecorations(out, "Start", n.Decs.Start, false)
+
+ // List: Lhs
+ for _, v := range n.Lhs {
+ out.Lhs = append(out.Lhs, r.restoreNode(v, "AssignStmt", "Lhs", "Expr", allowDuplicate).(ast.Expr))
+ }
+
+ // Token: Tok
+ out.Tok = n.Tok
+ out.TokPos = r.cursor
+ r.cursor += token.Pos(len(n.Tok.String()))
+
+ // Decoration: Tok
+ r.applyDecorations(out, "Tok", n.Decs.Tok, false)
+
+ // List: Rhs
+ for _, v := range n.Rhs {
+ out.Rhs = append(out.Rhs, r.restoreNode(v, "AssignStmt", "Rhs", "Expr", allowDuplicate).(ast.Expr))
+ }
+
+ // Decoration: End
+ r.applyDecorations(out, "End", n.Decs.End, true)
+ r.applySpace(n, "After", n.Decs.After)
+
+ return out
+ case *dst.BadDecl:
+ out := &ast.BadDecl{}
+ r.Ast.Nodes[n] = out
+ r.Dst.Nodes[out] = n
+ r.applySpace(n, "Before", n.Decs.Before)
+
+ // Decoration: Start
+ r.applyDecorations(out, "Start", n.Decs.Start, false)
+
+ // Bad
+ out.From = r.cursor
+ r.cursor += token.Pos(n.Length)
+ out.To = r.cursor
+
+ // Decoration: End
+ r.applyDecorations(out, "End", n.Decs.End, true)
+ r.applySpace(n, "After", n.Decs.After)
+
+ return out
+ case *dst.BadExpr:
+ out := &ast.BadExpr{}
+ r.Ast.Nodes[n] = out
+ r.Dst.Nodes[out] = n
+ r.applySpace(n, "Before", n.Decs.Before)
+
+ // Decoration: Start
+ r.applyDecorations(out, "Start", n.Decs.Start, false)
+
+ // Bad
+ out.From = r.cursor
+ r.cursor += token.Pos(n.Length)
+ out.To = r.cursor
+
+ // Decoration: End
+ r.applyDecorations(out, "End", n.Decs.End, true)
+ r.applySpace(n, "After", n.Decs.After)
+
+ return out
+ case *dst.BadStmt:
+ out := &ast.BadStmt{}
+ r.Ast.Nodes[n] = out
+ r.Dst.Nodes[out] = n
+ r.applySpace(n, "Before", n.Decs.Before)
+
+ // Decoration: Start
+ r.applyDecorations(out, "Start", n.Decs.Start, false)
+
+ // Bad
+ out.From = r.cursor
+ r.cursor += token.Pos(n.Length)
+ out.To = r.cursor
+
+ // Decoration: End
+ r.applyDecorations(out, "End", n.Decs.End, true)
+ r.applySpace(n, "After", n.Decs.After)
+
+ return out
+ case *dst.BasicLit:
+ out := &ast.BasicLit{}
+ r.Ast.Nodes[n] = out
+ r.Dst.Nodes[out] = n
+ r.applySpace(n, "Before", n.Decs.Before)
+
+ // Decoration: Start
+ r.applyDecorations(out, "Start", n.Decs.Start, false)
+
+ // String: Value
+ r.applyLiteral(n.Value)
+ out.ValuePos = r.cursor
+ out.Value = n.Value
+ r.cursor += token.Pos(len(n.Value))
+
+ // Decoration: End
+ r.applyDecorations(out, "End", n.Decs.End, true)
+
+ // Value: Kind
+ out.Kind = n.Kind
+ r.applySpace(n, "After", n.Decs.After)
+
+ return out
+ case *dst.BinaryExpr:
+ out := &ast.BinaryExpr{}
+ r.Ast.Nodes[n] = out
+ r.Dst.Nodes[out] = n
+ r.applySpace(n, "Before", n.Decs.Before)
+
+ // Decoration: Start
+ r.applyDecorations(out, "Start", n.Decs.Start, false)
+
+ // Node: X
+ if n.X != nil {
+ out.X = r.restoreNode(n.X, "BinaryExpr", "X", "Expr", allowDuplicate).(ast.Expr)
+ }
+
+ // Decoration: X
+ r.applyDecorations(out, "X", n.Decs.X, false)
+
+ // Token: Op
+ out.Op = n.Op
+ out.OpPos = r.cursor
+ r.cursor += token.Pos(len(n.Op.String()))
+
+ // Decoration: Op
+ r.applyDecorations(out, "Op", n.Decs.Op, false)
+
+ // Node: Y
+ if n.Y != nil {
+ out.Y = r.restoreNode(n.Y, "BinaryExpr", "Y", "Expr", allowDuplicate).(ast.Expr)
+ }
+
+ // Decoration: End
+ r.applyDecorations(out, "End", n.Decs.End, true)
+ r.applySpace(n, "After", n.Decs.After)
+
+ return out
+ case *dst.BlockStmt:
+ out := &ast.BlockStmt{}
+ r.Ast.Nodes[n] = out
+ r.Dst.Nodes[out] = n
+ r.applySpace(n, "Before", n.Decs.Before)
+
+ // Decoration: Start
+ r.applyDecorations(out, "Start", n.Decs.Start, false)
+
+ // Token: Lbrace
+ out.Lbrace = r.cursor
+ r.cursor += token.Pos(len(token.LBRACE.String()))
+
+ // Decoration: Lbrace
+ r.applyDecorations(out, "Lbrace", n.Decs.Lbrace, false)
+
+ // List: List
+ for _, v := range n.List {
+ out.List = append(out.List, r.restoreNode(v, "BlockStmt", "List", "Stmt", allowDuplicate).(ast.Stmt))
+ }
+
+ // Token: Rbrace
+ if n.RbraceHasNoPos {
+ out.Rbrace = token.NoPos
+ } else {
+ out.Rbrace = r.cursor
+ }
+ r.cursor += token.Pos(len(token.RBRACE.String()))
+
+ // Decoration: End
+ r.applyDecorations(out, "End", n.Decs.End, true)
+ r.applySpace(n, "After", n.Decs.After)
+
+ return out
+ case *dst.BranchStmt:
+ out := &ast.BranchStmt{}
+ r.Ast.Nodes[n] = out
+ r.Dst.Nodes[out] = n
+ r.applySpace(n, "Before", n.Decs.Before)
+
+ // Decoration: Start
+ r.applyDecorations(out, "Start", n.Decs.Start, false)
+
+ // Token: Tok
+ out.Tok = n.Tok
+ out.TokPos = r.cursor
+ r.cursor += token.Pos(len(n.Tok.String()))
+
+ // Decoration: Tok
+ r.applyDecorations(out, "Tok", n.Decs.Tok, false)
+
+ // Node: Label
+ if n.Label != nil {
+ out.Label = r.restoreNode(n.Label, "BranchStmt", "Label", "Ident", allowDuplicate).(*ast.Ident)
+ }
+
+ // Decoration: End
+ r.applyDecorations(out, "End", n.Decs.End, true)
+ r.applySpace(n, "After", n.Decs.After)
+
+ return out
+ case *dst.CallExpr:
+ out := &ast.CallExpr{}
+ r.Ast.Nodes[n] = out
+ r.Dst.Nodes[out] = n
+ r.applySpace(n, "Before", n.Decs.Before)
+
+ // Decoration: Start
+ r.applyDecorations(out, "Start", n.Decs.Start, false)
+
+ // Node: Fun
+ if n.Fun != nil {
+ out.Fun = r.restoreNode(n.Fun, "CallExpr", "Fun", "Expr", allowDuplicate).(ast.Expr)
+ }
+
+ // Decoration: Fun
+ r.applyDecorations(out, "Fun", n.Decs.Fun, false)
+
+ // Token: Lparen
+ out.Lparen = r.cursor
+ r.cursor += token.Pos(len(token.LPAREN.String()))
+
+ // Decoration: Lparen
+ r.applyDecorations(out, "Lparen", n.Decs.Lparen, false)
+
+ // List: Args
+ for _, v := range n.Args {
+ out.Args = append(out.Args, r.restoreNode(v, "CallExpr", "Args", "Expr", allowDuplicate).(ast.Expr))
+ }
+
+ // Token: Ellipsis
+ if n.Ellipsis {
+ out.Ellipsis = r.cursor
+ r.cursor += token.Pos(len(token.ELLIPSIS.String()))
+ }
+
+ // Decoration: Ellipsis
+ r.applyDecorations(out, "Ellipsis", n.Decs.Ellipsis, false)
+
+ // Token: Rparen
+ out.Rparen = r.cursor
+ r.cursor += token.Pos(len(token.RPAREN.String()))
+
+ // Decoration: End
+ r.applyDecorations(out, "End", n.Decs.End, true)
+ r.applySpace(n, "After", n.Decs.After)
+
+ return out
+ case *dst.CaseClause:
+ out := &ast.CaseClause{}
+ r.Ast.Nodes[n] = out
+ r.Dst.Nodes[out] = n
+ r.applySpace(n, "Before", n.Decs.Before)
+
+ // Decoration: Start
+ r.applyDecorations(out, "Start", n.Decs.Start, false)
+
+ // Token: Case
+ out.Case = r.cursor
+ r.cursor += token.Pos(len(func() token.Token {
+ if n.List == nil {
+ return token.DEFAULT
+ }
+ return token.CASE
+ }().String()))
+
+ // Decoration: Case
+ r.applyDecorations(out, "Case", n.Decs.Case, false)
+
+ // List: List
+ for _, v := range n.List {
+ out.List = append(out.List, r.restoreNode(v, "CaseClause", "List", "Expr", allowDuplicate).(ast.Expr))
+ }
+
+ // Token: Colon
+ out.Colon = r.cursor
+ r.cursor += token.Pos(len(token.COLON.String()))
+
+ // Decoration: Colon
+ r.applyDecorations(out, "Colon", n.Decs.Colon, false)
+
+ // List: Body
+ for _, v := range n.Body {
+ out.Body = append(out.Body, r.restoreNode(v, "CaseClause", "Body", "Stmt", allowDuplicate).(ast.Stmt))
+ }
+
+ // Decoration: End
+ r.applyDecorations(out, "End", n.Decs.End, true)
+ r.applySpace(n, "After", n.Decs.After)
+
+ return out
+ case *dst.ChanType:
+ out := &ast.ChanType{}
+ r.Ast.Nodes[n] = out
+ r.Dst.Nodes[out] = n
+ r.applySpace(n, "Before", n.Decs.Before)
+
+ // Decoration: Start
+ r.applyDecorations(out, "Start", n.Decs.Start, false)
+
+ // Token: Begin
+ out.Begin = r.cursor
+ r.cursor += token.Pos(len(func() token.Token {
+ if n.Dir == dst.RECV {
+ return token.ARROW
+ }
+ return token.CHAN
+ }().String()))
+
+ // Token: Chan
+ if n.Dir == dst.RECV {
+ r.cursor += token.Pos(len(token.CHAN.String()))
+ }
+
+ // Decoration: Begin
+ r.applyDecorations(out, "Begin", n.Decs.Begin, false)
+
+ // Token: Arrow
+ if n.Dir == dst.SEND {
+ out.Arrow = r.cursor
+ r.cursor += token.Pos(len(token.ARROW.String()))
+ }
+
+ // Decoration: Arrow
+ r.applyDecorations(out, "Arrow", n.Decs.Arrow, false)
+
+ // Node: Value
+ if n.Value != nil {
+ out.Value = r.restoreNode(n.Value, "ChanType", "Value", "Expr", allowDuplicate).(ast.Expr)
+ }
+
+ // Decoration: End
+ r.applyDecorations(out, "End", n.Decs.End, true)
+
+ // Value: Dir
+ out.Dir = ast.ChanDir(n.Dir)
+ r.applySpace(n, "After", n.Decs.After)
+
+ return out
+ case *dst.CommClause:
+ out := &ast.CommClause{}
+ r.Ast.Nodes[n] = out
+ r.Dst.Nodes[out] = n
+ r.applySpace(n, "Before", n.Decs.Before)
+
+ // Decoration: Start
+ r.applyDecorations(out, "Start", n.Decs.Start, false)
+
+ // Token: Case
+ out.Case = r.cursor
+ r.cursor += token.Pos(len(func() token.Token {
+ if n.Comm == nil {
+ return token.DEFAULT
+ }
+ return token.CASE
+ }().String()))
+
+ // Decoration: Case
+ r.applyDecorations(out, "Case", n.Decs.Case, false)
+
+ // Node: Comm
+ if n.Comm != nil {
+ out.Comm = r.restoreNode(n.Comm, "CommClause", "Comm", "Stmt", allowDuplicate).(ast.Stmt)
+ }
+
+ // Decoration: Comm
+ r.applyDecorations(out, "Comm", n.Decs.Comm, false)
+
+ // Token: Colon
+ out.Colon = r.cursor
+ r.cursor += token.Pos(len(token.COLON.String()))
+
+ // Decoration: Colon
+ r.applyDecorations(out, "Colon", n.Decs.Colon, false)
+
+ // List: Body
+ for _, v := range n.Body {
+ out.Body = append(out.Body, r.restoreNode(v, "CommClause", "Body", "Stmt", allowDuplicate).(ast.Stmt))
+ }
+
+ // Decoration: End
+ r.applyDecorations(out, "End", n.Decs.End, true)
+ r.applySpace(n, "After", n.Decs.After)
+
+ return out
+ case *dst.CompositeLit:
+ out := &ast.CompositeLit{}
+ r.Ast.Nodes[n] = out
+ r.Dst.Nodes[out] = n
+ r.applySpace(n, "Before", n.Decs.Before)
+
+ // Decoration: Start
+ r.applyDecorations(out, "Start", n.Decs.Start, false)
+
+ // Node: Type
+ if n.Type != nil {
+ out.Type = r.restoreNode(n.Type, "CompositeLit", "Type", "Expr", allowDuplicate).(ast.Expr)
+ }
+
+ // Decoration: Type
+ r.applyDecorations(out, "Type", n.Decs.Type, false)
+
+ // Token: Lbrace
+ out.Lbrace = r.cursor
+ r.cursor += token.Pos(len(token.LBRACE.String()))
+
+ // Decoration: Lbrace
+ r.applyDecorations(out, "Lbrace", n.Decs.Lbrace, false)
+
+ // List: Elts
+ for _, v := range n.Elts {
+ out.Elts = append(out.Elts, r.restoreNode(v, "CompositeLit", "Elts", "Expr", allowDuplicate).(ast.Expr))
+ }
+
+ // Token: Rbrace
+ out.Rbrace = r.cursor
+ r.cursor += token.Pos(len(token.RBRACE.String()))
+
+ // Decoration: End
+ r.applyDecorations(out, "End", n.Decs.End, true)
+
+ // Value: Incomplete
+ out.Incomplete = n.Incomplete
+ r.applySpace(n, "After", n.Decs.After)
+
+ return out
+ case *dst.DeclStmt:
+ out := &ast.DeclStmt{}
+ r.Ast.Nodes[n] = out
+ r.Dst.Nodes[out] = n
+ r.applySpace(n, "Before", n.Decs.Before)
+
+ // Decoration: Start
+ r.applyDecorations(out, "Start", n.Decs.Start, false)
+
+ // Node: Decl
+ if n.Decl != nil {
+ out.Decl = r.restoreNode(n.Decl, "DeclStmt", "Decl", "Decl", allowDuplicate).(ast.Decl)
+ }
+
+ // Decoration: End
+ r.applyDecorations(out, "End", n.Decs.End, true)
+ r.applySpace(n, "After", n.Decs.After)
+
+ return out
+ case *dst.DeferStmt:
+ out := &ast.DeferStmt{}
+ r.Ast.Nodes[n] = out
+ r.Dst.Nodes[out] = n
+ r.applySpace(n, "Before", n.Decs.Before)
+
+ // Decoration: Start
+ r.applyDecorations(out, "Start", n.Decs.Start, false)
+
+ // Token: Defer
+ out.Defer = r.cursor
+ r.cursor += token.Pos(len(token.DEFER.String()))
+
+ // Decoration: Defer
+ r.applyDecorations(out, "Defer", n.Decs.Defer, false)
+
+ // Node: Call
+ if n.Call != nil {
+ out.Call = r.restoreNode(n.Call, "DeferStmt", "Call", "CallExpr", allowDuplicate).(*ast.CallExpr)
+ }
+
+ // Decoration: End
+ r.applyDecorations(out, "End", n.Decs.End, true)
+ r.applySpace(n, "After", n.Decs.After)
+
+ return out
+ case *dst.Ellipsis:
+ out := &ast.Ellipsis{}
+ r.Ast.Nodes[n] = out
+ r.Dst.Nodes[out] = n
+ r.applySpace(n, "Before", n.Decs.Before)
+
+ // Decoration: Start
+ r.applyDecorations(out, "Start", n.Decs.Start, false)
+
+ // Token: Ellipsis
+ out.Ellipsis = r.cursor
+ r.cursor += token.Pos(len(token.ELLIPSIS.String()))
+
+ // Decoration: Ellipsis
+ r.applyDecorations(out, "Ellipsis", n.Decs.Ellipsis, false)
+
+ // Node: Elt
+ if n.Elt != nil {
+ out.Elt = r.restoreNode(n.Elt, "Ellipsis", "Elt", "Expr", allowDuplicate).(ast.Expr)
+ }
+
+ // Decoration: End
+ r.applyDecorations(out, "End", n.Decs.End, true)
+ r.applySpace(n, "After", n.Decs.After)
+
+ return out
+ case *dst.EmptyStmt:
+ out := &ast.EmptyStmt{}
+ r.Ast.Nodes[n] = out
+ r.Dst.Nodes[out] = n
+ r.applySpace(n, "Before", n.Decs.Before)
+
+ // Decoration: Start
+ r.applyDecorations(out, "Start", n.Decs.Start, false)
+
+ // Token: Semicolon
+ if !n.Implicit {
+ out.Semicolon = r.cursor
+ r.cursor += token.Pos(len(token.ARROW.String()))
+ }
+
+ // Decoration: End
+ r.applyDecorations(out, "End", n.Decs.End, true)
+
+ // Value: Implicit
+ out.Implicit = n.Implicit
+ r.applySpace(n, "After", n.Decs.After)
+
+ return out
+ case *dst.ExprStmt:
+ out := &ast.ExprStmt{}
+ r.Ast.Nodes[n] = out
+ r.Dst.Nodes[out] = n
+ r.applySpace(n, "Before", n.Decs.Before)
+
+ // Decoration: Start
+ r.applyDecorations(out, "Start", n.Decs.Start, false)
+
+ // Node: X
+ if n.X != nil {
+ out.X = r.restoreNode(n.X, "ExprStmt", "X", "Expr", allowDuplicate).(ast.Expr)
+ }
+
+ // Decoration: End
+ r.applyDecorations(out, "End", n.Decs.End, true)
+ r.applySpace(n, "After", n.Decs.After)
+
+ return out
+ case *dst.Field:
+ out := &ast.Field{}
+ r.Ast.Nodes[n] = out
+ r.Dst.Nodes[out] = n
+ r.applySpace(n, "Before", n.Decs.Before)
+
+ // Decoration: Start
+ r.applyDecorations(out, "Start", n.Decs.Start, false)
+
+ // List: Names
+ for _, v := range n.Names {
+ out.Names = append(out.Names, r.restoreNode(v, "Field", "Names", "Ident", allowDuplicate).(*ast.Ident))
+ }
+
+ // Node: Type
+ if n.Type != nil {
+ out.Type = r.restoreNode(n.Type, "Field", "Type", "Expr", allowDuplicate).(ast.Expr)
+ }
+
+ // Decoration: Type
+ r.applyDecorations(out, "Type", n.Decs.Type, false)
+
+ // Node: Tag
+ if n.Tag != nil {
+ out.Tag = r.restoreNode(n.Tag, "Field", "Tag", "BasicLit", allowDuplicate).(*ast.BasicLit)
+ }
+
+ // Decoration: End
+ r.applyDecorations(out, "End", n.Decs.End, true)
+ r.applySpace(n, "After", n.Decs.After)
+
+ return out
+ case *dst.FieldList:
+ out := &ast.FieldList{}
+ r.Ast.Nodes[n] = out
+ r.Dst.Nodes[out] = n
+ r.applySpace(n, "Before", n.Decs.Before)
+
+ // Decoration: Start
+ r.applyDecorations(out, "Start", n.Decs.Start, false)
+
+ // Token: Opening
+ if n.Opening {
+ out.Opening = r.cursor
+ r.cursor += token.Pos(len(token.LPAREN.String()))
+ }
+
+ // Decoration: Opening
+ r.applyDecorations(out, "Opening", n.Decs.Opening, false)
+
+ // List: List
+ for _, v := range n.List {
+ out.List = append(out.List, r.restoreNode(v, "FieldList", "List", "Field", allowDuplicate).(*ast.Field))
+ }
+
+ // Token: Closing
+ if n.Closing {
+ out.Closing = r.cursor
+ r.cursor += token.Pos(len(token.RPAREN.String()))
+ }
+
+ // Decoration: End
+ r.applyDecorations(out, "End", n.Decs.End, true)
+ r.applySpace(n, "After", n.Decs.After)
+
+ return out
+ case *dst.File:
+ out := &ast.File{}
+ r.Ast.Nodes[n] = out
+ r.Dst.Nodes[out] = n
+ r.applySpace(n, "Before", n.Decs.Before)
+
+ // Decoration: Start
+ r.applyDecorations(out, "Start", n.Decs.Start, false)
+
+ // Token: Package
+ out.Package = r.cursor
+ r.cursor += token.Pos(len(token.PACKAGE.String()))
+
+ // Decoration: Package
+ r.applyDecorations(out, "Package", n.Decs.Package, false)
+
+ // Node: Name
+ if n.Name != nil {
+ out.Name = r.restoreNode(n.Name, "File", "Name", "Ident", allowDuplicate).(*ast.Ident)
+ }
+
+ // Decoration: Name
+ r.applyDecorations(out, "Name", n.Decs.Name, false)
+
+ // List: Decls
+ for _, v := range n.Decls {
+ out.Decls = append(out.Decls, r.restoreNode(v, "File", "Decls", "Decl", allowDuplicate).(ast.Decl))
+ }
+
+ // Decoration: End
+ r.applyDecorations(out, "End", n.Decs.End, true)
+
+ // Scope: Scope
+ out.Scope = r.restoreScope(n.Scope)
+
+ // Value: GoVersion
+ out.GoVersion = n.GoVersion
+ r.applySpace(n, "After", n.Decs.After)
+
+ return out
+ case *dst.ForStmt:
+ out := &ast.ForStmt{}
+ r.Ast.Nodes[n] = out
+ r.Dst.Nodes[out] = n
+ r.applySpace(n, "Before", n.Decs.Before)
+
+ // Decoration: Start
+ r.applyDecorations(out, "Start", n.Decs.Start, false)
+
+ // Token: For
+ out.For = r.cursor
+ r.cursor += token.Pos(len(token.FOR.String()))
+
+ // Decoration: For
+ r.applyDecorations(out, "For", n.Decs.For, false)
+
+ // Node: Init
+ if n.Init != nil {
+ out.Init = r.restoreNode(n.Init, "ForStmt", "Init", "Stmt", allowDuplicate).(ast.Stmt)
+ }
+
+ // Token: InitSemicolon
+ if n.Init != nil {
+ r.cursor += token.Pos(len(token.SEMICOLON.String()))
+ }
+
+ // Decoration: Init
+ r.applyDecorations(out, "Init", n.Decs.Init, false)
+
+ // Node: Cond
+ if n.Cond != nil {
+ out.Cond = r.restoreNode(n.Cond, "ForStmt", "Cond", "Expr", allowDuplicate).(ast.Expr)
+ }
+
+ // Token: CondSemicolon
+ if n.Post != nil {
+ r.cursor += token.Pos(len(token.SEMICOLON.String()))
+ }
+
+ // Decoration: Cond
+ r.applyDecorations(out, "Cond", n.Decs.Cond, false)
+
+ // Node: Post
+ if n.Post != nil {
+ out.Post = r.restoreNode(n.Post, "ForStmt", "Post", "Stmt", allowDuplicate).(ast.Stmt)
+ }
+
+ // Decoration: Post
+ r.applyDecorations(out, "Post", n.Decs.Post, false)
+
+ // Node: Body
+ if n.Body != nil {
+ out.Body = r.restoreNode(n.Body, "ForStmt", "Body", "BlockStmt", allowDuplicate).(*ast.BlockStmt)
+ }
+
+ // Decoration: End
+ r.applyDecorations(out, "End", n.Decs.End, true)
+ r.applySpace(n, "After", n.Decs.After)
+
+ return out
+ case *dst.FuncDecl:
+ out := &ast.FuncDecl{}
+ r.Ast.Nodes[n] = out
+ r.Dst.Nodes[out] = n
+ r.applySpace(n, "Before", n.Decs.Before)
+
+ // Init: Type
+ out.Type = &ast.FuncType{}
+
+ // Decoration: Start
+ r.applyDecorations(out, "Start", n.Decs.Start, false)
+
+ // Special decoration: Start
+ r.applyDecorations(out, "Start", n.Type.Decs.Start, false)
+
+ // Token: Func
+ if true {
+ out.Type.Func = r.cursor
+ r.cursor += token.Pos(len(token.FUNC.String()))
+ }
+
+ // Decoration: Func
+ r.applyDecorations(out, "Func", n.Decs.Func, false)
+
+ // Special decoration: Func
+ r.applyDecorations(out, "Func", n.Type.Decs.Func, false)
+
+ // Node: Recv
+ if n.Recv != nil {
+ out.Recv = r.restoreNode(n.Recv, "FuncDecl", "Recv", "FieldList", allowDuplicate).(*ast.FieldList)
+ }
+
+ // Decoration: Recv
+ r.applyDecorations(out, "Recv", n.Decs.Recv, false)
+
+ // Node: Name
+ if n.Name != nil {
+ out.Name = r.restoreNode(n.Name, "FuncDecl", "Name", "Ident", allowDuplicate).(*ast.Ident)
+ }
+
+ // Decoration: Name
+ r.applyDecorations(out, "Name", n.Decs.Name, false)
+
+ // Node: TypeParams
+ if n.Type.TypeParams != nil {
+ out.Type.TypeParams = r.restoreNode(n.Type.TypeParams, "FuncDecl", "TypeParams", "FieldList", allowDuplicate).(*ast.FieldList)
+ }
+
+ // Decoration: TypeParams
+ r.applyDecorations(out, "TypeParams", n.Decs.TypeParams, false)
+
+ // Special decoration: TypeParams
+ r.applyDecorations(out, "TypeParams", n.Type.Decs.TypeParams, false)
+
+ // Node: Params
+ if n.Type.Params != nil {
+ out.Type.Params = r.restoreNode(n.Type.Params, "FuncDecl", "Params", "FieldList", allowDuplicate).(*ast.FieldList)
+ }
+
+ // Decoration: Params
+ r.applyDecorations(out, "Params", n.Decs.Params, false)
+
+ // Special decoration: Params
+ r.applyDecorations(out, "Params", n.Type.Decs.Params, false)
+
+ // Node: Results
+ if n.Type.Results != nil {
+ out.Type.Results = r.restoreNode(n.Type.Results, "FuncDecl", "Results", "FieldList", allowDuplicate).(*ast.FieldList)
+ }
+
+ // Decoration: Results
+ r.applyDecorations(out, "Results", n.Decs.Results, false)
+
+ // Special decoration: End
+ r.applyDecorations(out, "End", n.Type.Decs.End, false)
+
+ // Node: Body
+ if n.Body != nil {
+ out.Body = r.restoreNode(n.Body, "FuncDecl", "Body", "BlockStmt", allowDuplicate).(*ast.BlockStmt)
+ }
+
+ // Decoration: End
+ r.applyDecorations(out, "End", n.Decs.End, true)
+ r.applySpace(n, "After", n.Decs.After)
+
+ return out
+ case *dst.FuncLit:
+ out := &ast.FuncLit{}
+ r.Ast.Nodes[n] = out
+ r.Dst.Nodes[out] = n
+ r.applySpace(n, "Before", n.Decs.Before)
+
+ // Decoration: Start
+ r.applyDecorations(out, "Start", n.Decs.Start, false)
+
+ // Node: Type
+ if n.Type != nil {
+ out.Type = r.restoreNode(n.Type, "FuncLit", "Type", "FuncType", allowDuplicate).(*ast.FuncType)
+ }
+
+ // Decoration: Type
+ r.applyDecorations(out, "Type", n.Decs.Type, false)
+
+ // Node: Body
+ if n.Body != nil {
+ out.Body = r.restoreNode(n.Body, "FuncLit", "Body", "BlockStmt", allowDuplicate).(*ast.BlockStmt)
+ }
+
+ // Decoration: End
+ r.applyDecorations(out, "End", n.Decs.End, true)
+ r.applySpace(n, "After", n.Decs.After)
+
+ return out
+ case *dst.FuncType:
+ out := &ast.FuncType{}
+ r.Ast.Nodes[n] = out
+ r.Dst.Nodes[out] = n
+ r.applySpace(n, "Before", n.Decs.Before)
+
+ // Decoration: Start
+ r.applyDecorations(out, "Start", n.Decs.Start, false)
+
+ // Token: Func
+ if n.Func {
+ out.Func = r.cursor
+ r.cursor += token.Pos(len(token.FUNC.String()))
+ }
+
+ // Decoration: Func
+ r.applyDecorations(out, "Func", n.Decs.Func, false)
+
+ // Node: TypeParams
+ if n.TypeParams != nil {
+ out.TypeParams = r.restoreNode(n.TypeParams, "FuncType", "TypeParams", "FieldList", allowDuplicate).(*ast.FieldList)
+ }
+
+ // Decoration: TypeParams
+ r.applyDecorations(out, "TypeParams", n.Decs.TypeParams, false)
+
+ // Node: Params
+ if n.Params != nil {
+ out.Params = r.restoreNode(n.Params, "FuncType", "Params", "FieldList", allowDuplicate).(*ast.FieldList)
+ }
+
+ // Decoration: Params
+ r.applyDecorations(out, "Params", n.Decs.Params, false)
+
+ // Node: Results
+ if n.Results != nil {
+ out.Results = r.restoreNode(n.Results, "FuncType", "Results", "FieldList", allowDuplicate).(*ast.FieldList)
+ }
+
+ // Decoration: End
+ r.applyDecorations(out, "End", n.Decs.End, true)
+ r.applySpace(n, "After", n.Decs.After)
+
+ return out
+ case *dst.GenDecl:
+ out := &ast.GenDecl{}
+ r.Ast.Nodes[n] = out
+ r.Dst.Nodes[out] = n
+ r.applySpace(n, "Before", n.Decs.Before)
+
+ // Decoration: Start
+ r.applyDecorations(out, "Start", n.Decs.Start, false)
+
+ // Token: Tok
+ out.Tok = n.Tok
+ out.TokPos = r.cursor
+ r.cursor += token.Pos(len(n.Tok.String()))
+
+ // Decoration: Tok
+ r.applyDecorations(out, "Tok", n.Decs.Tok, false)
+
+ // Token: Lparen
+ if n.Lparen {
+ out.Lparen = r.cursor
+ r.cursor += token.Pos(len(token.LPAREN.String()))
+ }
+
+ // Decoration: Lparen
+ r.applyDecorations(out, "Lparen", n.Decs.Lparen, false)
+
+ // List: Specs
+ for _, v := range n.Specs {
+ out.Specs = append(out.Specs, r.restoreNode(v, "GenDecl", "Specs", "Spec", allowDuplicate).(ast.Spec))
+ }
+
+ // Token: Rparen
+ if n.Rparen {
+ out.Rparen = r.cursor
+ r.cursor += token.Pos(len(token.RPAREN.String()))
+ }
+
+ // Decoration: End
+ r.applyDecorations(out, "End", n.Decs.End, true)
+ r.applySpace(n, "After", n.Decs.After)
+
+ return out
+ case *dst.GoStmt:
+ out := &ast.GoStmt{}
+ r.Ast.Nodes[n] = out
+ r.Dst.Nodes[out] = n
+ r.applySpace(n, "Before", n.Decs.Before)
+
+ // Decoration: Start
+ r.applyDecorations(out, "Start", n.Decs.Start, false)
+
+ // Token: Go
+ out.Go = r.cursor
+ r.cursor += token.Pos(len(token.GO.String()))
+
+ // Decoration: Go
+ r.applyDecorations(out, "Go", n.Decs.Go, false)
+
+ // Node: Call
+ if n.Call != nil {
+ out.Call = r.restoreNode(n.Call, "GoStmt", "Call", "CallExpr", allowDuplicate).(*ast.CallExpr)
+ }
+
+ // Decoration: End
+ r.applyDecorations(out, "End", n.Decs.End, true)
+ r.applySpace(n, "After", n.Decs.After)
+
+ return out
+ case *dst.Ident:
+
+ // Special case for *dst.Ident - replace with SelectorExpr if needed
+ sel := r.restoreIdent(n, parentName, parentField, parentFieldType, allowDuplicate)
+ if sel != nil {
+ return sel
+ }
+
+ out := &ast.Ident{}
+ r.Ast.Nodes[n] = out
+ r.Dst.Nodes[out] = n
+ r.applySpace(n, "Before", n.Decs.Before)
+
+ // Decoration: Start
+ r.applyDecorations(out, "Start", n.Decs.Start, false)
+
+ // Decoration: X
+ r.applyDecorations(out, "X", n.Decs.X, false)
+
+ // String: Name
+ out.NamePos = r.cursor
+ out.Name = n.Name
+ r.cursor += token.Pos(len(n.Name))
+
+ // Decoration: End
+ r.applyDecorations(out, "End", n.Decs.End, true)
+
+ // Object: Obj
+ out.Obj = r.restoreObject(n.Obj)
+ r.applySpace(n, "After", n.Decs.After)
+
+ return out
+ case *dst.IfStmt:
+ out := &ast.IfStmt{}
+ r.Ast.Nodes[n] = out
+ r.Dst.Nodes[out] = n
+ r.applySpace(n, "Before", n.Decs.Before)
+
+ // Decoration: Start
+ r.applyDecorations(out, "Start", n.Decs.Start, false)
+
+ // Token: If
+ out.If = r.cursor
+ r.cursor += token.Pos(len(token.IF.String()))
+
+ // Decoration: If
+ r.applyDecorations(out, "If", n.Decs.If, false)
+
+ // Node: Init
+ if n.Init != nil {
+ out.Init = r.restoreNode(n.Init, "IfStmt", "Init", "Stmt", allowDuplicate).(ast.Stmt)
+ }
+
+ // Decoration: Init
+ r.applyDecorations(out, "Init", n.Decs.Init, false)
+
+ // Node: Cond
+ if n.Cond != nil {
+ out.Cond = r.restoreNode(n.Cond, "IfStmt", "Cond", "Expr", allowDuplicate).(ast.Expr)
+ }
+
+ // Decoration: Cond
+ r.applyDecorations(out, "Cond", n.Decs.Cond, false)
+
+ // Node: Body
+ if n.Body != nil {
+ out.Body = r.restoreNode(n.Body, "IfStmt", "Body", "BlockStmt", allowDuplicate).(*ast.BlockStmt)
+ }
+
+ // Token: ElseTok
+ if n.Else != nil {
+ r.cursor += token.Pos(len(token.ELSE.String()))
+ }
+
+ // Decoration: Else
+ r.applyDecorations(out, "Else", n.Decs.Else, false)
+
+ // Node: Else
+ if n.Else != nil {
+ out.Else = r.restoreNode(n.Else, "IfStmt", "Else", "Stmt", allowDuplicate).(ast.Stmt)
+ }
+
+ // Decoration: End
+ r.applyDecorations(out, "End", n.Decs.End, true)
+ r.applySpace(n, "After", n.Decs.After)
+
+ return out
+ case *dst.ImportSpec:
+ out := &ast.ImportSpec{}
+ r.Ast.Nodes[n] = out
+ r.Dst.Nodes[out] = n
+ r.applySpace(n, "Before", n.Decs.Before)
+
+ // Decoration: Start
+ r.applyDecorations(out, "Start", n.Decs.Start, false)
+
+ // Node: Name
+ if n.Name != nil {
+ out.Name = r.restoreNode(n.Name, "ImportSpec", "Name", "Ident", allowDuplicate).(*ast.Ident)
+ }
+
+ // Decoration: Name
+ r.applyDecorations(out, "Name", n.Decs.Name, false)
+
+ // Node: Path
+ if n.Path != nil {
+ out.Path = r.restoreNode(n.Path, "ImportSpec", "Path", "BasicLit", allowDuplicate).(*ast.BasicLit)
+ }
+
+ // Decoration: End
+ r.applyDecorations(out, "End", n.Decs.End, true)
+ r.applySpace(n, "After", n.Decs.After)
+
+ return out
+ case *dst.IncDecStmt:
+ out := &ast.IncDecStmt{}
+ r.Ast.Nodes[n] = out
+ r.Dst.Nodes[out] = n
+ r.applySpace(n, "Before", n.Decs.Before)
+
+ // Decoration: Start
+ r.applyDecorations(out, "Start", n.Decs.Start, false)
+
+ // Node: X
+ if n.X != nil {
+ out.X = r.restoreNode(n.X, "IncDecStmt", "X", "Expr", allowDuplicate).(ast.Expr)
+ }
+
+ // Decoration: X
+ r.applyDecorations(out, "X", n.Decs.X, false)
+
+ // Token: Tok
+ out.Tok = n.Tok
+ out.TokPos = r.cursor
+ r.cursor += token.Pos(len(n.Tok.String()))
+
+ // Decoration: End
+ r.applyDecorations(out, "End", n.Decs.End, true)
+ r.applySpace(n, "After", n.Decs.After)
+
+ return out
+ case *dst.IndexExpr:
+ out := &ast.IndexExpr{}
+ r.Ast.Nodes[n] = out
+ r.Dst.Nodes[out] = n
+ r.applySpace(n, "Before", n.Decs.Before)
+
+ // Decoration: Start
+ r.applyDecorations(out, "Start", n.Decs.Start, false)
+
+ // Node: X
+ if n.X != nil {
+ out.X = r.restoreNode(n.X, "IndexExpr", "X", "Expr", allowDuplicate).(ast.Expr)
+ }
+
+ // Decoration: X
+ r.applyDecorations(out, "X", n.Decs.X, false)
+
+ // Token: Lbrack
+ out.Lbrack = r.cursor
+ r.cursor += token.Pos(len(token.LBRACK.String()))
+
+ // Decoration: Lbrack
+ r.applyDecorations(out, "Lbrack", n.Decs.Lbrack, false)
+
+ // Node: Index
+ if n.Index != nil {
+ out.Index = r.restoreNode(n.Index, "IndexExpr", "Index", "Expr", allowDuplicate).(ast.Expr)
+ }
+
+ // Decoration: Index
+ r.applyDecorations(out, "Index", n.Decs.Index, false)
+
+ // Token: Rbrack
+ out.Rbrack = r.cursor
+ r.cursor += token.Pos(len(token.RBRACK.String()))
+
+ // Decoration: End
+ r.applyDecorations(out, "End", n.Decs.End, true)
+ r.applySpace(n, "After", n.Decs.After)
+
+ return out
+ case *dst.IndexListExpr:
+ out := &ast.IndexListExpr{}
+ r.Ast.Nodes[n] = out
+ r.Dst.Nodes[out] = n
+ r.applySpace(n, "Before", n.Decs.Before)
+
+ // Decoration: Start
+ r.applyDecorations(out, "Start", n.Decs.Start, false)
+
+ // Node: X
+ if n.X != nil {
+ out.X = r.restoreNode(n.X, "IndexListExpr", "X", "Expr", allowDuplicate).(ast.Expr)
+ }
+
+ // Decoration: X
+ r.applyDecorations(out, "X", n.Decs.X, false)
+
+ // Token: Lbrack
+ out.Lbrack = r.cursor
+ r.cursor += token.Pos(len(token.LBRACK.String()))
+
+ // Decoration: Lbrack
+ r.applyDecorations(out, "Lbrack", n.Decs.Lbrack, false)
+
+ // List: Indices
+ for _, v := range n.Indices {
+ out.Indices = append(out.Indices, r.restoreNode(v, "IndexListExpr", "Indices", "Expr", allowDuplicate).(ast.Expr))
+ }
+
+ // Decoration: Indices
+ r.applyDecorations(out, "Indices", n.Decs.Indices, false)
+
+ // Token: Rbrack
+ out.Rbrack = r.cursor
+ r.cursor += token.Pos(len(token.RBRACK.String()))
+
+ // Decoration: End
+ r.applyDecorations(out, "End", n.Decs.End, true)
+ r.applySpace(n, "After", n.Decs.After)
+
+ return out
+ case *dst.InterfaceType:
+ out := &ast.InterfaceType{}
+ r.Ast.Nodes[n] = out
+ r.Dst.Nodes[out] = n
+ r.applySpace(n, "Before", n.Decs.Before)
+
+ // Decoration: Start
+ r.applyDecorations(out, "Start", n.Decs.Start, false)
+
+ // Token: Interface
+ out.Interface = r.cursor
+ r.cursor += token.Pos(len(token.INTERFACE.String()))
+
+ // Decoration: Interface
+ r.applyDecorations(out, "Interface", n.Decs.Interface, false)
+
+ // Node: Methods
+ if n.Methods != nil {
+ out.Methods = r.restoreNode(n.Methods, "InterfaceType", "Methods", "FieldList", allowDuplicate).(*ast.FieldList)
+ }
+
+ // Decoration: End
+ r.applyDecorations(out, "End", n.Decs.End, true)
+
+ // Value: Incomplete
+ out.Incomplete = n.Incomplete
+ r.applySpace(n, "After", n.Decs.After)
+
+ return out
+ case *dst.KeyValueExpr:
+ out := &ast.KeyValueExpr{}
+ r.Ast.Nodes[n] = out
+ r.Dst.Nodes[out] = n
+ r.applySpace(n, "Before", n.Decs.Before)
+
+ // Decoration: Start
+ r.applyDecorations(out, "Start", n.Decs.Start, false)
+
+ // Node: Key
+ if n.Key != nil {
+ out.Key = r.restoreNode(n.Key, "KeyValueExpr", "Key", "Expr", allowDuplicate).(ast.Expr)
+ }
+
+ // Decoration: Key
+ r.applyDecorations(out, "Key", n.Decs.Key, false)
+
+ // Token: Colon
+ out.Colon = r.cursor
+ r.cursor += token.Pos(len(token.COLON.String()))
+
+ // Decoration: Colon
+ r.applyDecorations(out, "Colon", n.Decs.Colon, false)
+
+ // Node: Value
+ if n.Value != nil {
+ out.Value = r.restoreNode(n.Value, "KeyValueExpr", "Value", "Expr", allowDuplicate).(ast.Expr)
+ }
+
+ // Decoration: End
+ r.applyDecorations(out, "End", n.Decs.End, true)
+ r.applySpace(n, "After", n.Decs.After)
+
+ return out
+ case *dst.LabeledStmt:
+ out := &ast.LabeledStmt{}
+ r.Ast.Nodes[n] = out
+ r.Dst.Nodes[out] = n
+ r.applySpace(n, "Before", n.Decs.Before)
+
+ // Decoration: Start
+ r.applyDecorations(out, "Start", n.Decs.Start, false)
+
+ // Node: Label
+ if n.Label != nil {
+ out.Label = r.restoreNode(n.Label, "LabeledStmt", "Label", "Ident", allowDuplicate).(*ast.Ident)
+ }
+
+ // Decoration: Label
+ r.applyDecorations(out, "Label", n.Decs.Label, false)
+
+ // Token: Colon
+ out.Colon = r.cursor
+ r.cursor += token.Pos(len(token.COLON.String()))
+
+ // Decoration: Colon
+ r.applyDecorations(out, "Colon", n.Decs.Colon, false)
+
+ // Node: Stmt
+ if n.Stmt != nil {
+ out.Stmt = r.restoreNode(n.Stmt, "LabeledStmt", "Stmt", "Stmt", allowDuplicate).(ast.Stmt)
+ }
+
+ // Decoration: End
+ r.applyDecorations(out, "End", n.Decs.End, true)
+ r.applySpace(n, "After", n.Decs.After)
+
+ return out
+ case *dst.MapType:
+ out := &ast.MapType{}
+ r.Ast.Nodes[n] = out
+ r.Dst.Nodes[out] = n
+ r.applySpace(n, "Before", n.Decs.Before)
+
+ // Decoration: Start
+ r.applyDecorations(out, "Start", n.Decs.Start, false)
+
+ // Token: Map
+ out.Map = r.cursor
+ r.cursor += token.Pos(len(token.MAP.String()))
+
+ // Token: Lbrack
+ r.cursor += token.Pos(len(token.LBRACK.String()))
+
+ // Decoration: Map
+ r.applyDecorations(out, "Map", n.Decs.Map, false)
+
+ // Node: Key
+ if n.Key != nil {
+ out.Key = r.restoreNode(n.Key, "MapType", "Key", "Expr", allowDuplicate).(ast.Expr)
+ }
+
+ // Token: Rbrack
+ r.cursor += token.Pos(len(token.RBRACK.String()))
+
+ // Decoration: Key
+ r.applyDecorations(out, "Key", n.Decs.Key, false)
+
+ // Node: Value
+ if n.Value != nil {
+ out.Value = r.restoreNode(n.Value, "MapType", "Value", "Expr", allowDuplicate).(ast.Expr)
+ }
+
+ // Decoration: End
+ r.applyDecorations(out, "End", n.Decs.End, true)
+ r.applySpace(n, "After", n.Decs.After)
+
+ return out
+ case *dst.Package:
+ out := &ast.Package{}
+ r.Ast.Nodes[n] = out
+ r.Dst.Nodes[out] = n
+
+ // Value: Name
+ out.Name = n.Name
+
+ // Scope: Scope
+ out.Scope = r.restoreScope(n.Scope)
+
+ // Map: Imports
+ out.Imports = map[string]*ast.Object{}
+ for k, v := range n.Imports {
+ out.Imports[k] = r.restoreObject(v)
+ }
+
+ // Map: Files
+ out.Files = map[string]*ast.File{}
+ for k, v := range n.Files {
+ out.Files[k] = r.restoreNode(v, "Package", "Files", "File", allowDuplicate).(*ast.File)
+ }
+
+ return out
+ case *dst.ParenExpr:
+ out := &ast.ParenExpr{}
+ r.Ast.Nodes[n] = out
+ r.Dst.Nodes[out] = n
+ r.applySpace(n, "Before", n.Decs.Before)
+
+ // Decoration: Start
+ r.applyDecorations(out, "Start", n.Decs.Start, false)
+
+ // Token: Lparen
+ out.Lparen = r.cursor
+ r.cursor += token.Pos(len(token.LPAREN.String()))
+
+ // Decoration: Lparen
+ r.applyDecorations(out, "Lparen", n.Decs.Lparen, false)
+
+ // Node: X
+ if n.X != nil {
+ out.X = r.restoreNode(n.X, "ParenExpr", "X", "Expr", allowDuplicate).(ast.Expr)
+ }
+
+ // Decoration: X
+ r.applyDecorations(out, "X", n.Decs.X, false)
+
+ // Token: Rparen
+ out.Rparen = r.cursor
+ r.cursor += token.Pos(len(token.RPAREN.String()))
+
+ // Decoration: End
+ r.applyDecorations(out, "End", n.Decs.End, true)
+ r.applySpace(n, "After", n.Decs.After)
+
+ return out
+ case *dst.RangeStmt:
+ out := &ast.RangeStmt{}
+ r.Ast.Nodes[n] = out
+ r.Dst.Nodes[out] = n
+ r.applySpace(n, "Before", n.Decs.Before)
+
+ // Decoration: Start
+ r.applyDecorations(out, "Start", n.Decs.Start, false)
+
+ // Token: For
+ out.For = r.cursor
+ r.cursor += token.Pos(len(token.FOR.String()))
+
+ // Decoration: For
+ r.applyDecorations(out, "For", n.Decs.For, false)
+
+ // Node: Key
+ if n.Key != nil {
+ out.Key = r.restoreNode(n.Key, "RangeStmt", "Key", "Expr", allowDuplicate).(ast.Expr)
+ }
+
+ // Token: Comma
+ if n.Value != nil {
+ r.cursor += token.Pos(len(token.COMMA.String()))
+ }
+
+ // Decoration: Key
+ r.applyDecorations(out, "Key", n.Decs.Key, false)
+
+ // Node: Value
+ if n.Value != nil {
+ out.Value = r.restoreNode(n.Value, "RangeStmt", "Value", "Expr", allowDuplicate).(ast.Expr)
+ }
+
+ // Decoration: Value
+ r.applyDecorations(out, "Value", n.Decs.Value, false)
+
+ // Token: Tok
+ if n.Tok != token.ILLEGAL {
+ out.Tok = n.Tok
+ out.TokPos = r.cursor
+ r.cursor += token.Pos(len(n.Tok.String()))
+ }
+
+ // Token: Range
+ r.cursor += token.Pos(len(token.RANGE.String()))
+
+ // Decoration: Range
+ r.applyDecorations(out, "Range", n.Decs.Range, false)
+
+ // Node: X
+ if n.X != nil {
+ out.X = r.restoreNode(n.X, "RangeStmt", "X", "Expr", allowDuplicate).(ast.Expr)
+ }
+
+ // Decoration: X
+ r.applyDecorations(out, "X", n.Decs.X, false)
+
+ // Node: Body
+ if n.Body != nil {
+ out.Body = r.restoreNode(n.Body, "RangeStmt", "Body", "BlockStmt", allowDuplicate).(*ast.BlockStmt)
+ }
+
+ // Decoration: End
+ r.applyDecorations(out, "End", n.Decs.End, true)
+ r.applySpace(n, "After", n.Decs.After)
+
+ return out
+ case *dst.ReturnStmt:
+ out := &ast.ReturnStmt{}
+ r.Ast.Nodes[n] = out
+ r.Dst.Nodes[out] = n
+ r.applySpace(n, "Before", n.Decs.Before)
+
+ // Decoration: Start
+ r.applyDecorations(out, "Start", n.Decs.Start, false)
+
+ // Token: Return
+ out.Return = r.cursor
+ r.cursor += token.Pos(len(token.RETURN.String()))
+
+ // Decoration: Return
+ r.applyDecorations(out, "Return", n.Decs.Return, false)
+
+ // List: Results
+ for _, v := range n.Results {
+ out.Results = append(out.Results, r.restoreNode(v, "ReturnStmt", "Results", "Expr", allowDuplicate).(ast.Expr))
+ }
+
+ // Decoration: End
+ r.applyDecorations(out, "End", n.Decs.End, true)
+ r.applySpace(n, "After", n.Decs.After)
+
+ return out
+ case *dst.SelectStmt:
+ out := &ast.SelectStmt{}
+ r.Ast.Nodes[n] = out
+ r.Dst.Nodes[out] = n
+ r.applySpace(n, "Before", n.Decs.Before)
+
+ // Decoration: Start
+ r.applyDecorations(out, "Start", n.Decs.Start, false)
+
+ // Token: Select
+ out.Select = r.cursor
+ r.cursor += token.Pos(len(token.SELECT.String()))
+
+ // Decoration: Select
+ r.applyDecorations(out, "Select", n.Decs.Select, false)
+
+ // Node: Body
+ if n.Body != nil {
+ out.Body = r.restoreNode(n.Body, "SelectStmt", "Body", "BlockStmt", allowDuplicate).(*ast.BlockStmt)
+ }
+
+ // Decoration: End
+ r.applyDecorations(out, "End", n.Decs.End, true)
+ r.applySpace(n, "After", n.Decs.After)
+
+ return out
+ case *dst.SelectorExpr:
+ out := &ast.SelectorExpr{}
+ r.Ast.Nodes[n] = out
+ r.Dst.Nodes[out] = n
+ r.applySpace(n, "Before", n.Decs.Before)
+
+ // Decoration: Start
+ r.applyDecorations(out, "Start", n.Decs.Start, false)
+
+ // Node: X
+ if n.X != nil {
+ out.X = r.restoreNode(n.X, "SelectorExpr", "X", "Expr", allowDuplicate).(ast.Expr)
+ }
+
+ // Token: Period
+ r.cursor += token.Pos(len(token.PERIOD.String()))
+
+ // Decoration: X
+ r.applyDecorations(out, "X", n.Decs.X, false)
+
+ // Node: Sel
+ if n.Sel != nil {
+ out.Sel = r.restoreNode(n.Sel, "SelectorExpr", "Sel", "Ident", allowDuplicate).(*ast.Ident)
+ }
+
+ // Decoration: End
+ r.applyDecorations(out, "End", n.Decs.End, true)
+ r.applySpace(n, "After", n.Decs.After)
+
+ return out
+ case *dst.SendStmt:
+ out := &ast.SendStmt{}
+ r.Ast.Nodes[n] = out
+ r.Dst.Nodes[out] = n
+ r.applySpace(n, "Before", n.Decs.Before)
+
+ // Decoration: Start
+ r.applyDecorations(out, "Start", n.Decs.Start, false)
+
+ // Node: Chan
+ if n.Chan != nil {
+ out.Chan = r.restoreNode(n.Chan, "SendStmt", "Chan", "Expr", allowDuplicate).(ast.Expr)
+ }
+
+ // Decoration: Chan
+ r.applyDecorations(out, "Chan", n.Decs.Chan, false)
+
+ // Token: Arrow
+ out.Arrow = r.cursor
+ r.cursor += token.Pos(len(token.ARROW.String()))
+
+ // Decoration: Arrow
+ r.applyDecorations(out, "Arrow", n.Decs.Arrow, false)
+
+ // Node: Value
+ if n.Value != nil {
+ out.Value = r.restoreNode(n.Value, "SendStmt", "Value", "Expr", allowDuplicate).(ast.Expr)
+ }
+
+ // Decoration: End
+ r.applyDecorations(out, "End", n.Decs.End, true)
+ r.applySpace(n, "After", n.Decs.After)
+
+ return out
+ case *dst.SliceExpr:
+ out := &ast.SliceExpr{}
+ r.Ast.Nodes[n] = out
+ r.Dst.Nodes[out] = n
+ r.applySpace(n, "Before", n.Decs.Before)
+
+ // Decoration: Start
+ r.applyDecorations(out, "Start", n.Decs.Start, false)
+
+ // Node: X
+ if n.X != nil {
+ out.X = r.restoreNode(n.X, "SliceExpr", "X", "Expr", allowDuplicate).(ast.Expr)
+ }
+
+ // Decoration: X
+ r.applyDecorations(out, "X", n.Decs.X, false)
+
+ // Token: Lbrack
+ out.Lbrack = r.cursor
+ r.cursor += token.Pos(len(token.LBRACK.String()))
+
+ // Decoration: Lbrack
+ r.applyDecorations(out, "Lbrack", n.Decs.Lbrack, false)
+
+ // Node: Low
+ if n.Low != nil {
+ out.Low = r.restoreNode(n.Low, "SliceExpr", "Low", "Expr", allowDuplicate).(ast.Expr)
+ }
+
+ // Token: Colon1
+ r.cursor += token.Pos(len(token.COLON.String()))
+
+ // Decoration: Low
+ r.applyDecorations(out, "Low", n.Decs.Low, false)
+
+ // Node: High
+ if n.High != nil {
+ out.High = r.restoreNode(n.High, "SliceExpr", "High", "Expr", allowDuplicate).(ast.Expr)
+ }
+
+ // Token: Colon2
+ if n.Slice3 {
+ r.cursor += token.Pos(len(token.COLON.String()))
+ }
+
+ // Decoration: High
+ r.applyDecorations(out, "High", n.Decs.High, false)
+
+ // Node: Max
+ if n.Max != nil {
+ out.Max = r.restoreNode(n.Max, "SliceExpr", "Max", "Expr", allowDuplicate).(ast.Expr)
+ }
+
+ // Decoration: Max
+ r.applyDecorations(out, "Max", n.Decs.Max, false)
+
+ // Token: Rbrack
+ out.Rbrack = r.cursor
+ r.cursor += token.Pos(len(token.RBRACK.String()))
+
+ // Decoration: End
+ r.applyDecorations(out, "End", n.Decs.End, true)
+
+ // Value: Slice3
+ out.Slice3 = n.Slice3
+ r.applySpace(n, "After", n.Decs.After)
+
+ return out
+ case *dst.StarExpr:
+ out := &ast.StarExpr{}
+ r.Ast.Nodes[n] = out
+ r.Dst.Nodes[out] = n
+ r.applySpace(n, "Before", n.Decs.Before)
+
+ // Decoration: Start
+ r.applyDecorations(out, "Start", n.Decs.Start, false)
+
+ // Token: Star
+ out.Star = r.cursor
+ r.cursor += token.Pos(len(token.MUL.String()))
+
+ // Decoration: Star
+ r.applyDecorations(out, "Star", n.Decs.Star, false)
+
+ // Node: X
+ if n.X != nil {
+ out.X = r.restoreNode(n.X, "StarExpr", "X", "Expr", allowDuplicate).(ast.Expr)
+ }
+
+ // Decoration: End
+ r.applyDecorations(out, "End", n.Decs.End, true)
+ r.applySpace(n, "After", n.Decs.After)
+
+ return out
+ case *dst.StructType:
+ out := &ast.StructType{}
+ r.Ast.Nodes[n] = out
+ r.Dst.Nodes[out] = n
+ r.applySpace(n, "Before", n.Decs.Before)
+
+ // Decoration: Start
+ r.applyDecorations(out, "Start", n.Decs.Start, false)
+
+ // Token: Struct
+ out.Struct = r.cursor
+ r.cursor += token.Pos(len(token.STRUCT.String()))
+
+ // Decoration: Struct
+ r.applyDecorations(out, "Struct", n.Decs.Struct, false)
+
+ // Node: Fields
+ if n.Fields != nil {
+ out.Fields = r.restoreNode(n.Fields, "StructType", "Fields", "FieldList", allowDuplicate).(*ast.FieldList)
+ }
+
+ // Decoration: End
+ r.applyDecorations(out, "End", n.Decs.End, true)
+
+ // Value: Incomplete
+ out.Incomplete = n.Incomplete
+ r.applySpace(n, "After", n.Decs.After)
+
+ return out
+ case *dst.SwitchStmt:
+ out := &ast.SwitchStmt{}
+ r.Ast.Nodes[n] = out
+ r.Dst.Nodes[out] = n
+ r.applySpace(n, "Before", n.Decs.Before)
+
+ // Decoration: Start
+ r.applyDecorations(out, "Start", n.Decs.Start, false)
+
+ // Token: Switch
+ out.Switch = r.cursor
+ r.cursor += token.Pos(len(token.SWITCH.String()))
+
+ // Decoration: Switch
+ r.applyDecorations(out, "Switch", n.Decs.Switch, false)
+
+ // Node: Init
+ if n.Init != nil {
+ out.Init = r.restoreNode(n.Init, "SwitchStmt", "Init", "Stmt", allowDuplicate).(ast.Stmt)
+ }
+
+ // Decoration: Init
+ r.applyDecorations(out, "Init", n.Decs.Init, false)
+
+ // Node: Tag
+ if n.Tag != nil {
+ out.Tag = r.restoreNode(n.Tag, "SwitchStmt", "Tag", "Expr", allowDuplicate).(ast.Expr)
+ }
+
+ // Decoration: Tag
+ r.applyDecorations(out, "Tag", n.Decs.Tag, false)
+
+ // Node: Body
+ if n.Body != nil {
+ out.Body = r.restoreNode(n.Body, "SwitchStmt", "Body", "BlockStmt", allowDuplicate).(*ast.BlockStmt)
+ }
+
+ // Decoration: End
+ r.applyDecorations(out, "End", n.Decs.End, true)
+ r.applySpace(n, "After", n.Decs.After)
+
+ return out
+ case *dst.TypeAssertExpr:
+ out := &ast.TypeAssertExpr{}
+ r.Ast.Nodes[n] = out
+ r.Dst.Nodes[out] = n
+ r.applySpace(n, "Before", n.Decs.Before)
+
+ // Decoration: Start
+ r.applyDecorations(out, "Start", n.Decs.Start, false)
+
+ // Node: X
+ if n.X != nil {
+ out.X = r.restoreNode(n.X, "TypeAssertExpr", "X", "Expr", allowDuplicate).(ast.Expr)
+ }
+
+ // Token: Period
+ r.cursor += token.Pos(len(token.PERIOD.String()))
+
+ // Decoration: X
+ r.applyDecorations(out, "X", n.Decs.X, false)
+
+ // Token: Lparen
+ out.Lparen = r.cursor
+ r.cursor += token.Pos(len(token.LPAREN.String()))
+
+ // Decoration: Lparen
+ r.applyDecorations(out, "Lparen", n.Decs.Lparen, false)
+
+ // Node: Type
+ if n.Type != nil {
+ out.Type = r.restoreNode(n.Type, "TypeAssertExpr", "Type", "Expr", allowDuplicate).(ast.Expr)
+ }
+
+ // Token: TypeToken
+ if n.Type == nil {
+ r.cursor += token.Pos(len(token.TYPE.String()))
+ }
+
+ // Decoration: Type
+ r.applyDecorations(out, "Type", n.Decs.Type, false)
+
+ // Token: Rparen
+ out.Rparen = r.cursor
+ r.cursor += token.Pos(len(token.RPAREN.String()))
+
+ // Decoration: End
+ r.applyDecorations(out, "End", n.Decs.End, true)
+ r.applySpace(n, "After", n.Decs.After)
+
+ return out
+ case *dst.TypeSpec:
+ out := &ast.TypeSpec{}
+ r.Ast.Nodes[n] = out
+ r.Dst.Nodes[out] = n
+ r.applySpace(n, "Before", n.Decs.Before)
+
+ // Decoration: Start
+ r.applyDecorations(out, "Start", n.Decs.Start, false)
+
+ // Node: Name
+ if n.Name != nil {
+ out.Name = r.restoreNode(n.Name, "TypeSpec", "Name", "Ident", allowDuplicate).(*ast.Ident)
+ }
+
+ // Token: Assign
+ if n.Assign {
+ out.Assign = r.cursor
+ r.cursor += token.Pos(len(token.ASSIGN.String()))
+ }
+
+ // Decoration: Name
+ r.applyDecorations(out, "Name", n.Decs.Name, false)
+
+ // Node: TypeParams
+ if n.TypeParams != nil {
+ out.TypeParams = r.restoreNode(n.TypeParams, "TypeSpec", "TypeParams", "FieldList", allowDuplicate).(*ast.FieldList)
+ }
+
+ // Decoration: TypeParams
+ r.applyDecorations(out, "TypeParams", n.Decs.TypeParams, false)
+
+ // Node: Type
+ if n.Type != nil {
+ out.Type = r.restoreNode(n.Type, "TypeSpec", "Type", "Expr", allowDuplicate).(ast.Expr)
+ }
+
+ // Decoration: End
+ r.applyDecorations(out, "End", n.Decs.End, true)
+ r.applySpace(n, "After", n.Decs.After)
+
+ return out
+ case *dst.TypeSwitchStmt:
+ out := &ast.TypeSwitchStmt{}
+ r.Ast.Nodes[n] = out
+ r.Dst.Nodes[out] = n
+ r.applySpace(n, "Before", n.Decs.Before)
+
+ // Decoration: Start
+ r.applyDecorations(out, "Start", n.Decs.Start, false)
+
+ // Token: Switch
+ out.Switch = r.cursor
+ r.cursor += token.Pos(len(token.SWITCH.String()))
+
+ // Decoration: Switch
+ r.applyDecorations(out, "Switch", n.Decs.Switch, false)
+
+ // Node: Init
+ if n.Init != nil {
+ out.Init = r.restoreNode(n.Init, "TypeSwitchStmt", "Init", "Stmt", allowDuplicate).(ast.Stmt)
+ }
+
+ // Decoration: Init
+ r.applyDecorations(out, "Init", n.Decs.Init, false)
+
+ // Node: Assign
+ if n.Assign != nil {
+ out.Assign = r.restoreNode(n.Assign, "TypeSwitchStmt", "Assign", "Stmt", allowDuplicate).(ast.Stmt)
+ }
+
+ // Decoration: Assign
+ r.applyDecorations(out, "Assign", n.Decs.Assign, false)
+
+ // Node: Body
+ if n.Body != nil {
+ out.Body = r.restoreNode(n.Body, "TypeSwitchStmt", "Body", "BlockStmt", allowDuplicate).(*ast.BlockStmt)
+ }
+
+ // Decoration: End
+ r.applyDecorations(out, "End", n.Decs.End, true)
+ r.applySpace(n, "After", n.Decs.After)
+
+ return out
+ case *dst.UnaryExpr:
+ out := &ast.UnaryExpr{}
+ r.Ast.Nodes[n] = out
+ r.Dst.Nodes[out] = n
+ r.applySpace(n, "Before", n.Decs.Before)
+
+ // Decoration: Start
+ r.applyDecorations(out, "Start", n.Decs.Start, false)
+
+ // Token: Op
+ out.Op = n.Op
+ out.OpPos = r.cursor
+ r.cursor += token.Pos(len(n.Op.String()))
+
+ // Decoration: Op
+ r.applyDecorations(out, "Op", n.Decs.Op, false)
+
+ // Node: X
+ if n.X != nil {
+ out.X = r.restoreNode(n.X, "UnaryExpr", "X", "Expr", allowDuplicate).(ast.Expr)
+ }
+
+ // Decoration: End
+ r.applyDecorations(out, "End", n.Decs.End, true)
+ r.applySpace(n, "After", n.Decs.After)
+
+ return out
+ case *dst.ValueSpec:
+ out := &ast.ValueSpec{}
+ r.Ast.Nodes[n] = out
+ r.Dst.Nodes[out] = n
+ r.applySpace(n, "Before", n.Decs.Before)
+
+ // Decoration: Start
+ r.applyDecorations(out, "Start", n.Decs.Start, false)
+
+ // List: Names
+ for _, v := range n.Names {
+ out.Names = append(out.Names, r.restoreNode(v, "ValueSpec", "Names", "Ident", allowDuplicate).(*ast.Ident))
+ }
+
+ // Node: Type
+ if n.Type != nil {
+ out.Type = r.restoreNode(n.Type, "ValueSpec", "Type", "Expr", allowDuplicate).(ast.Expr)
+ }
+
+ // Token: Assign
+ if n.Values != nil {
+ r.cursor += token.Pos(len(token.ASSIGN.String()))
+ }
+
+ // Decoration: Assign
+ r.applyDecorations(out, "Assign", n.Decs.Assign, false)
+
+ // List: Values
+ for _, v := range n.Values {
+ out.Values = append(out.Values, r.restoreNode(v, "ValueSpec", "Values", "Expr", allowDuplicate).(ast.Expr))
+ }
+
+ // Decoration: End
+ r.applyDecorations(out, "End", n.Decs.End, true)
+ r.applySpace(n, "After", n.Decs.After)
+
+ return out
+ default:
+ panic(fmt.Sprintf("%T", n))
+ }
+}
diff --git a/vendor/github.com/dave/dst/decorator/restorer.go b/vendor/github.com/dave/dst/decorator/restorer.go
new file mode 100644
index 0000000000..57717834f3
--- /dev/null
+++ b/vendor/github.com/dave/dst/decorator/restorer.go
@@ -0,0 +1,823 @@
+package decorator
+
+import (
+ "fmt"
+ "go/ast"
+ "go/format"
+ "go/token"
+ "io"
+ "os"
+ "sort"
+ "strconv"
+ "strings"
+
+ "github.com/dave/dst"
+ "github.com/dave/dst/decorator/resolver"
+)
+
+// NewRestorer returns a restorer.
+func NewRestorer() *Restorer {
+ return &Restorer{
+ Map: newMap(),
+ Fset: token.NewFileSet(),
+ }
+}
+
+// NewRestorerWithImports returns a restorer with import management attributes set.
+func NewRestorerWithImports(path string, resolver resolver.RestorerResolver) *Restorer {
+ res := NewRestorer()
+ res.Path = path
+ res.Resolver = resolver
+ return res
+}
+
+// Restorer restores dst.Node to ast.Node
+type Restorer struct {
+ Map
+ Fset *token.FileSet // Fset is the *token.FileSet in use. Set this to use a pre-existing FileSet.
+ Extras bool // Resore Objects, Scopes etc. Not needed for printing the resultant AST. If set to true, Objects and Scopes must be carefully managed to avoid duplicate nodes.
+
+ // If a Resolver is provided, the names of all imported packages are resolved, and the imports
+ // block is updated. All remote identifiers are updated (sometimes this involves changing
+ // SelectorExpr.X.Name, or even swapping between Ident and SelectorExpr). To force specific
+ // import alias names, use the FileRestorer.Alias map.
+ Resolver resolver.RestorerResolver
+ // Local package path - required if Resolver is set.
+ Path string
+}
+
+// Print uses format.Node to print a *dst.File to stdout
+func (pr *Restorer) Print(f *dst.File) error {
+ return pr.Fprint(os.Stdout, f)
+}
+
+// Fprint uses format.Node to print a *dst.File to a writer
+func (pr *Restorer) Fprint(w io.Writer, f *dst.File) error {
+ af, err := pr.RestoreFile(f)
+ if err != nil {
+ return err
+ }
+ return format.Node(w, pr.Fset, af)
+}
+
+// RestoreFile restores a *dst.File to an *ast.File
+func (pr *Restorer) RestoreFile(file *dst.File) (*ast.File, error) {
+ return pr.FileRestorer().RestoreFile(file)
+}
+
+// FileRestorer restores a specific file with extra options
+func (pr *Restorer) FileRestorer() *FileRestorer {
+ return &FileRestorer{
+ Restorer: pr,
+ Alias: map[string]string{},
+ }
+}
+
+// FileRestorer restores a specific file with extra options
+type FileRestorer struct {
+ *Restorer
+ Alias map[string]string // Map of package path -> package alias for imports
+ Name string // The name of the restored file in the FileSet. Can usually be left empty.
+ file *dst.File
+ lines []int
+ comments []*ast.CommentGroup
+ base int
+ cursor token.Pos
+ nodeDecl map[*ast.Object]dst.Node // Objects that have a ast.Node Decl (look up after file has been rendered)
+ nodeData map[*ast.Object]dst.Node // Objects that have a ast.Node Data (look up after file has been rendered)
+ cursorAtNewLine token.Pos // The cursor position directly after adding a newline decoration (or a line comment which ends in a "\n"). If we're still at this cursor position when we add a line space, reduce the "\n" by one.
+ packageNames map[string]string // names in the code of all imported packages ("." for dot-imports)
+}
+
+// Print uses format.Node to print a *dst.File to stdout
+func (r *FileRestorer) Print(f *dst.File) error {
+ return r.Fprint(os.Stdout, f)
+}
+
+// Fprint uses format.Node to print a *dst.File to a writer
+func (r *FileRestorer) Fprint(w io.Writer, f *dst.File) error {
+ af, err := r.RestoreFile(f)
+ if err != nil {
+ return err
+ }
+ return format.Node(w, r.Fset, af)
+}
+
+// RestoreFile restores a *dst.File to *ast.File
+func (r *FileRestorer) RestoreFile(file *dst.File) (*ast.File, error) {
+
+ if r.Resolver == nil && r.Path != "" {
+ panic("Restorer Path should be empty when Resolver is nil")
+ }
+
+ if r.Resolver != nil && r.Path == "" {
+ panic("Restorer Path should be set when Resolver is set")
+ }
+
+ if r.Fset == nil {
+ r.Fset = token.NewFileSet()
+ }
+
+ // reset the FileRestorer, but leave Name and the Alias map unchanged
+
+ r.file = file
+ r.lines = []int{0} // initialise with the first line at Pos 0
+ r.nodeDecl = map[*ast.Object]dst.Node{}
+ r.nodeData = map[*ast.Object]dst.Node{}
+ r.packageNames = map[string]string{}
+ r.comments = []*ast.CommentGroup{}
+ r.cursorAtNewLine = 0
+ r.packageNames = map[string]string{}
+
+ r.base = r.Fset.Base() // base is the pos that the file will start at in the fset
+ r.cursor = token.Pos(r.base)
+
+ if err := r.updateImports(); err != nil {
+ return nil, err
+ }
+
+ // restore the file, populate comments and lines
+ f := r.restoreNode(r.file, "", "", "", false).(*ast.File)
+
+ for _, cg := range r.comments {
+ f.Comments = append(f.Comments, cg)
+ }
+
+ ff := r.Fset.AddFile(r.Name, r.base, r.fileSize())
+ if !ff.SetLines(r.lines) {
+ panic("ff.SetLines failed")
+ }
+
+ if r.Extras {
+ // Sometimes new nodes are created here (e.g. in RangeStmt the "Object" is an AssignStmt
+ // which never occurs in the actual code). These shouldn't have position information but
+ // perhaps it doesn't matter?
+ for o, dn := range r.nodeDecl {
+ o.Decl = r.restoreNode(dn, "", "", "", true)
+ }
+ for o, dn := range r.nodeData {
+ o.Data = r.restoreNode(dn, "", "", "", true)
+ }
+ }
+
+ return f, nil
+}
+
+func (r *FileRestorer) updateImports() error {
+
+ if r.Resolver == nil {
+ return nil
+ }
+
+ // list of the import block(s)
+ var blocks []*dst.GenDecl
+
+ // hasCgoBlock is only true if the "C" import is on it's own in a block at the start of the
+ // file. If so, this is avoided. If there are no more imports in the file, and a new block is
+ // added, it should be added below this block.
+ var hasCgoBlock bool
+
+ // map of package path -> alias for all packages currently in the imports block(s). Alias can
+ // be an alias, an empty string, "_" or "."
+ importsFound := map[string]string{}
+
+ // a list of all packages that occur in the source (package path -> true)
+ packagesInUse := map[string]bool{}
+
+ // a list of all the imports that will be in the imports block after the update
+ importsRequired := map[string]bool{}
+
+ dst.Inspect(r.file, func(n dst.Node) bool {
+ switch n := n.(type) {
+ case *dst.Ident:
+ if n.Path == "" {
+ return true
+ }
+ if n.Path == r.Path {
+ return true
+ }
+ packagesInUse[n.Path] = true
+ importsRequired[n.Path] = true
+
+ case *dst.GenDecl:
+ if n.Tok != token.IMPORT {
+ return true
+ }
+ // if this block has 1 spec and it's the "C" import, ignore it.
+ if len(n.Specs) == 1 && mustUnquote(n.Specs[0].(*dst.ImportSpec).Path.Value) == "C" {
+ hasCgoBlock = true
+ return true
+ }
+ blocks = append(blocks, n)
+
+ case *dst.ImportSpec:
+ path := mustUnquote(n.Path.Value)
+ if n.Name == nil {
+ importsFound[path] = ""
+ } else {
+ importsFound[path] = n.Name.Name
+ }
+ if path == "C" {
+ // never remove the "C" import
+ importsRequired["C"] = true
+ }
+ }
+ return true
+ })
+
+ // resolved names of all packages in use
+ resolved := map[string]string{}
+
+ // the effective alias requested - the manually supplied alias will override the alias from the
+ // import block
+ effectiveAlias := map[string]string{}
+ for path, alias := range importsFound {
+ if alias == "" {
+ continue
+ }
+ if a, ok := r.Alias[path]; ok && a == "" {
+ continue
+ }
+ if alias == "_" && packagesInUse[path] {
+ continue
+ }
+ effectiveAlias[path] = alias
+ }
+ for path, alias := range r.Alias {
+ if alias == "" {
+ continue
+ }
+ if alias == "_" && packagesInUse[path] {
+ continue
+ }
+ effectiveAlias[path] = alias
+ }
+
+ // any anonymous imports
+ for path, alias := range effectiveAlias {
+ if alias == "_" {
+ importsRequired[path] = true
+ }
+ }
+
+ for path := range packagesInUse {
+ if _, ok := effectiveAlias[path]; ok {
+ // no need to resolve the path of a package that has an alias
+ continue
+ }
+ name, err := r.Resolver.ResolvePackage(path)
+ if err != nil {
+ return fmt.Errorf("could not resolve package %s: %w", path, err)
+ }
+ resolved[path] = name
+ }
+
+ // We sort the required imports so that the order going into the alias conflict detection
+ // routine is determinate. Without this, in a conflict, the package that receives the automatic
+ // renamed alias would be different every time.
+ importsRequiredOrdered := make([]string, len(importsRequired))
+ i := 0
+ for path := range importsRequired {
+ importsRequiredOrdered[i] = path
+ i++
+ }
+ sort.Slice(importsRequiredOrdered, func(i, j int) bool { return packagePathOrderLess(importsRequiredOrdered[i], importsRequiredOrdered[j]) })
+
+ // alias in the imports block (alias, empty string, "_" or "."
+ aliases := map[string]string{}
+
+ // name in the code (name or empty string for dot imports). This is consumed later by the
+ // restoreIdent method, so is a field on FileRestorer.
+ r.packageNames = map[string]string{}
+
+ // conflict returns true if the provided name already exists in the packageNames list
+ conflict := func(name string) bool {
+ for _, n := range r.packageNames {
+ if name == n {
+ return true
+ }
+ }
+ return false
+ }
+
+ // findAlias finds a unique alias given a path and a preferred alias
+ findAlias := func(path, preferred string) (name, alias string) {
+
+ // if we pass in a preferred alias we should always return an alias even when the alias
+ // matches the package name. If for some reason the source file has aliased an import with
+ // the package name, we shouldn't remove this.
+ aliased := preferred != ""
+
+ if !aliased {
+ // if there is no preferred alias, we look up the name of the package in the resolved
+ // names map.
+ preferred = resolved[path]
+ }
+
+ // if the current name has a conflict, increment a modifier until a non-conflicting name is
+ // found
+ modifier := 1
+ current := preferred
+ for conflict(current) {
+ current = fmt.Sprintf("%s%d", preferred, modifier)
+ modifier++
+ }
+
+ if !aliased && current == resolved[path] {
+ // if we didn't supply an alias and the resultant name matches the default package name,
+ // return empty string for alias indicating that no alias is required.
+ return current, ""
+ }
+
+ return current, current
+ }
+
+ for _, path := range importsRequiredOrdered {
+
+ alias := effectiveAlias[path]
+
+ if alias == "." || alias == "_" {
+ // no conflict checking for dot-imports or anonymous imports
+ r.packageNames[path], aliases[path] = "", alias
+ continue
+ }
+
+ // regular imports have a unique name chosen.
+ r.packageNames[path], aliases[path] = findAlias(path, alias)
+ }
+
+ // make any additions
+ var added bool
+ for _, path := range importsRequiredOrdered {
+
+ if _, ok := importsFound[path]; ok {
+ continue
+ }
+
+ added = true
+
+ // if there's currently no import blocks, we must create one
+ if len(blocks) == 0 {
+ gd := &dst.GenDecl{
+ Tok: token.IMPORT,
+ // make sure it has an empty line before and after
+ Decs: dst.GenDeclDecorations{
+ NodeDecs: dst.NodeDecs{Before: dst.EmptyLine, After: dst.EmptyLine},
+ },
+ }
+ if hasCgoBlock {
+ // special case for if we have the "C" import
+ r.file.Decls = append([]dst.Decl{r.file.Decls[0], gd}, r.file.Decls[1:]...)
+ } else {
+ r.file.Decls = append([]dst.Decl{gd}, r.file.Decls...)
+ }
+ blocks = append(blocks, gd)
+ }
+
+ is := &dst.ImportSpec{
+ Path: &dst.BasicLit{Kind: token.STRING, Value: fmt.Sprintf("%q", path)},
+ }
+ if aliases[path] != "" {
+ is.Name = &dst.Ident{
+ Name: aliases[path],
+ }
+ }
+ blocks[0].Specs = append(blocks[0].Specs, is)
+ }
+
+ if added {
+ // rearrange import block
+ sort.Slice(blocks[0].Specs, func(i, j int) bool {
+ return packagePathOrderLess(
+ mustUnquote(blocks[0].Specs[i].(*dst.ImportSpec).Path.Value),
+ mustUnquote(blocks[0].Specs[j].(*dst.ImportSpec).Path.Value),
+ )
+ })
+ }
+
+ // import blocks that are empty will be removed from the File Decls list later
+ deleteBlocks := map[dst.Decl]bool{}
+
+ // update / delete any import specs from all blocks
+ for _, block := range blocks {
+ specs := make([]dst.Spec, 0, len(block.Specs))
+ for _, spec := range block.Specs {
+ spec := spec.(*dst.ImportSpec)
+ path := mustUnquote(spec.Path.Value)
+ if importsRequired[path] {
+ if spec.Name == nil && aliases[path] != "" {
+ // missing alias
+ spec.Name = &dst.Ident{Name: aliases[path]}
+ } else if spec.Name != nil && aliases[path] == "" {
+ // alias needs to be removed
+ spec.Name = nil
+ } else if spec.Name != nil && aliases[path] != spec.Name.Name {
+ // alias wrong
+ spec.Name.Name = aliases[path]
+ }
+ specs = append(specs, spec)
+ }
+ }
+
+ count := len(specs)
+
+ if count != len(block.Specs) {
+
+ block.Specs = specs
+
+ if count == 0 {
+ deleteBlocks[block] = true
+ } else if count == 1 {
+ block.Lparen = false
+ block.Rparen = false
+ } else {
+ block.Lparen = true
+ block.Rparen = true
+ }
+ }
+ }
+
+ if added {
+ // imports with a period in the path are assumed to not be standard library packages, so
+ // get a newline separating them from standard library packages. We remove any other
+ // newlines found in this block. We do this after the deletions because the first non-stdlib
+ // import might be deleted.
+ var foundDomainImport bool
+ for _, spec := range blocks[0].Specs {
+ path := mustUnquote(spec.(*dst.ImportSpec).Path.Value)
+ if strings.Contains(path, ".") && !foundDomainImport {
+ // first non-std-lib import -> empty line above
+ spec.Decorations().Before = dst.EmptyLine
+ spec.Decorations().After = dst.NewLine
+ foundDomainImport = true
+ continue
+ }
+ // all other specs, just newlines
+ spec.Decorations().Before = dst.NewLine
+ spec.Decorations().After = dst.NewLine
+ }
+
+ if len(blocks[0].Specs) == 1 {
+ blocks[0].Lparen = false
+ blocks[0].Rparen = false
+ } else {
+ blocks[0].Lparen = true
+ blocks[0].Rparen = true
+ }
+ }
+
+ // finally remove any deleted blocks from the File Decls list
+ if len(deleteBlocks) > 0 {
+ decls := make([]dst.Decl, 0, len(r.file.Decls))
+ for _, decl := range r.file.Decls {
+ if deleteBlocks[decl] {
+ continue
+ }
+ decls = append(decls, decl)
+ }
+ r.file.Decls = decls
+ }
+
+ return nil
+}
+
+// restoreIdent is a special case for restoring an ident. If the ident has a path and the imported
+// package is not a dot-import, we restore the Ident to a *ast.SelectorExpr with the correct name
+// in the X field.
+func (r *FileRestorer) restoreIdent(n *dst.Ident, parentName, parentField, parentFieldType string, allowDuplicate bool) ast.Node {
+
+ if r.Resolver == nil && n.Path != "" {
+ panic("This syntax has been decorated with import management enabled, but the restorer does not have import management enabled. Use NewRestorerWithImports to create a restorer with import management. See the Imports section of the readme for more information.")
+ }
+
+ var name string
+ if r.Resolver != nil && n.Path != "" {
+
+ if avoid[parentName+"."+parentField] {
+ panic(fmt.Sprintf("Path %s set on illegal Ident %s: parentName %s, parentField %s, parentFieldType %s", n.Path, n.Name, parentName, parentField, parentFieldType))
+ }
+
+ if n.Path != r.Path {
+ name = r.packageNames[n.Path]
+ }
+
+ if name == "." {
+ name = ""
+ }
+ }
+
+ if name == "" {
+ // continue to run standard Ident restore
+ return nil
+ }
+
+ // restore to a SelectorExpr
+ out := &ast.SelectorExpr{}
+ r.Ast.Nodes[n] = out
+ r.Dst.Nodes[out] = n
+ r.Dst.Nodes[out.Sel] = n
+ r.Dst.Nodes[out.X] = n
+ r.applySpace(n, "Before", n.Decs.Before)
+
+ // Decoration: Start
+ r.applyDecorations(out, "Start", n.Decs.Start, false)
+
+ // Node: X
+ out.X = r.restoreNode(dst.NewIdent(name), "SelectorExpr", "X", "Expr", allowDuplicate).(ast.Expr)
+
+ // Token: Period
+ r.cursor += token.Pos(len(token.PERIOD.String()))
+
+ // Decoration: X
+ r.applyDecorations(out, "X", n.Decs.X, false)
+
+ // Node: Sel
+ out.Sel = r.restoreNode(dst.NewIdent(n.Name), "SelectorExpr", "Sel", "Ident", allowDuplicate).(*ast.Ident)
+
+ // Decoration: End
+ r.applyDecorations(out, "End", n.Decs.End, true)
+ r.applySpace(n, "After", n.Decs.After)
+
+ return out
+
+}
+
+func packagePathOrderLess(pi, pj string) bool {
+ // package paths with a . should be ordered after those without
+ idot := strings.Contains(pi, ".")
+ jdot := strings.Contains(pj, ".")
+ if idot != jdot {
+ return jdot
+ }
+ return pi < pj
+}
+
+func (r *FileRestorer) fileSize() int {
+
+ // If a comment is at the end of a file, it will extend past the current cursor position...
+
+ // end pos of file
+ end := int(r.cursor)
+
+ // check that none of the comments or newlines extend past the file end position. If so, increment.
+ for _, cg := range r.comments {
+ if int(cg.End()) >= end {
+ end = int(cg.End()) + 1
+ }
+ }
+ for _, lineOffset := range r.lines {
+ pos := lineOffset + r.base // remember lines are relative to the file base
+ if pos >= end {
+ end = pos + 1
+ }
+ }
+
+ return end - r.base
+}
+
+func (r *FileRestorer) applyLiteral(text string) {
+ isMultiLine := strings.HasPrefix(text, "`") && strings.Contains(text, "\n")
+ if !isMultiLine {
+ return
+ }
+ for charIndex, char := range text {
+ if char == '\n' {
+ lineOffset := int(r.cursor) - r.base + charIndex // remember lines are relative to the file base
+ r.lines = append(r.lines, lineOffset)
+ }
+ }
+}
+
+func (r *FileRestorer) hasCommentField(n ast.Node) bool {
+ switch n.(type) {
+ case *ast.Field, *ast.ValueSpec, *ast.TypeSpec, *ast.ImportSpec:
+ return true
+ }
+ return false
+}
+
+func (r *FileRestorer) addCommentField(n ast.Node, slash token.Pos, text string) {
+ c := &ast.Comment{Slash: slash, Text: text}
+ switch n := n.(type) {
+ case *ast.Field:
+ if n.Comment == nil {
+ n.Comment = &ast.CommentGroup{}
+ r.comments = append(r.comments, n.Comment)
+ }
+ n.Comment.List = append(n.Comment.List, c)
+ case *ast.ImportSpec:
+ if n.Comment == nil {
+ n.Comment = &ast.CommentGroup{}
+ r.comments = append(r.comments, n.Comment)
+ }
+ n.Comment.List = append(n.Comment.List, c)
+ case *ast.ValueSpec:
+ if n.Comment == nil {
+ n.Comment = &ast.CommentGroup{}
+ r.comments = append(r.comments, n.Comment)
+ }
+ n.Comment.List = append(n.Comment.List, c)
+ case *ast.TypeSpec:
+ if n.Comment == nil {
+ n.Comment = &ast.CommentGroup{}
+ r.comments = append(r.comments, n.Comment)
+ }
+ n.Comment.List = append(n.Comment.List, c)
+ }
+}
+
+func (r *FileRestorer) applyDecorations(node ast.Node, name string, decorations dst.Decorations, end bool) {
+ firstLine := true
+ _, isNodeFile := node.(*ast.File)
+ isPackageComment := isNodeFile && name == "Start"
+
+ for _, d := range decorations {
+
+ isNewline := d == "\n"
+ isLineComment := strings.HasPrefix(d, "//")
+ isInlineComment := strings.HasPrefix(d, "/*")
+ isComment := isLineComment || isInlineComment
+ isMultiLineComment := isInlineComment && strings.Contains(d, "\n")
+
+ if end && r.cursorAtNewLine == r.cursor {
+ r.cursor++ // indent all comments in "End" decorations
+ }
+
+ // for multi-line comments, add a newline for each \n
+ if isMultiLineComment {
+ for charIndex, char := range d {
+ if char == '\n' {
+ lineOffset := int(r.cursor) - r.base + charIndex // remember lines are relative to the file base
+ r.lines = append(r.lines, lineOffset)
+ }
+ }
+ }
+
+ // if the decoration is a comment, add it and advance the cursor
+ if isComment {
+ if firstLine && end && r.hasCommentField(node) {
+ // for comments on the same line as the end of a node that has a Comment field, we
+ // add the comment to the node instead of the file.
+ r.addCommentField(node, r.cursor, d)
+ } else {
+ r.comments = append(r.comments, &ast.CommentGroup{List: []*ast.Comment{{Slash: r.cursor, Text: d}}})
+ }
+ r.cursor += token.Pos(len(d))
+ }
+
+ // for newline decorations and also line-comments, add a newline
+ if isLineComment || isNewline {
+ lineOffset := int(r.cursor) - r.base // remember lines are relative to the file base
+ r.lines = append(r.lines, lineOffset)
+ r.cursor++
+
+ r.cursorAtNewLine = r.cursor
+ }
+
+ if isNewline || isLineComment {
+ firstLine = false
+ }
+ }
+ if isPackageComment {
+ // This fixes https://github.com/dave/dst/issues/69
+ r.cursor++
+ }
+}
+
+func (r *FileRestorer) applySpace(node dst.Node, position string, space dst.SpaceType) {
+ switch node.(type) {
+ case *dst.BadDecl, *dst.BadExpr, *dst.BadStmt:
+ if position == "After" {
+ // BadXXX are always followed by an empty line
+ space = dst.EmptyLine
+ }
+ }
+ var newlines int
+ switch space {
+ case dst.NewLine:
+ newlines = 1
+ case dst.EmptyLine:
+ newlines = 2
+ }
+ if r.cursor == r.cursorAtNewLine {
+ newlines--
+ }
+ for i := 0; i < newlines; i++ {
+
+ // Advance the cursor one more byte for all newlines, so we step over any required
+ // separator char - e.g. comma. See net-hook test
+ r.cursor++
+
+ lineOffset := int(r.cursor) - r.base // remember lines are relative to the file base
+ r.lines = append(r.lines, lineOffset)
+ r.cursor++
+ r.cursorAtNewLine = r.cursor
+ }
+}
+
+func (r *FileRestorer) restoreObject(o *dst.Object) *ast.Object {
+ if !r.Extras {
+ return nil
+ }
+ if o == nil {
+ return nil
+ }
+ if ro, ok := r.Ast.Objects[o]; ok {
+ return ro
+ }
+ /*
+ // An Object describes a named language entity such as a package,
+ // constant, type, variable, function (incl. methods), or label.
+ //
+ // The Data fields contains object-specific data:
+ //
+ // Kind Data type Data value
+ // Pkg *Scope package scope
+ // Con int iota for the respective declaration
+ //
+ type Object struct {
+ Kind ObjKind
+ Name string // declared name
+ Decl interface{} // corresponding Field, XxxSpec, FuncDecl, LabeledStmt, AssignStmt, Scope; or nil
+ Data interface{} // object-specific data; or nil
+ Type interface{} // placeholder for type information; may be nil
+ }
+ */
+ out := &ast.Object{}
+
+ r.Ast.Objects[o] = out
+ r.Dst.Objects[out] = o
+
+ out.Kind = ast.ObjKind(o.Kind)
+ out.Name = o.Name
+
+ switch decl := o.Decl.(type) {
+ case *dst.Scope:
+ out.Decl = r.restoreScope(decl)
+ case dst.Node:
+ // Can't use restoreNode here because we aren't at the right cursor position, so we store a link
+ // to the Object and Node so we can look the Nodes up in the cache after the file is fully processed.
+ r.nodeDecl[out] = decl
+ case nil:
+ default:
+ panic(fmt.Sprintf("o.Decl is %T", o.Decl))
+ }
+
+ switch data := o.Data.(type) {
+ case int:
+ out.Data = data
+ case *dst.Scope:
+ out.Data = r.restoreScope(data)
+ case dst.Node:
+ // Can't use restoreNode here because we aren't at the right cursor position, so we store a link
+ // to the Object and Node so we can look the Nodes up in the cache after the file is fully processed.
+ r.nodeData[out] = data
+ case nil:
+ default:
+ panic(fmt.Sprintf("o.Data is %T", o.Data))
+ }
+
+ return out
+}
+
+func (r *FileRestorer) restoreScope(s *dst.Scope) *ast.Scope {
+ if !r.Extras {
+ return nil
+ }
+ if s == nil {
+ return nil
+ }
+ if rs, ok := r.Ast.Scopes[s]; ok {
+ return rs
+ }
+ /*
+ // A Scope maintains the set of named language entities declared
+ // in the scope and a link to the immediately surrounding (outer)
+ // scope.
+ //
+ type Scope struct {
+ Outer *Scope
+ Objects map[string]*Object
+ }
+ */
+ out := &ast.Scope{}
+
+ r.Ast.Scopes[s] = out
+ r.Dst.Scopes[out] = s
+
+ out.Outer = r.restoreScope(s.Outer)
+ out.Objects = map[string]*ast.Object{}
+ for k, v := range s.Objects {
+ out.Objects[k] = r.restoreObject(v)
+ }
+
+ return out
+}
+
+func mustUnquote(s string) string {
+ out, err := strconv.Unquote(s)
+ if err != nil {
+ panic(err)
+ }
+ return out
+}
diff --git a/vendor/github.com/dave/dst/dst.go b/vendor/github.com/dave/dst/dst.go
new file mode 100644
index 0000000000..fdf355b079
--- /dev/null
+++ b/vendor/github.com/dave/dst/dst.go
@@ -0,0 +1,664 @@
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Package dst declares the types used to represent decorated syntax
+// trees for Go packages.
+package dst
+
+import (
+ "go/token"
+)
+
+// ----------------------------------------------------------------------------
+// Interfaces
+//
+// There are 3 main classes of nodes: Expressions and type nodes,
+// statement nodes, and declaration nodes. The node names usually
+// match the corresponding Go spec production names to which they
+// correspond. The node fields correspond to the individual parts
+// of the respective productions.
+//
+// All nodes contain position information marking the beginning of
+// the corresponding source text segment; it is accessible via the
+// Pos accessor method. Nodes may contain additional position info
+// for language constructs where comments may be found between parts
+// of the construct (typically any larger, parenthesized subpart).
+// That position information is needed to properly position comments
+// when printing the construct.
+
+// Node is satisfied by all nodes types.
+type Node interface {
+ // Decorations returns the common Node decorations (Before, After, Start, End). This returns nil for Package nodes.
+ Decorations() *NodeDecs
+}
+
+// All expression nodes implement the Expr interface.
+type Expr interface {
+ Node
+ exprNode()
+}
+
+// All statement nodes implement the Stmt interface.
+type Stmt interface {
+ Node
+ stmtNode()
+}
+
+// All declaration nodes implement the Decl interface.
+type Decl interface {
+ Node
+ declNode()
+}
+
+// ----------------------------------------------------------------------------
+// Expressions and types
+
+// A Field represents a Field declaration list in a struct type,
+// a method list in an interface type, or a parameter/result declaration
+// in a signature.
+// Field.Names is nil for unnamed parameters (parameter lists which only contain types)
+// and embedded struct fields. In the latter case, the field name is the type name.
+type Field struct {
+ Names []*Ident // field/method/(type) parameter names; or nil
+ Type Expr // field/method/parameter type; or nil
+ Tag *BasicLit // field tag; or nil
+ Decs FieldDecorations
+}
+
+// A FieldList represents a list of Fields, enclosed by parentheses,
+// curly braces, or square brackets.
+type FieldList struct {
+ Opening bool
+ List []*Field // field list; or nil
+ Closing bool
+ Decs FieldListDecorations
+}
+
+// NumFields returns the number of parameters or struct fields represented by a FieldList.
+func (f *FieldList) NumFields() int {
+ n := 0
+ if f != nil {
+ for _, g := range f.List {
+ m := len(g.Names)
+ if m == 0 {
+ m = 1
+ }
+ n += m
+ }
+ }
+ return n
+}
+
+// An expression is represented by a tree consisting of one
+// or more of the following concrete expression nodes.
+type (
+ // A BadExpr node is a placeholder for an expression containing
+ // syntax errors for which a correct expression node cannot be
+ // created.
+ BadExpr struct {
+ Length int // position range of bad expression
+ Decs BadExprDecorations
+ }
+
+ // An Ident node represents an identifier.
+ Ident struct {
+ Name string // identifier name
+ Obj *Object // denoted object; or nil
+ Path string // path of the imported package, if this identifier is not local
+ Decs IdentDecorations
+ }
+
+ // An Ellipsis node stands for the "..." type in a
+ // parameter list or the "..." length in an array type.
+ //
+ Ellipsis struct {
+ Elt Expr // ellipsis element type (parameter lists only); or nil
+ Decs EllipsisDecorations
+ }
+
+ // A BasicLit node represents a literal of basic type.
+ BasicLit struct {
+ Kind token.Token // token.INT, token.FLOAT, token.IMAG, token.CHAR, or token.STRING
+ Value string // literal string; e.g. 42, 0x7f, 3.14, 1e-9, 2.4i, 'a', '\x7f', "foo" or `\m\n\o`
+ Decs BasicLitDecorations
+ }
+
+ // A FuncLit node represents a function literal.
+ FuncLit struct {
+ Type *FuncType // function type
+ Body *BlockStmt // function body
+ Decs FuncLitDecorations
+ }
+
+ // A CompositeLit node represents a composite literal.
+ CompositeLit struct {
+ Type Expr // literal type; or nil
+ Elts []Expr // list of composite elements; or nil
+ Incomplete bool // true if (source) expressions are missing in the Elts list
+ Decs CompositeLitDecorations
+ }
+
+ // A ParenExpr node represents a parenthesized expression.
+ ParenExpr struct {
+ X Expr // parenthesized expression
+ Decs ParenExprDecorations
+ }
+
+ // A SelectorExpr node represents an expression followed by a selector.
+ SelectorExpr struct {
+ X Expr // expression
+ Sel *Ident // field selector
+ Decs SelectorExprDecorations
+ }
+
+ // An IndexExpr node represents an expression followed by an index.
+ IndexExpr struct {
+ X Expr // expression
+ Index Expr // index expression
+ Decs IndexExprDecorations
+ }
+
+ // An IndexListExpr node represents an expression followed by multiple
+ // indices.
+ IndexListExpr struct {
+ X Expr // expression
+ Indices []Expr
+ Decs IndexListExprDecorations
+ }
+
+ // An SliceExpr node represents an expression followed by slice indices.
+ SliceExpr struct {
+ X Expr // expression
+ Low Expr // begin of slice range; or nil
+ High Expr // end of slice range; or nil
+ Max Expr // maximum capacity of slice; or nil
+ Slice3 bool // true if 3-index slice (2 colons present)
+ Decs SliceExprDecorations
+ }
+
+ // A TypeAssertExpr node represents an expression followed by a
+ // type assertion.
+ //
+ TypeAssertExpr struct {
+ X Expr // expression
+ Type Expr // asserted type; nil means type switch X.(type)
+ Decs TypeAssertExprDecorations
+ }
+
+ // A CallExpr node represents an expression followed by an argument list.
+ CallExpr struct {
+ Fun Expr // function expression
+ Args []Expr // function arguments; or nil
+ Ellipsis bool
+ Decs CallExprDecorations
+ }
+
+ // A StarExpr node represents an expression of the form "*" Expression.
+ // Semantically it could be a unary "*" expression, or a pointer type.
+ //
+ StarExpr struct {
+ X Expr // operand
+ Decs StarExprDecorations
+ }
+
+ // A UnaryExpr node represents a unary expression.
+ // Unary "*" expressions are represented via StarExpr nodes.
+ //
+ UnaryExpr struct {
+ Op token.Token // operator
+ X Expr // operand
+ Decs UnaryExprDecorations
+ }
+
+ // A BinaryExpr node represents a binary expression.
+ BinaryExpr struct {
+ X Expr // left operand
+ Op token.Token // operator
+ Y Expr // right operand
+ Decs BinaryExprDecorations
+ }
+
+ // A KeyValueExpr node represents (key : value) pairs
+ // in composite literals.
+ //
+ KeyValueExpr struct {
+ Key Expr
+ Value Expr
+ Decs KeyValueExprDecorations
+ }
+)
+
+// The direction of a channel type is indicated by a bit
+// mask including one or both of the following constants.
+type ChanDir int
+
+const (
+ SEND ChanDir = 1 << iota
+ RECV
+)
+
+// A type is represented by a tree consisting of one
+// or more of the following type-specific expression
+// nodes.
+type (
+ // An ArrayType node represents an array or slice type.
+ ArrayType struct {
+ Len Expr // Ellipsis node for [...]T array types, nil for slice types
+ Elt Expr // element type
+ Decs ArrayTypeDecorations
+ }
+
+ // A StructType node represents a struct type.
+ StructType struct {
+ Fields *FieldList // list of field declarations
+ Incomplete bool // true if (source) fields are missing in the Fields list
+ Decs StructTypeDecorations
+ }
+
+ // Pointer types are represented via StarExpr nodes.
+
+ // A FuncType node represents a function type.
+ FuncType struct {
+ Func bool
+ TypeParams *FieldList // type parameters; or nil
+ Params *FieldList // (incoming) parameters; non-nil
+ Results *FieldList // (outgoing) results; or nil
+ Decs FuncTypeDecorations
+ }
+
+ // An InterfaceType node represents an interface type.
+ InterfaceType struct {
+ Methods *FieldList // list of embedded interfaces, methods, or types
+ Incomplete bool // true if (source) methods or types are missing in the Methods list
+ Decs InterfaceTypeDecorations
+ }
+
+ // A MapType node represents a map type.
+ MapType struct {
+ Key Expr
+ Value Expr
+ Decs MapTypeDecorations
+ }
+
+ // A ChanType node represents a channel type.
+ ChanType struct {
+ Dir ChanDir // channel direction
+ Value Expr // value type
+ Decs ChanTypeDecorations
+ }
+)
+
+// exprNode() ensures that only expression/type nodes can be
+// assigned to an Expr.
+func (*BadExpr) exprNode() {}
+func (*Ident) exprNode() {}
+func (*Ellipsis) exprNode() {}
+func (*BasicLit) exprNode() {}
+func (*FuncLit) exprNode() {}
+func (*CompositeLit) exprNode() {}
+func (*ParenExpr) exprNode() {}
+func (*SelectorExpr) exprNode() {}
+func (*IndexExpr) exprNode() {}
+func (*IndexListExpr) exprNode() {}
+func (*SliceExpr) exprNode() {}
+func (*TypeAssertExpr) exprNode() {}
+func (*CallExpr) exprNode() {}
+func (*StarExpr) exprNode() {}
+func (*UnaryExpr) exprNode() {}
+func (*BinaryExpr) exprNode() {}
+func (*KeyValueExpr) exprNode() {}
+
+func (*ArrayType) exprNode() {}
+func (*StructType) exprNode() {}
+func (*FuncType) exprNode() {}
+func (*InterfaceType) exprNode() {}
+func (*MapType) exprNode() {}
+func (*ChanType) exprNode() {}
+
+// ----------------------------------------------------------------------------
+// Convenience functions for Idents
+
+// NewIdent creates a new Ident without position.
+// Useful for ASTs generated by code other than the Go parser.
+func NewIdent(name string) *Ident { return &Ident{name, nil, "", IdentDecorations{}} }
+
+// IsExported reports whether name starts with an upper-case letter.
+func IsExported(name string) bool { return token.IsExported(name) }
+
+// IsExported reports whether id starts with an upper-case letter.
+func (id *Ident) IsExported() bool { return token.IsExported(id.Name) }
+
+func (id *Ident) String() string {
+ if id != nil {
+ if id.Path != "" {
+ return id.Path + "." + id.Name
+ }
+ return id.Name
+ }
+ return ""
+}
+
+// ----------------------------------------------------------------------------
+// Statements
+
+// A statement is represented by a tree consisting of one
+// or more of the following concrete statement nodes.
+type (
+ // A BadStmt node is a placeholder for statements containing
+ // syntax errors for which no correct statement nodes can be
+ // created.
+ //
+ BadStmt struct {
+ Length int // position range of bad statement
+ Decs BadStmtDecorations
+ }
+
+ // A DeclStmt node represents a declaration in a statement list.
+ DeclStmt struct {
+ Decl Decl // *GenDecl with CONST, TYPE, or VAR token
+ Decs DeclStmtDecorations
+ }
+
+ // An EmptyStmt node represents an empty statement.
+ // The "position" of the empty statement is the position
+ // of the immediately following (explicit or implicit) semicolon.
+ //
+ EmptyStmt struct {
+ Implicit bool // if set, ";" was omitted in the source
+ Decs EmptyStmtDecorations
+ }
+
+ // A LabeledStmt node represents a labeled statement.
+ LabeledStmt struct {
+ Label *Ident
+ Stmt Stmt
+ Decs LabeledStmtDecorations
+ }
+
+ // An ExprStmt node represents a (stand-alone) expression
+ // in a statement list.
+ //
+ ExprStmt struct {
+ X Expr // expression
+ Decs ExprStmtDecorations
+ }
+
+ // A SendStmt node represents a send statement.
+ SendStmt struct {
+ Chan Expr
+ Value Expr
+ Decs SendStmtDecorations
+ }
+
+ // An IncDecStmt node represents an increment or decrement statement.
+ IncDecStmt struct {
+ X Expr
+ Tok token.Token // INC or DEC
+ Decs IncDecStmtDecorations
+ }
+
+ // An AssignStmt node represents an assignment or
+ // a short variable declaration.
+ //
+ AssignStmt struct {
+ Lhs []Expr
+ Tok token.Token // assignment token, DEFINE
+ Rhs []Expr
+ Decs AssignStmtDecorations
+ }
+
+ // A GoStmt node represents a go statement.
+ GoStmt struct {
+ Call *CallExpr
+ Decs GoStmtDecorations
+ }
+
+ // A DeferStmt node represents a defer statement.
+ DeferStmt struct {
+ Call *CallExpr
+ Decs DeferStmtDecorations
+ }
+
+ // A ReturnStmt node represents a return statement.
+ ReturnStmt struct {
+ Results []Expr // result expressions; or nil
+ Decs ReturnStmtDecorations
+ }
+
+ // A BranchStmt node represents a break, continue, goto,
+ // or fallthrough statement.
+ //
+ BranchStmt struct {
+ Tok token.Token // keyword token (BREAK, CONTINUE, GOTO, FALLTHROUGH)
+ Label *Ident // label name; or nil
+ Decs BranchStmtDecorations
+ }
+
+ // A BlockStmt node represents a braced statement list.
+ BlockStmt struct {
+ List []Stmt
+ RbraceHasNoPos bool // Rbrace may be absent due to syntax error, so we duplicate this in the output for compatibility.
+ Decs BlockStmtDecorations
+ }
+
+ // An IfStmt node represents an if statement.
+ IfStmt struct {
+ Init Stmt // initialization statement; or nil
+ Cond Expr // condition
+ Body *BlockStmt
+ Else Stmt // else branch; or nil
+ Decs IfStmtDecorations
+ }
+
+ // A CaseClause represents a case of an expression or type switch statement.
+ CaseClause struct {
+ List []Expr // list of expressions or types; nil means default case
+ Body []Stmt // statement list; or nil
+ Decs CaseClauseDecorations
+ }
+
+ // A SwitchStmt node represents an expression switch statement.
+ SwitchStmt struct {
+ Init Stmt // initialization statement; or nil
+ Tag Expr // tag expression; or nil
+ Body *BlockStmt // CaseClauses only
+ Decs SwitchStmtDecorations
+ }
+
+ // A TypeSwitchStmt node represents a type switch statement.
+ TypeSwitchStmt struct {
+ Init Stmt // initialization statement; or nil
+ Assign Stmt // x := y.(type) or y.(type)
+ Body *BlockStmt // CaseClauses only
+ Decs TypeSwitchStmtDecorations
+ }
+
+ // A CommClause node represents a case of a select statement.
+ CommClause struct {
+ Comm Stmt // send or receive statement; nil means default case
+ Body []Stmt // statement list; or nil
+ Decs CommClauseDecorations
+ }
+
+ // A SelectStmt node represents a select statement.
+ SelectStmt struct {
+ Body *BlockStmt // CommClauses only
+ Decs SelectStmtDecorations
+ }
+
+ // A ForStmt represents a for statement.
+ ForStmt struct {
+ Init Stmt // initialization statement; or nil
+ Cond Expr // condition; or nil
+ Post Stmt // post iteration statement; or nil
+ Body *BlockStmt
+ Decs ForStmtDecorations
+ }
+
+ // A RangeStmt represents a for statement with a range clause.
+ RangeStmt struct {
+ Key, Value Expr // Key, Value may be nil
+ Tok token.Token // ILLEGAL if Key == nil, ASSIGN, DEFINE
+ X Expr // value to range over
+ Body *BlockStmt
+ Decs RangeStmtDecorations
+ }
+)
+
+// stmtNode() ensures that only statement nodes can be
+// assigned to a Stmt.
+func (*BadStmt) stmtNode() {}
+func (*DeclStmt) stmtNode() {}
+func (*EmptyStmt) stmtNode() {}
+func (*LabeledStmt) stmtNode() {}
+func (*ExprStmt) stmtNode() {}
+func (*SendStmt) stmtNode() {}
+func (*IncDecStmt) stmtNode() {}
+func (*AssignStmt) stmtNode() {}
+func (*GoStmt) stmtNode() {}
+func (*DeferStmt) stmtNode() {}
+func (*ReturnStmt) stmtNode() {}
+func (*BranchStmt) stmtNode() {}
+func (*BlockStmt) stmtNode() {}
+func (*IfStmt) stmtNode() {}
+func (*CaseClause) stmtNode() {}
+func (*SwitchStmt) stmtNode() {}
+func (*TypeSwitchStmt) stmtNode() {}
+func (*CommClause) stmtNode() {}
+func (*SelectStmt) stmtNode() {}
+func (*ForStmt) stmtNode() {}
+func (*RangeStmt) stmtNode() {}
+
+// ----------------------------------------------------------------------------
+// Declarations
+
+// A Spec node represents a single (non-parenthesized) import,
+// constant, type, or variable declaration.
+type (
+ // The Spec type stands for any of *ImportSpec, *ValueSpec, and *TypeSpec.
+ Spec interface {
+ Node
+ specNode()
+ }
+
+ // An ImportSpec node represents a single package import.
+ ImportSpec struct {
+ Name *Ident // local package name (including "."); or nil
+ Path *BasicLit // import path
+ Decs ImportSpecDecorations
+ }
+
+ // A ValueSpec node represents a constant or variable declaration
+ // (ConstSpec or VarSpec production).
+ //
+ ValueSpec struct {
+ Names []*Ident // value names (len(Names) > 0)
+ Type Expr // value type; or nil
+ Values []Expr // initial values; or nil
+ Decs ValueSpecDecorations
+ }
+
+ // A TypeSpec node represents a type declaration (TypeSpec production).
+ TypeSpec struct {
+ Name *Ident // type name
+ TypeParams *FieldList // type parameters; or nil
+ Assign bool // position of '=', if any
+ Type Expr // *Ident, *ParenExpr, *SelectorExpr, *StarExpr, or any of the *XxxTypes
+ Decs TypeSpecDecorations
+ }
+)
+
+// Pos and End implementations for spec nodes.
+
+// specNode() ensures that only spec nodes can be
+// assigned to a Spec.
+func (*ImportSpec) specNode() {}
+func (*ValueSpec) specNode() {}
+func (*TypeSpec) specNode() {}
+
+// A declaration is represented by one of the following declaration nodes.
+type (
+ // A BadDecl node is a placeholder for a declaration containing
+ // syntax errors for which a correct declaration node cannot be
+ // created.
+ //
+ BadDecl struct {
+ Length int // position range of bad declaration
+ Decs BadDeclDecorations
+ }
+
+ // A GenDecl node (generic declaration node) represents an import,
+ // constant, type or variable declaration. A valid Lparen position
+ // (Lparen.IsValid()) indicates a parenthesized declaration.
+ //
+ // Relationship between Tok value and Specs element type:
+ //
+ // token.IMPORT *ImportSpec
+ // token.CONST *ValueSpec
+ // token.TYPE *TypeSpec
+ // token.VAR *ValueSpec
+ //
+ GenDecl struct {
+ Tok token.Token // IMPORT, CONST, TYPE, or VAR
+ Lparen bool
+ Specs []Spec
+ Rparen bool
+ Decs GenDeclDecorations
+ }
+
+ // A FuncDecl node represents a function declaration.
+ FuncDecl struct {
+ Recv *FieldList // receiver (methods); or nil (functions)
+ Name *Ident // function/method name
+ Type *FuncType // function signature: type and value parameters, results, and position of "func" keyword
+ Body *BlockStmt // function body; or nil for external (non-Go) function
+ Decs FuncDeclDecorations
+ }
+)
+
+// declNode() ensures that only declaration nodes can be
+// assigned to a Decl.
+func (*BadDecl) declNode() {}
+func (*GenDecl) declNode() {}
+func (*FuncDecl) declNode() {}
+
+// ----------------------------------------------------------------------------
+// Files and packages
+
+// A File node represents a Go source file.
+//
+// The Comments list contains all comments in the source file in order of
+// appearance, including the comments that are pointed to from other nodes
+// via Doc and Comment fields.
+//
+// For correct printing of source code containing comments (using packages
+// go/format and go/printer), special care must be taken to update comments
+// when a File's syntax tree is modified: For printing, comments are interspersed
+// between tokens based on their position. If syntax tree nodes are
+// removed or moved, relevant comments in their vicinity must also be removed
+// (from the File.Comments list) or moved accordingly (by updating their
+// positions). A CommentMap may be used to facilitate some of these operations.
+//
+// Whether and how a comment is associated with a node depends on the
+// interpretation of the syntax tree by the manipulating program: Except for Doc
+// and Comment comments directly associated with nodes, the remaining comments
+// are "free-floating" (see also issues #18593, #20744).
+type File struct {
+ Name *Ident // package name
+ Decls []Decl // top-level declarations; or nil
+ Scope *Scope // package scope (this file only)
+ Imports []*ImportSpec // imports in this file
+ Unresolved []*Ident // unresolved identifiers in this file
+ GoVersion string // minimum Go version required by //go:build or // +build directives
+ Decs FileDecorations
+}
+
+// A Package node represents a set of source files
+// collectively building a Go package.
+type Package struct {
+ Name string // package name
+ Scope *Scope // package scope across all files
+ Imports map[string]*Object // map of package id -> package object
+ Files map[string]*File // Go source files by filename
+}
diff --git a/vendor/github.com/dave/dst/dstutil/decorations-generated.go b/vendor/github.com/dave/dst/dstutil/decorations-generated.go
new file mode 100644
index 0000000000..b3e31579f0
--- /dev/null
+++ b/vendor/github.com/dave/dst/dstutil/decorations-generated.go
@@ -0,0 +1,369 @@
+package dstutil
+
+import "github.com/dave/dst"
+
+func decorations(n dst.Node) (before, after dst.SpaceType, points []DecorationPoint) {
+ switch n := n.(type) {
+ case *dst.ArrayType:
+ before = n.Decs.Before
+ after = n.Decs.After
+ points = append(points, DecorationPoint{"Start", n.Decs.Start})
+ points = append(points, DecorationPoint{"Lbrack", n.Decs.Lbrack})
+ points = append(points, DecorationPoint{"Len", n.Decs.Len})
+ points = append(points, DecorationPoint{"End", n.Decs.End})
+ case *dst.AssignStmt:
+ before = n.Decs.Before
+ after = n.Decs.After
+ points = append(points, DecorationPoint{"Start", n.Decs.Start})
+ points = append(points, DecorationPoint{"Tok", n.Decs.Tok})
+ points = append(points, DecorationPoint{"End", n.Decs.End})
+ case *dst.BadDecl:
+ before = n.Decs.Before
+ after = n.Decs.After
+ points = append(points, DecorationPoint{"Start", n.Decs.Start})
+ points = append(points, DecorationPoint{"End", n.Decs.End})
+ case *dst.BadExpr:
+ before = n.Decs.Before
+ after = n.Decs.After
+ points = append(points, DecorationPoint{"Start", n.Decs.Start})
+ points = append(points, DecorationPoint{"End", n.Decs.End})
+ case *dst.BadStmt:
+ before = n.Decs.Before
+ after = n.Decs.After
+ points = append(points, DecorationPoint{"Start", n.Decs.Start})
+ points = append(points, DecorationPoint{"End", n.Decs.End})
+ case *dst.BasicLit:
+ before = n.Decs.Before
+ after = n.Decs.After
+ points = append(points, DecorationPoint{"Start", n.Decs.Start})
+ points = append(points, DecorationPoint{"End", n.Decs.End})
+ case *dst.BinaryExpr:
+ before = n.Decs.Before
+ after = n.Decs.After
+ points = append(points, DecorationPoint{"Start", n.Decs.Start})
+ points = append(points, DecorationPoint{"X", n.Decs.X})
+ points = append(points, DecorationPoint{"Op", n.Decs.Op})
+ points = append(points, DecorationPoint{"End", n.Decs.End})
+ case *dst.BlockStmt:
+ before = n.Decs.Before
+ after = n.Decs.After
+ points = append(points, DecorationPoint{"Start", n.Decs.Start})
+ points = append(points, DecorationPoint{"Lbrace", n.Decs.Lbrace})
+ points = append(points, DecorationPoint{"End", n.Decs.End})
+ case *dst.BranchStmt:
+ before = n.Decs.Before
+ after = n.Decs.After
+ points = append(points, DecorationPoint{"Start", n.Decs.Start})
+ points = append(points, DecorationPoint{"Tok", n.Decs.Tok})
+ points = append(points, DecorationPoint{"End", n.Decs.End})
+ case *dst.CallExpr:
+ before = n.Decs.Before
+ after = n.Decs.After
+ points = append(points, DecorationPoint{"Start", n.Decs.Start})
+ points = append(points, DecorationPoint{"Fun", n.Decs.Fun})
+ points = append(points, DecorationPoint{"Lparen", n.Decs.Lparen})
+ points = append(points, DecorationPoint{"Ellipsis", n.Decs.Ellipsis})
+ points = append(points, DecorationPoint{"End", n.Decs.End})
+ case *dst.CaseClause:
+ before = n.Decs.Before
+ after = n.Decs.After
+ points = append(points, DecorationPoint{"Start", n.Decs.Start})
+ points = append(points, DecorationPoint{"Case", n.Decs.Case})
+ points = append(points, DecorationPoint{"Colon", n.Decs.Colon})
+ points = append(points, DecorationPoint{"End", n.Decs.End})
+ case *dst.ChanType:
+ before = n.Decs.Before
+ after = n.Decs.After
+ points = append(points, DecorationPoint{"Start", n.Decs.Start})
+ points = append(points, DecorationPoint{"Begin", n.Decs.Begin})
+ points = append(points, DecorationPoint{"Arrow", n.Decs.Arrow})
+ points = append(points, DecorationPoint{"End", n.Decs.End})
+ case *dst.CommClause:
+ before = n.Decs.Before
+ after = n.Decs.After
+ points = append(points, DecorationPoint{"Start", n.Decs.Start})
+ points = append(points, DecorationPoint{"Case", n.Decs.Case})
+ points = append(points, DecorationPoint{"Comm", n.Decs.Comm})
+ points = append(points, DecorationPoint{"Colon", n.Decs.Colon})
+ points = append(points, DecorationPoint{"End", n.Decs.End})
+ case *dst.CompositeLit:
+ before = n.Decs.Before
+ after = n.Decs.After
+ points = append(points, DecorationPoint{"Start", n.Decs.Start})
+ points = append(points, DecorationPoint{"Type", n.Decs.Type})
+ points = append(points, DecorationPoint{"Lbrace", n.Decs.Lbrace})
+ points = append(points, DecorationPoint{"End", n.Decs.End})
+ case *dst.DeclStmt:
+ before = n.Decs.Before
+ after = n.Decs.After
+ points = append(points, DecorationPoint{"Start", n.Decs.Start})
+ points = append(points, DecorationPoint{"End", n.Decs.End})
+ case *dst.DeferStmt:
+ before = n.Decs.Before
+ after = n.Decs.After
+ points = append(points, DecorationPoint{"Start", n.Decs.Start})
+ points = append(points, DecorationPoint{"Defer", n.Decs.Defer})
+ points = append(points, DecorationPoint{"End", n.Decs.End})
+ case *dst.Ellipsis:
+ before = n.Decs.Before
+ after = n.Decs.After
+ points = append(points, DecorationPoint{"Start", n.Decs.Start})
+ points = append(points, DecorationPoint{"Ellipsis", n.Decs.Ellipsis})
+ points = append(points, DecorationPoint{"End", n.Decs.End})
+ case *dst.EmptyStmt:
+ before = n.Decs.Before
+ after = n.Decs.After
+ points = append(points, DecorationPoint{"Start", n.Decs.Start})
+ points = append(points, DecorationPoint{"End", n.Decs.End})
+ case *dst.ExprStmt:
+ before = n.Decs.Before
+ after = n.Decs.After
+ points = append(points, DecorationPoint{"Start", n.Decs.Start})
+ points = append(points, DecorationPoint{"End", n.Decs.End})
+ case *dst.Field:
+ before = n.Decs.Before
+ after = n.Decs.After
+ points = append(points, DecorationPoint{"Start", n.Decs.Start})
+ points = append(points, DecorationPoint{"Type", n.Decs.Type})
+ points = append(points, DecorationPoint{"End", n.Decs.End})
+ case *dst.FieldList:
+ before = n.Decs.Before
+ after = n.Decs.After
+ points = append(points, DecorationPoint{"Start", n.Decs.Start})
+ points = append(points, DecorationPoint{"Opening", n.Decs.Opening})
+ points = append(points, DecorationPoint{"End", n.Decs.End})
+ case *dst.File:
+ before = n.Decs.Before
+ after = n.Decs.After
+ points = append(points, DecorationPoint{"Start", n.Decs.Start})
+ points = append(points, DecorationPoint{"Package", n.Decs.Package})
+ points = append(points, DecorationPoint{"Name", n.Decs.Name})
+ points = append(points, DecorationPoint{"End", n.Decs.End})
+ case *dst.ForStmt:
+ before = n.Decs.Before
+ after = n.Decs.After
+ points = append(points, DecorationPoint{"Start", n.Decs.Start})
+ points = append(points, DecorationPoint{"For", n.Decs.For})
+ points = append(points, DecorationPoint{"Init", n.Decs.Init})
+ points = append(points, DecorationPoint{"Cond", n.Decs.Cond})
+ points = append(points, DecorationPoint{"Post", n.Decs.Post})
+ points = append(points, DecorationPoint{"End", n.Decs.End})
+ case *dst.FuncDecl:
+ before = n.Decs.Before
+ after = n.Decs.After
+ points = append(points, DecorationPoint{"Start", n.Decs.Start})
+ points = append(points, DecorationPoint{"Func", n.Decs.Func})
+ points = append(points, DecorationPoint{"Recv", n.Decs.Recv})
+ points = append(points, DecorationPoint{"Name", n.Decs.Name})
+ points = append(points, DecorationPoint{"TypeParams", n.Decs.TypeParams})
+ points = append(points, DecorationPoint{"Params", n.Decs.Params})
+ points = append(points, DecorationPoint{"Results", n.Decs.Results})
+ points = append(points, DecorationPoint{"End", n.Decs.End})
+ case *dst.FuncLit:
+ before = n.Decs.Before
+ after = n.Decs.After
+ points = append(points, DecorationPoint{"Start", n.Decs.Start})
+ points = append(points, DecorationPoint{"Type", n.Decs.Type})
+ points = append(points, DecorationPoint{"End", n.Decs.End})
+ case *dst.FuncType:
+ before = n.Decs.Before
+ after = n.Decs.After
+ points = append(points, DecorationPoint{"Start", n.Decs.Start})
+ points = append(points, DecorationPoint{"Func", n.Decs.Func})
+ points = append(points, DecorationPoint{"TypeParams", n.Decs.TypeParams})
+ points = append(points, DecorationPoint{"Params", n.Decs.Params})
+ points = append(points, DecorationPoint{"End", n.Decs.End})
+ case *dst.GenDecl:
+ before = n.Decs.Before
+ after = n.Decs.After
+ points = append(points, DecorationPoint{"Start", n.Decs.Start})
+ points = append(points, DecorationPoint{"Tok", n.Decs.Tok})
+ points = append(points, DecorationPoint{"Lparen", n.Decs.Lparen})
+ points = append(points, DecorationPoint{"End", n.Decs.End})
+ case *dst.GoStmt:
+ before = n.Decs.Before
+ after = n.Decs.After
+ points = append(points, DecorationPoint{"Start", n.Decs.Start})
+ points = append(points, DecorationPoint{"Go", n.Decs.Go})
+ points = append(points, DecorationPoint{"End", n.Decs.End})
+ case *dst.Ident:
+ before = n.Decs.Before
+ after = n.Decs.After
+ points = append(points, DecorationPoint{"Start", n.Decs.Start})
+ points = append(points, DecorationPoint{"X", n.Decs.X})
+ points = append(points, DecorationPoint{"End", n.Decs.End})
+ case *dst.IfStmt:
+ before = n.Decs.Before
+ after = n.Decs.After
+ points = append(points, DecorationPoint{"Start", n.Decs.Start})
+ points = append(points, DecorationPoint{"If", n.Decs.If})
+ points = append(points, DecorationPoint{"Init", n.Decs.Init})
+ points = append(points, DecorationPoint{"Cond", n.Decs.Cond})
+ points = append(points, DecorationPoint{"Else", n.Decs.Else})
+ points = append(points, DecorationPoint{"End", n.Decs.End})
+ case *dst.ImportSpec:
+ before = n.Decs.Before
+ after = n.Decs.After
+ points = append(points, DecorationPoint{"Start", n.Decs.Start})
+ points = append(points, DecorationPoint{"Name", n.Decs.Name})
+ points = append(points, DecorationPoint{"End", n.Decs.End})
+ case *dst.IncDecStmt:
+ before = n.Decs.Before
+ after = n.Decs.After
+ points = append(points, DecorationPoint{"Start", n.Decs.Start})
+ points = append(points, DecorationPoint{"X", n.Decs.X})
+ points = append(points, DecorationPoint{"End", n.Decs.End})
+ case *dst.IndexExpr:
+ before = n.Decs.Before
+ after = n.Decs.After
+ points = append(points, DecorationPoint{"Start", n.Decs.Start})
+ points = append(points, DecorationPoint{"X", n.Decs.X})
+ points = append(points, DecorationPoint{"Lbrack", n.Decs.Lbrack})
+ points = append(points, DecorationPoint{"Index", n.Decs.Index})
+ points = append(points, DecorationPoint{"End", n.Decs.End})
+ case *dst.IndexListExpr:
+ before = n.Decs.Before
+ after = n.Decs.After
+ points = append(points, DecorationPoint{"Start", n.Decs.Start})
+ points = append(points, DecorationPoint{"X", n.Decs.X})
+ points = append(points, DecorationPoint{"Lbrack", n.Decs.Lbrack})
+ points = append(points, DecorationPoint{"Indices", n.Decs.Indices})
+ points = append(points, DecorationPoint{"End", n.Decs.End})
+ case *dst.InterfaceType:
+ before = n.Decs.Before
+ after = n.Decs.After
+ points = append(points, DecorationPoint{"Start", n.Decs.Start})
+ points = append(points, DecorationPoint{"Interface", n.Decs.Interface})
+ points = append(points, DecorationPoint{"End", n.Decs.End})
+ case *dst.KeyValueExpr:
+ before = n.Decs.Before
+ after = n.Decs.After
+ points = append(points, DecorationPoint{"Start", n.Decs.Start})
+ points = append(points, DecorationPoint{"Key", n.Decs.Key})
+ points = append(points, DecorationPoint{"Colon", n.Decs.Colon})
+ points = append(points, DecorationPoint{"End", n.Decs.End})
+ case *dst.LabeledStmt:
+ before = n.Decs.Before
+ after = n.Decs.After
+ points = append(points, DecorationPoint{"Start", n.Decs.Start})
+ points = append(points, DecorationPoint{"Label", n.Decs.Label})
+ points = append(points, DecorationPoint{"Colon", n.Decs.Colon})
+ points = append(points, DecorationPoint{"End", n.Decs.End})
+ case *dst.MapType:
+ before = n.Decs.Before
+ after = n.Decs.After
+ points = append(points, DecorationPoint{"Start", n.Decs.Start})
+ points = append(points, DecorationPoint{"Map", n.Decs.Map})
+ points = append(points, DecorationPoint{"Key", n.Decs.Key})
+ points = append(points, DecorationPoint{"End", n.Decs.End})
+ case *dst.Package:
+ case *dst.ParenExpr:
+ before = n.Decs.Before
+ after = n.Decs.After
+ points = append(points, DecorationPoint{"Start", n.Decs.Start})
+ points = append(points, DecorationPoint{"Lparen", n.Decs.Lparen})
+ points = append(points, DecorationPoint{"X", n.Decs.X})
+ points = append(points, DecorationPoint{"End", n.Decs.End})
+ case *dst.RangeStmt:
+ before = n.Decs.Before
+ after = n.Decs.After
+ points = append(points, DecorationPoint{"Start", n.Decs.Start})
+ points = append(points, DecorationPoint{"For", n.Decs.For})
+ points = append(points, DecorationPoint{"Key", n.Decs.Key})
+ points = append(points, DecorationPoint{"Value", n.Decs.Value})
+ points = append(points, DecorationPoint{"Range", n.Decs.Range})
+ points = append(points, DecorationPoint{"X", n.Decs.X})
+ points = append(points, DecorationPoint{"End", n.Decs.End})
+ case *dst.ReturnStmt:
+ before = n.Decs.Before
+ after = n.Decs.After
+ points = append(points, DecorationPoint{"Start", n.Decs.Start})
+ points = append(points, DecorationPoint{"Return", n.Decs.Return})
+ points = append(points, DecorationPoint{"End", n.Decs.End})
+ case *dst.SelectStmt:
+ before = n.Decs.Before
+ after = n.Decs.After
+ points = append(points, DecorationPoint{"Start", n.Decs.Start})
+ points = append(points, DecorationPoint{"Select", n.Decs.Select})
+ points = append(points, DecorationPoint{"End", n.Decs.End})
+ case *dst.SelectorExpr:
+ before = n.Decs.Before
+ after = n.Decs.After
+ points = append(points, DecorationPoint{"Start", n.Decs.Start})
+ points = append(points, DecorationPoint{"X", n.Decs.X})
+ points = append(points, DecorationPoint{"End", n.Decs.End})
+ case *dst.SendStmt:
+ before = n.Decs.Before
+ after = n.Decs.After
+ points = append(points, DecorationPoint{"Start", n.Decs.Start})
+ points = append(points, DecorationPoint{"Chan", n.Decs.Chan})
+ points = append(points, DecorationPoint{"Arrow", n.Decs.Arrow})
+ points = append(points, DecorationPoint{"End", n.Decs.End})
+ case *dst.SliceExpr:
+ before = n.Decs.Before
+ after = n.Decs.After
+ points = append(points, DecorationPoint{"Start", n.Decs.Start})
+ points = append(points, DecorationPoint{"X", n.Decs.X})
+ points = append(points, DecorationPoint{"Lbrack", n.Decs.Lbrack})
+ points = append(points, DecorationPoint{"Low", n.Decs.Low})
+ points = append(points, DecorationPoint{"High", n.Decs.High})
+ points = append(points, DecorationPoint{"Max", n.Decs.Max})
+ points = append(points, DecorationPoint{"End", n.Decs.End})
+ case *dst.StarExpr:
+ before = n.Decs.Before
+ after = n.Decs.After
+ points = append(points, DecorationPoint{"Start", n.Decs.Start})
+ points = append(points, DecorationPoint{"Star", n.Decs.Star})
+ points = append(points, DecorationPoint{"End", n.Decs.End})
+ case *dst.StructType:
+ before = n.Decs.Before
+ after = n.Decs.After
+ points = append(points, DecorationPoint{"Start", n.Decs.Start})
+ points = append(points, DecorationPoint{"Struct", n.Decs.Struct})
+ points = append(points, DecorationPoint{"End", n.Decs.End})
+ case *dst.SwitchStmt:
+ before = n.Decs.Before
+ after = n.Decs.After
+ points = append(points, DecorationPoint{"Start", n.Decs.Start})
+ points = append(points, DecorationPoint{"Switch", n.Decs.Switch})
+ points = append(points, DecorationPoint{"Init", n.Decs.Init})
+ points = append(points, DecorationPoint{"Tag", n.Decs.Tag})
+ points = append(points, DecorationPoint{"End", n.Decs.End})
+ case *dst.TypeAssertExpr:
+ before = n.Decs.Before
+ after = n.Decs.After
+ points = append(points, DecorationPoint{"Start", n.Decs.Start})
+ points = append(points, DecorationPoint{"X", n.Decs.X})
+ points = append(points, DecorationPoint{"Lparen", n.Decs.Lparen})
+ points = append(points, DecorationPoint{"Type", n.Decs.Type})
+ points = append(points, DecorationPoint{"End", n.Decs.End})
+ case *dst.TypeSpec:
+ before = n.Decs.Before
+ after = n.Decs.After
+ points = append(points, DecorationPoint{"Start", n.Decs.Start})
+ points = append(points, DecorationPoint{"Name", n.Decs.Name})
+ points = append(points, DecorationPoint{"TypeParams", n.Decs.TypeParams})
+ points = append(points, DecorationPoint{"End", n.Decs.End})
+ case *dst.TypeSwitchStmt:
+ before = n.Decs.Before
+ after = n.Decs.After
+ points = append(points, DecorationPoint{"Start", n.Decs.Start})
+ points = append(points, DecorationPoint{"Switch", n.Decs.Switch})
+ points = append(points, DecorationPoint{"Init", n.Decs.Init})
+ points = append(points, DecorationPoint{"Assign", n.Decs.Assign})
+ points = append(points, DecorationPoint{"End", n.Decs.End})
+ case *dst.UnaryExpr:
+ before = n.Decs.Before
+ after = n.Decs.After
+ points = append(points, DecorationPoint{"Start", n.Decs.Start})
+ points = append(points, DecorationPoint{"Op", n.Decs.Op})
+ points = append(points, DecorationPoint{"End", n.Decs.End})
+ case *dst.ValueSpec:
+ before = n.Decs.Before
+ after = n.Decs.After
+ points = append(points, DecorationPoint{"Start", n.Decs.Start})
+ points = append(points, DecorationPoint{"Assign", n.Decs.Assign})
+ points = append(points, DecorationPoint{"End", n.Decs.End})
+ }
+ return
+}
diff --git a/vendor/github.com/dave/dst/dstutil/decorations.go b/vendor/github.com/dave/dst/dstutil/decorations.go
new file mode 100644
index 0000000000..bb875fcd07
--- /dev/null
+++ b/vendor/github.com/dave/dst/dstutil/decorations.go
@@ -0,0 +1,14 @@
+package dstutil
+
+import "github.com/dave/dst"
+
+// Decorations returns information about all the decoration attachment points associated with a node
+func Decorations(n dst.Node) (before, after dst.SpaceType, info []DecorationPoint) {
+ return decorations(n)
+}
+
+// DecorationPoint contains the name of the decoration attachment point and a list of decorations attached there
+type DecorationPoint struct {
+ Name string
+ Decs []string
+}
diff --git a/vendor/github.com/dave/dst/dstutil/rewrite.go b/vendor/github.com/dave/dst/dstutil/rewrite.go
new file mode 100644
index 0000000000..1d1bc7c515
--- /dev/null
+++ b/vendor/github.com/dave/dst/dstutil/rewrite.go
@@ -0,0 +1,464 @@
+// Copyright 2017 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package dstutil
+
+import (
+ "fmt"
+
+ "reflect"
+ "sort"
+
+ "github.com/dave/dst"
+)
+
+// An ApplyFunc is invoked by Apply for each node n, even if n is nil,
+// before and/or after the node's children, using a Cursor describing
+// the current node and providing operations on it.
+//
+// The return value of ApplyFunc controls the syntax tree traversal.
+// See Apply for details.
+type ApplyFunc func(*Cursor) bool
+
+// Apply traverses a syntax tree recursively, starting with root,
+// and calling pre and post for each node as described below.
+// Apply returns the syntax tree, possibly modified.
+//
+// If pre is not nil, it is called for each node before the node's
+// children are traversed (pre-order). If pre returns false, no
+// children are traversed, and post is not called for that node.
+//
+// If post is not nil, and a prior call of pre didn't return false,
+// post is called for each node after its children are traversed
+// (post-order). If post returns false, traversal is terminated and
+// Apply returns immediately.
+//
+// Only fields that refer to AST nodes are considered children;
+// i.e., token.Pos, Scopes, Objects, and fields of basic types
+// (strings, etc.) are ignored.
+//
+// Children are traversed in the order in which they appear in the
+// respective node's struct definition. A package's files are
+// traversed in the filenames' alphabetical order.
+func Apply(root dst.Node, pre, post ApplyFunc) (result dst.Node) {
+ parent := &struct{ dst.Node }{root}
+ defer func() {
+ if r := recover(); r != nil && r != abort {
+ panic(r)
+ }
+ result = parent.Node
+ }()
+ a := &application{pre: pre, post: post}
+ a.apply(parent, "Node", nil, root)
+ return
+}
+
+var abort = new(int) // singleton, to signal termination of Apply
+
+// A Cursor describes a node encountered during Apply.
+// Information about the node and its parent is available
+// from the Node, Parent, Name, and Index methods.
+//
+// If p is a variable of type and value of the current parent node
+// c.Parent(), and f is the field identifier with name c.Name(),
+// the following invariants hold:
+//
+// p.f == c.Node() if c.Index() < 0
+// p.f[c.Index()] == c.Node() if c.Index() >= 0
+//
+// The methods Replace, Delete, InsertBefore, and InsertAfter
+// can be used to change the AST without disrupting Apply.
+type Cursor struct {
+ parent dst.Node
+ name string
+ iter *iterator // valid if non-nil
+ node dst.Node
+}
+
+// Node returns the current Node.
+func (c *Cursor) Node() dst.Node { return c.node }
+
+// Parent returns the parent of the current Node.
+func (c *Cursor) Parent() dst.Node { return c.parent }
+
+// Name returns the name of the parent Node field that contains the current Node.
+// If the parent is a *dst.Package and the current Node is a *dst.File, Name returns
+// the filename for the current Node.
+func (c *Cursor) Name() string { return c.name }
+
+// Index reports the index >= 0 of the current Node in the slice of Nodes that
+// contains it, or a value < 0 if the current Node is not part of a slice.
+// The index of the current node changes if InsertBefore is called while
+// processing the current node.
+func (c *Cursor) Index() int {
+ if c.iter != nil {
+ return c.iter.index
+ }
+ return -1
+}
+
+// field returns the current node's parent field value.
+func (c *Cursor) field() reflect.Value {
+ return reflect.Indirect(reflect.ValueOf(c.parent)).FieldByName(c.name)
+}
+
+// Replace replaces the current Node with n.
+// The replacement node is not walked by Apply.
+func (c *Cursor) Replace(n dst.Node) {
+ if _, ok := c.node.(*dst.File); ok {
+ file, ok := n.(*dst.File)
+ if !ok {
+ panic("attempt to replace *dst.File with non-*dst.File")
+ }
+ c.parent.(*dst.Package).Files[c.name] = file
+ return
+ }
+
+ v := c.field()
+ if i := c.Index(); i >= 0 {
+ v = v.Index(i)
+ }
+ v.Set(reflect.ValueOf(n))
+}
+
+// Delete deletes the current Node from its containing slice.
+// If the current Node is not part of a slice, Delete panics.
+// As a special case, if the current node is a package file,
+// Delete removes it from the package's Files map.
+func (c *Cursor) Delete() {
+ if _, ok := c.node.(*dst.File); ok {
+ delete(c.parent.(*dst.Package).Files, c.name)
+ return
+ }
+
+ i := c.Index()
+ if i < 0 {
+ panic("Delete node not contained in slice")
+ }
+ v := c.field()
+ l := v.Len()
+ reflect.Copy(v.Slice(i, l), v.Slice(i+1, l))
+ v.Index(l - 1).Set(reflect.Zero(v.Type().Elem()))
+ v.SetLen(l - 1)
+ c.iter.step--
+}
+
+// InsertAfter inserts n after the current Node in its containing slice.
+// If the current Node is not part of a slice, InsertAfter panics.
+// Apply does not walk n.
+func (c *Cursor) InsertAfter(n dst.Node) {
+ i := c.Index()
+ if i < 0 {
+ panic("InsertAfter node not contained in slice")
+ }
+ v := c.field()
+ v.Set(reflect.Append(v, reflect.Zero(v.Type().Elem())))
+ l := v.Len()
+ reflect.Copy(v.Slice(i+2, l), v.Slice(i+1, l))
+ v.Index(i + 1).Set(reflect.ValueOf(n))
+ c.iter.step++
+}
+
+// InsertBefore inserts n before the current Node in its containing slice.
+// If the current Node is not part of a slice, InsertBefore panics.
+// Apply will not walk n.
+func (c *Cursor) InsertBefore(n dst.Node) {
+ i := c.Index()
+ if i < 0 {
+ panic("InsertBefore node not contained in slice")
+ }
+ v := c.field()
+ v.Set(reflect.Append(v, reflect.Zero(v.Type().Elem())))
+ l := v.Len()
+ reflect.Copy(v.Slice(i+1, l), v.Slice(i, l))
+ v.Index(i).Set(reflect.ValueOf(n))
+ c.iter.index++
+}
+
+// application carries all the shared data so we can pass it around cheaply.
+type application struct {
+ pre, post ApplyFunc
+ cursor Cursor
+ iter iterator
+}
+
+func (a *application) apply(parent dst.Node, name string, iter *iterator, n dst.Node) {
+ // convert typed nil into untyped nil
+ if v := reflect.ValueOf(n); v.Kind() == reflect.Ptr && v.IsNil() {
+ n = nil
+ }
+
+ // avoid heap-allocating a new cursor for each apply call; reuse a.cursor instead
+ saved := a.cursor
+ a.cursor.parent = parent
+ a.cursor.name = name
+ a.cursor.iter = iter
+ a.cursor.node = n
+
+ if a.pre != nil && !a.pre(&a.cursor) {
+ a.cursor = saved
+ return
+ }
+
+ // walk children
+ // (the order of the cases matches the order of the corresponding node types in go/ast)
+ switch n := n.(type) {
+ case nil:
+ // nothing to do
+
+ case *dst.Field:
+ a.applyList(n, "Names")
+ a.apply(n, "Type", nil, n.Type)
+ a.apply(n, "Tag", nil, n.Tag)
+
+ case *dst.FieldList:
+ a.applyList(n, "List")
+
+ // Expressions
+ case *dst.BadExpr, *dst.Ident, *dst.BasicLit:
+ // nothing to do
+
+ case *dst.Ellipsis:
+ a.apply(n, "Elt", nil, n.Elt)
+
+ case *dst.FuncLit:
+ a.apply(n, "Type", nil, n.Type)
+ a.apply(n, "Body", nil, n.Body)
+
+ case *dst.CompositeLit:
+ a.apply(n, "Type", nil, n.Type)
+ a.applyList(n, "Elts")
+
+ case *dst.ParenExpr:
+ a.apply(n, "X", nil, n.X)
+
+ case *dst.SelectorExpr:
+ a.apply(n, "X", nil, n.X)
+ a.apply(n, "Sel", nil, n.Sel)
+
+ case *dst.IndexExpr:
+ a.apply(n, "X", nil, n.X)
+ a.apply(n, "Index", nil, n.Index)
+
+ case *dst.IndexListExpr:
+ a.apply(n, "X", nil, n.X)
+ a.applyList(n, "Indices")
+
+ case *dst.SliceExpr:
+ a.apply(n, "X", nil, n.X)
+ a.apply(n, "Low", nil, n.Low)
+ a.apply(n, "High", nil, n.High)
+ a.apply(n, "Max", nil, n.Max)
+
+ case *dst.TypeAssertExpr:
+ a.apply(n, "X", nil, n.X)
+ a.apply(n, "Type", nil, n.Type)
+
+ case *dst.CallExpr:
+ a.apply(n, "Fun", nil, n.Fun)
+ a.applyList(n, "Args")
+
+ case *dst.StarExpr:
+ a.apply(n, "X", nil, n.X)
+
+ case *dst.UnaryExpr:
+ a.apply(n, "X", nil, n.X)
+
+ case *dst.BinaryExpr:
+ a.apply(n, "X", nil, n.X)
+ a.apply(n, "Y", nil, n.Y)
+
+ case *dst.KeyValueExpr:
+ a.apply(n, "Key", nil, n.Key)
+ a.apply(n, "Value", nil, n.Value)
+
+ // Types
+ case *dst.ArrayType:
+ a.apply(n, "Len", nil, n.Len)
+ a.apply(n, "Elt", nil, n.Elt)
+
+ case *dst.StructType:
+ a.apply(n, "Fields", nil, n.Fields)
+
+ case *dst.FuncType:
+ a.apply(n, "TypeParams", nil, n.TypeParams)
+ a.apply(n, "Params", nil, n.Params)
+ a.apply(n, "Results", nil, n.Results)
+
+ case *dst.InterfaceType:
+ a.apply(n, "Methods", nil, n.Methods)
+
+ case *dst.MapType:
+ a.apply(n, "Key", nil, n.Key)
+ a.apply(n, "Value", nil, n.Value)
+
+ case *dst.ChanType:
+ a.apply(n, "Value", nil, n.Value)
+
+ // Statements
+ case *dst.BadStmt:
+ // nothing to do
+
+ case *dst.DeclStmt:
+ a.apply(n, "Decl", nil, n.Decl)
+
+ case *dst.EmptyStmt:
+ // nothing to do
+
+ case *dst.LabeledStmt:
+ a.apply(n, "Label", nil, n.Label)
+ a.apply(n, "Stmt", nil, n.Stmt)
+
+ case *dst.ExprStmt:
+ a.apply(n, "X", nil, n.X)
+
+ case *dst.SendStmt:
+ a.apply(n, "Chan", nil, n.Chan)
+ a.apply(n, "Value", nil, n.Value)
+
+ case *dst.IncDecStmt:
+ a.apply(n, "X", nil, n.X)
+
+ case *dst.AssignStmt:
+ a.applyList(n, "Lhs")
+ a.applyList(n, "Rhs")
+
+ case *dst.GoStmt:
+ a.apply(n, "Call", nil, n.Call)
+
+ case *dst.DeferStmt:
+ a.apply(n, "Call", nil, n.Call)
+
+ case *dst.ReturnStmt:
+ a.applyList(n, "Results")
+
+ case *dst.BranchStmt:
+ a.apply(n, "Label", nil, n.Label)
+
+ case *dst.BlockStmt:
+ a.applyList(n, "List")
+
+ case *dst.IfStmt:
+ a.apply(n, "Init", nil, n.Init)
+ a.apply(n, "Cond", nil, n.Cond)
+ a.apply(n, "Body", nil, n.Body)
+ a.apply(n, "Else", nil, n.Else)
+
+ case *dst.CaseClause:
+ a.applyList(n, "List")
+ a.applyList(n, "Body")
+
+ case *dst.SwitchStmt:
+ a.apply(n, "Init", nil, n.Init)
+ a.apply(n, "Tag", nil, n.Tag)
+ a.apply(n, "Body", nil, n.Body)
+
+ case *dst.TypeSwitchStmt:
+ a.apply(n, "Init", nil, n.Init)
+ a.apply(n, "Assign", nil, n.Assign)
+ a.apply(n, "Body", nil, n.Body)
+
+ case *dst.CommClause:
+ a.apply(n, "Comm", nil, n.Comm)
+ a.applyList(n, "Body")
+
+ case *dst.SelectStmt:
+ a.apply(n, "Body", nil, n.Body)
+
+ case *dst.ForStmt:
+ a.apply(n, "Init", nil, n.Init)
+ a.apply(n, "Cond", nil, n.Cond)
+ a.apply(n, "Post", nil, n.Post)
+ a.apply(n, "Body", nil, n.Body)
+
+ case *dst.RangeStmt:
+ a.apply(n, "Key", nil, n.Key)
+ a.apply(n, "Value", nil, n.Value)
+ a.apply(n, "X", nil, n.X)
+ a.apply(n, "Body", nil, n.Body)
+
+ // Declarations
+ case *dst.ImportSpec:
+ a.apply(n, "Name", nil, n.Name)
+ a.apply(n, "Path", nil, n.Path)
+
+ case *dst.ValueSpec:
+ a.applyList(n, "Names")
+ a.apply(n, "Type", nil, n.Type)
+ a.applyList(n, "Values")
+
+ case *dst.TypeSpec:
+ a.apply(n, "Name", nil, n.Name)
+ a.apply(n, "TypeParams", nil, n.TypeParams)
+ a.apply(n, "Type", nil, n.Type)
+
+ case *dst.BadDecl:
+ // nothing to do
+
+ case *dst.GenDecl:
+ a.applyList(n, "Specs")
+
+ case *dst.FuncDecl:
+ a.apply(n, "Recv", nil, n.Recv)
+ a.apply(n, "Name", nil, n.Name)
+ a.apply(n, "Type", nil, n.Type)
+ a.apply(n, "Body", nil, n.Body)
+
+ // Files and packages
+ case *dst.File:
+ a.apply(n, "Name", nil, n.Name)
+ a.applyList(n, "Decls")
+ // Don't walk n.Comments; they have either been walked already if
+ // they are Doc comments, or they can be easily walked explicitly.
+
+ case *dst.Package:
+ // collect and sort names for reproducible behavior
+ var names []string
+ for name := range n.Files {
+ names = append(names, name)
+ }
+ sort.Strings(names)
+ for _, name := range names {
+ a.apply(n, name, nil, n.Files[name])
+ }
+
+ default:
+ panic(fmt.Sprintf("Apply: unexpected node type %T", n))
+ }
+
+ if a.post != nil && !a.post(&a.cursor) {
+ panic(abort)
+ }
+
+ a.cursor = saved
+}
+
+// An iterator controls iteration over a slice of nodes.
+type iterator struct {
+ index, step int
+}
+
+func (a *application) applyList(parent dst.Node, name string) {
+ // avoid heap-allocating a new iterator for each applyList call; reuse a.iter instead
+ saved := a.iter
+ a.iter.index = 0
+ for {
+ // must reload parent.name each time, since cursor modifications might change it
+ v := reflect.Indirect(reflect.ValueOf(parent)).FieldByName(name)
+ if a.iter.index >= v.Len() {
+ break
+ }
+
+ // element x may be nil in a bad AST - be cautious
+ var x dst.Node
+ if e := v.Index(a.iter.index); e.IsValid() {
+ x = e.Interface().(dst.Node)
+ }
+
+ a.iter.step = 1
+ a.apply(parent, name, &a.iter, x)
+ a.iter.index += a.iter.step
+ }
+ a.iter = saved
+}
diff --git a/vendor/github.com/dave/dst/dstutil/util.go b/vendor/github.com/dave/dst/dstutil/util.go
new file mode 100644
index 0000000000..984262278c
--- /dev/null
+++ b/vendor/github.com/dave/dst/dstutil/util.go
@@ -0,0 +1,14 @@
+package dstutil
+
+import "github.com/dave/dst"
+
+// Unparen returns e with any enclosing parentheses stripped.
+func Unparen(e dst.Expr) dst.Expr {
+ for {
+ p, ok := e.(*dst.ParenExpr)
+ if !ok {
+ return e
+ }
+ e = p.X
+ }
+}
diff --git a/vendor/github.com/dave/dst/print.go b/vendor/github.com/dave/dst/print.go
new file mode 100644
index 0000000000..0a4a35c41c
--- /dev/null
+++ b/vendor/github.com/dave/dst/print.go
@@ -0,0 +1,245 @@
+// Copyright 2010 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// This file contains printing support for ASTs.
+
+package dst
+
+import (
+ "fmt"
+ "io"
+ "os"
+ "reflect"
+)
+
+// A FieldFilter may be provided to Fprint to control the output.
+type FieldFilter func(name string, value reflect.Value) bool
+
+// NotNilFilter returns true for field values that are not nil;
+// it returns false otherwise.
+func NotNilFilter(_ string, v reflect.Value) bool {
+ switch v.Kind() {
+ case reflect.Chan, reflect.Func, reflect.Interface, reflect.Map, reflect.Ptr, reflect.Slice:
+ return !v.IsNil()
+ }
+ return true
+}
+
+// Fprint prints the (sub-)tree starting at AST node x to w.
+// If fset != nil, position information is interpreted relative
+// to that file set. Otherwise positions are printed as integer
+// values (file set specific offsets).
+//
+// A non-nil FieldFilter f may be provided to control the output:
+// struct fields for which f(fieldname, fieldvalue) is true are
+// printed; all others are filtered from the output. Unexported
+// struct fields are never printed.
+func Fprint(w io.Writer, x interface{}, f FieldFilter) error {
+ return fprint(w, x, f)
+}
+
+func fprint(w io.Writer, x interface{}, f FieldFilter) (err error) {
+ // setup printer
+ p := printer{
+ output: w,
+ filter: f,
+ ptrmap: make(map[interface{}]int),
+ last: '\n', // force printing of line number on first line
+ }
+
+ // install error handler
+ defer func() {
+ if e := recover(); e != nil {
+ err = e.(localError).err // re-panics if it's not a localError
+ }
+ }()
+
+ // print x
+ if x == nil {
+ p.printf("nil\n")
+ return
+ }
+ p.print(reflect.ValueOf(x))
+ p.printf("\n")
+
+ return
+}
+
+// Print prints x to standard output, skipping nil fields.
+// Print(fset, x) is the same as Fprint(os.Stdout, fset, x, NotNilFilter).
+func Print(x interface{}) error {
+ return Fprint(os.Stdout, x, NotNilFilter)
+}
+
+type printer struct {
+ output io.Writer
+ filter FieldFilter
+ ptrmap map[interface{}]int // *T -> line number
+ indent int // current indentation level
+ last byte // the last byte processed by Write
+ line int // current line number
+}
+
+var indent = []byte(". ")
+
+func (p *printer) Write(data []byte) (n int, err error) {
+ var m int
+ for i, b := range data {
+ // invariant: data[0:n] has been written
+ if b == '\n' {
+ m, err = p.output.Write(data[n : i+1])
+ n += m
+ if err != nil {
+ return
+ }
+ p.line++
+ } else if p.last == '\n' {
+ _, err = fmt.Fprintf(p.output, "%6d ", p.line)
+ if err != nil {
+ return
+ }
+ for j := p.indent; j > 0; j-- {
+ _, err = p.output.Write(indent)
+ if err != nil {
+ return
+ }
+ }
+ }
+ p.last = b
+ }
+ if len(data) > n {
+ m, err = p.output.Write(data[n:])
+ n += m
+ }
+ return
+}
+
+// localError wraps locally caught errors so we can distinguish
+// them from genuine panics which we don't want to return as errors.
+type localError struct {
+ err error
+}
+
+// printf is a convenience wrapper that takes care of print errors.
+func (p *printer) printf(format string, args ...interface{}) {
+ if _, err := fmt.Fprintf(p, format, args...); err != nil {
+ panic(localError{err})
+ }
+}
+
+// Implementation note: Print is written for AST nodes but could be
+// used to print arbitrary data structures; such a version should
+// probably be in a different package.
+//
+// Note: This code detects (some) cycles created via pointers but
+// not cycles that are created via slices or maps containing the
+// same slice or map. Code for general data structures probably
+// should catch those as well.
+
+func (p *printer) print(x reflect.Value) {
+ if !NotNilFilter("", x) {
+ p.printf("nil")
+ return
+ }
+
+ switch x.Kind() {
+ case reflect.Interface:
+ p.print(x.Elem())
+
+ case reflect.Map:
+ p.printf("%s (len = %d) {", x.Type(), x.Len())
+ if x.Len() > 0 {
+ p.indent++
+ p.printf("\n")
+ for _, key := range x.MapKeys() {
+ p.print(key)
+ p.printf(": ")
+ p.print(x.MapIndex(key))
+ p.printf("\n")
+ }
+ p.indent--
+ }
+ p.printf("}")
+
+ case reflect.Ptr:
+ p.printf("*")
+ // type-checked ASTs may contain cycles - use ptrmap
+ // to keep track of objects that have been printed
+ // already and print the respective line number instead
+ ptr := x.Interface()
+ if line, exists := p.ptrmap[ptr]; exists {
+ p.printf("(obj @ %d)", line)
+ } else {
+ p.ptrmap[ptr] = p.line
+ p.print(x.Elem())
+ }
+
+ case reflect.Array:
+ p.printf("%s {", x.Type())
+ if x.Len() > 0 {
+ p.indent++
+ p.printf("\n")
+ for i, n := 0, x.Len(); i < n; i++ {
+ p.printf("%d: ", i)
+ p.print(x.Index(i))
+ p.printf("\n")
+ }
+ p.indent--
+ }
+ p.printf("}")
+
+ case reflect.Slice:
+ if s, ok := x.Interface().([]byte); ok {
+ p.printf("%#q", s)
+ return
+ }
+ p.printf("%s (len = %d) {", x.Type(), x.Len())
+ if x.Len() > 0 {
+ p.indent++
+ p.printf("\n")
+ for i, n := 0, x.Len(); i < n; i++ {
+ p.printf("%d: ", i)
+ p.print(x.Index(i))
+ p.printf("\n")
+ }
+ p.indent--
+ }
+ p.printf("}")
+
+ case reflect.Struct:
+ t := x.Type()
+ p.printf("%s {", t)
+ p.indent++
+ first := true
+ for i, n := 0, t.NumField(); i < n; i++ {
+ // exclude non-exported fields because their
+ // values cannot be accessed via reflection
+ if name := t.Field(i).Name; IsExported(name) {
+ value := x.Field(i)
+ if p.filter == nil || p.filter(name, value) {
+ if first {
+ p.printf("\n")
+ first = false
+ }
+ p.printf("%s: ", name)
+ p.print(value)
+ p.printf("\n")
+ }
+ }
+ }
+ p.indent--
+ p.printf("}")
+
+ default:
+ v := x.Interface()
+ switch v := v.(type) {
+ case string:
+ // print strings in quotes
+ p.printf("%q", v)
+ return
+ }
+ // default
+ p.printf("%v", v)
+ }
+}
diff --git a/vendor/github.com/dave/dst/readme.go b/vendor/github.com/dave/dst/readme.go
new file mode 100644
index 0000000000..7bb53bdc1a
--- /dev/null
+++ b/vendor/github.com/dave/dst/readme.go
@@ -0,0 +1,4 @@
+package dst
+
+//go:generate go get github.com/dave/rebecca/cmd/becca
+//go:generate becca -package=github.com/dave/dst
diff --git a/vendor/github.com/dave/dst/resolve.go b/vendor/github.com/dave/dst/resolve.go
new file mode 100644
index 0000000000..af5138c4db
--- /dev/null
+++ b/vendor/github.com/dave/dst/resolve.go
@@ -0,0 +1,169 @@
+// Copyright 2011 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// This file implements NewPackage.
+
+package dst
+
+import (
+ "fmt"
+ "go/scanner"
+ "go/token"
+ "strconv"
+)
+
+type pkgBuilder struct {
+ fset *token.FileSet
+ errors scanner.ErrorList
+}
+
+func (p *pkgBuilder) error(msg string) {
+ p.errors.Add(p.fset.Position(token.NoPos), msg)
+}
+
+func (p *pkgBuilder) errorf(format string, args ...interface{}) {
+ p.error(fmt.Sprintf(format, args...))
+}
+
+func (p *pkgBuilder) declare(scope, altScope *Scope, obj *Object) {
+ alt := scope.Insert(obj)
+ if alt == nil && altScope != nil {
+ // see if there is a conflicting declaration in altScope
+ alt = altScope.Lookup(obj.Name)
+ }
+ if alt != nil {
+ p.error(fmt.Sprintf("%s redeclared in this block", obj.Name))
+ }
+}
+
+func resolve(scope *Scope, ident *Ident) bool {
+ for ; scope != nil; scope = scope.Outer {
+ if obj := scope.Lookup(ident.Name); obj != nil {
+ ident.Obj = obj
+ return true
+ }
+ }
+ return false
+}
+
+// An Importer resolves import paths to package Objects.
+// The imports map records the packages already imported,
+// indexed by package id (canonical import path).
+// An Importer must determine the canonical import path and
+// check the map to see if it is already present in the imports map.
+// If so, the Importer can return the map entry. Otherwise, the
+// Importer should load the package data for the given path into
+// a new *Object (pkg), record pkg in the imports map, and then
+// return pkg.
+type Importer func(imports map[string]*Object, path string) (pkg *Object, err error)
+
+// NewPackage creates a new Package node from a set of File nodes. It resolves
+// unresolved identifiers across files and updates each file's Unresolved list
+// accordingly. If a non-nil importer and universe scope are provided, they are
+// used to resolve identifiers not declared in any of the package files. Any
+// remaining unresolved identifiers are reported as undeclared. If the files
+// belong to different packages, one package name is selected and files with
+// different package names are reported and then ignored.
+// The result is a package node and a scanner.ErrorList if there were errors.
+func NewPackage(fset *token.FileSet, files map[string]*File, importer Importer, universe *Scope) (*Package, error) {
+ var p pkgBuilder
+ p.fset = fset
+
+ // complete package scope
+ pkgName := ""
+ pkgScope := NewScope(universe)
+ for _, file := range files {
+ // package names must match
+ switch name := file.Name.Name; {
+ case pkgName == "":
+ pkgName = name
+ case name != pkgName:
+ p.errorf("package %s; expected %s", name, pkgName)
+ continue // ignore this file
+ }
+
+ // collect top-level file objects in package scope
+ for _, obj := range file.Scope.Objects {
+ p.declare(pkgScope, nil, obj)
+ }
+ }
+
+ // package global mapping of imported package ids to package objects
+ imports := make(map[string]*Object)
+
+ // complete file scopes with imports and resolve identifiers
+ for _, file := range files {
+ // ignore file if it belongs to a different package
+ // (error has already been reported)
+ if file.Name.Name != pkgName {
+ continue
+ }
+
+ // build file scope by processing all imports
+ importErrors := false
+ fileScope := NewScope(pkgScope)
+ for _, spec := range file.Imports {
+ if importer == nil {
+ importErrors = true
+ continue
+ }
+ path, _ := strconv.Unquote(spec.Path.Value)
+ pkg, err := importer(imports, path)
+ if err != nil {
+ p.errorf("could not import %s (%s)", path, err)
+ importErrors = true
+ continue
+ }
+ // TODO(gri) If a local package name != "." is provided,
+ // global identifier resolution could proceed even if the
+ // import failed. Consider adjusting the logic here a bit.
+
+ // local name overrides imported package name
+ name := pkg.Name
+ if spec.Name != nil {
+ name = spec.Name.Name
+ }
+
+ // add import to file scope
+ if name == "." {
+ // merge imported scope with file scope
+ for _, obj := range pkg.Data.(*Scope).Objects {
+ p.declare(fileScope, pkgScope, obj)
+ }
+ } else if name != "_" {
+ // declare imported package object in file scope
+ // (do not re-use pkg in the file scope but create
+ // a new object instead; the Decl field is different
+ // for different files)
+ obj := NewObj(Pkg, name)
+ obj.Decl = spec
+ obj.Data = pkg.Data
+ p.declare(fileScope, pkgScope, obj)
+ }
+ }
+
+ // resolve identifiers
+ if importErrors {
+ // don't use the universe scope without correct imports
+ // (objects in the universe may be shadowed by imports;
+ // with missing imports, identifiers might get resolved
+ // incorrectly to universe objects)
+ pkgScope.Outer = nil
+ }
+ i := 0
+ for _, ident := range file.Unresolved {
+ if !resolve(fileScope, ident) {
+ p.errorf("undeclared name: %s", ident.Name)
+ file.Unresolved[i] = ident
+ i++
+ }
+
+ }
+ file.Unresolved = file.Unresolved[0:i]
+ pkgScope.Outer = universe // reset universe scope
+ }
+
+ p.errors.Sort()
+ return &Package{pkgName, pkgScope, imports, files}, p.errors.Err()
+}
diff --git a/vendor/github.com/dave/dst/scope.go b/vendor/github.com/dave/dst/scope.go
new file mode 100644
index 0000000000..b87e44cde7
--- /dev/null
+++ b/vendor/github.com/dave/dst/scope.go
@@ -0,0 +1,108 @@
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// This file implements scopes and the objects they contain.
+
+package dst
+
+import (
+ "bytes"
+ "fmt"
+)
+
+// A Scope maintains the set of named language entities declared
+// in the scope and a link to the immediately surrounding (outer)
+// scope.
+type Scope struct {
+ Outer *Scope
+ Objects map[string]*Object
+}
+
+// NewScope creates a new scope nested in the outer scope.
+func NewScope(outer *Scope) *Scope {
+ const n = 4 // initial scope capacity
+ return &Scope{outer, make(map[string]*Object, n)}
+}
+
+// Lookup returns the object with the given name if it is
+// found in scope s, otherwise it returns nil. Outer scopes
+// are ignored.
+func (s *Scope) Lookup(name string) *Object {
+ return s.Objects[name]
+}
+
+// Insert attempts to insert a named object obj into the scope s.
+// If the scope already contains an object alt with the same name,
+// Insert leaves the scope unchanged and returns alt. Otherwise
+// it inserts obj and returns nil.
+func (s *Scope) Insert(obj *Object) (alt *Object) {
+ if alt = s.Objects[obj.Name]; alt == nil {
+ s.Objects[obj.Name] = obj
+ }
+ return
+}
+
+// Debugging support
+func (s *Scope) String() string {
+ var buf bytes.Buffer
+ fmt.Fprintf(&buf, "scope %p {", s)
+ if s != nil && len(s.Objects) > 0 {
+ fmt.Fprintln(&buf)
+ for _, obj := range s.Objects {
+ fmt.Fprintf(&buf, "\t%s %s\n", obj.Kind, obj.Name)
+ }
+ }
+ fmt.Fprintf(&buf, "}\n")
+ return buf.String()
+}
+
+// ----------------------------------------------------------------------------
+// Objects
+
+// An Object describes a named language entity such as a package,
+// constant, type, variable, function (incl. methods), or label.
+//
+// The Data fields contains object-specific data:
+//
+// Kind Data type Data value
+// Pkg *Scope package scope
+// Con int iota for the respective declaration
+type Object struct {
+ Kind ObjKind
+ Name string // declared name
+ Decl interface{} // corresponding Field, XxxSpec, FuncDecl, LabeledStmt, AssignStmt, Scope; or nil
+ Data interface{} // object-specific data; or nil
+ Type interface{} // placeholder for type information; may be nil
+}
+
+// NewObj creates a new object of a given kind and name.
+func NewObj(kind ObjKind, name string) *Object {
+ return &Object{Kind: kind, Name: name}
+}
+
+// ObjKind describes what an object represents.
+type ObjKind int
+
+// The list of possible Object kinds.
+const (
+ Bad ObjKind = iota // for error handling
+ Pkg // package
+ Con // constant
+ Typ // type
+ Var // variable
+ Fun // function or method
+ Lbl // label
+)
+
+var objKindStrings = [...]string{
+ Bad: "bad",
+ Pkg: "package",
+ Con: "const",
+ Typ: "type",
+ Var: "var",
+ Fun: "func",
+ Lbl: "label",
+}
+
+func (kind ObjKind) String() string { return objKindStrings[kind] }
diff --git a/vendor/github.com/dave/dst/walk.go b/vendor/github.com/dave/dst/walk.go
new file mode 100644
index 0000000000..d80885d892
--- /dev/null
+++ b/vendor/github.com/dave/dst/walk.go
@@ -0,0 +1,352 @@
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package dst
+
+import "fmt"
+
+// A Visitor's Visit method is invoked for each node encountered by Walk.
+// If the result visitor w is not nil, Walk visits each of the children
+// of node with the visitor w, followed by a call of w.Visit(nil).
+type Visitor interface {
+ Visit(node Node) (w Visitor)
+}
+
+// Helper functions for common node lists. They may be empty.
+
+func walkIdentList(v Visitor, list []*Ident) {
+ for _, x := range list {
+ Walk(v, x)
+ }
+}
+
+func walkExprList(v Visitor, list []Expr) {
+ for _, x := range list {
+ Walk(v, x)
+ }
+}
+
+func walkStmtList(v Visitor, list []Stmt) {
+ for _, x := range list {
+ Walk(v, x)
+ }
+}
+
+func walkDeclList(v Visitor, list []Decl) {
+ for _, x := range list {
+ Walk(v, x)
+ }
+}
+
+// TODO(gri): Investigate if providing a closure to Walk leads to
+// simpler use (and may help eliminate Inspect in turn).
+
+// Walk traverses an AST in depth-first order: It starts by calling
+// v.Visit(node); node must not be nil. If the visitor w returned by
+// v.Visit(node) is not nil, Walk is invoked recursively with visitor
+// w for each of the non-nil children of node, followed by a call of
+// w.Visit(nil).
+func Walk(v Visitor, node Node) {
+ if v = v.Visit(node); v == nil {
+ return
+ }
+
+ // walk children
+ // (the order of the cases matches the order
+ // of the corresponding node types in ast.go)
+ switch n := node.(type) {
+ case *Field:
+ walkIdentList(v, n.Names)
+ Walk(v, n.Type)
+ if n.Tag != nil {
+ Walk(v, n.Tag)
+ }
+
+ case *FieldList:
+ for _, f := range n.List {
+ Walk(v, f)
+ }
+
+ // Expressions
+ case *BadExpr, *Ident, *BasicLit:
+ // nothing to do
+
+ case *Ellipsis:
+ if n.Elt != nil {
+ Walk(v, n.Elt)
+ }
+
+ case *FuncLit:
+ Walk(v, n.Type)
+ Walk(v, n.Body)
+
+ case *CompositeLit:
+ if n.Type != nil {
+ Walk(v, n.Type)
+ }
+ walkExprList(v, n.Elts)
+
+ case *ParenExpr:
+ Walk(v, n.X)
+
+ case *SelectorExpr:
+ Walk(v, n.X)
+ Walk(v, n.Sel)
+
+ case *IndexExpr:
+ Walk(v, n.X)
+ Walk(v, n.Index)
+
+ case *IndexListExpr:
+ Walk(v, n.X)
+ walkExprList(v, n.Indices)
+
+ case *SliceExpr:
+ Walk(v, n.X)
+ if n.Low != nil {
+ Walk(v, n.Low)
+ }
+ if n.High != nil {
+ Walk(v, n.High)
+ }
+ if n.Max != nil {
+ Walk(v, n.Max)
+ }
+
+ case *TypeAssertExpr:
+ Walk(v, n.X)
+ if n.Type != nil {
+ Walk(v, n.Type)
+ }
+
+ case *CallExpr:
+ Walk(v, n.Fun)
+ walkExprList(v, n.Args)
+
+ case *StarExpr:
+ Walk(v, n.X)
+
+ case *UnaryExpr:
+ Walk(v, n.X)
+
+ case *BinaryExpr:
+ Walk(v, n.X)
+ Walk(v, n.Y)
+
+ case *KeyValueExpr:
+ Walk(v, n.Key)
+ Walk(v, n.Value)
+
+ // Types
+ case *ArrayType:
+ if n.Len != nil {
+ Walk(v, n.Len)
+ }
+ Walk(v, n.Elt)
+
+ case *StructType:
+ Walk(v, n.Fields)
+
+ case *FuncType:
+ if n.TypeParams != nil {
+ Walk(v, n.TypeParams)
+ }
+ if n.Params != nil {
+ Walk(v, n.Params)
+ }
+ if n.Results != nil {
+ Walk(v, n.Results)
+ }
+
+ case *InterfaceType:
+ Walk(v, n.Methods)
+
+ case *MapType:
+ Walk(v, n.Key)
+ Walk(v, n.Value)
+
+ case *ChanType:
+ Walk(v, n.Value)
+
+ // Statements
+ case *BadStmt:
+ // nothing to do
+
+ case *DeclStmt:
+ Walk(v, n.Decl)
+
+ case *EmptyStmt:
+ // nothing to do
+
+ case *LabeledStmt:
+ Walk(v, n.Label)
+ Walk(v, n.Stmt)
+
+ case *ExprStmt:
+ Walk(v, n.X)
+
+ case *SendStmt:
+ Walk(v, n.Chan)
+ Walk(v, n.Value)
+
+ case *IncDecStmt:
+ Walk(v, n.X)
+
+ case *AssignStmt:
+ walkExprList(v, n.Lhs)
+ walkExprList(v, n.Rhs)
+
+ case *GoStmt:
+ Walk(v, n.Call)
+
+ case *DeferStmt:
+ Walk(v, n.Call)
+
+ case *ReturnStmt:
+ walkExprList(v, n.Results)
+
+ case *BranchStmt:
+ if n.Label != nil {
+ Walk(v, n.Label)
+ }
+
+ case *BlockStmt:
+ walkStmtList(v, n.List)
+
+ case *IfStmt:
+ if n.Init != nil {
+ Walk(v, n.Init)
+ }
+ Walk(v, n.Cond)
+ Walk(v, n.Body)
+ if n.Else != nil {
+ Walk(v, n.Else)
+ }
+
+ case *CaseClause:
+ walkExprList(v, n.List)
+ walkStmtList(v, n.Body)
+
+ case *SwitchStmt:
+ if n.Init != nil {
+ Walk(v, n.Init)
+ }
+ if n.Tag != nil {
+ Walk(v, n.Tag)
+ }
+ Walk(v, n.Body)
+
+ case *TypeSwitchStmt:
+ if n.Init != nil {
+ Walk(v, n.Init)
+ }
+ Walk(v, n.Assign)
+ Walk(v, n.Body)
+
+ case *CommClause:
+ if n.Comm != nil {
+ Walk(v, n.Comm)
+ }
+ walkStmtList(v, n.Body)
+
+ case *SelectStmt:
+ Walk(v, n.Body)
+
+ case *ForStmt:
+ if n.Init != nil {
+ Walk(v, n.Init)
+ }
+ if n.Cond != nil {
+ Walk(v, n.Cond)
+ }
+ if n.Post != nil {
+ Walk(v, n.Post)
+ }
+ Walk(v, n.Body)
+
+ case *RangeStmt:
+ if n.Key != nil {
+ Walk(v, n.Key)
+ }
+ if n.Value != nil {
+ Walk(v, n.Value)
+ }
+ Walk(v, n.X)
+ Walk(v, n.Body)
+
+ // Declarations
+ case *ImportSpec:
+ if n.Name != nil {
+ Walk(v, n.Name)
+ }
+ Walk(v, n.Path)
+
+ case *ValueSpec:
+ walkIdentList(v, n.Names)
+ if n.Type != nil {
+ Walk(v, n.Type)
+ }
+ walkExprList(v, n.Values)
+
+ case *TypeSpec:
+ Walk(v, n.Name)
+ if n.TypeParams != nil {
+ Walk(v, n.TypeParams)
+ }
+ Walk(v, n.Type)
+
+ case *BadDecl:
+ // nothing to do
+
+ case *GenDecl:
+ for _, s := range n.Specs {
+ Walk(v, s)
+ }
+
+ case *FuncDecl:
+ if n.Recv != nil {
+ Walk(v, n.Recv)
+ }
+ Walk(v, n.Name)
+ Walk(v, n.Type)
+ if n.Body != nil {
+ Walk(v, n.Body)
+ }
+
+ // Files and packages
+ case *File:
+ Walk(v, n.Name)
+ walkDeclList(v, n.Decls)
+ // don't walk n.Comments - they have been
+ // visited already through the individual
+ // nodes
+
+ case *Package:
+ for _, f := range n.Files {
+ Walk(v, f)
+ }
+
+ default:
+ panic(fmt.Sprintf("ast.Walk: unexpected node type %T", n))
+ }
+
+ v.Visit(nil)
+}
+
+type inspector func(Node) bool
+
+func (f inspector) Visit(node Node) Visitor {
+ if f(node) {
+ return f
+ }
+ return nil
+}
+
+// Inspect traverses an AST in depth-first order: It starts by calling
+// f(node); node must not be nil. If f returns true, Inspect invokes f
+// recursively for each of the non-nil children of node, followed by a
+// call of f(nil).
+func Inspect(node Node, f func(Node) bool) {
+ Walk(inspector(f), node)
+}
diff --git a/vendor/github.com/dlclark/regexp2/v2/.gitignore b/vendor/github.com/dlclark/regexp2/v2/.gitignore
new file mode 100644
index 0000000000..e41389dffe
--- /dev/null
+++ b/vendor/github.com/dlclark/regexp2/v2/.gitignore
@@ -0,0 +1,29 @@
+# Compiled Object files, Static and Dynamic libs (Shared Objects)
+*.o
+*.a
+*.so
+
+# Folders
+_obj
+_test
+
+# Architecture specific extensions/prefixes
+*.[568vq]
+[568vq].out
+
+*.cgo1.go
+*.cgo2.c
+_cgo_defun.c
+_cgo_gotypes.go
+_cgo_export.*
+
+_testmain.go
+
+*.exe
+*.test
+*.prof
+*.out
+
+.DS_Store
+*.txt
+benchmarks/
diff --git a/vendor/github.com/dlclark/regexp2/v2/ATTRIB b/vendor/github.com/dlclark/regexp2/v2/ATTRIB
new file mode 100644
index 0000000000..cdf4560b9e
--- /dev/null
+++ b/vendor/github.com/dlclark/regexp2/v2/ATTRIB
@@ -0,0 +1,133 @@
+============
+These pieces of code were ported from dotnet/corefx:
+
+syntax/charclass.go (from RegexCharClass.cs): ported to use the built-in Go unicode classes. Canonicalize is
+ a direct port, but most of the other code required large changes because the C# implementation
+ used a string to represent the CharSet data structure and I cleaned that up in my implementation.
+
+syntax/code.go (from RegexCode.cs): ported literally with various cleanups and layout to make it more Go-ish.
+
+syntax/escape.go (from RegexParser.cs): ported Escape method and added some optimizations. Unescape is inspired by
+ the C# implementation but couldn't be directly ported because of the lack of do-while syntax in Go.
+
+syntax/parser.go (from RegexpParser.cs and RegexOptions.cs): ported parser struct and associated methods as
+ literally as possible. Several language differences required changes. E.g. lack pre/post-fix increments as
+ expressions, lack of do-while loops, lack of overloads, etc.
+
+syntax/prefix.go (from RegexFCD.cs and RegexBoyerMoore.cs): ported as literally as possible and added support
+ for unicode chars that are longer than the 16-bit char in C# for the 32-bit rune in Go.
+
+syntax/replacerdata.go (from RegexReplacement.cs): conceptually ported and re-organized to handle differences
+ in charclass implementation, and fix odd code layout between RegexParser.cs, Regex.cs, and RegexReplacement.cs.
+
+syntax/tree.go (from RegexTree.cs and RegexNode.cs): ported literally as possible.
+
+syntax/writer.go (from RegexWriter.cs): ported literally with minor changes to make it more Go-ish.
+
+match.go (from RegexMatch.cs): ported, simplified, and changed to handle Go's lack of inheritence.
+
+regexp.go (from Regex.cs and RegexOptions.cs): conceptually serves the same "starting point", but is simplified
+ and changed to handle differences in C# strings and Go strings/runes.
+
+replace.go (from RegexReplacement.cs): ported closely and then cleaned up to combine the MatchEvaluator and
+ simple string replace implementations.
+
+runner.go (from RegexRunner.cs): ported literally as possible.
+
+regexp_test.go (from CaptureTests.cs and GroupNamesAndNumbers.cs): conceptually ported, but the code was
+ manually structured like Go tests.
+
+replace_test.go (from RegexReplaceStringTest0.cs): conceptually ported
+
+rtl_test.go (from RightToLeft.cs): conceptually ported
+---
+dotnet/corefx was released under this license:
+
+The MIT License (MIT)
+
+Copyright (c) Microsoft Corporation
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+
+============
+These pieces of code are copied from the Go framework:
+
+- The overall directory structure of regexp2 was inspired by the Go runtime regexp package.
+- The optimization in the escape method of syntax/escape.go is from the Go runtime QuoteMeta() func in regexp/regexp.go
+- The method signatures in regexp.go are designed to match the Go framework regexp methods closely
+- func regexp2.MustCompile and func quote are almost identifical to the regexp package versions
+- BenchmarkMatch* and TestProgramTooLong* funcs in regexp_performance_test.go were copied from the framework
+ regexp/exec_test.go
+---
+The Go framework was released under this license:
+
+Copyright (c) 2012 The Go Authors. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+ * Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+copyright notice, this list of conditions and the following disclaimer
+in the documentation and/or other materials provided with the
+distribution.
+ * Neither the name of Google Inc. nor the names of its
+contributors may be used to endorse or promote products derived from
+this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+============
+Some test data were gathered from the Mono project.
+
+regexp_mono_test.go: ported from https://github.com/mono/mono/blob/master/mcs/class/System/Test/System.Text.RegularExpressions/PerlTrials.cs
+---
+Mono tests released under this license:
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
diff --git a/vendor/github.com/dlclark/regexp2/v2/LICENSE b/vendor/github.com/dlclark/regexp2/v2/LICENSE
new file mode 100644
index 0000000000..fe83dfdc92
--- /dev/null
+++ b/vendor/github.com/dlclark/regexp2/v2/LICENSE
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) Doug Clark
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/vendor/github.com/dlclark/regexp2/v2/README.md b/vendor/github.com/dlclark/regexp2/v2/README.md
new file mode 100644
index 0000000000..f49a0d0595
--- /dev/null
+++ b/vendor/github.com/dlclark/regexp2/v2/README.md
@@ -0,0 +1,283 @@
+# regexp2 - full featured regular expressions for Go
+Regexp2 is a feature-rich RegExp engine for Go. It doesn't have constant time guarantees like the built-in `regexp` package, but it allows backtracking and is compatible with Perl5 and .NET. You'll likely be better off with the RE2 engine from the `regexp` package and should only use this if you need to write very complex patterns or require compatibility with .NET.
+
+## Basis of the engine
+The engine is ported from the .NET framework's System.Text.RegularExpressions.Regex engine. That engine was open sourced in 2015 under the MIT license. There are some fundamental differences between .NET strings and Go strings that required a bit of borrowing from the Go framework regex engine as well. I cleaned up a couple of the dirtier bits during the port (regexcharclass.cs was terrible), but the parse tree, code emmitted, and therefore patterns matched should be identical.
+
+## New Code Generation
+For extra performance use `regexp2` with [`regexp2cg`](https://github.com/dlclark/regexp2cg). It is a code generation utility for `regexp2` and you can likely improve your regexp runtime performance by 3-10x in hot code paths. As always you should benchmark your specifics to confirm the results. Give it a try!
+
+## Installing
+This is a go-gettable library, so install is easy:
+
+ go get github.com/dlclark/regexp2/v2@latest
+
+## Changes in v2
+Version 2 includes changes that may affect compatibility with existing v1 users:
+
+* The module path is now `github.com/dlclark/regexp2/v2`, so imports need to use the `/v2` suffix.
+* The minimum supported Go version is now Go 1.25.
+* Changes to support https://github.com/dlclark/regexp2cg are merged in to support generated regex engines.
+* `Regexp.Split` is now available for splitting strings with regexp matches.
+* The new `compat` sub-package provides a [`regexp` compatibility adapter](#regexp-compatibility-adapter) with the same `Find*` and `Match*` method signatures as `regexp.Regexp`, plus a `compat.Matcher` interface that is implemented by both `*regexp.Regexp` and the adapter.
+* The parser, optimizer, and runner internals have changed significantly to support generated regexes and additional matching optimizations.
+* `Compile` and `MustCompile` now use variadic compile options for regex behavior and memory/performance tuning. See [Compile options](#compile-options) for more details.
+* Moved `regexp2.Debug` and `regexp2.Compile` to new `regexp2.OptionDebug()` and `regexp2.OptionIsCodeGen()` compile options.
+* Some types and constants in the `syntax` package have been exported or changed to support code generation.
+* Conceptually changed the goal of the `regexp2.ECMAScript` option to be closer to the ECMAScript standard rather than C#'s ECMAScript behavior.
+* Renamed the fields `Capture.Index` and `Capture.Length` to `Capture.RuneIndex` and `Capture.RuneLength` to be more clear that we're dealing with rune offsets.
+* Added `Capture.ByteRange()` to return the byte offset index and length of the captured text. This requires some additional processing to be done behind the scenes the first time it's called for a given capture to convert the native rune offsets to byte offsets.
+
+## Usage
+Usage is similar to the Go `regexp` package. Just like in `regexp`, you start by converting a regex into a state machine via the `Compile` or `MustCompile` methods. They ultimately do the same thing, but `MustCompile` will panic if the regex is invalid. You can then use the provided `Regexp` struct to find matches repeatedly. A `Regexp` struct is safe to use across goroutines.
+
+```go
+re := regexp2.MustCompile(`Your pattern`)
+if isMatch, _ := re.MatchString(`Something to match`); isMatch {
+ //do something
+}
+```
+
+The only error that the `*Match*` methods *should* return is a Timeout if you set the `re.MatchTimeout` field. Any other error is a bug in the `regexp2` package. If you need more details about capture groups in a match then use the `FindStringMatch` method, like so:
+
+```go
+if m, _ := re.FindStringMatch(`Something to match`); m != nil {
+ // the whole match is always group 0
+ fmt.Printf("Group 0: %v\n", m.String())
+
+ // you can get all the groups too
+ gps := m.Groups()
+
+ // a group can be captured multiple times, so each cap is separately addressable
+ fmt.Printf("Group 1, first capture", gps[1].Captures[0].String())
+ fmt.Printf("Group 1, second capture", gps[1].Captures[1].String())
+}
+```
+
+Group 0 is embedded in the Match. Group 0 is an automatically-assigned group that encompasses the whole pattern. This means that `m.String()` is the same as `m.Group.String()` and `m.Groups()[0].String()`
+
+The __last__ capture is embedded in each group, so `g.String()` will return the same thing as `g.Capture.String()` and `g.Captures[len(g.Captures)-1].String()`.
+
+If you want to find multiple matches from a single input string you should use the `FindNextMatch` method. For example, to implement a function similar to `regexp.FindAllString`:
+
+```go
+func regexp2FindAllString(re *regexp2.Regexp, s string) []string {
+ var matches []string
+ m, _ := re.FindStringMatch(s)
+ for m != nil {
+ matches = append(matches, m.String())
+ m, _ = re.FindNextMatch(m)
+ }
+ return matches
+}
+```
+
+`FindNextMatch` is optmized so that it re-uses the underlying string/rune slice.
+
+The internals of `regexp2` always operate on `[]rune` so `RuneIndex` and `RuneLength` data in a `Match` always reference a position in `rune`s rather than `byte`s (even if the input was given as a string). `ByteRange()` provides UTF-8 byte offsets, matching the original string input for string APIs. It's advisable to use the provided `String()` methods when you do not need explicit offsets. `ByteRange()` lazily caches byte offsets on the shared match text, so the first call on captures from the same match is not safe to run concurrently with other `ByteRange()` calls on that match.
+
+## Unicode character classes
+
+`regexp2` supports Unicode character classes with `\p{...}` and negated classes with `\P{...}`. Outside ECMAScript Unicode mode, it also accepts the RE2/PCRE-style one-letter form, such as `\pL`.
+
+The class name may be a Go Unicode category, category alias, script, or property exposed by the Go standard library Unicode tables. For example:
+
+```go
+letter := regexp2.MustCompile(`\p{L}+`)
+katakana := regexp2.MustCompile(`\p{Katakana}+`)
+notEmoji := regexp2.MustCompile(`\P{Emoji}+`)
+```
+
+`regexp2` also supports Unicode property selection syntax in the form `\p{property=value}`. Property and value aliases are matched loosely: case, hyphens, and underscores are ignored. For example, `\p{GCB=RI}`, `\p{grapheme_cluster_break=regional_indicator}`, and `\p{grapheme-cluster-break=regional-indicator}` all refer to the same class.
+
+Valid property names and aliases come from Unicode 17.0.0 [`PropertyAliases.txt`](https://www.unicode.org/Public/17.0.0/ucd/PropertyAliases.txt). Valid property values and aliases come from Unicode 17.0.0 [`PropertyValueAliases.txt`](https://www.unicode.org/Public/17.0.0/ucd/PropertyValueAliases.txt). The generated tables use Unicode 17.0.0 data from [`DerivedCoreProperties.txt`](https://www.unicode.org/Public/17.0.0/ucd/DerivedCoreProperties.txt), [`emoji/emoji-data.txt`](https://www.unicode.org/Public/17.0.0/ucd/emoji/emoji-data.txt), [`auxiliary/GraphemeBreakProperty.txt`](https://www.unicode.org/Public/17.0.0/ucd/auxiliary/GraphemeBreakProperty.txt), [`auxiliary/WordBreakProperty.txt`](https://www.unicode.org/Public/17.0.0/ucd/auxiliary/WordBreakProperty.txt), and [`auxiliary/SentenceBreakProperty.txt`](https://www.unicode.org/Public/17.0.0/ucd/auxiliary/SentenceBreakProperty.txt) for the package-local properties whose data changes more frequently than the Go standard library tables.
+
+## `regexp` compatibility adapter
+
+The `github.com/dlclark/regexp2/v2/compat` package provides an adapter for callers that want the same `Find*` and `Match*` method signatures as the standard library's `regexp.Regexp`, while still using the `regexp2` engine.
+
+```go
+import (
+ "github.com/dlclark/regexp2/v2"
+ "github.com/dlclark/regexp2/v2/compat"
+)
+
+re := compat.MustCompile(`Your pattern`, regexp2.RE2)
+if re.MatchString(`Something to match`) {
+ // do something
+}
+
+matches := re.FindAllString(`abc axbc`, -1)
+_ = matches
+```
+
+You can also wrap an existing compiled regexp:
+
+```go
+base := regexp2.MustCompile(`Your pattern`)
+re := compat.Wrap(base)
+```
+
+The adapter includes the standard-library matching surface: `Match`, `MatchString`, `MatchReader`, and all `Find(All)?(String)?(Submatch)?(Index)?` methods. Index-returning methods use UTF-8 byte offsets like `regexp`, not regexp2's rune offsets.
+
+The package also defines `compat.Matcher`, a common interface implemented by both `*regexp.Regexp` and `*compat.Regexp`. Use it when code should accept either the standard library engine or a regexp2-backed adapter:
+
+```go
+func findWords(re compat.Matcher, input string) []string {
+ return re.FindAllString(input, -1)
+}
+```
+
+Because those standard-library method signatures do not return errors, the adapter panics if the wrapped regexp2 matcher returns an error such as a match timeout. Use the main `regexp2` APIs directly when you need to handle timeouts as errors.
+
+## Compile options
+
+`Compile` and `MustCompile` take variadic compile options. Most users can omit them and get default regex behavior plus bounded shared pools for rune buffers and replacement output buffers, plus per-regexp caches for parsed replacement patterns and ASCII character class bitmaps.
+
+Regex option constants can be passed directly, individually or as a bitmask:
+
+```go
+re := regexp2.MustCompile(`Your pattern`, regexp2.IgnoreCase, regexp2.Singleline)
+re = regexp2.MustCompile(`Your pattern`, regexp2.IgnoreCase|regexp2.Singleline)
+```
+
+Performance tuning options override the default cache settings:
+
+```go
+re := regexp2.MustCompile(`Your pattern`,
+ regexp2.IgnoreCase,
+ regexp2.OptionMaxCachedRuneBufferLength(64*1024),
+ regexp2.OptionMaxCachedReplacerDataEntries(8),
+)
+```
+
+Compile-only options configure behavior that is not settable from the pattern:
+
+```go
+re := regexp2.MustCompile(`(?This) (is)`, regexp2.OptionMaintainCaptureOrder())
+```
+
+The defaults are intentionally bounded:
+
+| Option | Default | Used by | Working-set growth | Tradeoffs |
+| --- | ---: | --- | --- | --- |
+| `OptionMaintainCaptureOrder()` | false | Parser capture-slot assignment for mixed named and unnamed captures. | None at match time. This changes compile-time capture numbering only. | Keeps named and unnamed captures in pattern order instead of appending named captures after unnamed captures. This can change numeric backreference meaning, so it is caller-controlled rather than an inline regex option. |
+| `OptionDebug()` | false | Compile dumps and runner tracing. | Debug output volume only. | Useful for diagnostics, but it can produce noisy output and slower traced matching. |
+| `OptionIsCodeGen()` | false | Compile-time find-optimization analysis for [`regexp2cg`](https://github.com/dlclark/regexp2cg). | Per compiled regexp, during `Compile` or `MustCompile`. | Enables more expensive analysis intended for generated engines. Do not use it for normal interpreter execution; the interpreter defaults intentionally avoid this extra compile-time cost. |
+| `OptionMaxCachedRuneBufferLength(n)` | 256K runes | String APIs that run through pooled runners, such as `MatchString` and replacement-pattern `Replace`, when converting input strings to the engine's internal `[]rune` representation. | Process-wide shared `sync.Pool` retention by size class. This does not grow per compiled regexp or per input string; the practical working set follows recent and concurrent use across all regexps and can be dropped by GC. | Raising this lets calls use larger pooled rune buffers and can reduce allocations for repeated matches against large strings. Lowering it prevents larger buffers from being borrowed or returned, so large inputs allocate directly. |
+| `OptionMaxCachedReplaceBufferLength(n)` | 256 KB | Replacement-pattern `Replace` calls that build output through a shared byte buffer. | Process-wide shared `sync.Pool` retention by size class after replacement-pattern `Replace` runs. It does not grow from evaluator-based `ReplaceFunc` output and is shared across compiled regexps. | Raising this lets larger replacement outputs use pooled buffers and can reduce allocations. Lowering it prevents larger output buffers from being retained, so large replacements allocate directly. |
+| `OptionMaxCachedReplacerDataEntries(n)` | `16` | `Replace` with replacement pattern strings, after the replacement pattern is parsed into reusable replacement data. | Per compiled regexp. The cache grows as distinct cacheable replacement strings are used with `Replace`, up to this entry count. | Raising this helps when a single compiled regexp is used with many recurring replacement patterns. It increases per-regexp cache memory and lock-protected cache bookkeeping. Setting it to `0` disables this cache. |
+| `OptionMaxCachedReplacerDataBytes(n)` | 4 KB | The parsed replacement-pattern cache. Replacement strings longer than this are parsed for the call but not retained. | Per compiled regexp, combined with `OptionMaxCachedReplacerDataEntries`. Only replacement strings whose source text is at or below this size can add parsed data to the cache. | Raising this helps if large replacement patterns are reused. It can retain more memory per cached replacement. Lowering it avoids keeping unusual large replacement patterns around. |
+| `OptionDisableCharClassASCIIBitmap()` | false | Compile-time preparation of character classes and first-character prefix sets. By default, character classes with ASCII membership get a small bitmap used by `CharIn`. | Per compiled regexp, during `Compile` or `MustCompile`. Each eligible character class can hold one small bitmap; this does not scale with match concurrency or input size. | Leaving this false speeds up ASCII-heavy character class checks at the cost of a small amount of per-char-class memory and compile-time work. Setting to true can reduce memory for large numbers of compiled char classes in regexps, but ASCII character class matching may be slower. |
+
+For pooled buffer cache options, set `n` to `0` to disable pooling, or `-1` to allow all built-in size classes. The rune buffer classes are 1K, 4K, 16K, 64K, and 256K runes. The replacement byte buffer classes are 4 KB, 16 KB, 64 KB, 256 KB, and 1 MB. By default the 1 MB pool is unused. For replacement data byte-size cache options, `-1` means unbounded. For entry-count cache options, set `n` to `0` to disable the cache.
+
+## Compare `regexp` and `regexp2`
+| Category | regexp | regexp2 |
+| --- | --- | --- |
+| Catastrophic backtracking possible | no, constant execution time guarantees | yes, if your pattern is at risk you can use the `re.MatchTimeout` field |
+| Python-style capture groups `(?Pre)` | yes | no (yes in RE2 compat mode) |
+| .NET-style capture groups `(?re)` or `(?'name're)` | yes | yes |
+| comments `(?#comment)` | no | yes |
+| branch numbering reset `(?\|a\|b)` | no | no |
+| possessive match `(?>re)` | no | yes |
+| positive lookahead `(?=re)` | no | yes |
+| negative lookahead `(?!re)` | no | yes |
+| positive lookbehind `(?<=re)` | no | yes |
+| negative lookbehind `(?re)`)
+* add support for python-style named backreferences (e.g. `(?P=name)`)
+* change singleline behavior for `$` to only match end of string (like RE2) (see [#24](https://github.com/dlclark/regexp2/issues/24))
+* change the character classes `\d` `\s` and `\w` to match the same characters as RE2. NOTE: if you also use the `ECMAScript` option then this will change the `\s` character class to match ECMAScript instead of RE2. ECMAScript allows more whitespace characters in `\s` than RE2 (but still fewer than the the default behavior).
+* allow character escape sequences to have defaults. For example, by default `\_` isn't a known character escape and will fail to compile, but in RE2 mode it will match the literal character `_`
+
+```go
+re := regexp2.MustCompile(`Your RE2-compatible pattern`, regexp2.RE2)
+if isMatch, _ := re.MatchString(`Something to match`); isMatch {
+ //do something
+}
+```
+
+This feature is a work in progress and I'm open to ideas for more things to put here (maybe more relaxed character escaping rules?).
+
+## Catastrophic Backtracking and Timeouts
+
+`regexp2` supports features that can lead to catastrophic backtracking.
+`Regexp.MatchTimeout` can be set to to limit the impact of such behavior; the
+match will fail with an error after approximately MatchTimeout. No timeout
+checks are done by default.
+
+Timeout checking is not free. The current timeout checking implementation starts
+a background worker that updates a clock value approximately once every 100
+milliseconds. The matching code compares this value against the precomputed
+deadline for the match. The performance impact is as follows.
+
+1. A match with a timeout runs almost as fast as a match without a timeout.
+2. If any live matches have a timeout, there will be a background CPU load
+ (`~0.15%` currently on a modern machine). This load will remain constant
+ regardless of the number of matches done including matches done in parallel.
+3. If no live matches are using a timeout, the background load will remain
+ until the longest deadline (match timeout + the time when the match started)
+ is reached. E.g., if you set a timeout of one minute the load will persist
+ for approximately a minute even if the match finishes quickly.
+
+See [PR #58](https://github.com/dlclark/regexp2/pull/58) for more details and
+alternatives considered.
+
+## Goroutine leak error
+If you're using a library during unit tests (e.g. https://github.com/uber-go/goleak) that validates all goroutines are exited then you'll likely get an error if you or any of your dependencies use regex's with a MatchTimeout.
+To remedy the problem you'll need to tell the unit test to wait until the backgroup timeout goroutine is exited.
+
+```go
+func TestSomething(t *testing.T) {
+ defer goleak.VerifyNone(t)
+ defer regexp2.StopTimeoutClock()
+
+ // ... test
+}
+
+//or
+
+func TestMain(m *testing.M) {
+ // setup
+ // ...
+
+ // run
+ m.Run()
+
+ //tear down
+ regexp2.StopTimeoutClock()
+ goleak.VerifyNone(t)
+}
+```
+
+This will add ~100ms runtime to each test (or TestMain). If that's too much time you can set the clock cycle rate of the timeout goroutine in an init function in a test file. `regexp2.SetTimeoutCheckPeriod` isn't threadsafe so it must be setup before starting any regex's with Timeouts.
+
+```go
+func init() {
+ //speed up testing by making the timeout clock 1ms
+ regexp2.SetTimeoutCheckPeriod(time.Millisecond)
+}
+```
+
+## ECMAScript compatibility mode
+In this mode the engine attempts to match the [regex engine](https://tc39.es/ecma262/multipage/text-processing.html#sec-regexp-regular-expression-objects) described in the ECMAScript specification as closely as reasonably possible within regexp2's API and implementation.
+
+This flag should not be treated as compatibility with C#'s `RegexOptions.ECMAScript`. regexp2's ECMAScript behavior prioritizes ECMAScript specification behavior over matching the C# regex engine's interpretation of that option.
+
+Additionally a Unicode mode is provided which allows parsing of `\u{CodePoint}` syntax only when both `ECMAScript` and `Unicode` are provided.
+
+## Potential bugs
+I've run a battery of tests against regexp2 from various sources and found the debug output matches the .NET engine, but .NET and Go handle strings very differently. I've attempted to handle these differences, but most of my testing deals with basic ASCII with a little bit of multi-byte Unicode. There's a chance that there are bugs in the string handling related to character sets with supplementary Unicode chars. Right-to-Left support is coded, but not well tested either.
+
+## Find a bug?
+I'm open to new issues and pull requests with tests if you find something odd!
diff --git a/vendor/github.com/dlclark/regexp2/v2/Taskfile.yml b/vendor/github.com/dlclark/regexp2/v2/Taskfile.yml
new file mode 100644
index 0000000000..fffb3f2701
--- /dev/null
+++ b/vendor/github.com/dlclark/regexp2/v2/Taskfile.yml
@@ -0,0 +1,64 @@
+version: '3'
+
+tasks:
+ benchcmp:
+ desc: Compare current benchmarks against an optional commit, defaulting to HEAD
+ vars:
+ BENCH_COUNT: '{{default "5" .COUNT}}'
+ REF:
+ sh: |
+ if [ -n "{{.COMMIT}}" ]; then
+ printf '%s\n' "{{.COMMIT}}"
+ elif [ -n "{{.CLI_ARGS}}" ]; then
+ set -- {{.CLI_ARGS}}
+ printf '%s\n' "$1"
+ else
+ printf '%s\n' HEAD
+ fi
+ COMMIT_HASH:
+ sh: git rev-parse --verify "{{.REF}}^{commit}"
+ cmds:
+ - |
+ set -eu
+
+ mkdir -p benchmarks
+
+ base_file="benchmarks/{{.COMMIT_HASH}}-count{{.BENCH_COUNT}}.txt"
+ new_file="benchmarks/new.txt"
+ base_tmp=""
+ new_tmp=""
+ worktree_dir="$(mktemp -d /tmp/regexp2-benchcmp.XXXXXX)"
+
+ cleanup() {
+ if [ -n "$base_tmp" ]; then
+ rm -f "$base_tmp"
+ fi
+ if [ -n "$new_tmp" ]; then
+ rm -f "$new_tmp"
+ fi
+ git worktree remove --force "$worktree_dir" >/dev/null 2>&1 || true
+ }
+ trap cleanup EXIT
+
+ if [ -f "$base_file" ] && grep -q '^Benchmark' "$base_file"; then
+ printf 'Using cached baseline benchmarks from %s...\n' "$base_file"
+ else
+ if [ -f "$base_file" ]; then
+ printf 'Ignoring cached baseline without benchmark results at %s...\n' "$base_file"
+ fi
+ printf 'Running baseline benchmarks for %s (%s samples)...\n' "{{.COMMIT_HASH}}" "{{.BENCH_COUNT}}"
+ git worktree add --detach "$worktree_dir" "{{.COMMIT_HASH}}"
+ base_tmp="$(mktemp "${base_file}.tmp.XXXXXX")"
+ (cd "$worktree_dir" && env GOWORK=off go test -run '^$' -bench . -benchmem -count "{{.BENCH_COUNT}}" ./...) > "$base_tmp"
+ mv "$base_tmp" "$base_file"
+ base_tmp=""
+ fi
+
+ printf 'Running current benchmarks (%s samples)...\n' "{{.BENCH_COUNT}}"
+ new_tmp="$(mktemp "${new_file}.tmp.XXXXXX")"
+ env GOWORK=off go test -run '^$' -bench . -benchmem -count "{{.BENCH_COUNT}}" ./... > "$new_tmp"
+ mv "$new_tmp" "$new_file"
+ new_tmp=""
+
+ printf 'Comparing benchmark results with benchstat...\n'
+ benchstat "$base_file" "$new_file"
diff --git a/vendor/github.com/dlclark/regexp2/v2/bufferpool.go b/vendor/github.com/dlclark/regexp2/v2/bufferpool.go
new file mode 100644
index 0000000000..0580d6a171
--- /dev/null
+++ b/vendor/github.com/dlclark/regexp2/v2/bufferpool.go
@@ -0,0 +1,76 @@
+package regexp2
+
+import (
+ "bytes"
+ "slices"
+ "sync"
+)
+
+type pooledSliceBuffers[T any] struct {
+ sizes []int
+ pools []sync.Pool
+}
+
+func newPooledSliceBuffers[T any](sizes ...int) *pooledSliceBuffers[T] {
+ sizes = slices.Clone(sizes)
+ slices.Sort(sizes)
+ return &pooledSliceBuffers[T]{
+ sizes: sizes,
+ pools: make([]sync.Pool, len(sizes)),
+ }
+}
+
+func (p *pooledSliceBuffers[T]) poolIndex(neededSize, maxSize int) int {
+ if maxSize == 0 {
+ return -1
+ }
+ for i, classSize := range p.sizes {
+ if neededSize <= classSize {
+ if maxSize > 0 && classSize > maxSize {
+ return -1
+ }
+ return i
+ }
+ }
+ return -1
+}
+
+func (p *pooledSliceBuffers[T]) get(neededSize, maxSize int) ([]T, *[]T) {
+ idx := p.poolIndex(neededSize, maxSize)
+ if idx < 0 {
+ return make([]T, neededSize), nil
+ }
+ if v := p.pools[idx].Get(); v != nil {
+ bufp := v.(*[]T)
+ if cap(*bufp) >= neededSize {
+ return (*bufp)[:neededSize], bufp
+ }
+ }
+ buf := make([]T, neededSize, p.sizes[idx])
+ return buf, &buf
+}
+
+func (p *pooledSliceBuffers[T]) put(bufp *[]T) {
+ idx := p.poolIndex(cap(*bufp), -1)
+ if idx < 0 || cap(*bufp) != p.sizes[idx] {
+ return
+ }
+ *bufp = (*bufp)[:0]
+ p.pools[idx].Put(bufp)
+}
+
+// our specific pooled buffers
+var (
+ pooledRuneBuffers = newPooledSliceBuffers[rune](1<<10, 4<<10, 16<<10, 64<<10, 256<<10)
+ pooledByteBuffers = newPooledSliceBuffers[byte](4<<10, 16<<10, 64<<10, 256<<10, 1<<20)
+)
+
+func getPooledReplaceBuffer(neededBytes, maxSize int) (*bytes.Buffer, *[]byte) {
+ buf, pooled := pooledByteBuffers.get(neededBytes, maxSize)
+ return bytes.NewBuffer(buf[:0]), pooled
+}
+
+func putPooledReplaceBuffer(buf *bytes.Buffer, pooled *[]byte) {
+ *pooled = buf.Bytes()
+ pooledByteBuffers.put(pooled)
+}
diff --git a/vendor/github.com/dlclark/regexp2/v2/fastclock.go b/vendor/github.com/dlclark/regexp2/v2/fastclock.go
new file mode 100644
index 0000000000..d256e63c74
--- /dev/null
+++ b/vendor/github.com/dlclark/regexp2/v2/fastclock.go
@@ -0,0 +1,141 @@
+package regexp2
+
+import (
+ "sync"
+ "sync/atomic"
+ "time"
+)
+
+// fasttime holds a time value (ticks since clock initialization)
+type fasttime int64
+
+// fastclock provides a fast clock implementation.
+//
+// A background goroutine periodically stores the current time
+// into an atomic variable.
+//
+// A deadline can be quickly checked for expiration by comparing
+// its value to the clock stored in the atomic variable.
+//
+// The goroutine automatically stops once clockEnd is reached.
+// (clockEnd covers the largest deadline seen so far + some
+// extra time). This ensures that if regexp2 with timeouts
+// stops being used we will stop background work.
+type fastclock struct {
+ // instances of atomicTime must be at the start of the struct (or at least 64-bit aligned)
+ // otherwise 32-bit architectures will panic
+
+ current atomicTime // Current time (approximate)
+ clockEnd atomicTime // When clock updater is supposed to stop (>= any existing deadline)
+
+ // current and clockEnd can be read via atomic loads.
+ // Reads and writes of other fields require mu to be held.
+ mu sync.Mutex
+ start time.Time // Time corresponding to fasttime(0)
+ running bool // Is a clock updater running?
+}
+
+var fast fastclock
+
+// reached returns true if current time is at or past t.
+func (t fasttime) reached() bool {
+ return fast.current.read() >= t
+}
+
+// makeDeadline returns a time that is approximately time.Now().Add(d)
+func makeDeadline(d time.Duration) fasttime {
+ // Increase the deadline since the clock we are reading may be
+ // just about to tick forwards.
+ end := fast.current.read() + durationToTicks(d+clockPeriod)
+
+ // Start or extend clock if necessary.
+ if end > fast.clockEnd.read() {
+ // If time.Since(last use) > timeout, there's a chance that
+ // fast.current will no longer be updated, which can lead to
+ // incorrect 'end' calculations that can trigger a false timeout
+ fast.mu.Lock()
+ if !fast.running && !fast.start.IsZero() {
+ // update fast.current
+ fast.current.write(durationToTicks(time.Since(fast.start)))
+ // recalculate our end value
+ end = fast.current.read() + durationToTicks(d+clockPeriod)
+ }
+ fast.mu.Unlock()
+ extendClock(end)
+ }
+
+ return end
+}
+
+// extendClock ensures that clock is live and will run until at least end.
+func extendClock(end fasttime) {
+ fast.mu.Lock()
+ defer fast.mu.Unlock()
+
+ if fast.start.IsZero() {
+ fast.start = time.Now()
+ }
+
+ // Extend the running time to cover end as well as a bit of slop.
+ if shutdown := end + durationToTicks(time.Second); shutdown > fast.clockEnd.read() {
+ fast.clockEnd.write(shutdown)
+ }
+
+ // Start clock if necessary
+ if !fast.running {
+ fast.running = true
+ go runClock()
+ }
+}
+
+// stop the timeout clock in the background
+// should only used for unit tests to abandon the background goroutine
+func stopClock() {
+ fast.mu.Lock()
+ if fast.running {
+ fast.clockEnd.write(fasttime(0))
+ }
+ fast.mu.Unlock()
+
+ // pause until not running
+ // get and release the lock
+ isRunning := true
+ for isRunning {
+ time.Sleep(clockPeriod / 2)
+ fast.mu.Lock()
+ isRunning = fast.running
+ fast.mu.Unlock()
+ }
+}
+
+func durationToTicks(d time.Duration) fasttime {
+ // Downscale nanoseconds to approximately a millisecond so that we can avoid
+ // overflow even if the caller passes in math.MaxInt64.
+ return fasttime(d) >> 20
+}
+
+const DefaultClockPeriod = 100 * time.Millisecond
+
+// clockPeriod is the approximate interval between updates of approximateClock.
+var clockPeriod = DefaultClockPeriod
+
+func runClock() {
+ fast.mu.Lock()
+ defer fast.mu.Unlock()
+
+ for fast.current.read() <= fast.clockEnd.read() {
+ // Unlock while sleeping.
+ fast.mu.Unlock()
+ time.Sleep(clockPeriod)
+ fast.mu.Lock()
+
+ newTime := durationToTicks(time.Since(fast.start))
+ fast.current.write(newTime)
+ }
+ fast.running = false
+}
+
+type atomicTime struct{ v int64 } // Should change to atomic.Int64 when we can use go 1.19
+
+func (t *atomicTime) read() fasttime { return fasttime(atomic.LoadInt64(&t.v)) }
+func (t *atomicTime) write(v fasttime) { atomic.StoreInt64(&t.v, int64(v)) }
diff --git a/vendor/github.com/dlclark/regexp2/v2/helpers/indexof.go b/vendor/github.com/dlclark/regexp2/v2/helpers/indexof.go
new file mode 100644
index 0000000000..8d24a8c087
--- /dev/null
+++ b/vendor/github.com/dlclark/regexp2/v2/helpers/indexof.go
@@ -0,0 +1,394 @@
+package helpers
+
+import (
+ "bytes"
+ "slices"
+ "strings"
+ "unicode"
+ "unsafe"
+
+ "github.com/dlclark/regexp2/v2/syntax"
+)
+
+func IndexOfAny(in []rune, find []rune) int {
+ // special case
+ if len(find) == 0 {
+ return -1
+ }
+ // naive version
+ for i, c := range in {
+ if slices.Contains(find, c) {
+ return i
+ }
+ }
+ return -1
+}
+
+func IndexOfAny1(in []rune, find rune) int {
+ //TODO: bytes optimization?
+ return slices.Index(in, find)
+}
+
+func IndexOfAny2(in []rune, find1, find2 rune) int {
+ for i, c := range in {
+ if c == find1 || c == find2 {
+ return i
+ }
+ }
+
+ return -1
+}
+
+func IndexOfAny3(in []rune, find1, find2, find3 rune) int {
+ for i, c := range in {
+ if c == find1 || c == find2 || c == find3 {
+ return i
+ }
+ }
+
+ return -1
+}
+
+func IndexOfAnyInRange(in []rune, first, last rune) int {
+ for i, c := range in {
+ if c >= first && c <= last {
+ return i
+ }
+ }
+ return -1
+}
+
+func IndexOfAnyExcept(in []rune, bad []rune) int {
+ for i, c := range in {
+ found := false
+ for _, b := range bad {
+ if b == c {
+ found = true
+ break
+ }
+ }
+ if !found {
+ return i
+ }
+ }
+ return -1
+}
+
+func IndexOfAnyExcept1(in []rune, bad rune) int {
+ for i, c := range in {
+ if c != bad {
+ return i
+ }
+ }
+ return -1
+}
+
+func IndexOfAnyExcept2(in []rune, bad1, bad2 rune) int {
+ for i, c := range in {
+ if c != bad1 && c != bad2 {
+ return i
+ }
+ }
+
+ return -1
+}
+
+func IndexOfAnyExcept3(in []rune, bad1, bad2, bad3 rune) int {
+ for i, c := range in {
+ if c != bad1 && c != bad2 && c != bad3 {
+ return i
+ }
+ }
+
+ return -1
+}
+
+func IndexOfAnyExceptInRange(in []rune, first, last rune) int {
+ for i, c := range in {
+ if c > last {
+ return i
+ }
+ if c < first {
+ return i
+ }
+ }
+ return -1
+}
+
+func IndexFunc(in []rune, f func(ch rune) bool) int {
+ for i := range in {
+ if f(in[i]) {
+ return i
+ }
+ }
+ return -1
+}
+
+func IndexOfAnyExceptInSet(in []rune, set syntax.CharSet) int {
+ //TODO: this
+ panic("not implemented")
+}
+
+func LastIndexOf(in []rune, find []rune) int {
+ end := len(in) - len(find)
+ first := find[0]
+ lastOffset := len(find) - 1
+ last := find[lastOffset]
+ for i := end; i >= 0; i-- {
+ //TODO: check 2 chars needed?
+ // match start and end...check the middle
+ if in[i] == first && in[i+lastOffset] == last {
+ // found our first char
+ // check if the rest are equal
+ if bytesEqual(in[i:i+len(find)], find) {
+ return i
+ }
+ }
+ }
+
+ //not found
+ return -1
+}
+
+func LastIndexOfAnyExcept1(in []rune, not rune) int {
+ for i := len(in) - 1; i >= 0; i-- {
+ if in[i] != not {
+ return i
+ }
+ }
+ return -1
+}
+
+func LastIndexOfAny1(in []rune, find rune) int {
+ for i := len(in) - 1; i >= 0; i-- {
+ if in[i] == find {
+ // found our char
+ return i
+ }
+ }
+
+ //not found
+ return -1
+}
+
+func LastIndexOfAnyInRange(in []rune, first, last rune) int {
+ for i := len(in) - 1; i >= 0; i-- {
+ if in[i] >= first && in[i] <= last {
+ return i
+ }
+ }
+ return -1
+}
+
+//TODO: LastIndexOf methods
+//IndexOfAnyInRange
+//LastIndexOfAnyInRange
+//LastIndexOfAnyExceptInRange
+
+// find should always be sent in lower-case
+func IndexOfIgnoreCase(in []rune, find []rune) int {
+ // search the in slice for the "find" slice, ignoring case in the comparisons
+ end := len(in) - len(find)
+ first := find[0]
+ for i := 0; i <= end; i++ {
+ if in[i] != first && unicode.ToLower(in[i]) != first {
+ continue
+ }
+ match := true
+ for j := 1; j < len(find); j++ {
+ inChar := in[i+j]
+ if inChar != find[j] && unicode.ToLower(inChar) != find[j] {
+ match = false
+ break
+ }
+ }
+ if match {
+ return i
+ }
+ }
+ return -1
+}
+
+func IndexOfIgnoreCaseAscii(in []rune, find []rune) int {
+ // search the in slice for the "find" slice, ignoring case in the comparisons
+ // we can assume the find chars are ascii and do simple masks on them
+ if len(find) == 0 {
+ return 0
+ }
+ end := len(in) - len(find)
+ first := foldASCII(rune(find[0]))
+ for i := 0; i <= end; i++ {
+ if foldASCII(in[i]) != first {
+ continue
+ }
+ match := true
+ for j := 1; j < len(find); j++ {
+ if foldASCII(in[i+j]) != foldASCII(find[j]) {
+ match = false
+ break
+ }
+ }
+ if match {
+ return i
+ }
+ }
+ return -1
+}
+
+func IndexStringIgnoreCaseASCII(s, prefix string) int {
+ if len(prefix) == 0 {
+ return 0
+ }
+
+ for start, end := 0, len(s)-len(prefix); start <= end; {
+ offset := indexASCIIByteIgnoreCase(s[start:], prefix[0])
+ if offset < 0 || start+offset > end {
+ return -1
+ }
+
+ i := start + offset
+ if EqualStringIgnoreCaseASCII(s[i:i+len(prefix)], prefix) {
+ return i
+ }
+ start = i + 1
+ }
+ return -1
+}
+
+func EqualStringIgnoreCaseASCII(s, prefix string) bool {
+ if len(s) < len(prefix) {
+ return false
+ }
+ for i := 0; i < len(prefix); i++ {
+ if foldASCII(rune(s[i])) != foldASCII(rune(prefix[i])) {
+ return false
+ }
+ }
+ return true
+}
+
+func indexASCIIByteIgnoreCase(s string, ch byte) int {
+ ch = byte(foldASCII(rune(ch)))
+ lower := strings.IndexByte(s, ch)
+ if ch < 'a' || ch > 'z' {
+ return lower
+ }
+ upper := strings.IndexByte(s, ch-('a'-'A'))
+ if lower < 0 {
+ return upper
+ }
+ if upper >= 0 && upper < lower {
+ return upper
+ }
+ return lower
+}
+
+func foldASCII(c rune) rune {
+ if 'A' <= c && c <= 'Z' {
+ return c + ('a' - 'A')
+ }
+ return c
+}
+
+func IndexOf(in []rune, find []rune) int {
+ /*
+ Since we auto-gen the find code this shouldn't happen
+ if len(find) == 0 {
+ //special case
+ return -1
+ }*/
+ end := len(in) - len(find)
+ first := find[0]
+ //TODO: benchmark checking last char too or first two chars
+ for i := 0; i <= end; i++ {
+ // match start...check the rest
+ if in[i] == first {
+ // found our first char
+ // check if the rest are equal
+ if bytesEqual(in[i:i+len(find)], find) {
+ return i
+ }
+ /*if slices.Equal(in[i:i+len(find)], find) {
+ return i
+ }*/
+ }
+ }
+
+ //not found
+ return -1
+}
+
+func StartsWith(in []rune, find []rune) bool {
+ // if text is less than our "begin" then can't find it
+ if len(in) < len(find) {
+ return false
+ }
+
+ return bytesEqual(in[:len(find)], find)
+
+ /*for i := 0; i < len(find); i++ {
+ if in[i] != find[i] {
+ return false
+ }
+ }
+
+ return true*/
+}
+
+//StartsWithIgnoreCaseAscii would be faster
+
+// find should always be sent in lower-case
+func StartsWithIgnoreCase(in []rune, find []rune) bool {
+ // if text is less than our "begin" then can't find it
+ if len(in) < len(find) {
+ return false
+ }
+
+ for i := 0; i < len(find); i++ {
+ if in[i] == find[i] {
+ // if we match the char exactly then we're good
+ continue
+ }
+ // if the to-lower still doesn't match then it's not a match
+ if unicode.ToLower(in[i]) != find[i] {
+ return false
+ }
+ }
+
+ return true
+}
+
+// internal function, assumes the bounds are already set right on the slices for equality
+// casts the rune slices to bytes to use framework fast []byte comparison
+func bytesEqual(a, b []rune) bool {
+ bytesA := unsafe.Slice((*byte)(unsafe.Pointer(&a[0])), len(a)*4)
+ bytesB := unsafe.Slice((*byte)(unsafe.Pointer(&b[0])), len(b)*4)
+ return bytes.Equal(bytesA, bytesB)
+}
+
+func Equals(in []rune, start int, length int, find []rune) bool {
+ if len(find) == 0 {
+ return true
+ }
+ return bytesEqual(in[start:start+length], find)
+}
+
+func EqualsIgnoreCase(in []rune, start int, length int, find []rune) bool {
+ //fast path if case matches
+ if Equals(in, start, length, find) {
+ return true
+ }
+
+ // search the in slice for the "find" slice, ignoring case in the comparisons
+ // we can't assume casing or ascii-ness for either letter, have to toLower them both
+ for j := 0; j < len(find); j++ {
+ inChar := in[start+j]
+ findChar := find[j]
+ if inChar != findChar && unicode.ToLower(inChar) != unicode.ToLower(findChar) {
+ return false
+ }
+ }
+
+ // we've checked all chars and found matches every time
+ return true
+}
diff --git a/vendor/github.com/dlclark/regexp2/v2/helpers/math.go b/vendor/github.com/dlclark/regexp2/v2/helpers/math.go
new file mode 100644
index 0000000000..7f58991e3b
--- /dev/null
+++ b/vendor/github.com/dlclark/regexp2/v2/helpers/math.go
@@ -0,0 +1,15 @@
+package helpers
+
+func Min(a, b int) int {
+ if a < b {
+ return a
+ }
+ return b
+}
+
+func Max(a, b int) int {
+ if a > b {
+ return a
+ }
+ return b
+}
diff --git a/vendor/github.com/dlclark/regexp2/v2/helpers/runes.go b/vendor/github.com/dlclark/regexp2/v2/helpers/runes.go
new file mode 100644
index 0000000000..d878da80b7
--- /dev/null
+++ b/vendor/github.com/dlclark/regexp2/v2/helpers/runes.go
@@ -0,0 +1,58 @@
+package helpers
+
+import "unicode"
+
+func IsBetween(val rune, first, last rune) bool {
+ if val > last {
+ return false
+ }
+ if val >= first {
+ return true
+ }
+ return false
+}
+
+// According to UTS#18 Unicode Regular Expressions (http://www.unicode.org/reports/tr18/)
+// RL 1.4 Simple Word Boundaries The class of includes all Alphabetic
+// values from the Unicode character database, from UnicodeData.txt [UData], plus the U+200C
+// ZERO WIDTH NON-JOINER and U+200D ZERO WIDTH JOINER.
+func IsWordChar(r rune) bool {
+ // matches charclass.go
+
+ //TODO: add optimization here for ascii
+
+ //"L", "Mn", "Nd", "Pc"
+ return unicode.In(r,
+ unicode.Categories["L"], unicode.Categories["Mn"],
+ unicode.Categories["Nd"], unicode.Categories["Pc"]) || r == '\u200D' || r == '\u200C'
+ //return 'A' <= r && r <= 'Z' || 'a' <= r && r <= 'z' || '0' <= r && r <= '9' || r == '_'
+}
+
+func IsInMask32(ch rune, mask uint32) bool {
+ //BDFHJLNPRTVX = 10101010 10101010 10101010 00000000
+ //B = 00000000 00000000 00000000 01000010
+ //char=B-B = 00000000 00000000 00000000 00000000
+ //BDFH.. << 0 = 10101010 10101010 10101010 00000000
+ //char-32 = 11111111 11111111 11111111 11100000
+ //& = 10101010 10101010 10101010 00000000
+ // first bit is 1 then negative, so it matches
+
+ //charMinusLowUInt32 := int32(ch - low)
+ return int32((mask< unicode.MaxASCII {
+ // a bug got us here. that's bad.
+ panic(fmt.Errorf("non-ascii value found in ascii search values: %s", vals))
+ }
+ idx := c / 64
+ shift := c % 64
+ sv.set[idx] |= 1 << shift
+ }
+
+ return sv
+}
+
+// return the first index of our original vals values within the slice given
+func (s AsciiSearchValues) IndexOfAny(chars []rune) int {
+ for i := 0; i < len(chars); i++ {
+ c := chars[i]
+ if c > unicode.MaxASCII {
+ continue
+ }
+ idx := c / 64
+ shift := c % 64
+ if s.set[idx]&(1< unicode.MaxASCII {
+ return i
+ }
+ idx := c / 64
+ shift := c % 64
+ if s.set[idx]&(1< len(val) {
+ min = len(val)
+ }
+ if !slices.Contains(firstLetters, val[0]) {
+ firstLetters = append(firstLetters, val[0])
+ if ignoreCase && val[0] != unicode.ToUpper(val[0]) {
+ //if we're ignoring case and this letter is impacted by case, add it to our set
+ firstLetters = append(firstLetters, unicode.ToUpper(val[0]))
+ }
+ }
+ }
+
+ return StringSearchValues{
+ vals: vals,
+ ignoreCase: ignoreCase,
+ shortestVal: min,
+ firstChars: newRuneSearchValues(firstLetters),
+ }
+}
+
+func (s StringSearchValues) StartsWith(chars []rune) int {
+ panic("not implemented")
+}
+
+func (s StringSearchValues) StartsWithIgnoreCase(chars []rune) int {
+ panic("not implemented")
+}
+
+func (s StringSearchValues) IndexOfAny(in []rune) int {
+ // go through our input once
+ end := len(in) - s.shortestVal
+ for i := 0; i <= end; i++ {
+ // check if the char are in our starting chars
+ j := s.firstChars.IndexOfAny(in[i:])
+ // first chars not found at all
+ if j < 0 {
+ return -1
+ }
+ j += i
+ // found a first char, do our full search through each item
+ for _, val := range s.vals {
+ if len(in)-j >= len(val) && Equals(in, j, len(val), val) {
+ return j
+ }
+ if s.ignoreCase && len(in)-j >= len(val) && EqualsIgnoreCase(in, j, len(val), val) {
+ return j
+ }
+ }
+ //skip ahead
+ i = j
+ }
+
+ return -1
+}
diff --git a/vendor/github.com/dlclark/regexp2/v2/match.go b/vendor/github.com/dlclark/regexp2/v2/match.go
new file mode 100644
index 0000000000..4003ff0f55
--- /dev/null
+++ b/vendor/github.com/dlclark/regexp2/v2/match.go
@@ -0,0 +1,455 @@
+package regexp2
+
+import (
+ "bytes"
+ "fmt"
+ "unicode/utf8"
+)
+
+// Match is a single regex result match that contains groups and repeated captures
+//
+// -Groups
+// -Capture
+type Match struct {
+ Group //embeded group 0
+
+ regex *Regexp
+ otherGroups []Group
+
+ // input to the match
+ textpos int
+ textstart int
+
+ capcount int
+ sparseCaps map[int]int
+
+ // output from the match
+ matches [][]int
+ matchcount []int
+
+ // whether we've done any balancing with this match. If we
+ // have done balancing, we'll need to do extra work in Tidy().
+ balancing bool
+}
+
+// Group is an explicit or implit (group 0) matched group within the pattern
+type Group struct {
+ Capture // the last capture of this group is embeded for ease of use
+
+ Name string // group name
+ Captures []Capture // captures of this group
+}
+
+// Capture is a single capture of text within the larger original string
+type Capture struct {
+ // the original string
+ text *matchText
+ // RuneIndex is the position in the underlying rune slice where the first character of
+ // captured substring was found. Even if you pass in a string this will be in Runes.
+ RuneIndex int
+ // RuneLength is the number of runes in the captured substring.
+ RuneLength int
+}
+
+type matchText struct {
+ runes []rune
+ input string
+ hasStringInput bool
+ byteOffsets []int
+ byteOffsetsReady bool
+}
+
+// String returns the captured text as a String
+func (c *Capture) String() string {
+ return string(c.text.runes[c.RuneIndex : c.RuneIndex+c.RuneLength])
+}
+
+// Runes returns the captured text as a rune slice
+func (c *Capture) Runes() []rune {
+ return c.text.runes[c.RuneIndex : c.RuneIndex+c.RuneLength]
+}
+
+// ByteRange returns the UTF-8 byte index and byte length of the captured
+// substring. The first call lazily caches byte offsets on shared match text,
+// so it is not safe to call concurrently with ByteRange on another capture
+// from the same match until the cache has been initialized.
+func (c *Capture) ByteRange() (index, length int) {
+ if c.text == nil {
+ return c.RuneIndex, c.RuneLength
+ }
+ return c.text.byteRange(c.RuneIndex, c.RuneLength)
+}
+
+func newMatchText(r []rune) *matchText {
+ return &matchText{runes: r}
+}
+
+func newStringMatchText(input string, r []rune) *matchText {
+ return &matchText{runes: r, input: input, hasStringInput: true}
+}
+
+func (t *matchText) byteRange(runeIndex, runeLength int) (int, int) {
+ if !t.byteOffsetsReady {
+ t.byteOffsets = t.buildByteOffsets()
+ t.byteOffsetsReady = true
+ }
+ if t.byteOffsets == nil {
+ return runeIndex, runeLength
+ }
+ byteIndex := t.byteOffsets[runeIndex]
+ return byteIndex, t.byteOffsets[runeIndex+runeLength] - byteIndex
+}
+
+func (t *matchText) buildByteOffsets() []int {
+ if t.hasStringInput {
+ return stringByteOffsets(t.input)
+ }
+ return runeByteOffsets(t.runes)
+}
+
+func stringByteOffsets(s string) []int {
+ var byteOffsets []int
+ runeIndex := 0
+ for strIdx, ch := range s {
+ if byteOffsets != nil {
+ byteOffsets[runeIndex] = strIdx
+ }
+ runeLen := utf8.RuneLen(ch)
+ if ch == utf8.RuneError {
+ _, runeLen = utf8.DecodeRuneInString(s[strIdx:])
+ }
+ if byteOffsets == nil && (strIdx != runeIndex || runeLen != 1) {
+ byteOffsets = make([]int, len(s)+1)
+ for i := 0; i < runeIndex; i++ {
+ byteOffsets[i] = i
+ }
+ byteOffsets[runeIndex] = strIdx
+ }
+ runeIndex++
+ }
+ if byteOffsets != nil {
+ byteOffsets[runeIndex] = len(s)
+ return byteOffsets[:runeIndex+1]
+ }
+ return nil
+}
+
+func runeByteOffsets(runes []rune) []int {
+ var byteOffsets []int
+ bytePos := 0
+ for i, ch := range runes {
+ if byteOffsets != nil {
+ byteOffsets[i] = bytePos
+ }
+ runeLen := utf8.RuneLen(ch)
+ if runeLen < 0 {
+ runeLen = utf8.RuneLen(utf8.RuneError)
+ }
+ if byteOffsets == nil && runeLen != 1 {
+ byteOffsets = make([]int, len(runes)+1)
+ for j := 0; j < i; j++ {
+ byteOffsets[j] = j
+ }
+ byteOffsets[i] = bytePos
+ }
+ bytePos += runeLen
+ }
+ if byteOffsets != nil {
+ byteOffsets[len(runes)] = bytePos
+ }
+ return byteOffsets
+}
+
+func newMatch(regex *Regexp, capcount int, text *matchText, startpos int) *Match {
+ m := Match{
+ regex: regex,
+ matchcount: make([]int, capcount),
+ matches: make([][]int, capcount),
+ textstart: startpos,
+ balancing: false,
+ }
+ if (regex.options & ECMAScript) == 0 {
+ m.Name = "0"
+ }
+ m.text = text
+ m.matches[0] = make([]int, 2)
+ return &m
+}
+
+func newMatchSparse(regex *Regexp, caps map[int]int, capcount int, text *matchText, startpos int) *Match {
+ m := newMatch(regex, capcount, text, startpos)
+ m.sparseCaps = caps
+ return m
+}
+
+func (m *Match) reset(text *matchText, textstart int) {
+ m.text = text
+ m.textstart = textstart
+ for i := 0; i < len(m.matchcount); i++ {
+ m.matchcount[i] = 0
+ }
+ m.balancing = false
+}
+
+func (m *Match) tidy(textpos int) {
+
+ interval := m.matches[0]
+ setCaptureFields(&m.Capture, interval[0], interval[1])
+ m.textpos = textpos
+ m.capcount = m.matchcount[0]
+ //copy our root capture to the list
+ m.Captures = []Capture{m.Capture}
+
+ if m.balancing {
+ // The idea here is that we want to compact all of our unbalanced captures. To do that we
+ // use j basically as a count of how many unbalanced captures we have at any given time
+ // (really j is an index, but j/2 is the count). First we skip past all of the real captures
+ // until we find a balance captures. Then we check each subsequent entry. If it's a balance
+ // capture (it's negative), we decrement j. If it's a real capture, we increment j and copy
+ // it down to the last free position.
+ for cap := 0; cap < len(m.matchcount); cap++ {
+ limit := m.matchcount[cap] * 2
+ matcharray := m.matches[cap]
+
+ var i, j int
+
+ for i = 0; i < limit; i++ {
+ if matcharray[i] < 0 {
+ break
+ }
+ }
+
+ for j = i; i < limit; i++ {
+ if matcharray[i] < 0 {
+ // skip negative values
+ j--
+ } else {
+ // but if we find something positive (an actual capture), copy it back to the last
+ // unbalanced position.
+ if i != j {
+ matcharray[j] = matcharray[i]
+ }
+ j++
+ }
+ }
+
+ m.matchcount[cap] = j / 2
+ }
+
+ m.balancing = false
+ }
+}
+
+// isMatched tells if a group was matched by capnum
+func (m *Match) isMatched(cap int) bool {
+ return cap < len(m.matchcount) && m.matchcount[cap] > 0 && m.matches[cap][m.matchcount[cap]*2-1] != (-3+1)
+}
+
+// matchIndex returns the index of the last specified matched group by capnum
+func (m *Match) matchIndex(cap int) int {
+ i := m.matches[cap][m.matchcount[cap]*2-2]
+ if i >= 0 {
+ return i
+ }
+
+ return m.matches[cap][-3-i]
+}
+
+// matchLength returns the length of the last specified matched group by capnum
+func (m *Match) matchLength(cap int) int {
+ i := m.matches[cap][m.matchcount[cap]*2-1]
+ if i >= 0 {
+ return i
+ }
+
+ return m.matches[cap][-3-i]
+}
+
+// Nonpublic builder: add a capture to the group specified by "c"
+func (m *Match) addMatch(c, start, l int) {
+
+ if m.matches[c] == nil {
+ m.matches[c] = make([]int, 2)
+ }
+
+ capcount := m.matchcount[c]
+
+ if capcount*2+2 > len(m.matches[c]) {
+ oldmatches := m.matches[c]
+ newmatches := make([]int, capcount*8)
+ copy(newmatches, oldmatches[:capcount*2])
+ m.matches[c] = newmatches
+ }
+
+ m.matches[c][capcount*2] = start
+ m.matches[c][capcount*2+1] = l
+ m.matchcount[c] = capcount + 1
+ //log.Printf("addMatch: c=%v, i=%v, l=%v ... matches: %v", c, start, l, m.matches)
+}
+
+// Nonpublic builder: Add a capture to balance the specified group. This is used by the
+//
+// balanced match construct. (?...)
+//
+// If there were no such thing as backtracking, this would be as simple as calling RemoveMatch(c).
+// However, since we have backtracking, we need to keep track of everything.
+func (m *Match) balanceMatch(c int) {
+ m.balancing = true
+
+ // we'll look at the last capture first
+ capcount := m.matchcount[c]
+ target := capcount*2 - 2
+
+ // first see if it is negative, and therefore is a reference to the next available
+ // capture group for balancing. If it is, we'll reset target to point to that capture.
+ if m.matches[c][target] < 0 {
+ target = -3 - m.matches[c][target]
+ }
+
+ // move back to the previous capture
+ target -= 2
+
+ // if the previous capture is a reference, just copy that reference to the end. Otherwise, point to it.
+ if target >= 0 && m.matches[c][target] < 0 {
+ m.addMatch(c, m.matches[c][target], m.matches[c][target+1])
+ } else {
+ m.addMatch(c, -3-target, -4-target /* == -3 - (target + 1) */)
+ }
+}
+
+// Nonpublic builder: removes a group match by capnum
+func (m *Match) removeMatch(c int) {
+ m.matchcount[c]--
+}
+
+// GroupCount returns the number of groups this match has matched
+func (m *Match) GroupCount() int {
+ return len(m.matchcount)
+}
+
+// GroupByName returns a group based on the name of the group, or nil if the group name does not exist
+func (m *Match) GroupByName(name string) *Group {
+ num := m.regex.GroupNumberFromName(name)
+ if num < 0 {
+ return nil
+ }
+ return m.GroupByNumber(num)
+}
+
+// GroupByNumber returns a group based on the number of the group, or nil if the group number does not exist
+func (m *Match) GroupByNumber(num int) *Group {
+ // check our sparse map
+ if m.sparseCaps != nil {
+ if newNum, ok := m.sparseCaps[num]; ok {
+ num = newNum
+ }
+ }
+ if num >= len(m.matchcount) || num < 0 {
+ return nil
+ }
+
+ if num == 0 {
+ return &m.Group
+ }
+
+ m.populateOtherGroups()
+
+ return &m.otherGroups[num-1]
+}
+
+// Groups returns all the capture groups, starting with group 0 (the full match)
+func (m *Match) Groups() []Group {
+ m.populateOtherGroups()
+ g := make([]Group, len(m.otherGroups)+1)
+ g[0] = m.Group
+ copy(g[1:], m.otherGroups)
+ return g
+}
+
+func (m *Match) populateOtherGroups() {
+ // Construct all the Group objects first time called
+ if m.otherGroups == nil {
+ m.otherGroups = make([]Group, len(m.matchcount)-1)
+ for i := 0; i < len(m.otherGroups); i++ {
+ m.otherGroups[i] = newGroup(m.regex.GroupNameFromNumber(i+1), m.text, m.matches[i+1], m.matchcount[i+1])
+ }
+ }
+}
+
+func (m *Match) groupValueAppendToBuf(groupnum int, buf *bytes.Buffer) {
+ c := m.matchcount[groupnum]
+ if c == 0 {
+ return
+ }
+
+ matches := m.matches[groupnum]
+
+ index := matches[(c-1)*2]
+ last := index + matches[(c*2)-1]
+
+ for ; index < last; index++ {
+ buf.WriteRune(m.text.runes[index])
+ }
+}
+
+func newGroup(name string, text *matchText, caps []int, capcount int) Group {
+ g := Group{}
+ g.text = text
+ if capcount > 0 {
+ setCaptureFields(&g.Capture, caps[(capcount-1)*2], caps[(capcount*2)-1])
+ }
+ g.Name = name
+ g.Captures = make([]Capture, capcount)
+ for i := 0; i < capcount; i++ {
+ g.Captures[i] = newCapture(text, caps[i*2], caps[i*2+1])
+ }
+ //log.Printf("newGroup! capcount %v, %+v", capcount, g)
+
+ return g
+}
+
+func newCapture(text *matchText, runeIndex, runeLength int) Capture {
+ c := Capture{text: text}
+ setCaptureFields(&c, runeIndex, runeLength)
+ return c
+}
+
+func setCaptureFields(c *Capture, runeIndex, runeLength int) {
+ c.RuneIndex = runeIndex
+ c.RuneLength = runeLength
+}
+
+func (m *Match) dump() string {
+ buf := &bytes.Buffer{}
+ buf.WriteRune('\n')
+ if len(m.sparseCaps) > 0 {
+ for k, v := range m.sparseCaps {
+ fmt.Fprintf(buf, "Slot %v -> %v\n", k, v)
+ }
+ }
+
+ for i, g := range m.Groups() {
+ fmt.Fprintf(buf, "Group %v (%v), %v caps:\n", i, g.Name, len(g.Captures))
+
+ for _, c := range g.Captures {
+ fmt.Fprintf(buf, " (%v, %v) %v\n", c.RuneIndex, c.RuneLength, c.String())
+ }
+ }
+ /*
+ for i := 0; i < len(m.matchcount); i++ {
+ fmt.Fprintf(buf, "\nGroup %v (%v):\n", i, m.regex.GroupNameFromNumber(i))
+
+ for j := 0; j < m.matchcount[i]; j++ {
+ text := ""
+
+ if m.matches[i][j*2] >= 0 {
+ start := m.matches[i][j*2]
+ text = m.text.runes[start : start+m.matches[i][j*2+1]]
+ }
+
+ fmt.Fprintf(buf, " (%v, %v) %v\n", m.matches[i][j*2], m.matches[i][j*2+1], text)
+ }
+ }
+ */
+ return buf.String()
+}
diff --git a/vendor/github.com/dlclark/regexp2/v2/options.go b/vendor/github.com/dlclark/regexp2/v2/options.go
new file mode 100644
index 0000000000..c0e49fff51
--- /dev/null
+++ b/vendor/github.com/dlclark/regexp2/v2/options.go
@@ -0,0 +1,157 @@
+package regexp2
+
+var (
+ // DefaultUnmarshalOptions used when unmarshaling a regex from text
+ DefaultUnmarshalOptions = None
+ // DefaultOptimizationOptions controls the default memory/performance trade-offs used by Compile.
+ DefaultOptimizationOptions = OptimizationOptions{
+ MaxCachedRuneBufferLength: 256 << 10,
+ MaxCachedReplaceBufferLength: 256 << 10,
+ MaxCachedReplacerDataEntries: 16,
+ MaxCachedReplacerDataBytes: 4 << 10,
+ DisableCharClassASCIIBitmap: false,
+ }
+)
+
+// RegexOptions impact the runtime and parsing behavior
+// for each specific regex. They are setable in code as well
+// as in the regex pattern itself.
+type RegexOptions int32
+
+func (o RegexOptions) applyCompileOption(c *compileConfig) {
+ c.regexOptions |= o
+}
+
+const (
+ None RegexOptions = 0x0
+ IgnoreCase RegexOptions = 0x0001 // "i"
+ Multiline RegexOptions = 0x0002 // "m"
+ ExplicitCapture RegexOptions = 0x0004 // "n"
+ Singleline RegexOptions = 0x0010 // "s"
+ IgnorePatternWhitespace RegexOptions = 0x0020 // "x"
+ RightToLeft RegexOptions = 0x0040 // "r"
+ // ECMAScript attempts to follow ECMAScript regex behavior rather than C# RegexOptions.ECMAScript compatibility.
+ ECMAScript RegexOptions = 0x0100 // "e"
+ RE2 RegexOptions = 0x0200 // RE2 (regexp package) compatibility mode
+ Unicode RegexOptions = 0x0400 // "u"
+)
+
+// OptimizationOptions controls optional runtime caches and compile-time fast paths.
+//
+// For replacement data cache size fields, 0 disables persistent retention and
+// -1 means unbounded. For pooled buffer cache size fields, 0 disables pooling
+// and -1 allows all built-in size classes.
+// Defaults are intentionally bounded so Compile is safe for mixed-cardinality inputs.
+type OptimizationOptions struct {
+ // MaxCachedRuneBufferLength limits retained string-to-rune buffers in the shared size-classed pool.
+ MaxCachedRuneBufferLength int
+ // MaxCachedReplaceBufferLength limits retained replacement output buffers in the shared size-classed pool.
+ MaxCachedReplaceBufferLength int
+ // MaxCachedReplacerDataEntries limits the number of parsed replacement patterns cached per Regexp.
+ MaxCachedReplacerDataEntries int
+ // MaxCachedReplacerDataBytes skips caching replacement patterns longer than this many bytes.
+ MaxCachedReplacerDataBytes int
+ // DisableCharClassASCIIBitmap disables compile-time ASCII bitmap construction for character classes.
+ DisableCharClassASCIIBitmap bool
+}
+
+// CompileOption configures Compile and MustCompile.
+type CompileOption interface {
+ applyCompileOption(*compileConfig)
+}
+
+type compileConfig struct {
+ regexOptions RegexOptions
+ optimizations OptimizationOptions
+ codeGen bool
+ debug bool
+ maintainCaptureOrder bool
+}
+
+type compileOptionFunc func(*compileConfig)
+
+func (f compileOptionFunc) applyCompileOption(c *compileConfig) {
+ f(c)
+}
+
+func (o OptimizationOptions) cacheReplacerData(replacement string) bool {
+ if o.MaxCachedReplacerDataEntries == 0 {
+ return false
+ }
+ return keepCacheBytes(o.MaxCachedReplacerDataBytes, len(replacement))
+}
+
+func keepCacheBytes(maxBytes, actualBytes int) bool {
+ if maxBytes < 0 {
+ return true
+ }
+ return maxBytes > 0 && actualBytes <= maxBytes
+}
+
+func newCompileConfig(options []CompileOption) compileConfig {
+ c := compileConfig{
+ optimizations: DefaultOptimizationOptions,
+ }
+ for _, option := range options {
+ if option != nil {
+ option.applyCompileOption(&c)
+ }
+ }
+ return c
+}
+
+// OptionMaxCachedRuneBufferLength limits retained string-to-rune buffers in the shared size-classed pool.
+func OptionMaxCachedRuneBufferLength(n int) CompileOption {
+ return compileOptionFunc(func(c *compileConfig) {
+ c.optimizations.MaxCachedRuneBufferLength = n
+ })
+}
+
+// OptionMaxCachedReplaceBufferLength limits retained replacement output buffers in the shared size-classed pool.
+func OptionMaxCachedReplaceBufferLength(n int) CompileOption {
+ return compileOptionFunc(func(c *compileConfig) {
+ c.optimizations.MaxCachedReplaceBufferLength = n
+ })
+}
+
+// OptionMaxCachedReplacerDataEntries limits parsed replacement patterns cached per Regexp.
+func OptionMaxCachedReplacerDataEntries(n int) CompileOption {
+ return compileOptionFunc(func(c *compileConfig) {
+ c.optimizations.MaxCachedReplacerDataEntries = n
+ })
+}
+
+// OptionMaxCachedReplacerDataBytes skips caching replacement patterns longer than n bytes.
+func OptionMaxCachedReplacerDataBytes(n int) CompileOption {
+ return compileOptionFunc(func(c *compileConfig) {
+ c.optimizations.MaxCachedReplacerDataBytes = n
+ })
+}
+
+// OptionDisableCharClassASCIIBitmap disables compile-time ASCII bitmaps for character classes.
+func OptionDisableCharClassASCIIBitmap() CompileOption {
+ return compileOptionFunc(func(c *compileConfig) {
+ c.optimizations.DisableCharClassASCIIBitmap = true
+ })
+}
+
+// OptionIsCodeGen enables more expensive compile-time analysis intended for regexp2cg generated engines.
+func OptionIsCodeGen() CompileOption {
+ return compileOptionFunc(func(c *compileConfig) {
+ c.codeGen = true
+ })
+}
+
+// OptionDebug enables debug output and runner tracing for the compiled regexp.
+func OptionDebug() CompileOption {
+ return compileOptionFunc(func(c *compileConfig) {
+ c.debug = true
+ })
+}
+
+// OptionMaintainCaptureOrder assigns named and unnamed capture slots in pattern order.
+func OptionMaintainCaptureOrder() CompileOption {
+ return compileOptionFunc(func(c *compileConfig) {
+ c.maintainCaptureOrder = true
+ })
+}
diff --git a/vendor/github.com/dlclark/regexp2/v2/regexp.go b/vendor/github.com/dlclark/regexp2/v2/regexp.go
new file mode 100644
index 0000000000..0a5d140a3b
--- /dev/null
+++ b/vendor/github.com/dlclark/regexp2/v2/regexp.go
@@ -0,0 +1,717 @@
+/*
+Package regexp2 is a regexp package that has an interface similar to Go's framework regexp engine but uses a
+more feature full regex engine behind the scenes.
+
+It doesn't have constant time guarantees, but it allows backtracking and is compatible with Perl5 and .NET.
+You'll likely be better off with the RE2 engine from the regexp package and should only use this if you
+need to write very complex patterns or require compatibility with .NET.
+*/
+package regexp2
+
+import (
+ "container/list"
+ "errors"
+ "log"
+ "math"
+ "sort"
+ "strconv"
+ "sync"
+ "time"
+ "unicode/utf8"
+
+ "github.com/dlclark/regexp2/v2/syntax"
+)
+
+var (
+ // DefaultMatchTimeout used when running regexp matches -- "forever"
+ DefaultMatchTimeout = time.Duration(math.MaxInt64)
+)
+
+// Regexp is the representation of a compiled regular expression.
+// A Regexp is safe for concurrent use by multiple goroutines.
+type Regexp struct {
+ // A match will time out if it takes (approximately) more than
+ // MatchTimeout. This is a safety check in case the match
+ // encounters catastrophic backtracking. The default value
+ // (DefaultMatchTimeout) causes all time out checking to be
+ // suppressed.
+ MatchTimeout time.Duration
+
+ // read-only after Compile
+ pattern string // as passed to Compile
+ options RegexOptions // options
+ debug bool
+
+ caps map[int]int // capnum->index
+ capnames map[string]int //capture group name -> index
+ capslist []string //sorted list of capture group names
+ capsize int // size of the capture array
+
+ code *syntax.Code // compiled program
+
+ optimizations OptimizationOptions
+
+ // cache of machines for running regexp
+ runnerPool *sync.Pool
+
+ replaceCache *replacerDataCache
+
+ // hook points to override runner functions
+ findFirstChar func(r *Runner) bool
+ execute func(r *Runner) error
+ stringPrefixFilter StringPrefixFilter
+}
+
+// Compile parses a regular expression and returns, if successful,
+// a Regexp object that can be used to match against text.
+func Compile(expr string, options ...CompileOption) (*Regexp, error) {
+ c := newCompileConfig(options)
+ return compile(expr, c)
+}
+
+func compile(expr string, c compileConfig) (*Regexp, error) {
+ // parse it
+ parseOptions := syntax.ParseOptions{
+ RegexOptions: syntax.RegexOptions(c.regexOptions),
+ MaintainCaptureOrder: c.maintainCaptureOrder,
+ CodeGen: c.codeGen,
+ }
+ tree, err := syntax.Parse(expr, parseOptions)
+ if err != nil {
+ return nil, err
+ }
+
+ if c.debug {
+ log.Print(tree.Dump())
+ }
+
+ // translate it to code
+ code, err := syntax.Write(tree)
+ if err != nil {
+ return nil, err
+ }
+ if c.debug {
+ log.Print(code.Dump())
+ }
+ if !c.optimizations.DisableCharClassASCIIBitmap {
+ code.PrepareCharSetASCIIBitmaps()
+ }
+
+ // return it
+ re := &Regexp{
+ pattern: expr,
+ options: c.regexOptions,
+ debug: c.debug,
+ caps: code.Caps,
+ capnames: tree.Capnames,
+ capslist: tree.Caplist,
+ capsize: code.Capsize,
+ code: code,
+ MatchTimeout: DefaultMatchTimeout,
+ optimizations: c.optimizations,
+ }
+ re.stringPrefixFilter = newStringPrefixFilter(code)
+ re.initCaches()
+ return re, nil
+}
+
+// MustCompile is like Compile but panics if the expression cannot be parsed.
+// It simplifies safe initialization of global variables holding compiled regular
+// expressions.
+func MustCompile(str string, options ...CompileOption) *Regexp {
+ c := newCompileConfig(options)
+
+ // lookup if we have a pre-built state machine for this pattern and options
+ regexp := getEngineRegexp(str, c)
+ if regexp != nil {
+ return regexp
+ }
+
+ regexp, err := compile(str, c)
+ if err != nil {
+ panic(`regexp2: Compile(` + quote(str) + `): ` + err.Error())
+ }
+ return regexp
+}
+
+// Escape adds backslashes to any special characters in the input string
+func Escape(input string) string {
+ return syntax.Escape(input)
+}
+
+// Unescape removes any backslashes from previously-escaped special characters in the input string
+func Unescape(input string) (string, error) {
+ return syntax.Unescape(input)
+}
+
+// SetTimeoutPeriod is a debug function that sets the frequency of the timeout goroutine's sleep cycle.
+// Defaults to 100ms. The only benefit of setting this lower is that the 1 background goroutine that manages
+// timeouts may exit slightly sooner after all the timeouts have expired. See Github issue #63
+func SetTimeoutCheckPeriod(d time.Duration) {
+ clockPeriod = d
+}
+
+// StopTimeoutClock should only be used in unit tests to prevent the timeout clock goroutine
+// from appearing like a leaking goroutine
+func StopTimeoutClock() {
+ stopClock()
+}
+
+// String returns the source text used to compile the regular expression.
+func (re *Regexp) String() string {
+ return re.pattern
+}
+
+func quote(s string) string {
+ if strconv.CanBackquote(s) {
+ return "`" + s + "`"
+ }
+ return strconv.Quote(s)
+}
+
+func (re *Regexp) RightToLeft() bool {
+ return re.options&RightToLeft != 0
+}
+
+func (re *Regexp) Debug() bool {
+ return re.debug
+}
+
+// Replace searches the input string and replaces each match found with the replacement text.
+// Count will limit the number of matches attempted and startAt will allow
+// us to skip past possible matches at the start of the input (left or right depending on RightToLeft option).
+// Set startAt and count to -1 to go through the whole string
+func (re *Regexp) Replace(input, replacement string, startAt, count int) (string, error) {
+ data, err := re.getReplacerData(replacement)
+ if err != nil {
+ return "", err
+ }
+
+ return replace(re, data, nil, input, startAt, count)
+}
+
+func (re *Regexp) getReplacerData(replacement string) (*syntax.ReplacerData, error) {
+ shouldCache := re.replaceCache != nil && re.optimizations.cacheReplacerData(replacement)
+ if shouldCache {
+ if data, ok := re.replaceCache.get(replacement); ok {
+ return data, nil
+ }
+ }
+
+ data, err := syntax.NewReplacerData(replacement, re.caps, re.capsize, re.capnames, syntax.RegexOptions(re.options))
+ if err != nil {
+ return nil, err
+ }
+ if shouldCache {
+ re.replaceCache.add(replacement, data)
+ }
+ return data, nil
+}
+
+// ReplaceFunc searches the input string and replaces each match found using the string from the evaluator
+// Count will limit the number of matches attempted and startAt will allow
+// us to skip past possible matches at the start of the input (left or right depending on RightToLeft option).
+// Set startAt and count to -1 to go through the whole string.
+func (re *Regexp) ReplaceFunc(input string, evaluator MatchEvaluator, startAt, count int) (string, error) {
+ return replace(re, nil, evaluator, input, startAt, count)
+}
+
+// FindStringMatch searches the input string for a Regexp match
+func (re *Regexp) FindStringMatch(s string) (*Match, error) {
+ startAt, ok, err := re.findStringMatchStart(s, -1)
+ if err != nil {
+ return nil, err
+ }
+ if !ok {
+ return nil, nil
+ }
+
+ r, runeStart := re.getRunesAndStart(s, startAt)
+ if runeStart < 0 {
+ runeStart = 0
+ }
+ return re.run(false, runeStart, r, newStringMatchText(s, r))
+}
+
+// FindRunesMatch searches the input rune slice for a Regexp match
+func (re *Regexp) FindRunesMatch(r []rune) (*Match, error) {
+ return re.run(false, -1, r, newMatchText(r))
+}
+
+// FindStringMatchStartingAt searches the input string for a Regexp match starting at the startAt index
+func (re *Regexp) FindStringMatchStartingAt(s string, startAt int) (*Match, error) {
+ startAt, ok, err := re.findStringMatchStart(s, startAt)
+ if err != nil {
+ return nil, err
+ }
+ if !ok {
+ return nil, nil
+ }
+
+ r, startAt := re.getRunesAndStart(s, startAt)
+ if startAt == -1 {
+ // we didn't find our start index in the string -- that's a problem
+ return nil, errors.New("startAt must align to the start of a valid rune in the input string")
+ }
+
+ return re.run(false, startAt, r, newStringMatchText(s, r))
+}
+
+// FindRunesMatchStartingAt searches the input rune slice for a Regexp match starting at the startAt index
+func (re *Regexp) FindRunesMatchStartingAt(r []rune, startAt int) (*Match, error) {
+ return re.run(false, startAt, r, newMatchText(r))
+}
+
+// FindAllStringIndex returns a slice of byte index pairs identifying all
+// successive matches in s.
+func (re *Regexp) FindAllStringIndex(s string, n int) ([][]int, error) {
+ if n == 0 {
+ return nil, nil
+ }
+
+ startAt, ok, err := re.findStringMatchStart(s, -1)
+ if err != nil {
+ return nil, err
+ }
+ if !ok {
+ return nil, nil
+ }
+
+ runner := re.getRunner()
+ var input []rune
+ var pooledInput *[]rune
+ runeStart := 0
+ if startAt == 0 {
+ input, pooledInput = runner.decodeString(s)
+ } else {
+ input, runeStart, pooledInput = runner.decodeStringWithStart(s, startAt)
+ }
+ defer func() {
+ re.putRunner(runner)
+ if pooledInput != nil {
+ *pooledInput = input
+ pooledRuneBuffers.put(pooledInput)
+ }
+ }()
+
+ if runeStart < 0 {
+ runeStart = 0
+ }
+
+ byteOffsets := newStringByteMapper(s)
+ return re.findAllRunesIndex(runner, input, runeStart, n, func(runeIndex, runeLength int) (int, int) {
+ if byteOffsets == nil {
+ return runeIndex, runeIndex + runeLength
+ }
+ return byteOffsets.byteIndex(runeIndex), byteOffsets.byteIndex(runeIndex + runeLength)
+ })
+}
+
+// FindAllRunesIndex returns a slice of rune index pairs identifying all
+// successive matches in r.
+func (re *Regexp) FindAllRunesIndex(r []rune, n int) ([][]int, error) {
+ if n == 0 {
+ return nil, nil
+ }
+
+ runner := re.getRunner()
+ defer re.putRunner(runner)
+
+ startAt := 0
+ if re.RightToLeft() {
+ startAt = len(r)
+ }
+ return re.findAllRunesIndex(runner, r, startAt, n, func(runeIndex, runeLength int) (int, int) {
+ return runeIndex, runeIndex + runeLength
+ })
+}
+
+func (re *Regexp) findAllRunesIndex(runner *Runner, input []rune, startAt, n int, makeIndex func(runeIndex, runeLength int) (int, int)) ([][]int, error) {
+ var out [][]int
+ var flat []int
+ if n > 0 {
+ out = make([][]int, 0, n)
+ flat = make([]int, 0, n*2)
+ }
+
+ prevEnd := -1
+ for n != 0 {
+ m, err := runner.scan(input, nil, startAt, true, re.MatchTimeout)
+ if err != nil {
+ return nil, err
+ }
+ if m == nil {
+ break
+ }
+
+ if m.RuneLength != 0 || m.RuneIndex != prevEnd {
+ start, end := makeIndex(m.RuneIndex, m.RuneLength)
+ flat = append(flat, start, end)
+ out = append(out, flat[len(flat)-2:len(flat):len(flat)])
+ prevEnd = m.RuneIndex + m.RuneLength
+ if n > 0 {
+ n--
+ }
+ }
+
+ startAt = m.textpos
+ if m.RuneLength == 0 {
+ if re.RightToLeft() {
+ if m.textpos == 0 {
+ break
+ }
+ if startAt == m.textstart {
+ startAt--
+ }
+ } else {
+ if m.textpos == len(input) {
+ break
+ }
+ if startAt == m.textstart {
+ startAt++
+ }
+ }
+ }
+ }
+ return out, nil
+}
+
+type stringByteMapper struct {
+ runeIndexes []int
+ deltas []int
+}
+
+func newStringByteMapper(s string) *stringByteMapper {
+ var mapper *stringByteMapper
+ runeIndex := 0
+ delta := 0
+ for strIdx, ch := range s {
+ runeLen := utf8.RuneLen(ch)
+ if ch == utf8.RuneError {
+ _, runeLen = utf8.DecodeRuneInString(s[strIdx:])
+ }
+ if runeLen != 1 {
+ if mapper == nil {
+ mapper = &stringByteMapper{}
+ }
+ delta += runeLen - 1
+ mapper.runeIndexes = append(mapper.runeIndexes, runeIndex+1)
+ mapper.deltas = append(mapper.deltas, delta)
+ }
+ runeIndex++
+ }
+ return mapper
+}
+
+func (m *stringByteMapper) byteIndex(runeIndex int) int {
+ i := sort.Search(len(m.runeIndexes), func(i int) bool {
+ return m.runeIndexes[i] > runeIndex
+ }) - 1
+ if i < 0 {
+ return runeIndex
+ }
+ return runeIndex + m.deltas[i]
+}
+
+// FindNextMatch returns the next match in the same input string as the match parameter.
+// Will return nil if there is no next match or if given a nil match.
+func (re *Regexp) FindNextMatch(m *Match) (*Match, error) {
+ if m == nil {
+ return nil, nil
+ }
+
+ // If previous match was empty, advance by one before matching to prevent
+ // infinite loop
+ startAt := m.textpos
+ if m.RuneLength == 0 {
+ if re.RightToLeft() {
+ if m.textpos == 0 {
+ return nil, nil
+ }
+ if startAt == m.textstart {
+ startAt--
+ }
+ } else {
+ if m.textpos == len(m.text.runes) {
+ return nil, nil
+ }
+
+ if startAt == m.textstart {
+ startAt++
+ }
+
+ }
+ }
+ return re.run(false, startAt, m.text.runes, m.text)
+}
+
+// MatchString return true if the string matches the regex
+// error will be set if a timeout occurs
+func (re *Regexp) MatchString(s string) (bool, error) {
+ if re.stringPrefixFilter != nil && !re.RightToLeft() {
+ candidateByteIndex, ok := re.stringPrefixFilter(s, 0)
+ if !ok {
+ return false, nil
+ }
+
+ return re.matchStringAt(s, candidateByteIndex)
+ }
+ return re.matchString(s)
+}
+
+func (re *Regexp) matchString(s string) (bool, error) {
+ return re.matchStringAt(s, -1)
+}
+
+func (re *Regexp) matchStringAt(s string, startAt int) (bool, error) {
+ runner := re.getRunner()
+ var input []rune
+ var pooledInput *[]rune
+ runeStart := 0
+ if startAt <= 0 {
+ input, pooledInput = runner.decodeString(s)
+ if re.RightToLeft() {
+ runeStart = len(input)
+ }
+ } else {
+ input, runeStart, pooledInput = runner.decodeStringWithStart(s, startAt)
+ if runeStart < 0 {
+ runeStart = 0
+ }
+ }
+ defer func() {
+ re.putRunner(runner)
+ if pooledInput != nil {
+ *pooledInput = input
+ pooledRuneBuffers.put(pooledInput)
+ }
+ }()
+
+ m, err := runner.scan(input, nil, runeStart, true, re.MatchTimeout)
+ if err != nil {
+ return false, err
+ }
+ return m != nil, nil
+}
+
+func (re *Regexp) getRunesAndStart(s string, startAt int) ([]rune, int) {
+ if startAt < 0 {
+ if re.RightToLeft() {
+ r := getRunes(s)
+ return r, len(r)
+ }
+ return getRunes(s), 0
+ }
+ ret := make([]rune, len(s))
+ i := 0
+ runeIdx := -1
+ for strIdx, r := range s {
+ if strIdx == startAt {
+ runeIdx = i
+ }
+ ret[i] = r
+ i++
+ }
+ if startAt == len(s) {
+ runeIdx = i
+ }
+ return ret[:i], runeIdx
+}
+
+func getRunes(s string) []rune {
+ return []rune(s)
+}
+
+// MatchRunes return true if the runes matches the regex
+// error will be set if a timeout occurs
+func (re *Regexp) MatchRunes(r []rune) (bool, error) {
+ m, err := re.run(true, -1, r, nil)
+ if err != nil {
+ return false, err
+ }
+ return m != nil, nil
+}
+
+// GetGroupNames Returns the set of strings used to name capturing groups in the expression.
+func (re *Regexp) GetGroupNames() []string {
+ var result []string
+
+ if re.capslist == nil {
+ result = make([]string, re.capsize)
+
+ for i := 0; i < len(result); i++ {
+ result[i] = strconv.Itoa(i)
+ }
+ } else {
+ result = make([]string, len(re.capslist))
+ copy(result, re.capslist)
+ }
+
+ return result
+}
+
+// GetGroupNumbers returns the integer group numbers corresponding to a group name.
+func (re *Regexp) GetGroupNumbers() []int {
+ var result []int
+
+ if re.caps == nil {
+ result = make([]int, re.capsize)
+
+ for i := 0; i < len(result); i++ {
+ result[i] = i
+ }
+ } else {
+ result = make([]int, len(re.caps))
+
+ for k, v := range re.caps {
+ result[v] = k
+ }
+ }
+
+ return result
+}
+
+// GroupNameFromNumber retrieves a group name that corresponds to a group number.
+// It will return "" for an unknown group number. Unnamed groups automatically
+// receive a name that is the decimal string equivalent of its number, except in
+// ECMAScript mode where unnamed groups have no name.
+func (re *Regexp) GroupNameFromNumber(i int) string {
+ if re.capslist == nil {
+ if i >= 0 && i < re.capsize {
+ return strconv.Itoa(i)
+ }
+
+ return ""
+ }
+
+ if re.caps != nil {
+ var ok bool
+ if i, ok = re.caps[i]; !ok {
+ return ""
+ }
+ }
+
+ if i >= 0 && i < len(re.capslist) {
+ return re.capslist[i]
+ }
+
+ return ""
+}
+
+// GroupNumberFromName returns a group number that corresponds to a group name.
+// Returns -1 if the name is not a recognized group name. Numbered groups
+// automatically get a group name that is the decimal string equivalent of its
+// number, except in ECMAScript mode where unnamed groups have no name.
+func (re *Regexp) GroupNumberFromName(name string) int {
+ // look up name if we have a hashtable of names
+ if re.capnames != nil {
+ if k, ok := re.capnames[name]; ok {
+ return k
+ }
+
+ return -1
+ }
+
+ // convert to an int if it looks like a number
+ result := 0
+ for i := 0; i < len(name); i++ {
+ ch := name[i]
+
+ if ch > '9' || ch < '0' {
+ return -1
+ }
+
+ result *= 10
+ result += int(ch - '0')
+ }
+
+ // return int if it's in range
+ if result >= 0 && result < re.capsize {
+ return result
+ }
+
+ return -1
+}
+
+// MarshalText implements [encoding.TextMarshaler]. The output
+// matches that of calling the [Regexp.String] method.
+func (re *Regexp) MarshalText() ([]byte, error) {
+ return []byte(re.String()), nil
+}
+
+// UnmarshalText implements [encoding.TextUnmarshaler] by calling
+// [Compile] on the encoded value.
+func (re *Regexp) UnmarshalText(text []byte) error {
+ newRE, err := Compile(string(text), DefaultUnmarshalOptions)
+ if err != nil {
+ return err
+ }
+ *re = *newRE
+ return nil
+}
+
+func (re *Regexp) initCaches() {
+ re.runnerPool = &sync.Pool{
+ New: func() any {
+ return &Runner{
+ re: re,
+ code: re.code,
+ }
+ },
+ }
+ if re.optimizations.MaxCachedReplacerDataEntries > 0 {
+ re.replaceCache = newReplacerDataCache(re.optimizations.MaxCachedReplacerDataEntries)
+ }
+}
+
+type replacerDataCache struct {
+ mu sync.Mutex
+ maxSize int
+ ll *list.List
+ cache map[string]*list.Element
+}
+
+type replacerDataCacheEntry struct {
+ key string
+ data *syntax.ReplacerData
+}
+
+func newReplacerDataCache(maxSize int) *replacerDataCache {
+ return &replacerDataCache{
+ maxSize: maxSize,
+ ll: list.New(),
+ cache: make(map[string]*list.Element),
+ }
+}
+
+func (c *replacerDataCache) get(key string) (*syntax.ReplacerData, bool) {
+ c.mu.Lock()
+ defer c.mu.Unlock()
+
+ if ele, ok := c.cache[key]; ok {
+ c.ll.MoveToFront(ele)
+ return ele.Value.(*replacerDataCacheEntry).data, true
+ }
+ return nil, false
+}
+
+func (c *replacerDataCache) add(key string, data *syntax.ReplacerData) {
+ c.mu.Lock()
+ defer c.mu.Unlock()
+
+ if ele, ok := c.cache[key]; ok {
+ ele.Value.(*replacerDataCacheEntry).data = data
+ c.ll.MoveToFront(ele)
+ return
+ }
+
+ ele := c.ll.PushFront(&replacerDataCacheEntry{key: key, data: data})
+ c.cache[key] = ele
+ if c.maxSize > 0 && c.ll.Len() > c.maxSize {
+ oldest := c.ll.Back()
+ if oldest != nil {
+ c.ll.Remove(oldest)
+ delete(c.cache, oldest.Value.(*replacerDataCacheEntry).key)
+ }
+ }
+}
diff --git a/vendor/github.com/dlclark/regexp2/v2/regexp_codegen.go b/vendor/github.com/dlclark/regexp2/v2/regexp_codegen.go
new file mode 100644
index 0000000000..41c1aef354
--- /dev/null
+++ b/vendor/github.com/dlclark/regexp2/v2/regexp_codegen.go
@@ -0,0 +1,70 @@
+package regexp2
+
+import (
+ "sync"
+)
+
+type RuntimeEngineData struct {
+ Caps map[int]int // capnum->index
+ CapNames map[string]int // cap group name -> index
+ CapsList []string // sorted list of capture group names
+ CapSize int // size of the capture array
+ FindFirstChar func(*Runner) bool // generated candidate search
+ Execute func(*Runner) error
+ StringPrefixFilter StringPrefixFilter // optional pre-decode candidate search for string input
+}
+
+type cacheKey struct {
+ pattern string
+ opt RegexOptions
+ maintainCaptureOrder bool
+}
+
+func RegisterEngine(pattern string, engine RuntimeEngineData, options ...CompileOption) {
+ c := newCompileConfig(options)
+ enginesMu.Lock()
+ engines[cacheKeyFromConfig(pattern, c)] = engine
+ enginesMu.Unlock()
+}
+
+func newEngineRegexp(pattern string, c compileConfig, engine RuntimeEngineData) *Regexp {
+ re := &Regexp{
+ pattern: pattern,
+ options: c.regexOptions,
+ debug: c.debug,
+ caps: engine.Caps,
+ capnames: engine.CapNames,
+ capslist: engine.CapsList,
+ capsize: engine.CapSize,
+ MatchTimeout: DefaultMatchTimeout,
+ optimizations: c.optimizations,
+ findFirstChar: engine.FindFirstChar,
+ execute: engine.Execute,
+ stringPrefixFilter: engine.StringPrefixFilter,
+ }
+ re.initCaches()
+ return re
+}
+
+func getEngineRegexp(pattern string, c compileConfig) *Regexp {
+ enginesMu.RLock()
+ engine, ok := engines[cacheKeyFromConfig(pattern, c)]
+ enginesMu.RUnlock()
+ if !ok {
+ return nil
+ }
+ return newEngineRegexp(pattern, c, engine)
+}
+
+func cacheKeyFromConfig(pattern string, c compileConfig) cacheKey {
+ return cacheKey{
+ pattern: pattern,
+ opt: c.regexOptions,
+ maintainCaptureOrder: c.maintainCaptureOrder,
+ }
+}
+
+var (
+ enginesMu sync.RWMutex
+ engines = map[cacheKey]RuntimeEngineData{}
+)
diff --git a/vendor/github.com/dlclark/regexp2/v2/replace.go b/vendor/github.com/dlclark/regexp2/v2/replace.go
new file mode 100644
index 0000000000..240b40f4aa
--- /dev/null
+++ b/vendor/github.com/dlclark/regexp2/v2/replace.go
@@ -0,0 +1,357 @@
+package regexp2
+
+import (
+ "bytes"
+ "errors"
+
+ "github.com/dlclark/regexp2/v2/syntax"
+)
+
+const (
+ replaceSpecials = 4
+ replaceLeftPortion = -1
+ replaceRightPortion = -2
+ replaceLastGroup = -3
+ replaceWholeString = -4
+)
+
+// MatchEvaluator is a function that takes a match and returns a replacement string to be used
+type MatchEvaluator func(Match) string
+
+// Three very similar algorithms appear below: replace (pattern),
+// replace (evaluator), and split.
+
+func writeRunes(buf *bytes.Buffer, text []rune, start, end int) {
+ for i := start; i < end; i++ {
+ buf.WriteRune(text[i])
+ }
+}
+
+func compactBalancedMatches(m *Match) {
+ for cap := 0; cap < len(m.matchcount); cap++ {
+ limit := m.matchcount[cap] * 2
+ matcharray := m.matches[cap]
+
+ var i, j int
+ for i = 0; i < limit; i++ {
+ if matcharray[i] < 0 {
+ break
+ }
+ }
+
+ for j = i; i < limit; i++ {
+ if matcharray[i] < 0 {
+ j--
+ } else {
+ if i != j {
+ matcharray[j] = matcharray[i]
+ }
+ j++
+ }
+ }
+
+ m.matchcount[cap] = j / 2
+ }
+ m.balancing = false
+}
+
+// Replace Replaces all occurrences of the regex in the string with the
+// replacement pattern.
+//
+// Note that the special case of no matches is handled on its own:
+// with no matches, the input string is returned unchanged.
+// The right-to-left case is split out because StringBuilder
+// doesn't handle right-to-left string building directly very well.
+func replace(regex *Regexp, data *syntax.ReplacerData, evaluator MatchEvaluator, input string, startAt, count int) (string, error) {
+ if count < -1 {
+ return "", errors.New("count too small")
+ }
+ if count == 0 {
+ return "", nil
+ }
+
+ if evaluator == nil {
+ if !regex.RightToLeft() {
+ return replaceRunnerLTR(regex, data, input, startAt, count)
+ }
+ return replaceRunnerRTL(regex, data, input, startAt, count)
+ }
+
+ m, err := regex.FindStringMatchStartingAt(input, startAt)
+
+ if err != nil {
+ return "", err
+ }
+ if m == nil {
+ return input, nil
+ }
+
+ buf := &bytes.Buffer{}
+ text := m.text.runes
+
+ if !regex.RightToLeft() {
+ prevat := 0
+ for m != nil {
+ if m.RuneIndex != prevat {
+ buf.WriteString(string(text[prevat:m.RuneIndex]))
+ }
+ prevat = m.RuneIndex + m.RuneLength
+ buf.WriteString(evaluator(*m))
+
+ count--
+ if count == 0 {
+ break
+ }
+ m, err = regex.FindNextMatch(m)
+ if err != nil {
+ return "", err
+ }
+ }
+
+ if prevat < len(text) {
+ buf.WriteString(string(text[prevat:]))
+ }
+ } else {
+ prevat := len(text)
+ var al []string
+
+ for m != nil {
+ if m.RuneIndex+m.RuneLength != prevat {
+ al = append(al, string(text[m.RuneIndex+m.RuneLength:prevat]))
+ }
+ prevat = m.RuneIndex
+ al = append(al, evaluator(*m))
+
+ count--
+ if count == 0 {
+ break
+ }
+ m, err = regex.FindNextMatch(m)
+ if err != nil {
+ return "", err
+ }
+ }
+
+ if prevat > 0 {
+ buf.WriteString(string(text[:prevat]))
+ }
+
+ for i := len(al) - 1; i >= 0; i-- {
+ buf.WriteString(al[i])
+ }
+ }
+
+ return buf.String(), nil
+}
+
+func replaceRunnerLTR(regex *Regexp, data *syntax.ReplacerData, input string, startAt, count int) (string, error) {
+ if startAt > len(input) {
+ return "", errors.New("startAt must be less than the length of the input string")
+ }
+
+ runner := regex.getRunner()
+ text, runeStart, pooledText := runner.decodeStringWithStart(input, startAt)
+ textInfo := newStringMatchText(input, text)
+ defer func() {
+ regex.putRunner(runner)
+ if pooledText != nil {
+ pooledRuneBuffers.put(pooledText)
+ }
+ }()
+ if startAt >= 0 && runeStart < 0 {
+ return "", errors.New("startAt must align to the start of a valid rune in the input string")
+ }
+ if runeStart < 0 {
+ runeStart = 0
+ }
+
+ m, err := runner.scan(text, textInfo, runeStart, true, regex.MatchTimeout)
+ if err != nil {
+ return "", err
+ }
+ if m == nil {
+ return input, nil
+ }
+
+ buf, pooledBuf := getPooledReplaceBuffer(len(input), regex.optimizations.MaxCachedReplaceBufferLength)
+ if pooledBuf != nil {
+ defer putPooledReplaceBuffer(buf, pooledBuf)
+ }
+
+ prevat := 0
+ for m != nil {
+ if m.balancing {
+ compactBalancedMatches(m)
+ }
+
+ if m.RuneIndex != prevat {
+ writeRunes(buf, text, prevat, m.RuneIndex)
+ }
+ prevat = m.RuneIndex + m.RuneLength
+ replacementImpl(data, buf, m)
+
+ count--
+ if count == 0 {
+ break
+ }
+
+ scanStart := m.textpos
+ if m.RuneLength == 0 {
+ if scanStart >= len(text) {
+ break
+ }
+ scanStart++
+ }
+
+ m, err = runner.scan(text, textInfo, scanStart, true, regex.MatchTimeout)
+ if err != nil {
+ return "", err
+ }
+ }
+
+ if prevat < len(text) {
+ writeRunes(buf, text, prevat, len(text))
+ }
+ return buf.String(), nil
+}
+
+func replaceRunnerRTL(regex *Regexp, data *syntax.ReplacerData, input string, startAt, count int) (string, error) {
+ if startAt > len(input) {
+ return "", errors.New("startAt must be less than the length of the input string")
+ }
+
+ runner := regex.getRunner()
+ text, runeStart, pooledText := runner.decodeStringWithStart(input, startAt)
+ textInfo := newStringMatchText(input, text)
+ defer func() {
+ regex.putRunner(runner)
+ if pooledText != nil {
+ pooledRuneBuffers.put(pooledText)
+ }
+ }()
+ if startAt >= 0 && runeStart < 0 {
+ return "", errors.New("startAt must align to the start of a valid rune in the input string")
+ }
+ if runeStart < 0 {
+ runeStart = len(text)
+ }
+
+ m, err := runner.scan(text, textInfo, runeStart, true, regex.MatchTimeout)
+ if err != nil {
+ return "", err
+ }
+ if m == nil {
+ return input, nil
+ }
+
+ buf, pooledBuf := getPooledReplaceBuffer(len(input), regex.optimizations.MaxCachedReplaceBufferLength)
+ if pooledBuf != nil {
+ defer putPooledReplaceBuffer(buf, pooledBuf)
+ }
+
+ prevat := len(text)
+ var al []string
+
+ for m != nil {
+ if m.balancing {
+ compactBalancedMatches(m)
+ }
+
+ if m.RuneIndex+m.RuneLength != prevat {
+ al = append(al, string(text[m.RuneIndex+m.RuneLength:prevat]))
+ }
+ prevat = m.RuneIndex
+ replacementImplRTL(data, &al, m)
+
+ count--
+ if count == 0 {
+ break
+ }
+
+ scanStart := m.textpos
+ if m.RuneLength == 0 {
+ if scanStart <= 0 {
+ break
+ }
+ scanStart--
+ }
+
+ m, err = runner.scan(text, textInfo, scanStart, true, regex.MatchTimeout)
+ if err != nil {
+ return "", err
+ }
+ }
+
+ if prevat > 0 {
+ writeRunes(buf, text, 0, prevat)
+ }
+ for i := len(al) - 1; i >= 0; i-- {
+ buf.WriteString(al[i])
+ }
+ return buf.String(), nil
+}
+
+// Given a Match, emits into the StringBuilder the evaluated
+// substitution pattern.
+func replacementImpl(data *syntax.ReplacerData, buf *bytes.Buffer, m *Match) {
+ for _, r := range data.Rules {
+
+ if r >= 0 { // string lookup
+ buf.WriteString(data.Strings[r])
+ } else if r < -replaceSpecials { // group lookup
+ m.groupValueAppendToBuf(-replaceSpecials-1-r, buf)
+ } else {
+ switch -replaceSpecials - 1 - r { // special insertion patterns
+ case replaceLeftPortion:
+ for i := 0; i < m.RuneIndex; i++ {
+ buf.WriteRune(m.text.runes[i])
+ }
+ case replaceRightPortion:
+ for i := m.RuneIndex + m.RuneLength; i < len(m.text.runes); i++ {
+ buf.WriteRune(m.text.runes[i])
+ }
+ case replaceLastGroup:
+ m.groupValueAppendToBuf(m.GroupCount()-1, buf)
+ case replaceWholeString:
+ for i := 0; i < len(m.text.runes); i++ {
+ buf.WriteRune(m.text.runes[i])
+ }
+ }
+ }
+ }
+}
+
+func replacementImplRTL(data *syntax.ReplacerData, al *[]string, m *Match) {
+ l := *al
+ buf := &bytes.Buffer{}
+
+ for _, r := range data.Rules {
+ buf.Reset()
+ if r >= 0 { // string lookup
+ l = append(l, data.Strings[r])
+ } else if r < -replaceSpecials { // group lookup
+ m.groupValueAppendToBuf(-replaceSpecials-1-r, buf)
+ l = append(l, buf.String())
+ } else {
+ switch -replaceSpecials - 1 - r { // special insertion patterns
+ case replaceLeftPortion:
+ for i := 0; i < m.RuneIndex; i++ {
+ buf.WriteRune(m.text.runes[i])
+ }
+ case replaceRightPortion:
+ for i := m.RuneIndex + m.RuneLength; i < len(m.text.runes); i++ {
+ buf.WriteRune(m.text.runes[i])
+ }
+ case replaceLastGroup:
+ m.groupValueAppendToBuf(m.GroupCount()-1, buf)
+ case replaceWholeString:
+ for i := 0; i < len(m.text.runes); i++ {
+ buf.WriteRune(m.text.runes[i])
+ }
+ }
+ l = append(l, buf.String())
+ }
+ }
+
+ *al = l
+}
diff --git a/vendor/github.com/dlclark/regexp2/v2/runner.go b/vendor/github.com/dlclark/regexp2/v2/runner.go
new file mode 100644
index 0000000000..ce09df07db
--- /dev/null
+++ b/vendor/github.com/dlclark/regexp2/v2/runner.go
@@ -0,0 +1,2197 @@
+package regexp2
+
+import (
+ "bytes"
+ "fmt"
+ "math"
+ "slices"
+ "strconv"
+ "strings"
+ "time"
+ "unicode"
+
+ "github.com/dlclark/regexp2/v2/helpers"
+ "github.com/dlclark/regexp2/v2/syntax"
+)
+
+type Runner struct {
+ re *Regexp
+ code *syntax.Code
+ debug bool
+
+ Runtextstart int // starting point for search
+
+ Runtext []rune // text to search
+ Runtextpos int // current position in text
+ Runtextend int
+
+ // The backtracking stack. Opcodes use this to store data regarding
+ // what they have matched and where to backtrack to. Each "frame" on
+ // the stack takes the form of [CodePosition Data1 Data2...], where
+ // CodePosition is the position of the current opcode and
+ // the data values are all optional. The CodePosition can be negative, and
+ // these values (also called "back2") are used by the BranchMark family of opcodes
+ // to indicate whether they are backtracking after a successful or failed
+ // match.
+ // When we backtrack, we pop the CodePosition off the stack, set the current
+ // instruction pointer to that code position, and mark the opcode
+ // with a backtracking flag ("Back"). Each opcode then knows how to
+ // handle its own data.
+ runtrack []int
+ Runtrackpos int
+
+ // This stack is used to track text positions across different opcodes.
+ // For example, in /(a*b)+/, the parentheses result in a SetMark/CaptureMark
+ // pair. SetMark records the text position before we match a*b. Then
+ // CaptureMark uses that position to figure out where the capture starts.
+ // Opcodes which push onto this stack are always paired with other opcodes
+ // which will pop the value from it later. A successful match should mean
+ // that this stack is empty.
+ runstack []int
+ Runstackpos int
+
+ // The crawl stack is used to keep track of captures. Every time a group
+ // has a capture, we push its group number onto the runcrawl stack. In
+ // the case of a balanced match, we push BOTH groups onto the stack.
+ runcrawl []int
+ runcrawlpos int
+
+ runtrackcount int // count of states that may do backtracking
+
+ runmatch *Match // result object
+
+ ignoreTimeout bool
+ timeout time.Duration // timeout in milliseconds (needed for actual)
+ deadline fasttime
+
+ operator syntax.InstOp
+ codepos int
+ rightToLeft bool
+ caseInsensitive bool
+}
+
+// run searches for matches and can continue from the previous match.
+//
+// quick is usually false, but can be true to not return matches, just put it in caches.
+// textstart is -1 to start at the "beginning" (depending on Right-To-Left), otherwise an index in input.
+// textInfo is nil for quick scans that do not need returned capture text metadata.
+func (re *Regexp) run(quick bool, textstart int, input []rune, textInfo *matchText) (*Match, error) {
+
+ // get a cached runner
+ runner := re.getRunner()
+ defer re.putRunner(runner)
+
+ if textstart < 0 {
+ if re.RightToLeft() {
+ textstart = len(input)
+ } else {
+ textstart = 0
+ }
+ }
+
+ return runner.scan(input, textInfo, textstart, quick, re.MatchTimeout)
+}
+
+// Scans the string to find the first match. Uses the Match object
+// both to feed text in and as a place to store matches that come out.
+//
+// All the action is in the Go() method. Our
+// responsibility is to load up the class members before
+// calling Go.
+//
+// The optimizer can compute a set of candidate starting characters,
+// and we could use a separate method Skip() that will quickly scan past
+// any characters that we know can't match.
+//
+// The input slice is passed separately from matchText so quick scans can avoid
+// allocating match metadata. When textInfo is nil, successful matches are only
+// used as a boolean result and capture text is intentionally unavailable. If
+// we collapsed down to just textInfo it would "escape" and hit the GC for fast
+// scans without captures.
+func (r *Runner) scan(rt []rune, textInfo *matchText, textstart int, quick bool, timeout time.Duration) (*Match, error) {
+ r.timeout = timeout
+ r.ignoreTimeout = (time.Duration(math.MaxInt64) == timeout)
+ r.debug = r.re.Debug()
+ r.Runtextstart = textstart
+ r.Runtext = rt
+ r.Runtextend = len(rt)
+
+ stoppos := r.Runtextend
+ bump := 1
+
+ if r.re.RightToLeft() {
+ bump = -1
+ stoppos = 0
+ }
+
+ r.Runtextpos = textstart
+ //initted := false
+
+ // setup our scanner functions
+ findFirstChar := r.re.findFirstChar
+ execute := r.re.execute
+ if findFirstChar == nil {
+ findFirstChar = findFirstCharDefault
+ }
+ if execute == nil {
+ execute = executeDefault
+ }
+
+ minRequiredLength := 0
+ if r.code != nil && r.code.FindOptimizations != nil {
+ minRequiredLength = r.code.FindOptimizations.MinRequiredLength
+ }
+
+ r.initMatch(textInfo)
+
+ r.startTimeoutWatch()
+ for {
+ if minRequiredLength > 0 {
+ if r.code.RightToLeft {
+ if r.Runtextpos < minRequiredLength {
+ r.tidyMatch(true)
+ return nil, nil
+ }
+ } else if r.Runtextend-r.Runtextpos < minRequiredLength {
+ r.tidyMatch(true)
+ return nil, nil
+ }
+ }
+
+ if r.debug {
+ //fmt.Printf("\nSearch content: %v\n", string(r.runtext))
+ fmt.Printf("\nSearch range: from 0 to %v\n", r.Runtextend)
+ fmt.Printf("Firstchar search starting at %v stopping at %v\n", r.Runtextpos, stoppos)
+ }
+
+ if findFirstChar(r) {
+ if !r.ignoreTimeout {
+ if err := r.CheckTimeout(); err != nil {
+ return nil, err
+ }
+ }
+
+ if r.debug {
+ fmt.Printf("Executing engine starting at %v\n\n", r.Runtextpos)
+ }
+
+ if err := execute(r); err != nil {
+ return nil, err
+ }
+
+ if r.runmatch.matchcount[0] > 0 {
+ // We'll return a match even if it touches a previous empty match
+ return r.tidyMatch(quick), nil
+ }
+
+ // reset state for another go
+ r.Runtrackpos = len(r.runtrack)
+ r.Runstackpos = len(r.runstack)
+ r.runcrawlpos = len(r.runcrawl)
+ }
+
+ // failure!
+
+ if r.Runtextpos == stoppos {
+ r.tidyMatch(true)
+ return nil, nil
+ }
+
+ // Recognize leading []* and various anchors, and bump on failure accordingly
+
+ // r.bump by one and start again
+
+ r.Runtextpos += bump
+ }
+ // We never get here
+}
+
+func executeDefault(r *Runner) error {
+
+ r.goTo(0)
+
+ for {
+
+ if r.debug {
+ r.dumpState()
+ }
+
+ if !r.ignoreTimeout {
+ if err := r.CheckTimeout(); err != nil {
+ return err
+ }
+ }
+
+ switch r.operator {
+ case syntax.Stop:
+ return nil
+
+ case syntax.Nothing:
+ //noop
+
+ case syntax.Goto:
+ r.goTo(r.operand(0))
+ continue
+
+ case syntax.Testref:
+ if !r.runmatch.isMatched(r.operand(0)) {
+ break
+ }
+ r.advance(1)
+ continue
+
+ case syntax.Lazybranch:
+ r.trackPush1(r.textPos())
+ r.advance(1)
+ continue
+
+ case syntax.Lazybranch | syntax.Back:
+ r.trackPop()
+ r.textto(r.trackPeek())
+ r.goTo(r.operand(0))
+ continue
+
+ case syntax.Setmark:
+ r.stackPush(r.textPos())
+ r.trackPush()
+ r.advance(0)
+ continue
+
+ case syntax.Nullmark:
+ r.stackPush(-1)
+ r.trackPush()
+ r.advance(0)
+ continue
+
+ case syntax.Setmark | syntax.Back, syntax.Nullmark | syntax.Back:
+ r.stackPop()
+
+ case syntax.Getmark:
+ r.stackPop()
+ r.trackPush1(r.stackPeek())
+ r.textto(r.stackPeek())
+ r.advance(0)
+ continue
+
+ case syntax.Getmark | syntax.Back:
+ r.trackPop()
+ r.stackPush(r.trackPeek())
+
+ case syntax.Capturemark:
+ if r.operand(1) != -1 && !r.runmatch.isMatched(r.operand(1)) {
+ break
+ }
+ r.stackPop()
+ if r.operand(1) != -1 {
+ r.transferCapture(r.operand(0), r.operand(1), r.stackPeek(), r.textPos())
+ } else {
+ r.Capture(r.operand(0), r.stackPeek(), r.textPos())
+ }
+ r.trackPush1(r.stackPeek())
+
+ r.advance(2)
+
+ continue
+
+ case syntax.Capturemark | syntax.Back:
+ r.trackPop()
+ r.stackPush(r.trackPeek())
+ r.uncapture()
+ if r.operand(0) != -1 && r.operand(1) != -1 {
+ r.uncapture()
+ }
+
+ case syntax.Branchmark:
+ r.stackPop()
+
+ matched := r.textPos() - r.stackPeek()
+
+ if matched != 0 { // Nonempty match -> loop now
+ r.trackPush2(r.stackPeek(), r.textPos()) // Save old mark, textpos
+ r.stackPush(r.textPos()) // Make new mark
+ r.goTo(r.operand(0)) // Loop
+ } else { // Empty match -> straight now
+ r.trackPushNeg1(r.stackPeek()) // Save old mark
+ r.advance(1) // Straight
+ }
+ continue
+
+ case syntax.Branchmark | syntax.Back:
+ r.trackPopN(2)
+ r.stackPop()
+ r.textto(r.trackPeekN(1)) // Recall position
+ r.trackPushNeg1(r.trackPeek()) // Save old mark
+ r.advance(1) // Straight
+ continue
+
+ case syntax.Branchmark | syntax.Back2:
+ r.trackPop()
+ r.stackPush(r.trackPeek()) // Recall old mark
+ // Backtrack
+
+ case syntax.Lazybranchmark:
+ {
+ // We hit this the first time through a lazy loop and after each
+ // successful match of the inner expression. It simply continues
+ // on and doesn't loop.
+ r.stackPop()
+
+ oldMarkPos := r.stackPeek()
+
+ if r.textPos() != oldMarkPos { // Nonempty match -> try to loop again by going to 'back' state
+ if oldMarkPos != -1 {
+ r.trackPush2(oldMarkPos, r.textPos()) // Save old mark, textpos
+ } else {
+ r.trackPush2(r.textPos(), r.textPos())
+ }
+ } else {
+ // The inner expression found an empty match, so we'll go directly to 'back2' if we
+ // backtrack. Don't touch the grouping stack here; instead, record the old mark and
+ // a flag indicating that backtracking doesn't need to pop a grouping stack frame.
+ r.trackPushNeg2(oldMarkPos, 0)
+ }
+ r.advance(1)
+ continue
+ }
+
+ case syntax.Lazybranchmark | syntax.Back:
+
+ // After the first time, Lazybranchmark | syntax.Back occurs
+ // with each iteration of the loop, and therefore with every attempted
+ // match of the inner expression. We'll try to match the inner expression,
+ // then go back to Lazybranchmark if successful. If the inner expression
+ // fails, we go to Lazybranchmark | syntax.Back2
+
+ r.trackPopN(2)
+ pos := r.trackPeekN(1)
+ r.trackPushNeg2(r.trackPeek(), 1) // Save old mark, note that we pushed a new mark
+ r.stackPush(pos) // Make new mark
+ r.textto(pos) // Recall position
+ r.goTo(r.operand(0)) // Loop
+ continue
+
+ case syntax.Lazybranchmark | syntax.Back2:
+ // The lazy loop has failed. We'll do a true backtrack and
+ // start over before the lazy loop.
+ r.trackPopN(2)
+ oldMark := r.trackPeek()
+ needsPop := r.trackPeekN(1)
+ if needsPop != 0 {
+ r.stackPop()
+ }
+ r.stackPush(oldMark) // Recall old mark
+
+ case syntax.Setcount:
+ r.stackPush2(r.textPos(), r.operand(0))
+ r.trackPush()
+ r.advance(1)
+ continue
+
+ case syntax.Nullcount:
+ r.stackPush2(-1, r.operand(0))
+ r.trackPush()
+ r.advance(1)
+ continue
+
+ case syntax.Setcount | syntax.Back:
+ r.stackPopN(2)
+
+ case syntax.Nullcount | syntax.Back:
+ r.stackPopN(2)
+
+ case syntax.Branchcount:
+ // r.stackPush:
+ // 0: Mark
+ // 1: Count
+
+ r.stackPopN(2)
+ mark := r.stackPeek()
+ count := r.stackPeekN(1)
+ matched := r.textPos() - mark
+
+ if count >= r.operand(1) || (matched == 0 && count >= 0) { // Max loops or empty match -> straight now
+ r.trackPushNeg2(mark, count) // Save old mark, count
+ r.advance(2) // Straight
+ } else { // Nonempty match -> count+loop now
+ r.trackPush1(mark) // remember mark
+ r.stackPush2(r.textPos(), count+1) // Make new mark, incr count
+ r.goTo(r.operand(0)) // Loop
+ }
+ continue
+
+ case syntax.Branchcount | syntax.Back:
+ // r.trackPush:
+ // 0: Previous mark
+ // r.stackPush:
+ // 0: Mark (= current pos, discarded)
+ // 1: Count
+ r.trackPop()
+ r.stackPopN(2)
+ if r.stackPeekN(1) > 0 { // Positive -> can go straight
+ r.textto(r.stackPeek()) // Zap to mark
+ r.trackPushNeg2(r.trackPeek(), r.stackPeekN(1)-1) // Save old mark, old count
+ r.advance(2) // Straight
+ continue
+ }
+ r.stackPush2(r.trackPeek(), r.stackPeekN(1)-1) // recall old mark, old count
+
+ case syntax.Branchcount | syntax.Back2:
+ // r.trackPush:
+ // 0: Previous mark
+ // 1: Previous count
+ r.trackPopN(2)
+ r.stackPush2(r.trackPeek(), r.trackPeekN(1)) // Recall old mark, old count
+
+ case syntax.Lazybranchcount:
+ // r.stackPush:
+ // 0: Mark
+ // 1: Count
+
+ r.stackPopN(2)
+ mark := r.stackPeek()
+ count := r.stackPeekN(1)
+
+ if count < 0 { // Negative count -> loop now
+ r.trackPushNeg1(mark) // Save old mark
+ r.stackPush2(r.textPos(), count+1) // Make new mark, incr count
+ r.goTo(r.operand(0)) // Loop
+ } else { // Nonneg count -> straight now
+ r.trackPush3(mark, count, r.textPos()) // Save mark, count, position
+ r.advance(2) // Straight
+ }
+ continue
+
+ case syntax.Lazybranchcount | syntax.Back:
+ // r.trackPush:
+ // 0: Mark
+ // 1: Count
+ // 2: r.textPos
+
+ r.trackPopN(3)
+ mark := r.trackPeek()
+ textpos := r.trackPeekN(2)
+
+ if r.trackPeekN(1) < r.operand(1) && textpos != mark { // Under limit and not empty match -> loop
+ r.textto(textpos) // Recall position
+ r.stackPush2(textpos, r.trackPeekN(1)+1) // Make new mark, incr count
+ r.trackPushNeg1(mark) // Save old mark
+ r.goTo(r.operand(0)) // Loop
+ continue
+ } else { // Max loops or empty match -> backtrack
+ r.stackPush2(r.trackPeek(), r.trackPeekN(1)) // Recall old mark, count
+ // backtrack
+ }
+
+ case syntax.Lazybranchcount | syntax.Back2:
+ // r.trackPush:
+ // 0: Previous mark
+ // r.stackPush:
+ // 0: Mark (== current pos, discarded)
+ // 1: Count
+ r.trackPop()
+ r.stackPopN(2)
+ r.stackPush2(r.trackPeek(), r.stackPeekN(1)-1) // Recall old mark, count
+ // Backtrack
+
+ case syntax.Setjump:
+ r.stackPush2(r.trackpos(), r.Crawlpos())
+ r.trackPush()
+ r.advance(0)
+ continue
+
+ case syntax.Setjump | syntax.Back:
+ r.stackPopN(2)
+
+ case syntax.Backjump:
+ // r.stackPush:
+ // 0: Saved trackpos
+ // 1: r.crawlpos
+ r.stackPopN(2)
+ r.trackto(r.stackPeek())
+
+ for r.Crawlpos() != r.stackPeekN(1) {
+ r.uncapture()
+ }
+
+ case syntax.Forejump:
+ // r.stackPush:
+ // 0: Saved trackpos
+ // 1: r.crawlpos
+ r.stackPopN(2)
+ r.trackto(r.stackPeek())
+ r.trackPush1(r.stackPeekN(1))
+ r.advance(0)
+ continue
+
+ case syntax.Forejump | syntax.Back:
+ // r.trackPush:
+ // 0: r.crawlpos
+ r.trackPop()
+
+ for r.Crawlpos() != r.trackPeek() {
+ r.uncapture()
+ }
+
+ case syntax.Bol:
+ if r.leftchars() > 0 && r.charAt(r.textPos()-1) != '\n' {
+ break
+ }
+ r.advance(0)
+ continue
+
+ case syntax.Eol:
+ if r.rightchars() > 0 && r.charAt(r.textPos()) != '\n' {
+ break
+ }
+ r.advance(0)
+ continue
+
+ case syntax.Boundary:
+ if !r.IsBoundary(r.textPos()) {
+ break
+ }
+ r.advance(0)
+ continue
+
+ case syntax.Nonboundary:
+ if r.IsBoundary(r.textPos()) {
+ break
+ }
+ r.advance(0)
+ continue
+
+ case syntax.ECMABoundary:
+ if !r.IsECMABoundary(r.textPos()) {
+ break
+ }
+ r.advance(0)
+ continue
+
+ case syntax.NonECMABoundary:
+ if r.IsECMABoundary(r.textPos()) {
+ break
+ }
+ r.advance(0)
+ continue
+
+ case syntax.Beginning:
+ if r.leftchars() > 0 {
+ break
+ }
+ r.advance(0)
+ continue
+
+ case syntax.Start:
+ if r.textPos() != r.textstart() {
+ break
+ }
+ r.advance(0)
+ continue
+
+ case syntax.EndZ:
+ rchars := r.rightchars()
+ if rchars > 1 {
+ break
+ }
+ // RE2 and EcmaScript define $ as "asserts position at the end of the string"
+ // PCRE/.NET adds "or before the line terminator right at the end of the string (if any)"
+ if (r.re.options & (RE2 | ECMAScript)) != 0 {
+ // RE2/Ecmascript mode
+ if rchars > 0 {
+ break
+ }
+ } else if rchars == 1 && r.charAt(r.textPos()) != '\n' {
+ // "regular" mode
+ break
+ }
+
+ r.advance(0)
+ continue
+
+ case syntax.End:
+ if r.rightchars() > 0 {
+ break
+ }
+ r.advance(0)
+ continue
+
+ case syntax.One:
+ if r.forwardchars() < 1 || r.forwardcharnext() != rune(r.operand(0)) {
+ break
+ }
+
+ r.advance(1)
+ continue
+
+ case syntax.Notone:
+ if r.forwardchars() < 1 || r.forwardcharnext() == rune(r.operand(0)) {
+ break
+ }
+
+ r.advance(1)
+ continue
+
+ case syntax.Set:
+
+ if r.forwardchars() < 1 || !r.code.Sets[r.operand(0)].CharIn(r.forwardcharnext()) {
+ break
+ }
+
+ r.advance(1)
+ continue
+
+ case syntax.Multi:
+ if !r.runematch(r.code.Strings[r.operand(0)]) {
+ break
+ }
+
+ r.advance(1)
+ continue
+
+ case syntax.Ref:
+
+ capnum := r.operand(0)
+
+ if r.runmatch.isMatched(capnum) {
+ if !r.refmatch(r.runmatch.matchIndex(capnum), r.runmatch.matchLength(capnum)) {
+ break
+ }
+ } else {
+ if (r.re.options & ECMAScript) == 0 {
+ break
+ }
+ }
+
+ r.advance(1)
+ continue
+
+ case syntax.Onerep:
+
+ c := r.operand(1)
+
+ if r.forwardchars() < c {
+ break
+ }
+
+ ch := rune(r.operand(0))
+
+ for c > 0 {
+ if r.forwardcharnext() != ch {
+ goto BreakBackward
+ }
+ c--
+ }
+
+ r.advance(2)
+ continue
+
+ case syntax.Notonerep:
+
+ c := r.operand(1)
+
+ if r.forwardchars() < c {
+ break
+ }
+ ch := rune(r.operand(0))
+
+ for c > 0 {
+ if r.forwardcharnext() == ch {
+ goto BreakBackward
+ }
+ c--
+ }
+
+ r.advance(2)
+ continue
+
+ case syntax.Setrep:
+
+ c := r.operand(1)
+
+ if r.forwardchars() < c {
+ break
+ }
+
+ set := r.code.Sets[r.operand(0)]
+
+ for c > 0 {
+ if !set.CharIn(r.forwardcharnext()) {
+ goto BreakBackward
+ }
+ c--
+ }
+
+ r.advance(2)
+ continue
+
+ case syntax.Oneloop, syntax.Oneloopatomic:
+
+ c := r.operand(1)
+
+ if c > r.forwardchars() {
+ c = r.forwardchars()
+ }
+
+ ch := rune(r.operand(0))
+ i := c
+
+ for ; i > 0; i-- {
+ if r.forwardcharnext() != ch {
+ r.backwardnext()
+ break
+ }
+ }
+
+ if c > i && r.operator == syntax.Oneloop {
+ r.trackPush2(c-i-1, r.textPos()-r.bump())
+ }
+
+ r.advance(2)
+ continue
+
+ case syntax.Notoneloop, syntax.Notoneloopatomic:
+
+ c := r.operand(1)
+
+ if c > r.forwardchars() {
+ c = r.forwardchars()
+ }
+
+ ch := rune(r.operand(0))
+ i := c
+
+ for ; i > 0; i-- {
+ if r.forwardcharnext() == ch {
+ r.backwardnext()
+ break
+ }
+ }
+
+ if c > i && r.operator == syntax.Notoneloop {
+ r.trackPush2(c-i-1, r.textPos()-r.bump())
+ }
+
+ r.advance(2)
+ continue
+
+ case syntax.Setloop, syntax.Setloopatomic:
+
+ c := r.operand(1)
+
+ if c > r.forwardchars() {
+ c = r.forwardchars()
+ }
+
+ set := r.code.Sets[r.operand(0)]
+ i := c
+
+ for ; i > 0; i-- {
+ if !set.CharIn(r.forwardcharnext()) {
+ r.backwardnext()
+ break
+ }
+ }
+
+ if c > i && r.operator == syntax.Setloop {
+ r.trackPush2(c-i-1, r.textPos()-r.bump())
+ }
+
+ r.advance(2)
+ continue
+
+ case syntax.Oneloop | syntax.Back, syntax.Notoneloop | syntax.Back:
+
+ r.trackPopN(2)
+ i := r.trackPeek()
+ pos := r.trackPeekN(1)
+
+ r.textto(pos)
+
+ if i > 0 {
+ r.trackPush2(i-1, pos-r.bump())
+ }
+
+ r.advance(2)
+ continue
+
+ case syntax.Setloop | syntax.Back:
+
+ r.trackPopN(2)
+ i := r.trackPeek()
+ pos := r.trackPeekN(1)
+
+ r.textto(pos)
+
+ if i > 0 {
+ r.trackPush2(i-1, pos-r.bump())
+ }
+
+ r.advance(2)
+ continue
+
+ case syntax.Onelazy, syntax.Notonelazy:
+
+ c := r.operand(1)
+
+ if c > r.forwardchars() {
+ c = r.forwardchars()
+ }
+
+ if c > 0 {
+ r.trackPush2(c-1, r.textPos())
+ }
+
+ r.advance(2)
+ continue
+
+ case syntax.Setlazy:
+
+ c := r.operand(1)
+
+ if c > r.forwardchars() {
+ c = r.forwardchars()
+ }
+
+ if c > 0 {
+ r.trackPush2(c-1, r.textPos())
+ }
+
+ r.advance(2)
+ continue
+
+ case syntax.Onelazy | syntax.Back:
+
+ r.trackPopN(2)
+ pos := r.trackPeekN(1)
+ r.textto(pos)
+
+ if r.forwardcharnext() != rune(r.operand(0)) {
+ break
+ }
+
+ i := r.trackPeek()
+
+ if i > 0 {
+ r.trackPush2(i-1, pos+r.bump())
+ }
+
+ r.advance(2)
+ continue
+
+ case syntax.Notonelazy | syntax.Back:
+
+ r.trackPopN(2)
+ pos := r.trackPeekN(1)
+ r.textto(pos)
+
+ if r.forwardcharnext() == rune(r.operand(0)) {
+ break
+ }
+
+ i := r.trackPeek()
+
+ if i > 0 {
+ r.trackPush2(i-1, pos+r.bump())
+ }
+
+ r.advance(2)
+ continue
+
+ case syntax.Setlazy | syntax.Back:
+
+ r.trackPopN(2)
+ pos := r.trackPeekN(1)
+ r.textto(pos)
+
+ if !r.code.Sets[r.operand(0)].CharIn(r.forwardcharnext()) {
+ break
+ }
+
+ i := r.trackPeek()
+
+ if i > 0 {
+ r.trackPush2(i-1, pos+r.bump())
+ }
+
+ r.advance(2)
+ continue
+
+ case syntax.UpdateBumpalong:
+ // UpdateBumpalong should only exist in the code stream at such a point where the root
+ // of the backtracking stack contains the runtextpos from the start of this Go call. Replace
+ // that tracking value with the current runtextpos value if it's greater.
+ trackingpos := r.runtrack[len(r.runtrack)-1]
+ if trackingpos < r.Runtextpos {
+ r.runtrack[len(r.runtrack)-1] = r.Runtextpos
+ }
+ r.advance(0)
+ continue
+
+ default:
+ return fmt.Errorf("unknown state in regex runner: %v", r.operator)
+ }
+
+ BreakBackward:
+ ;
+
+ // "break Backward" comes here:
+ r.backtrack()
+ }
+}
+
+// increase the size of stack and track storage
+func (r *Runner) ensureStorage() {
+ if r.Runstackpos < r.runtrackcount*4 {
+ doubleIntSlice(&r.runstack, &r.Runstackpos)
+ }
+ if r.Runtrackpos < r.runtrackcount*4 {
+ doubleIntSlice(&r.runtrack, &r.Runtrackpos)
+ }
+}
+
+func (r *Runner) ensureStack(plus int) {
+ if r.Runstackpos-plus < r.runtrackcount*4 {
+ doubleIntSlice(&r.runstack, &r.Runstackpos)
+ }
+}
+
+func doubleIntSlice(s *[]int, pos *int) {
+ oldLen := len(*s)
+ newS := make([]int, oldLen*2)
+
+ copy(newS[oldLen:], *s)
+ *pos += oldLen
+ *s = newS
+}
+
+// Save a number on the longjump unrolling stack
+func (r *Runner) crawl(i int) {
+ if r.runcrawlpos == 0 {
+ doubleIntSlice(&r.runcrawl, &r.runcrawlpos)
+ }
+ r.runcrawlpos--
+ r.runcrawl[r.runcrawlpos] = i
+}
+
+// Remove a number from the longjump unrolling stack
+func (r *Runner) popcrawl() int {
+ val := r.runcrawl[r.runcrawlpos]
+ r.runcrawlpos++
+ return val
+}
+
+// Get the height of the stack
+func (r *Runner) Crawlpos() int {
+ return len(r.runcrawl) - r.runcrawlpos
+}
+
+func (r *Runner) advance(i int) {
+ r.codepos += (i + 1)
+ r.setOperator(r.code.Codes[r.codepos])
+}
+
+func (r *Runner) goTo(newpos int) {
+ // when branching backward or in place, ensure storage
+ if newpos <= r.codepos {
+ r.ensureStorage()
+ }
+
+ r.setOperator(r.code.Codes[newpos])
+ r.codepos = newpos
+}
+
+func (r *Runner) textto(newpos int) {
+ r.Runtextpos = newpos
+}
+
+func (r *Runner) trackto(newpos int) {
+ r.Runtrackpos = len(r.runtrack) - newpos
+}
+
+func (r *Runner) textstart() int {
+ return r.Runtextstart
+}
+
+func (r *Runner) textPos() int {
+ return r.Runtextpos
+}
+
+// push onto the backtracking stack
+func (r *Runner) trackpos() int {
+ return len(r.runtrack) - r.Runtrackpos
+}
+
+func (r *Runner) trackPush() {
+ r.Runtrackpos--
+ r.runtrack[r.Runtrackpos] = r.codepos
+}
+
+func (r *Runner) trackPush1(I1 int) {
+ r.Runtrackpos--
+ r.runtrack[r.Runtrackpos] = I1
+ r.Runtrackpos--
+ r.runtrack[r.Runtrackpos] = r.codepos
+}
+
+func (r *Runner) trackPush2(I1, I2 int) {
+ r.Runtrackpos--
+ r.runtrack[r.Runtrackpos] = I1
+ r.Runtrackpos--
+ r.runtrack[r.Runtrackpos] = I2
+ r.Runtrackpos--
+ r.runtrack[r.Runtrackpos] = r.codepos
+}
+
+func (r *Runner) trackPush3(I1, I2, I3 int) {
+ r.Runtrackpos--
+ r.runtrack[r.Runtrackpos] = I1
+ r.Runtrackpos--
+ r.runtrack[r.Runtrackpos] = I2
+ r.Runtrackpos--
+ r.runtrack[r.Runtrackpos] = I3
+ r.Runtrackpos--
+ r.runtrack[r.Runtrackpos] = r.codepos
+}
+
+func (r *Runner) trackPushNeg1(I1 int) {
+ r.Runtrackpos--
+ r.runtrack[r.Runtrackpos] = I1
+ r.Runtrackpos--
+ r.runtrack[r.Runtrackpos] = -r.codepos
+}
+
+func (r *Runner) trackPushNeg2(I1, I2 int) {
+ r.Runtrackpos--
+ r.runtrack[r.Runtrackpos] = I1
+ r.Runtrackpos--
+ r.runtrack[r.Runtrackpos] = I2
+ r.Runtrackpos--
+ r.runtrack[r.Runtrackpos] = -r.codepos
+}
+
+func (r *Runner) backtrack() {
+ newpos := r.runtrack[r.Runtrackpos]
+ r.Runtrackpos++
+
+ if r.debug {
+ if newpos < 0 {
+ fmt.Printf(" Backtracking (back2) to code position %v\n", -newpos)
+ } else {
+ fmt.Printf(" Backtracking to code position %v\n", newpos)
+ }
+ }
+
+ if newpos < 0 {
+ newpos = -newpos
+ r.setOperator(r.code.Codes[newpos] | int(syntax.Back2))
+ } else {
+ r.setOperator(r.code.Codes[newpos] | int(syntax.Back))
+ }
+
+ // When branching backward, ensure storage
+ if newpos < r.codepos {
+ r.ensureStorage()
+ }
+
+ r.codepos = newpos
+}
+
+func (r *Runner) setOperator(op int) {
+ r.caseInsensitive = (0 != (op & int(syntax.Ci)))
+ r.rightToLeft = (0 != (op & int(syntax.Rtl)))
+ r.operator = syntax.InstOp(op & ^int(syntax.Rtl|syntax.Ci))
+}
+
+func (r *Runner) trackPop() {
+ r.Runtrackpos++
+}
+
+// pop framesize items from the backtracking stack
+func (r *Runner) trackPopN(framesize int) {
+ r.Runtrackpos += framesize
+}
+
+// Technically we are actually peeking at items already popped. So if you want to
+// get and pop the top item from the stack, you do
+// r.trackPop();
+// r.trackPeek();
+func (r *Runner) trackPeek() int {
+ return r.runtrack[r.Runtrackpos-1]
+}
+
+// get the ith element down on the backtracking stack
+func (r *Runner) trackPeekN(i int) int {
+ return r.runtrack[r.Runtrackpos-i-1]
+}
+
+// Push onto the grouping stack
+func (r *Runner) stackPush(I1 int) {
+ r.Runstackpos--
+ r.runstack[r.Runstackpos] = I1
+}
+
+func (r *Runner) stackPush2(I1, I2 int) {
+ r.Runstackpos--
+ r.runstack[r.Runstackpos] = I1
+ r.Runstackpos--
+ r.runstack[r.Runstackpos] = I2
+}
+
+func (r *Runner) stackPop() {
+ r.Runstackpos++
+}
+
+// pop framesize items from the grouping stack
+func (r *Runner) stackPopN(framesize int) {
+ r.Runstackpos += framesize
+}
+
+// Technically we are actually peeking at items already popped. So if you want to
+// get and pop the top item from the stack, you do
+// r.stackPop();
+// r.stackPeek();
+func (r *Runner) stackPeek() int {
+ return r.runstack[r.Runstackpos-1]
+}
+
+// get the ith element down on the grouping stack
+func (r *Runner) stackPeekN(i int) int {
+ return r.runstack[r.Runstackpos-i-1]
+}
+
+func (r *Runner) operand(i int) int {
+ return r.code.Codes[r.codepos+i+1]
+}
+
+func (r *Runner) leftchars() int {
+ return r.Runtextpos
+}
+
+func (r *Runner) rightchars() int {
+ return r.Runtextend - r.Runtextpos
+}
+
+func (r *Runner) bump() int {
+ if r.rightToLeft {
+ return -1
+ }
+ return 1
+}
+
+func (r *Runner) forwardchars() int {
+ if r.rightToLeft {
+ return r.Runtextpos
+ }
+ return r.Runtextend - r.Runtextpos
+}
+
+func (r *Runner) forwardcharnext() rune {
+ var ch rune
+ if r.rightToLeft {
+ r.Runtextpos--
+ ch = r.Runtext[r.Runtextpos]
+ } else {
+ ch = r.Runtext[r.Runtextpos]
+ r.Runtextpos++
+ }
+
+ // move this to compile time for individual runes
+ /*if r.caseInsensitive {
+ return unicode.ToLower(ch)
+ }*/
+ return ch
+}
+
+func (r *Runner) runematch(str []rune) bool {
+ var pos int
+
+ c := len(str)
+ if !r.rightToLeft {
+ if r.Runtextend-r.Runtextpos < c {
+ return false
+ }
+
+ pos = r.Runtextpos + c
+ } else {
+ if r.Runtextpos-0 < c {
+ return false
+ }
+
+ pos = r.Runtextpos
+ }
+
+ if !r.caseInsensitive {
+ for c != 0 {
+ c--
+ pos--
+ if str[c] != r.Runtext[pos] {
+ return false
+ }
+ }
+ } else {
+ for c != 0 {
+ c--
+ pos--
+ if str[c] != unicode.ToLower(r.Runtext[pos]) {
+ return false
+ }
+ }
+ }
+
+ if !r.rightToLeft {
+ pos += len(str)
+ }
+
+ r.Runtextpos = pos
+
+ return true
+}
+
+func (r *Runner) refmatch(index, len int) bool {
+ var c, pos, cmpos int
+
+ if !r.rightToLeft {
+ if r.Runtextend-r.Runtextpos < len {
+ return false
+ }
+
+ pos = r.Runtextpos + len
+ } else {
+ if r.Runtextpos-0 < len {
+ return false
+ }
+
+ pos = r.Runtextpos
+ }
+ cmpos = index + len
+
+ c = len
+
+ if !r.caseInsensitive {
+ for c != 0 {
+ c--
+ cmpos--
+ pos--
+ if r.Runtext[cmpos] != r.Runtext[pos] {
+ return false
+ }
+
+ }
+ } else {
+ for c != 0 {
+ c--
+ cmpos--
+ pos--
+
+ if unicode.ToLower(r.Runtext[cmpos]) != unicode.ToLower(r.Runtext[pos]) {
+ return false
+ }
+ }
+ }
+
+ if !r.rightToLeft {
+ pos += len
+ }
+
+ r.Runtextpos = pos
+
+ return true
+}
+
+func (r *Runner) backwardnext() {
+ if r.rightToLeft {
+ r.Runtextpos++
+ } else {
+ r.Runtextpos--
+ }
+}
+
+func (r *Runner) charAt(j int) rune {
+ return r.Runtext[j]
+}
+
+func findFirstCharDefault(r *Runner) bool {
+ if 0 != (r.code.Anchors & (syntax.AnchorBeginning | syntax.AnchorStart | syntax.AnchorEndZ | syntax.AnchorEnd)) {
+ if !r.code.RightToLeft {
+ if (0 != (r.code.Anchors&syntax.AnchorBeginning) && r.Runtextpos > 0) ||
+ (0 != (r.code.Anchors&syntax.AnchorStart) && r.Runtextpos > r.Runtextstart) {
+ r.Runtextpos = r.Runtextend
+ return false
+ }
+ if 0 != (r.code.Anchors&syntax.AnchorEndZ) && r.Runtextpos < r.Runtextend-1 {
+ r.Runtextpos = r.Runtextend - 1
+ } else if 0 != (r.code.Anchors&syntax.AnchorEnd) && r.Runtextpos < r.Runtextend {
+ r.Runtextpos = r.Runtextend
+ }
+ } else {
+ if (0 != (r.code.Anchors&syntax.AnchorEnd) && r.Runtextpos < r.Runtextend) ||
+ (0 != (r.code.Anchors&syntax.AnchorEndZ) && (r.Runtextpos < r.Runtextend-1 ||
+ (r.Runtextpos == r.Runtextend-1 && r.charAt(r.Runtextpos) != '\n'))) ||
+ (0 != (r.code.Anchors&syntax.AnchorStart) && r.Runtextpos < r.Runtextstart) {
+ r.Runtextpos = 0
+ return false
+ }
+ if 0 != (r.code.Anchors&syntax.AnchorBeginning) && r.Runtextpos > 0 {
+ r.Runtextpos = 0
+ }
+ }
+
+ if r.code.BmPrefix != nil {
+ return r.code.BmPrefix.IsMatch(r.Runtext, r.Runtextpos, 0, r.Runtextend)
+ }
+
+ return true // found a valid start or end anchor
+ } else if r.code.BmPrefix != nil {
+ r.Runtextpos = r.code.BmPrefix.Scan(r.Runtext, r.Runtextpos, 0, r.Runtextend)
+
+ if r.Runtextpos == -1 {
+ if r.code.RightToLeft {
+ r.Runtextpos = 0
+ } else {
+ r.Runtextpos = r.Runtextend
+ }
+ return false
+ }
+
+ return true
+ }
+
+ if shouldUseFindFirstCharOptimized(r) {
+ if handled, found := findFirstCharOptimized(r); handled {
+ return found
+ }
+ }
+
+ if r.code.FcPrefix == nil {
+ return true
+ }
+
+ r.rightToLeft = r.code.RightToLeft
+ r.caseInsensitive = r.code.FcPrefix.CaseInsensitive
+
+ set := r.code.FcPrefix.PrefixSet
+ if set.IsSingleton() {
+ ch := set.SingletonChar()
+ for i := r.forwardchars(); i > 0; i-- {
+ if ch == r.forwardcharnext() {
+ r.backwardnext()
+ return true
+ }
+ }
+ } else {
+ for i := r.forwardchars(); i > 0; i-- {
+ n := r.forwardcharnext()
+ //fmt.Printf("%v in %v: %v\n", string(n), set.String(), set.CharIn(n))
+ if set.CharIn(n) {
+ r.backwardnext()
+ return true
+ }
+ }
+ }
+
+ return false
+}
+
+func shouldUseFindFirstCharOptimized(r *Runner) bool {
+ if r.code == nil || r.code.FindOptimizations == nil {
+ return false
+ }
+
+ switch r.code.FindOptimizations.FindMode {
+ case syntax.TrailingAnchor_FixedLength_LeftToRight_End,
+ syntax.LeadingString_OrdinalIgnoreCase_LeftToRight,
+ syntax.LeadingStrings_LeftToRight,
+ syntax.LeadingStrings_OrdinalIgnoreCase_LeftToRight,
+ syntax.FixedDistanceChar_LeftToRight,
+ syntax.FixedDistanceString_LeftToRight,
+ syntax.FixedDistanceSets_LeftToRight,
+ syntax.LiteralAfterLoop_LeftToRight,
+ syntax.RequiredLandmarkChain_LeftToRight:
+ return true
+ default:
+ return false
+ }
+}
+
+func findFirstCharOptimized(r *Runner) (handled bool, found bool) {
+ if r.code == nil || r.code.FindOptimizations == nil {
+ return false, false
+ }
+
+ opts := r.code.FindOptimizations
+ switch opts.FindMode {
+ case syntax.NoSearch:
+ return false, false
+ case syntax.TrailingAnchor_FixedLength_LeftToRight_End:
+ return true, findTrailingFixedLengthEnd(r, opts.MinRequiredLength)
+ case syntax.LeadingString_LeftToRight:
+ return true, findLeadingStringLeftToRight(r, []rune(opts.LeadingPrefix), false)
+ case syntax.LeadingString_OrdinalIgnoreCase_LeftToRight:
+ return true, findLeadingStringLeftToRight(r, []rune(opts.LeadingPrefix), true)
+ case syntax.LeadingStrings_LeftToRight:
+ return true, findLeadingStringsLeftToRight(r, opts.LeadingPrefixesRunes, false)
+ case syntax.LeadingStrings_OrdinalIgnoreCase_LeftToRight:
+ return true, findLeadingStringsLeftToRight(r, opts.LeadingPrefixesRunes, true)
+ case syntax.FixedDistanceSets_LeftToRight:
+ return true, findFixedDistanceSetsLeftToRight(r, opts.FixedDistanceSets)
+ case syntax.FixedDistanceChar_LeftToRight:
+ return true, findFixedDistanceCharLeftToRight(r, opts.FixedDistanceLiteral.C, opts.FixedDistanceLiteral.Distance)
+ case syntax.FixedDistanceString_LeftToRight:
+ return true, findFixedDistanceStringLeftToRight(r, []rune(opts.FixedDistanceLiteral.S), opts.FixedDistanceLiteral.Distance)
+ case syntax.LiteralAfterLoop_LeftToRight:
+ return true, findLiteralAfterLoopLeftToRight(r, opts.LiteralAfterLoop)
+ case syntax.RequiredLandmarkChain_LeftToRight:
+ return true, findRequiredLandmarkChainLeftToRight(r, opts.LandmarkChain)
+ default:
+ return false, false
+ }
+}
+
+func findTrailingFixedLengthEnd(r *Runner, fixedLength int) bool {
+ start := r.Runtextend - fixedLength
+ if start < r.Runtextpos || start < 0 {
+ r.Runtextpos = r.Runtextend
+ return false
+ }
+ r.Runtextpos = start
+ return true
+}
+
+func findLeadingStringLeftToRight(r *Runner, prefix []rune, ignoreCase bool) bool {
+ if len(prefix) == 0 {
+ return true
+ }
+
+ search := r.Runtext[r.Runtextpos:]
+ var offset int
+ if ignoreCase {
+ if isASCIIRunes(prefix) {
+ offset = helpers.IndexOfIgnoreCaseAscii(search, prefix)
+ } else {
+ offset = helpers.IndexOfIgnoreCase(search, prefix)
+ }
+ } else {
+ offset = helpers.IndexOf(search, prefix)
+ }
+ if offset < 0 {
+ r.Runtextpos = r.Runtextend
+ return false
+ }
+
+ start := r.Runtextpos + offset
+ if !hasRequiredLengthAt(r, start) {
+ r.Runtextpos = r.Runtextend
+ return false
+ }
+ r.Runtextpos = start
+ return true
+}
+
+func findLeadingStringsLeftToRight(r *Runner, prefixes [][]rune, ignoreCase bool) bool {
+ if len(prefixes) == 0 {
+ return false
+ }
+
+ for start := r.Runtextpos; start <= latestPossibleStart(r); start++ {
+ for _, prefix := range prefixes {
+ if ignoreCase {
+ if helpers.StartsWithIgnoreCase(r.Runtext[start:], prefix) {
+ r.Runtextpos = start
+ return true
+ }
+ } else if helpers.StartsWith(r.Runtext[start:], prefix) {
+ r.Runtextpos = start
+ return true
+ }
+ }
+ }
+
+ r.Runtextpos = r.Runtextend
+ return false
+}
+
+func findFixedDistanceCharLeftToRight(r *Runner, ch rune, distance int) bool {
+ searchStart := r.Runtextpos + distance
+ for searchStart < r.Runtextend {
+ offset := helpers.IndexOfAny1(r.Runtext[searchStart:], ch)
+ if offset < 0 {
+ r.Runtextpos = r.Runtextend
+ return false
+ }
+ literalIndex := searchStart + offset
+ start := literalIndex - distance
+ if start >= r.Runtextpos && hasRequiredLengthAt(r, start) {
+ r.Runtextpos = start
+ return true
+ }
+ if start > latestPossibleStart(r) {
+ break
+ }
+ searchStart = literalIndex + 1
+ }
+
+ r.Runtextpos = r.Runtextend
+ return false
+}
+
+func findFixedDistanceStringLeftToRight(r *Runner, literal []rune, distance int) bool {
+ if len(literal) == 0 {
+ return true
+ }
+
+ searchStart := r.Runtextpos + distance
+ for searchStart <= r.Runtextend-len(literal) {
+ offset := helpers.IndexOf(r.Runtext[searchStart:], literal)
+ if offset < 0 {
+ r.Runtextpos = r.Runtextend
+ return false
+ }
+ literalIndex := searchStart + offset
+ start := literalIndex - distance
+ if start >= r.Runtextpos && hasRequiredLengthAt(r, start) {
+ r.Runtextpos = start
+ return true
+ }
+ if start > latestPossibleStart(r) {
+ break
+ }
+ searchStart = literalIndex + 1
+ }
+
+ r.Runtextpos = r.Runtextend
+ return false
+}
+
+func findFixedDistanceSetsLeftToRight(r *Runner, sets []syntax.FixedDistanceSet) bool {
+ if len(sets) == 0 || sets[0].Set == nil {
+ return false
+ }
+
+ primary := sets[0]
+ searchStart := r.Runtextpos + primary.Distance
+ for searchStart < r.Runtextend {
+ offset := indexOfSet(r.Runtext[searchStart:], primary)
+ if offset < 0 {
+ r.Runtextpos = r.Runtextend
+ return false
+ }
+
+ charIndex := searchStart + offset
+ start := charIndex - primary.Distance
+ if start > latestPossibleStart(r) {
+ break
+ }
+ if start >= r.Runtextpos && hasRequiredLengthAt(r, start) && fixedDistanceSetsMatchAt(r, sets, start) {
+ r.Runtextpos = start
+ return true
+ }
+ searchStart = charIndex + 1
+ }
+
+ r.Runtextpos = r.Runtextend
+ return false
+}
+
+func findLiteralAfterLoopLeftToRight(r *Runner, literal *syntax.LiteralAfterLoop) bool {
+ if literal == nil || literal.LoopNode == nil || literal.LoopNode.Set == nil {
+ return false
+ }
+
+ searchStart := r.Runtextpos
+ for searchStart < r.Runtextend {
+ literalIndex := indexOfLiteralAfterLoop(r, literal, searchStart)
+ if literalIndex < 0 {
+ r.Runtextpos = r.Runtextend
+ return false
+ }
+
+ start := literalIndex
+ for start > r.Runtextpos && literal.LoopNode.Set.CharIn(r.Runtext[start-1]) {
+ start--
+ }
+ if hasRequiredLengthAt(r, start) {
+ r.Runtextpos = start
+ return true
+ }
+ searchStart = literalIndex + 1
+ }
+
+ r.Runtextpos = r.Runtextend
+ return false
+}
+
+func findRequiredLandmarkChainLeftToRight(r *Runner, chain *syntax.RequiredLandmarkChain) bool {
+ if chain == nil || chain.LeadingLoopSet == nil || len(chain.Landmarks) == 0 {
+ return false
+ }
+
+ for searchStart := r.Runtextpos; searchStart <= latestPossibleStart(r); {
+ first, ok := findNextRequiredLandmarkRunes(r.Runtext, searchStart, r.Runtextend, chain.Landmarks[0])
+ if !ok {
+ r.Runtextpos = r.Runtextend
+ return false
+ }
+
+ nextStart := first.End
+ for i := 1; i < len(chain.Landmarks); i++ {
+ landmark, ok := findNextRequiredLandmarkRunes(r.Runtext, nextStart, r.Runtextend, chain.Landmarks[i])
+ if !ok {
+ r.Runtextpos = r.Runtextend
+ return false
+ }
+ nextStart = landmark.End
+ }
+
+ candidate := first.Start
+ if candidate < r.Runtextpos {
+ candidate = r.Runtextpos
+ }
+ for candidate > r.Runtextpos && chain.LeadingLoopSet.CharIn(r.Runtext[candidate-1]) {
+ candidate--
+ }
+ if hasRequiredLengthAt(r, candidate) {
+ r.Runtextpos = candidate
+ return true
+ }
+
+ searchStart = first.CoreStart + 1
+ }
+
+ r.Runtextpos = r.Runtextend
+ return false
+}
+
+type requiredLandmarkMatch struct {
+ Start int
+ CoreStart int
+ End int
+}
+
+func findNextRequiredLandmarkRunes(input []rune, startAt, endAt int, landmark syntax.RequiredLandmark) (requiredLandmarkMatch, bool) {
+ for i := startAt; i < endAt; i++ {
+ for _, alt := range landmark.Alternatives {
+ if match, ok := requiredLandmarkAlternativeMatch(input, i, endAt, alt); ok {
+ return match, true
+ }
+ }
+ }
+ return requiredLandmarkMatch{}, false
+}
+
+func requiredLandmarkAlternativeMatch(input []rune, start, endAt int, alt syntax.RequiredLandmarkAlternative) (requiredLandmarkMatch, bool) {
+ if alt.RequireWhitespaceBefore &&
+ (start == 0 || alt.LeadingWhitespaceSet == nil || !alt.LeadingWhitespaceSet.CharIn(input[start-1])) {
+ return requiredLandmarkMatch{}, false
+ }
+
+ var end int
+ if len(alt.Literal) > 0 {
+ if start+len(alt.Literal) > endAt || !helpers.StartsWith(input[start:], alt.Literal) {
+ return requiredLandmarkMatch{}, false
+ }
+ end = start + len(alt.Literal)
+ } else if alt.Set != nil && alt.MinRepeat > 0 {
+ end = start
+ maxRepeat := alt.MaxRepeat
+ if maxRepeat <= 0 {
+ maxRepeat = alt.MinRepeat
+ }
+ for end < endAt && end-start < maxRepeat && alt.Set.CharIn(input[end]) {
+ end++
+ }
+ if end-start < alt.MinRepeat {
+ return requiredLandmarkMatch{}, false
+ }
+ } else {
+ return requiredLandmarkMatch{}, false
+ }
+
+ if alt.RequireWhitespaceAfter &&
+ (end >= endAt || alt.TrailingWhitespaceSet == nil || !alt.TrailingWhitespaceSet.CharIn(input[end])) {
+ return requiredLandmarkMatch{}, false
+ }
+
+ matchStart := start
+ for matchStart > 0 && alt.LeadingWhitespaceSet != nil && alt.LeadingWhitespaceSet.CharIn(input[matchStart-1]) {
+ matchStart--
+ }
+ return requiredLandmarkMatch{Start: matchStart, CoreStart: start, End: end}, true
+}
+
+func indexOfLiteralAfterLoop(r *Runner, literal *syntax.LiteralAfterLoop, searchStart int) int {
+ switch {
+ case literal.String != "":
+ needle := []rune(literal.String)
+ if literal.StringIgnoreCase {
+ var offset int
+ if isASCIIString(literal.String) {
+ offset = helpers.IndexOfIgnoreCaseAscii(r.Runtext[searchStart:], needle)
+ } else {
+ offset = helpers.IndexOfIgnoreCase(r.Runtext[searchStart:], needle)
+ }
+ if offset >= 0 {
+ return searchStart + offset
+ }
+ } else if offset := helpers.IndexOf(r.Runtext[searchStart:], needle); offset >= 0 {
+ return searchStart + offset
+ }
+ case len(literal.Chars) > 0:
+ if offset := helpers.IndexOfAny(r.Runtext[searchStart:], literal.Chars); offset >= 0 {
+ return searchStart + offset
+ }
+ default:
+ if offset := helpers.IndexOfAny1(r.Runtext[searchStart:], literal.Char); offset >= 0 {
+ return searchStart + offset
+ }
+ }
+ return -1
+}
+
+func isASCIIRunes(in []rune) bool {
+ for _, ch := range in {
+ if ch > unicode.MaxASCII {
+ return false
+ }
+ }
+ return true
+}
+
+func indexOfSet(chars []rune, set syntax.FixedDistanceSet) int {
+ if len(set.Chars) > 0 && !set.Negated {
+ return helpers.IndexOfAny(chars, set.Chars)
+ }
+ if len(set.Chars) > 0 && set.Negated {
+ return helpers.IndexOfAnyExcept(chars, set.Chars)
+ }
+ if set.Range != nil {
+ if set.Negated {
+ return helpers.IndexOfAnyExceptInRange(chars, set.Range.First, set.Range.Last)
+ }
+ return helpers.IndexOfAnyInRange(chars, set.Range.First, set.Range.Last)
+ }
+ return helpers.IndexFunc(chars, func(ch rune) bool {
+ return charInFixedDistanceSet(set, ch)
+ })
+}
+
+func fixedDistanceSetsMatchAt(r *Runner, sets []syntax.FixedDistanceSet, start int) bool {
+ for _, set := range sets {
+ index := start + set.Distance
+ if index < 0 || index >= r.Runtextend || !charInFixedDistanceSet(set, r.Runtext[index]) {
+ return false
+ }
+ }
+ return true
+}
+
+func charInFixedDistanceSet(set syntax.FixedDistanceSet, ch rune) bool {
+ if len(set.Chars) > 0 {
+ found := slices.Contains(set.Chars, ch)
+ if set.Negated {
+ return !found
+ }
+ return found
+ }
+ if set.Range != nil {
+ found := ch >= set.Range.First && ch <= set.Range.Last
+ if set.Negated {
+ return !found
+ }
+ return found
+ }
+ return set.Set != nil && set.Set.CharIn(ch)
+}
+
+func latestPossibleStart(r *Runner) int {
+ if r.code == nil || r.code.FindOptimizations == nil {
+ return r.Runtextend
+ }
+ minRequiredLength := r.code.FindOptimizations.MinRequiredLength
+ if minRequiredLength <= 0 {
+ return r.Runtextend
+ }
+ return r.Runtextend - minRequiredLength
+}
+
+func hasRequiredLengthAt(r *Runner, start int) bool {
+ return start >= 0 && start <= latestPossibleStart(r)
+}
+
+func (r *Runner) initMatch(textInfo *matchText) {
+ // Use a hashtable'ed Match object if the capture numbers are sparse
+
+ if r.runmatch == nil {
+ if r.re.caps != nil {
+ r.runmatch = newMatchSparse(r.re, r.re.caps, r.re.capsize, textInfo, r.Runtextstart)
+ } else {
+ r.runmatch = newMatch(r.re, r.re.capsize, textInfo, r.Runtextstart)
+ }
+ } else {
+ r.runmatch.reset(textInfo, r.Runtextstart)
+ }
+
+ // note we test runcrawl, because it is the last one to be allocated
+ // If there is an alloc failure in the middle of the three allocations,
+ // we may still return to reuse this instance, and we want to behave
+ // as if the allocations didn't occur. (we used to test _trackcount != 0)
+
+ if r.runcrawl != nil {
+ r.Runtrackpos = len(r.runtrack)
+ r.Runstackpos = len(r.runstack)
+ r.runcrawlpos = len(r.runcrawl)
+ return
+ }
+
+ r.initTrackCount()
+
+ tracksize := r.runtrackcount * 8
+ stacksize := r.runtrackcount * 8
+
+ if tracksize < 64 {
+ tracksize = 64
+ }
+ if stacksize < 32 {
+ stacksize = 32
+ }
+
+ r.runtrack = make([]int, tracksize)
+ r.Runtrackpos = tracksize
+
+ r.runstack = make([]int, stacksize)
+ r.Runstackpos = stacksize
+
+ r.runcrawl = make([]int, 32)
+ r.runcrawlpos = 32
+}
+
+func (r *Runner) tidyMatch(quick bool) *Match {
+ if !quick {
+ match := r.runmatch
+
+ r.runmatch = nil
+
+ match.tidy(r.Runtextpos)
+ return match
+ } else {
+ // send back our match -- it's not leaving the package, so it's safe to not clean it up
+ // this reduces allocs for frequent calls to the "IsMatch" bool-only functions
+ m := r.runmatch
+ if m == nil {
+ return nil
+ }
+ m.textpos = r.Runtextpos
+ if m.matchcount[0] > 0 {
+ interval := m.matches[0]
+ // bytes indices aren't used so just use fast path
+ m.RuneIndex = interval[0]
+ m.RuneLength = interval[1]
+ }
+ return m
+ }
+}
+
+// Capture captures a subexpression. Note that the
+// capnum used here has already been mapped to a non-sparse
+// index (by the code generator RegexWriter).
+func (r *Runner) Capture(capnum, start, end int) {
+ if end < start {
+ T := end
+ end = start
+ start = T
+ }
+
+ r.crawl(capnum)
+ r.runmatch.addMatch(capnum, start, end-start)
+}
+
+// transferCapture captures a subexpression. Note that the
+// capnum used here has already been mapped to a non-sparse
+// index (by the code generator RegexWriter).
+func (r *Runner) transferCapture(capnum, uncapnum, start, end int) {
+ var start2, end2 int
+
+ // these are the two intervals that are cancelling each other
+
+ if end < start {
+ T := end
+ end = start
+ start = T
+ }
+
+ start2 = r.runmatch.matchIndex(uncapnum)
+ end2 = start2 + r.runmatch.matchLength(uncapnum)
+
+ // The new capture gets the innermost defined interval
+
+ if start >= end2 {
+ end = start
+ start = end2
+ } else if end <= start2 {
+ start = start2
+ } else {
+ if end > end2 {
+ end = end2
+ }
+ if start2 > start {
+ start = start2
+ }
+ }
+
+ r.crawl(uncapnum)
+ r.runmatch.balanceMatch(uncapnum)
+
+ if capnum != -1 {
+ r.crawl(capnum)
+ r.runmatch.addMatch(capnum, start, end-start)
+ }
+}
+
+// revert the last capture
+func (r *Runner) uncapture() {
+ capnum := r.popcrawl()
+ r.runmatch.removeMatch(capnum)
+}
+
+//debug
+
+func (r *Runner) dumpState() {
+ back := ""
+ if r.operator&syntax.Back != 0 {
+ back = " Back"
+ }
+ if r.operator&syntax.Back2 != 0 {
+ back += " Back2"
+ }
+ fmt.Printf("Text: %v\nTrack: %v\nStack: %v\n %s%s\n\n",
+ r.textposDescription(),
+ r.stackDescription(r.runtrack, r.Runtrackpos),
+ r.stackDescription(r.runstack, r.Runstackpos),
+ r.code.OpcodeDescription(r.codepos),
+ back)
+}
+
+func (r *Runner) stackDescription(a []int, index int) string {
+ buf := &bytes.Buffer{}
+
+ fmt.Fprintf(buf, "%v/%v", len(a)-index, len(a))
+ if buf.Len() < 8 {
+ buf.WriteString(strings.Repeat(" ", 8-buf.Len()))
+ }
+
+ buf.WriteRune('(')
+ for i := index; i < len(a); i++ {
+ if i > index {
+ buf.WriteRune(' ')
+ }
+
+ buf.WriteString(strconv.Itoa(a[i]))
+ }
+
+ buf.WriteRune(')')
+
+ return buf.String()
+}
+
+func (r *Runner) textposDescription() string {
+ buf := &bytes.Buffer{}
+
+ buf.WriteString(strconv.Itoa(r.Runtextpos))
+
+ if buf.Len() < 8 {
+ buf.WriteString(strings.Repeat(" ", 8-buf.Len()))
+ }
+
+ if r.Runtextpos > 0 {
+ buf.WriteString(syntax.CharDescription(r.Runtext[r.Runtextpos-1]))
+ } else {
+ buf.WriteRune('^')
+ }
+
+ buf.WriteRune('>')
+
+ for i := r.Runtextpos; i < r.Runtextend; i++ {
+ buf.WriteString(syntax.CharDescription(r.Runtext[i]))
+ }
+ if buf.Len() >= 64 {
+ buf.Truncate(61)
+ buf.WriteString("...")
+ } else {
+ buf.WriteRune('$')
+ }
+
+ return buf.String()
+}
+
+// decide whether the pos
+// at the specified index is a boundary or not. It's just not worth
+// emitting inline code for this logic.
+func (r *Runner) IsBoundary(index int) bool {
+ return (index > 0 && syntax.IsWordChar(r.Runtext[index-1])) !=
+ (index < r.Runtextend && syntax.IsWordChar(r.Runtext[index]))
+}
+
+func (r *Runner) IsECMABoundary(index int) bool {
+ return (index > 0 && syntax.IsECMAWordChar(r.Runtext[index-1])) !=
+ (index < r.Runtextend && syntax.IsECMAWordChar(r.Runtext[index]))
+}
+
+func (r *Runner) startTimeoutWatch() {
+ if r.ignoreTimeout {
+ return
+ }
+ r.deadline = makeDeadline(r.timeout)
+}
+
+func (r *Runner) CheckTimeout() error {
+ if r.ignoreTimeout || !r.deadline.reached() {
+ return nil
+ }
+
+ return fmt.Errorf("match timeout after %v on input `%v`", r.timeout, string(r.Runtext))
+}
+
+func (r *Runner) initTrackCount() {
+ if r.code != nil {
+ r.runtrackcount = r.code.TrackCount
+ }
+}
+
+// decodeString converts s to []rune using a shared size-classed buffer pool when
+// allowed by the regexp optimization settings. Pooled slices must be returned
+// after the runner is done with them.
+func (r *Runner) decodeString(s string) ([]rune, *[]rune) {
+ buf, pooled := pooledRuneBuffers.get(len(s), r.re.optimizations.MaxCachedRuneBufferLength)
+ n := 0
+ for _, ch := range s {
+ buf[n] = ch
+ n++
+ }
+ return buf[:n], pooled
+}
+
+func (r *Runner) decodeStringWithStart(s string, startAt int) (runes []rune, runeStart int, pooled *[]rune) {
+ buf, pooled := pooledRuneBuffers.get(len(s), r.re.optimizations.MaxCachedRuneBufferLength)
+ n := 0
+ runeStart = -1
+ for strIdx, ch := range s {
+ if startAt >= 0 && strIdx == startAt {
+ runeStart = n
+ }
+ buf[n] = ch
+ n++
+ }
+ if startAt >= 0 && startAt == len(s) {
+ runeStart = n
+ }
+ return buf[:n], runeStart, pooled
+}
+
+// getRunner returns a runner to use for matching re.
+func (re *Regexp) getRunner() *Runner {
+ if re.runnerPool == nil {
+ re.initCaches()
+ }
+ return re.runnerPool.Get().(*Runner)
+}
+
+// putRunner returns a runner to the re's pool cache.
+func (re *Regexp) putRunner(r *Runner) {
+ r.Runtext = nil
+ if r.runmatch != nil {
+ r.runmatch.text = nil
+ }
+ re.runnerPool.Put(r)
+}
+
+func (r *Runner) LastIndexOfRune(startIndex int, endIndex int, find rune) int {
+ for i := endIndex - 1; i >= startIndex; i-- {
+ if r.Runtext[i] == find {
+ return i
+ }
+ }
+ return -1
+}
+
+// Undo captures until it reaches the specified capture position
+func (r *Runner) UncaptureUntil(capturePos int) {
+ for r.Crawlpos() > capturePos {
+ r.uncapture()
+ }
+}
+
+func (r *Runner) StackPop() int {
+ //get it
+ val := r.runstack[r.Runstackpos]
+ // pop it
+ r.Runstackpos++
+ // return it
+ return val
+}
+
+func (r *Runner) StackPush(val int) {
+ // check if we need to size up stack
+ r.ensureStack(1)
+ r.Runstackpos--
+ r.runstack[r.Runstackpos] = val
+}
+func (r *Runner) StackPush2(val1, val2 int) {
+ // check if we need to size up stack
+ r.ensureStack(2)
+ r.Runstackpos--
+ r.runstack[r.Runstackpos] = val1
+ r.Runstackpos--
+ r.runstack[r.Runstackpos] = val2
+}
+func (r *Runner) StackPush3(val1, val2, val3 int) {
+ // check if we need to size up stack
+ r.ensureStack(3)
+ r.Runstackpos--
+ r.runstack[r.Runstackpos] = val1
+ r.Runstackpos--
+ r.runstack[r.Runstackpos] = val2
+ r.Runstackpos--
+ r.runstack[r.Runstackpos] = val3
+}
+func (r *Runner) StackPush4(val1, val2, val3, val4 int) {
+ // check if we need to size up stack
+ r.ensureStack(4)
+ r.Runstackpos--
+ r.runstack[r.Runstackpos] = val1
+ r.Runstackpos--
+ r.runstack[r.Runstackpos] = val2
+ r.Runstackpos--
+ r.runstack[r.Runstackpos] = val3
+ r.Runstackpos--
+ r.runstack[r.Runstackpos] = val4
+}
+func (r *Runner) StackPush5(val1, val2, val3, val4, val5 int) {
+ // check if we need to size up stack
+ r.ensureStack(5)
+ r.Runstackpos--
+ r.runstack[r.Runstackpos] = val1
+ r.Runstackpos--
+ r.runstack[r.Runstackpos] = val2
+ r.Runstackpos--
+ r.runstack[r.Runstackpos] = val3
+ r.Runstackpos--
+ r.runstack[r.Runstackpos] = val4
+ r.Runstackpos--
+ r.runstack[r.Runstackpos] = val5
+}
+func (r *Runner) StackPushN(vals ...int) {
+ // check if we need to size up stack
+ r.ensureStack(len(vals))
+ for _, val := range vals {
+ r.Runstackpos--
+ r.runstack[r.Runstackpos] = val
+ }
+}
+func (r *Runner) IsMatched(cap int) bool {
+ return r.runmatch.isMatched(cap)
+}
+func (r *Runner) MatchLength(cap int) int {
+ return r.runmatch.matchLength(cap)
+}
+func (r *Runner) MatchIndex(cap int) int {
+ return r.runmatch.matchIndex(cap)
+}
diff --git a/vendor/github.com/dlclark/regexp2/v2/split.go b/vendor/github.com/dlclark/regexp2/v2/split.go
new file mode 100644
index 0000000000..1dbe0dcd17
--- /dev/null
+++ b/vendor/github.com/dlclark/regexp2/v2/split.go
@@ -0,0 +1,67 @@
+package regexp2
+
+import (
+ "errors"
+ "math"
+)
+
+// Split splits the given input string using the pattern and returns
+// a slice of the parts. Count limits the number of matches to process.
+// If Count is -1, then it will process the input fully.
+// If Count is 0, returns nil. If Count is 1, returns the original input.
+// The only expected error is a Timeout, if it's set.
+//
+// If capturing parentheses are used in the Regex expression, any captured
+// text is included in the resulting string array
+// For example, a pattern of "-" Split("a-b") will return ["a", "b"]
+// but a pattern with "(-)" Split ("a-b") will return ["a", "-", "b"]
+func (re *Regexp) Split(input string, count int) ([]string, error) {
+ if count < -1 {
+ return nil, errors.New("count too small")
+ }
+ if count == 0 {
+ return nil, nil
+ }
+ if count == 1 {
+ return []string{input}, nil
+ }
+ if count == -1 {
+ // no limit
+ count = math.MaxInt
+ }
+
+ // iterate through the matches
+ priorIndex := 0
+ var retVal []string
+ var txt []rune
+
+ m, err := re.FindStringMatch(input)
+
+ for ; m != nil && count > 0; m, err = re.FindNextMatch(m) {
+ txt = m.text.runes
+ // if we have an m, we don't have an err
+ // append our match
+ retVal = append(retVal, string(txt[priorIndex:m.RuneIndex]))
+ // append any capture groups, skipping group 0
+ gs := m.Groups()
+ for i := 1; i < len(gs); i++ {
+ retVal = append(retVal, gs[i].String())
+ }
+ priorIndex = m.RuneIndex + m.RuneLength
+ count--
+ }
+
+ if err != nil {
+ return nil, err
+ }
+
+ if txt == nil {
+ // we never matched, return the original string
+ return []string{input}, nil
+ }
+
+ // append our remainder
+ retVal = append(retVal, string(txt[priorIndex:]))
+
+ return retVal, nil
+}
diff --git a/vendor/github.com/dlclark/regexp2/v2/stringprefixfilter.go b/vendor/github.com/dlclark/regexp2/v2/stringprefixfilter.go
new file mode 100644
index 0000000000..fe9cb6ad78
--- /dev/null
+++ b/vendor/github.com/dlclark/regexp2/v2/stringprefixfilter.go
@@ -0,0 +1,375 @@
+package regexp2
+
+import (
+ "errors"
+ "strings"
+ "unicode/utf8"
+
+ "github.com/dlclark/regexp2/v2/helpers"
+ "github.com/dlclark/regexp2/v2/syntax"
+)
+
+const maxStringFilterLiteralLen = 8
+
+var (
+ errStringStartAtTooLarge = errors.New("startAt must be less than the length of the input string")
+ errStringStartAtNotRuneBoundary = errors.New("startAt must align to the start of a valid rune in the input string")
+)
+
+// StringPrefixFilter optionally searches string input before the engine decodes it
+// to runes. It returns a byte index for a candidate match start, or ok=false if
+// the regex cannot match. The filter must be conservative: false positives are
+// allowed, false negatives are not.
+type StringPrefixFilter func(input string, startAt int) (candidateByteIndex int, ok bool)
+
+func newStringPrefixFilter(code *syntax.Code) StringPrefixFilter {
+ if code == nil || code.RightToLeft || code.FindOptimizations == nil {
+ return nil
+ }
+
+ opts := code.FindOptimizations
+ minRequiredLength := opts.MinRequiredLength
+
+ switch opts.FindMode {
+ case syntax.LeadingString_LeftToRight:
+ return stringIndexPrefixFilter(opts.LeadingPrefix, false, minRequiredLength)
+ case syntax.LeadingString_OrdinalIgnoreCase_LeftToRight:
+ return stringIndexPrefixFilter(opts.LeadingPrefix, true, minRequiredLength)
+ case syntax.LeadingStrings_LeftToRight:
+ return stringIndexPrefixesFilter(opts.LeadingPrefixes, false, minRequiredLength)
+ case syntax.LeadingStrings_OrdinalIgnoreCase_LeftToRight:
+ return stringIndexPrefixesFilter(opts.LeadingPrefixes, true, minRequiredLength)
+ case syntax.FixedDistanceChar_LeftToRight:
+ return stringFixedDistanceCharFilter(opts.FixedDistanceLiteral.C, opts.FixedDistanceLiteral.Distance, minRequiredLength)
+ case syntax.FixedDistanceString_LeftToRight:
+ return stringFixedDistanceStringFilter(opts.FixedDistanceLiteral.S, opts.FixedDistanceLiteral.Distance, minRequiredLength)
+ case syntax.LiteralAfterLoop_LeftToRight:
+ return stringLiteralAfterLoopFilter(opts.LiteralAfterLoop, minRequiredLength)
+ default:
+ return nil
+ }
+}
+
+func stringIndexPrefixFilter(prefix string, ignoreCase bool, minRequiredLength int) StringPrefixFilter {
+ if prefix == "" {
+ return nil
+ }
+ if ignoreCase && !isASCIIString(prefix) {
+ return nil
+ }
+
+ return func(input string, startAt int) (candidateByteIndex int, ok bool) {
+ if !hasMinRequiredBytes(input, startAt, minRequiredLength) {
+ return 0, false
+ }
+
+ var offset int
+ if ignoreCase {
+ offset = helpers.IndexStringIgnoreCaseASCII(input[startAt:], prefix)
+ } else {
+ offset = strings.Index(input[startAt:], prefix)
+ }
+ if offset < 0 {
+ return 0, false
+ }
+ return startAt + offset, true
+ }
+}
+
+func stringIndexPrefixesFilter(prefixes []string, ignoreCase bool, minRequiredLength int) StringPrefixFilter {
+ if len(prefixes) == 0 {
+ return nil
+ }
+ if ignoreCase {
+ for _, prefix := range prefixes {
+ if !isASCIIString(prefix) {
+ return nil
+ }
+ }
+ }
+
+ if filter, ok := compileASCIIStringSetPrefixFilter(prefixes, ignoreCase, minRequiredLength); ok {
+ return filter.index
+ }
+
+ return func(input string, startAt int) (candidateByteIndex int, ok bool) {
+ return indexAnyPrefixFallback(input, startAt, prefixes, ignoreCase, minRequiredLength)
+ }
+}
+
+func indexAnyPrefixFallback(input string, startAt int, prefixes []string, ignoreCase bool, minRequiredLength int) (candidateByteIndex int, ok bool) {
+ if !hasMinRequiredBytes(input, startAt, minRequiredLength) {
+ return 0, false
+ }
+
+ best := -1
+ remaining := input[startAt:]
+ for _, prefix := range prefixes {
+ var offset int
+ if ignoreCase {
+ offset = helpers.IndexStringIgnoreCaseASCII(remaining, prefix)
+ } else {
+ offset = strings.Index(remaining, prefix)
+ }
+ if offset >= 0 && (best < 0 || offset < best) {
+ best = offset
+ }
+ }
+ if best < 0 {
+ return 0, false
+ }
+ return startAt + best, true
+}
+
+type asciiStringSetPrefixFilter struct {
+ firstChars string
+ prefixesByFirst [256][]string
+ minRequiredBytes int
+}
+
+// compileASCIIStringSetPrefixFilter builds a byte-oriented multi-prefix scanner
+// for the narrow shape where it beats running strings.Index once per prefix:
+// case-sensitive ASCII prefixes with at least two prefixes sharing a first byte.
+// It indexes possible first bytes with strings.IndexAny, then verifies only the
+// bucket for the byte found. Other shapes fall back to the old implementation.
+func compileASCIIStringSetPrefixFilter(prefixes []string, ignoreCase bool, minRequiredLength int) (*asciiStringSetPrefixFilter, bool) {
+ if ignoreCase {
+ return nil, false
+ }
+
+ filter := &asciiStringSetPrefixFilter{
+ minRequiredBytes: minRequiredLength,
+ }
+ var firstChars [256]bool
+ var hasSharedFirst bool
+ for _, prefix := range prefixes {
+ if prefix == "" || !isASCIIString(prefix) {
+ return nil, false
+ }
+
+ first := prefix[0]
+ filter.prefixesByFirst[first] = append(filter.prefixesByFirst[first], prefix)
+ if len(filter.prefixesByFirst[first]) > 1 {
+ hasSharedFirst = true
+ }
+ firstChars[first] = true
+ }
+
+ if !hasSharedFirst {
+ return nil, false
+ }
+
+ firstBytes := make([]byte, 0, len(prefixes)*2)
+ for i, ok := range firstChars {
+ if ok {
+ firstBytes = append(firstBytes, byte(i))
+ }
+ }
+ if len(firstBytes) == 0 {
+ return nil, false
+ }
+ filter.firstChars = string(firstBytes)
+ return filter, true
+}
+
+func (f *asciiStringSetPrefixFilter) index(input string, startAt int) (candidateByteIndex int, ok bool) {
+ if !hasMinRequiredBytes(input, startAt, f.minRequiredBytes) {
+ return 0, false
+ }
+
+ for searchAt := startAt; searchAt < len(input); {
+ offset := strings.IndexAny(input[searchAt:], f.firstChars)
+ if offset < 0 {
+ return 0, false
+ }
+ i := searchAt + offset
+ first := input[i]
+ for _, prefix := range f.prefixesByFirst[first] {
+ if len(input)-i >= len(prefix) && strings.HasPrefix(input[i:], prefix) {
+ return i, true
+ }
+ }
+ searchAt = i + 1
+ }
+ return 0, false
+}
+
+func stringFixedDistanceCharFilter(ch rune, distance, minRequiredLength int) StringPrefixFilter {
+ if distance < 0 {
+ return nil
+ }
+
+ return func(input string, startAt int) (candidateByteIndex int, ok bool) {
+ if !hasMinRequiredBytes(input, startAt, minRequiredLength) {
+ return 0, false
+ }
+
+ searchAt := startAt
+ for {
+ offset := strings.IndexRune(input[searchAt:], ch)
+ if offset < 0 {
+ return 0, false
+ }
+ byteIndex := searchAt + offset
+ candidateByteIndex, ok := stringFixedDistanceCandidateStart(input, startAt, byteIndex, distance)
+ if ok && hasMinRequiredBytes(input, candidateByteIndex, minRequiredLength) {
+ return candidateByteIndex, true
+ }
+ if ok {
+ return 0, false
+ }
+ _, size := utf8.DecodeRuneInString(input[byteIndex:])
+ if size == 0 {
+ return 0, false
+ }
+ searchAt = byteIndex + size
+ }
+ }
+}
+
+func stringFixedDistanceStringFilter(literal string, distance, minRequiredLength int) StringPrefixFilter {
+ if literal == "" || distance < 0 || len(literal) > maxStringFilterLiteralLen {
+ return nil
+ }
+
+ return func(input string, startAt int) (candidateByteIndex int, ok bool) {
+ if !hasMinRequiredBytes(input, startAt, minRequiredLength) {
+ return 0, false
+ }
+
+ searchAt := startAt
+ for searchAt <= len(input)-len(literal) {
+ offset := strings.Index(input[searchAt:], literal)
+ if offset < 0 {
+ return 0, false
+ }
+ literalIndex := searchAt + offset
+ candidateByteIndex, ok := stringFixedDistanceCandidateStart(input, startAt, literalIndex, distance)
+ if ok && hasMinRequiredBytes(input, candidateByteIndex, minRequiredLength) {
+ return candidateByteIndex, true
+ }
+ if ok {
+ return 0, false
+ }
+ searchAt = literalIndex + 1
+ }
+ return 0, false
+ }
+}
+
+func stringLiteralAfterLoopFilter(literal *syntax.LiteralAfterLoop, minRequiredLength int) StringPrefixFilter {
+ if literal == nil || literal.LoopNode == nil || literal.LoopNode.Set == nil {
+ return nil
+ }
+ if literal.StringIgnoreCase && (literal.String == "" || !isASCIIString(literal.String)) {
+ return nil
+ }
+
+ return func(input string, startAt int) (candidateByteIndex int, ok bool) {
+ if !hasMinRequiredBytes(input, startAt, minRequiredLength) {
+ return 0, false
+ }
+ if !stringHasLiteralAfterLoop(input, startAt, literal) {
+ return 0, false
+ }
+ return startAt, true
+ }
+}
+
+func stringHasLiteralAfterLoop(input string, searchAt int, literal *syntax.LiteralAfterLoop) bool {
+ switch {
+ case literal.String != "":
+ if literal.StringIgnoreCase {
+ return helpers.IndexStringIgnoreCaseASCII(input[searchAt:], literal.String) >= 0
+ }
+ return strings.Contains(input[searchAt:], literal.String)
+ case len(literal.Chars) > 0:
+ needle := string(literal.Chars)
+ return strings.ContainsAny(input[searchAt:], needle)
+ default:
+ return strings.ContainsRune(input[searchAt:], literal.Char)
+ }
+}
+
+func stringFixedDistanceCandidateStart(input string, startAt, byteIndex, distance int) (int, bool) {
+ candidateByteIndex := byteIndex
+ for i := 0; i < distance; i++ {
+ if candidateByteIndex <= startAt {
+ return 0, false
+ }
+ _, size := utf8.DecodeLastRuneInString(input[:candidateByteIndex])
+ if size == 0 {
+ return 0, false
+ }
+ candidateByteIndex -= size
+ }
+ return candidateByteIndex, true
+}
+
+func (re *Regexp) findStringPrefixCandidate(input string, startAt int) (candidateByteIndex int, ok bool) {
+ if re.stringPrefixFilter == nil || re.RightToLeft() {
+ return startAt, true
+ }
+ candidateByteIndex, ok = re.stringPrefixFilter(input, startAt)
+ if !ok {
+ return 0, false
+ }
+ if candidateByteIndex < startAt || candidateByteIndex > len(input) || !isStringRuneBoundary(input, candidateByteIndex) {
+ return startAt, true
+ }
+ return candidateByteIndex, true
+}
+
+func (re *Regexp) findStringMatchStart(input string, startAt int) (candidateByteIndex int, ok bool, err error) {
+ if startAt > len(input) {
+ return 0, false, errStringStartAtTooLarge
+ }
+ if startAt >= 0 && !isStringRuneBoundary(input, startAt) {
+ return 0, false, errStringStartAtNotRuneBoundary
+ }
+
+ if startAt < 0 {
+ if re.RightToLeft() {
+ startAt = len(input)
+ } else {
+ startAt = 0
+ }
+ }
+
+ candidateByteIndex, ok = re.findStringPrefixCandidate(input, startAt)
+ return candidateByteIndex, ok, nil
+}
+
+func hasMinRequiredBytes(input string, startAt, minRequiredLength int) bool {
+ if startAt < 0 || startAt > len(input) {
+ return false
+ }
+ return minRequiredLength <= 0 || len(input)-startAt >= minRequiredLength
+}
+
+func isStringRuneBoundary(s string, index int) bool {
+ if index == 0 || index == len(s) {
+ return true
+ }
+ if index < 0 || index > len(s) {
+ return false
+ }
+ for strIdx := range s {
+ if strIdx == index {
+ return true
+ }
+ if strIdx > index {
+ return false
+ }
+ }
+ return false
+}
+
+func isASCIIString(s string) bool {
+ for i := 0; i < len(s); i++ {
+ if s[i] >= utf8.RuneSelf {
+ return false
+ }
+ }
+ return true
+}
diff --git a/vendor/github.com/dlclark/regexp2/v2/syntax/charclass.go b/vendor/github.com/dlclark/regexp2/v2/syntax/charclass.go
new file mode 100644
index 0000000000..9dc4b630ea
--- /dev/null
+++ b/vendor/github.com/dlclark/regexp2/v2/syntax/charclass.go
@@ -0,0 +1,1507 @@
+package syntax
+
+import (
+ "bytes"
+ "encoding/binary"
+ "fmt"
+ "slices"
+ "sort"
+ "strings"
+ "unicode"
+ "unicode/utf8"
+)
+
+// CharSet combines start-end rune ranges and unicode categories representing a set of characters
+type CharSet struct {
+ ranges []SingleRange
+ categories []Category
+ sub *CharSet //optional subtractor
+ negate bool
+ anything bool
+
+ ascii *asciiBitmap
+}
+
+type asciiBitmap struct {
+ bits [2]uint64
+}
+
+type Category struct {
+ Negate bool
+ Cat string
+}
+
+type SingleRange struct {
+ First rune
+ Last rune
+}
+
+const (
+ SpaceCategoryText = " "
+ WordCategoryText = "W"
+)
+
+var (
+ ecmaSpace = []rune{0x0009, 0x000e, 0x0020, 0x0021, 0x00a0, 0x00a1, 0x1680, 0x1681, 0x2000, 0x200b, 0x2028, 0x202a, 0x202f, 0x2030, 0x205f, 0x2060, 0x3000, 0x3001, 0xfeff, 0xff00}
+ ecmaWord = []rune{0x0030, 0x003a, 0x0041, 0x005b, 0x005f, 0x0060, 0x0061, 0x007b}
+ ecmaDigit = []rune{0x0030, 0x003a}
+
+ re2Space = []rune{0x0009, 0x000b, 0x000c, 0x000e, 0x0020, 0x0021}
+)
+
+var (
+ AnyClass = getCharSetFromOldString([]rune{0}, false)
+ ECMAAnyClass = getCharSetFromOldString([]rune{0, 0x000a, 0x000b, 0x000d, 0x000e}, false)
+ NoneClass = getCharSetFromOldString(nil, false)
+ ECMAWordClass = getCharSetFromOldString(ecmaWord, false)
+ NotECMAWordClass = getCharSetFromOldString(ecmaWord, true)
+ ECMASpaceClass = getCharSetFromOldString(ecmaSpace, false)
+ NotECMASpaceClass = getCharSetFromOldString(ecmaSpace, true)
+ ECMADigitClass = getCharSetFromOldString(ecmaDigit, false)
+ NotECMADigitClass = getCharSetFromOldString(ecmaDigit, true)
+
+ WordClass = getCharSetFromCategoryString(false, false, WordCategoryText)
+ NotWordClass = getCharSetFromCategoryString(true, false, WordCategoryText)
+ SpaceClass = getCharSetFromCategoryString(false, false, SpaceCategoryText)
+ NotSpaceClass = getCharSetFromCategoryString(true, false, SpaceCategoryText)
+ DigitClass = getCharSetFromCategoryString(false, false, "Nd")
+ NotDigitClass = getCharSetFromCategoryString(false, true, "Nd")
+
+ RE2SpaceClass = getCharSetFromOldString(re2Space, false)
+ NotRE2SpaceClass = getCharSetFromOldString(re2Space, true)
+
+ NotNewLineClass = getCharSetFromOldString([]rune{0x0a, 0x0b}, true)
+)
+
+var unicodeCategories = func() map[string]*unicode.RangeTable {
+ retVal := make(map[string]*unicode.RangeTable)
+ for k, v := range unicode.Scripts {
+ retVal[k] = v
+ }
+ for k, v := range unicode.Categories {
+ retVal[k] = v
+ }
+ // aliases are just pointers to the original keys
+ for k, v := range unicode.CategoryAliases {
+ retVal[k] = unicode.Categories[v]
+ }
+ for k, v := range unicode.Properties {
+ retVal[k] = v
+ }
+ for k, v := range unicodeAliasCategories {
+ retVal[k] = v
+ }
+ return retVal
+}()
+
+func getCharSetFromCategoryString(negateSet bool, negateCat bool, cats ...string) func() *CharSet {
+ if negateCat && negateSet {
+ panic("BUG! You should only negate the set OR the category in a constant setup, but not both")
+ }
+
+ c := CharSet{negate: negateSet}
+
+ c.categories = make([]Category, len(cats))
+ for i, cat := range cats {
+ c.categories[i] = Category{Cat: cat, Negate: negateCat}
+ }
+ return func() *CharSet {
+ //make a copy each time
+ local := c
+ //return that address
+ return &local
+ }
+}
+
+func getCharSetFromOldString(setText []rune, negate bool) func() *CharSet {
+ c := CharSet{}
+ if len(setText) > 0 {
+ fillFirst := false
+ l := len(setText)
+ if negate {
+ if setText[0] == 0 {
+ setText = setText[1:]
+ } else {
+ l++
+ fillFirst = true
+ }
+ }
+
+ if l%2 == 0 {
+ c.ranges = make([]SingleRange, l/2)
+ } else {
+ c.ranges = make([]SingleRange, l/2+1)
+ }
+
+ first := true
+ if fillFirst {
+ c.ranges[0] = SingleRange{First: 0}
+ first = false
+ }
+
+ i := 0
+ for _, r := range setText {
+ if first {
+ // lower bound in a new range
+ c.ranges[i] = SingleRange{First: r}
+ first = false
+ } else {
+ c.ranges[i].Last = r - 1
+ i++
+ first = true
+ }
+ }
+ if !first {
+ c.ranges[i].Last = utf8.MaxRune
+ }
+ if len(c.ranges) == 1 && c.ranges[0].First == 0 && c.ranges[0].Last >= unicode.MaxRune {
+ // this is anything...or nothing
+ c.anything = !negate
+ }
+ }
+
+ return func() *CharSet {
+ local := c
+ return &local
+ }
+}
+
+// Copy makes a deep copy to prevent accidental mutation of a set
+func (c CharSet) Copy() CharSet {
+ ret := CharSet{
+ anything: c.anything,
+ negate: c.negate,
+ }
+
+ ret.ranges = append(ret.ranges, c.ranges...)
+ ret.categories = append(ret.categories, c.categories...)
+
+ if c.sub != nil {
+ sub := c.sub.Copy()
+ ret.sub = &sub
+ }
+
+ return ret
+}
+
+// gets a human-readable description for a set string
+func (c CharSet) String() string {
+ buf := &bytes.Buffer{}
+ buf.WriteRune('[')
+
+ if c.IsNegated() {
+ buf.WriteRune('^')
+ }
+
+ for _, r := range c.ranges {
+
+ buf.WriteString(CharDescription(r.First))
+ if r.First != r.Last {
+ if r.Last-r.First != 1 {
+ //groups that are 1 char apart skip the dash
+ buf.WriteRune('-')
+ }
+ buf.WriteString(CharDescription(r.Last))
+ }
+ }
+
+ for _, c := range c.categories {
+ buf.WriteString(c.String())
+ }
+
+ if c.sub != nil {
+ buf.WriteRune('-')
+ buf.WriteString(c.sub.String())
+ }
+
+ buf.WriteRune(']')
+
+ return buf.String()
+}
+
+func b2i(b bool) byte {
+ if b {
+ return 1
+ }
+ return 0
+}
+
+// mapHashFill converts a charset into a buffer for use in maps
+func (c CharSet) mapHashFill(buf *bytes.Buffer) {
+ buf.WriteByte(b2i(c.negate) + b2i(c.anything)*2)
+
+ _ = binary.Write(buf, binary.LittleEndian, int32(len(c.ranges)))
+ _ = binary.Write(buf, binary.LittleEndian, int32(len(c.categories)))
+ for _, r := range c.ranges {
+ buf.WriteRune(r.First)
+ buf.WriteRune(r.Last)
+ }
+ for _, ct := range c.categories {
+ // write the length of the cat and indicate if it's negated
+ if ct.Negate {
+ _ = binary.Write(buf, binary.LittleEndian, int8(-1*len(ct.Cat)))
+ } else {
+ _ = binary.Write(buf, binary.LittleEndian, int8(len(ct.Cat)))
+ }
+ buf.WriteString(ct.Cat)
+ }
+
+ if c.sub != nil {
+ c.sub.mapHashFill(buf)
+ }
+}
+
+func NewCharSetRuntime(buf string) CharSet {
+ retVal := CharSet{}
+ b := bytes.NewBufferString(buf)
+ val, _ := b.ReadByte()
+ //1s bit == negate, 2s bit == anything
+ retVal.negate = (val&0x1 == 0x1)
+ retVal.anything = (val&0x2 == 0x2)
+ var lenRanges, lenCats int32
+ _ = binary.Read(b, binary.LittleEndian, &lenRanges)
+ _ = binary.Read(b, binary.LittleEndian, &lenCats)
+
+ retVal.ranges = make([]SingleRange, lenRanges)
+ for i := 0; i < int(lenRanges); i++ {
+ r := SingleRange{}
+ r.First, _, _ = b.ReadRune()
+ r.Last, _, _ = b.ReadRune()
+ retVal.ranges[i] = r
+ }
+
+ retVal.categories = make([]Category, lenCats)
+ for i := 0; i < int(lenCats); i++ {
+ var lenCat int8
+ c := Category{}
+ _ = binary.Read(b, binary.LittleEndian, &lenCat)
+ if lenCat < 0 {
+ c.Negate = true
+ lenCat *= -1
+ }
+ c.Cat = string(b.Next(int(lenCat)))
+ retVal.categories[i] = c
+ }
+
+ //sub
+ if b.Len() > 0 {
+ sub := NewCharSetRuntime(b.String())
+ retVal.sub = &sub
+ }
+
+ return retVal
+}
+
+// CharIn returns true if the rune is in our character set (either ranges or categories).
+// It handles negations and subtracted sub-charsets.
+func (c CharSet) CharIn(ch rune) bool {
+ if ch >= 0 && ch < 128 && c.ascii != nil {
+ return (c.ascii.bits[ch/64] & (1 << (uint(ch) % 64))) != 0
+ }
+ return c.charInSlow(ch)
+}
+
+func (c CharSet) charInSlow(ch rune) bool {
+ val := false
+ // in s && !s.subtracted
+
+ //check ranges -- binary search for sets with many ranges, linear for small sets
+ n := len(c.ranges)
+ if n > 0 {
+ if n <= 4 {
+ for _, r := range c.ranges {
+ if ch < r.First {
+ break
+ }
+ if ch <= r.Last {
+ val = true
+ break
+ }
+ }
+ } else {
+ lo, hi := 0, n
+ for lo < hi {
+ mid := int(uint(lo+hi) >> 1)
+ if c.ranges[mid].First <= ch {
+ lo = mid + 1
+ } else {
+ hi = mid
+ }
+ }
+ if lo > 0 && ch <= c.ranges[lo-1].Last {
+ val = true
+ }
+ }
+ }
+
+ //check categories if we haven't already found a range
+ if !val && len(c.categories) > 0 {
+ val = c.charInCategories(ch)
+ }
+
+ // negate the whole char set
+ if c.negate {
+ val = !val
+ }
+
+ // get subtracted recurse
+ if val && c.sub != nil {
+ val = !c.sub.CharIn(ch)
+ }
+
+ //log.Printf("Char '%v' in %v == %v", string(ch), c.String(), val)
+ return val
+}
+
+func (c *CharSet) prepareASCIIBitmap() {
+ if c == nil || c.ascii != nil {
+ return
+ }
+ if c.sub != nil {
+ c.sub.prepareASCIIBitmap()
+ }
+ bm := &asciiBitmap{}
+ for i := range rune(128) {
+ if c.charInSlow(i) {
+ bm.bits[i/64] |= 1 << (uint(i) % 64)
+ }
+ }
+ c.ascii = bm
+}
+
+func (c *CharSet) charInCategories(ch rune) bool {
+ for _, ct := range c.categories {
+ // special categories...then unicode
+ if ct.Cat == SpaceCategoryText {
+ if unicode.IsSpace(ch) {
+ // we found a space so we're done
+ // negate means this is a "bad" thing
+ return !ct.Negate
+ } else if ct.Negate {
+ return true
+ }
+ } else if ct.Cat == WordCategoryText {
+ if IsWordChar(ch) {
+ return !ct.Negate
+ } else if ct.Negate {
+ return true
+ }
+ } else if unicode.Is(unicodeCategories[ct.Cat], ch) {
+ // if we're in this unicode category then we're done
+ // if negate=true on this category then we "failed" our test
+ // otherwise we're good that we found it
+ return !ct.Negate
+ } else if ct.Negate {
+ return true
+ }
+ }
+ return false
+}
+
+func (c Category) String() string {
+ switch c.Cat {
+ case SpaceCategoryText:
+ if c.Negate {
+ return "\\S"
+ }
+ return "\\s"
+ case WordCategoryText:
+ if c.Negate {
+ return "\\W"
+ }
+ return "\\w"
+ }
+ if _, ok := unicodeCategories[c.Cat]; ok {
+
+ if c.Negate {
+ return "\\P{" + c.Cat + "}"
+ }
+ return "\\p{" + c.Cat + "}"
+ }
+ return "Unknown category: " + c.Cat
+}
+
+// CharDescription Produces a human-readable description for a single character.
+func CharDescription(ch rune) string {
+ /*if ch == '\\' {
+ return "\\\\"
+ }
+
+ if ch > ' ' && ch <= '~' {
+ return string(ch)
+ } else if ch == '\n' {
+ return "\\n"
+ } else if ch == ' ' {
+ return "\\ "
+ }*/
+
+ b := &bytes.Buffer{}
+ escape(b, ch, false) //fmt.Sprintf("%U", ch)
+ return b.String()
+}
+
+// According to UTS#18 Unicode Regular Expressions (http://www.unicode.org/reports/tr18/)
+// RL 1.4 Simple Word Boundaries The class of includes all Alphabetic
+// values from the Unicode character database, from UnicodeData.txt [UData], plus the U+200C
+// ZERO WIDTH NON-JOINER and U+200D ZERO WIDTH JOINER.
+func IsWordChar(r rune) bool {
+ //"L", "Mn", "Nd", "Pc"
+ return unicode.In(r,
+ unicode.Categories["L"], unicode.Categories["Mn"],
+ unicode.Categories["Nd"], unicode.Categories["Pc"]) || r == '\u200D' || r == '\u200C'
+ //return 'A' <= r && r <= 'Z' || 'a' <= r && r <= 'z' || '0' <= r && r <= '9' || r == '_'
+}
+
+func IsECMAWordChar(r rune) bool {
+ return unicode.In(r,
+ unicode.Categories["L"], unicode.Categories["Mn"],
+ unicode.Categories["Nd"], unicode.Categories["Pc"])
+
+ //return 'A' <= r && r <= 'Z' || 'a' <= r && r <= 'z' || '0' <= r && r <= '9' || r == '_'
+}
+
+func IsECMAIdentifierStartChar(r rune) bool {
+ return r == '$' || r == '_' || unicode.In(r, unicode.L, unicode.Nl, unicode.Other_ID_Start)
+}
+
+func IsECMAIdentifierChar(r rune) bool {
+ return IsECMAIdentifierStartChar(r) || r == '\u200C' || r == '\u200D' ||
+ unicode.In(r, unicode.Mn, unicode.Mc, unicode.Nd, unicode.Pc, unicode.Other_ID_Continue)
+}
+
+// SingletonChar will return the char from the first range without validation.
+// It assumes you have checked for IsSingleton or IsSingletonInverse and will panic given bad input
+func (c CharSet) SingletonChar() rune {
+ return c.ranges[0].First
+}
+
+func (c CharSet) IsSingleton() bool {
+ return !c.negate && //negated is multiple chars
+ len(c.categories) == 0 && len(c.ranges) == 1 && // multiple ranges and unicode classes represent multiple chars
+ c.sub == nil && // subtraction means we've got multiple chars
+ c.ranges[0].First == c.ranges[0].Last // first and last equal means we're just 1 char
+}
+
+func (c CharSet) IsSingletonInverse() bool {
+ return c.negate && //same as above, but requires negated
+ len(c.categories) == 0 && len(c.ranges) == 1 && // multiple ranges and unicode classes represent multiple chars
+ c.sub == nil && // subtraction means we've got multiple chars
+ c.ranges[0].First == c.ranges[0].Last // first and last equal means we're just 1 char
+}
+
+func (c CharSet) IsMergeable() bool {
+ return !c.IsNegated() && !c.HasSubtraction()
+}
+
+func (c CharSet) IsNegated() bool {
+ return c.negate
+}
+
+func (c CharSet) HasSubtraction() bool {
+ return c.sub != nil
+}
+
+func (c CharSet) IsEmpty() bool {
+ return len(c.ranges) == 0 && len(c.categories) == 0 && c.sub == nil
+}
+
+func (c CharSet) IsAnything() bool {
+ return c.anything
+}
+
+func (c *CharSet) addDigit(ecma, negate bool) {
+ if ecma {
+ if negate {
+ c.addRanges(NotECMADigitClass().ranges)
+ } else {
+ c.addRanges(ECMADigitClass().ranges)
+ }
+ } else {
+ c.addCategories(Category{Cat: "Nd", Negate: negate})
+ }
+}
+
+func (c *CharSet) addChar(ch rune) {
+ c.addRange(ch, ch)
+}
+
+func (c *CharSet) addSpace(ecma, re2, negate bool) {
+ if ecma {
+ if negate {
+ c.addRanges(NotECMASpaceClass().ranges)
+ } else {
+ c.addRanges(ECMASpaceClass().ranges)
+ }
+ } else if re2 {
+ if negate {
+ c.addRanges(NotRE2SpaceClass().ranges)
+ } else {
+ c.addRanges(RE2SpaceClass().ranges)
+ }
+ } else {
+ c.addCategories(Category{Cat: SpaceCategoryText, Negate: negate})
+ }
+}
+
+func (c *CharSet) addWord(ecma, negate bool) {
+ if ecma {
+ if negate {
+ c.addRanges(NotECMAWordClass().ranges)
+ } else {
+ c.addRanges(ECMAWordClass().ranges)
+ }
+ } else {
+ c.addCategories(Category{Cat: WordCategoryText, Negate: negate})
+ }
+}
+
+// Add set ranges and categories into ours -- no deduping or anything
+func (c *CharSet) addSet(set CharSet) {
+ if c.anything {
+ return
+ }
+ if set.anything {
+ c.makeAnything()
+ return
+ }
+ // just append here to prevent double-canon
+ c.ranges = append(c.ranges, set.ranges...)
+ c.addCategories(set.categories...)
+ c.canonicalize()
+}
+
+func (c *CharSet) makeAnything() {
+ c.anything = true
+ c.categories = []Category{}
+ c.ranges = []SingleRange{{First: 0, Last: unicode.MaxRune}}
+}
+
+func (c *CharSet) addCategories(cats ...Category) {
+ // don't add dupes and remove positive+negative
+ if c.anything {
+ // if we've had a previous positive+negative group then
+ // just return, we're as broad as we can get
+ return
+ }
+
+ for _, ct := range cats {
+ found := false
+ for _, ct2 := range c.categories {
+ if ct.Cat == ct2.Cat {
+ if ct.Negate != ct2.Negate {
+ // oposite negations...this mean we just
+ // take us as anything and move on
+ c.makeAnything()
+ return
+ }
+ found = true
+ break
+ }
+ }
+
+ if !found {
+ c.categories = append(c.categories, ct)
+ }
+ }
+}
+
+// Merges new ranges to our own
+func (c *CharSet) addRanges(ranges []SingleRange) {
+ if c.anything {
+ return
+ }
+ c.ranges = append(c.ranges, ranges...)
+ c.canonicalize()
+}
+
+// Merges everything but the new ranges into our own
+func (c *CharSet) addNegativeRanges(ranges []SingleRange) {
+ if c.anything {
+ return
+ }
+
+ var hi rune
+
+ // convert incoming ranges into opposites, assume they are in order
+ for _, r := range ranges {
+ if hi < r.First {
+ c.ranges = append(c.ranges, SingleRange{hi, r.First - 1})
+ }
+ hi = r.Last + 1
+ }
+
+ if hi < utf8.MaxRune {
+ c.ranges = append(c.ranges, SingleRange{hi, utf8.MaxRune})
+ }
+
+ c.canonicalize()
+}
+
+func normalizeUnicodeCategoryAlias(catName string) string {
+ var b strings.Builder
+ b.Grow(len(catName))
+ for _, ch := range catName {
+ switch ch {
+ case '_', '-', ' ':
+ continue
+ default:
+ b.WriteRune(unicode.ToLower(ch))
+ }
+ }
+ return b.String()
+}
+
+func canonicalUnicodeCatName(catName string) (string, bool) {
+ if _, ok := unicodeCategories[catName]; ok {
+ return catName, true
+ }
+
+ normalized := normalizeUnicodeCategoryAlias(catName)
+ if canonical, ok := unicodeSupportedPropertyAliases[normalized]; ok {
+ return canonical, true
+ }
+ if canonical, ok := unicodeBarePropertyValueAliases[normalized]; ok {
+ return canonical, true
+ }
+
+ if eq := strings.IndexRune(catName, '='); eq >= 0 {
+ propName := catName[:eq]
+ valueName := catName[eq+1:]
+ prop, ok := unicodeSupportedPropertyAliases[normalizeUnicodeCategoryAlias(propName)]
+ if !ok {
+ return "", false
+ }
+ values := unicodeSupportedPropertyValueAliases[prop]
+ if values == nil {
+ return "", false
+ }
+ value, ok := values[normalizeUnicodeCategoryAlias(valueName)]
+ if !ok {
+ return "", false
+ }
+ canonical := prop + "=" + value
+ if _, ok := unicodeCategories[canonical]; ok {
+ return canonical, true
+ }
+ }
+
+ return "", false
+}
+
+func isValidUnicodeCat(catName string) bool {
+ _, ok := canonicalUnicodeCatName(catName)
+ return ok
+}
+
+func (c *CharSet) addCategory(categoryName string, negate, caseInsensitive bool) {
+ var ok bool
+ categoryName, ok = canonicalUnicodeCatName(categoryName)
+ if !ok {
+ // unknown unicode category, script, or property "blah"
+ panic(fmt.Errorf("unknown unicode category, script, or property '%v'", categoryName))
+
+ }
+
+ if caseInsensitive && (categoryName == "Ll" || categoryName == "Lu" || categoryName == "Lt") {
+ // when RegexOptions.IgnoreCase is specified then {Ll} {Lu} and {Lt} cases should all match
+ c.addCategories(
+ Category{Cat: "Ll", Negate: negate},
+ Category{Cat: "Lu", Negate: negate},
+ Category{Cat: "Lt", Negate: negate})
+ }
+ c.addCategories(Category{Cat: categoryName, Negate: negate})
+}
+
+// Adds to the class any case-equivalence versions of characters already
+// in the class. Used for case-insensitivity.
+func (c *CharSet) addCaseEquivalences() {
+ // we already have all case equiv
+ if c.anything {
+ return
+ }
+ for i := 0; i < len(c.ranges); i++ {
+ r := c.ranges[i]
+ if r.First == r.Last {
+ equiv := tryFindCaseEquivalences(r.First)
+ for _, eq := range equiv {
+ c.addChar(eq)
+ }
+ } else {
+ c.addCaseEquivalenceRange(r.First, r.Last)
+ }
+ }
+}
+
+// For a single range that's in the set, adds any additional ranges
+// necessary to ensure that lowercase equivalents are also included.
+func (c *CharSet) addCaseEquivalenceRange(chMin, chMax rune) {
+ for i := chMin; i <= chMax; i++ {
+ equiv := tryFindCaseEquivalences(i)
+ for _, eq := range equiv {
+ c.addChar(eq)
+ }
+ }
+}
+
+// Performs a fast lookup which determines if a character is involved in case conversion, as well as
+// returns the OTHER characters that should be considered equivalent in case it does participate in case conversion.
+func tryFindCaseEquivalences(ch rune) []rune {
+ newCh := unicode.SimpleFold(ch)
+ if newCh == ch {
+ // no case support
+ return nil
+ }
+ equiv := []rune{newCh}
+ for {
+ newCh = unicode.SimpleFold(newCh)
+ if newCh == ch {
+ return equiv
+ }
+ equiv = append(equiv, newCh)
+ }
+}
+
+func (c *CharSet) addSubtraction(sub *CharSet) {
+ c.sub = sub
+}
+
+func (c *CharSet) addRange(chMin, chMax rune) {
+ c.ranges = append(c.ranges, SingleRange{First: chMin, Last: chMax})
+ c.canonicalize()
+}
+
+func (c *CharSet) addNamedASCII(name string, negate bool) bool {
+ var rs []SingleRange
+
+ switch name {
+ case "alnum":
+ rs = []SingleRange{{'0', '9'}, {'A', 'Z'}, {'a', 'z'}}
+ case "alpha":
+ rs = []SingleRange{{'A', 'Z'}, {'a', 'z'}}
+ case "ascii":
+ rs = []SingleRange{{0, 0x7f}}
+ case "blank":
+ rs = []SingleRange{{'\t', '\t'}, {' ', ' '}}
+ case "cntrl":
+ rs = []SingleRange{{0, 0x1f}, {0x7f, 0x7f}}
+ case "digit":
+ c.addDigit(false, negate)
+ case "graph":
+ rs = []SingleRange{{'!', '~'}}
+ case "lower":
+ rs = []SingleRange{{'a', 'z'}}
+ case "print":
+ rs = []SingleRange{{' ', '~'}}
+ case "punct": //[!-/:-@[-`{-~]
+ rs = []SingleRange{{'!', '/'}, {':', '@'}, {'[', '`'}, {'{', '~'}}
+ case "space":
+ c.addSpace(true, false, negate)
+ case "upper":
+ rs = []SingleRange{{'A', 'Z'}}
+ case "word":
+ c.addWord(true, negate)
+ case "xdigit":
+ rs = []SingleRange{{'0', '9'}, {'A', 'F'}, {'a', 'f'}}
+ default:
+ return false
+ }
+
+ if len(rs) > 0 {
+ if negate {
+ c.addNegativeRanges(rs)
+ } else {
+ c.addRanges(rs)
+ }
+ }
+
+ return true
+}
+
+type singleRangeSorter []SingleRange
+
+func (p singleRangeSorter) Len() int { return len(p) }
+func (p singleRangeSorter) Less(i, j int) bool { return p[i].First < p[j].First }
+func (p singleRangeSorter) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
+
+// Logic to reduce a character class to a unique, sorted form.
+func (c *CharSet) canonicalize() {
+ var i, j int
+ var last rune
+
+ if len(c.ranges) == 0 {
+ return
+ }
+
+ //
+ // Find and eliminate overlapping or abutting ranges
+ //
+
+ if len(c.ranges) > 1 {
+ sort.Sort(singleRangeSorter(c.ranges))
+
+ done := false
+
+ for i, j = 1, 0; ; i++ {
+ for last = c.ranges[j].Last; ; i++ {
+ if i == len(c.ranges) || last >= unicode.MaxRune {
+ done = true
+ break
+ }
+
+ CurrentRange := c.ranges[i]
+ if CurrentRange.First > last+1 {
+ break
+ }
+
+ if last < CurrentRange.Last {
+ last = CurrentRange.Last
+ }
+ }
+
+ c.ranges[j] = SingleRange{First: c.ranges[j].First, Last: last}
+
+ j++
+
+ if done {
+ break
+ }
+
+ if j < i {
+ c.ranges[j] = c.ranges[i]
+ }
+ }
+
+ c.ranges = append(c.ranges[:j], c.ranges[len(c.ranges):]...)
+ }
+
+ // If the class now represents a single negated range, but does so by including every
+ // other character, invert it to produce a normalized form with a single range. This
+ // is valuable for subsequent optimizations in most of the engines.
+ if !c.negate && c.sub == nil && len(c.categories) == 0 {
+ if len(c.ranges) == 2 {
+ // There are two ranges in the list. See if there's one missing range between them.
+ // Such a range might be as small as a single character.
+ if c.ranges[0].First == 0 &&
+ c.ranges[1].Last >= unicode.MaxRune &&
+ c.ranges[0].Last < c.ranges[1].First-1 {
+ c.ranges = []SingleRange{{c.ranges[0].Last + 1, c.ranges[1].First - 1}}
+ c.negate = true
+ }
+ } else if len(c.ranges) == 1 {
+ switch c.ranges[0].First {
+ case 0:
+ // There's only one range in the list. Does it include everything but the last char?
+ if c.ranges[0].Last == unicode.MaxRune-1 {
+ c.ranges[0] = SingleRange{unicode.MaxRune, unicode.MaxRune}
+ c.negate = true
+ }
+ case 1:
+ // Or everything but the first char?
+ if c.ranges[0].Last >= unicode.MaxRune {
+ c.ranges[0] = SingleRange{'\x00', '\x00'}
+ c.negate = true
+ }
+ }
+ }
+ }
+
+ // If the class now has a range that includes everything, and if it doesn't have subtraction,
+ // we can remove all of its categories, as they're duplicative (the set already includes everything).
+ if !c.negate &&
+ c.sub == nil &&
+ len(c.ranges) == 1 && c.ranges[0].First == 0 && c.ranges[0].Last >= unicode.MaxRune {
+
+ c.makeAnything()
+ }
+
+ // If there's only a single character omitted from ranges, if there's no subtractor, and if there are categories,
+ // see if that character is in the categories. If it is, then we can replace whole thing with a complete "any" range.
+ // If it's not, then we can remove the categories, as they're only duplicating the rest of the range, turning the set
+ // into a "not one". This primarily helps in the case of a synthesized set from analysis that ends up combining '.' with
+ // categories, as we want to reduce that set down to either [^\n] or [\0-\uFFFF]. (This can be extrapolated to any number
+ // of missing characters; in fact, categories in general are superfluous and the entire set can be represented as ranges.
+ // But categories serve as a space optimization, and we strike a balance between testing many characters and the time/complexity
+ // it takes to do so. Thus, we limit this to the common case of a single missing character.)
+ if !c.negate && c.sub == nil && len(c.categories) > 0 &&
+ len(c.ranges) == 2 && c.ranges[0].First == 0 && c.ranges[0].Last+2 == c.ranges[1].First && c.ranges[1].Last == unicode.MaxRune {
+
+ if c.charInCategories(c.ranges[0].Last + 1) {
+ //c.ranges = []SingleRange{{'\x00', unicode.MaxRune}}
+ c.makeAnything()
+ } else {
+ c.negate = true
+ c.ranges = []SingleRange{{c.ranges[0].Last + 1, c.ranges[0].Last + 1}}
+ c.categories = []Category{}
+ }
+ }
+}
+
+// Adds to the class any lowercase versions of characters already
+// in the class. Used for case-insensitivity.
+func (c *CharSet) addLowercase() {
+ if c.anything {
+ return
+ }
+ toAdd := []SingleRange{}
+ for i := 0; i < len(c.ranges); i++ {
+ r := c.ranges[i]
+ if r.First == r.Last {
+ lower := unicode.ToLower(r.First)
+ c.ranges[i] = SingleRange{First: lower, Last: lower}
+ } else {
+ toAdd = append(toAdd, r)
+ }
+ }
+
+ for _, r := range toAdd {
+ c.addLowercaseRange(r.First, r.Last)
+ }
+ c.canonicalize()
+}
+
+/**************************************************************************
+ Let U be the set of Unicode character values and let L be the lowercase
+ function, mapping from U to U. To perform case insensitive matching of
+ character sets, we need to be able to map an interval I in U, say
+
+ I = [chMin, chMax] = { ch : chMin <= ch <= chMax }
+
+ to a set A such that A contains L(I) and A is contained in the union of
+ I and L(I).
+
+ The table below partitions U into intervals on which L is non-decreasing.
+ Thus, for any interval J = [a, b] contained in one of these intervals,
+ L(J) is contained in [L(a), L(b)].
+
+ It is also true that for any such J, [L(a), L(b)] is contained in the
+ union of J and L(J). This does not follow from L being non-decreasing on
+ these intervals. It follows from the nature of the L on each interval.
+ On each interval, L has one of the following forms:
+
+ (1) L(ch) = constant (LowercaseSet)
+ (2) L(ch) = ch + offset (LowercaseAdd)
+ (3) L(ch) = ch | 1 (LowercaseBor)
+ (4) L(ch) = ch + (ch & 1) (LowercaseBad)
+
+ It is easy to verify that for any of these forms [L(a), L(b)] is
+ contained in the union of [a, b] and L([a, b]).
+***************************************************************************/
+
+const (
+ LowercaseSet = 0 // Set to arg.
+ LowercaseAdd = 1 // Add arg.
+ LowercaseBor = 2 // Bitwise or with 1.
+ LowercaseBad = 3 // Bitwise and with 1 and add original.
+)
+
+type lcMap struct {
+ chMin, chMax rune
+ op, data int32
+}
+
+var lcTable = []lcMap{
+ {'\u0041', '\u005A', LowercaseAdd, 32},
+ {'\u00C0', '\u00DE', LowercaseAdd, 32},
+ {'\u0100', '\u012E', LowercaseBor, 0},
+ {'\u0130', '\u0130', LowercaseSet, 0x0069},
+ {'\u0132', '\u0136', LowercaseBor, 0},
+ {'\u0139', '\u0147', LowercaseBad, 0},
+ {'\u014A', '\u0176', LowercaseBor, 0},
+ {'\u0178', '\u0178', LowercaseSet, 0x00FF},
+ {'\u0179', '\u017D', LowercaseBad, 0},
+ {'\u0181', '\u0181', LowercaseSet, 0x0253},
+ {'\u0182', '\u0184', LowercaseBor, 0},
+ {'\u0186', '\u0186', LowercaseSet, 0x0254},
+ {'\u0187', '\u0187', LowercaseSet, 0x0188},
+ {'\u0189', '\u018A', LowercaseAdd, 205},
+ {'\u018B', '\u018B', LowercaseSet, 0x018C},
+ {'\u018E', '\u018E', LowercaseSet, 0x01DD},
+ {'\u018F', '\u018F', LowercaseSet, 0x0259},
+ {'\u0190', '\u0190', LowercaseSet, 0x025B},
+ {'\u0191', '\u0191', LowercaseSet, 0x0192},
+ {'\u0193', '\u0193', LowercaseSet, 0x0260},
+ {'\u0194', '\u0194', LowercaseSet, 0x0263},
+ {'\u0196', '\u0196', LowercaseSet, 0x0269},
+ {'\u0197', '\u0197', LowercaseSet, 0x0268},
+ {'\u0198', '\u0198', LowercaseSet, 0x0199},
+ {'\u019C', '\u019C', LowercaseSet, 0x026F},
+ {'\u019D', '\u019D', LowercaseSet, 0x0272},
+ {'\u019F', '\u019F', LowercaseSet, 0x0275},
+ {'\u01A0', '\u01A4', LowercaseBor, 0},
+ {'\u01A7', '\u01A7', LowercaseSet, 0x01A8},
+ {'\u01A9', '\u01A9', LowercaseSet, 0x0283},
+ {'\u01AC', '\u01AC', LowercaseSet, 0x01AD},
+ {'\u01AE', '\u01AE', LowercaseSet, 0x0288},
+ {'\u01AF', '\u01AF', LowercaseSet, 0x01B0},
+ {'\u01B1', '\u01B2', LowercaseAdd, 217},
+ {'\u01B3', '\u01B5', LowercaseBad, 0},
+ {'\u01B7', '\u01B7', LowercaseSet, 0x0292},
+ {'\u01B8', '\u01B8', LowercaseSet, 0x01B9},
+ {'\u01BC', '\u01BC', LowercaseSet, 0x01BD},
+ {'\u01C4', '\u01C5', LowercaseSet, 0x01C6},
+ {'\u01C7', '\u01C8', LowercaseSet, 0x01C9},
+ {'\u01CA', '\u01CB', LowercaseSet, 0x01CC},
+ {'\u01CD', '\u01DB', LowercaseBad, 0},
+ {'\u01DE', '\u01EE', LowercaseBor, 0},
+ {'\u01F1', '\u01F2', LowercaseSet, 0x01F3},
+ {'\u01F4', '\u01F4', LowercaseSet, 0x01F5},
+ {'\u01FA', '\u0216', LowercaseBor, 0},
+ {'\u0386', '\u0386', LowercaseSet, 0x03AC},
+ {'\u0388', '\u038A', LowercaseAdd, 37},
+ {'\u038C', '\u038C', LowercaseSet, 0x03CC},
+ {'\u038E', '\u038F', LowercaseAdd, 63},
+ {'\u0391', '\u03AB', LowercaseAdd, 32},
+ {'\u03E2', '\u03EE', LowercaseBor, 0},
+ {'\u0401', '\u040F', LowercaseAdd, 80},
+ {'\u0410', '\u042F', LowercaseAdd, 32},
+ {'\u0460', '\u0480', LowercaseBor, 0},
+ {'\u0490', '\u04BE', LowercaseBor, 0},
+ {'\u04C1', '\u04C3', LowercaseBad, 0},
+ {'\u04C7', '\u04C7', LowercaseSet, 0x04C8},
+ {'\u04CB', '\u04CB', LowercaseSet, 0x04CC},
+ {'\u04D0', '\u04EA', LowercaseBor, 0},
+ {'\u04EE', '\u04F4', LowercaseBor, 0},
+ {'\u04F8', '\u04F8', LowercaseSet, 0x04F9},
+ {'\u0531', '\u0556', LowercaseAdd, 48},
+ {'\u10A0', '\u10C5', LowercaseAdd, 48},
+ {'\u1E00', '\u1EF8', LowercaseBor, 0},
+ {'\u1F08', '\u1F0F', LowercaseAdd, -8},
+ {'\u1F18', '\u1F1F', LowercaseAdd, -8},
+ {'\u1F28', '\u1F2F', LowercaseAdd, -8},
+ {'\u1F38', '\u1F3F', LowercaseAdd, -8},
+ {'\u1F48', '\u1F4D', LowercaseAdd, -8},
+ {'\u1F59', '\u1F59', LowercaseSet, 0x1F51},
+ {'\u1F5B', '\u1F5B', LowercaseSet, 0x1F53},
+ {'\u1F5D', '\u1F5D', LowercaseSet, 0x1F55},
+ {'\u1F5F', '\u1F5F', LowercaseSet, 0x1F57},
+ {'\u1F68', '\u1F6F', LowercaseAdd, -8},
+ {'\u1F88', '\u1F8F', LowercaseAdd, -8},
+ {'\u1F98', '\u1F9F', LowercaseAdd, -8},
+ {'\u1FA8', '\u1FAF', LowercaseAdd, -8},
+ {'\u1FB8', '\u1FB9', LowercaseAdd, -8},
+ {'\u1FBA', '\u1FBB', LowercaseAdd, -74},
+ {'\u1FBC', '\u1FBC', LowercaseSet, 0x1FB3},
+ {'\u1FC8', '\u1FCB', LowercaseAdd, -86},
+ {'\u1FCC', '\u1FCC', LowercaseSet, 0x1FC3},
+ {'\u1FD8', '\u1FD9', LowercaseAdd, -8},
+ {'\u1FDA', '\u1FDB', LowercaseAdd, -100},
+ {'\u1FE8', '\u1FE9', LowercaseAdd, -8},
+ {'\u1FEA', '\u1FEB', LowercaseAdd, -112},
+ {'\u1FEC', '\u1FEC', LowercaseSet, 0x1FE5},
+ {'\u1FF8', '\u1FF9', LowercaseAdd, -128},
+ {'\u1FFA', '\u1FFB', LowercaseAdd, -126},
+ {'\u1FFC', '\u1FFC', LowercaseSet, 0x1FF3},
+ {'\u2160', '\u216F', LowercaseAdd, 16},
+ {'\u24B6', '\u24D0', LowercaseAdd, 26},
+ {'\uFF21', '\uFF3A', LowercaseAdd, 32},
+}
+
+func (c *CharSet) addLowercaseRange(chMin, chMax rune) {
+ var i, iMax, iMid int
+ var chMinT, chMaxT rune
+ var lc lcMap
+
+ for i, iMax = 0, len(lcTable); i < iMax; {
+ iMid = (i + iMax) / 2
+ if lcTable[iMid].chMax < chMin {
+ i = iMid + 1
+ } else {
+ iMax = iMid
+ }
+ }
+
+ for ; i < len(lcTable); i++ {
+ lc = lcTable[i]
+ if lc.chMin > chMax {
+ return
+ }
+ chMinT = lc.chMin
+ if chMinT < chMin {
+ chMinT = chMin
+ }
+
+ chMaxT = lc.chMax
+ if chMaxT > chMax {
+ chMaxT = chMax
+ }
+
+ switch lc.op {
+ case LowercaseSet:
+ chMinT = rune(lc.data)
+ chMaxT = rune(lc.data)
+ case LowercaseAdd:
+ chMinT += lc.data
+ chMaxT += lc.data
+ case LowercaseBor:
+ chMinT |= 1
+ chMaxT |= 1
+ case LowercaseBad:
+ chMinT += (chMinT & 1)
+ chMaxT += (chMaxT & 1)
+ }
+
+ if chMinT < chMin || chMaxT > chMax {
+ c.addRange(chMinT, chMaxT)
+ }
+ }
+}
+
+// Determines whether two sets could overlap.
+func (set1 *CharSet) MayOverlap(set2 *CharSet) bool {
+ // If the sets are identical, there's obviously overlap.
+ if set1.Equals(set2) {
+ return true
+ }
+
+ // If either set is all-inclusive, there's overlap by definition (unless
+ // the other set is empty, but that's so rare it's not worth checking.)
+ if set1.IsAnything() || set2.IsAnything() {
+ return true
+ }
+
+ // If one set is negated and the other one isn't, we're in one of two situations:
+ // - The remainder of the sets are identical, in which case these are inverses of
+ // each other, and they don't overlap.
+ // - The remainder of the sets aren't identical, in which case there's very likely
+ // overlap, and it's not worth spending more time investigating.
+ set1Negated := set1.IsNegated()
+ set2Negated := set2.IsNegated()
+ if set1Negated != set2Negated {
+
+ return !set1.equals(set2, true)
+ }
+
+ // If the sets are negated, since they're not equal, there's almost certainly overlap.
+ if set1Negated {
+ return true
+ }
+
+ // Special-case some known, common classes that don't overlap.
+ if knownDistinctSets(set1, set2) || knownDistinctSets(set2, set1) {
+ return false
+ }
+
+ // If set2 can be easily enumerated (e.g. no unicode categories), then enumerate it and
+ // check if any of its members are in set1. Otherwise, the same for set1.
+ if !set2.HasSubtraction() && len(set2.categories) == 0 {
+ return mayOverlapByEnumeration(set1, set2)
+ } else if !set1.HasSubtraction() && len(set1.categories) == 0 {
+ return mayOverlapByEnumeration(set2, set1)
+ }
+
+ // Assume that everything else might overlap. In the future if it proved impactful, we could be more accurate here,
+ // at the exense of more computation time.
+ return true
+}
+
+func knownDistinctSets(set1, set2 *CharSet) bool {
+
+ return (set1.Equals(SpaceClass()) || set1.Equals(ECMASpaceClass())) &&
+ (set2.Equals(DigitClass()) || set2.Equals(WordClass()) ||
+ set2.Equals(ECMADigitClass()) || set2.Equals(ECMAWordClass()))
+
+}
+
+func mayOverlapByEnumeration(set1, set2 *CharSet) bool {
+ for i := 0; i < len(set2.ranges); i++ {
+ for c := set2.ranges[i].First; c <= set2.ranges[i].Last; c++ {
+ if set1.CharIn(c) {
+ return true
+ }
+ }
+ }
+
+ return false
+}
+
+// Gets all of the characters in the specified set, storing them into the provided span.
+//
+// Only considers character classes that only contain sets (no categories),
+// just simple sets containing starting/ending pairs (subtraction from those pairs
+// is factored in, however).The returned characters may be negated: if IsNegated(set)
+// is false, then the returned characters are the only ones that match; if it returns
+// true, then the returned characters are the only ones that don't match.
+func (c *CharSet) GetSetChars(maxChars int) []rune {
+ // don't support categories, just ranges
+ if len(c.categories) > 0 || len(c.ranges) > maxChars {
+ return nil
+ }
+
+ // Negation with subtraction is too cumbersome to reason about efficiently.
+ if c.IsNegated() && c.HasSubtraction() {
+ return nil
+ }
+
+ chars := make([]rune, 0, maxChars)
+ curWork := 0
+ // Iterate through the pairs of ranges, storing each value in each range
+ // into the supplied span. If they all won't fit, we give up and return 0.
+ // Otherwise we return the number found. Note that we don't bother to handle
+ // the corner case where the last range's upper bound is LastChar (\uFFFF),
+ // based on it a) complicating things, and b) it being really unlikely to
+ // be part of a small set.
+ for _, r := range c.ranges {
+ // loop through each char in the range
+ for ch := r.First; ch <= r.Last; ch++ {
+
+ // Keep track of how many characters we've checked. This could work
+ // just comparing count rather than evaluated, but we also want to
+ // limit how much work is done here, which we can do by constraining
+ // the number of checks to the size of the storage provided.
+ curWork++
+ if curWork > maxChars {
+ return nil
+ }
+
+ // If the set is all ranges but has a subtracted class,
+ // validate the char is actually in the set prior to storing it:
+ // it might be in the subtracted range.
+ if c.HasSubtraction() && !c.CharIn(ch) {
+ continue
+ }
+ chars = append(chars, ch)
+ }
+ }
+ return chars
+}
+
+func (c *CharSet) Hash() []byte {
+ b := &bytes.Buffer{}
+ c.mapHashFill(b)
+ return b.Bytes()
+}
+
+func (c *CharSet) Equals(c2 *CharSet) bool {
+ return c.equals(c2, false)
+}
+
+func (c *CharSet) equals(c2 *CharSet, ignoreNegate bool) bool {
+ if c == nil && c2 == nil {
+ return true
+ }
+ if c == nil && c2 != nil || c2 == nil && c != nil {
+ return false
+ }
+
+ if !ignoreNegate {
+ if c.negate != c2.negate {
+ return false
+ }
+ }
+ if c.anything != c2.anything {
+ return false
+ }
+
+ if !slices.Equal(c.ranges, c2.ranges) {
+ return false
+ }
+ if !slices.Equal(c.categories, c2.categories) {
+ return false
+ }
+
+ return c.sub.equals(c2.sub, false)
+}
+
+var whitespaceChars = []rune{'\u0009', '\u000A', '\u000B', '\u000C', '\u000D',
+ '\u0020', '\u0085', '\u00A0', '\u1680', '\u2000',
+ '\u2001', '\u2002', '\u2003', '\u2004', '\u2005',
+ '\u2006', '\u2007', '\u2008', '\u2009', '\u200A',
+ '\u2028', '\u2029', '\u202F', '\u205F', '\u3000'}
+
+// Gets whether the specified set is a named set with a reasonably small count
+// of Unicode characters. Designed to help the regexp code generator choose a better
+// search algo for finding chars
+// Description is a short name that can be used as part of a var name in code gen
+func (c *CharSet) IsUnicodeCategoryOfSmallCharCount() (isSmall bool, chars []rune, negated bool, desc string) {
+ // figure out if we're SpaceClass, RE2SpaceClass, ECMASpaceClass or inverse
+ // "hash" ourselves -- this is actually fully serialized, not just hashed
+ if c.IsSingleton() {
+ return true, []rune{c.SingletonChar()}, false, ""
+ }
+ if c.IsSingletonInverse() {
+ return true, []rune{c.SingletonChar()}, true, ""
+ }
+
+ if c.Equals(SpaceClass()) {
+ // we're SpaceClass
+ return true, whitespaceChars, false, "whitespace"
+ }
+ if c.Equals(NotSpaceClass()) {
+ // we're NotSpaceClass
+ return true, whitespaceChars, true, "whitespace"
+ }
+
+ return false, nil, false, ""
+}
+
+// Gets whether the set description string is for two ASCII letters that case
+// to each other under IgnoreCase rules.
+func (c *CharSet) containsAsciiIgnoreCaseCharacter() (bool, []rune) {
+ if c.IsNegated() {
+ return false, nil
+ }
+ // get up to 3 chars, just to be able to error on both "too many" and "too few"
+ twoChars := c.GetSetChars(3)
+ return len(twoChars) == 2 && twoChars[0] < unicode.MaxASCII && twoChars[1] < unicode.MaxASCII &&
+ (twoChars[0]|0x20) == (twoChars[1]|0x20) &&
+ unicode.IsLetter(twoChars[0]) && unicode.IsLetter(twoChars[1]), twoChars
+}
+
+func anyParticipateInCaseConversion(chars []rune) bool {
+ for _, c := range chars {
+ if participatesInCaseConversion(c) {
+ return true
+ }
+ }
+ return false
+}
+
+func participatesInCaseConversion(ch rune) bool {
+ /*
+ case UnicodeCategory.ClosePunctuation:
+ case UnicodeCategory.ConnectorPunctuation:
+ case UnicodeCategory.Control:
+ case UnicodeCategory.DashPunctuation:
+ case UnicodeCategory.DecimalDigitNumber:
+ case UnicodeCategory.FinalQuotePunctuation:
+ case UnicodeCategory.InitialQuotePunctuation:
+ case UnicodeCategory.LineSeparator:
+ case UnicodeCategory.OpenPunctuation:
+ case UnicodeCategory.OtherNumber:
+ case UnicodeCategory.OtherPunctuation:
+ case UnicodeCategory.ParagraphSeparator:
+ case UnicodeCategory.SpaceSeparator:
+ */
+ return !unicode.In(ch, unicode.Pe, unicode.Pc, unicode.Cc, unicode.Pd, unicode.Nd, unicode.Pf,
+ unicode.Pi, unicode.Zl, unicode.Ps, unicode.No, unicode.Po, unicode.Zp, unicode.Zs)
+}
+
+func anyParticipatesInCaseConversion(str string) bool {
+ for _, c := range str {
+ if participatesInCaseConversion(c) {
+ return true
+ }
+ }
+ return false
+}
+
+func isAsciiRunes(in []rune) bool {
+ for i := 0; i < len(in); i++ {
+ if in[i] > unicode.MaxASCII {
+ return false
+ }
+ }
+ return true
+}
+
+func (c CharSet) GetIfNRanges(n int) []SingleRange {
+ if len(c.categories) > 0 {
+ return nil
+ }
+ if c.sub != nil {
+ return nil
+ }
+ if len(c.ranges) == n {
+ return c.ranges[:n]
+ }
+ return nil
+}
+
+func (c *CharSet) GetIfOnlyUnicodeCategories() (cats []Category, negate bool) {
+ if c.sub != nil {
+ return nil, false
+ }
+ if len(c.ranges) > 0 {
+ return nil, false
+ }
+ // all cats need to be rationalized to the same negation or not
+ if len(c.categories) == 0 {
+ return nil, false
+ }
+
+ neg := c.categories[0].Negate
+ for _, cat := range c.categories {
+ if neg != cat.Negate || cat.Cat == SpaceCategoryText || cat.Cat == WordCategoryText {
+ // negate some and not others...a problem
+ // or one of our non-unicode categories
+ return nil, false
+ }
+ }
+
+ // tell the caller to negate if either all the categories
+ // are negated or the set as a whole is negated, but not
+ // both
+ return c.categories, neg != c.negate
+}
+
+type CharClassAnalysisResults struct {
+ // true if the set contains only ranges; false if it contains Unicode categories and/or subtraction.
+ OnlyRanges bool
+ // true if we know for sure that the set contains only ASCII values; otherwise, false.
+ // This can only be true if OnlyRanges is true.
+ ContainsOnlyAscii bool
+ // true if we know for sure that the set doesn't contain any ASCII values; otherwise, false.
+ // This can only be true if OnlyRanges is true.
+ ContainsNoAscii bool
+ // true if we know for sure that all ASCII values are in the set; otherwise, false.
+ // This can only be true if OnlyRanges is true.
+ AllAsciiContained bool
+ // true if we know for sure that all non-ASCII values are in the set; otherwise, false.
+ // This can only be true if OnlyRanges is true.
+ AllNonAsciiContained bool
+ // The inclusive lower bound.
+ // This is only valid if OnlyRanges is true.
+ LowerBoundInclusiveIfOnlyRanges rune
+ // The exclusive upper bound.
+ // This is only valid if OnlyRanges is true.
+ UpperBoundExclusiveIfOnlyRanges rune
+}
+
+// Analyzes the set to determine some basic properties that can be used to optimize usage.
+func (set *CharSet) Analyze() CharClassAnalysisResults {
+ // The analysis is performed based entirely on ranges contained within the set.
+ // Thus, we require that it can be "easily enumerated", meaning it contains only
+ // ranges (and more specifically those with both the lower inclusive and upper
+ // exclusive bounds specified). We also permit the set to contain a subtracted
+ // character class, as for non-negated sets, that can only narrow what's permitted,
+ // and the analysis can be performed on the overestimate of the set prior to subtraction.
+ // However, negation is performed before subtraction, which means we can't trust
+ // the ranges to inform AllNonAsciiContained and AllAsciiContained, as the subtraction
+ // could create holes in those. As such, while we can permit subtraction for non-negated
+ // sets, for negated sets, we need to bail.
+ if (set.IsNegated() && set.HasSubtraction()) || len(set.categories) > 0 || len(set.ranges) == 0 {
+ // We can't make any strong claims about the set.
+ return CharClassAnalysisResults{}
+ }
+
+ firstValueInclusive := set.ranges[0].First
+ lastValueExclusive := set.ranges[len(set.ranges)-1].Last + 1
+
+ if set.IsNegated() {
+ // We're negated: if the upper bound of the range is ASCII, that means everything
+ // above it is actually included, meaning all non-ASCII are in the class.
+ // Similarly if the lower bound is non-ASCII, that means in a negated world
+ // everything ASCII is included.
+ return CharClassAnalysisResults{
+ OnlyRanges: true,
+ AllNonAsciiContained: lastValueExclusive <= unicode.MaxASCII,
+ AllAsciiContained: firstValueInclusive >= unicode.MaxASCII,
+ ContainsNoAscii: firstValueInclusive == 0 && set.ranges[0].Last >= unicode.MaxASCII,
+ ContainsOnlyAscii: false,
+ LowerBoundInclusiveIfOnlyRanges: firstValueInclusive,
+ UpperBoundExclusiveIfOnlyRanges: lastValueExclusive,
+ }
+ }
+
+ // If the upper bound is ASCII, that means everything included in the class is ASCII.
+ // Similarly if the lower bound is non-ASCII, that means no ASCII is in the class.
+ return CharClassAnalysisResults{
+ OnlyRanges: true,
+ AllNonAsciiContained: false,
+ AllAsciiContained: firstValueInclusive == 0 && set.ranges[0].Last >= unicode.MaxASCII && !set.HasSubtraction(),
+ ContainsOnlyAscii: lastValueExclusive <= unicode.MaxASCII,
+ ContainsNoAscii: firstValueInclusive >= unicode.MaxASCII,
+ LowerBoundInclusiveIfOnlyRanges: firstValueInclusive,
+ UpperBoundExclusiveIfOnlyRanges: lastValueExclusive,
+ }
+}
diff --git a/vendor/github.com/dlclark/regexp2/v2/syntax/code.go b/vendor/github.com/dlclark/regexp2/v2/syntax/code.go
new file mode 100644
index 0000000000..1df4e45a93
--- /dev/null
+++ b/vendor/github.com/dlclark/regexp2/v2/syntax/code.go
@@ -0,0 +1,316 @@
+package syntax
+
+import (
+ "bytes"
+ "fmt"
+ "math"
+)
+
+// similar to prog.go in the go regex package...also with comment 'may not belong in this package'
+
+// File provides operator constants for use by the Builder and the Machine.
+
+// Implementation notes:
+//
+// Regexps are built into RegexCodes, which contain an operation array,
+// a string table, and some constants.
+//
+// Each operation is one of the codes below, followed by the integer
+// operands specified for each op.
+//
+// Strings and sets are indices into a string table.
+
+type InstOp int
+
+const (
+ // lef/back operands description
+
+ Onerep InstOp = 0 // lef,back char,min,max a {n}
+ Notonerep InstOp = 1 // lef,back char,min,max .{n}
+ Setrep InstOp = 2 // lef,back set,min,max [\d]{n}
+
+ Oneloop InstOp = 3 // lef,back char,min,max a {,n}
+ Notoneloop InstOp = 4 // lef,back char,min,max .{,n}
+ Setloop InstOp = 5 // lef,back set,min,max [\d]{,n}
+
+ Onelazy InstOp = 6 // lef,back char,min,max a {,n}?
+ Notonelazy InstOp = 7 // lef,back char,min,max .{,n}?
+ Setlazy InstOp = 8 // lef,back set,min,max [\d]{,n}?
+
+ One InstOp = 9 // lef char a
+ Notone InstOp = 10 // lef char [^a]
+ Set InstOp = 11 // lef set [a-z\s] \w \s \d
+
+ Multi InstOp = 12 // lef string abcd
+ Ref InstOp = 13 // lef group \#
+
+ Bol InstOp = 14 // ^
+ Eol InstOp = 15 // $
+ Boundary InstOp = 16 // \b
+ Nonboundary InstOp = 17 // \B
+ Beginning InstOp = 18 // \A
+ Start InstOp = 19 // \G
+ EndZ InstOp = 20 // \Z
+ End InstOp = 21 // \Z
+
+ Nothing InstOp = 22 // Reject!
+
+ // Primitive control structures
+
+ Lazybranch InstOp = 23 // back jump straight first
+ Branchmark InstOp = 24 // back jump branch first for loop
+ Lazybranchmark InstOp = 25 // back jump straight first for loop
+ Nullcount InstOp = 26 // back val set counter, null mark
+ Setcount InstOp = 27 // back val set counter, make mark
+ Branchcount InstOp = 28 // back jump,limit branch++ if zero<=c impl group slots
+ Capsize int // number of impl group slots
+ FcPrefix *Prefix // the set of candidate first characters (may be null)
+ BmPrefix *BmPrefix // the fixed prefix string as a Boyer-Moore machine (may be null)
+ Anchors AnchorLoc // the set of zero-length start anchors (RegexFCD.Bol, etc)
+ RightToLeft bool // true if right to left
+ FindOptimizations *FindOptimizations // analyzed candidate search strategy
+}
+
+// PrepareCharSetASCIIBitmaps builds bounded ASCII lookup tables for compiled
+// character classes before the regexp is shared across goroutines.
+func (c *Code) PrepareCharSetASCIIBitmaps() {
+ if c == nil {
+ return
+ }
+ for _, set := range c.Sets {
+ set.prepareASCIIBitmap()
+ }
+ if c.FcPrefix != nil {
+ c.FcPrefix.PrefixSet.prepareASCIIBitmap()
+ }
+ if c.FindOptimizations != nil {
+ for _, set := range c.FindOptimizations.FixedDistanceSets {
+ set.Set.prepareASCIIBitmap()
+ }
+ if c.FindOptimizations.LiteralAfterLoop != nil && c.FindOptimizations.LiteralAfterLoop.LoopNode != nil {
+ c.FindOptimizations.LiteralAfterLoop.LoopNode.Set.prepareASCIIBitmap()
+ }
+ }
+}
+
+func opcodeBacktracks(op InstOp) bool {
+ op &= Mask
+
+ switch op {
+ case Oneloop, Notoneloop, Setloop, Onelazy, Notonelazy, Setlazy, Lazybranch, Branchmark, Lazybranchmark,
+ Nullcount, Setcount, Branchcount, Lazybranchcount, Setmark, Capturemark, Getmark, Setjump, Backjump,
+ Forejump, Goto:
+ return true
+
+ default:
+ return false
+ }
+}
+
+func opcodeSize(op InstOp) int {
+ op &= Mask
+
+ switch op {
+ case Nothing, Bol, Eol, Boundary, Nonboundary, ECMABoundary, NonECMABoundary, Beginning, Start, EndZ,
+ End, Nullmark, Setmark, Getmark, Setjump, Backjump, Forejump, Stop, UpdateBumpalong:
+ return 1
+
+ case One, Notone, Multi, Ref, Testref, Goto, Nullcount, Setcount, Lazybranch, Branchmark, Lazybranchmark,
+ Prune, Set:
+ return 2
+
+ case Capturemark, Branchcount, Lazybranchcount, Onerep, Notonerep, Oneloop, Notoneloop, Onelazy, Notonelazy,
+ Setlazy, Setrep, Setloop, Oneloopatomic, Notoneloopatomic, Setloopatomic:
+ return 3
+
+ default:
+ panic(fmt.Errorf("unexpected op code: %v", op))
+ }
+}
+
+var codeStr = []string{
+ "Onerep", "Notonerep", "Setrep",
+ "Oneloop", "Notoneloop", "Setloop",
+ "Onelazy", "Notonelazy", "Setlazy",
+ "One", "Notone", "Set",
+ "Multi", "Ref",
+ "Bol", "Eol", "Boundary", "Nonboundary", "Beginning", "Start", "EndZ", "End",
+ "Nothing",
+ "Lazybranch", "Branchmark", "Lazybranchmark",
+ "Nullcount", "Setcount", "Branchcount", "Lazybranchcount",
+ "Nullmark", "Setmark", "Capturemark", "Getmark",
+ "Setjump", "Backjump", "Forejump", "Testref", "Goto",
+ "Prune", "Stop",
+ "ECMABoundary", "NonECMABoundary",
+ "Oneloopatomic", "Notoneloopatomic", "Setloopatomic",
+ "Bumpalong",
+}
+
+func operatorDescription(op InstOp) string {
+ desc := codeStr[op&Mask]
+ if (op & Ci) != 0 {
+ desc += "-Ci"
+ }
+ if (op & Rtl) != 0 {
+ desc += "-Rtl"
+ }
+ if (op & Back) != 0 {
+ desc += "-Back"
+ }
+ if (op & Back2) != 0 {
+ desc += "-Back2"
+ }
+
+ return desc
+}
+
+// OpcodeDescription is a humman readable string of the specific offset
+func (c *Code) OpcodeDescription(offset int) string {
+ buf := &bytes.Buffer{}
+
+ op := InstOp(c.Codes[offset])
+ fmt.Fprintf(buf, "%06d ", offset)
+
+ if opcodeBacktracks(op & Mask) {
+ buf.WriteString("*")
+ } else {
+ buf.WriteString(" ")
+ }
+ buf.WriteString(operatorDescription(op))
+ buf.WriteString("(")
+ op &= Mask
+
+ switch op {
+ case One, Notone, Onerep, Notonerep, Oneloop, Notoneloop, Onelazy, Notonelazy,
+ Oneloopatomic, Notoneloopatomic:
+ buf.WriteString("Ch = ")
+ buf.WriteString(CharDescription(rune(c.Codes[offset+1])))
+
+ case Set, Setrep, Setloop, Setlazy, Setloopatomic:
+ buf.WriteString("Set = ")
+ buf.WriteString(c.Sets[c.Codes[offset+1]].String())
+
+ case Multi:
+ fmt.Fprintf(buf, "String = %s", string(c.Strings[c.Codes[offset+1]]))
+
+ case Ref, Testref:
+ fmt.Fprintf(buf, "Index = %d", c.Codes[offset+1])
+
+ case Capturemark:
+ fmt.Fprintf(buf, "Index = %d", c.Codes[offset+1])
+ if c.Codes[offset+2] != -1 {
+ fmt.Fprintf(buf, ", Unindex = %d", c.Codes[offset+2])
+ }
+
+ case Nullcount, Setcount:
+ fmt.Fprintf(buf, "Value = %d", c.Codes[offset+1])
+
+ case Goto, Lazybranch, Branchmark, Lazybranchmark, Branchcount, Lazybranchcount:
+ fmt.Fprintf(buf, "Addr = %d", c.Codes[offset+1])
+ }
+
+ switch op {
+ case Onerep, Notonerep, Oneloop, Notoneloop, Onelazy, Notonelazy, Setrep, Setloop, Setlazy,
+ Oneloopatomic, Notoneloopatomic, Setloopatomic:
+ buf.WriteString(", Rep = ")
+ if c.Codes[offset+2] == math.MaxInt32 {
+ buf.WriteString("inf")
+ } else {
+ fmt.Fprintf(buf, "%d", c.Codes[offset+2])
+ }
+
+ case Branchcount, Lazybranchcount:
+ buf.WriteString(", Limit = ")
+ if c.Codes[offset+2] == math.MaxInt32 {
+ buf.WriteString("inf")
+ } else {
+ fmt.Fprintf(buf, "%d", c.Codes[offset+2])
+ }
+
+ }
+
+ buf.WriteString(")")
+
+ return buf.String()
+}
+
+func (c *Code) Dump() string {
+ buf := &bytes.Buffer{}
+
+ if c.RightToLeft {
+ fmt.Fprintln(buf, "Direction: right-to-left")
+ } else {
+ fmt.Fprintln(buf, "Direction: left-to-right")
+ }
+ if c.FcPrefix == nil {
+ fmt.Fprintln(buf, "Firstchars: n/a")
+ } else {
+ fmt.Fprintf(buf, "Firstchars: %v\n", c.FcPrefix.PrefixSet.String())
+ }
+
+ if c.BmPrefix == nil {
+ fmt.Fprintln(buf, "Prefix: n/a")
+ } else {
+ fmt.Fprintf(buf, "Prefix: %v\n", Escape(c.BmPrefix.String()))
+ }
+
+ fmt.Fprintf(buf, "Anchors: %v\n", c.Anchors)
+ if c.FindOptimizations != nil {
+ fmt.Fprint(buf, c.FindOptimizations.Dump())
+ }
+ fmt.Fprintln(buf)
+
+ if c.BmPrefix != nil {
+ fmt.Fprintln(buf, "BoyerMoore:")
+ fmt.Fprintln(buf, c.BmPrefix.Dump(" "))
+ }
+ for i := 0; i < len(c.Codes); i += opcodeSize(InstOp(c.Codes[i])) {
+ fmt.Fprintln(buf, c.OpcodeDescription(i))
+ }
+
+ return buf.String()
+}
diff --git a/vendor/github.com/dlclark/regexp2/v2/syntax/escape.go b/vendor/github.com/dlclark/regexp2/v2/syntax/escape.go
new file mode 100644
index 0000000000..40dea1781e
--- /dev/null
+++ b/vendor/github.com/dlclark/regexp2/v2/syntax/escape.go
@@ -0,0 +1,94 @@
+package syntax
+
+import (
+ "bytes"
+ "strconv"
+ "strings"
+ "unicode"
+)
+
+func Escape(input string) string {
+ b := &bytes.Buffer{}
+ for _, r := range input {
+ escape(b, r, false)
+ }
+ return b.String()
+}
+
+const meta = `\.+*?()|[]{}^$# `
+
+func escape(b *bytes.Buffer, r rune, force bool) {
+ if unicode.IsPrint(r) {
+ if strings.ContainsRune(meta, r) || force {
+ b.WriteRune('\\')
+ }
+ b.WriteRune(r)
+ return
+ }
+
+ switch r {
+ case '\a':
+ b.WriteString(`\a`)
+ case '\f':
+ b.WriteString(`\f`)
+ case '\n':
+ b.WriteString(`\n`)
+ case '\r':
+ b.WriteString(`\r`)
+ case '\t':
+ b.WriteString(`\t`)
+ case '\v':
+ b.WriteString(`\v`)
+ default:
+ if r < 0x100 {
+ b.WriteString(`\x`)
+ s := strconv.FormatInt(int64(r), 16)
+ if len(s) == 1 {
+ b.WriteRune('0')
+ }
+ b.WriteString(s)
+ break
+ }
+ b.WriteString(`\u`)
+ b.WriteString(strconv.FormatInt(int64(r), 16))
+ }
+}
+
+func Unescape(input string) (string, error) {
+ idx := strings.IndexRune(input, '\\')
+ // no slashes means no unescape needed
+ if idx == -1 {
+ return input, nil
+ }
+
+ buf := bytes.NewBufferString(input[:idx])
+ // get the runes for the rest of the string -- we're going full parser scan on this
+
+ p := parser{}
+ p.setPattern(input[idx+1:])
+ for {
+ if p.rightMost() {
+ return "", p.getErr(ErrIllegalEndEscape)
+ }
+ r, err := p.scanCharEscape()
+ if err != nil {
+ return "", err
+ }
+ buf.WriteRune(r)
+ // are we done?
+ if p.rightMost() {
+ return buf.String(), nil
+ }
+
+ r = p.moveRightGetChar()
+ for r != '\\' {
+ buf.WriteRune(r)
+ if p.rightMost() {
+ // we're done, no more slashes
+ return buf.String(), nil
+ }
+ // keep scanning until we get another slash
+ r = p.moveRightGetChar()
+ }
+ }
+}
diff --git a/vendor/github.com/dlclark/regexp2/v2/syntax/fuzz.go b/vendor/github.com/dlclark/regexp2/v2/syntax/fuzz.go
new file mode 100644
index 0000000000..41cf8852b7
--- /dev/null
+++ b/vendor/github.com/dlclark/regexp2/v2/syntax/fuzz.go
@@ -0,0 +1,21 @@
+//go:build gofuzz
+// +build gofuzz
+
+package syntax
+
+// Fuzz is the input point for go-fuzz
+func Fuzz(data []byte) int {
+ sdata := string(data)
+ tree, err := Parse(sdata, ParseOptions{})
+ if err != nil {
+ return 0
+ }
+
+ // translate it to code
+ _, err = Write(tree)
+ if err != nil {
+ panic(err)
+ }
+
+ return 1
+}
diff --git a/vendor/github.com/dlclark/regexp2/v2/syntax/optimizations.go b/vendor/github.com/dlclark/regexp2/v2/syntax/optimizations.go
new file mode 100644
index 0000000000..0186497a0c
--- /dev/null
+++ b/vendor/github.com/dlclark/regexp2/v2/syntax/optimizations.go
@@ -0,0 +1,672 @@
+package syntax
+
+import (
+ "bytes"
+ "cmp"
+ "fmt"
+ "slices"
+)
+
+type FindOptimizations struct {
+ rightToLeft bool
+ asciiLookups [][]uint
+
+ FindMode FindNextStartingPositionMode
+ LeadingAnchor NodeType
+ TrailingAnchor NodeType
+ MinRequiredLength int
+ MaxPossibleLength int
+ LeadingPrefix string
+ LeadingPrefixes []string
+ LeadingPrefixesRunes [][]rune
+ //LeadingStrings *helpers.StringSearchValues
+
+ FixedDistanceLiteral FixedDistanceLiteral
+ FixedDistanceSets []FixedDistanceSet
+ LiteralAfterLoop *LiteralAfterLoop
+ LandmarkChain *RequiredLandmarkChain
+}
+
+type LiteralAfterLoop struct {
+ String string
+ StringIgnoreCase bool
+ Char rune
+ Chars []rune
+
+ LoopNode *RegexNode
+}
+
+type FixedDistanceSet struct {
+ Set *CharSet
+ Chars []rune
+ Negated bool
+ Range *SingleRange
+ Distance int
+}
+
+type FixedDistanceLiteral struct {
+ S string
+ C rune
+ Distance int
+}
+
+type RequiredLandmarkChain struct {
+ // LeadingLoopSet is the unbounded leading set loop that precedes every
+ // landmark in the original concatenation. At run time, after the first
+ // landmark alternative is found, the scanner walks backward over this set
+ // to recover the earliest plausible regex start position.
+ LeadingLoopSet *CharSet
+
+ // Landmarks must all be found, in slice order, for the chain prefilter to
+ // produce a candidate. Each landmark is satisfied by exactly one matching
+ // alternative; alternatives are tried independently by the runner.
+ Landmarks []RequiredLandmark
+}
+
+type RequiredLandmark struct {
+ // Alternatives describes the mutually exclusive shapes that can satisfy
+ // this single required landmark. A landmark matches when any one alternative
+ // matches at a position in the input.
+ Alternatives []RequiredLandmarkAlternative
+}
+
+type RequiredLandmarkAlternative struct {
+ // Literal is the core token for literal alternatives. When non-empty, it
+ // must match exactly at the candidate core position, and Set must be nil.
+ Literal []rune
+
+ // Set is the core token for character-class alternatives. When non-nil, it
+ // must match between MinRepeat and MaxRepeat runes at the candidate core
+ // position, and Literal must be empty. The analyzer only builds set
+ // alternatives for non-negated sets that can be cheaply enumerated, but the
+ // runner uses Set for membership checks.
+ Set *CharSet
+
+ // LeadingWhitespaceSet is the optional or required whitespace immediately
+ // before the core token. If RequireWhitespaceBefore is true, at least one
+ // rune from this set must precede the core. When this alternative is the
+ // first matched landmark, the runner may rewind over additional contiguous
+ // leading whitespace from this set before rewinding over LeadingLoopSet.
+ LeadingWhitespaceSet *CharSet
+
+ // TrailingWhitespaceSet is the optional or required whitespace immediately
+ // after the core token. If RequireWhitespaceAfter is true, at least one rune
+ // from this set must follow the core. The runner validates the requirement,
+ // but does not consume optional trailing whitespace into the landmark end.
+ TrailingWhitespaceSet *CharSet
+
+ // MinRepeat and MaxRepeat describe the core token width. Literal alternatives
+ // use 1..1 regardless of literal length because the literal is matched as one
+ // fixed core token; Set alternatives use the source set repetition.
+ MinRepeat int
+ MaxRepeat int
+
+ RequireWhitespaceBefore bool
+ RequireWhitespaceAfter bool
+}
+
+type FindNextStartingPositionMode int
+
+const (
+ NoSearch FindNextStartingPositionMode = iota
+ // A "beginning" anchor at the beginning of the pattern.
+ LeadingAnchor_LeftToRight_Beginning
+ // A "start" anchor at the beginning of the pattern.
+ LeadingAnchor_LeftToRight_Start
+ // An "endz" anchor at the beginning of the pattern. This is rare.
+ LeadingAnchor_LeftToRight_EndZ
+ // An "end" anchor at the beginning of the pattern. This is rare.
+ LeadingAnchor_LeftToRight_End
+ // A "beginning" anchor at the beginning of the right-to-left pattern.
+ LeadingAnchor_RightToLeft_Beginning
+ // A "start" anchor at the beginning of the right-to-left pattern.
+ LeadingAnchor_RightToLeft_Start
+ // An "endz" anchor at the beginning of the right-to-left pattern. This is rare.
+ LeadingAnchor_RightToLeft_EndZ
+ // An "end" anchor at the beginning of the right-to-left pattern. This is rare.
+ LeadingAnchor_RightToLeft_End
+ // An "end" anchor at the end of the pattern, with the pattern always matching a fixed-length expression.
+ TrailingAnchor_FixedLength_LeftToRight_End
+ // An "endz" anchor at the end of the pattern, with the pattern always matching a fixed-length expression.
+ TrailingAnchor_FixedLength_LeftToRight_EndZ
+ // A multi-character substring at the beginning of the pattern.
+ LeadingString_LeftToRight
+ // A multi-character substring at the beginning of the right-to-left pattern.
+ LeadingString_RightToLeft
+ // A multi-character ordinal case-insensitive substring at the beginning of the pattern.
+ LeadingString_OrdinalIgnoreCase_LeftToRight
+ // Multiple leading prefix strings
+ LeadingStrings_LeftToRight
+ // Multiple leading ordinal case-insensitive prefix strings
+ LeadingStrings_OrdinalIgnoreCase_LeftToRight
+
+ // A set starting the pattern.
+ LeadingSet_LeftToRight
+ // A set starting the right-to-left pattern.
+ LeadingSet_RightToLeft
+
+ // A single character at the start of the right-to-left pattern.
+ LeadingChar_RightToLeft
+
+ // A single character at a fixed distance from the start of the pattern.
+ FixedDistanceChar_LeftToRight
+ // A multi-character case-sensitive string at a fixed distance from the start of the pattern.
+ FixedDistanceString_LeftToRight
+
+ // One or more sets at a fixed distance from the start of the pattern.
+ FixedDistanceSets_LeftToRight
+
+ // A literal (single character, multi-char string, or set with small number of characters) after a non-overlapping set loop at the start of the pattern.
+ LiteralAfterLoop_LeftToRight
+
+ // A sequence of required landmarks after a leading loop.
+ RequiredLandmarkChain_LeftToRight
+)
+
+func (m FindNextStartingPositionMode) String() string {
+ switch m {
+ case NoSearch:
+ return "NoSearch"
+ case LeadingAnchor_LeftToRight_Beginning:
+ return "LeadingAnchor_LeftToRight_Beginning"
+ case LeadingAnchor_LeftToRight_Start:
+ return "LeadingAnchor_LeftToRight_Start"
+ case LeadingAnchor_LeftToRight_EndZ:
+ return "LeadingAnchor_LeftToRight_EndZ"
+ case LeadingAnchor_LeftToRight_End:
+ return "LeadingAnchor_LeftToRight_End"
+ case LeadingAnchor_RightToLeft_Beginning:
+ return "LeadingAnchor_RightToLeft_Beginning"
+ case LeadingAnchor_RightToLeft_Start:
+ return "LeadingAnchor_RightToLeft_Start"
+ case LeadingAnchor_RightToLeft_EndZ:
+ return "LeadingAnchor_RightToLeft_EndZ"
+ case LeadingAnchor_RightToLeft_End:
+ return "LeadingAnchor_RightToLeft_End"
+ case TrailingAnchor_FixedLength_LeftToRight_End:
+ return "TrailingAnchor_FixedLength_LeftToRight_End"
+ case TrailingAnchor_FixedLength_LeftToRight_EndZ:
+ return "TrailingAnchor_FixedLength_LeftToRight_EndZ"
+ case LeadingString_LeftToRight:
+ return "LeadingString_LeftToRight"
+ case LeadingString_RightToLeft:
+ return "LeadingString_RightToLeft"
+ case LeadingString_OrdinalIgnoreCase_LeftToRight:
+ return "LeadingString_OrdinalIgnoreCase_LeftToRight"
+ case LeadingStrings_LeftToRight:
+ return "LeadingStrings_LeftToRight"
+ case LeadingStrings_OrdinalIgnoreCase_LeftToRight:
+ return "LeadingStrings_OrdinalIgnoreCase_LeftToRight"
+ case LeadingSet_LeftToRight:
+ return "LeadingSet_LeftToRight"
+ case LeadingSet_RightToLeft:
+ return "LeadingSet_RightToLeft"
+ case LeadingChar_RightToLeft:
+ return "LeadingChar_RightToLeft"
+ case FixedDistanceChar_LeftToRight:
+ return "FixedDistanceChar_LeftToRight"
+ case FixedDistanceString_LeftToRight:
+ return "FixedDistanceString_LeftToRight"
+ case FixedDistanceSets_LeftToRight:
+ return "FixedDistanceSets_LeftToRight"
+ case LiteralAfterLoop_LeftToRight:
+ return "LiteralAfterLoop_LeftToRight"
+ case RequiredLandmarkChain_LeftToRight:
+ return "RequiredLandmarkChain_LeftToRight"
+ default:
+ return fmt.Sprintf("FindNextStartingPositionMode(%d)", int(m))
+ }
+}
+
+func (f *FindOptimizations) Dump() string {
+ buf := &bytes.Buffer{}
+ if f == nil {
+ fmt.Fprintln(buf, "Find mode: n/a")
+ return buf.String()
+ }
+
+ fmt.Fprintf(buf, "Find mode: %s\n", f.FindMode)
+ fmt.Fprintf(buf, "Min length: %d\n", f.MinRequiredLength)
+ if f.MaxPossibleLength > 0 {
+ fmt.Fprintf(buf, "Max length: %d\n", f.MaxPossibleLength)
+ }
+
+ switch f.FindMode {
+ case LeadingAnchor_LeftToRight_Beginning, LeadingAnchor_LeftToRight_Start,
+ LeadingAnchor_LeftToRight_EndZ, LeadingAnchor_LeftToRight_End,
+ LeadingAnchor_RightToLeft_Beginning, LeadingAnchor_RightToLeft_Start,
+ LeadingAnchor_RightToLeft_EndZ, LeadingAnchor_RightToLeft_End:
+ fmt.Fprintf(buf, "Anchor: %v\n", f.LeadingAnchor)
+
+ case TrailingAnchor_FixedLength_LeftToRight_End, TrailingAnchor_FixedLength_LeftToRight_EndZ:
+ fmt.Fprintf(buf, "Anchor: %v\n", f.TrailingAnchor)
+
+ case LeadingString_LeftToRight, LeadingString_RightToLeft, LeadingString_OrdinalIgnoreCase_LeftToRight:
+ fmt.Fprintf(buf, "Prefix: %q\n", f.LeadingPrefix)
+
+ case LeadingStrings_LeftToRight, LeadingStrings_OrdinalIgnoreCase_LeftToRight:
+ fmt.Fprintf(buf, "Prefixes: %q\n", f.LeadingPrefixes)
+
+ case FixedDistanceChar_LeftToRight:
+ fmt.Fprintf(buf, "Literal: %q at distance %d\n", f.FixedDistanceLiteral.C, f.FixedDistanceLiteral.Distance)
+
+ case FixedDistanceString_LeftToRight:
+ fmt.Fprintf(buf, "Literal: %q at distance %d\n", f.FixedDistanceLiteral.S, f.FixedDistanceLiteral.Distance)
+
+ case FixedDistanceSets_LeftToRight:
+ for i, set := range f.FixedDistanceSets {
+ fmt.Fprintf(buf, "Set[%d]: distance=%d %s\n", i, set.Distance, fixedDistanceSetDescription(set))
+ }
+
+ case LiteralAfterLoop_LeftToRight:
+ fmt.Fprintf(buf, "Literal: %s\n", literalAfterLoopDescription(f.LiteralAfterLoop))
+
+ case RequiredLandmarkChain_LeftToRight:
+ fmt.Fprintf(buf, "Landmarks: %s\n", landmarkChainDescription(f.LandmarkChain))
+ }
+
+ return buf.String()
+}
+
+func fixedDistanceSetDescription(set FixedDistanceSet) string {
+ switch {
+ case len(set.Chars) > 0:
+ return fmt.Sprintf("chars=%q negated=%t", string(set.Chars), set.Negated)
+ case set.Range != nil:
+ return fmt.Sprintf("range=%q-%q negated=%t", set.Range.First, set.Range.Last, set.Negated)
+ case set.Set != nil:
+ return fmt.Sprintf("set=%s", set.Set.String())
+ default:
+ return "set="
+ }
+}
+
+func literalAfterLoopDescription(literal *LiteralAfterLoop) string {
+ if literal == nil {
+ return ""
+ }
+ loopSet := ""
+ if literal.LoopNode != nil && literal.LoopNode.Set != nil {
+ loopSet = literal.LoopNode.Set.String()
+ }
+ switch {
+ case literal.String != "":
+ return fmt.Sprintf("string=%q ignoreCase=%t after loop set %s", literal.String, literal.StringIgnoreCase, loopSet)
+ case len(literal.Chars) > 0:
+ return fmt.Sprintf("chars=%q after loop set %s", string(literal.Chars), loopSet)
+ default:
+ return fmt.Sprintf("char=%q after loop set %s", literal.Char, loopSet)
+ }
+}
+
+func landmarkChainDescription(chain *RequiredLandmarkChain) string {
+ if chain == nil {
+ return ""
+ }
+ loopSet := ""
+ if chain.LeadingLoopSet != nil {
+ loopSet = chain.LeadingLoopSet.String()
+ }
+ buf := &bytes.Buffer{}
+ fmt.Fprintf(buf, "leadingLoop=%s", loopSet)
+ for i, landmark := range chain.Landmarks {
+ fmt.Fprintf(buf, " landmark[%d]=", i)
+ for j, alt := range landmark.Alternatives {
+ if j > 0 {
+ buf.WriteString("|")
+ }
+ buf.WriteString(requiredLandmarkAlternativeDescription(alt))
+ }
+ }
+ return buf.String()
+}
+
+func requiredLandmarkAlternativeDescription(alt RequiredLandmarkAlternative) string {
+ core := ""
+ switch {
+ case len(alt.Literal) > 0:
+ core = fmt.Sprintf("literal=%q", string(alt.Literal))
+ case alt.Set != nil:
+ core = fmt.Sprintf("set=%s repeat=%d..%d", alt.Set.String(), alt.MinRepeat, alt.MaxRepeat)
+ default:
+ core = ""
+ }
+ if alt.LeadingWhitespaceSet != nil {
+ core += fmt.Sprintf(" leadingWhitespace=%s required=%t", alt.LeadingWhitespaceSet.String(), alt.RequireWhitespaceBefore)
+ }
+ if alt.TrailingWhitespaceSet != nil {
+ core += fmt.Sprintf(" trailingWhitespace=%s required=%t", alt.TrailingWhitespaceSet.String(), alt.RequireWhitespaceAfter)
+ }
+ return core
+}
+
+func newFindOptimizations(tree *RegexTree, opt ParseOptions) *FindOptimizations {
+ f := newFindOptimizationsForNode(tree.Root, opt, false)
+
+ if !f.rightToLeft && !f.isUseful() {
+ if positiveLookahead, _ := findLeadingPositiveLookahead(tree.Root); positiveLookahead != nil {
+ positiveLookaheadOpts := newFindOptimizationsForNode(positiveLookahead.Children[0], opt, true)
+
+ // Lookaheads don't currently factor into the whole-pattern length analysis,
+ // as they can overlap with the rest of the expression. Keep the whole-pattern
+ // minimum if it's larger, and preserve any max from the original expression.
+ positiveLookaheadOpts.MinRequiredLength = max(f.MinRequiredLength, positiveLookaheadOpts.MinRequiredLength)
+ positiveLookaheadOpts.MaxPossibleLength = f.MaxPossibleLength
+ f = positiveLookaheadOpts
+ }
+ }
+
+ return f
+}
+
+func newFindOptimizationsForNode(root *RegexNode, opt ParseOptions, isLeadingPartial bool) *FindOptimizations {
+ f := &FindOptimizations{
+ rightToLeft: opt.RegexOptions&RightToLeft != 0,
+ MinRequiredLength: root.ComputeMinLength(),
+ LeadingAnchor: findLeadingOrTrailingAnchor(root, true),
+ MaxPossibleLength: -1,
+ }
+
+ if f.rightToLeft && f.LeadingAnchor == NtBol {
+ // Filter out Bol for RightToLeft, as we don't currently optimize for it.
+ f.LeadingAnchor = NtUnknown
+ }
+
+ f.FindMode = getFindMode(f.rightToLeft, f.LeadingAnchor)
+ if f.FindMode != NoSearch {
+ return f
+ }
+
+ // Compute any anchor trailing the expression. If there is one, and we can also compute a fixed length
+ // for the whole expression, we can use that to quickly jump to the right location in the input.
+ if !f.rightToLeft && !isLeadingPartial {
+ f.TrailingAnchor = findLeadingOrTrailingAnchor(root, false)
+ if f.TrailingAnchor == NtEnd || f.TrailingAnchor == NtEndZ {
+ f.MaxPossibleLength = root.computeMaxLength()
+ if f.MinRequiredLength == f.MaxPossibleLength {
+ if f.TrailingAnchor == NtEnd {
+ f.FindMode = TrailingAnchor_FixedLength_LeftToRight_End
+ } else {
+ f.FindMode = TrailingAnchor_FixedLength_LeftToRight_EndZ
+ }
+ return f
+ }
+ }
+ }
+
+ // If there's a leading substring, just use IndexOf and inherit all of its optimizations.
+ prefix := findPrefix(root)
+ if len(prefix) > 1 {
+ f.LeadingPrefix = prefix
+ if f.rightToLeft {
+ f.FindMode = LeadingString_RightToLeft
+ } else {
+ f.FindMode = LeadingString_LeftToRight
+ }
+ return f
+ }
+
+ // At this point there are no fast-searchable anchors or case-sensitive prefixes. We can now analyze the
+ // pattern for sets and then use any found sets to determine what kind of search to perform.
+
+ // If we're generating code, then the code generation process already handles sets that reduce to a single literal,
+ // so we can simplify and just always go for the sets.
+ dfa := false //(opt&NonBacktracking) != 0
+ codeGen := opt.CodeGen && !dfa // for now, we never generate code for NonBacktracking, so treat it as non-codegen
+ interpreter := !codeGen && !dfa
+ //usesRfoTryFind := !codeGen
+
+ // For interpreter, we want to employ optimizations, but we don't want to make construction significantly
+ // more expensive. regexp2cg can opt into more expensive analysis with OptionIsCodeGen. So for the
+ // interpreter we focus only on creating a set for the first character. Same for right-to-left, which
+ // is used very rarely and thus we don't need to invest in special-casing it.
+ if f.rightToLeft {
+ // Determine a set for anything that can possibly start the expression.
+ set := findFirstCharClass(root)
+ if set != nil {
+ var chars []rune
+ if !set.IsNegated() {
+ // See if the set is limited to holding only a few characters.
+ chars = set.GetSetChars(5)
+ }
+
+ if !codeGen && len(chars) == 1 {
+ // The set contains one and only one character, meaning every match starts
+ // with the same literal value (potentially case-insensitive). Search for that.
+ f.FixedDistanceLiteral.C = chars[0]
+ f.FindMode = LeadingChar_RightToLeft
+ } else {
+ // The set may match multiple characters. Search for that.
+ f.FixedDistanceSets = []FixedDistanceSet{{
+ Chars: chars,
+ Set: set,
+ Distance: 0,
+ }}
+ f.FindMode = LeadingSet_RightToLeft
+ f.asciiLookups = make([][]uint, 1)
+ }
+ }
+ return f
+ }
+
+ // We're now left-to-right only.
+
+ prefix = findPrefixOrdinalCaseInsensitive(root)
+ if len(prefix) > 1 {
+ f.LeadingPrefix = prefix
+ f.FindMode = LeadingString_OrdinalIgnoreCase_LeftToRight
+ return f
+ }
+
+ // We're now left-to-right only and looking for multiple prefixes and/or sets.
+
+ // If there are multiple leading strings, we can search for any of them.
+ // this works in the interpreter, but we avoid it due to additional cost during construction
+
+ if !interpreter {
+ ciPrefixes := findPrefixes(root, true)
+ if len(ciPrefixes) > 1 {
+ f.LeadingPrefixes = ciPrefixes
+ f.LeadingPrefixesRunes = toRunePrefixes(ciPrefixes)
+ f.FindMode = LeadingStrings_OrdinalIgnoreCase_LeftToRight
+ /*SYSTEM_TEXT_REGULAREXPRESSIONS
+ if usesRfoTryFind {
+ f.LeadingStrings = helpers.NewSearchValues(f.LeadingPrefixes, true)
+ }*/
+ return f
+ }
+ }
+
+ // Build up a list of all of the sets that are a fixed distance from the start of the expression.
+ fixedDistanceSets := findFixedDistanceSets(root, !interpreter)
+
+ // See if we can make a string of at least two characters long out of those sets. We should have already caught
+ // one at the beginning of the pattern, but there may be one hiding at a non-zero fixed distance into the pattern.
+ if len(fixedDistanceSets) > 0 {
+ bestFixedDistanceString := findFixedDistanceString(fixedDistanceSets)
+ if bestFixedDistanceString != nil {
+ f.FindMode = FixedDistanceString_LeftToRight
+ f.FixedDistanceLiteral = *bestFixedDistanceString
+ return f
+ }
+ }
+
+ // A landmark chain is more selective than a single leading set for shapes like
+ // /name-separator host-separator domain/. Prefer it before falling back to
+ // one-position or one-literal candidate searches.
+ if landmarkChain := findRequiredLandmarkChain(root); landmarkChain != nil {
+ f.FindMode = RequiredLandmarkChain_LeftToRight
+ f.LandmarkChain = landmarkChain
+ return f
+ }
+
+ // As a backup, see if we can find a literal after a leading atomic loop. That might be better than whatever sets we find, so
+ // we want to know whether we have one in our pocket before deciding whether to use a leading set (we'll prefer a leading
+ // set if it's something for which we can search efficiently).
+ literalAfterLoop := findLiteralFollowingLeadingLoop(root)
+
+ // If we got such sets, we'll likely use them. However, if the best of them is something that doesn't support an efficient
+ // search and we did successfully find a literal after an atomic loop we could search instead, we prefer the efficient search.
+ // For example, if we have a negated set, we will still prefer the literal-after-an-atomic-loop because negated sets typically
+ // contain _many_ characters (e.g. [^a] is everything but 'a') and are thus more likely to very quickly match, which means any
+ // vectorization employed is less likely to kick in and be worth the startup overhead.
+ if len(fixedDistanceSets) > 0 {
+ // Sort the sets by "quality", such that whatever set is first is the one deemed most efficient to use.
+ // In some searches, we may use multiple sets, so we want the subsequent ones to also be the efficiency runners-up.
+ slices.SortFunc(fixedDistanceSets, compareFixedDistanceSetsByQuality)
+
+ // If the best fixed-distance set is composed of high-frequency characters, IndexOfAny on
+ // those characters is likely to match too many positions. Prefer a case-sensitive
+ // multi-prefix search when one is available.
+ if !interpreter && !mayContainCaseInsensitiveMatching(root) && hasHighFrequencyChars(fixedDistanceSets[0]) {
+ caseSensitivePrefixes := findPrefixes(root, false)
+ if len(caseSensitivePrefixes) > 1 {
+ f.LeadingPrefixes = caseSensitivePrefixes
+ f.LeadingPrefixesRunes = toRunePrefixes(caseSensitivePrefixes)
+ f.FindMode = LeadingStrings_LeftToRight
+ return f
+ }
+ }
+
+ // If there is no literal after the loop, use whatever set we got.
+ // If there is a literal after the loop, consider it to be better than a negated set and better than a set with many characters.
+ if literalAfterLoop == nil || (len(fixedDistanceSets[0].Chars) > 0 && !fixedDistanceSets[0].Negated) {
+ // Determine whether to do searching based on one or more sets or on a single literal. Code-generated engines
+ // don't need to special-case literals as they already do codegen to create the optimal lookup based on
+ // the set's characteristics.
+ if !codeGen && len(fixedDistanceSets) == 1 && len(fixedDistanceSets[0].Chars) == 1 &&
+ !fixedDistanceSets[0].Negated {
+ f.FixedDistanceLiteral = FixedDistanceLiteral{
+ C: fixedDistanceSets[0].Chars[0],
+ Distance: fixedDistanceSets[0].Distance,
+ }
+ f.FindMode = FixedDistanceChar_LeftToRight
+ } else {
+ // Limit how many sets we use to avoid doing lots of unnecessary work. The list was already
+ // sorted from best to worst, so just keep the first ones up to our limit.
+ const MaxSetsToUse = 3 // arbitrary tuned limit
+ if len(fixedDistanceSets) > MaxSetsToUse {
+ fixedDistanceSets = fixedDistanceSets[:MaxSetsToUse]
+ }
+
+ // Store the sets, and compute which mode to use.
+ f.FixedDistanceSets = fixedDistanceSets
+ if len(fixedDistanceSets) == 1 && fixedDistanceSets[0].Distance == 0 {
+ f.FindMode = LeadingSet_LeftToRight
+ } else {
+ f.FindMode = FixedDistanceSets_LeftToRight
+ }
+ f.asciiLookups = make([][]uint, len(fixedDistanceSets))
+ }
+ return f
+ }
+ }
+
+ // If we found a literal we can search for after a leading set loop, use it.
+ if literalAfterLoop != nil {
+ f.FindMode = LiteralAfterLoop_LeftToRight
+ f.LiteralAfterLoop = literalAfterLoop
+ f.asciiLookups = make([][]uint, 1)
+ }
+
+ return f
+}
+
+func (f *FindOptimizations) isUseful() bool {
+ return f.FindMode != NoSearch || f.LeadingAnchor == NtBol
+}
+
+func toRunePrefixes(prefixes []string) [][]rune {
+ if len(prefixes) == 0 {
+ return nil
+ }
+ runes := make([][]rune, len(prefixes))
+ for i, prefix := range prefixes {
+ runes[i] = []rune(prefix)
+ }
+ return runes
+}
+
+func getFindMode(rtl bool, t NodeType) FindNextStartingPositionMode {
+ if rtl {
+ switch t {
+ case NtBeginning:
+ return LeadingAnchor_RightToLeft_Beginning
+ case NtStart:
+ return LeadingAnchor_RightToLeft_Start
+ case NtEnd:
+ return LeadingAnchor_RightToLeft_End
+ case NtEndZ:
+ return LeadingAnchor_RightToLeft_EndZ
+ }
+ } else {
+ switch t {
+ case NtBeginning:
+ return LeadingAnchor_LeftToRight_Beginning
+ case NtStart:
+ return LeadingAnchor_LeftToRight_Start
+ case NtEnd:
+ return LeadingAnchor_LeftToRight_End
+ case NtEndZ:
+ return LeadingAnchor_LeftToRight_EndZ
+ }
+ }
+
+ return NoSearch
+}
+
+// Analyzes a list of fixed-distance sets to extract a case-sensitive string at a fixed distance.
+func findFixedDistanceString(fixedDistanceSets []FixedDistanceSet) *FixedDistanceLiteral {
+ var best *FixedDistanceLiteral
+
+ // A result string must be at least two characters in length; therefore we require at least that many sets.
+ if len(fixedDistanceSets) >= 2 {
+ // We're walking the sets from beginning to end, so we need them sorted by distance.
+ slices.SortFunc(fixedDistanceSets, func(s1, s2 FixedDistanceSet) int {
+ return cmp.Compare(s1.Distance, s2.Distance)
+ })
+
+ vsb := &bytes.Buffer{}
+
+ // Looking for strings of length >= 2
+ start := -1
+ for i := 0; i < len(fixedDistanceSets)+1; i++ {
+ chars := []rune(nil)
+ if i < len(fixedDistanceSets) {
+ chars = fixedDistanceSets[i].Chars
+ }
+ invalidChars := len(chars) != 1 || fixedDistanceSets[i].Negated
+
+ // If the current set ends a sequence (or we've walked off the end), see whether
+ // what we've gathered constitues a valid string, and if it's better than the
+ // best we've already seen, store it. Regardless, reset the sequence in order
+ // to continue analyzing.
+ if invalidChars || (i > 0 && fixedDistanceSets[i].Distance != fixedDistanceSets[i-1].Distance+1) {
+ bestLen := 2
+ if best != nil {
+ bestLen = len(best.S)
+ }
+ if start != -1 && i-start >= bestLen {
+ best = &FixedDistanceLiteral{
+ S: vsb.String(),
+ Distance: fixedDistanceSets[start].Distance,
+ }
+ }
+
+ vsb.Reset()
+ start = -1
+ if invalidChars {
+ continue
+ }
+ }
+
+ if start == -1 {
+ start = i
+ }
+
+ vsb.WriteRune(chars[0])
+ }
+ }
+
+ return best
+}
diff --git a/vendor/github.com/dlclark/regexp2/v2/syntax/parser.go b/vendor/github.com/dlclark/regexp2/v2/syntax/parser.go
new file mode 100644
index 0000000000..9e9029a8c1
--- /dev/null
+++ b/vendor/github.com/dlclark/regexp2/v2/syntax/parser.go
@@ -0,0 +1,2529 @@
+package syntax
+
+import (
+ "fmt"
+ "math"
+ "sort"
+ "strconv"
+ "strings"
+ "unicode"
+)
+
+type RegexOptions int32
+
+const (
+ IgnoreCase RegexOptions = 0x0001 // "i"
+ Multiline RegexOptions = 0x0002 // "m"
+ ExplicitCapture RegexOptions = 0x0004 // "n"
+ Singleline RegexOptions = 0x0010 // "s"
+ IgnorePatternWhitespace RegexOptions = 0x0020 // "x"
+ RightToLeft RegexOptions = 0x0040 // "r"
+ ECMAScript RegexOptions = 0x0100 // "e"
+ RE2 RegexOptions = 0x0200 // RE2 compat mode
+ Unicode RegexOptions = 0x0400 // "u"
+)
+
+func optionFromCode(ch rune) RegexOptions {
+ // case-insensitive
+ switch ch {
+ case 'i', 'I':
+ return IgnoreCase
+ case 'r', 'R':
+ return RightToLeft
+ case 'm', 'M':
+ return Multiline
+ case 'n', 'N':
+ return ExplicitCapture
+ case 's', 'S':
+ return Singleline
+ case 'x', 'X':
+ return IgnorePatternWhitespace
+ case 'e', 'E':
+ return ECMAScript
+ case 'u', 'U':
+ return Unicode
+ default:
+ return 0
+ }
+}
+
+// An Error describes a failure to parse a regular expression
+// and gives the offending expression.
+type Error struct {
+ Code ErrorCode
+ Expr string
+ Args []interface{}
+}
+
+func (e *Error) Error() string {
+ if len(e.Args) == 0 {
+ return "error parsing regexp: " + e.Code.String() + " in `" + e.Expr + "`"
+ }
+ return "error parsing regexp: " + fmt.Sprintf(e.Code.String(), e.Args...) + " in `" + e.Expr + "`"
+}
+
+// An ErrorCode describes a failure to parse a regular expression.
+type ErrorCode string
+
+const (
+ // internal issue
+ ErrInternalError ErrorCode = "regexp/syntax: internal error"
+ // Parser errors
+ ErrUnterminatedComment = "unterminated comment"
+ ErrInvalidCharRange = "invalid character class range"
+ ErrInvalidRepeatSize = "invalid repeat count"
+ ErrInvalidUTF8 = "invalid UTF-8"
+ ErrCaptureGroupOutOfRange = "capture group number out of range"
+ ErrUnexpectedParen = "unexpected )"
+ ErrMissingParen = "missing closing )"
+ ErrMissingBrace = "missing closing }"
+ ErrInvalidRepeatOp = "invalid nested repetition operator"
+ ErrMissingRepeatArgument = "missing argument to repetition operator"
+ ErrConditionalExpression = "illegal conditional (?(...)) expression"
+ ErrTooManyAlternates = "too many | in (?()|)"
+ ErrUnrecognizedGrouping = "unrecognized grouping construct: (%v"
+ ErrInvalidGroupName = "invalid group name: group names must begin with a word character and have a matching terminator"
+ ErrInvalidECMAGroupName = "invalid capture group name"
+ ErrDuplicateGroupName = "duplicate capture group name"
+ ErrCapNumNotZero = "capture number cannot be zero"
+ ErrUndefinedBackRef = "reference to undefined group number %v"
+ ErrUndefinedNameRef = "reference to undefined group name %v"
+ ErrAlternationCantCapture = "alternation conditions do not capture and cannot be named"
+ ErrAlternationCantHaveComment = "alternation conditions cannot be comments"
+ ErrMalformedReference = "(?(%v) ) malformed"
+ ErrUndefinedReference = "(?(%v) ) reference to undefined group"
+ ErrIllegalEndEscape = "illegal \\ at end of pattern"
+ ErrMalformedSlashP = "malformed \\p{X} character escape"
+ ErrIncompleteSlashP = "incomplete \\p{X} character escape"
+ ErrUnknownSlashP = "unknown unicode category, script, or property '%v'"
+ ErrUnrecognizedEscape = "unrecognized escape sequence \\%v"
+ ErrMissingControl = "missing control character"
+ ErrUnrecognizedControl = "unrecognized control character"
+ ErrTooFewHex = "insufficient hexadecimal digits"
+ ErrInvalidHex = "hex values may not be larger than 0x10FFFF"
+ ErrMalformedNameRef = "malformed \\k<...> named back reference"
+ ErrBadClassInCharRange = "cannot include class \\%v in character range"
+ ErrShorthandClassInCharRange = "cannot create range with shorthand escape sequence \\%v"
+ ErrUnterminatedBracket = "unterminated [] set"
+ ErrSubtractionMustBeLast = "a subtraction must be the last element in a character class"
+ ErrReversedCharRange = "[%c-%c] range in reverse order"
+)
+
+func (e ErrorCode) String() string {
+ return string(e)
+}
+
+type parser struct {
+ stack *RegexNode
+ group *RegexNode
+ alternation *RegexNode
+ concatenation *RegexNode
+ unit *RegexNode
+
+ patternRaw string
+ pattern []rune
+
+ currentPos int
+
+ autocap int
+ capcount int
+ captop int
+ capsize int
+
+ caps map[int]int
+ capnames map[string]int
+
+ maintainCaptureOrder bool
+
+ capnumlist []int
+ capnamelist []string
+
+ options RegexOptions
+ optionsStack []RegexOptions
+ ignoreNextParen bool
+}
+
+type ParseOptions struct {
+ RegexOptions RegexOptions
+ MaintainCaptureOrder bool
+ CodeGen bool
+}
+
+const (
+ maxValueDiv10 int = math.MaxInt32 / 10
+ maxValueMod10 = math.MaxInt32 % 10
+)
+
+// Parse converts a regex string into a parse tree
+func Parse(re string, op ParseOptions) (*RegexTree, error) {
+ p := parser{
+ options: op.RegexOptions,
+ caps: make(map[int]int),
+ maintainCaptureOrder: op.MaintainCaptureOrder || (op.RegexOptions&ECMAScript) != 0,
+ }
+ p.setPattern(re)
+
+ if err := p.countCaptures(); err != nil {
+ return nil, err
+ }
+
+ p.reset(op.RegexOptions)
+ root, err := p.scanRegex()
+
+ if err != nil {
+ return nil, err
+ }
+ tree := &RegexTree{
+ Root: root,
+ Caps: p.caps,
+ Capnumlist: p.capnumlist,
+ Captop: p.captop,
+ Capnames: p.capnames,
+ Caplist: p.capnamelist,
+ Options: op.RegexOptions,
+ }
+ tree.FindOptimizations = newFindOptimizations(tree, op)
+
+ return tree, nil
+}
+
+func (p *parser) setPattern(pattern string) {
+ p.patternRaw = pattern
+ p.pattern = make([]rune, 0, len(pattern))
+
+ //populate our rune array to handle utf8 encoding
+ for _, r := range pattern {
+ p.pattern = append(p.pattern, r)
+ }
+}
+func (p *parser) getErr(code ErrorCode, args ...interface{}) error {
+ return &Error{Code: code, Expr: p.patternRaw, Args: args}
+}
+
+func (p *parser) noteCaptureSlot(i, pos int) {
+ if _, ok := p.caps[i]; !ok {
+ // the rhs of the hashtable isn't used in the parser
+ p.caps[i] = pos
+ p.capcount++
+
+ if p.captop <= i {
+ if i == math.MaxInt32 {
+ p.captop = i
+ } else {
+ p.captop = i + 1
+ }
+ }
+ }
+}
+
+func (p *parser) noteCaptureName(name string, pos int) error {
+ if p.capnames == nil {
+ p.capnames = make(map[string]int)
+ }
+
+ if _, ok := p.capnames[name]; !ok {
+ if p.maintainCaptureOrder {
+ slot := p.consumeAutocap()
+ p.capnames[name] = slot
+ p.noteCaptureSlot(slot, pos)
+ } else {
+ p.capnames[name] = pos
+ }
+ p.capnamelist = append(p.capnamelist, name)
+ } else if p.useOptionE() {
+ return p.getErr(ErrDuplicateGroupName)
+ }
+ return nil
+}
+
+func (p *parser) assignNameSlots() {
+ if p.maintainCaptureOrder {
+ p.assignOrderedNameSlots()
+ return
+ }
+
+ if p.capnames != nil {
+ for _, name := range p.capnamelist {
+ for p.isCaptureSlot(p.autocap) {
+ p.autocap++
+ }
+ pos := p.capnames[name]
+ p.capnames[name] = p.autocap
+ p.noteCaptureSlot(p.autocap, pos)
+
+ p.autocap++
+ }
+ }
+
+ // if the caps array has at least one gap, construct the list of used slots
+ if p.capcount < p.captop {
+ p.capnumlist = make([]int, p.capcount)
+ i := 0
+
+ for k := range p.caps {
+ p.capnumlist[i] = k
+ i++
+ }
+
+ sort.Ints(p.capnumlist)
+ }
+
+ // merge capsnumlist into capnamelist
+ if p.capnames != nil || p.capnumlist != nil {
+ var oldcapnamelist []string
+ var next int
+ var k int
+
+ if p.capnames == nil {
+ oldcapnamelist = nil
+ p.capnames = make(map[string]int)
+ p.capnamelist = []string{}
+ next = -1
+ } else {
+ oldcapnamelist = p.capnamelist
+ p.capnamelist = []string{}
+ next = p.capnames[oldcapnamelist[0]]
+ }
+
+ for i := 0; i < p.capcount; i++ {
+ j := i
+ if p.capnumlist != nil {
+ j = p.capnumlist[i]
+ }
+
+ if next == j {
+ p.capnamelist = append(p.capnamelist, oldcapnamelist[k])
+ k++
+
+ if k == len(oldcapnamelist) {
+ next = -1
+ } else {
+ next = p.capnames[oldcapnamelist[k]]
+ }
+
+ } else {
+ //feature: culture?
+ str := strconv.Itoa(j)
+ p.capnamelist = append(p.capnamelist, str)
+ p.capnames[str] = j
+ }
+ }
+ }
+}
+
+func (p *parser) assignOrderedNameSlots() {
+ if !p.useOptionE() && p.capnames == nil && p.capcount == p.captop {
+ return
+ }
+
+ if p.capcount < p.captop {
+ p.capnumlist = make([]int, p.capcount)
+ i := 0
+ for k := range p.caps {
+ p.capnumlist[i] = k
+ i++
+ }
+ sort.Ints(p.capnumlist)
+ }
+
+ names := p.capnamelist
+ p.capnamelist = make([]string, p.capcount)
+ if p.capnames == nil {
+ p.capnames = make(map[string]int, p.capcount)
+ }
+
+ for _, name := range names {
+ slot := p.capnames[name]
+ index := slot
+ if p.capnumlist != nil {
+ for i, capnum := range p.capnumlist {
+ if capnum == slot {
+ index = i
+ break
+ }
+ }
+ }
+ p.capnamelist[index] = name
+ }
+
+ for i := 0; i < p.capcount; i++ {
+ slot := i
+ if p.capnumlist != nil {
+ slot = p.capnumlist[i]
+ }
+ if p.useOptionE() {
+ continue
+ }
+ if p.capnamelist[i] == "" {
+ p.capnamelist[i] = strconv.Itoa(slot)
+ }
+ if _, ok := p.capnames[p.capnamelist[i]]; !ok {
+ p.capnames[p.capnamelist[i]] = slot
+ }
+ }
+}
+
+func (p *parser) consumeAutocap() int {
+ r := p.autocap
+ p.autocap++
+ return r
+}
+
+func (p *parser) consumeCaptureSlot(capnum int) {
+ if p.maintainCaptureOrder && capnum == p.autocap {
+ p.consumeAutocap()
+ }
+}
+
+// CountCaptures is a prescanner for deducing the slots used for
+// captures by doing a partial tokenization of the pattern.
+func (p *parser) countCaptures() error {
+ var ch rune
+
+ p.noteCaptureSlot(0, 0)
+
+ p.autocap = 1
+
+ for p.charsRight() > 0 {
+ pos := p.textpos()
+ ch = p.moveRightGetChar()
+ switch ch {
+ case '\\':
+ if p.charsRight() > 0 {
+ _, _ = p.scanBackslash(true)
+ }
+
+ case '#':
+ if p.useOptionX() {
+ p.moveLeft()
+ _ = p.scanBlank()
+ }
+
+ case '[':
+ _, _ = p.scanCharSet(false, true)
+
+ case ')':
+ if !p.emptyOptionsStack() {
+ p.popOptions()
+ }
+
+ case '(':
+ if p.charsRight() >= 2 && p.rightChar(1) == '#' && p.rightChar(0) == '?' {
+ p.moveLeft()
+ _ = p.scanBlank()
+ } else {
+ p.pushOptions()
+ if p.charsRight() > 0 && p.rightChar(0) == '?' {
+ // we have (?...
+ p.moveRight(1)
+
+ if p.charsRight() > 1 && (p.rightChar(0) == '<' || p.rightChar(0) == '\'') {
+ // named group: (?<... or (?'...
+
+ p.moveRight(1)
+ ch = p.rightChar(0)
+
+ if ch != '0' && p.isGroupNameStartChar(ch) {
+ if ch >= '1' && ch <= '9' && !p.useOptionE() {
+ dec, err := p.scanDecimal()
+ if err != nil {
+ return err
+ }
+ if p.maintainCaptureOrder {
+ if err = p.noteCaptureName(strconv.Itoa(dec), pos); err != nil {
+ return err
+ }
+ } else {
+ p.noteCaptureSlot(dec, pos)
+ }
+ } else {
+ capname, err := p.scanCapname()
+ if err != nil {
+ return err
+ }
+ if err = p.noteCaptureName(capname, pos); err != nil {
+ return err
+ }
+ }
+ }
+ } else if p.useRE2() && p.charsRight() > 2 && (p.rightChar(0) == 'P' && p.rightChar(1) == '<') {
+ // RE2-compat (?P<)
+ p.moveRight(2)
+ ch = p.rightChar(0)
+ if IsWordChar(ch) {
+ capname, err := p.scanCapname()
+ if err != nil {
+ return err
+ }
+ if err = p.noteCaptureName(capname, pos); err != nil {
+ return err
+ }
+ }
+
+ } else {
+ // (?...
+
+ // get the options if it's an option construct (?cimsx-cimsx...)
+ p.scanOptions()
+
+ if p.charsRight() > 0 {
+ if p.rightChar(0) == ')' {
+ // (?cimsx-cimsx)
+ p.moveRight(1)
+ p.popKeepOptions()
+ } else if p.rightChar(0) == '(' {
+ // alternation construct: (?(foo)yes|no)
+ // ignore the next paren so we don't capture the condition
+ p.ignoreNextParen = true
+
+ // break from here so we don't reset ignoreNextParen
+ continue
+ }
+ }
+ }
+ } else {
+ if !p.useOptionN() && !p.ignoreNextParen {
+ p.noteCaptureSlot(p.consumeAutocap(), pos)
+ }
+ }
+ }
+
+ p.ignoreNextParen = false
+
+ }
+ }
+
+ p.assignNameSlots()
+ return nil
+}
+
+func (p *parser) reset(topopts RegexOptions) {
+ p.currentPos = 0
+ p.autocap = 1
+ p.ignoreNextParen = false
+
+ if len(p.optionsStack) > 0 {
+ p.optionsStack = p.optionsStack[:0]
+ }
+
+ p.options = topopts
+ p.stack = nil
+}
+
+func (p *parser) scanRegex() (*RegexNode, error) {
+ var ch rune // nonspecial ch, means at beginning
+ isQuant := false
+
+ p.startGroup(newRegexNodeMN(NtCapture, p.options, 0, -1))
+
+ for p.charsRight() > 0 {
+ wasPrevQuantifier := isQuant
+ isQuant = false
+
+ if err := p.scanBlank(); err != nil {
+ return nil, err
+ }
+
+ startpos := p.textpos()
+
+ // move past all of the normal characters. We'll stop when we hit some kind of control character,
+ // or if IgnorePatternWhiteSpace is on, we'll stop when we see some whitespace.
+ if p.useOptionX() {
+ for p.charsRight() > 0 {
+ ch = p.rightChar(0)
+ if isStopperX(ch) && (ch != '{' || p.isTrueQuantifier()) {
+ break
+ }
+ p.moveRight(1)
+ }
+ } else {
+ for p.charsRight() > 0 {
+ ch = p.rightChar(0)
+ if isSpecial(ch) && (ch != '{' || p.isTrueQuantifier()) {
+ break
+ }
+ p.moveRight(1)
+ }
+ }
+
+ endpos := p.textpos()
+
+ if err := p.scanBlank(); err != nil {
+ return nil, err
+ }
+
+ if p.charsRight() == 0 {
+ ch = '!' // nonspecial, means at end
+ } else if ch = p.rightChar(0); isSpecial(ch) {
+ isQuant = isQuantifier(ch)
+ p.moveRight(1)
+ } else {
+ ch = ' ' // nonspecial, means at ordinary char
+ }
+
+ if startpos < endpos {
+ cchUnquantified := endpos - startpos
+ if isQuant {
+ cchUnquantified--
+ }
+ wasPrevQuantifier = false
+
+ if cchUnquantified > 0 {
+ p.addToConcatenate(startpos, cchUnquantified, false)
+ }
+
+ if isQuant {
+ p.addUnitOne(p.charAt(endpos - 1))
+ }
+ }
+
+ switch ch {
+ case '!':
+ goto BreakOuterScan
+
+ case ' ':
+ goto ContinueOuterScan
+
+ case '[':
+ cc, err := p.scanCharSet(p.useOptionI(), false)
+ if err != nil {
+ return nil, err
+ }
+ p.addUnitSet(cc)
+
+ case '(':
+ if p.useRE2() && p.charsRight() >= 3 && p.rightChar(0) == '?' && p.rightChar(1) == 'P' && p.rightChar(2) == '=' {
+ n, err := p.scanPythonNamedBackref()
+ if err != nil {
+ return nil, err
+ }
+ p.addUnitNode(n)
+ break
+ }
+
+ p.pushOptions()
+
+ if grouper, err := p.scanGroupOpen(); err != nil {
+ return nil, err
+ } else if grouper == nil {
+ p.popKeepOptions()
+ } else {
+ p.pushGroup()
+ p.startGroup(grouper)
+ }
+
+ continue
+
+ case '|':
+ p.addAlternate()
+ goto ContinueOuterScan
+
+ case ')':
+ if p.emptyStack() {
+ return nil, p.getErr(ErrUnexpectedParen)
+ }
+
+ if err := p.addGroup(); err != nil {
+ return nil, err
+ }
+ if err := p.popGroup(); err != nil {
+ return nil, err
+ }
+ p.popOptions()
+
+ if p.unit == nil {
+ goto ContinueOuterScan
+ }
+
+ case '\\':
+ n, err := p.scanBackslash(false)
+ if err != nil {
+ return nil, err
+ }
+ p.addUnitNode(n)
+
+ case '^':
+ if p.useOptionM() {
+ p.addUnitType(NtBol)
+ } else {
+ p.addUnitType(NtBeginning)
+ }
+
+ case '$':
+ if p.useOptionM() {
+ p.addUnitType(NtEol)
+ } else if p.useRE2() || p.useOptionE() {
+ // RE2 and EcmaScript define $ as "asserts position at the end of the string"
+ // PCRE/.NET adds "or before the line terminator right at the end of the string (if any)"
+ // which is NtEnd, not NtEndZ
+ p.addUnitType(NtEnd)
+ } else {
+ p.addUnitType(NtEndZ)
+ }
+
+ case '.':
+ if p.useOptionS() {
+ p.addUnitSet(AnyClass())
+ } else if p.useOptionE() {
+ p.addUnitSet(ECMAAnyClass())
+ } else {
+ p.addUnitNotone('\n')
+ }
+
+ case '{', '*', '+', '?':
+ if p.unit == nil {
+ if wasPrevQuantifier {
+ return nil, p.getErr(ErrInvalidRepeatOp)
+ } else {
+ return nil, p.getErr(ErrMissingRepeatArgument)
+ }
+ }
+ p.moveLeft()
+
+ default:
+ return nil, p.getErr(ErrInternalError)
+ }
+
+ if err := p.scanBlank(); err != nil {
+ return nil, err
+ }
+
+ if p.charsRight() > 0 {
+ isQuant = p.isTrueQuantifier()
+ }
+ if p.charsRight() == 0 || !isQuant {
+ //maintain odd C# assignment order -- not sure if required, could clean up?
+ p.addConcatenate()
+ goto ContinueOuterScan
+ }
+
+ ch = p.moveRightGetChar()
+
+ // Handle quantifiers
+ for p.unit != nil {
+ var min, max int
+ var lazy bool
+
+ switch ch {
+ case '*':
+ min = 0
+ max = math.MaxInt32
+
+ case '?':
+ min = 0
+ max = 1
+
+ case '+':
+ min = 1
+ max = math.MaxInt32
+
+ case '{':
+ {
+ var err error
+ startpos = p.textpos()
+ if min, err = p.scanDecimal(); err != nil {
+ return nil, err
+ }
+ max = min
+ if startpos < p.textpos() {
+ if p.charsRight() > 0 && p.rightChar(0) == ',' {
+ p.moveRight(1)
+ if p.charsRight() == 0 || p.rightChar(0) == '}' {
+ max = math.MaxInt32
+ } else {
+ if max, err = p.scanDecimal(); err != nil {
+ return nil, err
+ }
+ }
+ }
+ }
+
+ if startpos == p.textpos() || p.charsRight() == 0 || p.moveRightGetChar() != '}' {
+ p.addConcatenate()
+ p.textto(startpos - 1)
+ goto ContinueOuterScan
+ }
+ }
+
+ default:
+ return nil, p.getErr(ErrInternalError)
+ }
+
+ if err := p.scanBlank(); err != nil {
+ return nil, err
+ }
+
+ if p.charsRight() == 0 || p.rightChar(0) != '?' {
+ lazy = false
+ } else {
+ p.moveRight(1)
+ lazy = true
+ }
+
+ if min > max {
+ return nil, p.getErr(ErrInvalidRepeatSize)
+ }
+
+ p.addConcatenate3(lazy, min, max)
+ }
+
+ ContinueOuterScan:
+ }
+
+BreakOuterScan:
+ ;
+
+ if !p.emptyStack() {
+ return nil, p.getErr(ErrMissingParen)
+ }
+
+ if err := p.addGroup(); err != nil {
+ return nil, err
+ }
+
+ return p.unit.finalOptimize(), nil
+
+}
+
+/*
+ * Simple parsing for replacement patterns
+ */
+func (p *parser) scanReplacement() (*RegexNode, error) {
+ var c, startpos int
+
+ p.concatenation = newRegexNode(NtConcatenate, p.options)
+
+ for {
+ c = p.charsRight()
+ if c == 0 {
+ break
+ }
+
+ startpos = p.textpos()
+
+ for c > 0 && p.rightChar(0) != '$' {
+ p.moveRight(1)
+ c--
+ }
+
+ p.addToConcatenate(startpos, p.textpos()-startpos, true)
+
+ if c > 0 {
+ if p.moveRightGetChar() == '$' {
+ n, err := p.scanDollar()
+ if err != nil {
+ return nil, err
+ }
+ p.addUnitNode(n)
+ }
+ p.addConcatenate()
+ }
+ }
+
+ return p.concatenation, nil
+}
+
+/*
+ * Scans $ patterns recognized within replacement patterns
+ */
+func (p *parser) scanDollar() (*RegexNode, error) {
+ if p.charsRight() == 0 {
+ return newRegexNodeCh(NtOne, p.options, '$'), nil
+ }
+
+ ch := p.rightChar(0)
+ angled := false
+ backpos := p.textpos()
+ lastEndPos := backpos
+
+ // Note angle
+
+ if ch == '{' && p.charsRight() > 1 {
+ angled = true
+ p.moveRight(1)
+ ch = p.rightChar(0)
+ }
+
+ // Try to parse backreference: \1 or \{1} or \{cap}
+
+ if ch >= '0' && ch <= '9' {
+ if !angled && p.useOptionE() {
+ capnum := -1
+ newcapnum := int(ch - '0')
+ p.moveRight(1)
+ if p.isCaptureSlot(newcapnum) {
+ capnum = newcapnum
+ lastEndPos = p.textpos()
+ }
+
+ for p.charsRight() > 0 {
+ ch = p.rightChar(0)
+ if ch < '0' || ch > '9' {
+ break
+ }
+ digit := int(ch - '0')
+ if newcapnum > maxValueDiv10 || (newcapnum == maxValueDiv10 && digit > maxValueMod10) {
+ return nil, p.getErr(ErrCaptureGroupOutOfRange)
+ }
+
+ newcapnum = newcapnum*10 + digit
+
+ p.moveRight(1)
+ if p.isCaptureSlot(newcapnum) {
+ capnum = newcapnum
+ lastEndPos = p.textpos()
+ }
+ }
+ p.textto(lastEndPos)
+ if capnum >= 0 {
+ return newRegexNodeM(NtRef, p.options, capnum), nil
+ }
+ } else {
+ capnum, err := p.scanDecimal()
+ if err != nil {
+ return nil, err
+ }
+ if !angled || p.charsRight() > 0 && p.moveRightGetChar() == '}' {
+ if p.isCaptureSlot(capnum) {
+ return newRegexNodeM(NtRef, p.options, capnum), nil
+ }
+ }
+ }
+ } else if angled && p.isGroupNameStartChar(ch) {
+ capname, err := p.scanCapname()
+ if err != nil {
+ return nil, err
+ }
+
+ if p.charsRight() > 0 && p.moveRightGetChar() == '}' {
+ if p.isCaptureName(capname) {
+ return newRegexNodeM(NtRef, p.options, p.captureSlotFromName(capname)), nil
+ }
+ }
+ } else if !angled {
+ capnum := 1
+
+ switch ch {
+ case '$':
+ p.moveRight(1)
+ return newRegexNodeCh(NtOne, p.options, '$'), nil
+ case '&':
+ capnum = 0
+ case '`':
+ capnum = replaceLeftPortion
+ case '\'':
+ capnum = replaceRightPortion
+ case '+':
+ capnum = replaceLastGroup
+ case '_':
+ capnum = replaceWholeString
+ }
+
+ if capnum != 1 {
+ p.moveRight(1)
+ return newRegexNodeM(NtRef, p.options, capnum), nil
+ }
+ }
+
+ // unrecognized $: literalize
+
+ p.textto(backpos)
+ return newRegexNodeCh(NtOne, p.options, '$'), nil
+}
+
+func (p *parser) isGroupNameStartChar(ch rune) bool {
+ if p.useOptionE() {
+ return IsECMAIdentifierStartChar(ch) || ch == '\\'
+ }
+ return IsWordChar(ch)
+}
+
+func (p *parser) scanPythonNamedBackref() (*RegexNode, error) {
+ p.moveRight(3)
+ if p.charsRight() == 0 {
+ return nil, p.getErr(ErrMalformedNameRef)
+ }
+
+ ch := p.rightChar(0)
+ if !p.isGroupNameStartChar(ch) {
+ return nil, p.getErr(ErrInvalidGroupName)
+ }
+
+ capname, err := p.scanCapname()
+ if err != nil {
+ return nil, err
+ }
+
+ if capname == "" || p.charsRight() == 0 || p.moveRightGetChar() != ')' {
+ return nil, p.getErr(ErrMalformedNameRef)
+ }
+
+ if !p.isCaptureName(capname) {
+ return nil, p.getErr(ErrUndefinedNameRef, capname)
+ }
+
+ return newRegexNodeM(NtRef, p.options, p.captureSlotFromName(capname)), nil
+}
+
+// scanGroupOpen scans chars following a '(' (not counting the '('), and returns
+// a RegexNode for the type of group scanned, or nil if the group
+// simply changed options (?cimsx-cimsx) or was a comment (#...).
+func (p *parser) scanGroupOpen() (*RegexNode, error) {
+ var ch rune
+ var nt NodeType
+ var err error
+ close := '>'
+ start := p.textpos()
+
+ // just return a RegexNode if we have:
+ // 1. "(" followed by nothing
+ // 2. "(x" where x != ?
+ // 3. "(?)"
+ if p.charsRight() == 0 || p.rightChar(0) != '?' || (p.rightChar(0) == '?' && (p.charsRight() > 1 && p.rightChar(1) == ')')) {
+ if p.useOptionN() || p.ignoreNextParen {
+ p.ignoreNextParen = false
+ return newRegexNode(NtGroup, p.options), nil
+ }
+ return newRegexNodeMN(NtCapture, p.options, p.consumeAutocap(), -1), nil
+ }
+
+ p.moveRight(1)
+
+ for p.charsRight() > 0 {
+ switch ch = p.moveRightGetChar(); ch {
+ case ':':
+ nt = NtGroup
+
+ case '=':
+ p.options &= ^RightToLeft
+ nt = NtPosLook
+
+ case '!':
+ p.options &= ^RightToLeft
+ nt = NtNegLook
+
+ case '>':
+ nt = NtAtomic
+
+ case '\'':
+ close = '\''
+ fallthrough
+
+ case '<':
+ if p.charsRight() == 0 {
+ goto BreakRecognize
+ }
+
+ switch ch = p.moveRightGetChar(); ch {
+ case '=':
+ if close == '\'' {
+ goto BreakRecognize
+ }
+
+ p.options |= RightToLeft
+ nt = NtPosLook
+
+ case '!':
+ if close == '\'' {
+ goto BreakRecognize
+ }
+
+ p.options |= RightToLeft
+ nt = NtNegLook
+
+ default:
+ p.moveLeft()
+ capnum := -1
+ uncapnum := -1
+ proceed := false
+
+ // grab part before -
+
+ if ch >= '0' && ch <= '9' && !p.useOptionE() {
+ if capnum, err = p.scanDecimal(); err != nil {
+ return nil, err
+ }
+
+ if !p.isCaptureSlot(capnum) {
+ capnum = -1
+ }
+
+ // check if we have bogus characters after the number
+ if p.charsRight() > 0 && p.rightChar(0) != close && p.rightChar(0) != '-' {
+ return nil, p.getErr(ErrInvalidGroupName)
+ }
+ if capnum == 0 {
+ return nil, p.getErr(ErrCapNumNotZero)
+ }
+ } else if p.isGroupNameStartChar(ch) {
+ capname, err := p.scanCapname()
+ if err != nil {
+ return nil, err
+ }
+
+ if p.isCaptureName(capname) {
+ capnum = p.captureSlotFromName(capname)
+ }
+
+ // check if we have bogus character after the name
+ if p.charsRight() > 0 && p.rightChar(0) != close && p.rightChar(0) != '-' {
+ if p.useOptionE() {
+ return nil, p.getErr(ErrInvalidECMAGroupName)
+ }
+ return nil, p.getErr(ErrInvalidGroupName)
+ }
+ } else if ch == '-' {
+ proceed = true
+ } else {
+ // bad group name - starts with something other than a word character and isn't a number
+ if p.useOptionE() {
+ return nil, p.getErr(ErrInvalidECMAGroupName)
+ }
+ return nil, p.getErr(ErrInvalidGroupName)
+ }
+
+ // grab part after - if any
+
+ if !p.useOptionE() && (capnum != -1 || proceed) && p.charsRight() > 0 && p.rightChar(0) == '-' {
+ p.moveRight(1)
+
+ //no more chars left, no closing char, etc
+ if p.charsRight() == 0 {
+ return nil, p.getErr(ErrInvalidGroupName)
+ }
+
+ ch = p.rightChar(0)
+ if ch >= '0' && ch <= '9' {
+ if uncapnum, err = p.scanDecimal(); err != nil {
+ return nil, err
+ }
+
+ if !p.isCaptureSlot(uncapnum) {
+ return nil, p.getErr(ErrUndefinedBackRef, uncapnum)
+ }
+
+ // check if we have bogus characters after the number
+ if p.charsRight() > 0 && p.rightChar(0) != close {
+ return nil, p.getErr(ErrInvalidGroupName)
+ }
+ } else if IsWordChar(ch) {
+ uncapname, err := p.scanCapname()
+ if err != nil {
+ return nil, err
+ }
+
+ if !p.isCaptureName(uncapname) {
+ return nil, p.getErr(ErrUndefinedNameRef, uncapname)
+ }
+ uncapnum = p.captureSlotFromName(uncapname)
+
+ // check if we have bogus character after the name
+ if p.charsRight() > 0 && p.rightChar(0) != close {
+ return nil, p.getErr(ErrInvalidGroupName)
+ }
+ } else {
+ // bad group name - starts with something other than a word character and isn't a number
+ return nil, p.getErr(ErrInvalidGroupName)
+ }
+ }
+
+ // actually make the node
+
+ if (capnum != -1 || uncapnum != -1) && p.charsRight() > 0 && p.moveRightGetChar() == close {
+ p.consumeCaptureSlot(capnum)
+ return newRegexNodeMN(NtCapture, p.options, capnum, uncapnum), nil
+ }
+ goto BreakRecognize
+ }
+
+ case '(':
+ // alternation construct (?(...) | )
+
+ parenPos := p.textpos()
+ if p.charsRight() > 0 {
+ ch = p.rightChar(0)
+
+ // check if the alternation condition is a backref
+ if ch >= '0' && ch <= '9' {
+ var capnum int
+ if capnum, err = p.scanDecimal(); err != nil {
+ return nil, err
+ }
+ if p.charsRight() > 0 && p.moveRightGetChar() == ')' {
+ if p.isCaptureSlot(capnum) {
+ return newRegexNodeM(NtBackRefCond, p.options, capnum), nil
+ }
+ return nil, p.getErr(ErrUndefinedReference, capnum)
+ }
+
+ return nil, p.getErr(ErrMalformedReference, capnum)
+
+ } else if IsWordChar(ch) {
+ capname, err := p.scanCapname()
+ if err != nil {
+ return nil, err
+ }
+
+ if p.isCaptureName(capname) && p.charsRight() > 0 && p.moveRightGetChar() == ')' {
+ return newRegexNodeM(NtBackRefCond, p.options, p.captureSlotFromName(capname)), nil
+ }
+ }
+ }
+ // not a backref
+ nt = NtExprCond
+ p.textto(parenPos - 1) // jump to the start of the parentheses
+ p.ignoreNextParen = true // but make sure we don't try to capture the insides
+
+ charsRight := p.charsRight()
+ if charsRight >= 3 && p.rightChar(1) == '?' {
+ rightchar2 := p.rightChar(2)
+ // disallow comments in the condition
+ if rightchar2 == '#' {
+ return nil, p.getErr(ErrAlternationCantHaveComment)
+ }
+
+ // disallow named capture group (?<..>..) in the condition
+ if rightchar2 == '\'' {
+ return nil, p.getErr(ErrAlternationCantCapture)
+ }
+
+ if charsRight >= 4 && (rightchar2 == '<' && p.rightChar(3) != '!' && p.rightChar(3) != '=') {
+ return nil, p.getErr(ErrAlternationCantCapture)
+ }
+ }
+
+ case 'P':
+ if p.useRE2() {
+ // support for P syntax
+ if p.charsRight() < 3 {
+ goto BreakRecognize
+ }
+
+ ch = p.moveRightGetChar()
+ if ch != '<' {
+ goto BreakRecognize
+ }
+
+ ch = p.moveRightGetChar()
+ p.moveLeft()
+
+ if IsWordChar(ch) {
+ capnum := -1
+ capname, err := p.scanCapname()
+ if err != nil {
+ return nil, err
+ }
+
+ if p.isCaptureName(capname) {
+ capnum = p.captureSlotFromName(capname)
+ }
+
+ // check if we have bogus character after the name
+ if p.charsRight() > 0 && p.rightChar(0) != '>' {
+ return nil, p.getErr(ErrInvalidGroupName)
+ }
+
+ // actually make the node
+
+ if capnum != -1 && p.charsRight() > 0 && p.moveRightGetChar() == '>' {
+ p.consumeCaptureSlot(capnum)
+ return newRegexNodeMN(NtCapture, p.options, capnum, -1), nil
+ }
+ goto BreakRecognize
+
+ } else {
+ // bad group name - starts with something other than a word character and isn't a number
+ return nil, p.getErr(ErrInvalidGroupName)
+ }
+ }
+ // if we're not using RE2 compat mode then
+ // we just behave like normal
+ fallthrough
+
+ default:
+ p.moveLeft()
+
+ nt = NtGroup
+ // disallow options in the children of a testgroup node
+ if p.group.T != NtExprCond {
+ p.scanOptions()
+ }
+ if p.charsRight() == 0 {
+ goto BreakRecognize
+ }
+
+ if ch = p.moveRightGetChar(); ch == ')' {
+ return nil, nil
+ }
+
+ if ch != ':' {
+ goto BreakRecognize
+ }
+
+ }
+
+ return newRegexNode(nt, p.options), nil
+ }
+
+BreakRecognize:
+
+ // break Recognize comes here
+
+ return nil, p.getErr(ErrUnrecognizedGrouping, string(p.pattern[start:p.textpos()]))
+}
+
+// scans backslash specials and basics
+func (p *parser) scanBackslash(scanOnly bool) (*RegexNode, error) {
+
+ if p.charsRight() == 0 {
+ return nil, p.getErr(ErrIllegalEndEscape)
+ }
+
+ switch ch := p.rightChar(0); ch {
+ case 'b', 'B', 'A', 'G', 'Z', 'z':
+ p.moveRight(1)
+ return newRegexNode(p.typeFromCode(ch), p.options), nil
+
+ case 'w':
+ p.moveRight(1)
+ if p.useOptionE() || p.useRE2() {
+ return newRegexNodeSet(NtSet, p.options, ECMAWordClass()), nil
+ }
+ return newRegexNodeSet(NtSet, p.options, WordClass()), nil
+
+ case 'W':
+ p.moveRight(1)
+ if p.useOptionE() || p.useRE2() {
+ return newRegexNodeSet(NtSet, p.options, NotECMAWordClass()), nil
+ }
+ return newRegexNodeSet(NtSet, p.options, NotWordClass()), nil
+
+ case 's':
+ p.moveRight(1)
+ if p.useOptionE() {
+ return newRegexNodeSet(NtSet, p.options, ECMASpaceClass()), nil
+ } else if p.useRE2() {
+ return newRegexNodeSet(NtSet, p.options, RE2SpaceClass()), nil
+ }
+ return newRegexNodeSet(NtSet, p.options, SpaceClass()), nil
+
+ case 'S':
+ p.moveRight(1)
+ if p.useOptionE() {
+ return newRegexNodeSet(NtSet, p.options, NotECMASpaceClass()), nil
+ } else if p.useRE2() {
+ return newRegexNodeSet(NtSet, p.options, NotRE2SpaceClass()), nil
+ }
+ return newRegexNodeSet(NtSet, p.options, NotSpaceClass()), nil
+
+ case 'd':
+ p.moveRight(1)
+ if p.useOptionE() || p.useRE2() {
+ return newRegexNodeSet(NtSet, p.options, ECMADigitClass()), nil
+ }
+ return newRegexNodeSet(NtSet, p.options, DigitClass()), nil
+
+ case 'D':
+ p.moveRight(1)
+ if p.useOptionE() || p.useRE2() {
+ return newRegexNodeSet(NtSet, p.options, NotECMADigitClass()), nil
+ }
+ return newRegexNodeSet(NtSet, p.options, NotDigitClass()), nil
+
+ case 'p', 'P':
+ // skip if we're in ECMAScript mode WITHOUT unicode flag
+ if p.useOptionE() && !p.useOptionU() {
+ return p.scanBasicBackslash(scanOnly)
+ }
+
+ p.moveRight(1)
+ prop, err := p.parseProperty()
+ if err != nil {
+ return nil, err
+ }
+ cc := &CharSet{}
+ cc.addCategory(prop, (ch != 'p'), p.useOptionI())
+ if p.useOptionI() {
+ cc.addLowercase()
+ }
+
+ return newRegexNodeSet(NtSet, p.options, cc), nil
+
+ default:
+ return p.scanBasicBackslash(scanOnly)
+ }
+}
+
+// Scans \-style backreferences and character escapes
+func (p *parser) scanBasicBackslash(scanOnly bool) (*RegexNode, error) {
+ if p.charsRight() == 0 {
+ return nil, p.getErr(ErrIllegalEndEscape)
+ }
+ angled := false
+ k := false
+ close := '\x00'
+
+ backpos := p.textpos()
+ ch := p.rightChar(0)
+
+ // Allow \k instead of \, which is now deprecated.
+
+ // According to ECMAScript specification, \k is only parsed as a named group reference if
+ // there is at least one group name in the regexp.
+ // See https://www.ecma-international.org/ecma-262/#sec-isvalidregularexpressionliteral, step 7.
+ // Note, during the first (scanOnly) run we may not have all group names scanned, but that's ok.
+ if ch == 'k' && (!p.useOptionE() || p.useOptionU() || len(p.capnames) > 0) {
+ if p.charsRight() >= 2 {
+ p.moveRight(1)
+ ch = p.moveRightGetChar()
+
+ if ch == '<' || (!p.useOptionE() && ch == '\'') { // No support for \k'name' in ECMAScript
+ angled = true
+ if ch == '\'' {
+ close = '\''
+ } else {
+ close = '>'
+ }
+ }
+ }
+
+ if !angled || p.charsRight() <= 0 {
+ return nil, p.getErr(ErrMalformedNameRef)
+ }
+
+ ch = p.rightChar(0)
+ k = true
+
+ } else if !p.useOptionE() && (ch == '<' || ch == '\'') && p.charsRight() > 1 { // Note angle without \g
+ angled = true
+ if ch == '\'' {
+ close = '\''
+ } else {
+ close = '>'
+ }
+
+ p.moveRight(1)
+ ch = p.rightChar(0)
+ }
+
+ // Try to parse backreference: \<1> or \
+
+ if angled && ch >= '0' && ch <= '9' {
+ capnum, err := p.scanDecimal()
+ if err != nil {
+ return nil, err
+ }
+
+ if p.charsRight() > 0 && p.moveRightGetChar() == close {
+ if p.isCaptureSlot(capnum) {
+ return newRegexNodeM(NtRef, p.options, capnum), nil
+ }
+ return nil, p.getErr(ErrUndefinedBackRef, capnum)
+ }
+ } else if !angled && ch >= '1' && ch <= '9' { // Try to parse backreference or octal: \1
+ capnum, err := p.scanDecimal()
+ if err != nil {
+ return nil, err
+ }
+
+ if scanOnly {
+ return nil, nil
+ }
+
+ if p.isCaptureSlot(capnum) {
+ return newRegexNodeM(NtRef, p.options, capnum), nil
+ }
+ if capnum <= 9 && !p.useOptionE() {
+ return nil, p.getErr(ErrUndefinedBackRef, capnum)
+ }
+
+ } else if angled {
+ capname, err := p.scanCapname()
+ if err != nil {
+ return nil, err
+ }
+
+ if capname != "" && p.charsRight() > 0 && p.moveRightGetChar() == close {
+
+ if scanOnly {
+ return nil, nil
+ }
+
+ if p.isCaptureName(capname) {
+ return newRegexNodeM(NtRef, p.options, p.captureSlotFromName(capname)), nil
+ }
+ return nil, p.getErr(ErrUndefinedNameRef, capname)
+ } else {
+ if k {
+ return nil, p.getErr(ErrMalformedNameRef)
+ }
+ }
+ }
+
+ // Not backreference: must be char code
+
+ p.textto(backpos)
+ ch, err := p.scanCharEscape()
+ if err != nil {
+ return nil, err
+ }
+
+ if scanOnly {
+ return nil, nil
+ }
+
+ if p.useOptionI() {
+ ch = unicode.ToLower(ch)
+ }
+
+ return newRegexNodeCh(NtOne, p.options, ch), nil
+}
+
+// Scans X for \p{X} or \P{X}
+func (p *parser) parseProperty() (string, error) {
+ // RE2 and PCRE supports \pX syntax (no {} and only 1 letter unicode cats supported)
+ // since this is purely additive syntax it's not behind a flag
+ if p.charsRight() >= 1 && p.rightChar(0) != '{' && (!p.useOptionE() || !p.useOptionU()) {
+ ch := string(p.moveRightGetChar())
+ // check if it's a valid cat
+ canonical, ok := canonicalUnicodeCatName(ch)
+ if !ok {
+ return "", p.getErr(ErrUnknownSlashP, ch)
+ }
+ return canonical, nil
+ }
+
+ if p.charsRight() < 3 {
+ return "", p.getErr(ErrIncompleteSlashP)
+ }
+ ch := p.moveRightGetChar()
+ if ch != '{' {
+ return "", p.getErr(ErrMalformedSlashP)
+ }
+
+ startpos := p.textpos()
+ for p.charsRight() > 0 {
+ ch = p.moveRightGetChar()
+ if !IsWordChar(ch) && ch != '-' && ch != '=' {
+ p.moveLeft()
+ break
+ }
+ }
+ capname := string(p.pattern[startpos:p.textpos()])
+
+ if p.charsRight() == 0 || p.moveRightGetChar() != '}' {
+ return "", p.getErr(ErrIncompleteSlashP)
+ }
+
+ canonical, ok := canonicalUnicodeCatName(capname)
+ if !ok {
+ return "", p.getErr(ErrUnknownSlashP, capname)
+ }
+
+ return canonical, nil
+}
+
+// Returns ReNode type for zero-length assertions with a \ code.
+func (p *parser) typeFromCode(ch rune) NodeType {
+ switch ch {
+ case 'b':
+ if p.useOptionE() {
+ return NtECMABoundary
+ }
+ return NtBoundary
+ case 'B':
+ if p.useOptionE() {
+ return NtNonECMABoundary
+ }
+ return NtNonboundary
+ case 'A':
+ return NtBeginning
+ case 'G':
+ return NtStart
+ case 'Z':
+ return NtEndZ
+ case 'z':
+ return NtEnd
+ default:
+ return NtNothing
+ }
+}
+
+// Scans whitespace or x-mode comments.
+func (p *parser) scanBlank() error {
+ if p.useOptionX() {
+ for {
+ for p.charsRight() > 0 && isSpace(p.rightChar(0)) {
+ p.moveRight(1)
+ }
+
+ if p.charsRight() == 0 {
+ break
+ }
+
+ if p.rightChar(0) == '#' {
+ for p.charsRight() > 0 && p.rightChar(0) != '\n' {
+ p.moveRight(1)
+ }
+ } else if p.charsRight() >= 3 && p.rightChar(2) == '#' &&
+ p.rightChar(1) == '?' && p.rightChar(0) == '(' {
+ for p.charsRight() > 0 && p.rightChar(0) != ')' {
+ p.moveRight(1)
+ }
+ if p.charsRight() == 0 {
+ return p.getErr(ErrUnterminatedComment)
+ }
+ p.moveRight(1)
+ } else {
+ break
+ }
+ }
+ } else {
+ for {
+ if p.charsRight() < 3 || p.rightChar(2) != '#' ||
+ p.rightChar(1) != '?' || p.rightChar(0) != '(' {
+ return nil
+ }
+
+ for p.charsRight() > 0 && p.rightChar(0) != ')' {
+ p.moveRight(1)
+ }
+ if p.charsRight() == 0 {
+ return p.getErr(ErrUnterminatedComment)
+ }
+ p.moveRight(1)
+ }
+ }
+ return nil
+}
+
+func (p *parser) scanECMACapname() (string, error) {
+ startpos := p.textpos()
+ var sb strings.Builder
+ hasEscape := false
+ index := 0
+
+ for p.charsRight() > 0 {
+ savedpos := p.textpos()
+ ch := p.moveRightGetChar()
+ var err error
+ escaped := false
+
+ if ch == '\\' {
+ if p.charsRight() == 0 || p.rightChar(0) != 'u' {
+ return "", p.getErr(ErrInvalidECMAGroupName)
+ }
+ escaped = true
+ p.moveRight(1)
+ if p.charsRight() > 0 && p.rightChar(0) == '{' {
+ if !p.useOptionU() {
+ return "", p.getErr(ErrInvalidECMAGroupName)
+ }
+ p.moveRight(1)
+ ch, err = p.scanHexUntilBrace()
+ } else {
+ ch, err = p.scanHex(4)
+ }
+ if err != nil {
+ return "", err
+ }
+ if !hasEscape {
+ sb.WriteString(string(p.pattern[startpos:savedpos]))
+ hasEscape = true
+ }
+ }
+
+ valid := IsECMAIdentifierChar(ch)
+ if index == 0 {
+ valid = IsECMAIdentifierStartChar(ch)
+ }
+ if !valid {
+ if escaped {
+ return "", p.getErr(ErrInvalidECMAGroupName)
+ }
+ p.textto(savedpos)
+ break
+ }
+ if hasEscape {
+ sb.WriteRune(ch)
+ }
+ index++
+ }
+
+ if hasEscape {
+ return sb.String(), nil
+ }
+ return string(p.pattern[startpos:p.textpos()]), nil
+}
+
+func (p *parser) scanWord() string {
+ startpos := p.textpos()
+
+ for p.charsRight() > 0 {
+ if !IsWordChar(p.moveRightGetChar()) {
+ p.moveLeft()
+ break
+ }
+ }
+
+ return string(p.pattern[startpos:p.textpos()])
+}
+
+func (p *parser) scanCapname() (string, error) {
+ if p.useOptionE() {
+ return p.scanECMACapname()
+ }
+
+ return p.scanWord(), nil
+}
+
+// Scans contents of [] (not including []'s), and converts to a set.
+func (p *parser) scanCharSet(caseInsensitive, scanOnly bool) (*CharSet, error) {
+ var ch rune
+ chPrev := '\x00'
+ inRange := false
+ firstChar := true
+ closed := false
+
+ var cc *CharSet
+ if !scanOnly {
+ cc = &CharSet{}
+ }
+
+ if p.charsRight() > 0 && p.rightChar(0) == '^' {
+ p.moveRight(1)
+ if !scanOnly {
+ cc.negate = true
+ }
+ }
+
+ for ; p.charsRight() > 0; firstChar = false {
+ fTranslatedChar := false
+ ch = p.moveRightGetChar()
+ if ch == ']' {
+ if !firstChar {
+ closed = true
+ break
+ } else if p.useOptionE() {
+ if !scanOnly {
+ cc.addRanges(NoneClass().ranges)
+ }
+ closed = true
+ break
+ }
+
+ } else if ch == '\\' && p.charsRight() > 0 {
+ switch ch = p.moveRightGetChar(); ch {
+ case 'D', 'd':
+ if !scanOnly {
+ if inRange {
+ if !p.useOptionE() {
+ return nil, p.getErr(ErrBadClassInCharRange, ch)
+ }
+ cc.addChar(chPrev)
+ cc.addChar('-')
+ inRange = false
+ }
+ cc.addDigit(p.useOptionE() || p.useRE2(), ch == 'D')
+ }
+ continue
+
+ case 'S', 's':
+ if !scanOnly {
+ if inRange {
+ if !p.useOptionE() {
+ return nil, p.getErr(ErrBadClassInCharRange, ch)
+ }
+ cc.addChar(chPrev)
+ cc.addChar('-')
+ inRange = false
+ }
+ cc.addSpace(p.useOptionE(), p.useRE2(), ch == 'S')
+ }
+ continue
+
+ case 'W', 'w':
+ if !scanOnly {
+ if inRange {
+ if !p.useOptionE() {
+ return nil, p.getErr(ErrBadClassInCharRange, ch)
+ }
+ cc.addChar(chPrev)
+ cc.addChar('-')
+ inRange = false
+ }
+
+ cc.addWord(p.useOptionE() || p.useRE2(), ch == 'W')
+ }
+ continue
+
+ case 'p', 'P':
+ if p.useOptionE() && !p.useOptionU() && ch == 'P' && inRange {
+ return nil, p.getErr(ErrShorthandClassInCharRange, string(ch))
+ }
+ if p.useOptionE() && !p.useOptionU() && ch == 'p' {
+ if !scanOnly {
+ if inRange {
+ if chPrev > ch {
+ return nil, p.getErr(ErrReversedCharRange, chPrev, ch)
+ }
+ cc.addRange(chPrev, ch)
+ inRange = false
+ } else if p.charsRight() >= 2 && p.rightChar(0) == '-' && p.rightChar(1) != ']' {
+ cc.addChar('-')
+ p.moveRight(1)
+ chLast := p.moveRightGetChar()
+ if ch > chLast {
+ return nil, p.getErr(ErrReversedCharRange, ch, chLast)
+ }
+ cc.addRange(ch, chLast)
+ } else {
+ cc.addChar(ch)
+ }
+ }
+ continue
+ }
+ if !scanOnly {
+ prop, err := p.parseProperty()
+ if err != nil {
+ return nil, err
+ }
+ if inRange {
+ return nil, p.getErr(ErrShorthandClassInCharRange, string(ch))
+ }
+ cc.addCategory(prop, (ch != 'p'), caseInsensitive)
+ } else {
+ if _, err := p.parseProperty(); err != nil {
+ return nil, err
+ }
+ }
+
+ continue
+
+ case '-':
+ if !scanOnly {
+ cc.addRange(ch, ch)
+ }
+ continue
+
+ default:
+ p.moveLeft()
+ var err error
+ ch, err = p.scanCharEscape() // non-literal character
+ if err != nil {
+ return nil, err
+ }
+ fTranslatedChar = true
+ }
+ } else if ch == '[' {
+ // This is code for Posix style properties - [:Ll:] or [:IsTibetan:].
+ // It currently doesn't do anything other than skip the whole thing!
+ if p.charsRight() > 0 && p.rightChar(0) == ':' && !inRange {
+ savePos := p.textpos()
+
+ p.moveRight(1)
+ negate := false
+ if p.charsRight() > 1 && p.rightChar(0) == '^' {
+ negate = true
+ p.moveRight(1)
+ }
+
+ nm := p.scanWord() // snag the name
+ if !scanOnly && p.useRE2() {
+ // look up the name since these are valid for RE2
+ // add the group based on the name
+ if ok := cc.addNamedASCII(nm, negate); !ok {
+ return nil, p.getErr(ErrInvalidCharRange)
+ }
+ }
+ if p.charsRight() < 2 || p.moveRightGetChar() != ':' || p.moveRightGetChar() != ']' {
+ p.textto(savePos)
+ } else if p.useRE2() {
+ // move on
+ continue
+ }
+ }
+ }
+
+ if inRange {
+ inRange = false
+ if !scanOnly {
+ if ch == '[' && !fTranslatedChar && !firstChar {
+ // We thought we were in a range, but we're actually starting a subtraction.
+ // In that case, we'll add chPrev to our char class, skip the opening [, and
+ // scan the new character class recursively.
+ cc.addChar(chPrev)
+ sub, err := p.scanCharSet(caseInsensitive, false)
+ if err != nil {
+ return nil, err
+ }
+ cc.addSubtraction(sub)
+
+ if p.charsRight() > 0 && p.rightChar(0) != ']' {
+ return nil, p.getErr(ErrSubtractionMustBeLast)
+ }
+ } else {
+ // a regular range, like a-z
+ if chPrev > ch {
+ return nil, p.getErr(ErrReversedCharRange, chPrev, ch)
+ }
+ cc.addRange(chPrev, ch)
+ }
+ }
+ } else if p.charsRight() >= 2 && p.rightChar(0) == '-' && p.rightChar(1) != ']' {
+ // this could be the start of a range
+ chPrev = ch
+ inRange = true
+ p.moveRight(1)
+ } else if p.charsRight() >= 1 && ch == '-' && !fTranslatedChar && p.rightChar(0) == '[' && !firstChar {
+ // we aren't in a range, and now there is a subtraction. Usually this happens
+ // only when a subtraction follows a range, like [a-z-[b]]
+ if !scanOnly {
+ p.moveRight(1)
+ sub, err := p.scanCharSet(caseInsensitive, false)
+ if err != nil {
+ return nil, err
+ }
+ cc.addSubtraction(sub)
+
+ if p.charsRight() > 0 && p.rightChar(0) != ']' {
+ return nil, p.getErr(ErrSubtractionMustBeLast)
+ }
+ } else {
+ p.moveRight(1)
+ _, _ = p.scanCharSet(caseInsensitive, true)
+ }
+ } else {
+ if !scanOnly {
+ cc.addRange(ch, ch)
+ }
+ }
+ }
+
+ if !closed {
+ return nil, p.getErr(ErrUnterminatedBracket)
+ }
+
+ if !scanOnly && caseInsensitive {
+ cc.addLowercase()
+ }
+
+ return cc, nil
+}
+
+// Scans any number of decimal digits (pegs value at 2^31-1 if too large)
+func (p *parser) scanDecimal() (int, error) {
+ i := 0
+ var d int
+
+ for p.charsRight() > 0 {
+ d = int(p.rightChar(0) - '0')
+ if d < 0 || d > 9 {
+ break
+ }
+ p.moveRight(1)
+
+ if i > maxValueDiv10 || (i == maxValueDiv10 && d > maxValueMod10) {
+ return 0, p.getErr(ErrCaptureGroupOutOfRange)
+ }
+
+ i *= 10
+ i += d
+ }
+
+ return int(i), nil
+}
+
+// Returns true for options allowed only at the top level
+func isOnlyTopOption(option RegexOptions) bool {
+ return option == RightToLeft || option == ECMAScript || option == RE2
+}
+
+// Scans imnsxu-imnsxu option string, stops at the first unrecognized char.
+func (p *parser) scanOptions() {
+
+ for off := false; p.charsRight() > 0; p.moveRight(1) {
+ ch := p.rightChar(0)
+
+ switch ch {
+ case '-':
+ off = true
+ case '+':
+ off = false
+ default:
+ option := optionFromCode(ch)
+ if option == 0 || isOnlyTopOption(option) {
+ return
+ }
+
+ if off {
+ p.options &= ^option
+ } else {
+ p.options |= option
+ }
+ }
+ }
+}
+
+// Scans \ code for escape codes that map to single unicode chars.
+func (p *parser) scanCharEscape() (r rune, err error) {
+
+ ch := p.moveRightGetChar()
+
+ if ch >= '0' && ch <= '7' {
+ p.moveLeft()
+ return p.scanOctal(), nil
+ }
+
+ pos := p.textpos()
+
+ switch ch {
+ case 'x':
+ // support for \x{HEX} syntax from Perl and PCRE
+ if p.charsRight() > 0 && p.rightChar(0) == '{' {
+ if p.useOptionE() {
+ return ch, nil
+ }
+ p.moveRight(1)
+ return p.scanHexUntilBrace()
+ } else {
+ r, err = p.scanHex(2)
+ }
+ case 'u':
+ // ECMAscript suppot \u{HEX} only if `u` is also set
+ if p.useOptionE() && p.useOptionU() && p.charsRight() > 0 && p.rightChar(0) == '{' {
+ p.moveRight(1)
+ return p.scanHexUntilBrace()
+ } else {
+ r, err = p.scanHex(4)
+ }
+ case 'a':
+ return '\u0007', nil
+ case 'b':
+ return '\b', nil
+ case 'e':
+ return '\u001B', nil
+ case 'f':
+ return '\f', nil
+ case 'n':
+ return '\n', nil
+ case 'r':
+ return '\r', nil
+ case 't':
+ return '\t', nil
+ case 'v':
+ return '\u000B', nil
+ case 'c':
+ r, err = p.scanControl()
+ default:
+ if !p.useOptionE() && !p.useRE2() && IsWordChar(ch) {
+ return 0, p.getErr(ErrUnrecognizedEscape, string(ch))
+ }
+ return ch, nil
+ }
+ if err != nil && p.useOptionE() {
+ p.textto(pos)
+ return ch, nil
+ }
+ return
+}
+
+// Grabs and converts an ascii control character
+func (p *parser) scanControl() (rune, error) {
+ if p.charsRight() <= 0 {
+ return 0, p.getErr(ErrMissingControl)
+ }
+
+ ch := p.moveRightGetChar()
+
+ // \ca interpreted as \cA
+
+ if ch >= 'a' && ch <= 'z' {
+ ch = (ch - ('a' - 'A'))
+ }
+ ch = (ch - '@')
+ if ch >= 0 && ch < ' ' {
+ return ch, nil
+ }
+
+ return 0, p.getErr(ErrUnrecognizedControl)
+
+}
+
+// Scan hex digits until we hit a closing brace.
+// Non-hex digits, hex value too large for UTF-8, or running out of chars are errors
+func (p *parser) scanHexUntilBrace() (rune, error) {
+ // PCRE spec reads like unlimited hex digits are allowed, but unicode has a limit
+ // so we can enforce that
+ i := 0
+ hasContent := false
+
+ for p.charsRight() > 0 {
+ ch := p.moveRightGetChar()
+ if ch == '}' {
+ // hit our close brace, we're done here
+ // prevent \x{}
+ if !hasContent {
+ return 0, p.getErr(ErrTooFewHex)
+ }
+ return rune(i), nil
+ }
+ hasContent = true
+ // no brace needs to be hex digit
+ d := hexDigit(ch)
+ if d < 0 {
+ return 0, p.getErr(ErrMissingBrace)
+ }
+
+ i *= 0x10
+ i += d
+
+ if i > unicode.MaxRune {
+ return 0, p.getErr(ErrInvalidHex)
+ }
+ }
+
+ // we only make it here if we run out of digits without finding the brace
+ return 0, p.getErr(ErrMissingBrace)
+}
+
+// Scans exactly c hex digits (c=2 for \xFF, c=4 for \uFFFF)
+func (p *parser) scanHex(c int) (rune, error) {
+
+ i := 0
+
+ if p.charsRight() >= c {
+ for c > 0 {
+ d := hexDigit(p.moveRightGetChar())
+ if d < 0 {
+ break
+ }
+ i *= 0x10
+ i += d
+ c--
+ }
+ }
+
+ if c > 0 {
+ return 0, p.getErr(ErrTooFewHex)
+ }
+
+ return rune(i), nil
+}
+
+// Returns n <= 0xF for a hex digit.
+func hexDigit(ch rune) int {
+
+ if d := uint(ch - '0'); d <= 9 {
+ return int(d)
+ }
+
+ if d := uint(ch - 'a'); d <= 5 {
+ return int(d + 0xa)
+ }
+
+ if d := uint(ch - 'A'); d <= 5 {
+ return int(d + 0xa)
+ }
+
+ return -1
+}
+
+// Scans up to three octal digits (stops before exceeding 0377).
+func (p *parser) scanOctal() rune {
+ // Consume octal chars only up to 3 digits and value 0377
+
+ c := 3
+
+ if c > p.charsRight() {
+ c = p.charsRight()
+ }
+
+ //we know the first char is good because the caller had to check
+ i := 0
+ d := int(p.rightChar(0) - '0')
+ for c > 0 && d <= 7 && d >= 0 {
+ if i >= 0x20 && p.useOptionE() {
+ break
+ }
+ i *= 8
+ i += d
+ c--
+
+ p.moveRight(1)
+ if !p.rightMost() {
+ d = int(p.rightChar(0) - '0')
+ }
+ }
+
+ // Octal codes only go up to 255. Any larger and the behavior that Perl follows
+ // is simply to truncate the high bits.
+ i &= 0xFF
+
+ return rune(i)
+}
+
+// Returns the current parsing position.
+func (p *parser) textpos() int {
+ return p.currentPos
+}
+
+// Zaps to a specific parsing position.
+func (p *parser) textto(pos int) {
+ p.currentPos = pos
+}
+
+// Returns the char at the right of the current parsing position and advances to the right.
+func (p *parser) moveRightGetChar() rune {
+ ch := p.pattern[p.currentPos]
+ p.currentPos++
+ return ch
+}
+
+// Moves the current position to the right.
+func (p *parser) moveRight(i int) {
+ // default would be 1
+ p.currentPos += i
+}
+
+// Moves the current parsing position one to the left.
+func (p *parser) moveLeft() {
+ p.currentPos--
+}
+
+// Returns the char left of the current parsing position.
+func (p *parser) charAt(i int) rune {
+ return p.pattern[i]
+}
+
+// Returns the char i chars right of the current parsing position.
+func (p *parser) rightChar(i int) rune {
+ // default would be 0
+ return p.pattern[p.currentPos+i]
+}
+
+// Number of characters to the right of the current parsing position.
+func (p *parser) charsRight() int {
+ return len(p.pattern) - p.currentPos
+}
+
+func (p *parser) rightMost() bool {
+ return p.currentPos == len(p.pattern)
+}
+
+// Looks up the slot number for a given name
+func (p *parser) captureSlotFromName(capname string) int {
+ return p.capnames[capname]
+}
+
+// True if the capture slot was noted
+func (p *parser) isCaptureSlot(i int) bool {
+ if p.caps != nil {
+ _, ok := p.caps[i]
+ return ok
+ }
+
+ return (i >= 0 && i < p.capsize)
+}
+
+// Looks up the slot number for a given name
+func (p *parser) isCaptureName(capname string) bool {
+ if p.capnames == nil {
+ return false
+ }
+
+ _, ok := p.capnames[capname]
+ return ok
+}
+
+// option shortcuts
+
+// True if N option disabling '(' autocapture is on.
+func (p *parser) useOptionN() bool {
+ return (p.options & ExplicitCapture) != 0
+}
+
+// True if I option enabling case-insensitivity is on.
+func (p *parser) useOptionI() bool {
+ return (p.options & IgnoreCase) != 0
+}
+
+// True if M option altering meaning of $ and ^ is on.
+func (p *parser) useOptionM() bool {
+ return (p.options & Multiline) != 0
+}
+
+// True if S option altering meaning of . is on.
+func (p *parser) useOptionS() bool {
+ return (p.options & Singleline) != 0
+}
+
+// True if X option enabling whitespace/comment mode is on.
+func (p *parser) useOptionX() bool {
+ return (p.options & IgnorePatternWhitespace) != 0
+}
+
+// True if E option enabling ECMAScript behavior on.
+func (p *parser) useOptionE() bool {
+ return (p.options & ECMAScript) != 0
+}
+
+// true to use RE2 compatibility parsing behavior.
+func (p *parser) useRE2() bool {
+ return (p.options & RE2) != 0
+}
+
+// True if U option enabling ECMAScript's Unicode behavior on.
+func (p *parser) useOptionU() bool {
+ return (p.options & Unicode) != 0
+}
+
+// True if options stack is empty.
+func (p *parser) emptyOptionsStack() bool {
+ return len(p.optionsStack) == 0
+}
+
+// Finish the current quantifiable (when a quantifier is not found or is not possible)
+func (p *parser) addConcatenate() {
+ // The first (| inside a Testgroup group goes directly to the group
+ p.concatenation.addChild(p.unit)
+ p.unit = nil
+}
+
+// Finish the current quantifiable (when a quantifier is found)
+func (p *parser) addConcatenate3(lazy bool, min, max int) {
+ p.concatenation.addChild(p.unit.makeQuantifier(lazy, min, max))
+ p.unit = nil
+}
+
+// Sets the current unit to a single char node
+func (p *parser) addUnitOne(ch rune) {
+ p.unit = newRegexNodeCh(NtOne, p.options, ch)
+}
+
+// Sets the current unit to a single inverse-char node
+func (p *parser) addUnitNotone(ch rune) {
+ p.unit = newRegexNodeCh(NtNotone, p.options, ch)
+}
+
+// Sets the current unit to a single set node
+func (p *parser) addUnitSet(set *CharSet) {
+ p.unit = newRegexNodeSet(NtSet, p.options, set)
+}
+
+// Sets the current unit to a subtree
+func (p *parser) addUnitNode(node *RegexNode) {
+ p.unit = node
+}
+
+// Sets the current unit to an assertion of the specified type
+func (p *parser) addUnitType(t NodeType) {
+ p.unit = newRegexNode(t, p.options)
+}
+
+// Finish the current group (in response to a ')' or end)
+func (p *parser) addGroup() error {
+ if p.group.T == NtExprCond || p.group.T == NtBackRefCond {
+ p.group.addChild(p.concatenation.reverseLeft())
+ if (p.group.T == NtBackRefCond && len(p.group.Children) > 2) || len(p.group.Children) > 3 {
+ return p.getErr(ErrTooManyAlternates)
+ }
+ } else {
+ p.alternation.addChild(p.concatenation.reverseLeft())
+ p.group.addChild(p.alternation)
+ }
+
+ p.unit = p.group
+ return nil
+}
+
+// Pops the option stack, but keeps the current options unchanged.
+func (p *parser) popKeepOptions() {
+ lastIdx := len(p.optionsStack) - 1
+ p.optionsStack = p.optionsStack[:lastIdx]
+}
+
+// Recalls options from the stack.
+func (p *parser) popOptions() {
+ lastIdx := len(p.optionsStack) - 1
+ // get the last item on the stack and then remove it by reslicing
+ p.options = p.optionsStack[lastIdx]
+ p.optionsStack = p.optionsStack[:lastIdx]
+}
+
+// Saves options on a stack.
+func (p *parser) pushOptions() {
+ p.optionsStack = append(p.optionsStack, p.options)
+}
+
+// Add a string to the last concatenate.
+func (p *parser) addToConcatenate(pos, cch int, isReplacement bool) {
+ if cch == 0 {
+ return
+ }
+ if cch == 1 {
+ var node *RegexNode
+
+ if isReplacement {
+ node = newRegexNodeCh(NtOne, p.options&^IgnoreCase, p.pattern[pos])
+ } else {
+ node = newRegexNodeCh(NtOne, p.options, p.pattern[pos])
+ }
+ p.concatenation.addChild(node)
+ return
+ }
+
+ if cch > 1 && (!p.useOptionI() || isReplacement || !anyParticipateInCaseConversion(p.pattern[pos:pos+cch])) {
+ str := make([]rune, cch)
+ copy(str, p.pattern[pos:pos+cch])
+ p.concatenation.addChild(newRegexNodeStr(NtMulti, p.options&^IgnoreCase, str))
+ return
+ }
+
+ // each letter gets an upper-lower range
+ for i := pos; i < pos+cch; i++ {
+ p.concatenation.addChild(newRegexNodeCh(NtOne, p.options, p.pattern[i]))
+ }
+}
+
+// Push the parser state (in response to an open paren)
+func (p *parser) pushGroup() {
+ p.group.Parent = p.stack
+ p.alternation.Parent = p.group
+ p.concatenation.Parent = p.alternation
+ p.stack = p.concatenation
+}
+
+// Remember the pushed state (in response to a ')')
+func (p *parser) popGroup() error {
+ p.concatenation = p.stack
+ p.alternation = p.concatenation.Parent
+ p.group = p.alternation.Parent
+ p.stack = p.group.Parent
+
+ // The first () inside a Testgroup group goes directly to the group
+ if p.group.T == NtExprCond && len(p.group.Children) == 0 {
+ if p.unit == nil {
+ return p.getErr(ErrConditionalExpression)
+ }
+
+ p.group.addChild(p.unit)
+ p.unit = nil
+ }
+ return nil
+}
+
+// True if the group stack is empty.
+func (p *parser) emptyStack() bool {
+ return p.stack == nil
+}
+
+// Start a new round for the parser state (in response to an open paren or string start)
+func (p *parser) startGroup(openGroup *RegexNode) {
+ p.group = openGroup
+ p.alternation = newRegexNode(NtAlternate, p.options)
+ p.concatenation = newRegexNode(NtConcatenate, p.options)
+}
+
+// Finish the current concatenation (in response to a |)
+func (p *parser) addAlternate() {
+ // The | parts inside a Testgroup group go directly to the group
+
+ if p.group.T == NtExprCond || p.group.T == NtBackRefCond {
+ p.group.addChild(p.concatenation.reverseLeft())
+ } else {
+ p.alternation.addChild(p.concatenation.reverseLeft())
+ }
+
+ p.concatenation = newRegexNode(NtConcatenate, p.options)
+}
+
+// For categorizing ascii characters.
+
+const (
+ Q byte = 5 // quantifier
+ S byte = 4 // ordinary stopper
+ Z byte = 3 // ScanBlank stopper
+ X byte = 2 // whitespace
+ E byte = 1 // should be escaped
+)
+
+var _category = []byte{
+ //01 2 3 4 5 6 7 8 9 A B C D E F 0 1 2 3 4 5 6 7 8 9 A B C D E F
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, X, X, X, X, X, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ // ! " # $ % & ' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ?
+ X, 0, 0, Z, S, 0, 0, 0, S, S, Q, Q, 0, 0, S, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, Q,
+ //@A B C D E F G H I J K L M N O P Q R S T U V W X Y Z [ \ ] ^ _
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, S, S, 0, S, 0,
+ //'a b c d e f g h i j k l m n o p q r s t u v w x y z { | } ~
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, Q, S, 0, 0, 0,
+}
+
+func isSpace(ch rune) bool {
+ return (ch <= ' ' && _category[ch] == X)
+}
+
+// Returns true for those characters that terminate a string of ordinary chars.
+func isSpecial(ch rune) bool {
+ return (ch <= '|' && _category[ch] >= S)
+}
+
+// Returns true for those characters that terminate a string of ordinary chars.
+func isStopperX(ch rune) bool {
+ return (ch <= '|' && _category[ch] >= X)
+}
+
+// Returns true for those characters that begin a quantifier.
+func isQuantifier(ch rune) bool {
+ return (ch <= '{' && _category[ch] >= Q)
+}
+
+func (p *parser) isTrueQuantifier() bool {
+ nChars := p.charsRight()
+ if nChars == 0 {
+ return false
+ }
+
+ startpos := p.textpos()
+ ch := p.charAt(startpos)
+ if ch != '{' {
+ return ch <= '{' && _category[ch] >= Q
+ }
+
+ //UGLY: this is ugly -- the original code was ugly too
+ pos := startpos
+ for {
+ nChars--
+ if nChars <= 0 {
+ break
+ }
+ pos++
+ ch = p.charAt(pos)
+ if ch < '0' || ch > '9' {
+ break
+ }
+ }
+
+ if nChars == 0 || pos-startpos == 1 {
+ return false
+ }
+ if ch == '}' {
+ return true
+ }
+ if ch != ',' {
+ return false
+ }
+ for {
+ nChars--
+ if nChars <= 0 {
+ break
+ }
+ pos++
+ ch = p.charAt(pos)
+ if ch < '0' || ch > '9' {
+ break
+ }
+ }
+
+ return nChars > 0 && ch == '}'
+}
diff --git a/vendor/github.com/dlclark/regexp2/v2/syntax/prefix.go b/vendor/github.com/dlclark/regexp2/v2/syntax/prefix.go
new file mode 100644
index 0000000000..af5a8c06bb
--- /dev/null
+++ b/vendor/github.com/dlclark/regexp2/v2/syntax/prefix.go
@@ -0,0 +1,943 @@
+package syntax
+
+import (
+ "bytes"
+ "fmt"
+ "strconv"
+ "unicode"
+ "unicode/utf8"
+)
+
+type Prefix struct {
+ PrefixStr []rune
+ PrefixSet CharSet
+ CaseInsensitive bool
+}
+
+// It takes a RegexTree and computes the set of chars that can start it.
+func getFirstCharsPrefix(tree *RegexTree) *Prefix {
+ s := regexFcd{
+ fcStack: make([]regexFc, 32),
+ intStack: make([]int, 32),
+ }
+ fc := s.regexFCFromRegexTree(tree)
+
+ if fc == nil || fc.nullable || fc.cc.IsEmpty() {
+ return nil
+ }
+ fcSet := fc.getFirstChars()
+ return &Prefix{PrefixSet: fcSet, CaseInsensitive: fc.caseInsensitive}
+}
+
+type regexFcd struct {
+ intStack []int
+ intDepth int
+ fcStack []regexFc
+ fcDepth int
+ skipAllChildren bool // don't process any more children at the current level
+ skipchild bool // don't process the current child.
+ failed bool
+}
+
+/*
+ * The main FC computation. It does a shortcutted depth-first walk
+ * through the tree and calls CalculateFC to emits code before
+ * and after each child of an interior node, and at each leaf.
+ */
+func (s *regexFcd) regexFCFromRegexTree(tree *RegexTree) *regexFc {
+ curNode := tree.Root
+ curChild := 0
+
+ for {
+ if len(curNode.Children) == 0 {
+ // This is a leaf node
+ s.calculateFC(curNode.T, curNode, 0)
+ } else if curChild < len(curNode.Children) && !s.skipAllChildren {
+ // This is an interior node, and we have more children to analyze
+ s.calculateFC(curNode.T|BeforeChild, curNode, curChild)
+
+ if !s.skipchild {
+ curNode = curNode.Children[curChild]
+ // this stack is how we get a depth first walk of the tree.
+ s.pushInt(curChild)
+ curChild = 0
+ } else {
+ curChild++
+ s.skipchild = false
+ }
+ continue
+ }
+
+ // This is an interior node where we've finished analyzing all the children, or
+ // the end of a leaf node.
+ s.skipAllChildren = false
+
+ if s.intIsEmpty() {
+ break
+ }
+
+ curChild = s.popInt()
+ curNode = curNode.Parent
+
+ s.calculateFC(curNode.T|AfterChild, curNode, curChild)
+ if s.failed {
+ return nil
+ }
+
+ curChild++
+ }
+
+ if s.fcIsEmpty() {
+ return nil
+ }
+
+ return s.popFC()
+}
+
+// To avoid recursion, we use a simple integer stack.
+// This is the push.
+func (s *regexFcd) pushInt(I int) {
+ if s.intDepth >= len(s.intStack) {
+ expanded := make([]int, s.intDepth*2)
+ copy(expanded, s.intStack)
+ s.intStack = expanded
+ }
+
+ s.intStack[s.intDepth] = I
+ s.intDepth++
+}
+
+// True if the stack is empty.
+func (s *regexFcd) intIsEmpty() bool {
+ return s.intDepth == 0
+}
+
+// This is the pop.
+func (s *regexFcd) popInt() int {
+ s.intDepth--
+ return s.intStack[s.intDepth]
+}
+
+// We also use a stack of RegexFC objects.
+// This is the push.
+func (s *regexFcd) pushFC(fc regexFc) {
+ if s.fcDepth >= len(s.fcStack) {
+ expanded := make([]regexFc, s.fcDepth*2)
+ copy(expanded, s.fcStack)
+ s.fcStack = expanded
+ }
+
+ s.fcStack[s.fcDepth] = fc
+ s.fcDepth++
+}
+
+// True if the stack is empty.
+func (s *regexFcd) fcIsEmpty() bool {
+ return s.fcDepth == 0
+}
+
+// This is the pop.
+func (s *regexFcd) popFC() *regexFc {
+ s.fcDepth--
+ return &s.fcStack[s.fcDepth]
+}
+
+// This is the top.
+func (s *regexFcd) topFC() *regexFc {
+ return &s.fcStack[s.fcDepth-1]
+}
+
+// Called in Beforechild to prevent further processing of the current child
+func (s *regexFcd) skipChild() {
+ s.skipchild = true
+}
+
+// FC computation and shortcut cases for each node type
+func (s *regexFcd) calculateFC(nt NodeType, node *RegexNode, CurIndex int) {
+ //fmt.Printf("NodeType: %v, CurIndex: %v, Desc: %v\n", nt, CurIndex, node.description())
+ ci := false
+ rtl := false
+
+ if nt <= NtRef {
+ if (node.Options & IgnoreCase) != 0 {
+ ci = true
+ }
+ if (node.Options & RightToLeft) != 0 {
+ rtl = true
+ }
+ }
+
+ switch nt {
+ case NtConcatenate | BeforeChild, NtAlternate | BeforeChild, NtBackRefCond | BeforeChild, NtLoop | BeforeChild, NtLazyloop | BeforeChild:
+
+ case NtExprCond | BeforeChild:
+ if CurIndex == 0 {
+ s.skipChild()
+ }
+
+ case NtEmpty:
+ s.pushFC(regexFc{nullable: true})
+
+ case NtConcatenate | AfterChild:
+ if CurIndex != 0 {
+ child := s.popFC()
+ cumul := s.topFC()
+
+ s.failed = !cumul.addFC(*child, true)
+ }
+
+ fc := s.topFC()
+ if !fc.nullable {
+ s.skipAllChildren = true
+ }
+
+ case NtExprCond | AfterChild:
+ if CurIndex > 1 {
+ child := s.popFC()
+ cumul := s.topFC()
+
+ s.failed = !cumul.addFC(*child, false)
+ }
+
+ case NtAlternate | AfterChild, NtBackRefCond | AfterChild:
+ if CurIndex != 0 {
+ child := s.popFC()
+ cumul := s.topFC()
+
+ s.failed = !cumul.addFC(*child, false)
+ }
+
+ case NtLoop | AfterChild, NtLazyloop | AfterChild:
+ if node.M == 0 {
+ fc := s.topFC()
+ fc.nullable = true
+ }
+
+ case NtGroup | BeforeChild, NtGroup | AfterChild, NtCapture | BeforeChild, NtCapture | AfterChild, NtAtomic | BeforeChild, NtAtomic | AfterChild:
+
+ case NtPosLook | BeforeChild, NtNegLook | BeforeChild:
+ s.skipChild()
+ s.pushFC(regexFc{nullable: true})
+
+ case NtPosLook | AfterChild, NtNegLook | AfterChild:
+
+ case NtOne, NtNotone:
+ s.pushFC(newRegexFc(node.Ch, nt == NtNotone, false, ci))
+
+ case NtOneloop, NtOnelazy, NtOneloopatomic:
+ s.pushFC(newRegexFc(node.Ch, false, node.M == 0, ci))
+
+ case NtNotoneloop, NtNotonelazy, NtNotoneloopatomic:
+ s.pushFC(newRegexFc(node.Ch, true, node.M == 0, ci))
+
+ case NtMulti:
+ if len(node.Str) == 0 {
+ s.pushFC(regexFc{nullable: true})
+ } else if !rtl {
+ s.pushFC(newRegexFc(node.Str[0], false, false, ci))
+ } else {
+ s.pushFC(newRegexFc(node.Str[len(node.Str)-1], false, false, ci))
+ }
+
+ case NtSet:
+ s.pushFC(regexFc{cc: node.Set.Copy(), nullable: false, caseInsensitive: ci})
+
+ case NtSetloop, NtSetlazy, NtSetloopatomic:
+ s.pushFC(regexFc{cc: node.Set.Copy(), nullable: node.M == 0, caseInsensitive: ci})
+
+ case NtRef:
+ s.pushFC(regexFc{cc: *AnyClass(), nullable: true, caseInsensitive: false})
+
+ case NtNothing, NtBol, NtEol, NtBoundary, NtNonboundary, NtECMABoundary, NtNonECMABoundary, NtBeginning, NtStart, NtEndZ, NtEnd, NtUpdateBumpalong:
+ s.pushFC(regexFc{nullable: true})
+
+ default:
+ panic(fmt.Sprintf("unexpected op code: %v", nt))
+ }
+}
+
+type regexFc struct {
+ cc CharSet
+ nullable bool
+ caseInsensitive bool
+}
+
+func newRegexFc(ch rune, not, nullable, caseInsensitive bool) regexFc {
+ r := regexFc{
+ caseInsensitive: caseInsensitive,
+ nullable: nullable,
+ }
+ if not {
+ if ch > 0 {
+ r.cc.addRange('\x00', ch-1)
+ }
+ if ch < 0xFFFF {
+ r.cc.addRange(ch+1, utf8.MaxRune)
+ }
+ } else {
+ r.cc.addRange(ch, ch)
+ }
+ return r
+}
+
+func (r *regexFc) getFirstChars() CharSet {
+ if r.caseInsensitive {
+ r.cc.addLowercase()
+ }
+
+ return r.cc
+}
+
+func (r *regexFc) addFC(fc regexFc, concatenate bool) bool {
+ if !r.cc.IsMergeable() || !fc.cc.IsMergeable() {
+ return false
+ }
+
+ if concatenate {
+ if !r.nullable {
+ return true
+ }
+
+ if !fc.nullable {
+ r.nullable = false
+ }
+ } else {
+ if fc.nullable {
+ r.nullable = true
+ }
+ }
+
+ r.caseInsensitive = r.caseInsensitive || fc.caseInsensitive
+ r.cc.addSet(fc.cc)
+
+ return true
+}
+
+// This is a related computation: it takes a RegexTree and computes the
+// leading substring if it sees one. It's quite trivial and gives up easily.
+func getPrefix(tree *RegexTree) *Prefix {
+ var concatNode *RegexNode
+ nextChild := 0
+
+ curNode := tree.Root
+
+ for {
+ switch curNode.T {
+ case NtConcatenate:
+ if len(curNode.Children) > 0 {
+ concatNode = curNode
+ nextChild = 0
+ }
+
+ case NtAtomic, NtCapture:
+ curNode = curNode.Children[0]
+ concatNode = nil
+ continue
+
+ case NtOneloop, NtOnelazy:
+ if curNode.M > 0 {
+ return &Prefix{
+ PrefixStr: repeat(curNode.Ch, curNode.M),
+ CaseInsensitive: (curNode.Options & IgnoreCase) != 0,
+ }
+ }
+ return nil
+
+ case NtOne:
+ return &Prefix{
+ PrefixStr: []rune{curNode.Ch},
+ CaseInsensitive: (curNode.Options & IgnoreCase) != 0,
+ }
+
+ case NtMulti:
+ return &Prefix{
+ PrefixStr: curNode.Str,
+ CaseInsensitive: (curNode.Options & IgnoreCase) != 0,
+ }
+
+ case NtBol, NtEol, NtBoundary, NtECMABoundary, NtBeginning, NtStart,
+ NtEndZ, NtEnd, NtEmpty, NtPosLook, NtNegLook:
+
+ default:
+ return nil
+ }
+
+ if concatNode == nil || nextChild >= len(concatNode.Children) {
+ return nil
+ }
+
+ curNode = concatNode.Children[nextChild]
+ nextChild++
+ }
+}
+
+// repeat the rune r, c times... up to the max of MaxPrefixSize
+func repeat(r rune, c int) []rune {
+ if c > MaxPrefixSize {
+ c = MaxPrefixSize
+ }
+
+ ret := make([]rune, c)
+
+ // binary growth using copy for speed
+ ret[0] = r
+ bp := 1
+ for bp < len(ret) {
+ copy(ret[bp:], ret[:bp])
+ bp *= 2
+ }
+
+ return ret
+}
+
+// BmPrefix precomputes the Boyer-Moore
+// tables for fast string scanning. These tables allow
+// you to scan for the first occurrence of a string within
+// a large body of text without examining every character.
+// The performance of the heuristic depends on the actual
+// string and the text being searched, but usually, the longer
+// the string that is being searched for, the fewer characters
+// need to be examined.
+type BmPrefix struct {
+ positive []int
+ negativeASCII []int
+ negativeUnicode [][]int
+ pattern []rune
+ lowASCII rune
+ highASCII rune
+ rightToLeft bool
+ caseInsensitive bool
+}
+
+func newBmPrefix(pattern []rune, caseInsensitive, rightToLeft bool) *BmPrefix {
+
+ b := &BmPrefix{
+ rightToLeft: rightToLeft,
+ caseInsensitive: caseInsensitive,
+ pattern: pattern,
+ }
+
+ if caseInsensitive {
+ for i := 0; i < len(b.pattern); i++ {
+ // We do the ToLower character by character for consistency. With surrogate chars, doing
+ // a ToLower on the entire string could actually change the surrogate pair. This is more correct
+ // linguistically, but since Regex doesn't support surrogates, it's more important to be
+ // consistent.
+
+ b.pattern[i] = unicode.ToLower(b.pattern[i])
+ }
+ }
+
+ var beforefirst, last, bump int
+ var scan, match int
+
+ if !rightToLeft {
+ beforefirst = -1
+ last = len(b.pattern) - 1
+ bump = 1
+ } else {
+ beforefirst = len(b.pattern)
+ last = 0
+ bump = -1
+ }
+
+ // PART I - the good-suffix shift table
+ //
+ // compute the positive requirement:
+ // if char "i" is the first one from the right that doesn't match,
+ // then we know the matcher can advance by _positive[i].
+ //
+ // This algorithm is a simplified variant of the standard
+ // Boyer-Moore good suffix calculation.
+
+ b.positive = make([]int, len(b.pattern))
+
+ examine := last
+ ch := b.pattern[examine]
+ b.positive[examine] = bump
+ examine -= bump
+
+Outerloop:
+ for {
+ // find an internal char (examine) that matches the tail
+
+ for {
+ if examine == beforefirst {
+ break Outerloop
+ }
+ if b.pattern[examine] == ch {
+ break
+ }
+ examine -= bump
+ }
+
+ match = last
+ scan = examine
+
+ // find the length of the match
+ for {
+ if scan == beforefirst || b.pattern[match] != b.pattern[scan] {
+ // at the end of the match, note the difference in _positive
+ // this is not the length of the match, but the distance from the internal match
+ // to the tail suffix.
+ if b.positive[match] == 0 {
+ b.positive[match] = match - scan
+ }
+
+ // System.Diagnostics.Debug.WriteLine("Set positive[" + match + "] to " + (match - scan));
+
+ break
+ }
+
+ scan -= bump
+ match -= bump
+ }
+
+ examine -= bump
+ }
+
+ match = last - bump
+
+ // scan for the chars for which there are no shifts that yield a different candidate
+
+ // The inside of the if statement used to say
+ // "_positive[match] = last - beforefirst;"
+ // This is slightly less aggressive in how much we skip, but at worst it
+ // should mean a little more work rather than skipping a potential match.
+ for match != beforefirst {
+ if b.positive[match] == 0 {
+ b.positive[match] = bump
+ }
+
+ match -= bump
+ }
+
+ // PART II - the bad-character shift table
+ //
+ // compute the negative requirement:
+ // if char "ch" is the reject character when testing position "i",
+ // we can slide up by _negative[ch];
+ // (_negative[ch] = str.Length - 1 - str.LastIndexOf(ch))
+ //
+ // the lookup table is divided into ASCII and Unicode portions;
+ // only those parts of the Unicode 16-bit code set that actually
+ // appear in the string are in the table. (Maximum size with
+ // Unicode is 65K; ASCII only case is 512 bytes.)
+
+ b.negativeASCII = make([]int, 128)
+
+ for i := 0; i < len(b.negativeASCII); i++ {
+ b.negativeASCII[i] = last - beforefirst
+ }
+
+ b.lowASCII = 127
+ b.highASCII = 0
+
+ for examine = last; examine != beforefirst; examine -= bump {
+ ch = b.pattern[examine]
+
+ switch {
+ case ch < 128:
+ if b.lowASCII > ch {
+ b.lowASCII = ch
+ }
+
+ if b.highASCII < ch {
+ b.highASCII = ch
+ }
+
+ if b.negativeASCII[ch] == last-beforefirst {
+ b.negativeASCII[ch] = last - examine
+ }
+ case ch <= 0xffff:
+ i, j := ch>>8, ch&0xFF
+
+ if b.negativeUnicode == nil {
+ b.negativeUnicode = make([][]int, 256)
+ }
+
+ if b.negativeUnicode[i] == nil {
+ newarray := make([]int, 256)
+
+ for k := 0; k < len(newarray); k++ {
+ newarray[k] = last - beforefirst
+ }
+
+ if i == 0 {
+ copy(newarray, b.negativeASCII)
+ //TODO: this line needed?
+ b.negativeASCII = newarray
+ }
+
+ b.negativeUnicode[i] = newarray
+ }
+
+ if b.negativeUnicode[i][j] == last-beforefirst {
+ b.negativeUnicode[i][j] = last - examine
+ }
+ default:
+ // we can't do the filter because this algo doesn't support
+ // unicode chars >0xffff
+ return nil
+ }
+ }
+
+ return b
+}
+
+func (b *BmPrefix) String() string {
+ return string(b.pattern)
+}
+
+// Dump returns the contents of the filter as a human readable string
+func (b *BmPrefix) Dump(indent string) string {
+ buf := &bytes.Buffer{}
+
+ fmt.Fprintf(buf, "%sBM Pattern: %s\n%sPositive: ", indent, string(b.pattern), indent)
+ for i := 0; i < len(b.positive); i++ {
+ buf.WriteString(strconv.Itoa(b.positive[i]))
+ buf.WriteRune(' ')
+ }
+ buf.WriteRune('\n')
+
+ if b.negativeASCII != nil {
+ buf.WriteString(indent)
+ buf.WriteString("Negative table\n")
+ for i := 0; i < len(b.negativeASCII); i++ {
+ if b.negativeASCII[i] != len(b.pattern) {
+ fmt.Fprintf(buf, "%s %s %s\n", indent, Escape(string(rune(i))), strconv.Itoa(b.negativeASCII[i]))
+ }
+ }
+ }
+
+ return buf.String()
+}
+
+// Scan uses the Boyer-Moore algorithm to find the first occurrence
+// of the specified string within text, beginning at index, and
+// constrained within beglimit and endlimit.
+//
+// The direction and case-sensitivity of the match is determined
+// by the arguments to the RegexBoyerMoore constructor.
+func (b *BmPrefix) Scan(text []rune, index, beglimit, endlimit int) int {
+ var (
+ defadv, test, test2 int
+ match, startmatch, endmatch int
+ bump, advance int
+ chTest rune
+ unicodeLookup []int
+ )
+
+ if !b.rightToLeft {
+ defadv = len(b.pattern)
+ startmatch = len(b.pattern) - 1
+ endmatch = 0
+ test = index + defadv - 1
+ bump = 1
+ } else {
+ defadv = -len(b.pattern)
+ startmatch = 0
+ endmatch = -defadv - 1
+ test = index + defadv
+ bump = -1
+ }
+
+ chMatch := b.pattern[startmatch]
+
+ for {
+ if test >= endlimit || test < beglimit {
+ return -1
+ }
+
+ chTest = text[test]
+
+ if b.caseInsensitive {
+ chTest = unicode.ToLower(chTest)
+ }
+
+ if chTest != chMatch {
+ if chTest < 128 {
+ advance = b.negativeASCII[chTest]
+ } else if chTest < 0xffff && len(b.negativeUnicode) > 0 {
+ unicodeLookup = b.negativeUnicode[chTest>>8]
+ if len(unicodeLookup) > 0 {
+ advance = unicodeLookup[chTest&0xFF]
+ } else {
+ advance = defadv
+ }
+ } else {
+ advance = defadv
+ }
+
+ test += advance
+ } else { // if (chTest == chMatch)
+ test2 = test
+ match = startmatch
+
+ for {
+ if match == endmatch {
+ if b.rightToLeft {
+ return test2 + 1
+ } else {
+ return test2
+ }
+ }
+
+ match -= bump
+ test2 -= bump
+
+ chTest = text[test2]
+
+ if b.caseInsensitive {
+ chTest = unicode.ToLower(chTest)
+ }
+
+ if chTest != b.pattern[match] {
+ advance = b.positive[match]
+ if chTest < 128 {
+ test2 = (match - startmatch) + b.negativeASCII[chTest]
+ } else if chTest < 0xffff && len(b.negativeUnicode) > 0 {
+ unicodeLookup = b.negativeUnicode[chTest>>8]
+ if len(unicodeLookup) > 0 {
+ test2 = (match - startmatch) + unicodeLookup[chTest&0xFF]
+ } else {
+ test += advance
+ break
+ }
+ } else {
+ test += advance
+ break
+ }
+
+ if b.rightToLeft {
+ if test2 < advance {
+ advance = test2
+ }
+ } else if test2 > advance {
+ advance = test2
+ }
+
+ test += advance
+ break
+ }
+ }
+ }
+ }
+}
+
+// When a regex is anchored, we can do a quick IsMatch test instead of a Scan
+func (b *BmPrefix) IsMatch(text []rune, index, beglimit, endlimit int) bool {
+ if !b.rightToLeft {
+ if index < beglimit || endlimit-index < len(b.pattern) {
+ return false
+ }
+
+ return b.matchPattern(text, index)
+ } else {
+ if index > endlimit || index-beglimit < len(b.pattern) {
+ return false
+ }
+
+ return b.matchPattern(text, index-len(b.pattern))
+ }
+}
+
+func (b *BmPrefix) matchPattern(text []rune, index int) bool {
+ if len(text)-index < len(b.pattern) {
+ return false
+ }
+
+ if b.caseInsensitive {
+ for i := 0; i < len(b.pattern); i++ {
+ //Debug.Assert(textinfo.ToLower(_pattern[i]) == _pattern[i], "pattern should be converted to lower case in constructor!");
+ if unicode.ToLower(text[index+i]) != b.pattern[i] {
+ return false
+ }
+ }
+ return true
+ } else {
+ for i := 0; i < len(b.pattern); i++ {
+ if text[index+i] != b.pattern[i] {
+ return false
+ }
+ }
+ return true
+ }
+}
+
+type AnchorLoc int16
+
+// where the regex can be pegged
+const (
+ AnchorBeginning AnchorLoc = 0x0001
+ AnchorBol AnchorLoc = 0x0002
+ AnchorStart AnchorLoc = 0x0004
+ AnchorEol AnchorLoc = 0x0008
+ AnchorEndZ AnchorLoc = 0x0010
+ AnchorEnd AnchorLoc = 0x0020
+ AnchorBoundary AnchorLoc = 0x0040
+ AnchorECMABoundary AnchorLoc = 0x0080
+)
+
+func getAnchors(tree *RegexTree) AnchorLoc {
+
+ var concatNode *RegexNode
+ nextChild, result := 0, AnchorLoc(0)
+
+ curNode := tree.Root
+
+ for {
+ switch curNode.T {
+ case NtConcatenate:
+ if len(curNode.Children) > 0 {
+ concatNode = curNode
+ nextChild = 0
+ }
+
+ case NtAtomic, NtCapture:
+ curNode = curNode.Children[0]
+ concatNode = nil
+ continue
+
+ case NtBol, NtEol, NtBoundary, NtECMABoundary, NtBeginning,
+ NtStart, NtEndZ, NtEnd:
+ return result | anchorFromType(curNode.T)
+
+ case NtEmpty, NtPosLook, NtNegLook:
+
+ default:
+ return result
+ }
+
+ if concatNode == nil || nextChild >= len(concatNode.Children) {
+ return result
+ }
+
+ curNode = concatNode.Children[nextChild]
+ nextChild++
+ }
+}
+
+func anchorFromType(t NodeType) AnchorLoc {
+ switch t {
+ case NtBol:
+ return AnchorBol
+ case NtEol:
+ return AnchorEol
+ case NtBoundary:
+ return AnchorBoundary
+ case NtECMABoundary:
+ return AnchorECMABoundary
+ case NtBeginning:
+ return AnchorBeginning
+ case NtStart:
+ return AnchorStart
+ case NtEndZ:
+ return AnchorEndZ
+ case NtEnd:
+ return AnchorEnd
+ default:
+ return 0
+ }
+}
+
+// anchorDescription returns a human-readable description of the anchors
+func (anchors AnchorLoc) String() string {
+ buf := &bytes.Buffer{}
+
+ if (anchors & AnchorBeginning) != 0 {
+ buf.WriteString(", Beginning")
+ }
+ if (anchors & AnchorStart) != 0 {
+ buf.WriteString(", Start")
+ }
+ if (anchors & AnchorBol) != 0 {
+ buf.WriteString(", Bol")
+ }
+ if (anchors & AnchorBoundary) != 0 {
+ buf.WriteString(", Boundary")
+ }
+ if (anchors & AnchorECMABoundary) != 0 {
+ buf.WriteString(", ECMABoundary")
+ }
+ if (anchors & AnchorEol) != 0 {
+ buf.WriteString(", Eol")
+ }
+ if (anchors & AnchorEnd) != 0 {
+ buf.WriteString(", End")
+ }
+ if (anchors & AnchorEndZ) != 0 {
+ buf.WriteString(", EndZ")
+ }
+
+ // trim off comma
+ if buf.Len() >= 2 {
+ return buf.String()[2:]
+ }
+ return "None"
+}
+
+func findLeadingOrTrailingAnchor(node *RegexNode, leading bool) NodeType {
+ for {
+ switch node.T {
+ case NtBol, NtEol, NtBeginning, NtStart, NtEndZ, NtEnd, NtBoundary, NtECMABoundary:
+ // anchor found
+ return node.T
+ case NtAtomic, NtCapture:
+ // For groups, continue exploring the sole child.
+ node = node.Children[0]
+ continue
+ case NtConcatenate:
+ // For concatenations, we expect primarily to explore its first (for leading) or last (for trailing) child,
+ // but we can also skip over certain kinds of nodes (e.g. Empty), and thus iterate through its children backward
+ // looking for the last we shouldn't skip.
+ var child *RegexNode
+
+ if leading {
+ for i := 0; i < len(node.Children); i++ {
+ t := node.Children[i].T
+ if t != NtEmpty && t != NtPosLook && t != NtNegLook {
+ child = node.Children[i]
+ break
+ }
+ }
+ } else {
+ for i := len(node.Children) - 1; i >= 0; i-- {
+ t := node.Children[i].T
+ if t != NtEmpty && t != NtPosLook && t != NtNegLook {
+ child = node.Children[i]
+ break
+ }
+ }
+ }
+ if child != nil {
+ node = child
+ continue
+ }
+
+ case NtAlternate:
+ // For alternations, every branch needs to lead or trail with the same anchor.
+
+ // Get the leading/trailing anchor of the first branch. If there isn't one, bail.
+ anchor := findLeadingOrTrailingAnchor(node.Children[0], leading)
+ if anchor == NtUnknown {
+ return NtUnknown
+ }
+
+ // Look at each subsequent branch and validate it has the same leading or trailing
+ // anchor. If any doesn't, bail.
+ for i := 1; i < len(node.Children); i++ {
+ if findLeadingOrTrailingAnchor(node.Children[i], leading) != anchor {
+ return NtUnknown
+ }
+ }
+
+ // All branches have the same leading/trailing anchor. Return it.
+ return anchor
+
+ }
+
+ // no anchor
+ return NtUnknown
+ }
+}
diff --git a/vendor/github.com/dlclark/regexp2/v2/syntax/prefixanalyzer.go b/vendor/github.com/dlclark/regexp2/v2/syntax/prefixanalyzer.go
new file mode 100644
index 0000000000..0490585bd2
--- /dev/null
+++ b/vendor/github.com/dlclark/regexp2/v2/syntax/prefixanalyzer.go
@@ -0,0 +1,1491 @@
+package syntax
+
+import (
+ "bytes"
+ "cmp"
+ "math"
+ "slices"
+ "strings"
+ "unicode"
+ "unicode/utf8"
+ "unsafe"
+)
+
+// Computes a character class for the first character in tree. This uses a more robust algorithm
+// than is used by TryFindFixedLiterals and thus can find starting sets it couldn't. For example,
+// fixed literals won't find the starting set for a*b, as the a isn't guaranteed and the b is at a
+// variable position, but this will find [ab] as it's instead looking for anything that under any
+// circumstance could possibly start a match.
+func findFirstCharClass(root *RegexNode) *CharSet {
+ // Explore the graph, adding found chars into a result set, which is lazily initialized so that
+ // we can initialize it to a parsed set if we discover one first (this is helpful not just for allocation
+ // but because it enables supporting starting negated sets, which wouldn't work if they had to be merged
+ // into a non-negated default set). If the operation returns true, we successfully explore all relevant nodes
+ // in the graph. If it returns false, we were unable to successfully explore all relevant nodes, typically
+ // due to conflicts when trying to add characters into the result set, e.g. we may have read a negated set
+ // and were then unable to merge into that a subsequent non-negated set. If it returns null, it means the
+ // whole pattern was nullable such that it could match an empty string, in which case we
+ // can't make any statements about what begins a match.
+ var cc *CharSet
+ if tryFindFirstCharClass(root, &cc) == 1 {
+ return cc
+ }
+ return nil
+}
+
+// Walks the nodes of the expression looking for any node that could possibly match the first
+// character of a match, e.g. in `a*b*c+d`, we'd find [abc], or in `(abc|d*e)?[fgh]`, we'd find
+// [adefgh]. The function is called for each node, recurring into children where appropriate,
+// and returns:
+// - 1 if the child was successfully processed and represents a stopping point, e.g. a single
+// char loop with a minimum bound greater than 0 such that nothing after that node in a
+// concatenation could possibly match the first character.
+// - 0 if the child failed to be processed but needed to be, such that the results can't
+// be trusted. If any node returns false, the whole operation fails.
+// - -1 if the child was successfully processed but doesn't represent a stopping point, i.e.
+// it's zero-width (e.g. empty, a lookaround, an anchor, etc.) or it could be zero-width
+// (e.g. a loop with a min bound of 0). A concatenation processing a child that returns
+// -1 needs to keep processing the next child.
+func tryFindFirstCharClass(node *RegexNode, ccIn **CharSet) int {
+ cc := *ccIn
+
+ switch node.T {
+ // Base cases where we have results to add to the result set. Add the values into the result set, if possible.
+ // If this is a loop and it has a lower bound of 0, then it's zero-width, so return null.
+ case NtOne, NtOneloop, NtOnelazy, NtOneloopatomic:
+ if cc == nil {
+ cc = &CharSet{}
+ *ccIn = cc
+ }
+ if cc.IsMergeable() {
+ cc.addChar(node.Ch)
+ if node.T == NtOne || node.M > 0 {
+ return 1
+ }
+ return -1
+ }
+ return 0
+
+ case NtNotone, NtNotoneloop, NtNotonelazy, NtNotoneloopatomic:
+ if cc == nil {
+ cc = &CharSet{}
+ *ccIn = cc
+ }
+ if cc.IsMergeable() {
+ cc.addChar(node.Ch)
+ cc.negate = true
+ /*if node.Ch > 0 {
+ // Add the range before the excluded char.
+ cc.addRange(0, (node.Ch - 1))
+ }
+ if node.Ch < unicode.MaxRune {
+ // Add the range after the excluded char.
+ cc.addRange(node.Ch+1, unicode.MaxRune)
+ }*/
+ if node.T == NtNotone || node.M > 0 {
+ return 1
+ }
+ return -1
+ }
+ return 0
+
+ case NtSet, NtSetloop, NtSetlazy, NtSetloopatomic:
+ {
+ setSuccess := false
+ if cc == nil {
+ cp := node.Set.Copy()
+ *ccIn = &cp
+ setSuccess = true
+ } else if cc.IsMergeable() && node.Set.IsMergeable() {
+ cc.addSet(*node.Set)
+ setSuccess = true
+ }
+ if !setSuccess {
+ return 0
+ } else if node.T == NtSet || node.M > 0 {
+ return 1
+ }
+ return -1
+ }
+
+ case NtMulti:
+ if cc == nil {
+ cc = &CharSet{}
+ *ccIn = cc
+ }
+ if cc.IsMergeable() {
+ if node.Options&RightToLeft != 0 {
+ cc.addChar(node.Str[len(node.Str)-1])
+ } else {
+ cc.addChar(node.Str[0])
+ }
+ return 1
+ }
+ return 0
+
+ // Zero-width elements. These don't contribute to the starting set, so return null to indicate a caller
+ // should keep looking past them.
+ case NtEmpty, NtNothing, NtBol, NtEol, NtBoundary, NtNonboundary, NtECMABoundary, NtNonECMABoundary,
+ NtBeginning, NtStart, NtEndZ, NtEnd, NtUpdateBumpalong, NtPosLook, NtNegLook:
+ return -1
+
+ // Groups. These don't contribute anything of their own, and are just pass-throughs to their children.
+ case NtAtomic, NtCapture:
+ return tryFindFirstCharClass(node.Children[0], ccIn)
+
+ // Loops. Like groups, these are mostly pass-through: if the child fails, then the whole operation needs
+ // to fail, and if the child is nullable, then the loop is as well. However, if the child succeeds but
+ // the loop has a lower bound of 0, then the loop is still nullable.
+ case NtLoop, NtLazyloop:
+ val := tryFindFirstCharClass(node.Children[0], ccIn)
+ if val <= 0 || node.M != 0 {
+ return val
+ }
+ return -1
+
+ // Concatenation. Loop through the children as long as they're nullable. The moment a child returns true,
+ // we don't need or want to look further, as that child represents non-zero-width and nothing beyond it can
+ // contribute to the starting character set. The moment a child returns false, we need to fail the whole thing.
+ // If every child is nullable, then the concatenation is also nullable.
+ case NtConcatenate:
+ for i := 0; i < len(node.Children); i++ {
+ childResult := tryFindFirstCharClass(node.Children[i], ccIn)
+ if childResult != -1 {
+ return childResult
+ }
+ }
+ return -1
+
+ // Alternation. Every child is its own fork/branch and contributes to the starting set. As with concatenation,
+ // the moment any child fails, fail. And if any child is nullable, the alternation is also nullable (since that
+ // zero-width path could be taken). Otherwise, if every branch returns true, so too does the alternation.
+ case NtAlternate:
+ anyChildWasNull := false
+ for i := 0; i < len(node.Children); i++ {
+ childResult := tryFindFirstCharClass(node.Children[i], ccIn)
+ switch childResult {
+ case -1:
+ anyChildWasNull = true
+ case 0:
+ return 0
+ }
+ }
+ if anyChildWasNull {
+ return -1
+ }
+ return 1
+
+ // Conditionals. Just like alternation for their "yes"/"no" child branches. If either returns false, return false.
+ // If either is nullable, this is nullable. If both return true, return true.
+ case NtBackRefCond, NtExprCond:
+ branchStart := 1
+ if node.T == NtBackRefCond {
+ branchStart = 0
+ }
+ // conditional without all the branches
+ if branchStart+1 >= len(node.Children) {
+ return -1
+ }
+ start := tryFindFirstCharClass(node.Children[branchStart], ccIn)
+ next := tryFindFirstCharClass(node.Children[branchStart+1], ccIn)
+ if start == -1 || next == -1 {
+ return -1
+ }
+ if start == 0 || next == 0 {
+ return 0
+ }
+ return 1
+
+ // Backreferences. We can't easily make any claims about what content they might match, so just give up.
+ case NtRef:
+ return 0
+ }
+
+ // Unknown node.
+ return 0
+}
+
+// Computes the leading ordinal case-insensitive substring in node
+func findPrefixOrdinalCaseInsensitive(node *RegexNode) string {
+ for {
+ // Search down the left side of the tree looking for a concatenation. If we find one,
+ // ask it for any ordinal case-insensitive prefix it has.
+ switch node.T {
+ case NtLoop, NtLazyloop:
+ if node.M <= 0 {
+ return ""
+ }
+ fallthrough
+ case NtAtomic, NtCapture:
+ node = node.Children[0]
+ continue
+
+ case NtConcatenate:
+ _, _, caseInsensitiveString := node.TryGetOrdinalCaseInsensitiveString(0, len(node.Children), true)
+ return caseInsensitiveString
+
+ default:
+ return ""
+ }
+ }
+}
+
+// Computes the leading substring in node may be empty.
+func findPrefix(node *RegexNode) string {
+ vsb := &bytes.Buffer{}
+ tryFindPrefix(node, vsb)
+ return vsb.String()
+}
+
+// Processes the node, adding any prefix text to the builder.
+// Returns whether processing should continue with subsequent nodes.
+func tryFindPrefix(node *RegexNode, vsb *bytes.Buffer) bool {
+ // We don't bother to handle reversed input, so process at most one node
+ // when handling RightToLeft.
+ rtl := (node.Options & RightToLeft) != 0
+
+ switch node.T {
+ // Concatenation
+ case NtConcatenate:
+ for i := 0; i < len(node.Children); i++ {
+ if !tryFindPrefix(node.Children[i], vsb) {
+ return false
+ }
+ }
+ return !rtl
+ // Alternation: find a string that's a shared prefix of all branches
+ case NtAlternate:
+ // for RTL we'd need to be matching the suffixes of the alternation cases
+ if rtl {
+ return false
+ }
+
+ // Store the initial branch into the target builder, keeping track
+ // of how much was appended. Any of this contents that doesn't overlap
+ // will every other branch will be removed before returning.
+ initialLength := vsb.Len()
+ tryFindPrefix(node.Children[0], vsb)
+ addedLength := vsb.Len() - initialLength
+
+ // Then explore the rest of the branches, finding the length
+ // of prefix they all share in common with the initial branch.
+ if addedLength != 0 {
+ alternateSb := &bytes.Buffer{}
+ vsbSlice := vsb.Bytes()[initialLength : initialLength+addedLength]
+
+ // Process each branch. If we reach a point where we've proven there's
+ // no overlap, we can bail early.
+ for i := 1; i < len(node.Children) && addedLength != 0; i++ {
+ alternateSb.Reset()
+
+ // Process the branch into a temporary builder.
+ tryFindPrefix(node.Children[i], alternateSb)
+
+ // Find how much overlap there is between this branch's prefix
+ // and the smallest amount of prefix that overlapped with all
+ // the previously seen branches.
+ addedLength = commonPrefixLen(vsbSlice, alternateSb.Bytes())
+ }
+
+ // Then cull back on what was added based on the other branches.
+ vsb.Truncate(initialLength + addedLength)
+ }
+
+ // Don't explore anything after the alternation. We could make this work if desirable,
+ // but it's currently not worth the extra complication. The entire contents of every
+ // branch would need to be identical other than zero-width anchors/assertions.
+ return false
+
+ // One character
+ case NtOne:
+ vsb.WriteRune(node.Ch)
+ return !rtl
+
+ // Multiple characters
+ case NtMulti:
+ vsb.WriteString(string(node.Str))
+ return !rtl
+
+ // Loop of one character
+ case NtOneloop /*NtOneloopatomic,*/, NtOnelazy:
+ if node.M <= 0 {
+ return false
+ }
+ // arbitrary cut-off to avoid creating super long strings unnecessarily
+ count := 32
+ if node.M < count {
+ count = node.M
+ }
+ vsb.WriteString(strings.Repeat(string(node.Ch), count))
+ return count == node.N && !rtl
+
+ // Loop of a node
+ case NtLoop, NtLazyloop:
+ if node.M <= 0 {
+ return false
+ }
+
+ // arbitrary cut-off to avoid creating super long strings unnecessarily
+ limit := 4
+ if node.M < limit {
+ limit = node.M
+ }
+ for i := 0; i < limit; i++ {
+ if tryFindPrefix(node.Children[0], vsb) {
+ return false
+ }
+ }
+ return limit == node.N && !rtl
+
+ // Grouping nodes for which we only care about their single child
+ case NtAtomic, NtCapture:
+ return tryFindPrefix(node.Children[0], vsb)
+
+ // Zero-width anchors and assertions
+ case NtBol, NtEol, NtBoundary, NtECMABoundary, NtNonboundary, NtNonECMABoundary, NtBeginning,
+ NtStart, NtEndZ, NtEnd, NtEmpty, NtUpdateBumpalong, NtPosLook, NtNegLook:
+ return true
+ }
+ // Give up for anything else
+ return false
+}
+
+// commonPrefixLen returns the length of the common prefix of two strings.
+func commonPrefixLen(a, b []byte) int {
+ commonLen := min(len(a), len(b))
+ i := 0
+ // Optimization: load and compare word-sized chunks at a time.
+ // This is about 6x faster than the naive approach when len > 64.
+ //
+ // TODO(adonovan): further optimizations are possible,
+ // at the cost of portability, for example by:
+ // - better elimination of bounds checks;
+ // - use of uint64 instead of an array may result in better
+ // registerization, and allows computing the final portion
+ // from the bitmask:
+ //
+ // cmp := load64le(a, i) ^ load64le(b, i)
+ // if cmp != 0 {
+ // return i + bits.LeadingZeros64(cmp)/8
+ // }
+ //
+ // - use of vector instructions in the manner of
+ // runtime.cmpstring, which is expected to achieve 3x
+ // further improvement when len > 32.
+ //
+ const wordsize = int(unsafe.Sizeof(uint(0)))
+ var aword, bword [wordsize]byte
+ for i+wordsize <= commonLen {
+ copy(aword[:], a[i:i+wordsize])
+ copy(bword[:], b[i:i+wordsize])
+ if aword != bword {
+ break
+ }
+ i += wordsize
+ }
+ // naive implementation
+ for i < commonLen {
+ if a[i] != b[i] {
+ return i
+ }
+ i++
+ }
+ return i
+}
+func min(x, y int) int {
+ if x < y {
+ return x
+ } else {
+ return y
+ }
+}
+func max(x, y int) int {
+ if x > y {
+ return x
+ } else {
+ return y
+ }
+}
+
+// Minimum string length for prefixes to be useful. If any prefix has length 1,
+// then we're generally better off just using IndexOfAny with chars.
+const minPrefixLength = 2
+
+// Arbitrary string length limit (with some wiggle room) to avoid creating strings that are longer than is useful and consuming too much memory.
+const maxPrefixLength = 8
+
+// Arbitrary limit on the number of prefixes to find. If we find more than this, we're likely to be spending too much time finding prefixes that won't be useful.
+const maxPrefixes = 16
+
+// Finds an array of multiple prefixes that a node can begin with.
+// If a fixed set of prefixes is found, such that a match for this node is guaranteed to begin
+// with one of those prefixes, an array of those prefixes is returned. Otherwise, null.
+func findPrefixes(node *RegexNode, ignoreCase bool) []string {
+
+ // Analyze the node to find prefixes.
+ results := []*bytes.Buffer{{}}
+ findPrefixesCore(node, &results, ignoreCase)
+
+ // If we found too many prefixes or if any found is too short, fail.
+ if len(results) > maxPrefixes || slices.ContainsFunc(results, func(sb *bytes.Buffer) bool { return sb.Len() < minPrefixLength }) {
+ return nil
+ }
+
+ // Return the prefixes.
+ resultStrings := make([]string, len(results))
+ for i := 0; i < len(results); i++ {
+ resultStrings[i] = results[i].String()
+ }
+ return resultStrings
+}
+
+// Updates the results list with found prefixes. All existing strings in the list are treated as existing
+// discovered prefixes prior to the node being processed. The method returns true if subsequent nodes after
+// this one should be examined, or returns false if they shouldn't be because the node wasn't guaranteed
+// to be fully processed.
+func findPrefixesCore(node *RegexNode, res *[]*bytes.Buffer, ignoreCase bool) bool {
+ results := *res
+ // If we're too deep to analyze further, we can't trust what we've already computed, so stop iterating.
+ // Also bail if any of our results is already hitting the threshold, or if this node is RTL, which is
+ // not worth the complexity of handling.
+ // Or if we've already discovered more than the allowed number of prefixes.
+
+ if slices.ContainsFunc(results, func(sb *bytes.Buffer) bool { return sb.Len() >= maxPrefixLength }) ||
+ (node.Options&RightToLeft) != 0 ||
+ len(results) > maxPrefixes {
+ return false
+ }
+
+ // These limits are approximations. We'll stop trying to make strings longer once we exceed the max length,
+ // and if we exceed the max number of prefixes by a non-trivial amount, we'll fail the operation.
+ // limit how many chars we get from a set based on the max prefixes we care about
+ //setChars := make([]rune, 0, maxPrefixes)
+
+ // Loop down the left side of the tree, looking for a starting node we can handle. We only loop through
+ // atomic and capture nodes, as the child is guaranteed to execute once, as well as loops with a positive
+ // minimum and thus at least one guaranteed iteration.
+ for {
+ switch node.T {
+ // These nodes are all guaranteed to execute at least once, so we can just
+ // skip through them to their child.
+ case NtAtomic, NtCapture:
+ node = node.Children[0]
+ continue
+
+ // Zero-width anchors and assertions don't impact a prefix and may be skipped over.
+ case NtBol, NtEol, NtBoundary, NtECMABoundary, NtNonboundary, NtNonECMABoundary,
+ NtBeginning, NtStart, NtEndZ, NtEnd, NtEmpty, NtUpdateBumpalong,
+ NtPosLook, NtNegLook:
+ return true
+
+ // If we hit a single character, we can just return that character.
+ // This is only relevant for case-sensitive searches, as for case-insensitive we'd have sets for anything
+ // that produces a different result when case-folded, or for strings composed entirely of characters that
+ // don't participate in case conversion. Single character loops are handled the same as single characters
+ // up to the min iteration limit. We can continue processing after them as well if they're repeaters such
+ // that their min and max are the same.
+ case NtOne, NtOneloop, NtOnelazy, NtOneloopatomic:
+ if !ignoreCase || !participatesInCaseConversion(node.Ch) {
+ reps := maxPrefixLength
+ if node.T == NtOne {
+ reps = 1
+ } else if node.M < reps {
+ reps = node.M
+ }
+ if reps == 1 {
+ for _, sb := range results {
+ sb.WriteRune(node.Ch)
+ }
+ } else {
+ for _, sb := range results {
+ sb.WriteString(strings.Repeat(string(node.Ch), reps))
+ }
+ }
+ return node.T == NtOne || reps == node.N
+ }
+
+ // If we hit a string, we can just return that string.
+ // As with One above, this is only relevant for case-sensitive searches.
+ case NtMulti:
+ if !ignoreCase {
+ for _, sb := range results {
+ sb.WriteString(string(node.Str))
+ }
+ } else {
+ // If we're ignoring case, then only append up through characters that don't participate in case conversion.
+ // If there are any beyond that, we can't go further and need to stop with what we have.
+ for _, c := range node.Str {
+ if participatesInCaseConversion(c) {
+ return false
+ }
+
+ for _, sb := range results {
+ sb.WriteRune(c)
+ }
+ }
+ }
+ return true
+
+ // For case-sensitive, try to extract the characters that comprise it, and if there are
+ // any and there aren't more than the max number of prefixes, we can return
+ // them each as a prefix. Effectively, this is an alternation of the characters
+ // that comprise the set. For case-insensitive, we need the set to be two ASCII letters that case fold to the same thing.
+ // As with One and loops, set loops are handled the same as sets up to the min iteration limit.
+ case NtSet, NtSetloop, NtSetlazy, NtSetloopatomic:
+
+ setChars := node.Set.GetSetChars(maxPrefixes)
+
+ if len(setChars) == 0 {
+ return false
+ }
+
+ reps := maxPrefixLength
+ if node.T == NtSet {
+ reps = 1
+ } else if node.M < reps {
+ reps = node.M
+ }
+ if !ignoreCase {
+ for rep := 0; rep < reps; rep++ {
+ existingCount := len(results)
+ if existingCount*len(setChars) > maxPrefixes {
+ return false
+ }
+
+ // Duplicate all of the existing strings for all of the new suffixes, other than the first.
+ for _, suffix := range setChars[1:] {
+ for existing := 0; existing < existingCount; existing++ {
+ newSb := bytes.NewBuffer(slices.Clone(results[existing].Bytes()))
+ newSb.WriteRune(suffix)
+ results = append(results, newSb)
+ }
+ }
+ *res = results
+
+ // Then append the first suffix to all of the existing strings.
+ for existing := 0; existing < existingCount; existing++ {
+ results[existing].WriteRune(setChars[0])
+ }
+ }
+ } else {
+ // For ignore-case, we currently only handle the simple (but common) case of a single
+ // ASCII character that case folds to the same char.
+ ok, setChars := node.Set.containsAsciiIgnoreCaseCharacter()
+ if !ok {
+ return false
+ }
+
+ // Append it to each.
+ for _, sb := range results {
+ sb.WriteString(strings.Repeat(string(setChars[1]), reps))
+ }
+ }
+
+ *res = results
+ return node.T == NtSet || reps == node.N
+
+ case NtConcatenate:
+ for i := 0; i < len(node.Children); i++ {
+ if !findPrefixesCore(node.Children[i], res, ignoreCase) {
+ return false
+ }
+ }
+
+ return true
+
+ // We can append any guaranteed iterations as if they were a concatenation.
+ case NtLoop, NtLazyloop:
+ if node.M > 0 {
+ // MaxPrefixLength here is somewhat arbitrary, as a single loop iteration could yield multiple chars
+ limit := maxPrefixLength
+ if node.M < limit {
+ limit = node.M
+ }
+ for i := 0; i < limit; i++ {
+ if !findPrefixesCore(node.Children[0], res, ignoreCase) {
+ return false
+ }
+ }
+ return limit == node.N
+ }
+
+ // For alternations, we need to find a prefix for every branch; if we can't compute a
+ // prefix for any one branch, we can't trust the results and need to give up, since we don't
+ // know if our set of prefixes is complete.
+ case NtAlternate:
+
+ // If there are more children than our maximum, just give up immediately, as we
+ // won't be able to get a prefix for every branch and have it be within our max.
+ if len(node.Children) > maxPrefixes {
+ return false
+ }
+
+ // Build up the list of all prefixes across all branches.
+ var allBranchResults []*bytes.Buffer
+ alternateBranchResults := []*bytes.Buffer{{}}
+ for i := 0; i < len(node.Children); i++ {
+ findPrefixesCore(node.Children[i], &alternateBranchResults, ignoreCase)
+
+ // If we now have too many results, bail.
+ if len(allBranchResults)+len(alternateBranchResults) > maxPrefixes {
+ return false
+ }
+
+ for _, sb := range alternateBranchResults {
+ // If a branch yields an empty prefix, then none of the other branches
+ // matter, e.g. if the pattern is abc(def|ghi|), then this would result
+ // in prefixes abcdef, abcghi, and abc, and since abc is a prefix of both
+ // abcdef and abcghi, the former two would never be used.
+ if sb.Len() == 0 {
+ return false
+ }
+ }
+
+ if allBranchResults == nil {
+ allBranchResults = alternateBranchResults
+ alternateBranchResults = []*bytes.Buffer{{}}
+ } else {
+ allBranchResults = append(allBranchResults, alternateBranchResults...)
+ alternateBranchResults = []*bytes.Buffer{{}}
+ }
+ }
+
+ // At this point, we know we can successfully incorporate the alternation's results
+ // into the main results.
+
+ // If the results are currently empty (meaning a single empty StringBuilder), we can remove
+ // that builder and just replace the results with the alternation's results. We would otherwise
+ // be creating a dot product of every builder in the results with every branch's result, which
+ // is logically the same thing.
+ if len(results) == 1 && results[0].Len() == 0 {
+ results = allBranchResults
+ } else {
+ existingCount := len(results)
+
+ // Duplicate all of the existing strings for all of the new suffixes, other than the first.
+ for i := 1; i < len(allBranchResults); i++ {
+ suffix := allBranchResults[i]
+ for existing := 0; existing < existingCount; existing++ {
+ newSb := &bytes.Buffer{}
+ newSb.Write(results[existing].Bytes())
+ newSb.Write(suffix.Bytes())
+ results = append(results, newSb)
+ }
+ }
+
+ // Then append the first suffix to all of the existing strings.
+ for existing := 0; existing < existingCount; existing++ {
+ results[existing].Write(allBranchResults[0].Bytes())
+ }
+ }
+ *res = results
+
+ // We don't know that we fully processed every branch, so we can't iterate through what comes after this node.
+ // The results were successfully updated, but return false to indicate that nothing after this node should be examined.
+ }
+ return false
+ }
+}
+
+const maxLoopExpansion = 20 // arbitrary cut-off to avoid loops adding significant overhead to processing
+const maxFixedResults = 50 // arbitrary cut-off to avoid generating lots of sets unnecessarily
+
+// Finds sets at fixed-offsets from the beginning of the pattern/
+// set "thorough" to true to spend more time finding sets (e.g. through alternations); false to do a faster analysis that's potentially more incomplete.
+// Returns the array of found sets, or null if there aren't any.
+func findFixedDistanceSets(root *RegexNode, thorough bool) []FixedDistanceSet {
+
+ // Find all fixed-distance sets.
+ results := []FixedDistanceSet{}
+ distance := 0
+ tryFindRawFixedSets(root, &results, &distance, thorough)
+
+ // Remove any sets that match everything; they're not helpful. (This check exists primarily to weed
+ // out use of . in Singleline mode, but also filters out explicit sets like [\s\S].)
+ results = slices.DeleteFunc(results, func(s FixedDistanceSet) bool { return s.Set.IsAnything() })
+
+ // If we don't have any results, try harder to compute one for the starting character.
+ // This is a more involved computation that can find things the fixed-distance investigation
+ // doesn't.
+ if len(results) == 0 {
+ // weed out match-all, same as above
+ c := findFirstCharClass(root)
+ if c == nil || c.IsAnything() {
+ return nil
+ }
+
+ results = append(results, FixedDistanceSet{Set: c, Distance: 0})
+ }
+
+ // For every entry, try to get the chars that make up the set, if there are few enough.
+ // For any for which we couldn't get the small chars list, see if we can get other useful info.
+ //scratch := make([]rune, 0, 128)
+ for i := 0; i < len(results); i++ {
+ result := results[i]
+ result.Negated = result.Set.IsNegated()
+
+ // prefer IndexOfAny for tiny sets of 1 or 2 elements
+ if r := result.Set.GetIfNRanges(1); len(r) == 1 && r[0].Last-r[0].First > 1 {
+ result.Range = &r[0]
+ } else {
+ scratch := result.Set.GetSetChars(128)
+ if len(scratch) > 0 {
+ result.Chars = scratch
+ }
+ }
+
+ results[i] = result
+ }
+
+ return results
+}
+
+// Starting from the specified root node, populates results with any characters at a fixed distance
+// from the node's starting position. The function returns true if the entire contents of the node
+// is at a fixed distance, in which case distance will have been updated to include the full length
+// of the node. If it returns false, the node isn't entirely fixed, in which case subsequent nodes
+// shouldn't be examined and distance should no longer be trusted. However, regardless of whether it
+// returns true or false, it may have populated results, and all populated results are valid. All
+// FixedDistanceSet result will only have its Set string and Distance populated; the rest is left
+// to be populated by FindFixedDistanceSets after this returns.
+func tryFindRawFixedSets(node *RegexNode, res *[]FixedDistanceSet, distance *int, thorough bool) bool {
+ results := *res
+ if node.Options&RightToLeft != 0 {
+ return false
+ }
+
+ switch node.T {
+ case NtOne:
+ if len(results) < maxFixedResults {
+ set := &CharSet{}
+ set.addChar(node.Ch)
+ results = append(results, FixedDistanceSet{Set: set, Distance: *distance})
+ *res = results
+ *distance++
+ return true
+ }
+ return false
+
+ case NtOnelazy, NtOneloop, NtOneloopatomic:
+ if node.M > 0 {
+ set := &CharSet{}
+ set.addChar(node.Ch)
+ minIterations := maxLoopExpansion
+ if node.M < minIterations {
+ minIterations = node.M
+ }
+ i := 0
+ for ; i < minIterations && len(results) < maxFixedResults; i++ {
+ results = append(results, FixedDistanceSet{Set: set, Distance: *distance})
+ *distance++
+ }
+ *res = results
+ return i == node.M && i == node.N
+ }
+
+ case NtMulti:
+ i := 0
+ for ; i < len(node.Str) && len(results) < maxFixedResults; i++ {
+ set := &CharSet{}
+ set.addChar(node.Str[i])
+ results = append(results, FixedDistanceSet{Set: set, Distance: *distance})
+ *distance++
+ }
+ *res = results
+ return i == len(node.Str)
+
+ case NtSet:
+ if len(results) < maxFixedResults {
+ results = append(results, FixedDistanceSet{Set: node.Set, Distance: *distance})
+ *res = results
+ *distance++
+ return true
+ }
+ return false
+
+ case NtSetlazy, NtSetloop, NtSetloopatomic:
+ if node.M > 0 {
+ minIterations := maxLoopExpansion
+ if node.M < minIterations {
+ minIterations = node.M
+ }
+ i := 0
+ for ; i < minIterations && len(results) < maxFixedResults; i++ {
+ results = append(results, FixedDistanceSet{Set: node.Set, Distance: *distance})
+ *distance++
+ }
+ *res = results
+ return i == node.M && i == node.N
+ }
+
+ case NtNotone:
+ // We could create a set out of Notone, but it will be of little value in helping to improve
+ // the speed of finding the first place to match, as almost every character will match it.
+ *distance++
+ return true
+
+ case NtNotonelazy, NtNotoneloop, NtNotoneloopatomic:
+ if node.M == node.N {
+ *distance += node.M
+ return true
+ }
+ case NtBeginning, NtBol, NtBoundary, NtECMABoundary, NtEmpty, NtEnd, NtEndZ, NtEol,
+ NtNonboundary, NtNonECMABoundary, NtUpdateBumpalong,
+ NtStart, NtNegLook, NtPosLook:
+ // Zero-width anchors and assertions. In theory, for PositiveLookaround and NegativeLookaround we could also
+ // investigate them and use the learned knowledge to impact the generated sets, at least for lookaheads.
+ // For now, we don't bother.
+ return true
+
+ case NtAtomic, NtGroup, NtCapture:
+ return tryFindRawFixedSets(node.Children[0], res, distance, thorough)
+
+ case NtLazyloop, NtLoop:
+ if node.M > 0 {
+ // This effectively only iterates the loop once. If deemed valuable,
+ // it could be updated in the future to duplicate the found results
+ // (updated to incorporate distance from previous iterations) and
+ // summed distance for all node.M iterations. If node.M == node.N,
+ // this would then also allow continued evaluation of the rest of the
+ // expression after the loop.
+ tryFindRawFixedSets(node.Children[0], res, distance, thorough)
+ return false
+ }
+
+ case NtConcatenate:
+ for i := 0; i < len(node.Children); i++ {
+ if !tryFindRawFixedSets(node.Children[i], res, distance, thorough) {
+ return false
+ }
+ }
+ return true
+
+ case NtAlternate:
+ if thorough {
+ allSameSize := true
+ sameDistance := -1
+ var combined = make(map[int]struct {
+ Set *CharSet
+ Count int
+ })
+ var localResults []FixedDistanceSet
+
+ for i := 0; i < len(node.Children); i++ {
+ localResults = []FixedDistanceSet{}
+ localDistance := 0
+ allSameSize = allSameSize && tryFindRawFixedSets(node.Children[i], &localResults, &localDistance, thorough)
+
+ if len(localResults) == 0 {
+ return false
+ }
+
+ if allSameSize {
+ if sameDistance == -1 {
+ sameDistance = localDistance
+ } else if sameDistance != localDistance {
+ allSameSize = false
+ }
+ }
+
+ for _, fixedSet := range localResults {
+ if v, ok := combined[fixedSet.Distance]; ok {
+ if v.Set.IsMergeable() && fixedSet.Set.IsMergeable() {
+ v.Set.addSet(*fixedSet.Set)
+ v.Count++
+ combined[fixedSet.Distance] = v
+ }
+ } else {
+ combined[fixedSet.Distance] = struct {
+ Set *CharSet
+ Count int
+ }{Set: fixedSet.Set, Count: 1}
+ }
+ }
+ }
+
+ for k, v := range combined {
+ if len(results) >= maxFixedResults {
+ allSameSize = false
+ break
+ }
+
+ if v.Count == len(node.Children) {
+ results = append(results, FixedDistanceSet{Set: v.Set, Distance: k + *distance})
+ }
+ }
+ *res = results
+
+ if allSameSize {
+ *distance += sameDistance
+ return true
+ }
+
+ return false
+ }
+ }
+ return false
+}
+
+// CompareFunc for a set of fixed-distance set results from best to worst quality.
+func compareFixedDistanceSetsByQuality(s1, s2 FixedDistanceSet) int {
+ // Finally, try to move the "best" results to be earlier. "best" here are ones we're able to search
+ // for the fastest and that have the best chance of matching as few false positives as possible.
+ s1RangeLength := getRangeLength(s1.Range, s1.Negated)
+ s2RangeLength := getRangeLength(s2.Range, s2.Negated)
+
+ // If one set is negated and the other isn't, prefer the non-negated set. In general, negated
+ // sets are large and thus likely to match more frequently, making them slower to search for.
+ if s1.Negated != s2.Negated {
+ if s2.Negated {
+ return -1
+ }
+ return 1
+ }
+
+ // If we extracted only a few chars and the sets are negated, they both represent very large
+ // sets that are difficult to compare for quality.
+ if !s1.Negated {
+ // If both have chars, prioritize the one with the smaller frequency for those chars.
+ if len(s1.Chars) > 0 && len(s2.Chars) > 0 {
+ // Prefer sets with less frequent values. The frequency is only an approximation,
+ // used as a tie-breaker when we'd otherwise effectively be picking randomly.
+ // True frequencies will vary widely based on the actual data being searched, the language of the data, etc.
+ s1Frequency := sumFrequencies(s1.Chars)
+ s2Frequency := sumFrequencies(s2.Chars)
+
+ if s1Frequency != s2Frequency {
+ return cmp.Compare(s1Frequency, s2Frequency)
+ }
+
+ if !isAsciiRunes(s1.Chars) && !isAsciiRunes(s2.Chars) {
+ // Prefer the set with fewer values.
+ return cmp.Compare(len(s1.Chars), len(s2.Chars))
+ }
+ }
+
+ // If one has chars and the other has a range, prefer the shorter set.
+ if (len(s1.Chars) > 0 && s2RangeLength > 0) || (s1RangeLength > 0 && len(s2.Chars) > 0) {
+ s1Len := s1RangeLength
+ if len(s1.Chars) > s1Len {
+ s1Len = len(s1.Chars)
+ }
+ s2Len := s2RangeLength
+ if len(s2.Chars) > s2Len {
+ s2Len = len(s2.Chars)
+ }
+ c := cmp.Compare(s1Len, s2Len)
+ if c != 0 {
+ return c
+ }
+
+ // If lengths are the same, prefer the chars.
+ if len(s1.Chars) > 0 {
+ return -1
+ }
+ return 1
+ }
+
+ // If one has chars and the other doesn't, prioritize the one with chars.
+ if (len(s1.Chars) > 0) != (len(s2.Chars) > 0) {
+ if len(s1.Chars) > 0 {
+ return -1
+ }
+ return 1
+ }
+ }
+
+ // If one has a range and the other doesn't, prioritize the one with a range.
+ if (s1RangeLength > 0) != (s2RangeLength > 0) {
+ if s1RangeLength > 0 {
+ return -1
+ }
+ return 1
+ }
+
+ // If both have ranges, prefer the one that includes fewer characters.
+ if s1RangeLength > 0 {
+ return cmp.Compare(s1RangeLength, s2RangeLength)
+ }
+
+ // As a tiebreaker, prioritize the earlier one.
+ return cmp.Compare(s1.Distance, s2.Distance)
+}
+
+func getRangeLength(r *SingleRange, negated bool) int {
+ if r == nil {
+ return 0
+ }
+ if negated {
+ return int(unicode.MaxRune - (r.Last - r.First))
+ }
+ return int(r.Last - r.First + 1)
+}
+
+func sumFrequencies(chars []rune) float32 {
+ var sum float32
+ for _, c := range chars {
+ // Lookup each character in the table. Values >= 128 are ignored
+ // and thus we'll get skew in the data. It's already a gross approximation, though,
+ // and it is primarily meant for disambiguation of ASCII letters.
+ if c < unicode.MaxASCII {
+ sum += frequency[c]
+ }
+ }
+ return sum
+}
+
+func hasHighFrequencyChars(set FixedDistanceSet) bool {
+ if set.Negated {
+ return true
+ }
+
+ // Sets without extracted chars can't be frequency-analyzed.
+ // Single-char sets use IndexOf, which is a strong filter regardless of frequency.
+ if len(set.Chars) <= 1 {
+ return false
+ }
+
+ totalFrequency := sumFrequencies(set.Chars)
+
+ // If the average frequency of the set's chars exceeds this threshold, the
+ // characters are common enough that a multi-string search may be a better filter.
+ const highFrequencyThreshold = 0.6
+ return totalFrequency >= highFrequencyThreshold*float32(len(set.Chars))
+}
+
+func mayContainCaseInsensitiveMatching(node *RegexNode) bool {
+ if node.Options&IgnoreCase != 0 {
+ return true
+ }
+
+ if node.Set != nil {
+ chars := node.Set.GetSetChars(maxPrefixes)
+ for _, ch := range chars {
+ if participatesInCaseConversion(ch) &&
+ slices.Contains(chars, unicode.ToLower(ch)) &&
+ slices.Contains(chars, unicode.ToUpper(ch)) {
+ return true
+ }
+ }
+ }
+
+ for _, child := range node.Children {
+ if mayContainCaseInsensitiveMatching(child) {
+ return true
+ }
+ }
+
+ return false
+}
+
+// Percent occurrences in source text (100 * char count / total count)
+var frequency = []float32{
+ 0.000 /* '\x00' */, 0.000 /* '\x01' */, 0.000 /* '\x02' */, 0.000 /* '\x03' */, 0.000 /* '\x04' */, 0.000 /* '\x05' */, 0.000 /* '\x06' */, 0.000, /* '\x07' */
+ 0.000 /* '\x08' */, 0.001 /* '\x09' */, 0.000 /* '\x0A' */, 0.000 /* '\x0B' */, 0.000 /* '\x0C' */, 0.000 /* '\x0D' */, 0.000 /* '\x0E' */, 0.000, /* '\x0F' */
+ 0.000 /* '\x10' */, 0.000 /* '\x11' */, 0.000 /* '\x12' */, 0.000 /* '\x13' */, 0.003 /* '\x14' */, 0.000 /* '\x15' */, 0.000 /* '\x16' */, 0.000, /* '\x17' */
+ 0.000 /* '\x18' */, 0.004 /* '\x19' */, 0.000 /* '\x1A' */, 0.000 /* '\x1B' */, 0.006 /* '\x1C' */, 0.006 /* '\x1D' */, 0.000 /* '\x1E' */, 0.000, /* '\x1F' */
+ 8.952 /* ' ' */, 0.065 /* ' !' */, 0.420 /* ' "' */, 0.010 /* ' #' */, 0.011 /* ' $' */, 0.005 /* ' %' */, 0.070 /* ' &' */, 0.050, /* ' '' */
+ 3.911 /* ' (' */, 3.910 /* ' )' */, 0.356 /* ' *' */, 2.775 /* ' +' */, 1.411 /* ' ,' */, 0.173 /* ' -' */, 2.054 /* ' .' */, 0.677, /* ' /' */
+ 1.199 /* ' 0' */, 0.870 /* ' 1' */, 0.729 /* ' 2' */, 0.491 /* ' 3' */, 0.335 /* ' 4' */, 0.269 /* ' 5' */, 0.435 /* ' 6' */, 0.240, /* ' 7' */
+ 0.234 /* ' 8' */, 0.196 /* ' 9' */, 0.144 /* ' :' */, 0.983 /* ' ;' */, 0.357 /* ' <' */, 0.661 /* ' =' */, 0.371 /* ' >' */, 0.088, /* ' ?' */
+ 0.007 /* ' @' */, 0.763 /* ' A' */, 0.229 /* ' B' */, 0.551 /* ' C' */, 0.306 /* ' D' */, 0.449 /* ' E' */, 0.337 /* ' F' */, 0.162, /* ' G' */
+ 0.131 /* ' H' */, 0.489 /* ' I' */, 0.031 /* ' J' */, 0.035 /* ' K' */, 0.301 /* ' L' */, 0.205 /* ' M' */, 0.253 /* ' N' */, 0.228, /* ' O' */
+ 0.288 /* ' P' */, 0.034 /* ' Q' */, 0.380 /* ' R' */, 0.730 /* ' S' */, 0.675 /* ' T' */, 0.265 /* ' U' */, 0.309 /* ' V' */, 0.137, /* ' W' */
+ 0.084 /* ' X' */, 0.023 /* ' Y' */, 0.023 /* ' Z' */, 0.591 /* ' [' */, 0.085 /* ' \' */, 0.590 /* ' ]' */, 0.013 /* ' ^' */, 0.797, /* ' _' */
+ 0.001 /* ' `' */, 4.596 /* ' a' */, 1.296 /* ' b' */, 2.081 /* ' c' */, 2.005 /* ' d' */, 6.903 /* ' e' */, 1.494 /* ' f' */, 1.019, /* ' g' */
+ 1.024 /* ' h' */, 3.750 /* ' i' */, 0.286 /* ' j' */, 0.439 /* ' k' */, 2.913 /* ' l' */, 1.459 /* ' m' */, 3.908 /* ' n' */, 3.230, /* ' o' */
+ 1.444 /* ' p' */, 0.231 /* ' q' */, 4.220 /* ' r' */, 3.924 /* ' s' */, 5.312 /* ' t' */, 2.112 /* ' u' */, 0.737 /* ' v' */, 0.573, /* ' w' */
+ 0.992 /* ' x' */, 1.067 /* ' y' */, 0.181 /* ' z' */, 0.391 /* ' {' */, 0.056 /* ' |' */, 0.391 /* ' }' */, 0.002 /* ' ~' */, 0.000, /* '\x7F' */
+}
+
+// The above table was generated programmatically with the following. This can be augmented to incorporate additional data sources,
+// though it is only intended to be a rough approximation use when tie-breaking and we'd otherwise be picking randomly, so, it's something.
+// The frequencies may be wildly inaccurate when used with data sources different in nature than the training set, in which case we shouldn't
+// be much worse off than just picking randomly:
+//
+// using System.Runtime.InteropServices;
+//
+// var counts = new Dictionary();
+//
+// (string, string)[] rootsAndExtensions = new[]
+// {
+// (@"d:\repos\runtime\src\", "*.cs"), // C# files in dotnet/runtime
+// (@"d:\Top25GutenbergBooks", "*.txt"), // Top 25 most popular books on Project Gutenberg
+// };
+//
+// foreach ((string root, string ext) in rootsAndExtensions)
+// foreach (string path in Directory.EnumerateFiles(root, ext, SearchOption.AllDirectories))
+// foreach (string line in File.ReadLines(path))
+// foreach (char c in line.AsSpan().Trim())
+// CollectionsMarshal.GetValueRefOrAddDefault(counts, (byte)c, out _)++;
+//
+// long total = counts.Sum(i => i.Value);
+//
+// Console.WriteLine("/// Percent occurrences in source text (100 * char count / total count).");
+// Console.WriteLine("private static ReadOnlySpan Frequency =>");
+// Console.WriteLine("[");
+// int i = 0;
+// for (int row = 0; row < 16; row++)
+// {
+// Console.Write(" ");
+// for (int col = 0; col < 8; col++)
+// {
+// counts.TryGetValue((byte)i, out long charCount);
+// float frequency = (float)(charCount / (double)total) * 100;
+// Console.Write($" {frequency:N3}f /* '{(i >= 32 && i < 127 ? $" {(char)i}" : $"\\x{i:X2}")}' */,");
+// i++;
+// }
+// Console.WriteLine();
+// }
+// Console.WriteLine("];");
+
+// /
+// / Analyzes the pattern for a leading set loop followed by a non-overlapping literal. If such a pattern is found, an implementation
+// / can search for the literal and then walk backward through all matches for the loop until the beginning is found.
+// /
+func findLiteralFollowingLeadingLoop(node *RegexNode) *LiteralAfterLoop {
+ if (node.Options & RightToLeft) != 0 {
+ // As a simplification, ignore RightToLeft.
+ return nil
+ }
+
+ // Find the first concatenation. We traverse through atomic and capture nodes as they don't effect flow control. (We don't
+ // want to explore loops, even if they have a guaranteed iteration, because we may use information about the node to then
+ // skip the node's execution in the matching algorithm, and we would need to special-case only skipping the first iteration.)
+ for node.T == NtAtomic || node.T == NtCapture {
+ node = node.Children[0]
+ }
+ if node.T != NtConcatenate {
+ return nil
+ }
+
+ // Bail if the first node isn't a set loop. We treat any kind of set loop (Setloop, Setloopatomic, and Setlazy)
+ // the same because of two important constraints: the loop must not have an upper bound, and the literal we look
+ // for immediately following it must not overlap. With those constraints, all three of these kinds of loops will
+ // end up having the same semantics; in fact, if atomic optimizations are used, we will have converted Setloop
+ // into a Setloopatomic (but those optimizations are disabled for NonBacktracking in general). This
+ // could also be made to support Oneloopatomic and Notoneloopatomic, but the scenarios for that are rare.
+ firstChild := node.Children[0]
+ for firstChild.T == NtAtomic || firstChild.T == NtCapture {
+ firstChild = firstChild.Children[0]
+ }
+ if (firstChild.T != NtSetloop && firstChild.T != NtSetloopatomic && firstChild.T != NtSetlazy) ||
+ firstChild.N != math.MaxInt32 {
+ return nil
+ }
+
+ // Get the subsequent node. An UpdateBumpalong may have been added as an optimization, but it doesn't have an
+ // impact on semantics and we can skip it.
+ nextChild := node.Children[1]
+ if nextChild.T == NtUpdateBumpalong {
+ if len(node.Children) == 2 {
+ // If the UpdateBumpalong is the last node, nothing meaningful follows the set loop.
+ return nil
+ }
+ nextChild = node.Children[2]
+ }
+ nextChild = unwrapImmediateLiteralAfterLoopNode(nextChild)
+ if nextChild == nil {
+ return nil
+ }
+
+ // Is the set loop followed by a case-sensitive string we can search for?
+ if prefix := findPrefix(nextChild); len(prefix) >= 1 {
+ // The literal can be searched for as either a single char or as a string.
+ // But we need to make sure that its starting character isn't part of the preceding
+ // set, as then we can't know for certain where the set loop ends.
+ if firstChild.Set.CharIn(rune(prefix[0])) {
+ return nil
+ } else if len(prefix) == 1 {
+ return &LiteralAfterLoop{
+ LoopNode: firstChild,
+ Char: rune(prefix[0]),
+ }
+ }
+ return &LiteralAfterLoop{
+ LoopNode: firstChild,
+ String: prefix,
+ }
+ }
+
+ // Is the set loop followed by an ordinal case-insensitive string we can search for? We could
+ // search for a string with at least one char, but if it has only one, we're better off just
+ // searching as a set, so we look for strings with at least two chars.
+ if ordinalCaseInsensitivePrefix := findPrefixOrdinalCaseInsensitive(nextChild); len(ordinalCaseInsensitivePrefix) >= 2 {
+ // The literal can be searched for as a case-insensitive string. As with ordinal above,
+ // though, we need to make sure its starting character isn't part of the previous set.
+ // If that starting character participates in case conversion, then we need to test out
+ // both casings (FindPrefixOrdinalCaseInsensitive will only return strings composed of
+ // characters that either are ASCII or that don't participate in case conversion).
+ ch, _ := utf8.DecodeRuneInString(ordinalCaseInsensitivePrefix)
+ if participatesInCaseConversion(ch) {
+ if firstChild.Set.CharIn(ch|0x20) ||
+ firstChild.Set.CharIn(ch&^0x20) {
+ return nil
+ }
+ } else if firstChild.Set.CharIn(ch) {
+ return nil
+ }
+
+ return &LiteralAfterLoop{
+ LoopNode: firstChild,
+ String: ordinalCaseInsensitivePrefix,
+ StringIgnoreCase: true,
+ }
+ }
+
+ // If the resulting node is a set with at least one iteration, we can search for it.
+ if nextChild.IsSetFamily() &&
+ !nextChild.Set.IsNegated() &&
+ (nextChild.T == NtSet || nextChild.M >= 1) {
+ // maximum number of chars optimized by IndexOfAny
+ chars := nextChild.Set.GetSetChars(5)
+ if len(chars) > 0 {
+ for _, c := range chars {
+ if firstChild.Set.CharIn(c) {
+ return nil
+ }
+ }
+
+ return &LiteralAfterLoop{
+ LoopNode: firstChild,
+ Chars: chars,
+ }
+ }
+ }
+
+ // Otherwise, we couldn't find the pattern of an atomic set loop followed by a literal.
+ return nil
+}
+
+func unwrapImmediateLiteralAfterLoopNode(node *RegexNode) *RegexNode {
+ for {
+ node = unwrapTransparentNodes(node)
+ if node == nil {
+ return nil
+ }
+ if node.T != NtConcatenate {
+ return node
+ }
+ if len(node.Children) == 0 {
+ return nil
+ }
+ node = node.Children[0]
+ }
+}
+
+func findRequiredLandmarkChain(node *RegexNode) *RequiredLandmarkChain {
+ if (node.Options & RightToLeft) != 0 {
+ return nil
+ }
+
+ node = unwrapTransparentNodes(node)
+ if node.T != NtConcatenate || len(node.Children) < 4 {
+ return nil
+ }
+
+ firstChild := unwrapTransparentNodes(node.Children[0])
+ if !isUnboundedSetLoop(firstChild) {
+ return nil
+ }
+
+ // Collect landmarks that must appear in order later in the match. This is a
+ // conservative prefilter: if any child cannot be described as a detectable
+ // landmark, we skip that child rather than making it part of the chain.
+ landmarks := make([]RequiredLandmark, 0, 2)
+ for _, child := range node.Children[1:] {
+ if landmark, ok := extractRequiredLandmark(child); ok {
+ landmarks = append(landmarks, landmark)
+ } else if len(landmarks) == 0 && !isZeroWidthLandmarkGap(child) {
+ return nil
+ }
+ }
+ if len(landmarks) < 2 {
+ return nil
+ }
+
+ return &RequiredLandmarkChain{
+ LeadingLoopSet: firstChild.Set,
+ Landmarks: landmarks,
+ }
+}
+
+func isZeroWidthLandmarkGap(node *RegexNode) bool {
+ node = unwrapTransparentNodes(node)
+ if node == nil {
+ return true
+ }
+ switch node.T {
+ case NtEmpty, NtUpdateBumpalong,
+ NtBeginning, NtBol, NtStart, NtEndZ, NtEnd, NtEol,
+ NtBoundary, NtNonboundary, NtECMABoundary, NtNonECMABoundary:
+ return true
+ default:
+ return false
+ }
+}
+
+func unwrapTransparentNodes(node *RegexNode) *RegexNode {
+ for node != nil && (node.T == NtAtomic || node.T == NtCapture || node.T == NtGroup) && len(node.Children) == 1 {
+ node = node.Children[0]
+ }
+ return node
+}
+
+func isUnboundedSetLoop(node *RegexNode) bool {
+ return node != nil &&
+ (node.T == NtSetloop || node.T == NtSetloopatomic || node.T == NtSetlazy) &&
+ node.Set != nil &&
+ node.N == math.MaxInt32
+}
+
+func extractRequiredLandmark(node *RegexNode) (RequiredLandmark, bool) {
+ node = unwrapTransparentNodes(node)
+ if node == nil {
+ return RequiredLandmark{}, false
+ }
+
+ if node.T != NtAlternate {
+ alt, ok := extractRequiredLandmarkAlternative(node)
+ if !ok {
+ return RequiredLandmark{}, false
+ }
+ return RequiredLandmark{Alternatives: []RequiredLandmarkAlternative{alt}}, true
+ }
+
+ landmark := RequiredLandmark{Alternatives: make([]RequiredLandmarkAlternative, 0, len(node.Children))}
+ for _, child := range node.Children {
+ alt, ok := extractRequiredLandmarkAlternative(child)
+ if !ok {
+ return RequiredLandmark{}, false
+ }
+ landmark.Alternatives = append(landmark.Alternatives, alt)
+ }
+ return landmark, len(landmark.Alternatives) > 0
+}
+
+func extractRequiredLandmarkAlternative(node *RegexNode) (RequiredLandmarkAlternative, bool) {
+ node = unwrapTransparentNodes(node)
+ if node == nil {
+ return RequiredLandmarkAlternative{}, false
+ }
+
+ children := []*RegexNode{node}
+ if node.T == NtConcatenate {
+ children = node.Children
+ }
+
+ alt := RequiredLandmarkAlternative{}
+ i := 0
+ if i < len(children) {
+ if whitespaceSet, min, ok := whitespaceLoop(children[i]); ok {
+ alt.LeadingWhitespaceSet = whitespaceSet
+ alt.RequireWhitespaceBefore = min > 0
+ i++
+ }
+ }
+ if i >= len(children) {
+ return RequiredLandmarkAlternative{}, false
+ }
+
+ // The core of a landmark must be a literal or a bounded, enumerable set
+ // repetition. The VM still validates the full regex after this prefilter
+ // returns a candidate.
+ core := unwrapTransparentNodes(children[i])
+ switch core.T {
+ case NtOne:
+ alt.Literal = []rune{core.Ch}
+ alt.MinRepeat = 1
+ alt.MaxRepeat = 1
+ case NtMulti:
+ alt.Literal = core.Str
+ alt.MinRepeat = 1
+ alt.MaxRepeat = 1
+ case NtSet, NtSetloop, NtSetloopatomic, NtSetlazy:
+ if core.Set == nil {
+ return RequiredLandmarkAlternative{}, false
+ }
+ if core.T == NtSet {
+ alt.MinRepeat = 1
+ alt.MaxRepeat = 1
+ } else if core.M > 0 && core.N != math.MaxInt32 {
+ alt.MinRepeat = core.M
+ alt.MaxRepeat = core.N
+ } else {
+ return RequiredLandmarkAlternative{}, false
+ }
+ chars := core.Set.GetSetChars(8)
+ if len(chars) == 0 || core.Set.IsNegated() {
+ return RequiredLandmarkAlternative{}, false
+ }
+ alt.Set = core.Set
+ default:
+ return RequiredLandmarkAlternative{}, false
+ }
+ i++
+
+ if i < len(children) {
+ if whitespaceSet, min, ok := whitespaceLoop(children[i]); ok {
+ alt.TrailingWhitespaceSet = whitespaceSet
+ alt.RequireWhitespaceAfter = min > 0
+ i++
+ }
+ }
+ if i != len(children) {
+ return RequiredLandmarkAlternative{}, false
+ }
+ return alt, true
+}
+
+func whitespaceLoop(node *RegexNode) (*CharSet, int, bool) {
+ node = unwrapTransparentNodes(node)
+ if node != nil &&
+ (node.T == NtSetloop || node.T == NtSetloopatomic || node.T == NtSetlazy) &&
+ node.Set != nil &&
+ node.N == math.MaxInt32 &&
+ (node.Set.Equals(SpaceClass()) || node.Set.Equals(ECMASpaceClass()) || node.Set.Equals(RE2SpaceClass())) {
+ return node.Set, node.M, true
+ }
+ return nil, 0, false
+}
+
+// Returns a leading positive lookahead if found and whether to keep examining subsequent nodes in a concatenation.
+func findLeadingPositiveLookahead(node *RegexNode) (*RegexNode, bool) {
+ for {
+ if node.Options&RightToLeft != 0 {
+ return nil, false
+ }
+
+ switch node.T {
+ case NtPosLook:
+ return node, false
+
+ case NtBol, NtEol, NtBeginning, NtStart, NtEndZ, NtEnd,
+ NtBoundary, NtECMABoundary, NtNegLook, NtEmpty:
+ return nil, true
+
+ case NtAtomic, NtCapture:
+ node = node.Children[0]
+ continue
+
+ case NtLoop, NtLazyloop:
+ if node.M < 1 {
+ return nil, false
+ }
+ lookahead, _ := findLeadingPositiveLookahead(node.Children[0])
+ return lookahead, false
+
+ case NtConcatenate:
+ for i := 0; i < len(node.Children); i++ {
+ lookahead, keepLooking := findLeadingPositiveLookahead(node.Children[i])
+ if lookahead != nil || !keepLooking {
+ return lookahead, false
+ }
+ }
+ return nil, true
+
+ default:
+ return nil, false
+ }
+ }
+}
diff --git a/vendor/github.com/dlclark/regexp2/v2/syntax/replacerdata.go b/vendor/github.com/dlclark/regexp2/v2/syntax/replacerdata.go
new file mode 100644
index 0000000000..ea1b6ab3d1
--- /dev/null
+++ b/vendor/github.com/dlclark/regexp2/v2/syntax/replacerdata.go
@@ -0,0 +1,87 @@
+package syntax
+
+import (
+ "bytes"
+ "errors"
+)
+
+type ReplacerData struct {
+ Rep string
+ Strings []string
+ Rules []int
+}
+
+const (
+ replaceSpecials = 4
+ replaceLeftPortion = -1
+ replaceRightPortion = -2
+ replaceLastGroup = -3
+ replaceWholeString = -4
+)
+
+// ErrReplacementError is a general error during parsing the replacement text
+var ErrReplacementError = errors.New("replacement pattern error")
+
+// NewReplacerData will populate a reusable replacer data struct based on the given replacement string
+// and the capture group data from a regexp
+func NewReplacerData(rep string, caps map[int]int, capsize int, capnames map[string]int, op RegexOptions) (*ReplacerData, error) {
+ p := parser{
+ options: op,
+ caps: caps,
+ capsize: capsize,
+ capnames: capnames,
+ }
+ p.setPattern(rep)
+ concat, err := p.scanReplacement()
+ if err != nil {
+ return nil, err
+ }
+
+ if concat.T != NtConcatenate {
+ panic(ErrReplacementError)
+ }
+
+ sb := &bytes.Buffer{}
+ var (
+ strings []string
+ rules []int
+ )
+
+ for _, child := range concat.Children {
+ switch child.T {
+ case NtMulti:
+ child.writeStrToBuf(sb)
+
+ case NtOne:
+ sb.WriteRune(child.Ch)
+
+ case NtRef:
+ if sb.Len() > 0 {
+ rules = append(rules, len(strings))
+ strings = append(strings, sb.String())
+ sb.Reset()
+ }
+ slot := child.M
+
+ if len(caps) > 0 && slot >= 0 {
+ slot = caps[slot]
+ }
+
+ rules = append(rules, -replaceSpecials-1-slot)
+
+ default:
+ panic(ErrReplacementError)
+ }
+ }
+
+ if sb.Len() > 0 {
+ rules = append(rules, len(strings))
+ strings = append(strings, sb.String())
+ }
+
+ return &ReplacerData{
+ Rep: rep,
+ Strings: strings,
+ Rules: rules,
+ }, nil
+}
diff --git a/vendor/github.com/dlclark/regexp2/v2/syntax/tree.go b/vendor/github.com/dlclark/regexp2/v2/syntax/tree.go
new file mode 100644
index 0000000000..f4b8b6a267
--- /dev/null
+++ b/vendor/github.com/dlclark/regexp2/v2/syntax/tree.go
@@ -0,0 +1,2362 @@
+package syntax
+
+import (
+ "bytes"
+ "fmt"
+ "math"
+ "strconv"
+ "strings"
+ "unicode"
+
+ "slices"
+)
+
+// Arbitrary number of repetitions of the same character when we'd prefer to represent that as a repeater of that character rather than a string.
+const MultiVsRepeaterLimit = 64
+
+type RegexTree struct {
+ Root *RegexNode
+ Caps map[int]int
+ Capnumlist []int
+ Captop int
+ Capnames map[string]int
+ Caplist []string
+ Options RegexOptions
+ FindOptimizations *FindOptimizations
+}
+
+// It is built into a parsed tree for a regular expression.
+
+// Implementation notes:
+//
+// Since the node tree is a temporary data structure only used
+// during compilation of the regexp to integer codes, it's
+// designed for clarity and convenience rather than
+// space efficiency.
+//
+// RegexNodes are built into a tree, linked by the n.children list.
+// Each node also has a n.parent and n.ichild member indicating
+// its parent and which child # it is in its parent's list.
+//
+// RegexNodes come in as many types as there are constructs in
+// a regular expression, for example, "concatenate", "alternate",
+// "one", "rept", "group". There are also node types for basic
+// peephole optimizations, e.g., "onerep", "notsetrep", etc.
+//
+// Because perl 5 allows "lookback" groups that scan backwards,
+// each node also gets a "direction". Normally the value of
+// boolean n.backward = false.
+//
+// On the parse stack, each tree has a "role" - basically, the
+// nonterminal in the grammar that the parser has currently
+// assigned to the tree. That code is stored in n.role.
+//
+// Finally, some of the different kinds of nodes have data.
+// Two integers (for the looping constructs) are stored in
+// n.operands, an an object (either a string or a set)
+// is stored in n.data
+type RegexNode struct {
+ T NodeType
+ Children []*RegexNode
+ Str []rune
+ Set *CharSet
+ Ch rune
+ M int
+ N int
+ Options RegexOptions
+ Parent *RegexNode
+}
+
+type NodeType int32
+
+const (
+ // The following are leaves, and correspond to primitive operations
+ NtUnknown NodeType = -1
+ //NtOnerep NodeType = 0 // lef,back char,min,max a {n}
+ //NtNotonerep NodeType = 1 // lef,back char,min,max .{n}
+ //NtSetrep NodeType = 2 // lef,back set,min,max [\d]{n}
+ NtOneloop NodeType = 3 // lef,back char,min,max a {,n}
+ NtNotoneloop NodeType = 4 // lef,back char,min,max .{,n}
+ NtSetloop NodeType = 5 // lef,back set,min,max [\d]{,n}
+ NtOnelazy NodeType = 6 // lef,back char,min,max a {,n}?
+ NtNotonelazy NodeType = 7 // lef,back char,min,max .{,n}?
+ NtSetlazy NodeType = 8 // lef,back set,min,max [\d]{,n}?
+ NtOne NodeType = 9 // lef char a
+ NtNotone NodeType = 10 // lef char [^a]
+ NtSet NodeType = 11 // lef set [a-z\s] \w \s \d
+ NtMulti NodeType = 12 // lef string abcd
+ NtRef NodeType = 13 // lef group \#
+ NtBol NodeType = 14 // ^
+ NtEol NodeType = 15 // $
+ NtBoundary NodeType = 16 // \b
+ NtNonboundary NodeType = 17 // \B
+ NtBeginning NodeType = 18 // \A
+ NtStart NodeType = 19 // \G
+ NtEndZ NodeType = 20 // \Z
+ NtEnd NodeType = 21 // \Z
+
+ // Interior nodes do not correspond to primitive operations, but
+ // control structures compositing other operations
+
+ // Concat and alternate take n children, and can run forward or backwards
+
+ NtNothing NodeType = 22 // []
+ NtEmpty NodeType = 23 // ()
+ NtAlternate NodeType = 24 // a|b
+ NtConcatenate NodeType = 25 // ab
+ NtLoop NodeType = 26 // m,x * + ? {,}
+ NtLazyloop NodeType = 27 // m,x *? +? ?? {,}?
+ NtCapture NodeType = 28 // n ()
+ NtGroup NodeType = 29 // (?:)
+ NtPosLook NodeType = 30 // (?=) (?<=)
+ NtNegLook NodeType = 31 // (?!) (?) (?<)
+ NtBackRefCond NodeType = 33 // (?(n) | )
+ NtExprCond NodeType = 34 // (?(...) | )
+
+ NtECMABoundary NodeType = 41 // \b
+ NtNonECMABoundary NodeType = 42 // \B
+
+ // Atomic loop of the specified character.
+ // Operand 0 is the character. Operand 1 is the max iteration count.
+ NtOneloopatomic NodeType = 43
+ // Atomic loop of a single character other than the one specified.
+ // Operand 0 is the character. Operand 1 is the max iteration count.
+ NtNotoneloopatomic NodeType = 44
+ // Atomic loop of a single character matching the specified set
+ // Operand 0 is index into the strings table of the character class description. Operand 1 is the repetition count.
+ NtSetloopatomic NodeType = 45
+ // Updates the bumpalong position to the current position.
+ NtUpdateBumpalong NodeType = 46
+)
+
+func newRegexNode(t NodeType, opt RegexOptions) *RegexNode {
+ return &RegexNode{
+ T: t,
+ Options: opt,
+ }
+}
+
+func newRegexNodeCh(t NodeType, opt RegexOptions, ch rune) *RegexNode {
+ return nodeWithCaseConversion(&RegexNode{
+ T: t,
+ Options: opt,
+ Ch: ch,
+ })
+}
+
+func newRegexNodeStr(t NodeType, opt RegexOptions, str []rune) *RegexNode {
+ return &RegexNode{
+ T: t,
+ Options: opt,
+ Str: str,
+ }
+}
+
+func newRegexNodeSet(t NodeType, opt RegexOptions, set *CharSet) *RegexNode {
+ return nodeWithCaseConversion(&RegexNode{
+ T: t,
+ Options: opt,
+ Set: set,
+ })
+}
+
+func newRegexNodeM(t NodeType, opt RegexOptions, m int) *RegexNode {
+ return &RegexNode{
+ T: t,
+ Options: opt,
+ M: m,
+ }
+}
+func newRegexNodeMN(t NodeType, opt RegexOptions, m, n int) *RegexNode {
+ return &RegexNode{
+ T: t,
+ Options: opt,
+ M: m,
+ N: n,
+ }
+}
+
+func nodeWithCaseConversion(n *RegexNode) *RegexNode {
+ // if opts are ignore case and our rune is impacted by casing
+ // then we need to switch our type to the set version
+ // NtOne = NtSet
+ if n.Options&IgnoreCase == 0 {
+ return n
+ }
+
+ if n.Ch > 0 {
+ ch := n.Ch
+ if isLow, isUp := unicode.IsLower(ch), unicode.IsUpper(ch); isLow || isUp {
+ /*var upper, lower rune
+ // it's a capitalizable char
+ if isUp {
+ upper = ch
+ lower = unicode.ToLower(ch)
+ } else {
+ lower = ch
+ upper = unicode.ToUpper(ch)
+ }*/
+ set := &CharSet{}
+ set.addChar(ch)
+ set.addCaseEquivalences()
+ t := NtSet
+
+ switch n.T {
+ case NtOneloop, NtNotoneloop:
+ t = NtSetloop
+ case NtOnelazy, NtNotonelazy:
+ t = NtSetlazy
+ }
+ set.negate = n.IsNotoneFamily()
+
+ return &RegexNode{
+ T: t,
+ Options: n.Options & ^IgnoreCase,
+ Set: set,
+ }
+ }
+ } else if n.Set != nil {
+ // just to be safe we don't modify the original set pointer
+ // just in case it's used in a case-sensitive area
+ s := n.Set.Copy()
+ s.addCaseEquivalences()
+ n.Set = &s
+ n.Options &= ^IgnoreCase
+ }
+
+ return n
+}
+
+func (n *RegexNode) IsSetFamily() bool {
+ return n.T == NtSet || n.T == NtSetloop || n.T == NtSetlazy || n.T == NtSetloopatomic
+}
+func (n *RegexNode) IsOneFamily() bool {
+ return n.T == NtOne || n.T == NtOneloop || n.T == NtOnelazy || n.T == NtOneloopatomic
+}
+func (n *RegexNode) IsNotoneFamily() bool {
+ return n.T == NtNotone || n.T == NtNotoneloop || n.T == NtNotonelazy || n.T == NtNotoneloopatomic
+}
+
+func (n *RegexNode) IsSetloopFamily() bool {
+ return n.T == NtSetloop || n.T == NtSetlazy || n.T == NtSetloopatomic
+}
+func (n *RegexNode) IsOneloopFamily() bool {
+ return n.T == NtOneloop || n.T == NtOnelazy || n.T == NtOneloopatomic
+}
+func (n *RegexNode) IsNotoneloopFamily() bool {
+ return n.T == NtNotoneloop || n.T == NtNotonelazy || n.T == NtNotoneloopatomic
+}
+
+func (n *RegexNode) IsAtomicloopFamily() bool {
+ return n.T == NtOneloopatomic || n.T == NtNotoneloopatomic || n.T == NtSetloopatomic
+}
+
+func (n *RegexNode) writeStrToBuf(buf *bytes.Buffer) {
+ for i := 0; i < len(n.Str); i++ {
+ buf.WriteRune(n.Str[i])
+ }
+}
+
+func (n *RegexNode) addChild(child *RegexNode) {
+ child.Parent = n
+ reduced := child.reduce()
+ reduced.Parent = n
+ n.Children = append(n.Children, reduced)
+ reduced.Parent = n
+}
+
+func (n *RegexNode) insertChildren(afterIndex int, nodes []*RegexNode) {
+ for _, c := range nodes {
+ c.Parent = n
+ }
+ n.Children = slices.Insert(n.Children, afterIndex, nodes...)
+ //newChildren := make([]*RegexNode, 0, len(n.Children)+len(nodes))
+ //n.Children = append(append(append(newChildren, n.Children[:afterIndex]...), nodes...), n.Children[afterIndex:]...)
+}
+
+// removes children including the start but not the end index
+func (n *RegexNode) removeChildren(startIndex, endIndex int) {
+ n.Children = append(n.Children[:startIndex], n.Children[endIndex:]...)
+}
+
+func (n *RegexNode) ReplaceChild(index int, newChild *RegexNode) {
+ newChild.Parent = n // so that the child can see its parent while being reduced
+ newChild = newChild.reduce()
+ newChild.Parent = n // in case Reduce returns a different node that needs to be reparented
+
+ n.Children[index] = newChild
+}
+
+// Pass type as OneLazy or OneLoop
+func (n *RegexNode) makeRep(t NodeType, min, max int) {
+ n.T += (t - NtOne)
+ n.M = min
+ n.N = max
+}
+
+// Performs additional optimizations on an entire tree prior to being used.
+//
+// Some optimizations are performed by the parser while parsing, and others are performed
+// as nodes are being added to the tree. The optimizations here expect the tree to be fully
+// formed, as they inspect relationships between nodes that may not have been in place as
+// individual nodes were being processed/added to the tree.
+func (n *RegexNode) finalOptimize() *RegexNode {
+ rootNode := n
+
+ // Only apply optimization when LTR to avoid needing additional code for the much rarer RTL case.
+ // Also only apply these optimizations when not using NonBacktracking, as these optimizations are
+ // all about avoiding things that are impactful for the backtracking engines but nops for non-backtracking.
+ if n.Options&RightToLeft == 0 {
+ // Optimization: eliminate backtracking for loops.
+ // For any single-character loop (Oneloop, Notoneloop, Setloop), see if we can automatically convert
+ // that into its atomic counterpart (Oneloopatomic, Notoneloopatomic, Setloopatomic) based on what
+ // comes after it in the expression tree.
+ rootNode.findAndMakeLoopsAtomic()
+
+ // Optimization: backtracking removal at expression end.
+ // If we find backtracking construct at the end of the regex, we can instead make it non-backtracking,
+ // since nothing would ever backtrack into it anyway. Doing this then makes the construct available
+ // to implementations that don't support backtracking.
+ rootNode.eliminateEndingBacktracking()
+
+ // Optimization: unnecessary re-processing of starting loops.
+ // If an expression is guaranteed to begin with a single-character unbounded loop that isn't part of an alternation (in which case it
+ // wouldn't be guaranteed to be at the beginning) or a capture (in which case a back reference could be influenced by its length), then we
+ // can update the tree with a temporary node to indicate that the implementation should use that node's ending position in the input text
+ // as the next starting position at which to start the next match. This avoids redoing matches we've already performed, e.g. matching
+ // "\w+@dot.net" against "is this a valid address@dot.net", the \w+ will initially match the "is" and then will fail to match the "@".
+ // Rather than bumping the scan loop by 1 and trying again to match at the "s", we can instead start at the " ". For functional correctness
+ // we can only consider unbounded loops, as to be able to start at the end of the loop we need the loop to have consumed all possible matches;
+ // otherwise, you could end up with a pattern like "a{1,3}b" matching against "aaaabc", which should match, but if we pre-emptively stop consuming
+ // after the first three a's and re-start from that position, we'll end up failing the match even though it should have succeeded. We can also
+ // apply this optimization to non-atomic loops: even though backtracking could be necessary, such backtracking would be handled within the processing
+ // of a single starting position. Lazy loops similarly benefit, as a failed match will result in exploring the exact same search space as with
+ // a greedy loop, just in the opposite order (and a successful match will overwrite the bumpalong position); we need to avoid atomic lazy loops,
+ // however, as they will only end up as a repeater for the minimum length and thus will effectively end up with a non-infinite upper bound, which
+ // we've already outlined is problematic.
+ node := rootNode.Children[0] // skip implicit root capture node
+ atomicByAncestry := true // the root is implicitly atomic because nothing comes after it (same for the implicit root capture)
+ for {
+ if node.T == NtAtomic {
+ node = node.Children[0]
+ continue
+ } else if node.T == NtConcatenate {
+ atomicByAncestry = false
+ node = node.Children[0]
+ continue
+ } else if node.N == math.MaxInt32 &&
+ ((node.T == NtOneloop || node.T == NtOneloopatomic || node.T == NtNotoneloop || node.T == NtNotoneloopatomic || node.T == NtSetloop || node.T == NtSetloopatomic) ||
+ ((node.T == NtOnelazy || node.T == NtNotonelazy || node.T == NtSetlazy) && !atomicByAncestry)) {
+
+ if node.Parent != nil && node.Parent.T == NtConcatenate {
+ node.Parent.Children = slices.Insert(node.Parent.Children, 1, &RegexNode{T: NtUpdateBumpalong, Options: node.Options, Parent: node.Parent})
+ }
+ }
+
+ break
+ }
+
+ }
+
+ //debug helper
+ //rootNode.ValidateFinalTreeInvariants()
+
+ // Done optimizing. Return the final tree.
+ return rootNode
+}
+
+// Finds {one/notone/set}loop nodes in the concatenation that can be automatically upgraded
+// to {one/notone/set}loopatomic nodes. Such changes avoid potential useless backtracking.
+// e.g. A*B (where sets A and B don't overlap) => (?>A*)B.
+func (n *RegexNode) findAndMakeLoopsAtomic() {
+ if n.Options&RightToLeft != 0 {
+ // RTL is so rare, we don't need to spend additional time/code optimizing for it.
+ return
+ }
+
+ // For all node types that have children, recur into each of those children.
+ for i := 0; i < len(n.Children); i++ {
+ n.Children[i].findAndMakeLoopsAtomic()
+ }
+
+ // If this isn't a concatenation, nothing more to do.
+ if n.T != NtConcatenate {
+ return
+ }
+
+ // This is a concatenation. Iterate through each pair of nodes in the concatenation seeing whether we can
+ // make the first node (or its right-most child) atomic based on the second node (or its left-most child).
+ for i := 0; i < len(n.Children)-1; i++ {
+ n.Children[i].processNode(n.Children[i+1])
+ }
+}
+
+func (node *RegexNode) processNode(subsequent *RegexNode) {
+ // Skip down the node past irrelevant nodes.
+ for {
+ // We can always recur into captures and into the last node of concatenations.
+ if node.T == NtCapture || node.T == NtConcatenate {
+ node = node.Children[len(node.Children)-1]
+ continue
+ }
+
+ // For loops with at least one guaranteed iteration, we can recur into them, but
+ // we need to be careful not to just always do so; the ending node of a loop can only
+ // be made atomic if what comes after the loop but also the beginning of the loop are
+ // compatible for the optimization.
+ if node.T == NtLoop {
+ loopDescendent := node.FindLastExpressionInLoopForAutoAtomic()
+ if loopDescendent != nil {
+ node = loopDescendent
+ continue
+ }
+ }
+
+ // Can't skip any further.
+ break
+ }
+
+ // If the node can be changed to atomic based on what comes after it, do so.
+ switch node.T {
+ case NtOneloop, NtNotoneloop, NtSetloop:
+ if node.canBeMadeAtomic(subsequent, true, false) {
+ // The greedy loop doesn't overlap with what comes after it, which means giving anything it matches back will not
+ // help the overall match to succeed, which means it can simply become atomic to match as much as possible. The call
+ // to CanBeMadeAtomic passes iterateNullableSubsequent=true because, in a pattern like a*b*c*, when analyzing a*, we
+ // want to examine the b* and the c* rather than just giving up after seeing that b* is nullable; in order to make
+ // the a* atomic, we need to know that anything that could possibly come after the loop doesn't overlap.
+ node.makeLoopAtomic()
+ }
+
+ case NtOnelazy, NtNotonelazy, NtSetlazy:
+ if node.canBeMadeAtomic(subsequent, false, true) {
+ // The lazy loop doesn't overlap with what comes after it, which means it needs to match as much as its allowed
+ // to match in order for there to be a possibility that what comes next matches (if it doesn't match as much
+ // as it's allowed and there was still more it could match, then what comes next is guaranteed to not match,
+ // since it doesn't match any of the same things the loop matches). We don't want to just make the lazy loop
+ // atomic, as an atomic lazy loop matches as little as possible, not as much as possible. Instead, we want to
+ // make the lazy loop into an atomic greedy loop. Note that when we check CanBeMadeAtomic, we need to set
+ // "iterateNullableSubsequent" to false so that we only inspect non-nullable subsequent nodes. For example,
+ // given a pattern like a*?b, we want to upgrade that loop to being greedy atomic, e.g. (?>a*)b. But given a
+ // pattern like a*?b*, the subsequent node is nullable, which means it doesn't have to be part of a match, which
+ // means the a*? could match by itself, in which case as it's lazy it needs to match as few a's as possible, e.g.
+ // a+?b* against the input "aaaab" should match "a", not "aaaa" nor "aaaab". (Technically for lazy, we only need to prevent
+ // walking off the end of the pattern, but it's not currently worth complicating the implementation for that case.)
+ // allowLazy is set to true so that the implementation will analyze rather than ignore this node; generally lazy nodes
+ // are ignored due to making them atomic not generally being a sound change, but here we're explicitly choosing to
+ // given the circumstances.
+ node.T -= NtOnelazy - NtOneloop // lazy to greedy
+ node.makeLoopAtomic()
+ }
+
+ case NtAlternate, NtBackRefCond, NtExprCond:
+ // In the case of alternation, we can't change the alternation node itself
+ // based on what comes after it (at least not with more complicated analysis
+ // that factors in all branches together), but we can look at each individual
+ // branch, and analyze ending loops in each branch individually to see if they
+ // can be made atomic. Then if we do end up backtracking into the alternation,
+ // we at least won't need to backtrack into that loop. The same is true for
+ // conditionals, though we don't want to process the condition expression
+ // itself, as it's already considered atomic and handled as part of ReduceExpressionConditional.
+ b := 0
+ if node.T == NtExprCond {
+ b = 1
+ }
+ for ; b < len(node.Children); b++ {
+ node.Children[b].processNode(subsequent)
+ }
+
+ }
+}
+
+func (n *RegexNode) reduce() *RegexNode {
+ // Remove IgnoreCase option from everything except a Backreference
+ if n.T != NtRef {
+ n.Options &= ^IgnoreCase
+ }
+ switch n.T {
+ case NtAlternate:
+ return n.reduceAlternation()
+ case NtAtomic:
+ return n.reduceAtomic()
+ case NtConcatenate:
+ return n.reduceConcatenation()
+ case NtGroup:
+ return n.reduceGroup()
+ case NtLoop, NtLazyloop:
+ return n.reduceRep()
+ case NtPosLook, NtNegLook:
+ return n.reduceLookaround()
+ case NtSet, NtSetloop, NtSetlazy, NtSetloopatomic:
+ return n.reduceSet()
+ case NtExprCond:
+ return n.reduceExpressionConditional()
+ case NtBackRefCond:
+ return n.reduceBackreferenceConditional()
+ default:
+ return n
+ }
+}
+
+// / Optimizations for positive and negative lookaheads/behinds.
+func (n *RegexNode) reduceLookaround() *RegexNode {
+ // A lookaround is a zero-width atomic assertion.
+ // As it's atomic, nothing will backtrack into it, and we can
+ // eliminate any ending backtracking from it.
+ n.eliminateEndingBacktracking()
+
+ // A positive lookaround wrapped around an empty is a nop, and we can reduce it
+ // to simply Empty. A developer typically doesn't write this, but rather it evolves
+ // due to optimizations resulting in empty.
+
+ // A negative lookaround wrapped around an empty child, i.e. (?!), is
+ // sometimes used as a way to insert a guaranteed no-match into the expression,
+ // often as part of a conditional. We can reduce it to simply Nothing.
+
+ if n.Children[0].T == NtEmpty {
+ if n.T == NtPosLook {
+ n.T = NtEmpty
+ } else {
+ n.T = NtNothing
+ }
+ n.Children = nil
+ }
+
+ return n
+}
+
+// Optimizations for backreference conditionals.
+func (n *RegexNode) reduceBackreferenceConditional() *RegexNode {
+ // This isn't so much an optimization as it is changing the tree for consistency. We want
+ // all engines to be able to trust that every backreference conditional will have two children,
+ // even though it's optional in the syntax. If it's missing a "not matched" branch,
+ // we add one that will match empty.
+ if len(n.Children) == 1 {
+ n.addChild(&RegexNode{T: NtEmpty, Options: n.Options})
+ }
+
+ return n
+}
+
+// / Optimizations for expression conditionals.
+func (n *RegexNode) reduceExpressionConditional() *RegexNode {
+ // This isn't so much an optimization as it is changing the tree for consistency. We want
+ // all engines to be able to trust that every expression conditional will have three children,
+ // even though it's optional in the syntax. If it's missing a "not matched" branch,
+ // we add one that will match empty.
+ if len(n.Children) == 2 {
+ n.addChild(&RegexNode{T: NtEmpty, Options: n.Options})
+ }
+
+ // It's common for the condition to be an explicit positive lookahead, as specifying
+ // that eliminates any ambiguity in syntax as to whether the expression is to be matched
+ // as an expression or to be a reference to a capture group. After parsing, however,
+ // there's no ambiguity, and we can remove an extra level of positive lookahead, as the
+ // engines need to treat the condition as a zero-width positive, atomic assertion regardless.
+ condition := n.Children[0]
+ if condition.T == NtPosLook && (condition.Options&RightToLeft) == 0 {
+ n.ReplaceChild(0, condition.Children[0])
+ }
+
+ // We can also eliminate any ending backtracking in the condition, as the condition
+ // is considered to be a positive lookahead, which is an atomic zero-width assertion.
+ condition = n.Children[0]
+ condition.eliminateEndingBacktracking()
+
+ return n
+}
+
+// Remove unnecessary atomic nodes, and make appropriate descendents of the atomic node themselves atomic.
+// e.g. (?>(?>(?>a*))) => (?>a*)
+// e.g. (?>(abc*)*) => (?>(abc(?>c*))*)
+func (n *RegexNode) reduceAtomic() *RegexNode {
+ atomic := n
+ child := n.Children[0]
+ for child.T == NtAtomic {
+ atomic = child
+ child = atomic.Children[0]
+ }
+
+ switch child.T {
+ // If the child is empty/nothing, there's nothing to be made atomic so the Atomic
+ // node can simply be removed.
+ case NtEmpty, NtNothing:
+ return child
+
+ // If the child is already atomic, we can just remove the atomic node.
+ case NtOneloopatomic, NtNotoneloopatomic, NtSetloopatomic:
+ return child
+
+ // If an atomic subexpression contains only a {one/notone/set}{loop/lazy},
+ // change it to be an {one/notone/set}loopatomic and remove the atomic node.
+ case NtOneloop, NtNotoneloop, NtSetloop, NtOnelazy, NtNotonelazy, NtSetlazy:
+ child.makeLoopAtomic()
+ return child
+
+ // Alternations have a variety of possible optimizations that can be applied
+ // iff they're atomic.
+ case NtAlternate:
+ if (n.Options & RightToLeft) == 0 {
+ branches := child.Children
+
+ // If an alternation is atomic and its first branch is Empty, the whole thing
+ // is a nop, as Empty will match everything trivially, and no backtracking
+ // into the node will be performed, making the remaining branches irrelevant.
+ if branches[0].T == NtEmpty {
+ return &RegexNode{T: NtEmpty, Options: child.Options}
+ }
+
+ // Similarly, we can trim off any branches after an Empty, as they'll never be used.
+ // An Empty will match anything, and thus branches after that would only be used
+ // if we backtracked into it and advanced passed the Empty after trying the Empty...
+ // but if the alternation is atomic, such backtracking won't happen.
+ for i := 1; i < len(branches)-1; i++ {
+ if branches[i].T == NtEmpty {
+ branches = slices.Delete(branches, i+1, len(branches))
+ break
+ }
+ }
+
+ // If an alternation is atomic, we won't ever backtrack back into it, which
+ // means order matters but not repetition. With backtracking, it would be incorrect
+ // to convert an expression like "hi|there|hello" into "hi|hello|there", as doing
+ // so could then change the order of results if we matched "hi" and then failed
+ // based on what came after it, and both "hello" and "there" could be successful
+ // with what came later. But without backtracking, we can reorder "hi|there|hello"
+ // to instead be "hi|hello|there", as "hello" and "there" can't match the same text,
+ // and once this atomic alternation has matched, we won't try another branch. This
+ // reordering is valuable as it then enables further optimizations, e.g.
+ // "hi|there|hello" => "hi|hello|there" => "h(?:i|ello)|there", which means we only
+ // need to check the 'h' once in case it's not an 'h', and it's easier to employ different
+ // code gen that, for example, switches on first character of the branches, enabling faster
+ // choice of branch without always having to walk through each.
+ reordered := false
+ for start := 0; start < len(branches); start++ {
+ // Get the node that may start our range. If it's a one, multi, or concat of those, proceed.
+ startNode := branches[start]
+ if startNode.findBranchOneOrMultiStart() == nil {
+ continue
+ }
+
+ // Find the contiguous range of nodes from this point that are similarly one, multi, or concat of those.
+ endExclusive := start + 1
+ for endExclusive < len(branches) && branches[endExclusive].findBranchOneOrMultiStart() != nil {
+ endExclusive++
+ }
+
+ // If there's at least 3, there may be something to reorder (we won't reorder anything
+ // before the starting position, and so only 2 items is considered ordered).
+ if endExclusive-start >= 3 {
+ compare := start
+ for compare < endExclusive {
+ // Get the starting character
+ c := branches[compare].findBranchOneOrMultiStart().FirstCharOfOneOrMulti()
+
+ // Move compare to point to the last branch that has the same starting value.
+ for compare < endExclusive && branches[compare].findBranchOneOrMultiStart().FirstCharOfOneOrMulti() == c {
+ compare++
+ }
+
+ // Compare now points to the first node that doesn't match the starting node.
+ // If we've walked off our range, there's nothing left to reorder.
+ if compare < endExclusive {
+ // There may be something to reorder. See if there are any other nodes that begin with the same character.
+ for next := compare + 1; next < endExclusive; next++ {
+ nextChild := branches[next]
+ if nextChild.findBranchOneOrMultiStart().FirstCharOfOneOrMulti() == c {
+ branches = slices.Delete(branches, next, next+1)
+ branches = slices.Insert(branches, compare, nextChild)
+ compare++
+ reordered = true
+ }
+ }
+ }
+ }
+ }
+
+ // Move to the end of the range we've now explored. endExclusive is not a viable
+ // starting position either, and the start++ for the loop will thus take us to
+ // the next potential place to start a range.
+ start = endExclusive
+ }
+ child.Children = branches
+ // If anything was reordered, there may be new optimization opportunities inside
+ // of the alternation, so reduce it again.
+ if reordered {
+ atomic.ReplaceChild(0, child)
+ child = atomic.Children[0]
+ }
+ }
+ fallthrough
+
+ // For everything else, try to reduce ending backtracking of the last contained expression.
+ default:
+ child.eliminateEndingBacktracking()
+ return atomic
+ }
+}
+
+func (n *RegexNode) makeLoopAtomic() {
+
+ switch n.T {
+ case NtOneloop, NtNotoneloop, NtSetloop:
+ // For loops, we simply change the Type to the atomic variant.
+ // Atomic greedy loops should consume as many values as they can.
+ n.T += NtOneloopatomic - NtOneloop
+
+ case NtOnelazy, NtNotonelazy, NtSetlazy:
+ // For lazy, we not only change the Type, we also lower the max number of iterations
+ // to the minimum number of iterations, creating a repeater, as they should end up
+ // matching as little as possible.
+ n.T += NtOneloopatomic - NtOnelazy
+ n.N = n.M
+ if n.N == 0 {
+ // If moving the max to be the same as the min dropped it to 0, there's no
+ // work to be done for this node, and we can make it Empty.
+ n.T = NtEmpty
+ n.Str = nil
+ n.Ch = 0x0
+ } else if n.T == NtOneloopatomic && n.N >= 2 && n.N <= MultiVsRepeaterLimit {
+ // If this is now a One repeater with a small enough length,
+ // make it a Multi instead, as they're better optimized down the line.
+ n.T = NtMulti
+ n.Str = []rune(strings.Repeat(string(n.Ch), n.N))
+ n.Ch = 0x0
+ n.M = 0
+ n.N = 0
+ }
+ }
+}
+
+// Converts nodes at the end of the node tree to be atomic.
+// The correctness of this optimization depends on nothing being able to backtrack into
+// the provided node. That means it must be at the root of the overall expression, or
+// it must be an Atomic node that nothing will backtrack into by the very nature of Atomic.
+func (n *RegexNode) eliminateEndingBacktracking() {
+ // Walk the tree starting from the current node.
+ node := n
+ for {
+ switch node.T {
+ // {One/Notone/Set}loops can be upgraded to {One/Notone/Set}loopatomic nodes, e.g. [abc]* => (?>[abc]*).
+ // And {One/Notone/Set}lazys can similarly be upgraded to be atomic, which really makes them into repeaters
+ // or even empty nodes.
+ case NtOneloop, NtNotoneloop, NtSetloop, NtOnelazy, NtNotonelazy, NtSetlazy:
+ node.makeLoopAtomic()
+
+ // Just because a particular node is atomic doesn't mean all its descendants are.
+ // Process them as well. Lookarounds are implicitly atomic.
+ case NtAtomic, NtPosLook, NtNegLook:
+ node = node.Children[0]
+ continue
+
+ case NtCapture, NtConcatenate:
+ // For Capture and Concatenate, we just recur into their last child (only child in the case
+ // of Capture). However, if the child is an alternation or loop, we can also make the
+ // node itself atomic by wrapping it in an Atomic node. Since we later check to see whether a
+ // node is atomic based on its parent or grandparent, we don't bother wrapping such a node in
+ // an Atomic one if its grandparent is already Atomic.
+ // e.g. [xyz](?:abc|def) => [xyz](?>abc|def)
+
+ // validate grandparent isn't atomic
+ existingChild := node.Children[len(node.Children)-1]
+ if (existingChild.T == NtAlternate || existingChild.T == NtBackRefCond ||
+ existingChild.T == NtExprCond || existingChild.T == NtLoop ||
+ existingChild.T == NtLazyloop) &&
+ (node.Parent == nil || node.Parent.T != NtAtomic) {
+
+ atomic := &RegexNode{T: NtAtomic, Options: existingChild.Options}
+ atomic.addChild(existingChild)
+ node.ReplaceChild(len(node.Children)-1, atomic)
+ }
+ node = existingChild
+ continue
+
+ // For alternate, we can recur into each branch separately. We use this iteration for the first branch.
+ // Conditionals are just like alternations in this regard.
+ // e.g. abc*|def* => ab(?>c*)|de(?>f*)
+ case NtAlternate, NtBackRefCond, NtExprCond:
+
+ branches := len(node.Children)
+ for i := 1; i < branches; i++ {
+ node.Children[i].eliminateEndingBacktracking()
+ }
+
+ // ReduceExpressionConditional will have already applied ending backtracking removal
+ if node.T != NtExprCond {
+ node = node.Children[0]
+ continue
+ }
+
+ // For {Lazy}Loop, we search to see if there's a viable last expression, and iff there
+ // is we recur into processing it. Also, as with the single-char lazy loops, LazyLoop
+ // can have its max iteration count dropped to its min iteration count, as there's no
+ // reason for it to match more than the minimal at the end; that in turn makes it a
+ // repeater, which results in better code generation.
+ // e.g. (?:abc*)* => (?:ab(?>c*))*
+ // e.g. (abc*?)+? => (ab){1}
+ case NtLazyloop:
+ node.N = node.M
+ fallthrough
+ case NtLoop:
+ if node.N == 1 {
+ // If the loop has a max iteration count of 1 (e.g. it's an optional node),
+ // there's no possibility for conflict between multiple iterations, so
+ // we can process it.
+ node = node.Children[0]
+ continue
+ }
+
+ loopDescendent := node.FindLastExpressionInLoopForAutoAtomic()
+ if loopDescendent != nil {
+ node = loopDescendent
+ continue // loop around to process node
+ }
+
+ }
+
+ break
+ }
+}
+
+// Recurs into the last expression of a loop node, looking to see if it can find a node
+// that could be made atomic _assuming_ the conditions exist for it with the loop's ancestors.
+// Returns The found node that should be explored further for auto-atomicity; null if it doesn't exist.
+func (n *RegexNode) FindLastExpressionInLoopForAutoAtomic() *RegexNode {
+ node := n
+
+ // Start by looking at the loop's sole child.
+ node = node.Children[0]
+
+ // Skip past captures.
+ for node.T == NtCapture {
+ node = node.Children[0]
+ }
+
+ // If the loop's body is a concatenate, we can skip to its last child iff that
+ // last child doesn't conflict with the first child, since this whole concatenation
+ // could be repeated, such that the first node ends up following the last. For
+ // example, in the expression (a+[def])*, the last child is [def] and the first is
+ // a+, which can't possibly overlap with [def]. In contrast, if we had (a+[ade])*,
+ // [ade] could potentially match the starting 'a'.
+ if node.T == NtConcatenate {
+ concatCount := len(node.Children)
+ lastConcatChild := node.Children[concatCount-1]
+ if lastConcatChild.canBeMadeAtomic(node.Children[0], false, false) {
+ return lastConcatChild
+ }
+ }
+
+ // Otherwise, the loop has nothing that can participate in auto-atomicity.
+ return nil
+}
+
+// Determines whether a node can be switched to an atomic loop.
+//
+// The node following is subsequent, used to determine whether it overlaps.
+// iterateNullableSubsequent is whether to allow examining nodes beyond subsequent.
+// allowLazy is whether lazy loops in addition to greedy loops should be considered for atomicity.
+func (n *RegexNode) canBeMadeAtomic(subsequent *RegexNode, iterateNullableSubsequent, allowLazy bool) bool {
+ // In most case, we'll simply check the node against whatever subsequent is. However, in case
+ // subsequent ends up being a loop with a min bound of 0, we'll also need to evaluate the node
+ // against whatever comes after subsequent. In that case, we'll walk the tree to find the
+ // next subsequent, and we'll loop around against to perform the comparison again.
+ for {
+ // Skip the successor down to the closest node that's guaranteed to follow it.
+ childCount := len(subsequent.Children)
+ for ; childCount > 0; childCount = len(subsequent.Children) {
+ if subsequent.T == NtConcatenate || subsequent.T == NtCapture ||
+ subsequent.T == NtAtomic ||
+ (subsequent.T == NtPosLook && subsequent.Options&RightToLeft == 0) ||
+ ((subsequent.T == NtLoop || subsequent.T == NtLazyloop) && subsequent.M > 0) {
+ subsequent = subsequent.Children[0]
+ continue
+ }
+
+ break
+ }
+
+ // If the current node's options don't match the subsequent node, then we cannot make it atomic.
+ // This applies to RightToLeft for lookbehinds, as well as patterns that enable/disable global flags in the middle of the pattern.
+ if n.Options != subsequent.Options {
+ return false
+ }
+
+ // If the successor is an alternation, all of its children need to be evaluated, since any of them
+ // could come after this node. If any of them fail the optimization, then the whole node fails.
+ // This applies to expression conditionals as well, as long as they have both a yes and a no branch (if there's
+ // only a yes branch, we'd need to also check whatever comes after the conditional). It doesn't apply to
+ // backreference conditionals, as the condition itself is unknown statically and could overlap with the
+ // loop being considered for atomicity.
+ if subsequent.T == NtAlternate || (subsequent.T == NtExprCond && childCount == 3) {
+ // condition, yes, and no branch
+ for i := 0; i < childCount; i++ {
+ if !n.canBeMadeAtomic(subsequent.Children[i], iterateNullableSubsequent, false) {
+ return false
+ }
+ }
+ return true
+ }
+
+ // If this node is a {one/notone/set}loop, see if it overlaps with its successor in the concatenation.
+ // If it doesn't, then we can upgrade it to being a {one/notone/set}loopatomic.
+ // Doing so avoids unnecessary backtracking.
+ if n.T == NtOneloop || (n.T == NtOnelazy && allowLazy) {
+
+ if (subsequent.T == NtOne && n.Ch != subsequent.Ch) ||
+ (subsequent.T == NtNotone && n.Ch == subsequent.Ch) ||
+ (subsequent.T == NtSet && !subsequent.Set.CharIn(n.Ch)) ||
+ (subsequent.IsOneFamily() && subsequent.M > 0 && n.Ch != subsequent.Ch) ||
+ (subsequent.IsNotoneFamily() && subsequent.M > 0 && n.Ch == subsequent.Ch) ||
+ (subsequent.IsSetFamily() && subsequent.M > 0 && !subsequent.Set.CharIn(n.Ch)) ||
+ (subsequent.T == NtMulti && n.Ch != subsequent.Str[0]) ||
+ (subsequent.T == NtEnd) ||
+ (subsequent.T == NtEndZ && n.Ch != '\n') ||
+ (subsequent.T == NtEol && n.Ch != '\n') {
+ return true
+ }
+
+ // The loop can be made atomic based on this subsequent node, but we'll need to evaluate the next one as well.
+ if (subsequent.IsOneloopFamily() && subsequent.M == 0 && n.Ch != subsequent.Ch) ||
+ (subsequent.IsNotoneloopFamily() && subsequent.M == 0 && n.Ch == subsequent.Ch) ||
+ (subsequent.IsSetloopFamily() && subsequent.M == 0 && !subsequent.Set.CharIn(n.Ch)) ||
+ (subsequent.T == NtBoundary && n.M > 0 && IsWordChar(n.Ch)) ||
+ (subsequent.T == NtNonboundary && n.M > 0 && !IsWordChar(n.Ch)) ||
+ (subsequent.T == NtECMABoundary && n.M > 0 && IsECMAWordChar(n.Ch)) ||
+ (subsequent.T == NtNonECMABoundary && n.M > 0 && !IsECMAWordChar(n.Ch)) {
+ goto end
+ }
+
+ return false
+
+ } else if n.T == NtNotoneloop || (n.T == NtNotonelazy && allowLazy) {
+ if (subsequent.T == NtOne && n.Ch == subsequent.Ch) ||
+ (subsequent.IsOneFamily() && subsequent.M > 0 && n.Ch == subsequent.Ch) ||
+ (subsequent.T == NtMulti && n.Ch == subsequent.Str[0]) ||
+ (subsequent.T == NtEnd) {
+ return true
+ }
+
+ // The loop can be made atomic based on this subsequent node, but we'll need to evaluate the next one as well.
+ if subsequent.IsOneloopFamily() && subsequent.M == 0 && n.Ch == subsequent.Ch {
+ goto end
+ }
+
+ return false
+ } else if n.T == NtSetloop || (n.T == NtSetlazy && allowLazy) {
+ if (subsequent.T == NtOne && !n.Set.CharIn(subsequent.Ch)) ||
+ (subsequent.T == NtSet && !n.Set.MayOverlap(subsequent.Set)) ||
+ (subsequent.IsOneloopFamily() && subsequent.M > 0 && !n.Set.CharIn(subsequent.Ch)) ||
+ (subsequent.IsSetloopFamily() && subsequent.M > 0 && !n.Set.MayOverlap(subsequent.Set)) ||
+ (subsequent.T == NtMulti && !n.Set.CharIn(subsequent.Str[0])) ||
+ (subsequent.T == NtEnd) ||
+ (subsequent.T == NtEndZ && !n.Set.CharIn('\n')) ||
+ (subsequent.T == NtEol && !n.Set.CharIn('\n')) {
+ return true
+ }
+
+ if (subsequent.IsOneloopFamily() && subsequent.M == 0 && !n.Set.CharIn(subsequent.Ch)) ||
+ (subsequent.IsSetloopFamily() && subsequent.M == 0 && subsequent.Set.MayOverlap(n.Set)) ||
+ (subsequent.T == NtBoundary && n.M > 0 && (n.Set.Equals(WordClass()) || n.Set.Equals(DigitClass()))) ||
+ (subsequent.T == NtNonboundary && n.M > 0 && (n.Set.Equals(NotWordClass()) || n.Set.Equals(NotDigitClass()))) ||
+ (subsequent.T == NtECMABoundary && n.M > 0 && (n.Set.Equals(ECMAWordClass()) || n.Set.Equals(ECMADigitClass()))) ||
+ (subsequent.T == NtNonECMABoundary && n.M > 0 && (n.Set.Equals(NotECMAWordClass()) || n.Set.Equals(NotDigitClass()))) {
+ // The loop can be made atomic based on this subsequent node, but we'll need to evaluate the next one as well.
+ goto end
+ }
+ return false
+ } else {
+ return false
+ }
+
+ end:
+ // We only get here if the node could be made atomic based on subsequent but subsequent has a lower bound of zero
+ // and thus we need to move subsequent to be the next node in sequence and loop around to try again.
+ if !iterateNullableSubsequent {
+ return false
+ }
+
+ // To be conservative, we only walk up through a very limited set of constructs (even though we may have walked
+ // down through more, like loops), looking for the next concatenation that we're not at the end of, at
+ // which point subsequent becomes whatever node is next in that concatenation.
+ for {
+ parent := subsequent.Parent
+ if parent == nil {
+ // If we hit the root, we're at the end of the expression, at which point nothing could backtrack
+ // in and we can declare success.
+ return true
+ }
+
+ switch parent.T {
+ case NtAtomic, NtAlternate, NtCapture:
+ subsequent = parent
+ continue
+
+ case NtConcatenate:
+ peers := parent.Children
+ currentIndex := slices.Index(peers, subsequent)
+
+ if currentIndex+1 == len(peers) {
+ subsequent = parent
+ continue
+ } else {
+ subsequent = peers[currentIndex+1]
+ }
+
+ default:
+ // Anything else, we don't know what to do, so we have to assume it could conflict with the loop.
+ return false
+ }
+
+ break
+ }
+ }
+}
+
+// Basic optimization. Single-letter alternations can be replaced
+// by faster set specifications, and nested alternations with no
+// intervening operators can be flattened:
+//
+// a|b|c|def|g|h -> [a-c]|def|[gh]
+// apple|(?:orange|pear)|grape -> apple|orange|pear|grape
+func (n *RegexNode) reduceAlternation() *RegexNode {
+ if len(n.Children) == 0 {
+ return newRegexNode(NtNothing, n.Options)
+ }
+ if len(n.Children) == 1 {
+ return n.Children[0]
+ }
+ n.reduceSingleLetterAndNestedAlternations()
+
+ node := n.replaceNodeIfUnnecessary()
+ if node.T == NtAlternate {
+ node = node.extractCommonPrefixText()
+ if node.T == NtAlternate {
+ node = node.extractCommonPrefixOneNotoneSet()
+ if node.T == NtAlternate {
+ node = node.removeRedundantEmptiesAndNothings()
+ }
+ }
+ }
+ return node
+}
+
+// Analyzes all the branches of the alternation for text that's identical at the beginning
+// of every branch. That text is then pulled out into its own one or multi node in a
+// concatenation with the alternation (whose branches are updated to remove that prefix).
+// This is valuable for a few reasons. One, it exposes potentially more text to the
+// expression prefix analyzer used to influence FindFirstChar. Second, it exposes more
+// potential alternation optimizations, e.g. if the same prefix is followed in two branches
+// by sets that can be merged. Third, it reduces the amount of duplicated comparisons required
+// if we end up backtracking into subsequent branches.
+// e.g. abc|ade => a(?bc|de)
+func (n *RegexNode) extractCommonPrefixText() *RegexNode {
+ // To keep things relatively simple, we currently only handle:
+ // - Left to right (e.g. we don't process alternations in lookbehinds)
+ // - Branches that are one or multi nodes, or that are concatenations beginning with one or multi nodes.
+ // - All branches having the same options.
+
+ // Only extract left-to-right prefixes.
+ if (n.Options & RightToLeft) != 0 {
+ return n
+ }
+
+ for startingIndex := 0; startingIndex < len(n.Children)-1; startingIndex++ {
+ // Process the first branch to get the maximum possible common string.
+ startingNode := n.Children[startingIndex].findBranchOneOrMultiStart()
+ if startingNode == nil {
+ return n
+ }
+
+ startingNodeOptions := startingNode.Options
+ startingSpan := startingNode.Str
+ if startingNode.T == NtOne {
+ startingSpan = []rune{startingNode.Ch}
+ }
+
+ // Now compare the rest of the branches against it.
+ endingIndex := startingIndex + 1
+ for ; endingIndex < len(n.Children); endingIndex++ {
+ // Get the starting node of the next branch.
+ startingNode = n.Children[endingIndex].findBranchOneOrMultiStart()
+ if startingNode == nil || startingNode.Options != startingNodeOptions {
+ break
+ }
+
+ // See if the new branch's prefix has a shared prefix with the current one.
+ // If it does, shorten to that; if it doesn't, bail.
+ if startingNode.T == NtOne {
+ if startingSpan[0] != startingNode.Ch {
+ break
+ }
+
+ if len(startingSpan) != 1 {
+ startingSpan = startingSpan[0:1]
+ }
+ } else {
+ minLength := len(startingSpan)
+ if len(startingNode.Str) < minLength {
+ minLength = len(startingNode.Str)
+ }
+ c := 0
+ for c < minLength && startingSpan[c] == startingNode.Str[c] {
+ c++
+ }
+
+ if c == 0 {
+ break
+ }
+
+ startingSpan = startingSpan[0:c]
+ }
+ }
+
+ // When we get here, we have a starting string prefix shared by all branches
+ // in the range [startingIndex, endingIndex).
+ if endingIndex-startingIndex <= 1 {
+ // There's nothing to consolidate for this starting node.
+ continue
+ }
+
+ // We should be able to consolidate something for the nodes in the range [startingIndex, endingIndex).
+
+ // Create a new node of the form:
+ // Concatenation(prefix, Alternation(each | node | with | prefix | removed))
+ // that replaces all these branches in this alternation.
+ var prefix *RegexNode
+ if len(startingSpan) == 1 {
+ prefix = &RegexNode{T: NtOne, Options: startingNodeOptions, Ch: startingSpan[0]}
+ } else {
+ prefix = &RegexNode{T: NtMulti, Options: startingNodeOptions, Str: slices.Clone(startingSpan)}
+ }
+
+ newAlternate := &RegexNode{T: NtAlternate, Options: startingNodeOptions}
+ for i := startingIndex; i < endingIndex; i++ {
+ branch := n.Children[i]
+ if branch.T == NtConcatenate {
+ branch.Children[0].processOneOrMulti(startingSpan)
+ } else {
+ branch.processOneOrMulti(startingSpan)
+ }
+ branch = branch.reduce()
+ newAlternate.addChild(branch)
+ }
+
+ if n.Parent != nil && n.Parent.T == NtAtomic {
+ var atomic = &RegexNode{T: NtAtomic, Options: startingNodeOptions}
+ atomic.addChild(newAlternate)
+ newAlternate = atomic
+ }
+
+ newConcat := &RegexNode{T: NtConcatenate, Options: startingNodeOptions}
+ newConcat.addChild(prefix)
+ newConcat.addChild(newAlternate)
+ n.ReplaceChild(startingIndex, newConcat)
+ n.Children = slices.Delete(n.Children, startingIndex+1, endingIndex)
+ }
+
+ if len(n.Children) == 1 {
+ return n.Children[0]
+ }
+
+ return n
+}
+
+// This function optimizes out prefix nodes from alternation branches that are
+// the same across multiple contiguous branches.
+// e.g. \w12|\d34|\d56|\w78|\w90 => \w12|\d(?:34|56)|\w(?:78|90)
+func (n *RegexNode) extractCommonPrefixOneNotoneSet() *RegexNode {
+ // Only process left-to-right prefixes.
+ if (n.Options & RightToLeft) != 0 {
+ return n
+ }
+
+ // Only handle the case where each branch is a concatenation
+ for _, child := range n.Children {
+ if child.T != NtConcatenate || len(child.Children) < 2 {
+ return n
+ }
+ }
+
+ for startingIndex := 0; startingIndex < len(n.Children)-1; startingIndex++ {
+ // Only handle the case where each branch begins with the same One, Notone, or Set (individual or loop).
+ // Note that while we can do this for individual characters, fixed length loops, and atomic loops, doing
+ // it for non-atomic variable length loops could change behavior as each branch could otherwise have a
+ // different number of characters consumed by the loop based on what's after it.
+ required := n.Children[startingIndex].Children[0]
+
+ if (!required.IsOneFamily() && !required.IsNotoneFamily() && !required.IsSetFamily()) ||
+ required.M != required.N {
+ // skip if it's not one of these scenarios
+ continue
+ }
+
+ // Only handle the case where each branch begins with the exact same node value
+ endingIndex := startingIndex + 1
+ for ; endingIndex < len(n.Children); endingIndex++ {
+ other := n.Children[endingIndex].Children[0]
+ if required.T != other.T ||
+ required.Options != other.Options ||
+ required.M != other.M ||
+ required.N != other.N ||
+ required.Ch != other.Ch ||
+ !slices.Equal(required.Str, other.Str) ||
+ !required.Set.Equals(other.Set) {
+ break
+ }
+ }
+
+ if endingIndex-startingIndex <= 1 {
+ // Nothing to extract from this starting index.
+ continue
+ }
+
+ // Remove the prefix node from every branch, adding it to a new alternation
+ newAlternate := &RegexNode{T: NtAlternate, Options: n.Options}
+ for i := startingIndex; i < endingIndex; i++ {
+ n.Children[i].Children = slices.Delete(n.Children[i].Children, 0, 1)
+ newAlternate.addChild(n.Children[i])
+ }
+
+ // If this alternation is wrapped as atomic, we need to do the same for the new alternation.
+ if n.Parent != nil && n.Parent.T == NtAtomic {
+ atomic := &RegexNode{T: NtAtomic, Options: n.Options}
+ atomic.addChild(newAlternate)
+ newAlternate = atomic
+ }
+
+ // Now create a concatenation of the prefix node with the new alternation for the combined
+ // branches, and replace all of the branches in this alternation with that new concatenation.
+ newConcat := &RegexNode{T: NtConcatenate, Options: n.Options}
+ newConcat.addChild(required)
+ newConcat.addChild(newAlternate)
+ n.ReplaceChild(startingIndex, newConcat)
+ n.Children = slices.Delete(n.Children, startingIndex+1, endingIndex)
+ }
+
+ return n.replaceNodeIfUnnecessary()
+}
+
+// Removes unnecessary Empty and Nothing nodes from the alternation. A Nothing will never
+// match, so it can be removed entirely, and an Empty can be removed if there's a previous
+// Empty in the alternation: it's an extreme case of just having a repeated branch in an
+// alternation, and while we don't check for all duplicates, checking for empty is easy.
+func (n *RegexNode) removeRedundantEmptiesAndNothings() *RegexNode {
+ children := n.Children
+
+ i, j := 0, 0
+ seenEmpty := false
+ for i < len(children) {
+ child := children[i]
+ if child.T == NtNothing || (child.T == NtEmpty && seenEmpty) {
+ i++
+ continue
+ }
+ if child.T == NtEmpty {
+ seenEmpty = true
+ }
+ children[j] = children[i]
+ i++
+ j++
+ }
+
+ n.Children = slices.Delete(children, j, len(children))
+ return n.replaceNodeIfUnnecessary()
+}
+
+// Remove the starting text from the one or multi node. This may end up changing
+// the type of the node to be Empty if the starting text matches the node's full value.
+func (n *RegexNode) processOneOrMulti(startingSpan []rune) {
+ if n.T == NtOne {
+ n.T = NtEmpty
+ n.Ch = 0x0
+ } else {
+ if len(n.Str) == len(startingSpan) {
+ n.T = NtEmpty
+ n.Str = nil
+ } else if len(n.Str)-1 == len(startingSpan) {
+ n.T = NtOne
+ n.Ch = n.Str[len(n.Str)-1]
+ n.Str = nil
+ } else {
+ n.Str = n.Str[len(startingSpan):]
+ }
+ }
+}
+
+// Finds the starting one or multi of the branch, if it has one; otherwise, returns null.
+// For simplicity, this only considers branches that are One or Multi, or a Concatenation
+// beginning with a One or Multi. We don't traverse more than one level to avoid the
+// complication of then having to later update that hierarchy when removing the prefix,
+// but it could be done in the future if proven beneficial enough.
+func (n *RegexNode) findBranchOneOrMultiStart() *RegexNode {
+ branch := n
+ if n.T == NtConcatenate {
+ branch = n.Children[0]
+ }
+ if branch.T == NtOne || branch.T == NtMulti {
+ return branch
+ }
+ return nil
+}
+
+func (n *RegexNode) reduceSingleLetterAndNestedAlternations() {
+
+ wasLastSet := false
+ lastNodeCannotMerge := false
+ var optionsLast RegexOptions
+ var i, j int
+
+ for i, j = 0, 0; i < len(n.Children); i, j = i+1, j+1 {
+ at := n.Children[i]
+
+ if j < i {
+ n.Children[j] = at
+ }
+
+ for {
+ if at.T == NtAlternate {
+ n.insertChildren(i+1, at.Children)
+ j--
+ } else if at.T == NtSet || at.T == NtOne {
+ // Cannot merge sets if L or I options differ, or if either are negated.
+ optionsAt := at.Options & (RightToLeft | IgnoreCase)
+
+ if at.T == NtSet {
+ if !wasLastSet || optionsLast != optionsAt || lastNodeCannotMerge || !at.Set.IsMergeable() {
+ wasLastSet = true
+ lastNodeCannotMerge = !at.Set.IsMergeable()
+ optionsLast = optionsAt
+ break
+ }
+ } else if !wasLastSet || optionsLast != optionsAt || lastNodeCannotMerge {
+ wasLastSet = true
+ lastNodeCannotMerge = false
+ optionsLast = optionsAt
+ break
+ }
+
+ // The last node was a Set or a One, we're a Set or One and our options are the same.
+ // Merge the two nodes.
+ j--
+ prev := n.Children[j]
+
+ var prevCharClass *CharSet
+ if prev.T == NtOne {
+ prevCharClass = &CharSet{}
+ prevCharClass.addChar(prev.Ch)
+ } else {
+ prevCharClass = prev.Set
+ }
+
+ if at.T == NtOne {
+ prevCharClass.addChar(at.Ch)
+ } else {
+ prevCharClass.addSet(*at.Set)
+ }
+
+ prev.T = NtSet
+ prev.Set = prevCharClass
+ if prev.Options&IgnoreCase != 0 {
+ prev.Options &= ^IgnoreCase
+ }
+ } else if at.T == NtNothing {
+ j--
+ } else {
+ wasLastSet = false
+ lastNodeCannotMerge = false
+ }
+ break
+ }
+ }
+
+ if j < i {
+ n.removeChildren(j, i)
+ }
+}
+
+func (n *RegexNode) reduceConcatenation() *RegexNode {
+ // Eliminate empties and concat adjacent strings/chars
+
+ if len(n.Children) == 0 {
+ return newRegexNode(NtEmpty, n.Options)
+ }
+ // remove concat
+ if len(n.Children) == 1 {
+ return n.Children[0]
+ }
+
+ // If any node in the concatenation is a Nothing, the concatenation itself is a Nothing.
+ for i := 0; i < len(n.Children); i++ {
+ child := n.Children[i]
+ if child.T == NtNothing {
+ return child
+ }
+ }
+
+ // Coalesce adjacent loops. This helps to minimize work done by the interpreter, minimize code gen,
+ // and also help to reduce catastrophic backtracking.
+ n.reduceConcatenationWithAdjacentLoops()
+
+ // Coalesce adjacent characters/strings. This is done after the adjacent loop coalescing so that
+ // a One adjacent to both a Multi and a Loop prefers being folded into the Loop rather than into
+ // the Multi. Doing so helps with auto-atomicity when it's later applied.
+ n.reduceConcatenationWithAdjacentStrings()
+
+ // If the concatenation is now empty, return an empty node, or if it's got a single child, return that child.
+ // Otherwise, return this.
+ return n.replaceNodeIfUnnecessary()
+}
+
+func addMinLength(x, y int) int {
+ const maxMinLength = math.MaxInt32 - 1
+ if x >= maxMinLength || y >= maxMinLength || x > maxMinLength-y {
+ return maxMinLength
+ }
+ return x + y
+}
+
+func multiplyMinLength(x, y int) int {
+ const maxMinLength = math.MaxInt32 - 1
+ if x == 0 || y == 0 {
+ return 0
+ }
+ if x >= maxMinLength || y >= maxMinLength || x > maxMinLength/y {
+ return maxMinLength
+ }
+ return x * y
+}
+
+func addMaxLength(x, y int) int {
+ if x < 0 || y < 0 || x >= math.MaxInt32 || y >= math.MaxInt32 || x > (math.MaxInt32-1)-y {
+ return -1
+ }
+ return x + y
+}
+
+func multiplyMaxLength(x, y int) int {
+ if x < 0 || y < 0 {
+ return -1
+ }
+ if x == 0 || y == 0 {
+ return 0
+ }
+ if x >= math.MaxInt32 || y >= math.MaxInt32 || x > (math.MaxInt32-1)/y {
+ return -1
+ }
+ return x * y
+}
+
+func maxLessThanTwiceMin(max, min int) bool {
+ if min <= math.MaxInt32/2 {
+ return max < min*2
+ }
+ return max != math.MaxInt32
+}
+
+func canCombineCounts(nodeMin, nodeMax, nextMin, nextMax int) bool {
+ // We shouldn't have an infinite minimum; bail if we find one. Also check for the
+ // degenerate case where we'd make the min overflow or go infinite when it wasn't already.
+ if nodeMin == math.MaxInt32 ||
+ nextMin == math.MaxInt32 ||
+ addMaxLength(nodeMin, nextMin) < 0 {
+ return false
+ }
+
+ // Similar overflow / go infinite check for max (which can be infinite).
+ if nodeMax != math.MaxInt32 &&
+ nextMax != math.MaxInt32 &&
+ addMaxLength(nodeMax, nextMax) < 0 {
+ return false
+ }
+
+ return true
+}
+
+// Combine adjacent loops.
+// e.g. a*a*a* => a*
+// e.g. a+ab => a{2,}b
+func (n *RegexNode) reduceConcatenationWithAdjacentLoops() {
+ current, next, nextSave := 0, 1, 1
+
+ for next < len(n.Children) {
+ currentNode := n.Children[current]
+ nextNode := n.Children[next]
+
+ if currentNode.Options == nextNode.Options {
+ // Coalescing a loop with its same type
+ if ((currentNode.IsOneloopFamily() || currentNode.IsNotoneloopFamily()) && nextNode.T == currentNode.T && currentNode.Ch == nextNode.Ch) ||
+ (currentNode.IsSetloopFamily() && currentNode.T == nextNode.T && currentNode.Set.Equals(nextNode.Set)) {
+ if nextNode.M > 0 && currentNode.IsAtomicloopFamily() {
+ // Atomic loops can only be combined if the second loop has no lower bound, as if it has a lower bound,
+ // combining them changes behavior. Uncombined, the first loop can consume all matching items;
+ // the second loop might then not be able to meet its minimum and fail. But if they're combined, the combined
+ // minimum of the sole loop could now be met, introducing matches where there shouldn't have been any.
+ goto End
+ }
+
+ if !canCombineCounts(currentNode.M, currentNode.N, nextNode.M, nextNode.N) {
+ goto End
+ }
+ currentNode.M += nextNode.M
+ if currentNode.N != math.MaxInt32 {
+ if nextNode.N == math.MaxInt32 {
+ currentNode.N = math.MaxInt32
+ } else {
+ currentNode.N += nextNode.N
+ }
+ }
+ next++
+ continue
+
+ } else if ((currentNode.T == NtOneloop || currentNode.T == NtOnelazy) && nextNode.T == NtOne && currentNode.Ch == nextNode.Ch) ||
+ ((currentNode.T == NtNotoneloop || currentNode.T == NtNotonelazy) && nextNode.T == NtNotone && currentNode.Ch == nextNode.Ch) ||
+ ((currentNode.T == NtSetloop || currentNode.T == NtSetlazy) && nextNode.T == NtSet && currentNode.Set.Equals(nextNode.Set)) {
+ // Coalescing a loop with an additional item of the same type
+ if canCombineCounts(currentNode.M, currentNode.N, 1, 1) {
+ currentNode.M++
+ if currentNode.N != math.MaxInt32 {
+ currentNode.N++
+ }
+ next++
+ continue
+ }
+ } else if (currentNode.T == NtOneloop || currentNode.T == NtOnelazy) && nextNode.T == NtMulti && currentNode.Ch == nextNode.Str[0] {
+ // Coalescing a loop with a subsequent string
+ // Determine how many of the multi's characters can be combined.
+ // We already checked for the first, so we know it's at least one.
+ matchingCharsInMulti := 1
+ for matchingCharsInMulti < len(nextNode.Str) && currentNode.Ch == nextNode.Str[matchingCharsInMulti] {
+ matchingCharsInMulti++
+ }
+
+ if canCombineCounts(currentNode.M, currentNode.N, matchingCharsInMulti, matchingCharsInMulti) {
+ // Update the loop's bounds to include those characters from the multi
+ currentNode.M += matchingCharsInMulti
+ if currentNode.N != math.MaxInt32 {
+ currentNode.N += matchingCharsInMulti
+ }
+
+ // If it was the full multi, skip/remove the multi and continue processing this loop.
+ if len(nextNode.Str) == matchingCharsInMulti {
+ next++
+ continue
+ }
+
+ // Otherwise, trim the characters from the multiple that were absorbed into the loop.
+ // If it now only has a single character, it becomes a One.
+ if len(nextNode.Str)-matchingCharsInMulti == 1 {
+ nextNode.T = NtOne
+ nextNode.Ch = nextNode.Str[len(nextNode.Str)-1]
+ nextNode.Str = nil
+ } else {
+ nextNode.Str = nextNode.Str[matchingCharsInMulti:]
+ }
+ }
+
+ // NOTE: We could add support for coalescing a string with a subsequent loop, but the benefits of that
+ // are limited. Pulling a subsequent string's prefix back into the loop helps with making the loop atomic,
+ // but if the loop is after the string, pulling the suffix of the string forward into the loop may actually
+ // be a deoptimization as those characters could end up matching more slowly as part of loop matching.
+
+ } else if (currentNode.T == NtOne && nextNode.IsOneloopFamily() && currentNode.Ch == nextNode.Ch) ||
+ (currentNode.T == NtNotone && nextNode.IsNotoneloopFamily() && currentNode.Ch == nextNode.Ch) ||
+ (currentNode.T == NtSet && nextNode.IsSetloopFamily() && currentNode.Set.Equals(nextNode.Set)) {
+ // Coalescing an individual item with a loop.
+ if canCombineCounts(1, 1, nextNode.M, nextNode.N) {
+ currentNode.T = nextNode.T
+ currentNode.M = nextNode.M + 1
+ if nextNode.N == math.MaxInt32 {
+ currentNode.N = math.MaxInt32
+ } else {
+ currentNode.N = nextNode.N + 1
+ }
+ next++
+ continue
+ }
+ } else if (currentNode.T == NtNotone && nextNode.T == NtNotone && currentNode.Ch == nextNode.Ch) ||
+ (currentNode.T == NtSet && nextNode.T == NtSet && currentNode.Set.Equals(nextNode.Set)) {
+ // Coalescing an individual item with another individual item.
+ // We don't coalesce adjacent One nodes into a Oneloop as we'd rather they be joined into a Multi.
+ currentNode.makeRep(NtOneloop, 2, 2)
+ next++
+ continue
+ }
+
+ End:
+ }
+
+ n.Children[nextSave] = n.Children[next]
+ nextSave++
+ current = next
+ next++
+ }
+
+ if nextSave < len(n.Children) {
+ n.Children = slices.Delete(n.Children, nextSave, len(n.Children))
+ }
+}
+
+// Basic optimization. Adjacent strings can be concatenated.
+//
+// (?:abc)(?:def) -> abcdef
+func (n *RegexNode) reduceConcatenationWithAdjacentStrings() {
+ var optionsLast RegexOptions
+ var optionsAt RegexOptions
+ var i, j int
+
+ wasLastString := false
+
+ for i, j = 0, 0; i < len(n.Children); i, j = i+1, j+1 {
+ var at, prev *RegexNode
+
+ at = n.Children[i]
+
+ if j < i {
+ n.Children[j] = at
+ }
+
+ if at.T == NtConcatenate &&
+ ((at.Options & RightToLeft) == (n.Options & RightToLeft)) {
+ for k := 0; k < len(at.Children); k++ {
+ at.Children[k].Parent = n
+ }
+
+ //insert at.children at i+1 index in n.children
+ n.insertChildren(i+1, at.Children)
+
+ j--
+ } else if at.T == NtMulti || at.T == NtOne {
+ // Cannot merge strings if L or I options differ
+ optionsAt = at.Options & (RightToLeft | IgnoreCase)
+
+ if !wasLastString || optionsLast != optionsAt {
+ wasLastString = true
+ optionsLast = optionsAt
+ continue
+ }
+
+ j--
+ prev = n.Children[j]
+
+ if prev.T == NtOne {
+ prev.T = NtMulti
+ prev.Str = []rune{prev.Ch}
+ }
+
+ if (optionsAt & RightToLeft) == 0 {
+ if at.T == NtOne {
+ prev.Str = append(prev.Str, at.Ch)
+ } else {
+ prev.Str = append(prev.Str, at.Str...)
+ }
+ } else {
+ if at.T == NtOne {
+ // insert at the front by expanding our slice, copying the data over, and then setting the value
+ prev.Str = append(prev.Str, 0)
+ copy(prev.Str[1:], prev.Str)
+ prev.Str[0] = at.Ch
+ } else {
+ //insert at the front...this one we'll make a new slice and copy both into it
+ merge := make([]rune, len(prev.Str)+len(at.Str))
+ copy(merge, at.Str)
+ copy(merge[len(at.Str):], prev.Str)
+ prev.Str = merge
+ }
+ }
+ } else if at.T == NtEmpty {
+ j--
+ } else {
+ wasLastString = false
+ }
+ }
+
+ if j < i {
+ // remove indices j through i from the children
+ n.removeChildren(j, i)
+ }
+}
+
+// Nested repeaters just get multiplied with each other if they're not
+// too lumpy
+func (n *RegexNode) reduceRep() *RegexNode {
+
+ u := n
+ t := n.T
+ min := n.M
+ max := n.N
+
+ for len(u.Children) > 0 {
+ child := u.Children[0]
+
+ // multiply reps of the same type only
+ if child.T != t {
+ valid := false
+ if t == NtLoop {
+ switch child.T {
+ case NtOneloop, NtOneloopatomic, NtNotoneloop,
+ NtNotoneloopatomic, NtSetloop, NtSetloopatomic:
+ valid = true
+ }
+ } else {
+ switch child.T {
+ case NtOnelazy, NtNotonelazy, NtSetlazy:
+ valid = true
+ }
+ }
+ if !valid {
+ break
+ }
+ }
+
+ // child can be too lumpy to blur, e.g., (a {100,105}) {3} or (a {2,})?
+ // [but things like (a {2,})+ are not too lumpy...]
+ if u.M == 0 && child.M > 1 || maxLessThanTwiceMin(child.N, child.M) {
+ break
+ }
+
+ u = child
+ if u.M > 0 {
+ if (math.MaxInt32-1)/u.M < min {
+ u.M = math.MaxInt32
+ } else {
+ u.M *= min
+ }
+ }
+ if u.N > 0 {
+ if (math.MaxInt32-1)/u.N < max {
+ u.N = math.MaxInt32
+ } else {
+ u.N *= max
+ }
+ }
+ }
+
+ if min == math.MaxInt32 {
+ return newRegexNode(NtNothing, n.Options)
+ }
+
+ // If the Loop or Lazyloop now only has one child node and its a Set, One, or Notone,
+ // reduce to just Setloop/lazy, Oneloop/lazy, or Notoneloop/lazy. The parser will
+ // generally have only produced the latter, but other reductions could have exposed
+ // this.
+ if len(u.Children) == 1 {
+ child := u.Children[0]
+ switch child.T {
+ case NtOne, NtNotone, NtSet:
+ if u.T == NtLazyloop {
+ child.makeRep(NtOnelazy, u.M, u.N)
+ } else {
+ child.makeRep(NtOneloop, u.M, u.N)
+ }
+ u = child
+ }
+ }
+
+ return u
+
+}
+
+// Simple optimization. If a concatenation or alternation has only
+// one child strip out the intermediate node. If it has zero children,
+// turn it into an empty.
+func (n *RegexNode) replaceNodeIfUnnecessary() *RegexNode {
+ switch len(n.Children) {
+ case 0:
+ emptyType := NtEmpty
+ if n.T == NtAlternate {
+ emptyType = NtNothing
+ }
+ return newRegexNode(emptyType, n.Options)
+ case 1:
+ return n.Children[0]
+ default:
+ return n
+ }
+}
+
+func (n *RegexNode) reduceGroup() *RegexNode {
+ u := n
+
+ for u.T == NtGroup {
+ u = u.Children[0]
+ }
+
+ return u
+}
+
+// Simple optimization. If a set is a singleton, an inverse singleton,
+// or empty, it's transformed accordingly.
+func (n *RegexNode) reduceSet() *RegexNode {
+ // Extract empty-set, one and not-one case as special
+
+ if n.Set == nil {
+ n.T = NtNothing
+ } else if n.Set.IsSingleton() {
+ n.Ch = n.Set.SingletonChar()
+ n.Set = nil
+ n.T += (NtOne - NtSet)
+ } else if n.Set.IsSingletonInverse() {
+ n.Ch = n.Set.SingletonChar()
+ n.Set = nil
+ n.T += (NtNotone - NtSet)
+ }
+
+ return n
+}
+
+func (n *RegexNode) reverseLeft() *RegexNode {
+ if n.Options&RightToLeft != 0 && n.T == NtConcatenate && len(n.Children) > 0 {
+ //reverse children order
+ for left, right := 0, len(n.Children)-1; left < right; left, right = left+1, right-1 {
+ n.Children[left], n.Children[right] = n.Children[right], n.Children[left]
+ }
+ }
+
+ return n
+}
+
+func (n *RegexNode) makeQuantifier(lazy bool, min, max int) *RegexNode {
+ // Certain cases of repeaters (min == max) can be handled specially
+ if min == 0 && max == 0 {
+ // The node is repeated 0 times, so it's actually empty.
+ return newRegexNode(NtEmpty, n.Options)
+ }
+
+ if min == 1 && max == 1 {
+ // The node is repeated 1 time, so it's not actually a repeater.
+ return n
+ }
+
+ if min == max && max <= MultiVsRepeaterLimit && n.T == NtOne {
+ // The same character is repeated a fixed number of times, so it's actually a multi.
+ // While this could remain a repeater, multis are more readily optimized later in
+ // processing. The counts used here in real-world expressions are invariably small (e.g. 4),
+ // but we set an upper bound just to avoid creating really large strings.
+ n.T = NtMulti
+ n.Str = []rune(strings.Repeat(string(n.Ch), max))
+ n.Ch = 0
+ return n
+ }
+
+ switch n.T {
+ case NtOne, NtNotone, NtSet:
+ if lazy {
+ n.makeRep(NtOnelazy, min, max)
+ } else {
+ n.makeRep(NtOneloop, min, max)
+ }
+ return n
+
+ default:
+ var t NodeType
+ if lazy {
+ t = NtLazyloop
+ } else {
+ t = NtLoop
+ }
+ result := newRegexNodeMN(t, n.Options, min, max)
+ result.addChild(n)
+ return result
+ }
+}
+
+// Computes a min bound on the required length of any string that could possibly match.
+// If the result is 0, there is no minimum we can enforce.
+func (n *RegexNode) ComputeMinLength() int {
+ switch n.T {
+ case NtOne, NtNotone, NtSet:
+ // single char
+ return 1
+ case NtMulti:
+ // Every character in the string needs to match.
+ return len(n.Str)
+ case NtNotonelazy, NtNotoneloop, NtNotoneloopatomic,
+ NtOnelazy, NtOneloop, NtOneloopatomic, NtSetlazy, NtSetloop, NtSetloopatomic:
+ // One character repeated at least M times.
+ return n.M
+ case NtLazyloop, NtLoop:
+ // A node graph repeated at least M times.
+ return multiplyMinLength(n.M, n.Children[0].ComputeMinLength())
+ case NtAlternate:
+ // The minimum required length for any of the alternation's branches.
+ childCount := len(n.Children)
+ min := n.Children[0].ComputeMinLength()
+ for i := 1; i < childCount && min > 0; i++ {
+ newMin := n.Children[i].ComputeMinLength()
+ if newMin < min {
+ min = newMin
+ }
+ }
+ return min
+ case NtBackRefCond:
+ // Minimum of its yes and no branches. The backreference doesn't add to the length.
+ b1 := n.Children[0].ComputeMinLength()
+ if len(n.Children) == 1 {
+ return b1
+ }
+ b2 := n.Children[1].ComputeMinLength()
+ if b1 < b2 {
+ return b1
+ }
+ return b2
+ case NtExprCond:
+ // Minimum of its yes and no branches. The condition is a zero-width assertion.
+ if len(n.Children) == 2 {
+ return n.Children[1].ComputeMinLength()
+ }
+ b1 := n.Children[1].ComputeMinLength()
+ b2 := n.Children[2].ComputeMinLength()
+ if b1 < b2 {
+ return b1
+ }
+ return b2
+ case NtConcatenate:
+ // The sum of all of the concatenation's children.
+ sum := 0
+ for i := 0; i < len(n.Children); i++ {
+ sum = addMinLength(sum, n.Children[i].ComputeMinLength())
+ }
+ return sum
+ case NtAtomic, NtCapture, NtGroup:
+ // For groups, we just delegate to the sole child.
+ return n.Children[0].ComputeMinLength()
+ case NtEmpty, NtNothing,
+ NtBeginning, NtBol, NtBoundary, NtECMABoundary, NtEnd, NtEndZ, NtEol,
+ NtNonboundary, NtNonECMABoundary, NtStart, NtNegLook, NtPosLook, NtRef:
+ // Nothing to match. In the future, we could potentially use Nothing to say that the min length
+ // is infinite, but that would require a different structure, as that would only apply if the
+ // Nothing match is required in all cases (rather than, say, as one branch of an alternation).
+ }
+ return 0
+}
+
+// Computes a maximum length of any string that could possibly match.
+// or -1 if the length may not always be the same.
+func (n *RegexNode) computeMaxLength() int {
+ switch n.T {
+ case NtOne, NtNotone, NtSet:
+ return 1
+ case NtMulti:
+ return len(n.Str)
+ case NtNotonelazy, NtNotoneloop, NtNotoneloopatomic,
+ NtOnelazy, NtOneloop, NtOneloopatomic,
+ NtSetlazy, NtSetloop, NtSetloopatomic:
+ // Return the max number of iterations if there's an upper bound, or null if it's infinite
+ if n.N == math.MaxInt32 {
+ return -1
+ }
+ return n.N
+ case NtLazyloop, NtLoop:
+ if n.N == math.MaxInt32 {
+ return -1
+ }
+ // A node graph repeated a fixed number of times
+ if c := n.Children[0].computeMaxLength(); c >= 0 {
+ return multiplyMaxLength(n.N, c)
+ }
+ case NtAlternate:
+ // The maximum length of any child branch, as long as they all have one.
+ c := n.Children[0].computeMaxLength()
+
+ if c < 0 {
+ return -1
+ }
+ for i := 1; i < len(n.Children); i++ {
+ c2 := n.Children[i].computeMaxLength()
+ if c2 < 0 {
+ return -1
+ }
+
+ c = max(c, c2)
+ }
+ return c
+ case NtBackRefCond:
+ // The maximum length of either child branch, as long as they both have one.
+ b1 := n.Children[0].computeMaxLength()
+ if b1 < 0 {
+ return -1
+ }
+ b2 := n.Children[1].computeMaxLength()
+ if b2 < 0 {
+ return -1
+ }
+ return max(b1, b2)
+
+ case NtExprCond:
+ // The condition for an expression conditional is a zero-width assertion.
+ b1 := n.Children[1].computeMaxLength()
+ if b1 < 0 {
+ return -1
+ }
+ b2 := n.Children[2].computeMaxLength()
+ if b2 < 0 {
+ return -1
+ }
+ return max(b1, b2)
+
+ case NtConcatenate:
+ // The sum of all of the concatenation's children's max lengths, as long as they all have one.
+ sum := 0
+ for i := 0; i < len(n.Children); i++ {
+ c := n.Children[i].computeMaxLength()
+ if c < 0 {
+ return -1
+ }
+ sum = addMaxLength(sum, c)
+ if sum < 0 {
+ return -1
+ }
+ }
+ return sum
+
+ case NtAtomic, NtCapture:
+ // For groups, we just delegate to the sole child.
+ return n.Children[0].computeMaxLength()
+ case NtEmpty, NtNothing, NtUpdateBumpalong,
+ NtBeginning, NtBol, NtBoundary, NtECMABoundary, NtEnd, NtEndZ, NtEol,
+ NtNonboundary, NtNonECMABoundary, NtStart, NtNegLook, NtPosLook:
+ //zero-width
+ return 0
+
+ case NtRef:
+ // Requires matching data available only at run-time. In the future, we could choose to find
+ // and follow the capture group this aligns with, while being careful not to end up in an
+ // infinite cycle.
+ return -1
+ }
+
+ return -1
+}
+
+// debug functions
+
+var typeStr = []string{
+ "Onerep", "Notonerep", "Setrep",
+ "Oneloop", "Notoneloop", "Setloop",
+ "Onelazy", "Notonelazy", "Setlazy",
+ "One", "Notone", "Set",
+ "Multi", "Ref",
+ "Bol", "Eol", "Boundary", "Nonboundary",
+ "Beginning", "Start", "EndZ", "End",
+ "Nothing", "Empty",
+ "Alternate", "Concatenate",
+ "Loop", "Lazyloop",
+ "Capture", "Group", "PosLook", "NegLook", "Atomic",
+ "BackRefCond", "ExprCond",
+ "Unknown", "Unknown", "Unknown",
+ "Unknown", "Unknown", "Unknown",
+ "ECMABoundary", "NonECMABoundary",
+ "OneloopAtomic", "NotoneloopAtomic", "SetloopAtomic",
+ "UpdateBumpalong",
+}
+
+func (n *RegexNode) Description() string {
+ buf := &bytes.Buffer{}
+
+ buf.WriteString(typeStr[n.T])
+
+ if (n.Options & ExplicitCapture) != 0 {
+ buf.WriteString("-C")
+ }
+ if (n.Options & IgnoreCase) != 0 {
+ buf.WriteString("-I")
+ }
+ if (n.Options & RightToLeft) != 0 {
+ buf.WriteString("-L")
+ }
+ if (n.Options & Multiline) != 0 {
+ buf.WriteString("-M")
+ }
+ if (n.Options & Singleline) != 0 {
+ buf.WriteString("-S")
+ }
+ if (n.Options & IgnorePatternWhitespace) != 0 {
+ buf.WriteString("-X")
+ }
+ if (n.Options & ECMAScript) != 0 {
+ buf.WriteString("-E")
+ }
+
+ switch n.T {
+ case NtOneloop, NtOneloopatomic, NtNotoneloop, NtOnelazy, NtNotonelazy, NtOne, NtNotone, NtNotoneloopatomic:
+ buf.WriteString("(Ch = " + CharDescription(n.Ch) + ")")
+ case NtCapture:
+ buf.WriteString("(index = " + strconv.Itoa(n.M) + ", unindex = " + strconv.Itoa(n.N) + ")")
+ case NtRef, NtBackRefCond:
+ buf.WriteString("(index = " + strconv.Itoa(n.M) + ")")
+ case NtMulti:
+ fmt.Fprintf(buf, "(String = %#v)", string(n.Str))
+ case NtSet, NtSetloop, NtSetlazy, NtSetloopatomic:
+ buf.WriteString("(Set = " + n.Set.String() + ")")
+ }
+
+ switch n.T {
+ case NtOneloop, NtNotoneloop, NtOnelazy, NtNotonelazy, NtSetloop, NtSetlazy, NtLoop, NtLazyloop,
+ NtOneloopatomic, NtNotoneloopatomic, NtSetloopatomic:
+
+ buf.WriteString("(Min = ")
+ buf.WriteString(strconv.Itoa(n.M))
+ buf.WriteString(", Max = ")
+ if n.N == math.MaxInt32 {
+ buf.WriteString("inf")
+ } else {
+ buf.WriteString(strconv.Itoa(n.N))
+ }
+ buf.WriteString(")")
+ }
+
+ return buf.String()
+}
+
+var padSpace = []byte(" ")
+
+func (t *RegexTree) Dump() string {
+ return t.Root.dump()
+}
+
+func (n *RegexNode) dump() string {
+ var stack []int
+ CurNode := n
+ CurChild := 0
+
+ buf := bytes.NewBufferString(CurNode.Description())
+ buf.WriteRune('\n')
+
+ for {
+ if CurNode.Children != nil && CurChild < len(CurNode.Children) {
+ stack = append(stack, CurChild+1)
+ CurNode = CurNode.Children[CurChild]
+ CurChild = 0
+
+ Depth := len(stack)
+ if Depth > 32 {
+ Depth = 32
+ }
+ buf.Write(padSpace[:Depth])
+ buf.WriteString(CurNode.Description())
+ buf.WriteRune('\n')
+ } else {
+ if len(stack) == 0 {
+ break
+ }
+
+ CurChild = stack[len(stack)-1]
+ stack = stack[:len(stack)-1]
+ CurNode = CurNode.Parent
+ }
+ }
+ return buf.String()
+}
+
+// Determines whether the specified child index of a concatenation begins a sequence whose values
+// should be used to perform an ordinal case-insensitive comparison.
+//
+// When consumeZeroWidthNodes is false, the consumer needs the semantics of matching the produced string to fully represent
+// the semantics of all the consumed nodes, which means nodes can be consumed iff they produce text that's represented
+// by the resulting string. When true, the resulting string needs to fully represent all valid matches at that position,
+// but it can have false positives, which means the resulting string doesn't need to fully represent all zero-width nodes
+// consumed. true is only valid when used as part of a search to determine where to try a full match, not as part of
+// actual matching logic.
+// consumeZeroWidthNodes = false
+func (n *RegexNode) TryGetOrdinalCaseInsensitiveString(childIndex int, exclusiveChildBound int, consumeZeroWidthNodes bool) (success bool, nodesConsumed int, caseInsensitiveString string) {
+ vsb := &strings.Builder{}
+
+ // We're looking in particular for sets of ASCII characters, so we focus only on sets with two characters in them, e.g. [Aa].
+ //twoChars := make([]rune, 0, 2)
+
+ // Iterate from the child index to the exclusive upper bound.
+ var i int
+ for i = childIndex; i < exclusiveChildBound; i++ {
+ child := n.Children[i]
+
+ if child.T == NtOne {
+ // We only want to include ASCII characters, and only if they don't participate in case conversion
+ // such that they only case to themselves and nothing other cases to them. Otherwise, including
+ // them would potentially cause us to match against things not allowed by the pattern.
+ if child.Ch >= unicode.MaxASCII || participatesInCaseConversion(child.Ch) {
+ break
+ }
+
+ vsb.WriteRune(child.Ch)
+ } else if child.T == NtMulti {
+ // As with NtOne, the string needs to be composed solely of ASCII characters that
+ // don't participate in case conversion.
+ hasNonAscii := slices.ContainsFunc(child.Str, func(ch rune) bool { return ch > unicode.MaxASCII })
+ if hasNonAscii || anyParticipatesInCaseConversion(string(child.Str)) {
+ break
+ }
+
+ vsb.WriteString(string(child.Str))
+ } else if child.T == NtSet ||
+ ((child.T == NtSetloop || child.T == NtSetlazy || child.T == NtSetloopatomic) && child.M == child.N) {
+ // In particular we want to look for sets that contain only the upper and lowercase variant
+ // of the same ASCII letter.
+ ok, twoChars := child.Set.containsAsciiIgnoreCaseCharacter()
+ if !ok {
+ break
+ }
+
+ count := child.M
+ if child.T == NtSet {
+ count = 1
+ }
+ vsb.WriteString(strings.Repeat(string(twoChars[0]|0x20), count))
+ } else if child.T == NtEmpty {
+ // Skip over empty nodes, as they're pure nops. They would ideally have been optimized away,
+ // but can still remain in some situations.
+ } else if consumeZeroWidthNodes &&
+ // anchors
+ (child.T == NtBeginning || child.T == NtBol || child.T == NtStart ||
+ // boundaries
+ child.T == NtBoundary || child.T == NtECMABoundary || child.T == NtNonboundary || child.T == NtNonECMABoundary ||
+ // lookarounds
+ child.T == NtNegLook || child.T == NtPosLook ||
+ // logic
+ child.T == NtUpdateBumpalong) {
+ // Skip over zero-width nodes that might be reasonable at the beginning of or within a substring.
+ // We can only do these if consumeZeroWidthNodes is true, as otherwise we'd be producing a string that
+ // may not fully represent the semantics of this portion of the pattern.
+ } else {
+ break
+ }
+ }
+
+ // If we found at least two characters, consider it a sequence found. It's possible
+ // they all came from the same node, so this could be a sequence of just one node.
+ if vsb.Len() >= 2 {
+ return true, i - childIndex, vsb.String()
+ }
+
+ // No sequence found.
+ return false, 0, ""
+}
+
+func (child *RegexNode) canJoinLengthCheck() bool {
+ if child.T == NtOne || child.T == NtNotone || child.T == NtSet || child.T == NtMulti {
+ return true
+ }
+ if (child.IsSetloopFamily() || child.IsNotoneloopFamily() || child.IsOneloopFamily()) &&
+ child.M == child.N {
+ return true
+ }
+
+ return false
+}
+
+// Determine whether the specified child node is the beginning of a sequence that can
+// trivially have length checks combined in order to avoid bounds checks.
+// requiredLength is The sum of all the fixed lengths for the nodes in the sequence.
+// exclusiveEnd is The index of the node just after the last one in the sequence.
+// returns true if more than one node can have their length checks combined; otherwise, false.
+//
+// There are additional node types for which we can prove a fixed length, e.g. examining all branches
+// of an alternation and returning true if all their lengths are equal. However, the primary purpose
+// of this method is to avoid bounds checks by consolidating length checks that guard accesses to
+// strings/spans for which the JIT can see a fixed index within bounds, and alternations employ
+// patterns that defeat that (e.g. reassigning the span in question). As such, the implementation
+// remains focused on only a core subset of nodes that are a) likely to be used in concatenations and
+// b) employ simple patterns of checks.
+func (n *RegexNode) TryGetJoinableLengthCheckChildRange(childIndex int, requiredLength *int, exclusiveEnd *int) bool {
+
+ child := n.Children[childIndex]
+ if child.canJoinLengthCheck() {
+ *requiredLength = child.ComputeMinLength()
+
+ for *exclusiveEnd = childIndex + 1; *exclusiveEnd < len(n.Children); *exclusiveEnd++ {
+ child = n.Children[*exclusiveEnd]
+ if !child.canJoinLengthCheck() {
+ break
+ }
+
+ *requiredLength += child.ComputeMinLength()
+ }
+
+ if *exclusiveEnd-childIndex > 1 {
+ return true
+ }
+ }
+
+ *requiredLength = 0
+ *exclusiveEnd = 0
+ return false
+}
+
+type StartingLiteral struct {
+ Range SingleRange
+ String []rune
+ SetChars []rune
+ Negated bool
+}
+
+func (n *RegexNode) FindStartingLiteral() *StartingLiteral {
+ node := n.FindStartingLiteralNode(true)
+ if node == nil {
+ return nil
+ }
+
+ if node.IsOneFamily() {
+ return &StartingLiteral{Range: SingleRange{node.Ch, node.Ch}, Negated: false}
+ }
+ if node.IsNotoneFamily() {
+ return &StartingLiteral{Range: SingleRange{node.Ch, node.Ch}, Negated: true}
+ }
+ if node.IsSetFamily() {
+ ranges := node.Set.GetIfNRanges(1)
+ if len(ranges) == 1 && ranges[0].Last-ranges[0].First > 1 {
+ return &StartingLiteral{Range: ranges[0], Negated: node.Set.IsNegated()}
+ }
+ setChars := node.Set.GetSetChars(128)
+ if len(setChars) > 0 {
+ return &StartingLiteral{SetChars: setChars, Negated: node.Set.IsNegated()}
+ }
+ }
+ if node.T == NtMulti {
+ return &StartingLiteral{String: node.Str}
+ }
+
+ return nil
+}
+
+// Finds the guaranteed beginning literal(s) of the node, or null if none exists.
+// allowZeroWidth = true
+func (n *RegexNode) FindStartingLiteralNode(allowZeroWidth bool) *RegexNode {
+ node := n
+ for {
+ if node != nil && node.Options&RightToLeft == 0 {
+ switch node.T {
+ case NtOne, NtNotone, NtMulti, NtSet:
+ return node
+
+ case NtOneloop, NtOneloopatomic, NtOnelazy,
+ NtNotoneloop, NtNotoneloopatomic, NtNotonelazy,
+ NtSetloop, NtSetloopatomic, NtSetlazy:
+ if node.M > 0 {
+ return node
+ }
+
+ case NtAtomic, NtConcatenate, NtCapture, NtGroup:
+ node = node.Children[0]
+ continue
+ case NtLoop, NtLazyloop:
+ node = node.Children[0]
+ continue
+ case NtPosLook:
+ if allowZeroWidth {
+ node = node.Children[0]
+ continue
+ }
+ }
+ }
+
+ return nil
+ }
+}
+
+// Gets the character that begins a One or Multi.
+func (n *RegexNode) FirstCharOfOneOrMulti() rune {
+ if n.IsOneFamily() {
+ return n.Ch
+ }
+ return n.Str[0]
+}
diff --git a/vendor/github.com/dlclark/regexp2/v2/syntax/unicode_alias_tables.go b/vendor/github.com/dlclark/regexp2/v2/syntax/unicode_alias_tables.go
new file mode 100644
index 0000000000..a165b57ea5
--- /dev/null
+++ b/vendor/github.com/dlclark/regexp2/v2/syntax/unicode_alias_tables.go
@@ -0,0 +1,6058 @@
+package syntax
+
+import "unicode"
+
+const unicodePropertyTableVersion = "17.0.0"
+const goUnicodeTableVersion = unicode.Version
+
+// Unicode property alias tables generated from Unicode 17.0.0 data.
+//
+// At generation time, the Go standard library Unicode tables used for scripts,
+// general categories, category aliases, and built-in properties are Unicode
+// 15.0.0 in the supported Go toolchain. These package-local tables
+// intentionally use Unicode 17.0.0 for commonly updated properties, especially Emoji and
+// Extended_Pictographic.
+//
+// Sources:
+// - PropertyAliases.txt
+// - PropertyValueAliases.txt
+// - DerivedCoreProperties.txt
+// - emoji/emoji-data.txt
+// - auxiliary/GraphemeBreakProperty.txt
+// - auxiliary/WordBreakProperty.txt
+// - auxiliary/SentenceBreakProperty.txt
+var unicodeAliasCategories = map[string]*unicode.RangeTable{
+ "Emoji": unicodeAliasEmoji,
+ "Emoji_Component": unicodeAliasEmoji_Component,
+ "Emoji_Modifier": unicodeAliasEmoji_Modifier,
+ "Emoji_Modifier_Base": unicodeAliasEmoji_Modifier_Base,
+ "Emoji_Presentation": unicodeAliasEmoji_Presentation,
+ "Extended_Pictographic": unicodeAliasExtended_Pictographic,
+ "Grapheme_Cluster_Break=CR": unicodeAliasGrapheme_Cluster_Break_CR,
+ "Grapheme_Cluster_Break=Control": unicodeAliasGrapheme_Cluster_Break_Control,
+ "Grapheme_Cluster_Break=Extend": unicodeAliasGrapheme_Cluster_Break_Extend,
+ "Grapheme_Cluster_Break=L": unicodeAliasGrapheme_Cluster_Break_L,
+ "Grapheme_Cluster_Break=LF": unicodeAliasGrapheme_Cluster_Break_LF,
+ "Grapheme_Cluster_Break=LV": unicodeAliasGrapheme_Cluster_Break_LV,
+ "Grapheme_Cluster_Break=LVT": unicodeAliasGrapheme_Cluster_Break_LVT,
+ "Grapheme_Cluster_Break=Prepend": unicodeAliasGrapheme_Cluster_Break_Prepend,
+ "Grapheme_Cluster_Break=Regional_Indicator": unicodeAliasGrapheme_Cluster_Break_Regional_Indicator,
+ "Grapheme_Cluster_Break=SpacingMark": unicodeAliasGrapheme_Cluster_Break_SpacingMark,
+ "Grapheme_Cluster_Break=T": unicodeAliasGrapheme_Cluster_Break_T,
+ "Grapheme_Cluster_Break=V": unicodeAliasGrapheme_Cluster_Break_V,
+ "Grapheme_Cluster_Break=ZWJ": unicodeAliasGrapheme_Cluster_Break_ZWJ,
+ "Math": unicodeAliasMath,
+ "Sentence_Break=ATerm": unicodeAliasSentence_Break_ATerm,
+ "Sentence_Break=CR": unicodeAliasSentence_Break_CR,
+ "Sentence_Break=Close": unicodeAliasSentence_Break_Close,
+ "Sentence_Break=Extend": unicodeAliasSentence_Break_Extend,
+ "Sentence_Break=Format": unicodeAliasSentence_Break_Format,
+ "Sentence_Break=LF": unicodeAliasSentence_Break_LF,
+ "Sentence_Break=Lower": unicodeAliasSentence_Break_Lower,
+ "Sentence_Break=Numeric": unicodeAliasSentence_Break_Numeric,
+ "Sentence_Break=OLetter": unicodeAliasSentence_Break_OLetter,
+ "Sentence_Break=SContinue": unicodeAliasSentence_Break_SContinue,
+ "Sentence_Break=STerm": unicodeAliasSentence_Break_STerm,
+ "Sentence_Break=Sep": unicodeAliasSentence_Break_Sep,
+ "Sentence_Break=Sp": unicodeAliasSentence_Break_Sp,
+ "Sentence_Break=Upper": unicodeAliasSentence_Break_Upper,
+ "Word_Break=ALetter": unicodeAliasWord_Break_ALetter,
+ "Word_Break=CR": unicodeAliasWord_Break_CR,
+ "Word_Break=Double_Quote": unicodeAliasWord_Break_Double_Quote,
+ "Word_Break=Extend": unicodeAliasWord_Break_Extend,
+ "Word_Break=ExtendNumLet": unicodeAliasWord_Break_ExtendNumLet,
+ "Word_Break=Format": unicodeAliasWord_Break_Format,
+ "Word_Break=Hebrew_Letter": unicodeAliasWord_Break_Hebrew_Letter,
+ "Word_Break=Katakana": unicodeAliasWord_Break_Katakana,
+ "Word_Break=LF": unicodeAliasWord_Break_LF,
+ "Word_Break=MidLetter": unicodeAliasWord_Break_MidLetter,
+ "Word_Break=MidNum": unicodeAliasWord_Break_MidNum,
+ "Word_Break=MidNumLet": unicodeAliasWord_Break_MidNumLet,
+ "Word_Break=Newline": unicodeAliasWord_Break_Newline,
+ "Word_Break=Numeric": unicodeAliasWord_Break_Numeric,
+ "Word_Break=Regional_Indicator": unicodeAliasWord_Break_Regional_Indicator,
+ "Word_Break=Single_Quote": unicodeAliasWord_Break_Single_Quote,
+ "Word_Break=WSegSpace": unicodeAliasWord_Break_WSegSpace,
+ "Word_Break=ZWJ": unicodeAliasWord_Break_ZWJ,
+}
+
+var unicodeSupportedPropertyAliases = map[string]string{
+ "ebase": "Emoji_Modifier_Base",
+ "ecomp": "Emoji_Component",
+ "emod": "Emoji_Modifier",
+ "emoji": "Emoji",
+ "emojicomponent": "Emoji_Component",
+ "emojimodifier": "Emoji_Modifier",
+ "emojimodifierbase": "Emoji_Modifier_Base",
+ "emojipresentation": "Emoji_Presentation",
+ "epres": "Emoji_Presentation",
+ "extendedpictographic": "Extended_Pictographic",
+ "extpict": "Extended_Pictographic",
+ "gcb": "Grapheme_Cluster_Break",
+ "graphemeclusterbreak": "Grapheme_Cluster_Break",
+ "math": "Math",
+ "sb": "Sentence_Break",
+ "sentencebreak": "Sentence_Break",
+ "wb": "Word_Break",
+ "wordbreak": "Word_Break",
+}
+
+var unicodeSupportedPropertyValueAliases = map[string]map[string]string{
+ "Grapheme_Cluster_Break": {
+ "cn": "Control",
+ "control": "Control",
+ "cr": "CR",
+ "ex": "Extend",
+ "extend": "Extend",
+ "l": "L",
+ "lf": "LF",
+ "lv": "LV",
+ "lvt": "LVT",
+ "pp": "Prepend",
+ "prepend": "Prepend",
+ "regionalindicator": "Regional_Indicator",
+ "ri": "Regional_Indicator",
+ "sm": "SpacingMark",
+ "spacingmark": "SpacingMark",
+ "t": "T",
+ "v": "V",
+ "zwj": "ZWJ",
+ },
+ "Sentence_Break": {
+ "at": "ATerm",
+ "aterm": "ATerm",
+ "cl": "Close",
+ "close": "Close",
+ "cr": "CR",
+ "ex": "Extend",
+ "extend": "Extend",
+ "fo": "Format",
+ "format": "Format",
+ "le": "OLetter",
+ "lf": "LF",
+ "lo": "Lower",
+ "lower": "Lower",
+ "nu": "Numeric",
+ "numeric": "Numeric",
+ "oletter": "OLetter",
+ "sc": "SContinue",
+ "scontinue": "SContinue",
+ "se": "Sep",
+ "sep": "Sep",
+ "sp": "Sp",
+ "st": "STerm",
+ "sterm": "STerm",
+ "up": "Upper",
+ "upper": "Upper",
+ },
+ "Word_Break": {
+ "aletter": "ALetter",
+ "cr": "CR",
+ "doublequote": "Double_Quote",
+ "dq": "Double_Quote",
+ "ex": "ExtendNumLet",
+ "extend": "Extend",
+ "extendnumlet": "ExtendNumLet",
+ "fo": "Format",
+ "format": "Format",
+ "hebrewletter": "Hebrew_Letter",
+ "hl": "Hebrew_Letter",
+ "ka": "Katakana",
+ "katakana": "Katakana",
+ "le": "ALetter",
+ "lf": "LF",
+ "mb": "MidNumLet",
+ "midletter": "MidLetter",
+ "midnum": "MidNum",
+ "midnumlet": "MidNumLet",
+ "ml": "MidLetter",
+ "mn": "MidNum",
+ "newline": "Newline",
+ "nl": "Newline",
+ "nu": "Numeric",
+ "numeric": "Numeric",
+ "regionalindicator": "Regional_Indicator",
+ "ri": "Regional_Indicator",
+ "singlequote": "Single_Quote",
+ "sq": "Single_Quote",
+ "wsegspace": "WSegSpace",
+ "zwj": "ZWJ",
+ },
+}
+
+var unicodeBarePropertyValueAliases = map[string]string{
+ "extendnumlet": "Word_Break=ExtendNumLet",
+ "hebrewletter": "Word_Break=Hebrew_Letter",
+ "regionalindicator": "Grapheme_Cluster_Break=Regional_Indicator",
+ "ri": "Grapheme_Cluster_Break=Regional_Indicator",
+ "wsegspace": "Word_Break=WSegSpace",
+}
+
+var unicodeAliasEmoji = &unicode.RangeTable{
+ R16: []unicode.Range16{
+ {Lo: 0x23, Hi: 0x23, Stride: 1},
+ {Lo: 0x2A, Hi: 0x2A, Stride: 1},
+ {Lo: 0x30, Hi: 0x39, Stride: 1},
+ {Lo: 0xA9, Hi: 0xA9, Stride: 1},
+ {Lo: 0xAE, Hi: 0xAE, Stride: 1},
+ {Lo: 0x203C, Hi: 0x203C, Stride: 1},
+ {Lo: 0x2049, Hi: 0x2049, Stride: 1},
+ {Lo: 0x2122, Hi: 0x2122, Stride: 1},
+ {Lo: 0x2139, Hi: 0x2139, Stride: 1},
+ {Lo: 0x2194, Hi: 0x2199, Stride: 1},
+ {Lo: 0x21A9, Hi: 0x21AA, Stride: 1},
+ {Lo: 0x231A, Hi: 0x231B, Stride: 1},
+ {Lo: 0x2328, Hi: 0x2328, Stride: 1},
+ {Lo: 0x23CF, Hi: 0x23CF, Stride: 1},
+ {Lo: 0x23E9, Hi: 0x23F3, Stride: 1},
+ {Lo: 0x23F8, Hi: 0x23FA, Stride: 1},
+ {Lo: 0x24C2, Hi: 0x24C2, Stride: 1},
+ {Lo: 0x25AA, Hi: 0x25AB, Stride: 1},
+ {Lo: 0x25B6, Hi: 0x25B6, Stride: 1},
+ {Lo: 0x25C0, Hi: 0x25C0, Stride: 1},
+ {Lo: 0x25FB, Hi: 0x25FE, Stride: 1},
+ {Lo: 0x2600, Hi: 0x2604, Stride: 1},
+ {Lo: 0x260E, Hi: 0x260E, Stride: 1},
+ {Lo: 0x2611, Hi: 0x2611, Stride: 1},
+ {Lo: 0x2614, Hi: 0x2615, Stride: 1},
+ {Lo: 0x2618, Hi: 0x2618, Stride: 1},
+ {Lo: 0x261D, Hi: 0x261D, Stride: 1},
+ {Lo: 0x2620, Hi: 0x2620, Stride: 1},
+ {Lo: 0x2622, Hi: 0x2623, Stride: 1},
+ {Lo: 0x2626, Hi: 0x2626, Stride: 1},
+ {Lo: 0x262A, Hi: 0x262A, Stride: 1},
+ {Lo: 0x262E, Hi: 0x262F, Stride: 1},
+ {Lo: 0x2638, Hi: 0x263A, Stride: 1},
+ {Lo: 0x2640, Hi: 0x2640, Stride: 1},
+ {Lo: 0x2642, Hi: 0x2642, Stride: 1},
+ {Lo: 0x2648, Hi: 0x2653, Stride: 1},
+ {Lo: 0x265F, Hi: 0x2660, Stride: 1},
+ {Lo: 0x2663, Hi: 0x2663, Stride: 1},
+ {Lo: 0x2665, Hi: 0x2666, Stride: 1},
+ {Lo: 0x2668, Hi: 0x2668, Stride: 1},
+ {Lo: 0x267B, Hi: 0x267B, Stride: 1},
+ {Lo: 0x267E, Hi: 0x267F, Stride: 1},
+ {Lo: 0x2692, Hi: 0x2697, Stride: 1},
+ {Lo: 0x2699, Hi: 0x2699, Stride: 1},
+ {Lo: 0x269B, Hi: 0x269C, Stride: 1},
+ {Lo: 0x26A0, Hi: 0x26A1, Stride: 1},
+ {Lo: 0x26A7, Hi: 0x26A7, Stride: 1},
+ {Lo: 0x26AA, Hi: 0x26AB, Stride: 1},
+ {Lo: 0x26B0, Hi: 0x26B1, Stride: 1},
+ {Lo: 0x26BD, Hi: 0x26BE, Stride: 1},
+ {Lo: 0x26C4, Hi: 0x26C5, Stride: 1},
+ {Lo: 0x26C8, Hi: 0x26C8, Stride: 1},
+ {Lo: 0x26CE, Hi: 0x26CF, Stride: 1},
+ {Lo: 0x26D1, Hi: 0x26D1, Stride: 1},
+ {Lo: 0x26D3, Hi: 0x26D4, Stride: 1},
+ {Lo: 0x26E9, Hi: 0x26EA, Stride: 1},
+ {Lo: 0x26F0, Hi: 0x26F5, Stride: 1},
+ {Lo: 0x26F7, Hi: 0x26FA, Stride: 1},
+ {Lo: 0x26FD, Hi: 0x26FD, Stride: 1},
+ {Lo: 0x2702, Hi: 0x2702, Stride: 1},
+ {Lo: 0x2705, Hi: 0x2705, Stride: 1},
+ {Lo: 0x2708, Hi: 0x270D, Stride: 1},
+ {Lo: 0x270F, Hi: 0x270F, Stride: 1},
+ {Lo: 0x2712, Hi: 0x2712, Stride: 1},
+ {Lo: 0x2714, Hi: 0x2714, Stride: 1},
+ {Lo: 0x2716, Hi: 0x2716, Stride: 1},
+ {Lo: 0x271D, Hi: 0x271D, Stride: 1},
+ {Lo: 0x2721, Hi: 0x2721, Stride: 1},
+ {Lo: 0x2728, Hi: 0x2728, Stride: 1},
+ {Lo: 0x2733, Hi: 0x2734, Stride: 1},
+ {Lo: 0x2744, Hi: 0x2744, Stride: 1},
+ {Lo: 0x2747, Hi: 0x2747, Stride: 1},
+ {Lo: 0x274C, Hi: 0x274C, Stride: 1},
+ {Lo: 0x274E, Hi: 0x274E, Stride: 1},
+ {Lo: 0x2753, Hi: 0x2755, Stride: 1},
+ {Lo: 0x2757, Hi: 0x2757, Stride: 1},
+ {Lo: 0x2763, Hi: 0x2764, Stride: 1},
+ {Lo: 0x2795, Hi: 0x2797, Stride: 1},
+ {Lo: 0x27A1, Hi: 0x27A1, Stride: 1},
+ {Lo: 0x27B0, Hi: 0x27B0, Stride: 1},
+ {Lo: 0x27BF, Hi: 0x27BF, Stride: 1},
+ {Lo: 0x2934, Hi: 0x2935, Stride: 1},
+ {Lo: 0x2B05, Hi: 0x2B07, Stride: 1},
+ {Lo: 0x2B1B, Hi: 0x2B1C, Stride: 1},
+ {Lo: 0x2B50, Hi: 0x2B50, Stride: 1},
+ {Lo: 0x2B55, Hi: 0x2B55, Stride: 1},
+ {Lo: 0x3030, Hi: 0x3030, Stride: 1},
+ {Lo: 0x303D, Hi: 0x303D, Stride: 1},
+ {Lo: 0x3297, Hi: 0x3297, Stride: 1},
+ {Lo: 0x3299, Hi: 0x3299, Stride: 1},
+ },
+ R32: []unicode.Range32{
+ {Lo: 0x1F004, Hi: 0x1F004, Stride: 1},
+ {Lo: 0x1F0CF, Hi: 0x1F0CF, Stride: 1},
+ {Lo: 0x1F170, Hi: 0x1F171, Stride: 1},
+ {Lo: 0x1F17E, Hi: 0x1F17F, Stride: 1},
+ {Lo: 0x1F18E, Hi: 0x1F18E, Stride: 1},
+ {Lo: 0x1F191, Hi: 0x1F19A, Stride: 1},
+ {Lo: 0x1F1E6, Hi: 0x1F1FF, Stride: 1},
+ {Lo: 0x1F201, Hi: 0x1F202, Stride: 1},
+ {Lo: 0x1F21A, Hi: 0x1F21A, Stride: 1},
+ {Lo: 0x1F22F, Hi: 0x1F22F, Stride: 1},
+ {Lo: 0x1F232, Hi: 0x1F23A, Stride: 1},
+ {Lo: 0x1F250, Hi: 0x1F251, Stride: 1},
+ {Lo: 0x1F300, Hi: 0x1F321, Stride: 1},
+ {Lo: 0x1F324, Hi: 0x1F393, Stride: 1},
+ {Lo: 0x1F396, Hi: 0x1F397, Stride: 1},
+ {Lo: 0x1F399, Hi: 0x1F39B, Stride: 1},
+ {Lo: 0x1F39E, Hi: 0x1F3F0, Stride: 1},
+ {Lo: 0x1F3F3, Hi: 0x1F3F5, Stride: 1},
+ {Lo: 0x1F3F7, Hi: 0x1F4FD, Stride: 1},
+ {Lo: 0x1F4FF, Hi: 0x1F53D, Stride: 1},
+ {Lo: 0x1F549, Hi: 0x1F54E, Stride: 1},
+ {Lo: 0x1F550, Hi: 0x1F567, Stride: 1},
+ {Lo: 0x1F56F, Hi: 0x1F570, Stride: 1},
+ {Lo: 0x1F573, Hi: 0x1F57A, Stride: 1},
+ {Lo: 0x1F587, Hi: 0x1F587, Stride: 1},
+ {Lo: 0x1F58A, Hi: 0x1F58D, Stride: 1},
+ {Lo: 0x1F590, Hi: 0x1F590, Stride: 1},
+ {Lo: 0x1F595, Hi: 0x1F596, Stride: 1},
+ {Lo: 0x1F5A4, Hi: 0x1F5A5, Stride: 1},
+ {Lo: 0x1F5A8, Hi: 0x1F5A8, Stride: 1},
+ {Lo: 0x1F5B1, Hi: 0x1F5B2, Stride: 1},
+ {Lo: 0x1F5BC, Hi: 0x1F5BC, Stride: 1},
+ {Lo: 0x1F5C2, Hi: 0x1F5C4, Stride: 1},
+ {Lo: 0x1F5D1, Hi: 0x1F5D3, Stride: 1},
+ {Lo: 0x1F5DC, Hi: 0x1F5DE, Stride: 1},
+ {Lo: 0x1F5E1, Hi: 0x1F5E1, Stride: 1},
+ {Lo: 0x1F5E3, Hi: 0x1F5E3, Stride: 1},
+ {Lo: 0x1F5E8, Hi: 0x1F5E8, Stride: 1},
+ {Lo: 0x1F5EF, Hi: 0x1F5EF, Stride: 1},
+ {Lo: 0x1F5F3, Hi: 0x1F5F3, Stride: 1},
+ {Lo: 0x1F5FA, Hi: 0x1F64F, Stride: 1},
+ {Lo: 0x1F680, Hi: 0x1F6C5, Stride: 1},
+ {Lo: 0x1F6CB, Hi: 0x1F6D2, Stride: 1},
+ {Lo: 0x1F6D5, Hi: 0x1F6D8, Stride: 1},
+ {Lo: 0x1F6DC, Hi: 0x1F6E5, Stride: 1},
+ {Lo: 0x1F6E9, Hi: 0x1F6E9, Stride: 1},
+ {Lo: 0x1F6EB, Hi: 0x1F6EC, Stride: 1},
+ {Lo: 0x1F6F0, Hi: 0x1F6F0, Stride: 1},
+ {Lo: 0x1F6F3, Hi: 0x1F6FC, Stride: 1},
+ {Lo: 0x1F7E0, Hi: 0x1F7EB, Stride: 1},
+ {Lo: 0x1F7F0, Hi: 0x1F7F0, Stride: 1},
+ {Lo: 0x1F90C, Hi: 0x1F93A, Stride: 1},
+ {Lo: 0x1F93C, Hi: 0x1F945, Stride: 1},
+ {Lo: 0x1F947, Hi: 0x1F9FF, Stride: 1},
+ {Lo: 0x1FA70, Hi: 0x1FA7C, Stride: 1},
+ {Lo: 0x1FA80, Hi: 0x1FA8A, Stride: 1},
+ {Lo: 0x1FA8E, Hi: 0x1FAC6, Stride: 1},
+ {Lo: 0x1FAC8, Hi: 0x1FAC8, Stride: 1},
+ {Lo: 0x1FACD, Hi: 0x1FADC, Stride: 1},
+ {Lo: 0x1FADF, Hi: 0x1FAEA, Stride: 1},
+ {Lo: 0x1FAEF, Hi: 0x1FAF8, Stride: 1},
+ },
+}
+
+var unicodeAliasEmoji_Component = &unicode.RangeTable{
+ R16: []unicode.Range16{
+ {Lo: 0x23, Hi: 0x23, Stride: 1},
+ {Lo: 0x2A, Hi: 0x2A, Stride: 1},
+ {Lo: 0x30, Hi: 0x39, Stride: 1},
+ {Lo: 0x200D, Hi: 0x200D, Stride: 1},
+ {Lo: 0x20E3, Hi: 0x20E3, Stride: 1},
+ {Lo: 0xFE0F, Hi: 0xFE0F, Stride: 1},
+ },
+ R32: []unicode.Range32{
+ {Lo: 0x1F1E6, Hi: 0x1F1FF, Stride: 1},
+ {Lo: 0x1F3FB, Hi: 0x1F3FF, Stride: 1},
+ {Lo: 0x1F9B0, Hi: 0x1F9B3, Stride: 1},
+ {Lo: 0xE0020, Hi: 0xE007F, Stride: 1},
+ },
+}
+
+var unicodeAliasEmoji_Modifier = &unicode.RangeTable{
+ R32: []unicode.Range32{
+ {Lo: 0x1F3FB, Hi: 0x1F3FF, Stride: 1},
+ },
+}
+
+var unicodeAliasEmoji_Modifier_Base = &unicode.RangeTable{
+ R16: []unicode.Range16{
+ {Lo: 0x261D, Hi: 0x261D, Stride: 1},
+ {Lo: 0x26F9, Hi: 0x26F9, Stride: 1},
+ {Lo: 0x270A, Hi: 0x270D, Stride: 1},
+ },
+ R32: []unicode.Range32{
+ {Lo: 0x1F385, Hi: 0x1F385, Stride: 1},
+ {Lo: 0x1F3C2, Hi: 0x1F3C4, Stride: 1},
+ {Lo: 0x1F3C7, Hi: 0x1F3C7, Stride: 1},
+ {Lo: 0x1F3CA, Hi: 0x1F3CC, Stride: 1},
+ {Lo: 0x1F442, Hi: 0x1F443, Stride: 1},
+ {Lo: 0x1F446, Hi: 0x1F450, Stride: 1},
+ {Lo: 0x1F466, Hi: 0x1F478, Stride: 1},
+ {Lo: 0x1F47C, Hi: 0x1F47C, Stride: 1},
+ {Lo: 0x1F481, Hi: 0x1F483, Stride: 1},
+ {Lo: 0x1F485, Hi: 0x1F487, Stride: 1},
+ {Lo: 0x1F48F, Hi: 0x1F48F, Stride: 1},
+ {Lo: 0x1F491, Hi: 0x1F491, Stride: 1},
+ {Lo: 0x1F4AA, Hi: 0x1F4AA, Stride: 1},
+ {Lo: 0x1F574, Hi: 0x1F575, Stride: 1},
+ {Lo: 0x1F57A, Hi: 0x1F57A, Stride: 1},
+ {Lo: 0x1F590, Hi: 0x1F590, Stride: 1},
+ {Lo: 0x1F595, Hi: 0x1F596, Stride: 1},
+ {Lo: 0x1F645, Hi: 0x1F647, Stride: 1},
+ {Lo: 0x1F64B, Hi: 0x1F64F, Stride: 1},
+ {Lo: 0x1F6A3, Hi: 0x1F6A3, Stride: 1},
+ {Lo: 0x1F6B4, Hi: 0x1F6B6, Stride: 1},
+ {Lo: 0x1F6C0, Hi: 0x1F6C0, Stride: 1},
+ {Lo: 0x1F6CC, Hi: 0x1F6CC, Stride: 1},
+ {Lo: 0x1F90C, Hi: 0x1F90C, Stride: 1},
+ {Lo: 0x1F90F, Hi: 0x1F90F, Stride: 1},
+ {Lo: 0x1F918, Hi: 0x1F91F, Stride: 1},
+ {Lo: 0x1F926, Hi: 0x1F926, Stride: 1},
+ {Lo: 0x1F930, Hi: 0x1F939, Stride: 1},
+ {Lo: 0x1F93C, Hi: 0x1F93E, Stride: 1},
+ {Lo: 0x1F977, Hi: 0x1F977, Stride: 1},
+ {Lo: 0x1F9B5, Hi: 0x1F9B6, Stride: 1},
+ {Lo: 0x1F9B8, Hi: 0x1F9B9, Stride: 1},
+ {Lo: 0x1F9BB, Hi: 0x1F9BB, Stride: 1},
+ {Lo: 0x1F9CD, Hi: 0x1F9CF, Stride: 1},
+ {Lo: 0x1F9D1, Hi: 0x1F9DD, Stride: 1},
+ {Lo: 0x1FAC3, Hi: 0x1FAC5, Stride: 1},
+ {Lo: 0x1FAF0, Hi: 0x1FAF8, Stride: 1},
+ },
+}
+
+var unicodeAliasEmoji_Presentation = &unicode.RangeTable{
+ R16: []unicode.Range16{
+ {Lo: 0x231A, Hi: 0x231B, Stride: 1},
+ {Lo: 0x23E9, Hi: 0x23EC, Stride: 1},
+ {Lo: 0x23F0, Hi: 0x23F0, Stride: 1},
+ {Lo: 0x23F3, Hi: 0x23F3, Stride: 1},
+ {Lo: 0x25FD, Hi: 0x25FE, Stride: 1},
+ {Lo: 0x2614, Hi: 0x2615, Stride: 1},
+ {Lo: 0x2648, Hi: 0x2653, Stride: 1},
+ {Lo: 0x267F, Hi: 0x267F, Stride: 1},
+ {Lo: 0x2693, Hi: 0x2693, Stride: 1},
+ {Lo: 0x26A1, Hi: 0x26A1, Stride: 1},
+ {Lo: 0x26AA, Hi: 0x26AB, Stride: 1},
+ {Lo: 0x26BD, Hi: 0x26BE, Stride: 1},
+ {Lo: 0x26C4, Hi: 0x26C5, Stride: 1},
+ {Lo: 0x26CE, Hi: 0x26CE, Stride: 1},
+ {Lo: 0x26D4, Hi: 0x26D4, Stride: 1},
+ {Lo: 0x26EA, Hi: 0x26EA, Stride: 1},
+ {Lo: 0x26F2, Hi: 0x26F3, Stride: 1},
+ {Lo: 0x26F5, Hi: 0x26F5, Stride: 1},
+ {Lo: 0x26FA, Hi: 0x26FA, Stride: 1},
+ {Lo: 0x26FD, Hi: 0x26FD, Stride: 1},
+ {Lo: 0x2705, Hi: 0x2705, Stride: 1},
+ {Lo: 0x270A, Hi: 0x270B, Stride: 1},
+ {Lo: 0x2728, Hi: 0x2728, Stride: 1},
+ {Lo: 0x274C, Hi: 0x274C, Stride: 1},
+ {Lo: 0x274E, Hi: 0x274E, Stride: 1},
+ {Lo: 0x2753, Hi: 0x2755, Stride: 1},
+ {Lo: 0x2757, Hi: 0x2757, Stride: 1},
+ {Lo: 0x2795, Hi: 0x2797, Stride: 1},
+ {Lo: 0x27B0, Hi: 0x27B0, Stride: 1},
+ {Lo: 0x27BF, Hi: 0x27BF, Stride: 1},
+ {Lo: 0x2B1B, Hi: 0x2B1C, Stride: 1},
+ {Lo: 0x2B50, Hi: 0x2B50, Stride: 1},
+ {Lo: 0x2B55, Hi: 0x2B55, Stride: 1},
+ },
+ R32: []unicode.Range32{
+ {Lo: 0x1F004, Hi: 0x1F004, Stride: 1},
+ {Lo: 0x1F0CF, Hi: 0x1F0CF, Stride: 1},
+ {Lo: 0x1F18E, Hi: 0x1F18E, Stride: 1},
+ {Lo: 0x1F191, Hi: 0x1F19A, Stride: 1},
+ {Lo: 0x1F1E6, Hi: 0x1F1FF, Stride: 1},
+ {Lo: 0x1F201, Hi: 0x1F201, Stride: 1},
+ {Lo: 0x1F21A, Hi: 0x1F21A, Stride: 1},
+ {Lo: 0x1F22F, Hi: 0x1F22F, Stride: 1},
+ {Lo: 0x1F232, Hi: 0x1F236, Stride: 1},
+ {Lo: 0x1F238, Hi: 0x1F23A, Stride: 1},
+ {Lo: 0x1F250, Hi: 0x1F251, Stride: 1},
+ {Lo: 0x1F300, Hi: 0x1F320, Stride: 1},
+ {Lo: 0x1F32D, Hi: 0x1F335, Stride: 1},
+ {Lo: 0x1F337, Hi: 0x1F37C, Stride: 1},
+ {Lo: 0x1F37E, Hi: 0x1F393, Stride: 1},
+ {Lo: 0x1F3A0, Hi: 0x1F3CA, Stride: 1},
+ {Lo: 0x1F3CF, Hi: 0x1F3D3, Stride: 1},
+ {Lo: 0x1F3E0, Hi: 0x1F3F0, Stride: 1},
+ {Lo: 0x1F3F4, Hi: 0x1F3F4, Stride: 1},
+ {Lo: 0x1F3F8, Hi: 0x1F43E, Stride: 1},
+ {Lo: 0x1F440, Hi: 0x1F440, Stride: 1},
+ {Lo: 0x1F442, Hi: 0x1F4FC, Stride: 1},
+ {Lo: 0x1F4FF, Hi: 0x1F53D, Stride: 1},
+ {Lo: 0x1F54B, Hi: 0x1F54E, Stride: 1},
+ {Lo: 0x1F550, Hi: 0x1F567, Stride: 1},
+ {Lo: 0x1F57A, Hi: 0x1F57A, Stride: 1},
+ {Lo: 0x1F595, Hi: 0x1F596, Stride: 1},
+ {Lo: 0x1F5A4, Hi: 0x1F5A4, Stride: 1},
+ {Lo: 0x1F5FB, Hi: 0x1F64F, Stride: 1},
+ {Lo: 0x1F680, Hi: 0x1F6C5, Stride: 1},
+ {Lo: 0x1F6CC, Hi: 0x1F6CC, Stride: 1},
+ {Lo: 0x1F6D0, Hi: 0x1F6D2, Stride: 1},
+ {Lo: 0x1F6D5, Hi: 0x1F6D8, Stride: 1},
+ {Lo: 0x1F6DC, Hi: 0x1F6DF, Stride: 1},
+ {Lo: 0x1F6EB, Hi: 0x1F6EC, Stride: 1},
+ {Lo: 0x1F6F4, Hi: 0x1F6FC, Stride: 1},
+ {Lo: 0x1F7E0, Hi: 0x1F7EB, Stride: 1},
+ {Lo: 0x1F7F0, Hi: 0x1F7F0, Stride: 1},
+ {Lo: 0x1F90C, Hi: 0x1F93A, Stride: 1},
+ {Lo: 0x1F93C, Hi: 0x1F945, Stride: 1},
+ {Lo: 0x1F947, Hi: 0x1F9FF, Stride: 1},
+ {Lo: 0x1FA70, Hi: 0x1FA7C, Stride: 1},
+ {Lo: 0x1FA80, Hi: 0x1FA8A, Stride: 1},
+ {Lo: 0x1FA8E, Hi: 0x1FAC6, Stride: 1},
+ {Lo: 0x1FAC8, Hi: 0x1FAC8, Stride: 1},
+ {Lo: 0x1FACD, Hi: 0x1FADC, Stride: 1},
+ {Lo: 0x1FADF, Hi: 0x1FAEA, Stride: 1},
+ {Lo: 0x1FAEF, Hi: 0x1FAF8, Stride: 1},
+ },
+}
+
+var unicodeAliasExtended_Pictographic = &unicode.RangeTable{
+ R16: []unicode.Range16{
+ {Lo: 0xA9, Hi: 0xA9, Stride: 1},
+ {Lo: 0xAE, Hi: 0xAE, Stride: 1},
+ {Lo: 0x203C, Hi: 0x203C, Stride: 1},
+ {Lo: 0x2049, Hi: 0x2049, Stride: 1},
+ {Lo: 0x2122, Hi: 0x2122, Stride: 1},
+ {Lo: 0x2139, Hi: 0x2139, Stride: 1},
+ {Lo: 0x2194, Hi: 0x2199, Stride: 1},
+ {Lo: 0x21A9, Hi: 0x21AA, Stride: 1},
+ {Lo: 0x231A, Hi: 0x231B, Stride: 1},
+ {Lo: 0x2328, Hi: 0x2328, Stride: 1},
+ {Lo: 0x23CF, Hi: 0x23CF, Stride: 1},
+ {Lo: 0x23E9, Hi: 0x23F3, Stride: 1},
+ {Lo: 0x23F8, Hi: 0x23FA, Stride: 1},
+ {Lo: 0x24C2, Hi: 0x24C2, Stride: 1},
+ {Lo: 0x25AA, Hi: 0x25AB, Stride: 1},
+ {Lo: 0x25B6, Hi: 0x25B6, Stride: 1},
+ {Lo: 0x25C0, Hi: 0x25C0, Stride: 1},
+ {Lo: 0x25FB, Hi: 0x25FE, Stride: 1},
+ {Lo: 0x2600, Hi: 0x2604, Stride: 1},
+ {Lo: 0x260E, Hi: 0x260E, Stride: 1},
+ {Lo: 0x2611, Hi: 0x2611, Stride: 1},
+ {Lo: 0x2614, Hi: 0x2615, Stride: 1},
+ {Lo: 0x2618, Hi: 0x2618, Stride: 1},
+ {Lo: 0x261D, Hi: 0x261D, Stride: 1},
+ {Lo: 0x2620, Hi: 0x2620, Stride: 1},
+ {Lo: 0x2622, Hi: 0x2623, Stride: 1},
+ {Lo: 0x2626, Hi: 0x2626, Stride: 1},
+ {Lo: 0x262A, Hi: 0x262A, Stride: 1},
+ {Lo: 0x262E, Hi: 0x262F, Stride: 1},
+ {Lo: 0x2638, Hi: 0x263A, Stride: 1},
+ {Lo: 0x2640, Hi: 0x2640, Stride: 1},
+ {Lo: 0x2642, Hi: 0x2642, Stride: 1},
+ {Lo: 0x2648, Hi: 0x2653, Stride: 1},
+ {Lo: 0x265F, Hi: 0x2660, Stride: 1},
+ {Lo: 0x2663, Hi: 0x2663, Stride: 1},
+ {Lo: 0x2665, Hi: 0x2666, Stride: 1},
+ {Lo: 0x2668, Hi: 0x2668, Stride: 1},
+ {Lo: 0x267B, Hi: 0x267B, Stride: 1},
+ {Lo: 0x267E, Hi: 0x267F, Stride: 1},
+ {Lo: 0x2692, Hi: 0x2697, Stride: 1},
+ {Lo: 0x2699, Hi: 0x2699, Stride: 1},
+ {Lo: 0x269B, Hi: 0x269C, Stride: 1},
+ {Lo: 0x26A0, Hi: 0x26A1, Stride: 1},
+ {Lo: 0x26A7, Hi: 0x26A7, Stride: 1},
+ {Lo: 0x26AA, Hi: 0x26AB, Stride: 1},
+ {Lo: 0x26B0, Hi: 0x26B1, Stride: 1},
+ {Lo: 0x26BD, Hi: 0x26BE, Stride: 1},
+ {Lo: 0x26C4, Hi: 0x26C5, Stride: 1},
+ {Lo: 0x26C8, Hi: 0x26C8, Stride: 1},
+ {Lo: 0x26CE, Hi: 0x26CF, Stride: 1},
+ {Lo: 0x26D1, Hi: 0x26D1, Stride: 1},
+ {Lo: 0x26D3, Hi: 0x26D4, Stride: 1},
+ {Lo: 0x26E9, Hi: 0x26EA, Stride: 1},
+ {Lo: 0x26F0, Hi: 0x26F5, Stride: 1},
+ {Lo: 0x26F7, Hi: 0x26FA, Stride: 1},
+ {Lo: 0x26FD, Hi: 0x26FD, Stride: 1},
+ {Lo: 0x2702, Hi: 0x2702, Stride: 1},
+ {Lo: 0x2705, Hi: 0x2705, Stride: 1},
+ {Lo: 0x2708, Hi: 0x270D, Stride: 1},
+ {Lo: 0x270F, Hi: 0x270F, Stride: 1},
+ {Lo: 0x2712, Hi: 0x2712, Stride: 1},
+ {Lo: 0x2714, Hi: 0x2714, Stride: 1},
+ {Lo: 0x2716, Hi: 0x2716, Stride: 1},
+ {Lo: 0x271D, Hi: 0x271D, Stride: 1},
+ {Lo: 0x2721, Hi: 0x2721, Stride: 1},
+ {Lo: 0x2728, Hi: 0x2728, Stride: 1},
+ {Lo: 0x2733, Hi: 0x2734, Stride: 1},
+ {Lo: 0x2744, Hi: 0x2744, Stride: 1},
+ {Lo: 0x2747, Hi: 0x2747, Stride: 1},
+ {Lo: 0x274C, Hi: 0x274C, Stride: 1},
+ {Lo: 0x274E, Hi: 0x274E, Stride: 1},
+ {Lo: 0x2753, Hi: 0x2755, Stride: 1},
+ {Lo: 0x2757, Hi: 0x2757, Stride: 1},
+ {Lo: 0x2763, Hi: 0x2764, Stride: 1},
+ {Lo: 0x2795, Hi: 0x2797, Stride: 1},
+ {Lo: 0x27A1, Hi: 0x27A1, Stride: 1},
+ {Lo: 0x27B0, Hi: 0x27B0, Stride: 1},
+ {Lo: 0x27BF, Hi: 0x27BF, Stride: 1},
+ {Lo: 0x2934, Hi: 0x2935, Stride: 1},
+ {Lo: 0x2B05, Hi: 0x2B07, Stride: 1},
+ {Lo: 0x2B1B, Hi: 0x2B1C, Stride: 1},
+ {Lo: 0x2B50, Hi: 0x2B50, Stride: 1},
+ {Lo: 0x2B55, Hi: 0x2B55, Stride: 1},
+ {Lo: 0x3030, Hi: 0x3030, Stride: 1},
+ {Lo: 0x303D, Hi: 0x303D, Stride: 1},
+ {Lo: 0x3297, Hi: 0x3297, Stride: 1},
+ {Lo: 0x3299, Hi: 0x3299, Stride: 1},
+ },
+ R32: []unicode.Range32{
+ {Lo: 0x1F004, Hi: 0x1F004, Stride: 1},
+ {Lo: 0x1F02C, Hi: 0x1F02F, Stride: 1},
+ {Lo: 0x1F094, Hi: 0x1F09F, Stride: 1},
+ {Lo: 0x1F0AF, Hi: 0x1F0B0, Stride: 1},
+ {Lo: 0x1F0C0, Hi: 0x1F0C0, Stride: 1},
+ {Lo: 0x1F0CF, Hi: 0x1F0D0, Stride: 1},
+ {Lo: 0x1F0F6, Hi: 0x1F0FF, Stride: 1},
+ {Lo: 0x1F170, Hi: 0x1F171, Stride: 1},
+ {Lo: 0x1F17E, Hi: 0x1F17F, Stride: 1},
+ {Lo: 0x1F18E, Hi: 0x1F18E, Stride: 1},
+ {Lo: 0x1F191, Hi: 0x1F19A, Stride: 1},
+ {Lo: 0x1F1AE, Hi: 0x1F1E5, Stride: 1},
+ {Lo: 0x1F201, Hi: 0x1F20F, Stride: 1},
+ {Lo: 0x1F21A, Hi: 0x1F21A, Stride: 1},
+ {Lo: 0x1F22F, Hi: 0x1F22F, Stride: 1},
+ {Lo: 0x1F232, Hi: 0x1F23A, Stride: 1},
+ {Lo: 0x1F23C, Hi: 0x1F23F, Stride: 1},
+ {Lo: 0x1F249, Hi: 0x1F25F, Stride: 1},
+ {Lo: 0x1F266, Hi: 0x1F321, Stride: 1},
+ {Lo: 0x1F324, Hi: 0x1F393, Stride: 1},
+ {Lo: 0x1F396, Hi: 0x1F397, Stride: 1},
+ {Lo: 0x1F399, Hi: 0x1F39B, Stride: 1},
+ {Lo: 0x1F39E, Hi: 0x1F3F0, Stride: 1},
+ {Lo: 0x1F3F3, Hi: 0x1F3F5, Stride: 1},
+ {Lo: 0x1F3F7, Hi: 0x1F3FA, Stride: 1},
+ {Lo: 0x1F400, Hi: 0x1F4FD, Stride: 1},
+ {Lo: 0x1F4FF, Hi: 0x1F53D, Stride: 1},
+ {Lo: 0x1F549, Hi: 0x1F54E, Stride: 1},
+ {Lo: 0x1F550, Hi: 0x1F567, Stride: 1},
+ {Lo: 0x1F56F, Hi: 0x1F570, Stride: 1},
+ {Lo: 0x1F573, Hi: 0x1F57A, Stride: 1},
+ {Lo: 0x1F587, Hi: 0x1F587, Stride: 1},
+ {Lo: 0x1F58A, Hi: 0x1F58D, Stride: 1},
+ {Lo: 0x1F590, Hi: 0x1F590, Stride: 1},
+ {Lo: 0x1F595, Hi: 0x1F596, Stride: 1},
+ {Lo: 0x1F5A4, Hi: 0x1F5A5, Stride: 1},
+ {Lo: 0x1F5A8, Hi: 0x1F5A8, Stride: 1},
+ {Lo: 0x1F5B1, Hi: 0x1F5B2, Stride: 1},
+ {Lo: 0x1F5BC, Hi: 0x1F5BC, Stride: 1},
+ {Lo: 0x1F5C2, Hi: 0x1F5C4, Stride: 1},
+ {Lo: 0x1F5D1, Hi: 0x1F5D3, Stride: 1},
+ {Lo: 0x1F5DC, Hi: 0x1F5DE, Stride: 1},
+ {Lo: 0x1F5E1, Hi: 0x1F5E1, Stride: 1},
+ {Lo: 0x1F5E3, Hi: 0x1F5E3, Stride: 1},
+ {Lo: 0x1F5E8, Hi: 0x1F5E8, Stride: 1},
+ {Lo: 0x1F5EF, Hi: 0x1F5EF, Stride: 1},
+ {Lo: 0x1F5F3, Hi: 0x1F5F3, Stride: 1},
+ {Lo: 0x1F5FA, Hi: 0x1F64F, Stride: 1},
+ {Lo: 0x1F680, Hi: 0x1F6C5, Stride: 1},
+ {Lo: 0x1F6CB, Hi: 0x1F6D2, Stride: 1},
+ {Lo: 0x1F6D5, Hi: 0x1F6E5, Stride: 1},
+ {Lo: 0x1F6E9, Hi: 0x1F6E9, Stride: 1},
+ {Lo: 0x1F6EB, Hi: 0x1F6F0, Stride: 1},
+ {Lo: 0x1F6F3, Hi: 0x1F6FF, Stride: 1},
+ {Lo: 0x1F7DA, Hi: 0x1F7FF, Stride: 1},
+ {Lo: 0x1F80C, Hi: 0x1F80F, Stride: 1},
+ {Lo: 0x1F848, Hi: 0x1F84F, Stride: 1},
+ {Lo: 0x1F85A, Hi: 0x1F85F, Stride: 1},
+ {Lo: 0x1F888, Hi: 0x1F88F, Stride: 1},
+ {Lo: 0x1F8AE, Hi: 0x1F8AF, Stride: 1},
+ {Lo: 0x1F8BC, Hi: 0x1F8BF, Stride: 1},
+ {Lo: 0x1F8C2, Hi: 0x1F8CF, Stride: 1},
+ {Lo: 0x1F8D9, Hi: 0x1F8FF, Stride: 1},
+ {Lo: 0x1F90C, Hi: 0x1F93A, Stride: 1},
+ {Lo: 0x1F93C, Hi: 0x1F945, Stride: 1},
+ {Lo: 0x1F947, Hi: 0x1F9FF, Stride: 1},
+ {Lo: 0x1FA58, Hi: 0x1FA5F, Stride: 1},
+ {Lo: 0x1FA6E, Hi: 0x1FAFF, Stride: 1},
+ {Lo: 0x1FC00, Hi: 0x1FFFD, Stride: 1},
+ },
+}
+
+var unicodeAliasGrapheme_Cluster_Break_CR = &unicode.RangeTable{
+ R16: []unicode.Range16{
+ {Lo: 0xD, Hi: 0xD, Stride: 1},
+ },
+}
+
+var unicodeAliasGrapheme_Cluster_Break_Control = &unicode.RangeTable{
+ R16: []unicode.Range16{
+ {Lo: 0x0, Hi: 0x9, Stride: 1},
+ {Lo: 0xB, Hi: 0xC, Stride: 1},
+ {Lo: 0xE, Hi: 0x1F, Stride: 1},
+ {Lo: 0x7F, Hi: 0x9F, Stride: 1},
+ {Lo: 0xAD, Hi: 0xAD, Stride: 1},
+ {Lo: 0x61C, Hi: 0x61C, Stride: 1},
+ {Lo: 0x180E, Hi: 0x180E, Stride: 1},
+ {Lo: 0x200B, Hi: 0x200B, Stride: 1},
+ {Lo: 0x200E, Hi: 0x200F, Stride: 1},
+ {Lo: 0x2028, Hi: 0x202E, Stride: 1},
+ {Lo: 0x2060, Hi: 0x206F, Stride: 1},
+ {Lo: 0xFEFF, Hi: 0xFEFF, Stride: 1},
+ {Lo: 0xFFF0, Hi: 0xFFFB, Stride: 1},
+ },
+ R32: []unicode.Range32{
+ {Lo: 0x13430, Hi: 0x1343F, Stride: 1},
+ {Lo: 0x1BCA0, Hi: 0x1BCA3, Stride: 1},
+ {Lo: 0x1D173, Hi: 0x1D17A, Stride: 1},
+ {Lo: 0xE0000, Hi: 0xE001F, Stride: 1},
+ {Lo: 0xE0080, Hi: 0xE00FF, Stride: 1},
+ {Lo: 0xE01F0, Hi: 0xE0FFF, Stride: 1},
+ },
+}
+
+var unicodeAliasGrapheme_Cluster_Break_Extend = &unicode.RangeTable{
+ R16: []unicode.Range16{
+ {Lo: 0x300, Hi: 0x36F, Stride: 1},
+ {Lo: 0x483, Hi: 0x489, Stride: 1},
+ {Lo: 0x591, Hi: 0x5BD, Stride: 1},
+ {Lo: 0x5BF, Hi: 0x5BF, Stride: 1},
+ {Lo: 0x5C1, Hi: 0x5C2, Stride: 1},
+ {Lo: 0x5C4, Hi: 0x5C5, Stride: 1},
+ {Lo: 0x5C7, Hi: 0x5C7, Stride: 1},
+ {Lo: 0x610, Hi: 0x61A, Stride: 1},
+ {Lo: 0x64B, Hi: 0x65F, Stride: 1},
+ {Lo: 0x670, Hi: 0x670, Stride: 1},
+ {Lo: 0x6D6, Hi: 0x6DC, Stride: 1},
+ {Lo: 0x6DF, Hi: 0x6E4, Stride: 1},
+ {Lo: 0x6E7, Hi: 0x6E8, Stride: 1},
+ {Lo: 0x6EA, Hi: 0x6ED, Stride: 1},
+ {Lo: 0x711, Hi: 0x711, Stride: 1},
+ {Lo: 0x730, Hi: 0x74A, Stride: 1},
+ {Lo: 0x7A6, Hi: 0x7B0, Stride: 1},
+ {Lo: 0x7EB, Hi: 0x7F3, Stride: 1},
+ {Lo: 0x7FD, Hi: 0x7FD, Stride: 1},
+ {Lo: 0x816, Hi: 0x819, Stride: 1},
+ {Lo: 0x81B, Hi: 0x823, Stride: 1},
+ {Lo: 0x825, Hi: 0x827, Stride: 1},
+ {Lo: 0x829, Hi: 0x82D, Stride: 1},
+ {Lo: 0x859, Hi: 0x85B, Stride: 1},
+ {Lo: 0x897, Hi: 0x89F, Stride: 1},
+ {Lo: 0x8CA, Hi: 0x8E1, Stride: 1},
+ {Lo: 0x8E3, Hi: 0x902, Stride: 1},
+ {Lo: 0x93A, Hi: 0x93A, Stride: 1},
+ {Lo: 0x93C, Hi: 0x93C, Stride: 1},
+ {Lo: 0x941, Hi: 0x948, Stride: 1},
+ {Lo: 0x94D, Hi: 0x94D, Stride: 1},
+ {Lo: 0x951, Hi: 0x957, Stride: 1},
+ {Lo: 0x962, Hi: 0x963, Stride: 1},
+ {Lo: 0x981, Hi: 0x981, Stride: 1},
+ {Lo: 0x9BC, Hi: 0x9BC, Stride: 1},
+ {Lo: 0x9BE, Hi: 0x9BE, Stride: 1},
+ {Lo: 0x9C1, Hi: 0x9C4, Stride: 1},
+ {Lo: 0x9CD, Hi: 0x9CD, Stride: 1},
+ {Lo: 0x9D7, Hi: 0x9D7, Stride: 1},
+ {Lo: 0x9E2, Hi: 0x9E3, Stride: 1},
+ {Lo: 0x9FE, Hi: 0x9FE, Stride: 1},
+ {Lo: 0xA01, Hi: 0xA02, Stride: 1},
+ {Lo: 0xA3C, Hi: 0xA3C, Stride: 1},
+ {Lo: 0xA41, Hi: 0xA42, Stride: 1},
+ {Lo: 0xA47, Hi: 0xA48, Stride: 1},
+ {Lo: 0xA4B, Hi: 0xA4D, Stride: 1},
+ {Lo: 0xA51, Hi: 0xA51, Stride: 1},
+ {Lo: 0xA70, Hi: 0xA71, Stride: 1},
+ {Lo: 0xA75, Hi: 0xA75, Stride: 1},
+ {Lo: 0xA81, Hi: 0xA82, Stride: 1},
+ {Lo: 0xABC, Hi: 0xABC, Stride: 1},
+ {Lo: 0xAC1, Hi: 0xAC5, Stride: 1},
+ {Lo: 0xAC7, Hi: 0xAC8, Stride: 1},
+ {Lo: 0xACD, Hi: 0xACD, Stride: 1},
+ {Lo: 0xAE2, Hi: 0xAE3, Stride: 1},
+ {Lo: 0xAFA, Hi: 0xAFF, Stride: 1},
+ {Lo: 0xB01, Hi: 0xB01, Stride: 1},
+ {Lo: 0xB3C, Hi: 0xB3C, Stride: 1},
+ {Lo: 0xB3E, Hi: 0xB3F, Stride: 1},
+ {Lo: 0xB41, Hi: 0xB44, Stride: 1},
+ {Lo: 0xB4D, Hi: 0xB4D, Stride: 1},
+ {Lo: 0xB55, Hi: 0xB57, Stride: 1},
+ {Lo: 0xB62, Hi: 0xB63, Stride: 1},
+ {Lo: 0xB82, Hi: 0xB82, Stride: 1},
+ {Lo: 0xBBE, Hi: 0xBBE, Stride: 1},
+ {Lo: 0xBC0, Hi: 0xBC0, Stride: 1},
+ {Lo: 0xBCD, Hi: 0xBCD, Stride: 1},
+ {Lo: 0xBD7, Hi: 0xBD7, Stride: 1},
+ {Lo: 0xC00, Hi: 0xC00, Stride: 1},
+ {Lo: 0xC04, Hi: 0xC04, Stride: 1},
+ {Lo: 0xC3C, Hi: 0xC3C, Stride: 1},
+ {Lo: 0xC3E, Hi: 0xC40, Stride: 1},
+ {Lo: 0xC46, Hi: 0xC48, Stride: 1},
+ {Lo: 0xC4A, Hi: 0xC4D, Stride: 1},
+ {Lo: 0xC55, Hi: 0xC56, Stride: 1},
+ {Lo: 0xC62, Hi: 0xC63, Stride: 1},
+ {Lo: 0xC81, Hi: 0xC81, Stride: 1},
+ {Lo: 0xCBC, Hi: 0xCBC, Stride: 1},
+ {Lo: 0xCBF, Hi: 0xCC0, Stride: 1},
+ {Lo: 0xCC2, Hi: 0xCC2, Stride: 1},
+ {Lo: 0xCC6, Hi: 0xCC8, Stride: 1},
+ {Lo: 0xCCA, Hi: 0xCCD, Stride: 1},
+ {Lo: 0xCD5, Hi: 0xCD6, Stride: 1},
+ {Lo: 0xCE2, Hi: 0xCE3, Stride: 1},
+ {Lo: 0xD00, Hi: 0xD01, Stride: 1},
+ {Lo: 0xD3B, Hi: 0xD3C, Stride: 1},
+ {Lo: 0xD3E, Hi: 0xD3E, Stride: 1},
+ {Lo: 0xD41, Hi: 0xD44, Stride: 1},
+ {Lo: 0xD4D, Hi: 0xD4D, Stride: 1},
+ {Lo: 0xD57, Hi: 0xD57, Stride: 1},
+ {Lo: 0xD62, Hi: 0xD63, Stride: 1},
+ {Lo: 0xD81, Hi: 0xD81, Stride: 1},
+ {Lo: 0xDCA, Hi: 0xDCA, Stride: 1},
+ {Lo: 0xDCF, Hi: 0xDCF, Stride: 1},
+ {Lo: 0xDD2, Hi: 0xDD4, Stride: 1},
+ {Lo: 0xDD6, Hi: 0xDD6, Stride: 1},
+ {Lo: 0xDDF, Hi: 0xDDF, Stride: 1},
+ {Lo: 0xE31, Hi: 0xE31, Stride: 1},
+ {Lo: 0xE34, Hi: 0xE3A, Stride: 1},
+ {Lo: 0xE47, Hi: 0xE4E, Stride: 1},
+ {Lo: 0xEB1, Hi: 0xEB1, Stride: 1},
+ {Lo: 0xEB4, Hi: 0xEBC, Stride: 1},
+ {Lo: 0xEC8, Hi: 0xECE, Stride: 1},
+ {Lo: 0xF18, Hi: 0xF19, Stride: 1},
+ {Lo: 0xF35, Hi: 0xF35, Stride: 1},
+ {Lo: 0xF37, Hi: 0xF37, Stride: 1},
+ {Lo: 0xF39, Hi: 0xF39, Stride: 1},
+ {Lo: 0xF71, Hi: 0xF7E, Stride: 1},
+ {Lo: 0xF80, Hi: 0xF84, Stride: 1},
+ {Lo: 0xF86, Hi: 0xF87, Stride: 1},
+ {Lo: 0xF8D, Hi: 0xF97, Stride: 1},
+ {Lo: 0xF99, Hi: 0xFBC, Stride: 1},
+ {Lo: 0xFC6, Hi: 0xFC6, Stride: 1},
+ {Lo: 0x102D, Hi: 0x1030, Stride: 1},
+ {Lo: 0x1032, Hi: 0x1037, Stride: 1},
+ {Lo: 0x1039, Hi: 0x103A, Stride: 1},
+ {Lo: 0x103D, Hi: 0x103E, Stride: 1},
+ {Lo: 0x1058, Hi: 0x1059, Stride: 1},
+ {Lo: 0x105E, Hi: 0x1060, Stride: 1},
+ {Lo: 0x1071, Hi: 0x1074, Stride: 1},
+ {Lo: 0x1082, Hi: 0x1082, Stride: 1},
+ {Lo: 0x1085, Hi: 0x1086, Stride: 1},
+ {Lo: 0x108D, Hi: 0x108D, Stride: 1},
+ {Lo: 0x109D, Hi: 0x109D, Stride: 1},
+ {Lo: 0x135D, Hi: 0x135F, Stride: 1},
+ {Lo: 0x1712, Hi: 0x1715, Stride: 1},
+ {Lo: 0x1732, Hi: 0x1734, Stride: 1},
+ {Lo: 0x1752, Hi: 0x1753, Stride: 1},
+ {Lo: 0x1772, Hi: 0x1773, Stride: 1},
+ {Lo: 0x17B4, Hi: 0x17B5, Stride: 1},
+ {Lo: 0x17B7, Hi: 0x17BD, Stride: 1},
+ {Lo: 0x17C6, Hi: 0x17C6, Stride: 1},
+ {Lo: 0x17C9, Hi: 0x17D3, Stride: 1},
+ {Lo: 0x17DD, Hi: 0x17DD, Stride: 1},
+ {Lo: 0x180B, Hi: 0x180D, Stride: 1},
+ {Lo: 0x180F, Hi: 0x180F, Stride: 1},
+ {Lo: 0x1885, Hi: 0x1886, Stride: 1},
+ {Lo: 0x18A9, Hi: 0x18A9, Stride: 1},
+ {Lo: 0x1920, Hi: 0x1922, Stride: 1},
+ {Lo: 0x1927, Hi: 0x1928, Stride: 1},
+ {Lo: 0x1932, Hi: 0x1932, Stride: 1},
+ {Lo: 0x1939, Hi: 0x193B, Stride: 1},
+ {Lo: 0x1A17, Hi: 0x1A18, Stride: 1},
+ {Lo: 0x1A1B, Hi: 0x1A1B, Stride: 1},
+ {Lo: 0x1A56, Hi: 0x1A56, Stride: 1},
+ {Lo: 0x1A58, Hi: 0x1A5E, Stride: 1},
+ {Lo: 0x1A60, Hi: 0x1A60, Stride: 1},
+ {Lo: 0x1A62, Hi: 0x1A62, Stride: 1},
+ {Lo: 0x1A65, Hi: 0x1A6C, Stride: 1},
+ {Lo: 0x1A73, Hi: 0x1A7C, Stride: 1},
+ {Lo: 0x1A7F, Hi: 0x1A7F, Stride: 1},
+ {Lo: 0x1AB0, Hi: 0x1ADD, Stride: 1},
+ {Lo: 0x1AE0, Hi: 0x1AEB, Stride: 1},
+ {Lo: 0x1B00, Hi: 0x1B03, Stride: 1},
+ {Lo: 0x1B34, Hi: 0x1B3D, Stride: 1},
+ {Lo: 0x1B42, Hi: 0x1B44, Stride: 1},
+ {Lo: 0x1B6B, Hi: 0x1B73, Stride: 1},
+ {Lo: 0x1B80, Hi: 0x1B81, Stride: 1},
+ {Lo: 0x1BA2, Hi: 0x1BA5, Stride: 1},
+ {Lo: 0x1BA8, Hi: 0x1BAD, Stride: 1},
+ {Lo: 0x1BE6, Hi: 0x1BE6, Stride: 1},
+ {Lo: 0x1BE8, Hi: 0x1BE9, Stride: 1},
+ {Lo: 0x1BED, Hi: 0x1BED, Stride: 1},
+ {Lo: 0x1BEF, Hi: 0x1BF3, Stride: 1},
+ {Lo: 0x1C2C, Hi: 0x1C33, Stride: 1},
+ {Lo: 0x1C36, Hi: 0x1C37, Stride: 1},
+ {Lo: 0x1CD0, Hi: 0x1CD2, Stride: 1},
+ {Lo: 0x1CD4, Hi: 0x1CE0, Stride: 1},
+ {Lo: 0x1CE2, Hi: 0x1CE8, Stride: 1},
+ {Lo: 0x1CED, Hi: 0x1CED, Stride: 1},
+ {Lo: 0x1CF4, Hi: 0x1CF4, Stride: 1},
+ {Lo: 0x1CF8, Hi: 0x1CF9, Stride: 1},
+ {Lo: 0x1DC0, Hi: 0x1DFF, Stride: 1},
+ {Lo: 0x200C, Hi: 0x200C, Stride: 1},
+ {Lo: 0x20D0, Hi: 0x20F0, Stride: 1},
+ {Lo: 0x2CEF, Hi: 0x2CF1, Stride: 1},
+ {Lo: 0x2D7F, Hi: 0x2D7F, Stride: 1},
+ {Lo: 0x2DE0, Hi: 0x2DFF, Stride: 1},
+ {Lo: 0x302A, Hi: 0x302F, Stride: 1},
+ {Lo: 0x3099, Hi: 0x309A, Stride: 1},
+ {Lo: 0xA66F, Hi: 0xA672, Stride: 1},
+ {Lo: 0xA674, Hi: 0xA67D, Stride: 1},
+ {Lo: 0xA69E, Hi: 0xA69F, Stride: 1},
+ {Lo: 0xA6F0, Hi: 0xA6F1, Stride: 1},
+ {Lo: 0xA802, Hi: 0xA802, Stride: 1},
+ {Lo: 0xA806, Hi: 0xA806, Stride: 1},
+ {Lo: 0xA80B, Hi: 0xA80B, Stride: 1},
+ {Lo: 0xA825, Hi: 0xA826, Stride: 1},
+ {Lo: 0xA82C, Hi: 0xA82C, Stride: 1},
+ {Lo: 0xA8C4, Hi: 0xA8C5, Stride: 1},
+ {Lo: 0xA8E0, Hi: 0xA8F1, Stride: 1},
+ {Lo: 0xA8FF, Hi: 0xA8FF, Stride: 1},
+ {Lo: 0xA926, Hi: 0xA92D, Stride: 1},
+ {Lo: 0xA947, Hi: 0xA951, Stride: 1},
+ {Lo: 0xA953, Hi: 0xA953, Stride: 1},
+ {Lo: 0xA980, Hi: 0xA982, Stride: 1},
+ {Lo: 0xA9B3, Hi: 0xA9B3, Stride: 1},
+ {Lo: 0xA9B6, Hi: 0xA9B9, Stride: 1},
+ {Lo: 0xA9BC, Hi: 0xA9BD, Stride: 1},
+ {Lo: 0xA9C0, Hi: 0xA9C0, Stride: 1},
+ {Lo: 0xA9E5, Hi: 0xA9E5, Stride: 1},
+ {Lo: 0xAA29, Hi: 0xAA2E, Stride: 1},
+ {Lo: 0xAA31, Hi: 0xAA32, Stride: 1},
+ {Lo: 0xAA35, Hi: 0xAA36, Stride: 1},
+ {Lo: 0xAA43, Hi: 0xAA43, Stride: 1},
+ {Lo: 0xAA4C, Hi: 0xAA4C, Stride: 1},
+ {Lo: 0xAA7C, Hi: 0xAA7C, Stride: 1},
+ {Lo: 0xAAB0, Hi: 0xAAB0, Stride: 1},
+ {Lo: 0xAAB2, Hi: 0xAAB4, Stride: 1},
+ {Lo: 0xAAB7, Hi: 0xAAB8, Stride: 1},
+ {Lo: 0xAABE, Hi: 0xAABF, Stride: 1},
+ {Lo: 0xAAC1, Hi: 0xAAC1, Stride: 1},
+ {Lo: 0xAAEC, Hi: 0xAAED, Stride: 1},
+ {Lo: 0xAAF6, Hi: 0xAAF6, Stride: 1},
+ {Lo: 0xABE5, Hi: 0xABE5, Stride: 1},
+ {Lo: 0xABE8, Hi: 0xABE8, Stride: 1},
+ {Lo: 0xABED, Hi: 0xABED, Stride: 1},
+ {Lo: 0xFB1E, Hi: 0xFB1E, Stride: 1},
+ {Lo: 0xFE00, Hi: 0xFE0F, Stride: 1},
+ {Lo: 0xFE20, Hi: 0xFE2F, Stride: 1},
+ {Lo: 0xFF9E, Hi: 0xFF9F, Stride: 1},
+ },
+ R32: []unicode.Range32{
+ {Lo: 0x101FD, Hi: 0x101FD, Stride: 1},
+ {Lo: 0x102E0, Hi: 0x102E0, Stride: 1},
+ {Lo: 0x10376, Hi: 0x1037A, Stride: 1},
+ {Lo: 0x10A01, Hi: 0x10A03, Stride: 1},
+ {Lo: 0x10A05, Hi: 0x10A06, Stride: 1},
+ {Lo: 0x10A0C, Hi: 0x10A0F, Stride: 1},
+ {Lo: 0x10A38, Hi: 0x10A3A, Stride: 1},
+ {Lo: 0x10A3F, Hi: 0x10A3F, Stride: 1},
+ {Lo: 0x10AE5, Hi: 0x10AE6, Stride: 1},
+ {Lo: 0x10D24, Hi: 0x10D27, Stride: 1},
+ {Lo: 0x10D69, Hi: 0x10D6D, Stride: 1},
+ {Lo: 0x10EAB, Hi: 0x10EAC, Stride: 1},
+ {Lo: 0x10EFA, Hi: 0x10EFF, Stride: 1},
+ {Lo: 0x10F46, Hi: 0x10F50, Stride: 1},
+ {Lo: 0x10F82, Hi: 0x10F85, Stride: 1},
+ {Lo: 0x11001, Hi: 0x11001, Stride: 1},
+ {Lo: 0x11038, Hi: 0x11046, Stride: 1},
+ {Lo: 0x11070, Hi: 0x11070, Stride: 1},
+ {Lo: 0x11073, Hi: 0x11074, Stride: 1},
+ {Lo: 0x1107F, Hi: 0x11081, Stride: 1},
+ {Lo: 0x110B3, Hi: 0x110B6, Stride: 1},
+ {Lo: 0x110B9, Hi: 0x110BA, Stride: 1},
+ {Lo: 0x110C2, Hi: 0x110C2, Stride: 1},
+ {Lo: 0x11100, Hi: 0x11102, Stride: 1},
+ {Lo: 0x11127, Hi: 0x1112B, Stride: 1},
+ {Lo: 0x1112D, Hi: 0x11134, Stride: 1},
+ {Lo: 0x11173, Hi: 0x11173, Stride: 1},
+ {Lo: 0x11180, Hi: 0x11181, Stride: 1},
+ {Lo: 0x111B6, Hi: 0x111BE, Stride: 1},
+ {Lo: 0x111C0, Hi: 0x111C0, Stride: 1},
+ {Lo: 0x111C9, Hi: 0x111CC, Stride: 1},
+ {Lo: 0x111CF, Hi: 0x111CF, Stride: 1},
+ {Lo: 0x1122F, Hi: 0x11231, Stride: 1},
+ {Lo: 0x11234, Hi: 0x11237, Stride: 1},
+ {Lo: 0x1123E, Hi: 0x1123E, Stride: 1},
+ {Lo: 0x11241, Hi: 0x11241, Stride: 1},
+ {Lo: 0x112DF, Hi: 0x112DF, Stride: 1},
+ {Lo: 0x112E3, Hi: 0x112EA, Stride: 1},
+ {Lo: 0x11300, Hi: 0x11301, Stride: 1},
+ {Lo: 0x1133B, Hi: 0x1133C, Stride: 1},
+ {Lo: 0x1133E, Hi: 0x1133E, Stride: 1},
+ {Lo: 0x11340, Hi: 0x11340, Stride: 1},
+ {Lo: 0x1134D, Hi: 0x1134D, Stride: 1},
+ {Lo: 0x11357, Hi: 0x11357, Stride: 1},
+ {Lo: 0x11366, Hi: 0x1136C, Stride: 1},
+ {Lo: 0x11370, Hi: 0x11374, Stride: 1},
+ {Lo: 0x113B8, Hi: 0x113B8, Stride: 1},
+ {Lo: 0x113BB, Hi: 0x113C0, Stride: 1},
+ {Lo: 0x113C2, Hi: 0x113C2, Stride: 1},
+ {Lo: 0x113C5, Hi: 0x113C5, Stride: 1},
+ {Lo: 0x113C7, Hi: 0x113C9, Stride: 1},
+ {Lo: 0x113CE, Hi: 0x113D0, Stride: 1},
+ {Lo: 0x113D2, Hi: 0x113D2, Stride: 1},
+ {Lo: 0x113E1, Hi: 0x113E2, Stride: 1},
+ {Lo: 0x11438, Hi: 0x1143F, Stride: 1},
+ {Lo: 0x11442, Hi: 0x11444, Stride: 1},
+ {Lo: 0x11446, Hi: 0x11446, Stride: 1},
+ {Lo: 0x1145E, Hi: 0x1145E, Stride: 1},
+ {Lo: 0x114B0, Hi: 0x114B0, Stride: 1},
+ {Lo: 0x114B3, Hi: 0x114B8, Stride: 1},
+ {Lo: 0x114BA, Hi: 0x114BA, Stride: 1},
+ {Lo: 0x114BD, Hi: 0x114BD, Stride: 1},
+ {Lo: 0x114BF, Hi: 0x114C0, Stride: 1},
+ {Lo: 0x114C2, Hi: 0x114C3, Stride: 1},
+ {Lo: 0x115AF, Hi: 0x115AF, Stride: 1},
+ {Lo: 0x115B2, Hi: 0x115B5, Stride: 1},
+ {Lo: 0x115BC, Hi: 0x115BD, Stride: 1},
+ {Lo: 0x115BF, Hi: 0x115C0, Stride: 1},
+ {Lo: 0x115DC, Hi: 0x115DD, Stride: 1},
+ {Lo: 0x11633, Hi: 0x1163A, Stride: 1},
+ {Lo: 0x1163D, Hi: 0x1163D, Stride: 1},
+ {Lo: 0x1163F, Hi: 0x11640, Stride: 1},
+ {Lo: 0x116AB, Hi: 0x116AB, Stride: 1},
+ {Lo: 0x116AD, Hi: 0x116AD, Stride: 1},
+ {Lo: 0x116B0, Hi: 0x116B7, Stride: 1},
+ {Lo: 0x1171D, Hi: 0x1171D, Stride: 1},
+ {Lo: 0x1171F, Hi: 0x1171F, Stride: 1},
+ {Lo: 0x11722, Hi: 0x11725, Stride: 1},
+ {Lo: 0x11727, Hi: 0x1172B, Stride: 1},
+ {Lo: 0x1182F, Hi: 0x11837, Stride: 1},
+ {Lo: 0x11839, Hi: 0x1183A, Stride: 1},
+ {Lo: 0x11930, Hi: 0x11930, Stride: 1},
+ {Lo: 0x1193B, Hi: 0x1193E, Stride: 1},
+ {Lo: 0x11943, Hi: 0x11943, Stride: 1},
+ {Lo: 0x119D4, Hi: 0x119D7, Stride: 1},
+ {Lo: 0x119DA, Hi: 0x119DB, Stride: 1},
+ {Lo: 0x119E0, Hi: 0x119E0, Stride: 1},
+ {Lo: 0x11A01, Hi: 0x11A0A, Stride: 1},
+ {Lo: 0x11A33, Hi: 0x11A38, Stride: 1},
+ {Lo: 0x11A3B, Hi: 0x11A3E, Stride: 1},
+ {Lo: 0x11A47, Hi: 0x11A47, Stride: 1},
+ {Lo: 0x11A51, Hi: 0x11A56, Stride: 1},
+ {Lo: 0x11A59, Hi: 0x11A5B, Stride: 1},
+ {Lo: 0x11A8A, Hi: 0x11A96, Stride: 1},
+ {Lo: 0x11A98, Hi: 0x11A99, Stride: 1},
+ {Lo: 0x11B60, Hi: 0x11B60, Stride: 1},
+ {Lo: 0x11B62, Hi: 0x11B64, Stride: 1},
+ {Lo: 0x11B66, Hi: 0x11B66, Stride: 1},
+ {Lo: 0x11C30, Hi: 0x11C36, Stride: 1},
+ {Lo: 0x11C38, Hi: 0x11C3D, Stride: 1},
+ {Lo: 0x11C3F, Hi: 0x11C3F, Stride: 1},
+ {Lo: 0x11C92, Hi: 0x11CA7, Stride: 1},
+ {Lo: 0x11CAA, Hi: 0x11CB0, Stride: 1},
+ {Lo: 0x11CB2, Hi: 0x11CB3, Stride: 1},
+ {Lo: 0x11CB5, Hi: 0x11CB6, Stride: 1},
+ {Lo: 0x11D31, Hi: 0x11D36, Stride: 1},
+ {Lo: 0x11D3A, Hi: 0x11D3A, Stride: 1},
+ {Lo: 0x11D3C, Hi: 0x11D3D, Stride: 1},
+ {Lo: 0x11D3F, Hi: 0x11D45, Stride: 1},
+ {Lo: 0x11D47, Hi: 0x11D47, Stride: 1},
+ {Lo: 0x11D90, Hi: 0x11D91, Stride: 1},
+ {Lo: 0x11D95, Hi: 0x11D95, Stride: 1},
+ {Lo: 0x11D97, Hi: 0x11D97, Stride: 1},
+ {Lo: 0x11EF3, Hi: 0x11EF4, Stride: 1},
+ {Lo: 0x11F00, Hi: 0x11F01, Stride: 1},
+ {Lo: 0x11F36, Hi: 0x11F3A, Stride: 1},
+ {Lo: 0x11F40, Hi: 0x11F42, Stride: 1},
+ {Lo: 0x11F5A, Hi: 0x11F5A, Stride: 1},
+ {Lo: 0x13440, Hi: 0x13440, Stride: 1},
+ {Lo: 0x13447, Hi: 0x13455, Stride: 1},
+ {Lo: 0x1611E, Hi: 0x16129, Stride: 1},
+ {Lo: 0x1612D, Hi: 0x1612F, Stride: 1},
+ {Lo: 0x16AF0, Hi: 0x16AF4, Stride: 1},
+ {Lo: 0x16B30, Hi: 0x16B36, Stride: 1},
+ {Lo: 0x16F4F, Hi: 0x16F4F, Stride: 1},
+ {Lo: 0x16F8F, Hi: 0x16F92, Stride: 1},
+ {Lo: 0x16FE4, Hi: 0x16FE4, Stride: 1},
+ {Lo: 0x16FF0, Hi: 0x16FF1, Stride: 1},
+ {Lo: 0x1BC9D, Hi: 0x1BC9E, Stride: 1},
+ {Lo: 0x1CF00, Hi: 0x1CF2D, Stride: 1},
+ {Lo: 0x1CF30, Hi: 0x1CF46, Stride: 1},
+ {Lo: 0x1D165, Hi: 0x1D169, Stride: 1},
+ {Lo: 0x1D16D, Hi: 0x1D172, Stride: 1},
+ {Lo: 0x1D17B, Hi: 0x1D182, Stride: 1},
+ {Lo: 0x1D185, Hi: 0x1D18B, Stride: 1},
+ {Lo: 0x1D1AA, Hi: 0x1D1AD, Stride: 1},
+ {Lo: 0x1D242, Hi: 0x1D244, Stride: 1},
+ {Lo: 0x1DA00, Hi: 0x1DA36, Stride: 1},
+ {Lo: 0x1DA3B, Hi: 0x1DA6C, Stride: 1},
+ {Lo: 0x1DA75, Hi: 0x1DA75, Stride: 1},
+ {Lo: 0x1DA84, Hi: 0x1DA84, Stride: 1},
+ {Lo: 0x1DA9B, Hi: 0x1DA9F, Stride: 1},
+ {Lo: 0x1DAA1, Hi: 0x1DAAF, Stride: 1},
+ {Lo: 0x1E000, Hi: 0x1E006, Stride: 1},
+ {Lo: 0x1E008, Hi: 0x1E018, Stride: 1},
+ {Lo: 0x1E01B, Hi: 0x1E021, Stride: 1},
+ {Lo: 0x1E023, Hi: 0x1E024, Stride: 1},
+ {Lo: 0x1E026, Hi: 0x1E02A, Stride: 1},
+ {Lo: 0x1E08F, Hi: 0x1E08F, Stride: 1},
+ {Lo: 0x1E130, Hi: 0x1E136, Stride: 1},
+ {Lo: 0x1E2AE, Hi: 0x1E2AE, Stride: 1},
+ {Lo: 0x1E2EC, Hi: 0x1E2EF, Stride: 1},
+ {Lo: 0x1E4EC, Hi: 0x1E4EF, Stride: 1},
+ {Lo: 0x1E5EE, Hi: 0x1E5EF, Stride: 1},
+ {Lo: 0x1E6E3, Hi: 0x1E6E3, Stride: 1},
+ {Lo: 0x1E6E6, Hi: 0x1E6E6, Stride: 1},
+ {Lo: 0x1E6EE, Hi: 0x1E6EF, Stride: 1},
+ {Lo: 0x1E6F5, Hi: 0x1E6F5, Stride: 1},
+ {Lo: 0x1E8D0, Hi: 0x1E8D6, Stride: 1},
+ {Lo: 0x1E944, Hi: 0x1E94A, Stride: 1},
+ {Lo: 0x1F3FB, Hi: 0x1F3FF, Stride: 1},
+ {Lo: 0xE0020, Hi: 0xE007F, Stride: 1},
+ {Lo: 0xE0100, Hi: 0xE01EF, Stride: 1},
+ },
+}
+
+var unicodeAliasGrapheme_Cluster_Break_L = &unicode.RangeTable{
+ R16: []unicode.Range16{
+ {Lo: 0x1100, Hi: 0x115F, Stride: 1},
+ {Lo: 0xA960, Hi: 0xA97C, Stride: 1},
+ },
+}
+
+var unicodeAliasGrapheme_Cluster_Break_LF = &unicode.RangeTable{
+ R16: []unicode.Range16{
+ {Lo: 0xA, Hi: 0xA, Stride: 1},
+ },
+}
+
+var unicodeAliasGrapheme_Cluster_Break_LV = &unicode.RangeTable{
+ R16: []unicode.Range16{
+ {Lo: 0xAC00, Hi: 0xAC00, Stride: 1},
+ {Lo: 0xAC1C, Hi: 0xAC1C, Stride: 1},
+ {Lo: 0xAC38, Hi: 0xAC38, Stride: 1},
+ {Lo: 0xAC54, Hi: 0xAC54, Stride: 1},
+ {Lo: 0xAC70, Hi: 0xAC70, Stride: 1},
+ {Lo: 0xAC8C, Hi: 0xAC8C, Stride: 1},
+ {Lo: 0xACA8, Hi: 0xACA8, Stride: 1},
+ {Lo: 0xACC4, Hi: 0xACC4, Stride: 1},
+ {Lo: 0xACE0, Hi: 0xACE0, Stride: 1},
+ {Lo: 0xACFC, Hi: 0xACFC, Stride: 1},
+ {Lo: 0xAD18, Hi: 0xAD18, Stride: 1},
+ {Lo: 0xAD34, Hi: 0xAD34, Stride: 1},
+ {Lo: 0xAD50, Hi: 0xAD50, Stride: 1},
+ {Lo: 0xAD6C, Hi: 0xAD6C, Stride: 1},
+ {Lo: 0xAD88, Hi: 0xAD88, Stride: 1},
+ {Lo: 0xADA4, Hi: 0xADA4, Stride: 1},
+ {Lo: 0xADC0, Hi: 0xADC0, Stride: 1},
+ {Lo: 0xADDC, Hi: 0xADDC, Stride: 1},
+ {Lo: 0xADF8, Hi: 0xADF8, Stride: 1},
+ {Lo: 0xAE14, Hi: 0xAE14, Stride: 1},
+ {Lo: 0xAE30, Hi: 0xAE30, Stride: 1},
+ {Lo: 0xAE4C, Hi: 0xAE4C, Stride: 1},
+ {Lo: 0xAE68, Hi: 0xAE68, Stride: 1},
+ {Lo: 0xAE84, Hi: 0xAE84, Stride: 1},
+ {Lo: 0xAEA0, Hi: 0xAEA0, Stride: 1},
+ {Lo: 0xAEBC, Hi: 0xAEBC, Stride: 1},
+ {Lo: 0xAED8, Hi: 0xAED8, Stride: 1},
+ {Lo: 0xAEF4, Hi: 0xAEF4, Stride: 1},
+ {Lo: 0xAF10, Hi: 0xAF10, Stride: 1},
+ {Lo: 0xAF2C, Hi: 0xAF2C, Stride: 1},
+ {Lo: 0xAF48, Hi: 0xAF48, Stride: 1},
+ {Lo: 0xAF64, Hi: 0xAF64, Stride: 1},
+ {Lo: 0xAF80, Hi: 0xAF80, Stride: 1},
+ {Lo: 0xAF9C, Hi: 0xAF9C, Stride: 1},
+ {Lo: 0xAFB8, Hi: 0xAFB8, Stride: 1},
+ {Lo: 0xAFD4, Hi: 0xAFD4, Stride: 1},
+ {Lo: 0xAFF0, Hi: 0xAFF0, Stride: 1},
+ {Lo: 0xB00C, Hi: 0xB00C, Stride: 1},
+ {Lo: 0xB028, Hi: 0xB028, Stride: 1},
+ {Lo: 0xB044, Hi: 0xB044, Stride: 1},
+ {Lo: 0xB060, Hi: 0xB060, Stride: 1},
+ {Lo: 0xB07C, Hi: 0xB07C, Stride: 1},
+ {Lo: 0xB098, Hi: 0xB098, Stride: 1},
+ {Lo: 0xB0B4, Hi: 0xB0B4, Stride: 1},
+ {Lo: 0xB0D0, Hi: 0xB0D0, Stride: 1},
+ {Lo: 0xB0EC, Hi: 0xB0EC, Stride: 1},
+ {Lo: 0xB108, Hi: 0xB108, Stride: 1},
+ {Lo: 0xB124, Hi: 0xB124, Stride: 1},
+ {Lo: 0xB140, Hi: 0xB140, Stride: 1},
+ {Lo: 0xB15C, Hi: 0xB15C, Stride: 1},
+ {Lo: 0xB178, Hi: 0xB178, Stride: 1},
+ {Lo: 0xB194, Hi: 0xB194, Stride: 1},
+ {Lo: 0xB1B0, Hi: 0xB1B0, Stride: 1},
+ {Lo: 0xB1CC, Hi: 0xB1CC, Stride: 1},
+ {Lo: 0xB1E8, Hi: 0xB1E8, Stride: 1},
+ {Lo: 0xB204, Hi: 0xB204, Stride: 1},
+ {Lo: 0xB220, Hi: 0xB220, Stride: 1},
+ {Lo: 0xB23C, Hi: 0xB23C, Stride: 1},
+ {Lo: 0xB258, Hi: 0xB258, Stride: 1},
+ {Lo: 0xB274, Hi: 0xB274, Stride: 1},
+ {Lo: 0xB290, Hi: 0xB290, Stride: 1},
+ {Lo: 0xB2AC, Hi: 0xB2AC, Stride: 1},
+ {Lo: 0xB2C8, Hi: 0xB2C8, Stride: 1},
+ {Lo: 0xB2E4, Hi: 0xB2E4, Stride: 1},
+ {Lo: 0xB300, Hi: 0xB300, Stride: 1},
+ {Lo: 0xB31C, Hi: 0xB31C, Stride: 1},
+ {Lo: 0xB338, Hi: 0xB338, Stride: 1},
+ {Lo: 0xB354, Hi: 0xB354, Stride: 1},
+ {Lo: 0xB370, Hi: 0xB370, Stride: 1},
+ {Lo: 0xB38C, Hi: 0xB38C, Stride: 1},
+ {Lo: 0xB3A8, Hi: 0xB3A8, Stride: 1},
+ {Lo: 0xB3C4, Hi: 0xB3C4, Stride: 1},
+ {Lo: 0xB3E0, Hi: 0xB3E0, Stride: 1},
+ {Lo: 0xB3FC, Hi: 0xB3FC, Stride: 1},
+ {Lo: 0xB418, Hi: 0xB418, Stride: 1},
+ {Lo: 0xB434, Hi: 0xB434, Stride: 1},
+ {Lo: 0xB450, Hi: 0xB450, Stride: 1},
+ {Lo: 0xB46C, Hi: 0xB46C, Stride: 1},
+ {Lo: 0xB488, Hi: 0xB488, Stride: 1},
+ {Lo: 0xB4A4, Hi: 0xB4A4, Stride: 1},
+ {Lo: 0xB4C0, Hi: 0xB4C0, Stride: 1},
+ {Lo: 0xB4DC, Hi: 0xB4DC, Stride: 1},
+ {Lo: 0xB4F8, Hi: 0xB4F8, Stride: 1},
+ {Lo: 0xB514, Hi: 0xB514, Stride: 1},
+ {Lo: 0xB530, Hi: 0xB530, Stride: 1},
+ {Lo: 0xB54C, Hi: 0xB54C, Stride: 1},
+ {Lo: 0xB568, Hi: 0xB568, Stride: 1},
+ {Lo: 0xB584, Hi: 0xB584, Stride: 1},
+ {Lo: 0xB5A0, Hi: 0xB5A0, Stride: 1},
+ {Lo: 0xB5BC, Hi: 0xB5BC, Stride: 1},
+ {Lo: 0xB5D8, Hi: 0xB5D8, Stride: 1},
+ {Lo: 0xB5F4, Hi: 0xB5F4, Stride: 1},
+ {Lo: 0xB610, Hi: 0xB610, Stride: 1},
+ {Lo: 0xB62C, Hi: 0xB62C, Stride: 1},
+ {Lo: 0xB648, Hi: 0xB648, Stride: 1},
+ {Lo: 0xB664, Hi: 0xB664, Stride: 1},
+ {Lo: 0xB680, Hi: 0xB680, Stride: 1},
+ {Lo: 0xB69C, Hi: 0xB69C, Stride: 1},
+ {Lo: 0xB6B8, Hi: 0xB6B8, Stride: 1},
+ {Lo: 0xB6D4, Hi: 0xB6D4, Stride: 1},
+ {Lo: 0xB6F0, Hi: 0xB6F0, Stride: 1},
+ {Lo: 0xB70C, Hi: 0xB70C, Stride: 1},
+ {Lo: 0xB728, Hi: 0xB728, Stride: 1},
+ {Lo: 0xB744, Hi: 0xB744, Stride: 1},
+ {Lo: 0xB760, Hi: 0xB760, Stride: 1},
+ {Lo: 0xB77C, Hi: 0xB77C, Stride: 1},
+ {Lo: 0xB798, Hi: 0xB798, Stride: 1},
+ {Lo: 0xB7B4, Hi: 0xB7B4, Stride: 1},
+ {Lo: 0xB7D0, Hi: 0xB7D0, Stride: 1},
+ {Lo: 0xB7EC, Hi: 0xB7EC, Stride: 1},
+ {Lo: 0xB808, Hi: 0xB808, Stride: 1},
+ {Lo: 0xB824, Hi: 0xB824, Stride: 1},
+ {Lo: 0xB840, Hi: 0xB840, Stride: 1},
+ {Lo: 0xB85C, Hi: 0xB85C, Stride: 1},
+ {Lo: 0xB878, Hi: 0xB878, Stride: 1},
+ {Lo: 0xB894, Hi: 0xB894, Stride: 1},
+ {Lo: 0xB8B0, Hi: 0xB8B0, Stride: 1},
+ {Lo: 0xB8CC, Hi: 0xB8CC, Stride: 1},
+ {Lo: 0xB8E8, Hi: 0xB8E8, Stride: 1},
+ {Lo: 0xB904, Hi: 0xB904, Stride: 1},
+ {Lo: 0xB920, Hi: 0xB920, Stride: 1},
+ {Lo: 0xB93C, Hi: 0xB93C, Stride: 1},
+ {Lo: 0xB958, Hi: 0xB958, Stride: 1},
+ {Lo: 0xB974, Hi: 0xB974, Stride: 1},
+ {Lo: 0xB990, Hi: 0xB990, Stride: 1},
+ {Lo: 0xB9AC, Hi: 0xB9AC, Stride: 1},
+ {Lo: 0xB9C8, Hi: 0xB9C8, Stride: 1},
+ {Lo: 0xB9E4, Hi: 0xB9E4, Stride: 1},
+ {Lo: 0xBA00, Hi: 0xBA00, Stride: 1},
+ {Lo: 0xBA1C, Hi: 0xBA1C, Stride: 1},
+ {Lo: 0xBA38, Hi: 0xBA38, Stride: 1},
+ {Lo: 0xBA54, Hi: 0xBA54, Stride: 1},
+ {Lo: 0xBA70, Hi: 0xBA70, Stride: 1},
+ {Lo: 0xBA8C, Hi: 0xBA8C, Stride: 1},
+ {Lo: 0xBAA8, Hi: 0xBAA8, Stride: 1},
+ {Lo: 0xBAC4, Hi: 0xBAC4, Stride: 1},
+ {Lo: 0xBAE0, Hi: 0xBAE0, Stride: 1},
+ {Lo: 0xBAFC, Hi: 0xBAFC, Stride: 1},
+ {Lo: 0xBB18, Hi: 0xBB18, Stride: 1},
+ {Lo: 0xBB34, Hi: 0xBB34, Stride: 1},
+ {Lo: 0xBB50, Hi: 0xBB50, Stride: 1},
+ {Lo: 0xBB6C, Hi: 0xBB6C, Stride: 1},
+ {Lo: 0xBB88, Hi: 0xBB88, Stride: 1},
+ {Lo: 0xBBA4, Hi: 0xBBA4, Stride: 1},
+ {Lo: 0xBBC0, Hi: 0xBBC0, Stride: 1},
+ {Lo: 0xBBDC, Hi: 0xBBDC, Stride: 1},
+ {Lo: 0xBBF8, Hi: 0xBBF8, Stride: 1},
+ {Lo: 0xBC14, Hi: 0xBC14, Stride: 1},
+ {Lo: 0xBC30, Hi: 0xBC30, Stride: 1},
+ {Lo: 0xBC4C, Hi: 0xBC4C, Stride: 1},
+ {Lo: 0xBC68, Hi: 0xBC68, Stride: 1},
+ {Lo: 0xBC84, Hi: 0xBC84, Stride: 1},
+ {Lo: 0xBCA0, Hi: 0xBCA0, Stride: 1},
+ {Lo: 0xBCBC, Hi: 0xBCBC, Stride: 1},
+ {Lo: 0xBCD8, Hi: 0xBCD8, Stride: 1},
+ {Lo: 0xBCF4, Hi: 0xBCF4, Stride: 1},
+ {Lo: 0xBD10, Hi: 0xBD10, Stride: 1},
+ {Lo: 0xBD2C, Hi: 0xBD2C, Stride: 1},
+ {Lo: 0xBD48, Hi: 0xBD48, Stride: 1},
+ {Lo: 0xBD64, Hi: 0xBD64, Stride: 1},
+ {Lo: 0xBD80, Hi: 0xBD80, Stride: 1},
+ {Lo: 0xBD9C, Hi: 0xBD9C, Stride: 1},
+ {Lo: 0xBDB8, Hi: 0xBDB8, Stride: 1},
+ {Lo: 0xBDD4, Hi: 0xBDD4, Stride: 1},
+ {Lo: 0xBDF0, Hi: 0xBDF0, Stride: 1},
+ {Lo: 0xBE0C, Hi: 0xBE0C, Stride: 1},
+ {Lo: 0xBE28, Hi: 0xBE28, Stride: 1},
+ {Lo: 0xBE44, Hi: 0xBE44, Stride: 1},
+ {Lo: 0xBE60, Hi: 0xBE60, Stride: 1},
+ {Lo: 0xBE7C, Hi: 0xBE7C, Stride: 1},
+ {Lo: 0xBE98, Hi: 0xBE98, Stride: 1},
+ {Lo: 0xBEB4, Hi: 0xBEB4, Stride: 1},
+ {Lo: 0xBED0, Hi: 0xBED0, Stride: 1},
+ {Lo: 0xBEEC, Hi: 0xBEEC, Stride: 1},
+ {Lo: 0xBF08, Hi: 0xBF08, Stride: 1},
+ {Lo: 0xBF24, Hi: 0xBF24, Stride: 1},
+ {Lo: 0xBF40, Hi: 0xBF40, Stride: 1},
+ {Lo: 0xBF5C, Hi: 0xBF5C, Stride: 1},
+ {Lo: 0xBF78, Hi: 0xBF78, Stride: 1},
+ {Lo: 0xBF94, Hi: 0xBF94, Stride: 1},
+ {Lo: 0xBFB0, Hi: 0xBFB0, Stride: 1},
+ {Lo: 0xBFCC, Hi: 0xBFCC, Stride: 1},
+ {Lo: 0xBFE8, Hi: 0xBFE8, Stride: 1},
+ {Lo: 0xC004, Hi: 0xC004, Stride: 1},
+ {Lo: 0xC020, Hi: 0xC020, Stride: 1},
+ {Lo: 0xC03C, Hi: 0xC03C, Stride: 1},
+ {Lo: 0xC058, Hi: 0xC058, Stride: 1},
+ {Lo: 0xC074, Hi: 0xC074, Stride: 1},
+ {Lo: 0xC090, Hi: 0xC090, Stride: 1},
+ {Lo: 0xC0AC, Hi: 0xC0AC, Stride: 1},
+ {Lo: 0xC0C8, Hi: 0xC0C8, Stride: 1},
+ {Lo: 0xC0E4, Hi: 0xC0E4, Stride: 1},
+ {Lo: 0xC100, Hi: 0xC100, Stride: 1},
+ {Lo: 0xC11C, Hi: 0xC11C, Stride: 1},
+ {Lo: 0xC138, Hi: 0xC138, Stride: 1},
+ {Lo: 0xC154, Hi: 0xC154, Stride: 1},
+ {Lo: 0xC170, Hi: 0xC170, Stride: 1},
+ {Lo: 0xC18C, Hi: 0xC18C, Stride: 1},
+ {Lo: 0xC1A8, Hi: 0xC1A8, Stride: 1},
+ {Lo: 0xC1C4, Hi: 0xC1C4, Stride: 1},
+ {Lo: 0xC1E0, Hi: 0xC1E0, Stride: 1},
+ {Lo: 0xC1FC, Hi: 0xC1FC, Stride: 1},
+ {Lo: 0xC218, Hi: 0xC218, Stride: 1},
+ {Lo: 0xC234, Hi: 0xC234, Stride: 1},
+ {Lo: 0xC250, Hi: 0xC250, Stride: 1},
+ {Lo: 0xC26C, Hi: 0xC26C, Stride: 1},
+ {Lo: 0xC288, Hi: 0xC288, Stride: 1},
+ {Lo: 0xC2A4, Hi: 0xC2A4, Stride: 1},
+ {Lo: 0xC2C0, Hi: 0xC2C0, Stride: 1},
+ {Lo: 0xC2DC, Hi: 0xC2DC, Stride: 1},
+ {Lo: 0xC2F8, Hi: 0xC2F8, Stride: 1},
+ {Lo: 0xC314, Hi: 0xC314, Stride: 1},
+ {Lo: 0xC330, Hi: 0xC330, Stride: 1},
+ {Lo: 0xC34C, Hi: 0xC34C, Stride: 1},
+ {Lo: 0xC368, Hi: 0xC368, Stride: 1},
+ {Lo: 0xC384, Hi: 0xC384, Stride: 1},
+ {Lo: 0xC3A0, Hi: 0xC3A0, Stride: 1},
+ {Lo: 0xC3BC, Hi: 0xC3BC, Stride: 1},
+ {Lo: 0xC3D8, Hi: 0xC3D8, Stride: 1},
+ {Lo: 0xC3F4, Hi: 0xC3F4, Stride: 1},
+ {Lo: 0xC410, Hi: 0xC410, Stride: 1},
+ {Lo: 0xC42C, Hi: 0xC42C, Stride: 1},
+ {Lo: 0xC448, Hi: 0xC448, Stride: 1},
+ {Lo: 0xC464, Hi: 0xC464, Stride: 1},
+ {Lo: 0xC480, Hi: 0xC480, Stride: 1},
+ {Lo: 0xC49C, Hi: 0xC49C, Stride: 1},
+ {Lo: 0xC4B8, Hi: 0xC4B8, Stride: 1},
+ {Lo: 0xC4D4, Hi: 0xC4D4, Stride: 1},
+ {Lo: 0xC4F0, Hi: 0xC4F0, Stride: 1},
+ {Lo: 0xC50C, Hi: 0xC50C, Stride: 1},
+ {Lo: 0xC528, Hi: 0xC528, Stride: 1},
+ {Lo: 0xC544, Hi: 0xC544, Stride: 1},
+ {Lo: 0xC560, Hi: 0xC560, Stride: 1},
+ {Lo: 0xC57C, Hi: 0xC57C, Stride: 1},
+ {Lo: 0xC598, Hi: 0xC598, Stride: 1},
+ {Lo: 0xC5B4, Hi: 0xC5B4, Stride: 1},
+ {Lo: 0xC5D0, Hi: 0xC5D0, Stride: 1},
+ {Lo: 0xC5EC, Hi: 0xC5EC, Stride: 1},
+ {Lo: 0xC608, Hi: 0xC608, Stride: 1},
+ {Lo: 0xC624, Hi: 0xC624, Stride: 1},
+ {Lo: 0xC640, Hi: 0xC640, Stride: 1},
+ {Lo: 0xC65C, Hi: 0xC65C, Stride: 1},
+ {Lo: 0xC678, Hi: 0xC678, Stride: 1},
+ {Lo: 0xC694, Hi: 0xC694, Stride: 1},
+ {Lo: 0xC6B0, Hi: 0xC6B0, Stride: 1},
+ {Lo: 0xC6CC, Hi: 0xC6CC, Stride: 1},
+ {Lo: 0xC6E8, Hi: 0xC6E8, Stride: 1},
+ {Lo: 0xC704, Hi: 0xC704, Stride: 1},
+ {Lo: 0xC720, Hi: 0xC720, Stride: 1},
+ {Lo: 0xC73C, Hi: 0xC73C, Stride: 1},
+ {Lo: 0xC758, Hi: 0xC758, Stride: 1},
+ {Lo: 0xC774, Hi: 0xC774, Stride: 1},
+ {Lo: 0xC790, Hi: 0xC790, Stride: 1},
+ {Lo: 0xC7AC, Hi: 0xC7AC, Stride: 1},
+ {Lo: 0xC7C8, Hi: 0xC7C8, Stride: 1},
+ {Lo: 0xC7E4, Hi: 0xC7E4, Stride: 1},
+ {Lo: 0xC800, Hi: 0xC800, Stride: 1},
+ {Lo: 0xC81C, Hi: 0xC81C, Stride: 1},
+ {Lo: 0xC838, Hi: 0xC838, Stride: 1},
+ {Lo: 0xC854, Hi: 0xC854, Stride: 1},
+ {Lo: 0xC870, Hi: 0xC870, Stride: 1},
+ {Lo: 0xC88C, Hi: 0xC88C, Stride: 1},
+ {Lo: 0xC8A8, Hi: 0xC8A8, Stride: 1},
+ {Lo: 0xC8C4, Hi: 0xC8C4, Stride: 1},
+ {Lo: 0xC8E0, Hi: 0xC8E0, Stride: 1},
+ {Lo: 0xC8FC, Hi: 0xC8FC, Stride: 1},
+ {Lo: 0xC918, Hi: 0xC918, Stride: 1},
+ {Lo: 0xC934, Hi: 0xC934, Stride: 1},
+ {Lo: 0xC950, Hi: 0xC950, Stride: 1},
+ {Lo: 0xC96C, Hi: 0xC96C, Stride: 1},
+ {Lo: 0xC988, Hi: 0xC988, Stride: 1},
+ {Lo: 0xC9A4, Hi: 0xC9A4, Stride: 1},
+ {Lo: 0xC9C0, Hi: 0xC9C0, Stride: 1},
+ {Lo: 0xC9DC, Hi: 0xC9DC, Stride: 1},
+ {Lo: 0xC9F8, Hi: 0xC9F8, Stride: 1},
+ {Lo: 0xCA14, Hi: 0xCA14, Stride: 1},
+ {Lo: 0xCA30, Hi: 0xCA30, Stride: 1},
+ {Lo: 0xCA4C, Hi: 0xCA4C, Stride: 1},
+ {Lo: 0xCA68, Hi: 0xCA68, Stride: 1},
+ {Lo: 0xCA84, Hi: 0xCA84, Stride: 1},
+ {Lo: 0xCAA0, Hi: 0xCAA0, Stride: 1},
+ {Lo: 0xCABC, Hi: 0xCABC, Stride: 1},
+ {Lo: 0xCAD8, Hi: 0xCAD8, Stride: 1},
+ {Lo: 0xCAF4, Hi: 0xCAF4, Stride: 1},
+ {Lo: 0xCB10, Hi: 0xCB10, Stride: 1},
+ {Lo: 0xCB2C, Hi: 0xCB2C, Stride: 1},
+ {Lo: 0xCB48, Hi: 0xCB48, Stride: 1},
+ {Lo: 0xCB64, Hi: 0xCB64, Stride: 1},
+ {Lo: 0xCB80, Hi: 0xCB80, Stride: 1},
+ {Lo: 0xCB9C, Hi: 0xCB9C, Stride: 1},
+ {Lo: 0xCBB8, Hi: 0xCBB8, Stride: 1},
+ {Lo: 0xCBD4, Hi: 0xCBD4, Stride: 1},
+ {Lo: 0xCBF0, Hi: 0xCBF0, Stride: 1},
+ {Lo: 0xCC0C, Hi: 0xCC0C, Stride: 1},
+ {Lo: 0xCC28, Hi: 0xCC28, Stride: 1},
+ {Lo: 0xCC44, Hi: 0xCC44, Stride: 1},
+ {Lo: 0xCC60, Hi: 0xCC60, Stride: 1},
+ {Lo: 0xCC7C, Hi: 0xCC7C, Stride: 1},
+ {Lo: 0xCC98, Hi: 0xCC98, Stride: 1},
+ {Lo: 0xCCB4, Hi: 0xCCB4, Stride: 1},
+ {Lo: 0xCCD0, Hi: 0xCCD0, Stride: 1},
+ {Lo: 0xCCEC, Hi: 0xCCEC, Stride: 1},
+ {Lo: 0xCD08, Hi: 0xCD08, Stride: 1},
+ {Lo: 0xCD24, Hi: 0xCD24, Stride: 1},
+ {Lo: 0xCD40, Hi: 0xCD40, Stride: 1},
+ {Lo: 0xCD5C, Hi: 0xCD5C, Stride: 1},
+ {Lo: 0xCD78, Hi: 0xCD78, Stride: 1},
+ {Lo: 0xCD94, Hi: 0xCD94, Stride: 1},
+ {Lo: 0xCDB0, Hi: 0xCDB0, Stride: 1},
+ {Lo: 0xCDCC, Hi: 0xCDCC, Stride: 1},
+ {Lo: 0xCDE8, Hi: 0xCDE8, Stride: 1},
+ {Lo: 0xCE04, Hi: 0xCE04, Stride: 1},
+ {Lo: 0xCE20, Hi: 0xCE20, Stride: 1},
+ {Lo: 0xCE3C, Hi: 0xCE3C, Stride: 1},
+ {Lo: 0xCE58, Hi: 0xCE58, Stride: 1},
+ {Lo: 0xCE74, Hi: 0xCE74, Stride: 1},
+ {Lo: 0xCE90, Hi: 0xCE90, Stride: 1},
+ {Lo: 0xCEAC, Hi: 0xCEAC, Stride: 1},
+ {Lo: 0xCEC8, Hi: 0xCEC8, Stride: 1},
+ {Lo: 0xCEE4, Hi: 0xCEE4, Stride: 1},
+ {Lo: 0xCF00, Hi: 0xCF00, Stride: 1},
+ {Lo: 0xCF1C, Hi: 0xCF1C, Stride: 1},
+ {Lo: 0xCF38, Hi: 0xCF38, Stride: 1},
+ {Lo: 0xCF54, Hi: 0xCF54, Stride: 1},
+ {Lo: 0xCF70, Hi: 0xCF70, Stride: 1},
+ {Lo: 0xCF8C, Hi: 0xCF8C, Stride: 1},
+ {Lo: 0xCFA8, Hi: 0xCFA8, Stride: 1},
+ {Lo: 0xCFC4, Hi: 0xCFC4, Stride: 1},
+ {Lo: 0xCFE0, Hi: 0xCFE0, Stride: 1},
+ {Lo: 0xCFFC, Hi: 0xCFFC, Stride: 1},
+ {Lo: 0xD018, Hi: 0xD018, Stride: 1},
+ {Lo: 0xD034, Hi: 0xD034, Stride: 1},
+ {Lo: 0xD050, Hi: 0xD050, Stride: 1},
+ {Lo: 0xD06C, Hi: 0xD06C, Stride: 1},
+ {Lo: 0xD088, Hi: 0xD088, Stride: 1},
+ {Lo: 0xD0A4, Hi: 0xD0A4, Stride: 1},
+ {Lo: 0xD0C0, Hi: 0xD0C0, Stride: 1},
+ {Lo: 0xD0DC, Hi: 0xD0DC, Stride: 1},
+ {Lo: 0xD0F8, Hi: 0xD0F8, Stride: 1},
+ {Lo: 0xD114, Hi: 0xD114, Stride: 1},
+ {Lo: 0xD130, Hi: 0xD130, Stride: 1},
+ {Lo: 0xD14C, Hi: 0xD14C, Stride: 1},
+ {Lo: 0xD168, Hi: 0xD168, Stride: 1},
+ {Lo: 0xD184, Hi: 0xD184, Stride: 1},
+ {Lo: 0xD1A0, Hi: 0xD1A0, Stride: 1},
+ {Lo: 0xD1BC, Hi: 0xD1BC, Stride: 1},
+ {Lo: 0xD1D8, Hi: 0xD1D8, Stride: 1},
+ {Lo: 0xD1F4, Hi: 0xD1F4, Stride: 1},
+ {Lo: 0xD210, Hi: 0xD210, Stride: 1},
+ {Lo: 0xD22C, Hi: 0xD22C, Stride: 1},
+ {Lo: 0xD248, Hi: 0xD248, Stride: 1},
+ {Lo: 0xD264, Hi: 0xD264, Stride: 1},
+ {Lo: 0xD280, Hi: 0xD280, Stride: 1},
+ {Lo: 0xD29C, Hi: 0xD29C, Stride: 1},
+ {Lo: 0xD2B8, Hi: 0xD2B8, Stride: 1},
+ {Lo: 0xD2D4, Hi: 0xD2D4, Stride: 1},
+ {Lo: 0xD2F0, Hi: 0xD2F0, Stride: 1},
+ {Lo: 0xD30C, Hi: 0xD30C, Stride: 1},
+ {Lo: 0xD328, Hi: 0xD328, Stride: 1},
+ {Lo: 0xD344, Hi: 0xD344, Stride: 1},
+ {Lo: 0xD360, Hi: 0xD360, Stride: 1},
+ {Lo: 0xD37C, Hi: 0xD37C, Stride: 1},
+ {Lo: 0xD398, Hi: 0xD398, Stride: 1},
+ {Lo: 0xD3B4, Hi: 0xD3B4, Stride: 1},
+ {Lo: 0xD3D0, Hi: 0xD3D0, Stride: 1},
+ {Lo: 0xD3EC, Hi: 0xD3EC, Stride: 1},
+ {Lo: 0xD408, Hi: 0xD408, Stride: 1},
+ {Lo: 0xD424, Hi: 0xD424, Stride: 1},
+ {Lo: 0xD440, Hi: 0xD440, Stride: 1},
+ {Lo: 0xD45C, Hi: 0xD45C, Stride: 1},
+ {Lo: 0xD478, Hi: 0xD478, Stride: 1},
+ {Lo: 0xD494, Hi: 0xD494, Stride: 1},
+ {Lo: 0xD4B0, Hi: 0xD4B0, Stride: 1},
+ {Lo: 0xD4CC, Hi: 0xD4CC, Stride: 1},
+ {Lo: 0xD4E8, Hi: 0xD4E8, Stride: 1},
+ {Lo: 0xD504, Hi: 0xD504, Stride: 1},
+ {Lo: 0xD520, Hi: 0xD520, Stride: 1},
+ {Lo: 0xD53C, Hi: 0xD53C, Stride: 1},
+ {Lo: 0xD558, Hi: 0xD558, Stride: 1},
+ {Lo: 0xD574, Hi: 0xD574, Stride: 1},
+ {Lo: 0xD590, Hi: 0xD590, Stride: 1},
+ {Lo: 0xD5AC, Hi: 0xD5AC, Stride: 1},
+ {Lo: 0xD5C8, Hi: 0xD5C8, Stride: 1},
+ {Lo: 0xD5E4, Hi: 0xD5E4, Stride: 1},
+ {Lo: 0xD600, Hi: 0xD600, Stride: 1},
+ {Lo: 0xD61C, Hi: 0xD61C, Stride: 1},
+ {Lo: 0xD638, Hi: 0xD638, Stride: 1},
+ {Lo: 0xD654, Hi: 0xD654, Stride: 1},
+ {Lo: 0xD670, Hi: 0xD670, Stride: 1},
+ {Lo: 0xD68C, Hi: 0xD68C, Stride: 1},
+ {Lo: 0xD6A8, Hi: 0xD6A8, Stride: 1},
+ {Lo: 0xD6C4, Hi: 0xD6C4, Stride: 1},
+ {Lo: 0xD6E0, Hi: 0xD6E0, Stride: 1},
+ {Lo: 0xD6FC, Hi: 0xD6FC, Stride: 1},
+ {Lo: 0xD718, Hi: 0xD718, Stride: 1},
+ {Lo: 0xD734, Hi: 0xD734, Stride: 1},
+ {Lo: 0xD750, Hi: 0xD750, Stride: 1},
+ {Lo: 0xD76C, Hi: 0xD76C, Stride: 1},
+ {Lo: 0xD788, Hi: 0xD788, Stride: 1},
+ },
+}
+
+var unicodeAliasGrapheme_Cluster_Break_LVT = &unicode.RangeTable{
+ R16: []unicode.Range16{
+ {Lo: 0xAC01, Hi: 0xAC1B, Stride: 1},
+ {Lo: 0xAC1D, Hi: 0xAC37, Stride: 1},
+ {Lo: 0xAC39, Hi: 0xAC53, Stride: 1},
+ {Lo: 0xAC55, Hi: 0xAC6F, Stride: 1},
+ {Lo: 0xAC71, Hi: 0xAC8B, Stride: 1},
+ {Lo: 0xAC8D, Hi: 0xACA7, Stride: 1},
+ {Lo: 0xACA9, Hi: 0xACC3, Stride: 1},
+ {Lo: 0xACC5, Hi: 0xACDF, Stride: 1},
+ {Lo: 0xACE1, Hi: 0xACFB, Stride: 1},
+ {Lo: 0xACFD, Hi: 0xAD17, Stride: 1},
+ {Lo: 0xAD19, Hi: 0xAD33, Stride: 1},
+ {Lo: 0xAD35, Hi: 0xAD4F, Stride: 1},
+ {Lo: 0xAD51, Hi: 0xAD6B, Stride: 1},
+ {Lo: 0xAD6D, Hi: 0xAD87, Stride: 1},
+ {Lo: 0xAD89, Hi: 0xADA3, Stride: 1},
+ {Lo: 0xADA5, Hi: 0xADBF, Stride: 1},
+ {Lo: 0xADC1, Hi: 0xADDB, Stride: 1},
+ {Lo: 0xADDD, Hi: 0xADF7, Stride: 1},
+ {Lo: 0xADF9, Hi: 0xAE13, Stride: 1},
+ {Lo: 0xAE15, Hi: 0xAE2F, Stride: 1},
+ {Lo: 0xAE31, Hi: 0xAE4B, Stride: 1},
+ {Lo: 0xAE4D, Hi: 0xAE67, Stride: 1},
+ {Lo: 0xAE69, Hi: 0xAE83, Stride: 1},
+ {Lo: 0xAE85, Hi: 0xAE9F, Stride: 1},
+ {Lo: 0xAEA1, Hi: 0xAEBB, Stride: 1},
+ {Lo: 0xAEBD, Hi: 0xAED7, Stride: 1},
+ {Lo: 0xAED9, Hi: 0xAEF3, Stride: 1},
+ {Lo: 0xAEF5, Hi: 0xAF0F, Stride: 1},
+ {Lo: 0xAF11, Hi: 0xAF2B, Stride: 1},
+ {Lo: 0xAF2D, Hi: 0xAF47, Stride: 1},
+ {Lo: 0xAF49, Hi: 0xAF63, Stride: 1},
+ {Lo: 0xAF65, Hi: 0xAF7F, Stride: 1},
+ {Lo: 0xAF81, Hi: 0xAF9B, Stride: 1},
+ {Lo: 0xAF9D, Hi: 0xAFB7, Stride: 1},
+ {Lo: 0xAFB9, Hi: 0xAFD3, Stride: 1},
+ {Lo: 0xAFD5, Hi: 0xAFEF, Stride: 1},
+ {Lo: 0xAFF1, Hi: 0xB00B, Stride: 1},
+ {Lo: 0xB00D, Hi: 0xB027, Stride: 1},
+ {Lo: 0xB029, Hi: 0xB043, Stride: 1},
+ {Lo: 0xB045, Hi: 0xB05F, Stride: 1},
+ {Lo: 0xB061, Hi: 0xB07B, Stride: 1},
+ {Lo: 0xB07D, Hi: 0xB097, Stride: 1},
+ {Lo: 0xB099, Hi: 0xB0B3, Stride: 1},
+ {Lo: 0xB0B5, Hi: 0xB0CF, Stride: 1},
+ {Lo: 0xB0D1, Hi: 0xB0EB, Stride: 1},
+ {Lo: 0xB0ED, Hi: 0xB107, Stride: 1},
+ {Lo: 0xB109, Hi: 0xB123, Stride: 1},
+ {Lo: 0xB125, Hi: 0xB13F, Stride: 1},
+ {Lo: 0xB141, Hi: 0xB15B, Stride: 1},
+ {Lo: 0xB15D, Hi: 0xB177, Stride: 1},
+ {Lo: 0xB179, Hi: 0xB193, Stride: 1},
+ {Lo: 0xB195, Hi: 0xB1AF, Stride: 1},
+ {Lo: 0xB1B1, Hi: 0xB1CB, Stride: 1},
+ {Lo: 0xB1CD, Hi: 0xB1E7, Stride: 1},
+ {Lo: 0xB1E9, Hi: 0xB203, Stride: 1},
+ {Lo: 0xB205, Hi: 0xB21F, Stride: 1},
+ {Lo: 0xB221, Hi: 0xB23B, Stride: 1},
+ {Lo: 0xB23D, Hi: 0xB257, Stride: 1},
+ {Lo: 0xB259, Hi: 0xB273, Stride: 1},
+ {Lo: 0xB275, Hi: 0xB28F, Stride: 1},
+ {Lo: 0xB291, Hi: 0xB2AB, Stride: 1},
+ {Lo: 0xB2AD, Hi: 0xB2C7, Stride: 1},
+ {Lo: 0xB2C9, Hi: 0xB2E3, Stride: 1},
+ {Lo: 0xB2E5, Hi: 0xB2FF, Stride: 1},
+ {Lo: 0xB301, Hi: 0xB31B, Stride: 1},
+ {Lo: 0xB31D, Hi: 0xB337, Stride: 1},
+ {Lo: 0xB339, Hi: 0xB353, Stride: 1},
+ {Lo: 0xB355, Hi: 0xB36F, Stride: 1},
+ {Lo: 0xB371, Hi: 0xB38B, Stride: 1},
+ {Lo: 0xB38D, Hi: 0xB3A7, Stride: 1},
+ {Lo: 0xB3A9, Hi: 0xB3C3, Stride: 1},
+ {Lo: 0xB3C5, Hi: 0xB3DF, Stride: 1},
+ {Lo: 0xB3E1, Hi: 0xB3FB, Stride: 1},
+ {Lo: 0xB3FD, Hi: 0xB417, Stride: 1},
+ {Lo: 0xB419, Hi: 0xB433, Stride: 1},
+ {Lo: 0xB435, Hi: 0xB44F, Stride: 1},
+ {Lo: 0xB451, Hi: 0xB46B, Stride: 1},
+ {Lo: 0xB46D, Hi: 0xB487, Stride: 1},
+ {Lo: 0xB489, Hi: 0xB4A3, Stride: 1},
+ {Lo: 0xB4A5, Hi: 0xB4BF, Stride: 1},
+ {Lo: 0xB4C1, Hi: 0xB4DB, Stride: 1},
+ {Lo: 0xB4DD, Hi: 0xB4F7, Stride: 1},
+ {Lo: 0xB4F9, Hi: 0xB513, Stride: 1},
+ {Lo: 0xB515, Hi: 0xB52F, Stride: 1},
+ {Lo: 0xB531, Hi: 0xB54B, Stride: 1},
+ {Lo: 0xB54D, Hi: 0xB567, Stride: 1},
+ {Lo: 0xB569, Hi: 0xB583, Stride: 1},
+ {Lo: 0xB585, Hi: 0xB59F, Stride: 1},
+ {Lo: 0xB5A1, Hi: 0xB5BB, Stride: 1},
+ {Lo: 0xB5BD, Hi: 0xB5D7, Stride: 1},
+ {Lo: 0xB5D9, Hi: 0xB5F3, Stride: 1},
+ {Lo: 0xB5F5, Hi: 0xB60F, Stride: 1},
+ {Lo: 0xB611, Hi: 0xB62B, Stride: 1},
+ {Lo: 0xB62D, Hi: 0xB647, Stride: 1},
+ {Lo: 0xB649, Hi: 0xB663, Stride: 1},
+ {Lo: 0xB665, Hi: 0xB67F, Stride: 1},
+ {Lo: 0xB681, Hi: 0xB69B, Stride: 1},
+ {Lo: 0xB69D, Hi: 0xB6B7, Stride: 1},
+ {Lo: 0xB6B9, Hi: 0xB6D3, Stride: 1},
+ {Lo: 0xB6D5, Hi: 0xB6EF, Stride: 1},
+ {Lo: 0xB6F1, Hi: 0xB70B, Stride: 1},
+ {Lo: 0xB70D, Hi: 0xB727, Stride: 1},
+ {Lo: 0xB729, Hi: 0xB743, Stride: 1},
+ {Lo: 0xB745, Hi: 0xB75F, Stride: 1},
+ {Lo: 0xB761, Hi: 0xB77B, Stride: 1},
+ {Lo: 0xB77D, Hi: 0xB797, Stride: 1},
+ {Lo: 0xB799, Hi: 0xB7B3, Stride: 1},
+ {Lo: 0xB7B5, Hi: 0xB7CF, Stride: 1},
+ {Lo: 0xB7D1, Hi: 0xB7EB, Stride: 1},
+ {Lo: 0xB7ED, Hi: 0xB807, Stride: 1},
+ {Lo: 0xB809, Hi: 0xB823, Stride: 1},
+ {Lo: 0xB825, Hi: 0xB83F, Stride: 1},
+ {Lo: 0xB841, Hi: 0xB85B, Stride: 1},
+ {Lo: 0xB85D, Hi: 0xB877, Stride: 1},
+ {Lo: 0xB879, Hi: 0xB893, Stride: 1},
+ {Lo: 0xB895, Hi: 0xB8AF, Stride: 1},
+ {Lo: 0xB8B1, Hi: 0xB8CB, Stride: 1},
+ {Lo: 0xB8CD, Hi: 0xB8E7, Stride: 1},
+ {Lo: 0xB8E9, Hi: 0xB903, Stride: 1},
+ {Lo: 0xB905, Hi: 0xB91F, Stride: 1},
+ {Lo: 0xB921, Hi: 0xB93B, Stride: 1},
+ {Lo: 0xB93D, Hi: 0xB957, Stride: 1},
+ {Lo: 0xB959, Hi: 0xB973, Stride: 1},
+ {Lo: 0xB975, Hi: 0xB98F, Stride: 1},
+ {Lo: 0xB991, Hi: 0xB9AB, Stride: 1},
+ {Lo: 0xB9AD, Hi: 0xB9C7, Stride: 1},
+ {Lo: 0xB9C9, Hi: 0xB9E3, Stride: 1},
+ {Lo: 0xB9E5, Hi: 0xB9FF, Stride: 1},
+ {Lo: 0xBA01, Hi: 0xBA1B, Stride: 1},
+ {Lo: 0xBA1D, Hi: 0xBA37, Stride: 1},
+ {Lo: 0xBA39, Hi: 0xBA53, Stride: 1},
+ {Lo: 0xBA55, Hi: 0xBA6F, Stride: 1},
+ {Lo: 0xBA71, Hi: 0xBA8B, Stride: 1},
+ {Lo: 0xBA8D, Hi: 0xBAA7, Stride: 1},
+ {Lo: 0xBAA9, Hi: 0xBAC3, Stride: 1},
+ {Lo: 0xBAC5, Hi: 0xBADF, Stride: 1},
+ {Lo: 0xBAE1, Hi: 0xBAFB, Stride: 1},
+ {Lo: 0xBAFD, Hi: 0xBB17, Stride: 1},
+ {Lo: 0xBB19, Hi: 0xBB33, Stride: 1},
+ {Lo: 0xBB35, Hi: 0xBB4F, Stride: 1},
+ {Lo: 0xBB51, Hi: 0xBB6B, Stride: 1},
+ {Lo: 0xBB6D, Hi: 0xBB87, Stride: 1},
+ {Lo: 0xBB89, Hi: 0xBBA3, Stride: 1},
+ {Lo: 0xBBA5, Hi: 0xBBBF, Stride: 1},
+ {Lo: 0xBBC1, Hi: 0xBBDB, Stride: 1},
+ {Lo: 0xBBDD, Hi: 0xBBF7, Stride: 1},
+ {Lo: 0xBBF9, Hi: 0xBC13, Stride: 1},
+ {Lo: 0xBC15, Hi: 0xBC2F, Stride: 1},
+ {Lo: 0xBC31, Hi: 0xBC4B, Stride: 1},
+ {Lo: 0xBC4D, Hi: 0xBC67, Stride: 1},
+ {Lo: 0xBC69, Hi: 0xBC83, Stride: 1},
+ {Lo: 0xBC85, Hi: 0xBC9F, Stride: 1},
+ {Lo: 0xBCA1, Hi: 0xBCBB, Stride: 1},
+ {Lo: 0xBCBD, Hi: 0xBCD7, Stride: 1},
+ {Lo: 0xBCD9, Hi: 0xBCF3, Stride: 1},
+ {Lo: 0xBCF5, Hi: 0xBD0F, Stride: 1},
+ {Lo: 0xBD11, Hi: 0xBD2B, Stride: 1},
+ {Lo: 0xBD2D, Hi: 0xBD47, Stride: 1},
+ {Lo: 0xBD49, Hi: 0xBD63, Stride: 1},
+ {Lo: 0xBD65, Hi: 0xBD7F, Stride: 1},
+ {Lo: 0xBD81, Hi: 0xBD9B, Stride: 1},
+ {Lo: 0xBD9D, Hi: 0xBDB7, Stride: 1},
+ {Lo: 0xBDB9, Hi: 0xBDD3, Stride: 1},
+ {Lo: 0xBDD5, Hi: 0xBDEF, Stride: 1},
+ {Lo: 0xBDF1, Hi: 0xBE0B, Stride: 1},
+ {Lo: 0xBE0D, Hi: 0xBE27, Stride: 1},
+ {Lo: 0xBE29, Hi: 0xBE43, Stride: 1},
+ {Lo: 0xBE45, Hi: 0xBE5F, Stride: 1},
+ {Lo: 0xBE61, Hi: 0xBE7B, Stride: 1},
+ {Lo: 0xBE7D, Hi: 0xBE97, Stride: 1},
+ {Lo: 0xBE99, Hi: 0xBEB3, Stride: 1},
+ {Lo: 0xBEB5, Hi: 0xBECF, Stride: 1},
+ {Lo: 0xBED1, Hi: 0xBEEB, Stride: 1},
+ {Lo: 0xBEED, Hi: 0xBF07, Stride: 1},
+ {Lo: 0xBF09, Hi: 0xBF23, Stride: 1},
+ {Lo: 0xBF25, Hi: 0xBF3F, Stride: 1},
+ {Lo: 0xBF41, Hi: 0xBF5B, Stride: 1},
+ {Lo: 0xBF5D, Hi: 0xBF77, Stride: 1},
+ {Lo: 0xBF79, Hi: 0xBF93, Stride: 1},
+ {Lo: 0xBF95, Hi: 0xBFAF, Stride: 1},
+ {Lo: 0xBFB1, Hi: 0xBFCB, Stride: 1},
+ {Lo: 0xBFCD, Hi: 0xBFE7, Stride: 1},
+ {Lo: 0xBFE9, Hi: 0xC003, Stride: 1},
+ {Lo: 0xC005, Hi: 0xC01F, Stride: 1},
+ {Lo: 0xC021, Hi: 0xC03B, Stride: 1},
+ {Lo: 0xC03D, Hi: 0xC057, Stride: 1},
+ {Lo: 0xC059, Hi: 0xC073, Stride: 1},
+ {Lo: 0xC075, Hi: 0xC08F, Stride: 1},
+ {Lo: 0xC091, Hi: 0xC0AB, Stride: 1},
+ {Lo: 0xC0AD, Hi: 0xC0C7, Stride: 1},
+ {Lo: 0xC0C9, Hi: 0xC0E3, Stride: 1},
+ {Lo: 0xC0E5, Hi: 0xC0FF, Stride: 1},
+ {Lo: 0xC101, Hi: 0xC11B, Stride: 1},
+ {Lo: 0xC11D, Hi: 0xC137, Stride: 1},
+ {Lo: 0xC139, Hi: 0xC153, Stride: 1},
+ {Lo: 0xC155, Hi: 0xC16F, Stride: 1},
+ {Lo: 0xC171, Hi: 0xC18B, Stride: 1},
+ {Lo: 0xC18D, Hi: 0xC1A7, Stride: 1},
+ {Lo: 0xC1A9, Hi: 0xC1C3, Stride: 1},
+ {Lo: 0xC1C5, Hi: 0xC1DF, Stride: 1},
+ {Lo: 0xC1E1, Hi: 0xC1FB, Stride: 1},
+ {Lo: 0xC1FD, Hi: 0xC217, Stride: 1},
+ {Lo: 0xC219, Hi: 0xC233, Stride: 1},
+ {Lo: 0xC235, Hi: 0xC24F, Stride: 1},
+ {Lo: 0xC251, Hi: 0xC26B, Stride: 1},
+ {Lo: 0xC26D, Hi: 0xC287, Stride: 1},
+ {Lo: 0xC289, Hi: 0xC2A3, Stride: 1},
+ {Lo: 0xC2A5, Hi: 0xC2BF, Stride: 1},
+ {Lo: 0xC2C1, Hi: 0xC2DB, Stride: 1},
+ {Lo: 0xC2DD, Hi: 0xC2F7, Stride: 1},
+ {Lo: 0xC2F9, Hi: 0xC313, Stride: 1},
+ {Lo: 0xC315, Hi: 0xC32F, Stride: 1},
+ {Lo: 0xC331, Hi: 0xC34B, Stride: 1},
+ {Lo: 0xC34D, Hi: 0xC367, Stride: 1},
+ {Lo: 0xC369, Hi: 0xC383, Stride: 1},
+ {Lo: 0xC385, Hi: 0xC39F, Stride: 1},
+ {Lo: 0xC3A1, Hi: 0xC3BB, Stride: 1},
+ {Lo: 0xC3BD, Hi: 0xC3D7, Stride: 1},
+ {Lo: 0xC3D9, Hi: 0xC3F3, Stride: 1},
+ {Lo: 0xC3F5, Hi: 0xC40F, Stride: 1},
+ {Lo: 0xC411, Hi: 0xC42B, Stride: 1},
+ {Lo: 0xC42D, Hi: 0xC447, Stride: 1},
+ {Lo: 0xC449, Hi: 0xC463, Stride: 1},
+ {Lo: 0xC465, Hi: 0xC47F, Stride: 1},
+ {Lo: 0xC481, Hi: 0xC49B, Stride: 1},
+ {Lo: 0xC49D, Hi: 0xC4B7, Stride: 1},
+ {Lo: 0xC4B9, Hi: 0xC4D3, Stride: 1},
+ {Lo: 0xC4D5, Hi: 0xC4EF, Stride: 1},
+ {Lo: 0xC4F1, Hi: 0xC50B, Stride: 1},
+ {Lo: 0xC50D, Hi: 0xC527, Stride: 1},
+ {Lo: 0xC529, Hi: 0xC543, Stride: 1},
+ {Lo: 0xC545, Hi: 0xC55F, Stride: 1},
+ {Lo: 0xC561, Hi: 0xC57B, Stride: 1},
+ {Lo: 0xC57D, Hi: 0xC597, Stride: 1},
+ {Lo: 0xC599, Hi: 0xC5B3, Stride: 1},
+ {Lo: 0xC5B5, Hi: 0xC5CF, Stride: 1},
+ {Lo: 0xC5D1, Hi: 0xC5EB, Stride: 1},
+ {Lo: 0xC5ED, Hi: 0xC607, Stride: 1},
+ {Lo: 0xC609, Hi: 0xC623, Stride: 1},
+ {Lo: 0xC625, Hi: 0xC63F, Stride: 1},
+ {Lo: 0xC641, Hi: 0xC65B, Stride: 1},
+ {Lo: 0xC65D, Hi: 0xC677, Stride: 1},
+ {Lo: 0xC679, Hi: 0xC693, Stride: 1},
+ {Lo: 0xC695, Hi: 0xC6AF, Stride: 1},
+ {Lo: 0xC6B1, Hi: 0xC6CB, Stride: 1},
+ {Lo: 0xC6CD, Hi: 0xC6E7, Stride: 1},
+ {Lo: 0xC6E9, Hi: 0xC703, Stride: 1},
+ {Lo: 0xC705, Hi: 0xC71F, Stride: 1},
+ {Lo: 0xC721, Hi: 0xC73B, Stride: 1},
+ {Lo: 0xC73D, Hi: 0xC757, Stride: 1},
+ {Lo: 0xC759, Hi: 0xC773, Stride: 1},
+ {Lo: 0xC775, Hi: 0xC78F, Stride: 1},
+ {Lo: 0xC791, Hi: 0xC7AB, Stride: 1},
+ {Lo: 0xC7AD, Hi: 0xC7C7, Stride: 1},
+ {Lo: 0xC7C9, Hi: 0xC7E3, Stride: 1},
+ {Lo: 0xC7E5, Hi: 0xC7FF, Stride: 1},
+ {Lo: 0xC801, Hi: 0xC81B, Stride: 1},
+ {Lo: 0xC81D, Hi: 0xC837, Stride: 1},
+ {Lo: 0xC839, Hi: 0xC853, Stride: 1},
+ {Lo: 0xC855, Hi: 0xC86F, Stride: 1},
+ {Lo: 0xC871, Hi: 0xC88B, Stride: 1},
+ {Lo: 0xC88D, Hi: 0xC8A7, Stride: 1},
+ {Lo: 0xC8A9, Hi: 0xC8C3, Stride: 1},
+ {Lo: 0xC8C5, Hi: 0xC8DF, Stride: 1},
+ {Lo: 0xC8E1, Hi: 0xC8FB, Stride: 1},
+ {Lo: 0xC8FD, Hi: 0xC917, Stride: 1},
+ {Lo: 0xC919, Hi: 0xC933, Stride: 1},
+ {Lo: 0xC935, Hi: 0xC94F, Stride: 1},
+ {Lo: 0xC951, Hi: 0xC96B, Stride: 1},
+ {Lo: 0xC96D, Hi: 0xC987, Stride: 1},
+ {Lo: 0xC989, Hi: 0xC9A3, Stride: 1},
+ {Lo: 0xC9A5, Hi: 0xC9BF, Stride: 1},
+ {Lo: 0xC9C1, Hi: 0xC9DB, Stride: 1},
+ {Lo: 0xC9DD, Hi: 0xC9F7, Stride: 1},
+ {Lo: 0xC9F9, Hi: 0xCA13, Stride: 1},
+ {Lo: 0xCA15, Hi: 0xCA2F, Stride: 1},
+ {Lo: 0xCA31, Hi: 0xCA4B, Stride: 1},
+ {Lo: 0xCA4D, Hi: 0xCA67, Stride: 1},
+ {Lo: 0xCA69, Hi: 0xCA83, Stride: 1},
+ {Lo: 0xCA85, Hi: 0xCA9F, Stride: 1},
+ {Lo: 0xCAA1, Hi: 0xCABB, Stride: 1},
+ {Lo: 0xCABD, Hi: 0xCAD7, Stride: 1},
+ {Lo: 0xCAD9, Hi: 0xCAF3, Stride: 1},
+ {Lo: 0xCAF5, Hi: 0xCB0F, Stride: 1},
+ {Lo: 0xCB11, Hi: 0xCB2B, Stride: 1},
+ {Lo: 0xCB2D, Hi: 0xCB47, Stride: 1},
+ {Lo: 0xCB49, Hi: 0xCB63, Stride: 1},
+ {Lo: 0xCB65, Hi: 0xCB7F, Stride: 1},
+ {Lo: 0xCB81, Hi: 0xCB9B, Stride: 1},
+ {Lo: 0xCB9D, Hi: 0xCBB7, Stride: 1},
+ {Lo: 0xCBB9, Hi: 0xCBD3, Stride: 1},
+ {Lo: 0xCBD5, Hi: 0xCBEF, Stride: 1},
+ {Lo: 0xCBF1, Hi: 0xCC0B, Stride: 1},
+ {Lo: 0xCC0D, Hi: 0xCC27, Stride: 1},
+ {Lo: 0xCC29, Hi: 0xCC43, Stride: 1},
+ {Lo: 0xCC45, Hi: 0xCC5F, Stride: 1},
+ {Lo: 0xCC61, Hi: 0xCC7B, Stride: 1},
+ {Lo: 0xCC7D, Hi: 0xCC97, Stride: 1},
+ {Lo: 0xCC99, Hi: 0xCCB3, Stride: 1},
+ {Lo: 0xCCB5, Hi: 0xCCCF, Stride: 1},
+ {Lo: 0xCCD1, Hi: 0xCCEB, Stride: 1},
+ {Lo: 0xCCED, Hi: 0xCD07, Stride: 1},
+ {Lo: 0xCD09, Hi: 0xCD23, Stride: 1},
+ {Lo: 0xCD25, Hi: 0xCD3F, Stride: 1},
+ {Lo: 0xCD41, Hi: 0xCD5B, Stride: 1},
+ {Lo: 0xCD5D, Hi: 0xCD77, Stride: 1},
+ {Lo: 0xCD79, Hi: 0xCD93, Stride: 1},
+ {Lo: 0xCD95, Hi: 0xCDAF, Stride: 1},
+ {Lo: 0xCDB1, Hi: 0xCDCB, Stride: 1},
+ {Lo: 0xCDCD, Hi: 0xCDE7, Stride: 1},
+ {Lo: 0xCDE9, Hi: 0xCE03, Stride: 1},
+ {Lo: 0xCE05, Hi: 0xCE1F, Stride: 1},
+ {Lo: 0xCE21, Hi: 0xCE3B, Stride: 1},
+ {Lo: 0xCE3D, Hi: 0xCE57, Stride: 1},
+ {Lo: 0xCE59, Hi: 0xCE73, Stride: 1},
+ {Lo: 0xCE75, Hi: 0xCE8F, Stride: 1},
+ {Lo: 0xCE91, Hi: 0xCEAB, Stride: 1},
+ {Lo: 0xCEAD, Hi: 0xCEC7, Stride: 1},
+ {Lo: 0xCEC9, Hi: 0xCEE3, Stride: 1},
+ {Lo: 0xCEE5, Hi: 0xCEFF, Stride: 1},
+ {Lo: 0xCF01, Hi: 0xCF1B, Stride: 1},
+ {Lo: 0xCF1D, Hi: 0xCF37, Stride: 1},
+ {Lo: 0xCF39, Hi: 0xCF53, Stride: 1},
+ {Lo: 0xCF55, Hi: 0xCF6F, Stride: 1},
+ {Lo: 0xCF71, Hi: 0xCF8B, Stride: 1},
+ {Lo: 0xCF8D, Hi: 0xCFA7, Stride: 1},
+ {Lo: 0xCFA9, Hi: 0xCFC3, Stride: 1},
+ {Lo: 0xCFC5, Hi: 0xCFDF, Stride: 1},
+ {Lo: 0xCFE1, Hi: 0xCFFB, Stride: 1},
+ {Lo: 0xCFFD, Hi: 0xD017, Stride: 1},
+ {Lo: 0xD019, Hi: 0xD033, Stride: 1},
+ {Lo: 0xD035, Hi: 0xD04F, Stride: 1},
+ {Lo: 0xD051, Hi: 0xD06B, Stride: 1},
+ {Lo: 0xD06D, Hi: 0xD087, Stride: 1},
+ {Lo: 0xD089, Hi: 0xD0A3, Stride: 1},
+ {Lo: 0xD0A5, Hi: 0xD0BF, Stride: 1},
+ {Lo: 0xD0C1, Hi: 0xD0DB, Stride: 1},
+ {Lo: 0xD0DD, Hi: 0xD0F7, Stride: 1},
+ {Lo: 0xD0F9, Hi: 0xD113, Stride: 1},
+ {Lo: 0xD115, Hi: 0xD12F, Stride: 1},
+ {Lo: 0xD131, Hi: 0xD14B, Stride: 1},
+ {Lo: 0xD14D, Hi: 0xD167, Stride: 1},
+ {Lo: 0xD169, Hi: 0xD183, Stride: 1},
+ {Lo: 0xD185, Hi: 0xD19F, Stride: 1},
+ {Lo: 0xD1A1, Hi: 0xD1BB, Stride: 1},
+ {Lo: 0xD1BD, Hi: 0xD1D7, Stride: 1},
+ {Lo: 0xD1D9, Hi: 0xD1F3, Stride: 1},
+ {Lo: 0xD1F5, Hi: 0xD20F, Stride: 1},
+ {Lo: 0xD211, Hi: 0xD22B, Stride: 1},
+ {Lo: 0xD22D, Hi: 0xD247, Stride: 1},
+ {Lo: 0xD249, Hi: 0xD263, Stride: 1},
+ {Lo: 0xD265, Hi: 0xD27F, Stride: 1},
+ {Lo: 0xD281, Hi: 0xD29B, Stride: 1},
+ {Lo: 0xD29D, Hi: 0xD2B7, Stride: 1},
+ {Lo: 0xD2B9, Hi: 0xD2D3, Stride: 1},
+ {Lo: 0xD2D5, Hi: 0xD2EF, Stride: 1},
+ {Lo: 0xD2F1, Hi: 0xD30B, Stride: 1},
+ {Lo: 0xD30D, Hi: 0xD327, Stride: 1},
+ {Lo: 0xD329, Hi: 0xD343, Stride: 1},
+ {Lo: 0xD345, Hi: 0xD35F, Stride: 1},
+ {Lo: 0xD361, Hi: 0xD37B, Stride: 1},
+ {Lo: 0xD37D, Hi: 0xD397, Stride: 1},
+ {Lo: 0xD399, Hi: 0xD3B3, Stride: 1},
+ {Lo: 0xD3B5, Hi: 0xD3CF, Stride: 1},
+ {Lo: 0xD3D1, Hi: 0xD3EB, Stride: 1},
+ {Lo: 0xD3ED, Hi: 0xD407, Stride: 1},
+ {Lo: 0xD409, Hi: 0xD423, Stride: 1},
+ {Lo: 0xD425, Hi: 0xD43F, Stride: 1},
+ {Lo: 0xD441, Hi: 0xD45B, Stride: 1},
+ {Lo: 0xD45D, Hi: 0xD477, Stride: 1},
+ {Lo: 0xD479, Hi: 0xD493, Stride: 1},
+ {Lo: 0xD495, Hi: 0xD4AF, Stride: 1},
+ {Lo: 0xD4B1, Hi: 0xD4CB, Stride: 1},
+ {Lo: 0xD4CD, Hi: 0xD4E7, Stride: 1},
+ {Lo: 0xD4E9, Hi: 0xD503, Stride: 1},
+ {Lo: 0xD505, Hi: 0xD51F, Stride: 1},
+ {Lo: 0xD521, Hi: 0xD53B, Stride: 1},
+ {Lo: 0xD53D, Hi: 0xD557, Stride: 1},
+ {Lo: 0xD559, Hi: 0xD573, Stride: 1},
+ {Lo: 0xD575, Hi: 0xD58F, Stride: 1},
+ {Lo: 0xD591, Hi: 0xD5AB, Stride: 1},
+ {Lo: 0xD5AD, Hi: 0xD5C7, Stride: 1},
+ {Lo: 0xD5C9, Hi: 0xD5E3, Stride: 1},
+ {Lo: 0xD5E5, Hi: 0xD5FF, Stride: 1},
+ {Lo: 0xD601, Hi: 0xD61B, Stride: 1},
+ {Lo: 0xD61D, Hi: 0xD637, Stride: 1},
+ {Lo: 0xD639, Hi: 0xD653, Stride: 1},
+ {Lo: 0xD655, Hi: 0xD66F, Stride: 1},
+ {Lo: 0xD671, Hi: 0xD68B, Stride: 1},
+ {Lo: 0xD68D, Hi: 0xD6A7, Stride: 1},
+ {Lo: 0xD6A9, Hi: 0xD6C3, Stride: 1},
+ {Lo: 0xD6C5, Hi: 0xD6DF, Stride: 1},
+ {Lo: 0xD6E1, Hi: 0xD6FB, Stride: 1},
+ {Lo: 0xD6FD, Hi: 0xD717, Stride: 1},
+ {Lo: 0xD719, Hi: 0xD733, Stride: 1},
+ {Lo: 0xD735, Hi: 0xD74F, Stride: 1},
+ {Lo: 0xD751, Hi: 0xD76B, Stride: 1},
+ {Lo: 0xD76D, Hi: 0xD787, Stride: 1},
+ {Lo: 0xD789, Hi: 0xD7A3, Stride: 1},
+ },
+}
+
+var unicodeAliasGrapheme_Cluster_Break_Prepend = &unicode.RangeTable{
+ R16: []unicode.Range16{
+ {Lo: 0x600, Hi: 0x605, Stride: 1},
+ {Lo: 0x6DD, Hi: 0x6DD, Stride: 1},
+ {Lo: 0x70F, Hi: 0x70F, Stride: 1},
+ {Lo: 0x890, Hi: 0x891, Stride: 1},
+ {Lo: 0x8E2, Hi: 0x8E2, Stride: 1},
+ {Lo: 0xD4E, Hi: 0xD4E, Stride: 1},
+ },
+ R32: []unicode.Range32{
+ {Lo: 0x110BD, Hi: 0x110BD, Stride: 1},
+ {Lo: 0x110CD, Hi: 0x110CD, Stride: 1},
+ {Lo: 0x111C2, Hi: 0x111C3, Stride: 1},
+ {Lo: 0x113D1, Hi: 0x113D1, Stride: 1},
+ {Lo: 0x1193F, Hi: 0x1193F, Stride: 1},
+ {Lo: 0x11941, Hi: 0x11941, Stride: 1},
+ {Lo: 0x11A84, Hi: 0x11A89, Stride: 1},
+ {Lo: 0x11D46, Hi: 0x11D46, Stride: 1},
+ {Lo: 0x11F02, Hi: 0x11F02, Stride: 1},
+ },
+}
+
+var unicodeAliasGrapheme_Cluster_Break_Regional_Indicator = &unicode.RangeTable{
+ R32: []unicode.Range32{
+ {Lo: 0x1F1E6, Hi: 0x1F1FF, Stride: 1},
+ },
+}
+
+var unicodeAliasGrapheme_Cluster_Break_SpacingMark = &unicode.RangeTable{
+ R16: []unicode.Range16{
+ {Lo: 0x903, Hi: 0x903, Stride: 1},
+ {Lo: 0x93B, Hi: 0x93B, Stride: 1},
+ {Lo: 0x93E, Hi: 0x940, Stride: 1},
+ {Lo: 0x949, Hi: 0x94C, Stride: 1},
+ {Lo: 0x94E, Hi: 0x94F, Stride: 1},
+ {Lo: 0x982, Hi: 0x983, Stride: 1},
+ {Lo: 0x9BF, Hi: 0x9C0, Stride: 1},
+ {Lo: 0x9C7, Hi: 0x9C8, Stride: 1},
+ {Lo: 0x9CB, Hi: 0x9CC, Stride: 1},
+ {Lo: 0xA03, Hi: 0xA03, Stride: 1},
+ {Lo: 0xA3E, Hi: 0xA40, Stride: 1},
+ {Lo: 0xA83, Hi: 0xA83, Stride: 1},
+ {Lo: 0xABE, Hi: 0xAC0, Stride: 1},
+ {Lo: 0xAC9, Hi: 0xAC9, Stride: 1},
+ {Lo: 0xACB, Hi: 0xACC, Stride: 1},
+ {Lo: 0xB02, Hi: 0xB03, Stride: 1},
+ {Lo: 0xB40, Hi: 0xB40, Stride: 1},
+ {Lo: 0xB47, Hi: 0xB48, Stride: 1},
+ {Lo: 0xB4B, Hi: 0xB4C, Stride: 1},
+ {Lo: 0xBBF, Hi: 0xBBF, Stride: 1},
+ {Lo: 0xBC1, Hi: 0xBC2, Stride: 1},
+ {Lo: 0xBC6, Hi: 0xBC8, Stride: 1},
+ {Lo: 0xBCA, Hi: 0xBCC, Stride: 1},
+ {Lo: 0xC01, Hi: 0xC03, Stride: 1},
+ {Lo: 0xC41, Hi: 0xC44, Stride: 1},
+ {Lo: 0xC82, Hi: 0xC83, Stride: 1},
+ {Lo: 0xCBE, Hi: 0xCBE, Stride: 1},
+ {Lo: 0xCC1, Hi: 0xCC1, Stride: 1},
+ {Lo: 0xCC3, Hi: 0xCC4, Stride: 1},
+ {Lo: 0xCF3, Hi: 0xCF3, Stride: 1},
+ {Lo: 0xD02, Hi: 0xD03, Stride: 1},
+ {Lo: 0xD3F, Hi: 0xD40, Stride: 1},
+ {Lo: 0xD46, Hi: 0xD48, Stride: 1},
+ {Lo: 0xD4A, Hi: 0xD4C, Stride: 1},
+ {Lo: 0xD82, Hi: 0xD83, Stride: 1},
+ {Lo: 0xDD0, Hi: 0xDD1, Stride: 1},
+ {Lo: 0xDD8, Hi: 0xDDE, Stride: 1},
+ {Lo: 0xDF2, Hi: 0xDF3, Stride: 1},
+ {Lo: 0xE33, Hi: 0xE33, Stride: 1},
+ {Lo: 0xEB3, Hi: 0xEB3, Stride: 1},
+ {Lo: 0xF3E, Hi: 0xF3F, Stride: 1},
+ {Lo: 0xF7F, Hi: 0xF7F, Stride: 1},
+ {Lo: 0x1031, Hi: 0x1031, Stride: 1},
+ {Lo: 0x103B, Hi: 0x103C, Stride: 1},
+ {Lo: 0x1056, Hi: 0x1057, Stride: 1},
+ {Lo: 0x1084, Hi: 0x1084, Stride: 1},
+ {Lo: 0x17B6, Hi: 0x17B6, Stride: 1},
+ {Lo: 0x17BE, Hi: 0x17C5, Stride: 1},
+ {Lo: 0x17C7, Hi: 0x17C8, Stride: 1},
+ {Lo: 0x1923, Hi: 0x1926, Stride: 1},
+ {Lo: 0x1929, Hi: 0x192B, Stride: 1},
+ {Lo: 0x1930, Hi: 0x1931, Stride: 1},
+ {Lo: 0x1933, Hi: 0x1938, Stride: 1},
+ {Lo: 0x1A19, Hi: 0x1A1A, Stride: 1},
+ {Lo: 0x1A55, Hi: 0x1A55, Stride: 1},
+ {Lo: 0x1A57, Hi: 0x1A57, Stride: 1},
+ {Lo: 0x1A6D, Hi: 0x1A72, Stride: 1},
+ {Lo: 0x1B04, Hi: 0x1B04, Stride: 1},
+ {Lo: 0x1B3E, Hi: 0x1B41, Stride: 1},
+ {Lo: 0x1B82, Hi: 0x1B82, Stride: 1},
+ {Lo: 0x1BA1, Hi: 0x1BA1, Stride: 1},
+ {Lo: 0x1BA6, Hi: 0x1BA7, Stride: 1},
+ {Lo: 0x1BE7, Hi: 0x1BE7, Stride: 1},
+ {Lo: 0x1BEA, Hi: 0x1BEC, Stride: 1},
+ {Lo: 0x1BEE, Hi: 0x1BEE, Stride: 1},
+ {Lo: 0x1C24, Hi: 0x1C2B, Stride: 1},
+ {Lo: 0x1C34, Hi: 0x1C35, Stride: 1},
+ {Lo: 0x1CE1, Hi: 0x1CE1, Stride: 1},
+ {Lo: 0x1CF7, Hi: 0x1CF7, Stride: 1},
+ {Lo: 0xA823, Hi: 0xA824, Stride: 1},
+ {Lo: 0xA827, Hi: 0xA827, Stride: 1},
+ {Lo: 0xA880, Hi: 0xA881, Stride: 1},
+ {Lo: 0xA8B4, Hi: 0xA8C3, Stride: 1},
+ {Lo: 0xA952, Hi: 0xA952, Stride: 1},
+ {Lo: 0xA983, Hi: 0xA983, Stride: 1},
+ {Lo: 0xA9B4, Hi: 0xA9B5, Stride: 1},
+ {Lo: 0xA9BA, Hi: 0xA9BB, Stride: 1},
+ {Lo: 0xA9BE, Hi: 0xA9BF, Stride: 1},
+ {Lo: 0xAA2F, Hi: 0xAA30, Stride: 1},
+ {Lo: 0xAA33, Hi: 0xAA34, Stride: 1},
+ {Lo: 0xAA4D, Hi: 0xAA4D, Stride: 1},
+ {Lo: 0xAAEB, Hi: 0xAAEB, Stride: 1},
+ {Lo: 0xAAEE, Hi: 0xAAEF, Stride: 1},
+ {Lo: 0xAAF5, Hi: 0xAAF5, Stride: 1},
+ {Lo: 0xABE3, Hi: 0xABE4, Stride: 1},
+ {Lo: 0xABE6, Hi: 0xABE7, Stride: 1},
+ {Lo: 0xABE9, Hi: 0xABEA, Stride: 1},
+ {Lo: 0xABEC, Hi: 0xABEC, Stride: 1},
+ },
+ R32: []unicode.Range32{
+ {Lo: 0x11000, Hi: 0x11000, Stride: 1},
+ {Lo: 0x11002, Hi: 0x11002, Stride: 1},
+ {Lo: 0x11082, Hi: 0x11082, Stride: 1},
+ {Lo: 0x110B0, Hi: 0x110B2, Stride: 1},
+ {Lo: 0x110B7, Hi: 0x110B8, Stride: 1},
+ {Lo: 0x1112C, Hi: 0x1112C, Stride: 1},
+ {Lo: 0x11145, Hi: 0x11146, Stride: 1},
+ {Lo: 0x11182, Hi: 0x11182, Stride: 1},
+ {Lo: 0x111B3, Hi: 0x111B5, Stride: 1},
+ {Lo: 0x111BF, Hi: 0x111BF, Stride: 1},
+ {Lo: 0x111CE, Hi: 0x111CE, Stride: 1},
+ {Lo: 0x1122C, Hi: 0x1122E, Stride: 1},
+ {Lo: 0x11232, Hi: 0x11233, Stride: 1},
+ {Lo: 0x112E0, Hi: 0x112E2, Stride: 1},
+ {Lo: 0x11302, Hi: 0x11303, Stride: 1},
+ {Lo: 0x1133F, Hi: 0x1133F, Stride: 1},
+ {Lo: 0x11341, Hi: 0x11344, Stride: 1},
+ {Lo: 0x11347, Hi: 0x11348, Stride: 1},
+ {Lo: 0x1134B, Hi: 0x1134C, Stride: 1},
+ {Lo: 0x11362, Hi: 0x11363, Stride: 1},
+ {Lo: 0x113B9, Hi: 0x113BA, Stride: 1},
+ {Lo: 0x113CA, Hi: 0x113CA, Stride: 1},
+ {Lo: 0x113CC, Hi: 0x113CD, Stride: 1},
+ {Lo: 0x11435, Hi: 0x11437, Stride: 1},
+ {Lo: 0x11440, Hi: 0x11441, Stride: 1},
+ {Lo: 0x11445, Hi: 0x11445, Stride: 1},
+ {Lo: 0x114B1, Hi: 0x114B2, Stride: 1},
+ {Lo: 0x114B9, Hi: 0x114B9, Stride: 1},
+ {Lo: 0x114BB, Hi: 0x114BC, Stride: 1},
+ {Lo: 0x114BE, Hi: 0x114BE, Stride: 1},
+ {Lo: 0x114C1, Hi: 0x114C1, Stride: 1},
+ {Lo: 0x115B0, Hi: 0x115B1, Stride: 1},
+ {Lo: 0x115B8, Hi: 0x115BB, Stride: 1},
+ {Lo: 0x115BE, Hi: 0x115BE, Stride: 1},
+ {Lo: 0x11630, Hi: 0x11632, Stride: 1},
+ {Lo: 0x1163B, Hi: 0x1163C, Stride: 1},
+ {Lo: 0x1163E, Hi: 0x1163E, Stride: 1},
+ {Lo: 0x116AC, Hi: 0x116AC, Stride: 1},
+ {Lo: 0x116AE, Hi: 0x116AF, Stride: 1},
+ {Lo: 0x1171E, Hi: 0x1171E, Stride: 1},
+ {Lo: 0x11726, Hi: 0x11726, Stride: 1},
+ {Lo: 0x1182C, Hi: 0x1182E, Stride: 1},
+ {Lo: 0x11838, Hi: 0x11838, Stride: 1},
+ {Lo: 0x11931, Hi: 0x11935, Stride: 1},
+ {Lo: 0x11937, Hi: 0x11938, Stride: 1},
+ {Lo: 0x11940, Hi: 0x11940, Stride: 1},
+ {Lo: 0x11942, Hi: 0x11942, Stride: 1},
+ {Lo: 0x119D1, Hi: 0x119D3, Stride: 1},
+ {Lo: 0x119DC, Hi: 0x119DF, Stride: 1},
+ {Lo: 0x119E4, Hi: 0x119E4, Stride: 1},
+ {Lo: 0x11A39, Hi: 0x11A39, Stride: 1},
+ {Lo: 0x11A57, Hi: 0x11A58, Stride: 1},
+ {Lo: 0x11A97, Hi: 0x11A97, Stride: 1},
+ {Lo: 0x11B61, Hi: 0x11B61, Stride: 1},
+ {Lo: 0x11B65, Hi: 0x11B65, Stride: 1},
+ {Lo: 0x11B67, Hi: 0x11B67, Stride: 1},
+ {Lo: 0x11C2F, Hi: 0x11C2F, Stride: 1},
+ {Lo: 0x11C3E, Hi: 0x11C3E, Stride: 1},
+ {Lo: 0x11CA9, Hi: 0x11CA9, Stride: 1},
+ {Lo: 0x11CB1, Hi: 0x11CB1, Stride: 1},
+ {Lo: 0x11CB4, Hi: 0x11CB4, Stride: 1},
+ {Lo: 0x11D8A, Hi: 0x11D8E, Stride: 1},
+ {Lo: 0x11D93, Hi: 0x11D94, Stride: 1},
+ {Lo: 0x11D96, Hi: 0x11D96, Stride: 1},
+ {Lo: 0x11EF5, Hi: 0x11EF6, Stride: 1},
+ {Lo: 0x11F03, Hi: 0x11F03, Stride: 1},
+ {Lo: 0x11F34, Hi: 0x11F35, Stride: 1},
+ {Lo: 0x11F3E, Hi: 0x11F3F, Stride: 1},
+ {Lo: 0x1612A, Hi: 0x1612C, Stride: 1},
+ {Lo: 0x16F51, Hi: 0x16F87, Stride: 1},
+ },
+}
+
+var unicodeAliasGrapheme_Cluster_Break_T = &unicode.RangeTable{
+ R16: []unicode.Range16{
+ {Lo: 0x11A8, Hi: 0x11FF, Stride: 1},
+ {Lo: 0xD7CB, Hi: 0xD7FB, Stride: 1},
+ },
+}
+
+var unicodeAliasGrapheme_Cluster_Break_V = &unicode.RangeTable{
+ R16: []unicode.Range16{
+ {Lo: 0x1160, Hi: 0x11A7, Stride: 1},
+ {Lo: 0xD7B0, Hi: 0xD7C6, Stride: 1},
+ },
+ R32: []unicode.Range32{
+ {Lo: 0x16D63, Hi: 0x16D63, Stride: 1},
+ {Lo: 0x16D67, Hi: 0x16D6A, Stride: 1},
+ },
+}
+
+var unicodeAliasGrapheme_Cluster_Break_ZWJ = &unicode.RangeTable{
+ R16: []unicode.Range16{
+ {Lo: 0x200D, Hi: 0x200D, Stride: 1},
+ },
+}
+
+var unicodeAliasMath = &unicode.RangeTable{
+ R16: []unicode.Range16{
+ {Lo: 0x2B, Hi: 0x2B, Stride: 1},
+ {Lo: 0x3C, Hi: 0x3E, Stride: 1},
+ {Lo: 0x5E, Hi: 0x5E, Stride: 1},
+ {Lo: 0x7C, Hi: 0x7C, Stride: 1},
+ {Lo: 0x7E, Hi: 0x7E, Stride: 1},
+ {Lo: 0xAC, Hi: 0xAC, Stride: 1},
+ {Lo: 0xB1, Hi: 0xB1, Stride: 1},
+ {Lo: 0xD7, Hi: 0xD7, Stride: 1},
+ {Lo: 0xF7, Hi: 0xF7, Stride: 1},
+ {Lo: 0x3D0, Hi: 0x3D2, Stride: 1},
+ {Lo: 0x3D5, Hi: 0x3D5, Stride: 1},
+ {Lo: 0x3F0, Hi: 0x3F1, Stride: 1},
+ {Lo: 0x3F4, Hi: 0x3F6, Stride: 1},
+ {Lo: 0x606, Hi: 0x608, Stride: 1},
+ {Lo: 0x2016, Hi: 0x2016, Stride: 1},
+ {Lo: 0x2032, Hi: 0x2034, Stride: 1},
+ {Lo: 0x2040, Hi: 0x2040, Stride: 1},
+ {Lo: 0x2044, Hi: 0x2044, Stride: 1},
+ {Lo: 0x2052, Hi: 0x2052, Stride: 1},
+ {Lo: 0x2061, Hi: 0x2064, Stride: 1},
+ {Lo: 0x207A, Hi: 0x207E, Stride: 1},
+ {Lo: 0x208A, Hi: 0x208E, Stride: 1},
+ {Lo: 0x20D0, Hi: 0x20DC, Stride: 1},
+ {Lo: 0x20E1, Hi: 0x20E1, Stride: 1},
+ {Lo: 0x20E5, Hi: 0x20E6, Stride: 1},
+ {Lo: 0x20EB, Hi: 0x20EF, Stride: 1},
+ {Lo: 0x2102, Hi: 0x2102, Stride: 1},
+ {Lo: 0x2107, Hi: 0x2107, Stride: 1},
+ {Lo: 0x210A, Hi: 0x2113, Stride: 1},
+ {Lo: 0x2115, Hi: 0x2115, Stride: 1},
+ {Lo: 0x2118, Hi: 0x211D, Stride: 1},
+ {Lo: 0x2124, Hi: 0x2124, Stride: 1},
+ {Lo: 0x2128, Hi: 0x2129, Stride: 1},
+ {Lo: 0x212C, Hi: 0x212D, Stride: 1},
+ {Lo: 0x212F, Hi: 0x2131, Stride: 1},
+ {Lo: 0x2133, Hi: 0x2138, Stride: 1},
+ {Lo: 0x213C, Hi: 0x2149, Stride: 1},
+ {Lo: 0x214B, Hi: 0x214B, Stride: 1},
+ {Lo: 0x2190, Hi: 0x21A7, Stride: 1},
+ {Lo: 0x21A9, Hi: 0x21AE, Stride: 1},
+ {Lo: 0x21B0, Hi: 0x21B1, Stride: 1},
+ {Lo: 0x21B6, Hi: 0x21B7, Stride: 1},
+ {Lo: 0x21BC, Hi: 0x21DB, Stride: 1},
+ {Lo: 0x21DD, Hi: 0x21DD, Stride: 1},
+ {Lo: 0x21E4, Hi: 0x21E5, Stride: 1},
+ {Lo: 0x21F4, Hi: 0x22FF, Stride: 1},
+ {Lo: 0x2308, Hi: 0x230B, Stride: 1},
+ {Lo: 0x2320, Hi: 0x2321, Stride: 1},
+ {Lo: 0x237C, Hi: 0x237C, Stride: 1},
+ {Lo: 0x239B, Hi: 0x23B5, Stride: 1},
+ {Lo: 0x23B7, Hi: 0x23B7, Stride: 1},
+ {Lo: 0x23D0, Hi: 0x23D0, Stride: 1},
+ {Lo: 0x23DC, Hi: 0x23E2, Stride: 1},
+ {Lo: 0x25A0, Hi: 0x25A1, Stride: 1},
+ {Lo: 0x25AE, Hi: 0x25B7, Stride: 1},
+ {Lo: 0x25BC, Hi: 0x25C1, Stride: 1},
+ {Lo: 0x25C6, Hi: 0x25C7, Stride: 1},
+ {Lo: 0x25CA, Hi: 0x25CB, Stride: 1},
+ {Lo: 0x25CF, Hi: 0x25D3, Stride: 1},
+ {Lo: 0x25E2, Hi: 0x25E2, Stride: 1},
+ {Lo: 0x25E4, Hi: 0x25E4, Stride: 1},
+ {Lo: 0x25E7, Hi: 0x25EC, Stride: 1},
+ {Lo: 0x25F8, Hi: 0x25FF, Stride: 1},
+ {Lo: 0x2605, Hi: 0x2606, Stride: 1},
+ {Lo: 0x2640, Hi: 0x2640, Stride: 1},
+ {Lo: 0x2642, Hi: 0x2642, Stride: 1},
+ {Lo: 0x2660, Hi: 0x2663, Stride: 1},
+ {Lo: 0x266D, Hi: 0x266F, Stride: 1},
+ {Lo: 0x27C0, Hi: 0x27FF, Stride: 1},
+ {Lo: 0x2900, Hi: 0x2AFF, Stride: 1},
+ {Lo: 0x2B30, Hi: 0x2B44, Stride: 1},
+ {Lo: 0x2B47, Hi: 0x2B4C, Stride: 1},
+ {Lo: 0xFB29, Hi: 0xFB29, Stride: 1},
+ {Lo: 0xFE61, Hi: 0xFE66, Stride: 1},
+ {Lo: 0xFE68, Hi: 0xFE68, Stride: 1},
+ {Lo: 0xFF0B, Hi: 0xFF0B, Stride: 1},
+ {Lo: 0xFF1C, Hi: 0xFF1E, Stride: 1},
+ {Lo: 0xFF3C, Hi: 0xFF3C, Stride: 1},
+ {Lo: 0xFF3E, Hi: 0xFF3E, Stride: 1},
+ {Lo: 0xFF5C, Hi: 0xFF5C, Stride: 1},
+ {Lo: 0xFF5E, Hi: 0xFF5E, Stride: 1},
+ {Lo: 0xFFE2, Hi: 0xFFE2, Stride: 1},
+ {Lo: 0xFFE9, Hi: 0xFFEC, Stride: 1},
+ },
+ R32: []unicode.Range32{
+ {Lo: 0x10D8E, Hi: 0x10D8F, Stride: 1},
+ {Lo: 0x1CEF0, Hi: 0x1CEF0, Stride: 1},
+ {Lo: 0x1D400, Hi: 0x1D454, Stride: 1},
+ {Lo: 0x1D456, Hi: 0x1D49C, Stride: 1},
+ {Lo: 0x1D49E, Hi: 0x1D49F, Stride: 1},
+ {Lo: 0x1D4A2, Hi: 0x1D4A2, Stride: 1},
+ {Lo: 0x1D4A5, Hi: 0x1D4A6, Stride: 1},
+ {Lo: 0x1D4A9, Hi: 0x1D4AC, Stride: 1},
+ {Lo: 0x1D4AE, Hi: 0x1D4B9, Stride: 1},
+ {Lo: 0x1D4BB, Hi: 0x1D4BB, Stride: 1},
+ {Lo: 0x1D4BD, Hi: 0x1D4C3, Stride: 1},
+ {Lo: 0x1D4C5, Hi: 0x1D505, Stride: 1},
+ {Lo: 0x1D507, Hi: 0x1D50A, Stride: 1},
+ {Lo: 0x1D50D, Hi: 0x1D514, Stride: 1},
+ {Lo: 0x1D516, Hi: 0x1D51C, Stride: 1},
+ {Lo: 0x1D51E, Hi: 0x1D539, Stride: 1},
+ {Lo: 0x1D53B, Hi: 0x1D53E, Stride: 1},
+ {Lo: 0x1D540, Hi: 0x1D544, Stride: 1},
+ {Lo: 0x1D546, Hi: 0x1D546, Stride: 1},
+ {Lo: 0x1D54A, Hi: 0x1D550, Stride: 1},
+ {Lo: 0x1D552, Hi: 0x1D6A5, Stride: 1},
+ {Lo: 0x1D6A8, Hi: 0x1D7CB, Stride: 1},
+ {Lo: 0x1D7CE, Hi: 0x1D7FF, Stride: 1},
+ {Lo: 0x1EE00, Hi: 0x1EE03, Stride: 1},
+ {Lo: 0x1EE05, Hi: 0x1EE1F, Stride: 1},
+ {Lo: 0x1EE21, Hi: 0x1EE22, Stride: 1},
+ {Lo: 0x1EE24, Hi: 0x1EE24, Stride: 1},
+ {Lo: 0x1EE27, Hi: 0x1EE27, Stride: 1},
+ {Lo: 0x1EE29, Hi: 0x1EE32, Stride: 1},
+ {Lo: 0x1EE34, Hi: 0x1EE37, Stride: 1},
+ {Lo: 0x1EE39, Hi: 0x1EE39, Stride: 1},
+ {Lo: 0x1EE3B, Hi: 0x1EE3B, Stride: 1},
+ {Lo: 0x1EE42, Hi: 0x1EE42, Stride: 1},
+ {Lo: 0x1EE47, Hi: 0x1EE47, Stride: 1},
+ {Lo: 0x1EE49, Hi: 0x1EE49, Stride: 1},
+ {Lo: 0x1EE4B, Hi: 0x1EE4B, Stride: 1},
+ {Lo: 0x1EE4D, Hi: 0x1EE4F, Stride: 1},
+ {Lo: 0x1EE51, Hi: 0x1EE52, Stride: 1},
+ {Lo: 0x1EE54, Hi: 0x1EE54, Stride: 1},
+ {Lo: 0x1EE57, Hi: 0x1EE57, Stride: 1},
+ {Lo: 0x1EE59, Hi: 0x1EE59, Stride: 1},
+ {Lo: 0x1EE5B, Hi: 0x1EE5B, Stride: 1},
+ {Lo: 0x1EE5D, Hi: 0x1EE5D, Stride: 1},
+ {Lo: 0x1EE5F, Hi: 0x1EE5F, Stride: 1},
+ {Lo: 0x1EE61, Hi: 0x1EE62, Stride: 1},
+ {Lo: 0x1EE64, Hi: 0x1EE64, Stride: 1},
+ {Lo: 0x1EE67, Hi: 0x1EE6A, Stride: 1},
+ {Lo: 0x1EE6C, Hi: 0x1EE72, Stride: 1},
+ {Lo: 0x1EE74, Hi: 0x1EE77, Stride: 1},
+ {Lo: 0x1EE79, Hi: 0x1EE7C, Stride: 1},
+ {Lo: 0x1EE7E, Hi: 0x1EE7E, Stride: 1},
+ {Lo: 0x1EE80, Hi: 0x1EE89, Stride: 1},
+ {Lo: 0x1EE8B, Hi: 0x1EE9B, Stride: 1},
+ {Lo: 0x1EEA1, Hi: 0x1EEA3, Stride: 1},
+ {Lo: 0x1EEA5, Hi: 0x1EEA9, Stride: 1},
+ {Lo: 0x1EEAB, Hi: 0x1EEBB, Stride: 1},
+ {Lo: 0x1EEF0, Hi: 0x1EEF1, Stride: 1},
+ {Lo: 0x1F8D0, Hi: 0x1F8D8, Stride: 1},
+ },
+}
+
+var unicodeAliasSentence_Break_ATerm = &unicode.RangeTable{
+ R16: []unicode.Range16{
+ {Lo: 0x2E, Hi: 0x2E, Stride: 1},
+ {Lo: 0x2024, Hi: 0x2024, Stride: 1},
+ {Lo: 0xFE52, Hi: 0xFE52, Stride: 1},
+ {Lo: 0xFF0E, Hi: 0xFF0E, Stride: 1},
+ },
+}
+
+var unicodeAliasSentence_Break_CR = &unicode.RangeTable{
+ R16: []unicode.Range16{
+ {Lo: 0xD, Hi: 0xD, Stride: 1},
+ },
+}
+
+var unicodeAliasSentence_Break_Close = &unicode.RangeTable{
+ R16: []unicode.Range16{
+ {Lo: 0x22, Hi: 0x22, Stride: 1},
+ {Lo: 0x27, Hi: 0x29, Stride: 1},
+ {Lo: 0x5B, Hi: 0x5B, Stride: 1},
+ {Lo: 0x5D, Hi: 0x5D, Stride: 1},
+ {Lo: 0x7B, Hi: 0x7B, Stride: 1},
+ {Lo: 0x7D, Hi: 0x7D, Stride: 1},
+ {Lo: 0xAB, Hi: 0xAB, Stride: 1},
+ {Lo: 0xBB, Hi: 0xBB, Stride: 1},
+ {Lo: 0xF3A, Hi: 0xF3D, Stride: 1},
+ {Lo: 0x169B, Hi: 0x169C, Stride: 1},
+ {Lo: 0x2018, Hi: 0x201F, Stride: 1},
+ {Lo: 0x2039, Hi: 0x203A, Stride: 1},
+ {Lo: 0x2045, Hi: 0x2046, Stride: 1},
+ {Lo: 0x207D, Hi: 0x207E, Stride: 1},
+ {Lo: 0x208D, Hi: 0x208E, Stride: 1},
+ {Lo: 0x2308, Hi: 0x230B, Stride: 1},
+ {Lo: 0x2329, Hi: 0x232A, Stride: 1},
+ {Lo: 0x275B, Hi: 0x2760, Stride: 1},
+ {Lo: 0x2768, Hi: 0x2775, Stride: 1},
+ {Lo: 0x27C5, Hi: 0x27C6, Stride: 1},
+ {Lo: 0x27E6, Hi: 0x27EF, Stride: 1},
+ {Lo: 0x2983, Hi: 0x2998, Stride: 1},
+ {Lo: 0x29D8, Hi: 0x29DB, Stride: 1},
+ {Lo: 0x29FC, Hi: 0x29FD, Stride: 1},
+ {Lo: 0x2E00, Hi: 0x2E0D, Stride: 1},
+ {Lo: 0x2E1C, Hi: 0x2E1D, Stride: 1},
+ {Lo: 0x2E20, Hi: 0x2E29, Stride: 1},
+ {Lo: 0x2E42, Hi: 0x2E42, Stride: 1},
+ {Lo: 0x2E55, Hi: 0x2E5C, Stride: 1},
+ {Lo: 0x3008, Hi: 0x3011, Stride: 1},
+ {Lo: 0x3014, Hi: 0x301B, Stride: 1},
+ {Lo: 0x301D, Hi: 0x301F, Stride: 1},
+ {Lo: 0xFD3E, Hi: 0xFD3F, Stride: 1},
+ {Lo: 0xFE17, Hi: 0xFE18, Stride: 1},
+ {Lo: 0xFE35, Hi: 0xFE44, Stride: 1},
+ {Lo: 0xFE47, Hi: 0xFE48, Stride: 1},
+ {Lo: 0xFE59, Hi: 0xFE5E, Stride: 1},
+ {Lo: 0xFF08, Hi: 0xFF09, Stride: 1},
+ {Lo: 0xFF3B, Hi: 0xFF3B, Stride: 1},
+ {Lo: 0xFF3D, Hi: 0xFF3D, Stride: 1},
+ {Lo: 0xFF5B, Hi: 0xFF5B, Stride: 1},
+ {Lo: 0xFF5D, Hi: 0xFF5D, Stride: 1},
+ {Lo: 0xFF5F, Hi: 0xFF60, Stride: 1},
+ {Lo: 0xFF62, Hi: 0xFF63, Stride: 1},
+ },
+ R32: []unicode.Range32{
+ {Lo: 0x1F676, Hi: 0x1F678, Stride: 1},
+ },
+}
+
+var unicodeAliasSentence_Break_Extend = &unicode.RangeTable{
+ R16: []unicode.Range16{
+ {Lo: 0x300, Hi: 0x36F, Stride: 1},
+ {Lo: 0x483, Hi: 0x489, Stride: 1},
+ {Lo: 0x591, Hi: 0x5BD, Stride: 1},
+ {Lo: 0x5BF, Hi: 0x5BF, Stride: 1},
+ {Lo: 0x5C1, Hi: 0x5C2, Stride: 1},
+ {Lo: 0x5C4, Hi: 0x5C5, Stride: 1},
+ {Lo: 0x5C7, Hi: 0x5C7, Stride: 1},
+ {Lo: 0x610, Hi: 0x61A, Stride: 1},
+ {Lo: 0x64B, Hi: 0x65F, Stride: 1},
+ {Lo: 0x670, Hi: 0x670, Stride: 1},
+ {Lo: 0x6D6, Hi: 0x6DC, Stride: 1},
+ {Lo: 0x6DF, Hi: 0x6E4, Stride: 1},
+ {Lo: 0x6E7, Hi: 0x6E8, Stride: 1},
+ {Lo: 0x6EA, Hi: 0x6ED, Stride: 1},
+ {Lo: 0x711, Hi: 0x711, Stride: 1},
+ {Lo: 0x730, Hi: 0x74A, Stride: 1},
+ {Lo: 0x7A6, Hi: 0x7B0, Stride: 1},
+ {Lo: 0x7EB, Hi: 0x7F3, Stride: 1},
+ {Lo: 0x7FD, Hi: 0x7FD, Stride: 1},
+ {Lo: 0x816, Hi: 0x819, Stride: 1},
+ {Lo: 0x81B, Hi: 0x823, Stride: 1},
+ {Lo: 0x825, Hi: 0x827, Stride: 1},
+ {Lo: 0x829, Hi: 0x82D, Stride: 1},
+ {Lo: 0x859, Hi: 0x85B, Stride: 1},
+ {Lo: 0x897, Hi: 0x89F, Stride: 1},
+ {Lo: 0x8CA, Hi: 0x8E1, Stride: 1},
+ {Lo: 0x8E3, Hi: 0x903, Stride: 1},
+ {Lo: 0x93A, Hi: 0x93C, Stride: 1},
+ {Lo: 0x93E, Hi: 0x94F, Stride: 1},
+ {Lo: 0x951, Hi: 0x957, Stride: 1},
+ {Lo: 0x962, Hi: 0x963, Stride: 1},
+ {Lo: 0x981, Hi: 0x983, Stride: 1},
+ {Lo: 0x9BC, Hi: 0x9BC, Stride: 1},
+ {Lo: 0x9BE, Hi: 0x9C4, Stride: 1},
+ {Lo: 0x9C7, Hi: 0x9C8, Stride: 1},
+ {Lo: 0x9CB, Hi: 0x9CD, Stride: 1},
+ {Lo: 0x9D7, Hi: 0x9D7, Stride: 1},
+ {Lo: 0x9E2, Hi: 0x9E3, Stride: 1},
+ {Lo: 0x9FE, Hi: 0x9FE, Stride: 1},
+ {Lo: 0xA01, Hi: 0xA03, Stride: 1},
+ {Lo: 0xA3C, Hi: 0xA3C, Stride: 1},
+ {Lo: 0xA3E, Hi: 0xA42, Stride: 1},
+ {Lo: 0xA47, Hi: 0xA48, Stride: 1},
+ {Lo: 0xA4B, Hi: 0xA4D, Stride: 1},
+ {Lo: 0xA51, Hi: 0xA51, Stride: 1},
+ {Lo: 0xA70, Hi: 0xA71, Stride: 1},
+ {Lo: 0xA75, Hi: 0xA75, Stride: 1},
+ {Lo: 0xA81, Hi: 0xA83, Stride: 1},
+ {Lo: 0xABC, Hi: 0xABC, Stride: 1},
+ {Lo: 0xABE, Hi: 0xAC5, Stride: 1},
+ {Lo: 0xAC7, Hi: 0xAC9, Stride: 1},
+ {Lo: 0xACB, Hi: 0xACD, Stride: 1},
+ {Lo: 0xAE2, Hi: 0xAE3, Stride: 1},
+ {Lo: 0xAFA, Hi: 0xAFF, Stride: 1},
+ {Lo: 0xB01, Hi: 0xB03, Stride: 1},
+ {Lo: 0xB3C, Hi: 0xB3C, Stride: 1},
+ {Lo: 0xB3E, Hi: 0xB44, Stride: 1},
+ {Lo: 0xB47, Hi: 0xB48, Stride: 1},
+ {Lo: 0xB4B, Hi: 0xB4D, Stride: 1},
+ {Lo: 0xB55, Hi: 0xB57, Stride: 1},
+ {Lo: 0xB62, Hi: 0xB63, Stride: 1},
+ {Lo: 0xB82, Hi: 0xB82, Stride: 1},
+ {Lo: 0xBBE, Hi: 0xBC2, Stride: 1},
+ {Lo: 0xBC6, Hi: 0xBC8, Stride: 1},
+ {Lo: 0xBCA, Hi: 0xBCD, Stride: 1},
+ {Lo: 0xBD7, Hi: 0xBD7, Stride: 1},
+ {Lo: 0xC00, Hi: 0xC04, Stride: 1},
+ {Lo: 0xC3C, Hi: 0xC3C, Stride: 1},
+ {Lo: 0xC3E, Hi: 0xC44, Stride: 1},
+ {Lo: 0xC46, Hi: 0xC48, Stride: 1},
+ {Lo: 0xC4A, Hi: 0xC4D, Stride: 1},
+ {Lo: 0xC55, Hi: 0xC56, Stride: 1},
+ {Lo: 0xC62, Hi: 0xC63, Stride: 1},
+ {Lo: 0xC81, Hi: 0xC83, Stride: 1},
+ {Lo: 0xCBC, Hi: 0xCBC, Stride: 1},
+ {Lo: 0xCBE, Hi: 0xCC4, Stride: 1},
+ {Lo: 0xCC6, Hi: 0xCC8, Stride: 1},
+ {Lo: 0xCCA, Hi: 0xCCD, Stride: 1},
+ {Lo: 0xCD5, Hi: 0xCD6, Stride: 1},
+ {Lo: 0xCE2, Hi: 0xCE3, Stride: 1},
+ {Lo: 0xCF3, Hi: 0xCF3, Stride: 1},
+ {Lo: 0xD00, Hi: 0xD03, Stride: 1},
+ {Lo: 0xD3B, Hi: 0xD3C, Stride: 1},
+ {Lo: 0xD3E, Hi: 0xD44, Stride: 1},
+ {Lo: 0xD46, Hi: 0xD48, Stride: 1},
+ {Lo: 0xD4A, Hi: 0xD4D, Stride: 1},
+ {Lo: 0xD57, Hi: 0xD57, Stride: 1},
+ {Lo: 0xD62, Hi: 0xD63, Stride: 1},
+ {Lo: 0xD81, Hi: 0xD83, Stride: 1},
+ {Lo: 0xDCA, Hi: 0xDCA, Stride: 1},
+ {Lo: 0xDCF, Hi: 0xDD4, Stride: 1},
+ {Lo: 0xDD6, Hi: 0xDD6, Stride: 1},
+ {Lo: 0xDD8, Hi: 0xDDF, Stride: 1},
+ {Lo: 0xDF2, Hi: 0xDF3, Stride: 1},
+ {Lo: 0xE31, Hi: 0xE31, Stride: 1},
+ {Lo: 0xE34, Hi: 0xE3A, Stride: 1},
+ {Lo: 0xE47, Hi: 0xE4E, Stride: 1},
+ {Lo: 0xEB1, Hi: 0xEB1, Stride: 1},
+ {Lo: 0xEB4, Hi: 0xEBC, Stride: 1},
+ {Lo: 0xEC8, Hi: 0xECE, Stride: 1},
+ {Lo: 0xF18, Hi: 0xF19, Stride: 1},
+ {Lo: 0xF35, Hi: 0xF35, Stride: 1},
+ {Lo: 0xF37, Hi: 0xF37, Stride: 1},
+ {Lo: 0xF39, Hi: 0xF39, Stride: 1},
+ {Lo: 0xF3E, Hi: 0xF3F, Stride: 1},
+ {Lo: 0xF71, Hi: 0xF84, Stride: 1},
+ {Lo: 0xF86, Hi: 0xF87, Stride: 1},
+ {Lo: 0xF8D, Hi: 0xF97, Stride: 1},
+ {Lo: 0xF99, Hi: 0xFBC, Stride: 1},
+ {Lo: 0xFC6, Hi: 0xFC6, Stride: 1},
+ {Lo: 0x102B, Hi: 0x103E, Stride: 1},
+ {Lo: 0x1056, Hi: 0x1059, Stride: 1},
+ {Lo: 0x105E, Hi: 0x1060, Stride: 1},
+ {Lo: 0x1062, Hi: 0x1064, Stride: 1},
+ {Lo: 0x1067, Hi: 0x106D, Stride: 1},
+ {Lo: 0x1071, Hi: 0x1074, Stride: 1},
+ {Lo: 0x1082, Hi: 0x108D, Stride: 1},
+ {Lo: 0x108F, Hi: 0x108F, Stride: 1},
+ {Lo: 0x109A, Hi: 0x109D, Stride: 1},
+ {Lo: 0x135D, Hi: 0x135F, Stride: 1},
+ {Lo: 0x1712, Hi: 0x1715, Stride: 1},
+ {Lo: 0x1732, Hi: 0x1734, Stride: 1},
+ {Lo: 0x1752, Hi: 0x1753, Stride: 1},
+ {Lo: 0x1772, Hi: 0x1773, Stride: 1},
+ {Lo: 0x17B4, Hi: 0x17D3, Stride: 1},
+ {Lo: 0x17DD, Hi: 0x17DD, Stride: 1},
+ {Lo: 0x180B, Hi: 0x180D, Stride: 1},
+ {Lo: 0x180F, Hi: 0x180F, Stride: 1},
+ {Lo: 0x1885, Hi: 0x1886, Stride: 1},
+ {Lo: 0x18A9, Hi: 0x18A9, Stride: 1},
+ {Lo: 0x1920, Hi: 0x192B, Stride: 1},
+ {Lo: 0x1930, Hi: 0x193B, Stride: 1},
+ {Lo: 0x1A17, Hi: 0x1A1B, Stride: 1},
+ {Lo: 0x1A55, Hi: 0x1A5E, Stride: 1},
+ {Lo: 0x1A60, Hi: 0x1A7C, Stride: 1},
+ {Lo: 0x1A7F, Hi: 0x1A7F, Stride: 1},
+ {Lo: 0x1AB0, Hi: 0x1ADD, Stride: 1},
+ {Lo: 0x1AE0, Hi: 0x1AEB, Stride: 1},
+ {Lo: 0x1B00, Hi: 0x1B04, Stride: 1},
+ {Lo: 0x1B34, Hi: 0x1B44, Stride: 1},
+ {Lo: 0x1B6B, Hi: 0x1B73, Stride: 1},
+ {Lo: 0x1B80, Hi: 0x1B82, Stride: 1},
+ {Lo: 0x1BA1, Hi: 0x1BAD, Stride: 1},
+ {Lo: 0x1BE6, Hi: 0x1BF3, Stride: 1},
+ {Lo: 0x1C24, Hi: 0x1C37, Stride: 1},
+ {Lo: 0x1CD0, Hi: 0x1CD2, Stride: 1},
+ {Lo: 0x1CD4, Hi: 0x1CE8, Stride: 1},
+ {Lo: 0x1CED, Hi: 0x1CED, Stride: 1},
+ {Lo: 0x1CF4, Hi: 0x1CF4, Stride: 1},
+ {Lo: 0x1CF7, Hi: 0x1CF9, Stride: 1},
+ {Lo: 0x1DC0, Hi: 0x1DFF, Stride: 1},
+ {Lo: 0x200C, Hi: 0x200D, Stride: 1},
+ {Lo: 0x20D0, Hi: 0x20F0, Stride: 1},
+ {Lo: 0x2CEF, Hi: 0x2CF1, Stride: 1},
+ {Lo: 0x2D7F, Hi: 0x2D7F, Stride: 1},
+ {Lo: 0x2DE0, Hi: 0x2DFF, Stride: 1},
+ {Lo: 0x302A, Hi: 0x302F, Stride: 1},
+ {Lo: 0x3099, Hi: 0x309A, Stride: 1},
+ {Lo: 0xA66F, Hi: 0xA672, Stride: 1},
+ {Lo: 0xA674, Hi: 0xA67D, Stride: 1},
+ {Lo: 0xA69E, Hi: 0xA69F, Stride: 1},
+ {Lo: 0xA6F0, Hi: 0xA6F1, Stride: 1},
+ {Lo: 0xA802, Hi: 0xA802, Stride: 1},
+ {Lo: 0xA806, Hi: 0xA806, Stride: 1},
+ {Lo: 0xA80B, Hi: 0xA80B, Stride: 1},
+ {Lo: 0xA823, Hi: 0xA827, Stride: 1},
+ {Lo: 0xA82C, Hi: 0xA82C, Stride: 1},
+ {Lo: 0xA880, Hi: 0xA881, Stride: 1},
+ {Lo: 0xA8B4, Hi: 0xA8C5, Stride: 1},
+ {Lo: 0xA8E0, Hi: 0xA8F1, Stride: 1},
+ {Lo: 0xA8FF, Hi: 0xA8FF, Stride: 1},
+ {Lo: 0xA926, Hi: 0xA92D, Stride: 1},
+ {Lo: 0xA947, Hi: 0xA953, Stride: 1},
+ {Lo: 0xA980, Hi: 0xA983, Stride: 1},
+ {Lo: 0xA9B3, Hi: 0xA9C0, Stride: 1},
+ {Lo: 0xA9E5, Hi: 0xA9E5, Stride: 1},
+ {Lo: 0xAA29, Hi: 0xAA36, Stride: 1},
+ {Lo: 0xAA43, Hi: 0xAA43, Stride: 1},
+ {Lo: 0xAA4C, Hi: 0xAA4D, Stride: 1},
+ {Lo: 0xAA7B, Hi: 0xAA7D, Stride: 1},
+ {Lo: 0xAAB0, Hi: 0xAAB0, Stride: 1},
+ {Lo: 0xAAB2, Hi: 0xAAB4, Stride: 1},
+ {Lo: 0xAAB7, Hi: 0xAAB8, Stride: 1},
+ {Lo: 0xAABE, Hi: 0xAABF, Stride: 1},
+ {Lo: 0xAAC1, Hi: 0xAAC1, Stride: 1},
+ {Lo: 0xAAEB, Hi: 0xAAEF, Stride: 1},
+ {Lo: 0xAAF5, Hi: 0xAAF6, Stride: 1},
+ {Lo: 0xABE3, Hi: 0xABEA, Stride: 1},
+ {Lo: 0xABEC, Hi: 0xABED, Stride: 1},
+ {Lo: 0xFB1E, Hi: 0xFB1E, Stride: 1},
+ {Lo: 0xFE00, Hi: 0xFE0F, Stride: 1},
+ {Lo: 0xFE20, Hi: 0xFE2F, Stride: 1},
+ {Lo: 0xFF9E, Hi: 0xFF9F, Stride: 1},
+ },
+ R32: []unicode.Range32{
+ {Lo: 0x101FD, Hi: 0x101FD, Stride: 1},
+ {Lo: 0x102E0, Hi: 0x102E0, Stride: 1},
+ {Lo: 0x10376, Hi: 0x1037A, Stride: 1},
+ {Lo: 0x10A01, Hi: 0x10A03, Stride: 1},
+ {Lo: 0x10A05, Hi: 0x10A06, Stride: 1},
+ {Lo: 0x10A0C, Hi: 0x10A0F, Stride: 1},
+ {Lo: 0x10A38, Hi: 0x10A3A, Stride: 1},
+ {Lo: 0x10A3F, Hi: 0x10A3F, Stride: 1},
+ {Lo: 0x10AE5, Hi: 0x10AE6, Stride: 1},
+ {Lo: 0x10D24, Hi: 0x10D27, Stride: 1},
+ {Lo: 0x10D69, Hi: 0x10D6D, Stride: 1},
+ {Lo: 0x10EAB, Hi: 0x10EAC, Stride: 1},
+ {Lo: 0x10EFA, Hi: 0x10EFF, Stride: 1},
+ {Lo: 0x10F46, Hi: 0x10F50, Stride: 1},
+ {Lo: 0x10F82, Hi: 0x10F85, Stride: 1},
+ {Lo: 0x11000, Hi: 0x11002, Stride: 1},
+ {Lo: 0x11038, Hi: 0x11046, Stride: 1},
+ {Lo: 0x11070, Hi: 0x11070, Stride: 1},
+ {Lo: 0x11073, Hi: 0x11074, Stride: 1},
+ {Lo: 0x1107F, Hi: 0x11082, Stride: 1},
+ {Lo: 0x110B0, Hi: 0x110BA, Stride: 1},
+ {Lo: 0x110C2, Hi: 0x110C2, Stride: 1},
+ {Lo: 0x11100, Hi: 0x11102, Stride: 1},
+ {Lo: 0x11127, Hi: 0x11134, Stride: 1},
+ {Lo: 0x11145, Hi: 0x11146, Stride: 1},
+ {Lo: 0x11173, Hi: 0x11173, Stride: 1},
+ {Lo: 0x11180, Hi: 0x11182, Stride: 1},
+ {Lo: 0x111B3, Hi: 0x111C0, Stride: 1},
+ {Lo: 0x111C9, Hi: 0x111CC, Stride: 1},
+ {Lo: 0x111CE, Hi: 0x111CF, Stride: 1},
+ {Lo: 0x1122C, Hi: 0x11237, Stride: 1},
+ {Lo: 0x1123E, Hi: 0x1123E, Stride: 1},
+ {Lo: 0x11241, Hi: 0x11241, Stride: 1},
+ {Lo: 0x112DF, Hi: 0x112EA, Stride: 1},
+ {Lo: 0x11300, Hi: 0x11303, Stride: 1},
+ {Lo: 0x1133B, Hi: 0x1133C, Stride: 1},
+ {Lo: 0x1133E, Hi: 0x11344, Stride: 1},
+ {Lo: 0x11347, Hi: 0x11348, Stride: 1},
+ {Lo: 0x1134B, Hi: 0x1134D, Stride: 1},
+ {Lo: 0x11357, Hi: 0x11357, Stride: 1},
+ {Lo: 0x11362, Hi: 0x11363, Stride: 1},
+ {Lo: 0x11366, Hi: 0x1136C, Stride: 1},
+ {Lo: 0x11370, Hi: 0x11374, Stride: 1},
+ {Lo: 0x113B8, Hi: 0x113C0, Stride: 1},
+ {Lo: 0x113C2, Hi: 0x113C2, Stride: 1},
+ {Lo: 0x113C5, Hi: 0x113C5, Stride: 1},
+ {Lo: 0x113C7, Hi: 0x113CA, Stride: 1},
+ {Lo: 0x113CC, Hi: 0x113D0, Stride: 1},
+ {Lo: 0x113D2, Hi: 0x113D2, Stride: 1},
+ {Lo: 0x113E1, Hi: 0x113E2, Stride: 1},
+ {Lo: 0x11435, Hi: 0x11446, Stride: 1},
+ {Lo: 0x1145E, Hi: 0x1145E, Stride: 1},
+ {Lo: 0x114B0, Hi: 0x114C3, Stride: 1},
+ {Lo: 0x115AF, Hi: 0x115B5, Stride: 1},
+ {Lo: 0x115B8, Hi: 0x115C0, Stride: 1},
+ {Lo: 0x115DC, Hi: 0x115DD, Stride: 1},
+ {Lo: 0x11630, Hi: 0x11640, Stride: 1},
+ {Lo: 0x116AB, Hi: 0x116B7, Stride: 1},
+ {Lo: 0x1171D, Hi: 0x1172B, Stride: 1},
+ {Lo: 0x1182C, Hi: 0x1183A, Stride: 1},
+ {Lo: 0x11930, Hi: 0x11935, Stride: 1},
+ {Lo: 0x11937, Hi: 0x11938, Stride: 1},
+ {Lo: 0x1193B, Hi: 0x1193E, Stride: 1},
+ {Lo: 0x11940, Hi: 0x11940, Stride: 1},
+ {Lo: 0x11942, Hi: 0x11943, Stride: 1},
+ {Lo: 0x119D1, Hi: 0x119D7, Stride: 1},
+ {Lo: 0x119DA, Hi: 0x119E0, Stride: 1},
+ {Lo: 0x119E4, Hi: 0x119E4, Stride: 1},
+ {Lo: 0x11A01, Hi: 0x11A0A, Stride: 1},
+ {Lo: 0x11A33, Hi: 0x11A39, Stride: 1},
+ {Lo: 0x11A3B, Hi: 0x11A3E, Stride: 1},
+ {Lo: 0x11A47, Hi: 0x11A47, Stride: 1},
+ {Lo: 0x11A51, Hi: 0x11A5B, Stride: 1},
+ {Lo: 0x11A8A, Hi: 0x11A99, Stride: 1},
+ {Lo: 0x11B60, Hi: 0x11B67, Stride: 1},
+ {Lo: 0x11C2F, Hi: 0x11C36, Stride: 1},
+ {Lo: 0x11C38, Hi: 0x11C3F, Stride: 1},
+ {Lo: 0x11C92, Hi: 0x11CA7, Stride: 1},
+ {Lo: 0x11CA9, Hi: 0x11CB6, Stride: 1},
+ {Lo: 0x11D31, Hi: 0x11D36, Stride: 1},
+ {Lo: 0x11D3A, Hi: 0x11D3A, Stride: 1},
+ {Lo: 0x11D3C, Hi: 0x11D3D, Stride: 1},
+ {Lo: 0x11D3F, Hi: 0x11D45, Stride: 1},
+ {Lo: 0x11D47, Hi: 0x11D47, Stride: 1},
+ {Lo: 0x11D8A, Hi: 0x11D8E, Stride: 1},
+ {Lo: 0x11D90, Hi: 0x11D91, Stride: 1},
+ {Lo: 0x11D93, Hi: 0x11D97, Stride: 1},
+ {Lo: 0x11EF3, Hi: 0x11EF6, Stride: 1},
+ {Lo: 0x11F00, Hi: 0x11F01, Stride: 1},
+ {Lo: 0x11F03, Hi: 0x11F03, Stride: 1},
+ {Lo: 0x11F34, Hi: 0x11F3A, Stride: 1},
+ {Lo: 0x11F3E, Hi: 0x11F42, Stride: 1},
+ {Lo: 0x11F5A, Hi: 0x11F5A, Stride: 1},
+ {Lo: 0x13440, Hi: 0x13440, Stride: 1},
+ {Lo: 0x13447, Hi: 0x13455, Stride: 1},
+ {Lo: 0x1611E, Hi: 0x1612F, Stride: 1},
+ {Lo: 0x16AF0, Hi: 0x16AF4, Stride: 1},
+ {Lo: 0x16B30, Hi: 0x16B36, Stride: 1},
+ {Lo: 0x16F4F, Hi: 0x16F4F, Stride: 1},
+ {Lo: 0x16F51, Hi: 0x16F87, Stride: 1},
+ {Lo: 0x16F8F, Hi: 0x16F92, Stride: 1},
+ {Lo: 0x16FE4, Hi: 0x16FE4, Stride: 1},
+ {Lo: 0x16FF0, Hi: 0x16FF1, Stride: 1},
+ {Lo: 0x1BC9D, Hi: 0x1BC9E, Stride: 1},
+ {Lo: 0x1CF00, Hi: 0x1CF2D, Stride: 1},
+ {Lo: 0x1CF30, Hi: 0x1CF46, Stride: 1},
+ {Lo: 0x1D165, Hi: 0x1D169, Stride: 1},
+ {Lo: 0x1D16D, Hi: 0x1D172, Stride: 1},
+ {Lo: 0x1D17B, Hi: 0x1D182, Stride: 1},
+ {Lo: 0x1D185, Hi: 0x1D18B, Stride: 1},
+ {Lo: 0x1D1AA, Hi: 0x1D1AD, Stride: 1},
+ {Lo: 0x1D242, Hi: 0x1D244, Stride: 1},
+ {Lo: 0x1DA00, Hi: 0x1DA36, Stride: 1},
+ {Lo: 0x1DA3B, Hi: 0x1DA6C, Stride: 1},
+ {Lo: 0x1DA75, Hi: 0x1DA75, Stride: 1},
+ {Lo: 0x1DA84, Hi: 0x1DA84, Stride: 1},
+ {Lo: 0x1DA9B, Hi: 0x1DA9F, Stride: 1},
+ {Lo: 0x1DAA1, Hi: 0x1DAAF, Stride: 1},
+ {Lo: 0x1E000, Hi: 0x1E006, Stride: 1},
+ {Lo: 0x1E008, Hi: 0x1E018, Stride: 1},
+ {Lo: 0x1E01B, Hi: 0x1E021, Stride: 1},
+ {Lo: 0x1E023, Hi: 0x1E024, Stride: 1},
+ {Lo: 0x1E026, Hi: 0x1E02A, Stride: 1},
+ {Lo: 0x1E08F, Hi: 0x1E08F, Stride: 1},
+ {Lo: 0x1E130, Hi: 0x1E136, Stride: 1},
+ {Lo: 0x1E2AE, Hi: 0x1E2AE, Stride: 1},
+ {Lo: 0x1E2EC, Hi: 0x1E2EF, Stride: 1},
+ {Lo: 0x1E4EC, Hi: 0x1E4EF, Stride: 1},
+ {Lo: 0x1E5EE, Hi: 0x1E5EF, Stride: 1},
+ {Lo: 0x1E6E3, Hi: 0x1E6E3, Stride: 1},
+ {Lo: 0x1E6E6, Hi: 0x1E6E6, Stride: 1},
+ {Lo: 0x1E6EE, Hi: 0x1E6EF, Stride: 1},
+ {Lo: 0x1E6F5, Hi: 0x1E6F5, Stride: 1},
+ {Lo: 0x1E8D0, Hi: 0x1E8D6, Stride: 1},
+ {Lo: 0x1E944, Hi: 0x1E94A, Stride: 1},
+ {Lo: 0xE0020, Hi: 0xE007F, Stride: 1},
+ {Lo: 0xE0100, Hi: 0xE01EF, Stride: 1},
+ },
+}
+
+var unicodeAliasSentence_Break_Format = &unicode.RangeTable{
+ R16: []unicode.Range16{
+ {Lo: 0xAD, Hi: 0xAD, Stride: 1},
+ {Lo: 0x61C, Hi: 0x61C, Stride: 1},
+ {Lo: 0x70F, Hi: 0x70F, Stride: 1},
+ {Lo: 0x180E, Hi: 0x180E, Stride: 1},
+ {Lo: 0x200B, Hi: 0x200B, Stride: 1},
+ {Lo: 0x200E, Hi: 0x200F, Stride: 1},
+ {Lo: 0x202A, Hi: 0x202E, Stride: 1},
+ {Lo: 0x2060, Hi: 0x2064, Stride: 1},
+ {Lo: 0x2066, Hi: 0x206F, Stride: 1},
+ {Lo: 0xFEFF, Hi: 0xFEFF, Stride: 1},
+ {Lo: 0xFFF9, Hi: 0xFFFB, Stride: 1},
+ },
+ R32: []unicode.Range32{
+ {Lo: 0x13430, Hi: 0x1343F, Stride: 1},
+ {Lo: 0x1BCA0, Hi: 0x1BCA3, Stride: 1},
+ {Lo: 0x1D173, Hi: 0x1D17A, Stride: 1},
+ {Lo: 0xE0001, Hi: 0xE0001, Stride: 1},
+ },
+}
+
+var unicodeAliasSentence_Break_LF = &unicode.RangeTable{
+ R16: []unicode.Range16{
+ {Lo: 0xA, Hi: 0xA, Stride: 1},
+ },
+}
+
+var unicodeAliasSentence_Break_Lower = &unicode.RangeTable{
+ R16: []unicode.Range16{
+ {Lo: 0x61, Hi: 0x7A, Stride: 1},
+ {Lo: 0xAA, Hi: 0xAA, Stride: 1},
+ {Lo: 0xB5, Hi: 0xB5, Stride: 1},
+ {Lo: 0xBA, Hi: 0xBA, Stride: 1},
+ {Lo: 0xDF, Hi: 0xF6, Stride: 1},
+ {Lo: 0xF8, Hi: 0xFF, Stride: 1},
+ {Lo: 0x101, Hi: 0x101, Stride: 1},
+ {Lo: 0x103, Hi: 0x103, Stride: 1},
+ {Lo: 0x105, Hi: 0x105, Stride: 1},
+ {Lo: 0x107, Hi: 0x107, Stride: 1},
+ {Lo: 0x109, Hi: 0x109, Stride: 1},
+ {Lo: 0x10B, Hi: 0x10B, Stride: 1},
+ {Lo: 0x10D, Hi: 0x10D, Stride: 1},
+ {Lo: 0x10F, Hi: 0x10F, Stride: 1},
+ {Lo: 0x111, Hi: 0x111, Stride: 1},
+ {Lo: 0x113, Hi: 0x113, Stride: 1},
+ {Lo: 0x115, Hi: 0x115, Stride: 1},
+ {Lo: 0x117, Hi: 0x117, Stride: 1},
+ {Lo: 0x119, Hi: 0x119, Stride: 1},
+ {Lo: 0x11B, Hi: 0x11B, Stride: 1},
+ {Lo: 0x11D, Hi: 0x11D, Stride: 1},
+ {Lo: 0x11F, Hi: 0x11F, Stride: 1},
+ {Lo: 0x121, Hi: 0x121, Stride: 1},
+ {Lo: 0x123, Hi: 0x123, Stride: 1},
+ {Lo: 0x125, Hi: 0x125, Stride: 1},
+ {Lo: 0x127, Hi: 0x127, Stride: 1},
+ {Lo: 0x129, Hi: 0x129, Stride: 1},
+ {Lo: 0x12B, Hi: 0x12B, Stride: 1},
+ {Lo: 0x12D, Hi: 0x12D, Stride: 1},
+ {Lo: 0x12F, Hi: 0x12F, Stride: 1},
+ {Lo: 0x131, Hi: 0x131, Stride: 1},
+ {Lo: 0x133, Hi: 0x133, Stride: 1},
+ {Lo: 0x135, Hi: 0x135, Stride: 1},
+ {Lo: 0x137, Hi: 0x138, Stride: 1},
+ {Lo: 0x13A, Hi: 0x13A, Stride: 1},
+ {Lo: 0x13C, Hi: 0x13C, Stride: 1},
+ {Lo: 0x13E, Hi: 0x13E, Stride: 1},
+ {Lo: 0x140, Hi: 0x140, Stride: 1},
+ {Lo: 0x142, Hi: 0x142, Stride: 1},
+ {Lo: 0x144, Hi: 0x144, Stride: 1},
+ {Lo: 0x146, Hi: 0x146, Stride: 1},
+ {Lo: 0x148, Hi: 0x149, Stride: 1},
+ {Lo: 0x14B, Hi: 0x14B, Stride: 1},
+ {Lo: 0x14D, Hi: 0x14D, Stride: 1},
+ {Lo: 0x14F, Hi: 0x14F, Stride: 1},
+ {Lo: 0x151, Hi: 0x151, Stride: 1},
+ {Lo: 0x153, Hi: 0x153, Stride: 1},
+ {Lo: 0x155, Hi: 0x155, Stride: 1},
+ {Lo: 0x157, Hi: 0x157, Stride: 1},
+ {Lo: 0x159, Hi: 0x159, Stride: 1},
+ {Lo: 0x15B, Hi: 0x15B, Stride: 1},
+ {Lo: 0x15D, Hi: 0x15D, Stride: 1},
+ {Lo: 0x15F, Hi: 0x15F, Stride: 1},
+ {Lo: 0x161, Hi: 0x161, Stride: 1},
+ {Lo: 0x163, Hi: 0x163, Stride: 1},
+ {Lo: 0x165, Hi: 0x165, Stride: 1},
+ {Lo: 0x167, Hi: 0x167, Stride: 1},
+ {Lo: 0x169, Hi: 0x169, Stride: 1},
+ {Lo: 0x16B, Hi: 0x16B, Stride: 1},
+ {Lo: 0x16D, Hi: 0x16D, Stride: 1},
+ {Lo: 0x16F, Hi: 0x16F, Stride: 1},
+ {Lo: 0x171, Hi: 0x171, Stride: 1},
+ {Lo: 0x173, Hi: 0x173, Stride: 1},
+ {Lo: 0x175, Hi: 0x175, Stride: 1},
+ {Lo: 0x177, Hi: 0x177, Stride: 1},
+ {Lo: 0x17A, Hi: 0x17A, Stride: 1},
+ {Lo: 0x17C, Hi: 0x17C, Stride: 1},
+ {Lo: 0x17E, Hi: 0x180, Stride: 1},
+ {Lo: 0x183, Hi: 0x183, Stride: 1},
+ {Lo: 0x185, Hi: 0x185, Stride: 1},
+ {Lo: 0x188, Hi: 0x188, Stride: 1},
+ {Lo: 0x18C, Hi: 0x18D, Stride: 1},
+ {Lo: 0x192, Hi: 0x192, Stride: 1},
+ {Lo: 0x195, Hi: 0x195, Stride: 1},
+ {Lo: 0x199, Hi: 0x19B, Stride: 1},
+ {Lo: 0x19E, Hi: 0x19E, Stride: 1},
+ {Lo: 0x1A1, Hi: 0x1A1, Stride: 1},
+ {Lo: 0x1A3, Hi: 0x1A3, Stride: 1},
+ {Lo: 0x1A5, Hi: 0x1A5, Stride: 1},
+ {Lo: 0x1A8, Hi: 0x1A8, Stride: 1},
+ {Lo: 0x1AA, Hi: 0x1AB, Stride: 1},
+ {Lo: 0x1AD, Hi: 0x1AD, Stride: 1},
+ {Lo: 0x1B0, Hi: 0x1B0, Stride: 1},
+ {Lo: 0x1B4, Hi: 0x1B4, Stride: 1},
+ {Lo: 0x1B6, Hi: 0x1B6, Stride: 1},
+ {Lo: 0x1B9, Hi: 0x1BA, Stride: 1},
+ {Lo: 0x1BD, Hi: 0x1BF, Stride: 1},
+ {Lo: 0x1C6, Hi: 0x1C6, Stride: 1},
+ {Lo: 0x1C9, Hi: 0x1C9, Stride: 1},
+ {Lo: 0x1CC, Hi: 0x1CC, Stride: 1},
+ {Lo: 0x1CE, Hi: 0x1CE, Stride: 1},
+ {Lo: 0x1D0, Hi: 0x1D0, Stride: 1},
+ {Lo: 0x1D2, Hi: 0x1D2, Stride: 1},
+ {Lo: 0x1D4, Hi: 0x1D4, Stride: 1},
+ {Lo: 0x1D6, Hi: 0x1D6, Stride: 1},
+ {Lo: 0x1D8, Hi: 0x1D8, Stride: 1},
+ {Lo: 0x1DA, Hi: 0x1DA, Stride: 1},
+ {Lo: 0x1DC, Hi: 0x1DD, Stride: 1},
+ {Lo: 0x1DF, Hi: 0x1DF, Stride: 1},
+ {Lo: 0x1E1, Hi: 0x1E1, Stride: 1},
+ {Lo: 0x1E3, Hi: 0x1E3, Stride: 1},
+ {Lo: 0x1E5, Hi: 0x1E5, Stride: 1},
+ {Lo: 0x1E7, Hi: 0x1E7, Stride: 1},
+ {Lo: 0x1E9, Hi: 0x1E9, Stride: 1},
+ {Lo: 0x1EB, Hi: 0x1EB, Stride: 1},
+ {Lo: 0x1ED, Hi: 0x1ED, Stride: 1},
+ {Lo: 0x1EF, Hi: 0x1F0, Stride: 1},
+ {Lo: 0x1F3, Hi: 0x1F3, Stride: 1},
+ {Lo: 0x1F5, Hi: 0x1F5, Stride: 1},
+ {Lo: 0x1F9, Hi: 0x1F9, Stride: 1},
+ {Lo: 0x1FB, Hi: 0x1FB, Stride: 1},
+ {Lo: 0x1FD, Hi: 0x1FD, Stride: 1},
+ {Lo: 0x1FF, Hi: 0x1FF, Stride: 1},
+ {Lo: 0x201, Hi: 0x201, Stride: 1},
+ {Lo: 0x203, Hi: 0x203, Stride: 1},
+ {Lo: 0x205, Hi: 0x205, Stride: 1},
+ {Lo: 0x207, Hi: 0x207, Stride: 1},
+ {Lo: 0x209, Hi: 0x209, Stride: 1},
+ {Lo: 0x20B, Hi: 0x20B, Stride: 1},
+ {Lo: 0x20D, Hi: 0x20D, Stride: 1},
+ {Lo: 0x20F, Hi: 0x20F, Stride: 1},
+ {Lo: 0x211, Hi: 0x211, Stride: 1},
+ {Lo: 0x213, Hi: 0x213, Stride: 1},
+ {Lo: 0x215, Hi: 0x215, Stride: 1},
+ {Lo: 0x217, Hi: 0x217, Stride: 1},
+ {Lo: 0x219, Hi: 0x219, Stride: 1},
+ {Lo: 0x21B, Hi: 0x21B, Stride: 1},
+ {Lo: 0x21D, Hi: 0x21D, Stride: 1},
+ {Lo: 0x21F, Hi: 0x21F, Stride: 1},
+ {Lo: 0x221, Hi: 0x221, Stride: 1},
+ {Lo: 0x223, Hi: 0x223, Stride: 1},
+ {Lo: 0x225, Hi: 0x225, Stride: 1},
+ {Lo: 0x227, Hi: 0x227, Stride: 1},
+ {Lo: 0x229, Hi: 0x229, Stride: 1},
+ {Lo: 0x22B, Hi: 0x22B, Stride: 1},
+ {Lo: 0x22D, Hi: 0x22D, Stride: 1},
+ {Lo: 0x22F, Hi: 0x22F, Stride: 1},
+ {Lo: 0x231, Hi: 0x231, Stride: 1},
+ {Lo: 0x233, Hi: 0x239, Stride: 1},
+ {Lo: 0x23C, Hi: 0x23C, Stride: 1},
+ {Lo: 0x23F, Hi: 0x240, Stride: 1},
+ {Lo: 0x242, Hi: 0x242, Stride: 1},
+ {Lo: 0x247, Hi: 0x247, Stride: 1},
+ {Lo: 0x249, Hi: 0x249, Stride: 1},
+ {Lo: 0x24B, Hi: 0x24B, Stride: 1},
+ {Lo: 0x24D, Hi: 0x24D, Stride: 1},
+ {Lo: 0x24F, Hi: 0x293, Stride: 1},
+ {Lo: 0x296, Hi: 0x2B8, Stride: 1},
+ {Lo: 0x2C0, Hi: 0x2C1, Stride: 1},
+ {Lo: 0x2E0, Hi: 0x2E4, Stride: 1},
+ {Lo: 0x371, Hi: 0x371, Stride: 1},
+ {Lo: 0x373, Hi: 0x373, Stride: 1},
+ {Lo: 0x377, Hi: 0x377, Stride: 1},
+ {Lo: 0x37A, Hi: 0x37D, Stride: 1},
+ {Lo: 0x390, Hi: 0x390, Stride: 1},
+ {Lo: 0x3AC, Hi: 0x3CE, Stride: 1},
+ {Lo: 0x3D0, Hi: 0x3D1, Stride: 1},
+ {Lo: 0x3D5, Hi: 0x3D7, Stride: 1},
+ {Lo: 0x3D9, Hi: 0x3D9, Stride: 1},
+ {Lo: 0x3DB, Hi: 0x3DB, Stride: 1},
+ {Lo: 0x3DD, Hi: 0x3DD, Stride: 1},
+ {Lo: 0x3DF, Hi: 0x3DF, Stride: 1},
+ {Lo: 0x3E1, Hi: 0x3E1, Stride: 1},
+ {Lo: 0x3E3, Hi: 0x3E3, Stride: 1},
+ {Lo: 0x3E5, Hi: 0x3E5, Stride: 1},
+ {Lo: 0x3E7, Hi: 0x3E7, Stride: 1},
+ {Lo: 0x3E9, Hi: 0x3E9, Stride: 1},
+ {Lo: 0x3EB, Hi: 0x3EB, Stride: 1},
+ {Lo: 0x3ED, Hi: 0x3ED, Stride: 1},
+ {Lo: 0x3EF, Hi: 0x3F3, Stride: 1},
+ {Lo: 0x3F5, Hi: 0x3F5, Stride: 1},
+ {Lo: 0x3F8, Hi: 0x3F8, Stride: 1},
+ {Lo: 0x3FB, Hi: 0x3FC, Stride: 1},
+ {Lo: 0x430, Hi: 0x45F, Stride: 1},
+ {Lo: 0x461, Hi: 0x461, Stride: 1},
+ {Lo: 0x463, Hi: 0x463, Stride: 1},
+ {Lo: 0x465, Hi: 0x465, Stride: 1},
+ {Lo: 0x467, Hi: 0x467, Stride: 1},
+ {Lo: 0x469, Hi: 0x469, Stride: 1},
+ {Lo: 0x46B, Hi: 0x46B, Stride: 1},
+ {Lo: 0x46D, Hi: 0x46D, Stride: 1},
+ {Lo: 0x46F, Hi: 0x46F, Stride: 1},
+ {Lo: 0x471, Hi: 0x471, Stride: 1},
+ {Lo: 0x473, Hi: 0x473, Stride: 1},
+ {Lo: 0x475, Hi: 0x475, Stride: 1},
+ {Lo: 0x477, Hi: 0x477, Stride: 1},
+ {Lo: 0x479, Hi: 0x479, Stride: 1},
+ {Lo: 0x47B, Hi: 0x47B, Stride: 1},
+ {Lo: 0x47D, Hi: 0x47D, Stride: 1},
+ {Lo: 0x47F, Hi: 0x47F, Stride: 1},
+ {Lo: 0x481, Hi: 0x481, Stride: 1},
+ {Lo: 0x48B, Hi: 0x48B, Stride: 1},
+ {Lo: 0x48D, Hi: 0x48D, Stride: 1},
+ {Lo: 0x48F, Hi: 0x48F, Stride: 1},
+ {Lo: 0x491, Hi: 0x491, Stride: 1},
+ {Lo: 0x493, Hi: 0x493, Stride: 1},
+ {Lo: 0x495, Hi: 0x495, Stride: 1},
+ {Lo: 0x497, Hi: 0x497, Stride: 1},
+ {Lo: 0x499, Hi: 0x499, Stride: 1},
+ {Lo: 0x49B, Hi: 0x49B, Stride: 1},
+ {Lo: 0x49D, Hi: 0x49D, Stride: 1},
+ {Lo: 0x49F, Hi: 0x49F, Stride: 1},
+ {Lo: 0x4A1, Hi: 0x4A1, Stride: 1},
+ {Lo: 0x4A3, Hi: 0x4A3, Stride: 1},
+ {Lo: 0x4A5, Hi: 0x4A5, Stride: 1},
+ {Lo: 0x4A7, Hi: 0x4A7, Stride: 1},
+ {Lo: 0x4A9, Hi: 0x4A9, Stride: 1},
+ {Lo: 0x4AB, Hi: 0x4AB, Stride: 1},
+ {Lo: 0x4AD, Hi: 0x4AD, Stride: 1},
+ {Lo: 0x4AF, Hi: 0x4AF, Stride: 1},
+ {Lo: 0x4B1, Hi: 0x4B1, Stride: 1},
+ {Lo: 0x4B3, Hi: 0x4B3, Stride: 1},
+ {Lo: 0x4B5, Hi: 0x4B5, Stride: 1},
+ {Lo: 0x4B7, Hi: 0x4B7, Stride: 1},
+ {Lo: 0x4B9, Hi: 0x4B9, Stride: 1},
+ {Lo: 0x4BB, Hi: 0x4BB, Stride: 1},
+ {Lo: 0x4BD, Hi: 0x4BD, Stride: 1},
+ {Lo: 0x4BF, Hi: 0x4BF, Stride: 1},
+ {Lo: 0x4C2, Hi: 0x4C2, Stride: 1},
+ {Lo: 0x4C4, Hi: 0x4C4, Stride: 1},
+ {Lo: 0x4C6, Hi: 0x4C6, Stride: 1},
+ {Lo: 0x4C8, Hi: 0x4C8, Stride: 1},
+ {Lo: 0x4CA, Hi: 0x4CA, Stride: 1},
+ {Lo: 0x4CC, Hi: 0x4CC, Stride: 1},
+ {Lo: 0x4CE, Hi: 0x4CF, Stride: 1},
+ {Lo: 0x4D1, Hi: 0x4D1, Stride: 1},
+ {Lo: 0x4D3, Hi: 0x4D3, Stride: 1},
+ {Lo: 0x4D5, Hi: 0x4D5, Stride: 1},
+ {Lo: 0x4D7, Hi: 0x4D7, Stride: 1},
+ {Lo: 0x4D9, Hi: 0x4D9, Stride: 1},
+ {Lo: 0x4DB, Hi: 0x4DB, Stride: 1},
+ {Lo: 0x4DD, Hi: 0x4DD, Stride: 1},
+ {Lo: 0x4DF, Hi: 0x4DF, Stride: 1},
+ {Lo: 0x4E1, Hi: 0x4E1, Stride: 1},
+ {Lo: 0x4E3, Hi: 0x4E3, Stride: 1},
+ {Lo: 0x4E5, Hi: 0x4E5, Stride: 1},
+ {Lo: 0x4E7, Hi: 0x4E7, Stride: 1},
+ {Lo: 0x4E9, Hi: 0x4E9, Stride: 1},
+ {Lo: 0x4EB, Hi: 0x4EB, Stride: 1},
+ {Lo: 0x4ED, Hi: 0x4ED, Stride: 1},
+ {Lo: 0x4EF, Hi: 0x4EF, Stride: 1},
+ {Lo: 0x4F1, Hi: 0x4F1, Stride: 1},
+ {Lo: 0x4F3, Hi: 0x4F3, Stride: 1},
+ {Lo: 0x4F5, Hi: 0x4F5, Stride: 1},
+ {Lo: 0x4F7, Hi: 0x4F7, Stride: 1},
+ {Lo: 0x4F9, Hi: 0x4F9, Stride: 1},
+ {Lo: 0x4FB, Hi: 0x4FB, Stride: 1},
+ {Lo: 0x4FD, Hi: 0x4FD, Stride: 1},
+ {Lo: 0x4FF, Hi: 0x4FF, Stride: 1},
+ {Lo: 0x501, Hi: 0x501, Stride: 1},
+ {Lo: 0x503, Hi: 0x503, Stride: 1},
+ {Lo: 0x505, Hi: 0x505, Stride: 1},
+ {Lo: 0x507, Hi: 0x507, Stride: 1},
+ {Lo: 0x509, Hi: 0x509, Stride: 1},
+ {Lo: 0x50B, Hi: 0x50B, Stride: 1},
+ {Lo: 0x50D, Hi: 0x50D, Stride: 1},
+ {Lo: 0x50F, Hi: 0x50F, Stride: 1},
+ {Lo: 0x511, Hi: 0x511, Stride: 1},
+ {Lo: 0x513, Hi: 0x513, Stride: 1},
+ {Lo: 0x515, Hi: 0x515, Stride: 1},
+ {Lo: 0x517, Hi: 0x517, Stride: 1},
+ {Lo: 0x519, Hi: 0x519, Stride: 1},
+ {Lo: 0x51B, Hi: 0x51B, Stride: 1},
+ {Lo: 0x51D, Hi: 0x51D, Stride: 1},
+ {Lo: 0x51F, Hi: 0x51F, Stride: 1},
+ {Lo: 0x521, Hi: 0x521, Stride: 1},
+ {Lo: 0x523, Hi: 0x523, Stride: 1},
+ {Lo: 0x525, Hi: 0x525, Stride: 1},
+ {Lo: 0x527, Hi: 0x527, Stride: 1},
+ {Lo: 0x529, Hi: 0x529, Stride: 1},
+ {Lo: 0x52B, Hi: 0x52B, Stride: 1},
+ {Lo: 0x52D, Hi: 0x52D, Stride: 1},
+ {Lo: 0x52F, Hi: 0x52F, Stride: 1},
+ {Lo: 0x560, Hi: 0x588, Stride: 1},
+ {Lo: 0x10FC, Hi: 0x10FC, Stride: 1},
+ {Lo: 0x13F8, Hi: 0x13FD, Stride: 1},
+ {Lo: 0x1C80, Hi: 0x1C88, Stride: 1},
+ {Lo: 0x1C8A, Hi: 0x1C8A, Stride: 1},
+ {Lo: 0x1D00, Hi: 0x1DBF, Stride: 1},
+ {Lo: 0x1E01, Hi: 0x1E01, Stride: 1},
+ {Lo: 0x1E03, Hi: 0x1E03, Stride: 1},
+ {Lo: 0x1E05, Hi: 0x1E05, Stride: 1},
+ {Lo: 0x1E07, Hi: 0x1E07, Stride: 1},
+ {Lo: 0x1E09, Hi: 0x1E09, Stride: 1},
+ {Lo: 0x1E0B, Hi: 0x1E0B, Stride: 1},
+ {Lo: 0x1E0D, Hi: 0x1E0D, Stride: 1},
+ {Lo: 0x1E0F, Hi: 0x1E0F, Stride: 1},
+ {Lo: 0x1E11, Hi: 0x1E11, Stride: 1},
+ {Lo: 0x1E13, Hi: 0x1E13, Stride: 1},
+ {Lo: 0x1E15, Hi: 0x1E15, Stride: 1},
+ {Lo: 0x1E17, Hi: 0x1E17, Stride: 1},
+ {Lo: 0x1E19, Hi: 0x1E19, Stride: 1},
+ {Lo: 0x1E1B, Hi: 0x1E1B, Stride: 1},
+ {Lo: 0x1E1D, Hi: 0x1E1D, Stride: 1},
+ {Lo: 0x1E1F, Hi: 0x1E1F, Stride: 1},
+ {Lo: 0x1E21, Hi: 0x1E21, Stride: 1},
+ {Lo: 0x1E23, Hi: 0x1E23, Stride: 1},
+ {Lo: 0x1E25, Hi: 0x1E25, Stride: 1},
+ {Lo: 0x1E27, Hi: 0x1E27, Stride: 1},
+ {Lo: 0x1E29, Hi: 0x1E29, Stride: 1},
+ {Lo: 0x1E2B, Hi: 0x1E2B, Stride: 1},
+ {Lo: 0x1E2D, Hi: 0x1E2D, Stride: 1},
+ {Lo: 0x1E2F, Hi: 0x1E2F, Stride: 1},
+ {Lo: 0x1E31, Hi: 0x1E31, Stride: 1},
+ {Lo: 0x1E33, Hi: 0x1E33, Stride: 1},
+ {Lo: 0x1E35, Hi: 0x1E35, Stride: 1},
+ {Lo: 0x1E37, Hi: 0x1E37, Stride: 1},
+ {Lo: 0x1E39, Hi: 0x1E39, Stride: 1},
+ {Lo: 0x1E3B, Hi: 0x1E3B, Stride: 1},
+ {Lo: 0x1E3D, Hi: 0x1E3D, Stride: 1},
+ {Lo: 0x1E3F, Hi: 0x1E3F, Stride: 1},
+ {Lo: 0x1E41, Hi: 0x1E41, Stride: 1},
+ {Lo: 0x1E43, Hi: 0x1E43, Stride: 1},
+ {Lo: 0x1E45, Hi: 0x1E45, Stride: 1},
+ {Lo: 0x1E47, Hi: 0x1E47, Stride: 1},
+ {Lo: 0x1E49, Hi: 0x1E49, Stride: 1},
+ {Lo: 0x1E4B, Hi: 0x1E4B, Stride: 1},
+ {Lo: 0x1E4D, Hi: 0x1E4D, Stride: 1},
+ {Lo: 0x1E4F, Hi: 0x1E4F, Stride: 1},
+ {Lo: 0x1E51, Hi: 0x1E51, Stride: 1},
+ {Lo: 0x1E53, Hi: 0x1E53, Stride: 1},
+ {Lo: 0x1E55, Hi: 0x1E55, Stride: 1},
+ {Lo: 0x1E57, Hi: 0x1E57, Stride: 1},
+ {Lo: 0x1E59, Hi: 0x1E59, Stride: 1},
+ {Lo: 0x1E5B, Hi: 0x1E5B, Stride: 1},
+ {Lo: 0x1E5D, Hi: 0x1E5D, Stride: 1},
+ {Lo: 0x1E5F, Hi: 0x1E5F, Stride: 1},
+ {Lo: 0x1E61, Hi: 0x1E61, Stride: 1},
+ {Lo: 0x1E63, Hi: 0x1E63, Stride: 1},
+ {Lo: 0x1E65, Hi: 0x1E65, Stride: 1},
+ {Lo: 0x1E67, Hi: 0x1E67, Stride: 1},
+ {Lo: 0x1E69, Hi: 0x1E69, Stride: 1},
+ {Lo: 0x1E6B, Hi: 0x1E6B, Stride: 1},
+ {Lo: 0x1E6D, Hi: 0x1E6D, Stride: 1},
+ {Lo: 0x1E6F, Hi: 0x1E6F, Stride: 1},
+ {Lo: 0x1E71, Hi: 0x1E71, Stride: 1},
+ {Lo: 0x1E73, Hi: 0x1E73, Stride: 1},
+ {Lo: 0x1E75, Hi: 0x1E75, Stride: 1},
+ {Lo: 0x1E77, Hi: 0x1E77, Stride: 1},
+ {Lo: 0x1E79, Hi: 0x1E79, Stride: 1},
+ {Lo: 0x1E7B, Hi: 0x1E7B, Stride: 1},
+ {Lo: 0x1E7D, Hi: 0x1E7D, Stride: 1},
+ {Lo: 0x1E7F, Hi: 0x1E7F, Stride: 1},
+ {Lo: 0x1E81, Hi: 0x1E81, Stride: 1},
+ {Lo: 0x1E83, Hi: 0x1E83, Stride: 1},
+ {Lo: 0x1E85, Hi: 0x1E85, Stride: 1},
+ {Lo: 0x1E87, Hi: 0x1E87, Stride: 1},
+ {Lo: 0x1E89, Hi: 0x1E89, Stride: 1},
+ {Lo: 0x1E8B, Hi: 0x1E8B, Stride: 1},
+ {Lo: 0x1E8D, Hi: 0x1E8D, Stride: 1},
+ {Lo: 0x1E8F, Hi: 0x1E8F, Stride: 1},
+ {Lo: 0x1E91, Hi: 0x1E91, Stride: 1},
+ {Lo: 0x1E93, Hi: 0x1E93, Stride: 1},
+ {Lo: 0x1E95, Hi: 0x1E9D, Stride: 1},
+ {Lo: 0x1E9F, Hi: 0x1E9F, Stride: 1},
+ {Lo: 0x1EA1, Hi: 0x1EA1, Stride: 1},
+ {Lo: 0x1EA3, Hi: 0x1EA3, Stride: 1},
+ {Lo: 0x1EA5, Hi: 0x1EA5, Stride: 1},
+ {Lo: 0x1EA7, Hi: 0x1EA7, Stride: 1},
+ {Lo: 0x1EA9, Hi: 0x1EA9, Stride: 1},
+ {Lo: 0x1EAB, Hi: 0x1EAB, Stride: 1},
+ {Lo: 0x1EAD, Hi: 0x1EAD, Stride: 1},
+ {Lo: 0x1EAF, Hi: 0x1EAF, Stride: 1},
+ {Lo: 0x1EB1, Hi: 0x1EB1, Stride: 1},
+ {Lo: 0x1EB3, Hi: 0x1EB3, Stride: 1},
+ {Lo: 0x1EB5, Hi: 0x1EB5, Stride: 1},
+ {Lo: 0x1EB7, Hi: 0x1EB7, Stride: 1},
+ {Lo: 0x1EB9, Hi: 0x1EB9, Stride: 1},
+ {Lo: 0x1EBB, Hi: 0x1EBB, Stride: 1},
+ {Lo: 0x1EBD, Hi: 0x1EBD, Stride: 1},
+ {Lo: 0x1EBF, Hi: 0x1EBF, Stride: 1},
+ {Lo: 0x1EC1, Hi: 0x1EC1, Stride: 1},
+ {Lo: 0x1EC3, Hi: 0x1EC3, Stride: 1},
+ {Lo: 0x1EC5, Hi: 0x1EC5, Stride: 1},
+ {Lo: 0x1EC7, Hi: 0x1EC7, Stride: 1},
+ {Lo: 0x1EC9, Hi: 0x1EC9, Stride: 1},
+ {Lo: 0x1ECB, Hi: 0x1ECB, Stride: 1},
+ {Lo: 0x1ECD, Hi: 0x1ECD, Stride: 1},
+ {Lo: 0x1ECF, Hi: 0x1ECF, Stride: 1},
+ {Lo: 0x1ED1, Hi: 0x1ED1, Stride: 1},
+ {Lo: 0x1ED3, Hi: 0x1ED3, Stride: 1},
+ {Lo: 0x1ED5, Hi: 0x1ED5, Stride: 1},
+ {Lo: 0x1ED7, Hi: 0x1ED7, Stride: 1},
+ {Lo: 0x1ED9, Hi: 0x1ED9, Stride: 1},
+ {Lo: 0x1EDB, Hi: 0x1EDB, Stride: 1},
+ {Lo: 0x1EDD, Hi: 0x1EDD, Stride: 1},
+ {Lo: 0x1EDF, Hi: 0x1EDF, Stride: 1},
+ {Lo: 0x1EE1, Hi: 0x1EE1, Stride: 1},
+ {Lo: 0x1EE3, Hi: 0x1EE3, Stride: 1},
+ {Lo: 0x1EE5, Hi: 0x1EE5, Stride: 1},
+ {Lo: 0x1EE7, Hi: 0x1EE7, Stride: 1},
+ {Lo: 0x1EE9, Hi: 0x1EE9, Stride: 1},
+ {Lo: 0x1EEB, Hi: 0x1EEB, Stride: 1},
+ {Lo: 0x1EED, Hi: 0x1EED, Stride: 1},
+ {Lo: 0x1EEF, Hi: 0x1EEF, Stride: 1},
+ {Lo: 0x1EF1, Hi: 0x1EF1, Stride: 1},
+ {Lo: 0x1EF3, Hi: 0x1EF3, Stride: 1},
+ {Lo: 0x1EF5, Hi: 0x1EF5, Stride: 1},
+ {Lo: 0x1EF7, Hi: 0x1EF7, Stride: 1},
+ {Lo: 0x1EF9, Hi: 0x1EF9, Stride: 1},
+ {Lo: 0x1EFB, Hi: 0x1EFB, Stride: 1},
+ {Lo: 0x1EFD, Hi: 0x1EFD, Stride: 1},
+ {Lo: 0x1EFF, Hi: 0x1F07, Stride: 1},
+ {Lo: 0x1F10, Hi: 0x1F15, Stride: 1},
+ {Lo: 0x1F20, Hi: 0x1F27, Stride: 1},
+ {Lo: 0x1F30, Hi: 0x1F37, Stride: 1},
+ {Lo: 0x1F40, Hi: 0x1F45, Stride: 1},
+ {Lo: 0x1F50, Hi: 0x1F57, Stride: 1},
+ {Lo: 0x1F60, Hi: 0x1F67, Stride: 1},
+ {Lo: 0x1F70, Hi: 0x1F7D, Stride: 1},
+ {Lo: 0x1F80, Hi: 0x1F87, Stride: 1},
+ {Lo: 0x1F90, Hi: 0x1F97, Stride: 1},
+ {Lo: 0x1FA0, Hi: 0x1FA7, Stride: 1},
+ {Lo: 0x1FB0, Hi: 0x1FB4, Stride: 1},
+ {Lo: 0x1FB6, Hi: 0x1FB7, Stride: 1},
+ {Lo: 0x1FBE, Hi: 0x1FBE, Stride: 1},
+ {Lo: 0x1FC2, Hi: 0x1FC4, Stride: 1},
+ {Lo: 0x1FC6, Hi: 0x1FC7, Stride: 1},
+ {Lo: 0x1FD0, Hi: 0x1FD3, Stride: 1},
+ {Lo: 0x1FD6, Hi: 0x1FD7, Stride: 1},
+ {Lo: 0x1FE0, Hi: 0x1FE7, Stride: 1},
+ {Lo: 0x1FF2, Hi: 0x1FF4, Stride: 1},
+ {Lo: 0x1FF6, Hi: 0x1FF7, Stride: 1},
+ {Lo: 0x2071, Hi: 0x2071, Stride: 1},
+ {Lo: 0x207F, Hi: 0x207F, Stride: 1},
+ {Lo: 0x2090, Hi: 0x209C, Stride: 1},
+ {Lo: 0x210A, Hi: 0x210A, Stride: 1},
+ {Lo: 0x210E, Hi: 0x210F, Stride: 1},
+ {Lo: 0x2113, Hi: 0x2113, Stride: 1},
+ {Lo: 0x212F, Hi: 0x212F, Stride: 1},
+ {Lo: 0x2134, Hi: 0x2134, Stride: 1},
+ {Lo: 0x2139, Hi: 0x2139, Stride: 1},
+ {Lo: 0x213C, Hi: 0x213D, Stride: 1},
+ {Lo: 0x2146, Hi: 0x2149, Stride: 1},
+ {Lo: 0x214E, Hi: 0x214E, Stride: 1},
+ {Lo: 0x2170, Hi: 0x217F, Stride: 1},
+ {Lo: 0x2184, Hi: 0x2184, Stride: 1},
+ {Lo: 0x24D0, Hi: 0x24E9, Stride: 1},
+ {Lo: 0x2C30, Hi: 0x2C5F, Stride: 1},
+ {Lo: 0x2C61, Hi: 0x2C61, Stride: 1},
+ {Lo: 0x2C65, Hi: 0x2C66, Stride: 1},
+ {Lo: 0x2C68, Hi: 0x2C68, Stride: 1},
+ {Lo: 0x2C6A, Hi: 0x2C6A, Stride: 1},
+ {Lo: 0x2C6C, Hi: 0x2C6C, Stride: 1},
+ {Lo: 0x2C71, Hi: 0x2C71, Stride: 1},
+ {Lo: 0x2C73, Hi: 0x2C74, Stride: 1},
+ {Lo: 0x2C76, Hi: 0x2C7D, Stride: 1},
+ {Lo: 0x2C81, Hi: 0x2C81, Stride: 1},
+ {Lo: 0x2C83, Hi: 0x2C83, Stride: 1},
+ {Lo: 0x2C85, Hi: 0x2C85, Stride: 1},
+ {Lo: 0x2C87, Hi: 0x2C87, Stride: 1},
+ {Lo: 0x2C89, Hi: 0x2C89, Stride: 1},
+ {Lo: 0x2C8B, Hi: 0x2C8B, Stride: 1},
+ {Lo: 0x2C8D, Hi: 0x2C8D, Stride: 1},
+ {Lo: 0x2C8F, Hi: 0x2C8F, Stride: 1},
+ {Lo: 0x2C91, Hi: 0x2C91, Stride: 1},
+ {Lo: 0x2C93, Hi: 0x2C93, Stride: 1},
+ {Lo: 0x2C95, Hi: 0x2C95, Stride: 1},
+ {Lo: 0x2C97, Hi: 0x2C97, Stride: 1},
+ {Lo: 0x2C99, Hi: 0x2C99, Stride: 1},
+ {Lo: 0x2C9B, Hi: 0x2C9B, Stride: 1},
+ {Lo: 0x2C9D, Hi: 0x2C9D, Stride: 1},
+ {Lo: 0x2C9F, Hi: 0x2C9F, Stride: 1},
+ {Lo: 0x2CA1, Hi: 0x2CA1, Stride: 1},
+ {Lo: 0x2CA3, Hi: 0x2CA3, Stride: 1},
+ {Lo: 0x2CA5, Hi: 0x2CA5, Stride: 1},
+ {Lo: 0x2CA7, Hi: 0x2CA7, Stride: 1},
+ {Lo: 0x2CA9, Hi: 0x2CA9, Stride: 1},
+ {Lo: 0x2CAB, Hi: 0x2CAB, Stride: 1},
+ {Lo: 0x2CAD, Hi: 0x2CAD, Stride: 1},
+ {Lo: 0x2CAF, Hi: 0x2CAF, Stride: 1},
+ {Lo: 0x2CB1, Hi: 0x2CB1, Stride: 1},
+ {Lo: 0x2CB3, Hi: 0x2CB3, Stride: 1},
+ {Lo: 0x2CB5, Hi: 0x2CB5, Stride: 1},
+ {Lo: 0x2CB7, Hi: 0x2CB7, Stride: 1},
+ {Lo: 0x2CB9, Hi: 0x2CB9, Stride: 1},
+ {Lo: 0x2CBB, Hi: 0x2CBB, Stride: 1},
+ {Lo: 0x2CBD, Hi: 0x2CBD, Stride: 1},
+ {Lo: 0x2CBF, Hi: 0x2CBF, Stride: 1},
+ {Lo: 0x2CC1, Hi: 0x2CC1, Stride: 1},
+ {Lo: 0x2CC3, Hi: 0x2CC3, Stride: 1},
+ {Lo: 0x2CC5, Hi: 0x2CC5, Stride: 1},
+ {Lo: 0x2CC7, Hi: 0x2CC7, Stride: 1},
+ {Lo: 0x2CC9, Hi: 0x2CC9, Stride: 1},
+ {Lo: 0x2CCB, Hi: 0x2CCB, Stride: 1},
+ {Lo: 0x2CCD, Hi: 0x2CCD, Stride: 1},
+ {Lo: 0x2CCF, Hi: 0x2CCF, Stride: 1},
+ {Lo: 0x2CD1, Hi: 0x2CD1, Stride: 1},
+ {Lo: 0x2CD3, Hi: 0x2CD3, Stride: 1},
+ {Lo: 0x2CD5, Hi: 0x2CD5, Stride: 1},
+ {Lo: 0x2CD7, Hi: 0x2CD7, Stride: 1},
+ {Lo: 0x2CD9, Hi: 0x2CD9, Stride: 1},
+ {Lo: 0x2CDB, Hi: 0x2CDB, Stride: 1},
+ {Lo: 0x2CDD, Hi: 0x2CDD, Stride: 1},
+ {Lo: 0x2CDF, Hi: 0x2CDF, Stride: 1},
+ {Lo: 0x2CE1, Hi: 0x2CE1, Stride: 1},
+ {Lo: 0x2CE3, Hi: 0x2CE4, Stride: 1},
+ {Lo: 0x2CEC, Hi: 0x2CEC, Stride: 1},
+ {Lo: 0x2CEE, Hi: 0x2CEE, Stride: 1},
+ {Lo: 0x2CF3, Hi: 0x2CF3, Stride: 1},
+ {Lo: 0x2D00, Hi: 0x2D25, Stride: 1},
+ {Lo: 0x2D27, Hi: 0x2D27, Stride: 1},
+ {Lo: 0x2D2D, Hi: 0x2D2D, Stride: 1},
+ {Lo: 0xA641, Hi: 0xA641, Stride: 1},
+ {Lo: 0xA643, Hi: 0xA643, Stride: 1},
+ {Lo: 0xA645, Hi: 0xA645, Stride: 1},
+ {Lo: 0xA647, Hi: 0xA647, Stride: 1},
+ {Lo: 0xA649, Hi: 0xA649, Stride: 1},
+ {Lo: 0xA64B, Hi: 0xA64B, Stride: 1},
+ {Lo: 0xA64D, Hi: 0xA64D, Stride: 1},
+ {Lo: 0xA64F, Hi: 0xA64F, Stride: 1},
+ {Lo: 0xA651, Hi: 0xA651, Stride: 1},
+ {Lo: 0xA653, Hi: 0xA653, Stride: 1},
+ {Lo: 0xA655, Hi: 0xA655, Stride: 1},
+ {Lo: 0xA657, Hi: 0xA657, Stride: 1},
+ {Lo: 0xA659, Hi: 0xA659, Stride: 1},
+ {Lo: 0xA65B, Hi: 0xA65B, Stride: 1},
+ {Lo: 0xA65D, Hi: 0xA65D, Stride: 1},
+ {Lo: 0xA65F, Hi: 0xA65F, Stride: 1},
+ {Lo: 0xA661, Hi: 0xA661, Stride: 1},
+ {Lo: 0xA663, Hi: 0xA663, Stride: 1},
+ {Lo: 0xA665, Hi: 0xA665, Stride: 1},
+ {Lo: 0xA667, Hi: 0xA667, Stride: 1},
+ {Lo: 0xA669, Hi: 0xA669, Stride: 1},
+ {Lo: 0xA66B, Hi: 0xA66B, Stride: 1},
+ {Lo: 0xA66D, Hi: 0xA66D, Stride: 1},
+ {Lo: 0xA681, Hi: 0xA681, Stride: 1},
+ {Lo: 0xA683, Hi: 0xA683, Stride: 1},
+ {Lo: 0xA685, Hi: 0xA685, Stride: 1},
+ {Lo: 0xA687, Hi: 0xA687, Stride: 1},
+ {Lo: 0xA689, Hi: 0xA689, Stride: 1},
+ {Lo: 0xA68B, Hi: 0xA68B, Stride: 1},
+ {Lo: 0xA68D, Hi: 0xA68D, Stride: 1},
+ {Lo: 0xA68F, Hi: 0xA68F, Stride: 1},
+ {Lo: 0xA691, Hi: 0xA691, Stride: 1},
+ {Lo: 0xA693, Hi: 0xA693, Stride: 1},
+ {Lo: 0xA695, Hi: 0xA695, Stride: 1},
+ {Lo: 0xA697, Hi: 0xA697, Stride: 1},
+ {Lo: 0xA699, Hi: 0xA699, Stride: 1},
+ {Lo: 0xA69B, Hi: 0xA69D, Stride: 1},
+ {Lo: 0xA723, Hi: 0xA723, Stride: 1},
+ {Lo: 0xA725, Hi: 0xA725, Stride: 1},
+ {Lo: 0xA727, Hi: 0xA727, Stride: 1},
+ {Lo: 0xA729, Hi: 0xA729, Stride: 1},
+ {Lo: 0xA72B, Hi: 0xA72B, Stride: 1},
+ {Lo: 0xA72D, Hi: 0xA72D, Stride: 1},
+ {Lo: 0xA72F, Hi: 0xA731, Stride: 1},
+ {Lo: 0xA733, Hi: 0xA733, Stride: 1},
+ {Lo: 0xA735, Hi: 0xA735, Stride: 1},
+ {Lo: 0xA737, Hi: 0xA737, Stride: 1},
+ {Lo: 0xA739, Hi: 0xA739, Stride: 1},
+ {Lo: 0xA73B, Hi: 0xA73B, Stride: 1},
+ {Lo: 0xA73D, Hi: 0xA73D, Stride: 1},
+ {Lo: 0xA73F, Hi: 0xA73F, Stride: 1},
+ {Lo: 0xA741, Hi: 0xA741, Stride: 1},
+ {Lo: 0xA743, Hi: 0xA743, Stride: 1},
+ {Lo: 0xA745, Hi: 0xA745, Stride: 1},
+ {Lo: 0xA747, Hi: 0xA747, Stride: 1},
+ {Lo: 0xA749, Hi: 0xA749, Stride: 1},
+ {Lo: 0xA74B, Hi: 0xA74B, Stride: 1},
+ {Lo: 0xA74D, Hi: 0xA74D, Stride: 1},
+ {Lo: 0xA74F, Hi: 0xA74F, Stride: 1},
+ {Lo: 0xA751, Hi: 0xA751, Stride: 1},
+ {Lo: 0xA753, Hi: 0xA753, Stride: 1},
+ {Lo: 0xA755, Hi: 0xA755, Stride: 1},
+ {Lo: 0xA757, Hi: 0xA757, Stride: 1},
+ {Lo: 0xA759, Hi: 0xA759, Stride: 1},
+ {Lo: 0xA75B, Hi: 0xA75B, Stride: 1},
+ {Lo: 0xA75D, Hi: 0xA75D, Stride: 1},
+ {Lo: 0xA75F, Hi: 0xA75F, Stride: 1},
+ {Lo: 0xA761, Hi: 0xA761, Stride: 1},
+ {Lo: 0xA763, Hi: 0xA763, Stride: 1},
+ {Lo: 0xA765, Hi: 0xA765, Stride: 1},
+ {Lo: 0xA767, Hi: 0xA767, Stride: 1},
+ {Lo: 0xA769, Hi: 0xA769, Stride: 1},
+ {Lo: 0xA76B, Hi: 0xA76B, Stride: 1},
+ {Lo: 0xA76D, Hi: 0xA76D, Stride: 1},
+ {Lo: 0xA76F, Hi: 0xA778, Stride: 1},
+ {Lo: 0xA77A, Hi: 0xA77A, Stride: 1},
+ {Lo: 0xA77C, Hi: 0xA77C, Stride: 1},
+ {Lo: 0xA77F, Hi: 0xA77F, Stride: 1},
+ {Lo: 0xA781, Hi: 0xA781, Stride: 1},
+ {Lo: 0xA783, Hi: 0xA783, Stride: 1},
+ {Lo: 0xA785, Hi: 0xA785, Stride: 1},
+ {Lo: 0xA787, Hi: 0xA787, Stride: 1},
+ {Lo: 0xA78C, Hi: 0xA78C, Stride: 1},
+ {Lo: 0xA78E, Hi: 0xA78E, Stride: 1},
+ {Lo: 0xA791, Hi: 0xA791, Stride: 1},
+ {Lo: 0xA793, Hi: 0xA795, Stride: 1},
+ {Lo: 0xA797, Hi: 0xA797, Stride: 1},
+ {Lo: 0xA799, Hi: 0xA799, Stride: 1},
+ {Lo: 0xA79B, Hi: 0xA79B, Stride: 1},
+ {Lo: 0xA79D, Hi: 0xA79D, Stride: 1},
+ {Lo: 0xA79F, Hi: 0xA79F, Stride: 1},
+ {Lo: 0xA7A1, Hi: 0xA7A1, Stride: 1},
+ {Lo: 0xA7A3, Hi: 0xA7A3, Stride: 1},
+ {Lo: 0xA7A5, Hi: 0xA7A5, Stride: 1},
+ {Lo: 0xA7A7, Hi: 0xA7A7, Stride: 1},
+ {Lo: 0xA7A9, Hi: 0xA7A9, Stride: 1},
+ {Lo: 0xA7AF, Hi: 0xA7AF, Stride: 1},
+ {Lo: 0xA7B5, Hi: 0xA7B5, Stride: 1},
+ {Lo: 0xA7B7, Hi: 0xA7B7, Stride: 1},
+ {Lo: 0xA7B9, Hi: 0xA7B9, Stride: 1},
+ {Lo: 0xA7BB, Hi: 0xA7BB, Stride: 1},
+ {Lo: 0xA7BD, Hi: 0xA7BD, Stride: 1},
+ {Lo: 0xA7BF, Hi: 0xA7BF, Stride: 1},
+ {Lo: 0xA7C1, Hi: 0xA7C1, Stride: 1},
+ {Lo: 0xA7C3, Hi: 0xA7C3, Stride: 1},
+ {Lo: 0xA7C8, Hi: 0xA7C8, Stride: 1},
+ {Lo: 0xA7CA, Hi: 0xA7CA, Stride: 1},
+ {Lo: 0xA7CD, Hi: 0xA7CD, Stride: 1},
+ {Lo: 0xA7CF, Hi: 0xA7CF, Stride: 1},
+ {Lo: 0xA7D1, Hi: 0xA7D1, Stride: 1},
+ {Lo: 0xA7D3, Hi: 0xA7D3, Stride: 1},
+ {Lo: 0xA7D5, Hi: 0xA7D5, Stride: 1},
+ {Lo: 0xA7D7, Hi: 0xA7D7, Stride: 1},
+ {Lo: 0xA7D9, Hi: 0xA7D9, Stride: 1},
+ {Lo: 0xA7DB, Hi: 0xA7DB, Stride: 1},
+ {Lo: 0xA7F1, Hi: 0xA7F4, Stride: 1},
+ {Lo: 0xA7F6, Hi: 0xA7F6, Stride: 1},
+ {Lo: 0xA7F8, Hi: 0xA7FA, Stride: 1},
+ {Lo: 0xAB30, Hi: 0xAB5A, Stride: 1},
+ {Lo: 0xAB5C, Hi: 0xAB69, Stride: 1},
+ {Lo: 0xAB70, Hi: 0xABBF, Stride: 1},
+ {Lo: 0xFB00, Hi: 0xFB06, Stride: 1},
+ {Lo: 0xFB13, Hi: 0xFB17, Stride: 1},
+ {Lo: 0xFF41, Hi: 0xFF5A, Stride: 1},
+ },
+ R32: []unicode.Range32{
+ {Lo: 0x10428, Hi: 0x1044F, Stride: 1},
+ {Lo: 0x104D8, Hi: 0x104FB, Stride: 1},
+ {Lo: 0x10597, Hi: 0x105A1, Stride: 1},
+ {Lo: 0x105A3, Hi: 0x105B1, Stride: 1},
+ {Lo: 0x105B3, Hi: 0x105B9, Stride: 1},
+ {Lo: 0x105BB, Hi: 0x105BC, Stride: 1},
+ {Lo: 0x10780, Hi: 0x10780, Stride: 1},
+ {Lo: 0x10783, Hi: 0x10785, Stride: 1},
+ {Lo: 0x10787, Hi: 0x107B0, Stride: 1},
+ {Lo: 0x107B2, Hi: 0x107BA, Stride: 1},
+ {Lo: 0x10CC0, Hi: 0x10CF2, Stride: 1},
+ {Lo: 0x10D70, Hi: 0x10D85, Stride: 1},
+ {Lo: 0x118C0, Hi: 0x118DF, Stride: 1},
+ {Lo: 0x16E60, Hi: 0x16E7F, Stride: 1},
+ {Lo: 0x16EBB, Hi: 0x16ED3, Stride: 1},
+ {Lo: 0x1D41A, Hi: 0x1D433, Stride: 1},
+ {Lo: 0x1D44E, Hi: 0x1D454, Stride: 1},
+ {Lo: 0x1D456, Hi: 0x1D467, Stride: 1},
+ {Lo: 0x1D482, Hi: 0x1D49B, Stride: 1},
+ {Lo: 0x1D4B6, Hi: 0x1D4B9, Stride: 1},
+ {Lo: 0x1D4BB, Hi: 0x1D4BB, Stride: 1},
+ {Lo: 0x1D4BD, Hi: 0x1D4C3, Stride: 1},
+ {Lo: 0x1D4C5, Hi: 0x1D4CF, Stride: 1},
+ {Lo: 0x1D4EA, Hi: 0x1D503, Stride: 1},
+ {Lo: 0x1D51E, Hi: 0x1D537, Stride: 1},
+ {Lo: 0x1D552, Hi: 0x1D56B, Stride: 1},
+ {Lo: 0x1D586, Hi: 0x1D59F, Stride: 1},
+ {Lo: 0x1D5BA, Hi: 0x1D5D3, Stride: 1},
+ {Lo: 0x1D5EE, Hi: 0x1D607, Stride: 1},
+ {Lo: 0x1D622, Hi: 0x1D63B, Stride: 1},
+ {Lo: 0x1D656, Hi: 0x1D66F, Stride: 1},
+ {Lo: 0x1D68A, Hi: 0x1D6A5, Stride: 1},
+ {Lo: 0x1D6C2, Hi: 0x1D6DA, Stride: 1},
+ {Lo: 0x1D6DC, Hi: 0x1D6E1, Stride: 1},
+ {Lo: 0x1D6FC, Hi: 0x1D714, Stride: 1},
+ {Lo: 0x1D716, Hi: 0x1D71B, Stride: 1},
+ {Lo: 0x1D736, Hi: 0x1D74E, Stride: 1},
+ {Lo: 0x1D750, Hi: 0x1D755, Stride: 1},
+ {Lo: 0x1D770, Hi: 0x1D788, Stride: 1},
+ {Lo: 0x1D78A, Hi: 0x1D78F, Stride: 1},
+ {Lo: 0x1D7AA, Hi: 0x1D7C2, Stride: 1},
+ {Lo: 0x1D7C4, Hi: 0x1D7C9, Stride: 1},
+ {Lo: 0x1D7CB, Hi: 0x1D7CB, Stride: 1},
+ {Lo: 0x1DF00, Hi: 0x1DF09, Stride: 1},
+ {Lo: 0x1DF0B, Hi: 0x1DF1E, Stride: 1},
+ {Lo: 0x1DF25, Hi: 0x1DF2A, Stride: 1},
+ {Lo: 0x1E030, Hi: 0x1E06D, Stride: 1},
+ {Lo: 0x1E922, Hi: 0x1E943, Stride: 1},
+ },
+}
+
+var unicodeAliasSentence_Break_Numeric = &unicode.RangeTable{
+ R16: []unicode.Range16{
+ {Lo: 0x30, Hi: 0x39, Stride: 1},
+ {Lo: 0x600, Hi: 0x605, Stride: 1},
+ {Lo: 0x660, Hi: 0x669, Stride: 1},
+ {Lo: 0x66B, Hi: 0x66C, Stride: 1},
+ {Lo: 0x6DD, Hi: 0x6DD, Stride: 1},
+ {Lo: 0x6F0, Hi: 0x6F9, Stride: 1},
+ {Lo: 0x7C0, Hi: 0x7C9, Stride: 1},
+ {Lo: 0x890, Hi: 0x891, Stride: 1},
+ {Lo: 0x8E2, Hi: 0x8E2, Stride: 1},
+ {Lo: 0x966, Hi: 0x96F, Stride: 1},
+ {Lo: 0x9E6, Hi: 0x9EF, Stride: 1},
+ {Lo: 0xA66, Hi: 0xA6F, Stride: 1},
+ {Lo: 0xAE6, Hi: 0xAEF, Stride: 1},
+ {Lo: 0xB66, Hi: 0xB6F, Stride: 1},
+ {Lo: 0xBE6, Hi: 0xBEF, Stride: 1},
+ {Lo: 0xC66, Hi: 0xC6F, Stride: 1},
+ {Lo: 0xCE6, Hi: 0xCEF, Stride: 1},
+ {Lo: 0xD66, Hi: 0xD6F, Stride: 1},
+ {Lo: 0xDE6, Hi: 0xDEF, Stride: 1},
+ {Lo: 0xE50, Hi: 0xE59, Stride: 1},
+ {Lo: 0xED0, Hi: 0xED9, Stride: 1},
+ {Lo: 0xF20, Hi: 0xF29, Stride: 1},
+ {Lo: 0x1040, Hi: 0x1049, Stride: 1},
+ {Lo: 0x1090, Hi: 0x1099, Stride: 1},
+ {Lo: 0x17E0, Hi: 0x17E9, Stride: 1},
+ {Lo: 0x1810, Hi: 0x1819, Stride: 1},
+ {Lo: 0x1946, Hi: 0x194F, Stride: 1},
+ {Lo: 0x19D0, Hi: 0x19DA, Stride: 1},
+ {Lo: 0x1A80, Hi: 0x1A89, Stride: 1},
+ {Lo: 0x1A90, Hi: 0x1A99, Stride: 1},
+ {Lo: 0x1B50, Hi: 0x1B59, Stride: 1},
+ {Lo: 0x1BB0, Hi: 0x1BB9, Stride: 1},
+ {Lo: 0x1C40, Hi: 0x1C49, Stride: 1},
+ {Lo: 0x1C50, Hi: 0x1C59, Stride: 1},
+ {Lo: 0xA620, Hi: 0xA629, Stride: 1},
+ {Lo: 0xA8D0, Hi: 0xA8D9, Stride: 1},
+ {Lo: 0xA900, Hi: 0xA909, Stride: 1},
+ {Lo: 0xA9D0, Hi: 0xA9D9, Stride: 1},
+ {Lo: 0xA9F0, Hi: 0xA9F9, Stride: 1},
+ {Lo: 0xAA50, Hi: 0xAA59, Stride: 1},
+ {Lo: 0xABF0, Hi: 0xABF9, Stride: 1},
+ {Lo: 0xFF10, Hi: 0xFF19, Stride: 1},
+ },
+ R32: []unicode.Range32{
+ {Lo: 0x104A0, Hi: 0x104A9, Stride: 1},
+ {Lo: 0x10D30, Hi: 0x10D39, Stride: 1},
+ {Lo: 0x10D40, Hi: 0x10D49, Stride: 1},
+ {Lo: 0x11066, Hi: 0x1106F, Stride: 1},
+ {Lo: 0x110BD, Hi: 0x110BD, Stride: 1},
+ {Lo: 0x110CD, Hi: 0x110CD, Stride: 1},
+ {Lo: 0x110F0, Hi: 0x110F9, Stride: 1},
+ {Lo: 0x11136, Hi: 0x1113F, Stride: 1},
+ {Lo: 0x111D0, Hi: 0x111D9, Stride: 1},
+ {Lo: 0x112F0, Hi: 0x112F9, Stride: 1},
+ {Lo: 0x11450, Hi: 0x11459, Stride: 1},
+ {Lo: 0x114D0, Hi: 0x114D9, Stride: 1},
+ {Lo: 0x11650, Hi: 0x11659, Stride: 1},
+ {Lo: 0x116C0, Hi: 0x116C9, Stride: 1},
+ {Lo: 0x116D0, Hi: 0x116E3, Stride: 1},
+ {Lo: 0x11730, Hi: 0x11739, Stride: 1},
+ {Lo: 0x118E0, Hi: 0x118E9, Stride: 1},
+ {Lo: 0x11950, Hi: 0x11959, Stride: 1},
+ {Lo: 0x11BF0, Hi: 0x11BF9, Stride: 1},
+ {Lo: 0x11C50, Hi: 0x11C59, Stride: 1},
+ {Lo: 0x11D50, Hi: 0x11D59, Stride: 1},
+ {Lo: 0x11DA0, Hi: 0x11DA9, Stride: 1},
+ {Lo: 0x11DE0, Hi: 0x11DE9, Stride: 1},
+ {Lo: 0x11F50, Hi: 0x11F59, Stride: 1},
+ {Lo: 0x16130, Hi: 0x16139, Stride: 1},
+ {Lo: 0x16A60, Hi: 0x16A69, Stride: 1},
+ {Lo: 0x16AC0, Hi: 0x16AC9, Stride: 1},
+ {Lo: 0x16B50, Hi: 0x16B59, Stride: 1},
+ {Lo: 0x16D70, Hi: 0x16D79, Stride: 1},
+ {Lo: 0x1CCF0, Hi: 0x1CCF9, Stride: 1},
+ {Lo: 0x1D7CE, Hi: 0x1D7FF, Stride: 1},
+ {Lo: 0x1E140, Hi: 0x1E149, Stride: 1},
+ {Lo: 0x1E2F0, Hi: 0x1E2F9, Stride: 1},
+ {Lo: 0x1E4F0, Hi: 0x1E4F9, Stride: 1},
+ {Lo: 0x1E5F1, Hi: 0x1E5FA, Stride: 1},
+ {Lo: 0x1E950, Hi: 0x1E959, Stride: 1},
+ {Lo: 0x1FBF0, Hi: 0x1FBF9, Stride: 1},
+ },
+}
+
+var unicodeAliasSentence_Break_OLetter = &unicode.RangeTable{
+ R16: []unicode.Range16{
+ {Lo: 0x1BB, Hi: 0x1BB, Stride: 1},
+ {Lo: 0x1C0, Hi: 0x1C3, Stride: 1},
+ {Lo: 0x294, Hi: 0x295, Stride: 1},
+ {Lo: 0x2B9, Hi: 0x2BF, Stride: 1},
+ {Lo: 0x2C6, Hi: 0x2D1, Stride: 1},
+ {Lo: 0x2EC, Hi: 0x2EC, Stride: 1},
+ {Lo: 0x2EE, Hi: 0x2EE, Stride: 1},
+ {Lo: 0x374, Hi: 0x374, Stride: 1},
+ {Lo: 0x559, Hi: 0x559, Stride: 1},
+ {Lo: 0x5D0, Hi: 0x5EA, Stride: 1},
+ {Lo: 0x5EF, Hi: 0x5F3, Stride: 1},
+ {Lo: 0x620, Hi: 0x64A, Stride: 1},
+ {Lo: 0x66E, Hi: 0x66F, Stride: 1},
+ {Lo: 0x671, Hi: 0x6D3, Stride: 1},
+ {Lo: 0x6D5, Hi: 0x6D5, Stride: 1},
+ {Lo: 0x6E5, Hi: 0x6E6, Stride: 1},
+ {Lo: 0x6EE, Hi: 0x6EF, Stride: 1},
+ {Lo: 0x6FA, Hi: 0x6FC, Stride: 1},
+ {Lo: 0x6FF, Hi: 0x6FF, Stride: 1},
+ {Lo: 0x710, Hi: 0x710, Stride: 1},
+ {Lo: 0x712, Hi: 0x72F, Stride: 1},
+ {Lo: 0x74D, Hi: 0x7A5, Stride: 1},
+ {Lo: 0x7B1, Hi: 0x7B1, Stride: 1},
+ {Lo: 0x7CA, Hi: 0x7EA, Stride: 1},
+ {Lo: 0x7F4, Hi: 0x7F5, Stride: 1},
+ {Lo: 0x7FA, Hi: 0x7FA, Stride: 1},
+ {Lo: 0x800, Hi: 0x815, Stride: 1},
+ {Lo: 0x81A, Hi: 0x81A, Stride: 1},
+ {Lo: 0x824, Hi: 0x824, Stride: 1},
+ {Lo: 0x828, Hi: 0x828, Stride: 1},
+ {Lo: 0x840, Hi: 0x858, Stride: 1},
+ {Lo: 0x860, Hi: 0x86A, Stride: 1},
+ {Lo: 0x870, Hi: 0x887, Stride: 1},
+ {Lo: 0x889, Hi: 0x88F, Stride: 1},
+ {Lo: 0x8A0, Hi: 0x8C9, Stride: 1},
+ {Lo: 0x904, Hi: 0x939, Stride: 1},
+ {Lo: 0x93D, Hi: 0x93D, Stride: 1},
+ {Lo: 0x950, Hi: 0x950, Stride: 1},
+ {Lo: 0x958, Hi: 0x961, Stride: 1},
+ {Lo: 0x971, Hi: 0x980, Stride: 1},
+ {Lo: 0x985, Hi: 0x98C, Stride: 1},
+ {Lo: 0x98F, Hi: 0x990, Stride: 1},
+ {Lo: 0x993, Hi: 0x9A8, Stride: 1},
+ {Lo: 0x9AA, Hi: 0x9B0, Stride: 1},
+ {Lo: 0x9B2, Hi: 0x9B2, Stride: 1},
+ {Lo: 0x9B6, Hi: 0x9B9, Stride: 1},
+ {Lo: 0x9BD, Hi: 0x9BD, Stride: 1},
+ {Lo: 0x9CE, Hi: 0x9CE, Stride: 1},
+ {Lo: 0x9DC, Hi: 0x9DD, Stride: 1},
+ {Lo: 0x9DF, Hi: 0x9E1, Stride: 1},
+ {Lo: 0x9F0, Hi: 0x9F1, Stride: 1},
+ {Lo: 0x9FC, Hi: 0x9FC, Stride: 1},
+ {Lo: 0xA05, Hi: 0xA0A, Stride: 1},
+ {Lo: 0xA0F, Hi: 0xA10, Stride: 1},
+ {Lo: 0xA13, Hi: 0xA28, Stride: 1},
+ {Lo: 0xA2A, Hi: 0xA30, Stride: 1},
+ {Lo: 0xA32, Hi: 0xA33, Stride: 1},
+ {Lo: 0xA35, Hi: 0xA36, Stride: 1},
+ {Lo: 0xA38, Hi: 0xA39, Stride: 1},
+ {Lo: 0xA59, Hi: 0xA5C, Stride: 1},
+ {Lo: 0xA5E, Hi: 0xA5E, Stride: 1},
+ {Lo: 0xA72, Hi: 0xA74, Stride: 1},
+ {Lo: 0xA85, Hi: 0xA8D, Stride: 1},
+ {Lo: 0xA8F, Hi: 0xA91, Stride: 1},
+ {Lo: 0xA93, Hi: 0xAA8, Stride: 1},
+ {Lo: 0xAAA, Hi: 0xAB0, Stride: 1},
+ {Lo: 0xAB2, Hi: 0xAB3, Stride: 1},
+ {Lo: 0xAB5, Hi: 0xAB9, Stride: 1},
+ {Lo: 0xABD, Hi: 0xABD, Stride: 1},
+ {Lo: 0xAD0, Hi: 0xAD0, Stride: 1},
+ {Lo: 0xAE0, Hi: 0xAE1, Stride: 1},
+ {Lo: 0xAF9, Hi: 0xAF9, Stride: 1},
+ {Lo: 0xB05, Hi: 0xB0C, Stride: 1},
+ {Lo: 0xB0F, Hi: 0xB10, Stride: 1},
+ {Lo: 0xB13, Hi: 0xB28, Stride: 1},
+ {Lo: 0xB2A, Hi: 0xB30, Stride: 1},
+ {Lo: 0xB32, Hi: 0xB33, Stride: 1},
+ {Lo: 0xB35, Hi: 0xB39, Stride: 1},
+ {Lo: 0xB3D, Hi: 0xB3D, Stride: 1},
+ {Lo: 0xB5C, Hi: 0xB5D, Stride: 1},
+ {Lo: 0xB5F, Hi: 0xB61, Stride: 1},
+ {Lo: 0xB71, Hi: 0xB71, Stride: 1},
+ {Lo: 0xB83, Hi: 0xB83, Stride: 1},
+ {Lo: 0xB85, Hi: 0xB8A, Stride: 1},
+ {Lo: 0xB8E, Hi: 0xB90, Stride: 1},
+ {Lo: 0xB92, Hi: 0xB95, Stride: 1},
+ {Lo: 0xB99, Hi: 0xB9A, Stride: 1},
+ {Lo: 0xB9C, Hi: 0xB9C, Stride: 1},
+ {Lo: 0xB9E, Hi: 0xB9F, Stride: 1},
+ {Lo: 0xBA3, Hi: 0xBA4, Stride: 1},
+ {Lo: 0xBA8, Hi: 0xBAA, Stride: 1},
+ {Lo: 0xBAE, Hi: 0xBB9, Stride: 1},
+ {Lo: 0xBD0, Hi: 0xBD0, Stride: 1},
+ {Lo: 0xC05, Hi: 0xC0C, Stride: 1},
+ {Lo: 0xC0E, Hi: 0xC10, Stride: 1},
+ {Lo: 0xC12, Hi: 0xC28, Stride: 1},
+ {Lo: 0xC2A, Hi: 0xC39, Stride: 1},
+ {Lo: 0xC3D, Hi: 0xC3D, Stride: 1},
+ {Lo: 0xC58, Hi: 0xC5A, Stride: 1},
+ {Lo: 0xC5C, Hi: 0xC5D, Stride: 1},
+ {Lo: 0xC60, Hi: 0xC61, Stride: 1},
+ {Lo: 0xC80, Hi: 0xC80, Stride: 1},
+ {Lo: 0xC85, Hi: 0xC8C, Stride: 1},
+ {Lo: 0xC8E, Hi: 0xC90, Stride: 1},
+ {Lo: 0xC92, Hi: 0xCA8, Stride: 1},
+ {Lo: 0xCAA, Hi: 0xCB3, Stride: 1},
+ {Lo: 0xCB5, Hi: 0xCB9, Stride: 1},
+ {Lo: 0xCBD, Hi: 0xCBD, Stride: 1},
+ {Lo: 0xCDC, Hi: 0xCDE, Stride: 1},
+ {Lo: 0xCE0, Hi: 0xCE1, Stride: 1},
+ {Lo: 0xCF1, Hi: 0xCF2, Stride: 1},
+ {Lo: 0xD04, Hi: 0xD0C, Stride: 1},
+ {Lo: 0xD0E, Hi: 0xD10, Stride: 1},
+ {Lo: 0xD12, Hi: 0xD3A, Stride: 1},
+ {Lo: 0xD3D, Hi: 0xD3D, Stride: 1},
+ {Lo: 0xD4E, Hi: 0xD4E, Stride: 1},
+ {Lo: 0xD54, Hi: 0xD56, Stride: 1},
+ {Lo: 0xD5F, Hi: 0xD61, Stride: 1},
+ {Lo: 0xD7A, Hi: 0xD7F, Stride: 1},
+ {Lo: 0xD85, Hi: 0xD96, Stride: 1},
+ {Lo: 0xD9A, Hi: 0xDB1, Stride: 1},
+ {Lo: 0xDB3, Hi: 0xDBB, Stride: 1},
+ {Lo: 0xDBD, Hi: 0xDBD, Stride: 1},
+ {Lo: 0xDC0, Hi: 0xDC6, Stride: 1},
+ {Lo: 0xE01, Hi: 0xE30, Stride: 1},
+ {Lo: 0xE32, Hi: 0xE33, Stride: 1},
+ {Lo: 0xE40, Hi: 0xE46, Stride: 1},
+ {Lo: 0xE81, Hi: 0xE82, Stride: 1},
+ {Lo: 0xE84, Hi: 0xE84, Stride: 1},
+ {Lo: 0xE86, Hi: 0xE8A, Stride: 1},
+ {Lo: 0xE8C, Hi: 0xEA3, Stride: 1},
+ {Lo: 0xEA5, Hi: 0xEA5, Stride: 1},
+ {Lo: 0xEA7, Hi: 0xEB0, Stride: 1},
+ {Lo: 0xEB2, Hi: 0xEB3, Stride: 1},
+ {Lo: 0xEBD, Hi: 0xEBD, Stride: 1},
+ {Lo: 0xEC0, Hi: 0xEC4, Stride: 1},
+ {Lo: 0xEC6, Hi: 0xEC6, Stride: 1},
+ {Lo: 0xEDC, Hi: 0xEDF, Stride: 1},
+ {Lo: 0xF00, Hi: 0xF00, Stride: 1},
+ {Lo: 0xF40, Hi: 0xF47, Stride: 1},
+ {Lo: 0xF49, Hi: 0xF6C, Stride: 1},
+ {Lo: 0xF88, Hi: 0xF8C, Stride: 1},
+ {Lo: 0x1000, Hi: 0x102A, Stride: 1},
+ {Lo: 0x103F, Hi: 0x103F, Stride: 1},
+ {Lo: 0x1050, Hi: 0x1055, Stride: 1},
+ {Lo: 0x105A, Hi: 0x105D, Stride: 1},
+ {Lo: 0x1061, Hi: 0x1061, Stride: 1},
+ {Lo: 0x1065, Hi: 0x1066, Stride: 1},
+ {Lo: 0x106E, Hi: 0x1070, Stride: 1},
+ {Lo: 0x1075, Hi: 0x1081, Stride: 1},
+ {Lo: 0x108E, Hi: 0x108E, Stride: 1},
+ {Lo: 0x10D0, Hi: 0x10FA, Stride: 1},
+ {Lo: 0x10FD, Hi: 0x1248, Stride: 1},
+ {Lo: 0x124A, Hi: 0x124D, Stride: 1},
+ {Lo: 0x1250, Hi: 0x1256, Stride: 1},
+ {Lo: 0x1258, Hi: 0x1258, Stride: 1},
+ {Lo: 0x125A, Hi: 0x125D, Stride: 1},
+ {Lo: 0x1260, Hi: 0x1288, Stride: 1},
+ {Lo: 0x128A, Hi: 0x128D, Stride: 1},
+ {Lo: 0x1290, Hi: 0x12B0, Stride: 1},
+ {Lo: 0x12B2, Hi: 0x12B5, Stride: 1},
+ {Lo: 0x12B8, Hi: 0x12BE, Stride: 1},
+ {Lo: 0x12C0, Hi: 0x12C0, Stride: 1},
+ {Lo: 0x12C2, Hi: 0x12C5, Stride: 1},
+ {Lo: 0x12C8, Hi: 0x12D6, Stride: 1},
+ {Lo: 0x12D8, Hi: 0x1310, Stride: 1},
+ {Lo: 0x1312, Hi: 0x1315, Stride: 1},
+ {Lo: 0x1318, Hi: 0x135A, Stride: 1},
+ {Lo: 0x1380, Hi: 0x138F, Stride: 1},
+ {Lo: 0x1401, Hi: 0x166C, Stride: 1},
+ {Lo: 0x166F, Hi: 0x167F, Stride: 1},
+ {Lo: 0x1681, Hi: 0x169A, Stride: 1},
+ {Lo: 0x16A0, Hi: 0x16EA, Stride: 1},
+ {Lo: 0x16EE, Hi: 0x16F8, Stride: 1},
+ {Lo: 0x1700, Hi: 0x1711, Stride: 1},
+ {Lo: 0x171F, Hi: 0x1731, Stride: 1},
+ {Lo: 0x1740, Hi: 0x1751, Stride: 1},
+ {Lo: 0x1760, Hi: 0x176C, Stride: 1},
+ {Lo: 0x176E, Hi: 0x1770, Stride: 1},
+ {Lo: 0x1780, Hi: 0x17B3, Stride: 1},
+ {Lo: 0x17D7, Hi: 0x17D7, Stride: 1},
+ {Lo: 0x17DC, Hi: 0x17DC, Stride: 1},
+ {Lo: 0x1820, Hi: 0x1878, Stride: 1},
+ {Lo: 0x1880, Hi: 0x1884, Stride: 1},
+ {Lo: 0x1887, Hi: 0x18A8, Stride: 1},
+ {Lo: 0x18AA, Hi: 0x18AA, Stride: 1},
+ {Lo: 0x18B0, Hi: 0x18F5, Stride: 1},
+ {Lo: 0x1900, Hi: 0x191E, Stride: 1},
+ {Lo: 0x1950, Hi: 0x196D, Stride: 1},
+ {Lo: 0x1970, Hi: 0x1974, Stride: 1},
+ {Lo: 0x1980, Hi: 0x19AB, Stride: 1},
+ {Lo: 0x19B0, Hi: 0x19C9, Stride: 1},
+ {Lo: 0x1A00, Hi: 0x1A16, Stride: 1},
+ {Lo: 0x1A20, Hi: 0x1A54, Stride: 1},
+ {Lo: 0x1AA7, Hi: 0x1AA7, Stride: 1},
+ {Lo: 0x1B05, Hi: 0x1B33, Stride: 1},
+ {Lo: 0x1B45, Hi: 0x1B4C, Stride: 1},
+ {Lo: 0x1B83, Hi: 0x1BA0, Stride: 1},
+ {Lo: 0x1BAE, Hi: 0x1BAF, Stride: 1},
+ {Lo: 0x1BBA, Hi: 0x1BE5, Stride: 1},
+ {Lo: 0x1C00, Hi: 0x1C23, Stride: 1},
+ {Lo: 0x1C4D, Hi: 0x1C4F, Stride: 1},
+ {Lo: 0x1C5A, Hi: 0x1C7D, Stride: 1},
+ {Lo: 0x1C90, Hi: 0x1CBA, Stride: 1},
+ {Lo: 0x1CBD, Hi: 0x1CBF, Stride: 1},
+ {Lo: 0x1CE9, Hi: 0x1CEC, Stride: 1},
+ {Lo: 0x1CEE, Hi: 0x1CF3, Stride: 1},
+ {Lo: 0x1CF5, Hi: 0x1CF6, Stride: 1},
+ {Lo: 0x1CFA, Hi: 0x1CFA, Stride: 1},
+ {Lo: 0x2135, Hi: 0x2138, Stride: 1},
+ {Lo: 0x2180, Hi: 0x2182, Stride: 1},
+ {Lo: 0x2185, Hi: 0x2188, Stride: 1},
+ {Lo: 0x2D30, Hi: 0x2D67, Stride: 1},
+ {Lo: 0x2D6F, Hi: 0x2D6F, Stride: 1},
+ {Lo: 0x2D80, Hi: 0x2D96, Stride: 1},
+ {Lo: 0x2DA0, Hi: 0x2DA6, Stride: 1},
+ {Lo: 0x2DA8, Hi: 0x2DAE, Stride: 1},
+ {Lo: 0x2DB0, Hi: 0x2DB6, Stride: 1},
+ {Lo: 0x2DB8, Hi: 0x2DBE, Stride: 1},
+ {Lo: 0x2DC0, Hi: 0x2DC6, Stride: 1},
+ {Lo: 0x2DC8, Hi: 0x2DCE, Stride: 1},
+ {Lo: 0x2DD0, Hi: 0x2DD6, Stride: 1},
+ {Lo: 0x2DD8, Hi: 0x2DDE, Stride: 1},
+ {Lo: 0x2E2F, Hi: 0x2E2F, Stride: 1},
+ {Lo: 0x3005, Hi: 0x3007, Stride: 1},
+ {Lo: 0x3021, Hi: 0x3029, Stride: 1},
+ {Lo: 0x3031, Hi: 0x3035, Stride: 1},
+ {Lo: 0x3038, Hi: 0x303C, Stride: 1},
+ {Lo: 0x3041, Hi: 0x3096, Stride: 1},
+ {Lo: 0x309D, Hi: 0x309F, Stride: 1},
+ {Lo: 0x30A1, Hi: 0x30FA, Stride: 1},
+ {Lo: 0x30FC, Hi: 0x30FF, Stride: 1},
+ {Lo: 0x3105, Hi: 0x312F, Stride: 1},
+ {Lo: 0x3131, Hi: 0x318E, Stride: 1},
+ {Lo: 0x31A0, Hi: 0x31BF, Stride: 1},
+ {Lo: 0x31F0, Hi: 0x31FF, Stride: 1},
+ {Lo: 0x3400, Hi: 0x4DBF, Stride: 1},
+ {Lo: 0x4E00, Hi: 0xA48C, Stride: 1},
+ {Lo: 0xA4D0, Hi: 0xA4FD, Stride: 1},
+ {Lo: 0xA500, Hi: 0xA60C, Stride: 1},
+ {Lo: 0xA610, Hi: 0xA61F, Stride: 1},
+ {Lo: 0xA62A, Hi: 0xA62B, Stride: 1},
+ {Lo: 0xA66E, Hi: 0xA66E, Stride: 1},
+ {Lo: 0xA67F, Hi: 0xA67F, Stride: 1},
+ {Lo: 0xA6A0, Hi: 0xA6EF, Stride: 1},
+ {Lo: 0xA717, Hi: 0xA71F, Stride: 1},
+ {Lo: 0xA788, Hi: 0xA788, Stride: 1},
+ {Lo: 0xA78F, Hi: 0xA78F, Stride: 1},
+ {Lo: 0xA7F7, Hi: 0xA7F7, Stride: 1},
+ {Lo: 0xA7FB, Hi: 0xA801, Stride: 1},
+ {Lo: 0xA803, Hi: 0xA805, Stride: 1},
+ {Lo: 0xA807, Hi: 0xA80A, Stride: 1},
+ {Lo: 0xA80C, Hi: 0xA822, Stride: 1},
+ {Lo: 0xA840, Hi: 0xA873, Stride: 1},
+ {Lo: 0xA882, Hi: 0xA8B3, Stride: 1},
+ {Lo: 0xA8F2, Hi: 0xA8F7, Stride: 1},
+ {Lo: 0xA8FB, Hi: 0xA8FB, Stride: 1},
+ {Lo: 0xA8FD, Hi: 0xA8FE, Stride: 1},
+ {Lo: 0xA90A, Hi: 0xA925, Stride: 1},
+ {Lo: 0xA930, Hi: 0xA946, Stride: 1},
+ {Lo: 0xA960, Hi: 0xA97C, Stride: 1},
+ {Lo: 0xA984, Hi: 0xA9B2, Stride: 1},
+ {Lo: 0xA9CF, Hi: 0xA9CF, Stride: 1},
+ {Lo: 0xA9E0, Hi: 0xA9E4, Stride: 1},
+ {Lo: 0xA9E6, Hi: 0xA9EF, Stride: 1},
+ {Lo: 0xA9FA, Hi: 0xA9FE, Stride: 1},
+ {Lo: 0xAA00, Hi: 0xAA28, Stride: 1},
+ {Lo: 0xAA40, Hi: 0xAA42, Stride: 1},
+ {Lo: 0xAA44, Hi: 0xAA4B, Stride: 1},
+ {Lo: 0xAA60, Hi: 0xAA76, Stride: 1},
+ {Lo: 0xAA7A, Hi: 0xAA7A, Stride: 1},
+ {Lo: 0xAA7E, Hi: 0xAAAF, Stride: 1},
+ {Lo: 0xAAB1, Hi: 0xAAB1, Stride: 1},
+ {Lo: 0xAAB5, Hi: 0xAAB6, Stride: 1},
+ {Lo: 0xAAB9, Hi: 0xAABD, Stride: 1},
+ {Lo: 0xAAC0, Hi: 0xAAC0, Stride: 1},
+ {Lo: 0xAAC2, Hi: 0xAAC2, Stride: 1},
+ {Lo: 0xAADB, Hi: 0xAADD, Stride: 1},
+ {Lo: 0xAAE0, Hi: 0xAAEA, Stride: 1},
+ {Lo: 0xAAF2, Hi: 0xAAF4, Stride: 1},
+ {Lo: 0xAB01, Hi: 0xAB06, Stride: 1},
+ {Lo: 0xAB09, Hi: 0xAB0E, Stride: 1},
+ {Lo: 0xAB11, Hi: 0xAB16, Stride: 1},
+ {Lo: 0xAB20, Hi: 0xAB26, Stride: 1},
+ {Lo: 0xAB28, Hi: 0xAB2E, Stride: 1},
+ {Lo: 0xABC0, Hi: 0xABE2, Stride: 1},
+ {Lo: 0xAC00, Hi: 0xD7A3, Stride: 1},
+ {Lo: 0xD7B0, Hi: 0xD7C6, Stride: 1},
+ {Lo: 0xD7CB, Hi: 0xD7FB, Stride: 1},
+ {Lo: 0xF900, Hi: 0xFA6D, Stride: 1},
+ {Lo: 0xFA70, Hi: 0xFAD9, Stride: 1},
+ {Lo: 0xFB1D, Hi: 0xFB1D, Stride: 1},
+ {Lo: 0xFB1F, Hi: 0xFB28, Stride: 1},
+ {Lo: 0xFB2A, Hi: 0xFB36, Stride: 1},
+ {Lo: 0xFB38, Hi: 0xFB3C, Stride: 1},
+ {Lo: 0xFB3E, Hi: 0xFB3E, Stride: 1},
+ {Lo: 0xFB40, Hi: 0xFB41, Stride: 1},
+ {Lo: 0xFB43, Hi: 0xFB44, Stride: 1},
+ {Lo: 0xFB46, Hi: 0xFBB1, Stride: 1},
+ {Lo: 0xFBD3, Hi: 0xFD3D, Stride: 1},
+ {Lo: 0xFD50, Hi: 0xFD8F, Stride: 1},
+ {Lo: 0xFD92, Hi: 0xFDC7, Stride: 1},
+ {Lo: 0xFDF0, Hi: 0xFDFB, Stride: 1},
+ {Lo: 0xFE70, Hi: 0xFE74, Stride: 1},
+ {Lo: 0xFE76, Hi: 0xFEFC, Stride: 1},
+ {Lo: 0xFF66, Hi: 0xFF9D, Stride: 1},
+ {Lo: 0xFFA0, Hi: 0xFFBE, Stride: 1},
+ {Lo: 0xFFC2, Hi: 0xFFC7, Stride: 1},
+ {Lo: 0xFFCA, Hi: 0xFFCF, Stride: 1},
+ {Lo: 0xFFD2, Hi: 0xFFD7, Stride: 1},
+ {Lo: 0xFFDA, Hi: 0xFFDC, Stride: 1},
+ },
+ R32: []unicode.Range32{
+ {Lo: 0x10000, Hi: 0x1000B, Stride: 1},
+ {Lo: 0x1000D, Hi: 0x10026, Stride: 1},
+ {Lo: 0x10028, Hi: 0x1003A, Stride: 1},
+ {Lo: 0x1003C, Hi: 0x1003D, Stride: 1},
+ {Lo: 0x1003F, Hi: 0x1004D, Stride: 1},
+ {Lo: 0x10050, Hi: 0x1005D, Stride: 1},
+ {Lo: 0x10080, Hi: 0x100FA, Stride: 1},
+ {Lo: 0x10140, Hi: 0x10174, Stride: 1},
+ {Lo: 0x10280, Hi: 0x1029C, Stride: 1},
+ {Lo: 0x102A0, Hi: 0x102D0, Stride: 1},
+ {Lo: 0x10300, Hi: 0x1031F, Stride: 1},
+ {Lo: 0x1032D, Hi: 0x1034A, Stride: 1},
+ {Lo: 0x10350, Hi: 0x10375, Stride: 1},
+ {Lo: 0x10380, Hi: 0x1039D, Stride: 1},
+ {Lo: 0x103A0, Hi: 0x103C3, Stride: 1},
+ {Lo: 0x103C8, Hi: 0x103CF, Stride: 1},
+ {Lo: 0x103D1, Hi: 0x103D5, Stride: 1},
+ {Lo: 0x10450, Hi: 0x1049D, Stride: 1},
+ {Lo: 0x10500, Hi: 0x10527, Stride: 1},
+ {Lo: 0x10530, Hi: 0x10563, Stride: 1},
+ {Lo: 0x105C0, Hi: 0x105F3, Stride: 1},
+ {Lo: 0x10600, Hi: 0x10736, Stride: 1},
+ {Lo: 0x10740, Hi: 0x10755, Stride: 1},
+ {Lo: 0x10760, Hi: 0x10767, Stride: 1},
+ {Lo: 0x10781, Hi: 0x10782, Stride: 1},
+ {Lo: 0x10800, Hi: 0x10805, Stride: 1},
+ {Lo: 0x10808, Hi: 0x10808, Stride: 1},
+ {Lo: 0x1080A, Hi: 0x10835, Stride: 1},
+ {Lo: 0x10837, Hi: 0x10838, Stride: 1},
+ {Lo: 0x1083C, Hi: 0x1083C, Stride: 1},
+ {Lo: 0x1083F, Hi: 0x10855, Stride: 1},
+ {Lo: 0x10860, Hi: 0x10876, Stride: 1},
+ {Lo: 0x10880, Hi: 0x1089E, Stride: 1},
+ {Lo: 0x108E0, Hi: 0x108F2, Stride: 1},
+ {Lo: 0x108F4, Hi: 0x108F5, Stride: 1},
+ {Lo: 0x10900, Hi: 0x10915, Stride: 1},
+ {Lo: 0x10920, Hi: 0x10939, Stride: 1},
+ {Lo: 0x10940, Hi: 0x10959, Stride: 1},
+ {Lo: 0x10980, Hi: 0x109B7, Stride: 1},
+ {Lo: 0x109BE, Hi: 0x109BF, Stride: 1},
+ {Lo: 0x10A00, Hi: 0x10A00, Stride: 1},
+ {Lo: 0x10A10, Hi: 0x10A13, Stride: 1},
+ {Lo: 0x10A15, Hi: 0x10A17, Stride: 1},
+ {Lo: 0x10A19, Hi: 0x10A35, Stride: 1},
+ {Lo: 0x10A60, Hi: 0x10A7C, Stride: 1},
+ {Lo: 0x10A80, Hi: 0x10A9C, Stride: 1},
+ {Lo: 0x10AC0, Hi: 0x10AC7, Stride: 1},
+ {Lo: 0x10AC9, Hi: 0x10AE4, Stride: 1},
+ {Lo: 0x10B00, Hi: 0x10B35, Stride: 1},
+ {Lo: 0x10B40, Hi: 0x10B55, Stride: 1},
+ {Lo: 0x10B60, Hi: 0x10B72, Stride: 1},
+ {Lo: 0x10B80, Hi: 0x10B91, Stride: 1},
+ {Lo: 0x10C00, Hi: 0x10C48, Stride: 1},
+ {Lo: 0x10D00, Hi: 0x10D23, Stride: 1},
+ {Lo: 0x10D4A, Hi: 0x10D4F, Stride: 1},
+ {Lo: 0x10D6F, Hi: 0x10D6F, Stride: 1},
+ {Lo: 0x10E80, Hi: 0x10EA9, Stride: 1},
+ {Lo: 0x10EB0, Hi: 0x10EB1, Stride: 1},
+ {Lo: 0x10EC2, Hi: 0x10EC7, Stride: 1},
+ {Lo: 0x10F00, Hi: 0x10F1C, Stride: 1},
+ {Lo: 0x10F27, Hi: 0x10F27, Stride: 1},
+ {Lo: 0x10F30, Hi: 0x10F45, Stride: 1},
+ {Lo: 0x10F70, Hi: 0x10F81, Stride: 1},
+ {Lo: 0x10FB0, Hi: 0x10FC4, Stride: 1},
+ {Lo: 0x10FE0, Hi: 0x10FF6, Stride: 1},
+ {Lo: 0x11003, Hi: 0x11037, Stride: 1},
+ {Lo: 0x11071, Hi: 0x11072, Stride: 1},
+ {Lo: 0x11075, Hi: 0x11075, Stride: 1},
+ {Lo: 0x11083, Hi: 0x110AF, Stride: 1},
+ {Lo: 0x110D0, Hi: 0x110E8, Stride: 1},
+ {Lo: 0x11103, Hi: 0x11126, Stride: 1},
+ {Lo: 0x11144, Hi: 0x11144, Stride: 1},
+ {Lo: 0x11147, Hi: 0x11147, Stride: 1},
+ {Lo: 0x11150, Hi: 0x11172, Stride: 1},
+ {Lo: 0x11176, Hi: 0x11176, Stride: 1},
+ {Lo: 0x11183, Hi: 0x111B2, Stride: 1},
+ {Lo: 0x111C1, Hi: 0x111C4, Stride: 1},
+ {Lo: 0x111DA, Hi: 0x111DA, Stride: 1},
+ {Lo: 0x111DC, Hi: 0x111DC, Stride: 1},
+ {Lo: 0x11200, Hi: 0x11211, Stride: 1},
+ {Lo: 0x11213, Hi: 0x1122B, Stride: 1},
+ {Lo: 0x1123F, Hi: 0x11240, Stride: 1},
+ {Lo: 0x11280, Hi: 0x11286, Stride: 1},
+ {Lo: 0x11288, Hi: 0x11288, Stride: 1},
+ {Lo: 0x1128A, Hi: 0x1128D, Stride: 1},
+ {Lo: 0x1128F, Hi: 0x1129D, Stride: 1},
+ {Lo: 0x1129F, Hi: 0x112A8, Stride: 1},
+ {Lo: 0x112B0, Hi: 0x112DE, Stride: 1},
+ {Lo: 0x11305, Hi: 0x1130C, Stride: 1},
+ {Lo: 0x1130F, Hi: 0x11310, Stride: 1},
+ {Lo: 0x11313, Hi: 0x11328, Stride: 1},
+ {Lo: 0x1132A, Hi: 0x11330, Stride: 1},
+ {Lo: 0x11332, Hi: 0x11333, Stride: 1},
+ {Lo: 0x11335, Hi: 0x11339, Stride: 1},
+ {Lo: 0x1133D, Hi: 0x1133D, Stride: 1},
+ {Lo: 0x11350, Hi: 0x11350, Stride: 1},
+ {Lo: 0x1135D, Hi: 0x11361, Stride: 1},
+ {Lo: 0x11380, Hi: 0x11389, Stride: 1},
+ {Lo: 0x1138B, Hi: 0x1138B, Stride: 1},
+ {Lo: 0x1138E, Hi: 0x1138E, Stride: 1},
+ {Lo: 0x11390, Hi: 0x113B5, Stride: 1},
+ {Lo: 0x113B7, Hi: 0x113B7, Stride: 1},
+ {Lo: 0x113D1, Hi: 0x113D1, Stride: 1},
+ {Lo: 0x113D3, Hi: 0x113D3, Stride: 1},
+ {Lo: 0x11400, Hi: 0x11434, Stride: 1},
+ {Lo: 0x11447, Hi: 0x1144A, Stride: 1},
+ {Lo: 0x1145F, Hi: 0x11461, Stride: 1},
+ {Lo: 0x11480, Hi: 0x114AF, Stride: 1},
+ {Lo: 0x114C4, Hi: 0x114C5, Stride: 1},
+ {Lo: 0x114C7, Hi: 0x114C7, Stride: 1},
+ {Lo: 0x11580, Hi: 0x115AE, Stride: 1},
+ {Lo: 0x115D8, Hi: 0x115DB, Stride: 1},
+ {Lo: 0x11600, Hi: 0x1162F, Stride: 1},
+ {Lo: 0x11644, Hi: 0x11644, Stride: 1},
+ {Lo: 0x11680, Hi: 0x116AA, Stride: 1},
+ {Lo: 0x116B8, Hi: 0x116B8, Stride: 1},
+ {Lo: 0x11700, Hi: 0x1171A, Stride: 1},
+ {Lo: 0x11740, Hi: 0x11746, Stride: 1},
+ {Lo: 0x11800, Hi: 0x1182B, Stride: 1},
+ {Lo: 0x118FF, Hi: 0x11906, Stride: 1},
+ {Lo: 0x11909, Hi: 0x11909, Stride: 1},
+ {Lo: 0x1190C, Hi: 0x11913, Stride: 1},
+ {Lo: 0x11915, Hi: 0x11916, Stride: 1},
+ {Lo: 0x11918, Hi: 0x1192F, Stride: 1},
+ {Lo: 0x1193F, Hi: 0x1193F, Stride: 1},
+ {Lo: 0x11941, Hi: 0x11941, Stride: 1},
+ {Lo: 0x119A0, Hi: 0x119A7, Stride: 1},
+ {Lo: 0x119AA, Hi: 0x119D0, Stride: 1},
+ {Lo: 0x119E1, Hi: 0x119E1, Stride: 1},
+ {Lo: 0x119E3, Hi: 0x119E3, Stride: 1},
+ {Lo: 0x11A00, Hi: 0x11A00, Stride: 1},
+ {Lo: 0x11A0B, Hi: 0x11A32, Stride: 1},
+ {Lo: 0x11A3A, Hi: 0x11A3A, Stride: 1},
+ {Lo: 0x11A50, Hi: 0x11A50, Stride: 1},
+ {Lo: 0x11A5C, Hi: 0x11A89, Stride: 1},
+ {Lo: 0x11A9D, Hi: 0x11A9D, Stride: 1},
+ {Lo: 0x11AB0, Hi: 0x11AF8, Stride: 1},
+ {Lo: 0x11BC0, Hi: 0x11BE0, Stride: 1},
+ {Lo: 0x11C00, Hi: 0x11C08, Stride: 1},
+ {Lo: 0x11C0A, Hi: 0x11C2E, Stride: 1},
+ {Lo: 0x11C40, Hi: 0x11C40, Stride: 1},
+ {Lo: 0x11C72, Hi: 0x11C8F, Stride: 1},
+ {Lo: 0x11D00, Hi: 0x11D06, Stride: 1},
+ {Lo: 0x11D08, Hi: 0x11D09, Stride: 1},
+ {Lo: 0x11D0B, Hi: 0x11D30, Stride: 1},
+ {Lo: 0x11D46, Hi: 0x11D46, Stride: 1},
+ {Lo: 0x11D60, Hi: 0x11D65, Stride: 1},
+ {Lo: 0x11D67, Hi: 0x11D68, Stride: 1},
+ {Lo: 0x11D6A, Hi: 0x11D89, Stride: 1},
+ {Lo: 0x11D98, Hi: 0x11D98, Stride: 1},
+ {Lo: 0x11DB0, Hi: 0x11DDB, Stride: 1},
+ {Lo: 0x11EE0, Hi: 0x11EF2, Stride: 1},
+ {Lo: 0x11F02, Hi: 0x11F02, Stride: 1},
+ {Lo: 0x11F04, Hi: 0x11F10, Stride: 1},
+ {Lo: 0x11F12, Hi: 0x11F33, Stride: 1},
+ {Lo: 0x11FB0, Hi: 0x11FB0, Stride: 1},
+ {Lo: 0x12000, Hi: 0x12399, Stride: 1},
+ {Lo: 0x12400, Hi: 0x1246E, Stride: 1},
+ {Lo: 0x12480, Hi: 0x12543, Stride: 1},
+ {Lo: 0x12F90, Hi: 0x12FF0, Stride: 1},
+ {Lo: 0x13000, Hi: 0x1342F, Stride: 1},
+ {Lo: 0x13441, Hi: 0x13446, Stride: 1},
+ {Lo: 0x13460, Hi: 0x143FA, Stride: 1},
+ {Lo: 0x14400, Hi: 0x14646, Stride: 1},
+ {Lo: 0x16100, Hi: 0x1611D, Stride: 1},
+ {Lo: 0x16800, Hi: 0x16A38, Stride: 1},
+ {Lo: 0x16A40, Hi: 0x16A5E, Stride: 1},
+ {Lo: 0x16A70, Hi: 0x16ABE, Stride: 1},
+ {Lo: 0x16AD0, Hi: 0x16AED, Stride: 1},
+ {Lo: 0x16B00, Hi: 0x16B2F, Stride: 1},
+ {Lo: 0x16B40, Hi: 0x16B43, Stride: 1},
+ {Lo: 0x16B63, Hi: 0x16B77, Stride: 1},
+ {Lo: 0x16B7D, Hi: 0x16B8F, Stride: 1},
+ {Lo: 0x16D40, Hi: 0x16D6C, Stride: 1},
+ {Lo: 0x16F00, Hi: 0x16F4A, Stride: 1},
+ {Lo: 0x16F50, Hi: 0x16F50, Stride: 1},
+ {Lo: 0x16F93, Hi: 0x16F9F, Stride: 1},
+ {Lo: 0x16FE0, Hi: 0x16FE1, Stride: 1},
+ {Lo: 0x16FE3, Hi: 0x16FE3, Stride: 1},
+ {Lo: 0x16FF2, Hi: 0x16FF6, Stride: 1},
+ {Lo: 0x17000, Hi: 0x18CD5, Stride: 1},
+ {Lo: 0x18CFF, Hi: 0x18D1E, Stride: 1},
+ {Lo: 0x18D80, Hi: 0x18DF2, Stride: 1},
+ {Lo: 0x1AFF0, Hi: 0x1AFF3, Stride: 1},
+ {Lo: 0x1AFF5, Hi: 0x1AFFB, Stride: 1},
+ {Lo: 0x1AFFD, Hi: 0x1AFFE, Stride: 1},
+ {Lo: 0x1B000, Hi: 0x1B122, Stride: 1},
+ {Lo: 0x1B132, Hi: 0x1B132, Stride: 1},
+ {Lo: 0x1B150, Hi: 0x1B152, Stride: 1},
+ {Lo: 0x1B155, Hi: 0x1B155, Stride: 1},
+ {Lo: 0x1B164, Hi: 0x1B167, Stride: 1},
+ {Lo: 0x1B170, Hi: 0x1B2FB, Stride: 1},
+ {Lo: 0x1BC00, Hi: 0x1BC6A, Stride: 1},
+ {Lo: 0x1BC70, Hi: 0x1BC7C, Stride: 1},
+ {Lo: 0x1BC80, Hi: 0x1BC88, Stride: 1},
+ {Lo: 0x1BC90, Hi: 0x1BC99, Stride: 1},
+ {Lo: 0x1DF0A, Hi: 0x1DF0A, Stride: 1},
+ {Lo: 0x1E100, Hi: 0x1E12C, Stride: 1},
+ {Lo: 0x1E137, Hi: 0x1E13D, Stride: 1},
+ {Lo: 0x1E14E, Hi: 0x1E14E, Stride: 1},
+ {Lo: 0x1E290, Hi: 0x1E2AD, Stride: 1},
+ {Lo: 0x1E2C0, Hi: 0x1E2EB, Stride: 1},
+ {Lo: 0x1E4D0, Hi: 0x1E4EB, Stride: 1},
+ {Lo: 0x1E5D0, Hi: 0x1E5ED, Stride: 1},
+ {Lo: 0x1E5F0, Hi: 0x1E5F0, Stride: 1},
+ {Lo: 0x1E6C0, Hi: 0x1E6DE, Stride: 1},
+ {Lo: 0x1E6E0, Hi: 0x1E6E2, Stride: 1},
+ {Lo: 0x1E6E4, Hi: 0x1E6E5, Stride: 1},
+ {Lo: 0x1E6E7, Hi: 0x1E6ED, Stride: 1},
+ {Lo: 0x1E6F0, Hi: 0x1E6F4, Stride: 1},
+ {Lo: 0x1E6FE, Hi: 0x1E6FF, Stride: 1},
+ {Lo: 0x1E7E0, Hi: 0x1E7E6, Stride: 1},
+ {Lo: 0x1E7E8, Hi: 0x1E7EB, Stride: 1},
+ {Lo: 0x1E7ED, Hi: 0x1E7EE, Stride: 1},
+ {Lo: 0x1E7F0, Hi: 0x1E7FE, Stride: 1},
+ {Lo: 0x1E800, Hi: 0x1E8C4, Stride: 1},
+ {Lo: 0x1E94B, Hi: 0x1E94B, Stride: 1},
+ {Lo: 0x1EE00, Hi: 0x1EE03, Stride: 1},
+ {Lo: 0x1EE05, Hi: 0x1EE1F, Stride: 1},
+ {Lo: 0x1EE21, Hi: 0x1EE22, Stride: 1},
+ {Lo: 0x1EE24, Hi: 0x1EE24, Stride: 1},
+ {Lo: 0x1EE27, Hi: 0x1EE27, Stride: 1},
+ {Lo: 0x1EE29, Hi: 0x1EE32, Stride: 1},
+ {Lo: 0x1EE34, Hi: 0x1EE37, Stride: 1},
+ {Lo: 0x1EE39, Hi: 0x1EE39, Stride: 1},
+ {Lo: 0x1EE3B, Hi: 0x1EE3B, Stride: 1},
+ {Lo: 0x1EE42, Hi: 0x1EE42, Stride: 1},
+ {Lo: 0x1EE47, Hi: 0x1EE47, Stride: 1},
+ {Lo: 0x1EE49, Hi: 0x1EE49, Stride: 1},
+ {Lo: 0x1EE4B, Hi: 0x1EE4B, Stride: 1},
+ {Lo: 0x1EE4D, Hi: 0x1EE4F, Stride: 1},
+ {Lo: 0x1EE51, Hi: 0x1EE52, Stride: 1},
+ {Lo: 0x1EE54, Hi: 0x1EE54, Stride: 1},
+ {Lo: 0x1EE57, Hi: 0x1EE57, Stride: 1},
+ {Lo: 0x1EE59, Hi: 0x1EE59, Stride: 1},
+ {Lo: 0x1EE5B, Hi: 0x1EE5B, Stride: 1},
+ {Lo: 0x1EE5D, Hi: 0x1EE5D, Stride: 1},
+ {Lo: 0x1EE5F, Hi: 0x1EE5F, Stride: 1},
+ {Lo: 0x1EE61, Hi: 0x1EE62, Stride: 1},
+ {Lo: 0x1EE64, Hi: 0x1EE64, Stride: 1},
+ {Lo: 0x1EE67, Hi: 0x1EE6A, Stride: 1},
+ {Lo: 0x1EE6C, Hi: 0x1EE72, Stride: 1},
+ {Lo: 0x1EE74, Hi: 0x1EE77, Stride: 1},
+ {Lo: 0x1EE79, Hi: 0x1EE7C, Stride: 1},
+ {Lo: 0x1EE7E, Hi: 0x1EE7E, Stride: 1},
+ {Lo: 0x1EE80, Hi: 0x1EE89, Stride: 1},
+ {Lo: 0x1EE8B, Hi: 0x1EE9B, Stride: 1},
+ {Lo: 0x1EEA1, Hi: 0x1EEA3, Stride: 1},
+ {Lo: 0x1EEA5, Hi: 0x1EEA9, Stride: 1},
+ {Lo: 0x1EEAB, Hi: 0x1EEBB, Stride: 1},
+ {Lo: 0x20000, Hi: 0x2A6DF, Stride: 1},
+ {Lo: 0x2A700, Hi: 0x2B81D, Stride: 1},
+ {Lo: 0x2B820, Hi: 0x2CEAD, Stride: 1},
+ {Lo: 0x2CEB0, Hi: 0x2EBE0, Stride: 1},
+ {Lo: 0x2EBF0, Hi: 0x2EE5D, Stride: 1},
+ {Lo: 0x2F800, Hi: 0x2FA1D, Stride: 1},
+ {Lo: 0x30000, Hi: 0x3134A, Stride: 1},
+ {Lo: 0x31350, Hi: 0x33479, Stride: 1},
+ },
+}
+
+var unicodeAliasSentence_Break_SContinue = &unicode.RangeTable{
+ R16: []unicode.Range16{
+ {Lo: 0x2C, Hi: 0x2D, Stride: 1},
+ {Lo: 0x3A, Hi: 0x3B, Stride: 1},
+ {Lo: 0x37E, Hi: 0x37E, Stride: 1},
+ {Lo: 0x55D, Hi: 0x55D, Stride: 1},
+ {Lo: 0x60C, Hi: 0x60D, Stride: 1},
+ {Lo: 0x7F8, Hi: 0x7F8, Stride: 1},
+ {Lo: 0x1802, Hi: 0x1802, Stride: 1},
+ {Lo: 0x1808, Hi: 0x1808, Stride: 1},
+ {Lo: 0x2013, Hi: 0x2014, Stride: 1},
+ {Lo: 0x3001, Hi: 0x3001, Stride: 1},
+ {Lo: 0xFE10, Hi: 0xFE11, Stride: 1},
+ {Lo: 0xFE13, Hi: 0xFE14, Stride: 1},
+ {Lo: 0xFE31, Hi: 0xFE32, Stride: 1},
+ {Lo: 0xFE50, Hi: 0xFE51, Stride: 1},
+ {Lo: 0xFE54, Hi: 0xFE55, Stride: 1},
+ {Lo: 0xFE58, Hi: 0xFE58, Stride: 1},
+ {Lo: 0xFE63, Hi: 0xFE63, Stride: 1},
+ {Lo: 0xFF0C, Hi: 0xFF0D, Stride: 1},
+ {Lo: 0xFF1A, Hi: 0xFF1B, Stride: 1},
+ {Lo: 0xFF64, Hi: 0xFF64, Stride: 1},
+ },
+}
+
+var unicodeAliasSentence_Break_STerm = &unicode.RangeTable{
+ R16: []unicode.Range16{
+ {Lo: 0x21, Hi: 0x21, Stride: 1},
+ {Lo: 0x3F, Hi: 0x3F, Stride: 1},
+ {Lo: 0x589, Hi: 0x589, Stride: 1},
+ {Lo: 0x61D, Hi: 0x61F, Stride: 1},
+ {Lo: 0x6D4, Hi: 0x6D4, Stride: 1},
+ {Lo: 0x700, Hi: 0x702, Stride: 1},
+ {Lo: 0x7F9, Hi: 0x7F9, Stride: 1},
+ {Lo: 0x837, Hi: 0x837, Stride: 1},
+ {Lo: 0x839, Hi: 0x839, Stride: 1},
+ {Lo: 0x83D, Hi: 0x83E, Stride: 1},
+ {Lo: 0x964, Hi: 0x965, Stride: 1},
+ {Lo: 0x104A, Hi: 0x104B, Stride: 1},
+ {Lo: 0x1362, Hi: 0x1362, Stride: 1},
+ {Lo: 0x1367, Hi: 0x1368, Stride: 1},
+ {Lo: 0x166E, Hi: 0x166E, Stride: 1},
+ {Lo: 0x1735, Hi: 0x1736, Stride: 1},
+ {Lo: 0x17D4, Hi: 0x17D5, Stride: 1},
+ {Lo: 0x1803, Hi: 0x1803, Stride: 1},
+ {Lo: 0x1809, Hi: 0x1809, Stride: 1},
+ {Lo: 0x1944, Hi: 0x1945, Stride: 1},
+ {Lo: 0x1AA8, Hi: 0x1AAB, Stride: 1},
+ {Lo: 0x1B4E, Hi: 0x1B4F, Stride: 1},
+ {Lo: 0x1B5A, Hi: 0x1B5B, Stride: 1},
+ {Lo: 0x1B5E, Hi: 0x1B5F, Stride: 1},
+ {Lo: 0x1B7D, Hi: 0x1B7F, Stride: 1},
+ {Lo: 0x1C3B, Hi: 0x1C3C, Stride: 1},
+ {Lo: 0x1C7E, Hi: 0x1C7F, Stride: 1},
+ {Lo: 0x203C, Hi: 0x203D, Stride: 1},
+ {Lo: 0x2047, Hi: 0x2049, Stride: 1},
+ {Lo: 0x2CF9, Hi: 0x2CFB, Stride: 1},
+ {Lo: 0x2E2E, Hi: 0x2E2E, Stride: 1},
+ {Lo: 0x2E3C, Hi: 0x2E3C, Stride: 1},
+ {Lo: 0x2E53, Hi: 0x2E54, Stride: 1},
+ {Lo: 0x3002, Hi: 0x3002, Stride: 1},
+ {Lo: 0xA4FF, Hi: 0xA4FF, Stride: 1},
+ {Lo: 0xA60E, Hi: 0xA60F, Stride: 1},
+ {Lo: 0xA6F3, Hi: 0xA6F3, Stride: 1},
+ {Lo: 0xA6F7, Hi: 0xA6F7, Stride: 1},
+ {Lo: 0xA876, Hi: 0xA877, Stride: 1},
+ {Lo: 0xA8CE, Hi: 0xA8CF, Stride: 1},
+ {Lo: 0xA92F, Hi: 0xA92F, Stride: 1},
+ {Lo: 0xA9C8, Hi: 0xA9C9, Stride: 1},
+ {Lo: 0xAA5D, Hi: 0xAA5F, Stride: 1},
+ {Lo: 0xAAF0, Hi: 0xAAF1, Stride: 1},
+ {Lo: 0xABEB, Hi: 0xABEB, Stride: 1},
+ {Lo: 0xFE12, Hi: 0xFE12, Stride: 1},
+ {Lo: 0xFE15, Hi: 0xFE16, Stride: 1},
+ {Lo: 0xFE56, Hi: 0xFE57, Stride: 1},
+ {Lo: 0xFF01, Hi: 0xFF01, Stride: 1},
+ {Lo: 0xFF1F, Hi: 0xFF1F, Stride: 1},
+ {Lo: 0xFF61, Hi: 0xFF61, Stride: 1},
+ },
+ R32: []unicode.Range32{
+ {Lo: 0x10A56, Hi: 0x10A57, Stride: 1},
+ {Lo: 0x10F55, Hi: 0x10F59, Stride: 1},
+ {Lo: 0x10F86, Hi: 0x10F89, Stride: 1},
+ {Lo: 0x11047, Hi: 0x11048, Stride: 1},
+ {Lo: 0x110BE, Hi: 0x110C1, Stride: 1},
+ {Lo: 0x11141, Hi: 0x11143, Stride: 1},
+ {Lo: 0x111C5, Hi: 0x111C6, Stride: 1},
+ {Lo: 0x111CD, Hi: 0x111CD, Stride: 1},
+ {Lo: 0x111DE, Hi: 0x111DF, Stride: 1},
+ {Lo: 0x11238, Hi: 0x11239, Stride: 1},
+ {Lo: 0x1123B, Hi: 0x1123C, Stride: 1},
+ {Lo: 0x112A9, Hi: 0x112A9, Stride: 1},
+ {Lo: 0x113D4, Hi: 0x113D5, Stride: 1},
+ {Lo: 0x1144B, Hi: 0x1144C, Stride: 1},
+ {Lo: 0x115C2, Hi: 0x115C3, Stride: 1},
+ {Lo: 0x115C9, Hi: 0x115D7, Stride: 1},
+ {Lo: 0x11641, Hi: 0x11642, Stride: 1},
+ {Lo: 0x1173C, Hi: 0x1173E, Stride: 1},
+ {Lo: 0x11944, Hi: 0x11944, Stride: 1},
+ {Lo: 0x11946, Hi: 0x11946, Stride: 1},
+ {Lo: 0x11A42, Hi: 0x11A43, Stride: 1},
+ {Lo: 0x11A9B, Hi: 0x11A9C, Stride: 1},
+ {Lo: 0x11C41, Hi: 0x11C42, Stride: 1},
+ {Lo: 0x11EF7, Hi: 0x11EF8, Stride: 1},
+ {Lo: 0x11F43, Hi: 0x11F44, Stride: 1},
+ {Lo: 0x16A6E, Hi: 0x16A6F, Stride: 1},
+ {Lo: 0x16AF5, Hi: 0x16AF5, Stride: 1},
+ {Lo: 0x16B37, Hi: 0x16B38, Stride: 1},
+ {Lo: 0x16B44, Hi: 0x16B44, Stride: 1},
+ {Lo: 0x16D6E, Hi: 0x16D6F, Stride: 1},
+ {Lo: 0x16E98, Hi: 0x16E98, Stride: 1},
+ {Lo: 0x1BC9F, Hi: 0x1BC9F, Stride: 1},
+ {Lo: 0x1DA88, Hi: 0x1DA88, Stride: 1},
+ },
+}
+
+var unicodeAliasSentence_Break_Sep = &unicode.RangeTable{
+ R16: []unicode.Range16{
+ {Lo: 0x85, Hi: 0x85, Stride: 1},
+ {Lo: 0x2028, Hi: 0x2029, Stride: 1},
+ },
+}
+
+var unicodeAliasSentence_Break_Sp = &unicode.RangeTable{
+ R16: []unicode.Range16{
+ {Lo: 0x9, Hi: 0x9, Stride: 1},
+ {Lo: 0xB, Hi: 0xC, Stride: 1},
+ {Lo: 0x20, Hi: 0x20, Stride: 1},
+ {Lo: 0xA0, Hi: 0xA0, Stride: 1},
+ {Lo: 0x1680, Hi: 0x1680, Stride: 1},
+ {Lo: 0x2000, Hi: 0x200A, Stride: 1},
+ {Lo: 0x202F, Hi: 0x202F, Stride: 1},
+ {Lo: 0x205F, Hi: 0x205F, Stride: 1},
+ {Lo: 0x3000, Hi: 0x3000, Stride: 1},
+ },
+}
+
+var unicodeAliasSentence_Break_Upper = &unicode.RangeTable{
+ R16: []unicode.Range16{
+ {Lo: 0x41, Hi: 0x5A, Stride: 1},
+ {Lo: 0xC0, Hi: 0xD6, Stride: 1},
+ {Lo: 0xD8, Hi: 0xDE, Stride: 1},
+ {Lo: 0x100, Hi: 0x100, Stride: 1},
+ {Lo: 0x102, Hi: 0x102, Stride: 1},
+ {Lo: 0x104, Hi: 0x104, Stride: 1},
+ {Lo: 0x106, Hi: 0x106, Stride: 1},
+ {Lo: 0x108, Hi: 0x108, Stride: 1},
+ {Lo: 0x10A, Hi: 0x10A, Stride: 1},
+ {Lo: 0x10C, Hi: 0x10C, Stride: 1},
+ {Lo: 0x10E, Hi: 0x10E, Stride: 1},
+ {Lo: 0x110, Hi: 0x110, Stride: 1},
+ {Lo: 0x112, Hi: 0x112, Stride: 1},
+ {Lo: 0x114, Hi: 0x114, Stride: 1},
+ {Lo: 0x116, Hi: 0x116, Stride: 1},
+ {Lo: 0x118, Hi: 0x118, Stride: 1},
+ {Lo: 0x11A, Hi: 0x11A, Stride: 1},
+ {Lo: 0x11C, Hi: 0x11C, Stride: 1},
+ {Lo: 0x11E, Hi: 0x11E, Stride: 1},
+ {Lo: 0x120, Hi: 0x120, Stride: 1},
+ {Lo: 0x122, Hi: 0x122, Stride: 1},
+ {Lo: 0x124, Hi: 0x124, Stride: 1},
+ {Lo: 0x126, Hi: 0x126, Stride: 1},
+ {Lo: 0x128, Hi: 0x128, Stride: 1},
+ {Lo: 0x12A, Hi: 0x12A, Stride: 1},
+ {Lo: 0x12C, Hi: 0x12C, Stride: 1},
+ {Lo: 0x12E, Hi: 0x12E, Stride: 1},
+ {Lo: 0x130, Hi: 0x130, Stride: 1},
+ {Lo: 0x132, Hi: 0x132, Stride: 1},
+ {Lo: 0x134, Hi: 0x134, Stride: 1},
+ {Lo: 0x136, Hi: 0x136, Stride: 1},
+ {Lo: 0x139, Hi: 0x139, Stride: 1},
+ {Lo: 0x13B, Hi: 0x13B, Stride: 1},
+ {Lo: 0x13D, Hi: 0x13D, Stride: 1},
+ {Lo: 0x13F, Hi: 0x13F, Stride: 1},
+ {Lo: 0x141, Hi: 0x141, Stride: 1},
+ {Lo: 0x143, Hi: 0x143, Stride: 1},
+ {Lo: 0x145, Hi: 0x145, Stride: 1},
+ {Lo: 0x147, Hi: 0x147, Stride: 1},
+ {Lo: 0x14A, Hi: 0x14A, Stride: 1},
+ {Lo: 0x14C, Hi: 0x14C, Stride: 1},
+ {Lo: 0x14E, Hi: 0x14E, Stride: 1},
+ {Lo: 0x150, Hi: 0x150, Stride: 1},
+ {Lo: 0x152, Hi: 0x152, Stride: 1},
+ {Lo: 0x154, Hi: 0x154, Stride: 1},
+ {Lo: 0x156, Hi: 0x156, Stride: 1},
+ {Lo: 0x158, Hi: 0x158, Stride: 1},
+ {Lo: 0x15A, Hi: 0x15A, Stride: 1},
+ {Lo: 0x15C, Hi: 0x15C, Stride: 1},
+ {Lo: 0x15E, Hi: 0x15E, Stride: 1},
+ {Lo: 0x160, Hi: 0x160, Stride: 1},
+ {Lo: 0x162, Hi: 0x162, Stride: 1},
+ {Lo: 0x164, Hi: 0x164, Stride: 1},
+ {Lo: 0x166, Hi: 0x166, Stride: 1},
+ {Lo: 0x168, Hi: 0x168, Stride: 1},
+ {Lo: 0x16A, Hi: 0x16A, Stride: 1},
+ {Lo: 0x16C, Hi: 0x16C, Stride: 1},
+ {Lo: 0x16E, Hi: 0x16E, Stride: 1},
+ {Lo: 0x170, Hi: 0x170, Stride: 1},
+ {Lo: 0x172, Hi: 0x172, Stride: 1},
+ {Lo: 0x174, Hi: 0x174, Stride: 1},
+ {Lo: 0x176, Hi: 0x176, Stride: 1},
+ {Lo: 0x178, Hi: 0x179, Stride: 1},
+ {Lo: 0x17B, Hi: 0x17B, Stride: 1},
+ {Lo: 0x17D, Hi: 0x17D, Stride: 1},
+ {Lo: 0x181, Hi: 0x182, Stride: 1},
+ {Lo: 0x184, Hi: 0x184, Stride: 1},
+ {Lo: 0x186, Hi: 0x187, Stride: 1},
+ {Lo: 0x189, Hi: 0x18B, Stride: 1},
+ {Lo: 0x18E, Hi: 0x191, Stride: 1},
+ {Lo: 0x193, Hi: 0x194, Stride: 1},
+ {Lo: 0x196, Hi: 0x198, Stride: 1},
+ {Lo: 0x19C, Hi: 0x19D, Stride: 1},
+ {Lo: 0x19F, Hi: 0x1A0, Stride: 1},
+ {Lo: 0x1A2, Hi: 0x1A2, Stride: 1},
+ {Lo: 0x1A4, Hi: 0x1A4, Stride: 1},
+ {Lo: 0x1A6, Hi: 0x1A7, Stride: 1},
+ {Lo: 0x1A9, Hi: 0x1A9, Stride: 1},
+ {Lo: 0x1AC, Hi: 0x1AC, Stride: 1},
+ {Lo: 0x1AE, Hi: 0x1AF, Stride: 1},
+ {Lo: 0x1B1, Hi: 0x1B3, Stride: 1},
+ {Lo: 0x1B5, Hi: 0x1B5, Stride: 1},
+ {Lo: 0x1B7, Hi: 0x1B8, Stride: 1},
+ {Lo: 0x1BC, Hi: 0x1BC, Stride: 1},
+ {Lo: 0x1C4, Hi: 0x1C5, Stride: 1},
+ {Lo: 0x1C7, Hi: 0x1C8, Stride: 1},
+ {Lo: 0x1CA, Hi: 0x1CB, Stride: 1},
+ {Lo: 0x1CD, Hi: 0x1CD, Stride: 1},
+ {Lo: 0x1CF, Hi: 0x1CF, Stride: 1},
+ {Lo: 0x1D1, Hi: 0x1D1, Stride: 1},
+ {Lo: 0x1D3, Hi: 0x1D3, Stride: 1},
+ {Lo: 0x1D5, Hi: 0x1D5, Stride: 1},
+ {Lo: 0x1D7, Hi: 0x1D7, Stride: 1},
+ {Lo: 0x1D9, Hi: 0x1D9, Stride: 1},
+ {Lo: 0x1DB, Hi: 0x1DB, Stride: 1},
+ {Lo: 0x1DE, Hi: 0x1DE, Stride: 1},
+ {Lo: 0x1E0, Hi: 0x1E0, Stride: 1},
+ {Lo: 0x1E2, Hi: 0x1E2, Stride: 1},
+ {Lo: 0x1E4, Hi: 0x1E4, Stride: 1},
+ {Lo: 0x1E6, Hi: 0x1E6, Stride: 1},
+ {Lo: 0x1E8, Hi: 0x1E8, Stride: 1},
+ {Lo: 0x1EA, Hi: 0x1EA, Stride: 1},
+ {Lo: 0x1EC, Hi: 0x1EC, Stride: 1},
+ {Lo: 0x1EE, Hi: 0x1EE, Stride: 1},
+ {Lo: 0x1F1, Hi: 0x1F2, Stride: 1},
+ {Lo: 0x1F4, Hi: 0x1F4, Stride: 1},
+ {Lo: 0x1F6, Hi: 0x1F8, Stride: 1},
+ {Lo: 0x1FA, Hi: 0x1FA, Stride: 1},
+ {Lo: 0x1FC, Hi: 0x1FC, Stride: 1},
+ {Lo: 0x1FE, Hi: 0x1FE, Stride: 1},
+ {Lo: 0x200, Hi: 0x200, Stride: 1},
+ {Lo: 0x202, Hi: 0x202, Stride: 1},
+ {Lo: 0x204, Hi: 0x204, Stride: 1},
+ {Lo: 0x206, Hi: 0x206, Stride: 1},
+ {Lo: 0x208, Hi: 0x208, Stride: 1},
+ {Lo: 0x20A, Hi: 0x20A, Stride: 1},
+ {Lo: 0x20C, Hi: 0x20C, Stride: 1},
+ {Lo: 0x20E, Hi: 0x20E, Stride: 1},
+ {Lo: 0x210, Hi: 0x210, Stride: 1},
+ {Lo: 0x212, Hi: 0x212, Stride: 1},
+ {Lo: 0x214, Hi: 0x214, Stride: 1},
+ {Lo: 0x216, Hi: 0x216, Stride: 1},
+ {Lo: 0x218, Hi: 0x218, Stride: 1},
+ {Lo: 0x21A, Hi: 0x21A, Stride: 1},
+ {Lo: 0x21C, Hi: 0x21C, Stride: 1},
+ {Lo: 0x21E, Hi: 0x21E, Stride: 1},
+ {Lo: 0x220, Hi: 0x220, Stride: 1},
+ {Lo: 0x222, Hi: 0x222, Stride: 1},
+ {Lo: 0x224, Hi: 0x224, Stride: 1},
+ {Lo: 0x226, Hi: 0x226, Stride: 1},
+ {Lo: 0x228, Hi: 0x228, Stride: 1},
+ {Lo: 0x22A, Hi: 0x22A, Stride: 1},
+ {Lo: 0x22C, Hi: 0x22C, Stride: 1},
+ {Lo: 0x22E, Hi: 0x22E, Stride: 1},
+ {Lo: 0x230, Hi: 0x230, Stride: 1},
+ {Lo: 0x232, Hi: 0x232, Stride: 1},
+ {Lo: 0x23A, Hi: 0x23B, Stride: 1},
+ {Lo: 0x23D, Hi: 0x23E, Stride: 1},
+ {Lo: 0x241, Hi: 0x241, Stride: 1},
+ {Lo: 0x243, Hi: 0x246, Stride: 1},
+ {Lo: 0x248, Hi: 0x248, Stride: 1},
+ {Lo: 0x24A, Hi: 0x24A, Stride: 1},
+ {Lo: 0x24C, Hi: 0x24C, Stride: 1},
+ {Lo: 0x24E, Hi: 0x24E, Stride: 1},
+ {Lo: 0x370, Hi: 0x370, Stride: 1},
+ {Lo: 0x372, Hi: 0x372, Stride: 1},
+ {Lo: 0x376, Hi: 0x376, Stride: 1},
+ {Lo: 0x37F, Hi: 0x37F, Stride: 1},
+ {Lo: 0x386, Hi: 0x386, Stride: 1},
+ {Lo: 0x388, Hi: 0x38A, Stride: 1},
+ {Lo: 0x38C, Hi: 0x38C, Stride: 1},
+ {Lo: 0x38E, Hi: 0x38F, Stride: 1},
+ {Lo: 0x391, Hi: 0x3A1, Stride: 1},
+ {Lo: 0x3A3, Hi: 0x3AB, Stride: 1},
+ {Lo: 0x3CF, Hi: 0x3CF, Stride: 1},
+ {Lo: 0x3D2, Hi: 0x3D4, Stride: 1},
+ {Lo: 0x3D8, Hi: 0x3D8, Stride: 1},
+ {Lo: 0x3DA, Hi: 0x3DA, Stride: 1},
+ {Lo: 0x3DC, Hi: 0x3DC, Stride: 1},
+ {Lo: 0x3DE, Hi: 0x3DE, Stride: 1},
+ {Lo: 0x3E0, Hi: 0x3E0, Stride: 1},
+ {Lo: 0x3E2, Hi: 0x3E2, Stride: 1},
+ {Lo: 0x3E4, Hi: 0x3E4, Stride: 1},
+ {Lo: 0x3E6, Hi: 0x3E6, Stride: 1},
+ {Lo: 0x3E8, Hi: 0x3E8, Stride: 1},
+ {Lo: 0x3EA, Hi: 0x3EA, Stride: 1},
+ {Lo: 0x3EC, Hi: 0x3EC, Stride: 1},
+ {Lo: 0x3EE, Hi: 0x3EE, Stride: 1},
+ {Lo: 0x3F4, Hi: 0x3F4, Stride: 1},
+ {Lo: 0x3F7, Hi: 0x3F7, Stride: 1},
+ {Lo: 0x3F9, Hi: 0x3FA, Stride: 1},
+ {Lo: 0x3FD, Hi: 0x42F, Stride: 1},
+ {Lo: 0x460, Hi: 0x460, Stride: 1},
+ {Lo: 0x462, Hi: 0x462, Stride: 1},
+ {Lo: 0x464, Hi: 0x464, Stride: 1},
+ {Lo: 0x466, Hi: 0x466, Stride: 1},
+ {Lo: 0x468, Hi: 0x468, Stride: 1},
+ {Lo: 0x46A, Hi: 0x46A, Stride: 1},
+ {Lo: 0x46C, Hi: 0x46C, Stride: 1},
+ {Lo: 0x46E, Hi: 0x46E, Stride: 1},
+ {Lo: 0x470, Hi: 0x470, Stride: 1},
+ {Lo: 0x472, Hi: 0x472, Stride: 1},
+ {Lo: 0x474, Hi: 0x474, Stride: 1},
+ {Lo: 0x476, Hi: 0x476, Stride: 1},
+ {Lo: 0x478, Hi: 0x478, Stride: 1},
+ {Lo: 0x47A, Hi: 0x47A, Stride: 1},
+ {Lo: 0x47C, Hi: 0x47C, Stride: 1},
+ {Lo: 0x47E, Hi: 0x47E, Stride: 1},
+ {Lo: 0x480, Hi: 0x480, Stride: 1},
+ {Lo: 0x48A, Hi: 0x48A, Stride: 1},
+ {Lo: 0x48C, Hi: 0x48C, Stride: 1},
+ {Lo: 0x48E, Hi: 0x48E, Stride: 1},
+ {Lo: 0x490, Hi: 0x490, Stride: 1},
+ {Lo: 0x492, Hi: 0x492, Stride: 1},
+ {Lo: 0x494, Hi: 0x494, Stride: 1},
+ {Lo: 0x496, Hi: 0x496, Stride: 1},
+ {Lo: 0x498, Hi: 0x498, Stride: 1},
+ {Lo: 0x49A, Hi: 0x49A, Stride: 1},
+ {Lo: 0x49C, Hi: 0x49C, Stride: 1},
+ {Lo: 0x49E, Hi: 0x49E, Stride: 1},
+ {Lo: 0x4A0, Hi: 0x4A0, Stride: 1},
+ {Lo: 0x4A2, Hi: 0x4A2, Stride: 1},
+ {Lo: 0x4A4, Hi: 0x4A4, Stride: 1},
+ {Lo: 0x4A6, Hi: 0x4A6, Stride: 1},
+ {Lo: 0x4A8, Hi: 0x4A8, Stride: 1},
+ {Lo: 0x4AA, Hi: 0x4AA, Stride: 1},
+ {Lo: 0x4AC, Hi: 0x4AC, Stride: 1},
+ {Lo: 0x4AE, Hi: 0x4AE, Stride: 1},
+ {Lo: 0x4B0, Hi: 0x4B0, Stride: 1},
+ {Lo: 0x4B2, Hi: 0x4B2, Stride: 1},
+ {Lo: 0x4B4, Hi: 0x4B4, Stride: 1},
+ {Lo: 0x4B6, Hi: 0x4B6, Stride: 1},
+ {Lo: 0x4B8, Hi: 0x4B8, Stride: 1},
+ {Lo: 0x4BA, Hi: 0x4BA, Stride: 1},
+ {Lo: 0x4BC, Hi: 0x4BC, Stride: 1},
+ {Lo: 0x4BE, Hi: 0x4BE, Stride: 1},
+ {Lo: 0x4C0, Hi: 0x4C1, Stride: 1},
+ {Lo: 0x4C3, Hi: 0x4C3, Stride: 1},
+ {Lo: 0x4C5, Hi: 0x4C5, Stride: 1},
+ {Lo: 0x4C7, Hi: 0x4C7, Stride: 1},
+ {Lo: 0x4C9, Hi: 0x4C9, Stride: 1},
+ {Lo: 0x4CB, Hi: 0x4CB, Stride: 1},
+ {Lo: 0x4CD, Hi: 0x4CD, Stride: 1},
+ {Lo: 0x4D0, Hi: 0x4D0, Stride: 1},
+ {Lo: 0x4D2, Hi: 0x4D2, Stride: 1},
+ {Lo: 0x4D4, Hi: 0x4D4, Stride: 1},
+ {Lo: 0x4D6, Hi: 0x4D6, Stride: 1},
+ {Lo: 0x4D8, Hi: 0x4D8, Stride: 1},
+ {Lo: 0x4DA, Hi: 0x4DA, Stride: 1},
+ {Lo: 0x4DC, Hi: 0x4DC, Stride: 1},
+ {Lo: 0x4DE, Hi: 0x4DE, Stride: 1},
+ {Lo: 0x4E0, Hi: 0x4E0, Stride: 1},
+ {Lo: 0x4E2, Hi: 0x4E2, Stride: 1},
+ {Lo: 0x4E4, Hi: 0x4E4, Stride: 1},
+ {Lo: 0x4E6, Hi: 0x4E6, Stride: 1},
+ {Lo: 0x4E8, Hi: 0x4E8, Stride: 1},
+ {Lo: 0x4EA, Hi: 0x4EA, Stride: 1},
+ {Lo: 0x4EC, Hi: 0x4EC, Stride: 1},
+ {Lo: 0x4EE, Hi: 0x4EE, Stride: 1},
+ {Lo: 0x4F0, Hi: 0x4F0, Stride: 1},
+ {Lo: 0x4F2, Hi: 0x4F2, Stride: 1},
+ {Lo: 0x4F4, Hi: 0x4F4, Stride: 1},
+ {Lo: 0x4F6, Hi: 0x4F6, Stride: 1},
+ {Lo: 0x4F8, Hi: 0x4F8, Stride: 1},
+ {Lo: 0x4FA, Hi: 0x4FA, Stride: 1},
+ {Lo: 0x4FC, Hi: 0x4FC, Stride: 1},
+ {Lo: 0x4FE, Hi: 0x4FE, Stride: 1},
+ {Lo: 0x500, Hi: 0x500, Stride: 1},
+ {Lo: 0x502, Hi: 0x502, Stride: 1},
+ {Lo: 0x504, Hi: 0x504, Stride: 1},
+ {Lo: 0x506, Hi: 0x506, Stride: 1},
+ {Lo: 0x508, Hi: 0x508, Stride: 1},
+ {Lo: 0x50A, Hi: 0x50A, Stride: 1},
+ {Lo: 0x50C, Hi: 0x50C, Stride: 1},
+ {Lo: 0x50E, Hi: 0x50E, Stride: 1},
+ {Lo: 0x510, Hi: 0x510, Stride: 1},
+ {Lo: 0x512, Hi: 0x512, Stride: 1},
+ {Lo: 0x514, Hi: 0x514, Stride: 1},
+ {Lo: 0x516, Hi: 0x516, Stride: 1},
+ {Lo: 0x518, Hi: 0x518, Stride: 1},
+ {Lo: 0x51A, Hi: 0x51A, Stride: 1},
+ {Lo: 0x51C, Hi: 0x51C, Stride: 1},
+ {Lo: 0x51E, Hi: 0x51E, Stride: 1},
+ {Lo: 0x520, Hi: 0x520, Stride: 1},
+ {Lo: 0x522, Hi: 0x522, Stride: 1},
+ {Lo: 0x524, Hi: 0x524, Stride: 1},
+ {Lo: 0x526, Hi: 0x526, Stride: 1},
+ {Lo: 0x528, Hi: 0x528, Stride: 1},
+ {Lo: 0x52A, Hi: 0x52A, Stride: 1},
+ {Lo: 0x52C, Hi: 0x52C, Stride: 1},
+ {Lo: 0x52E, Hi: 0x52E, Stride: 1},
+ {Lo: 0x531, Hi: 0x556, Stride: 1},
+ {Lo: 0x10A0, Hi: 0x10C5, Stride: 1},
+ {Lo: 0x10C7, Hi: 0x10C7, Stride: 1},
+ {Lo: 0x10CD, Hi: 0x10CD, Stride: 1},
+ {Lo: 0x13A0, Hi: 0x13F5, Stride: 1},
+ {Lo: 0x1C89, Hi: 0x1C89, Stride: 1},
+ {Lo: 0x1E00, Hi: 0x1E00, Stride: 1},
+ {Lo: 0x1E02, Hi: 0x1E02, Stride: 1},
+ {Lo: 0x1E04, Hi: 0x1E04, Stride: 1},
+ {Lo: 0x1E06, Hi: 0x1E06, Stride: 1},
+ {Lo: 0x1E08, Hi: 0x1E08, Stride: 1},
+ {Lo: 0x1E0A, Hi: 0x1E0A, Stride: 1},
+ {Lo: 0x1E0C, Hi: 0x1E0C, Stride: 1},
+ {Lo: 0x1E0E, Hi: 0x1E0E, Stride: 1},
+ {Lo: 0x1E10, Hi: 0x1E10, Stride: 1},
+ {Lo: 0x1E12, Hi: 0x1E12, Stride: 1},
+ {Lo: 0x1E14, Hi: 0x1E14, Stride: 1},
+ {Lo: 0x1E16, Hi: 0x1E16, Stride: 1},
+ {Lo: 0x1E18, Hi: 0x1E18, Stride: 1},
+ {Lo: 0x1E1A, Hi: 0x1E1A, Stride: 1},
+ {Lo: 0x1E1C, Hi: 0x1E1C, Stride: 1},
+ {Lo: 0x1E1E, Hi: 0x1E1E, Stride: 1},
+ {Lo: 0x1E20, Hi: 0x1E20, Stride: 1},
+ {Lo: 0x1E22, Hi: 0x1E22, Stride: 1},
+ {Lo: 0x1E24, Hi: 0x1E24, Stride: 1},
+ {Lo: 0x1E26, Hi: 0x1E26, Stride: 1},
+ {Lo: 0x1E28, Hi: 0x1E28, Stride: 1},
+ {Lo: 0x1E2A, Hi: 0x1E2A, Stride: 1},
+ {Lo: 0x1E2C, Hi: 0x1E2C, Stride: 1},
+ {Lo: 0x1E2E, Hi: 0x1E2E, Stride: 1},
+ {Lo: 0x1E30, Hi: 0x1E30, Stride: 1},
+ {Lo: 0x1E32, Hi: 0x1E32, Stride: 1},
+ {Lo: 0x1E34, Hi: 0x1E34, Stride: 1},
+ {Lo: 0x1E36, Hi: 0x1E36, Stride: 1},
+ {Lo: 0x1E38, Hi: 0x1E38, Stride: 1},
+ {Lo: 0x1E3A, Hi: 0x1E3A, Stride: 1},
+ {Lo: 0x1E3C, Hi: 0x1E3C, Stride: 1},
+ {Lo: 0x1E3E, Hi: 0x1E3E, Stride: 1},
+ {Lo: 0x1E40, Hi: 0x1E40, Stride: 1},
+ {Lo: 0x1E42, Hi: 0x1E42, Stride: 1},
+ {Lo: 0x1E44, Hi: 0x1E44, Stride: 1},
+ {Lo: 0x1E46, Hi: 0x1E46, Stride: 1},
+ {Lo: 0x1E48, Hi: 0x1E48, Stride: 1},
+ {Lo: 0x1E4A, Hi: 0x1E4A, Stride: 1},
+ {Lo: 0x1E4C, Hi: 0x1E4C, Stride: 1},
+ {Lo: 0x1E4E, Hi: 0x1E4E, Stride: 1},
+ {Lo: 0x1E50, Hi: 0x1E50, Stride: 1},
+ {Lo: 0x1E52, Hi: 0x1E52, Stride: 1},
+ {Lo: 0x1E54, Hi: 0x1E54, Stride: 1},
+ {Lo: 0x1E56, Hi: 0x1E56, Stride: 1},
+ {Lo: 0x1E58, Hi: 0x1E58, Stride: 1},
+ {Lo: 0x1E5A, Hi: 0x1E5A, Stride: 1},
+ {Lo: 0x1E5C, Hi: 0x1E5C, Stride: 1},
+ {Lo: 0x1E5E, Hi: 0x1E5E, Stride: 1},
+ {Lo: 0x1E60, Hi: 0x1E60, Stride: 1},
+ {Lo: 0x1E62, Hi: 0x1E62, Stride: 1},
+ {Lo: 0x1E64, Hi: 0x1E64, Stride: 1},
+ {Lo: 0x1E66, Hi: 0x1E66, Stride: 1},
+ {Lo: 0x1E68, Hi: 0x1E68, Stride: 1},
+ {Lo: 0x1E6A, Hi: 0x1E6A, Stride: 1},
+ {Lo: 0x1E6C, Hi: 0x1E6C, Stride: 1},
+ {Lo: 0x1E6E, Hi: 0x1E6E, Stride: 1},
+ {Lo: 0x1E70, Hi: 0x1E70, Stride: 1},
+ {Lo: 0x1E72, Hi: 0x1E72, Stride: 1},
+ {Lo: 0x1E74, Hi: 0x1E74, Stride: 1},
+ {Lo: 0x1E76, Hi: 0x1E76, Stride: 1},
+ {Lo: 0x1E78, Hi: 0x1E78, Stride: 1},
+ {Lo: 0x1E7A, Hi: 0x1E7A, Stride: 1},
+ {Lo: 0x1E7C, Hi: 0x1E7C, Stride: 1},
+ {Lo: 0x1E7E, Hi: 0x1E7E, Stride: 1},
+ {Lo: 0x1E80, Hi: 0x1E80, Stride: 1},
+ {Lo: 0x1E82, Hi: 0x1E82, Stride: 1},
+ {Lo: 0x1E84, Hi: 0x1E84, Stride: 1},
+ {Lo: 0x1E86, Hi: 0x1E86, Stride: 1},
+ {Lo: 0x1E88, Hi: 0x1E88, Stride: 1},
+ {Lo: 0x1E8A, Hi: 0x1E8A, Stride: 1},
+ {Lo: 0x1E8C, Hi: 0x1E8C, Stride: 1},
+ {Lo: 0x1E8E, Hi: 0x1E8E, Stride: 1},
+ {Lo: 0x1E90, Hi: 0x1E90, Stride: 1},
+ {Lo: 0x1E92, Hi: 0x1E92, Stride: 1},
+ {Lo: 0x1E94, Hi: 0x1E94, Stride: 1},
+ {Lo: 0x1E9E, Hi: 0x1E9E, Stride: 1},
+ {Lo: 0x1EA0, Hi: 0x1EA0, Stride: 1},
+ {Lo: 0x1EA2, Hi: 0x1EA2, Stride: 1},
+ {Lo: 0x1EA4, Hi: 0x1EA4, Stride: 1},
+ {Lo: 0x1EA6, Hi: 0x1EA6, Stride: 1},
+ {Lo: 0x1EA8, Hi: 0x1EA8, Stride: 1},
+ {Lo: 0x1EAA, Hi: 0x1EAA, Stride: 1},
+ {Lo: 0x1EAC, Hi: 0x1EAC, Stride: 1},
+ {Lo: 0x1EAE, Hi: 0x1EAE, Stride: 1},
+ {Lo: 0x1EB0, Hi: 0x1EB0, Stride: 1},
+ {Lo: 0x1EB2, Hi: 0x1EB2, Stride: 1},
+ {Lo: 0x1EB4, Hi: 0x1EB4, Stride: 1},
+ {Lo: 0x1EB6, Hi: 0x1EB6, Stride: 1},
+ {Lo: 0x1EB8, Hi: 0x1EB8, Stride: 1},
+ {Lo: 0x1EBA, Hi: 0x1EBA, Stride: 1},
+ {Lo: 0x1EBC, Hi: 0x1EBC, Stride: 1},
+ {Lo: 0x1EBE, Hi: 0x1EBE, Stride: 1},
+ {Lo: 0x1EC0, Hi: 0x1EC0, Stride: 1},
+ {Lo: 0x1EC2, Hi: 0x1EC2, Stride: 1},
+ {Lo: 0x1EC4, Hi: 0x1EC4, Stride: 1},
+ {Lo: 0x1EC6, Hi: 0x1EC6, Stride: 1},
+ {Lo: 0x1EC8, Hi: 0x1EC8, Stride: 1},
+ {Lo: 0x1ECA, Hi: 0x1ECA, Stride: 1},
+ {Lo: 0x1ECC, Hi: 0x1ECC, Stride: 1},
+ {Lo: 0x1ECE, Hi: 0x1ECE, Stride: 1},
+ {Lo: 0x1ED0, Hi: 0x1ED0, Stride: 1},
+ {Lo: 0x1ED2, Hi: 0x1ED2, Stride: 1},
+ {Lo: 0x1ED4, Hi: 0x1ED4, Stride: 1},
+ {Lo: 0x1ED6, Hi: 0x1ED6, Stride: 1},
+ {Lo: 0x1ED8, Hi: 0x1ED8, Stride: 1},
+ {Lo: 0x1EDA, Hi: 0x1EDA, Stride: 1},
+ {Lo: 0x1EDC, Hi: 0x1EDC, Stride: 1},
+ {Lo: 0x1EDE, Hi: 0x1EDE, Stride: 1},
+ {Lo: 0x1EE0, Hi: 0x1EE0, Stride: 1},
+ {Lo: 0x1EE2, Hi: 0x1EE2, Stride: 1},
+ {Lo: 0x1EE4, Hi: 0x1EE4, Stride: 1},
+ {Lo: 0x1EE6, Hi: 0x1EE6, Stride: 1},
+ {Lo: 0x1EE8, Hi: 0x1EE8, Stride: 1},
+ {Lo: 0x1EEA, Hi: 0x1EEA, Stride: 1},
+ {Lo: 0x1EEC, Hi: 0x1EEC, Stride: 1},
+ {Lo: 0x1EEE, Hi: 0x1EEE, Stride: 1},
+ {Lo: 0x1EF0, Hi: 0x1EF0, Stride: 1},
+ {Lo: 0x1EF2, Hi: 0x1EF2, Stride: 1},
+ {Lo: 0x1EF4, Hi: 0x1EF4, Stride: 1},
+ {Lo: 0x1EF6, Hi: 0x1EF6, Stride: 1},
+ {Lo: 0x1EF8, Hi: 0x1EF8, Stride: 1},
+ {Lo: 0x1EFA, Hi: 0x1EFA, Stride: 1},
+ {Lo: 0x1EFC, Hi: 0x1EFC, Stride: 1},
+ {Lo: 0x1EFE, Hi: 0x1EFE, Stride: 1},
+ {Lo: 0x1F08, Hi: 0x1F0F, Stride: 1},
+ {Lo: 0x1F18, Hi: 0x1F1D, Stride: 1},
+ {Lo: 0x1F28, Hi: 0x1F2F, Stride: 1},
+ {Lo: 0x1F38, Hi: 0x1F3F, Stride: 1},
+ {Lo: 0x1F48, Hi: 0x1F4D, Stride: 1},
+ {Lo: 0x1F59, Hi: 0x1F59, Stride: 1},
+ {Lo: 0x1F5B, Hi: 0x1F5B, Stride: 1},
+ {Lo: 0x1F5D, Hi: 0x1F5D, Stride: 1},
+ {Lo: 0x1F5F, Hi: 0x1F5F, Stride: 1},
+ {Lo: 0x1F68, Hi: 0x1F6F, Stride: 1},
+ {Lo: 0x1F88, Hi: 0x1F8F, Stride: 1},
+ {Lo: 0x1F98, Hi: 0x1F9F, Stride: 1},
+ {Lo: 0x1FA8, Hi: 0x1FAF, Stride: 1},
+ {Lo: 0x1FB8, Hi: 0x1FBC, Stride: 1},
+ {Lo: 0x1FC8, Hi: 0x1FCC, Stride: 1},
+ {Lo: 0x1FD8, Hi: 0x1FDB, Stride: 1},
+ {Lo: 0x1FE8, Hi: 0x1FEC, Stride: 1},
+ {Lo: 0x1FF8, Hi: 0x1FFC, Stride: 1},
+ {Lo: 0x2102, Hi: 0x2102, Stride: 1},
+ {Lo: 0x2107, Hi: 0x2107, Stride: 1},
+ {Lo: 0x210B, Hi: 0x210D, Stride: 1},
+ {Lo: 0x2110, Hi: 0x2112, Stride: 1},
+ {Lo: 0x2115, Hi: 0x2115, Stride: 1},
+ {Lo: 0x2119, Hi: 0x211D, Stride: 1},
+ {Lo: 0x2124, Hi: 0x2124, Stride: 1},
+ {Lo: 0x2126, Hi: 0x2126, Stride: 1},
+ {Lo: 0x2128, Hi: 0x2128, Stride: 1},
+ {Lo: 0x212A, Hi: 0x212D, Stride: 1},
+ {Lo: 0x2130, Hi: 0x2133, Stride: 1},
+ {Lo: 0x213E, Hi: 0x213F, Stride: 1},
+ {Lo: 0x2145, Hi: 0x2145, Stride: 1},
+ {Lo: 0x2160, Hi: 0x216F, Stride: 1},
+ {Lo: 0x2183, Hi: 0x2183, Stride: 1},
+ {Lo: 0x24B6, Hi: 0x24CF, Stride: 1},
+ {Lo: 0x2C00, Hi: 0x2C2F, Stride: 1},
+ {Lo: 0x2C60, Hi: 0x2C60, Stride: 1},
+ {Lo: 0x2C62, Hi: 0x2C64, Stride: 1},
+ {Lo: 0x2C67, Hi: 0x2C67, Stride: 1},
+ {Lo: 0x2C69, Hi: 0x2C69, Stride: 1},
+ {Lo: 0x2C6B, Hi: 0x2C6B, Stride: 1},
+ {Lo: 0x2C6D, Hi: 0x2C70, Stride: 1},
+ {Lo: 0x2C72, Hi: 0x2C72, Stride: 1},
+ {Lo: 0x2C75, Hi: 0x2C75, Stride: 1},
+ {Lo: 0x2C7E, Hi: 0x2C80, Stride: 1},
+ {Lo: 0x2C82, Hi: 0x2C82, Stride: 1},
+ {Lo: 0x2C84, Hi: 0x2C84, Stride: 1},
+ {Lo: 0x2C86, Hi: 0x2C86, Stride: 1},
+ {Lo: 0x2C88, Hi: 0x2C88, Stride: 1},
+ {Lo: 0x2C8A, Hi: 0x2C8A, Stride: 1},
+ {Lo: 0x2C8C, Hi: 0x2C8C, Stride: 1},
+ {Lo: 0x2C8E, Hi: 0x2C8E, Stride: 1},
+ {Lo: 0x2C90, Hi: 0x2C90, Stride: 1},
+ {Lo: 0x2C92, Hi: 0x2C92, Stride: 1},
+ {Lo: 0x2C94, Hi: 0x2C94, Stride: 1},
+ {Lo: 0x2C96, Hi: 0x2C96, Stride: 1},
+ {Lo: 0x2C98, Hi: 0x2C98, Stride: 1},
+ {Lo: 0x2C9A, Hi: 0x2C9A, Stride: 1},
+ {Lo: 0x2C9C, Hi: 0x2C9C, Stride: 1},
+ {Lo: 0x2C9E, Hi: 0x2C9E, Stride: 1},
+ {Lo: 0x2CA0, Hi: 0x2CA0, Stride: 1},
+ {Lo: 0x2CA2, Hi: 0x2CA2, Stride: 1},
+ {Lo: 0x2CA4, Hi: 0x2CA4, Stride: 1},
+ {Lo: 0x2CA6, Hi: 0x2CA6, Stride: 1},
+ {Lo: 0x2CA8, Hi: 0x2CA8, Stride: 1},
+ {Lo: 0x2CAA, Hi: 0x2CAA, Stride: 1},
+ {Lo: 0x2CAC, Hi: 0x2CAC, Stride: 1},
+ {Lo: 0x2CAE, Hi: 0x2CAE, Stride: 1},
+ {Lo: 0x2CB0, Hi: 0x2CB0, Stride: 1},
+ {Lo: 0x2CB2, Hi: 0x2CB2, Stride: 1},
+ {Lo: 0x2CB4, Hi: 0x2CB4, Stride: 1},
+ {Lo: 0x2CB6, Hi: 0x2CB6, Stride: 1},
+ {Lo: 0x2CB8, Hi: 0x2CB8, Stride: 1},
+ {Lo: 0x2CBA, Hi: 0x2CBA, Stride: 1},
+ {Lo: 0x2CBC, Hi: 0x2CBC, Stride: 1},
+ {Lo: 0x2CBE, Hi: 0x2CBE, Stride: 1},
+ {Lo: 0x2CC0, Hi: 0x2CC0, Stride: 1},
+ {Lo: 0x2CC2, Hi: 0x2CC2, Stride: 1},
+ {Lo: 0x2CC4, Hi: 0x2CC4, Stride: 1},
+ {Lo: 0x2CC6, Hi: 0x2CC6, Stride: 1},
+ {Lo: 0x2CC8, Hi: 0x2CC8, Stride: 1},
+ {Lo: 0x2CCA, Hi: 0x2CCA, Stride: 1},
+ {Lo: 0x2CCC, Hi: 0x2CCC, Stride: 1},
+ {Lo: 0x2CCE, Hi: 0x2CCE, Stride: 1},
+ {Lo: 0x2CD0, Hi: 0x2CD0, Stride: 1},
+ {Lo: 0x2CD2, Hi: 0x2CD2, Stride: 1},
+ {Lo: 0x2CD4, Hi: 0x2CD4, Stride: 1},
+ {Lo: 0x2CD6, Hi: 0x2CD6, Stride: 1},
+ {Lo: 0x2CD8, Hi: 0x2CD8, Stride: 1},
+ {Lo: 0x2CDA, Hi: 0x2CDA, Stride: 1},
+ {Lo: 0x2CDC, Hi: 0x2CDC, Stride: 1},
+ {Lo: 0x2CDE, Hi: 0x2CDE, Stride: 1},
+ {Lo: 0x2CE0, Hi: 0x2CE0, Stride: 1},
+ {Lo: 0x2CE2, Hi: 0x2CE2, Stride: 1},
+ {Lo: 0x2CEB, Hi: 0x2CEB, Stride: 1},
+ {Lo: 0x2CED, Hi: 0x2CED, Stride: 1},
+ {Lo: 0x2CF2, Hi: 0x2CF2, Stride: 1},
+ {Lo: 0xA640, Hi: 0xA640, Stride: 1},
+ {Lo: 0xA642, Hi: 0xA642, Stride: 1},
+ {Lo: 0xA644, Hi: 0xA644, Stride: 1},
+ {Lo: 0xA646, Hi: 0xA646, Stride: 1},
+ {Lo: 0xA648, Hi: 0xA648, Stride: 1},
+ {Lo: 0xA64A, Hi: 0xA64A, Stride: 1},
+ {Lo: 0xA64C, Hi: 0xA64C, Stride: 1},
+ {Lo: 0xA64E, Hi: 0xA64E, Stride: 1},
+ {Lo: 0xA650, Hi: 0xA650, Stride: 1},
+ {Lo: 0xA652, Hi: 0xA652, Stride: 1},
+ {Lo: 0xA654, Hi: 0xA654, Stride: 1},
+ {Lo: 0xA656, Hi: 0xA656, Stride: 1},
+ {Lo: 0xA658, Hi: 0xA658, Stride: 1},
+ {Lo: 0xA65A, Hi: 0xA65A, Stride: 1},
+ {Lo: 0xA65C, Hi: 0xA65C, Stride: 1},
+ {Lo: 0xA65E, Hi: 0xA65E, Stride: 1},
+ {Lo: 0xA660, Hi: 0xA660, Stride: 1},
+ {Lo: 0xA662, Hi: 0xA662, Stride: 1},
+ {Lo: 0xA664, Hi: 0xA664, Stride: 1},
+ {Lo: 0xA666, Hi: 0xA666, Stride: 1},
+ {Lo: 0xA668, Hi: 0xA668, Stride: 1},
+ {Lo: 0xA66A, Hi: 0xA66A, Stride: 1},
+ {Lo: 0xA66C, Hi: 0xA66C, Stride: 1},
+ {Lo: 0xA680, Hi: 0xA680, Stride: 1},
+ {Lo: 0xA682, Hi: 0xA682, Stride: 1},
+ {Lo: 0xA684, Hi: 0xA684, Stride: 1},
+ {Lo: 0xA686, Hi: 0xA686, Stride: 1},
+ {Lo: 0xA688, Hi: 0xA688, Stride: 1},
+ {Lo: 0xA68A, Hi: 0xA68A, Stride: 1},
+ {Lo: 0xA68C, Hi: 0xA68C, Stride: 1},
+ {Lo: 0xA68E, Hi: 0xA68E, Stride: 1},
+ {Lo: 0xA690, Hi: 0xA690, Stride: 1},
+ {Lo: 0xA692, Hi: 0xA692, Stride: 1},
+ {Lo: 0xA694, Hi: 0xA694, Stride: 1},
+ {Lo: 0xA696, Hi: 0xA696, Stride: 1},
+ {Lo: 0xA698, Hi: 0xA698, Stride: 1},
+ {Lo: 0xA69A, Hi: 0xA69A, Stride: 1},
+ {Lo: 0xA722, Hi: 0xA722, Stride: 1},
+ {Lo: 0xA724, Hi: 0xA724, Stride: 1},
+ {Lo: 0xA726, Hi: 0xA726, Stride: 1},
+ {Lo: 0xA728, Hi: 0xA728, Stride: 1},
+ {Lo: 0xA72A, Hi: 0xA72A, Stride: 1},
+ {Lo: 0xA72C, Hi: 0xA72C, Stride: 1},
+ {Lo: 0xA72E, Hi: 0xA72E, Stride: 1},
+ {Lo: 0xA732, Hi: 0xA732, Stride: 1},
+ {Lo: 0xA734, Hi: 0xA734, Stride: 1},
+ {Lo: 0xA736, Hi: 0xA736, Stride: 1},
+ {Lo: 0xA738, Hi: 0xA738, Stride: 1},
+ {Lo: 0xA73A, Hi: 0xA73A, Stride: 1},
+ {Lo: 0xA73C, Hi: 0xA73C, Stride: 1},
+ {Lo: 0xA73E, Hi: 0xA73E, Stride: 1},
+ {Lo: 0xA740, Hi: 0xA740, Stride: 1},
+ {Lo: 0xA742, Hi: 0xA742, Stride: 1},
+ {Lo: 0xA744, Hi: 0xA744, Stride: 1},
+ {Lo: 0xA746, Hi: 0xA746, Stride: 1},
+ {Lo: 0xA748, Hi: 0xA748, Stride: 1},
+ {Lo: 0xA74A, Hi: 0xA74A, Stride: 1},
+ {Lo: 0xA74C, Hi: 0xA74C, Stride: 1},
+ {Lo: 0xA74E, Hi: 0xA74E, Stride: 1},
+ {Lo: 0xA750, Hi: 0xA750, Stride: 1},
+ {Lo: 0xA752, Hi: 0xA752, Stride: 1},
+ {Lo: 0xA754, Hi: 0xA754, Stride: 1},
+ {Lo: 0xA756, Hi: 0xA756, Stride: 1},
+ {Lo: 0xA758, Hi: 0xA758, Stride: 1},
+ {Lo: 0xA75A, Hi: 0xA75A, Stride: 1},
+ {Lo: 0xA75C, Hi: 0xA75C, Stride: 1},
+ {Lo: 0xA75E, Hi: 0xA75E, Stride: 1},
+ {Lo: 0xA760, Hi: 0xA760, Stride: 1},
+ {Lo: 0xA762, Hi: 0xA762, Stride: 1},
+ {Lo: 0xA764, Hi: 0xA764, Stride: 1},
+ {Lo: 0xA766, Hi: 0xA766, Stride: 1},
+ {Lo: 0xA768, Hi: 0xA768, Stride: 1},
+ {Lo: 0xA76A, Hi: 0xA76A, Stride: 1},
+ {Lo: 0xA76C, Hi: 0xA76C, Stride: 1},
+ {Lo: 0xA76E, Hi: 0xA76E, Stride: 1},
+ {Lo: 0xA779, Hi: 0xA779, Stride: 1},
+ {Lo: 0xA77B, Hi: 0xA77B, Stride: 1},
+ {Lo: 0xA77D, Hi: 0xA77E, Stride: 1},
+ {Lo: 0xA780, Hi: 0xA780, Stride: 1},
+ {Lo: 0xA782, Hi: 0xA782, Stride: 1},
+ {Lo: 0xA784, Hi: 0xA784, Stride: 1},
+ {Lo: 0xA786, Hi: 0xA786, Stride: 1},
+ {Lo: 0xA78B, Hi: 0xA78B, Stride: 1},
+ {Lo: 0xA78D, Hi: 0xA78D, Stride: 1},
+ {Lo: 0xA790, Hi: 0xA790, Stride: 1},
+ {Lo: 0xA792, Hi: 0xA792, Stride: 1},
+ {Lo: 0xA796, Hi: 0xA796, Stride: 1},
+ {Lo: 0xA798, Hi: 0xA798, Stride: 1},
+ {Lo: 0xA79A, Hi: 0xA79A, Stride: 1},
+ {Lo: 0xA79C, Hi: 0xA79C, Stride: 1},
+ {Lo: 0xA79E, Hi: 0xA79E, Stride: 1},
+ {Lo: 0xA7A0, Hi: 0xA7A0, Stride: 1},
+ {Lo: 0xA7A2, Hi: 0xA7A2, Stride: 1},
+ {Lo: 0xA7A4, Hi: 0xA7A4, Stride: 1},
+ {Lo: 0xA7A6, Hi: 0xA7A6, Stride: 1},
+ {Lo: 0xA7A8, Hi: 0xA7A8, Stride: 1},
+ {Lo: 0xA7AA, Hi: 0xA7AE, Stride: 1},
+ {Lo: 0xA7B0, Hi: 0xA7B4, Stride: 1},
+ {Lo: 0xA7B6, Hi: 0xA7B6, Stride: 1},
+ {Lo: 0xA7B8, Hi: 0xA7B8, Stride: 1},
+ {Lo: 0xA7BA, Hi: 0xA7BA, Stride: 1},
+ {Lo: 0xA7BC, Hi: 0xA7BC, Stride: 1},
+ {Lo: 0xA7BE, Hi: 0xA7BE, Stride: 1},
+ {Lo: 0xA7C0, Hi: 0xA7C0, Stride: 1},
+ {Lo: 0xA7C2, Hi: 0xA7C2, Stride: 1},
+ {Lo: 0xA7C4, Hi: 0xA7C7, Stride: 1},
+ {Lo: 0xA7C9, Hi: 0xA7C9, Stride: 1},
+ {Lo: 0xA7CB, Hi: 0xA7CC, Stride: 1},
+ {Lo: 0xA7CE, Hi: 0xA7CE, Stride: 1},
+ {Lo: 0xA7D0, Hi: 0xA7D0, Stride: 1},
+ {Lo: 0xA7D2, Hi: 0xA7D2, Stride: 1},
+ {Lo: 0xA7D4, Hi: 0xA7D4, Stride: 1},
+ {Lo: 0xA7D6, Hi: 0xA7D6, Stride: 1},
+ {Lo: 0xA7D8, Hi: 0xA7D8, Stride: 1},
+ {Lo: 0xA7DA, Hi: 0xA7DA, Stride: 1},
+ {Lo: 0xA7DC, Hi: 0xA7DC, Stride: 1},
+ {Lo: 0xA7F5, Hi: 0xA7F5, Stride: 1},
+ {Lo: 0xFF21, Hi: 0xFF3A, Stride: 1},
+ },
+ R32: []unicode.Range32{
+ {Lo: 0x10400, Hi: 0x10427, Stride: 1},
+ {Lo: 0x104B0, Hi: 0x104D3, Stride: 1},
+ {Lo: 0x10570, Hi: 0x1057A, Stride: 1},
+ {Lo: 0x1057C, Hi: 0x1058A, Stride: 1},
+ {Lo: 0x1058C, Hi: 0x10592, Stride: 1},
+ {Lo: 0x10594, Hi: 0x10595, Stride: 1},
+ {Lo: 0x10C80, Hi: 0x10CB2, Stride: 1},
+ {Lo: 0x10D50, Hi: 0x10D65, Stride: 1},
+ {Lo: 0x118A0, Hi: 0x118BF, Stride: 1},
+ {Lo: 0x16E40, Hi: 0x16E5F, Stride: 1},
+ {Lo: 0x16EA0, Hi: 0x16EB8, Stride: 1},
+ {Lo: 0x1D400, Hi: 0x1D419, Stride: 1},
+ {Lo: 0x1D434, Hi: 0x1D44D, Stride: 1},
+ {Lo: 0x1D468, Hi: 0x1D481, Stride: 1},
+ {Lo: 0x1D49C, Hi: 0x1D49C, Stride: 1},
+ {Lo: 0x1D49E, Hi: 0x1D49F, Stride: 1},
+ {Lo: 0x1D4A2, Hi: 0x1D4A2, Stride: 1},
+ {Lo: 0x1D4A5, Hi: 0x1D4A6, Stride: 1},
+ {Lo: 0x1D4A9, Hi: 0x1D4AC, Stride: 1},
+ {Lo: 0x1D4AE, Hi: 0x1D4B5, Stride: 1},
+ {Lo: 0x1D4D0, Hi: 0x1D4E9, Stride: 1},
+ {Lo: 0x1D504, Hi: 0x1D505, Stride: 1},
+ {Lo: 0x1D507, Hi: 0x1D50A, Stride: 1},
+ {Lo: 0x1D50D, Hi: 0x1D514, Stride: 1},
+ {Lo: 0x1D516, Hi: 0x1D51C, Stride: 1},
+ {Lo: 0x1D538, Hi: 0x1D539, Stride: 1},
+ {Lo: 0x1D53B, Hi: 0x1D53E, Stride: 1},
+ {Lo: 0x1D540, Hi: 0x1D544, Stride: 1},
+ {Lo: 0x1D546, Hi: 0x1D546, Stride: 1},
+ {Lo: 0x1D54A, Hi: 0x1D550, Stride: 1},
+ {Lo: 0x1D56C, Hi: 0x1D585, Stride: 1},
+ {Lo: 0x1D5A0, Hi: 0x1D5B9, Stride: 1},
+ {Lo: 0x1D5D4, Hi: 0x1D5ED, Stride: 1},
+ {Lo: 0x1D608, Hi: 0x1D621, Stride: 1},
+ {Lo: 0x1D63C, Hi: 0x1D655, Stride: 1},
+ {Lo: 0x1D670, Hi: 0x1D689, Stride: 1},
+ {Lo: 0x1D6A8, Hi: 0x1D6C0, Stride: 1},
+ {Lo: 0x1D6E2, Hi: 0x1D6FA, Stride: 1},
+ {Lo: 0x1D71C, Hi: 0x1D734, Stride: 1},
+ {Lo: 0x1D756, Hi: 0x1D76E, Stride: 1},
+ {Lo: 0x1D790, Hi: 0x1D7A8, Stride: 1},
+ {Lo: 0x1D7CA, Hi: 0x1D7CA, Stride: 1},
+ {Lo: 0x1E900, Hi: 0x1E921, Stride: 1},
+ {Lo: 0x1F130, Hi: 0x1F149, Stride: 1},
+ {Lo: 0x1F150, Hi: 0x1F169, Stride: 1},
+ {Lo: 0x1F170, Hi: 0x1F189, Stride: 1},
+ },
+}
+
+var unicodeAliasWord_Break_ALetter = &unicode.RangeTable{
+ R16: []unicode.Range16{
+ {Lo: 0x41, Hi: 0x5A, Stride: 1},
+ {Lo: 0x61, Hi: 0x7A, Stride: 1},
+ {Lo: 0xAA, Hi: 0xAA, Stride: 1},
+ {Lo: 0xB5, Hi: 0xB5, Stride: 1},
+ {Lo: 0xB8, Hi: 0xB8, Stride: 1},
+ {Lo: 0xBA, Hi: 0xBA, Stride: 1},
+ {Lo: 0xC0, Hi: 0xD6, Stride: 1},
+ {Lo: 0xD8, Hi: 0xF6, Stride: 1},
+ {Lo: 0xF8, Hi: 0x2D7, Stride: 1},
+ {Lo: 0x2DE, Hi: 0x2FF, Stride: 1},
+ {Lo: 0x370, Hi: 0x374, Stride: 1},
+ {Lo: 0x376, Hi: 0x377, Stride: 1},
+ {Lo: 0x37A, Hi: 0x37D, Stride: 1},
+ {Lo: 0x37F, Hi: 0x37F, Stride: 1},
+ {Lo: 0x386, Hi: 0x386, Stride: 1},
+ {Lo: 0x388, Hi: 0x38A, Stride: 1},
+ {Lo: 0x38C, Hi: 0x38C, Stride: 1},
+ {Lo: 0x38E, Hi: 0x3A1, Stride: 1},
+ {Lo: 0x3A3, Hi: 0x3F5, Stride: 1},
+ {Lo: 0x3F7, Hi: 0x481, Stride: 1},
+ {Lo: 0x48A, Hi: 0x52F, Stride: 1},
+ {Lo: 0x531, Hi: 0x556, Stride: 1},
+ {Lo: 0x559, Hi: 0x55C, Stride: 1},
+ {Lo: 0x55E, Hi: 0x55E, Stride: 1},
+ {Lo: 0x560, Hi: 0x588, Stride: 1},
+ {Lo: 0x58A, Hi: 0x58A, Stride: 1},
+ {Lo: 0x5F3, Hi: 0x5F3, Stride: 1},
+ {Lo: 0x620, Hi: 0x64A, Stride: 1},
+ {Lo: 0x66E, Hi: 0x66F, Stride: 1},
+ {Lo: 0x671, Hi: 0x6D3, Stride: 1},
+ {Lo: 0x6D5, Hi: 0x6D5, Stride: 1},
+ {Lo: 0x6E5, Hi: 0x6E6, Stride: 1},
+ {Lo: 0x6EE, Hi: 0x6EF, Stride: 1},
+ {Lo: 0x6FA, Hi: 0x6FC, Stride: 1},
+ {Lo: 0x6FF, Hi: 0x6FF, Stride: 1},
+ {Lo: 0x70F, Hi: 0x710, Stride: 1},
+ {Lo: 0x712, Hi: 0x72F, Stride: 1},
+ {Lo: 0x74D, Hi: 0x7A5, Stride: 1},
+ {Lo: 0x7B1, Hi: 0x7B1, Stride: 1},
+ {Lo: 0x7CA, Hi: 0x7EA, Stride: 1},
+ {Lo: 0x7F4, Hi: 0x7F5, Stride: 1},
+ {Lo: 0x7FA, Hi: 0x7FA, Stride: 1},
+ {Lo: 0x800, Hi: 0x815, Stride: 1},
+ {Lo: 0x81A, Hi: 0x81A, Stride: 1},
+ {Lo: 0x824, Hi: 0x824, Stride: 1},
+ {Lo: 0x828, Hi: 0x828, Stride: 1},
+ {Lo: 0x840, Hi: 0x858, Stride: 1},
+ {Lo: 0x860, Hi: 0x86A, Stride: 1},
+ {Lo: 0x870, Hi: 0x887, Stride: 1},
+ {Lo: 0x889, Hi: 0x88F, Stride: 1},
+ {Lo: 0x8A0, Hi: 0x8C9, Stride: 1},
+ {Lo: 0x904, Hi: 0x939, Stride: 1},
+ {Lo: 0x93D, Hi: 0x93D, Stride: 1},
+ {Lo: 0x950, Hi: 0x950, Stride: 1},
+ {Lo: 0x958, Hi: 0x961, Stride: 1},
+ {Lo: 0x971, Hi: 0x980, Stride: 1},
+ {Lo: 0x985, Hi: 0x98C, Stride: 1},
+ {Lo: 0x98F, Hi: 0x990, Stride: 1},
+ {Lo: 0x993, Hi: 0x9A8, Stride: 1},
+ {Lo: 0x9AA, Hi: 0x9B0, Stride: 1},
+ {Lo: 0x9B2, Hi: 0x9B2, Stride: 1},
+ {Lo: 0x9B6, Hi: 0x9B9, Stride: 1},
+ {Lo: 0x9BD, Hi: 0x9BD, Stride: 1},
+ {Lo: 0x9CE, Hi: 0x9CE, Stride: 1},
+ {Lo: 0x9DC, Hi: 0x9DD, Stride: 1},
+ {Lo: 0x9DF, Hi: 0x9E1, Stride: 1},
+ {Lo: 0x9F0, Hi: 0x9F1, Stride: 1},
+ {Lo: 0x9FC, Hi: 0x9FC, Stride: 1},
+ {Lo: 0xA05, Hi: 0xA0A, Stride: 1},
+ {Lo: 0xA0F, Hi: 0xA10, Stride: 1},
+ {Lo: 0xA13, Hi: 0xA28, Stride: 1},
+ {Lo: 0xA2A, Hi: 0xA30, Stride: 1},
+ {Lo: 0xA32, Hi: 0xA33, Stride: 1},
+ {Lo: 0xA35, Hi: 0xA36, Stride: 1},
+ {Lo: 0xA38, Hi: 0xA39, Stride: 1},
+ {Lo: 0xA59, Hi: 0xA5C, Stride: 1},
+ {Lo: 0xA5E, Hi: 0xA5E, Stride: 1},
+ {Lo: 0xA72, Hi: 0xA74, Stride: 1},
+ {Lo: 0xA85, Hi: 0xA8D, Stride: 1},
+ {Lo: 0xA8F, Hi: 0xA91, Stride: 1},
+ {Lo: 0xA93, Hi: 0xAA8, Stride: 1},
+ {Lo: 0xAAA, Hi: 0xAB0, Stride: 1},
+ {Lo: 0xAB2, Hi: 0xAB3, Stride: 1},
+ {Lo: 0xAB5, Hi: 0xAB9, Stride: 1},
+ {Lo: 0xABD, Hi: 0xABD, Stride: 1},
+ {Lo: 0xAD0, Hi: 0xAD0, Stride: 1},
+ {Lo: 0xAE0, Hi: 0xAE1, Stride: 1},
+ {Lo: 0xAF9, Hi: 0xAF9, Stride: 1},
+ {Lo: 0xB05, Hi: 0xB0C, Stride: 1},
+ {Lo: 0xB0F, Hi: 0xB10, Stride: 1},
+ {Lo: 0xB13, Hi: 0xB28, Stride: 1},
+ {Lo: 0xB2A, Hi: 0xB30, Stride: 1},
+ {Lo: 0xB32, Hi: 0xB33, Stride: 1},
+ {Lo: 0xB35, Hi: 0xB39, Stride: 1},
+ {Lo: 0xB3D, Hi: 0xB3D, Stride: 1},
+ {Lo: 0xB5C, Hi: 0xB5D, Stride: 1},
+ {Lo: 0xB5F, Hi: 0xB61, Stride: 1},
+ {Lo: 0xB71, Hi: 0xB71, Stride: 1},
+ {Lo: 0xB83, Hi: 0xB83, Stride: 1},
+ {Lo: 0xB85, Hi: 0xB8A, Stride: 1},
+ {Lo: 0xB8E, Hi: 0xB90, Stride: 1},
+ {Lo: 0xB92, Hi: 0xB95, Stride: 1},
+ {Lo: 0xB99, Hi: 0xB9A, Stride: 1},
+ {Lo: 0xB9C, Hi: 0xB9C, Stride: 1},
+ {Lo: 0xB9E, Hi: 0xB9F, Stride: 1},
+ {Lo: 0xBA3, Hi: 0xBA4, Stride: 1},
+ {Lo: 0xBA8, Hi: 0xBAA, Stride: 1},
+ {Lo: 0xBAE, Hi: 0xBB9, Stride: 1},
+ {Lo: 0xBD0, Hi: 0xBD0, Stride: 1},
+ {Lo: 0xC05, Hi: 0xC0C, Stride: 1},
+ {Lo: 0xC0E, Hi: 0xC10, Stride: 1},
+ {Lo: 0xC12, Hi: 0xC28, Stride: 1},
+ {Lo: 0xC2A, Hi: 0xC39, Stride: 1},
+ {Lo: 0xC3D, Hi: 0xC3D, Stride: 1},
+ {Lo: 0xC58, Hi: 0xC5A, Stride: 1},
+ {Lo: 0xC5C, Hi: 0xC5D, Stride: 1},
+ {Lo: 0xC60, Hi: 0xC61, Stride: 1},
+ {Lo: 0xC80, Hi: 0xC80, Stride: 1},
+ {Lo: 0xC85, Hi: 0xC8C, Stride: 1},
+ {Lo: 0xC8E, Hi: 0xC90, Stride: 1},
+ {Lo: 0xC92, Hi: 0xCA8, Stride: 1},
+ {Lo: 0xCAA, Hi: 0xCB3, Stride: 1},
+ {Lo: 0xCB5, Hi: 0xCB9, Stride: 1},
+ {Lo: 0xCBD, Hi: 0xCBD, Stride: 1},
+ {Lo: 0xCDC, Hi: 0xCDE, Stride: 1},
+ {Lo: 0xCE0, Hi: 0xCE1, Stride: 1},
+ {Lo: 0xCF1, Hi: 0xCF2, Stride: 1},
+ {Lo: 0xD04, Hi: 0xD0C, Stride: 1},
+ {Lo: 0xD0E, Hi: 0xD10, Stride: 1},
+ {Lo: 0xD12, Hi: 0xD3A, Stride: 1},
+ {Lo: 0xD3D, Hi: 0xD3D, Stride: 1},
+ {Lo: 0xD4E, Hi: 0xD4E, Stride: 1},
+ {Lo: 0xD54, Hi: 0xD56, Stride: 1},
+ {Lo: 0xD5F, Hi: 0xD61, Stride: 1},
+ {Lo: 0xD7A, Hi: 0xD7F, Stride: 1},
+ {Lo: 0xD85, Hi: 0xD96, Stride: 1},
+ {Lo: 0xD9A, Hi: 0xDB1, Stride: 1},
+ {Lo: 0xDB3, Hi: 0xDBB, Stride: 1},
+ {Lo: 0xDBD, Hi: 0xDBD, Stride: 1},
+ {Lo: 0xDC0, Hi: 0xDC6, Stride: 1},
+ {Lo: 0xF00, Hi: 0xF00, Stride: 1},
+ {Lo: 0xF40, Hi: 0xF47, Stride: 1},
+ {Lo: 0xF49, Hi: 0xF6C, Stride: 1},
+ {Lo: 0xF88, Hi: 0xF8C, Stride: 1},
+ {Lo: 0x10A0, Hi: 0x10C5, Stride: 1},
+ {Lo: 0x10C7, Hi: 0x10C7, Stride: 1},
+ {Lo: 0x10CD, Hi: 0x10CD, Stride: 1},
+ {Lo: 0x10D0, Hi: 0x10FA, Stride: 1},
+ {Lo: 0x10FC, Hi: 0x1248, Stride: 1},
+ {Lo: 0x124A, Hi: 0x124D, Stride: 1},
+ {Lo: 0x1250, Hi: 0x1256, Stride: 1},
+ {Lo: 0x1258, Hi: 0x1258, Stride: 1},
+ {Lo: 0x125A, Hi: 0x125D, Stride: 1},
+ {Lo: 0x1260, Hi: 0x1288, Stride: 1},
+ {Lo: 0x128A, Hi: 0x128D, Stride: 1},
+ {Lo: 0x1290, Hi: 0x12B0, Stride: 1},
+ {Lo: 0x12B2, Hi: 0x12B5, Stride: 1},
+ {Lo: 0x12B8, Hi: 0x12BE, Stride: 1},
+ {Lo: 0x12C0, Hi: 0x12C0, Stride: 1},
+ {Lo: 0x12C2, Hi: 0x12C5, Stride: 1},
+ {Lo: 0x12C8, Hi: 0x12D6, Stride: 1},
+ {Lo: 0x12D8, Hi: 0x1310, Stride: 1},
+ {Lo: 0x1312, Hi: 0x1315, Stride: 1},
+ {Lo: 0x1318, Hi: 0x135A, Stride: 1},
+ {Lo: 0x1380, Hi: 0x138F, Stride: 1},
+ {Lo: 0x13A0, Hi: 0x13F5, Stride: 1},
+ {Lo: 0x13F8, Hi: 0x13FD, Stride: 1},
+ {Lo: 0x1401, Hi: 0x166C, Stride: 1},
+ {Lo: 0x166F, Hi: 0x167F, Stride: 1},
+ {Lo: 0x1681, Hi: 0x169A, Stride: 1},
+ {Lo: 0x16A0, Hi: 0x16EA, Stride: 1},
+ {Lo: 0x16EE, Hi: 0x16F8, Stride: 1},
+ {Lo: 0x1700, Hi: 0x1711, Stride: 1},
+ {Lo: 0x171F, Hi: 0x1731, Stride: 1},
+ {Lo: 0x1740, Hi: 0x1751, Stride: 1},
+ {Lo: 0x1760, Hi: 0x176C, Stride: 1},
+ {Lo: 0x176E, Hi: 0x1770, Stride: 1},
+ {Lo: 0x1820, Hi: 0x1878, Stride: 1},
+ {Lo: 0x1880, Hi: 0x1884, Stride: 1},
+ {Lo: 0x1887, Hi: 0x18A8, Stride: 1},
+ {Lo: 0x18AA, Hi: 0x18AA, Stride: 1},
+ {Lo: 0x18B0, Hi: 0x18F5, Stride: 1},
+ {Lo: 0x1900, Hi: 0x191E, Stride: 1},
+ {Lo: 0x1A00, Hi: 0x1A16, Stride: 1},
+ {Lo: 0x1B05, Hi: 0x1B33, Stride: 1},
+ {Lo: 0x1B45, Hi: 0x1B4C, Stride: 1},
+ {Lo: 0x1B83, Hi: 0x1BA0, Stride: 1},
+ {Lo: 0x1BAE, Hi: 0x1BAF, Stride: 1},
+ {Lo: 0x1BBA, Hi: 0x1BE5, Stride: 1},
+ {Lo: 0x1C00, Hi: 0x1C23, Stride: 1},
+ {Lo: 0x1C4D, Hi: 0x1C4F, Stride: 1},
+ {Lo: 0x1C5A, Hi: 0x1C7D, Stride: 1},
+ {Lo: 0x1C80, Hi: 0x1C8A, Stride: 1},
+ {Lo: 0x1C90, Hi: 0x1CBA, Stride: 1},
+ {Lo: 0x1CBD, Hi: 0x1CBF, Stride: 1},
+ {Lo: 0x1CE9, Hi: 0x1CEC, Stride: 1},
+ {Lo: 0x1CEE, Hi: 0x1CF3, Stride: 1},
+ {Lo: 0x1CF5, Hi: 0x1CF6, Stride: 1},
+ {Lo: 0x1CFA, Hi: 0x1CFA, Stride: 1},
+ {Lo: 0x1D00, Hi: 0x1DBF, Stride: 1},
+ {Lo: 0x1E00, Hi: 0x1F15, Stride: 1},
+ {Lo: 0x1F18, Hi: 0x1F1D, Stride: 1},
+ {Lo: 0x1F20, Hi: 0x1F45, Stride: 1},
+ {Lo: 0x1F48, Hi: 0x1F4D, Stride: 1},
+ {Lo: 0x1F50, Hi: 0x1F57, Stride: 1},
+ {Lo: 0x1F59, Hi: 0x1F59, Stride: 1},
+ {Lo: 0x1F5B, Hi: 0x1F5B, Stride: 1},
+ {Lo: 0x1F5D, Hi: 0x1F5D, Stride: 1},
+ {Lo: 0x1F5F, Hi: 0x1F7D, Stride: 1},
+ {Lo: 0x1F80, Hi: 0x1FB4, Stride: 1},
+ {Lo: 0x1FB6, Hi: 0x1FBC, Stride: 1},
+ {Lo: 0x1FBE, Hi: 0x1FBE, Stride: 1},
+ {Lo: 0x1FC2, Hi: 0x1FC4, Stride: 1},
+ {Lo: 0x1FC6, Hi: 0x1FCC, Stride: 1},
+ {Lo: 0x1FD0, Hi: 0x1FD3, Stride: 1},
+ {Lo: 0x1FD6, Hi: 0x1FDB, Stride: 1},
+ {Lo: 0x1FE0, Hi: 0x1FEC, Stride: 1},
+ {Lo: 0x1FF2, Hi: 0x1FF4, Stride: 1},
+ {Lo: 0x1FF6, Hi: 0x1FFC, Stride: 1},
+ {Lo: 0x2071, Hi: 0x2071, Stride: 1},
+ {Lo: 0x207F, Hi: 0x207F, Stride: 1},
+ {Lo: 0x2090, Hi: 0x209C, Stride: 1},
+ {Lo: 0x2102, Hi: 0x2102, Stride: 1},
+ {Lo: 0x2107, Hi: 0x2107, Stride: 1},
+ {Lo: 0x210A, Hi: 0x2113, Stride: 1},
+ {Lo: 0x2115, Hi: 0x2115, Stride: 1},
+ {Lo: 0x2119, Hi: 0x211D, Stride: 1},
+ {Lo: 0x2124, Hi: 0x2124, Stride: 1},
+ {Lo: 0x2126, Hi: 0x2126, Stride: 1},
+ {Lo: 0x2128, Hi: 0x2128, Stride: 1},
+ {Lo: 0x212A, Hi: 0x212D, Stride: 1},
+ {Lo: 0x212F, Hi: 0x2139, Stride: 1},
+ {Lo: 0x213C, Hi: 0x213F, Stride: 1},
+ {Lo: 0x2145, Hi: 0x2149, Stride: 1},
+ {Lo: 0x214E, Hi: 0x214E, Stride: 1},
+ {Lo: 0x2160, Hi: 0x2188, Stride: 1},
+ {Lo: 0x24B6, Hi: 0x24E9, Stride: 1},
+ {Lo: 0x2C00, Hi: 0x2CE4, Stride: 1},
+ {Lo: 0x2CEB, Hi: 0x2CEE, Stride: 1},
+ {Lo: 0x2CF2, Hi: 0x2CF3, Stride: 1},
+ {Lo: 0x2D00, Hi: 0x2D25, Stride: 1},
+ {Lo: 0x2D27, Hi: 0x2D27, Stride: 1},
+ {Lo: 0x2D2D, Hi: 0x2D2D, Stride: 1},
+ {Lo: 0x2D30, Hi: 0x2D67, Stride: 1},
+ {Lo: 0x2D6F, Hi: 0x2D6F, Stride: 1},
+ {Lo: 0x2D80, Hi: 0x2D96, Stride: 1},
+ {Lo: 0x2DA0, Hi: 0x2DA6, Stride: 1},
+ {Lo: 0x2DA8, Hi: 0x2DAE, Stride: 1},
+ {Lo: 0x2DB0, Hi: 0x2DB6, Stride: 1},
+ {Lo: 0x2DB8, Hi: 0x2DBE, Stride: 1},
+ {Lo: 0x2DC0, Hi: 0x2DC6, Stride: 1},
+ {Lo: 0x2DC8, Hi: 0x2DCE, Stride: 1},
+ {Lo: 0x2DD0, Hi: 0x2DD6, Stride: 1},
+ {Lo: 0x2DD8, Hi: 0x2DDE, Stride: 1},
+ {Lo: 0x2E2F, Hi: 0x2E2F, Stride: 1},
+ {Lo: 0x3005, Hi: 0x3005, Stride: 1},
+ {Lo: 0x303B, Hi: 0x303C, Stride: 1},
+ {Lo: 0x3105, Hi: 0x312F, Stride: 1},
+ {Lo: 0x3131, Hi: 0x318E, Stride: 1},
+ {Lo: 0x31A0, Hi: 0x31BF, Stride: 1},
+ {Lo: 0xA000, Hi: 0xA48C, Stride: 1},
+ {Lo: 0xA4D0, Hi: 0xA4FD, Stride: 1},
+ {Lo: 0xA500, Hi: 0xA60C, Stride: 1},
+ {Lo: 0xA610, Hi: 0xA61F, Stride: 1},
+ {Lo: 0xA62A, Hi: 0xA62B, Stride: 1},
+ {Lo: 0xA640, Hi: 0xA66E, Stride: 1},
+ {Lo: 0xA67F, Hi: 0xA69D, Stride: 1},
+ {Lo: 0xA6A0, Hi: 0xA6EF, Stride: 1},
+ {Lo: 0xA708, Hi: 0xA7DC, Stride: 1},
+ {Lo: 0xA7F1, Hi: 0xA801, Stride: 1},
+ {Lo: 0xA803, Hi: 0xA805, Stride: 1},
+ {Lo: 0xA807, Hi: 0xA80A, Stride: 1},
+ {Lo: 0xA80C, Hi: 0xA822, Stride: 1},
+ {Lo: 0xA840, Hi: 0xA873, Stride: 1},
+ {Lo: 0xA882, Hi: 0xA8B3, Stride: 1},
+ {Lo: 0xA8F2, Hi: 0xA8F7, Stride: 1},
+ {Lo: 0xA8FB, Hi: 0xA8FB, Stride: 1},
+ {Lo: 0xA8FD, Hi: 0xA8FE, Stride: 1},
+ {Lo: 0xA90A, Hi: 0xA925, Stride: 1},
+ {Lo: 0xA930, Hi: 0xA946, Stride: 1},
+ {Lo: 0xA960, Hi: 0xA97C, Stride: 1},
+ {Lo: 0xA984, Hi: 0xA9B2, Stride: 1},
+ {Lo: 0xA9CF, Hi: 0xA9CF, Stride: 1},
+ {Lo: 0xAA00, Hi: 0xAA28, Stride: 1},
+ {Lo: 0xAA40, Hi: 0xAA42, Stride: 1},
+ {Lo: 0xAA44, Hi: 0xAA4B, Stride: 1},
+ {Lo: 0xAAE0, Hi: 0xAAEA, Stride: 1},
+ {Lo: 0xAAF2, Hi: 0xAAF4, Stride: 1},
+ {Lo: 0xAB01, Hi: 0xAB06, Stride: 1},
+ {Lo: 0xAB09, Hi: 0xAB0E, Stride: 1},
+ {Lo: 0xAB11, Hi: 0xAB16, Stride: 1},
+ {Lo: 0xAB20, Hi: 0xAB26, Stride: 1},
+ {Lo: 0xAB28, Hi: 0xAB2E, Stride: 1},
+ {Lo: 0xAB30, Hi: 0xAB69, Stride: 1},
+ {Lo: 0xAB70, Hi: 0xABE2, Stride: 1},
+ {Lo: 0xAC00, Hi: 0xD7A3, Stride: 1},
+ {Lo: 0xD7B0, Hi: 0xD7C6, Stride: 1},
+ {Lo: 0xD7CB, Hi: 0xD7FB, Stride: 1},
+ {Lo: 0xFB00, Hi: 0xFB06, Stride: 1},
+ {Lo: 0xFB13, Hi: 0xFB17, Stride: 1},
+ {Lo: 0xFB50, Hi: 0xFBB1, Stride: 1},
+ {Lo: 0xFBD3, Hi: 0xFD3D, Stride: 1},
+ {Lo: 0xFD50, Hi: 0xFD8F, Stride: 1},
+ {Lo: 0xFD92, Hi: 0xFDC7, Stride: 1},
+ {Lo: 0xFDF0, Hi: 0xFDFB, Stride: 1},
+ {Lo: 0xFE70, Hi: 0xFE74, Stride: 1},
+ {Lo: 0xFE76, Hi: 0xFEFC, Stride: 1},
+ {Lo: 0xFF21, Hi: 0xFF3A, Stride: 1},
+ {Lo: 0xFF41, Hi: 0xFF5A, Stride: 1},
+ {Lo: 0xFFA0, Hi: 0xFFBE, Stride: 1},
+ {Lo: 0xFFC2, Hi: 0xFFC7, Stride: 1},
+ {Lo: 0xFFCA, Hi: 0xFFCF, Stride: 1},
+ {Lo: 0xFFD2, Hi: 0xFFD7, Stride: 1},
+ {Lo: 0xFFDA, Hi: 0xFFDC, Stride: 1},
+ },
+ R32: []unicode.Range32{
+ {Lo: 0x10000, Hi: 0x1000B, Stride: 1},
+ {Lo: 0x1000D, Hi: 0x10026, Stride: 1},
+ {Lo: 0x10028, Hi: 0x1003A, Stride: 1},
+ {Lo: 0x1003C, Hi: 0x1003D, Stride: 1},
+ {Lo: 0x1003F, Hi: 0x1004D, Stride: 1},
+ {Lo: 0x10050, Hi: 0x1005D, Stride: 1},
+ {Lo: 0x10080, Hi: 0x100FA, Stride: 1},
+ {Lo: 0x10140, Hi: 0x10174, Stride: 1},
+ {Lo: 0x10280, Hi: 0x1029C, Stride: 1},
+ {Lo: 0x102A0, Hi: 0x102D0, Stride: 1},
+ {Lo: 0x10300, Hi: 0x1031F, Stride: 1},
+ {Lo: 0x1032D, Hi: 0x1034A, Stride: 1},
+ {Lo: 0x10350, Hi: 0x10375, Stride: 1},
+ {Lo: 0x10380, Hi: 0x1039D, Stride: 1},
+ {Lo: 0x103A0, Hi: 0x103C3, Stride: 1},
+ {Lo: 0x103C8, Hi: 0x103CF, Stride: 1},
+ {Lo: 0x103D1, Hi: 0x103D5, Stride: 1},
+ {Lo: 0x10400, Hi: 0x1049D, Stride: 1},
+ {Lo: 0x104B0, Hi: 0x104D3, Stride: 1},
+ {Lo: 0x104D8, Hi: 0x104FB, Stride: 1},
+ {Lo: 0x10500, Hi: 0x10527, Stride: 1},
+ {Lo: 0x10530, Hi: 0x10563, Stride: 1},
+ {Lo: 0x10570, Hi: 0x1057A, Stride: 1},
+ {Lo: 0x1057C, Hi: 0x1058A, Stride: 1},
+ {Lo: 0x1058C, Hi: 0x10592, Stride: 1},
+ {Lo: 0x10594, Hi: 0x10595, Stride: 1},
+ {Lo: 0x10597, Hi: 0x105A1, Stride: 1},
+ {Lo: 0x105A3, Hi: 0x105B1, Stride: 1},
+ {Lo: 0x105B3, Hi: 0x105B9, Stride: 1},
+ {Lo: 0x105BB, Hi: 0x105BC, Stride: 1},
+ {Lo: 0x105C0, Hi: 0x105F3, Stride: 1},
+ {Lo: 0x10600, Hi: 0x10736, Stride: 1},
+ {Lo: 0x10740, Hi: 0x10755, Stride: 1},
+ {Lo: 0x10760, Hi: 0x10767, Stride: 1},
+ {Lo: 0x10780, Hi: 0x10785, Stride: 1},
+ {Lo: 0x10787, Hi: 0x107B0, Stride: 1},
+ {Lo: 0x107B2, Hi: 0x107BA, Stride: 1},
+ {Lo: 0x10800, Hi: 0x10805, Stride: 1},
+ {Lo: 0x10808, Hi: 0x10808, Stride: 1},
+ {Lo: 0x1080A, Hi: 0x10835, Stride: 1},
+ {Lo: 0x10837, Hi: 0x10838, Stride: 1},
+ {Lo: 0x1083C, Hi: 0x1083C, Stride: 1},
+ {Lo: 0x1083F, Hi: 0x10855, Stride: 1},
+ {Lo: 0x10860, Hi: 0x10876, Stride: 1},
+ {Lo: 0x10880, Hi: 0x1089E, Stride: 1},
+ {Lo: 0x108E0, Hi: 0x108F2, Stride: 1},
+ {Lo: 0x108F4, Hi: 0x108F5, Stride: 1},
+ {Lo: 0x10900, Hi: 0x10915, Stride: 1},
+ {Lo: 0x10920, Hi: 0x10939, Stride: 1},
+ {Lo: 0x10940, Hi: 0x10959, Stride: 1},
+ {Lo: 0x10980, Hi: 0x109B7, Stride: 1},
+ {Lo: 0x109BE, Hi: 0x109BF, Stride: 1},
+ {Lo: 0x10A00, Hi: 0x10A00, Stride: 1},
+ {Lo: 0x10A10, Hi: 0x10A13, Stride: 1},
+ {Lo: 0x10A15, Hi: 0x10A17, Stride: 1},
+ {Lo: 0x10A19, Hi: 0x10A35, Stride: 1},
+ {Lo: 0x10A60, Hi: 0x10A7C, Stride: 1},
+ {Lo: 0x10A80, Hi: 0x10A9C, Stride: 1},
+ {Lo: 0x10AC0, Hi: 0x10AC7, Stride: 1},
+ {Lo: 0x10AC9, Hi: 0x10AE4, Stride: 1},
+ {Lo: 0x10B00, Hi: 0x10B35, Stride: 1},
+ {Lo: 0x10B40, Hi: 0x10B55, Stride: 1},
+ {Lo: 0x10B60, Hi: 0x10B72, Stride: 1},
+ {Lo: 0x10B80, Hi: 0x10B91, Stride: 1},
+ {Lo: 0x10C00, Hi: 0x10C48, Stride: 1},
+ {Lo: 0x10C80, Hi: 0x10CB2, Stride: 1},
+ {Lo: 0x10CC0, Hi: 0x10CF2, Stride: 1},
+ {Lo: 0x10D00, Hi: 0x10D23, Stride: 1},
+ {Lo: 0x10D4A, Hi: 0x10D65, Stride: 1},
+ {Lo: 0x10D6F, Hi: 0x10D85, Stride: 1},
+ {Lo: 0x10E80, Hi: 0x10EA9, Stride: 1},
+ {Lo: 0x10EB0, Hi: 0x10EB1, Stride: 1},
+ {Lo: 0x10EC2, Hi: 0x10EC7, Stride: 1},
+ {Lo: 0x10F00, Hi: 0x10F1C, Stride: 1},
+ {Lo: 0x10F27, Hi: 0x10F27, Stride: 1},
+ {Lo: 0x10F30, Hi: 0x10F45, Stride: 1},
+ {Lo: 0x10F70, Hi: 0x10F81, Stride: 1},
+ {Lo: 0x10FB0, Hi: 0x10FC4, Stride: 1},
+ {Lo: 0x10FE0, Hi: 0x10FF6, Stride: 1},
+ {Lo: 0x11003, Hi: 0x11037, Stride: 1},
+ {Lo: 0x11071, Hi: 0x11072, Stride: 1},
+ {Lo: 0x11075, Hi: 0x11075, Stride: 1},
+ {Lo: 0x11083, Hi: 0x110AF, Stride: 1},
+ {Lo: 0x110D0, Hi: 0x110E8, Stride: 1},
+ {Lo: 0x11103, Hi: 0x11126, Stride: 1},
+ {Lo: 0x11144, Hi: 0x11144, Stride: 1},
+ {Lo: 0x11147, Hi: 0x11147, Stride: 1},
+ {Lo: 0x11150, Hi: 0x11172, Stride: 1},
+ {Lo: 0x11176, Hi: 0x11176, Stride: 1},
+ {Lo: 0x11183, Hi: 0x111B2, Stride: 1},
+ {Lo: 0x111C1, Hi: 0x111C4, Stride: 1},
+ {Lo: 0x111DA, Hi: 0x111DA, Stride: 1},
+ {Lo: 0x111DC, Hi: 0x111DC, Stride: 1},
+ {Lo: 0x11200, Hi: 0x11211, Stride: 1},
+ {Lo: 0x11213, Hi: 0x1122B, Stride: 1},
+ {Lo: 0x1123F, Hi: 0x11240, Stride: 1},
+ {Lo: 0x11280, Hi: 0x11286, Stride: 1},
+ {Lo: 0x11288, Hi: 0x11288, Stride: 1},
+ {Lo: 0x1128A, Hi: 0x1128D, Stride: 1},
+ {Lo: 0x1128F, Hi: 0x1129D, Stride: 1},
+ {Lo: 0x1129F, Hi: 0x112A8, Stride: 1},
+ {Lo: 0x112B0, Hi: 0x112DE, Stride: 1},
+ {Lo: 0x11305, Hi: 0x1130C, Stride: 1},
+ {Lo: 0x1130F, Hi: 0x11310, Stride: 1},
+ {Lo: 0x11313, Hi: 0x11328, Stride: 1},
+ {Lo: 0x1132A, Hi: 0x11330, Stride: 1},
+ {Lo: 0x11332, Hi: 0x11333, Stride: 1},
+ {Lo: 0x11335, Hi: 0x11339, Stride: 1},
+ {Lo: 0x1133D, Hi: 0x1133D, Stride: 1},
+ {Lo: 0x11350, Hi: 0x11350, Stride: 1},
+ {Lo: 0x1135D, Hi: 0x11361, Stride: 1},
+ {Lo: 0x11380, Hi: 0x11389, Stride: 1},
+ {Lo: 0x1138B, Hi: 0x1138B, Stride: 1},
+ {Lo: 0x1138E, Hi: 0x1138E, Stride: 1},
+ {Lo: 0x11390, Hi: 0x113B5, Stride: 1},
+ {Lo: 0x113B7, Hi: 0x113B7, Stride: 1},
+ {Lo: 0x113D1, Hi: 0x113D1, Stride: 1},
+ {Lo: 0x113D3, Hi: 0x113D3, Stride: 1},
+ {Lo: 0x11400, Hi: 0x11434, Stride: 1},
+ {Lo: 0x11447, Hi: 0x1144A, Stride: 1},
+ {Lo: 0x1145F, Hi: 0x11461, Stride: 1},
+ {Lo: 0x11480, Hi: 0x114AF, Stride: 1},
+ {Lo: 0x114C4, Hi: 0x114C5, Stride: 1},
+ {Lo: 0x114C7, Hi: 0x114C7, Stride: 1},
+ {Lo: 0x11580, Hi: 0x115AE, Stride: 1},
+ {Lo: 0x115D8, Hi: 0x115DB, Stride: 1},
+ {Lo: 0x11600, Hi: 0x1162F, Stride: 1},
+ {Lo: 0x11644, Hi: 0x11644, Stride: 1},
+ {Lo: 0x11680, Hi: 0x116AA, Stride: 1},
+ {Lo: 0x116B8, Hi: 0x116B8, Stride: 1},
+ {Lo: 0x11800, Hi: 0x1182B, Stride: 1},
+ {Lo: 0x118A0, Hi: 0x118DF, Stride: 1},
+ {Lo: 0x118FF, Hi: 0x11906, Stride: 1},
+ {Lo: 0x11909, Hi: 0x11909, Stride: 1},
+ {Lo: 0x1190C, Hi: 0x11913, Stride: 1},
+ {Lo: 0x11915, Hi: 0x11916, Stride: 1},
+ {Lo: 0x11918, Hi: 0x1192F, Stride: 1},
+ {Lo: 0x1193F, Hi: 0x1193F, Stride: 1},
+ {Lo: 0x11941, Hi: 0x11941, Stride: 1},
+ {Lo: 0x119A0, Hi: 0x119A7, Stride: 1},
+ {Lo: 0x119AA, Hi: 0x119D0, Stride: 1},
+ {Lo: 0x119E1, Hi: 0x119E1, Stride: 1},
+ {Lo: 0x119E3, Hi: 0x119E3, Stride: 1},
+ {Lo: 0x11A00, Hi: 0x11A00, Stride: 1},
+ {Lo: 0x11A0B, Hi: 0x11A32, Stride: 1},
+ {Lo: 0x11A3A, Hi: 0x11A3A, Stride: 1},
+ {Lo: 0x11A50, Hi: 0x11A50, Stride: 1},
+ {Lo: 0x11A5C, Hi: 0x11A89, Stride: 1},
+ {Lo: 0x11A9D, Hi: 0x11A9D, Stride: 1},
+ {Lo: 0x11AB0, Hi: 0x11AF8, Stride: 1},
+ {Lo: 0x11BC0, Hi: 0x11BE0, Stride: 1},
+ {Lo: 0x11C00, Hi: 0x11C08, Stride: 1},
+ {Lo: 0x11C0A, Hi: 0x11C2E, Stride: 1},
+ {Lo: 0x11C40, Hi: 0x11C40, Stride: 1},
+ {Lo: 0x11C72, Hi: 0x11C8F, Stride: 1},
+ {Lo: 0x11D00, Hi: 0x11D06, Stride: 1},
+ {Lo: 0x11D08, Hi: 0x11D09, Stride: 1},
+ {Lo: 0x11D0B, Hi: 0x11D30, Stride: 1},
+ {Lo: 0x11D46, Hi: 0x11D46, Stride: 1},
+ {Lo: 0x11D60, Hi: 0x11D65, Stride: 1},
+ {Lo: 0x11D67, Hi: 0x11D68, Stride: 1},
+ {Lo: 0x11D6A, Hi: 0x11D89, Stride: 1},
+ {Lo: 0x11D98, Hi: 0x11D98, Stride: 1},
+ {Lo: 0x11DB0, Hi: 0x11DDB, Stride: 1},
+ {Lo: 0x11EE0, Hi: 0x11EF2, Stride: 1},
+ {Lo: 0x11F02, Hi: 0x11F02, Stride: 1},
+ {Lo: 0x11F04, Hi: 0x11F10, Stride: 1},
+ {Lo: 0x11F12, Hi: 0x11F33, Stride: 1},
+ {Lo: 0x11FB0, Hi: 0x11FB0, Stride: 1},
+ {Lo: 0x12000, Hi: 0x12399, Stride: 1},
+ {Lo: 0x12400, Hi: 0x1246E, Stride: 1},
+ {Lo: 0x12480, Hi: 0x12543, Stride: 1},
+ {Lo: 0x12F90, Hi: 0x12FF0, Stride: 1},
+ {Lo: 0x13000, Hi: 0x1342F, Stride: 1},
+ {Lo: 0x13441, Hi: 0x13446, Stride: 1},
+ {Lo: 0x13460, Hi: 0x143FA, Stride: 1},
+ {Lo: 0x14400, Hi: 0x14646, Stride: 1},
+ {Lo: 0x16100, Hi: 0x1611D, Stride: 1},
+ {Lo: 0x16800, Hi: 0x16A38, Stride: 1},
+ {Lo: 0x16A40, Hi: 0x16A5E, Stride: 1},
+ {Lo: 0x16A70, Hi: 0x16ABE, Stride: 1},
+ {Lo: 0x16AD0, Hi: 0x16AED, Stride: 1},
+ {Lo: 0x16B00, Hi: 0x16B2F, Stride: 1},
+ {Lo: 0x16B40, Hi: 0x16B43, Stride: 1},
+ {Lo: 0x16B63, Hi: 0x16B77, Stride: 1},
+ {Lo: 0x16B7D, Hi: 0x16B8F, Stride: 1},
+ {Lo: 0x16D40, Hi: 0x16D6C, Stride: 1},
+ {Lo: 0x16E40, Hi: 0x16E7F, Stride: 1},
+ {Lo: 0x16EA0, Hi: 0x16EB8, Stride: 1},
+ {Lo: 0x16EBB, Hi: 0x16ED3, Stride: 1},
+ {Lo: 0x16F00, Hi: 0x16F4A, Stride: 1},
+ {Lo: 0x16F50, Hi: 0x16F50, Stride: 1},
+ {Lo: 0x16F93, Hi: 0x16F9F, Stride: 1},
+ {Lo: 0x16FE0, Hi: 0x16FE1, Stride: 1},
+ {Lo: 0x16FE3, Hi: 0x16FE3, Stride: 1},
+ {Lo: 0x1BC00, Hi: 0x1BC6A, Stride: 1},
+ {Lo: 0x1BC70, Hi: 0x1BC7C, Stride: 1},
+ {Lo: 0x1BC80, Hi: 0x1BC88, Stride: 1},
+ {Lo: 0x1BC90, Hi: 0x1BC99, Stride: 1},
+ {Lo: 0x1D400, Hi: 0x1D454, Stride: 1},
+ {Lo: 0x1D456, Hi: 0x1D49C, Stride: 1},
+ {Lo: 0x1D49E, Hi: 0x1D49F, Stride: 1},
+ {Lo: 0x1D4A2, Hi: 0x1D4A2, Stride: 1},
+ {Lo: 0x1D4A5, Hi: 0x1D4A6, Stride: 1},
+ {Lo: 0x1D4A9, Hi: 0x1D4AC, Stride: 1},
+ {Lo: 0x1D4AE, Hi: 0x1D4B9, Stride: 1},
+ {Lo: 0x1D4BB, Hi: 0x1D4BB, Stride: 1},
+ {Lo: 0x1D4BD, Hi: 0x1D4C3, Stride: 1},
+ {Lo: 0x1D4C5, Hi: 0x1D505, Stride: 1},
+ {Lo: 0x1D507, Hi: 0x1D50A, Stride: 1},
+ {Lo: 0x1D50D, Hi: 0x1D514, Stride: 1},
+ {Lo: 0x1D516, Hi: 0x1D51C, Stride: 1},
+ {Lo: 0x1D51E, Hi: 0x1D539, Stride: 1},
+ {Lo: 0x1D53B, Hi: 0x1D53E, Stride: 1},
+ {Lo: 0x1D540, Hi: 0x1D544, Stride: 1},
+ {Lo: 0x1D546, Hi: 0x1D546, Stride: 1},
+ {Lo: 0x1D54A, Hi: 0x1D550, Stride: 1},
+ {Lo: 0x1D552, Hi: 0x1D6A5, Stride: 1},
+ {Lo: 0x1D6A8, Hi: 0x1D6C0, Stride: 1},
+ {Lo: 0x1D6C2, Hi: 0x1D6DA, Stride: 1},
+ {Lo: 0x1D6DC, Hi: 0x1D6FA, Stride: 1},
+ {Lo: 0x1D6FC, Hi: 0x1D714, Stride: 1},
+ {Lo: 0x1D716, Hi: 0x1D734, Stride: 1},
+ {Lo: 0x1D736, Hi: 0x1D74E, Stride: 1},
+ {Lo: 0x1D750, Hi: 0x1D76E, Stride: 1},
+ {Lo: 0x1D770, Hi: 0x1D788, Stride: 1},
+ {Lo: 0x1D78A, Hi: 0x1D7A8, Stride: 1},
+ {Lo: 0x1D7AA, Hi: 0x1D7C2, Stride: 1},
+ {Lo: 0x1D7C4, Hi: 0x1D7CB, Stride: 1},
+ {Lo: 0x1DF00, Hi: 0x1DF1E, Stride: 1},
+ {Lo: 0x1DF25, Hi: 0x1DF2A, Stride: 1},
+ {Lo: 0x1E030, Hi: 0x1E06D, Stride: 1},
+ {Lo: 0x1E100, Hi: 0x1E12C, Stride: 1},
+ {Lo: 0x1E137, Hi: 0x1E13D, Stride: 1},
+ {Lo: 0x1E14E, Hi: 0x1E14E, Stride: 1},
+ {Lo: 0x1E290, Hi: 0x1E2AD, Stride: 1},
+ {Lo: 0x1E2C0, Hi: 0x1E2EB, Stride: 1},
+ {Lo: 0x1E4D0, Hi: 0x1E4EB, Stride: 1},
+ {Lo: 0x1E5D0, Hi: 0x1E5ED, Stride: 1},
+ {Lo: 0x1E5F0, Hi: 0x1E5F0, Stride: 1},
+ {Lo: 0x1E6C0, Hi: 0x1E6DE, Stride: 1},
+ {Lo: 0x1E6E0, Hi: 0x1E6E2, Stride: 1},
+ {Lo: 0x1E6E4, Hi: 0x1E6E5, Stride: 1},
+ {Lo: 0x1E6E7, Hi: 0x1E6ED, Stride: 1},
+ {Lo: 0x1E6F0, Hi: 0x1E6F4, Stride: 1},
+ {Lo: 0x1E6FE, Hi: 0x1E6FF, Stride: 1},
+ {Lo: 0x1E7E0, Hi: 0x1E7E6, Stride: 1},
+ {Lo: 0x1E7E8, Hi: 0x1E7EB, Stride: 1},
+ {Lo: 0x1E7ED, Hi: 0x1E7EE, Stride: 1},
+ {Lo: 0x1E7F0, Hi: 0x1E7FE, Stride: 1},
+ {Lo: 0x1E800, Hi: 0x1E8C4, Stride: 1},
+ {Lo: 0x1E900, Hi: 0x1E943, Stride: 1},
+ {Lo: 0x1E94B, Hi: 0x1E94B, Stride: 1},
+ {Lo: 0x1EE00, Hi: 0x1EE03, Stride: 1},
+ {Lo: 0x1EE05, Hi: 0x1EE1F, Stride: 1},
+ {Lo: 0x1EE21, Hi: 0x1EE22, Stride: 1},
+ {Lo: 0x1EE24, Hi: 0x1EE24, Stride: 1},
+ {Lo: 0x1EE27, Hi: 0x1EE27, Stride: 1},
+ {Lo: 0x1EE29, Hi: 0x1EE32, Stride: 1},
+ {Lo: 0x1EE34, Hi: 0x1EE37, Stride: 1},
+ {Lo: 0x1EE39, Hi: 0x1EE39, Stride: 1},
+ {Lo: 0x1EE3B, Hi: 0x1EE3B, Stride: 1},
+ {Lo: 0x1EE42, Hi: 0x1EE42, Stride: 1},
+ {Lo: 0x1EE47, Hi: 0x1EE47, Stride: 1},
+ {Lo: 0x1EE49, Hi: 0x1EE49, Stride: 1},
+ {Lo: 0x1EE4B, Hi: 0x1EE4B, Stride: 1},
+ {Lo: 0x1EE4D, Hi: 0x1EE4F, Stride: 1},
+ {Lo: 0x1EE51, Hi: 0x1EE52, Stride: 1},
+ {Lo: 0x1EE54, Hi: 0x1EE54, Stride: 1},
+ {Lo: 0x1EE57, Hi: 0x1EE57, Stride: 1},
+ {Lo: 0x1EE59, Hi: 0x1EE59, Stride: 1},
+ {Lo: 0x1EE5B, Hi: 0x1EE5B, Stride: 1},
+ {Lo: 0x1EE5D, Hi: 0x1EE5D, Stride: 1},
+ {Lo: 0x1EE5F, Hi: 0x1EE5F, Stride: 1},
+ {Lo: 0x1EE61, Hi: 0x1EE62, Stride: 1},
+ {Lo: 0x1EE64, Hi: 0x1EE64, Stride: 1},
+ {Lo: 0x1EE67, Hi: 0x1EE6A, Stride: 1},
+ {Lo: 0x1EE6C, Hi: 0x1EE72, Stride: 1},
+ {Lo: 0x1EE74, Hi: 0x1EE77, Stride: 1},
+ {Lo: 0x1EE79, Hi: 0x1EE7C, Stride: 1},
+ {Lo: 0x1EE7E, Hi: 0x1EE7E, Stride: 1},
+ {Lo: 0x1EE80, Hi: 0x1EE89, Stride: 1},
+ {Lo: 0x1EE8B, Hi: 0x1EE9B, Stride: 1},
+ {Lo: 0x1EEA1, Hi: 0x1EEA3, Stride: 1},
+ {Lo: 0x1EEA5, Hi: 0x1EEA9, Stride: 1},
+ {Lo: 0x1EEAB, Hi: 0x1EEBB, Stride: 1},
+ {Lo: 0x1F130, Hi: 0x1F149, Stride: 1},
+ {Lo: 0x1F150, Hi: 0x1F169, Stride: 1},
+ {Lo: 0x1F170, Hi: 0x1F189, Stride: 1},
+ },
+}
+
+var unicodeAliasWord_Break_CR = &unicode.RangeTable{
+ R16: []unicode.Range16{
+ {Lo: 0xD, Hi: 0xD, Stride: 1},
+ },
+}
+
+var unicodeAliasWord_Break_Double_Quote = &unicode.RangeTable{
+ R16: []unicode.Range16{
+ {Lo: 0x22, Hi: 0x22, Stride: 1},
+ },
+}
+
+var unicodeAliasWord_Break_Extend = &unicode.RangeTable{
+ R16: []unicode.Range16{
+ {Lo: 0x300, Hi: 0x36F, Stride: 1},
+ {Lo: 0x483, Hi: 0x489, Stride: 1},
+ {Lo: 0x591, Hi: 0x5BD, Stride: 1},
+ {Lo: 0x5BF, Hi: 0x5BF, Stride: 1},
+ {Lo: 0x5C1, Hi: 0x5C2, Stride: 1},
+ {Lo: 0x5C4, Hi: 0x5C5, Stride: 1},
+ {Lo: 0x5C7, Hi: 0x5C7, Stride: 1},
+ {Lo: 0x610, Hi: 0x61A, Stride: 1},
+ {Lo: 0x64B, Hi: 0x65F, Stride: 1},
+ {Lo: 0x670, Hi: 0x670, Stride: 1},
+ {Lo: 0x6D6, Hi: 0x6DC, Stride: 1},
+ {Lo: 0x6DF, Hi: 0x6E4, Stride: 1},
+ {Lo: 0x6E7, Hi: 0x6E8, Stride: 1},
+ {Lo: 0x6EA, Hi: 0x6ED, Stride: 1},
+ {Lo: 0x711, Hi: 0x711, Stride: 1},
+ {Lo: 0x730, Hi: 0x74A, Stride: 1},
+ {Lo: 0x7A6, Hi: 0x7B0, Stride: 1},
+ {Lo: 0x7EB, Hi: 0x7F3, Stride: 1},
+ {Lo: 0x7FD, Hi: 0x7FD, Stride: 1},
+ {Lo: 0x816, Hi: 0x819, Stride: 1},
+ {Lo: 0x81B, Hi: 0x823, Stride: 1},
+ {Lo: 0x825, Hi: 0x827, Stride: 1},
+ {Lo: 0x829, Hi: 0x82D, Stride: 1},
+ {Lo: 0x859, Hi: 0x85B, Stride: 1},
+ {Lo: 0x897, Hi: 0x89F, Stride: 1},
+ {Lo: 0x8CA, Hi: 0x8E1, Stride: 1},
+ {Lo: 0x8E3, Hi: 0x903, Stride: 1},
+ {Lo: 0x93A, Hi: 0x93C, Stride: 1},
+ {Lo: 0x93E, Hi: 0x94F, Stride: 1},
+ {Lo: 0x951, Hi: 0x957, Stride: 1},
+ {Lo: 0x962, Hi: 0x963, Stride: 1},
+ {Lo: 0x981, Hi: 0x983, Stride: 1},
+ {Lo: 0x9BC, Hi: 0x9BC, Stride: 1},
+ {Lo: 0x9BE, Hi: 0x9C4, Stride: 1},
+ {Lo: 0x9C7, Hi: 0x9C8, Stride: 1},
+ {Lo: 0x9CB, Hi: 0x9CD, Stride: 1},
+ {Lo: 0x9D7, Hi: 0x9D7, Stride: 1},
+ {Lo: 0x9E2, Hi: 0x9E3, Stride: 1},
+ {Lo: 0x9FE, Hi: 0x9FE, Stride: 1},
+ {Lo: 0xA01, Hi: 0xA03, Stride: 1},
+ {Lo: 0xA3C, Hi: 0xA3C, Stride: 1},
+ {Lo: 0xA3E, Hi: 0xA42, Stride: 1},
+ {Lo: 0xA47, Hi: 0xA48, Stride: 1},
+ {Lo: 0xA4B, Hi: 0xA4D, Stride: 1},
+ {Lo: 0xA51, Hi: 0xA51, Stride: 1},
+ {Lo: 0xA70, Hi: 0xA71, Stride: 1},
+ {Lo: 0xA75, Hi: 0xA75, Stride: 1},
+ {Lo: 0xA81, Hi: 0xA83, Stride: 1},
+ {Lo: 0xABC, Hi: 0xABC, Stride: 1},
+ {Lo: 0xABE, Hi: 0xAC5, Stride: 1},
+ {Lo: 0xAC7, Hi: 0xAC9, Stride: 1},
+ {Lo: 0xACB, Hi: 0xACD, Stride: 1},
+ {Lo: 0xAE2, Hi: 0xAE3, Stride: 1},
+ {Lo: 0xAFA, Hi: 0xAFF, Stride: 1},
+ {Lo: 0xB01, Hi: 0xB03, Stride: 1},
+ {Lo: 0xB3C, Hi: 0xB3C, Stride: 1},
+ {Lo: 0xB3E, Hi: 0xB44, Stride: 1},
+ {Lo: 0xB47, Hi: 0xB48, Stride: 1},
+ {Lo: 0xB4B, Hi: 0xB4D, Stride: 1},
+ {Lo: 0xB55, Hi: 0xB57, Stride: 1},
+ {Lo: 0xB62, Hi: 0xB63, Stride: 1},
+ {Lo: 0xB82, Hi: 0xB82, Stride: 1},
+ {Lo: 0xBBE, Hi: 0xBC2, Stride: 1},
+ {Lo: 0xBC6, Hi: 0xBC8, Stride: 1},
+ {Lo: 0xBCA, Hi: 0xBCD, Stride: 1},
+ {Lo: 0xBD7, Hi: 0xBD7, Stride: 1},
+ {Lo: 0xC00, Hi: 0xC04, Stride: 1},
+ {Lo: 0xC3C, Hi: 0xC3C, Stride: 1},
+ {Lo: 0xC3E, Hi: 0xC44, Stride: 1},
+ {Lo: 0xC46, Hi: 0xC48, Stride: 1},
+ {Lo: 0xC4A, Hi: 0xC4D, Stride: 1},
+ {Lo: 0xC55, Hi: 0xC56, Stride: 1},
+ {Lo: 0xC62, Hi: 0xC63, Stride: 1},
+ {Lo: 0xC81, Hi: 0xC83, Stride: 1},
+ {Lo: 0xCBC, Hi: 0xCBC, Stride: 1},
+ {Lo: 0xCBE, Hi: 0xCC4, Stride: 1},
+ {Lo: 0xCC6, Hi: 0xCC8, Stride: 1},
+ {Lo: 0xCCA, Hi: 0xCCD, Stride: 1},
+ {Lo: 0xCD5, Hi: 0xCD6, Stride: 1},
+ {Lo: 0xCE2, Hi: 0xCE3, Stride: 1},
+ {Lo: 0xCF3, Hi: 0xCF3, Stride: 1},
+ {Lo: 0xD00, Hi: 0xD03, Stride: 1},
+ {Lo: 0xD3B, Hi: 0xD3C, Stride: 1},
+ {Lo: 0xD3E, Hi: 0xD44, Stride: 1},
+ {Lo: 0xD46, Hi: 0xD48, Stride: 1},
+ {Lo: 0xD4A, Hi: 0xD4D, Stride: 1},
+ {Lo: 0xD57, Hi: 0xD57, Stride: 1},
+ {Lo: 0xD62, Hi: 0xD63, Stride: 1},
+ {Lo: 0xD81, Hi: 0xD83, Stride: 1},
+ {Lo: 0xDCA, Hi: 0xDCA, Stride: 1},
+ {Lo: 0xDCF, Hi: 0xDD4, Stride: 1},
+ {Lo: 0xDD6, Hi: 0xDD6, Stride: 1},
+ {Lo: 0xDD8, Hi: 0xDDF, Stride: 1},
+ {Lo: 0xDF2, Hi: 0xDF3, Stride: 1},
+ {Lo: 0xE31, Hi: 0xE31, Stride: 1},
+ {Lo: 0xE34, Hi: 0xE3A, Stride: 1},
+ {Lo: 0xE47, Hi: 0xE4E, Stride: 1},
+ {Lo: 0xEB1, Hi: 0xEB1, Stride: 1},
+ {Lo: 0xEB4, Hi: 0xEBC, Stride: 1},
+ {Lo: 0xEC8, Hi: 0xECE, Stride: 1},
+ {Lo: 0xF18, Hi: 0xF19, Stride: 1},
+ {Lo: 0xF35, Hi: 0xF35, Stride: 1},
+ {Lo: 0xF37, Hi: 0xF37, Stride: 1},
+ {Lo: 0xF39, Hi: 0xF39, Stride: 1},
+ {Lo: 0xF3E, Hi: 0xF3F, Stride: 1},
+ {Lo: 0xF71, Hi: 0xF84, Stride: 1},
+ {Lo: 0xF86, Hi: 0xF87, Stride: 1},
+ {Lo: 0xF8D, Hi: 0xF97, Stride: 1},
+ {Lo: 0xF99, Hi: 0xFBC, Stride: 1},
+ {Lo: 0xFC6, Hi: 0xFC6, Stride: 1},
+ {Lo: 0x102B, Hi: 0x103E, Stride: 1},
+ {Lo: 0x1056, Hi: 0x1059, Stride: 1},
+ {Lo: 0x105E, Hi: 0x1060, Stride: 1},
+ {Lo: 0x1062, Hi: 0x1064, Stride: 1},
+ {Lo: 0x1067, Hi: 0x106D, Stride: 1},
+ {Lo: 0x1071, Hi: 0x1074, Stride: 1},
+ {Lo: 0x1082, Hi: 0x108D, Stride: 1},
+ {Lo: 0x108F, Hi: 0x108F, Stride: 1},
+ {Lo: 0x109A, Hi: 0x109D, Stride: 1},
+ {Lo: 0x135D, Hi: 0x135F, Stride: 1},
+ {Lo: 0x1712, Hi: 0x1715, Stride: 1},
+ {Lo: 0x1732, Hi: 0x1734, Stride: 1},
+ {Lo: 0x1752, Hi: 0x1753, Stride: 1},
+ {Lo: 0x1772, Hi: 0x1773, Stride: 1},
+ {Lo: 0x17B4, Hi: 0x17D3, Stride: 1},
+ {Lo: 0x17DD, Hi: 0x17DD, Stride: 1},
+ {Lo: 0x180B, Hi: 0x180D, Stride: 1},
+ {Lo: 0x180F, Hi: 0x180F, Stride: 1},
+ {Lo: 0x1885, Hi: 0x1886, Stride: 1},
+ {Lo: 0x18A9, Hi: 0x18A9, Stride: 1},
+ {Lo: 0x1920, Hi: 0x192B, Stride: 1},
+ {Lo: 0x1930, Hi: 0x193B, Stride: 1},
+ {Lo: 0x1A17, Hi: 0x1A1B, Stride: 1},
+ {Lo: 0x1A55, Hi: 0x1A5E, Stride: 1},
+ {Lo: 0x1A60, Hi: 0x1A7C, Stride: 1},
+ {Lo: 0x1A7F, Hi: 0x1A7F, Stride: 1},
+ {Lo: 0x1AB0, Hi: 0x1ADD, Stride: 1},
+ {Lo: 0x1AE0, Hi: 0x1AEB, Stride: 1},
+ {Lo: 0x1B00, Hi: 0x1B04, Stride: 1},
+ {Lo: 0x1B34, Hi: 0x1B44, Stride: 1},
+ {Lo: 0x1B6B, Hi: 0x1B73, Stride: 1},
+ {Lo: 0x1B80, Hi: 0x1B82, Stride: 1},
+ {Lo: 0x1BA1, Hi: 0x1BAD, Stride: 1},
+ {Lo: 0x1BE6, Hi: 0x1BF3, Stride: 1},
+ {Lo: 0x1C24, Hi: 0x1C37, Stride: 1},
+ {Lo: 0x1CD0, Hi: 0x1CD2, Stride: 1},
+ {Lo: 0x1CD4, Hi: 0x1CE8, Stride: 1},
+ {Lo: 0x1CED, Hi: 0x1CED, Stride: 1},
+ {Lo: 0x1CF4, Hi: 0x1CF4, Stride: 1},
+ {Lo: 0x1CF7, Hi: 0x1CF9, Stride: 1},
+ {Lo: 0x1DC0, Hi: 0x1DFF, Stride: 1},
+ {Lo: 0x200C, Hi: 0x200C, Stride: 1},
+ {Lo: 0x20D0, Hi: 0x20F0, Stride: 1},
+ {Lo: 0x2CEF, Hi: 0x2CF1, Stride: 1},
+ {Lo: 0x2D7F, Hi: 0x2D7F, Stride: 1},
+ {Lo: 0x2DE0, Hi: 0x2DFF, Stride: 1},
+ {Lo: 0x302A, Hi: 0x302F, Stride: 1},
+ {Lo: 0x3099, Hi: 0x309A, Stride: 1},
+ {Lo: 0xA66F, Hi: 0xA672, Stride: 1},
+ {Lo: 0xA674, Hi: 0xA67D, Stride: 1},
+ {Lo: 0xA69E, Hi: 0xA69F, Stride: 1},
+ {Lo: 0xA6F0, Hi: 0xA6F1, Stride: 1},
+ {Lo: 0xA802, Hi: 0xA802, Stride: 1},
+ {Lo: 0xA806, Hi: 0xA806, Stride: 1},
+ {Lo: 0xA80B, Hi: 0xA80B, Stride: 1},
+ {Lo: 0xA823, Hi: 0xA827, Stride: 1},
+ {Lo: 0xA82C, Hi: 0xA82C, Stride: 1},
+ {Lo: 0xA880, Hi: 0xA881, Stride: 1},
+ {Lo: 0xA8B4, Hi: 0xA8C5, Stride: 1},
+ {Lo: 0xA8E0, Hi: 0xA8F1, Stride: 1},
+ {Lo: 0xA8FF, Hi: 0xA8FF, Stride: 1},
+ {Lo: 0xA926, Hi: 0xA92D, Stride: 1},
+ {Lo: 0xA947, Hi: 0xA953, Stride: 1},
+ {Lo: 0xA980, Hi: 0xA983, Stride: 1},
+ {Lo: 0xA9B3, Hi: 0xA9C0, Stride: 1},
+ {Lo: 0xA9E5, Hi: 0xA9E5, Stride: 1},
+ {Lo: 0xAA29, Hi: 0xAA36, Stride: 1},
+ {Lo: 0xAA43, Hi: 0xAA43, Stride: 1},
+ {Lo: 0xAA4C, Hi: 0xAA4D, Stride: 1},
+ {Lo: 0xAA7B, Hi: 0xAA7D, Stride: 1},
+ {Lo: 0xAAB0, Hi: 0xAAB0, Stride: 1},
+ {Lo: 0xAAB2, Hi: 0xAAB4, Stride: 1},
+ {Lo: 0xAAB7, Hi: 0xAAB8, Stride: 1},
+ {Lo: 0xAABE, Hi: 0xAABF, Stride: 1},
+ {Lo: 0xAAC1, Hi: 0xAAC1, Stride: 1},
+ {Lo: 0xAAEB, Hi: 0xAAEF, Stride: 1},
+ {Lo: 0xAAF5, Hi: 0xAAF6, Stride: 1},
+ {Lo: 0xABE3, Hi: 0xABEA, Stride: 1},
+ {Lo: 0xABEC, Hi: 0xABED, Stride: 1},
+ {Lo: 0xFB1E, Hi: 0xFB1E, Stride: 1},
+ {Lo: 0xFE00, Hi: 0xFE0F, Stride: 1},
+ {Lo: 0xFE20, Hi: 0xFE2F, Stride: 1},
+ {Lo: 0xFF9E, Hi: 0xFF9F, Stride: 1},
+ },
+ R32: []unicode.Range32{
+ {Lo: 0x101FD, Hi: 0x101FD, Stride: 1},
+ {Lo: 0x102E0, Hi: 0x102E0, Stride: 1},
+ {Lo: 0x10376, Hi: 0x1037A, Stride: 1},
+ {Lo: 0x10A01, Hi: 0x10A03, Stride: 1},
+ {Lo: 0x10A05, Hi: 0x10A06, Stride: 1},
+ {Lo: 0x10A0C, Hi: 0x10A0F, Stride: 1},
+ {Lo: 0x10A38, Hi: 0x10A3A, Stride: 1},
+ {Lo: 0x10A3F, Hi: 0x10A3F, Stride: 1},
+ {Lo: 0x10AE5, Hi: 0x10AE6, Stride: 1},
+ {Lo: 0x10D24, Hi: 0x10D27, Stride: 1},
+ {Lo: 0x10D69, Hi: 0x10D6D, Stride: 1},
+ {Lo: 0x10EAB, Hi: 0x10EAC, Stride: 1},
+ {Lo: 0x10EFA, Hi: 0x10EFF, Stride: 1},
+ {Lo: 0x10F46, Hi: 0x10F50, Stride: 1},
+ {Lo: 0x10F82, Hi: 0x10F85, Stride: 1},
+ {Lo: 0x11000, Hi: 0x11002, Stride: 1},
+ {Lo: 0x11038, Hi: 0x11046, Stride: 1},
+ {Lo: 0x11070, Hi: 0x11070, Stride: 1},
+ {Lo: 0x11073, Hi: 0x11074, Stride: 1},
+ {Lo: 0x1107F, Hi: 0x11082, Stride: 1},
+ {Lo: 0x110B0, Hi: 0x110BA, Stride: 1},
+ {Lo: 0x110C2, Hi: 0x110C2, Stride: 1},
+ {Lo: 0x11100, Hi: 0x11102, Stride: 1},
+ {Lo: 0x11127, Hi: 0x11134, Stride: 1},
+ {Lo: 0x11145, Hi: 0x11146, Stride: 1},
+ {Lo: 0x11173, Hi: 0x11173, Stride: 1},
+ {Lo: 0x11180, Hi: 0x11182, Stride: 1},
+ {Lo: 0x111B3, Hi: 0x111C0, Stride: 1},
+ {Lo: 0x111C9, Hi: 0x111CC, Stride: 1},
+ {Lo: 0x111CE, Hi: 0x111CF, Stride: 1},
+ {Lo: 0x1122C, Hi: 0x11237, Stride: 1},
+ {Lo: 0x1123E, Hi: 0x1123E, Stride: 1},
+ {Lo: 0x11241, Hi: 0x11241, Stride: 1},
+ {Lo: 0x112DF, Hi: 0x112EA, Stride: 1},
+ {Lo: 0x11300, Hi: 0x11303, Stride: 1},
+ {Lo: 0x1133B, Hi: 0x1133C, Stride: 1},
+ {Lo: 0x1133E, Hi: 0x11344, Stride: 1},
+ {Lo: 0x11347, Hi: 0x11348, Stride: 1},
+ {Lo: 0x1134B, Hi: 0x1134D, Stride: 1},
+ {Lo: 0x11357, Hi: 0x11357, Stride: 1},
+ {Lo: 0x11362, Hi: 0x11363, Stride: 1},
+ {Lo: 0x11366, Hi: 0x1136C, Stride: 1},
+ {Lo: 0x11370, Hi: 0x11374, Stride: 1},
+ {Lo: 0x113B8, Hi: 0x113C0, Stride: 1},
+ {Lo: 0x113C2, Hi: 0x113C2, Stride: 1},
+ {Lo: 0x113C5, Hi: 0x113C5, Stride: 1},
+ {Lo: 0x113C7, Hi: 0x113CA, Stride: 1},
+ {Lo: 0x113CC, Hi: 0x113D0, Stride: 1},
+ {Lo: 0x113D2, Hi: 0x113D2, Stride: 1},
+ {Lo: 0x113E1, Hi: 0x113E2, Stride: 1},
+ {Lo: 0x11435, Hi: 0x11446, Stride: 1},
+ {Lo: 0x1145E, Hi: 0x1145E, Stride: 1},
+ {Lo: 0x114B0, Hi: 0x114C3, Stride: 1},
+ {Lo: 0x115AF, Hi: 0x115B5, Stride: 1},
+ {Lo: 0x115B8, Hi: 0x115C0, Stride: 1},
+ {Lo: 0x115DC, Hi: 0x115DD, Stride: 1},
+ {Lo: 0x11630, Hi: 0x11640, Stride: 1},
+ {Lo: 0x116AB, Hi: 0x116B7, Stride: 1},
+ {Lo: 0x1171D, Hi: 0x1172B, Stride: 1},
+ {Lo: 0x1182C, Hi: 0x1183A, Stride: 1},
+ {Lo: 0x11930, Hi: 0x11935, Stride: 1},
+ {Lo: 0x11937, Hi: 0x11938, Stride: 1},
+ {Lo: 0x1193B, Hi: 0x1193E, Stride: 1},
+ {Lo: 0x11940, Hi: 0x11940, Stride: 1},
+ {Lo: 0x11942, Hi: 0x11943, Stride: 1},
+ {Lo: 0x119D1, Hi: 0x119D7, Stride: 1},
+ {Lo: 0x119DA, Hi: 0x119E0, Stride: 1},
+ {Lo: 0x119E4, Hi: 0x119E4, Stride: 1},
+ {Lo: 0x11A01, Hi: 0x11A0A, Stride: 1},
+ {Lo: 0x11A33, Hi: 0x11A39, Stride: 1},
+ {Lo: 0x11A3B, Hi: 0x11A3E, Stride: 1},
+ {Lo: 0x11A47, Hi: 0x11A47, Stride: 1},
+ {Lo: 0x11A51, Hi: 0x11A5B, Stride: 1},
+ {Lo: 0x11A8A, Hi: 0x11A99, Stride: 1},
+ {Lo: 0x11B60, Hi: 0x11B67, Stride: 1},
+ {Lo: 0x11C2F, Hi: 0x11C36, Stride: 1},
+ {Lo: 0x11C38, Hi: 0x11C3F, Stride: 1},
+ {Lo: 0x11C92, Hi: 0x11CA7, Stride: 1},
+ {Lo: 0x11CA9, Hi: 0x11CB6, Stride: 1},
+ {Lo: 0x11D31, Hi: 0x11D36, Stride: 1},
+ {Lo: 0x11D3A, Hi: 0x11D3A, Stride: 1},
+ {Lo: 0x11D3C, Hi: 0x11D3D, Stride: 1},
+ {Lo: 0x11D3F, Hi: 0x11D45, Stride: 1},
+ {Lo: 0x11D47, Hi: 0x11D47, Stride: 1},
+ {Lo: 0x11D8A, Hi: 0x11D8E, Stride: 1},
+ {Lo: 0x11D90, Hi: 0x11D91, Stride: 1},
+ {Lo: 0x11D93, Hi: 0x11D97, Stride: 1},
+ {Lo: 0x11EF3, Hi: 0x11EF6, Stride: 1},
+ {Lo: 0x11F00, Hi: 0x11F01, Stride: 1},
+ {Lo: 0x11F03, Hi: 0x11F03, Stride: 1},
+ {Lo: 0x11F34, Hi: 0x11F3A, Stride: 1},
+ {Lo: 0x11F3E, Hi: 0x11F42, Stride: 1},
+ {Lo: 0x11F5A, Hi: 0x11F5A, Stride: 1},
+ {Lo: 0x13440, Hi: 0x13440, Stride: 1},
+ {Lo: 0x13447, Hi: 0x13455, Stride: 1},
+ {Lo: 0x1611E, Hi: 0x1612F, Stride: 1},
+ {Lo: 0x16AF0, Hi: 0x16AF4, Stride: 1},
+ {Lo: 0x16B30, Hi: 0x16B36, Stride: 1},
+ {Lo: 0x16F4F, Hi: 0x16F4F, Stride: 1},
+ {Lo: 0x16F51, Hi: 0x16F87, Stride: 1},
+ {Lo: 0x16F8F, Hi: 0x16F92, Stride: 1},
+ {Lo: 0x16FE4, Hi: 0x16FE4, Stride: 1},
+ {Lo: 0x16FF0, Hi: 0x16FF1, Stride: 1},
+ {Lo: 0x1BC9D, Hi: 0x1BC9E, Stride: 1},
+ {Lo: 0x1CF00, Hi: 0x1CF2D, Stride: 1},
+ {Lo: 0x1CF30, Hi: 0x1CF46, Stride: 1},
+ {Lo: 0x1D165, Hi: 0x1D169, Stride: 1},
+ {Lo: 0x1D16D, Hi: 0x1D172, Stride: 1},
+ {Lo: 0x1D17B, Hi: 0x1D182, Stride: 1},
+ {Lo: 0x1D185, Hi: 0x1D18B, Stride: 1},
+ {Lo: 0x1D1AA, Hi: 0x1D1AD, Stride: 1},
+ {Lo: 0x1D242, Hi: 0x1D244, Stride: 1},
+ {Lo: 0x1DA00, Hi: 0x1DA36, Stride: 1},
+ {Lo: 0x1DA3B, Hi: 0x1DA6C, Stride: 1},
+ {Lo: 0x1DA75, Hi: 0x1DA75, Stride: 1},
+ {Lo: 0x1DA84, Hi: 0x1DA84, Stride: 1},
+ {Lo: 0x1DA9B, Hi: 0x1DA9F, Stride: 1},
+ {Lo: 0x1DAA1, Hi: 0x1DAAF, Stride: 1},
+ {Lo: 0x1E000, Hi: 0x1E006, Stride: 1},
+ {Lo: 0x1E008, Hi: 0x1E018, Stride: 1},
+ {Lo: 0x1E01B, Hi: 0x1E021, Stride: 1},
+ {Lo: 0x1E023, Hi: 0x1E024, Stride: 1},
+ {Lo: 0x1E026, Hi: 0x1E02A, Stride: 1},
+ {Lo: 0x1E08F, Hi: 0x1E08F, Stride: 1},
+ {Lo: 0x1E130, Hi: 0x1E136, Stride: 1},
+ {Lo: 0x1E2AE, Hi: 0x1E2AE, Stride: 1},
+ {Lo: 0x1E2EC, Hi: 0x1E2EF, Stride: 1},
+ {Lo: 0x1E4EC, Hi: 0x1E4EF, Stride: 1},
+ {Lo: 0x1E5EE, Hi: 0x1E5EF, Stride: 1},
+ {Lo: 0x1E6E3, Hi: 0x1E6E3, Stride: 1},
+ {Lo: 0x1E6E6, Hi: 0x1E6E6, Stride: 1},
+ {Lo: 0x1E6EE, Hi: 0x1E6EF, Stride: 1},
+ {Lo: 0x1E6F5, Hi: 0x1E6F5, Stride: 1},
+ {Lo: 0x1E8D0, Hi: 0x1E8D6, Stride: 1},
+ {Lo: 0x1E944, Hi: 0x1E94A, Stride: 1},
+ {Lo: 0x1F3FB, Hi: 0x1F3FF, Stride: 1},
+ {Lo: 0xE0020, Hi: 0xE007F, Stride: 1},
+ {Lo: 0xE0100, Hi: 0xE01EF, Stride: 1},
+ },
+}
+
+var unicodeAliasWord_Break_ExtendNumLet = &unicode.RangeTable{
+ R16: []unicode.Range16{
+ {Lo: 0x5F, Hi: 0x5F, Stride: 1},
+ {Lo: 0x202F, Hi: 0x202F, Stride: 1},
+ {Lo: 0x203F, Hi: 0x2040, Stride: 1},
+ {Lo: 0x2054, Hi: 0x2054, Stride: 1},
+ {Lo: 0xFE33, Hi: 0xFE34, Stride: 1},
+ {Lo: 0xFE4D, Hi: 0xFE4F, Stride: 1},
+ {Lo: 0xFF3F, Hi: 0xFF3F, Stride: 1},
+ },
+}
+
+var unicodeAliasWord_Break_Format = &unicode.RangeTable{
+ R16: []unicode.Range16{
+ {Lo: 0xAD, Hi: 0xAD, Stride: 1},
+ {Lo: 0x61C, Hi: 0x61C, Stride: 1},
+ {Lo: 0x180E, Hi: 0x180E, Stride: 1},
+ {Lo: 0x200E, Hi: 0x200F, Stride: 1},
+ {Lo: 0x202A, Hi: 0x202E, Stride: 1},
+ {Lo: 0x2060, Hi: 0x2064, Stride: 1},
+ {Lo: 0x2066, Hi: 0x206F, Stride: 1},
+ {Lo: 0xFEFF, Hi: 0xFEFF, Stride: 1},
+ {Lo: 0xFFF9, Hi: 0xFFFB, Stride: 1},
+ },
+ R32: []unicode.Range32{
+ {Lo: 0x13430, Hi: 0x1343F, Stride: 1},
+ {Lo: 0x1BCA0, Hi: 0x1BCA3, Stride: 1},
+ {Lo: 0x1D173, Hi: 0x1D17A, Stride: 1},
+ {Lo: 0xE0001, Hi: 0xE0001, Stride: 1},
+ },
+}
+
+var unicodeAliasWord_Break_Hebrew_Letter = &unicode.RangeTable{
+ R16: []unicode.Range16{
+ {Lo: 0x5D0, Hi: 0x5EA, Stride: 1},
+ {Lo: 0x5EF, Hi: 0x5F2, Stride: 1},
+ {Lo: 0xFB1D, Hi: 0xFB1D, Stride: 1},
+ {Lo: 0xFB1F, Hi: 0xFB28, Stride: 1},
+ {Lo: 0xFB2A, Hi: 0xFB36, Stride: 1},
+ {Lo: 0xFB38, Hi: 0xFB3C, Stride: 1},
+ {Lo: 0xFB3E, Hi: 0xFB3E, Stride: 1},
+ {Lo: 0xFB40, Hi: 0xFB41, Stride: 1},
+ {Lo: 0xFB43, Hi: 0xFB44, Stride: 1},
+ {Lo: 0xFB46, Hi: 0xFB4F, Stride: 1},
+ },
+}
+
+var unicodeAliasWord_Break_Katakana = &unicode.RangeTable{
+ R16: []unicode.Range16{
+ {Lo: 0x3031, Hi: 0x3035, Stride: 1},
+ {Lo: 0x309B, Hi: 0x309C, Stride: 1},
+ {Lo: 0x30A0, Hi: 0x30FA, Stride: 1},
+ {Lo: 0x30FC, Hi: 0x30FF, Stride: 1},
+ {Lo: 0x31F0, Hi: 0x31FF, Stride: 1},
+ {Lo: 0x32D0, Hi: 0x32FE, Stride: 1},
+ {Lo: 0x3300, Hi: 0x3357, Stride: 1},
+ {Lo: 0xFF66, Hi: 0xFF9D, Stride: 1},
+ },
+ R32: []unicode.Range32{
+ {Lo: 0x1AFF0, Hi: 0x1AFF3, Stride: 1},
+ {Lo: 0x1AFF5, Hi: 0x1AFFB, Stride: 1},
+ {Lo: 0x1AFFD, Hi: 0x1AFFE, Stride: 1},
+ {Lo: 0x1B000, Hi: 0x1B000, Stride: 1},
+ {Lo: 0x1B120, Hi: 0x1B122, Stride: 1},
+ {Lo: 0x1B155, Hi: 0x1B155, Stride: 1},
+ {Lo: 0x1B164, Hi: 0x1B167, Stride: 1},
+ },
+}
+
+var unicodeAliasWord_Break_LF = &unicode.RangeTable{
+ R16: []unicode.Range16{
+ {Lo: 0xA, Hi: 0xA, Stride: 1},
+ },
+}
+
+var unicodeAliasWord_Break_MidLetter = &unicode.RangeTable{
+ R16: []unicode.Range16{
+ {Lo: 0x3A, Hi: 0x3A, Stride: 1},
+ {Lo: 0xB7, Hi: 0xB7, Stride: 1},
+ {Lo: 0x387, Hi: 0x387, Stride: 1},
+ {Lo: 0x55F, Hi: 0x55F, Stride: 1},
+ {Lo: 0x5F4, Hi: 0x5F4, Stride: 1},
+ {Lo: 0x2027, Hi: 0x2027, Stride: 1},
+ {Lo: 0xFE13, Hi: 0xFE13, Stride: 1},
+ {Lo: 0xFE55, Hi: 0xFE55, Stride: 1},
+ {Lo: 0xFF1A, Hi: 0xFF1A, Stride: 1},
+ },
+}
+
+var unicodeAliasWord_Break_MidNum = &unicode.RangeTable{
+ R16: []unicode.Range16{
+ {Lo: 0x2C, Hi: 0x2C, Stride: 1},
+ {Lo: 0x3B, Hi: 0x3B, Stride: 1},
+ {Lo: 0x37E, Hi: 0x37E, Stride: 1},
+ {Lo: 0x589, Hi: 0x589, Stride: 1},
+ {Lo: 0x60C, Hi: 0x60D, Stride: 1},
+ {Lo: 0x66C, Hi: 0x66C, Stride: 1},
+ {Lo: 0x7F8, Hi: 0x7F8, Stride: 1},
+ {Lo: 0x2044, Hi: 0x2044, Stride: 1},
+ {Lo: 0xFE50, Hi: 0xFE50, Stride: 1},
+ {Lo: 0xFE54, Hi: 0xFE54, Stride: 1},
+ {Lo: 0xFF0C, Hi: 0xFF0C, Stride: 1},
+ {Lo: 0xFF1B, Hi: 0xFF1B, Stride: 1},
+ },
+}
+
+var unicodeAliasWord_Break_MidNumLet = &unicode.RangeTable{
+ R16: []unicode.Range16{
+ {Lo: 0x2E, Hi: 0x2E, Stride: 1},
+ {Lo: 0x2018, Hi: 0x2019, Stride: 1},
+ {Lo: 0x2024, Hi: 0x2024, Stride: 1},
+ {Lo: 0xFE52, Hi: 0xFE52, Stride: 1},
+ {Lo: 0xFF07, Hi: 0xFF07, Stride: 1},
+ {Lo: 0xFF0E, Hi: 0xFF0E, Stride: 1},
+ },
+}
+
+var unicodeAliasWord_Break_Newline = &unicode.RangeTable{
+ R16: []unicode.Range16{
+ {Lo: 0xB, Hi: 0xC, Stride: 1},
+ {Lo: 0x85, Hi: 0x85, Stride: 1},
+ {Lo: 0x2028, Hi: 0x2029, Stride: 1},
+ },
+}
+
+var unicodeAliasWord_Break_Numeric = &unicode.RangeTable{
+ R16: []unicode.Range16{
+ {Lo: 0x30, Hi: 0x39, Stride: 1},
+ {Lo: 0x600, Hi: 0x605, Stride: 1},
+ {Lo: 0x660, Hi: 0x669, Stride: 1},
+ {Lo: 0x66B, Hi: 0x66B, Stride: 1},
+ {Lo: 0x6DD, Hi: 0x6DD, Stride: 1},
+ {Lo: 0x6F0, Hi: 0x6F9, Stride: 1},
+ {Lo: 0x7C0, Hi: 0x7C9, Stride: 1},
+ {Lo: 0x890, Hi: 0x891, Stride: 1},
+ {Lo: 0x8E2, Hi: 0x8E2, Stride: 1},
+ {Lo: 0x966, Hi: 0x96F, Stride: 1},
+ {Lo: 0x9E6, Hi: 0x9EF, Stride: 1},
+ {Lo: 0xA66, Hi: 0xA6F, Stride: 1},
+ {Lo: 0xAE6, Hi: 0xAEF, Stride: 1},
+ {Lo: 0xB66, Hi: 0xB6F, Stride: 1},
+ {Lo: 0xBE6, Hi: 0xBEF, Stride: 1},
+ {Lo: 0xC66, Hi: 0xC6F, Stride: 1},
+ {Lo: 0xCE6, Hi: 0xCEF, Stride: 1},
+ {Lo: 0xD66, Hi: 0xD6F, Stride: 1},
+ {Lo: 0xDE6, Hi: 0xDEF, Stride: 1},
+ {Lo: 0xE50, Hi: 0xE59, Stride: 1},
+ {Lo: 0xED0, Hi: 0xED9, Stride: 1},
+ {Lo: 0xF20, Hi: 0xF29, Stride: 1},
+ {Lo: 0x1040, Hi: 0x1049, Stride: 1},
+ {Lo: 0x1090, Hi: 0x1099, Stride: 1},
+ {Lo: 0x17E0, Hi: 0x17E9, Stride: 1},
+ {Lo: 0x1810, Hi: 0x1819, Stride: 1},
+ {Lo: 0x1946, Hi: 0x194F, Stride: 1},
+ {Lo: 0x19D0, Hi: 0x19DA, Stride: 1},
+ {Lo: 0x1A80, Hi: 0x1A89, Stride: 1},
+ {Lo: 0x1A90, Hi: 0x1A99, Stride: 1},
+ {Lo: 0x1B50, Hi: 0x1B59, Stride: 1},
+ {Lo: 0x1BB0, Hi: 0x1BB9, Stride: 1},
+ {Lo: 0x1C40, Hi: 0x1C49, Stride: 1},
+ {Lo: 0x1C50, Hi: 0x1C59, Stride: 1},
+ {Lo: 0xA620, Hi: 0xA629, Stride: 1},
+ {Lo: 0xA8D0, Hi: 0xA8D9, Stride: 1},
+ {Lo: 0xA900, Hi: 0xA909, Stride: 1},
+ {Lo: 0xA9D0, Hi: 0xA9D9, Stride: 1},
+ {Lo: 0xA9F0, Hi: 0xA9F9, Stride: 1},
+ {Lo: 0xAA50, Hi: 0xAA59, Stride: 1},
+ {Lo: 0xABF0, Hi: 0xABF9, Stride: 1},
+ {Lo: 0xFF10, Hi: 0xFF19, Stride: 1},
+ },
+ R32: []unicode.Range32{
+ {Lo: 0x104A0, Hi: 0x104A9, Stride: 1},
+ {Lo: 0x10D30, Hi: 0x10D39, Stride: 1},
+ {Lo: 0x10D40, Hi: 0x10D49, Stride: 1},
+ {Lo: 0x11066, Hi: 0x1106F, Stride: 1},
+ {Lo: 0x110BD, Hi: 0x110BD, Stride: 1},
+ {Lo: 0x110CD, Hi: 0x110CD, Stride: 1},
+ {Lo: 0x110F0, Hi: 0x110F9, Stride: 1},
+ {Lo: 0x11136, Hi: 0x1113F, Stride: 1},
+ {Lo: 0x111D0, Hi: 0x111D9, Stride: 1},
+ {Lo: 0x112F0, Hi: 0x112F9, Stride: 1},
+ {Lo: 0x11450, Hi: 0x11459, Stride: 1},
+ {Lo: 0x114D0, Hi: 0x114D9, Stride: 1},
+ {Lo: 0x11650, Hi: 0x11659, Stride: 1},
+ {Lo: 0x116C0, Hi: 0x116C9, Stride: 1},
+ {Lo: 0x116D0, Hi: 0x116E3, Stride: 1},
+ {Lo: 0x11730, Hi: 0x11739, Stride: 1},
+ {Lo: 0x118E0, Hi: 0x118E9, Stride: 1},
+ {Lo: 0x11950, Hi: 0x11959, Stride: 1},
+ {Lo: 0x11BF0, Hi: 0x11BF9, Stride: 1},
+ {Lo: 0x11C50, Hi: 0x11C59, Stride: 1},
+ {Lo: 0x11D50, Hi: 0x11D59, Stride: 1},
+ {Lo: 0x11DA0, Hi: 0x11DA9, Stride: 1},
+ {Lo: 0x11DE0, Hi: 0x11DE9, Stride: 1},
+ {Lo: 0x11F50, Hi: 0x11F59, Stride: 1},
+ {Lo: 0x16130, Hi: 0x16139, Stride: 1},
+ {Lo: 0x16A60, Hi: 0x16A69, Stride: 1},
+ {Lo: 0x16AC0, Hi: 0x16AC9, Stride: 1},
+ {Lo: 0x16B50, Hi: 0x16B59, Stride: 1},
+ {Lo: 0x16D70, Hi: 0x16D79, Stride: 1},
+ {Lo: 0x1CCF0, Hi: 0x1CCF9, Stride: 1},
+ {Lo: 0x1D7CE, Hi: 0x1D7FF, Stride: 1},
+ {Lo: 0x1E140, Hi: 0x1E149, Stride: 1},
+ {Lo: 0x1E2F0, Hi: 0x1E2F9, Stride: 1},
+ {Lo: 0x1E4F0, Hi: 0x1E4F9, Stride: 1},
+ {Lo: 0x1E5F1, Hi: 0x1E5FA, Stride: 1},
+ {Lo: 0x1E950, Hi: 0x1E959, Stride: 1},
+ {Lo: 0x1FBF0, Hi: 0x1FBF9, Stride: 1},
+ },
+}
+
+var unicodeAliasWord_Break_Regional_Indicator = &unicode.RangeTable{
+ R32: []unicode.Range32{
+ {Lo: 0x1F1E6, Hi: 0x1F1FF, Stride: 1},
+ },
+}
+
+var unicodeAliasWord_Break_Single_Quote = &unicode.RangeTable{
+ R16: []unicode.Range16{
+ {Lo: 0x27, Hi: 0x27, Stride: 1},
+ },
+}
+
+var unicodeAliasWord_Break_WSegSpace = &unicode.RangeTable{
+ R16: []unicode.Range16{
+ {Lo: 0x20, Hi: 0x20, Stride: 1},
+ {Lo: 0x1680, Hi: 0x1680, Stride: 1},
+ {Lo: 0x2000, Hi: 0x2006, Stride: 1},
+ {Lo: 0x2008, Hi: 0x200A, Stride: 1},
+ {Lo: 0x205F, Hi: 0x205F, Stride: 1},
+ {Lo: 0x3000, Hi: 0x3000, Stride: 1},
+ },
+}
+
+var unicodeAliasWord_Break_ZWJ = &unicode.RangeTable{
+ R16: []unicode.Range16{
+ {Lo: 0x200D, Hi: 0x200D, Stride: 1},
+ },
+}
diff --git a/vendor/github.com/dlclark/regexp2/v2/syntax/writer.go b/vendor/github.com/dlclark/regexp2/v2/syntax/writer.go
new file mode 100644
index 0000000000..818b4b56c3
--- /dev/null
+++ b/vendor/github.com/dlclark/regexp2/v2/syntax/writer.go
@@ -0,0 +1,500 @@
+package syntax
+
+import (
+ "bytes"
+ "fmt"
+ "math"
+)
+
+func Write(tree *RegexTree) (*Code, error) {
+ w := writer{
+ intStack: make([]int, 0, 32),
+ emitted: make([]int, 2),
+ stringhash: make(map[string]int),
+ sethash: make(map[string]int),
+ }
+
+ code, err := w.codeFromTree(tree)
+
+ return code, err
+}
+
+type writer struct {
+ emitted []int
+
+ intStack []int
+ curpos int
+ stringhash map[string]int
+ stringtable [][]rune
+ sethash map[string]int
+ settable []*CharSet
+ counting bool
+ count int
+ trackcount int
+ caps map[int]int
+}
+
+const (
+ BeforeChild NodeType = 64
+ AfterChild NodeType = 128
+ //MaxPrefixSize is the largest number of runes we'll use for a BoyerMoyer prefix
+ MaxPrefixSize = 50
+)
+
+// The top level RegexCode generator. It does a depth-first walk
+// through the tree and calls EmitFragment to emits code before
+// and after each child of an interior node, and at each leaf.
+//
+// It runs two passes, first to count the size of the generated
+// code, and second to generate the code.
+//
+// We should time it against the alternative, which is
+// to just generate the code and grow the array as we go.
+func (w *writer) codeFromTree(tree *RegexTree) (*Code, error) {
+ var (
+ curNode *RegexNode
+ curChild int
+ capsize int
+ )
+ // construct sparse capnum mapping if some numbers are unused
+
+ if tree.Capnumlist == nil || tree.Captop == len(tree.Capnumlist) {
+ capsize = tree.Captop
+ w.caps = nil
+ } else {
+ capsize = len(tree.Capnumlist)
+ w.caps = tree.Caps
+ for i := 0; i < len(tree.Capnumlist); i++ {
+ w.caps[tree.Capnumlist[i]] = i
+ }
+ }
+
+ w.counting = true
+
+ for {
+ if !w.counting {
+ w.emitted = make([]int, w.count)
+ }
+
+ curNode = tree.Root
+ curChild = 0
+
+ w.emit1(Lazybranch, 0)
+
+ for {
+ if len(curNode.Children) == 0 {
+ if err := w.emitFragment(curNode.T, curNode, 0); err != nil {
+ return nil, err
+ }
+ } else if curChild < len(curNode.Children) {
+ if err := w.emitFragment(curNode.T|BeforeChild, curNode, curChild); err != nil {
+ return nil, err
+ }
+
+ curNode = curNode.Children[curChild]
+
+ w.pushInt(curChild)
+ curChild = 0
+ continue
+ }
+
+ if w.emptyStack() {
+ break
+ }
+
+ curChild = w.popInt()
+ curNode = curNode.Parent
+
+ if err := w.emitFragment(curNode.T|AfterChild, curNode, curChild); err != nil {
+ return nil, err
+ }
+ curChild++
+ }
+
+ w.patchJump(0, w.curPos())
+ w.emit(Stop)
+
+ if !w.counting {
+ break
+ }
+
+ w.counting = false
+ }
+
+ fcPrefix := getFirstCharsPrefix(tree)
+ prefix := getPrefix(tree)
+ rtl := (tree.Options & RightToLeft) != 0
+
+ var bmPrefix *BmPrefix
+ //TODO: benchmark string prefixes
+ if prefix != nil && len(prefix.PrefixStr) > 0 && MaxPrefixSize > 0 {
+ if len(prefix.PrefixStr) > MaxPrefixSize {
+ // limit prefix changes to 10k
+ prefix.PrefixStr = prefix.PrefixStr[:MaxPrefixSize]
+ }
+ bmPrefix = newBmPrefix(prefix.PrefixStr, prefix.CaseInsensitive, rtl)
+ } else {
+ bmPrefix = nil
+ }
+
+ return &Code{
+ Codes: w.emitted,
+ Strings: w.stringtable,
+ Sets: w.settable,
+ TrackCount: w.trackcount,
+ Caps: w.caps,
+ Capsize: capsize,
+ FcPrefix: fcPrefix,
+ BmPrefix: bmPrefix,
+ Anchors: getAnchors(tree),
+ RightToLeft: rtl,
+ FindOptimizations: tree.FindOptimizations,
+ }, nil
+}
+
+// The main RegexCode generator. It does a depth-first walk
+// through the tree and calls EmitFragment to emits code before
+// and after each child of an interior node, and at each leaf.
+func (w *writer) emitFragment(nodetype NodeType, node *RegexNode, curIndex int) error {
+ bits := InstOp(0)
+
+ if (node.Options & RightToLeft) != 0 {
+ bits |= Rtl
+ }
+ if (node.Options & IgnoreCase) != 0 {
+ bits |= Ci
+ }
+
+ ntBits := NodeType(bits)
+
+ switch nodetype {
+ case NtConcatenate | BeforeChild, NtConcatenate | AfterChild, NtEmpty:
+
+ case NtAlternate | BeforeChild:
+ if curIndex < len(node.Children)-1 {
+ w.pushInt(w.curPos())
+ w.emit1(Lazybranch, 0)
+ }
+
+ case NtAlternate | AfterChild:
+ if curIndex < len(node.Children)-1 {
+ lbPos := w.popInt()
+ w.pushInt(w.curPos())
+ w.emit1(Goto, 0)
+ w.patchJump(lbPos, w.curPos())
+ } else {
+ for i := 0; i < curIndex; i++ {
+ w.patchJump(w.popInt(), w.curPos())
+ }
+ }
+
+ case NtBackRefCond | BeforeChild:
+ if curIndex == 0 {
+ w.emit(Setjump)
+ w.pushInt(w.curPos())
+ w.emit1(Lazybranch, 0)
+ w.emit1(Testref, w.mapCapnum(node.M))
+ w.emit(Forejump)
+ }
+
+ case NtBackRefCond | AfterChild:
+ switch curIndex {
+ case 0:
+ branchpos := w.popInt()
+ w.pushInt(w.curPos())
+ w.emit1(Goto, 0)
+ w.patchJump(branchpos, w.curPos())
+ w.emit(Forejump)
+ if len(node.Children) <= 1 {
+ w.patchJump(w.popInt(), w.curPos())
+ }
+ case 1:
+ w.patchJump(w.popInt(), w.curPos())
+ }
+
+ case NtExprCond | BeforeChild:
+ if curIndex == 0 {
+ w.emit(Setjump)
+ w.emit(Setmark)
+ w.pushInt(w.curPos())
+ w.emit1(Lazybranch, 0)
+ }
+
+ case NtExprCond | AfterChild:
+ switch curIndex {
+ case 0:
+ w.emit(Getmark)
+ w.emit(Forejump)
+ case 1:
+ branchpos := w.popInt()
+ w.pushInt(w.curPos())
+ w.emit1(Goto, 0)
+ w.patchJump(branchpos, w.curPos())
+ w.emit(Getmark)
+ w.emit(Forejump)
+ if len(node.Children) <= 2 {
+ w.patchJump(w.popInt(), w.curPos())
+ }
+ case 2:
+ w.patchJump(w.popInt(), w.curPos())
+ }
+
+ case NtLoop | BeforeChild, NtLazyloop | BeforeChild:
+
+ if node.N < math.MaxInt32 || node.M > 1 {
+ if node.M == 0 {
+ w.emit1(Nullcount, 0)
+ } else {
+ w.emit1(Setcount, 1-node.M)
+ }
+ } else if node.M == 0 {
+ w.emit(Nullmark)
+ } else {
+ w.emit(Setmark)
+ }
+
+ if node.M == 0 {
+ w.pushInt(w.curPos())
+ w.emit1(Goto, 0)
+ }
+ w.pushInt(w.curPos())
+
+ case NtLoop | AfterChild, NtLazyloop | AfterChild:
+
+ startJumpPos := w.curPos()
+ lazy := InstOp(nodetype - (NtLoop | AfterChild))
+
+ if node.N < math.MaxInt32 || node.M > 1 {
+ if node.N == math.MaxInt32 {
+ w.emit2(Branchcount+lazy, w.popInt(), math.MaxInt32)
+ } else {
+ w.emit2(Branchcount+lazy, w.popInt(), node.N-node.M)
+ }
+ } else {
+ w.emit1(Branchmark+lazy, w.popInt())
+ }
+
+ if node.M == 0 {
+ w.patchJump(w.popInt(), startJumpPos)
+ }
+
+ case NtGroup | BeforeChild, NtGroup | AfterChild:
+
+ case NtCapture | BeforeChild:
+ w.emit(Setmark)
+
+ case NtCapture | AfterChild:
+ w.emit2(Capturemark, w.mapCapnum(node.M), w.mapCapnum(node.N))
+
+ case NtPosLook | BeforeChild:
+ // NOTE: the following line causes lookahead/lookbehind to be
+ // NON-BACKTRACKING. It can be commented out with (*)
+ w.emit(Setjump)
+
+ w.emit(Setmark)
+
+ case NtPosLook | AfterChild:
+ w.emit(Getmark)
+
+ // NOTE: the following line causes lookahead/lookbehind to be
+ // NON-BACKTRACKING. It can be commented out with (*)
+ w.emit(Forejump)
+
+ case NtNegLook | BeforeChild:
+ w.emit(Setjump)
+ w.pushInt(w.curPos())
+ w.emit1(Lazybranch, 0)
+
+ case NtNegLook | AfterChild:
+ w.emit(Backjump)
+ w.patchJump(w.popInt(), w.curPos())
+ w.emit(Forejump)
+
+ case NtAtomic | BeforeChild:
+ w.emit(Setjump)
+
+ case NtAtomic | AfterChild:
+ w.emit(Forejump)
+
+ case NtOne, NtNotone:
+ w.emit1(InstOp(node.T|ntBits), int(node.Ch))
+
+ case NtNotoneloop, NtNotoneloopatomic, NtNotonelazy, NtOneloop, NtOneloopatomic, NtOnelazy:
+ if node.M > 0 {
+ if node.T == NtOneloop || node.T == NtOnelazy || node.T == NtOneloopatomic {
+ w.emit2(Onerep|bits, int(node.Ch), node.M)
+ } else {
+ w.emit2(Notonerep|bits, int(node.Ch), node.M)
+ }
+ }
+ if node.N > node.M {
+ if node.N == math.MaxInt32 {
+ w.emit2(InstOp(node.T|ntBits), int(node.Ch), math.MaxInt32)
+ } else {
+ w.emit2(InstOp(node.T|ntBits), int(node.Ch), node.N-node.M)
+ }
+ }
+
+ case NtSetloop, NtSetlazy, NtSetloopatomic:
+ if node.M > 0 {
+ w.emit2(Setrep|bits, w.setCode(node.Set), node.M)
+ }
+ if node.N > node.M {
+ if node.N == math.MaxInt32 {
+ w.emit2(InstOp(node.T|ntBits), w.setCode(node.Set), math.MaxInt32)
+ } else {
+ w.emit2(InstOp(node.T|ntBits), w.setCode(node.Set), node.N-node.M)
+ }
+ }
+
+ case NtMulti:
+ w.emit1(InstOp(node.T|ntBits), w.stringCode(node.Str))
+
+ case NtSet:
+ w.emit1(InstOp(node.T|ntBits), w.setCode(node.Set))
+
+ case NtRef:
+ w.emit1(InstOp(node.T|ntBits), w.mapCapnum(node.M))
+
+ case NtNothing, NtBol, NtEol, NtBoundary, NtNonboundary, NtECMABoundary, NtNonECMABoundary, NtBeginning, NtStart, NtEndZ, NtEnd, NtUpdateBumpalong:
+ w.emit(InstOp(node.T))
+
+ default:
+ return fmt.Errorf("unexpected opcode in regular expression generation: %v", nodetype)
+ }
+
+ return nil
+}
+
+// To avoid recursion, we use a simple integer stack.
+// This is the push.
+func (w *writer) pushInt(i int) {
+ w.intStack = append(w.intStack, i)
+}
+
+// Returns true if the stack is empty.
+func (w *writer) emptyStack() bool {
+ return len(w.intStack) == 0
+}
+
+// This is the pop.
+func (w *writer) popInt() int {
+ //get our item
+ idx := len(w.intStack) - 1
+ i := w.intStack[idx]
+ //trim our slice
+ w.intStack = w.intStack[:idx]
+ return i
+}
+
+// Returns the current position in the emitted code.
+func (w *writer) curPos() int {
+ return w.curpos
+}
+
+// Fixes up a jump instruction at the specified offset
+// so that it jumps to the specified jumpDest.
+func (w *writer) patchJump(offset, jumpDest int) {
+ w.emitted[offset+1] = jumpDest
+}
+
+// Returns an index in the set table for a charset
+// uses a map to eliminate duplicates.
+func (w *writer) setCode(set *CharSet) int {
+ if w.counting {
+ return 0
+ }
+
+ buf := &bytes.Buffer{}
+
+ set.mapHashFill(buf)
+ hash := buf.String()
+ i, ok := w.sethash[hash]
+ if !ok {
+ i = len(w.sethash)
+ w.sethash[hash] = i
+ w.settable = append(w.settable, set)
+ }
+ return i
+}
+
+// Returns an index in the string table for a string.
+// uses a map to eliminate duplicates.
+func (w *writer) stringCode(str []rune) int {
+ if w.counting {
+ return 0
+ }
+
+ hash := string(str)
+ i, ok := w.stringhash[hash]
+ if !ok {
+ i = len(w.stringhash)
+ w.stringhash[hash] = i
+ w.stringtable = append(w.stringtable, str)
+ }
+
+ return i
+}
+
+// When generating code on a regex that uses a sparse set
+// of capture slots, we hash them to a dense set of indices
+// for an array of capture slots. Instead of doing the hash
+// at match time, it's done at compile time, here.
+func (w *writer) mapCapnum(capnum int) int {
+ if capnum == -1 {
+ return -1
+ }
+
+ if w.caps != nil {
+ return w.caps[capnum]
+ }
+
+ return capnum
+}
+
+// Emits a zero-argument operation. Note that the emit
+// functions all run in two modes: they can emit code, or
+// they can just count the size of the code.
+func (w *writer) emit(op InstOp) {
+ if w.counting {
+ w.count++
+ if opcodeBacktracks(op) {
+ w.trackcount++
+ }
+ return
+ }
+ w.emitted[w.curpos] = int(op)
+ w.curpos++
+}
+
+// Emits a one-argument operation.
+func (w *writer) emit1(op InstOp, opd1 int) {
+ if w.counting {
+ w.count += 2
+ if opcodeBacktracks(op) {
+ w.trackcount++
+ }
+ return
+ }
+ w.emitted[w.curpos] = int(op)
+ w.curpos++
+ w.emitted[w.curpos] = opd1
+ w.curpos++
+}
+
+// Emits a two-argument operation.
+func (w *writer) emit2(op InstOp, opd1, opd2 int) {
+ if w.counting {
+ w.count += 3
+ if opcodeBacktracks(op) {
+ w.trackcount++
+ }
+ return
+ }
+ w.emitted[w.curpos] = int(op)
+ w.curpos++
+ w.emitted[w.curpos] = opd1
+ w.curpos++
+ w.emitted[w.curpos] = opd2
+ w.curpos++
+}
diff --git a/vendor/github.com/firefart/nonamedreturns/analyzer/analyzer.go b/vendor/github.com/firefart/nonamedreturns/analyzer/analyzer.go
index ecd4915a8b..745120769a 100644
--- a/vendor/github.com/firefart/nonamedreturns/analyzer/analyzer.go
+++ b/vendor/github.com/firefart/nonamedreturns/analyzer/analyzer.go
@@ -1,8 +1,10 @@
package analyzer
import (
+ "errors"
"flag"
"go/ast"
+ "go/token"
"go/types"
"golang.org/x/tools/go/analysis"
@@ -10,7 +12,10 @@ import (
"golang.org/x/tools/go/ast/inspector"
)
-const FlagReportErrorInDefer = "report-error-in-defer"
+const (
+ FlagReportErrorInDefer = "report-error-in-defer"
+ FlagAllowUnusedNamedReturns = "allow-unused-named-returns"
+)
var Analyzer = &analysis.Analyzer{
Name: "nonamedreturns",
@@ -23,16 +28,21 @@ var Analyzer = &analysis.Analyzer{
func flags() flag.FlagSet {
fs := flag.FlagSet{}
fs.Bool(FlagReportErrorInDefer, false, "report named error if it is assigned inside defer")
+ fs.Bool(FlagAllowUnusedNamedReturns, false, "allow named returns in the signature but report them if referenced in the body or used by a naked return")
return fs
}
-func run(pass *analysis.Pass) (interface{}, error) {
+func run(pass *analysis.Pass) (any, error) {
reportErrorInDefer := pass.Analyzer.Flags.Lookup(FlagReportErrorInDefer).Value.String() == "true"
+ allowUnusedNamedReturns := pass.Analyzer.Flags.Lookup(FlagAllowUnusedNamedReturns).Value.String() == "true"
errorType := types.Universe.Lookup("error").Type()
- inspector := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
+ inspector, ok := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
+ if !ok {
+ return nil, errors.New("failed to get inspector")
+ }
- // only filter function defintions
+ // only filter function definitions
nodeFilter := []ast.Node{
(*ast.FuncDecl)(nil),
(*ast.FuncLit)(nil),
@@ -63,77 +73,202 @@ func run(pass *analysis.Pass) (interface{}, error) {
return
}
- resultsList := funcResults.List
+ if allowUnusedNamedReturns {
+ var referenced map[types.Object]bool
+ var hasNakedReturn bool
+ usageComputed := false
+
+ for _, p := range funcResults.List {
+ if len(p.Names) == 0 {
+ continue
+ }
- for _, p := range resultsList {
+ for _, n := range p.Names {
+ if n.Name == "_" {
+ continue
+ }
+
+ if !usageComputed {
+ referenced, hasNakedReturn = collectNamedReturnUsage(funcBody, pass.TypesInfo)
+ usageComputed = true
+ }
+
+ obj := pass.TypesInfo.ObjectOf(n)
+ if referenced[obj] || hasNakedReturn {
+ pass.Reportf(n.Pos(), "named return %q with type %q must not be referenced or used by a naked return", n.Name, types.ExprString(p.Type))
+ }
+ }
+ }
+
+ return
+ }
+
+ // existing behavior: report every named return (subject to the
+ // error-in-defer exemption)
+
+ // deferUsed, assigned and hasReturnWithResults are computed lazily and
+ // at most once per function: the relatively expensive body walk only
+ // happens when there is an error-typed named return whose defer
+ // exemption we need to check.
+ var deferUsed, assigned map[types.Object]bool
+ var hasReturnWithResults bool
+
+ for _, p := range funcResults.List {
if len(p.Names) == 0 {
// all good, the parameter is not named
continue
}
+ isError := types.Identical(pass.TypesInfo.TypeOf(p.Type), errorType)
+
for _, n := range p.Names {
if n.Name == "_" {
continue
}
- if !reportErrorInDefer &&
- types.Identical(pass.TypesInfo.TypeOf(p.Type), errorType) &&
- findDeferWithVariableAssignment(funcBody, pass.TypesInfo, pass.TypesInfo.ObjectOf(n)) {
- continue
+ // A named error return is allowed when it is referenced inside a defer
+ // (e.g. to inspect or modify it before returning) as long as it is also
+ // assigned somewhere in the function body. The assignment may happen
+ // inside the defer itself, anywhere else in the function, or implicitly
+ // via a `return` statement with result values (which assigns every
+ // named return before the defers run).
+ if !reportErrorInDefer && isError {
+ if deferUsed == nil {
+ deferUsed, assigned, hasReturnWithResults = collectDeferUsageAndAssignments(funcBody, pass.TypesInfo)
+ }
+
+ obj := pass.TypesInfo.ObjectOf(n)
+ if deferUsed[obj] && (assigned[obj] || hasReturnWithResults) {
+ continue
+ }
}
- pass.Reportf(node.Pos(), "named return %q with type %q found", n.Name, types.ExprString(p.Type))
+ pass.Reportf(n.Pos(), "named return %q with type %q found", n.Name, types.ExprString(p.Type))
}
}
})
- return nil, nil
+ return nil, nil // nolint:nilnil
}
-func findDeferWithVariableAssignment(body *ast.BlockStmt, info *types.Info, variable types.Object) bool {
- found := false
+// collectDeferUsageAndAssignments walks body a single time and returns:
+// - deferUsed: objects referenced (read or written) inside a deferred func literal
+// - assigned: objects that appear on the left-hand side of an assignment
+// (including `for ... = range` statements) anywhere in the body, including
+// inside a deferred func literal
+// - hasReturnWithResults: true if the body contains a `return` statement with
+// result values at the top level of the function. Such a return implicitly
+// assigns every named return before the defers run, so it counts as an
+// assignment for all of them. Returns inside nested closures (including the
+// deferred closure itself) populate the closure's own results and are
+// therefore excluded.
+//
+// Variable shadowing is handled naturally: a shadowed declaration introduces a
+// distinct types.Object, so it does not match the outer named return.
+func collectDeferUsageAndAssignments(body *ast.BlockStmt, info *types.Info) (map[types.Object]bool, map[types.Object]bool, bool) {
+ deferUsed := make(map[types.Object]bool)
+ assigned := make(map[types.Object]bool)
+ hasReturnWithResults := false
- ast.Inspect(body, func(node ast.Node) bool {
- if found {
- return false // stop inspection
+ markAssigned := func(expr ast.Expr) {
+ if i, ok := expr.(*ast.Ident); ok {
+ if obj := info.ObjectOf(i); obj != nil {
+ assigned[obj] = true
+ }
}
+ }
- if d, ok := node.(*ast.DeferStmt); ok {
- if fn, ok2 := d.Call.Fun.(*ast.FuncLit); ok2 {
- if findVariableAssignment(fn.Body, info, variable) {
- found = true
- return false
+ var walk func(node ast.Node, inClosure bool)
+ walk = func(node ast.Node, inClosure bool) {
+ ast.Inspect(node, func(n ast.Node) bool {
+ switch x := n.(type) {
+ case *ast.AssignStmt:
+ for _, lh := range x.Lhs {
+ markAssigned(lh)
}
+ case *ast.RangeStmt:
+ if x.Tok == token.ASSIGN {
+ if x.Key != nil {
+ markAssigned(x.Key)
+ }
+ if x.Value != nil {
+ markAssigned(x.Value)
+ }
+ }
+ case *ast.ReturnStmt:
+ // a return inside a closure populates the closure's own
+ // results, not the enclosing function's named returns
+ if !inClosure && len(x.Results) > 0 {
+ hasReturnWithResults = true
+ }
+ case *ast.DeferStmt:
+ if fn, ok := x.Call.Fun.(*ast.FuncLit); ok {
+ ast.Inspect(fn.Body, func(inner ast.Node) bool {
+ if i, ok := inner.(*ast.Ident); ok {
+ if obj := info.ObjectOf(i); obj != nil {
+ deferUsed[obj] = true
+ }
+ }
+ return true
+ })
+ }
+ // keep descending (via the FuncLit case below) so assignments
+ // and nested defers inside the deferred closure are still
+ // collected by the outer walk
+ case *ast.FuncLit:
+ // everything inside a closure (deferred or not) is in-closure
+ // for return purposes, but assignments to captured named
+ // returns still count
+ walk(x.Body, true)
+ return false
}
- }
-
- return true
- })
+ return true
+ })
+ }
+ walk(body, false)
- return found
+ return deferUsed, assigned, hasReturnWithResults
}
-func findVariableAssignment(body *ast.BlockStmt, info *types.Info, variable types.Object) bool {
- found := false
+// collectNamedReturnUsage walks body a single time and returns:
+// - referenced: objects referenced (read or written) anywhere in the body,
+// including inside nested closures (which may capture the outer named return)
+// - hasNakedReturn: true if the body contains a return statement with no result
+// expressions at the top level of the function (naked returns inside nested
+// closures are excluded because they populate the closure's own results, not
+// the enclosing function's named returns)
+//
+// Shadowing is handled naturally: a shadowed declaration introduces a distinct
+// types.Object, so it does not match the outer named return.
+func collectNamedReturnUsage(body *ast.BlockStmt, info *types.Info) (map[types.Object]bool, bool) {
+ referenced := make(map[types.Object]bool)
+ hasNakedReturn := false
- ast.Inspect(body, func(node ast.Node) bool {
- if found {
- return false // stop inspection
- }
-
- if a, ok := node.(*ast.AssignStmt); ok {
- for _, lh := range a.Lhs {
- if i, ok2 := lh.(*ast.Ident); ok2 {
- if info.ObjectOf(i) == variable {
- found = true
- return false
- }
+ var walk func(node ast.Node, inClosure bool)
+ walk = func(node ast.Node, inClosure bool) {
+ ast.Inspect(node, func(n ast.Node) bool {
+ switch x := n.(type) {
+ case *ast.Ident:
+ if obj := info.ObjectOf(x); obj != nil {
+ referenced[obj] = true
}
+ case *ast.ReturnStmt:
+ // a naked return inside a closure populates the closure's
+ // own results, not the enclosing function's named returns
+ if !inClosure && len(x.Results) == 0 {
+ hasNakedReturn = true
+ }
+ case *ast.FuncLit:
+ // keep collecting referenced identifiers (closures can
+ // capture the outer named return), but everything inside
+ // the closure is in-closure for naked-return purposes
+ walk(x.Body, true)
+ return false
}
- }
-
- return true
- })
+ return true
+ })
+ }
+ walk(body, false)
- return found
+ return referenced, hasNakedReturn
}
diff --git a/vendor/github.com/ghostiam/protogetter/README.md b/vendor/github.com/ghostiam/protogetter/README.md
index c033e9597f..9322d69b62 100644
--- a/vendor/github.com/ghostiam/protogetter/README.md
+++ b/vendor/github.com/ghostiam/protogetter/README.md
@@ -54,13 +54,35 @@ v := m.Foo.Bar.Baz.Int
which simplifies the code and makes it more reliable.
-## Installation
+## Usage
+
+### Recommended way — via golangci-lint
+
+Protogetter is integrated into [golangci-lint](https://github.com/golangci/golangci-lint) and can be run together with other linters. This is the preferred way to use it in most projects.
+
+Example minimal `.golangci.yml` configuration:
+
+```yaml
+linters:
+ enable:
+ - protogetter
+```
+
+Run:
+
+```bash
+golangci-lint run ./...
+```
+
+## Standalone usage
+
+### Installation
```bash
go install github.com/ghostiam/protogetter/cmd/protogetter@latest
```
-## Usage
+### Direct run
To run the linter:
```bash
diff --git a/vendor/github.com/ghostiam/protogetter/flake.lock b/vendor/github.com/ghostiam/protogetter/flake.lock
new file mode 100644
index 0000000000..ae76b78c31
--- /dev/null
+++ b/vendor/github.com/ghostiam/protogetter/flake.lock
@@ -0,0 +1,61 @@
+{
+ "nodes": {
+ "flake-utils": {
+ "inputs": {
+ "systems": "systems"
+ },
+ "locked": {
+ "lastModified": 1731533236,
+ "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
+ "owner": "numtide",
+ "repo": "flake-utils",
+ "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
+ "type": "github"
+ },
+ "original": {
+ "owner": "numtide",
+ "repo": "flake-utils",
+ "type": "github"
+ }
+ },
+ "nixpkgs": {
+ "locked": {
+ "lastModified": 1777954456,
+ "narHash": "sha256-hGdgeU2Nk87RAuZyYjyDjFL6LK7dAZN5RE9+hrDTkDU=",
+ "owner": "NixOS",
+ "repo": "nixpkgs",
+ "rev": "549bd84d6279f9852cae6225e372cc67fb91a4c1",
+ "type": "github"
+ },
+ "original": {
+ "owner": "NixOS",
+ "ref": "nixos-unstable",
+ "repo": "nixpkgs",
+ "type": "github"
+ }
+ },
+ "root": {
+ "inputs": {
+ "flake-utils": "flake-utils",
+ "nixpkgs": "nixpkgs"
+ }
+ },
+ "systems": {
+ "locked": {
+ "lastModified": 1681028828,
+ "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
+ "owner": "nix-systems",
+ "repo": "default",
+ "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
+ "type": "github"
+ },
+ "original": {
+ "owner": "nix-systems",
+ "repo": "default",
+ "type": "github"
+ }
+ }
+ },
+ "root": "root",
+ "version": 7
+}
diff --git a/vendor/github.com/ghostiam/protogetter/flake.nix b/vendor/github.com/ghostiam/protogetter/flake.nix
new file mode 100644
index 0000000000..ce7498493d
--- /dev/null
+++ b/vendor/github.com/ghostiam/protogetter/flake.nix
@@ -0,0 +1,70 @@
+{
+ description = "A flake that builds a repo";
+
+ inputs = {
+ nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
+ flake-utils.url = "github:numtide/flake-utils";
+ };
+
+ outputs =
+ inputs@{
+ nixpkgs,
+ flake-utils,
+ ...
+ }:
+ flake-utils.lib.eachDefaultSystem (
+ system:
+ let
+ pkgs = import nixpkgs { inherit system; };
+ go = pkgs.go_1_26;
+ buildInputs = with pkgs; [
+ go
+ coreutils
+ curl
+ xmlstarlet
+
+ # Protobuf + gRPC
+ protobuf
+ protoc-gen-go
+ protoc-gen-go-grpc
+ grpc
+ ];
+
+ defaultShellHook = ''
+ export SHELL="${pkgs.bashInteractive}/bin/bash"
+
+ export FLAKE_ROOT="$(nix flake metadata | grep 'Resolved URL' | awk '{print $3}' | sed 's/^path://' | sed 's/^git+file:\/\///')"
+ export HISTFILE="$FLAKE_ROOT/.nix_bash_history"
+
+ export GOROOT="${go}/share/go"
+ '';
+ in
+ {
+ # run: `nix develop`
+ devShells = {
+ default = pkgs.mkShell {
+ inherit buildInputs;
+ shellHook = defaultShellHook;
+ };
+
+ # Update IDEA paths. Use only if nix installed in whole system.
+ # run: `nix develop .#idea`
+ idea = pkgs.mkShell {
+ inherit buildInputs;
+
+ shellHook = pkgs.lib.concatLines [
+ defaultShellHook
+ ''
+ cd "$FLAKE_ROOT"
+
+ echo "Replace GOPATH"
+ xmlstarlet ed -L -u '//project/component[@name="GOROOT"]/@url' -v 'file://${go}/share/go' .idea/workspace.xml
+
+ exit 0
+ ''
+ ];
+ };
+ };
+ }
+ );
+}
diff --git a/vendor/github.com/ghostiam/protogetter/processor.go b/vendor/github.com/ghostiam/protogetter/processor.go
index 44f346e850..5d548cad9a 100644
--- a/vendor/github.com/ghostiam/protogetter/processor.go
+++ b/vendor/github.com/ghostiam/protogetter/processor.go
@@ -33,12 +33,21 @@ func (c *processor) process(n ast.Node) (*Result, error) {
switch x := n.(type) {
case *ast.AssignStmt:
// Skip any assignment to the field.
- for _, s := range x.Lhs {
+ for i, s := range x.Lhs {
c.filter.AddPos(s.Pos())
if se, ok := s.(*ast.StarExpr); ok {
c.filter.AddPos(se.X.Pos())
}
+
+ if len(x.Rhs) > i {
+ value := x.Rhs[i]
+ if se, ok := value.(*ast.SelectorExpr); ok {
+ if hasPointerKeyWithoutPointerGetter(c.info, s, se) {
+ c.filter.AddPos(se.Sel.Pos())
+ }
+ }
+ }
}
case *ast.IncDecStmt:
@@ -52,6 +61,13 @@ func (c *processor) process(n ast.Node) (*Result, error) {
c.filter.AddPos(x.X.Pos())
}
+ case *ast.KeyValueExpr:
+ if se, ok := x.Value.(*ast.SelectorExpr); ok {
+ if hasPointerKeyWithoutPointerGetter(c.info, x.Key, se) {
+ c.filter.AddPos(se.Sel.Pos())
+ }
+ }
+
case *ast.CallExpr:
if !c.cfg.ReplaceFirstArgInAppend && len(x.Args) > 0 {
if v, ok := x.Fun.(*ast.Ident); ok && v.Name == "append" {
@@ -61,17 +77,38 @@ func (c *processor) process(n ast.Node) (*Result, error) {
}
}
- f, ok := x.Fun.(*ast.SelectorExpr)
- if !ok {
- return &Result{}, nil
- }
+ switch fun := x.Fun.(type) {
+ case *ast.Ident:
+ // Allow passing optional parameters to the function without getter.
- if !isProtoMessage(c.info, f.X) {
+ if len(x.Args) == 0 {
+ return &Result{}, nil
+ }
+
+ if fun.Obj == nil || fun.Obj.Kind != ast.Fun {
+ return &Result{}, nil
+ }
+
+ decl, ok := fun.Obj.Decl.(*ast.FuncDecl)
+ if !ok || decl.Type == nil {
+ return &Result{}, nil
+ }
+
+ c.filterOptionalProtoSelectorExpr(x.Args)
+
+ case *ast.SelectorExpr:
+ c.filterOptionalProtoSelectorExpr(x.Args)
+
+ if !isProtoMessage(c.info, fun.X) {
+ return &Result{}, nil
+ }
+
+ c.processInner(x)
+
+ default:
return &Result{}, nil
}
- c.processInner(x)
-
case *ast.SelectorExpr:
if !isProtoMessage(c.info, x.X) {
// If the selector is not on a proto message, skip it.
@@ -141,6 +178,31 @@ func (c *processor) process(n ast.Node) (*Result, error) {
c.filter.AddPos(x.X.Pos())
+ case *ast.DeclStmt:
+ decl, ok := x.Decl.(*ast.GenDecl)
+ if !ok {
+ return &Result{}, nil
+ }
+
+ for _, spec := range decl.Specs {
+ vSpec, ok := spec.(*ast.ValueSpec)
+ if !ok {
+ continue
+ }
+
+ _, ok = vSpec.Type.(*ast.StarExpr)
+ if !ok {
+ continue
+ }
+
+ for _, ve := range vSpec.Values {
+ c.filter.AddPos(ve.Pos())
+ }
+ }
+
+ case *ast.ReturnStmt:
+ c.filterOptionalProtoSelectorExpr(x.Results)
+
default:
return nil, fmt.Errorf("not implemented for type: %s (%s)", reflect.TypeOf(x), formatNode(n))
}
@@ -155,6 +217,25 @@ func (c *processor) process(n ast.Node) (*Result, error) {
}, nil
}
+func (c *processor) filterOptionalProtoSelectorExpr(args []ast.Expr) {
+ for _, arg := range args {
+ a, ok := arg.(*ast.SelectorExpr)
+ if !ok {
+ continue
+ }
+
+ if !isProtoMessage(c.info, a.X) {
+ continue
+ }
+
+ if !isOptionalProto(c.info, a) {
+ continue
+ }
+
+ c.filter.AddPos(a.Sel.Pos())
+ }
+}
+
func (c *processor) processInner(expr ast.Expr) {
switch x := expr.(type) {
case *ast.Ident:
@@ -177,7 +258,11 @@ func (c *processor) processInner(expr ast.Expr) {
c.write(".")
// If getter exists, use it.
- if methodIsExists(c.info, x.X, "Get"+x.Sel.Name) {
+ if methodIsExists(c.info, x.X, "Get"+x.Sel.Name) &&
+ // Skip if the field is filtered.
+ !c.filter.IsFiltered(x.Sel.Pos()) &&
+ // Check if the field is a proto-message.
+ isProtoMessage(c.info, x.X) {
c.writeFrom(x.Sel.Name)
c.writeTo("Get" + x.Sel.Name + "()")
return
@@ -218,7 +303,7 @@ func (c *processor) processInner(expr ast.Expr) {
c.write("*")
c.processInner(x.X)
- case *ast.CompositeLit, *ast.TypeAssertExpr, *ast.ArrayType, *ast.FuncLit, *ast.SliceExpr:
+ case *ast.CompositeLit, *ast.TypeAssertExpr, *ast.ArrayType, *ast.FuncLit, *ast.SliceExpr, *ast.MapType:
// Process the node as is.
c.write(formatNode(x))
@@ -277,6 +362,20 @@ func isProtoMessage(info *types.Info, expr ast.Expr) bool {
return false
}
+func isOptionalProto(info *types.Info, a *ast.SelectorExpr) bool {
+ _, isPtrArg := info.TypeOf(a).Underlying().(*types.Pointer)
+ if !isPtrArg {
+ return false
+ }
+
+ getterHasPointer, _ := getterResultHasPointer(info, a.X, a.Sel.Name)
+ if getterHasPointer {
+ return false
+ }
+
+ return true
+}
+
func typesNamed(info *types.Info, x ast.Expr) (*types.Named, bool) {
if info == nil {
return nil, false
@@ -292,7 +391,10 @@ func typesNamed(info *types.Info, x ast.Expr) (*types.Named, bool) {
t = ptr.Elem()
}
- named, ok := t.(*types.Named)
+ // A type declared as an alias of a message, as in `type Message = pb.Message`, is a
+ // types.Alias rather than the types.Named it aliases, so the message it stands for is reached
+ // through it.
+ named, ok := types.Unalias(t).(*types.Named)
if !ok {
return nil, false
}
@@ -349,3 +451,17 @@ func getterResultHasPointer(info *types.Info, x ast.Expr, name string) (hasPoint
return false, false
}
+
+func hasPointerKeyWithoutPointerGetter(info *types.Info, key ast.Expr, value *ast.SelectorExpr) bool {
+ _, isPtr := info.TypeOf(key).(*types.Pointer)
+ if !isPtr {
+ return false
+ }
+
+ getterHasPointer, ok := getterResultHasPointer(info, value.X, value.Sel.Name)
+ if !ok {
+ return false
+ }
+
+ return !getterHasPointer
+}
diff --git a/vendor/github.com/ghostiam/protogetter/protogetter.go b/vendor/github.com/ghostiam/protogetter/protogetter.go
index c1c42c75d0..d0cb042782 100644
--- a/vendor/github.com/ghostiam/protogetter/protogetter.go
+++ b/vendor/github.com/ghostiam/protogetter/protogetter.go
@@ -96,6 +96,9 @@ func Run(pass *analysis.Pass, cfg *Config) error {
(*ast.StarExpr)(nil),
(*ast.IncDecStmt)(nil),
(*ast.UnaryExpr)(nil),
+ (*ast.KeyValueExpr)(nil),
+ (*ast.DeclStmt)(nil),
+ (*ast.ReturnStmt)(nil),
}
// Skip filtered files.
diff --git a/vendor/github.com/go-critic/go-critic/checkers/appendAssign_checker.go b/vendor/github.com/go-critic/go-critic/checkers/appendAssign_checker.go
index 2a67dccec8..a18a36f80a 100644
--- a/vendor/github.com/go-critic/go-critic/checkers/appendAssign_checker.go
+++ b/vendor/github.com/go-critic/go-critic/checkers/appendAssign_checker.go
@@ -10,7 +10,6 @@ import (
"github.com/go-toolsmith/astequal"
"github.com/go-toolsmith/astp"
- "golang.org/x/tools/go/ast/astutil"
)
func init() {
@@ -93,7 +92,7 @@ func (c *appendAssignChecker) checkAppend(x ast.Expr, call *ast.CallExpr) {
}
func (c *appendAssignChecker) matchSlices(cause ast.Node, x, y ast.Expr) {
- if !astequal.Expr(x, astutil.Unparen(y)) {
+ if !astequal.Expr(x, ast.Unparen(y)) {
c.warn(cause)
}
}
diff --git a/vendor/github.com/go-critic/go-critic/checkers/badCond_checker.go b/vendor/github.com/go-critic/go-critic/checkers/badCond_checker.go
index 9be45ccc78..f5f4bd3f8c 100644
--- a/vendor/github.com/go-critic/go-critic/checkers/badCond_checker.go
+++ b/vendor/github.com/go-critic/go-critic/checkers/badCond_checker.go
@@ -13,7 +13,6 @@ import (
"github.com/go-toolsmith/astcopy"
"github.com/go-toolsmith/astequal"
"github.com/go-toolsmith/typep"
- "golang.org/x/tools/go/ast/astutil"
)
func init() {
@@ -56,8 +55,8 @@ func (c *badCondChecker) checkExpr(expr ast.Expr) {
// TODO(quasilyte): recognize more patterns.
cond := astcast.ToBinaryExpr(expr)
- lhs := astcast.ToBinaryExpr(astutil.Unparen(cond.X))
- rhs := astcast.ToBinaryExpr(astutil.Unparen(cond.Y))
+ lhs := astcast.ToBinaryExpr(ast.Unparen(cond.X))
+ rhs := astcast.ToBinaryExpr(ast.Unparen(cond.Y))
if cond.Op != token.LAND {
return
@@ -87,7 +86,8 @@ func (c *badCondChecker) checkExpr(expr ast.Expr) {
func (c *badCondChecker) equalToBoth(lhs, rhs *ast.BinaryExpr) bool {
return lhs.Op == token.EQL && rhs.Op == token.EQL &&
- astequal.Expr(lhs.X, rhs.X)
+ astequal.Expr(lhs.X, rhs.X) &&
+ typep.SideEffectFree(c.ctx.TypesInfo, lhs.Y) && typep.SideEffectFree(c.ctx.TypesInfo, rhs.Y)
}
func (c *badCondChecker) lessAndGreater(lhs, rhs *ast.BinaryExpr) bool {
diff --git a/vendor/github.com/go-critic/go-critic/checkers/badRegexp_checker.go b/vendor/github.com/go-critic/go-critic/checkers/badRegexp_checker.go
index 6c6845053d..8f5cf97f68 100644
--- a/vendor/github.com/go-critic/go-critic/checkers/badRegexp_checker.go
+++ b/vendor/github.com/go-critic/go-critic/checkers/badRegexp_checker.go
@@ -148,7 +148,7 @@ func (c *badRegexpChecker) walk(e syntax.Expr) {
case syntax.OpCaret:
if !c.isGoodAnchor(e) {
- c.warn("dangling or redundant ^, maybe \\^ is intended?")
+ c.warnf("dangling or redundant ^, maybe \\^ is intended?")
}
default:
@@ -176,11 +176,11 @@ func (c *badRegexpChecker) updateFlagState(state *regexpFlagState, e syntax.Expr
if clearing {
if !state[ch] {
- c.warn("clearing unset flag %c in %s", ch, e.Value)
+ c.warnf("clearing unset flag %c in %s", ch, e.Value)
}
} else {
if state[ch] {
- c.warn("redundant flag %c in %s", ch, e.Value)
+ c.warnf("redundant flag %c in %s", ch, e.Value)
}
}
state[ch] = !clearing
@@ -198,7 +198,7 @@ func (c *badRegexpChecker) checkNestedQuantifier(e syntax.Expr) {
switch x.Op {
case syntax.OpPlus, syntax.OpStar:
- c.warn("repeated greedy quantifier in %s", e.Value)
+ c.warnf("repeated greedy quantifier in %s", e.Value)
}
}
@@ -208,7 +208,7 @@ func (c *badRegexpChecker) checkAltDups(alt syntax.Expr) {
set := make(map[string]struct{}, len(alt.Args))
for _, a := range alt.Args {
if _, ok := set[a.Value]; ok {
- c.warn("`%s` is duplicated in %s", a.Value, alt.Value)
+ c.warnf("`%s` is duplicated in %s", a.Value, alt.Value)
}
set[a.Value] = struct{}{}
}
@@ -232,7 +232,7 @@ func (c *badRegexpChecker) checkAltAnchor(alt syntax.Expr) {
}
}
if matched {
- c.warn("^ applied only to `%s` in %s", first.Value[len(`^`):], alt.Value)
+ c.warnf("^ applied only to `%s` in %s", first.Value[len(`^`):], alt.Value)
}
}
@@ -247,7 +247,7 @@ func (c *badRegexpChecker) checkAltAnchor(alt syntax.Expr) {
}
}
if matched {
- c.warn("$ applied only to `%s` in %s", last.Value[:len(last.Value)-len(`$`)], alt.Value)
+ c.warnf("$ applied only to `%s` in %s", last.Value[:len(last.Value)-len(`$`)], alt.Value)
}
}
}
@@ -429,7 +429,7 @@ func (c *badRegexpChecker) isGoodAnchor(e syntax.Expr) bool {
return false
}
-func (c *badRegexpChecker) warn(format string, args ...interface{}) {
+func (c *badRegexpChecker) warnf(format string, args ...interface{}) {
c.ctx.Warn(c.cause, format, args...)
}
diff --git a/vendor/github.com/go-critic/go-critic/checkers/boolExprSimplify_checker.go b/vendor/github.com/go-critic/go-critic/checkers/boolExprSimplify_checker.go
index a1c69cb7ab..5fd71b7f30 100644
--- a/vendor/github.com/go-critic/go-critic/checkers/boolExprSimplify_checker.go
+++ b/vendor/github.com/go-critic/go-critic/checkers/boolExprSimplify_checker.go
@@ -81,9 +81,9 @@ func (c *boolExprSimplifyChecker) simplifyBool(x ast.Expr) ast.Expr {
func (c *boolExprSimplifyChecker) doubleNegation(cur *astutil.Cursor) bool {
neg1 := astcast.ToUnaryExpr(cur.Node())
- neg2 := astcast.ToUnaryExpr(astutil.Unparen(neg1.X))
+ neg2 := astcast.ToUnaryExpr(ast.Unparen(neg1.X))
if neg1.Op == token.NOT && neg2.Op == token.NOT {
- cur.Replace(astutil.Unparen(neg2.X))
+ cur.Replace(ast.Unparen(neg2.X))
return true
}
return false
@@ -110,7 +110,7 @@ func (c *boolExprSimplifyChecker) invertComparison(cur *astutil.Cursor) bool {
}
neg := astcast.ToUnaryExpr(cur.Node())
- cmp := astcast.ToBinaryExpr(astutil.Unparen(neg.X))
+ cmp := astcast.ToBinaryExpr(ast.Unparen(neg.X))
if neg.Op != token.NOT {
return false
}
@@ -147,8 +147,8 @@ func (c *boolExprSimplifyChecker) combineChecks(cur *astutil.Cursor) bool {
return false
}
- lhs := astcast.ToBinaryExpr(astutil.Unparen(or.X))
- rhs := astcast.ToBinaryExpr(astutil.Unparen(or.Y))
+ lhs := astcast.ToBinaryExpr(ast.Unparen(or.X))
+ rhs := astcast.ToBinaryExpr(ast.Unparen(or.Y))
if !astequal.Expr(lhs.X, rhs.X) || !astequal.Expr(lhs.Y, rhs.Y) {
return false
diff --git a/vendor/github.com/go-critic/go-critic/checkers/checkers.go b/vendor/github.com/go-critic/go-critic/checkers/checkers.go
index 5797dafdf4..751c71501e 100644
--- a/vendor/github.com/go-critic/go-critic/checkers/checkers.go
+++ b/vendor/github.com/go-critic/go-critic/checkers/checkers.go
@@ -1,4 +1,4 @@
-// Package checkers is a gocritic linter main checkers collection.
+// Package checkers is a go-critic linter main checkers collection.
package checkers
import (
diff --git a/vendor/github.com/go-critic/go-critic/checkers/commentedOutCode_checker.go b/vendor/github.com/go-critic/go-critic/checkers/commentedOutCode_checker.go
index 8595b79515..788355d7fc 100644
--- a/vendor/github.com/go-critic/go-critic/checkers/commentedOutCode_checker.go
+++ b/vendor/github.com/go-critic/go-critic/checkers/commentedOutCode_checker.go
@@ -93,6 +93,10 @@ func (c *commentedOutCodeChecker) VisitLocalComment(cg *ast.CommentGroup) {
return
}
+ if c.isExampleOutputComment(s) {
+ return
+ }
+
stmt := strparse.Stmt(s)
if c.isPermittedStmt(stmt) {
@@ -109,11 +113,6 @@ func (c *commentedOutCodeChecker) VisitLocalComment(cg *ast.CommentGroup) {
return
}
- // Some attempts to avoid false positives.
- if c.skipBlock(s) {
- return
- }
-
// Add braces to make block statement from
// multiple statements.
stmt = strparse.Stmt(fmt.Sprintf("{ %s }", s))
@@ -123,15 +122,18 @@ func (c *commentedOutCodeChecker) VisitLocalComment(cg *ast.CommentGroup) {
}
}
-func (c *commentedOutCodeChecker) skipBlock(s string) bool {
- lines := strings.Split(s, "\n") // There is at least 1 line, that's invariant
-
- // Special example test block.
- if isExampleTestFunc(c.fn) && strings.Contains(lines[0], "Output:") {
- return true
- }
-
- return false
+// An example output comment can be one of the following:
+//
+// Output: some output
+//
+// or
+//
+// Output:
+// some output
+//
+// See https://go.dev/blog/examples
+func (c *commentedOutCodeChecker) isExampleOutputComment(s string) bool {
+ return isExampleTestFunc(c.fn) && strings.Contains(s, "Output:")
}
func (c *commentedOutCodeChecker) isPermittedStmt(stmt ast.Stmt) bool {
diff --git a/vendor/github.com/go-critic/go-critic/checkers/deprecatedComment_checker.go b/vendor/github.com/go-critic/go-critic/checkers/deprecatedComment_checker.go
index c61d773da6..bb41d478ea 100644
--- a/vendor/github.com/go-critic/go-critic/checkers/deprecatedComment_checker.go
+++ b/vendor/github.com/go-critic/go-critic/checkers/deprecatedComment_checker.go
@@ -8,6 +8,8 @@ import (
"github.com/go-critic/go-critic/linter"
)
+const deprecatedPrefix = "Deprecated: "
+
func init() {
var info linter.CheckerInfo
info.Name = "deprecatedComment"
@@ -91,20 +93,25 @@ func (c *deprecatedCommentChecker) VisitDocComment(doc *ast.CommentGroup) {
//
// TODO(quasilyte): there are also multi-line deprecation comments.
+ // prev stores the previous line after it was trimmed.
+ // It's used to check whether the deprecation prefix is at the beginning of a new paragraph.
+ var prev string
+
for _, comment := range doc.List {
if strings.HasPrefix(comment.Text, "/*") {
// TODO(quasilyte): handle multi-line doc comments.
continue
}
- l := comment.Text[len("//"):]
- if len(l) < len("Deprecated: ") {
+ rawLine := strings.TrimPrefix(comment.Text, "//")
+ l := strings.TrimSpace(rawLine)
+ if len(rawLine) < len(deprecatedPrefix) {
+ prev = l
continue
}
- l = strings.TrimSpace(l)
// Check whether someone messed up with a prefix casing.
upcase := strings.ToUpper(l)
- if strings.HasPrefix(upcase, "DEPRECATED: ") && !strings.HasPrefix(l, "Deprecated: ") {
+ if strings.HasPrefix(upcase, "DEPRECATED: ") && !strings.HasPrefix(l, deprecatedPrefix) {
c.warnCasing(comment, l)
return
}
@@ -134,6 +141,12 @@ func (c *deprecatedCommentChecker) VisitDocComment(doc *ast.CommentGroup) {
return
}
}
+
+ if strings.HasPrefix(l, deprecatedPrefix) && prev != "" {
+ c.warnParagraph(comment)
+ return
+ }
+ prev = l
}
}
@@ -154,3 +167,7 @@ func (c *deprecatedCommentChecker) warnTypo(cause ast.Node, line string) {
word := strings.Split(line, ":")[0]
c.ctx.Warn(cause, "typo in `%s`; should be `Deprecated`", word)
}
+
+func (c *deprecatedCommentChecker) warnParagraph(cause ast.Node) {
+ c.ctx.Warn(cause, "`Deprecated: ` notices should be in a dedicated paragraph, separated from the rest")
+}
diff --git a/vendor/github.com/go-critic/go-critic/checkers/dupOption_checker.go b/vendor/github.com/go-critic/go-critic/checkers/dupOption_checker.go
new file mode 100644
index 0000000000..5e7eeda169
--- /dev/null
+++ b/vendor/github.com/go-critic/go-critic/checkers/dupOption_checker.go
@@ -0,0 +1,118 @@
+package checkers
+
+import (
+ "go/ast"
+ "go/token"
+ "go/types"
+
+ "github.com/go-critic/go-critic/checkers/internal/astwalk"
+ "github.com/go-critic/go-critic/linter"
+ "github.com/go-toolsmith/astcast"
+ "github.com/go-toolsmith/astfmt"
+)
+
+func init() {
+ var info linter.CheckerInfo
+ info.Name = "dupOption"
+ info.Tags = []string{linter.DiagnosticTag, linter.ExperimentalTag}
+ info.Summary = "Detects duplicated option function arguments in variadic function calls"
+ info.Before = `doSomething(name,
+ withWidth(w),
+ withHeight(h),
+ withWidth(w),
+)`
+ info.After = `doSomething(name,
+ withWidth(w),
+ withHeight(h),
+)`
+
+ collection.AddChecker(&info, func(ctx *linter.CheckerContext) (linter.FileWalker, error) {
+ c := &dupOptionChecker{ctx: ctx}
+ return astwalk.WalkerForExpr(c), nil
+ })
+}
+
+type dupOptionChecker struct {
+ astwalk.WalkHandler
+ ctx *linter.CheckerContext
+}
+
+func (c *dupOptionChecker) VisitExpr(expr ast.Expr) {
+ call := astcast.ToCallExpr(expr)
+ variadicArgs, argType := c.getVariadicArgs(call)
+ if len(variadicArgs) == 0 {
+ return
+ }
+
+ if !c.isOptionType(argType) {
+ return
+ }
+
+ dupArgs := c.findDupArgs(variadicArgs)
+ for _, arg := range dupArgs {
+ c.warn(arg)
+ }
+}
+
+func (c *dupOptionChecker) getVariadicArgs(call *ast.CallExpr) ([]ast.Expr, types.Type) {
+ if len(call.Args) == 0 {
+ return nil, nil
+ }
+
+ // skip for someFunc(a, b ...)
+ if call.Ellipsis != token.NoPos {
+ return nil, nil
+ }
+
+ funType := c.ctx.TypeOf(call.Fun)
+ sign, ok := funType.(*types.Signature)
+ if !ok || !sign.Variadic() {
+ return nil, nil
+ }
+
+ last := sign.Params().Len() - 1
+ sliceType, ok := sign.Params().At(last).Type().(*types.Slice)
+ if !ok {
+ return nil, nil
+ }
+
+ if last > len(call.Args) {
+ return nil, nil
+ }
+
+ argType := sliceType.Elem()
+ return call.Args[last:], argType
+}
+
+func (c *dupOptionChecker) isOptionType(typeInfo types.Type) bool {
+ typeInfo = typeInfo.Underlying()
+
+ sign, ok := typeInfo.(*types.Signature)
+ if !ok {
+ return false
+ }
+
+ if sign.Params().Len() == 0 {
+ return false
+ }
+
+ return true
+}
+
+func (c *dupOptionChecker) findDupArgs(args []ast.Expr) []ast.Expr {
+ codeMap := make(map[string]bool)
+ dupArgs := make([]ast.Expr, 0)
+ for _, arg := range args {
+ code := astfmt.Sprint(arg)
+ if codeMap[code] {
+ dupArgs = append(dupArgs, arg)
+ continue
+ }
+ codeMap[code] = true
+ }
+ return dupArgs
+}
+
+func (c *dupOptionChecker) warn(arg ast.Node) {
+ c.ctx.Warn(arg, "function argument `%s` is duplicated", arg)
+}
diff --git a/vendor/github.com/go-critic/go-critic/checkers/embedded_rules.go b/vendor/github.com/go-critic/go-critic/checkers/embedded_rules.go
index ad507425e6..0d448399e1 100644
--- a/vendor/github.com/go-critic/go-critic/checkers/embedded_rules.go
+++ b/vendor/github.com/go-critic/go-critic/checkers/embedded_rules.go
@@ -6,6 +6,7 @@ import (
"go/build"
"go/token"
"os"
+ "sync"
"github.com/go-critic/go-critic/checkers/rulesdata"
"github.com/go-critic/go-critic/linter"
@@ -15,6 +16,42 @@ import (
//go:generate go run ./rules/precompile.go -rules ./rules/rules.go -o ./rulesdata/rulesdata.go
+// cachedEngine holds a pre-initialized ruleguard engine for a specific rule group.
+// The engine is created once and reused for all checker instances.
+type cachedEngine struct {
+ engine *ruleguard.Engine
+ once sync.Once
+ err error
+
+ // Configuration needed to create the engine
+ fset *token.FileSet
+ buildContext *build.Context
+ groupName string
+ debug bool
+}
+
+func (ce *cachedEngine) get() (*ruleguard.Engine, error) {
+ ce.once.Do(func() {
+ parseContext := &ruleguard.LoadContext{
+ Fset: ce.fset,
+ GroupFilter: func(gr *ruleguard.GoRuleGroup) bool {
+ return gr.Name == ce.groupName
+ },
+ DebugImports: ce.debug,
+ DebugPrint: func(s string) {
+ fmt.Println("debug:", s)
+ },
+ }
+ engine := ruleguard.NewEngine()
+ engine.BuildContext = ce.buildContext
+ ce.err = engine.LoadFromIR(parseContext, "rules/rules.go", rulesdata.PrecompiledRules)
+ if ce.err == nil {
+ ce.engine = engine
+ }
+ })
+ return ce.engine, ce.err
+}
+
func InitEmbeddedRules() error {
filename := "rules/rules.go"
@@ -49,8 +86,8 @@ func InitEmbeddedRules() error {
groups = rootEngine.LoadedGroups()
}
- // For every rules group we create a new checker and a separate engine.
- // That dedicated ruleguard engine will contain rules only from one group.
+ // For every rules group we create a cached engine holder.
+ // The engine will be created lazily on first use and then reused.
for i := range groups {
g := groups[i]
info := &linter.CheckerInfo{
@@ -63,20 +100,17 @@ func InitEmbeddedRules() error {
EmbeddedRuleguard: true,
}
+
+ // Create a cached engine for this rule group
+ cache := &cachedEngine{
+ fset: fset,
+ buildContext: buildContext,
+ groupName: g.Name,
+ debug: ruleguardDebug,
+ }
+
collection.AddChecker(info, func(ctx *linter.CheckerContext) (linter.FileWalker, error) {
- parseContext := &ruleguard.LoadContext{
- Fset: fset,
- GroupFilter: func(gr *ruleguard.GoRuleGroup) bool {
- return gr.Name == g.Name
- },
- DebugImports: ruleguardDebug,
- DebugPrint: func(s string) {
- fmt.Println("debug:", s)
- },
- }
- engine := ruleguard.NewEngine()
- engine.BuildContext = buildContext
- err := engine.LoadFromIR(parseContext, filename, rulesdata.PrecompiledRules)
+ engine, err := cache.get()
if err != nil {
return nil, err
}
diff --git a/vendor/github.com/go-critic/go-critic/checkers/exitAfterDefer_checker.go b/vendor/github.com/go-critic/go-critic/checkers/exitAfterDefer_checker.go
index 9889f48e8e..19b20e4259 100644
--- a/vendor/github.com/go-critic/go-critic/checkers/exitAfterDefer_checker.go
+++ b/vendor/github.com/go-critic/go-critic/checkers/exitAfterDefer_checker.go
@@ -45,6 +45,12 @@ func (c *exitAfterDeferChecker) VisitFuncDecl(fn *ast.FuncDecl) {
var deferStmt *ast.DeferStmt
pre := func(cur *astutil.Cursor) bool {
+ // If we found a defer statement in the function post traversal.
+ // and are looking at the Else branch during a pre traversal, stop seeking as it could be false positive.
+ if deferStmt != nil && cur.Name() == "Else" {
+ return false
+ }
+
// Don't recurse into local anonymous functions.
return !astp.IsFuncLit(cur.Node())
}
diff --git a/vendor/github.com/go-critic/go-critic/checkers/newDeref_checker.go b/vendor/github.com/go-critic/go-critic/checkers/newDeref_checker.go
index 1a1b05e0df..069fd37716 100644
--- a/vendor/github.com/go-critic/go-critic/checkers/newDeref_checker.go
+++ b/vendor/github.com/go-critic/go-critic/checkers/newDeref_checker.go
@@ -9,7 +9,6 @@ import (
"github.com/go-critic/go-critic/linter"
"github.com/go-toolsmith/astcast"
- "golang.org/x/tools/go/ast/astutil"
)
func init() {
@@ -39,7 +38,7 @@ func (c *newDerefChecker) VisitExpr(expr ast.Expr) {
if _, ok := typ.(*types.TypeParam); ok {
return
}
- zv := lintutil.ZeroValueOf(astutil.Unparen(call.Args[0]), typ)
+ zv := lintutil.ZeroValueOf(ast.Unparen(call.Args[0]), typ)
if zv != nil {
c.warn(expr, zv)
}
diff --git a/vendor/github.com/go-critic/go-critic/checkers/rangeExprCopy_checker.go b/vendor/github.com/go-critic/go-critic/checkers/rangeExprCopy_checker.go
index 3f61ee0bda..6890522427 100644
--- a/vendor/github.com/go-critic/go-critic/checkers/rangeExprCopy_checker.go
+++ b/vendor/github.com/go-critic/go-critic/checkers/rangeExprCopy_checker.go
@@ -54,7 +54,7 @@ type rangeExprCopyChecker struct {
func (c *rangeExprCopyChecker) EnterFunc(fn *ast.FuncDecl) bool {
return fn.Body != nil &&
- !(c.skipTestFuncs && isUnitTestFunc(c.ctx, fn))
+ (!c.skipTestFuncs || !isUnitTestFunc(c.ctx, fn))
}
func (c *rangeExprCopyChecker) VisitStmt(stmt ast.Stmt) {
diff --git a/vendor/github.com/go-critic/go-critic/checkers/rangeValCopy_checker.go b/vendor/github.com/go-critic/go-critic/checkers/rangeValCopy_checker.go
index 6d15c30cd1..a0afc1fafb 100644
--- a/vendor/github.com/go-critic/go-critic/checkers/rangeValCopy_checker.go
+++ b/vendor/github.com/go-critic/go-critic/checkers/rangeValCopy_checker.go
@@ -53,7 +53,7 @@ type rangeValCopyChecker struct {
func (c *rangeValCopyChecker) EnterFunc(fn *ast.FuncDecl) bool {
return fn.Body != nil &&
- !(c.skipTestFuncs && isUnitTestFunc(c.ctx, fn))
+ (!c.skipTestFuncs || !isUnitTestFunc(c.ctx, fn))
}
func (c *rangeValCopyChecker) VisitStmt(stmt ast.Stmt) {
diff --git a/vendor/github.com/go-critic/go-critic/checkers/rulesdata/rulesdata.go b/vendor/github.com/go-critic/go-critic/checkers/rulesdata/rulesdata.go
index 4ab31076fc..4e3aab357a 100644
--- a/vendor/github.com/go-critic/go-critic/checkers/rulesdata/rulesdata.go
+++ b/vendor/github.com/go-critic/go-critic/checkers/rulesdata/rulesdata.go
@@ -1391,48 +1391,53 @@ var PrecompiledRules = &ir.File{
Line: 384,
SyntaxPatterns: []ir.PatternString{
{Line: 384, Value: "copy($x, $x)"},
- {Line: 385, Value: "math.Max($x, $x)"},
- {Line: 386, Value: "math.Min($x, $x)"},
- {Line: 387, Value: "reflect.Copy($x, $x)"},
- {Line: 388, Value: "reflect.DeepEqual($x, $x)"},
- {Line: 389, Value: "strings.Contains($x, $x)"},
- {Line: 390, Value: "strings.Compare($x, $x)"},
- {Line: 391, Value: "strings.EqualFold($x, $x)"},
- {Line: 392, Value: "strings.HasPrefix($x, $x)"},
- {Line: 393, Value: "strings.HasSuffix($x, $x)"},
- {Line: 394, Value: "strings.Index($x, $x)"},
- {Line: 395, Value: "strings.LastIndex($x, $x)"},
- {Line: 396, Value: "strings.Split($x, $x)"},
- {Line: 397, Value: "strings.SplitAfter($x, $x)"},
- {Line: 398, Value: "strings.SplitAfterN($x, $x, $_)"},
- {Line: 399, Value: "strings.SplitN($x, $x, $_)"},
- {Line: 400, Value: "strings.Replace($_, $x, $x, $_)"},
- {Line: 401, Value: "strings.ReplaceAll($_, $x, $x)"},
- {Line: 402, Value: "bytes.Contains($x, $x)"},
- {Line: 403, Value: "bytes.Compare($x, $x)"},
- {Line: 404, Value: "bytes.Equal($x, $x)"},
- {Line: 405, Value: "bytes.EqualFold($x, $x)"},
- {Line: 406, Value: "bytes.HasPrefix($x, $x)"},
- {Line: 407, Value: "bytes.HasSuffix($x, $x)"},
- {Line: 408, Value: "bytes.Index($x, $x)"},
- {Line: 409, Value: "bytes.LastIndex($x, $x)"},
- {Line: 410, Value: "bytes.Split($x, $x)"},
- {Line: 411, Value: "bytes.SplitAfter($x, $x)"},
- {Line: 412, Value: "bytes.SplitAfterN($x, $x, $_)"},
- {Line: 413, Value: "bytes.SplitN($x, $x, $_)"},
- {Line: 414, Value: "bytes.Replace($_, $x, $x, $_)"},
- {Line: 415, Value: "bytes.ReplaceAll($_, $x, $x)"},
- {Line: 416, Value: "types.Identical($x, $x)"},
- {Line: 417, Value: "types.IdenticalIgnoreTags($x, $x)"},
- {Line: 418, Value: "draw.Draw($x, $_, $x, $_, $_)"},
+ {Line: 385, Value: "cmp.Compare($x, $x)"},
+ {Line: 386, Value: "maps.Equal($x, $x)"},
+ {Line: 387, Value: "math.Dim($x, $x)"},
+ {Line: 388, Value: "math.Max($x, $x)"},
+ {Line: 389, Value: "math.Min($x, $x)"},
+ {Line: 390, Value: "reflect.Copy($x, $x)"},
+ {Line: 391, Value: "reflect.DeepEqual($x, $x)"},
+ {Line: 392, Value: "slices.Compare($x, $x)"},
+ {Line: 393, Value: "slices.Equal($x, $x)"},
+ {Line: 394, Value: "strings.Contains($x, $x)"},
+ {Line: 395, Value: "strings.Compare($x, $x)"},
+ {Line: 396, Value: "strings.EqualFold($x, $x)"},
+ {Line: 397, Value: "strings.HasPrefix($x, $x)"},
+ {Line: 398, Value: "strings.HasSuffix($x, $x)"},
+ {Line: 399, Value: "strings.Index($x, $x)"},
+ {Line: 400, Value: "strings.LastIndex($x, $x)"},
+ {Line: 401, Value: "strings.Split($x, $x)"},
+ {Line: 402, Value: "strings.SplitAfter($x, $x)"},
+ {Line: 403, Value: "strings.SplitAfterN($x, $x, $_)"},
+ {Line: 404, Value: "strings.SplitN($x, $x, $_)"},
+ {Line: 405, Value: "strings.Replace($_, $x, $x, $_)"},
+ {Line: 406, Value: "strings.ReplaceAll($_, $x, $x)"},
+ {Line: 407, Value: "bytes.Contains($x, $x)"},
+ {Line: 408, Value: "bytes.Compare($x, $x)"},
+ {Line: 409, Value: "bytes.Equal($x, $x)"},
+ {Line: 410, Value: "bytes.EqualFold($x, $x)"},
+ {Line: 411, Value: "bytes.HasPrefix($x, $x)"},
+ {Line: 412, Value: "bytes.HasSuffix($x, $x)"},
+ {Line: 413, Value: "bytes.Index($x, $x)"},
+ {Line: 414, Value: "bytes.LastIndex($x, $x)"},
+ {Line: 415, Value: "bytes.Split($x, $x)"},
+ {Line: 416, Value: "bytes.SplitAfter($x, $x)"},
+ {Line: 417, Value: "bytes.SplitAfterN($x, $x, $_)"},
+ {Line: 418, Value: "bytes.SplitN($x, $x, $_)"},
+ {Line: 419, Value: "bytes.Replace($_, $x, $x, $_)"},
+ {Line: 420, Value: "bytes.ReplaceAll($_, $x, $x)"},
+ {Line: 421, Value: "types.Identical($x, $x)"},
+ {Line: 422, Value: "types.IdenticalIgnoreTags($x, $x)"},
+ {Line: 423, Value: "draw.Draw($x, $_, $x, $_, $_)"},
},
ReportTemplate: "suspicious duplicated args in $$",
- WhereExpr: ir.FilterExpr{Line: 419, Op: ir.FilterVarPureOp, Src: "m[\"x\"].Pure", Value: "x"},
+ WhereExpr: ir.FilterExpr{Line: 424, Op: ir.FilterVarPureOp, Src: "m[\"x\"].Pure", Value: "x"},
},
},
},
{
- Line: 427,
+ Line: 432,
Name: "returnAfterHttpError",
MatcherName: "m",
DocTags: []string{"diagnostic", "experimental"},
@@ -1440,14 +1445,14 @@ var PrecompiledRules = &ir.File{
DocBefore: "if err != nil { http.Error(...); }",
DocAfter: "if err != nil { http.Error(...); return; }",
Rules: []ir.Rule{{
- Line: 428,
- SyntaxPatterns: []ir.PatternString{{Line: 428, Value: "if $_ { $*_; http.Error($w, $err, $code) }"}},
+ Line: 433,
+ SyntaxPatterns: []ir.PatternString{{Line: 433, Value: "if $_ { $*_; http.Error($w, $err, $code) }"}},
ReportTemplate: "Possibly return is missed after the http.Error call",
LocationVar: "w",
}},
},
{
- Line: 437,
+ Line: 442,
Name: "preferFilepathJoin",
MatcherName: "m",
DocTags: []string{"style", "experimental"},
@@ -1455,35 +1460,35 @@ var PrecompiledRules = &ir.File{
DocBefore: "x + string(os.PathSeparator) + y",
DocAfter: "filepath.Join(x, y)",
Rules: []ir.Rule{{
- Line: 438,
- SyntaxPatterns: []ir.PatternString{{Line: 438, Value: "$x + string(os.PathSeparator) + $y"}},
+ Line: 443,
+ SyntaxPatterns: []ir.PatternString{{Line: 443, Value: "$x + string(os.PathSeparator) + $y"}},
ReportTemplate: "filepath.Join($x, $y) should be preferred to the $$",
SuggestTemplate: "filepath.Join($x, $y)",
WhereExpr: ir.FilterExpr{
- Line: 439,
+ Line: 444,
Op: ir.FilterAndOp,
Src: "m[\"x\"].Type.Is(`string`) && m[\"y\"].Type.Is(`string`)",
Args: []ir.FilterExpr{
{
- Line: 439,
+ Line: 444,
Op: ir.FilterVarTypeIsOp,
Src: "m[\"x\"].Type.Is(`string`)",
Value: "x",
- Args: []ir.FilterExpr{{Line: 439, Op: ir.FilterStringOp, Src: "`string`", Value: "string"}},
+ Args: []ir.FilterExpr{{Line: 444, Op: ir.FilterStringOp, Src: "`string`", Value: "string"}},
},
{
- Line: 439,
+ Line: 444,
Op: ir.FilterVarTypeIsOp,
Src: "m[\"y\"].Type.Is(`string`)",
Value: "y",
- Args: []ir.FilterExpr{{Line: 439, Op: ir.FilterStringOp, Src: "`string`", Value: "string"}},
+ Args: []ir.FilterExpr{{Line: 444, Op: ir.FilterStringOp, Src: "`string`", Value: "string"}},
},
},
},
}},
},
{
- Line: 448,
+ Line: 453,
Name: "preferStringWriter",
MatcherName: "m",
DocTags: []string{"performance", "experimental"},
@@ -1492,35 +1497,35 @@ var PrecompiledRules = &ir.File{
DocAfter: "w.WriteString(\"foo\")",
Rules: []ir.Rule{
{
- Line: 449,
- SyntaxPatterns: []ir.PatternString{{Line: 449, Value: "$w.Write([]byte($s))"}},
+ Line: 454,
+ SyntaxPatterns: []ir.PatternString{{Line: 454, Value: "$w.Write([]byte($s))"}},
ReportTemplate: "$w.WriteString($s) should be preferred to the $$",
SuggestTemplate: "$w.WriteString($s)",
WhereExpr: ir.FilterExpr{
- Line: 450,
+ Line: 455,
Op: ir.FilterVarTypeImplementsOp,
Src: "m[\"w\"].Type.Implements(\"io.StringWriter\")",
Value: "w",
- Args: []ir.FilterExpr{{Line: 450, Op: ir.FilterStringOp, Src: "\"io.StringWriter\"", Value: "io.StringWriter"}},
+ Args: []ir.FilterExpr{{Line: 455, Op: ir.FilterStringOp, Src: "\"io.StringWriter\"", Value: "io.StringWriter"}},
},
},
{
- Line: 454,
- SyntaxPatterns: []ir.PatternString{{Line: 454, Value: "io.WriteString($w, $s)"}},
+ Line: 459,
+ SyntaxPatterns: []ir.PatternString{{Line: 459, Value: "io.WriteString($w, $s)"}},
ReportTemplate: "$w.WriteString($s) should be preferred to the $$",
SuggestTemplate: "$w.WriteString($s)",
WhereExpr: ir.FilterExpr{
- Line: 455,
+ Line: 460,
Op: ir.FilterVarTypeImplementsOp,
Src: "m[\"w\"].Type.Implements(\"io.StringWriter\")",
Value: "w",
- Args: []ir.FilterExpr{{Line: 455, Op: ir.FilterStringOp, Src: "\"io.StringWriter\"", Value: "io.StringWriter"}},
+ Args: []ir.FilterExpr{{Line: 460, Op: ir.FilterStringOp, Src: "\"io.StringWriter\"", Value: "io.StringWriter"}},
},
},
},
},
{
- Line: 464,
+ Line: 469,
Name: "sliceClear",
MatcherName: "m",
DocTags: []string{"performance", "experimental"},
@@ -1528,22 +1533,22 @@ var PrecompiledRules = &ir.File{
DocBefore: "for i := 0; i < len(buf); i++ { buf[i] = 0 }",
DocAfter: "for i := range buf { buf[i] = 0 }",
Rules: []ir.Rule{{
- Line: 465,
- SyntaxPatterns: []ir.PatternString{{Line: 465, Value: "for $i := 0; $i < len($xs); $i++ { $xs[$i] = $zero }"}},
+ Line: 470,
+ SyntaxPatterns: []ir.PatternString{{Line: 470, Value: "for $i := 0; $i < len($xs); $i++ { $xs[$i] = $zero }"}},
ReportTemplate: "rewrite as for-range so compiler can recognize this pattern",
WhereExpr: ir.FilterExpr{
- Line: 466,
+ Line: 471,
Op: ir.FilterEqOp,
Src: "m[\"zero\"].Value.Int() == 0",
Args: []ir.FilterExpr{
{
- Line: 466,
+ Line: 471,
Op: ir.FilterVarValueIntOp,
Src: "m[\"zero\"].Value.Int()",
Value: "zero",
},
{
- Line: 466,
+ Line: 471,
Op: ir.FilterIntOp,
Src: "0",
Value: int64(0),
@@ -1553,7 +1558,7 @@ var PrecompiledRules = &ir.File{
}},
},
{
- Line: 474,
+ Line: 479,
Name: "syncMapLoadAndDelete",
MatcherName: "m",
DocTags: []string{"diagnostic", "experimental"},
@@ -1561,68 +1566,82 @@ var PrecompiledRules = &ir.File{
DocBefore: "v, ok := m.Load(k); if ok { m.Delete($k); f(v); }",
DocAfter: "v, deleted := m.LoadAndDelete(k); if deleted { f(v) }",
Rules: []ir.Rule{{
- Line: 475,
- SyntaxPatterns: []ir.PatternString{{Line: 475, Value: "$_, $ok := $m.Load($k); if $ok { $m.Delete($k); $*_ }"}},
+ Line: 480,
+ SyntaxPatterns: []ir.PatternString{{Line: 480, Value: "$_, $ok := $m.Load($k); if $ok { $m.Delete($k); $*_ }"}},
ReportTemplate: "use $m.LoadAndDelete to perform load+delete operations atomically",
WhereExpr: ir.FilterExpr{
- Line: 476,
+ Line: 481,
Op: ir.FilterAndOp,
Src: "m.GoVersion().GreaterEqThan(\"1.15\") &&\n\tm[\"m\"].Type.Is(`*sync.Map`)",
Args: []ir.FilterExpr{
{
- Line: 476,
+ Line: 481,
Op: ir.FilterGoVersionGreaterEqThanOp,
Src: "m.GoVersion().GreaterEqThan(\"1.15\")",
Value: "1.15",
},
{
- Line: 477,
+ Line: 482,
Op: ir.FilterVarTypeIsOp,
Src: "m[\"m\"].Type.Is(`*sync.Map`)",
Value: "m",
- Args: []ir.FilterExpr{{Line: 477, Op: ir.FilterStringOp, Src: "`*sync.Map`", Value: "*sync.Map"}},
+ Args: []ir.FilterExpr{{Line: 482, Op: ir.FilterStringOp, Src: "`*sync.Map`", Value: "*sync.Map"}},
},
},
},
}},
},
{
- Line: 485,
+ Line: 490,
Name: "sprintfQuotedString",
MatcherName: "m",
DocTags: []string{"diagnostic", "experimental"},
- DocSummary: "Detects \"%s\" formatting directives that can be replaced with %q",
+ DocSummary: "Detects manually quoted \"%s\" directives that can be replaced with %q or %#q",
DocBefore: "fmt.Sprintf(`\"%s\"`, s)",
DocAfter: "fmt.Sprintf(`%q`, s)",
- Rules: []ir.Rule{{
- Line: 486,
- SyntaxPatterns: []ir.PatternString{{Line: 486, Value: "fmt.Sprintf($s, $*_)"}},
- ReportTemplate: "use %q instead of \"%s\" for quoted strings",
- WhereExpr: ir.FilterExpr{
- Line: 487,
- Op: ir.FilterOrOp,
- Src: "m[\"s\"].Text.Matches(\"^`.*\\\"%s\\\".*`$\") ||\n\tm[\"s\"].Text.Matches(`^\".*\\\\\"%s\\\\\".*\"$`)",
- Args: []ir.FilterExpr{
- {
- Line: 487,
- Op: ir.FilterVarTextMatchesOp,
- Src: "m[\"s\"].Text.Matches(\"^`.*\\\"%s\\\".*`$\")",
- Value: "s",
- Args: []ir.FilterExpr{{Line: 487, Op: ir.FilterStringOp, Src: "\"^`.*\\\"%s\\\".*`$\"", Value: "^`.*\"%s\".*`$"}},
- },
- {
- Line: 488,
- Op: ir.FilterVarTextMatchesOp,
- Src: "m[\"s\"].Text.Matches(`^\".*\\\\\"%s\\\\\".*\"$`)",
- Value: "s",
- Args: []ir.FilterExpr{{Line: 488, Op: ir.FilterStringOp, Src: "`^\".*\\\\\"%s\\\\\".*\"$`", Value: "^\".*\\\\\"%s\\\\\".*\"$"}},
+ Rules: []ir.Rule{
+ {
+ Line: 491,
+ SyntaxPatterns: []ir.PatternString{{Line: 491, Value: "fmt.Sprintf($s, $*_)"}},
+ ReportTemplate: "use %q instead of \"%s\" for quoted strings",
+ WhereExpr: ir.FilterExpr{
+ Line: 492,
+ Op: ir.FilterOrOp,
+ Src: "m[\"s\"].Text.Matches(\"^`.*\\\"%s\\\".*`$\") ||\n\tm[\"s\"].Text.Matches(`^\".*\\\\\"%s\\\\\".*\"$`)",
+ Args: []ir.FilterExpr{
+ {
+ Line: 492,
+ Op: ir.FilterVarTextMatchesOp,
+ Src: "m[\"s\"].Text.Matches(\"^`.*\\\"%s\\\".*`$\")",
+ Value: "s",
+ Args: []ir.FilterExpr{{Line: 492, Op: ir.FilterStringOp, Src: "\"^`.*\\\"%s\\\".*`$\"", Value: "^`.*\"%s\".*`$"}},
+ },
+ {
+ Line: 493,
+ Op: ir.FilterVarTextMatchesOp,
+ Src: "m[\"s\"].Text.Matches(`^\".*\\\\\"%s\\\\\".*\"$`)",
+ Value: "s",
+ Args: []ir.FilterExpr{{Line: 493, Op: ir.FilterStringOp, Src: "`^\".*\\\\\"%s\\\\\".*\"$`", Value: "^\".*\\\\\"%s\\\\\".*\"$"}},
+ },
},
},
},
- }},
+ {
+ Line: 498,
+ SyntaxPatterns: []ir.PatternString{{Line: 498, Value: "fmt.Sprintf($s, $*_)"}},
+ ReportTemplate: "use %#q instead of \"`%s`\" for backquoted strings",
+ WhereExpr: ir.FilterExpr{
+ Line: 499,
+ Op: ir.FilterVarTextMatchesOp,
+ Src: "m[\"s\"].Text.Matches(\"^\\\".*`%s`.*\\\"$\")",
+ Value: "s",
+ Args: []ir.FilterExpr{{Line: 499, Op: ir.FilterStringOp, Src: "\"^\\\".*`%s`.*\\\"$\"", Value: "^\".*`%s`.*\"$"}},
+ },
+ },
+ },
},
{
- Line: 496,
+ Line: 507,
Name: "offBy1",
MatcherName: "m",
DocTags: []string{"diagnostic"},
@@ -1631,80 +1650,80 @@ var PrecompiledRules = &ir.File{
DocAfter: "xs[len(xs)-1]",
Rules: []ir.Rule{
{
- Line: 497,
- SyntaxPatterns: []ir.PatternString{{Line: 497, Value: "$x[len($x)]"}},
+ Line: 508,
+ SyntaxPatterns: []ir.PatternString{{Line: 508, Value: "$x[len($x)]"}},
ReportTemplate: "index expr always panics; maybe you wanted $x[len($x)-1]?",
SuggestTemplate: "$x[len($x)-1]",
WhereExpr: ir.FilterExpr{
- Line: 498,
+ Line: 509,
Op: ir.FilterAndOp,
Src: "m[\"x\"].Pure && m[\"x\"].Type.Is(`[]$_`)",
Args: []ir.FilterExpr{
- {Line: 498, Op: ir.FilterVarPureOp, Src: "m[\"x\"].Pure", Value: "x"},
+ {Line: 509, Op: ir.FilterVarPureOp, Src: "m[\"x\"].Pure", Value: "x"},
{
- Line: 498,
+ Line: 509,
Op: ir.FilterVarTypeIsOp,
Src: "m[\"x\"].Type.Is(`[]$_`)",
Value: "x",
- Args: []ir.FilterExpr{{Line: 498, Op: ir.FilterStringOp, Src: "`[]$_`", Value: "[]$_"}},
+ Args: []ir.FilterExpr{{Line: 509, Op: ir.FilterStringOp, Src: "`[]$_`", Value: "[]$_"}},
},
},
},
},
{
- Line: 505,
+ Line: 516,
SyntaxPatterns: []ir.PatternString{
- {Line: 506, Value: "$i := strings.Index($s, $_); $_ := $slicing[$i:]"},
- {Line: 507, Value: "$i := strings.Index($s, $_); $_ = $slicing[$i:]"},
- {Line: 508, Value: "$i := bytes.Index($s, $_); $_ := $slicing[$i:]"},
- {Line: 509, Value: "$i := bytes.Index($s, $_); $_ = $slicing[$i:]"},
+ {Line: 517, Value: "$i := strings.Index($s, $_); $_ := $slicing[$i:]"},
+ {Line: 518, Value: "$i := strings.Index($s, $_); $_ = $slicing[$i:]"},
+ {Line: 519, Value: "$i := bytes.Index($s, $_); $_ := $slicing[$i:]"},
+ {Line: 520, Value: "$i := bytes.Index($s, $_); $_ = $slicing[$i:]"},
},
ReportTemplate: "Index() can return -1; maybe you wanted to do $s[$i+1:]",
WhereExpr: ir.FilterExpr{
- Line: 510,
+ Line: 521,
Op: ir.FilterEqOp,
Src: "m[\"s\"].Text == m[\"slicing\"].Text",
Args: []ir.FilterExpr{
- {Line: 510, Op: ir.FilterVarTextOp, Src: "m[\"s\"].Text", Value: "s"},
- {Line: 510, Op: ir.FilterVarTextOp, Src: "m[\"slicing\"].Text", Value: "slicing"},
+ {Line: 521, Op: ir.FilterVarTextOp, Src: "m[\"s\"].Text", Value: "s"},
+ {Line: 521, Op: ir.FilterVarTextOp, Src: "m[\"slicing\"].Text", Value: "slicing"},
},
},
LocationVar: "slicing",
},
{
- Line: 514,
+ Line: 525,
SyntaxPatterns: []ir.PatternString{
- {Line: 515, Value: "$i := strings.Index($s, $_); $_ := $slicing[:$i]"},
- {Line: 516, Value: "$i := strings.Index($s, $_); $_ = $slicing[:$i]"},
- {Line: 517, Value: "$i := bytes.Index($s, $_); $_ := $slicing[:$i]"},
- {Line: 518, Value: "$i := bytes.Index($s, $_); $_ = $slicing[:$i]"},
+ {Line: 526, Value: "$i := strings.Index($s, $_); $_ := $slicing[:$i]"},
+ {Line: 527, Value: "$i := strings.Index($s, $_); $_ = $slicing[:$i]"},
+ {Line: 528, Value: "$i := bytes.Index($s, $_); $_ := $slicing[:$i]"},
+ {Line: 529, Value: "$i := bytes.Index($s, $_); $_ = $slicing[:$i]"},
},
ReportTemplate: "Index() can return -1; maybe you wanted to do $s[:$i+1]",
WhereExpr: ir.FilterExpr{
- Line: 519,
+ Line: 530,
Op: ir.FilterEqOp,
Src: "m[\"s\"].Text == m[\"slicing\"].Text",
Args: []ir.FilterExpr{
- {Line: 519, Op: ir.FilterVarTextOp, Src: "m[\"s\"].Text", Value: "s"},
- {Line: 519, Op: ir.FilterVarTextOp, Src: "m[\"slicing\"].Text", Value: "slicing"},
+ {Line: 530, Op: ir.FilterVarTextOp, Src: "m[\"s\"].Text", Value: "s"},
+ {Line: 530, Op: ir.FilterVarTextOp, Src: "m[\"slicing\"].Text", Value: "slicing"},
},
},
LocationVar: "slicing",
},
{
- Line: 523,
+ Line: 534,
SyntaxPatterns: []ir.PatternString{
- {Line: 524, Value: "$s[strings.Index($s, $_):]"},
- {Line: 525, Value: "$s[:strings.Index($s, $_)]"},
- {Line: 526, Value: "$s[bytes.Index($s, $_):]"},
- {Line: 527, Value: "$s[:bytes.Index($s, $_)]"},
+ {Line: 535, Value: "$s[strings.Index($s, $_):]"},
+ {Line: 536, Value: "$s[:strings.Index($s, $_)]"},
+ {Line: 537, Value: "$s[bytes.Index($s, $_):]"},
+ {Line: 538, Value: "$s[:bytes.Index($s, $_)]"},
},
ReportTemplate: "Index() can return -1; maybe you wanted to do Index()+1",
},
},
},
{
- Line: 535,
+ Line: 546,
Name: "unslice",
MatcherName: "m",
DocTags: []string{"style"},
@@ -1712,35 +1731,35 @@ var PrecompiledRules = &ir.File{
DocBefore: "copy(b[:], values...)",
DocAfter: "copy(b, values...)",
Rules: []ir.Rule{{
- Line: 536,
- SyntaxPatterns: []ir.PatternString{{Line: 536, Value: "$s[:]"}},
+ Line: 547,
+ SyntaxPatterns: []ir.PatternString{{Line: 547, Value: "$s[:]"}},
ReportTemplate: "could simplify $$ to $s",
SuggestTemplate: "$s",
WhereExpr: ir.FilterExpr{
- Line: 537,
+ Line: 548,
Op: ir.FilterOrOp,
Src: "m[\"s\"].Type.Is(`string`) || m[\"s\"].Type.Is(`[]$_`)",
Args: []ir.FilterExpr{
{
- Line: 537,
+ Line: 548,
Op: ir.FilterVarTypeIsOp,
Src: "m[\"s\"].Type.Is(`string`)",
Value: "s",
- Args: []ir.FilterExpr{{Line: 537, Op: ir.FilterStringOp, Src: "`string`", Value: "string"}},
+ Args: []ir.FilterExpr{{Line: 548, Op: ir.FilterStringOp, Src: "`string`", Value: "string"}},
},
{
- Line: 537,
+ Line: 548,
Op: ir.FilterVarTypeIsOp,
Src: "m[\"s\"].Type.Is(`[]$_`)",
Value: "s",
- Args: []ir.FilterExpr{{Line: 537, Op: ir.FilterStringOp, Src: "`[]$_`", Value: "[]$_"}},
+ Args: []ir.FilterExpr{{Line: 548, Op: ir.FilterStringOp, Src: "`[]$_`", Value: "[]$_"}},
},
},
},
}},
},
{
- Line: 546,
+ Line: 557,
Name: "yodaStyleExpr",
MatcherName: "m",
DocTags: []string{"style", "experimental"},
@@ -1749,105 +1768,105 @@ var PrecompiledRules = &ir.File{
DocAfter: "return ptr != nil",
Rules: []ir.Rule{
{
- Line: 547,
- SyntaxPatterns: []ir.PatternString{{Line: 547, Value: "$constval != $x"}},
+ Line: 558,
+ SyntaxPatterns: []ir.PatternString{{Line: 558, Value: "$constval != $x"}},
ReportTemplate: "consider to change order in expression to $x != $constval",
WhereExpr: ir.FilterExpr{
- Line: 547,
+ Line: 558,
Op: ir.FilterAndOp,
Src: "m[\"constval\"].Node.Is(`BasicLit`) && !m[\"x\"].Node.Is(`BasicLit`)",
Args: []ir.FilterExpr{
{
- Line: 547,
+ Line: 558,
Op: ir.FilterVarNodeIsOp,
Src: "m[\"constval\"].Node.Is(`BasicLit`)",
Value: "constval",
- Args: []ir.FilterExpr{{Line: 547, Op: ir.FilterStringOp, Src: "`BasicLit`", Value: "BasicLit"}},
+ Args: []ir.FilterExpr{{Line: 558, Op: ir.FilterStringOp, Src: "`BasicLit`", Value: "BasicLit"}},
},
{
- Line: 547,
+ Line: 558,
Op: ir.FilterNotOp,
Src: "!m[\"x\"].Node.Is(`BasicLit`)",
Args: []ir.FilterExpr{{
- Line: 547,
+ Line: 558,
Op: ir.FilterVarNodeIsOp,
Src: "m[\"x\"].Node.Is(`BasicLit`)",
Value: "x",
- Args: []ir.FilterExpr{{Line: 547, Op: ir.FilterStringOp, Src: "`BasicLit`", Value: "BasicLit"}},
+ Args: []ir.FilterExpr{{Line: 558, Op: ir.FilterStringOp, Src: "`BasicLit`", Value: "BasicLit"}},
}},
},
},
},
},
{
- Line: 549,
- SyntaxPatterns: []ir.PatternString{{Line: 549, Value: "$constval == $x"}},
+ Line: 560,
+ SyntaxPatterns: []ir.PatternString{{Line: 560, Value: "$constval == $x"}},
ReportTemplate: "consider to change order in expression to $x == $constval",
WhereExpr: ir.FilterExpr{
- Line: 549,
+ Line: 560,
Op: ir.FilterAndOp,
Src: "m[\"constval\"].Node.Is(`BasicLit`) && !m[\"x\"].Node.Is(`BasicLit`)",
Args: []ir.FilterExpr{
{
- Line: 549,
+ Line: 560,
Op: ir.FilterVarNodeIsOp,
Src: "m[\"constval\"].Node.Is(`BasicLit`)",
Value: "constval",
- Args: []ir.FilterExpr{{Line: 549, Op: ir.FilterStringOp, Src: "`BasicLit`", Value: "BasicLit"}},
+ Args: []ir.FilterExpr{{Line: 560, Op: ir.FilterStringOp, Src: "`BasicLit`", Value: "BasicLit"}},
},
{
- Line: 549,
+ Line: 560,
Op: ir.FilterNotOp,
Src: "!m[\"x\"].Node.Is(`BasicLit`)",
Args: []ir.FilterExpr{{
- Line: 549,
+ Line: 560,
Op: ir.FilterVarNodeIsOp,
Src: "m[\"x\"].Node.Is(`BasicLit`)",
Value: "x",
- Args: []ir.FilterExpr{{Line: 549, Op: ir.FilterStringOp, Src: "`BasicLit`", Value: "BasicLit"}},
+ Args: []ir.FilterExpr{{Line: 560, Op: ir.FilterStringOp, Src: "`BasicLit`", Value: "BasicLit"}},
}},
},
},
},
},
{
- Line: 552,
- SyntaxPatterns: []ir.PatternString{{Line: 552, Value: "nil != $x"}},
+ Line: 563,
+ SyntaxPatterns: []ir.PatternString{{Line: 563, Value: "nil != $x"}},
ReportTemplate: "consider to change order in expression to $x != nil",
WhereExpr: ir.FilterExpr{
- Line: 552,
+ Line: 563,
Op: ir.FilterNotOp,
Src: "!m[\"x\"].Node.Is(`BasicLit`)",
Args: []ir.FilterExpr{{
- Line: 552,
+ Line: 563,
Op: ir.FilterVarNodeIsOp,
Src: "m[\"x\"].Node.Is(`BasicLit`)",
Value: "x",
- Args: []ir.FilterExpr{{Line: 552, Op: ir.FilterStringOp, Src: "`BasicLit`", Value: "BasicLit"}},
+ Args: []ir.FilterExpr{{Line: 563, Op: ir.FilterStringOp, Src: "`BasicLit`", Value: "BasicLit"}},
}},
},
},
{
- Line: 554,
- SyntaxPatterns: []ir.PatternString{{Line: 554, Value: "nil == $x"}},
+ Line: 565,
+ SyntaxPatterns: []ir.PatternString{{Line: 565, Value: "nil == $x"}},
ReportTemplate: "consider to change order in expression to $x == nil",
WhereExpr: ir.FilterExpr{
- Line: 554,
+ Line: 565,
Op: ir.FilterNotOp,
Src: "!m[\"x\"].Node.Is(`BasicLit`)",
Args: []ir.FilterExpr{{
- Line: 554,
+ Line: 565,
Op: ir.FilterVarNodeIsOp,
Src: "m[\"x\"].Node.Is(`BasicLit`)",
Value: "x",
- Args: []ir.FilterExpr{{Line: 554, Op: ir.FilterStringOp, Src: "`BasicLit`", Value: "BasicLit"}},
+ Args: []ir.FilterExpr{{Line: 565, Op: ir.FilterStringOp, Src: "`BasicLit`", Value: "BasicLit"}},
}},
},
},
},
},
{
- Line: 562,
+ Line: 573,
Name: "equalFold",
MatcherName: "m",
DocTags: []string{"performance", "experimental"},
@@ -1856,114 +1875,114 @@ var PrecompiledRules = &ir.File{
DocAfter: "strings.EqualFold(x, y)",
Rules: []ir.Rule{
{
- Line: 571,
+ Line: 582,
SyntaxPatterns: []ir.PatternString{
- {Line: 572, Value: "strings.ToLower($x) == $y"},
- {Line: 573, Value: "strings.ToLower($x) == strings.ToLower($y)"},
- {Line: 574, Value: "$x == strings.ToLower($y)"},
- {Line: 575, Value: "strings.ToUpper($x) == $y"},
- {Line: 576, Value: "strings.ToUpper($x) == strings.ToUpper($y)"},
- {Line: 577, Value: "$x == strings.ToUpper($y)"},
+ {Line: 583, Value: "strings.ToLower($x) == $y"},
+ {Line: 584, Value: "strings.ToLower($x) == strings.ToLower($y)"},
+ {Line: 585, Value: "$x == strings.ToLower($y)"},
+ {Line: 586, Value: "strings.ToUpper($x) == $y"},
+ {Line: 587, Value: "strings.ToUpper($x) == strings.ToUpper($y)"},
+ {Line: 588, Value: "$x == strings.ToUpper($y)"},
},
ReportTemplate: "consider replacing with strings.EqualFold($x, $y)",
SuggestTemplate: "strings.EqualFold($x, $y)",
WhereExpr: ir.FilterExpr{
- Line: 578,
+ Line: 589,
Op: ir.FilterAndOp,
Src: "m[\"x\"].Pure && m[\"y\"].Pure && m[\"x\"].Text != m[\"y\"].Text",
Args: []ir.FilterExpr{
{
- Line: 578,
+ Line: 589,
Op: ir.FilterAndOp,
Src: "m[\"x\"].Pure && m[\"y\"].Pure",
Args: []ir.FilterExpr{
- {Line: 578, Op: ir.FilterVarPureOp, Src: "m[\"x\"].Pure", Value: "x"},
- {Line: 578, Op: ir.FilterVarPureOp, Src: "m[\"y\"].Pure", Value: "y"},
+ {Line: 589, Op: ir.FilterVarPureOp, Src: "m[\"x\"].Pure", Value: "x"},
+ {Line: 589, Op: ir.FilterVarPureOp, Src: "m[\"y\"].Pure", Value: "y"},
},
},
{
- Line: 578,
+ Line: 589,
Op: ir.FilterNeqOp,
Src: "m[\"x\"].Text != m[\"y\"].Text",
Args: []ir.FilterExpr{
- {Line: 578, Op: ir.FilterVarTextOp, Src: "m[\"x\"].Text", Value: "x"},
- {Line: 578, Op: ir.FilterVarTextOp, Src: "m[\"y\"].Text", Value: "y"},
+ {Line: 589, Op: ir.FilterVarTextOp, Src: "m[\"x\"].Text", Value: "x"},
+ {Line: 589, Op: ir.FilterVarTextOp, Src: "m[\"y\"].Text", Value: "y"},
},
},
},
},
},
{
- Line: 583,
+ Line: 594,
SyntaxPatterns: []ir.PatternString{
- {Line: 584, Value: "strings.ToLower($x) != $y"},
- {Line: 585, Value: "strings.ToLower($x) != strings.ToLower($y)"},
- {Line: 586, Value: "$x != strings.ToLower($y)"},
- {Line: 587, Value: "strings.ToUpper($x) != $y"},
- {Line: 588, Value: "strings.ToUpper($x) != strings.ToUpper($y)"},
- {Line: 589, Value: "$x != strings.ToUpper($y)"},
+ {Line: 595, Value: "strings.ToLower($x) != $y"},
+ {Line: 596, Value: "strings.ToLower($x) != strings.ToLower($y)"},
+ {Line: 597, Value: "$x != strings.ToLower($y)"},
+ {Line: 598, Value: "strings.ToUpper($x) != $y"},
+ {Line: 599, Value: "strings.ToUpper($x) != strings.ToUpper($y)"},
+ {Line: 600, Value: "$x != strings.ToUpper($y)"},
},
ReportTemplate: "consider replacing with !strings.EqualFold($x, $y)",
SuggestTemplate: "!strings.EqualFold($x, $y)",
WhereExpr: ir.FilterExpr{
- Line: 590,
+ Line: 601,
Op: ir.FilterAndOp,
Src: "m[\"x\"].Pure && m[\"y\"].Pure && m[\"x\"].Text != m[\"y\"].Text",
Args: []ir.FilterExpr{
{
- Line: 590,
+ Line: 601,
Op: ir.FilterAndOp,
Src: "m[\"x\"].Pure && m[\"y\"].Pure",
Args: []ir.FilterExpr{
- {Line: 590, Op: ir.FilterVarPureOp, Src: "m[\"x\"].Pure", Value: "x"},
- {Line: 590, Op: ir.FilterVarPureOp, Src: "m[\"y\"].Pure", Value: "y"},
+ {Line: 601, Op: ir.FilterVarPureOp, Src: "m[\"x\"].Pure", Value: "x"},
+ {Line: 601, Op: ir.FilterVarPureOp, Src: "m[\"y\"].Pure", Value: "y"},
},
},
{
- Line: 590,
+ Line: 601,
Op: ir.FilterNeqOp,
Src: "m[\"x\"].Text != m[\"y\"].Text",
Args: []ir.FilterExpr{
- {Line: 590, Op: ir.FilterVarTextOp, Src: "m[\"x\"].Text", Value: "x"},
- {Line: 590, Op: ir.FilterVarTextOp, Src: "m[\"y\"].Text", Value: "y"},
+ {Line: 601, Op: ir.FilterVarTextOp, Src: "m[\"x\"].Text", Value: "x"},
+ {Line: 601, Op: ir.FilterVarTextOp, Src: "m[\"y\"].Text", Value: "y"},
},
},
},
},
},
{
- Line: 595,
+ Line: 606,
SyntaxPatterns: []ir.PatternString{
- {Line: 596, Value: "bytes.Equal(bytes.ToLower($x), $y)"},
- {Line: 597, Value: "bytes.Equal(bytes.ToLower($x), bytes.ToLower($y))"},
- {Line: 598, Value: "bytes.Equal($x, bytes.ToLower($y))"},
- {Line: 599, Value: "bytes.Equal(bytes.ToUpper($x), $y)"},
- {Line: 600, Value: "bytes.Equal(bytes.ToUpper($x), bytes.ToUpper($y))"},
- {Line: 601, Value: "bytes.Equal($x, bytes.ToUpper($y))"},
+ {Line: 607, Value: "bytes.Equal(bytes.ToLower($x), $y)"},
+ {Line: 608, Value: "bytes.Equal(bytes.ToLower($x), bytes.ToLower($y))"},
+ {Line: 609, Value: "bytes.Equal($x, bytes.ToLower($y))"},
+ {Line: 610, Value: "bytes.Equal(bytes.ToUpper($x), $y)"},
+ {Line: 611, Value: "bytes.Equal(bytes.ToUpper($x), bytes.ToUpper($y))"},
+ {Line: 612, Value: "bytes.Equal($x, bytes.ToUpper($y))"},
},
ReportTemplate: "consider replacing with bytes.EqualFold($x, $y)",
SuggestTemplate: "bytes.EqualFold($x, $y)",
WhereExpr: ir.FilterExpr{
- Line: 602,
+ Line: 613,
Op: ir.FilterAndOp,
Src: "m[\"x\"].Pure && m[\"y\"].Pure && m[\"x\"].Text != m[\"y\"].Text",
Args: []ir.FilterExpr{
{
- Line: 602,
+ Line: 613,
Op: ir.FilterAndOp,
Src: "m[\"x\"].Pure && m[\"y\"].Pure",
Args: []ir.FilterExpr{
- {Line: 602, Op: ir.FilterVarPureOp, Src: "m[\"x\"].Pure", Value: "x"},
- {Line: 602, Op: ir.FilterVarPureOp, Src: "m[\"y\"].Pure", Value: "y"},
+ {Line: 613, Op: ir.FilterVarPureOp, Src: "m[\"x\"].Pure", Value: "x"},
+ {Line: 613, Op: ir.FilterVarPureOp, Src: "m[\"y\"].Pure", Value: "y"},
},
},
{
- Line: 602,
+ Line: 613,
Op: ir.FilterNeqOp,
Src: "m[\"x\"].Text != m[\"y\"].Text",
Args: []ir.FilterExpr{
- {Line: 602, Op: ir.FilterVarTextOp, Src: "m[\"x\"].Text", Value: "x"},
- {Line: 602, Op: ir.FilterVarTextOp, Src: "m[\"y\"].Text", Value: "y"},
+ {Line: 613, Op: ir.FilterVarTextOp, Src: "m[\"x\"].Text", Value: "x"},
+ {Line: 613, Op: ir.FilterVarTextOp, Src: "m[\"y\"].Text", Value: "y"},
},
},
},
@@ -1972,7 +1991,7 @@ var PrecompiledRules = &ir.File{
},
},
{
- Line: 611,
+ Line: 622,
Name: "argOrder",
MatcherName: "m",
DocTags: []string{"diagnostic"},
@@ -1980,45 +1999,45 @@ var PrecompiledRules = &ir.File{
DocBefore: "strings.HasPrefix(\"#\", userpass)",
DocAfter: "strings.HasPrefix(userpass, \"#\")",
Rules: []ir.Rule{{
- Line: 612,
+ Line: 623,
SyntaxPatterns: []ir.PatternString{
- {Line: 613, Value: "strings.HasPrefix($lit, $s)"},
- {Line: 614, Value: "bytes.HasPrefix($lit, $s)"},
- {Line: 615, Value: "strings.HasSuffix($lit, $s)"},
- {Line: 616, Value: "bytes.HasSuffix($lit, $s)"},
- {Line: 617, Value: "strings.Contains($lit, $s)"},
- {Line: 618, Value: "bytes.Contains($lit, $s)"},
- {Line: 619, Value: "strings.TrimPrefix($lit, $s)"},
- {Line: 620, Value: "bytes.TrimPrefix($lit, $s)"},
- {Line: 621, Value: "strings.TrimSuffix($lit, $s)"},
- {Line: 622, Value: "bytes.TrimSuffix($lit, $s)"},
- {Line: 623, Value: "strings.Split($lit, $s)"},
- {Line: 624, Value: "bytes.Split($lit, $s)"},
+ {Line: 624, Value: "strings.HasPrefix($lit, $s)"},
+ {Line: 625, Value: "bytes.HasPrefix($lit, $s)"},
+ {Line: 626, Value: "strings.HasSuffix($lit, $s)"},
+ {Line: 627, Value: "bytes.HasSuffix($lit, $s)"},
+ {Line: 628, Value: "strings.Contains($lit, $s)"},
+ {Line: 629, Value: "bytes.Contains($lit, $s)"},
+ {Line: 630, Value: "strings.TrimPrefix($lit, $s)"},
+ {Line: 631, Value: "bytes.TrimPrefix($lit, $s)"},
+ {Line: 632, Value: "strings.TrimSuffix($lit, $s)"},
+ {Line: 633, Value: "bytes.TrimSuffix($lit, $s)"},
+ {Line: 634, Value: "strings.Split($lit, $s)"},
+ {Line: 635, Value: "bytes.Split($lit, $s)"},
},
ReportTemplate: "$lit and $s arguments order looks reversed",
WhereExpr: ir.FilterExpr{
- Line: 625,
+ Line: 636,
Op: ir.FilterAndOp,
Src: "(m[\"lit\"].Const || m[\"lit\"].ConstSlice) &&\n\t!(m[\"s\"].Const || m[\"s\"].ConstSlice) &&\n\t!m[\"lit\"].Node.Is(`Ident`)",
Args: []ir.FilterExpr{
{
- Line: 625,
+ Line: 636,
Op: ir.FilterAndOp,
Src: "(m[\"lit\"].Const || m[\"lit\"].ConstSlice) &&\n\t!(m[\"s\"].Const || m[\"s\"].ConstSlice)",
Args: []ir.FilterExpr{
{
- Line: 625,
+ Line: 636,
Op: ir.FilterOrOp,
Src: "(m[\"lit\"].Const || m[\"lit\"].ConstSlice)",
Args: []ir.FilterExpr{
{
- Line: 625,
+ Line: 636,
Op: ir.FilterVarConstOp,
Src: "m[\"lit\"].Const",
Value: "lit",
},
{
- Line: 625,
+ Line: 636,
Op: ir.FilterVarConstSliceOp,
Src: "m[\"lit\"].ConstSlice",
Value: "lit",
@@ -2026,22 +2045,22 @@ var PrecompiledRules = &ir.File{
},
},
{
- Line: 626,
+ Line: 637,
Op: ir.FilterNotOp,
Src: "!(m[\"s\"].Const || m[\"s\"].ConstSlice)",
Args: []ir.FilterExpr{{
- Line: 626,
+ Line: 637,
Op: ir.FilterOrOp,
Src: "(m[\"s\"].Const || m[\"s\"].ConstSlice)",
Args: []ir.FilterExpr{
{
- Line: 626,
+ Line: 637,
Op: ir.FilterVarConstOp,
Src: "m[\"s\"].Const",
Value: "s",
},
{
- Line: 626,
+ Line: 637,
Op: ir.FilterVarConstSliceOp,
Src: "m[\"s\"].ConstSlice",
Value: "s",
@@ -2052,15 +2071,15 @@ var PrecompiledRules = &ir.File{
},
},
{
- Line: 627,
+ Line: 638,
Op: ir.FilterNotOp,
Src: "!m[\"lit\"].Node.Is(`Ident`)",
Args: []ir.FilterExpr{{
- Line: 627,
+ Line: 638,
Op: ir.FilterVarNodeIsOp,
Src: "m[\"lit\"].Node.Is(`Ident`)",
Value: "lit",
- Args: []ir.FilterExpr{{Line: 627, Op: ir.FilterStringOp, Src: "`Ident`", Value: "Ident"}},
+ Args: []ir.FilterExpr{{Line: 638, Op: ir.FilterStringOp, Src: "`Ident`", Value: "Ident"}},
}},
},
},
@@ -2068,7 +2087,7 @@ var PrecompiledRules = &ir.File{
}},
},
{
- Line: 635,
+ Line: 646,
Name: "stringConcatSimplify",
MatcherName: "m",
DocTags: []string{"style", "experimental"},
@@ -2077,27 +2096,27 @@ var PrecompiledRules = &ir.File{
DocAfter: "x + \"_\" + y",
Rules: []ir.Rule{
{
- Line: 636,
- SyntaxPatterns: []ir.PatternString{{Line: 636, Value: "strings.Join([]string{$x, $y}, \"\")"}},
+ Line: 647,
+ SyntaxPatterns: []ir.PatternString{{Line: 647, Value: "strings.Join([]string{$x, $y}, \"\")"}},
ReportTemplate: "suggestion: $x + $y",
SuggestTemplate: "$x + $y",
},
{
- Line: 637,
- SyntaxPatterns: []ir.PatternString{{Line: 637, Value: "strings.Join([]string{$x, $y, $z}, \"\")"}},
+ Line: 648,
+ SyntaxPatterns: []ir.PatternString{{Line: 648, Value: "strings.Join([]string{$x, $y, $z}, \"\")"}},
ReportTemplate: "suggestion: $x + $y + $z",
SuggestTemplate: "$x + $y + $z",
},
{
- Line: 638,
- SyntaxPatterns: []ir.PatternString{{Line: 638, Value: "strings.Join([]string{$x, $y}, $glue)"}},
+ Line: 649,
+ SyntaxPatterns: []ir.PatternString{{Line: 649, Value: "strings.Join([]string{$x, $y}, $glue)"}},
ReportTemplate: "suggestion: $x + $glue + $y",
SuggestTemplate: "$x + $glue + $y",
},
},
},
{
- Line: 645,
+ Line: 656,
Name: "timeExprSimplify",
MatcherName: "m",
DocTags: []string{"style", "experimental"},
@@ -2106,39 +2125,39 @@ var PrecompiledRules = &ir.File{
DocAfter: "t.UnixMilli()",
Rules: []ir.Rule{
{
- Line: 650,
- SyntaxPatterns: []ir.PatternString{{Line: 650, Value: "$t.Unix() / 1000"}},
+ Line: 661,
+ SyntaxPatterns: []ir.PatternString{{Line: 661, Value: "$t.Unix() / 1000"}},
ReportTemplate: "use $t.UnixMilli() instead of $$",
SuggestTemplate: "$t.UnixMilli()",
WhereExpr: ir.FilterExpr{
- Line: 651,
+ Line: 662,
Op: ir.FilterAndOp,
Src: "m.GoVersion().GreaterEqThan(\"1.17\") && isTime(m[\"t\"])",
Args: []ir.FilterExpr{
{
- Line: 651,
+ Line: 662,
Op: ir.FilterGoVersionGreaterEqThanOp,
Src: "m.GoVersion().GreaterEqThan(\"1.17\")",
Value: "1.17",
},
{
- Line: 651,
+ Line: 662,
Op: ir.FilterOrOp,
Src: "isTime(m[\"t\"])",
Args: []ir.FilterExpr{
{
- Line: 651,
+ Line: 662,
Op: ir.FilterVarTypeIsOp,
Src: "m[\"t\"].Type.Is(`time.Time`)",
Value: "t",
- Args: []ir.FilterExpr{{Line: 647, Op: ir.FilterStringOp, Src: "`time.Time`", Value: "time.Time"}},
+ Args: []ir.FilterExpr{{Line: 658, Op: ir.FilterStringOp, Src: "`time.Time`", Value: "time.Time"}},
},
{
- Line: 651,
+ Line: 662,
Op: ir.FilterVarTypeIsOp,
Src: "m[\"t\"].Type.Is(`*time.Time`)",
Value: "t",
- Args: []ir.FilterExpr{{Line: 647, Op: ir.FilterStringOp, Src: "`*time.Time`", Value: "*time.Time"}},
+ Args: []ir.FilterExpr{{Line: 658, Op: ir.FilterStringOp, Src: "`*time.Time`", Value: "*time.Time"}},
},
},
},
@@ -2146,39 +2165,39 @@ var PrecompiledRules = &ir.File{
},
},
{
- Line: 655,
- SyntaxPatterns: []ir.PatternString{{Line: 655, Value: "$t.UnixNano() * 1000"}},
+ Line: 666,
+ SyntaxPatterns: []ir.PatternString{{Line: 666, Value: "$t.UnixNano() * 1000"}},
ReportTemplate: "use $t.UnixMicro() instead of $$",
SuggestTemplate: "$t.UnixMicro()",
WhereExpr: ir.FilterExpr{
- Line: 656,
+ Line: 667,
Op: ir.FilterAndOp,
Src: "m.GoVersion().GreaterEqThan(\"1.17\") && isTime(m[\"t\"])",
Args: []ir.FilterExpr{
{
- Line: 656,
+ Line: 667,
Op: ir.FilterGoVersionGreaterEqThanOp,
Src: "m.GoVersion().GreaterEqThan(\"1.17\")",
Value: "1.17",
},
{
- Line: 656,
+ Line: 667,
Op: ir.FilterOrOp,
Src: "isTime(m[\"t\"])",
Args: []ir.FilterExpr{
{
- Line: 656,
+ Line: 667,
Op: ir.FilterVarTypeIsOp,
Src: "m[\"t\"].Type.Is(`time.Time`)",
Value: "t",
- Args: []ir.FilterExpr{{Line: 647, Op: ir.FilterStringOp, Src: "`time.Time`", Value: "time.Time"}},
+ Args: []ir.FilterExpr{{Line: 658, Op: ir.FilterStringOp, Src: "`time.Time`", Value: "time.Time"}},
},
{
- Line: 656,
+ Line: 667,
Op: ir.FilterVarTypeIsOp,
Src: "m[\"t\"].Type.Is(`*time.Time`)",
Value: "t",
- Args: []ir.FilterExpr{{Line: 647, Op: ir.FilterStringOp, Src: "`*time.Time`", Value: "*time.Time"}},
+ Args: []ir.FilterExpr{{Line: 658, Op: ir.FilterStringOp, Src: "`*time.Time`", Value: "*time.Time"}},
},
},
},
@@ -2188,7 +2207,7 @@ var PrecompiledRules = &ir.File{
},
},
{
- Line: 665,
+ Line: 676,
Name: "exposedSyncMutex",
MatcherName: "m",
DocTags: []string{"style", "experimental"},
@@ -2197,57 +2216,57 @@ var PrecompiledRules = &ir.File{
DocAfter: "type Foo struct{ ...; mu sync.Mutex; ... }",
Rules: []ir.Rule{
{
- Line: 670,
- SyntaxPatterns: []ir.PatternString{{Line: 670, Value: "type $x struct { $*_; sync.Mutex; $*_ }"}},
+ Line: 681,
+ SyntaxPatterns: []ir.PatternString{{Line: 681, Value: "type $x struct { $*_; sync.Mutex; $*_ }"}},
ReportTemplate: "don't embed sync.Mutex",
WhereExpr: ir.FilterExpr{
- Line: 671,
+ Line: 682,
Op: ir.FilterVarTextMatchesOp,
Src: "isExported(m[\"x\"])",
Value: "x",
- Args: []ir.FilterExpr{{Line: 667, Op: ir.FilterStringOp, Src: "`^\\p{Lu}`", Value: "^\\p{Lu}"}},
+ Args: []ir.FilterExpr{{Line: 678, Op: ir.FilterStringOp, Src: "`^\\p{Lu}`", Value: "^\\p{Lu}"}},
},
},
{
- Line: 674,
- SyntaxPatterns: []ir.PatternString{{Line: 674, Value: "type $x struct { $*_; *sync.Mutex; $*_ }"}},
+ Line: 685,
+ SyntaxPatterns: []ir.PatternString{{Line: 685, Value: "type $x struct { $*_; *sync.Mutex; $*_ }"}},
ReportTemplate: "don't embed *sync.Mutex",
WhereExpr: ir.FilterExpr{
- Line: 675,
+ Line: 686,
Op: ir.FilterVarTextMatchesOp,
Src: "isExported(m[\"x\"])",
Value: "x",
- Args: []ir.FilterExpr{{Line: 667, Op: ir.FilterStringOp, Src: "`^\\p{Lu}`", Value: "^\\p{Lu}"}},
+ Args: []ir.FilterExpr{{Line: 678, Op: ir.FilterStringOp, Src: "`^\\p{Lu}`", Value: "^\\p{Lu}"}},
},
},
{
- Line: 678,
- SyntaxPatterns: []ir.PatternString{{Line: 678, Value: "type $x struct { $*_; sync.RWMutex; $*_ }"}},
+ Line: 689,
+ SyntaxPatterns: []ir.PatternString{{Line: 689, Value: "type $x struct { $*_; sync.RWMutex; $*_ }"}},
ReportTemplate: "don't embed sync.RWMutex",
WhereExpr: ir.FilterExpr{
- Line: 679,
+ Line: 690,
Op: ir.FilterVarTextMatchesOp,
Src: "isExported(m[\"x\"])",
Value: "x",
- Args: []ir.FilterExpr{{Line: 667, Op: ir.FilterStringOp, Src: "`^\\p{Lu}`", Value: "^\\p{Lu}"}},
+ Args: []ir.FilterExpr{{Line: 678, Op: ir.FilterStringOp, Src: "`^\\p{Lu}`", Value: "^\\p{Lu}"}},
},
},
{
- Line: 682,
- SyntaxPatterns: []ir.PatternString{{Line: 682, Value: "type $x struct { $*_; *sync.RWMutex; $*_ }"}},
+ Line: 693,
+ SyntaxPatterns: []ir.PatternString{{Line: 693, Value: "type $x struct { $*_; *sync.RWMutex; $*_ }"}},
ReportTemplate: "don't embed *sync.RWMutex",
WhereExpr: ir.FilterExpr{
- Line: 683,
+ Line: 694,
Op: ir.FilterVarTextMatchesOp,
Src: "isExported(m[\"x\"])",
Value: "x",
- Args: []ir.FilterExpr{{Line: 667, Op: ir.FilterStringOp, Src: "`^\\p{Lu}`", Value: "^\\p{Lu}"}},
+ Args: []ir.FilterExpr{{Line: 678, Op: ir.FilterStringOp, Src: "`^\\p{Lu}`", Value: "^\\p{Lu}"}},
},
},
},
},
{
- Line: 691,
+ Line: 702,
Name: "badSorting",
MatcherName: "m",
DocTags: []string{"diagnostic", "experimental"},
@@ -2256,48 +2275,48 @@ var PrecompiledRules = &ir.File{
DocAfter: "sort.Strings(xs)",
Rules: []ir.Rule{
{
- Line: 692,
- SyntaxPatterns: []ir.PatternString{{Line: 692, Value: "$x = sort.IntSlice($x)"}},
+ Line: 703,
+ SyntaxPatterns: []ir.PatternString{{Line: 703, Value: "$x = sort.IntSlice($x)"}},
ReportTemplate: "suspicious sort.IntSlice usage, maybe sort.Ints was intended?",
SuggestTemplate: "sort.Ints($x)",
WhereExpr: ir.FilterExpr{
- Line: 693,
+ Line: 704,
Op: ir.FilterVarTypeIsOp,
Src: "m[\"x\"].Type.Is(`[]int`)",
Value: "x",
- Args: []ir.FilterExpr{{Line: 693, Op: ir.FilterStringOp, Src: "`[]int`", Value: "[]int"}},
+ Args: []ir.FilterExpr{{Line: 704, Op: ir.FilterStringOp, Src: "`[]int`", Value: "[]int"}},
},
},
{
- Line: 697,
- SyntaxPatterns: []ir.PatternString{{Line: 697, Value: "$x = sort.Float64Slice($x)"}},
+ Line: 708,
+ SyntaxPatterns: []ir.PatternString{{Line: 708, Value: "$x = sort.Float64Slice($x)"}},
ReportTemplate: "suspicious sort.Float64s usage, maybe sort.Float64s was intended?",
SuggestTemplate: "sort.Float64s($x)",
WhereExpr: ir.FilterExpr{
- Line: 698,
+ Line: 709,
Op: ir.FilterVarTypeIsOp,
Src: "m[\"x\"].Type.Is(`[]float64`)",
Value: "x",
- Args: []ir.FilterExpr{{Line: 698, Op: ir.FilterStringOp, Src: "`[]float64`", Value: "[]float64"}},
+ Args: []ir.FilterExpr{{Line: 709, Op: ir.FilterStringOp, Src: "`[]float64`", Value: "[]float64"}},
},
},
{
- Line: 702,
- SyntaxPatterns: []ir.PatternString{{Line: 702, Value: "$x = sort.StringSlice($x)"}},
+ Line: 713,
+ SyntaxPatterns: []ir.PatternString{{Line: 713, Value: "$x = sort.StringSlice($x)"}},
ReportTemplate: "suspicious sort.StringSlice usage, maybe sort.Strings was intended?",
SuggestTemplate: "sort.Strings($x)",
WhereExpr: ir.FilterExpr{
- Line: 703,
+ Line: 714,
Op: ir.FilterVarTypeIsOp,
Src: "m[\"x\"].Type.Is(`[]string`)",
Value: "x",
- Args: []ir.FilterExpr{{Line: 703, Op: ir.FilterStringOp, Src: "`[]string`", Value: "[]string"}},
+ Args: []ir.FilterExpr{{Line: 714, Op: ir.FilterStringOp, Src: "`[]string`", Value: "[]string"}},
},
},
},
},
{
- Line: 712,
+ Line: 723,
Name: "externalErrorReassign",
MatcherName: "m",
DocTags: []string{"diagnostic", "experimental"},
@@ -2305,34 +2324,34 @@ var PrecompiledRules = &ir.File{
DocBefore: "io.EOF = nil",
DocAfter: "/* don't do it */",
Rules: []ir.Rule{{
- Line: 713,
- SyntaxPatterns: []ir.PatternString{{Line: 713, Value: "$pkg.$err = $x"}},
+ Line: 724,
+ SyntaxPatterns: []ir.PatternString{{Line: 724, Value: "$pkg.$err = $x"}},
ReportTemplate: "suspicious reassignment of error from another package",
WhereExpr: ir.FilterExpr{
- Line: 714,
+ Line: 725,
Op: ir.FilterAndOp,
Src: "m[\"err\"].Type.Is(`error`) && m[\"pkg\"].Object.Is(`PkgName`)",
Args: []ir.FilterExpr{
{
- Line: 714,
+ Line: 725,
Op: ir.FilterVarTypeIsOp,
Src: "m[\"err\"].Type.Is(`error`)",
Value: "err",
- Args: []ir.FilterExpr{{Line: 714, Op: ir.FilterStringOp, Src: "`error`", Value: "error"}},
+ Args: []ir.FilterExpr{{Line: 725, Op: ir.FilterStringOp, Src: "`error`", Value: "error"}},
},
{
- Line: 714,
+ Line: 725,
Op: ir.FilterVarObjectIsOp,
Src: "m[\"pkg\"].Object.Is(`PkgName`)",
Value: "pkg",
- Args: []ir.FilterExpr{{Line: 714, Op: ir.FilterStringOp, Src: "`PkgName`", Value: "PkgName"}},
+ Args: []ir.FilterExpr{{Line: 725, Op: ir.FilterStringOp, Src: "`PkgName`", Value: "PkgName"}},
},
},
},
}},
},
{
- Line: 722,
+ Line: 733,
Name: "emptyDecl",
MatcherName: "m",
DocTags: []string{"diagnostic", "experimental"},
@@ -2341,42 +2360,42 @@ var PrecompiledRules = &ir.File{
DocAfter: "/* nothing */",
Rules: []ir.Rule{
{
- Line: 723,
- SyntaxPatterns: []ir.PatternString{{Line: 723, Value: "var()"}},
+ Line: 734,
+ SyntaxPatterns: []ir.PatternString{{Line: 734, Value: "var()"}},
ReportTemplate: "empty var() block",
},
{
- Line: 724,
- SyntaxPatterns: []ir.PatternString{{Line: 724, Value: "const()"}},
+ Line: 735,
+ SyntaxPatterns: []ir.PatternString{{Line: 735, Value: "const()"}},
ReportTemplate: "empty const() block",
},
{
- Line: 725,
- SyntaxPatterns: []ir.PatternString{{Line: 725, Value: "type()"}},
+ Line: 736,
+ SyntaxPatterns: []ir.PatternString{{Line: 736, Value: "type()"}},
ReportTemplate: "empty type() block",
},
},
},
{
- Line: 732,
+ Line: 743,
Name: "dynamicFmtString",
MatcherName: "m",
DocTags: []string{"diagnostic", "experimental"},
DocSummary: "Detects suspicious formatting strings usage",
DocBefore: "fmt.Errorf(msg)",
- DocAfter: "fmt.Errorf(\"%s\", msg)",
+ DocAfter: "errors.New(msg) or fmt.Errorf(\"%s\", msg)",
Rules: []ir.Rule{
{
- Line: 733,
- SyntaxPatterns: []ir.PatternString{{Line: 733, Value: "fmt.Errorf($f)"}},
+ Line: 744,
+ SyntaxPatterns: []ir.PatternString{{Line: 744, Value: "fmt.Errorf($f)"}},
ReportTemplate: "use errors.New($f) or fmt.Errorf(\"%s\", $f) instead",
SuggestTemplate: "errors.New($f)",
WhereExpr: ir.FilterExpr{
- Line: 734,
+ Line: 745,
Op: ir.FilterNotOp,
Src: "!m[\"f\"].Const",
Args: []ir.FilterExpr{{
- Line: 734,
+ Line: 745,
Op: ir.FilterVarConstOp,
Src: "m[\"f\"].Const",
Value: "f",
@@ -2384,15 +2403,15 @@ var PrecompiledRules = &ir.File{
},
},
{
- Line: 738,
- SyntaxPatterns: []ir.PatternString{{Line: 738, Value: "fmt.Errorf($f($*args))"}},
+ Line: 749,
+ SyntaxPatterns: []ir.PatternString{{Line: 749, Value: "fmt.Errorf($f($*args))"}},
ReportTemplate: "use errors.New($f($*args)) or fmt.Errorf(\"%s\", $f($*args)) instead",
SuggestTemplate: "errors.New($f($*args))",
},
},
},
{
- Line: 747,
+ Line: 758,
Name: "stringsCompare",
MatcherName: "m",
DocTags: []string{"style", "experimental"},
@@ -2401,25 +2420,25 @@ var PrecompiledRules = &ir.File{
DocAfter: "x < y",
Rules: []ir.Rule{
{
- Line: 748,
- SyntaxPatterns: []ir.PatternString{{Line: 748, Value: "strings.Compare($s1, $s2) == 0"}},
+ Line: 759,
+ SyntaxPatterns: []ir.PatternString{{Line: 759, Value: "strings.Compare($s1, $s2) == 0"}},
ReportTemplate: "suggestion: $s1 == $s2",
SuggestTemplate: "$s1 == $s2",
},
{
- Line: 751,
+ Line: 762,
SyntaxPatterns: []ir.PatternString{
- {Line: 751, Value: "strings.Compare($s1, $s2) == -1"},
- {Line: 752, Value: "strings.Compare($s1, $s2) < 0"},
+ {Line: 762, Value: "strings.Compare($s1, $s2) == -1"},
+ {Line: 763, Value: "strings.Compare($s1, $s2) < 0"},
},
ReportTemplate: "suggestion: $s1 < $s2",
SuggestTemplate: "$s1 < $s2",
},
{
- Line: 755,
+ Line: 766,
SyntaxPatterns: []ir.PatternString{
- {Line: 755, Value: "strings.Compare($s1, $s2) == 1"},
- {Line: 756, Value: "strings.Compare($s1, $s2) > 0"},
+ {Line: 766, Value: "strings.Compare($s1, $s2) == 1"},
+ {Line: 767, Value: "strings.Compare($s1, $s2) > 0"},
},
ReportTemplate: "suggestion: $s1 > $s2",
SuggestTemplate: "$s1 > $s2",
@@ -2427,7 +2446,7 @@ var PrecompiledRules = &ir.File{
},
},
{
- Line: 764,
+ Line: 775,
Name: "uncheckedInlineErr",
MatcherName: "m",
DocTags: []string{"diagnostic", "experimental"},
@@ -2435,47 +2454,47 @@ var PrecompiledRules = &ir.File{
DocBefore: "if err := expr(); err2 != nil { /*...*/ }",
DocAfter: "if err := expr(); err != nil { /*...*/ }",
Rules: []ir.Rule{{
- Line: 765,
+ Line: 776,
SyntaxPatterns: []ir.PatternString{
- {Line: 766, Value: "if $err := $_($*_); $err2 != nil { $*_ }"},
- {Line: 767, Value: "if $err = $_($*_); $err2 != nil { $*_ }"},
- {Line: 768, Value: "if $*_, $err := $_($*_); $err2 != nil { $*_ }"},
- {Line: 769, Value: "if $*_, $err = $_($*_); $err2 != nil { $*_ }"},
+ {Line: 777, Value: "if $err := $_($*_); $err2 != nil { $*_ }"},
+ {Line: 778, Value: "if $err = $_($*_); $err2 != nil { $*_ }"},
+ {Line: 779, Value: "if $*_, $err := $_($*_); $err2 != nil { $*_ }"},
+ {Line: 780, Value: "if $*_, $err = $_($*_); $err2 != nil { $*_ }"},
},
ReportTemplate: "$err error is unchecked, maybe intended to check it instead of $err2",
WhereExpr: ir.FilterExpr{
- Line: 770,
+ Line: 781,
Op: ir.FilterAndOp,
Src: "m[\"err\"].Type.Implements(\"error\") && m[\"err2\"].Type.Implements(\"error\") &&\n\tm[\"err\"].Text != m[\"err2\"].Text",
Args: []ir.FilterExpr{
{
- Line: 770,
+ Line: 781,
Op: ir.FilterAndOp,
Src: "m[\"err\"].Type.Implements(\"error\") && m[\"err2\"].Type.Implements(\"error\")",
Args: []ir.FilterExpr{
{
- Line: 770,
+ Line: 781,
Op: ir.FilterVarTypeImplementsOp,
Src: "m[\"err\"].Type.Implements(\"error\")",
Value: "err",
- Args: []ir.FilterExpr{{Line: 770, Op: ir.FilterStringOp, Src: "\"error\"", Value: "error"}},
+ Args: []ir.FilterExpr{{Line: 781, Op: ir.FilterStringOp, Src: "\"error\"", Value: "error"}},
},
{
- Line: 770,
+ Line: 781,
Op: ir.FilterVarTypeImplementsOp,
Src: "m[\"err2\"].Type.Implements(\"error\")",
Value: "err2",
- Args: []ir.FilterExpr{{Line: 770, Op: ir.FilterStringOp, Src: "\"error\"", Value: "error"}},
+ Args: []ir.FilterExpr{{Line: 781, Op: ir.FilterStringOp, Src: "\"error\"", Value: "error"}},
},
},
},
{
- Line: 771,
+ Line: 782,
Op: ir.FilterNeqOp,
Src: "m[\"err\"].Text != m[\"err2\"].Text",
Args: []ir.FilterExpr{
- {Line: 771, Op: ir.FilterVarTextOp, Src: "m[\"err\"].Text", Value: "err"},
- {Line: 771, Op: ir.FilterVarTextOp, Src: "m[\"err2\"].Text", Value: "err2"},
+ {Line: 782, Op: ir.FilterVarTextOp, Src: "m[\"err\"].Text", Value: "err"},
+ {Line: 782, Op: ir.FilterVarTextOp, Src: "m[\"err2\"].Text", Value: "err2"},
},
},
},
@@ -2484,7 +2503,7 @@ var PrecompiledRules = &ir.File{
}},
},
{
- Line: 780,
+ Line: 791,
Name: "badSyncOnceFunc",
MatcherName: "m",
DocTags: []string{"diagnostic", "experimental"},
@@ -2493,22 +2512,22 @@ var PrecompiledRules = &ir.File{
DocAfter: "fooOnce := sync.OnceFunc(foo); ...; fooOnce()",
Rules: []ir.Rule{
{
- Line: 781,
- SyntaxPatterns: []ir.PatternString{{Line: 781, Value: "$*_; sync.OnceFunc($x); $*_;"}},
+ Line: 792,
+ SyntaxPatterns: []ir.PatternString{{Line: 792, Value: "$*_; sync.OnceFunc($x); $*_;"}},
ReportTemplate: "possible sync.OnceFunc misuse, sync.OnceFunc($x) result is not used",
WhereExpr: ir.FilterExpr{
- Line: 783,
+ Line: 794,
Op: ir.FilterGoVersionGreaterEqThanOp,
Src: "m.GoVersion().GreaterEqThan(\"1.21\")",
Value: "1.21",
},
},
{
- Line: 785,
- SyntaxPatterns: []ir.PatternString{{Line: 785, Value: "sync.OnceFunc($x)()"}},
+ Line: 796,
+ SyntaxPatterns: []ir.PatternString{{Line: 796, Value: "sync.OnceFunc($x)()"}},
ReportTemplate: "possible sync.OnceFunc misuse, consider to assign sync.OnceFunc($x) to a variable",
WhereExpr: ir.FilterExpr{
- Line: 787,
+ Line: 798,
Op: ir.FilterGoVersionGreaterEqThanOp,
Src: "m.GoVersion().GreaterEqThan(\"1.21\")",
Value: "1.21",
@@ -2516,6 +2535,61 @@ var PrecompiledRules = &ir.File{
},
},
},
+ {
+ Line: 805,
+ Name: "zeroByteRepeat",
+ MatcherName: "m",
+ DocTags: []string{"performance"},
+ DocSummary: "Detects bytes.Repeat with 0 value",
+ DocBefore: "bytes.Repeat([]byte{0}, x)",
+ DocAfter: "make([]byte, x)",
+ Rules: []ir.Rule{
+ {
+ Line: 806,
+ SyntaxPatterns: []ir.PatternString{{Line: 806, Value: "bytes.Repeat([]byte{0}, $x)"}},
+ ReportTemplate: "avoid bytes.Repeat([]byte{0}, $x); consider using make([]byte, $x) instead",
+ SuggestTemplate: "make([]byte, $x)",
+ },
+ {
+ Line: 811,
+ SyntaxPatterns: []ir.PatternString{{Line: 811, Value: "bytes.Repeat([]byte{$x}, $n)"}},
+ ReportTemplate: "avoid bytes.Repeat with a const 0; use make([]byte, $n) instead",
+ SuggestTemplate: "make([]byte, $n)",
+ WhereExpr: ir.FilterExpr{
+ Line: 812,
+ Op: ir.FilterAndOp,
+ Src: "m[\"x\"].Const && m[\"x\"].Value.Int() == 0",
+ Args: []ir.FilterExpr{
+ {
+ Line: 812,
+ Op: ir.FilterVarConstOp,
+ Src: "m[\"x\"].Const",
+ Value: "x",
+ },
+ {
+ Line: 812,
+ Op: ir.FilterEqOp,
+ Src: "m[\"x\"].Value.Int() == 0",
+ Args: []ir.FilterExpr{
+ {
+ Line: 812,
+ Op: ir.FilterVarValueIntOp,
+ Src: "m[\"x\"].Value.Int()",
+ Value: "x",
+ },
+ {
+ Line: 812,
+ Op: ir.FilterIntOp,
+ Src: "0",
+ Value: int64(0),
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
},
}
diff --git a/vendor/github.com/go-critic/go-critic/checkers/sortSlice_checker.go b/vendor/github.com/go-critic/go-critic/checkers/sortSlice_checker.go
index 22ef3b16a7..f04ea2c6e8 100644
--- a/vendor/github.com/go-critic/go-critic/checkers/sortSlice_checker.go
+++ b/vendor/github.com/go-critic/go-critic/checkers/sortSlice_checker.go
@@ -11,7 +11,6 @@ import (
"github.com/go-toolsmith/astcast"
"github.com/go-toolsmith/astequal"
"github.com/go-toolsmith/typep"
- "golang.org/x/tools/go/ast/astutil"
)
func init() {
@@ -65,7 +64,7 @@ func (c *sortSliceChecker) VisitExpr(expr ast.Expr) {
if !ok {
return
}
- cmp := astcast.ToBinaryExpr(astutil.Unparen(ret.Results[0]))
+ cmp := astcast.ToBinaryExpr(ast.Unparen(ret.Results[0]))
if !typep.SideEffectFree(c.ctx.TypesInfo, cmp) {
return
}
diff --git a/vendor/github.com/go-critic/go-critic/checkers/sqlQuery_checker.go b/vendor/github.com/go-critic/go-critic/checkers/sqlQuery_checker.go
index 8a132b5860..02a2370d30 100644
--- a/vendor/github.com/go-critic/go-critic/checkers/sqlQuery_checker.go
+++ b/vendor/github.com/go-critic/go-critic/checkers/sqlQuery_checker.go
@@ -125,6 +125,13 @@ func (c *sqlQueryChecker) typeHasExecMethod(typ types.Type) bool {
return true
}
}
+ case *types.Alias:
+ switch typ := typ.Underlying().(type) {
+ case *types.Interface:
+ return c.typeHasExecMethod(typ)
+ default:
+ // TODO(cristaloleg): is there something else to handle?
+ }
case *types.Interface:
for i := 0; i < typ.NumMethods(); i++ {
if c.funcIsExec(typ.Method(i)) {
diff --git a/vendor/github.com/go-critic/go-critic/checkers/utils.go b/vendor/github.com/go-critic/go-critic/checkers/utils.go
index 6e12cf9b30..89d7570698 100644
--- a/vendor/github.com/go-critic/go-critic/checkers/utils.go
+++ b/vendor/github.com/go-critic/go-critic/checkers/utils.go
@@ -9,183 +9,200 @@ import (
)
// goStdlib contains `go list std` command output list.
+// `internal` and `vendor` packages are excluded.
// Used to detect packages that belong to standard Go packages distribution.
var goStdlib = map[string]bool{
- "archive/tar": true,
- "archive/zip": true,
- "bufio": true,
- "bytes": true,
- "compress/bzip2": true,
- "compress/flate": true,
- "compress/gzip": true,
- "compress/lzw": true,
- "compress/zlib": true,
- "container/heap": true,
- "container/list": true,
- "container/ring": true,
- "context": true,
- "crypto": true,
- "crypto/aes": true,
- "crypto/cipher": true,
- "crypto/des": true,
- "crypto/dsa": true,
- "crypto/ecdsa": true,
- "crypto/elliptic": true,
- "crypto/hmac": true,
- "crypto/internal/randutil": true,
- "crypto/internal/subtle": true,
- "crypto/md5": true,
- "crypto/rand": true,
- "crypto/rc4": true,
- "crypto/rsa": true,
- "crypto/sha1": true,
- "crypto/sha256": true,
- "crypto/sha512": true,
- "crypto/subtle": true,
- "crypto/tls": true,
- "crypto/x509": true,
- "crypto/x509/pkix": true,
- "database/sql": true,
- "database/sql/driver": true,
- "debug/dwarf": true,
- "debug/elf": true,
- "debug/gosym": true,
- "debug/macho": true,
- "debug/pe": true,
- "debug/plan9obj": true,
- "encoding": true,
- "encoding/ascii85": true,
- "encoding/asn1": true,
- "encoding/base32": true,
- "encoding/base64": true,
- "encoding/binary": true,
- "encoding/csv": true,
- "encoding/gob": true,
- "encoding/hex": true,
- "encoding/json": true,
- "encoding/pem": true,
- "encoding/xml": true,
- "errors": true,
- "expvar": true,
- "flag": true,
- "fmt": true,
- "go/ast": true,
- "go/build": true,
- "go/constant": true,
- "go/doc": true,
- "go/format": true,
- "go/importer": true,
- "go/internal/gccgoimporter": true,
- "go/internal/gcimporter": true,
- "go/internal/srcimporter": true,
- "go/parser": true,
- "go/printer": true,
- "go/scanner": true,
- "go/token": true,
- "go/types": true,
- "hash": true,
- "hash/adler32": true,
- "hash/crc32": true,
- "hash/crc64": true,
- "hash/fnv": true,
- "html": true,
- "html/template": true,
- "image": true,
- "image/color": true,
- "image/color/palette": true,
- "image/draw": true,
- "image/gif": true,
- "image/internal/imageutil": true,
- "image/jpeg": true,
- "image/png": true,
- "index/suffixarray": true,
- "internal/bytealg": true,
- "internal/cpu": true,
- "internal/nettrace": true,
- "internal/poll": true,
- "internal/race": true,
- "internal/singleflight": true,
- "internal/syscall/unix": true,
- "internal/syscall/windows": true,
- "internal/syscall/windows/registry": true,
- "internal/syscall/windows/sysdll": true,
- "internal/testenv": true,
- "internal/testlog": true,
- "internal/trace": true,
- "io": true,
- "io/ioutil": true,
- "log": true,
- "log/syslog": true,
- "math": true,
- "math/big": true,
- "math/bits": true,
- "math/cmplx": true,
- "math/rand": true,
- "mime": true,
- "mime/multipart": true,
- "mime/quotedprintable": true,
- "net": true,
- "net/http": true,
- "net/http/cgi": true,
- "net/http/cookiejar": true,
- "net/http/fcgi": true,
- "net/http/httptest": true,
- "net/http/httptrace": true,
- "net/http/httputil": true,
- "net/http/internal": true,
- "net/http/pprof": true,
- "net/internal/socktest": true,
- "net/mail": true,
- "net/rpc": true,
- "net/rpc/jsonrpc": true,
- "net/smtp": true,
- "net/textproto": true,
- "net/url": true,
- "os": true,
- "os/exec": true,
- "os/signal": true,
- "os/signal/internal/pty": true,
- "os/user": true,
- "path": true,
- "path/filepath": true,
- "plugin": true,
- "reflect": true,
- "regexp": true,
- "regexp/syntax": true,
- "runtime": true,
- "runtime/cgo": true,
- "runtime/debug": true,
- "runtime/internal/atomic": true,
- "runtime/internal/sys": true,
- "runtime/pprof": true,
- "runtime/pprof/internal/profile": true,
- "runtime/race": true,
- "runtime/trace": true,
- "sort": true,
- "strconv": true,
- "strings": true,
- "sync": true,
- "sync/atomic": true,
- "syscall": true,
- "testing": true,
- "testing/internal/testdeps": true,
- "testing/iotest": true,
- "testing/quick": true,
- "text/scanner": true,
- "text/tabwriter": true,
- "text/template": true,
- "text/template/parse": true,
- "time": true,
- "unicode": true,
- "unicode/utf16": true,
- "unicode/utf8": true,
- "unsafe": true,
+ "archive/tar": true,
+ "archive/zip": true,
+ "bufio": true,
+ "bytes": true,
+ "cmp": true,
+ "compress/bzip2": true,
+ "compress/flate": true,
+ "compress/gzip": true,
+ "compress/lzw": true,
+ "compress/zlib": true,
+ "container/heap": true,
+ "container/list": true,
+ "container/ring": true,
+ "context": true,
+ "crypto": true,
+ "crypto/aes": true,
+ "crypto/cipher": true,
+ "crypto/des": true,
+ "crypto/dsa": true,
+ "crypto/ecdh": true,
+ "crypto/ecdsa": true,
+ "crypto/ed25519": true,
+ "crypto/elliptic": true,
+ "crypto/fips140": true,
+ "crypto/hkdf": true,
+ "crypto/hmac": true,
+ "crypto/hpke": true,
+ "crypto/md5": true,
+ "crypto/mldsa": true,
+ "crypto/mlkem": true,
+ "crypto/mlkem/mlkemtest": true,
+ "crypto/pbkdf2": true,
+ "crypto/rand": true,
+ "crypto/rc4": true,
+ "crypto/rsa": true,
+ "crypto/sha1": true,
+ "crypto/sha256": true,
+ "crypto/sha3": true,
+ "crypto/sha512": true,
+ "crypto/subtle": true,
+ "crypto/tls": true,
+ "crypto/x509": true,
+ "crypto/x509/pkix": true,
+ "database/sql": true,
+ "database/sql/driver": true,
+ "debug/buildinfo": true,
+ "debug/dwarf": true,
+ "debug/elf": true,
+ "debug/gosym": true,
+ "debug/macho": true,
+ "debug/pe": true,
+ "debug/plan9obj": true,
+ "embed": true,
+ "encoding": true,
+ "encoding/ascii85": true,
+ "encoding/asn1": true,
+ "encoding/base32": true,
+ "encoding/base64": true,
+ "encoding/binary": true,
+ "encoding/csv": true,
+ "encoding/gob": true,
+ "encoding/hex": true,
+ "encoding/json": true,
+ "encoding/json/jsontext": true,
+ "encoding/json/v2": true,
+ "encoding/pem": true,
+ "encoding/xml": true,
+ "errors": true,
+ "expvar": true,
+ "flag": true,
+ "fmt": true,
+ "go/ast": true,
+ "go/build": true,
+ "go/build/constraint": true,
+ "go/constant": true,
+ "go/doc": true,
+ "go/doc/comment": true,
+ "go/format": true,
+ "go/importer": true,
+ "go/parser": true,
+ "go/printer": true,
+ "go/scanner": true,
+ "go/token": true,
+ "go/types": true,
+ "go/version": true,
+ "hash": true,
+ "hash/adler32": true,
+ "hash/crc32": true,
+ "hash/crc64": true,
+ "hash/fnv": true,
+ "hash/maphash": true,
+ "html": true,
+ "html/template": true,
+ "image": true,
+ "image/color": true,
+ "image/color/palette": true,
+ "image/draw": true,
+ "image/gif": true,
+ "image/jpeg": true,
+ "image/png": true,
+ "index/suffixarray": true,
+ "io": true,
+ "io/fs": true,
+ "io/ioutil": true,
+ "iter": true,
+ "log": true,
+ "log/internal": true,
+ "log/slog": true,
+ "log/slog/internal": true,
+ "log/syslog": true,
+ "maps": true,
+ "math": true,
+ "math/big": true,
+ "math/bits": true,
+ "math/cmplx": true,
+ "math/rand": true,
+ "math/rand/v2": true,
+ "mime": true,
+ "mime/multipart": true,
+ "mime/quotedprintable": true,
+ "net": true,
+ "net/http": true,
+ "net/http/cgi": true,
+ "net/http/cookiejar": true,
+ "net/http/fcgi": true,
+ "net/http/httptest": true,
+ "net/http/httptrace": true,
+ "net/http/httputil": true,
+ "net/http/internal": true,
+ "net/http/pprof": true,
+ "net/mail": true,
+ "net/netip": true,
+ "net/rpc": true,
+ "net/rpc/jsonrpc": true,
+ "net/smtp": true,
+ "net/textproto": true,
+ "net/url": true,
+ "os": true,
+ "os/exec": true,
+ "os/signal": true,
+ "os/user": true,
+ "path": true,
+ "path/filepath": true,
+ "plugin": true,
+ "reflect": true,
+ "regexp": true,
+ "regexp/syntax": true,
+ "runtime": true,
+ "runtime/cgo": true,
+ "runtime/coverage": true,
+ "runtime/debug": true,
+ "runtime/metrics": true,
+ "runtime/pprof": true,
+ "runtime/race": true,
+ "runtime/trace": true,
+ "slices": true,
+ "sort": true,
+ "strconv": true,
+ "strings": true,
+ "structs": true,
+ "sync": true,
+ "sync/atomic": true,
+ "syscall": true,
+ "testing": true,
+ "testing/cryptotest": true,
+ "testing/fstest": true,
+ "testing/iotest": true,
+ "testing/quick": true,
+ "testing/slogtest": true,
+ "testing/synctest": true,
+ "text/scanner": true,
+ "text/tabwriter": true,
+ "text/template": true,
+ "text/template/parse": true,
+ "time": true,
+ "time/tzdata": true,
+ "unicode": true,
+ "unicode/utf16": true,
+ "unicode/utf8": true,
+ "unique": true,
+ "unsafe": true,
+ "uuid": true,
+ "weak": true,
}
var goBuiltins = map[string]bool{
// Types
+ "any": true,
"bool": true,
"byte": true,
+ "comparable": true,
"complex64": true,
"complex128": true,
"error": true,
@@ -216,6 +233,7 @@ var goBuiltins = map[string]bool{
// Functions
"append": true,
"cap": true,
+ "clear": true,
"close": true,
"complex": true,
"copy": true,
diff --git a/vendor/github.com/go-critic/go-critic/checkers/weakCond_checker.go b/vendor/github.com/go-critic/go-critic/checkers/weakCond_checker.go
index 3d7c9c1225..921a45dbef 100644
--- a/vendor/github.com/go-critic/go-critic/checkers/weakCond_checker.go
+++ b/vendor/github.com/go-critic/go-critic/checkers/weakCond_checker.go
@@ -11,7 +11,6 @@ import (
"github.com/go-toolsmith/astcast"
"github.com/go-toolsmith/astequal"
"github.com/go-toolsmith/typep"
- "golang.org/x/tools/go/ast/astutil"
)
func init() {
@@ -37,8 +36,8 @@ func (c *weakCondChecker) VisitExpr(expr ast.Expr) {
// TODO(Quasilyte): analyze and fix false positives.
cond := astcast.ToBinaryExpr(expr)
- lhs := astcast.ToBinaryExpr(astutil.Unparen(cond.X))
- rhs := astutil.Unparen(cond.Y)
+ lhs := astcast.ToBinaryExpr(ast.Unparen(cond.X))
+ rhs := ast.Unparen(cond.Y)
// Pattern 1.
// `x != nil && usageOf(x[i])`
diff --git a/vendor/github.com/go-critic/go-critic/linter/go_version.go b/vendor/github.com/go-critic/go-critic/linter/go_version.go
index b5ef2f75ff..a7393ef80a 100644
--- a/vendor/github.com/go-critic/go-critic/linter/go_version.go
+++ b/vendor/github.com/go-critic/go-critic/linter/go_version.go
@@ -18,10 +18,10 @@ type GoVersion struct {
//
// As a special case, Major=0 covers all versions.
func (v GoVersion) GreaterOrEqual(other GoVersion) bool {
- switch {
- case v.Major == 0:
+ switch v.Major {
+ case 0:
return true
- case v.Major == other.Major:
+ case other.Major:
return v.Minor >= other.Minor
default:
return v.Major >= other.Major
diff --git a/vendor/github.com/go-critic/go-critic/linter/linter.go b/vendor/github.com/go-critic/go-critic/linter/linter.go
index d4bc17536e..c751d94cce 100644
--- a/vendor/github.com/go-critic/go-critic/linter/linter.go
+++ b/vendor/github.com/go-critic/go-critic/linter/linter.go
@@ -249,8 +249,8 @@ func NewContext(fset *token.FileSet, sizes types.Sizes) *Context {
// It's permitted to have "go" prefix (e.g. "go1.5").
//
// Empty string (the default) means that we make no
-// Go version assumptions and (like gocritic does) behave
-// like all features are available. To make gocritic
+// Go version assumptions and (like go-critic does) behave
+// like all features are available. To make go-critic
// more conservative, the upper Go version level should be adjusted.
func (c *Context) SetGoVersion(version string) {
v, err := ParseGoVersion(version)
diff --git a/vendor/github.com/godoc-lint/godoc-lint/LICENSE b/vendor/github.com/godoc-lint/godoc-lint/LICENSE
new file mode 100644
index 0000000000..f51a8f9b58
--- /dev/null
+++ b/vendor/github.com/godoc-lint/godoc-lint/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2025 Babak K. Shandiz
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/vendor/github.com/godoc-lint/godoc-lint/pkg/analysis/analyzer.go b/vendor/github.com/godoc-lint/godoc-lint/pkg/analysis/analyzer.go
new file mode 100644
index 0000000000..0523900586
--- /dev/null
+++ b/vendor/github.com/godoc-lint/godoc-lint/pkg/analysis/analyzer.go
@@ -0,0 +1,108 @@
+// Package analysis provides the main analyzer implementation.
+package analysis
+
+import (
+ "errors"
+ "fmt"
+ "path/filepath"
+
+ "golang.org/x/tools/go/analysis"
+
+ "github.com/godoc-lint/godoc-lint/pkg/model"
+ "github.com/godoc-lint/godoc-lint/pkg/util"
+)
+
+const (
+ metaName = "godoclint"
+ metaDoc = "Checks Golang's documentation practice (godoc)"
+ metaURL = "https://github.com/godoc-lint/godoc-lint"
+)
+
+// Analyzer implements the godoc-lint analyzer.
+type Analyzer struct {
+ baseDir string
+ cb model.ConfigBuilder
+ inspector model.Inspector
+ reg model.Registry
+ exitFunc func(int, error)
+
+ analyzer *analysis.Analyzer
+}
+
+// NewAnalyzer returns a new instance of the corresponding analyzer.
+func NewAnalyzer(baseDir string, cb model.ConfigBuilder, reg model.Registry, inspector model.Inspector, exitFunc func(int, error)) *Analyzer {
+ result := &Analyzer{
+ baseDir: baseDir,
+ cb: cb,
+ reg: reg,
+ inspector: inspector,
+ exitFunc: exitFunc,
+ analyzer: &analysis.Analyzer{
+ Name: metaName,
+ Doc: metaDoc,
+ URL: metaURL,
+ Requires: []*analysis.Analyzer{inspector.GetAnalyzer()},
+ },
+ }
+
+ result.analyzer.Run = result.run
+ return result
+}
+
+// GetAnalyzer returns the underlying analyzer.
+func (a *Analyzer) GetAnalyzer() *analysis.Analyzer {
+ return a.analyzer
+}
+
+func (a *Analyzer) run(pass *analysis.Pass) (any, error) {
+ if len(pass.Files) == 0 {
+ return nil, nil
+ }
+
+ ft := util.GetPassFileToken(pass.Files[0], pass)
+ if ft == nil {
+ err := errors.New("cannot prepare config")
+ if a.exitFunc != nil {
+ a.exitFunc(2, err)
+ }
+ return nil, err
+ }
+
+ if !util.IsPathUnderBaseDir(a.baseDir, ft.Name()) {
+ return nil, nil
+ }
+
+ pkgDir := filepath.Dir(ft.Name())
+ cfg, err := a.cb.GetConfig(pkgDir)
+ if err != nil {
+ err := fmt.Errorf("cannot prepare config: %w", err)
+ if a.exitFunc != nil {
+ a.exitFunc(2, err)
+ }
+ return nil, err
+ }
+
+ ir := pass.ResultOf[a.inspector.GetAnalyzer()].(*model.InspectorResult)
+ if ir == nil || ir.Files == nil {
+ return nil, nil
+ }
+
+ actx := &model.AnalysisContext{
+ Config: cfg,
+ InspectorResult: ir,
+ Pass: pass,
+ }
+
+ for _, checker := range a.reg.List() {
+ // TODO(babakks): This can be done once to improve performance.
+ ruleSet := checker.GetCoveredRules()
+ if !actx.Config.IsAnyRuleApplicable(ruleSet) {
+ continue
+ }
+
+ if err := checker.Apply(actx); err != nil {
+ return nil, fmt.Errorf("checker error: %w", err)
+ }
+ }
+ return nil, nil
+}
diff --git a/vendor/github.com/godoc-lint/godoc-lint/pkg/check/deprecated/deprecated.go b/vendor/github.com/godoc-lint/godoc-lint/pkg/check/deprecated/deprecated.go
new file mode 100644
index 0000000000..fa8e646b89
--- /dev/null
+++ b/vendor/github.com/godoc-lint/godoc-lint/pkg/check/deprecated/deprecated.go
@@ -0,0 +1,114 @@
+// Package deprecated provides a checker for correct usage of deprecation
+// markers.
+package deprecated
+
+import (
+ "go/ast"
+ "go/doc/comment"
+ "regexp"
+
+ "github.com/godoc-lint/godoc-lint/pkg/model"
+ "github.com/godoc-lint/godoc-lint/pkg/util"
+)
+
+const deprecatedRule = model.DeprecatedRule
+
+var ruleSet = model.RuleSet{}.Add(deprecatedRule)
+
+// DeprecatedChecker checks correct usage of "Deprecated:" markers.
+type DeprecatedChecker struct{}
+
+// NewDeprecatedChecker returns a new instance of the corresponding checker.
+func NewDeprecatedChecker() *DeprecatedChecker {
+ return &DeprecatedChecker{}
+}
+
+// GetCoveredRules implements the corresponding interface method.
+func (r *DeprecatedChecker) GetCoveredRules() model.RuleSet {
+ return ruleSet
+}
+
+// Apply implements the corresponding interface method.
+func (r *DeprecatedChecker) Apply(actx *model.AnalysisContext) error {
+ docs := make(map[*model.CommentGroup]struct{}, 10*len(actx.InspectorResult.Files))
+
+ for _, ir := range util.AnalysisApplicableFiles(actx, false, model.RuleSet{}.Add(deprecatedRule)) {
+ if ir.PackageDoc != nil {
+ docs[ir.PackageDoc] = struct{}{}
+ }
+
+ for _, sd := range ir.SymbolDecl {
+ isExported := ast.IsExported(sd.Name)
+ if !isExported {
+ continue
+ }
+
+ if sd.ParentDoc != nil {
+ docs[sd.ParentDoc] = struct{}{}
+ }
+ if sd.Doc == nil {
+ continue
+ }
+ docs[sd.Doc] = struct{}{}
+ }
+ }
+
+ for doc := range docs {
+ checkDeprecations(actx, doc)
+ }
+ return nil
+}
+
+// probableDeprecationRE finds probable deprecation markers, including the
+// correct usage.
+var probableDeprecationRE = regexp.MustCompile(`(?i)^deprecated:.?`)
+
+const correctDeprecationMarker = "Deprecated: "
+
+func checkDeprecations(actx *model.AnalysisContext, doc *model.CommentGroup) {
+ if doc.DisabledRules.All || doc.DisabledRules.Rules.Has(deprecatedRule) {
+ return
+ }
+
+ for _, block := range doc.Parsed.Content {
+ // The correct usage of deprecation markers is to put them at the beginning
+ // of a paragraph (i.e. not a heading, code block, etc). Also the syntax is
+ // strict and must only be "Deprecated: " (case-sensitive and with the
+ // trailing whitespace).
+ //
+ // However, not all wrong usages are reliably discoverable. For example:
+ //
+ // // Foo is a symbol.
+ // // deprecated: use Bar.
+ // // func Foo() {}
+ //
+ // In this cases, the "deprecated: " marker is at the beginning of a new
+ // line, but as of godoc parser, it's just in the middle of the paragraph
+ // started at the top line. There might be some smart ways to detect these
+ // cases, but the problem is there will be false-positives to them. For
+ // instance, a valid case like this should never be detected as a wrong
+ // usage:
+ //
+ // // Foo is a symbol but here are the reasons why it's
+ // // deprecated: blah, blah, ...
+ // // func Foo() {}
+ //
+ // Needless to say we don't want to deal with human language complexities.
+
+ par, ok := block.(*comment.Paragraph)
+ if !ok || len(par.Text) == 0 {
+ continue
+ }
+ text, ok := par.Text[0].(comment.Plain)
+ if !ok {
+ continue
+ }
+
+ if match := probableDeprecationRE.FindString(string(text)); match == "" || match == correctDeprecationMarker {
+ continue
+ }
+
+ actx.Pass.ReportRangef(&doc.CG, "deprecation note should be formatted as %q", correctDeprecationMarker)
+ break
+ }
+}
diff --git a/vendor/github.com/godoc-lint/godoc-lint/pkg/check/max_len/max_len.go b/vendor/github.com/godoc-lint/godoc-lint/pkg/check/max_len/max_len.go
new file mode 100644
index 0000000000..a0ba371b29
--- /dev/null
+++ b/vendor/github.com/godoc-lint/godoc-lint/pkg/check/max_len/max_len.go
@@ -0,0 +1,155 @@
+// Package max_len provides a checker for maximum line length of godocs.
+package max_len
+
+import (
+ "fmt"
+ gdc "go/doc/comment"
+ "regexp"
+ "slices"
+ "strings"
+ "unicode/utf8"
+
+ "golang.org/x/tools/go/analysis"
+
+ "github.com/godoc-lint/godoc-lint/pkg/model"
+ "github.com/godoc-lint/godoc-lint/pkg/util"
+)
+
+const maxLenRule = model.MaxLenRule
+
+var ruleSet = model.RuleSet{}.Add(maxLenRule)
+
+// MaxLenChecker checks maximum line length of godocs.
+type MaxLenChecker struct{}
+
+// NewMaxLenChecker returns a new instance of the corresponding checker.
+func NewMaxLenChecker() *MaxLenChecker {
+ return &MaxLenChecker{}
+}
+
+// GetCoveredRules implements the corresponding interface method.
+func (r *MaxLenChecker) GetCoveredRules() model.RuleSet {
+ return ruleSet
+}
+
+// Apply implements the corresponding interface method.
+func (r *MaxLenChecker) Apply(actx *model.AnalysisContext) error {
+ includeTests := actx.Config.GetRuleOptions().MaxLenIncludeTests
+ maxLen := int(actx.Config.GetRuleOptions().MaxLenLength)
+ ignoreRegexps := actx.Config.GetRuleOptions().MaxLenIgnorePatterns
+
+ docs := make(map[*model.CommentGroup]struct{}, 10*len(actx.InspectorResult.Files))
+
+ for _, ir := range util.AnalysisApplicableFiles(actx, includeTests, model.RuleSet{}.Add(maxLenRule)) {
+ if ir.PackageDoc != nil {
+ docs[ir.PackageDoc] = struct{}{}
+ }
+
+ for _, sd := range ir.SymbolDecl {
+ if sd.ParentDoc != nil {
+ docs[sd.ParentDoc] = struct{}{}
+ }
+ if sd.Doc == nil {
+ continue
+ }
+ docs[sd.Doc] = struct{}{}
+ }
+ }
+
+ for doc := range docs {
+ checkMaxLen(actx, doc, maxLen, ignoreRegexps)
+ }
+ return nil
+}
+
+func checkMaxLen(actx *model.AnalysisContext, doc *model.CommentGroup, maxLen int, ignoreRegexps []*regexp.Regexp) {
+ if doc.DisabledRules.All || doc.DisabledRules.Rules.Has(maxLenRule) {
+ return
+ }
+
+ linkDefsMap := make(map[string]struct{}, len(doc.Parsed.Links))
+ for _, linkDef := range doc.Parsed.Links {
+ linkDefLine := fmt.Sprintf("[%s]: %s", linkDef.Text, linkDef.URL)
+ linkDefsMap[linkDefLine] = struct{}{}
+ }
+
+ nonCodeBlocks := make([]gdc.Block, 0, len(doc.Parsed.Content))
+ for _, b := range doc.Parsed.Content {
+ if _, ok := b.(*gdc.Code); ok {
+ continue
+ }
+ nonCodeBlocks = append(nonCodeBlocks, b)
+ }
+ strippedCodeAndLinks := &gdc.Doc{
+ Content: nonCodeBlocks,
+ }
+ text := string((&gdc.Printer{}).Comment(strippedCodeAndLinks))
+ linesIter := strings.SplitSeq(removeCarriageReturn(text), "\n")
+
+ // This is a clone of the original comment list since we need to remove
+ // elements from it, if needed. The main purpose of this is to don't miss
+ // duplicate long lines.
+ cgl := slices.Clone(doc.CG.List)
+
+ for l := range linesIter {
+ lineLen := utf8.RuneCountInString(l)
+ if lineLen <= maxLen {
+ continue
+ }
+ if shouldIgnoreLine(l, ignoreRegexps) {
+ continue
+ }
+
+ // Here we try to find the accurate position of the line within the
+ // original comment group. Historically, we would use the entire godoc
+ // block range to report the issue (See #55).
+ //
+ // However, the following approach does not work with /*..*/ comment
+ // blocks, since for them individual lines are not separately available,
+ // i.e. all lines would be in a single ast.Comment instance and
+ // therefore the ast.Comment.Pos will always point to the starting /*
+ // token.
+
+ foundAt := -1
+ for i, c := range cgl {
+ // As of [ast.Comment] docs, c.Text does not include carriage
+ // returns (\r) that may have been present in the source. This is
+ // good, since we have already stripped them from the lines.
+ //
+ // If the comment is a //-style one, c.Text starts with "// ". Since
+ // we're only interested in //-style cases, it's enough to check for
+ // that prefix.
+ if c.Text == "// "+l {
+ foundAt = i
+ break
+ }
+ }
+
+ var rng analysis.Range
+ if foundAt != -1 {
+ rng = cgl[foundAt]
+ // Remove the found comment line from the list so that we don't miss
+ // duplicate long lines, or even reporting the same line number more
+ // than once while leaving the other(s).
+ cgl = slices.Delete(cgl, foundAt, foundAt+1)
+ } else {
+ // Fallback to reporting the entire godoc block.
+ rng = &doc.CG
+ }
+
+ actx.Pass.ReportRangef(rng, "godoc line is too long (%d > %d)", lineLen, maxLen)
+ }
+}
+
+func shouldIgnoreLine(line string, ignoreRegexps []*regexp.Regexp) bool {
+ for _, re := range ignoreRegexps {
+ if re.MatchString(line) {
+ return true
+ }
+ }
+ return false
+}
+
+func removeCarriageReturn(s string) string {
+ return strings.ReplaceAll(s, "\r", "")
+}
diff --git a/vendor/github.com/godoc-lint/godoc-lint/pkg/check/no_unused_link/no_unused_link.go b/vendor/github.com/godoc-lint/godoc-lint/pkg/check/no_unused_link/no_unused_link.go
new file mode 100644
index 0000000000..8910204bef
--- /dev/null
+++ b/vendor/github.com/godoc-lint/godoc-lint/pkg/check/no_unused_link/no_unused_link.go
@@ -0,0 +1,69 @@
+// Package no_unused_link provides a checker for unused links in godocs.
+package no_unused_link
+
+import (
+ "github.com/godoc-lint/godoc-lint/pkg/model"
+ "github.com/godoc-lint/godoc-lint/pkg/util"
+)
+
+const noUnusedLinkRule = model.NoUnusedLinkRule
+
+var ruleSet = model.RuleSet{}.Add(noUnusedLinkRule)
+
+// NoUnusedLinkChecker checks for unused links.
+type NoUnusedLinkChecker struct{}
+
+// NewNoUnusedLinkChecker returns a new instance of the corresponding checker.
+func NewNoUnusedLinkChecker() *NoUnusedLinkChecker {
+ return &NoUnusedLinkChecker{}
+}
+
+// GetCoveredRules implements the corresponding interface method.
+func (r *NoUnusedLinkChecker) GetCoveredRules() model.RuleSet {
+ return ruleSet
+}
+
+// Apply implements the corresponding interface method.
+func (r *NoUnusedLinkChecker) Apply(actx *model.AnalysisContext) error {
+ includeTests := actx.Config.GetRuleOptions().NoUnusedLinkIncludeTests
+
+ docs := make(map[*model.CommentGroup]struct{}, 10*len(actx.InspectorResult.Files))
+
+ for _, ir := range util.AnalysisApplicableFiles(actx, includeTests, model.RuleSet{}.Add(noUnusedLinkRule)) {
+ if ir.PackageDoc != nil {
+ docs[ir.PackageDoc] = struct{}{}
+ }
+
+ for _, sd := range ir.SymbolDecl {
+ if sd.ParentDoc != nil {
+ docs[sd.ParentDoc] = struct{}{}
+ }
+ if sd.Doc == nil {
+ continue
+ }
+ docs[sd.Doc] = struct{}{}
+ }
+ }
+
+ for doc := range docs {
+ checkNoUnusedLink(actx, doc)
+ }
+ return nil
+}
+
+func checkNoUnusedLink(actx *model.AnalysisContext, doc *model.CommentGroup) {
+ if doc.DisabledRules.All || doc.DisabledRules.Rules.Has(noUnusedLinkRule) {
+ return
+ }
+
+ if doc.Text == "" {
+ return
+ }
+
+ for _, linkDef := range doc.Parsed.Links {
+ if linkDef.Used {
+ continue
+ }
+ actx.Pass.ReportRangef(&doc.CG, "godoc has unused link (%q)", linkDef.Text)
+ }
+}
diff --git a/vendor/github.com/godoc-lint/godoc-lint/pkg/check/pkg_doc/pkg_doc.go b/vendor/github.com/godoc-lint/godoc-lint/pkg/check/pkg_doc/pkg_doc.go
new file mode 100644
index 0000000000..e339ab33de
--- /dev/null
+++ b/vendor/github.com/godoc-lint/godoc-lint/pkg/check/pkg_doc/pkg_doc.go
@@ -0,0 +1,206 @@
+// Package pkg_doc provides a checker for package godocs.
+package pkg_doc
+
+import (
+ "go/ast"
+ "strings"
+
+ "github.com/godoc-lint/godoc-lint/pkg/check/shared"
+ "github.com/godoc-lint/godoc-lint/pkg/model"
+ "github.com/godoc-lint/godoc-lint/pkg/util"
+)
+
+const (
+ pkgDocRule = model.PkgDocRule
+ singlePkgDocRule = model.SinglePkgDocRule
+ requirePkgDocRule = model.RequirePkgDocRule
+)
+
+var ruleSet = model.RuleSet{}.Add(
+ pkgDocRule,
+ singlePkgDocRule,
+ requirePkgDocRule,
+)
+
+// PkgDocChecker checks package godocs.
+type PkgDocChecker struct{}
+
+// NewPkgDocChecker returns a new instance of the corresponding checker.
+func NewPkgDocChecker() *PkgDocChecker {
+ return &PkgDocChecker{}
+}
+
+// GetCoveredRules implements the corresponding interface method.
+func (r *PkgDocChecker) GetCoveredRules() model.RuleSet {
+ return ruleSet
+}
+
+// Apply implements the corresponding interface method.
+func (r *PkgDocChecker) Apply(actx *model.AnalysisContext) error {
+ checkPkgDocRule(actx)
+ checkSinglePkgDocRule(actx)
+ checkRequirePkgDocRule(actx)
+ return nil
+}
+
+const (
+ commandPkgName = "main"
+ commandTestPkgName = "main_test"
+)
+
+func checkPkgDocRule(actx *model.AnalysisContext) {
+ if !actx.Config.IsAnyRuleApplicable(model.RuleSet{}.Add(pkgDocRule)) {
+ return
+ }
+
+ includeTests := actx.Config.GetRuleOptions().PkgDocIncludeTests
+
+ for f, ir := range util.AnalysisApplicableFiles(actx, includeTests, model.RuleSet{}.Add(pkgDocRule)) {
+ if ir.PackageDoc == nil {
+ continue
+ }
+
+ if ir.PackageDoc.DisabledRules.All || ir.PackageDoc.DisabledRules.Rules.Has(pkgDocRule) {
+ continue
+ }
+
+ if f.Name.Name == commandPkgName || f.Name.Name == commandTestPkgName {
+ // Skip command packages, as they are not required to start with
+ // "Package main" or "Package main_test".
+ //
+ // See for more details:
+ // - https://github.com/godoc-lint/godoc-lint/issues/10
+ // - https://go.dev/doc/comment#cmd
+ continue
+ }
+
+ if ir.PackageDoc.Text == "" {
+ continue
+ }
+
+ if shared.HasDeprecatedParagraph(ir.PackageDoc.Parsed.Content) {
+ // If there's a paragraph starting with "Deprecated:", we skip the
+ // entire godoc. The reason is a deprecated symbol will not appear
+ // when docs are rendered.
+ //
+ // Another reason is that we cannot just skip those paragraphs and
+ // look for the symbol in the remaining text. To do that, we need
+ // to iterate over all comment.Block nodes, and check if a block
+ // is a paragraph AND starts with the deprecation marker. This is
+ // simple, but the challenge appears when we get to the first block
+ // that does not have the marker and we want to check if it starts
+ // with the symbol name. We'd expect that to be a paragraph, but
+ // that is not always the case. For example, take this decl:
+ //
+ // // Deprecated: blah blah
+ // //
+ // // Foo is integer
+ // //
+ // // Deprecation: blah blah
+ // type Foo int
+ //
+ // The first block is a paragraph which we can easily skip due to
+ // the "Deprecated:" marker. However, the second block is actually
+ // parsed as a heading. One can verify this by copy/pasting it in
+ // a Go file and check the gopls hover.
+ //
+ // There might be a workaround for this, but this also means the
+ // godoc parser behaves in unexpected ways, and until we don't
+ // really know the extent of its quirks, it's safer to just skip
+ // further checks on such godocs.
+ continue
+ }
+
+ if expectedPrefix, ok := checkPkgDocPrefix(ir.PackageDoc.Text, f.Name.Name); !ok {
+ actx.Pass.Reportf(ir.PackageDoc.CG.Pos(), "package godoc should start with %q", expectedPrefix+" ")
+ }
+ }
+}
+
+func checkPkgDocPrefix(text, packageName string) (string, bool) {
+ expectedPrefix := "Package " + packageName
+ if !strings.HasPrefix(text, expectedPrefix) {
+ return expectedPrefix, false
+ }
+ rest := text[len(expectedPrefix):]
+ return expectedPrefix, rest == "" || rest[0] == ' ' || rest[0] == '\t' || rest[0] == '\r' || rest[0] == '\n'
+}
+
+func checkSinglePkgDocRule(actx *model.AnalysisContext) {
+ if !actx.Config.IsAnyRuleApplicable(model.RuleSet{}.Add(singlePkgDocRule)) {
+ return
+ }
+
+ includeTests := actx.Config.GetRuleOptions().SinglePkgDocIncludeTests
+
+ documentedPkgs := make(map[string][]*ast.File, 2)
+
+ for f, ir := range util.AnalysisApplicableFiles(actx, includeTests, model.RuleSet{}.Add(singlePkgDocRule)) {
+ if ir.PackageDoc == nil || ir.PackageDoc.Text == "" {
+ continue
+ }
+
+ if ir.PackageDoc.DisabledRules.All || ir.PackageDoc.DisabledRules.Rules.Has(singlePkgDocRule) {
+ continue
+ }
+
+ pkg := f.Name.Name
+ if _, ok := documentedPkgs[pkg]; !ok {
+ documentedPkgs[pkg] = make([]*ast.File, 0, 2)
+ }
+ documentedPkgs[pkg] = append(documentedPkgs[pkg], f)
+ }
+
+ for pkg, fs := range documentedPkgs {
+ if len(fs) < 2 {
+ continue
+ }
+ for _, f := range fs {
+ ir := actx.InspectorResult.Files[f]
+ actx.Pass.Reportf(ir.PackageDoc.CG.Pos(), "package has more than one godoc (%q)", pkg)
+ }
+ }
+}
+
+func checkRequirePkgDocRule(actx *model.AnalysisContext) {
+ if !actx.Config.IsAnyRuleApplicable(model.RuleSet{}.Add(requirePkgDocRule)) {
+ return
+ }
+
+ includeTests := actx.Config.GetRuleOptions().RequirePkgDocIncludeTests
+
+ pkgFiles := make(map[string][]*ast.File, 2)
+
+ for f := range util.AnalysisApplicableFiles(actx, includeTests, model.RuleSet{}.Add(requirePkgDocRule)) {
+ pkg := f.Name.Name
+ if _, ok := pkgFiles[pkg]; !ok {
+ pkgFiles[pkg] = make([]*ast.File, 0, len(actx.Pass.Files))
+ }
+ pkgFiles[pkg] = append(pkgFiles[pkg], f)
+ }
+
+ for pkg, fs := range pkgFiles {
+ pkgHasGodoc := false
+ for _, f := range fs {
+ ir := actx.InspectorResult.Files[f]
+
+ if ir.PackageDoc == nil || ir.PackageDoc.Text == "" {
+ continue
+ }
+
+ if ir.PackageDoc.DisabledRules.All || ir.PackageDoc.DisabledRules.Rules.Has(requirePkgDocRule) {
+ continue
+ }
+
+ pkgHasGodoc = true
+ break
+ }
+
+ if pkgHasGodoc {
+ continue
+ }
+
+ // Add a diagnostic message to the first file of the package.
+ actx.Pass.Reportf(fs[0].Name.Pos(), "package should have a godoc (%q)", pkg)
+ }
+}
diff --git a/vendor/github.com/godoc-lint/godoc-lint/pkg/check/registry.go b/vendor/github.com/godoc-lint/godoc-lint/pkg/check/registry.go
new file mode 100644
index 0000000000..657fa8bc4d
--- /dev/null
+++ b/vendor/github.com/godoc-lint/godoc-lint/pkg/check/registry.go
@@ -0,0 +1,66 @@
+// Package check provides a registry of checkers.
+package check
+
+import (
+ "github.com/godoc-lint/godoc-lint/pkg/check/deprecated"
+ "github.com/godoc-lint/godoc-lint/pkg/check/max_len"
+ "github.com/godoc-lint/godoc-lint/pkg/check/no_unused_link"
+ "github.com/godoc-lint/godoc-lint/pkg/check/pkg_doc"
+ "github.com/godoc-lint/godoc-lint/pkg/check/require_doc"
+ "github.com/godoc-lint/godoc-lint/pkg/check/start_with_name"
+ "github.com/godoc-lint/godoc-lint/pkg/check/stdlib_doclink"
+ "github.com/godoc-lint/godoc-lint/pkg/model"
+)
+
+// Registry implements a registry of rules.
+type Registry struct {
+ checkers map[model.Checker]struct{}
+ coveredRules model.RuleSet
+}
+
+// NewRegistry returns a new rule registry instance.
+func NewRegistry(checkers ...model.Checker) *Registry {
+ registry := Registry{
+ checkers: make(map[model.Checker]struct{}, len(checkers)+10),
+ }
+ for _, c := range checkers {
+ registry.Add(c)
+ }
+ return ®istry
+}
+
+// NewPopulatedRegistry returns a registry with all supported rules registered.
+func NewPopulatedRegistry() *Registry {
+ return NewRegistry(
+ max_len.NewMaxLenChecker(),
+ pkg_doc.NewPkgDocChecker(),
+ require_doc.NewRequireDocChecker(),
+ start_with_name.NewStartWithNameChecker(),
+ no_unused_link.NewNoUnusedLinkChecker(),
+ deprecated.NewDeprecatedChecker(),
+ stdlib_doclink.NewStdlibDoclinkChecker(),
+ )
+}
+
+// Add implements the corresponding interface method.
+func (r *Registry) Add(checker model.Checker) {
+ if _, ok := r.checkers[checker]; ok {
+ return
+ }
+ r.coveredRules = r.coveredRules.Merge(checker.GetCoveredRules())
+ r.checkers[checker] = struct{}{}
+}
+
+// List implements the corresponding interface method.
+func (r *Registry) List() []model.Checker {
+ all := make([]model.Checker, 0, len(r.checkers))
+ for c := range r.checkers {
+ all = append(all, c)
+ }
+ return all
+}
+
+// GetCoveredRules implements the corresponding interface method.
+func (r *Registry) GetCoveredRules() model.RuleSet {
+ return r.coveredRules
+}
diff --git a/vendor/github.com/godoc-lint/godoc-lint/pkg/check/require_doc/require_doc.go b/vendor/github.com/godoc-lint/godoc-lint/pkg/check/require_doc/require_doc.go
new file mode 100644
index 0000000000..de2436b7b0
--- /dev/null
+++ b/vendor/github.com/godoc-lint/godoc-lint/pkg/check/require_doc/require_doc.go
@@ -0,0 +1,179 @@
+// Package require_doc provides a checker that requires symbols to have godocs.
+package require_doc
+
+import (
+ "go/ast"
+
+ "golang.org/x/tools/go/analysis"
+
+ "github.com/godoc-lint/godoc-lint/pkg/model"
+ "github.com/godoc-lint/godoc-lint/pkg/util"
+)
+
+const requireDocRule = model.RequireDocRule
+
+var ruleSet = model.RuleSet{}.Add(requireDocRule)
+
+// RequireDocChecker checks required godocs.
+type RequireDocChecker struct{}
+
+// NewRequireDocChecker returns a new instance of the corresponding checker.
+func NewRequireDocChecker() *RequireDocChecker {
+ return &RequireDocChecker{}
+}
+
+// GetCoveredRules implements the corresponding interface method.
+func (r *RequireDocChecker) GetCoveredRules() model.RuleSet {
+ return ruleSet
+}
+
+// Apply implements the corresponding interface method.
+func (r *RequireDocChecker) Apply(actx *model.AnalysisContext) error {
+ includeTests := actx.Config.GetRuleOptions().RequireDocIncludeTests
+ requirePublic := !actx.Config.GetRuleOptions().RequireDocIgnoreExported
+ requirePrivate := !actx.Config.GetRuleOptions().RequireDocIgnoreUnexported
+
+ if !requirePublic && !requirePrivate {
+ return nil
+ }
+
+ for _, ir := range util.AnalysisApplicableFiles(actx, includeTests, model.RuleSet{}.Add(requireDocRule)) {
+ for _, decl := range ir.SymbolDecl {
+ isExported := ast.IsExported(decl.Name)
+ if decl.IsMethod && decl.MethodRecvBaseTypeName != "" {
+ // A method is considered exported (in terms of godoc visibility)
+ // only if both the method name and the base type name are exported.
+ isExported = isExported && ast.IsExported(decl.MethodRecvBaseTypeName)
+ }
+
+ if isExported && !requirePublic || !isExported && !requirePrivate {
+ continue
+ }
+
+ if decl.Name == "_" {
+ // Blank identifiers should be ignored; e.g.:
+ //
+ // var _ = 0
+ continue
+ }
+
+ if decl.Doc != nil && (decl.Doc.DisabledRules.All || decl.Doc.DisabledRules.Rules.Has(requireDocRule)) {
+ continue
+ }
+
+ if decl.Kind == model.SymbolDeclKindBad {
+ continue
+ }
+
+ if decl.Kind == model.SymbolDeclKindFunc {
+ if decl.Doc == nil || decl.Doc.Text == "" {
+ reportRange(actx.Pass, decl.Ident)
+ }
+ continue
+ }
+
+ // Now we only have const/var/type declarations.
+
+ if decl.Doc != nil && decl.Doc.Text != "" {
+ // cases:
+ //
+ // // godoc
+ // const foo = 0
+ //
+ // // godoc
+ // const foo, bar = 0, 0
+ //
+ // const (
+ // // godoc
+ // foo = 0
+ // )
+ //
+ // const (
+ // // godoc
+ // foo, bar = 0, 0
+ // )
+ //
+ // // godoc
+ // type foo int
+ //
+ // type (
+ // // godoc
+ // foo int
+ // )
+ continue
+ }
+
+ if decl.TrailingDoc != nil && decl.TrailingDoc.Text != "" {
+ // cases:
+ //
+ // const foo = 0 // godoc
+ //
+ // const foo, bar = 0, 0 // godoc
+ //
+ // const (
+ // foo = 0 // godoc
+ // )
+ //
+ // const (
+ // foo, bar = 0, 0 // godoc
+ // )
+ //
+ // type foo int // godoc
+ //
+ // type (
+ // foo int // godoc
+ // )
+ continue
+ }
+
+ if decl.ParentDoc != nil && decl.ParentDoc.Text != "" {
+ // cases:
+ //
+ // // godoc
+ // const (
+ // foo = 0
+ // )
+ //
+ // // godoc
+ // const (
+ // foo, bar = 0, 0
+ // )
+ //
+ // // godoc
+ // type (
+ // foo int
+ // )
+ continue
+ }
+
+ // At this point there is no godoc for the symbol.
+ //
+ // cases:
+ //
+ // const foo = 0
+ //
+ // const foo, bar = 0, 0
+ //
+ // const (
+ // foo = 0
+ // )
+ //
+ // const (
+ // foo, bar = 0, 0
+ // )
+ //
+ // type foo int
+ //
+ // type (
+ // foo int
+ // )
+
+ reportRange(actx.Pass, decl.Ident)
+ }
+ }
+ return nil
+}
+
+func reportRange(pass *analysis.Pass, ident *ast.Ident) {
+ pass.ReportRangef(ident, "symbol should have a godoc (%q)", ident.Name)
+}
diff --git a/vendor/github.com/godoc-lint/godoc-lint/pkg/check/shared/deprecated.go b/vendor/github.com/godoc-lint/godoc-lint/pkg/check/shared/deprecated.go
new file mode 100644
index 0000000000..b7d471926b
--- /dev/null
+++ b/vendor/github.com/godoc-lint/godoc-lint/pkg/check/shared/deprecated.go
@@ -0,0 +1,29 @@
+// Package shared provides shared utilities for checkers.
+package shared
+
+import (
+ "go/doc/comment"
+ "strings"
+)
+
+// HasDeprecatedParagraph reports whether the given comment blocks contain a
+// paragraph starting with deprecation marker.
+func HasDeprecatedParagraph(blocks []comment.Block) bool {
+ for _, block := range blocks {
+ par, ok := block.(*comment.Paragraph)
+ if !ok || len(par.Text) == 0 {
+ continue
+ }
+ text, ok := par.Text[0].(comment.Plain)
+ if !ok {
+ continue
+ }
+
+ // Only an exact match (casing and the trailing whitespace) is considered
+ // a valid deprecation marker.
+ if strings.HasPrefix(string(text), "Deprecated: ") {
+ return true
+ }
+ }
+ return false
+}
diff --git a/vendor/github.com/godoc-lint/godoc-lint/pkg/check/start_with_name/start_with_name.go b/vendor/github.com/godoc-lint/godoc-lint/pkg/check/start_with_name/start_with_name.go
new file mode 100644
index 0000000000..b80e760208
--- /dev/null
+++ b/vendor/github.com/godoc-lint/godoc-lint/pkg/check/start_with_name/start_with_name.go
@@ -0,0 +1,140 @@
+// Package start_with_name provides a checker for godocs starting with the
+// symbol name.
+package start_with_name
+
+import (
+ "go/ast"
+ "regexp"
+ "strings"
+
+ "github.com/godoc-lint/godoc-lint/pkg/check/shared"
+ "github.com/godoc-lint/godoc-lint/pkg/model"
+ "github.com/godoc-lint/godoc-lint/pkg/util"
+)
+
+const startWithNameRule = model.StartWithNameRule
+
+var ruleSet = model.RuleSet{}.Add(startWithNameRule)
+
+// StartWithNameChecker checks starter of godocs.
+type StartWithNameChecker struct{}
+
+// NewStartWithNameChecker returns a new instance of the corresponding checker.
+func NewStartWithNameChecker() *StartWithNameChecker {
+ return &StartWithNameChecker{}
+}
+
+// GetCoveredRules implements the corresponding interface method.
+func (r *StartWithNameChecker) GetCoveredRules() model.RuleSet {
+ return ruleSet
+}
+
+// Apply implements the corresponding interface method.
+func (r *StartWithNameChecker) Apply(actx *model.AnalysisContext) error {
+ if !actx.Config.IsAnyRuleApplicable(model.RuleSet{}.Add(startWithNameRule)) {
+ return nil
+ }
+
+ includeTests := actx.Config.GetRuleOptions().StartWithNameIncludeTests
+ includePrivate := actx.Config.GetRuleOptions().StartWithNameIncludeUnexported
+
+ for _, ir := range util.AnalysisApplicableFiles(actx, includeTests, model.RuleSet{}.Add(startWithNameRule)) {
+ for _, decl := range ir.SymbolDecl {
+ isExported := ast.IsExported(decl.Name)
+ if decl.IsMethod && decl.MethodRecvBaseTypeName != "" {
+ // A method is considered exported (in terms of godoc visibility)
+ // only if both the method name and the base type name are exported.
+ isExported = isExported && ast.IsExported(decl.MethodRecvBaseTypeName)
+ }
+
+ if !isExported && !includePrivate {
+ continue
+ }
+
+ if decl.Name == "_" {
+ // Blank identifiers should be ignored; e.g.:
+ //
+ // var _ = 0
+ continue
+ }
+
+ if decl.Kind == model.SymbolDeclKindBad {
+ continue
+ }
+
+ if decl.Doc == nil || decl.Doc.Text == "" {
+ continue
+ }
+
+ if decl.Doc.DisabledRules.All || decl.Doc.DisabledRules.Rules.Has(startWithNameRule) {
+ continue
+ }
+
+ if decl.MultiNameDecl {
+ continue
+ }
+
+ if shared.HasDeprecatedParagraph(decl.Doc.Parsed.Content) {
+ // If there's a paragraph starting with "Deprecated:", we skip the
+ // entire godoc. The reason is a deprecated symbol will not appear
+ // when docs are rendered.
+ //
+ // Another reason is that we cannot just skip those paragraphs and
+ // look for the symbol in the remaining text. To do that, we need
+ // to iterate over all comment.Block nodes, and check if a block
+ // is a paragraph AND starts with the deprecation marker. This is
+ // simple, but the challenge appears when we get to the first block
+ // that does not have the marker and we want to check if it starts
+ // with the symbol name. We'd expect that to be a paragraph, but
+ // that is not always the case. For example, take this decl:
+ //
+ // // Deprecated: blah blah
+ // //
+ // // Foo is integer
+ // //
+ // // Deprecation: blah blah
+ // type Foo int
+ //
+ // The first block is a paragraph which we can easily skip due to
+ // the "Deprecated:" marker. However, the second block is actually
+ // parsed as a heading. One can verify this by copy/pasting it in
+ // a Go file and check the gopls hover.
+ //
+ // There might be a workaround for this, but this also means the
+ // godoc parser behaves in unexpected ways, and until we don't
+ // really know the extent of its quirks, it's safer to just skip
+ // further checks on such godocs.
+ continue
+ }
+
+ if matchSymbolName(decl.Doc.Text, decl.Name) {
+ continue
+ }
+
+ actx.Pass.ReportRangef(&decl.Doc.CG, "godoc should start with symbol name (%q)", decl.Name)
+ }
+ }
+ return nil
+}
+
+var (
+ startPattern = regexp.MustCompile(`^(?:(A|a|AN|An|an|THE|The|the) )?(?P.+?)\b`)
+ startPatternSymbolNameIndex = startPattern.SubexpIndex("symbol_name")
+)
+
+func matchSymbolName(text, symbol string) bool {
+ head, _, _ := strings.Cut(text, "\n")
+ head, _ = strings.CutPrefix(head, "\r")
+ head = strings.SplitN(head, " ", 2)[0]
+ head = strings.SplitN(head, "\t", 2)[0]
+
+ if head == symbol {
+ return true
+ }
+
+ match := startPattern.FindStringSubmatch(text)
+ if match == nil {
+ return false
+ }
+ return match[startPatternSymbolNameIndex] == symbol
+}
diff --git a/vendor/github.com/godoc-lint/godoc-lint/pkg/check/stdlib_doclink/data.go b/vendor/github.com/godoc-lint/godoc-lint/pkg/check/stdlib_doclink/data.go
new file mode 100644
index 0000000000..92fb8b1bcf
--- /dev/null
+++ b/vendor/github.com/godoc-lint/godoc-lint/pkg/check/stdlib_doclink/data.go
@@ -0,0 +1,27 @@
+package stdlib_doclink
+
+import (
+ "bytes"
+ _ "embed"
+ "encoding/json"
+ "sync"
+
+ "github.com/godoc-lint/godoc-lint/pkg/check/stdlib_doclink/internal"
+)
+
+//go:embed stdlib.json
+var stdlibRaw []byte
+
+var stdlib = sync.OnceValue(func() internal.Stdlib {
+ v, _ := parseStdlib()
+ return v
+})
+
+func parseStdlib() (internal.Stdlib, error) {
+ result := internal.Stdlib{}
+ if err := json.NewDecoder(bytes.NewReader(stdlibRaw)).Decode(&result); err != nil {
+ // This never happens
+ return internal.Stdlib{}, err
+ }
+ return result, nil
+}
diff --git a/vendor/github.com/godoc-lint/godoc-lint/pkg/check/stdlib_doclink/internal/type.go b/vendor/github.com/godoc-lint/godoc-lint/pkg/check/stdlib_doclink/internal/type.go
new file mode 100644
index 0000000000..4197695e10
--- /dev/null
+++ b/vendor/github.com/godoc-lint/godoc-lint/pkg/check/stdlib_doclink/internal/type.go
@@ -0,0 +1,30 @@
+// Package internal contains internal types for stdlib_doclink checker.
+package internal
+
+import (
+ _ "embed"
+)
+
+// SymbolKind represents the kind of a symbol in the standard library.
+type SymbolKind string
+
+// Kinds of symbols.
+const (
+ SymbolKindNA SymbolKind = ""
+ SymbolKindConst SymbolKind = "c"
+ SymbolKindVar SymbolKind = "v"
+ SymbolKindFunc SymbolKind = "f"
+ SymbolKindMethod SymbolKind = "m"
+ SymbolKindType SymbolKind = "t"
+)
+
+// StdlibPackage represents a standard library package with its path, name, and
+// symbols.
+type StdlibPackage struct {
+ Path string `json:"path"`
+ Name string `json:"name"`
+ Symbols map[string]SymbolKind `json:"symbols"`
+}
+
+// Stdlib represents a collection of standard library packages.
+type Stdlib map[string]*StdlibPackage
diff --git a/vendor/github.com/godoc-lint/godoc-lint/pkg/check/stdlib_doclink/stdlib.json b/vendor/github.com/godoc-lint/godoc-lint/pkg/check/stdlib_doclink/stdlib.json
new file mode 100644
index 0000000000..6c914204f5
--- /dev/null
+++ b/vendor/github.com/godoc-lint/godoc-lint/pkg/check/stdlib_doclink/stdlib.json
@@ -0,0 +1 @@
+{"archive/tar":{"path":"archive/tar","name":"tar","symbols":{"ErrFieldTooLong":"v","ErrHeader":"v","ErrInsecurePath":"v","ErrWriteAfterClose":"v","ErrWriteTooLong":"v","FileInfoHeader":"f","FileInfoNames":"t","Format":"t","Format.String":"m","FormatGNU":"c","FormatPAX":"c","FormatUSTAR":"c","FormatUnknown":"c","Header":"t","Header.FileInfo":"m","NewReader":"f","NewWriter":"f","Reader":"t","Reader.Next":"m","Reader.Read":"m","TypeBlock":"c","TypeChar":"c","TypeCont":"c","TypeDir":"c","TypeFifo":"c","TypeGNULongLink":"c","TypeGNULongName":"c","TypeGNUSparse":"c","TypeLink":"c","TypeReg":"c","TypeRegA":"c","TypeSymlink":"c","TypeXGlobalHeader":"c","TypeXHeader":"c","Writer":"t","Writer.AddFS":"m","Writer.Close":"m","Writer.Flush":"m","Writer.Write":"m","Writer.WriteHeader":"m"}},"archive/zip":{"path":"archive/zip","name":"zip","symbols":{"Compressor":"t","Decompressor":"t","Deflate":"c","ErrAlgorithm":"v","ErrChecksum":"v","ErrFormat":"v","ErrInsecurePath":"v","File":"t","File.DataOffset":"m","File.Open":"m","File.OpenRaw":"m","FileHeader":"t","FileHeader.FileInfo":"m","FileHeader.ModTime":"m","FileHeader.Mode":"m","FileHeader.SetModTime":"m","FileHeader.SetMode":"m","FileInfoHeader":"f","NewReader":"f","NewWriter":"f","OpenReader":"f","ReadCloser":"t","ReadCloser.Close":"m","Reader":"t","Reader.Open":"m","Reader.RegisterDecompressor":"m","RegisterCompressor":"f","RegisterDecompressor":"f","Store":"c","Writer":"t","Writer.AddFS":"m","Writer.Close":"m","Writer.Copy":"m","Writer.Create":"m","Writer.CreateHeader":"m","Writer.CreateRaw":"m","Writer.Flush":"m","Writer.RegisterCompressor":"m","Writer.SetComment":"m","Writer.SetOffset":"m"}},"bufio":{"path":"bufio","name":"bufio","symbols":{"ErrAdvanceTooFar":"v","ErrBadReadCount":"v","ErrBufferFull":"v","ErrFinalToken":"v","ErrInvalidUnreadByte":"v","ErrInvalidUnreadRune":"v","ErrNegativeAdvance":"v","ErrNegativeCount":"v","ErrTooLong":"v","MaxScanTokenSize":"c","NewReadWriter":"f","NewReader":"f","NewReaderSize":"f","NewScanner":"f","NewWriter":"f","NewWriterSize":"f","ReadWriter":"t","Reader":"t","Reader.Buffered":"m","Reader.Discard":"m","Reader.Peek":"m","Reader.Read":"m","Reader.ReadByte":"m","Reader.ReadBytes":"m","Reader.ReadLine":"m","Reader.ReadRune":"m","Reader.ReadSlice":"m","Reader.ReadString":"m","Reader.Reset":"m","Reader.Size":"m","Reader.UnreadByte":"m","Reader.UnreadRune":"m","Reader.WriteTo":"m","ScanBytes":"f","ScanLines":"f","ScanRunes":"f","ScanWords":"f","Scanner":"t","Scanner.Buffer":"m","Scanner.Bytes":"m","Scanner.Err":"m","Scanner.Scan":"m","Scanner.Split":"m","Scanner.Text":"m","SplitFunc":"t","Writer":"t","Writer.Available":"m","Writer.AvailableBuffer":"m","Writer.Buffered":"m","Writer.Flush":"m","Writer.ReadFrom":"m","Writer.Reset":"m","Writer.Size":"m","Writer.Write":"m","Writer.WriteByte":"m","Writer.WriteRune":"m","Writer.WriteString":"m"}},"builtin":{"path":"builtin","name":"builtin","symbols":{"ComplexType":"t","FloatType":"t","IntegerType":"t","Type":"t","Type1":"t","TypeOrExpr":"t"}},"bytes":{"path":"bytes","name":"bytes","symbols":{"Buffer":"t","Buffer.Available":"m","Buffer.AvailableBuffer":"m","Buffer.Bytes":"m","Buffer.Cap":"m","Buffer.Grow":"m","Buffer.Len":"m","Buffer.Next":"m","Buffer.Peek":"m","Buffer.Read":"m","Buffer.ReadByte":"m","Buffer.ReadBytes":"m","Buffer.ReadFrom":"m","Buffer.ReadRune":"m","Buffer.ReadString":"m","Buffer.Reset":"m","Buffer.String":"m","Buffer.Truncate":"m","Buffer.UnreadByte":"m","Buffer.UnreadRune":"m","Buffer.Write":"m","Buffer.WriteByte":"m","Buffer.WriteRune":"m","Buffer.WriteString":"m","Buffer.WriteTo":"m","Clone":"f","Compare":"f","Contains":"f","ContainsAny":"f","ContainsFunc":"f","ContainsRune":"f","Count":"f","Cut":"f","CutLast":"f","CutPrefix":"f","CutSuffix":"f","Equal":"f","EqualFold":"f","ErrTooLarge":"v","Fields":"f","FieldsFunc":"f","FieldsFuncSeq":"f","FieldsSeq":"f","HasPrefix":"f","HasSuffix":"f","Index":"f","IndexAny":"f","IndexByte":"f","IndexFunc":"f","IndexRune":"f","Join":"f","LastIndex":"f","LastIndexAny":"f","LastIndexByte":"f","LastIndexFunc":"f","Lines":"f","Map":"f","MinRead":"c","NewBuffer":"f","NewBufferString":"f","NewReader":"f","Reader":"t","Reader.Len":"m","Reader.Read":"m","Reader.ReadAt":"m","Reader.ReadByte":"m","Reader.ReadRune":"m","Reader.Reset":"m","Reader.Seek":"m","Reader.Size":"m","Reader.UnreadByte":"m","Reader.UnreadRune":"m","Reader.WriteTo":"m","Repeat":"f","Replace":"f","ReplaceAll":"f","Runes":"f","Split":"f","SplitAfter":"f","SplitAfterN":"f","SplitAfterSeq":"f","SplitN":"f","SplitSeq":"f","Title":"f","ToLower":"f","ToLowerSpecial":"f","ToTitle":"f","ToTitleSpecial":"f","ToUpper":"f","ToUpperSpecial":"f","ToValidUTF8":"f","Trim":"f","TrimFunc":"f","TrimLeft":"f","TrimLeftFunc":"f","TrimPrefix":"f","TrimRight":"f","TrimRightFunc":"f","TrimSpace":"f","TrimSuffix":"f"}},"cmp":{"path":"cmp","name":"cmp","symbols":{"Compare":"f","Less":"f","Or":"f","Ordered":"t"}},"compress/bzip2":{"path":"compress/bzip2","name":"bzip2","symbols":{"NewReader":"f","StructuralError":"t","StructuralError.Error":"m"}},"compress/flate":{"path":"compress/flate","name":"flate","symbols":{"BestCompression":"c","BestSpeed":"c","CorruptInputError":"t","CorruptInputError.Error":"m","DefaultCompression":"c","HuffmanOnly":"c","InternalError":"t","InternalError.Error":"m","NewReader":"f","NewReaderDict":"f","NewWriter":"f","NewWriterDict":"f","NoCompression":"c","ReadError":"t","ReadError.Error":"m","Reader":"t","Resetter":"t","WriteError":"t","WriteError.Error":"m","Writer":"t","Writer.Close":"m","Writer.Flush":"m","Writer.Reset":"m","Writer.Write":"m"}},"compress/gzip":{"path":"compress/gzip","name":"gzip","symbols":{"BestCompression":"c","BestSpeed":"c","DefaultCompression":"c","ErrChecksum":"v","ErrHeader":"v","Header":"t","HuffmanOnly":"c","NewReader":"f","NewWriter":"f","NewWriterLevel":"f","NoCompression":"c","Reader":"t","Reader.Close":"m","Reader.Multistream":"m","Reader.Read":"m","Reader.Reset":"m","Writer":"t","Writer.Close":"m","Writer.Flush":"m","Writer.Reset":"m","Writer.Write":"m"}},"compress/lzw":{"path":"compress/lzw","name":"lzw","symbols":{"LSB":"c","MSB":"c","NewReader":"f","NewWriter":"f","Order":"t","Reader":"t","Reader.Close":"m","Reader.Read":"m","Reader.Reset":"m","Writer":"t","Writer.Close":"m","Writer.Reset":"m","Writer.Write":"m"}},"compress/zlib":{"path":"compress/zlib","name":"zlib","symbols":{"BestCompression":"c","BestSpeed":"c","DefaultCompression":"c","ErrChecksum":"v","ErrDictionary":"v","ErrHeader":"v","HuffmanOnly":"c","NewReader":"f","NewReaderDict":"f","NewWriter":"f","NewWriterLevel":"f","NewWriterLevelDict":"f","NoCompression":"c","Resetter":"t","Writer":"t","Writer.Close":"m","Writer.Flush":"m","Writer.Reset":"m","Writer.Write":"m"}},"container/heap":{"path":"container/heap","name":"heap","symbols":{"Fix":"f","Init":"f","Interface":"t","Pop":"f","Push":"f","Remove":"f"}},"container/list":{"path":"container/list","name":"list","symbols":{"Element":"t","Element.Next":"m","Element.Prev":"m","List":"t","List.Back":"m","List.Front":"m","List.Init":"m","List.InsertAfter":"m","List.InsertBefore":"m","List.Len":"m","List.MoveAfter":"m","List.MoveBefore":"m","List.MoveToBack":"m","List.MoveToFront":"m","List.PushBack":"m","List.PushBackList":"m","List.PushFront":"m","List.PushFrontList":"m","List.Remove":"m","New":"f"}},"container/ring":{"path":"container/ring","name":"ring","symbols":{"New":"f","Ring":"t","Ring.Do":"m","Ring.Len":"m","Ring.Link":"m","Ring.Move":"m","Ring.Next":"m","Ring.Prev":"m","Ring.Unlink":"m"}},"context":{"path":"context","name":"context","symbols":{"AfterFunc":"f","Background":"f","CancelCauseFunc":"t","CancelFunc":"t","Canceled":"v","Cause":"f","Context":"t","DeadlineExceeded":"v","TODO":"f","WithCancel":"f","WithCancelCause":"f","WithDeadline":"f","WithDeadlineCause":"f","WithTimeout":"f","WithTimeoutCause":"f","WithValue":"f","WithoutCancel":"f"}},"crypto":{"path":"crypto","name":"crypto","symbols":{"BLAKE2b_256":"c","BLAKE2b_384":"c","BLAKE2b_512":"c","BLAKE2s_256":"c","Decapsulator":"t","Decrypter":"t","DecrypterOpts":"t","Encapsulator":"t","Hash":"t","Hash.Available":"m","Hash.HashFunc":"m","Hash.New":"m","Hash.Size":"m","Hash.String":"m","MD4":"c","MD5":"c","MD5SHA1":"c","MLDSAMu":"c","MessageSigner":"t","PrivateKey":"t","PublicKey":"t","RIPEMD160":"c","RegisterHash":"f","SHA1":"c","SHA224":"c","SHA256":"c","SHA384":"c","SHA3_224":"c","SHA3_256":"c","SHA3_384":"c","SHA3_512":"c","SHA512":"c","SHA512_224":"c","SHA512_256":"c","SignMessage":"f","Signer":"t","SignerOpts":"t"}},"crypto/aes":{"path":"crypto/aes","name":"aes","symbols":{"BlockSize":"c","KeySizeError":"t","KeySizeError.Error":"m","NewCipher":"f"}},"crypto/cipher":{"path":"crypto/cipher","name":"cipher","symbols":{"AEAD":"t","Block":"t","BlockMode":"t","NewCBCDecrypter":"f","NewCBCEncrypter":"f","NewCFBDecrypter":"f","NewCFBEncrypter":"f","NewCTR":"f","NewGCM":"f","NewGCMWithNonceSize":"f","NewGCMWithRandomNonce":"f","NewGCMWithTagSize":"f","NewOFB":"f","Stream":"t","StreamReader":"t","StreamReader.Read":"m","StreamWriter":"t","StreamWriter.Close":"m","StreamWriter.Write":"m"}},"crypto/des":{"path":"crypto/des","name":"des","symbols":{"BlockSize":"c","KeySizeError":"t","KeySizeError.Error":"m","NewCipher":"f","NewTripleDESCipher":"f"}},"crypto/dsa":{"path":"crypto/dsa","name":"dsa","symbols":{"ErrInvalidPublicKey":"v","GenerateKey":"f","GenerateParameters":"f","L1024N160":"c","L2048N224":"c","L2048N256":"c","L3072N256":"c","ParameterSizes":"t","Parameters":"t","PrivateKey":"t","PublicKey":"t","Sign":"f","Verify":"f"}},"crypto/ecdh":{"path":"crypto/ecdh","name":"ecdh","symbols":{"Curve":"t","KeyExchanger":"t","P256":"f","P384":"f","P521":"f","PrivateKey":"t","PrivateKey.Bytes":"m","PrivateKey.Curve":"m","PrivateKey.ECDH":"m","PrivateKey.Equal":"m","PrivateKey.Public":"m","PrivateKey.PublicKey":"m","PublicKey":"t","PublicKey.Bytes":"m","PublicKey.Curve":"m","PublicKey.Equal":"m","X25519":"f"}},"crypto/ecdsa":{"path":"crypto/ecdsa","name":"ecdsa","symbols":{"GenerateKey":"f","ParseRawPrivateKey":"f","ParseUncompressedPublicKey":"f","PrivateKey":"t","PrivateKey.Bytes":"m","PrivateKey.ECDH":"m","PrivateKey.Equal":"m","PrivateKey.Public":"m","PrivateKey.Sign":"m","PublicKey":"t","PublicKey.Bytes":"m","PublicKey.ECDH":"m","PublicKey.Equal":"m","Sign":"f","SignASN1":"f","Verify":"f","VerifyASN1":"f"}},"crypto/ed25519":{"path":"crypto/ed25519","name":"ed25519","symbols":{"GenerateKey":"f","NewKeyFromSeed":"f","Options":"t","Options.HashFunc":"m","PrivateKey":"t","PrivateKey.Equal":"m","PrivateKey.Public":"m","PrivateKey.Seed":"m","PrivateKey.Sign":"m","PrivateKeySize":"c","PublicKey":"t","PublicKey.Equal":"m","PublicKeySize":"c","SeedSize":"c","Sign":"f","SignatureSize":"c","Verify":"f","VerifyWithOptions":"f"}},"crypto/elliptic":{"path":"crypto/elliptic","name":"elliptic","symbols":{"Curve":"t","CurveParams":"t","CurveParams.Add":"m","CurveParams.Double":"m","CurveParams.IsOnCurve":"m","CurveParams.Params":"m","CurveParams.ScalarBaseMult":"m","CurveParams.ScalarMult":"m","GenerateKey":"f","Marshal":"f","MarshalCompressed":"f","P224":"f","P256":"f","P384":"f","P521":"f","Unmarshal":"f","UnmarshalCompressed":"f"}},"crypto/fips140":{"path":"crypto/fips140","name":"fips140","symbols":{"Enabled":"f","Enforced":"f","Version":"f","WithoutEnforcement":"f"}},"crypto/hkdf":{"path":"crypto/hkdf","name":"hkdf","symbols":{"Expand":"f","Extract":"f","Key":"f"}},"crypto/hmac":{"path":"crypto/hmac","name":"hmac","symbols":{"Equal":"f","New":"f"}},"crypto/hpke":{"path":"crypto/hpke","name":"hpke","symbols":{"AEAD":"t","AES128GCM":"f","AES256GCM":"f","ChaCha20Poly1305":"f","DHKEM":"f","ExportOnly":"f","HKDFSHA256":"f","HKDFSHA384":"f","HKDFSHA512":"f","KDF":"t","KEM":"t","MLKEM1024":"f","MLKEM1024P384":"f","MLKEM768":"f","MLKEM768P256":"f","MLKEM768X25519":"f","NewAEAD":"f","NewDHKEMPrivateKey":"f","NewDHKEMPublicKey":"f","NewHybridPrivateKey":"f","NewHybridPublicKey":"f","NewKDF":"f","NewKEM":"f","NewMLKEMPrivateKey":"f","NewMLKEMPublicKey":"f","NewRecipient":"f","NewSender":"f","Open":"f","PrivateKey":"t","PublicKey":"t","Recipient":"t","Recipient.Export":"m","Recipient.Open":"m","SHAKE128":"f","SHAKE256":"f","Seal":"f","Sender":"t","Sender.Export":"m","Sender.Seal":"m"}},"crypto/md5":{"path":"crypto/md5","name":"md5","symbols":{"BlockSize":"c","New":"f","Size":"c","Sum":"f"}},"crypto/mldsa":{"path":"crypto/mldsa","name":"mldsa","symbols":{"GenerateKey":"f","MLDSA44":"f","MLDSA44PublicKeySize":"c","MLDSA44SignatureSize":"c","MLDSA65":"f","MLDSA65PublicKeySize":"c","MLDSA65SignatureSize":"c","MLDSA87":"f","MLDSA87PublicKeySize":"c","MLDSA87SignatureSize":"c","NewPrivateKey":"f","NewPublicKey":"f","Options":"t","Options.HashFunc":"m","Parameters":"t","Parameters.PublicKeySize":"m","Parameters.SignatureSize":"m","Parameters.String":"m","PrivateKey":"t","PrivateKey.Bytes":"m","PrivateKey.Equal":"m","PrivateKey.Public":"m","PrivateKey.PublicKey":"m","PrivateKey.Sign":"m","PrivateKey.SignDeterministic":"m","PrivateKeySize":"c","PublicKey":"t","PublicKey.Bytes":"m","PublicKey.Equal":"m","PublicKey.Parameters":"m","Verify":"f"}},"crypto/mlkem":{"path":"crypto/mlkem","name":"mlkem","symbols":{"CiphertextSize1024":"c","CiphertextSize768":"c","DecapsulationKey1024":"t","DecapsulationKey1024.Bytes":"m","DecapsulationKey1024.Decapsulate":"m","DecapsulationKey1024.EncapsulationKey":"m","DecapsulationKey1024.Encapsulator":"m","DecapsulationKey768":"t","DecapsulationKey768.Bytes":"m","DecapsulationKey768.Decapsulate":"m","DecapsulationKey768.EncapsulationKey":"m","DecapsulationKey768.Encapsulator":"m","EncapsulationKey1024":"t","EncapsulationKey1024.Bytes":"m","EncapsulationKey1024.Encapsulate":"m","EncapsulationKey768":"t","EncapsulationKey768.Bytes":"m","EncapsulationKey768.Encapsulate":"m","EncapsulationKeySize1024":"c","EncapsulationKeySize768":"c","GenerateKey1024":"f","GenerateKey768":"f","NewDecapsulationKey1024":"f","NewDecapsulationKey768":"f","NewEncapsulationKey1024":"f","NewEncapsulationKey768":"f","SeedSize":"c","SharedKeySize":"c"}},"crypto/mlkem/mlkemtest":{"path":"crypto/mlkem/mlkemtest","name":"mlkemtest","symbols":{"Encapsulate1024":"f","Encapsulate768":"f"}},"crypto/pbkdf2":{"path":"crypto/pbkdf2","name":"pbkdf2","symbols":{"Key":"f"}},"crypto/rand":{"path":"crypto/rand","name":"rand","symbols":{"Int":"f","Prime":"f","Read":"f","Reader":"v","Text":"f"}},"crypto/rc4":{"path":"crypto/rc4","name":"rc4","symbols":{"Cipher":"t","Cipher.Reset":"m","Cipher.XORKeyStream":"m","KeySizeError":"t","KeySizeError.Error":"m","NewCipher":"f"}},"crypto/rsa":{"path":"crypto/rsa","name":"rsa","symbols":{"CRTValue":"t","DecryptOAEP":"f","DecryptPKCS1v15":"f","DecryptPKCS1v15SessionKey":"f","EncryptOAEP":"f","EncryptOAEPWithOptions":"f","EncryptPKCS1v15":"f","ErrDecryption":"v","ErrMessageTooLong":"v","ErrVerification":"v","GenerateKey":"f","GenerateMultiPrimeKey":"f","OAEPOptions":"t","PKCS1v15DecryptOptions":"t","PSSOptions":"t","PSSOptions.HashFunc":"m","PSSSaltLengthAuto":"c","PSSSaltLengthEqualsHash":"c","PrecomputedValues":"t","PrivateKey":"t","PrivateKey.Decrypt":"m","PrivateKey.Equal":"m","PrivateKey.Precompute":"m","PrivateKey.Public":"m","PrivateKey.Sign":"m","PrivateKey.Validate":"m","PublicKey":"t","PublicKey.Equal":"m","PublicKey.Size":"m","SignPKCS1v15":"f","SignPSS":"f","VerifyPKCS1v15":"f","VerifyPSS":"f"}},"crypto/sha1":{"path":"crypto/sha1","name":"sha1","symbols":{"BlockSize":"c","New":"f","Size":"c","Sum":"f"}},"crypto/sha256":{"path":"crypto/sha256","name":"sha256","symbols":{"BlockSize":"c","New":"f","New224":"f","Size":"c","Size224":"c","Sum224":"f","Sum256":"f"}},"crypto/sha3":{"path":"crypto/sha3","name":"sha3","symbols":{"New224":"f","New256":"f","New384":"f","New512":"f","NewCSHAKE128":"f","NewCSHAKE256":"f","NewSHAKE128":"f","NewSHAKE256":"f","SHA3":"t","SHA3.AppendBinary":"m","SHA3.BlockSize":"m","SHA3.Clone":"m","SHA3.MarshalBinary":"m","SHA3.Reset":"m","SHA3.Size":"m","SHA3.Sum":"m","SHA3.UnmarshalBinary":"m","SHA3.Write":"m","SHAKE":"t","SHAKE.AppendBinary":"m","SHAKE.BlockSize":"m","SHAKE.MarshalBinary":"m","SHAKE.Read":"m","SHAKE.Reset":"m","SHAKE.UnmarshalBinary":"m","SHAKE.Write":"m","Sum224":"f","Sum256":"f","Sum384":"f","Sum512":"f","SumSHAKE128":"f","SumSHAKE256":"f"}},"crypto/sha512":{"path":"crypto/sha512","name":"sha512","symbols":{"BlockSize":"c","New":"f","New384":"f","New512_224":"f","New512_256":"f","Size":"c","Size224":"c","Size256":"c","Size384":"c","Sum384":"f","Sum512":"f","Sum512_224":"f","Sum512_256":"f"}},"crypto/subtle":{"path":"crypto/subtle","name":"subtle","symbols":{"ConstantTimeByteEq":"f","ConstantTimeCompare":"f","ConstantTimeCopy":"f","ConstantTimeEq":"f","ConstantTimeLessOrEq":"f","ConstantTimeSelect":"f","WithDataIndependentTiming":"f","XORBytes":"f"}},"crypto/tls":{"path":"crypto/tls","name":"tls","symbols":{"AlertError":"t","AlertError.Error":"m","Certificate":"t","CertificateRequestInfo":"t","CertificateRequestInfo.Context":"m","CertificateRequestInfo.SupportsCertificate":"m","CertificateVerificationError":"t","CertificateVerificationError.Error":"m","CertificateVerificationError.Unwrap":"m","CipherSuite":"t","CipherSuiteName":"f","CipherSuites":"f","Client":"f","ClientAuthType":"t","ClientAuthType.String":"m","ClientHelloInfo":"t","ClientHelloInfo.Context":"m","ClientHelloInfo.SupportsCertificate":"m","ClientSessionCache":"t","ClientSessionState":"t","ClientSessionState.ResumptionState":"m","Config":"t","Config.BuildNameToCertificate":"m","Config.Clone":"m","Config.DecryptTicket":"m","Config.EncryptTicket":"m","Config.SetSessionTicketKeys":"m","Conn":"t","Conn.Close":"m","Conn.CloseWrite":"m","Conn.ConnectionState":"m","Conn.Handshake":"m","Conn.HandshakeContext":"m","Conn.LocalAddr":"m","Conn.NetConn":"m","Conn.OCSPResponse":"m","Conn.Read":"m","Conn.RemoteAddr":"m","Conn.SetDeadline":"m","Conn.SetReadDeadline":"m","Conn.SetWriteDeadline":"m","Conn.VerifyHostname":"m","Conn.Write":"m","ConnectionState":"t","ConnectionState.ExportKeyingMaterial":"m","CurveID":"t","CurveID.String":"m","CurveP256":"c","CurveP384":"c","CurveP521":"c","Dial":"f","DialWithDialer":"f","Dialer":"t","Dialer.Dial":"m","Dialer.DialContext":"m","ECDSAWithP256AndSHA256":"c","ECDSAWithP384AndSHA384":"c","ECDSAWithP521AndSHA512":"c","ECDSAWithSHA1":"c","ECHRejectionError":"t","ECHRejectionError.Error":"m","Ed25519":"c","EncryptedClientHelloKey":"t","InsecureCipherSuites":"f","Listen":"f","LoadX509KeyPair":"f","MLDSA44":"c","MLDSA65":"c","MLDSA87":"c","MLKEM1024":"c","NewLRUClientSessionCache":"f","NewListener":"f","NewResumptionState":"f","NoClientCert":"c","PKCS1WithSHA1":"c","PKCS1WithSHA256":"c","PKCS1WithSHA384":"c","PKCS1WithSHA512":"c","PSSWithSHA256":"c","PSSWithSHA384":"c","PSSWithSHA512":"c","ParseSessionState":"f","QUICClient":"f","QUICConfig":"t","QUICConn":"t","QUICConn.Close":"m","QUICConn.ConnectionState":"m","QUICConn.HandleData":"m","QUICConn.NextEvent":"m","QUICConn.SendSessionTicket":"m","QUICConn.SetTransportParameters":"m","QUICConn.Start":"m","QUICConn.StoreSession":"m","QUICEncryptionLevel":"t","QUICEncryptionLevel.String":"m","QUICEncryptionLevelApplication":"c","QUICEncryptionLevelEarly":"c","QUICEncryptionLevelHandshake":"c","QUICEncryptionLevelInitial":"c","QUICErrorEvent":"c","QUICEvent":"t","QUICEventKind":"t","QUICHandshakeDone":"c","QUICNoEvent":"c","QUICRejectedEarlyData":"c","QUICResumeSession":"c","QUICServer":"f","QUICSessionTicketOptions":"t","QUICSetReadSecret":"c","QUICSetWriteSecret":"c","QUICStoreSession":"c","QUICTransportParameters":"c","QUICTransportParametersRequired":"c","QUICWriteData":"c","RecordHeaderError":"t","RecordHeaderError.Error":"m","RenegotiateFreelyAsClient":"c","RenegotiateNever":"c","RenegotiateOnceAsClient":"c","RenegotiationSupport":"t","RequestClientCert":"c","RequireAndVerifyClientCert":"c","RequireAnyClientCert":"c","SecP256r1MLKEM768":"c","SecP384r1MLKEM1024":"c","Server":"f","SessionState":"t","SessionState.Bytes":"m","SignatureScheme":"t","SignatureScheme.String":"m","TLS_AES_128_GCM_SHA256":"c","TLS_AES_256_GCM_SHA384":"c","TLS_CHACHA20_POLY1305_SHA256":"c","TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA":"c","TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256":"c","TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256":"c","TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA":"c","TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384":"c","TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305":"c","TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256":"c","TLS_ECDHE_ECDSA_WITH_RC4_128_SHA":"c","TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA":"c","TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA":"c","TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256":"c","TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256":"c","TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA":"c","TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384":"c","TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305":"c","TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256":"c","TLS_ECDHE_RSA_WITH_RC4_128_SHA":"c","TLS_FALLBACK_SCSV":"c","TLS_RSA_WITH_3DES_EDE_CBC_SHA":"c","TLS_RSA_WITH_AES_128_CBC_SHA":"c","TLS_RSA_WITH_AES_128_CBC_SHA256":"c","TLS_RSA_WITH_AES_128_GCM_SHA256":"c","TLS_RSA_WITH_AES_256_CBC_SHA":"c","TLS_RSA_WITH_AES_256_GCM_SHA384":"c","TLS_RSA_WITH_RC4_128_SHA":"c","VerifyClientCertIfGiven":"c","VersionName":"f","VersionSSL30":"c","VersionTLS10":"c","VersionTLS11":"c","VersionTLS12":"c","VersionTLS13":"c","X25519":"c","X25519MLKEM768":"c","X509KeyPair":"f"}},"crypto/x509":{"path":"crypto/x509","name":"x509","symbols":{"CANotAuthorizedForExtKeyUsage":"c","CANotAuthorizedForThisName":"c","CertPool":"t","CertPool.AddCert":"m","CertPool.AddCertWithConstraint":"m","CertPool.AppendCertsFromPEM":"m","CertPool.Clone":"m","CertPool.Equal":"m","CertPool.Subjects":"m","Certificate":"t","Certificate.CheckCRLSignature":"m","Certificate.CheckSignature":"m","Certificate.CheckSignatureFrom":"m","Certificate.CreateCRL":"m","Certificate.Equal":"m","Certificate.Verify":"m","Certificate.VerifyHostname":"m","CertificateInvalidError":"t","CertificateInvalidError.Error":"m","CertificateRequest":"t","CertificateRequest.CheckSignature":"m","ConstraintViolationError":"t","ConstraintViolationError.Error":"m","CreateCertificate":"f","CreateCertificateRequest":"f","CreateRevocationList":"f","DSA":"c","DSAWithSHA1":"c","DSAWithSHA256":"c","DecryptPEMBlock":"f","ECDSA":"c","ECDSAWithSHA1":"c","ECDSAWithSHA256":"c","ECDSAWithSHA384":"c","ECDSAWithSHA512":"c","Ed25519":"c","EncryptPEMBlock":"f","ErrUnsupportedAlgorithm":"v","Expired":"c","ExtKeyUsage":"t","ExtKeyUsage.OID":"m","ExtKeyUsage.String":"m","ExtKeyUsageAny":"c","ExtKeyUsageClientAuth":"c","ExtKeyUsageCodeSigning":"c","ExtKeyUsageEmailProtection":"c","ExtKeyUsageIPSECEndSystem":"c","ExtKeyUsageIPSECTunnel":"c","ExtKeyUsageIPSECUser":"c","ExtKeyUsageMicrosoftCommercialCodeSigning":"c","ExtKeyUsageMicrosoftKernelCodeSigning":"c","ExtKeyUsageMicrosoftServerGatedCrypto":"c","ExtKeyUsageNetscapeServerGatedCrypto":"c","ExtKeyUsageOCSPSigning":"c","ExtKeyUsageServerAuth":"c","ExtKeyUsageTimeStamping":"c","HostnameError":"t","HostnameError.Error":"m","IncompatibleUsage":"c","IncorrectPasswordError":"v","InsecureAlgorithmError":"t","InsecureAlgorithmError.Error":"m","InvalidReason":"t","IsEncryptedPEMBlock":"f","KeyUsage":"t","KeyUsage.String":"m","KeyUsageCRLSign":"c","KeyUsageCertSign":"c","KeyUsageContentCommitment":"c","KeyUsageDataEncipherment":"c","KeyUsageDecipherOnly":"c","KeyUsageDigitalSignature":"c","KeyUsageEncipherOnly":"c","KeyUsageKeyAgreement":"c","KeyUsageKeyEncipherment":"c","MD2WithRSA":"c","MD5WithRSA":"c","MLDSA":"c","MLDSA44":"c","MLDSA65":"c","MLDSA87":"c","MarshalECPrivateKey":"f","MarshalPKCS1PrivateKey":"f","MarshalPKCS1PublicKey":"f","MarshalPKCS8PrivateKey":"f","MarshalPKIXPublicKey":"f","NameConstraintsWithoutSANs":"c","NameMismatch":"c","NewCertPool":"f","NoValidChains":"c","NotAuthorizedToSign":"c","OID":"t","OID.AppendBinary":"m","OID.AppendText":"m","OID.Equal":"m","OID.EqualASN1OID":"m","OID.MarshalBinary":"m","OID.MarshalText":"m","OID.String":"m","OID.UnmarshalBinary":"m","OID.UnmarshalText":"m","OIDFromASN1OID":"f","OIDFromInts":"f","PEMCipher":"t","PEMCipher3DES":"c","PEMCipherAES128":"c","PEMCipherAES192":"c","PEMCipherAES256":"c","PEMCipherDES":"c","ParseCRL":"f","ParseCertificate":"f","ParseCertificateRequest":"f","ParseCertificates":"f","ParseDERCRL":"f","ParseECPrivateKey":"f","ParseOID":"f","ParsePKCS1PrivateKey":"f","ParsePKCS1PublicKey":"f","ParsePKCS8PrivateKey":"f","ParsePKIXPublicKey":"f","ParseRevocationList":"f","PolicyMapping":"t","PublicKeyAlgorithm":"t","PublicKeyAlgorithm.String":"m","PureEd25519":"c","RSA":"c","RevocationList":"t","RevocationList.CheckSignatureFrom":"m","RevocationListEntry":"t","SHA1WithRSA":"c","SHA256WithRSA":"c","SHA256WithRSAPSS":"c","SHA384WithRSA":"c","SHA384WithRSAPSS":"c","SHA512WithRSA":"c","SHA512WithRSAPSS":"c","SetFallbackRoots":"f","SignatureAlgorithm":"t","SignatureAlgorithm.String":"m","SystemCertPool":"f","SystemRootsError":"t","SystemRootsError.Error":"m","SystemRootsError.Unwrap":"m","TooManyConstraints":"c","TooManyIntermediates":"c","UnconstrainedName":"c","UnhandledCriticalExtension":"t","UnhandledCriticalExtension.Error":"m","UnknownAuthorityError":"t","UnknownAuthorityError.Error":"m","UnknownPublicKeyAlgorithm":"c","UnknownSignatureAlgorithm":"c","VerifyOptions":"t"}},"crypto/x509/pkix":{"path":"crypto/x509/pkix","name":"pkix","symbols":{"AlgorithmIdentifier":"t","AttributeTypeAndValue":"t","AttributeTypeAndValueSET":"t","CertificateList":"t","CertificateList.HasExpired":"m","Extension":"t","Name":"t","Name.FillFromRDNSequence":"m","Name.String":"m","Name.ToRDNSequence":"m","RDNSequence":"t","RDNSequence.String":"m","RelativeDistinguishedNameSET":"t","RevokedCertificate":"t","TBSCertificateList":"t"}},"database/sql":{"path":"database/sql","name":"sql","symbols":{"ColumnType":"t","ColumnType.DatabaseTypeName":"m","ColumnType.DecimalSize":"m","ColumnType.Length":"m","ColumnType.Name":"m","ColumnType.Nullable":"m","ColumnType.ScanType":"m","Conn":"t","Conn.BeginTx":"m","Conn.Close":"m","Conn.ExecContext":"m","Conn.PingContext":"m","Conn.PrepareContext":"m","Conn.QueryContext":"m","Conn.QueryRowContext":"m","Conn.Raw":"m","ConvertAssign":"f","DB":"t","DB.Begin":"m","DB.BeginTx":"m","DB.Close":"m","DB.Conn":"m","DB.Driver":"m","DB.Exec":"m","DB.ExecContext":"m","DB.Ping":"m","DB.PingContext":"m","DB.Prepare":"m","DB.PrepareContext":"m","DB.Query":"m","DB.QueryContext":"m","DB.QueryRow":"m","DB.QueryRowContext":"m","DB.SetConnMaxIdleTime":"m","DB.SetConnMaxLifetime":"m","DB.SetMaxIdleConns":"m","DB.SetMaxOpenConns":"m","DB.Stats":"m","DBStats":"t","Drivers":"f","ErrConnDone":"v","ErrNoRows":"v","ErrTxDone":"v","IsolationLevel":"t","IsolationLevel.String":"m","LevelDefault":"c","LevelLinearizable":"c","LevelReadCommitted":"c","LevelReadUncommitted":"c","LevelRepeatableRead":"c","LevelSerializable":"c","LevelSnapshot":"c","LevelWriteCommitted":"c","Named":"f","NamedArg":"t","Null":"t","NullBool":"t","NullBool.Scan":"m","NullBool.Value":"m","NullByte":"t","NullByte.Scan":"m","NullByte.Value":"m","NullFloat64":"t","NullFloat64.Scan":"m","NullFloat64.Value":"m","NullInt16":"t","NullInt16.Scan":"m","NullInt16.Value":"m","NullInt32":"t","NullInt32.Scan":"m","NullInt32.Value":"m","NullInt64":"t","NullInt64.Scan":"m","NullInt64.Value":"m","NullString":"t","NullString.Scan":"m","NullString.Value":"m","NullTime":"t","NullTime.Scan":"m","NullTime.Value":"m","Open":"f","OpenDB":"f","Out":"t","RawBytes":"t","Register":"f","Result":"t","Row":"t","Row.Err":"m","Row.Scan":"m","Rows":"t","Rows.Close":"m","Rows.ColumnTypes":"m","Rows.Columns":"m","Rows.Err":"m","Rows.Next":"m","Rows.NextResultSet":"m","Rows.Scan":"m","Scanner":"t","Stmt":"t","Stmt.Close":"m","Stmt.Exec":"m","Stmt.ExecContext":"m","Stmt.Query":"m","Stmt.QueryContext":"m","Stmt.QueryRow":"m","Stmt.QueryRowContext":"m","Tx":"t","Tx.Commit":"m","Tx.Exec":"m","Tx.ExecContext":"m","Tx.Prepare":"m","Tx.PrepareContext":"m","Tx.Query":"m","Tx.QueryContext":"m","Tx.QueryRow":"m","Tx.QueryRowContext":"m","Tx.Rollback":"m","Tx.Stmt":"m","Tx.StmtContext":"m","TxOptions":"t"}},"database/sql/driver":{"path":"database/sql/driver","name":"driver","symbols":{"Bool":"v","ColumnConverter":"t","Conn":"t","ConnBeginTx":"t","ConnPrepareContext":"t","Connector":"t","DefaultParameterConverter":"v","Driver":"t","DriverContext":"t","ErrBadConn":"v","ErrRemoveArgument":"v","ErrSkip":"v","Execer":"t","ExecerContext":"t","Int32":"v","IsScanValue":"f","IsValue":"f","IsolationLevel":"t","NamedValue":"t","NamedValueChecker":"t","NotNull":"t","NotNull.ConvertValue":"m","Null":"t","Null.ConvertValue":"m","Pinger":"t","Queryer":"t","QueryerContext":"t","Result":"t","ResultNoRows":"v","Rows":"t","RowsAffected":"t","RowsAffected.LastInsertId":"m","RowsAffected.RowsAffected":"m","RowsColumnScanner":"t","RowsColumnTypeDatabaseTypeName":"t","RowsColumnTypeLength":"t","RowsColumnTypeNullable":"t","RowsColumnTypePrecisionScale":"t","RowsColumnTypeScanType":"t","RowsNextResultSet":"t","ScanContext":"t","SessionResetter":"t","Stmt":"t","StmtExecContext":"t","StmtQueryContext":"t","String":"v","Tx":"t","TxOptions":"t","Validator":"t","Value":"t","ValueConverter":"t","Valuer":"t"}},"debug/buildinfo":{"path":"debug/buildinfo","name":"buildinfo","symbols":{"BuildInfo":"t","Read":"f","ReadFile":"f"}},"debug/dwarf":{"path":"debug/dwarf","name":"dwarf","symbols":{"AddrType":"t","ArrayType":"t","ArrayType.Size":"m","ArrayType.String":"m","Attr":"t","Attr.GoString":"m","Attr.String":"m","AttrAbstractOrigin":"c","AttrAccessibility":"c","AttrAddrBase":"c","AttrAddrClass":"c","AttrAlignment":"c","AttrAllocated":"c","AttrArtificial":"c","AttrAssociated":"c","AttrBaseTypes":"c","AttrBinaryScale":"c","AttrBitOffset":"c","AttrBitSize":"c","AttrByteSize":"c","AttrCallAllCalls":"c","AttrCallAllSourceCalls":"c","AttrCallAllTailCalls":"c","AttrCallColumn":"c","AttrCallDataLocation":"c","AttrCallDataValue":"c","AttrCallFile":"c","AttrCallLine":"c","AttrCallOrigin":"c","AttrCallPC":"c","AttrCallParameter":"c","AttrCallReturnPC":"c","AttrCallTailCall":"c","AttrCallTarget":"c","AttrCallTargetClobbered":"c","AttrCallValue":"c","AttrCalling":"c","AttrCommonRef":"c","AttrCompDir":"c","AttrConstExpr":"c","AttrConstValue":"c","AttrContainingType":"c","AttrCount":"c","AttrDataBitOffset":"c","AttrDataLocation":"c","AttrDataMemberLoc":"c","AttrDecimalScale":"c","AttrDecimalSign":"c","AttrDeclColumn":"c","AttrDeclFile":"c","AttrDeclLine":"c","AttrDeclaration":"c","AttrDefaultValue":"c","AttrDefaulted":"c","AttrDeleted":"c","AttrDescription":"c","AttrDigitCount":"c","AttrDiscr":"c","AttrDiscrList":"c","AttrDiscrValue":"c","AttrDwoName":"c","AttrElemental":"c","AttrEncoding":"c","AttrEndianity":"c","AttrEntrypc":"c","AttrEnumClass":"c","AttrExplicit":"c","AttrExportSymbols":"c","AttrExtension":"c","AttrExternal":"c","AttrFrameBase":"c","AttrFriend":"c","AttrHighpc":"c","AttrIdentifierCase":"c","AttrImport":"c","AttrInline":"c","AttrIsOptional":"c","AttrLanguage":"c","AttrLinkageName":"c","AttrLocation":"c","AttrLoclistsBase":"c","AttrLowerBound":"c","AttrLowpc":"c","AttrMacroInfo":"c","AttrMacros":"c","AttrMainSubprogram":"c","AttrMutable":"c","AttrName":"c","AttrNamelistItem":"c","AttrNoreturn":"c","AttrObjectPointer":"c","AttrOrdering":"c","AttrPictureString":"c","AttrPriority":"c","AttrProducer":"c","AttrPrototyped":"c","AttrPure":"c","AttrRanges":"c","AttrRank":"c","AttrRecursive":"c","AttrReference":"c","AttrReturnAddr":"c","AttrRnglistsBase":"c","AttrRvalueReference":"c","AttrSegment":"c","AttrSibling":"c","AttrSignature":"c","AttrSmall":"c","AttrSpecification":"c","AttrStartScope":"c","AttrStaticLink":"c","AttrStmtList":"c","AttrStrOffsetsBase":"c","AttrStride":"c","AttrStrideSize":"c","AttrStringLength":"c","AttrStringLengthBitSize":"c","AttrStringLengthByteSize":"c","AttrThreadsScaled":"c","AttrTrampoline":"c","AttrType":"c","AttrUpperBound":"c","AttrUseLocation":"c","AttrUseUTF8":"c","AttrVarParam":"c","AttrVirtuality":"c","AttrVisibility":"c","AttrVtableElemLoc":"c","BasicType":"t","BasicType.Basic":"m","BasicType.String":"m","BoolType":"t","CharType":"t","Class":"t","Class.GoString":"m","Class.String":"m","ClassAddrPtr":"c","ClassAddress":"c","ClassBlock":"c","ClassConstant":"c","ClassExprLoc":"c","ClassFlag":"c","ClassLinePtr":"c","ClassLocList":"c","ClassLocListPtr":"c","ClassMacPtr":"c","ClassRangeListPtr":"c","ClassReference":"c","ClassReferenceAlt":"c","ClassReferenceSig":"c","ClassRngList":"c","ClassRngListsPtr":"c","ClassStrOffsetsPtr":"c","ClassString":"c","ClassStringAlt":"c","ClassUnknown":"c","CommonType":"t","CommonType.Common":"m","CommonType.Size":"m","ComplexType":"t","Data":"t","Data.AddSection":"m","Data.AddTypes":"m","Data.LineReader":"m","Data.Ranges":"m","Data.Reader":"m","Data.Type":"m","DecodeError":"t","DecodeError.Error":"m","DotDotDotType":"t","DotDotDotType.String":"m","Entry":"t","Entry.AttrField":"m","Entry.Val":"m","EnumType":"t","EnumType.String":"m","EnumValue":"t","ErrUnknownPC":"v","Field":"t","FloatType":"t","FuncType":"t","FuncType.String":"m","IntType":"t","LineEntry":"t","LineFile":"t","LineReader":"t","LineReader.Files":"m","LineReader.Next":"m","LineReader.Reset":"m","LineReader.Seek":"m","LineReader.SeekPC":"m","LineReader.Tell":"m","LineReaderPos":"t","New":"f","Offset":"t","PtrType":"t","PtrType.String":"m","QualType":"t","QualType.Size":"m","QualType.String":"m","Reader":"t","Reader.AddressSize":"m","Reader.ByteOrder":"m","Reader.Next":"m","Reader.Seek":"m","Reader.SeekPC":"m","Reader.SkipChildren":"m","StructField":"t","StructType":"t","StructType.Defn":"m","StructType.String":"m","Tag":"t","Tag.GoString":"m","Tag.String":"m","TagAccessDeclaration":"c","TagArrayType":"c","TagAtomicType":"c","TagBaseType":"c","TagCallSite":"c","TagCallSiteParameter":"c","TagCatchDwarfBlock":"c","TagClassType":"c","TagCoarrayType":"c","TagCommonDwarfBlock":"c","TagCommonInclusion":"c","TagCompileUnit":"c","TagCondition":"c","TagConstType":"c","TagConstant":"c","TagDwarfProcedure":"c","TagDynamicType":"c","TagEntryPoint":"c","TagEnumerationType":"c","TagEnumerator":"c","TagFileType":"c","TagFormalParameter":"c","TagFriend":"c","TagGenericSubrange":"c","TagImmutableType":"c","TagImportedDeclaration":"c","TagImportedModule":"c","TagImportedUnit":"c","TagInheritance":"c","TagInlinedSubroutine":"c","TagInterfaceType":"c","TagLabel":"c","TagLexDwarfBlock":"c","TagMember":"c","TagModule":"c","TagMutableType":"c","TagNamelist":"c","TagNamelistItem":"c","TagNamespace":"c","TagPackedType":"c","TagPartialUnit":"c","TagPointerType":"c","TagPtrToMemberType":"c","TagReferenceType":"c","TagRestrictType":"c","TagRvalueReferenceType":"c","TagSetType":"c","TagSharedType":"c","TagSkeletonUnit":"c","TagStringType":"c","TagStructType":"c","TagSubprogram":"c","TagSubrangeType":"c","TagSubroutineType":"c","TagTemplateAlias":"c","TagTemplateTypeParameter":"c","TagTemplateValueParameter":"c","TagThrownType":"c","TagTryDwarfBlock":"c","TagTypeUnit":"c","TagTypedef":"c","TagUnionType":"c","TagUnspecifiedParameters":"c","TagUnspecifiedType":"c","TagVariable":"c","TagVariant":"c","TagVariantPart":"c","TagVolatileType":"c","TagWithStmt":"c","Type":"t","TypedefType":"t","TypedefType.Size":"m","TypedefType.String":"m","UcharType":"t","UintType":"t","UnspecifiedType":"t","UnsupportedType":"t","UnsupportedType.String":"m","VoidType":"t","VoidType.String":"m"}},"debug/elf":{"path":"debug/elf","name":"elf","symbols":{"ARM_MAGIC_TRAMP_NUMBER":"c","COMPRESS_HIOS":"c","COMPRESS_HIPROC":"c","COMPRESS_LOOS":"c","COMPRESS_LOPROC":"c","COMPRESS_ZLIB":"c","COMPRESS_ZSTD":"c","Chdr32":"t","Chdr64":"t","Class":"t","Class.GoString":"m","Class.String":"m","CompressionType":"t","CompressionType.GoString":"m","CompressionType.String":"m","DF_1_CONFALT":"c","DF_1_DIRECT":"c","DF_1_DISPRELDNE":"c","DF_1_DISPRELPND":"c","DF_1_EDITED":"c","DF_1_ENDFILTEE":"c","DF_1_GLOBAL":"c","DF_1_GLOBAUDIT":"c","DF_1_GROUP":"c","DF_1_IGNMULDEF":"c","DF_1_INITFIRST":"c","DF_1_INTERPOSE":"c","DF_1_KMOD":"c","DF_1_LOADFLTR":"c","DF_1_NOCOMMON":"c","DF_1_NODEFLIB":"c","DF_1_NODELETE":"c","DF_1_NODIRECT":"c","DF_1_NODUMP":"c","DF_1_NOHDR":"c","DF_1_NOKSYMS":"c","DF_1_NOOPEN":"c","DF_1_NORELOC":"c","DF_1_NOW":"c","DF_1_ORIGIN":"c","DF_1_PIE":"c","DF_1_SINGLETON":"c","DF_1_STUB":"c","DF_1_SYMINTPOSE":"c","DF_1_TRANS":"c","DF_1_WEAKFILTER":"c","DF_BIND_NOW":"c","DF_ORIGIN":"c","DF_STATIC_TLS":"c","DF_SYMBOLIC":"c","DF_TEXTREL":"c","DT_ADDRRNGHI":"c","DT_ADDRRNGLO":"c","DT_AUDIT":"c","DT_AUXILIARY":"c","DT_BIND_NOW":"c","DT_CHECKSUM":"c","DT_CONFIG":"c","DT_DEBUG":"c","DT_DEPAUDIT":"c","DT_ENCODING":"c","DT_FEATURE":"c","DT_FILTER":"c","DT_FINI":"c","DT_FINI_ARRAY":"c","DT_FINI_ARRAYSZ":"c","DT_FLAGS":"c","DT_FLAGS_1":"c","DT_GNU_CONFLICT":"c","DT_GNU_CONFLICTSZ":"c","DT_GNU_HASH":"c","DT_GNU_LIBLIST":"c","DT_GNU_LIBLISTSZ":"c","DT_GNU_PRELINKED":"c","DT_HASH":"c","DT_HIOS":"c","DT_HIPROC":"c","DT_INIT":"c","DT_INIT_ARRAY":"c","DT_INIT_ARRAYSZ":"c","DT_JMPREL":"c","DT_LOOS":"c","DT_LOPROC":"c","DT_MIPS_AUX_DYNAMIC":"c","DT_MIPS_BASE_ADDRESS":"c","DT_MIPS_COMPACT_SIZE":"c","DT_MIPS_CONFLICT":"c","DT_MIPS_CONFLICTNO":"c","DT_MIPS_CXX_FLAGS":"c","DT_MIPS_DELTA_CLASS":"c","DT_MIPS_DELTA_CLASSSYM":"c","DT_MIPS_DELTA_CLASSSYM_NO":"c","DT_MIPS_DELTA_CLASS_NO":"c","DT_MIPS_DELTA_INSTANCE":"c","DT_MIPS_DELTA_INSTANCE_NO":"c","DT_MIPS_DELTA_RELOC":"c","DT_MIPS_DELTA_RELOC_NO":"c","DT_MIPS_DELTA_SYM":"c","DT_MIPS_DELTA_SYM_NO":"c","DT_MIPS_DYNSTR_ALIGN":"c","DT_MIPS_FLAGS":"c","DT_MIPS_GOTSYM":"c","DT_MIPS_GP_VALUE":"c","DT_MIPS_HIDDEN_GOTIDX":"c","DT_MIPS_HIPAGENO":"c","DT_MIPS_ICHECKSUM":"c","DT_MIPS_INTERFACE":"c","DT_MIPS_INTERFACE_SIZE":"c","DT_MIPS_IVERSION":"c","DT_MIPS_LIBLIST":"c","DT_MIPS_LIBLISTNO":"c","DT_MIPS_LOCALPAGE_GOTIDX":"c","DT_MIPS_LOCAL_GOTIDX":"c","DT_MIPS_LOCAL_GOTNO":"c","DT_MIPS_MSYM":"c","DT_MIPS_OPTIONS":"c","DT_MIPS_PERF_SUFFIX":"c","DT_MIPS_PIXIE_INIT":"c","DT_MIPS_PLTGOT":"c","DT_MIPS_PROTECTED_GOTIDX":"c","DT_MIPS_RLD_MAP":"c","DT_MIPS_RLD_MAP_REL":"c","DT_MIPS_RLD_TEXT_RESOLVE_ADDR":"c","DT_MIPS_RLD_VERSION":"c","DT_MIPS_RWPLT":"c","DT_MIPS_SYMBOL_LIB":"c","DT_MIPS_SYMTABNO":"c","DT_MIPS_TIME_STAMP":"c","DT_MIPS_UNREFEXTNO":"c","DT_MOVEENT":"c","DT_MOVESZ":"c","DT_MOVETAB":"c","DT_NEEDED":"c","DT_NULL":"c","DT_PLTGOT":"c","DT_PLTPAD":"c","DT_PLTPADSZ":"c","DT_PLTREL":"c","DT_PLTRELSZ":"c","DT_POSFLAG_1":"c","DT_PPC64_GLINK":"c","DT_PPC64_OPD":"c","DT_PPC64_OPDSZ":"c","DT_PPC64_OPT":"c","DT_PPC_GOT":"c","DT_PPC_OPT":"c","DT_PREINIT_ARRAY":"c","DT_PREINIT_ARRAYSZ":"c","DT_REL":"c","DT_RELA":"c","DT_RELACOUNT":"c","DT_RELAENT":"c","DT_RELASZ":"c","DT_RELCOUNT":"c","DT_RELENT":"c","DT_RELSZ":"c","DT_RPATH":"c","DT_RUNPATH":"c","DT_SONAME":"c","DT_SPARC_REGISTER":"c","DT_STRSZ":"c","DT_STRTAB":"c","DT_SYMBOLIC":"c","DT_SYMENT":"c","DT_SYMINENT":"c","DT_SYMINFO":"c","DT_SYMINSZ":"c","DT_SYMTAB":"c","DT_SYMTAB_SHNDX":"c","DT_TEXTREL":"c","DT_TLSDESC_GOT":"c","DT_TLSDESC_PLT":"c","DT_USED":"c","DT_VALRNGHI":"c","DT_VALRNGLO":"c","DT_VERDEF":"c","DT_VERDEFNUM":"c","DT_VERNEED":"c","DT_VERNEEDNUM":"c","DT_VERSYM":"c","Data":"t","Data.GoString":"m","Data.String":"m","Dyn32":"t","Dyn64":"t","DynFlag":"t","DynFlag.GoString":"m","DynFlag.String":"m","DynFlag1":"t","DynFlag1.GoString":"m","DynFlag1.String":"m","DynTag":"t","DynTag.GoString":"m","DynTag.String":"m","DynamicVersion":"t","DynamicVersionDep":"t","DynamicVersionFlag":"t","DynamicVersionNeed":"t","EI_ABIVERSION":"c","EI_CLASS":"c","EI_DATA":"c","EI_NIDENT":"c","EI_OSABI":"c","EI_PAD":"c","EI_VERSION":"c","ELFCLASS32":"c","ELFCLASS64":"c","ELFCLASSNONE":"c","ELFDATA2LSB":"c","ELFDATA2MSB":"c","ELFDATANONE":"c","ELFMAG":"c","ELFOSABI_86OPEN":"c","ELFOSABI_AIX":"c","ELFOSABI_ARM":"c","ELFOSABI_AROS":"c","ELFOSABI_CLOUDABI":"c","ELFOSABI_FENIXOS":"c","ELFOSABI_FREEBSD":"c","ELFOSABI_HPUX":"c","ELFOSABI_HURD":"c","ELFOSABI_IRIX":"c","ELFOSABI_LINUX":"c","ELFOSABI_MODESTO":"c","ELFOSABI_NETBSD":"c","ELFOSABI_NONE":"c","ELFOSABI_NSK":"c","ELFOSABI_OPENBSD":"c","ELFOSABI_OPENVMS":"c","ELFOSABI_SOLARIS":"c","ELFOSABI_STANDALONE":"c","ELFOSABI_TRU64":"c","EM_386":"c","EM_486":"c","EM_56800EX":"c","EM_68HC05":"c","EM_68HC08":"c","EM_68HC11":"c","EM_68HC12":"c","EM_68HC16":"c","EM_68K":"c","EM_78KOR":"c","EM_8051":"c","EM_860":"c","EM_88K":"c","EM_960":"c","EM_AARCH64":"c","EM_ALPHA":"c","EM_ALPHA_STD":"c","EM_ALTERA_NIOS2":"c","EM_AMDGPU":"c","EM_ARC":"c","EM_ARCA":"c","EM_ARC_COMPACT":"c","EM_ARC_COMPACT2":"c","EM_ARM":"c","EM_AVR":"c","EM_AVR32":"c","EM_BA1":"c","EM_BA2":"c","EM_BLACKFIN":"c","EM_BPF":"c","EM_C166":"c","EM_CDP":"c","EM_CE":"c","EM_CLOUDSHIELD":"c","EM_COGE":"c","EM_COLDFIRE":"c","EM_COOL":"c","EM_COREA_1ST":"c","EM_COREA_2ND":"c","EM_CR":"c","EM_CR16":"c","EM_CRAYNV2":"c","EM_CRIS":"c","EM_CRX":"c","EM_CSR_KALIMBA":"c","EM_CUDA":"c","EM_CYPRESS_M8C":"c","EM_D10V":"c","EM_D30V":"c","EM_DSP24":"c","EM_DSPIC30F":"c","EM_DXP":"c","EM_ECOG1":"c","EM_ECOG16":"c","EM_ECOG1X":"c","EM_ECOG2":"c","EM_ETPU":"c","EM_EXCESS":"c","EM_F2MC16":"c","EM_FIREPATH":"c","EM_FR20":"c","EM_FR30":"c","EM_FT32":"c","EM_FX66":"c","EM_H8S":"c","EM_H8_300":"c","EM_H8_300H":"c","EM_H8_500":"c","EM_HUANY":"c","EM_IA_64":"c","EM_INTEL205":"c","EM_INTEL206":"c","EM_INTEL207":"c","EM_INTEL208":"c","EM_INTEL209":"c","EM_IP2K":"c","EM_JAVELIN":"c","EM_K10M":"c","EM_KM32":"c","EM_KMX16":"c","EM_KMX32":"c","EM_KMX8":"c","EM_KVARC":"c","EM_L10M":"c","EM_LANAI":"c","EM_LATTICEMICO32":"c","EM_LOONGARCH":"c","EM_M16C":"c","EM_M32":"c","EM_M32C":"c","EM_M32R":"c","EM_MANIK":"c","EM_MAX":"c","EM_MAXQ30":"c","EM_MCHP_PIC":"c","EM_MCST_ELBRUS":"c","EM_ME16":"c","EM_METAG":"c","EM_MICROBLAZE":"c","EM_MIPS":"c","EM_MIPS_RS3_LE":"c","EM_MIPS_RS4_BE":"c","EM_MIPS_X":"c","EM_MMA":"c","EM_MMDSP_PLUS":"c","EM_MMIX":"c","EM_MN10200":"c","EM_MN10300":"c","EM_MOXIE":"c","EM_MSP430":"c","EM_NCPU":"c","EM_NDR1":"c","EM_NDS32":"c","EM_NONE":"c","EM_NORC":"c","EM_NS32K":"c","EM_OPEN8":"c","EM_OPENRISC":"c","EM_PARISC":"c","EM_PCP":"c","EM_PDP10":"c","EM_PDP11":"c","EM_PDSP":"c","EM_PJ":"c","EM_PPC":"c","EM_PPC64":"c","EM_PRISM":"c","EM_QDSP6":"c","EM_R32C":"c","EM_RCE":"c","EM_RH32":"c","EM_RISCV":"c","EM_RL78":"c","EM_RS08":"c","EM_RX":"c","EM_S370":"c","EM_S390":"c","EM_SCORE7":"c","EM_SEP":"c","EM_SE_C17":"c","EM_SE_C33":"c","EM_SH":"c","EM_SHARC":"c","EM_SLE9X":"c","EM_SNP1K":"c","EM_SPARC":"c","EM_SPARC32PLUS":"c","EM_SPARCV9":"c","EM_ST100":"c","EM_ST19":"c","EM_ST200":"c","EM_ST7":"c","EM_ST9PLUS":"c","EM_STARCORE":"c","EM_STM8":"c","EM_STXP7X":"c","EM_SVX":"c","EM_TILE64":"c","EM_TILEGX":"c","EM_TILEPRO":"c","EM_TINYJ":"c","EM_TI_ARP32":"c","EM_TI_C2000":"c","EM_TI_C5500":"c","EM_TI_C6000":"c","EM_TI_PRU":"c","EM_TMM_GPP":"c","EM_TPC":"c","EM_TRICORE":"c","EM_TRIMEDIA":"c","EM_TSK3000":"c","EM_UNICORE":"c","EM_V800":"c","EM_V850":"c","EM_VAX":"c","EM_VIDEOCORE":"c","EM_VIDEOCORE3":"c","EM_VIDEOCORE5":"c","EM_VISIUM":"c","EM_VPP500":"c","EM_X86_64":"c","EM_XCORE":"c","EM_XGATE":"c","EM_XIMO16":"c","EM_XTENSA":"c","EM_Z80":"c","EM_ZSP":"c","ET_CORE":"c","ET_DYN":"c","ET_EXEC":"c","ET_HIOS":"c","ET_HIPROC":"c","ET_LOOS":"c","ET_LOPROC":"c","ET_NONE":"c","ET_REL":"c","EV_CURRENT":"c","EV_NONE":"c","ErrNoSymbols":"v","File":"t","File.Close":"m","File.DWARF":"m","File.DynString":"m","File.DynValue":"m","File.DynamicSymbols":"m","File.DynamicVersionNeeds":"m","File.DynamicVersions":"m","File.ImportedLibraries":"m","File.ImportedSymbols":"m","File.Section":"m","File.SectionByType":"m","File.Symbols":"m","FileHeader":"t","FormatError":"t","FormatError.Error":"m","Header32":"t","Header64":"t","ImportedSymbol":"t","Machine":"t","Machine.GoString":"m","Machine.String":"m","NT_FPREGSET":"c","NT_PRPSINFO":"c","NT_PRSTATUS":"c","NType":"t","NType.GoString":"m","NType.String":"m","NewFile":"f","OSABI":"t","OSABI.GoString":"m","OSABI.String":"m","Open":"f","PF_MASKOS":"c","PF_MASKPROC":"c","PF_R":"c","PF_W":"c","PF_X":"c","PT_AARCH64_ARCHEXT":"c","PT_AARCH64_UNWIND":"c","PT_ARM_ARCHEXT":"c","PT_ARM_EXIDX":"c","PT_DYNAMIC":"c","PT_GNU_EH_FRAME":"c","PT_GNU_MBIND_HI":"c","PT_GNU_MBIND_LO":"c","PT_GNU_PROPERTY":"c","PT_GNU_RELRO":"c","PT_GNU_STACK":"c","PT_HIOS":"c","PT_HIPROC":"c","PT_INTERP":"c","PT_LOAD":"c","PT_LOOS":"c","PT_LOPROC":"c","PT_MIPS_ABIFLAGS":"c","PT_MIPS_OPTIONS":"c","PT_MIPS_REGINFO":"c","PT_MIPS_RTPROC":"c","PT_NOTE":"c","PT_NULL":"c","PT_OPENBSD_BOOTDATA":"c","PT_OPENBSD_NOBTCFI":"c","PT_OPENBSD_RANDOMIZE":"c","PT_OPENBSD_WXNEEDED":"c","PT_PAX_FLAGS":"c","PT_PHDR":"c","PT_RISCV_ATTRIBUTES":"c","PT_S390_PGSTE":"c","PT_SHLIB":"c","PT_SUNWSTACK":"c","PT_SUNW_EH_FRAME":"c","PT_TLS":"c","Prog":"t","Prog.Open":"m","Prog32":"t","Prog64":"t","ProgFlag":"t","ProgFlag.GoString":"m","ProgFlag.String":"m","ProgHeader":"t","ProgType":"t","ProgType.GoString":"m","ProgType.String":"m","R_386":"t","R_386.GoString":"m","R_386.String":"m","R_386_16":"c","R_386_32":"c","R_386_32PLT":"c","R_386_8":"c","R_386_COPY":"c","R_386_GLOB_DAT":"c","R_386_GOT32":"c","R_386_GOT32X":"c","R_386_GOTOFF":"c","R_386_GOTPC":"c","R_386_IRELATIVE":"c","R_386_JMP_SLOT":"c","R_386_NONE":"c","R_386_PC16":"c","R_386_PC32":"c","R_386_PC8":"c","R_386_PLT32":"c","R_386_RELATIVE":"c","R_386_SIZE32":"c","R_386_TLS_DESC":"c","R_386_TLS_DESC_CALL":"c","R_386_TLS_DTPMOD32":"c","R_386_TLS_DTPOFF32":"c","R_386_TLS_GD":"c","R_386_TLS_GD_32":"c","R_386_TLS_GD_CALL":"c","R_386_TLS_GD_POP":"c","R_386_TLS_GD_PUSH":"c","R_386_TLS_GOTDESC":"c","R_386_TLS_GOTIE":"c","R_386_TLS_IE":"c","R_386_TLS_IE_32":"c","R_386_TLS_LDM":"c","R_386_TLS_LDM_32":"c","R_386_TLS_LDM_CALL":"c","R_386_TLS_LDM_POP":"c","R_386_TLS_LDM_PUSH":"c","R_386_TLS_LDO_32":"c","R_386_TLS_LE":"c","R_386_TLS_LE_32":"c","R_386_TLS_TPOFF":"c","R_386_TLS_TPOFF32":"c","R_390":"t","R_390.GoString":"m","R_390.String":"m","R_390_12":"c","R_390_16":"c","R_390_20":"c","R_390_32":"c","R_390_64":"c","R_390_8":"c","R_390_COPY":"c","R_390_GLOB_DAT":"c","R_390_GOT12":"c","R_390_GOT16":"c","R_390_GOT20":"c","R_390_GOT32":"c","R_390_GOT64":"c","R_390_GOTENT":"c","R_390_GOTOFF":"c","R_390_GOTOFF16":"c","R_390_GOTOFF64":"c","R_390_GOTPC":"c","R_390_GOTPCDBL":"c","R_390_GOTPLT12":"c","R_390_GOTPLT16":"c","R_390_GOTPLT20":"c","R_390_GOTPLT32":"c","R_390_GOTPLT64":"c","R_390_GOTPLTENT":"c","R_390_GOTPLTOFF16":"c","R_390_GOTPLTOFF32":"c","R_390_GOTPLTOFF64":"c","R_390_JMP_SLOT":"c","R_390_NONE":"c","R_390_PC16":"c","R_390_PC16DBL":"c","R_390_PC32":"c","R_390_PC32DBL":"c","R_390_PC64":"c","R_390_PLT16DBL":"c","R_390_PLT32":"c","R_390_PLT32DBL":"c","R_390_PLT64":"c","R_390_RELATIVE":"c","R_390_TLS_DTPMOD":"c","R_390_TLS_DTPOFF":"c","R_390_TLS_GD32":"c","R_390_TLS_GD64":"c","R_390_TLS_GDCALL":"c","R_390_TLS_GOTIE12":"c","R_390_TLS_GOTIE20":"c","R_390_TLS_GOTIE32":"c","R_390_TLS_GOTIE64":"c","R_390_TLS_IE32":"c","R_390_TLS_IE64":"c","R_390_TLS_IEENT":"c","R_390_TLS_LDCALL":"c","R_390_TLS_LDM32":"c","R_390_TLS_LDM64":"c","R_390_TLS_LDO32":"c","R_390_TLS_LDO64":"c","R_390_TLS_LE32":"c","R_390_TLS_LE64":"c","R_390_TLS_LOAD":"c","R_390_TLS_TPOFF":"c","R_AARCH64":"t","R_AARCH64.GoString":"m","R_AARCH64.String":"m","R_AARCH64_ABS16":"c","R_AARCH64_ABS32":"c","R_AARCH64_ABS64":"c","R_AARCH64_ADD_ABS_LO12_NC":"c","R_AARCH64_ADR_GOT_PAGE":"c","R_AARCH64_ADR_PREL_LO21":"c","R_AARCH64_ADR_PREL_PG_HI21":"c","R_AARCH64_ADR_PREL_PG_HI21_NC":"c","R_AARCH64_CALL26":"c","R_AARCH64_CONDBR19":"c","R_AARCH64_COPY":"c","R_AARCH64_GLOB_DAT":"c","R_AARCH64_GOT_LD_PREL19":"c","R_AARCH64_IRELATIVE":"c","R_AARCH64_JUMP26":"c","R_AARCH64_JUMP_SLOT":"c","R_AARCH64_LD64_GOTOFF_LO15":"c","R_AARCH64_LD64_GOTPAGE_LO15":"c","R_AARCH64_LD64_GOT_LO12_NC":"c","R_AARCH64_LDST128_ABS_LO12_NC":"c","R_AARCH64_LDST16_ABS_LO12_NC":"c","R_AARCH64_LDST32_ABS_LO12_NC":"c","R_AARCH64_LDST64_ABS_LO12_NC":"c","R_AARCH64_LDST8_ABS_LO12_NC":"c","R_AARCH64_LD_PREL_LO19":"c","R_AARCH64_MOVW_SABS_G0":"c","R_AARCH64_MOVW_SABS_G1":"c","R_AARCH64_MOVW_SABS_G2":"c","R_AARCH64_MOVW_UABS_G0":"c","R_AARCH64_MOVW_UABS_G0_NC":"c","R_AARCH64_MOVW_UABS_G1":"c","R_AARCH64_MOVW_UABS_G1_NC":"c","R_AARCH64_MOVW_UABS_G2":"c","R_AARCH64_MOVW_UABS_G2_NC":"c","R_AARCH64_MOVW_UABS_G3":"c","R_AARCH64_NONE":"c","R_AARCH64_NULL":"c","R_AARCH64_P32_ABS16":"c","R_AARCH64_P32_ABS32":"c","R_AARCH64_P32_ADD_ABS_LO12_NC":"c","R_AARCH64_P32_ADR_GOT_PAGE":"c","R_AARCH64_P32_ADR_PREL_LO21":"c","R_AARCH64_P32_ADR_PREL_PG_HI21":"c","R_AARCH64_P32_CALL26":"c","R_AARCH64_P32_CONDBR19":"c","R_AARCH64_P32_COPY":"c","R_AARCH64_P32_GLOB_DAT":"c","R_AARCH64_P32_GOT_LD_PREL19":"c","R_AARCH64_P32_IRELATIVE":"c","R_AARCH64_P32_JUMP26":"c","R_AARCH64_P32_JUMP_SLOT":"c","R_AARCH64_P32_LD32_GOT_LO12_NC":"c","R_AARCH64_P32_LDST128_ABS_LO12_NC":"c","R_AARCH64_P32_LDST16_ABS_LO12_NC":"c","R_AARCH64_P32_LDST32_ABS_LO12_NC":"c","R_AARCH64_P32_LDST64_ABS_LO12_NC":"c","R_AARCH64_P32_LDST8_ABS_LO12_NC":"c","R_AARCH64_P32_LD_PREL_LO19":"c","R_AARCH64_P32_MOVW_SABS_G0":"c","R_AARCH64_P32_MOVW_UABS_G0":"c","R_AARCH64_P32_MOVW_UABS_G0_NC":"c","R_AARCH64_P32_MOVW_UABS_G1":"c","R_AARCH64_P32_PREL16":"c","R_AARCH64_P32_PREL32":"c","R_AARCH64_P32_RELATIVE":"c","R_AARCH64_P32_TLSDESC":"c","R_AARCH64_P32_TLSDESC_ADD_LO12_NC":"c","R_AARCH64_P32_TLSDESC_ADR_PAGE21":"c","R_AARCH64_P32_TLSDESC_ADR_PREL21":"c","R_AARCH64_P32_TLSDESC_CALL":"c","R_AARCH64_P32_TLSDESC_LD32_LO12_NC":"c","R_AARCH64_P32_TLSDESC_LD_PREL19":"c","R_AARCH64_P32_TLSGD_ADD_LO12_NC":"c","R_AARCH64_P32_TLSGD_ADR_PAGE21":"c","R_AARCH64_P32_TLSIE_ADR_GOTTPREL_PAGE21":"c","R_AARCH64_P32_TLSIE_LD32_GOTTPREL_LO12_NC":"c","R_AARCH64_P32_TLSIE_LD_GOTTPREL_PREL19":"c","R_AARCH64_P32_TLSLE_ADD_TPREL_HI12":"c","R_AARCH64_P32_TLSLE_ADD_TPREL_LO12":"c","R_AARCH64_P32_TLSLE_ADD_TPREL_LO12_NC":"c","R_AARCH64_P32_TLSLE_MOVW_TPREL_G0":"c","R_AARCH64_P32_TLSLE_MOVW_TPREL_G0_NC":"c","R_AARCH64_P32_TLSLE_MOVW_TPREL_G1":"c","R_AARCH64_P32_TLS_DTPMOD":"c","R_AARCH64_P32_TLS_DTPREL":"c","R_AARCH64_P32_TLS_TPREL":"c","R_AARCH64_P32_TSTBR14":"c","R_AARCH64_PREL16":"c","R_AARCH64_PREL32":"c","R_AARCH64_PREL64":"c","R_AARCH64_RELATIVE":"c","R_AARCH64_TLSDESC":"c","R_AARCH64_TLSDESC_ADD":"c","R_AARCH64_TLSDESC_ADD_LO12_NC":"c","R_AARCH64_TLSDESC_ADR_PAGE21":"c","R_AARCH64_TLSDESC_ADR_PREL21":"c","R_AARCH64_TLSDESC_CALL":"c","R_AARCH64_TLSDESC_LD64_LO12_NC":"c","R_AARCH64_TLSDESC_LDR":"c","R_AARCH64_TLSDESC_LD_PREL19":"c","R_AARCH64_TLSDESC_OFF_G0_NC":"c","R_AARCH64_TLSDESC_OFF_G1":"c","R_AARCH64_TLSGD_ADD_LO12_NC":"c","R_AARCH64_TLSGD_ADR_PAGE21":"c","R_AARCH64_TLSGD_ADR_PREL21":"c","R_AARCH64_TLSGD_MOVW_G0_NC":"c","R_AARCH64_TLSGD_MOVW_G1":"c","R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21":"c","R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC":"c","R_AARCH64_TLSIE_LD_GOTTPREL_PREL19":"c","R_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC":"c","R_AARCH64_TLSIE_MOVW_GOTTPREL_G1":"c","R_AARCH64_TLSLD_ADR_PAGE21":"c","R_AARCH64_TLSLD_ADR_PREL21":"c","R_AARCH64_TLSLD_LDST128_DTPREL_LO12":"c","R_AARCH64_TLSLD_LDST128_DTPREL_LO12_NC":"c","R_AARCH64_TLSLE_ADD_TPREL_HI12":"c","R_AARCH64_TLSLE_ADD_TPREL_LO12":"c","R_AARCH64_TLSLE_ADD_TPREL_LO12_NC":"c","R_AARCH64_TLSLE_LDST128_TPREL_LO12":"c","R_AARCH64_TLSLE_LDST128_TPREL_LO12_NC":"c","R_AARCH64_TLSLE_MOVW_TPREL_G0":"c","R_AARCH64_TLSLE_MOVW_TPREL_G0_NC":"c","R_AARCH64_TLSLE_MOVW_TPREL_G1":"c","R_AARCH64_TLSLE_MOVW_TPREL_G1_NC":"c","R_AARCH64_TLSLE_MOVW_TPREL_G2":"c","R_AARCH64_TLS_DTPMOD64":"c","R_AARCH64_TLS_DTPREL64":"c","R_AARCH64_TLS_TPREL64":"c","R_AARCH64_TSTBR14":"c","R_ALPHA":"t","R_ALPHA.GoString":"m","R_ALPHA.String":"m","R_ALPHA_BRADDR":"c","R_ALPHA_COPY":"c","R_ALPHA_GLOB_DAT":"c","R_ALPHA_GPDISP":"c","R_ALPHA_GPREL32":"c","R_ALPHA_GPRELHIGH":"c","R_ALPHA_GPRELLOW":"c","R_ALPHA_GPVALUE":"c","R_ALPHA_HINT":"c","R_ALPHA_IMMED_BR_HI32":"c","R_ALPHA_IMMED_GP_16":"c","R_ALPHA_IMMED_GP_HI32":"c","R_ALPHA_IMMED_LO32":"c","R_ALPHA_IMMED_SCN_HI32":"c","R_ALPHA_JMP_SLOT":"c","R_ALPHA_LITERAL":"c","R_ALPHA_LITUSE":"c","R_ALPHA_NONE":"c","R_ALPHA_OP_PRSHIFT":"c","R_ALPHA_OP_PSUB":"c","R_ALPHA_OP_PUSH":"c","R_ALPHA_OP_STORE":"c","R_ALPHA_REFLONG":"c","R_ALPHA_REFQUAD":"c","R_ALPHA_RELATIVE":"c","R_ALPHA_SREL16":"c","R_ALPHA_SREL32":"c","R_ALPHA_SREL64":"c","R_ARM":"t","R_ARM.GoString":"m","R_ARM.String":"m","R_ARM_ABS12":"c","R_ARM_ABS16":"c","R_ARM_ABS32":"c","R_ARM_ABS32_NOI":"c","R_ARM_ABS8":"c","R_ARM_ALU_PCREL_15_8":"c","R_ARM_ALU_PCREL_23_15":"c","R_ARM_ALU_PCREL_7_0":"c","R_ARM_ALU_PC_G0":"c","R_ARM_ALU_PC_G0_NC":"c","R_ARM_ALU_PC_G1":"c","R_ARM_ALU_PC_G1_NC":"c","R_ARM_ALU_PC_G2":"c","R_ARM_ALU_SBREL_19_12_NC":"c","R_ARM_ALU_SBREL_27_20_CK":"c","R_ARM_ALU_SB_G0":"c","R_ARM_ALU_SB_G0_NC":"c","R_ARM_ALU_SB_G1":"c","R_ARM_ALU_SB_G1_NC":"c","R_ARM_ALU_SB_G2":"c","R_ARM_AMP_VCALL9":"c","R_ARM_BASE_ABS":"c","R_ARM_CALL":"c","R_ARM_COPY":"c","R_ARM_GLOB_DAT":"c","R_ARM_GNU_VTENTRY":"c","R_ARM_GNU_VTINHERIT":"c","R_ARM_GOT32":"c","R_ARM_GOTOFF":"c","R_ARM_GOTOFF12":"c","R_ARM_GOTPC":"c","R_ARM_GOTRELAX":"c","R_ARM_GOT_ABS":"c","R_ARM_GOT_BREL12":"c","R_ARM_GOT_PREL":"c","R_ARM_IRELATIVE":"c","R_ARM_JUMP24":"c","R_ARM_JUMP_SLOT":"c","R_ARM_LDC_PC_G0":"c","R_ARM_LDC_PC_G1":"c","R_ARM_LDC_PC_G2":"c","R_ARM_LDC_SB_G0":"c","R_ARM_LDC_SB_G1":"c","R_ARM_LDC_SB_G2":"c","R_ARM_LDRS_PC_G0":"c","R_ARM_LDRS_PC_G1":"c","R_ARM_LDRS_PC_G2":"c","R_ARM_LDRS_SB_G0":"c","R_ARM_LDRS_SB_G1":"c","R_ARM_LDRS_SB_G2":"c","R_ARM_LDR_PC_G1":"c","R_ARM_LDR_PC_G2":"c","R_ARM_LDR_SBREL_11_10_NC":"c","R_ARM_LDR_SB_G0":"c","R_ARM_LDR_SB_G1":"c","R_ARM_LDR_SB_G2":"c","R_ARM_ME_TOO":"c","R_ARM_MOVT_ABS":"c","R_ARM_MOVT_BREL":"c","R_ARM_MOVT_PREL":"c","R_ARM_MOVW_ABS_NC":"c","R_ARM_MOVW_BREL":"c","R_ARM_MOVW_BREL_NC":"c","R_ARM_MOVW_PREL_NC":"c","R_ARM_NONE":"c","R_ARM_PC13":"c","R_ARM_PC24":"c","R_ARM_PLT32":"c","R_ARM_PLT32_ABS":"c","R_ARM_PREL31":"c","R_ARM_PRIVATE_0":"c","R_ARM_PRIVATE_1":"c","R_ARM_PRIVATE_10":"c","R_ARM_PRIVATE_11":"c","R_ARM_PRIVATE_12":"c","R_ARM_PRIVATE_13":"c","R_ARM_PRIVATE_14":"c","R_ARM_PRIVATE_15":"c","R_ARM_PRIVATE_2":"c","R_ARM_PRIVATE_3":"c","R_ARM_PRIVATE_4":"c","R_ARM_PRIVATE_5":"c","R_ARM_PRIVATE_6":"c","R_ARM_PRIVATE_7":"c","R_ARM_PRIVATE_8":"c","R_ARM_PRIVATE_9":"c","R_ARM_RABS32":"c","R_ARM_RBASE":"c","R_ARM_REL32":"c","R_ARM_REL32_NOI":"c","R_ARM_RELATIVE":"c","R_ARM_RPC24":"c","R_ARM_RREL32":"c","R_ARM_RSBREL32":"c","R_ARM_RXPC25":"c","R_ARM_SBREL31":"c","R_ARM_SBREL32":"c","R_ARM_SWI24":"c","R_ARM_TARGET1":"c","R_ARM_TARGET2":"c","R_ARM_THM_ABS5":"c","R_ARM_THM_ALU_ABS_G0_NC":"c","R_ARM_THM_ALU_ABS_G1_NC":"c","R_ARM_THM_ALU_ABS_G2_NC":"c","R_ARM_THM_ALU_ABS_G3":"c","R_ARM_THM_ALU_PREL_11_0":"c","R_ARM_THM_GOT_BREL12":"c","R_ARM_THM_JUMP11":"c","R_ARM_THM_JUMP19":"c","R_ARM_THM_JUMP24":"c","R_ARM_THM_JUMP6":"c","R_ARM_THM_JUMP8":"c","R_ARM_THM_MOVT_ABS":"c","R_ARM_THM_MOVT_BREL":"c","R_ARM_THM_MOVT_PREL":"c","R_ARM_THM_MOVW_ABS_NC":"c","R_ARM_THM_MOVW_BREL":"c","R_ARM_THM_MOVW_BREL_NC":"c","R_ARM_THM_MOVW_PREL_NC":"c","R_ARM_THM_PC12":"c","R_ARM_THM_PC22":"c","R_ARM_THM_PC8":"c","R_ARM_THM_RPC22":"c","R_ARM_THM_SWI8":"c","R_ARM_THM_TLS_CALL":"c","R_ARM_THM_TLS_DESCSEQ16":"c","R_ARM_THM_TLS_DESCSEQ32":"c","R_ARM_THM_XPC22":"c","R_ARM_TLS_CALL":"c","R_ARM_TLS_DESCSEQ":"c","R_ARM_TLS_DTPMOD32":"c","R_ARM_TLS_DTPOFF32":"c","R_ARM_TLS_GD32":"c","R_ARM_TLS_GOTDESC":"c","R_ARM_TLS_IE12GP":"c","R_ARM_TLS_IE32":"c","R_ARM_TLS_LDM32":"c","R_ARM_TLS_LDO12":"c","R_ARM_TLS_LDO32":"c","R_ARM_TLS_LE12":"c","R_ARM_TLS_LE32":"c","R_ARM_TLS_TPOFF32":"c","R_ARM_V4BX":"c","R_ARM_XPC25":"c","R_INFO":"f","R_INFO32":"f","R_LARCH":"t","R_LARCH.GoString":"m","R_LARCH.String":"m","R_LARCH_32":"c","R_LARCH_32_PCREL":"c","R_LARCH_64":"c","R_LARCH_64_PCREL":"c","R_LARCH_ABS64_HI12":"c","R_LARCH_ABS64_LO20":"c","R_LARCH_ABS_HI20":"c","R_LARCH_ABS_LO12":"c","R_LARCH_ADD16":"c","R_LARCH_ADD24":"c","R_LARCH_ADD32":"c","R_LARCH_ADD6":"c","R_LARCH_ADD64":"c","R_LARCH_ADD8":"c","R_LARCH_ADD_ULEB128":"c","R_LARCH_ALIGN":"c","R_LARCH_B16":"c","R_LARCH_B21":"c","R_LARCH_B26":"c","R_LARCH_CALL36":"c","R_LARCH_CFA":"c","R_LARCH_COPY":"c","R_LARCH_DELETE":"c","R_LARCH_GNU_VTENTRY":"c","R_LARCH_GNU_VTINHERIT":"c","R_LARCH_GOT64_HI12":"c","R_LARCH_GOT64_LO20":"c","R_LARCH_GOT64_PC_HI12":"c","R_LARCH_GOT64_PC_LO20":"c","R_LARCH_GOT_HI20":"c","R_LARCH_GOT_LO12":"c","R_LARCH_GOT_PC_HI20":"c","R_LARCH_GOT_PC_LO12":"c","R_LARCH_IRELATIVE":"c","R_LARCH_JUMP_SLOT":"c","R_LARCH_MARK_LA":"c","R_LARCH_MARK_PCREL":"c","R_LARCH_NONE":"c","R_LARCH_PCALA64_HI12":"c","R_LARCH_PCALA64_LO20":"c","R_LARCH_PCALA_HI20":"c","R_LARCH_PCALA_LO12":"c","R_LARCH_PCREL20_S2":"c","R_LARCH_RELATIVE":"c","R_LARCH_RELAX":"c","R_LARCH_SOP_ADD":"c","R_LARCH_SOP_AND":"c","R_LARCH_SOP_ASSERT":"c","R_LARCH_SOP_IF_ELSE":"c","R_LARCH_SOP_NOT":"c","R_LARCH_SOP_POP_32_S_0_10_10_16_S2":"c","R_LARCH_SOP_POP_32_S_0_5_10_16_S2":"c","R_LARCH_SOP_POP_32_S_10_12":"c","R_LARCH_SOP_POP_32_S_10_16":"c","R_LARCH_SOP_POP_32_S_10_16_S2":"c","R_LARCH_SOP_POP_32_S_10_5":"c","R_LARCH_SOP_POP_32_S_5_20":"c","R_LARCH_SOP_POP_32_U":"c","R_LARCH_SOP_POP_32_U_10_12":"c","R_LARCH_SOP_PUSH_ABSOLUTE":"c","R_LARCH_SOP_PUSH_DUP":"c","R_LARCH_SOP_PUSH_GPREL":"c","R_LARCH_SOP_PUSH_PCREL":"c","R_LARCH_SOP_PUSH_PLT_PCREL":"c","R_LARCH_SOP_PUSH_TLS_GD":"c","R_LARCH_SOP_PUSH_TLS_GOT":"c","R_LARCH_SOP_PUSH_TLS_TPREL":"c","R_LARCH_SOP_SL":"c","R_LARCH_SOP_SR":"c","R_LARCH_SOP_SUB":"c","R_LARCH_SUB16":"c","R_LARCH_SUB24":"c","R_LARCH_SUB32":"c","R_LARCH_SUB6":"c","R_LARCH_SUB64":"c","R_LARCH_SUB8":"c","R_LARCH_SUB_ULEB128":"c","R_LARCH_TLS_DESC32":"c","R_LARCH_TLS_DESC64":"c","R_LARCH_TLS_DESC64_HI12":"c","R_LARCH_TLS_DESC64_LO20":"c","R_LARCH_TLS_DESC64_PC_HI12":"c","R_LARCH_TLS_DESC64_PC_LO20":"c","R_LARCH_TLS_DESC_CALL":"c","R_LARCH_TLS_DESC_HI20":"c","R_LARCH_TLS_DESC_LD":"c","R_LARCH_TLS_DESC_LO12":"c","R_LARCH_TLS_DESC_PCREL20_S2":"c","R_LARCH_TLS_DESC_PC_HI20":"c","R_LARCH_TLS_DESC_PC_LO12":"c","R_LARCH_TLS_DTPMOD32":"c","R_LARCH_TLS_DTPMOD64":"c","R_LARCH_TLS_DTPREL32":"c","R_LARCH_TLS_DTPREL64":"c","R_LARCH_TLS_GD_HI20":"c","R_LARCH_TLS_GD_PCREL20_S2":"c","R_LARCH_TLS_GD_PC_HI20":"c","R_LARCH_TLS_IE64_HI12":"c","R_LARCH_TLS_IE64_LO20":"c","R_LARCH_TLS_IE64_PC_HI12":"c","R_LARCH_TLS_IE64_PC_LO20":"c","R_LARCH_TLS_IE_HI20":"c","R_LARCH_TLS_IE_LO12":"c","R_LARCH_TLS_IE_PC_HI20":"c","R_LARCH_TLS_IE_PC_LO12":"c","R_LARCH_TLS_LD_HI20":"c","R_LARCH_TLS_LD_PCREL20_S2":"c","R_LARCH_TLS_LD_PC_HI20":"c","R_LARCH_TLS_LE64_HI12":"c","R_LARCH_TLS_LE64_LO20":"c","R_LARCH_TLS_LE_ADD_R":"c","R_LARCH_TLS_LE_HI20":"c","R_LARCH_TLS_LE_HI20_R":"c","R_LARCH_TLS_LE_LO12":"c","R_LARCH_TLS_LE_LO12_R":"c","R_LARCH_TLS_TPREL32":"c","R_LARCH_TLS_TPREL64":"c","R_MIPS":"t","R_MIPS.GoString":"m","R_MIPS.String":"m","R_MIPS_16":"c","R_MIPS_26":"c","R_MIPS_32":"c","R_MIPS_64":"c","R_MIPS_ADD_IMMEDIATE":"c","R_MIPS_CALL16":"c","R_MIPS_CALL_HI16":"c","R_MIPS_CALL_LO16":"c","R_MIPS_DELETE":"c","R_MIPS_GOT16":"c","R_MIPS_GOT_DISP":"c","R_MIPS_GOT_HI16":"c","R_MIPS_GOT_LO16":"c","R_MIPS_GOT_OFST":"c","R_MIPS_GOT_PAGE":"c","R_MIPS_GPREL16":"c","R_MIPS_GPREL32":"c","R_MIPS_HI16":"c","R_MIPS_HIGHER":"c","R_MIPS_HIGHEST":"c","R_MIPS_INSERT_A":"c","R_MIPS_INSERT_B":"c","R_MIPS_JALR":"c","R_MIPS_LITERAL":"c","R_MIPS_LO16":"c","R_MIPS_NONE":"c","R_MIPS_PC16":"c","R_MIPS_PC32":"c","R_MIPS_PJUMP":"c","R_MIPS_REL16":"c","R_MIPS_REL32":"c","R_MIPS_RELGOT":"c","R_MIPS_SCN_DISP":"c","R_MIPS_SHIFT5":"c","R_MIPS_SHIFT6":"c","R_MIPS_SUB":"c","R_MIPS_TLS_DTPMOD32":"c","R_MIPS_TLS_DTPMOD64":"c","R_MIPS_TLS_DTPREL32":"c","R_MIPS_TLS_DTPREL64":"c","R_MIPS_TLS_DTPREL_HI16":"c","R_MIPS_TLS_DTPREL_LO16":"c","R_MIPS_TLS_GD":"c","R_MIPS_TLS_GOTTPREL":"c","R_MIPS_TLS_LDM":"c","R_MIPS_TLS_TPREL32":"c","R_MIPS_TLS_TPREL64":"c","R_MIPS_TLS_TPREL_HI16":"c","R_MIPS_TLS_TPREL_LO16":"c","R_PPC":"t","R_PPC.GoString":"m","R_PPC.String":"m","R_PPC64":"t","R_PPC64.GoString":"m","R_PPC64.String":"m","R_PPC64_ADDR14":"c","R_PPC64_ADDR14_BRNTAKEN":"c","R_PPC64_ADDR14_BRTAKEN":"c","R_PPC64_ADDR16":"c","R_PPC64_ADDR16_DS":"c","R_PPC64_ADDR16_HA":"c","R_PPC64_ADDR16_HI":"c","R_PPC64_ADDR16_HIGH":"c","R_PPC64_ADDR16_HIGHA":"c","R_PPC64_ADDR16_HIGHER":"c","R_PPC64_ADDR16_HIGHER34":"c","R_PPC64_ADDR16_HIGHERA":"c","R_PPC64_ADDR16_HIGHERA34":"c","R_PPC64_ADDR16_HIGHEST":"c","R_PPC64_ADDR16_HIGHEST34":"c","R_PPC64_ADDR16_HIGHESTA":"c","R_PPC64_ADDR16_HIGHESTA34":"c","R_PPC64_ADDR16_LO":"c","R_PPC64_ADDR16_LO_DS":"c","R_PPC64_ADDR24":"c","R_PPC64_ADDR32":"c","R_PPC64_ADDR64":"c","R_PPC64_ADDR64_LOCAL":"c","R_PPC64_COPY":"c","R_PPC64_D28":"c","R_PPC64_D34":"c","R_PPC64_D34_HA30":"c","R_PPC64_D34_HI30":"c","R_PPC64_D34_LO":"c","R_PPC64_DTPMOD64":"c","R_PPC64_DTPREL16":"c","R_PPC64_DTPREL16_DS":"c","R_PPC64_DTPREL16_HA":"c","R_PPC64_DTPREL16_HI":"c","R_PPC64_DTPREL16_HIGH":"c","R_PPC64_DTPREL16_HIGHA":"c","R_PPC64_DTPREL16_HIGHER":"c","R_PPC64_DTPREL16_HIGHERA":"c","R_PPC64_DTPREL16_HIGHEST":"c","R_PPC64_DTPREL16_HIGHESTA":"c","R_PPC64_DTPREL16_LO":"c","R_PPC64_DTPREL16_LO_DS":"c","R_PPC64_DTPREL34":"c","R_PPC64_DTPREL64":"c","R_PPC64_ENTRY":"c","R_PPC64_GLOB_DAT":"c","R_PPC64_GNU_VTENTRY":"c","R_PPC64_GNU_VTINHERIT":"c","R_PPC64_GOT16":"c","R_PPC64_GOT16_DS":"c","R_PPC64_GOT16_HA":"c","R_PPC64_GOT16_HI":"c","R_PPC64_GOT16_LO":"c","R_PPC64_GOT16_LO_DS":"c","R_PPC64_GOT_DTPREL16_DS":"c","R_PPC64_GOT_DTPREL16_HA":"c","R_PPC64_GOT_DTPREL16_HI":"c","R_PPC64_GOT_DTPREL16_LO_DS":"c","R_PPC64_GOT_DTPREL_PCREL34":"c","R_PPC64_GOT_PCREL34":"c","R_PPC64_GOT_TLSGD16":"c","R_PPC64_GOT_TLSGD16_HA":"c","R_PPC64_GOT_TLSGD16_HI":"c","R_PPC64_GOT_TLSGD16_LO":"c","R_PPC64_GOT_TLSGD_PCREL34":"c","R_PPC64_GOT_TLSLD16":"c","R_PPC64_GOT_TLSLD16_HA":"c","R_PPC64_GOT_TLSLD16_HI":"c","R_PPC64_GOT_TLSLD16_LO":"c","R_PPC64_GOT_TLSLD_PCREL34":"c","R_PPC64_GOT_TPREL16_DS":"c","R_PPC64_GOT_TPREL16_HA":"c","R_PPC64_GOT_TPREL16_HI":"c","R_PPC64_GOT_TPREL16_LO_DS":"c","R_PPC64_GOT_TPREL_PCREL34":"c","R_PPC64_IRELATIVE":"c","R_PPC64_JMP_IREL":"c","R_PPC64_JMP_SLOT":"c","R_PPC64_NONE":"c","R_PPC64_PCREL28":"c","R_PPC64_PCREL34":"c","R_PPC64_PCREL_OPT":"c","R_PPC64_PLT16_HA":"c","R_PPC64_PLT16_HI":"c","R_PPC64_PLT16_LO":"c","R_PPC64_PLT16_LO_DS":"c","R_PPC64_PLT32":"c","R_PPC64_PLT64":"c","R_PPC64_PLTCALL":"c","R_PPC64_PLTCALL_NOTOC":"c","R_PPC64_PLTGOT16":"c","R_PPC64_PLTGOT16_DS":"c","R_PPC64_PLTGOT16_HA":"c","R_PPC64_PLTGOT16_HI":"c","R_PPC64_PLTGOT16_LO":"c","R_PPC64_PLTGOT_LO_DS":"c","R_PPC64_PLTREL32":"c","R_PPC64_PLTREL64":"c","R_PPC64_PLTSEQ":"c","R_PPC64_PLTSEQ_NOTOC":"c","R_PPC64_PLT_PCREL34":"c","R_PPC64_PLT_PCREL34_NOTOC":"c","R_PPC64_REL14":"c","R_PPC64_REL14_BRNTAKEN":"c","R_PPC64_REL14_BRTAKEN":"c","R_PPC64_REL16":"c","R_PPC64_REL16DX_HA":"c","R_PPC64_REL16_HA":"c","R_PPC64_REL16_HI":"c","R_PPC64_REL16_HIGH":"c","R_PPC64_REL16_HIGHA":"c","R_PPC64_REL16_HIGHER":"c","R_PPC64_REL16_HIGHER34":"c","R_PPC64_REL16_HIGHERA":"c","R_PPC64_REL16_HIGHERA34":"c","R_PPC64_REL16_HIGHEST":"c","R_PPC64_REL16_HIGHEST34":"c","R_PPC64_REL16_HIGHESTA":"c","R_PPC64_REL16_HIGHESTA34":"c","R_PPC64_REL16_LO":"c","R_PPC64_REL24":"c","R_PPC64_REL24_NOTOC":"c","R_PPC64_REL24_P9NOTOC":"c","R_PPC64_REL30":"c","R_PPC64_REL32":"c","R_PPC64_REL64":"c","R_PPC64_RELATIVE":"c","R_PPC64_SECTOFF":"c","R_PPC64_SECTOFF_DS":"c","R_PPC64_SECTOFF_HA":"c","R_PPC64_SECTOFF_HI":"c","R_PPC64_SECTOFF_LO":"c","R_PPC64_SECTOFF_LO_DS":"c","R_PPC64_TLS":"c","R_PPC64_TLSGD":"c","R_PPC64_TLSLD":"c","R_PPC64_TOC":"c","R_PPC64_TOC16":"c","R_PPC64_TOC16_DS":"c","R_PPC64_TOC16_HA":"c","R_PPC64_TOC16_HI":"c","R_PPC64_TOC16_LO":"c","R_PPC64_TOC16_LO_DS":"c","R_PPC64_TOCSAVE":"c","R_PPC64_TPREL16":"c","R_PPC64_TPREL16_DS":"c","R_PPC64_TPREL16_HA":"c","R_PPC64_TPREL16_HI":"c","R_PPC64_TPREL16_HIGH":"c","R_PPC64_TPREL16_HIGHA":"c","R_PPC64_TPREL16_HIGHER":"c","R_PPC64_TPREL16_HIGHERA":"c","R_PPC64_TPREL16_HIGHEST":"c","R_PPC64_TPREL16_HIGHESTA":"c","R_PPC64_TPREL16_LO":"c","R_PPC64_TPREL16_LO_DS":"c","R_PPC64_TPREL34":"c","R_PPC64_TPREL64":"c","R_PPC64_UADDR16":"c","R_PPC64_UADDR32":"c","R_PPC64_UADDR64":"c","R_PPC_ADDR14":"c","R_PPC_ADDR14_BRNTAKEN":"c","R_PPC_ADDR14_BRTAKEN":"c","R_PPC_ADDR16":"c","R_PPC_ADDR16_HA":"c","R_PPC_ADDR16_HI":"c","R_PPC_ADDR16_LO":"c","R_PPC_ADDR24":"c","R_PPC_ADDR32":"c","R_PPC_COPY":"c","R_PPC_DTPMOD32":"c","R_PPC_DTPREL16":"c","R_PPC_DTPREL16_HA":"c","R_PPC_DTPREL16_HI":"c","R_PPC_DTPREL16_LO":"c","R_PPC_DTPREL32":"c","R_PPC_EMB_BIT_FLD":"c","R_PPC_EMB_MRKREF":"c","R_PPC_EMB_NADDR16":"c","R_PPC_EMB_NADDR16_HA":"c","R_PPC_EMB_NADDR16_HI":"c","R_PPC_EMB_NADDR16_LO":"c","R_PPC_EMB_NADDR32":"c","R_PPC_EMB_RELSDA":"c","R_PPC_EMB_RELSEC16":"c","R_PPC_EMB_RELST_HA":"c","R_PPC_EMB_RELST_HI":"c","R_PPC_EMB_RELST_LO":"c","R_PPC_EMB_SDA21":"c","R_PPC_EMB_SDA2I16":"c","R_PPC_EMB_SDA2REL":"c","R_PPC_EMB_SDAI16":"c","R_PPC_GLOB_DAT":"c","R_PPC_GOT16":"c","R_PPC_GOT16_HA":"c","R_PPC_GOT16_HI":"c","R_PPC_GOT16_LO":"c","R_PPC_GOT_TLSGD16":"c","R_PPC_GOT_TLSGD16_HA":"c","R_PPC_GOT_TLSGD16_HI":"c","R_PPC_GOT_TLSGD16_LO":"c","R_PPC_GOT_TLSLD16":"c","R_PPC_GOT_TLSLD16_HA":"c","R_PPC_GOT_TLSLD16_HI":"c","R_PPC_GOT_TLSLD16_LO":"c","R_PPC_GOT_TPREL16":"c","R_PPC_GOT_TPREL16_HA":"c","R_PPC_GOT_TPREL16_HI":"c","R_PPC_GOT_TPREL16_LO":"c","R_PPC_JMP_SLOT":"c","R_PPC_LOCAL24PC":"c","R_PPC_NONE":"c","R_PPC_PLT16_HA":"c","R_PPC_PLT16_HI":"c","R_PPC_PLT16_LO":"c","R_PPC_PLT32":"c","R_PPC_PLTREL24":"c","R_PPC_PLTREL32":"c","R_PPC_REL14":"c","R_PPC_REL14_BRNTAKEN":"c","R_PPC_REL14_BRTAKEN":"c","R_PPC_REL24":"c","R_PPC_REL32":"c","R_PPC_RELATIVE":"c","R_PPC_SDAREL16":"c","R_PPC_SECTOFF":"c","R_PPC_SECTOFF_HA":"c","R_PPC_SECTOFF_HI":"c","R_PPC_SECTOFF_LO":"c","R_PPC_TLS":"c","R_PPC_TPREL16":"c","R_PPC_TPREL16_HA":"c","R_PPC_TPREL16_HI":"c","R_PPC_TPREL16_LO":"c","R_PPC_TPREL32":"c","R_PPC_UADDR16":"c","R_PPC_UADDR32":"c","R_RISCV":"t","R_RISCV.GoString":"m","R_RISCV.String":"m","R_RISCV_32":"c","R_RISCV_32_PCREL":"c","R_RISCV_64":"c","R_RISCV_ADD16":"c","R_RISCV_ADD32":"c","R_RISCV_ADD64":"c","R_RISCV_ADD8":"c","R_RISCV_ALIGN":"c","R_RISCV_BRANCH":"c","R_RISCV_CALL":"c","R_RISCV_CALL_PLT":"c","R_RISCV_COPY":"c","R_RISCV_GNU_VTENTRY":"c","R_RISCV_GNU_VTINHERIT":"c","R_RISCV_GOT_HI20":"c","R_RISCV_GPREL_I":"c","R_RISCV_GPREL_S":"c","R_RISCV_HI20":"c","R_RISCV_JAL":"c","R_RISCV_JUMP_SLOT":"c","R_RISCV_LO12_I":"c","R_RISCV_LO12_S":"c","R_RISCV_NONE":"c","R_RISCV_PCREL_HI20":"c","R_RISCV_PCREL_LO12_I":"c","R_RISCV_PCREL_LO12_S":"c","R_RISCV_RELATIVE":"c","R_RISCV_RELAX":"c","R_RISCV_RVC_BRANCH":"c","R_RISCV_RVC_JUMP":"c","R_RISCV_RVC_LUI":"c","R_RISCV_SET16":"c","R_RISCV_SET32":"c","R_RISCV_SET6":"c","R_RISCV_SET8":"c","R_RISCV_SUB16":"c","R_RISCV_SUB32":"c","R_RISCV_SUB6":"c","R_RISCV_SUB64":"c","R_RISCV_SUB8":"c","R_RISCV_TLS_DTPMOD32":"c","R_RISCV_TLS_DTPMOD64":"c","R_RISCV_TLS_DTPREL32":"c","R_RISCV_TLS_DTPREL64":"c","R_RISCV_TLS_GD_HI20":"c","R_RISCV_TLS_GOT_HI20":"c","R_RISCV_TLS_TPREL32":"c","R_RISCV_TLS_TPREL64":"c","R_RISCV_TPREL_ADD":"c","R_RISCV_TPREL_HI20":"c","R_RISCV_TPREL_I":"c","R_RISCV_TPREL_LO12_I":"c","R_RISCV_TPREL_LO12_S":"c","R_RISCV_TPREL_S":"c","R_SPARC":"t","R_SPARC.GoString":"m","R_SPARC.String":"m","R_SPARC_10":"c","R_SPARC_11":"c","R_SPARC_13":"c","R_SPARC_16":"c","R_SPARC_22":"c","R_SPARC_32":"c","R_SPARC_5":"c","R_SPARC_6":"c","R_SPARC_64":"c","R_SPARC_7":"c","R_SPARC_8":"c","R_SPARC_COPY":"c","R_SPARC_DISP16":"c","R_SPARC_DISP32":"c","R_SPARC_DISP64":"c","R_SPARC_DISP8":"c","R_SPARC_GLOB_DAT":"c","R_SPARC_GLOB_JMP":"c","R_SPARC_GOT10":"c","R_SPARC_GOT13":"c","R_SPARC_GOT22":"c","R_SPARC_H44":"c","R_SPARC_HH22":"c","R_SPARC_HI22":"c","R_SPARC_HIPLT22":"c","R_SPARC_HIX22":"c","R_SPARC_HM10":"c","R_SPARC_JMP_SLOT":"c","R_SPARC_L44":"c","R_SPARC_LM22":"c","R_SPARC_LO10":"c","R_SPARC_LOPLT10":"c","R_SPARC_LOX10":"c","R_SPARC_M44":"c","R_SPARC_NONE":"c","R_SPARC_OLO10":"c","R_SPARC_PC10":"c","R_SPARC_PC22":"c","R_SPARC_PCPLT10":"c","R_SPARC_PCPLT22":"c","R_SPARC_PCPLT32":"c","R_SPARC_PC_HH22":"c","R_SPARC_PC_HM10":"c","R_SPARC_PC_LM22":"c","R_SPARC_PLT32":"c","R_SPARC_PLT64":"c","R_SPARC_REGISTER":"c","R_SPARC_RELATIVE":"c","R_SPARC_UA16":"c","R_SPARC_UA32":"c","R_SPARC_UA64":"c","R_SPARC_WDISP16":"c","R_SPARC_WDISP19":"c","R_SPARC_WDISP22":"c","R_SPARC_WDISP30":"c","R_SPARC_WPLT30":"c","R_SYM32":"f","R_SYM64":"f","R_TYPE32":"f","R_TYPE64":"f","R_X86_64":"t","R_X86_64.GoString":"m","R_X86_64.String":"m","R_X86_64_16":"c","R_X86_64_32":"c","R_X86_64_32S":"c","R_X86_64_64":"c","R_X86_64_8":"c","R_X86_64_COPY":"c","R_X86_64_DTPMOD64":"c","R_X86_64_DTPOFF32":"c","R_X86_64_DTPOFF64":"c","R_X86_64_GLOB_DAT":"c","R_X86_64_GOT32":"c","R_X86_64_GOT64":"c","R_X86_64_GOTOFF64":"c","R_X86_64_GOTPC32":"c","R_X86_64_GOTPC32_TLSDESC":"c","R_X86_64_GOTPC64":"c","R_X86_64_GOTPCREL":"c","R_X86_64_GOTPCREL64":"c","R_X86_64_GOTPCRELX":"c","R_X86_64_GOTPLT64":"c","R_X86_64_GOTTPOFF":"c","R_X86_64_IRELATIVE":"c","R_X86_64_JMP_SLOT":"c","R_X86_64_NONE":"c","R_X86_64_PC16":"c","R_X86_64_PC32":"c","R_X86_64_PC32_BND":"c","R_X86_64_PC64":"c","R_X86_64_PC8":"c","R_X86_64_PLT32":"c","R_X86_64_PLT32_BND":"c","R_X86_64_PLTOFF64":"c","R_X86_64_RELATIVE":"c","R_X86_64_RELATIVE64":"c","R_X86_64_REX_GOTPCRELX":"c","R_X86_64_SIZE32":"c","R_X86_64_SIZE64":"c","R_X86_64_TLSDESC":"c","R_X86_64_TLSDESC_CALL":"c","R_X86_64_TLSGD":"c","R_X86_64_TLSLD":"c","R_X86_64_TPOFF32":"c","R_X86_64_TPOFF64":"c","Rel32":"t","Rel64":"t","Rela32":"t","Rela64":"t","SHF_ALLOC":"c","SHF_COMPRESSED":"c","SHF_EXECINSTR":"c","SHF_GROUP":"c","SHF_INFO_LINK":"c","SHF_LINK_ORDER":"c","SHF_MASKOS":"c","SHF_MASKPROC":"c","SHF_MERGE":"c","SHF_OS_NONCONFORMING":"c","SHF_STRINGS":"c","SHF_TLS":"c","SHF_WRITE":"c","SHN_ABS":"c","SHN_COMMON":"c","SHN_HIOS":"c","SHN_HIPROC":"c","SHN_HIRESERVE":"c","SHN_LOOS":"c","SHN_LOPROC":"c","SHN_LORESERVE":"c","SHN_UNDEF":"c","SHN_XINDEX":"c","SHT_DYNAMIC":"c","SHT_DYNSYM":"c","SHT_FINI_ARRAY":"c","SHT_GNU_ATTRIBUTES":"c","SHT_GNU_HASH":"c","SHT_GNU_LIBLIST":"c","SHT_GNU_VERDEF":"c","SHT_GNU_VERNEED":"c","SHT_GNU_VERSYM":"c","SHT_GROUP":"c","SHT_HASH":"c","SHT_HIOS":"c","SHT_HIPROC":"c","SHT_HIUSER":"c","SHT_INIT_ARRAY":"c","SHT_LOOS":"c","SHT_LOPROC":"c","SHT_LOUSER":"c","SHT_MIPS_ABIFLAGS":"c","SHT_NOBITS":"c","SHT_NOTE":"c","SHT_NULL":"c","SHT_PREINIT_ARRAY":"c","SHT_PROGBITS":"c","SHT_REL":"c","SHT_RELA":"c","SHT_RISCV_ATTRIBUTES":"c","SHT_SHLIB":"c","SHT_STRTAB":"c","SHT_SYMTAB":"c","SHT_SYMTAB_SHNDX":"c","STB_GLOBAL":"c","STB_HIOS":"c","STB_HIPROC":"c","STB_LOCAL":"c","STB_LOOS":"c","STB_LOPROC":"c","STB_WEAK":"c","STT_COMMON":"c","STT_FILE":"c","STT_FUNC":"c","STT_GNU_IFUNC":"c","STT_HIOS":"c","STT_HIPROC":"c","STT_LOOS":"c","STT_LOPROC":"c","STT_NOTYPE":"c","STT_OBJECT":"c","STT_RELC":"c","STT_SECTION":"c","STT_SRELC":"c","STT_TLS":"c","STV_DEFAULT":"c","STV_HIDDEN":"c","STV_INTERNAL":"c","STV_PROTECTED":"c","ST_BIND":"f","ST_INFO":"f","ST_TYPE":"f","ST_VISIBILITY":"f","Section":"t","Section.Data":"m","Section.Open":"m","Section32":"t","Section64":"t","SectionFlag":"t","SectionFlag.GoString":"m","SectionFlag.String":"m","SectionHeader":"t","SectionIndex":"t","SectionIndex.GoString":"m","SectionIndex.String":"m","SectionType":"t","SectionType.GoString":"m","SectionType.String":"m","Sym32":"t","Sym32Size":"c","Sym64":"t","Sym64Size":"c","SymBind":"t","SymBind.GoString":"m","SymBind.String":"m","SymType":"t","SymType.GoString":"m","SymType.String":"m","SymVis":"t","SymVis.GoString":"m","SymVis.String":"m","Symbol":"t","Type":"t","Type.GoString":"m","Type.String":"m","VER_FLG_BASE":"c","VER_FLG_INFO":"c","VER_FLG_WEAK":"c","Version":"t","Version.GoString":"m","Version.String":"m","VersionIndex":"t","VersionIndex.Index":"m","VersionIndex.IsHidden":"m"}},"debug/gosym":{"path":"debug/gosym","name":"gosym","symbols":{"DecodingError":"t","DecodingError.Error":"m","Func":"t","LineTable":"t","LineTable.LineToPC":"m","LineTable.PCToLine":"m","NewLineTable":"f","NewTable":"f","Obj":"t","Sym":"t","Sym.BaseName":"m","Sym.PackageName":"m","Sym.ReceiverName":"m","Sym.Static":"m","Table":"t","Table.LineToPC":"m","Table.LookupFunc":"m","Table.LookupSym":"m","Table.PCToFunc":"m","Table.PCToLine":"m","Table.SymByAddr":"m","UnknownFileError":"t","UnknownFileError.Error":"m","UnknownLineError":"t","UnknownLineError.Error":"m"}},"debug/macho":{"path":"debug/macho","name":"macho","symbols":{"ARM64_RELOC_ADDEND":"c","ARM64_RELOC_BRANCH26":"c","ARM64_RELOC_GOT_LOAD_PAGE21":"c","ARM64_RELOC_GOT_LOAD_PAGEOFF12":"c","ARM64_RELOC_PAGE21":"c","ARM64_RELOC_PAGEOFF12":"c","ARM64_RELOC_POINTER_TO_GOT":"c","ARM64_RELOC_SUBTRACTOR":"c","ARM64_RELOC_TLVP_LOAD_PAGE21":"c","ARM64_RELOC_TLVP_LOAD_PAGEOFF12":"c","ARM64_RELOC_UNSIGNED":"c","ARM_RELOC_BR24":"c","ARM_RELOC_HALF":"c","ARM_RELOC_HALF_SECTDIFF":"c","ARM_RELOC_LOCAL_SECTDIFF":"c","ARM_RELOC_PAIR":"c","ARM_RELOC_PB_LA_PTR":"c","ARM_RELOC_SECTDIFF":"c","ARM_RELOC_VANILLA":"c","ARM_THUMB_32BIT_BRANCH":"c","ARM_THUMB_RELOC_BR22":"c","Cpu":"t","Cpu.GoString":"m","Cpu.String":"m","Cpu386":"c","CpuAmd64":"c","CpuArm":"c","CpuArm64":"c","CpuPpc":"c","CpuPpc64":"c","Dylib":"t","DylibCmd":"t","Dysymtab":"t","DysymtabCmd":"t","ErrNotFat":"v","FatArch":"t","FatArchHeader":"t","FatFile":"t","FatFile.Close":"m","File":"t","File.Close":"m","File.DWARF":"m","File.ImportedLibraries":"m","File.ImportedSymbols":"m","File.Section":"m","File.Segment":"m","FileHeader":"t","FlagAllModsBound":"c","FlagAllowStackExecution":"c","FlagAppExtensionSafe":"c","FlagBindAtLoad":"c","FlagBindsToWeak":"c","FlagCanonical":"c","FlagDeadStrippableDylib":"c","FlagDyldLink":"c","FlagForceFlat":"c","FlagHasTLVDescriptors":"c","FlagIncrLink":"c","FlagLazyInit":"c","FlagNoFixPrebinding":"c","FlagNoHeapExecution":"c","FlagNoMultiDefs":"c","FlagNoReexportedDylibs":"c","FlagNoUndefs":"c","FlagPIE":"c","FlagPrebindable":"c","FlagPrebound":"c","FlagRootSafe":"c","FlagSetuidSafe":"c","FlagSplitSegs":"c","FlagSubsectionsViaSymbols":"c","FlagTwoLevel":"c","FlagWeakDefines":"c","FormatError":"t","FormatError.Error":"m","GENERIC_RELOC_LOCAL_SECTDIFF":"c","GENERIC_RELOC_PAIR":"c","GENERIC_RELOC_PB_LA_PTR":"c","GENERIC_RELOC_SECTDIFF":"c","GENERIC_RELOC_TLV":"c","GENERIC_RELOC_VANILLA":"c","Load":"t","LoadBytes":"t","LoadBytes.Raw":"m","LoadCmd":"t","LoadCmd.GoString":"m","LoadCmd.String":"m","LoadCmdDylib":"c","LoadCmdDylinker":"c","LoadCmdDysymtab":"c","LoadCmdRpath":"c","LoadCmdSegment":"c","LoadCmdSegment64":"c","LoadCmdSymtab":"c","LoadCmdThread":"c","LoadCmdUnixThread":"c","Magic32":"c","Magic64":"c","MagicFat":"c","NewFatFile":"f","NewFile":"f","Nlist32":"t","Nlist64":"t","Open":"f","OpenFat":"f","Regs386":"t","RegsAMD64":"t","Reloc":"t","RelocTypeARM":"t","RelocTypeARM.GoString":"m","RelocTypeARM.String":"m","RelocTypeARM64":"t","RelocTypeARM64.GoString":"m","RelocTypeARM64.String":"m","RelocTypeGeneric":"t","RelocTypeGeneric.GoString":"m","RelocTypeGeneric.String":"m","RelocTypeX86_64":"t","RelocTypeX86_64.GoString":"m","RelocTypeX86_64.String":"m","Rpath":"t","RpathCmd":"t","Section":"t","Section.Data":"m","Section.Open":"m","Section32":"t","Section64":"t","SectionHeader":"t","Segment":"t","Segment.Data":"m","Segment.Open":"m","Segment32":"t","Segment64":"t","SegmentHeader":"t","Symbol":"t","Symtab":"t","SymtabCmd":"t","Thread":"t","Type":"t","Type.GoString":"m","Type.String":"m","TypeBundle":"c","TypeDylib":"c","TypeExec":"c","TypeObj":"c","X86_64_RELOC_BRANCH":"c","X86_64_RELOC_GOT":"c","X86_64_RELOC_GOT_LOAD":"c","X86_64_RELOC_SIGNED":"c","X86_64_RELOC_SIGNED_1":"c","X86_64_RELOC_SIGNED_2":"c","X86_64_RELOC_SIGNED_4":"c","X86_64_RELOC_SUBTRACTOR":"c","X86_64_RELOC_TLV":"c","X86_64_RELOC_UNSIGNED":"c"}},"debug/pe":{"path":"debug/pe","name":"pe","symbols":{"COFFSymbol":"t","COFFSymbol.FullName":"m","COFFSymbolAuxFormat5":"t","COFFSymbolSize":"c","DataDirectory":"t","File":"t","File.COFFSymbolReadSectionDefAux":"m","File.Close":"m","File.DWARF":"m","File.ImportedLibraries":"m","File.ImportedSymbols":"m","File.Section":"m","FileHeader":"t","FormatError":"t","FormatError.Error":"m","IMAGE_COMDAT_SELECT_ANY":"c","IMAGE_COMDAT_SELECT_ASSOCIATIVE":"c","IMAGE_COMDAT_SELECT_EXACT_MATCH":"c","IMAGE_COMDAT_SELECT_LARGEST":"c","IMAGE_COMDAT_SELECT_NODUPLICATES":"c","IMAGE_COMDAT_SELECT_SAME_SIZE":"c","IMAGE_DIRECTORY_ENTRY_ARCHITECTURE":"c","IMAGE_DIRECTORY_ENTRY_BASERELOC":"c","IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT":"c","IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR":"c","IMAGE_DIRECTORY_ENTRY_DEBUG":"c","IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT":"c","IMAGE_DIRECTORY_ENTRY_EXCEPTION":"c","IMAGE_DIRECTORY_ENTRY_EXPORT":"c","IMAGE_DIRECTORY_ENTRY_GLOBALPTR":"c","IMAGE_DIRECTORY_ENTRY_IAT":"c","IMAGE_DIRECTORY_ENTRY_IMPORT":"c","IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG":"c","IMAGE_DIRECTORY_ENTRY_RESOURCE":"c","IMAGE_DIRECTORY_ENTRY_SECURITY":"c","IMAGE_DIRECTORY_ENTRY_TLS":"c","IMAGE_DLLCHARACTERISTICS_APPCONTAINER":"c","IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE":"c","IMAGE_DLLCHARACTERISTICS_FORCE_INTEGRITY":"c","IMAGE_DLLCHARACTERISTICS_GUARD_CF":"c","IMAGE_DLLCHARACTERISTICS_HIGH_ENTROPY_VA":"c","IMAGE_DLLCHARACTERISTICS_NO_BIND":"c","IMAGE_DLLCHARACTERISTICS_NO_ISOLATION":"c","IMAGE_DLLCHARACTERISTICS_NO_SEH":"c","IMAGE_DLLCHARACTERISTICS_NX_COMPAT":"c","IMAGE_DLLCHARACTERISTICS_TERMINAL_SERVER_AWARE":"c","IMAGE_DLLCHARACTERISTICS_WDM_DRIVER":"c","IMAGE_FILE_32BIT_MACHINE":"c","IMAGE_FILE_AGGRESIVE_WS_TRIM":"c","IMAGE_FILE_BYTES_REVERSED_HI":"c","IMAGE_FILE_BYTES_REVERSED_LO":"c","IMAGE_FILE_DEBUG_STRIPPED":"c","IMAGE_FILE_DLL":"c","IMAGE_FILE_EXECUTABLE_IMAGE":"c","IMAGE_FILE_LARGE_ADDRESS_AWARE":"c","IMAGE_FILE_LINE_NUMS_STRIPPED":"c","IMAGE_FILE_LOCAL_SYMS_STRIPPED":"c","IMAGE_FILE_MACHINE_AM33":"c","IMAGE_FILE_MACHINE_AMD64":"c","IMAGE_FILE_MACHINE_ARM":"c","IMAGE_FILE_MACHINE_ARM64":"c","IMAGE_FILE_MACHINE_ARMNT":"c","IMAGE_FILE_MACHINE_EBC":"c","IMAGE_FILE_MACHINE_I386":"c","IMAGE_FILE_MACHINE_IA64":"c","IMAGE_FILE_MACHINE_LOONGARCH32":"c","IMAGE_FILE_MACHINE_LOONGARCH64":"c","IMAGE_FILE_MACHINE_M32R":"c","IMAGE_FILE_MACHINE_MIPS16":"c","IMAGE_FILE_MACHINE_MIPSFPU":"c","IMAGE_FILE_MACHINE_MIPSFPU16":"c","IMAGE_FILE_MACHINE_POWERPC":"c","IMAGE_FILE_MACHINE_POWERPCFP":"c","IMAGE_FILE_MACHINE_R4000":"c","IMAGE_FILE_MACHINE_RISCV128":"c","IMAGE_FILE_MACHINE_RISCV32":"c","IMAGE_FILE_MACHINE_RISCV64":"c","IMAGE_FILE_MACHINE_SH3":"c","IMAGE_FILE_MACHINE_SH3DSP":"c","IMAGE_FILE_MACHINE_SH4":"c","IMAGE_FILE_MACHINE_SH5":"c","IMAGE_FILE_MACHINE_THUMB":"c","IMAGE_FILE_MACHINE_UNKNOWN":"c","IMAGE_FILE_MACHINE_WCEMIPSV2":"c","IMAGE_FILE_NET_RUN_FROM_SWAP":"c","IMAGE_FILE_RELOCS_STRIPPED":"c","IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP":"c","IMAGE_FILE_SYSTEM":"c","IMAGE_FILE_UP_SYSTEM_ONLY":"c","IMAGE_SCN_CNT_CODE":"c","IMAGE_SCN_CNT_INITIALIZED_DATA":"c","IMAGE_SCN_CNT_UNINITIALIZED_DATA":"c","IMAGE_SCN_LNK_COMDAT":"c","IMAGE_SCN_MEM_DISCARDABLE":"c","IMAGE_SCN_MEM_EXECUTE":"c","IMAGE_SCN_MEM_READ":"c","IMAGE_SCN_MEM_WRITE":"c","IMAGE_SUBSYSTEM_EFI_APPLICATION":"c","IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER":"c","IMAGE_SUBSYSTEM_EFI_ROM":"c","IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER":"c","IMAGE_SUBSYSTEM_NATIVE":"c","IMAGE_SUBSYSTEM_NATIVE_WINDOWS":"c","IMAGE_SUBSYSTEM_OS2_CUI":"c","IMAGE_SUBSYSTEM_POSIX_CUI":"c","IMAGE_SUBSYSTEM_UNKNOWN":"c","IMAGE_SUBSYSTEM_WINDOWS_BOOT_APPLICATION":"c","IMAGE_SUBSYSTEM_WINDOWS_CE_GUI":"c","IMAGE_SUBSYSTEM_WINDOWS_CUI":"c","IMAGE_SUBSYSTEM_WINDOWS_GUI":"c","IMAGE_SUBSYSTEM_XBOX":"c","ImportDirectory":"t","NewFile":"f","Open":"f","OptionalHeader32":"t","OptionalHeader64":"t","Reloc":"t","Section":"t","Section.Data":"m","Section.Open":"m","SectionHeader":"t","SectionHeader32":"t","StringTable":"t","StringTable.String":"m","Symbol":"t"}},"debug/plan9obj":{"path":"debug/plan9obj","name":"plan9obj","symbols":{"ErrNoSymbols":"v","File":"t","File.Close":"m","File.Section":"m","File.Symbols":"m","FileHeader":"t","Magic386":"c","Magic64":"c","MagicAMD64":"c","MagicARM":"c","NewFile":"f","Open":"f","Section":"t","Section.Data":"m","Section.Open":"m","SectionHeader":"t","Sym":"t"}},"embed":{"path":"embed","name":"embed","symbols":{"FS":"t","FS.Open":"m","FS.ReadDir":"m","FS.ReadFile":"m"}},"encoding":{"path":"encoding","name":"encoding","symbols":{"BinaryAppender":"t","BinaryMarshaler":"t","BinaryUnmarshaler":"t","TextAppender":"t","TextMarshaler":"t","TextUnmarshaler":"t"}},"encoding/ascii85":{"path":"encoding/ascii85","name":"ascii85","symbols":{"CorruptInputError":"t","CorruptInputError.Error":"m","Decode":"f","Encode":"f","MaxEncodedLen":"f","NewDecoder":"f","NewEncoder":"f"}},"encoding/asn1":{"path":"encoding/asn1","name":"asn1","symbols":{"BitString":"t","BitString.At":"m","BitString.RightAlign":"m","ClassApplication":"c","ClassContextSpecific":"c","ClassPrivate":"c","ClassUniversal":"c","Enumerated":"t","Flag":"t","Marshal":"f","MarshalWithParams":"f","NullBytes":"v","NullRawValue":"v","ObjectIdentifier":"t","ObjectIdentifier.Equal":"m","ObjectIdentifier.String":"m","RawContent":"t","RawValue":"t","StructuralError":"t","StructuralError.Error":"m","SyntaxError":"t","SyntaxError.Error":"m","TagBMPString":"c","TagBitString":"c","TagBoolean":"c","TagEnum":"c","TagGeneralString":"c","TagGeneralizedTime":"c","TagIA5String":"c","TagInteger":"c","TagNull":"c","TagNumericString":"c","TagOID":"c","TagOctetString":"c","TagPrintableString":"c","TagSequence":"c","TagSet":"c","TagT61String":"c","TagUTCTime":"c","TagUTF8String":"c","Unmarshal":"f","UnmarshalWithParams":"f"}},"encoding/base32":{"path":"encoding/base32","name":"base32","symbols":{"CorruptInputError":"t","CorruptInputError.Error":"m","Encoding":"t","Encoding.AppendDecode":"m","Encoding.AppendEncode":"m","Encoding.Decode":"m","Encoding.DecodeString":"m","Encoding.DecodedLen":"m","Encoding.Encode":"m","Encoding.EncodeToString":"m","Encoding.EncodedLen":"m","Encoding.WithPadding":"m","HexEncoding":"v","NewDecoder":"f","NewEncoder":"f","NewEncoding":"f","NoPadding":"c","StdEncoding":"v","StdPadding":"c"}},"encoding/base64":{"path":"encoding/base64","name":"base64","symbols":{"CorruptInputError":"t","CorruptInputError.Error":"m","Encoding":"t","Encoding.AppendDecode":"m","Encoding.AppendEncode":"m","Encoding.Decode":"m","Encoding.DecodeString":"m","Encoding.DecodedLen":"m","Encoding.Encode":"m","Encoding.EncodeToString":"m","Encoding.EncodedLen":"m","Encoding.Strict":"m","Encoding.WithPadding":"m","NewDecoder":"f","NewEncoder":"f","NewEncoding":"f","NoPadding":"c","RawStdEncoding":"v","RawURLEncoding":"v","StdEncoding":"v","StdPadding":"c","URLEncoding":"v"}},"encoding/binary":{"path":"encoding/binary","name":"binary","symbols":{"Append":"f","AppendByteOrder":"t","AppendUvarint":"f","AppendVarint":"f","BigEndian":"v","ByteOrder":"t","Decode":"f","Encode":"f","LittleEndian":"v","MaxVarintLen16":"c","MaxVarintLen32":"c","MaxVarintLen64":"c","NativeEndian":"v","PutUvarint":"f","PutVarint":"f","Read":"f","ReadUvarint":"f","ReadVarint":"f","Size":"f","Uvarint":"f","Varint":"f","Write":"f"}},"encoding/csv":{"path":"encoding/csv","name":"csv","symbols":{"ErrBareQuote":"v","ErrFieldCount":"v","ErrQuote":"v","ErrTrailingComma":"v","NewReader":"f","NewWriter":"f","ParseError":"t","ParseError.Error":"m","ParseError.Unwrap":"m","Reader":"t","Reader.FieldPos":"m","Reader.InputOffset":"m","Reader.Read":"m","Reader.ReadAll":"m","Writer":"t","Writer.Error":"m","Writer.Flush":"m","Writer.Write":"m","Writer.WriteAll":"m"}},"encoding/gob":{"path":"encoding/gob","name":"gob","symbols":{"CommonType":"t","Decoder":"t","Decoder.Decode":"m","Decoder.DecodeValue":"m","Encoder":"t","Encoder.Encode":"m","Encoder.EncodeValue":"m","GobDecoder":"t","GobEncoder":"t","NewDecoder":"f","NewEncoder":"f","Register":"f","RegisterName":"f"}},"encoding/hex":{"path":"encoding/hex","name":"hex","symbols":{"AppendDecode":"f","AppendEncode":"f","Decode":"f","DecodeString":"f","DecodedLen":"f","Dump":"f","Dumper":"f","Encode":"f","EncodeToString":"f","EncodedLen":"f","ErrLength":"v","InvalidByteError":"t","InvalidByteError.Error":"m","NewDecoder":"f","NewEncoder":"f"}},"encoding/json":{"path":"encoding/json","name":"json","symbols":{"CallMethodsWithLegacySemantics":"f","Compact":"f","Decoder":"t","Decoder.Buffered":"m","Decoder.Decode":"m","Decoder.DisallowUnknownFields":"m","Decoder.InputOffset":"m","Decoder.More":"m","Decoder.Token":"m","Decoder.UseNumber":"m","DefaultOptionsV1":"f","Delim":"t","Delim.String":"m","Encoder":"t","Encoder.Encode":"m","Encoder.SetEscapeHTML":"m","Encoder.SetIndent":"m","FormatByteArrayAsArray":"f","FormatBytesWithLegacySemantics":"f","FormatDurationAsNano":"f","HTMLEscape":"f","Indent":"f","InvalidUTF8Error":"t","InvalidUTF8Error.Error":"m","InvalidUnmarshalError":"t","InvalidUnmarshalError.Error":"m","Marshal":"f","MarshalIndent":"f","Marshaler":"t","MarshalerError":"t","MarshalerError.Error":"m","MarshalerError.Unwrap":"m","MatchCaseSensitiveDelimiter":"f","MergeWithLegacySemantics":"f","NewDecoder":"f","NewEncoder":"f","Number":"t","Number.Float64":"m","Number.Int64":"m","Number.MarshalJSONTo":"m","Number.String":"m","Number.UnmarshalJSONFrom":"m","OmitEmptyWithLegacySemantics":"f","Options":"t","ParseBytesWithLooseRFC4648":"f","ParseTimeWithLooseRFC3339":"f","RawMessage":"t","ReportErrorsWithLegacySemantics":"f","StringifyWithLegacySemantics":"f","SyntaxError":"t","SyntaxError.Error":"m","Token":"t","Unmarshal":"f","UnmarshalArrayFromAnyLength":"f","UnmarshalFieldError":"t","UnmarshalFieldError.Error":"m","UnmarshalTypeError":"t","UnmarshalTypeError.Error":"m","UnmarshalTypeError.Unwrap":"m","Unmarshaler":"t","UnsupportedTypeError":"t","UnsupportedTypeError.Error":"m","UnsupportedValueError":"t","UnsupportedValueError.Error":"m","Valid":"f"}},"encoding/json/jsontext":{"path":"encoding/json/jsontext","name":"jsontext","symbols":{"AllowDuplicateNames":"f","AllowInvalidUTF8":"f","AppendFloat":"f","AppendFormat":"f","AppendQuote":"f","AppendUnquote":"f","BeginArray":"v","BeginObject":"v","Bool":"f","CanonicalizeRawFloats":"f","CanonicalizeRawInts":"f","Decoder":"t","Decoder.InputOffset":"m","Decoder.Options":"m","Decoder.PeekKind":"m","Decoder.ReadToken":"m","Decoder.ReadValue":"m","Decoder.Reset":"m","Decoder.SkipValue":"m","Decoder.StackDepth":"m","Decoder.StackIndex":"m","Decoder.StackPointer":"m","Decoder.UnreadBuffer":"m","Encoder":"t","Encoder.AvailableBuffer":"m","Encoder.Options":"m","Encoder.OutputOffset":"m","Encoder.Reset":"m","Encoder.StackDepth":"m","Encoder.StackIndex":"m","Encoder.StackPointer":"m","Encoder.WriteToken":"m","Encoder.WriteValue":"m","EndArray":"v","EndObject":"v","ErrDuplicateName":"v","ErrNonStringName":"v","EscapeForHTML":"f","EscapeForJS":"f","False":"v","Float":"f","Float32":"f","Int":"f","Internal":"v","Kind":"t","Kind.String":"m","KindBeginArray":"c","KindBeginObject":"c","KindEndArray":"c","KindEndObject":"c","KindFalse":"c","KindInvalid":"c","KindNull":"c","KindNumber":"c","KindString":"c","KindTrue":"c","Multiline":"f","NewDecoder":"f","NewEncoder":"f","Null":"v","Options":"t","Pointer":"t","Pointer.AppendToken":"m","Pointer.Contains":"m","Pointer.IsValid":"m","Pointer.LastToken":"m","Pointer.Parent":"m","Pointer.Tokens":"m","PreserveRawStrings":"f","ReorderRawObjects":"f","SpaceAfterColon":"f","SpaceAfterComma":"f","String":"f","SyntacticError":"t","SyntacticError.Error":"m","SyntacticError.Unwrap":"m","Token":"t","Token.Bool":"m","Token.Clone":"m","Token.Float":"m","Token.Float32":"m","Token.Int":"m","Token.Kind":"m","Token.String":"m","Token.Uint":"m","True":"v","Uint":"f","Value":"t","Value.Canonicalize":"m","Value.Clone":"m","Value.Compact":"m","Value.Format":"m","Value.Indent":"m","Value.IsValid":"m","Value.Kind":"m","Value.MarshalJSON":"m","Value.String":"m","Value.UnmarshalJSON":"m","WithIndent":"f","WithIndentPrefix":"f"}},"encoding/json/v2":{"path":"encoding/json/v2","name":"json","symbols":{"DefaultOptionsV2":"f","Deterministic":"f","ErrUnknownName":"v","FormatNilMapAsNull":"f","FormatNilSliceAsNull":"f","GetOption":"f","JoinMarshalers":"f","JoinOptions":"f","JoinUnmarshalers":"f","Marshal":"f","MarshalEncode":"f","MarshalFunc":"f","MarshalToFunc":"f","MarshalWrite":"f","Marshaler":"t","MarshalerTo":"t","Marshalers":"t","MatchCaseInsensitiveNames":"f","OmitZeroStructFields":"f","Options":"t","RejectUnknownMembers":"f","SemanticError":"t","SemanticError.Error":"m","SemanticError.Unwrap":"m","StringifyNumbers":"f","Unmarshal":"f","UnmarshalDecode":"f","UnmarshalFromFunc":"f","UnmarshalFunc":"f","UnmarshalRead":"f","Unmarshaler":"t","UnmarshalerFrom":"t","Unmarshalers":"t","WithMarshalers":"f","WithUnmarshalers":"f"}},"encoding/pem":{"path":"encoding/pem","name":"pem","symbols":{"Block":"t","Decode":"f","Encode":"f","EncodeToMemory":"f"}},"encoding/xml":{"path":"encoding/xml","name":"xml","symbols":{"Attr":"t","CharData":"t","CharData.Copy":"m","Comment":"t","Comment.Copy":"m","CopyToken":"f","Decoder":"t","Decoder.Decode":"m","Decoder.DecodeElement":"m","Decoder.InputOffset":"m","Decoder.InputPos":"m","Decoder.RawToken":"m","Decoder.Skip":"m","Decoder.Token":"m","Directive":"t","Directive.Copy":"m","Encoder":"t","Encoder.Close":"m","Encoder.Encode":"m","Encoder.EncodeElement":"m","Encoder.EncodeToken":"m","Encoder.Flush":"m","Encoder.Indent":"m","EndElement":"t","Escape":"f","EscapeText":"f","HTMLAutoClose":"v","HTMLEntity":"v","Header":"c","Marshal":"f","MarshalIndent":"f","Marshaler":"t","MarshalerAttr":"t","Name":"t","NewDecoder":"f","NewEncoder":"f","NewTokenDecoder":"f","ProcInst":"t","ProcInst.Copy":"m","StartElement":"t","StartElement.Copy":"m","StartElement.End":"m","SyntaxError":"t","SyntaxError.Error":"m","TagPathError":"t","TagPathError.Error":"m","Token":"t","TokenReader":"t","Unmarshal":"f","UnmarshalError":"t","UnmarshalError.Error":"m","Unmarshaler":"t","UnmarshalerAttr":"t","UnsupportedTypeError":"t","UnsupportedTypeError.Error":"m"}},"errors":{"path":"errors","name":"errors","symbols":{"As":"f","AsType":"f","ErrUnsupported":"v","Is":"f","Join":"f","New":"f","Unwrap":"f"}},"expvar":{"path":"expvar","name":"expvar","symbols":{"Do":"f","Float":"t","Float.Add":"m","Float.Set":"m","Float.String":"m","Float.Value":"m","Func":"t","Func.String":"m","Func.Value":"m","Get":"f","Handler":"f","Int":"t","Int.Add":"m","Int.Set":"m","Int.String":"m","Int.Value":"m","KeyValue":"t","Map":"t","Map.Add":"m","Map.AddFloat":"m","Map.Delete":"m","Map.Do":"m","Map.Get":"m","Map.Init":"m","Map.Set":"m","Map.String":"m","NewFloat":"f","NewInt":"f","NewMap":"f","NewString":"f","Publish":"f","String":"t","String.Set":"m","String.String":"m","String.Value":"m","Var":"t"}},"flag":{"path":"flag","name":"flag","symbols":{"Arg":"f","Args":"f","Bool":"f","BoolFunc":"f","BoolVar":"f","CommandLine":"v","ContinueOnError":"c","Duration":"f","DurationVar":"f","ErrHelp":"v","ErrorHandling":"t","ExitOnError":"c","Flag":"t","FlagSet":"t","FlagSet.Arg":"m","FlagSet.Args":"m","FlagSet.Bool":"m","FlagSet.BoolFunc":"m","FlagSet.BoolVar":"m","FlagSet.Duration":"m","FlagSet.DurationVar":"m","FlagSet.ErrorHandling":"m","FlagSet.Float64":"m","FlagSet.Float64Var":"m","FlagSet.Func":"m","FlagSet.Init":"m","FlagSet.Int":"m","FlagSet.Int64":"m","FlagSet.Int64Var":"m","FlagSet.IntVar":"m","FlagSet.Lookup":"m","FlagSet.NArg":"m","FlagSet.NFlag":"m","FlagSet.Name":"m","FlagSet.Output":"m","FlagSet.Parse":"m","FlagSet.Parsed":"m","FlagSet.PrintDefaults":"m","FlagSet.Set":"m","FlagSet.SetOutput":"m","FlagSet.String":"m","FlagSet.StringVar":"m","FlagSet.TextVar":"m","FlagSet.Uint":"m","FlagSet.Uint64":"m","FlagSet.Uint64Var":"m","FlagSet.UintVar":"m","FlagSet.Var":"m","FlagSet.Visit":"m","FlagSet.VisitAll":"m","Float64":"f","Float64Var":"f","Func":"f","Getter":"t","Int":"f","Int64":"f","Int64Var":"f","IntVar":"f","Lookup":"f","NArg":"f","NFlag":"f","NewFlagSet":"f","PanicOnError":"c","Parse":"f","Parsed":"f","PrintDefaults":"f","Set":"f","String":"f","StringVar":"f","TextVar":"f","Uint":"f","Uint64":"f","Uint64Var":"f","UintVar":"f","UnquoteUsage":"f","Usage":"v","Value":"t","Var":"f","Visit":"f","VisitAll":"f"}},"fmt":{"path":"fmt","name":"fmt","symbols":{"Append":"f","Appendf":"f","Appendln":"f","Errorf":"f","FormatString":"f","Formatter":"t","Fprint":"f","Fprintf":"f","Fprintln":"f","Fscan":"f","Fscanf":"f","Fscanln":"f","GoStringer":"t","Print":"f","Printf":"f","Println":"f","Scan":"f","ScanState":"t","Scanf":"f","Scanln":"f","Scanner":"t","Sprint":"f","Sprintf":"f","Sprintln":"f","Sscan":"f","Sscanf":"f","Sscanln":"f","State":"t","Stringer":"t"}},"go/ast":{"path":"go/ast","name":"ast","symbols":{"ArrayType":"t","ArrayType.End":"m","ArrayType.Pos":"m","AssignStmt":"t","AssignStmt.End":"m","AssignStmt.Pos":"m","Bad":"c","BadDecl":"t","BadDecl.End":"m","BadDecl.Pos":"m","BadExpr":"t","BadExpr.End":"m","BadExpr.Pos":"m","BadStmt":"t","BadStmt.End":"m","BadStmt.Pos":"m","BasicLit":"t","BasicLit.End":"m","BasicLit.Pos":"m","BinaryExpr":"t","BinaryExpr.End":"m","BinaryExpr.Pos":"m","BlockStmt":"t","BlockStmt.End":"m","BlockStmt.Pos":"m","BranchStmt":"t","BranchStmt.End":"m","BranchStmt.Pos":"m","CallExpr":"t","CallExpr.End":"m","CallExpr.Pos":"m","CaseClause":"t","CaseClause.End":"m","CaseClause.Pos":"m","ChanDir":"t","ChanType":"t","ChanType.End":"m","ChanType.Pos":"m","CommClause":"t","CommClause.End":"m","CommClause.Pos":"m","Comment":"t","Comment.End":"m","Comment.Pos":"m","CommentGroup":"t","CommentGroup.End":"m","CommentGroup.Pos":"m","CommentGroup.Text":"m","CommentMap":"t","CommentMap.Comments":"m","CommentMap.Filter":"m","CommentMap.String":"m","CommentMap.Update":"m","CompositeLit":"t","CompositeLit.End":"m","CompositeLit.Pos":"m","Con":"c","Decl":"t","DeclStmt":"t","DeclStmt.End":"m","DeclStmt.Pos":"m","DeferStmt":"t","DeferStmt.End":"m","DeferStmt.Pos":"m","Directive":"t","Directive.End":"m","Directive.ParseArgs":"m","Directive.Pos":"m","DirectiveArg":"t","Ellipsis":"t","Ellipsis.End":"m","Ellipsis.Pos":"m","EmptyStmt":"t","EmptyStmt.End":"m","EmptyStmt.Pos":"m","Expr":"t","ExprStmt":"t","ExprStmt.End":"m","ExprStmt.Pos":"m","Field":"t","Field.End":"m","Field.Pos":"m","FieldFilter":"t","FieldList":"t","FieldList.End":"m","FieldList.NumFields":"m","FieldList.Pos":"m","File":"t","File.End":"m","File.Pos":"m","FileExports":"f","Filter":"t","FilterDecl":"f","FilterFile":"f","FilterFuncDuplicates":"c","FilterImportDuplicates":"c","FilterPackage":"f","FilterUnassociatedComments":"c","ForStmt":"t","ForStmt.End":"m","ForStmt.Pos":"m","Fprint":"f","Fun":"c","FuncDecl":"t","FuncDecl.End":"m","FuncDecl.Pos":"m","FuncLit":"t","FuncLit.End":"m","FuncLit.Pos":"m","FuncType":"t","FuncType.End":"m","FuncType.Pos":"m","GenDecl":"t","GenDecl.End":"m","GenDecl.Pos":"m","GoStmt":"t","GoStmt.End":"m","GoStmt.Pos":"m","Ident":"t","Ident.End":"m","Ident.IsExported":"m","Ident.Pos":"m","Ident.String":"m","IfStmt":"t","IfStmt.End":"m","IfStmt.Pos":"m","ImportSpec":"t","ImportSpec.End":"m","ImportSpec.Pos":"m","Importer":"t","IncDecStmt":"t","IncDecStmt.End":"m","IncDecStmt.Pos":"m","IndexExpr":"t","IndexExpr.End":"m","IndexExpr.Pos":"m","IndexListExpr":"t","IndexListExpr.End":"m","IndexListExpr.Pos":"m","Inspect":"f","InterfaceType":"t","InterfaceType.End":"m","InterfaceType.Pos":"m","IsExported":"f","IsGenerated":"f","KeyValueExpr":"t","KeyValueExpr.End":"m","KeyValueExpr.Pos":"m","LabeledStmt":"t","LabeledStmt.End":"m","LabeledStmt.Pos":"m","Lbl":"c","MapType":"t","MapType.End":"m","MapType.Pos":"m","MergeMode":"t","MergePackageFiles":"f","NewCommentMap":"f","NewIdent":"f","NewObj":"f","NewPackage":"f","NewScope":"f","Node":"t","NotNilFilter":"f","ObjKind":"t","ObjKind.String":"m","Object":"t","Object.Pos":"m","Package":"t","Package.End":"m","Package.Pos":"m","PackageExports":"f","ParenExpr":"t","ParenExpr.End":"m","ParenExpr.Pos":"m","ParseDirective":"f","Pkg":"c","Preorder":"f","PreorderStack":"f","Print":"f","RECV":"c","RangeStmt":"t","RangeStmt.End":"m","RangeStmt.Pos":"m","ReturnStmt":"t","ReturnStmt.End":"m","ReturnStmt.Pos":"m","SEND":"c","Scope":"t","Scope.Insert":"m","Scope.Lookup":"m","Scope.String":"m","SelectStmt":"t","SelectStmt.End":"m","SelectStmt.Pos":"m","SelectorExpr":"t","SelectorExpr.End":"m","SelectorExpr.Pos":"m","SendStmt":"t","SendStmt.End":"m","SendStmt.Pos":"m","SliceExpr":"t","SliceExpr.End":"m","SliceExpr.Pos":"m","SortImports":"f","Spec":"t","StarExpr":"t","StarExpr.End":"m","StarExpr.Pos":"m","Stmt":"t","StructType":"t","StructType.End":"m","StructType.Pos":"m","SwitchStmt":"t","SwitchStmt.End":"m","SwitchStmt.Pos":"m","Typ":"c","TypeAssertExpr":"t","TypeAssertExpr.End":"m","TypeAssertExpr.Pos":"m","TypeSpec":"t","TypeSpec.End":"m","TypeSpec.Pos":"m","TypeSwitchStmt":"t","TypeSwitchStmt.End":"m","TypeSwitchStmt.Pos":"m","UnaryExpr":"t","UnaryExpr.End":"m","UnaryExpr.Pos":"m","Unparen":"f","ValueSpec":"t","ValueSpec.End":"m","ValueSpec.Pos":"m","Var":"c","Visitor":"t","Walk":"f"}},"go/build":{"path":"go/build","name":"build","symbols":{"AllowBinary":"c","ArchChar":"f","Context":"t","Context.Import":"m","Context.ImportDir":"m","Context.MatchFile":"m","Context.SrcDirs":"m","Default":"v","Directive":"t","FindOnly":"c","IgnoreVendor":"c","Import":"f","ImportComment":"c","ImportDir":"f","ImportMode":"t","IsLocalImport":"f","MultiplePackageError":"t","MultiplePackageError.Error":"m","NoGoError":"t","NoGoError.Error":"m","Package":"t","Package.IsCommand":"m","ToolDir":"v"}},"go/build/constraint":{"path":"go/build/constraint","name":"constraint","symbols":{"AndExpr":"t","AndExpr.Eval":"m","AndExpr.String":"m","Expr":"t","GoVersion":"f","IsGoBuild":"f","IsPlusBuild":"f","NotExpr":"t","NotExpr.Eval":"m","NotExpr.String":"m","OrExpr":"t","OrExpr.Eval":"m","OrExpr.String":"m","Parse":"f","PlusBuildLines":"f","SyntaxError":"t","SyntaxError.Error":"m","TagExpr":"t","TagExpr.Eval":"m","TagExpr.String":"m"}},"go/constant":{"path":"go/constant","name":"constant","symbols":{"BinaryOp":"f","BitLen":"f","Bool":"c","BoolVal":"f","Bytes":"f","Compare":"f","Complex":"c","Denom":"f","Float":"c","Float32Val":"f","Float64Val":"f","Imag":"f","Int":"c","Int64Val":"f","Kind":"t","Kind.String":"m","Make":"f","MakeBool":"f","MakeFloat64":"f","MakeFromBytes":"f","MakeFromLiteral":"f","MakeImag":"f","MakeInt64":"f","MakeString":"f","MakeUint64":"f","MakeUnknown":"f","Num":"f","Real":"f","Shift":"f","Sign":"f","String":"c","StringLen":"f","StringVal":"f","ToComplex":"f","ToFloat":"f","ToInt":"f","Uint64Val":"f","UnaryOp":"f","Unknown":"c","Val":"f","Value":"t"}},"go/doc":{"path":"go/doc","name":"doc","symbols":{"AllDecls":"c","AllMethods":"c","Example":"t","Examples":"f","Filter":"t","Func":"t","IllegalPrefixes":"v","IsPredeclared":"f","Mode":"t","New":"f","NewFromFiles":"f","Note":"t","Package":"t","Package.Filter":"m","Package.HTML":"m","Package.Markdown":"m","Package.Parser":"m","Package.Printer":"m","Package.Synopsis":"m","Package.Text":"m","PreserveAST":"c","Synopsis":"f","ToHTML":"f","ToText":"f","Type":"t","Value":"t"}},"go/doc/comment":{"path":"go/doc/comment","name":"comment","symbols":{"Block":"t","Code":"t","DefaultLookupPackage":"f","Doc":"t","DocLink":"t","DocLink.DefaultURL":"m","Heading":"t","Heading.DefaultID":"m","Italic":"t","Link":"t","LinkDef":"t","List":"t","List.BlankBefore":"m","List.BlankBetween":"m","ListItem":"t","Paragraph":"t","Parser":"t","Parser.Parse":"m","Plain":"t","Printer":"t","Printer.Comment":"m","Printer.HTML":"m","Printer.Markdown":"m","Printer.Text":"m","Text":"t"}},"go/format":{"path":"go/format","name":"format","symbols":{"Node":"f","Source":"f"}},"go/importer":{"path":"go/importer","name":"importer","symbols":{"Default":"f","For":"f","ForCompiler":"f","Lookup":"t"}},"go/parser":{"path":"go/parser","name":"parser","symbols":{"AllErrors":"c","DeclarationErrors":"c","ImportsOnly":"c","Mode":"t","PackageClauseOnly":"c","ParseComments":"c","ParseDir":"f","ParseExpr":"f","ParseExprFrom":"f","ParseFile":"f","SkipObjectResolution":"c","SpuriousErrors":"c","Trace":"c"}},"go/printer":{"path":"go/printer","name":"printer","symbols":{"CommentedNode":"t","Config":"t","Config.Fprint":"m","Fprint":"f","Mode":"t","RawFormat":"c","SourcePos":"c","TabIndent":"c","UseSpaces":"c"}},"go/scanner":{"path":"go/scanner","name":"scanner","symbols":{"Error":"t","Error.Error":"m","ErrorHandler":"t","ErrorList":"t","ErrorList.Add":"m","ErrorList.Err":"m","ErrorList.Error":"m","ErrorList.Len":"m","ErrorList.Less":"m","ErrorList.RemoveMultiples":"m","ErrorList.Reset":"m","ErrorList.Sort":"m","ErrorList.Swap":"m","Mode":"t","PrintError":"f","ScanComments":"c","Scanner":"t","Scanner.End":"m","Scanner.Init":"m","Scanner.Scan":"m"}},"go/token":{"path":"go/token","name":"token","symbols":{"ADD":"c","ADD_ASSIGN":"c","AND":"c","AND_ASSIGN":"c","AND_NOT":"c","AND_NOT_ASSIGN":"c","ARROW":"c","ASSIGN":"c","BREAK":"c","CASE":"c","CHAN":"c","CHAR":"c","COLON":"c","COMMA":"c","COMMENT":"c","CONST":"c","CONTINUE":"c","DEC":"c","DEFAULT":"c","DEFER":"c","DEFINE":"c","ELLIPSIS":"c","ELSE":"c","EOF":"c","EQL":"c","FALLTHROUGH":"c","FLOAT":"c","FOR":"c","FUNC":"c","File":"t","File.AddLine":"m","File.AddLineColumnInfo":"m","File.AddLineInfo":"m","File.Base":"m","File.End":"m","File.Line":"m","File.LineCount":"m","File.LineStart":"m","File.Lines":"m","File.MergeLine":"m","File.Name":"m","File.Offset":"m","File.Pos":"m","File.Position":"m","File.PositionFor":"m","File.SetLines":"m","File.SetLinesForContent":"m","File.Size":"m","File.String":"m","FileSet":"t","FileSet.AddExistingFiles":"m","FileSet.AddFile":"m","FileSet.Base":"m","FileSet.File":"m","FileSet.Iterate":"m","FileSet.Position":"m","FileSet.PositionFor":"m","FileSet.Read":"m","FileSet.RemoveFile":"m","FileSet.Write":"m","GEQ":"c","GO":"c","GOTO":"c","GTR":"c","HighestPrec":"c","IDENT":"c","IF":"c","ILLEGAL":"c","IMAG":"c","IMPORT":"c","INC":"c","INT":"c","INTERFACE":"c","IsExported":"f","IsIdentifier":"f","IsKeyword":"f","LAND":"c","LBRACE":"c","LBRACK":"c","LEQ":"c","LOR":"c","LPAREN":"c","LSS":"c","Lookup":"f","LowestPrec":"c","MAP":"c","MUL":"c","MUL_ASSIGN":"c","NEQ":"c","NOT":"c","NewFileSet":"f","NoPos":"c","OR":"c","OR_ASSIGN":"c","PACKAGE":"c","PERIOD":"c","Pos":"t","Pos.IsValid":"m","Position":"t","Position.IsValid":"m","Position.String":"m","QUO":"c","QUO_ASSIGN":"c","RANGE":"c","RBRACE":"c","RBRACK":"c","REM":"c","REM_ASSIGN":"c","RETURN":"c","RPAREN":"c","SELECT":"c","SEMICOLON":"c","SHL":"c","SHL_ASSIGN":"c","SHR":"c","SHR_ASSIGN":"c","STRING":"c","STRUCT":"c","SUB":"c","SUB_ASSIGN":"c","SWITCH":"c","TILDE":"c","TYPE":"c","Token":"t","Token.IsKeyword":"m","Token.IsLiteral":"m","Token.IsOperator":"m","Token.Precedence":"m","Token.String":"m","UnaryPrec":"c","VAR":"c","XOR":"c","XOR_ASSIGN":"c"}},"go/types":{"path":"go/types","name":"types","symbols":{"Alias":"t","Alias.Obj":"m","Alias.Origin":"m","Alias.Rhs":"m","Alias.SetTypeParams":"m","Alias.String":"m","Alias.TypeArgs":"m","Alias.TypeParams":"m","Alias.Underlying":"m","ArgumentError":"t","ArgumentError.Error":"m","ArgumentError.Unwrap":"m","Array":"t","Array.Elem":"m","Array.Len":"m","Array.String":"m","Array.Underlying":"m","AssertableTo":"f","AssignableTo":"f","Basic":"t","Basic.Info":"m","Basic.Kind":"m","Basic.Name":"m","Basic.String":"m","Basic.Underlying":"m","BasicInfo":"t","BasicKind":"t","Bool":"c","Builtin":"t","Builtin.String":"m","Byte":"c","Chan":"t","Chan.Dir":"m","Chan.Elem":"m","Chan.String":"m","Chan.Underlying":"m","ChanDir":"t","CheckExpr":"f","Checker":"t","Checker.Files":"m","Comparable":"f","Complex128":"c","Complex64":"c","Config":"t","Config.Check":"m","Const":"t","Const.String":"m","Const.Val":"m","Context":"t","ConvertibleTo":"f","DefPredeclaredTestFuncs":"f","Default":"f","Error":"t","Error.Error":"m","Eval":"f","ExprString":"f","FieldVal":"c","FieldVar":"c","Float32":"c","Float64":"c","Func":"t","Func.FullName":"m","Func.Origin":"m","Func.Pkg":"m","Func.Scope":"m","Func.Signature":"m","Func.String":"m","Hasher":"t","Hasher.Equal":"m","Hasher.Hash":"m","HasherIgnoreTags":"t","HasherIgnoreTags.Equal":"m","HasherIgnoreTags.Hash":"m","Id":"f","Identical":"f","IdenticalIgnoreTags":"f","Implements":"f","ImportMode":"t","Importer":"t","ImporterFrom":"t","Info":"t","Info.ObjectOf":"m","Info.PkgNameOf":"m","Info.TypeOf":"m","Initializer":"t","Initializer.String":"m","Instance":"t","Instance.String":"m","Instantiate":"f","Int":"c","Int16":"c","Int32":"c","Int64":"c","Int8":"c","Interface":"t","Interface.Complete":"m","Interface.Embedded":"m","Interface.EmbeddedType":"m","Interface.EmbeddedTypes":"m","Interface.Empty":"m","Interface.ExplicitMethod":"m","Interface.ExplicitMethods":"m","Interface.IsComparable":"m","Interface.IsImplicit":"m","Interface.IsMethodSet":"m","Interface.MarkImplicit":"m","Interface.Method":"m","Interface.Methods":"m","Interface.NumEmbeddeds":"m","Interface.NumExplicitMethods":"m","Interface.NumMethods":"m","Interface.String":"m","Interface.Underlying":"m","Invalid":"c","IsBoolean":"c","IsComplex":"c","IsConstType":"c","IsFloat":"c","IsInteger":"c","IsInterface":"f","IsNumeric":"c","IsOrdered":"c","IsString":"c","IsUnsigned":"c","IsUntyped":"c","Label":"t","Label.String":"m","LocalVar":"c","LookupFieldOrMethod":"f","LookupSelection":"f","Map":"t","Map.Elem":"m","Map.Key":"m","Map.String":"m","Map.Underlying":"m","MethodExpr":"c","MethodSet":"t","MethodSet.At":"m","MethodSet.Len":"m","MethodSet.Lookup":"m","MethodSet.Methods":"m","MethodSet.String":"m","MethodVal":"c","MissingMethod":"f","Named":"t","Named.AddMethod":"m","Named.Method":"m","Named.Methods":"m","Named.NumMethods":"m","Named.Obj":"m","Named.Origin":"m","Named.SetTypeParams":"m","Named.SetUnderlying":"m","Named.String":"m","Named.TypeArgs":"m","Named.TypeParams":"m","Named.Underlying":"m","NewAlias":"f","NewArray":"f","NewChan":"f","NewChecker":"f","NewConst":"f","NewContext":"f","NewField":"f","NewFunc":"f","NewInterface":"f","NewInterfaceType":"f","NewLabel":"f","NewMap":"f","NewMethodSet":"f","NewNamed":"f","NewPackage":"f","NewParam":"f","NewPkgName":"f","NewPointer":"f","NewScope":"f","NewSignature":"f","NewSignatureType":"f","NewSlice":"f","NewStruct":"f","NewTerm":"f","NewTuple":"f","NewTypeName":"f","NewTypeParam":"f","NewUnion":"f","NewVar":"f","Nil":"t","Nil.String":"m","Object":"t","ObjectString":"f","Package":"t","Package.Complete":"m","Package.GoVersion":"m","Package.Imports":"m","Package.MarkComplete":"m","Package.Name":"m","Package.Path":"m","Package.Scope":"m","Package.SetImports":"m","Package.SetName":"m","Package.String":"m","PackageVar":"c","ParamVar":"c","PkgName":"t","PkgName.Imported":"m","PkgName.String":"m","Pointer":"t","Pointer.Elem":"m","Pointer.String":"m","Pointer.Underlying":"m","Qualifier":"t","RecvOnly":"c","RecvVar":"c","RelativeTo":"f","ResultVar":"c","Rune":"c","Satisfies":"f","Scope":"t","Scope.Child":"m","Scope.Children":"m","Scope.Contains":"m","Scope.End":"m","Scope.Innermost":"m","Scope.Insert":"m","Scope.Len":"m","Scope.Lookup":"m","Scope.LookupParent":"m","Scope.Names":"m","Scope.NumChildren":"m","Scope.Parent":"m","Scope.Pos":"m","Scope.String":"m","Scope.WriteTo":"m","Selection":"t","Selection.Index":"m","Selection.Indirect":"m","Selection.Kind":"m","Selection.Obj":"m","Selection.Recv":"m","Selection.String":"m","Selection.Type":"m","SelectionKind":"t","SelectionString":"f","SendOnly":"c","SendRecv":"c","Signature":"t","Signature.Params":"m","Signature.Recv":"m","Signature.RecvTypeParams":"m","Signature.Results":"m","Signature.String":"m","Signature.TypeParams":"m","Signature.Underlying":"m","Signature.Variadic":"m","Sizes":"t","SizesFor":"f","Slice":"t","Slice.Elem":"m","Slice.String":"m","Slice.Underlying":"m","StdSizes":"t","StdSizes.Alignof":"m","StdSizes.Offsetsof":"m","StdSizes.Sizeof":"m","String":"c","Struct":"t","Struct.Field":"m","Struct.Fields":"m","Struct.NumFields":"m","Struct.String":"m","Struct.Tag":"m","Struct.Underlying":"m","Term":"t","Term.String":"m","Term.Tilde":"m","Term.Type":"m","Tuple":"t","Tuple.At":"m","Tuple.Len":"m","Tuple.String":"m","Tuple.Underlying":"m","Tuple.Variables":"m","Typ":"v","Type":"t","TypeAndValue":"t","TypeAndValue.Addressable":"m","TypeAndValue.Assignable":"m","TypeAndValue.HasOk":"m","TypeAndValue.IsBuiltin":"m","TypeAndValue.IsNil":"m","TypeAndValue.IsType":"m","TypeAndValue.IsValue":"m","TypeAndValue.IsVoid":"m","TypeList":"t","TypeList.At":"m","TypeList.Len":"m","TypeList.String":"m","TypeList.Types":"m","TypeName":"t","TypeName.IsAlias":"m","TypeName.String":"m","TypeParam":"t","TypeParam.Constraint":"m","TypeParam.Index":"m","TypeParam.Obj":"m","TypeParam.SetConstraint":"m","TypeParam.String":"m","TypeParam.Underlying":"m","TypeParamList":"t","TypeParamList.At":"m","TypeParamList.Len":"m","TypeParamList.String":"m","TypeParamList.TypeParams":"m","TypeString":"f","Uint":"c","Uint16":"c","Uint32":"c","Uint64":"c","Uint8":"c","Uintptr":"c","Unalias":"f","Union":"t","Union.Len":"m","Union.String":"m","Union.Term":"m","Union.Terms":"m","Union.Underlying":"m","Universe":"v","Unsafe":"v","UnsafePointer":"c","UntypedBool":"c","UntypedComplex":"c","UntypedFloat":"c","UntypedInt":"c","UntypedNil":"c","UntypedRune":"c","UntypedString":"c","Var":"t","Var.Anonymous":"m","Var.Embedded":"m","Var.IsField":"m","Var.Kind":"m","Var.Origin":"m","Var.SetKind":"m","Var.String":"m","VarKind":"t","VarKind.String":"m","WriteExpr":"f","WriteSignature":"f","WriteType":"f"}},"go/version":{"path":"go/version","name":"version","symbols":{"Compare":"f","IsValid":"f","Lang":"f"}},"hash":{"path":"hash","name":"hash","symbols":{"Cloner":"t","Hash":"t","Hash32":"t","Hash64":"t","XOF":"t"}},"hash/adler32":{"path":"hash/adler32","name":"adler32","symbols":{"Checksum":"f","New":"f","Size":"c"}},"hash/crc32":{"path":"hash/crc32","name":"crc32","symbols":{"Castagnoli":"c","Checksum":"f","ChecksumIEEE":"f","IEEE":"c","IEEETable":"v","Koopman":"c","MakeTable":"f","New":"f","NewIEEE":"f","Size":"c","Table":"t","Update":"f"}},"hash/crc64":{"path":"hash/crc64","name":"crc64","symbols":{"Checksum":"f","ECMA":"c","ISO":"c","MakeTable":"f","New":"f","Size":"c","Table":"t","Update":"f"}},"hash/fnv":{"path":"hash/fnv","name":"fnv","symbols":{"New128":"f","New128a":"f","New32":"f","New32a":"f","New64":"f","New64a":"f"}},"hash/maphash":{"path":"hash/maphash","name":"maphash","symbols":{"Bytes":"f","Comparable":"f","ComparableHasher":"t","Hash":"t","Hash.BlockSize":"m","Hash.Clone":"m","Hash.Reset":"m","Hash.Seed":"m","Hash.SetSeed":"m","Hash.Size":"m","Hash.Sum":"m","Hash.Sum64":"m","Hash.Write":"m","Hash.WriteByte":"m","Hash.WriteString":"m","Hasher":"t","MakeSeed":"f","Seed":"t","String":"f","WriteComparable":"f"}},"html":{"path":"html","name":"html","symbols":{"EscapeString":"f","UnescapeString":"f"}},"html/template":{"path":"html/template","name":"template","symbols":{"CSS":"t","ErrAmbigContext":"c","ErrBadHTML":"c","ErrBranchEnd":"c","ErrEndContext":"c","ErrJSTemplate":"c","ErrNoSuchTemplate":"c","ErrOutputContext":"c","ErrPartialCharset":"c","ErrPartialEscape":"c","ErrPredefinedEscaper":"c","ErrRangeLoopReentry":"c","ErrSlashAmbig":"c","Error":"t","Error.Error":"m","ErrorCode":"t","FuncMap":"t","HTML":"t","HTMLAttr":"t","HTMLEscape":"f","HTMLEscapeString":"f","HTMLEscaper":"f","IsTrue":"f","JS":"t","JSEscape":"f","JSEscapeString":"f","JSEscaper":"f","JSStr":"t","Must":"f","New":"f","OK":"c","ParseFS":"f","ParseFiles":"f","ParseGlob":"f","Srcset":"t","Template":"t","Template.AddParseTree":"m","Template.Clone":"m","Template.DefinedTemplates":"m","Template.Delims":"m","Template.Execute":"m","Template.ExecuteTemplate":"m","Template.Funcs":"m","Template.Lookup":"m","Template.Name":"m","Template.New":"m","Template.Option":"m","Template.Parse":"m","Template.ParseFS":"m","Template.ParseFiles":"m","Template.ParseGlob":"m","Template.Templates":"m","URL":"t","URLQueryEscaper":"f"}},"image":{"path":"image","name":"image","symbols":{"Alpha":"t","Alpha.AlphaAt":"m","Alpha.At":"m","Alpha.Bounds":"m","Alpha.ColorModel":"m","Alpha.Opaque":"m","Alpha.PixOffset":"m","Alpha.RGBA64At":"m","Alpha.Set":"m","Alpha.SetAlpha":"m","Alpha.SetRGBA64":"m","Alpha.SubImage":"m","Alpha16":"t","Alpha16.Alpha16At":"m","Alpha16.At":"m","Alpha16.Bounds":"m","Alpha16.ColorModel":"m","Alpha16.Opaque":"m","Alpha16.PixOffset":"m","Alpha16.RGBA64At":"m","Alpha16.Set":"m","Alpha16.SetAlpha16":"m","Alpha16.SetRGBA64":"m","Alpha16.SubImage":"m","Black":"v","CMYK":"t","CMYK.At":"m","CMYK.Bounds":"m","CMYK.CMYKAt":"m","CMYK.ColorModel":"m","CMYK.Opaque":"m","CMYK.PixOffset":"m","CMYK.RGBA64At":"m","CMYK.Set":"m","CMYK.SetCMYK":"m","CMYK.SetRGBA64":"m","CMYK.SubImage":"m","Config":"t","Decode":"f","DecodeConfig":"f","ErrFormat":"v","Gray":"t","Gray.At":"m","Gray.Bounds":"m","Gray.ColorModel":"m","Gray.GrayAt":"m","Gray.Opaque":"m","Gray.PixOffset":"m","Gray.RGBA64At":"m","Gray.Set":"m","Gray.SetGray":"m","Gray.SetRGBA64":"m","Gray.SubImage":"m","Gray16":"t","Gray16.At":"m","Gray16.Bounds":"m","Gray16.ColorModel":"m","Gray16.Gray16At":"m","Gray16.Opaque":"m","Gray16.PixOffset":"m","Gray16.RGBA64At":"m","Gray16.Set":"m","Gray16.SetGray16":"m","Gray16.SetRGBA64":"m","Gray16.SubImage":"m","Image":"t","NRGBA":"t","NRGBA.At":"m","NRGBA.Bounds":"m","NRGBA.ColorModel":"m","NRGBA.NRGBAAt":"m","NRGBA.Opaque":"m","NRGBA.PixOffset":"m","NRGBA.RGBA64At":"m","NRGBA.Set":"m","NRGBA.SetNRGBA":"m","NRGBA.SetRGBA64":"m","NRGBA.SubImage":"m","NRGBA64":"t","NRGBA64.At":"m","NRGBA64.Bounds":"m","NRGBA64.ColorModel":"m","NRGBA64.NRGBA64At":"m","NRGBA64.Opaque":"m","NRGBA64.PixOffset":"m","NRGBA64.RGBA64At":"m","NRGBA64.Set":"m","NRGBA64.SetNRGBA64":"m","NRGBA64.SetRGBA64":"m","NRGBA64.SubImage":"m","NYCbCrA":"t","NYCbCrA.AOffset":"m","NYCbCrA.At":"m","NYCbCrA.ColorModel":"m","NYCbCrA.NYCbCrAAt":"m","NYCbCrA.Opaque":"m","NYCbCrA.RGBA64At":"m","NYCbCrA.SubImage":"m","NewAlpha":"f","NewAlpha16":"f","NewCMYK":"f","NewGray":"f","NewGray16":"f","NewNRGBA":"f","NewNRGBA64":"f","NewNYCbCrA":"f","NewPaletted":"f","NewRGBA":"f","NewRGBA64":"f","NewUniform":"f","NewYCbCr":"f","Opaque":"v","Paletted":"t","Paletted.At":"m","Paletted.Bounds":"m","Paletted.ColorIndexAt":"m","Paletted.ColorModel":"m","Paletted.Opaque":"m","Paletted.PixOffset":"m","Paletted.RGBA64At":"m","Paletted.Set":"m","Paletted.SetColorIndex":"m","Paletted.SetRGBA64":"m","Paletted.SubImage":"m","PalettedImage":"t","Point":"t","Point.Add":"m","Point.Div":"m","Point.Eq":"m","Point.In":"m","Point.Mod":"m","Point.Mul":"m","Point.String":"m","Point.Sub":"m","Pt":"f","RGBA":"t","RGBA.At":"m","RGBA.Bounds":"m","RGBA.ColorModel":"m","RGBA.Opaque":"m","RGBA.PixOffset":"m","RGBA.RGBA64At":"m","RGBA.RGBAAt":"m","RGBA.Set":"m","RGBA.SetRGBA":"m","RGBA.SetRGBA64":"m","RGBA.SubImage":"m","RGBA64":"t","RGBA64.At":"m","RGBA64.Bounds":"m","RGBA64.ColorModel":"m","RGBA64.Opaque":"m","RGBA64.PixOffset":"m","RGBA64.RGBA64At":"m","RGBA64.Set":"m","RGBA64.SetRGBA64":"m","RGBA64.SubImage":"m","RGBA64Image":"t","Rect":"f","Rectangle":"t","Rectangle.Add":"m","Rectangle.At":"m","Rectangle.Bounds":"m","Rectangle.Canon":"m","Rectangle.ColorModel":"m","Rectangle.Dx":"m","Rectangle.Dy":"m","Rectangle.Empty":"m","Rectangle.Eq":"m","Rectangle.In":"m","Rectangle.Inset":"m","Rectangle.Intersect":"m","Rectangle.Overlaps":"m","Rectangle.RGBA64At":"m","Rectangle.Size":"m","Rectangle.String":"m","Rectangle.Sub":"m","Rectangle.Union":"m","RegisterFormat":"f","Transparent":"v","Uniform":"t","Uniform.At":"m","Uniform.Bounds":"m","Uniform.ColorModel":"m","Uniform.Convert":"m","Uniform.Opaque":"m","Uniform.RGBA":"m","Uniform.RGBA64At":"m","White":"v","YCbCr":"t","YCbCr.At":"m","YCbCr.Bounds":"m","YCbCr.COffset":"m","YCbCr.ColorModel":"m","YCbCr.Opaque":"m","YCbCr.RGBA64At":"m","YCbCr.SubImage":"m","YCbCr.YCbCrAt":"m","YCbCr.YOffset":"m","YCbCrSubsampleRatio":"t","YCbCrSubsampleRatio.String":"m","YCbCrSubsampleRatio410":"c","YCbCrSubsampleRatio411":"c","YCbCrSubsampleRatio420":"c","YCbCrSubsampleRatio422":"c","YCbCrSubsampleRatio440":"c","YCbCrSubsampleRatio444":"c","ZP":"v","ZR":"v"}},"image/color":{"path":"image/color","name":"color","symbols":{"Alpha":"t","Alpha.RGBA":"m","Alpha16":"t","Alpha16.RGBA":"m","Alpha16Model":"v","AlphaModel":"v","Black":"v","CMYK":"t","CMYK.RGBA":"m","CMYKModel":"v","CMYKToRGB":"f","Color":"t","Gray":"t","Gray.RGBA":"m","Gray16":"t","Gray16.RGBA":"m","Gray16Model":"v","GrayModel":"v","Model":"t","ModelFunc":"f","NRGBA":"t","NRGBA.RGBA":"m","NRGBA64":"t","NRGBA64.RGBA":"m","NRGBA64Model":"v","NRGBAModel":"v","NYCbCrA":"t","NYCbCrA.RGBA":"m","NYCbCrAModel":"v","Opaque":"v","Palette":"t","Palette.Convert":"m","Palette.Index":"m","RGBA":"t","RGBA.RGBA":"m","RGBA64":"t","RGBA64.RGBA":"m","RGBA64Model":"v","RGBAModel":"v","RGBToCMYK":"f","RGBToYCbCr":"f","Transparent":"v","White":"v","YCbCr":"t","YCbCr.RGBA":"m","YCbCrModel":"v","YCbCrToRGB":"f"}},"image/color/palette":{"path":"image/color/palette","name":"palette","symbols":{"Plan9":"v","WebSafe":"v"}},"image/draw":{"path":"image/draw","name":"draw","symbols":{"Draw":"f","DrawMask":"f","Drawer":"t","FloydSteinberg":"v","Image":"t","Op":"t","Op.Draw":"m","Over":"c","Quantizer":"t","RGBA64Image":"t","Src":"c"}},"image/gif":{"path":"image/gif","name":"gif","symbols":{"Decode":"f","DecodeAll":"f","DecodeConfig":"f","DisposalBackground":"c","DisposalNone":"c","DisposalPrevious":"c","Encode":"f","EncodeAll":"f","GIF":"t","Options":"t"}},"image/jpeg":{"path":"image/jpeg","name":"jpeg","symbols":{"Decode":"f","DecodeConfig":"f","DefaultQuality":"c","Encode":"f","FormatError":"t","FormatError.Error":"m","Options":"t","Reader":"t","UnsupportedError":"t","UnsupportedError.Error":"m"}},"image/png":{"path":"image/png","name":"png","symbols":{"BestCompression":"c","BestSpeed":"c","CompressionLevel":"t","Decode":"f","DecodeConfig":"f","DefaultCompression":"c","Encode":"f","Encoder":"t","Encoder.Encode":"m","EncoderBuffer":"t","EncoderBufferPool":"t","FormatError":"t","FormatError.Error":"m","NoCompression":"c","UnsupportedError":"t","UnsupportedError.Error":"m"}},"index/suffixarray":{"path":"index/suffixarray","name":"suffixarray","symbols":{"Index":"t","Index.Bytes":"m","Index.FindAllIndex":"m","Index.Lookup":"m","Index.Read":"m","Index.Write":"m","New":"f"}},"io":{"path":"io","name":"io","symbols":{"ByteReader":"t","ByteScanner":"t","ByteWriter":"t","Closer":"t","Copy":"f","CopyBuffer":"f","CopyN":"f","Discard":"v","EOF":"v","ErrClosedPipe":"v","ErrNoProgress":"v","ErrShortBuffer":"v","ErrShortWrite":"v","ErrUnexpectedEOF":"v","LimitReader":"f","LimitedReader":"t","LimitedReader.Read":"m","MultiReader":"f","MultiWriter":"f","NewOffsetWriter":"f","NewSectionReader":"f","NopCloser":"f","OffsetWriter":"t","OffsetWriter.Seek":"m","OffsetWriter.Write":"m","OffsetWriter.WriteAt":"m","Pipe":"f","PipeReader":"t","PipeReader.Close":"m","PipeReader.CloseWithError":"m","PipeReader.Read":"m","PipeWriter":"t","PipeWriter.Close":"m","PipeWriter.CloseWithError":"m","PipeWriter.Write":"m","ReadAll":"f","ReadAtLeast":"f","ReadCloser":"t","ReadFull":"f","ReadSeekCloser":"t","ReadSeeker":"t","ReadWriteCloser":"t","ReadWriteSeeker":"t","ReadWriter":"t","Reader":"t","ReaderAt":"t","ReaderFrom":"t","RuneReader":"t","RuneScanner":"t","SectionReader":"t","SectionReader.Outer":"m","SectionReader.Read":"m","SectionReader.ReadAt":"m","SectionReader.Seek":"m","SectionReader.Size":"m","SeekCurrent":"c","SeekEnd":"c","SeekStart":"c","Seeker":"t","StringWriter":"t","TeeReader":"f","WriteCloser":"t","WriteSeeker":"t","WriteString":"f","Writer":"t","WriterAt":"t","WriterTo":"t"}},"io/fs":{"path":"io/fs","name":"fs","symbols":{"DirEntry":"t","ErrClosed":"v","ErrExist":"v","ErrInvalid":"v","ErrNotExist":"v","ErrPermission":"v","FS":"t","File":"t","FileInfo":"t","FileInfoToDirEntry":"f","FileMode":"t","FileMode.IsDir":"m","FileMode.IsRegular":"m","FileMode.Perm":"m","FileMode.String":"m","FileMode.Type":"m","FormatDirEntry":"f","FormatFileInfo":"f","Glob":"f","GlobFS":"t","Lstat":"f","ModeAppend":"c","ModeCharDevice":"c","ModeDevice":"c","ModeDir":"c","ModeExclusive":"c","ModeIrregular":"c","ModeNamedPipe":"c","ModePerm":"c","ModeSetgid":"c","ModeSetuid":"c","ModeSocket":"c","ModeSticky":"c","ModeSymlink":"c","ModeTemporary":"c","ModeType":"c","PathError":"t","PathError.Error":"m","PathError.Timeout":"m","PathError.Unwrap":"m","ReadDir":"f","ReadDirFS":"t","ReadDirFile":"t","ReadFile":"f","ReadFileFS":"t","ReadLink":"f","ReadLinkFS":"t","SkipAll":"v","SkipDir":"v","Stat":"f","StatFS":"t","Sub":"f","SubFS":"t","ValidPath":"f","WalkDir":"f","WalkDirFunc":"t"}},"io/ioutil":{"path":"io/ioutil","name":"ioutil","symbols":{"Discard":"v","NopCloser":"f","ReadAll":"f","ReadDir":"f","ReadFile":"f","TempDir":"f","TempFile":"f","WriteFile":"f"}},"iter":{"path":"iter","name":"iter","symbols":{"Pull":"f","Pull2":"f","Seq":"t","Seq2":"t"}},"log":{"path":"log","name":"log","symbols":{"Default":"f","Fatal":"f","Fatalf":"f","Fatalln":"f","Flags":"f","LUTC":"c","Ldate":"c","Llongfile":"c","Lmicroseconds":"c","Lmsgprefix":"c","Logger":"t","Logger.Fatal":"m","Logger.Fatalf":"m","Logger.Fatalln":"m","Logger.Flags":"m","Logger.Output":"m","Logger.Panic":"m","Logger.Panicf":"m","Logger.Panicln":"m","Logger.Prefix":"m","Logger.Print":"m","Logger.Printf":"m","Logger.Println":"m","Logger.SetFlags":"m","Logger.SetOutput":"m","Logger.SetPrefix":"m","Logger.Writer":"m","Lshortfile":"c","LstdFlags":"c","Ltime":"c","New":"f","Output":"f","Panic":"f","Panicf":"f","Panicln":"f","Prefix":"f","Print":"f","Printf":"f","Println":"f","SetFlags":"f","SetOutput":"f","SetPrefix":"f","Writer":"f"}},"log/slog":{"path":"log/slog","name":"slog","symbols":{"Any":"f","AnyValue":"f","Attr":"t","Attr.Equal":"m","Attr.String":"m","Bool":"f","BoolValue":"f","Debug":"f","DebugContext":"f","Default":"f","DiscardHandler":"v","Duration":"f","DurationValue":"f","Error":"f","ErrorContext":"f","Float64":"f","Float64Value":"f","Group":"f","GroupAttrs":"f","GroupValue":"f","Handler":"t","HandlerOptions":"t","Info":"f","InfoContext":"f","Int":"f","Int64":"f","Int64Value":"f","IntValue":"f","JSONHandler":"t","JSONHandler.Enabled":"m","JSONHandler.Handle":"m","JSONHandler.WithAttrs":"m","JSONHandler.WithGroup":"m","Kind":"t","Kind.String":"m","KindAny":"c","KindBool":"c","KindDuration":"c","KindFloat64":"c","KindGroup":"c","KindInt64":"c","KindLogValuer":"c","KindString":"c","KindTime":"c","KindUint64":"c","Level":"t","Level.AppendText":"m","Level.Level":"m","Level.MarshalJSON":"m","Level.MarshalText":"m","Level.String":"m","Level.UnmarshalJSON":"m","Level.UnmarshalText":"m","LevelDebug":"c","LevelError":"c","LevelInfo":"c","LevelKey":"c","LevelVar":"t","LevelVar.AppendText":"m","LevelVar.Level":"m","LevelVar.MarshalText":"m","LevelVar.Set":"m","LevelVar.String":"m","LevelVar.UnmarshalText":"m","LevelWarn":"c","Leveler":"t","Log":"f","LogAttrs":"f","LogValuer":"t","Logger":"t","Logger.Debug":"m","Logger.DebugContext":"m","Logger.Enabled":"m","Logger.Error":"m","Logger.ErrorContext":"m","Logger.Handler":"m","Logger.Info":"m","Logger.InfoContext":"m","Logger.Log":"m","Logger.LogAttrs":"m","Logger.Warn":"m","Logger.WarnContext":"m","Logger.With":"m","Logger.WithGroup":"m","MessageKey":"c","MultiHandler":"t","MultiHandler.Enabled":"m","MultiHandler.Handle":"m","MultiHandler.WithAttrs":"m","MultiHandler.WithGroup":"m","New":"f","NewJSONHandler":"f","NewLogLogger":"f","NewMultiHandler":"f","NewRecord":"f","NewTextHandler":"f","Record":"t","Record.Add":"m","Record.AddAttrs":"m","Record.Attrs":"m","Record.Clone":"m","Record.NumAttrs":"m","Record.Source":"m","SetDefault":"f","SetLogLoggerLevel":"f","Source":"t","SourceKey":"c","String":"f","StringValue":"f","TextHandler":"t","TextHandler.Enabled":"m","TextHandler.Handle":"m","TextHandler.WithAttrs":"m","TextHandler.WithGroup":"m","Time":"f","TimeKey":"c","TimeValue":"f","Uint64":"f","Uint64Value":"f","Value":"t","Value.Any":"m","Value.Bool":"m","Value.Duration":"m","Value.Equal":"m","Value.Float64":"m","Value.Group":"m","Value.Int64":"m","Value.Kind":"m","Value.LogValuer":"m","Value.Resolve":"m","Value.String":"m","Value.Time":"m","Value.Uint64":"m","Warn":"f","WarnContext":"f","With":"f"}},"log/syslog":{"path":"log/syslog","name":"syslog","symbols":{"Dial":"f","LOG_ALERT":"c","LOG_AUTH":"c","LOG_AUTHPRIV":"c","LOG_CRIT":"c","LOG_CRON":"c","LOG_DAEMON":"c","LOG_DEBUG":"c","LOG_EMERG":"c","LOG_ERR":"c","LOG_FTP":"c","LOG_INFO":"c","LOG_KERN":"c","LOG_LOCAL0":"c","LOG_LOCAL1":"c","LOG_LOCAL2":"c","LOG_LOCAL3":"c","LOG_LOCAL4":"c","LOG_LOCAL5":"c","LOG_LOCAL6":"c","LOG_LOCAL7":"c","LOG_LPR":"c","LOG_MAIL":"c","LOG_NEWS":"c","LOG_NOTICE":"c","LOG_SYSLOG":"c","LOG_USER":"c","LOG_UUCP":"c","LOG_WARNING":"c","New":"f","NewLogger":"f","Priority":"t","Writer":"t","Writer.Alert":"m","Writer.Close":"m","Writer.Crit":"m","Writer.Debug":"m","Writer.Emerg":"m","Writer.Err":"m","Writer.Info":"m","Writer.Notice":"m","Writer.Warning":"m","Writer.Write":"m"}},"maps":{"path":"maps","name":"maps","symbols":{"All":"f","Clone":"f","Collect":"f","Copy":"f","DeleteFunc":"f","Equal":"f","EqualFunc":"f","Insert":"f","Keys":"f","Values":"f"}},"math":{"path":"math","name":"math","symbols":{"Abs":"f","Acos":"f","Acosh":"f","Asin":"f","Asinh":"f","Atan":"f","Atan2":"f","Atanh":"f","Cbrt":"f","Ceil":"f","Copysign":"f","Cos":"f","Cosh":"f","Dim":"f","E":"c","Erf":"f","Erfc":"f","Erfcinv":"f","Erfinv":"f","Exp":"f","Exp2":"f","Expm1":"f","FMA":"f","Float32bits":"f","Float32frombits":"f","Float64bits":"f","Float64frombits":"f","Floor":"f","Frexp":"f","Gamma":"f","Hypot":"f","Ilogb":"f","Inf":"f","IsInf":"f","IsNaN":"f","J0":"f","J1":"f","Jn":"f","Ldexp":"f","Lgamma":"f","Ln10":"c","Ln2":"c","Log":"f","Log10":"f","Log10E":"c","Log1p":"f","Log2":"f","Log2E":"c","Logb":"f","Max":"f","MaxFloat32":"c","MaxFloat64":"c","MaxInt":"c","MaxInt16":"c","MaxInt32":"c","MaxInt64":"c","MaxInt8":"c","MaxUint":"c","MaxUint16":"c","MaxUint32":"c","MaxUint64":"c","MaxUint8":"c","Min":"f","MinInt":"c","MinInt16":"c","MinInt32":"c","MinInt64":"c","MinInt8":"c","Mod":"f","Modf":"f","NaN":"f","Nextafter":"f","Nextafter32":"f","Phi":"c","Pi":"c","Pow":"f","Pow10":"f","Remainder":"f","Round":"f","RoundToEven":"f","Signbit":"f","Sin":"f","Sincos":"f","Sinh":"f","SmallestNonzeroFloat32":"c","SmallestNonzeroFloat64":"c","Sqrt":"f","Sqrt2":"c","SqrtE":"c","SqrtPhi":"c","SqrtPi":"c","Tan":"f","Tanh":"f","Trunc":"f","Y0":"f","Y1":"f","Yn":"f"}},"math/big":{"path":"math/big","name":"big","symbols":{"Above":"c","Accuracy":"t","Accuracy.String":"m","AwayFromZero":"c","Below":"c","Ceil":"c","ErrNaN":"t","ErrNaN.Error":"m","Exact":"c","Float":"t","Float.Abs":"m","Float.Acc":"m","Float.Add":"m","Float.Append":"m","Float.AppendText":"m","Float.Cmp":"m","Float.Copy":"m","Float.Float32":"m","Float.Float64":"m","Float.Format":"m","Float.GobDecode":"m","Float.GobEncode":"m","Float.Int":"m","Float.Int64":"m","Float.IsInf":"m","Float.IsInt":"m","Float.MantExp":"m","Float.MarshalText":"m","Float.MinPrec":"m","Float.Mode":"m","Float.Mul":"m","Float.Neg":"m","Float.Parse":"m","Float.Prec":"m","Float.Quo":"m","Float.Rat":"m","Float.Scan":"m","Float.Set":"m","Float.SetFloat64":"m","Float.SetInf":"m","Float.SetInt":"m","Float.SetInt64":"m","Float.SetMantExp":"m","Float.SetMode":"m","Float.SetPrec":"m","Float.SetRat":"m","Float.SetString":"m","Float.SetUint64":"m","Float.Sign":"m","Float.Signbit":"m","Float.Sqrt":"m","Float.String":"m","Float.Sub":"m","Float.Text":"m","Float.Uint64":"m","Float.UnmarshalText":"m","Floor":"c","Int":"t","Int.Abs":"m","Int.Add":"m","Int.And":"m","Int.AndNot":"m","Int.Append":"m","Int.AppendText":"m","Int.Binomial":"m","Int.Bit":"m","Int.BitLen":"m","Int.Bits":"m","Int.Bytes":"m","Int.Cmp":"m","Int.CmpAbs":"m","Int.Div":"m","Int.DivMod":"m","Int.Divide":"m","Int.Exp":"m","Int.FillBytes":"m","Int.Float64":"m","Int.Format":"m","Int.GCD":"m","Int.GobDecode":"m","Int.GobEncode":"m","Int.Int64":"m","Int.IsInt64":"m","Int.IsUint64":"m","Int.Lsh":"m","Int.MarshalJSON":"m","Int.MarshalText":"m","Int.Mod":"m","Int.ModInverse":"m","Int.ModSqrt":"m","Int.Mul":"m","Int.MulRange":"m","Int.Neg":"m","Int.Not":"m","Int.Or":"m","Int.ProbablyPrime":"m","Int.Quo":"m","Int.QuoRem":"m","Int.Rand":"m","Int.Rem":"m","Int.Rsh":"m","Int.Scan":"m","Int.Set":"m","Int.SetBit":"m","Int.SetBits":"m","Int.SetBytes":"m","Int.SetInt64":"m","Int.SetString":"m","Int.SetUint64":"m","Int.Sign":"m","Int.Sqrt":"m","Int.String":"m","Int.Sub":"m","Int.Text":"m","Int.TrailingZeroBits":"m","Int.Uint64":"m","Int.UnmarshalJSON":"m","Int.UnmarshalText":"m","Int.Xor":"m","Jacobi":"f","MaxBase":"c","MaxExp":"c","MaxPrec":"c","MinExp":"c","NewFloat":"f","NewInt":"f","NewRat":"f","ParseFloat":"f","Rat":"t","Rat.Abs":"m","Rat.Add":"m","Rat.AppendText":"m","Rat.Cmp":"m","Rat.Denom":"m","Rat.Float32":"m","Rat.Float64":"m","Rat.FloatPrec":"m","Rat.FloatString":"m","Rat.GobDecode":"m","Rat.GobEncode":"m","Rat.Inv":"m","Rat.IsInt":"m","Rat.MarshalText":"m","Rat.Mul":"m","Rat.Neg":"m","Rat.Num":"m","Rat.Quo":"m","Rat.RatString":"m","Rat.Scan":"m","Rat.Set":"m","Rat.SetFloat64":"m","Rat.SetFrac":"m","Rat.SetFrac64":"m","Rat.SetInt":"m","Rat.SetInt64":"m","Rat.SetString":"m","Rat.SetUint64":"m","Rat.Sign":"m","Rat.String":"m","Rat.Sub":"m","Rat.UnmarshalText":"m","Round":"c","RoundingMode":"t","RoundingMode.String":"m","ToNearestAway":"c","ToNearestEven":"c","ToNegativeInf":"c","ToPositiveInf":"c","ToZero":"c","Trunc":"c","Word":"t"}},"math/bits":{"path":"math/bits","name":"bits","symbols":{"Add":"f","Add32":"f","Add64":"f","Div":"f","Div32":"f","Div64":"f","LeadingZeros":"f","LeadingZeros16":"f","LeadingZeros32":"f","LeadingZeros64":"f","LeadingZeros8":"f","Len":"f","Len16":"f","Len32":"f","Len64":"f","Len8":"f","Mul":"f","Mul32":"f","Mul64":"f","OnesCount":"f","OnesCount16":"f","OnesCount32":"f","OnesCount64":"f","OnesCount8":"f","Rem":"f","Rem32":"f","Rem64":"f","Reverse":"f","Reverse16":"f","Reverse32":"f","Reverse64":"f","Reverse8":"f","ReverseBytes":"f","ReverseBytes16":"f","ReverseBytes32":"f","ReverseBytes64":"f","RotateLeft":"f","RotateLeft16":"f","RotateLeft32":"f","RotateLeft64":"f","RotateLeft8":"f","Sub":"f","Sub32":"f","Sub64":"f","TrailingZeros":"f","TrailingZeros16":"f","TrailingZeros32":"f","TrailingZeros64":"f","TrailingZeros8":"f","UintSize":"c"}},"math/cmplx":{"path":"math/cmplx","name":"cmplx","symbols":{"Abs":"f","Acos":"f","Acosh":"f","Asin":"f","Asinh":"f","Atan":"f","Atanh":"f","Conj":"f","Cos":"f","Cosh":"f","Cot":"f","Exp":"f","Inf":"f","IsInf":"f","IsNaN":"f","Log":"f","Log10":"f","NaN":"f","Phase":"f","Polar":"f","Pow":"f","Rect":"f","Sin":"f","Sinh":"f","Sqrt":"f","Tan":"f","Tanh":"f"}},"math/rand":{"path":"math/rand","name":"rand","symbols":{"ExpFloat64":"f","Float32":"f","Float64":"f","Int":"f","Int31":"f","Int31n":"f","Int63":"f","Int63n":"f","Intn":"f","New":"f","NewSource":"f","NewZipf":"f","NormFloat64":"f","Perm":"f","Rand":"t","Rand.ExpFloat64":"m","Rand.Float32":"m","Rand.Float64":"m","Rand.Int":"m","Rand.Int31":"m","Rand.Int31n":"m","Rand.Int63":"m","Rand.Int63n":"m","Rand.Intn":"m","Rand.NormFloat64":"m","Rand.Perm":"m","Rand.Read":"m","Rand.Seed":"m","Rand.Shuffle":"m","Rand.Uint32":"m","Rand.Uint64":"m","Read":"f","Seed":"f","Shuffle":"f","Source":"t","Source64":"t","Uint32":"f","Uint64":"f","Zipf":"t","Zipf.Uint64":"m"}},"math/rand/v2":{"path":"math/rand/v2","name":"rand","symbols":{"ChaCha8":"t","ChaCha8.AppendBinary":"m","ChaCha8.MarshalBinary":"m","ChaCha8.Read":"m","ChaCha8.Seed":"m","ChaCha8.Uint64":"m","ChaCha8.UnmarshalBinary":"m","ExpFloat64":"f","Float32":"f","Float64":"f","Int":"f","Int32":"f","Int32N":"f","Int64":"f","Int64N":"f","IntN":"f","N":"f","New":"f","NewChaCha8":"f","NewPCG":"f","NewZipf":"f","NormFloat64":"f","PCG":"t","PCG.AppendBinary":"m","PCG.MarshalBinary":"m","PCG.Seed":"m","PCG.Uint64":"m","PCG.UnmarshalBinary":"m","Perm":"f","Rand":"t","Rand.ExpFloat64":"m","Rand.Float32":"m","Rand.Float64":"m","Rand.Int":"m","Rand.Int32":"m","Rand.Int32N":"m","Rand.Int64":"m","Rand.Int64N":"m","Rand.IntN":"m","Rand.N":"m","Rand.NormFloat64":"m","Rand.Perm":"m","Rand.Shuffle":"m","Rand.Uint":"m","Rand.Uint32":"m","Rand.Uint32N":"m","Rand.Uint64":"m","Rand.Uint64N":"m","Rand.UintN":"m","Shuffle":"f","Source":"t","Uint":"f","Uint32":"f","Uint32N":"f","Uint64":"f","Uint64N":"f","UintN":"f","Zipf":"t","Zipf.Uint64":"m"}},"mime":{"path":"mime","name":"mime","symbols":{"AddExtensionType":"f","BEncoding":"c","ErrInvalidMediaParameter":"v","ExtensionsByType":"f","FormatMediaType":"f","ParseMediaType":"f","QEncoding":"c","TypeByExtension":"f","WordDecoder":"t","WordDecoder.Decode":"m","WordDecoder.DecodeHeader":"m","WordEncoder":"t","WordEncoder.Encode":"m"}},"mime/multipart":{"path":"mime/multipart","name":"multipart","symbols":{"ErrMessageTooLarge":"v","File":"t","FileContentDisposition":"f","FileHeader":"t","FileHeader.Open":"m","Form":"t","Form.RemoveAll":"m","NewReader":"f","NewWriter":"f","Part":"t","Part.Close":"m","Part.FileName":"m","Part.FormName":"m","Part.Read":"m","Reader":"t","Reader.NextPart":"m","Reader.NextRawPart":"m","Reader.ReadForm":"m","Writer":"t","Writer.Boundary":"m","Writer.Close":"m","Writer.CreateFormField":"m","Writer.CreateFormFile":"m","Writer.CreatePart":"m","Writer.FormDataContentType":"m","Writer.SetBoundary":"m","Writer.WriteField":"m"}},"mime/quotedprintable":{"path":"mime/quotedprintable","name":"quotedprintable","symbols":{"NewReader":"f","NewWriter":"f","Reader":"t","Reader.Read":"m","Writer":"t","Writer.Close":"m","Writer.Write":"m"}},"net":{"path":"net","name":"net","symbols":{"Addr":"t","AddrError":"t","AddrError.Error":"m","AddrError.Temporary":"m","AddrError.Timeout":"m","Buffers":"t","Buffers.Read":"m","Buffers.WriteTo":"m","CIDRMask":"f","Conn":"t","DNSConfigError":"t","DNSConfigError.Error":"m","DNSConfigError.Temporary":"m","DNSConfigError.Timeout":"m","DNSConfigError.Unwrap":"m","DNSError":"t","DNSError.Error":"m","DNSError.Temporary":"m","DNSError.Timeout":"m","DNSError.Unwrap":"m","DefaultResolver":"v","Dial":"f","DialIP":"f","DialTCP":"f","DialTimeout":"f","DialUDP":"f","DialUnix":"f","Dialer":"t","Dialer.Dial":"m","Dialer.DialContext":"m","Dialer.DialIP":"m","Dialer.DialTCP":"m","Dialer.DialUDP":"m","Dialer.DialUnix":"m","Dialer.MultipathTCP":"m","Dialer.SetMultipathTCP":"m","ErrClosed":"v","ErrWriteToConnected":"v","Error":"t","FileConn":"f","FileListener":"f","FilePacketConn":"f","FlagBroadcast":"c","FlagLoopback":"c","FlagMulticast":"c","FlagPointToPoint":"c","FlagRunning":"c","FlagUp":"c","Flags":"t","Flags.String":"m","HardwareAddr":"t","HardwareAddr.String":"m","IP":"t","IP.AppendText":"m","IP.DefaultMask":"m","IP.Equal":"m","IP.IsGlobalUnicast":"m","IP.IsInterfaceLocalMulticast":"m","IP.IsLinkLocalMulticast":"m","IP.IsLinkLocalUnicast":"m","IP.IsLoopback":"m","IP.IsMulticast":"m","IP.IsPrivate":"m","IP.IsUnspecified":"m","IP.MarshalText":"m","IP.Mask":"m","IP.String":"m","IP.To16":"m","IP.To4":"m","IP.UnmarshalText":"m","IPAddr":"t","IPAddr.Network":"m","IPAddr.String":"m","IPConn":"t","IPConn.ReadFrom":"m","IPConn.ReadFromIP":"m","IPConn.ReadMsgIP":"m","IPConn.SyscallConn":"m","IPConn.WriteMsgIP":"m","IPConn.WriteTo":"m","IPConn.WriteToIP":"m","IPMask":"t","IPMask.Size":"m","IPMask.String":"m","IPNet":"t","IPNet.Contains":"m","IPNet.Network":"m","IPNet.String":"m","IPv4":"f","IPv4Mask":"f","IPv4allrouter":"v","IPv4allsys":"v","IPv4bcast":"v","IPv4len":"c","IPv4zero":"v","IPv6interfacelocalallnodes":"v","IPv6len":"c","IPv6linklocalallnodes":"v","IPv6linklocalallrouters":"v","IPv6loopback":"v","IPv6unspecified":"v","IPv6zero":"v","Interface":"t","Interface.Addrs":"m","Interface.MulticastAddrs":"m","InterfaceAddrs":"f","InterfaceByIndex":"f","InterfaceByName":"f","Interfaces":"f","InvalidAddrError":"t","InvalidAddrError.Error":"m","InvalidAddrError.Temporary":"m","InvalidAddrError.Timeout":"m","JoinHostPort":"f","KeepAliveConfig":"t","Listen":"f","ListenConfig":"t","ListenConfig.Listen":"m","ListenConfig.ListenPacket":"m","ListenConfig.MultipathTCP":"m","ListenConfig.SetMultipathTCP":"m","ListenIP":"f","ListenMulticastUDP":"f","ListenPacket":"f","ListenTCP":"f","ListenUDP":"f","ListenUnix":"f","ListenUnixgram":"f","Listener":"t","LookupAddr":"f","LookupCNAME":"f","LookupHost":"f","LookupIP":"f","LookupMX":"f","LookupNS":"f","LookupPort":"f","LookupSRV":"f","LookupTXT":"f","MX":"t","NS":"t","OpError":"t","OpError.Error":"m","OpError.Temporary":"m","OpError.Timeout":"m","OpError.Unwrap":"m","PacketConn":"t","ParseCIDR":"f","ParseError":"t","ParseError.Error":"m","ParseError.Temporary":"m","ParseError.Timeout":"m","ParseIP":"f","ParseMAC":"f","Pipe":"f","ResolveIPAddr":"f","ResolveTCPAddr":"f","ResolveUDPAddr":"f","ResolveUnixAddr":"f","Resolver":"t","Resolver.LookupAddr":"m","Resolver.LookupCNAME":"m","Resolver.LookupHost":"m","Resolver.LookupIP":"m","Resolver.LookupIPAddr":"m","Resolver.LookupMX":"m","Resolver.LookupNS":"m","Resolver.LookupNetIP":"m","Resolver.LookupPort":"m","Resolver.LookupSRV":"m","Resolver.LookupTXT":"m","SRV":"t","SplitHostPort":"f","TCPAddr":"t","TCPAddr.AddrPort":"m","TCPAddr.Network":"m","TCPAddr.String":"m","TCPAddrFromAddrPort":"f","TCPConn":"t","TCPConn.CloseRead":"m","TCPConn.CloseWrite":"m","TCPConn.MultipathTCP":"m","TCPConn.ReadFrom":"m","TCPConn.SetKeepAlive":"m","TCPConn.SetKeepAliveConfig":"m","TCPConn.SetKeepAlivePeriod":"m","TCPConn.SetLinger":"m","TCPConn.SetNoDelay":"m","TCPConn.SyscallConn":"m","TCPConn.WriteTo":"m","TCPListener":"t","TCPListener.Accept":"m","TCPListener.AcceptTCP":"m","TCPListener.Addr":"m","TCPListener.Close":"m","TCPListener.File":"m","TCPListener.SetDeadline":"m","TCPListener.SyscallConn":"m","UDPAddr":"t","UDPAddr.AddrPort":"m","UDPAddr.Network":"m","UDPAddr.String":"m","UDPAddrFromAddrPort":"f","UDPConn":"t","UDPConn.ReadFrom":"m","UDPConn.ReadFromUDP":"m","UDPConn.ReadFromUDPAddrPort":"m","UDPConn.ReadMsgUDP":"m","UDPConn.ReadMsgUDPAddrPort":"m","UDPConn.SyscallConn":"m","UDPConn.WriteMsgUDP":"m","UDPConn.WriteMsgUDPAddrPort":"m","UDPConn.WriteTo":"m","UDPConn.WriteToUDP":"m","UDPConn.WriteToUDPAddrPort":"m","UnixAddr":"t","UnixAddr.Network":"m","UnixAddr.String":"m","UnixConn":"t","UnixConn.CloseRead":"m","UnixConn.CloseWrite":"m","UnixConn.ReadFrom":"m","UnixConn.ReadFromUnix":"m","UnixConn.ReadMsgUnix":"m","UnixConn.SyscallConn":"m","UnixConn.WriteMsgUnix":"m","UnixConn.WriteTo":"m","UnixConn.WriteToUnix":"m","UnixListener":"t","UnixListener.Accept":"m","UnixListener.AcceptUnix":"m","UnixListener.Addr":"m","UnixListener.Close":"m","UnixListener.File":"m","UnixListener.SetDeadline":"m","UnixListener.SetUnlinkOnClose":"m","UnixListener.SyscallConn":"m","UnknownNetworkError":"t","UnknownNetworkError.Error":"m","UnknownNetworkError.Temporary":"m","UnknownNetworkError.Timeout":"m"}},"net/http":{"path":"net/http","name":"http","symbols":{"AllowQuerySemicolons":"f","CanonicalHeaderKey":"f","Client":"t","Client.CloseIdleConnections":"m","Client.Do":"m","Client.Get":"m","Client.Head":"m","Client.Post":"m","Client.PostForm":"m","ClientConn":"t","ClientConn.Available":"m","ClientConn.Close":"m","ClientConn.Err":"m","ClientConn.InFlight":"m","ClientConn.Release":"m","ClientConn.Reserve":"m","ClientConn.RoundTrip":"m","ClientConn.SetStateHook":"m","CloseNotifier":"t","ConnState":"t","ConnState.String":"m","Cookie":"t","Cookie.String":"m","Cookie.Valid":"m","CookieJar":"t","CrossOriginProtection":"t","CrossOriginProtection.AddInsecureBypassPattern":"m","CrossOriginProtection.AddTrustedOrigin":"m","CrossOriginProtection.Check":"m","CrossOriginProtection.Handler":"m","CrossOriginProtection.SetDenyHandler":"m","DefaultClient":"v","DefaultMaxHeaderBytes":"c","DefaultMaxHeaderValueCount":"c","DefaultMaxIdleConnsPerHost":"c","DefaultServeMux":"v","DefaultTransport":"v","DetectContentType":"f","Dir":"t","Dir.Open":"m","ErrAbortHandler":"v","ErrBodyNotAllowed":"v","ErrBodyReadAfterClose":"v","ErrContentLength":"v","ErrHandlerTimeout":"v","ErrHeaderTooLong":"v","ErrHijacked":"v","ErrLineTooLong":"v","ErrMissingBoundary":"v","ErrMissingContentLength":"v","ErrMissingFile":"v","ErrNoCookie":"v","ErrNoLocation":"v","ErrNotMultipart":"v","ErrNotSupported":"v","ErrSchemeMismatch":"v","ErrServerClosed":"v","ErrShortBody":"v","ErrSkipAltProtocol":"v","ErrUnexpectedTrailer":"v","ErrUseLastResponse":"v","ErrWriteAfterFlush":"v","Error":"f","FS":"f","File":"t","FileServer":"f","FileServerFS":"f","FileSystem":"t","Flusher":"t","Get":"f","HTTP2Config":"t","Handle":"f","HandleFunc":"f","Handler":"t","HandlerFunc":"t","HandlerFunc.ServeHTTP":"m","Head":"f","Header":"t","Header.Add":"m","Header.Clone":"m","Header.Del":"m","Header.Get":"m","Header.Set":"m","Header.Values":"m","Header.Write":"m","Header.WriteSubset":"m","Hijacker":"t","ListenAndServe":"f","ListenAndServeTLS":"f","LocalAddrContextKey":"v","MaxBytesError":"t","MaxBytesError.Error":"m","MaxBytesHandler":"f","MaxBytesReader":"f","MethodConnect":"c","MethodDelete":"c","MethodGet":"c","MethodHead":"c","MethodOptions":"c","MethodPatch":"c","MethodPost":"c","MethodPut":"c","MethodTrace":"c","NewCrossOriginProtection":"f","NewFileTransport":"f","NewFileTransportFS":"f","NewRequest":"f","NewRequestWithContext":"f","NewResponseController":"f","NewServeMux":"f","NoBody":"v","NotFound":"f","NotFoundHandler":"f","ParseCookie":"f","ParseHTTPVersion":"f","ParseSetCookie":"f","ParseTime":"f","Post":"f","PostForm":"f","ProtocolError":"t","ProtocolError.Error":"m","ProtocolError.Is":"m","Protocols":"t","Protocols.HTTP1":"m","Protocols.HTTP2":"m","Protocols.SetHTTP1":"m","Protocols.SetHTTP2":"m","Protocols.SetUnencryptedHTTP2":"m","Protocols.String":"m","Protocols.UnencryptedHTTP2":"m","ProxyFromEnvironment":"f","ProxyURL":"f","PushOptions":"t","Pusher":"t","ReadRequest":"f","ReadResponse":"f","Redirect":"f","RedirectHandler":"f","Request":"t","Request.AddCookie":"m","Request.BasicAuth":"m","Request.Clone":"m","Request.Context":"m","Request.Cookie":"m","Request.Cookies":"m","Request.CookiesNamed":"m","Request.FormFile":"m","Request.FormValue":"m","Request.MultipartReader":"m","Request.ParseForm":"m","Request.ParseMultipartForm":"m","Request.PathValue":"m","Request.PostFormValue":"m","Request.ProtoAtLeast":"m","Request.Referer":"m","Request.SetBasicAuth":"m","Request.SetPathValue":"m","Request.UserAgent":"m","Request.WithContext":"m","Request.Write":"m","Request.WriteProxy":"m","Response":"t","Response.Cookies":"m","Response.Location":"m","Response.ProtoAtLeast":"m","Response.Write":"m","ResponseController":"t","ResponseController.EnableFullDuplex":"m","ResponseController.Flush":"m","ResponseController.Hijack":"m","ResponseController.SetReadDeadline":"m","ResponseController.SetWriteDeadline":"m","ResponseWriter":"t","RoundTripper":"t","SameSite":"t","SameSiteDefaultMode":"c","SameSiteLaxMode":"c","SameSiteNoneMode":"c","SameSiteStrictMode":"c","Serve":"f","ServeContent":"f","ServeFile":"f","ServeFileFS":"f","ServeMux":"t","ServeMux.Handle":"m","ServeMux.HandleFunc":"m","ServeMux.Handler":"m","ServeMux.ServeHTTP":"m","ServeTLS":"f","Server":"t","Server.Close":"m","Server.ListenAndServe":"m","Server.ListenAndServeTLS":"m","Server.RegisterOnShutdown":"m","Server.Serve":"m","Server.ServeTLS":"m","Server.SetKeepAlivesEnabled":"m","Server.Shutdown":"m","ServerContextKey":"v","SetCookie":"f","StateActive":"c","StateClosed":"c","StateHijacked":"c","StateIdle":"c","StateNew":"c","StatusAccepted":"c","StatusAlreadyReported":"c","StatusBadGateway":"c","StatusBadRequest":"c","StatusConflict":"c","StatusContinue":"c","StatusCreated":"c","StatusEarlyHints":"c","StatusExpectationFailed":"c","StatusFailedDependency":"c","StatusForbidden":"c","StatusFound":"c","StatusGatewayTimeout":"c","StatusGone":"c","StatusHTTPVersionNotSupported":"c","StatusIMUsed":"c","StatusInsufficientStorage":"c","StatusInternalServerError":"c","StatusLengthRequired":"c","StatusLocked":"c","StatusLoopDetected":"c","StatusMethodNotAllowed":"c","StatusMisdirectedRequest":"c","StatusMovedPermanently":"c","StatusMultiStatus":"c","StatusMultipleChoices":"c","StatusNetworkAuthenticationRequired":"c","StatusNoContent":"c","StatusNonAuthoritativeInfo":"c","StatusNotAcceptable":"c","StatusNotExtended":"c","StatusNotFound":"c","StatusNotImplemented":"c","StatusNotModified":"c","StatusOK":"c","StatusPartialContent":"c","StatusPaymentRequired":"c","StatusPermanentRedirect":"c","StatusPreconditionFailed":"c","StatusPreconditionRequired":"c","StatusProcessing":"c","StatusProxyAuthRequired":"c","StatusRequestEntityTooLarge":"c","StatusRequestHeaderFieldsTooLarge":"c","StatusRequestTimeout":"c","StatusRequestURITooLong":"c","StatusRequestedRangeNotSatisfiable":"c","StatusResetContent":"c","StatusSeeOther":"c","StatusServiceUnavailable":"c","StatusSwitchingProtocols":"c","StatusTeapot":"c","StatusTemporaryRedirect":"c","StatusText":"f","StatusTooEarly":"c","StatusTooManyRequests":"c","StatusUnauthorized":"c","StatusUnavailableForLegalReasons":"c","StatusUnprocessableEntity":"c","StatusUnsupportedMediaType":"c","StatusUpgradeRequired":"c","StatusUseProxy":"c","StatusVariantAlsoNegotiates":"c","StripPrefix":"f","TimeFormat":"c","TimeoutHandler":"f","TrailerPrefix":"c","Transport":"t","Transport.CancelRequest":"m","Transport.Clone":"m","Transport.CloseIdleConnections":"m","Transport.NewClientConn":"m","Transport.RegisterProtocol":"m","Transport.RoundTrip":"m"}},"net/http/cgi":{"path":"net/http/cgi","name":"cgi","symbols":{"Handler":"t","Handler.ServeHTTP":"m","Request":"f","RequestFromMap":"f","Serve":"f"}},"net/http/cookiejar":{"path":"net/http/cookiejar","name":"cookiejar","symbols":{"Jar":"t","Jar.Cookies":"m","Jar.SetCookies":"m","New":"f","Options":"t","PublicSuffixList":"t"}},"net/http/fcgi":{"path":"net/http/fcgi","name":"fcgi","symbols":{"ErrConnClosed":"v","ErrRequestAborted":"v","ProcessEnv":"f","Serve":"f"}},"net/http/httptest":{"path":"net/http/httptest","name":"httptest","symbols":{"DefaultRemoteAddr":"c","NewRecorder":"f","NewRequest":"f","NewRequestWithContext":"f","NewServer":"f","NewTLSServer":"f","NewTestServer":"f","NewUnstartedServer":"f","ResponseRecorder":"t","ResponseRecorder.Flush":"m","ResponseRecorder.Header":"m","ResponseRecorder.Result":"m","ResponseRecorder.Write":"m","ResponseRecorder.WriteHeader":"m","ResponseRecorder.WriteString":"m","Server":"t","Server.Certificate":"m","Server.Client":"m","Server.Close":"m","Server.CloseClientConnections":"m","Server.Start":"m","Server.StartTLS":"m"}},"net/http/httptrace":{"path":"net/http/httptrace","name":"httptrace","symbols":{"ClientTrace":"t","ContextClientTrace":"f","DNSDoneInfo":"t","DNSStartInfo":"t","GotConnInfo":"t","WithClientTrace":"f","WroteRequestInfo":"t"}},"net/http/httputil":{"path":"net/http/httputil","name":"httputil","symbols":{"BufferPool":"t","ClientConn":"t","ClientConn.Close":"m","ClientConn.Do":"m","ClientConn.Hijack":"m","ClientConn.Pending":"m","ClientConn.Read":"m","ClientConn.Write":"m","DumpRequest":"f","DumpRequestOut":"f","DumpResponse":"f","ErrClosed":"v","ErrLineTooLong":"v","ErrPersistEOF":"v","ErrPipeline":"v","NewChunkedReader":"f","NewChunkedWriter":"f","NewClientConn":"f","NewProxyClientConn":"f","NewServerConn":"f","NewSingleHostReverseProxy":"f","ProxyRequest":"t","ProxyRequest.SetURL":"m","ProxyRequest.SetXForwarded":"m","ReverseProxy":"t","ReverseProxy.ServeHTTP":"m","ServerConn":"t","ServerConn.Close":"m","ServerConn.Hijack":"m","ServerConn.Pending":"m","ServerConn.Read":"m","ServerConn.Write":"m"}},"net/http/pprof":{"path":"net/http/pprof","name":"pprof","symbols":{"Cmdline":"f","Handler":"f","Index":"f","Profile":"f","Symbol":"f","Trace":"f"}},"net/mail":{"path":"net/mail","name":"mail","symbols":{"Address":"t","Address.String":"m","AddressParser":"t","AddressParser.Parse":"m","AddressParser.ParseList":"m","ErrHeaderNotPresent":"v","Header":"t","Header.AddressList":"m","Header.Date":"m","Header.Get":"m","Message":"t","ParseAddress":"f","ParseAddressList":"f","ParseDate":"f","ReadMessage":"f"}},"net/netip":{"path":"net/netip","name":"netip","symbols":{"Addr":"t","Addr.AppendBinary":"m","Addr.AppendText":"m","Addr.AppendTo":"m","Addr.As16":"m","Addr.As4":"m","Addr.AsSlice":"m","Addr.BitLen":"m","Addr.Compare":"m","Addr.Is4":"m","Addr.Is4In6":"m","Addr.Is6":"m","Addr.IsGlobalUnicast":"m","Addr.IsInterfaceLocalMulticast":"m","Addr.IsLinkLocalMulticast":"m","Addr.IsLinkLocalUnicast":"m","Addr.IsLoopback":"m","Addr.IsMulticast":"m","Addr.IsPrivate":"m","Addr.IsUnspecified":"m","Addr.IsValid":"m","Addr.Less":"m","Addr.MarshalBinary":"m","Addr.MarshalText":"m","Addr.Next":"m","Addr.Prefix":"m","Addr.Prev":"m","Addr.String":"m","Addr.StringExpanded":"m","Addr.Unmap":"m","Addr.UnmarshalBinary":"m","Addr.UnmarshalText":"m","Addr.WithZone":"m","Addr.Zone":"m","AddrFrom16":"f","AddrFrom4":"f","AddrFromSlice":"f","AddrPort":"t","AddrPort.Addr":"m","AddrPort.AppendBinary":"m","AddrPort.AppendText":"m","AddrPort.AppendTo":"m","AddrPort.Compare":"m","AddrPort.IsValid":"m","AddrPort.MarshalBinary":"m","AddrPort.MarshalText":"m","AddrPort.Port":"m","AddrPort.String":"m","AddrPort.UnmarshalBinary":"m","AddrPort.UnmarshalText":"m","AddrPortFrom":"f","IPv4Unspecified":"f","IPv6LinkLocalAllNodes":"f","IPv6LinkLocalAllRouters":"f","IPv6Loopback":"f","IPv6Unspecified":"f","MustParseAddr":"f","MustParseAddrPort":"f","MustParsePrefix":"f","ParseAddr":"f","ParseAddrPort":"f","ParsePrefix":"f","Prefix":"t","Prefix.Addr":"m","Prefix.AppendBinary":"m","Prefix.AppendText":"m","Prefix.AppendTo":"m","Prefix.Bits":"m","Prefix.Compare":"m","Prefix.Contains":"m","Prefix.IsSingleIP":"m","Prefix.IsValid":"m","Prefix.MarshalBinary":"m","Prefix.MarshalText":"m","Prefix.Masked":"m","Prefix.Overlaps":"m","Prefix.String":"m","Prefix.UnmarshalBinary":"m","Prefix.UnmarshalText":"m","PrefixFrom":"f"}},"net/rpc":{"path":"net/rpc","name":"rpc","symbols":{"Accept":"f","Call":"t","Client":"t","Client.Call":"m","Client.Close":"m","Client.Go":"m","ClientCodec":"t","DefaultDebugPath":"c","DefaultRPCPath":"c","DefaultServer":"v","Dial":"f","DialHTTP":"f","DialHTTPPath":"f","ErrShutdown":"v","HandleHTTP":"f","NewClient":"f","NewClientWithCodec":"f","NewServer":"f","Register":"f","RegisterName":"f","Request":"t","Response":"t","ServeCodec":"f","ServeConn":"f","ServeRequest":"f","Server":"t","Server.Accept":"m","Server.HandleHTTP":"m","Server.Register":"m","Server.RegisterName":"m","Server.ServeCodec":"m","Server.ServeConn":"m","Server.ServeHTTP":"m","Server.ServeRequest":"m","ServerCodec":"t","ServerError":"t","ServerError.Error":"m"}},"net/rpc/jsonrpc":{"path":"net/rpc/jsonrpc","name":"jsonrpc","symbols":{"Dial":"f","NewClient":"f","NewClientCodec":"f","NewServerCodec":"f","ServeConn":"f"}},"net/smtp":{"path":"net/smtp","name":"smtp","symbols":{"Auth":"t","CRAMMD5Auth":"f","Client":"t","Client.Auth":"m","Client.Close":"m","Client.Data":"m","Client.Extension":"m","Client.Hello":"m","Client.Mail":"m","Client.Noop":"m","Client.Quit":"m","Client.Rcpt":"m","Client.Reset":"m","Client.StartTLS":"m","Client.TLSConnectionState":"m","Client.Verify":"m","Dial":"f","NewClient":"f","PlainAuth":"f","SendMail":"f","ServerInfo":"t"}},"net/textproto":{"path":"net/textproto","name":"textproto","symbols":{"CanonicalMIMEHeaderKey":"f","Conn":"t","Conn.Close":"m","Conn.Cmd":"m","Dial":"f","Error":"t","Error.Error":"m","MIMEHeader":"t","MIMEHeader.Add":"m","MIMEHeader.Del":"m","MIMEHeader.Get":"m","MIMEHeader.Set":"m","MIMEHeader.Values":"m","NewConn":"f","NewReader":"f","NewWriter":"f","Pipeline":"t","Pipeline.EndRequest":"m","Pipeline.EndResponse":"m","Pipeline.Next":"m","Pipeline.StartRequest":"m","Pipeline.StartResponse":"m","ProtocolError":"t","ProtocolError.Error":"m","Reader":"t","Reader.DotReader":"m","Reader.ReadCodeLine":"m","Reader.ReadContinuedLine":"m","Reader.ReadContinuedLineBytes":"m","Reader.ReadDotBytes":"m","Reader.ReadDotLines":"m","Reader.ReadLine":"m","Reader.ReadLineBytes":"m","Reader.ReadMIMEHeader":"m","Reader.ReadResponse":"m","TrimBytes":"f","TrimString":"f","Writer":"t","Writer.DotWriter":"m","Writer.PrintfLine":"m"}},"net/url":{"path":"net/url","name":"url","symbols":{"Error":"t","Error.Error":"m","Error.Temporary":"m","Error.Timeout":"m","Error.Unwrap":"m","EscapeError":"t","EscapeError.Error":"m","InvalidHostError":"t","InvalidHostError.Error":"m","JoinPath":"f","Parse":"f","ParseQuery":"f","ParseRequestURI":"f","PathEscape":"f","PathUnescape":"f","QueryEscape":"f","QueryUnescape":"f","URL":"t","URL.AppendBinary":"m","URL.Clone":"m","URL.EscapedFragment":"m","URL.EscapedPath":"m","URL.Hostname":"m","URL.IsAbs":"m","URL.JoinPath":"m","URL.MarshalBinary":"m","URL.Parse":"m","URL.Port":"m","URL.Query":"m","URL.Redacted":"m","URL.RequestURI":"m","URL.ResolveReference":"m","URL.String":"m","URL.UnmarshalBinary":"m","User":"f","UserPassword":"f","Userinfo":"t","Userinfo.Password":"m","Userinfo.String":"m","Userinfo.Username":"m","Values":"t","Values.Add":"m","Values.Clone":"m","Values.Del":"m","Values.Encode":"m","Values.Get":"m","Values.Has":"m","Values.Set":"m"}},"os":{"path":"os","name":"os","symbols":{"Args":"v","Chdir":"f","Chmod":"f","Chown":"f","Chtimes":"f","Clearenv":"f","CopyFS":"f","Create":"f","CreateTemp":"f","DevNull":"c","DirEntry":"t","DirFS":"f","Environ":"f","ErrClosed":"v","ErrDeadlineExceeded":"v","ErrExist":"v","ErrInvalid":"v","ErrNoDeadline":"v","ErrNoHandle":"v","ErrNotExist":"v","ErrPermission":"v","ErrProcessDone":"v","Executable":"f","Exit":"f","Expand":"f","ExpandEnv":"f","File":"t","File.Chdir":"m","File.Chmod":"m","File.Chown":"m","File.Close":"m","File.Fd":"m","File.Name":"m","File.Read":"m","File.ReadAt":"m","File.ReadDir":"m","File.ReadFrom":"m","File.Readdir":"m","File.Readdirnames":"m","File.Seek":"m","File.SetDeadline":"m","File.SetReadDeadline":"m","File.SetWriteDeadline":"m","File.Stat":"m","File.Sync":"m","File.SyscallConn":"m","File.Truncate":"m","File.Write":"m","File.WriteAt":"m","File.WriteString":"m","File.WriteTo":"m","FileInfo":"t","FileMode":"t","FindProcess":"f","Getegid":"f","Getenv":"f","Geteuid":"f","Getgid":"f","Getgroups":"f","Getpagesize":"f","Getpid":"f","Getppid":"f","Getuid":"f","Getwd":"f","Hostname":"f","Interrupt":"v","IsExist":"f","IsNotExist":"f","IsPathSeparator":"f","IsPermission":"f","IsTimeout":"f","Kill":"v","Lchown":"f","Link":"f","LinkError":"t","LinkError.Error":"m","LinkError.Unwrap":"m","LookupEnv":"f","Lstat":"f","Mkdir":"f","MkdirAll":"f","MkdirTemp":"f","ModeAppend":"c","ModeCharDevice":"c","ModeDevice":"c","ModeDir":"c","ModeExclusive":"c","ModeIrregular":"c","ModeNamedPipe":"c","ModePerm":"c","ModeSetgid":"c","ModeSetuid":"c","ModeSocket":"c","ModeSticky":"c","ModeSymlink":"c","ModeTemporary":"c","ModeType":"c","NewFile":"f","NewSyscallError":"f","O_APPEND":"c","O_CREATE":"c","O_EXCL":"c","O_RDONLY":"c","O_RDWR":"c","O_SYNC":"c","O_TRUNC":"c","O_WRONLY":"c","Open":"f","OpenFile":"f","OpenInRoot":"f","OpenRoot":"f","PathError":"t","PathListSeparator":"c","PathSeparator":"c","Pipe":"f","ProcAttr":"t","Process":"t","Process.Kill":"m","Process.Release":"m","Process.Signal":"m","Process.Wait":"m","Process.WithHandle":"m","ProcessState":"t","ProcessState.ExitCode":"m","ProcessState.Exited":"m","ProcessState.Pid":"m","ProcessState.String":"m","ProcessState.Success":"m","ProcessState.Sys":"m","ProcessState.SysUsage":"m","ProcessState.SystemTime":"m","ProcessState.UserTime":"m","ReadDir":"f","ReadFile":"f","Readlink":"f","Remove":"f","RemoveAll":"f","Rename":"f","Root":"t","Root.Chmod":"m","Root.Chown":"m","Root.Chtimes":"m","Root.Close":"m","Root.Create":"m","Root.FS":"m","Root.Lchown":"m","Root.Link":"m","Root.Lstat":"m","Root.Mkdir":"m","Root.MkdirAll":"m","Root.Name":"m","Root.Open":"m","Root.OpenFile":"m","Root.OpenRoot":"m","Root.ReadFile":"m","Root.Readlink":"m","Root.Remove":"m","Root.RemoveAll":"m","Root.Rename":"m","Root.Stat":"m","Root.Symlink":"m","Root.WriteFile":"m","SEEK_CUR":"c","SEEK_END":"c","SEEK_SET":"c","SameFile":"f","Setenv":"f","Signal":"t","StartProcess":"f","Stat":"f","Stderr":"v","Stdin":"v","Stdout":"v","Symlink":"f","SyscallError":"t","SyscallError.Error":"m","SyscallError.Timeout":"m","SyscallError.Unwrap":"m","TempDir":"f","Truncate":"f","Unsetenv":"f","UserCacheDir":"f","UserConfigDir":"f","UserHomeDir":"f","WriteFile":"f"}},"os/exec":{"path":"os/exec","name":"exec","symbols":{"Cmd":"t","Cmd.CombinedOutput":"m","Cmd.Environ":"m","Cmd.Output":"m","Cmd.Run":"m","Cmd.Start":"m","Cmd.StderrPipe":"m","Cmd.StdinPipe":"m","Cmd.StdoutPipe":"m","Cmd.String":"m","Cmd.Wait":"m","Command":"f","CommandContext":"f","ErrDot":"v","ErrNotFound":"v","ErrWaitDelay":"v","Error":"t","Error.Error":"m","Error.Unwrap":"m","ExitError":"t","ExitError.Error":"m","LookPath":"f"}},"os/signal":{"path":"os/signal","name":"signal","symbols":{"Ignore":"f","Ignored":"f","Notify":"f","NotifyContext":"f","Reset":"f","Stop":"f"}},"os/user":{"path":"os/user","name":"user","symbols":{"Current":"f","Group":"t","Lookup":"f","LookupGroup":"f","LookupGroupId":"f","LookupId":"f","UnknownGroupError":"t","UnknownGroupError.Error":"m","UnknownGroupIdError":"t","UnknownGroupIdError.Error":"m","UnknownUserError":"t","UnknownUserError.Error":"m","UnknownUserIdError":"t","UnknownUserIdError.Error":"m","User":"t","User.GroupIds":"m"}},"path":{"path":"path","name":"path","symbols":{"Base":"f","Clean":"f","Dir":"f","ErrBadPattern":"v","Ext":"f","IsAbs":"f","Join":"f","Match":"f","Split":"f"}},"path/filepath":{"path":"path/filepath","name":"filepath","symbols":{"Abs":"f","Base":"f","Clean":"f","Dir":"f","ErrBadPattern":"v","EvalSymlinks":"f","Ext":"f","FromSlash":"f","Glob":"f","HasPrefix":"f","IsAbs":"f","IsLocal":"f","Join":"f","ListSeparator":"c","Localize":"f","Match":"f","Rel":"f","Separator":"c","SkipAll":"v","SkipDir":"v","Split":"f","SplitList":"f","ToSlash":"f","VolumeName":"f","Walk":"f","WalkDir":"f","WalkFunc":"t"}},"plugin":{"path":"plugin","name":"plugin","symbols":{"Open":"f","Plugin":"t","Plugin.Lookup":"m","Symbol":"t"}},"reflect":{"path":"reflect","name":"reflect","symbols":{"Append":"f","AppendSlice":"f","Array":"c","ArrayOf":"f","Bool":"c","BothDir":"c","Chan":"c","ChanDir":"t","ChanDir.String":"m","ChanOf":"f","Complex128":"c","Complex64":"c","Copy":"f","DeepEqual":"f","Float32":"c","Float64":"c","Func":"c","FuncOf":"f","Indirect":"f","Int":"c","Int16":"c","Int32":"c","Int64":"c","Int8":"c","Interface":"c","Invalid":"c","Kind":"t","Kind.String":"m","MakeChan":"f","MakeFunc":"f","MakeMap":"f","MakeMapWithSize":"f","MakeSlice":"f","Map":"c","MapIter":"t","MapIter.Key":"m","MapIter.Next":"m","MapIter.Reset":"m","MapIter.Value":"m","MapOf":"f","Method":"t","Method.IsExported":"m","New":"f","NewAt":"f","Pointer":"c","PointerTo":"f","Ptr":"c","PtrTo":"f","RecvDir":"c","Select":"f","SelectCase":"t","SelectDefault":"c","SelectDir":"t","SelectRecv":"c","SelectSend":"c","SendDir":"c","Slice":"c","SliceAt":"f","SliceHeader":"t","SliceOf":"f","String":"c","StringHeader":"t","Struct":"c","StructField":"t","StructField.IsExported":"m","StructOf":"f","StructTag":"t","StructTag.Get":"m","StructTag.Lookup":"m","Swapper":"f","Type":"t","TypeAssert":"f","TypeFor":"f","TypeOf":"f","Uint":"c","Uint16":"c","Uint32":"c","Uint64":"c","Uint8":"c","Uintptr":"c","UnsafePointer":"c","Value":"t","Value.Addr":"m","Value.Bool":"m","Value.Bytes":"m","Value.Call":"m","Value.CallSlice":"m","Value.CanAddr":"m","Value.CanComplex":"m","Value.CanConvert":"m","Value.CanFloat":"m","Value.CanInt":"m","Value.CanInterface":"m","Value.CanSet":"m","Value.CanUint":"m","Value.Cap":"m","Value.Clear":"m","Value.Close":"m","Value.Comparable":"m","Value.Complex":"m","Value.Convert":"m","Value.Elem":"m","Value.Equal":"m","Value.Field":"m","Value.FieldByIndex":"m","Value.FieldByIndexErr":"m","Value.FieldByName":"m","Value.FieldByNameFunc":"m","Value.Fields":"m","Value.Float":"m","Value.Grow":"m","Value.Index":"m","Value.Int":"m","Value.Interface":"m","Value.InterfaceData":"m","Value.IsNil":"m","Value.IsValid":"m","Value.IsZero":"m","Value.Kind":"m","Value.Len":"m","Value.MapIndex":"m","Value.MapKeys":"m","Value.MapRange":"m","Value.Method":"m","Value.MethodByName":"m","Value.Methods":"m","Value.NumField":"m","Value.NumMethod":"m","Value.OverflowComplex":"m","Value.OverflowFloat":"m","Value.OverflowInt":"m","Value.OverflowUint":"m","Value.Pointer":"m","Value.Recv":"m","Value.Send":"m","Value.Seq":"m","Value.Seq2":"m","Value.Set":"m","Value.SetBool":"m","Value.SetBytes":"m","Value.SetCap":"m","Value.SetComplex":"m","Value.SetFloat":"m","Value.SetInt":"m","Value.SetIterKey":"m","Value.SetIterValue":"m","Value.SetLen":"m","Value.SetMapIndex":"m","Value.SetPointer":"m","Value.SetString":"m","Value.SetUint":"m","Value.SetZero":"m","Value.Slice":"m","Value.Slice3":"m","Value.String":"m","Value.TryRecv":"m","Value.TrySend":"m","Value.Type":"m","Value.Uint":"m","Value.UnsafeAddr":"m","Value.UnsafePointer":"m","ValueError":"t","ValueError.Error":"m","ValueOf":"f","VisibleFields":"f","Zero":"f"}},"regexp":{"path":"regexp","name":"regexp","symbols":{"Compile":"f","CompilePOSIX":"f","Match":"f","MatchReader":"f","MatchString":"f","MustCompile":"f","MustCompilePOSIX":"f","QuoteMeta":"f","Regexp":"t","Regexp.AppendText":"m","Regexp.Copy":"m","Regexp.Expand":"m","Regexp.ExpandString":"m","Regexp.Find":"m","Regexp.FindAll":"m","Regexp.FindAllIndex":"m","Regexp.FindAllString":"m","Regexp.FindAllStringIndex":"m","Regexp.FindAllStringSubmatch":"m","Regexp.FindAllStringSubmatchIndex":"m","Regexp.FindAllSubmatch":"m","Regexp.FindAllSubmatchIndex":"m","Regexp.FindIndex":"m","Regexp.FindReaderIndex":"m","Regexp.FindReaderSubmatchIndex":"m","Regexp.FindString":"m","Regexp.FindStringIndex":"m","Regexp.FindStringSubmatch":"m","Regexp.FindStringSubmatchIndex":"m","Regexp.FindSubmatch":"m","Regexp.FindSubmatchIndex":"m","Regexp.LiteralPrefix":"m","Regexp.Longest":"m","Regexp.MarshalText":"m","Regexp.Match":"m","Regexp.MatchReader":"m","Regexp.MatchString":"m","Regexp.NumSubexp":"m","Regexp.ReplaceAll":"m","Regexp.ReplaceAllFunc":"m","Regexp.ReplaceAllLiteral":"m","Regexp.ReplaceAllLiteralString":"m","Regexp.ReplaceAllString":"m","Regexp.ReplaceAllStringFunc":"m","Regexp.Split":"m","Regexp.String":"m","Regexp.SubexpIndex":"m","Regexp.SubexpNames":"m","Regexp.UnmarshalText":"m"}},"regexp/syntax":{"path":"regexp/syntax","name":"syntax","symbols":{"ClassNL":"c","Compile":"f","DotNL":"c","EmptyBeginLine":"c","EmptyBeginText":"c","EmptyEndLine":"c","EmptyEndText":"c","EmptyNoWordBoundary":"c","EmptyOp":"t","EmptyOpContext":"f","EmptyWordBoundary":"c","ErrInternalError":"c","ErrInvalidCharClass":"c","ErrInvalidCharRange":"c","ErrInvalidEscape":"c","ErrInvalidNamedCapture":"c","ErrInvalidPerlOp":"c","ErrInvalidRepeatOp":"c","ErrInvalidRepeatSize":"c","ErrInvalidUTF8":"c","ErrLarge":"c","ErrMissingBracket":"c","ErrMissingParen":"c","ErrMissingRepeatArgument":"c","ErrNestingDepth":"c","ErrTrailingBackslash":"c","ErrUnexpectedParen":"c","Error":"t","Error.Error":"m","ErrorCode":"t","ErrorCode.String":"m","Flags":"t","FoldCase":"c","Inst":"t","Inst.MatchEmptyWidth":"m","Inst.MatchRune":"m","Inst.MatchRunePos":"m","Inst.String":"m","InstAlt":"c","InstAltMatch":"c","InstCapture":"c","InstEmptyWidth":"c","InstFail":"c","InstMatch":"c","InstNop":"c","InstOp":"t","InstOp.String":"m","InstRune":"c","InstRune1":"c","InstRuneAny":"c","InstRuneAnyNotNL":"c","IsWordChar":"f","Literal":"c","MatchNL":"c","NonGreedy":"c","OneLine":"c","Op":"t","Op.String":"m","OpAlternate":"c","OpAnyChar":"c","OpAnyCharNotNL":"c","OpBeginLine":"c","OpBeginText":"c","OpCapture":"c","OpCharClass":"c","OpConcat":"c","OpEmptyMatch":"c","OpEndLine":"c","OpEndText":"c","OpLiteral":"c","OpNoMatch":"c","OpNoWordBoundary":"c","OpPlus":"c","OpQuest":"c","OpRepeat":"c","OpStar":"c","OpWordBoundary":"c","POSIX":"c","Parse":"f","Perl":"c","PerlX":"c","Prog":"t","Prog.Prefix":"m","Prog.StartCond":"m","Prog.String":"m","Regexp":"t","Regexp.CapNames":"m","Regexp.Equal":"m","Regexp.MaxCap":"m","Regexp.Simplify":"m","Regexp.String":"m","Simple":"c","UnicodeGroups":"c","WasDollar":"c"}},"runtime":{"path":"runtime","name":"runtime","symbols":{"AddCleanup":"f","BlockProfile":"f","BlockProfileRecord":"t","Breakpoint":"f","CPUProfile":"f","Caller":"f","Callers":"f","CallersFrames":"f","Cleanup":"t","Cleanup.Stop":"m","Compiler":"c","Error":"t","Frame":"t","Frames":"t","Frames.Next":"m","Func":"t","Func.Entry":"m","Func.FileLine":"m","Func.Name":"m","FuncForPC":"f","GC":"f","GOARCH":"c","GOMAXPROCS":"f","GOOS":"c","GOROOT":"f","Goexit":"f","GoroutineProfile":"f","Gosched":"f","KeepAlive":"f","LockOSThread":"f","MemProfile":"f","MemProfileRate":"v","MemProfileRecord":"t","MemProfileRecord.InUseBytes":"m","MemProfileRecord.InUseObjects":"m","MemProfileRecord.Stack":"m","MemStats":"t","MutexProfile":"f","NumCPU":"f","NumCgoCall":"f","NumGoroutine":"f","PanicNilError":"t","PanicNilError.Error":"m","PanicNilError.RuntimeError":"m","Pinner":"t","Pinner.Pin":"m","Pinner.Unpin":"m","ReadMemStats":"f","ReadTrace":"f","SetBlockProfileRate":"f","SetCPUProfileRate":"f","SetCgoTraceback":"f","SetDefaultGOMAXPROCS":"f","SetFinalizer":"f","SetMutexProfileFraction":"f","Stack":"f","StackRecord":"t","StackRecord.Stack":"m","StartTrace":"f","StopTrace":"f","ThreadCreateProfile":"f","TypeAssertionError":"t","TypeAssertionError.Error":"m","TypeAssertionError.RuntimeError":"m","UnlockOSThread":"f","Version":"f"}},"runtime/cgo":{"path":"runtime/cgo","name":"cgo","symbols":{"Handle":"t","Handle.Delete":"m","Handle.Value":"m","Incomplete":"t","NewHandle":"f"}},"runtime/coverage":{"path":"runtime/coverage","name":"coverage","symbols":{"ClearCounters":"f","WriteCounters":"f","WriteCountersDir":"f","WriteMeta":"f","WriteMetaDir":"f"}},"runtime/debug":{"path":"runtime/debug","name":"debug","symbols":{"BuildInfo":"t","BuildInfo.String":"m","BuildSetting":"t","CrashOptions":"t","FreeOSMemory":"f","GCStats":"t","Module":"t","ParseBuildInfo":"f","PrintStack":"f","ReadBuildInfo":"f","ReadGCStats":"f","SetCrashOutput":"f","SetGCPercent":"f","SetMaxStack":"f","SetMaxThreads":"f","SetMemoryLimit":"f","SetPanicOnFault":"f","SetTraceback":"f","Stack":"f","WriteHeapDump":"f"}},"runtime/metrics":{"path":"runtime/metrics","name":"metrics","symbols":{"All":"f","Description":"t","Float64Histogram":"t","KindBad":"c","KindFloat64":"c","KindFloat64Histogram":"c","KindUint64":"c","Read":"f","Sample":"t","Value":"t","Value.Float64":"m","Value.Float64Histogram":"m","Value.Kind":"m","Value.Uint64":"m","ValueKind":"t"}},"runtime/pprof":{"path":"runtime/pprof","name":"pprof","symbols":{"Do":"f","ForLabels":"f","Label":"f","LabelSet":"t","Labels":"f","Lookup":"f","NewProfile":"f","Profile":"t","Profile.Add":"m","Profile.Count":"m","Profile.Name":"m","Profile.Remove":"m","Profile.WriteTo":"m","Profiles":"f","SetGoroutineLabels":"f","StartCPUProfile":"f","StopCPUProfile":"f","WithLabels":"f","WriteHeapProfile":"f"}},"runtime/trace":{"path":"runtime/trace","name":"trace","symbols":{"FlightRecorder":"t","FlightRecorder.Enabled":"m","FlightRecorder.Start":"m","FlightRecorder.Stop":"m","FlightRecorder.WriteTo":"m","FlightRecorderConfig":"t","IsEnabled":"f","Log":"f","Logf":"f","NewFlightRecorder":"f","NewTask":"f","Region":"t","Region.End":"m","Start":"f","StartRegion":"f","Stop":"f","Task":"t","Task.End":"m","WithRegion":"f"}},"slices":{"path":"slices","name":"slices","symbols":{"All":"f","AppendSeq":"f","Backward":"f","BinarySearch":"f","BinarySearchFunc":"f","Chunk":"f","Clip":"f","Clone":"f","Collect":"f","Compact":"f","CompactFunc":"f","Compare":"f","CompareFunc":"f","Concat":"f","Contains":"f","ContainsFunc":"f","Delete":"f","DeleteFunc":"f","Equal":"f","EqualFunc":"f","Grow":"f","Index":"f","IndexFunc":"f","Insert":"f","IsSorted":"f","IsSortedFunc":"f","Max":"f","MaxFunc":"f","Min":"f","MinFunc":"f","Repeat":"f","Replace":"f","Reverse":"f","Sort":"f","SortFunc":"f","SortStableFunc":"f","Sorted":"f","SortedFunc":"f","SortedStableFunc":"f","Values":"f"}},"sort":{"path":"sort","name":"sort","symbols":{"Find":"f","Float64Slice":"t","Float64Slice.Len":"m","Float64Slice.Less":"m","Float64Slice.Search":"m","Float64Slice.Sort":"m","Float64Slice.Swap":"m","Float64s":"f","Float64sAreSorted":"f","IntSlice":"t","IntSlice.Len":"m","IntSlice.Less":"m","IntSlice.Search":"m","IntSlice.Sort":"m","IntSlice.Swap":"m","Interface":"t","Ints":"f","IntsAreSorted":"f","IsSorted":"f","Reverse":"f","Search":"f","SearchFloat64s":"f","SearchInts":"f","SearchStrings":"f","Slice":"f","SliceIsSorted":"f","SliceStable":"f","Sort":"f","Stable":"f","StringSlice":"t","StringSlice.Len":"m","StringSlice.Less":"m","StringSlice.Search":"m","StringSlice.Sort":"m","StringSlice.Swap":"m","Strings":"f","StringsAreSorted":"f"}},"strconv":{"path":"strconv","name":"strconv","symbols":{"AppendBool":"f","AppendFloat":"f","AppendInt":"f","AppendQuote":"f","AppendQuoteRune":"f","AppendQuoteRuneToASCII":"f","AppendQuoteRuneToGraphic":"f","AppendQuoteToASCII":"f","AppendQuoteToGraphic":"f","AppendUint":"f","Atoi":"f","CanBackquote":"f","ErrRange":"v","ErrSyntax":"v","FormatBool":"f","FormatComplex":"f","FormatFloat":"f","FormatInt":"f","FormatUint":"f","IntSize":"c","IsGraphic":"f","IsPrint":"f","Itoa":"f","NumError":"t","NumError.Error":"m","NumError.Unwrap":"m","ParseBool":"f","ParseComplex":"f","ParseFloat":"f","ParseInt":"f","ParseUint":"f","Quote":"f","QuoteRune":"f","QuoteRuneToASCII":"f","QuoteRuneToGraphic":"f","QuoteToASCII":"f","QuoteToGraphic":"f","QuotedPrefix":"f","Unquote":"f","UnquoteChar":"f"}},"strings":{"path":"strings","name":"strings","symbols":{"Builder":"t","Builder.Cap":"m","Builder.Grow":"m","Builder.Len":"m","Builder.Reset":"m","Builder.String":"m","Builder.Write":"m","Builder.WriteByte":"m","Builder.WriteRune":"m","Builder.WriteString":"m","Clone":"f","Compare":"f","Contains":"f","ContainsAny":"f","ContainsFunc":"f","ContainsRune":"f","Count":"f","Cut":"f","CutLast":"f","CutPrefix":"f","CutSuffix":"f","EqualFold":"f","Fields":"f","FieldsFunc":"f","FieldsFuncSeq":"f","FieldsSeq":"f","HasPrefix":"f","HasSuffix":"f","Index":"f","IndexAny":"f","IndexByte":"f","IndexFunc":"f","IndexRune":"f","Join":"f","LastIndex":"f","LastIndexAny":"f","LastIndexByte":"f","LastIndexFunc":"f","Lines":"f","Map":"f","NewReader":"f","NewReplacer":"f","Reader":"t","Reader.Len":"m","Reader.Read":"m","Reader.ReadAt":"m","Reader.ReadByte":"m","Reader.ReadRune":"m","Reader.Reset":"m","Reader.Seek":"m","Reader.Size":"m","Reader.UnreadByte":"m","Reader.UnreadRune":"m","Reader.WriteTo":"m","Repeat":"f","Replace":"f","ReplaceAll":"f","Replacer":"t","Replacer.Replace":"m","Replacer.WriteString":"m","Split":"f","SplitAfter":"f","SplitAfterN":"f","SplitAfterSeq":"f","SplitN":"f","SplitSeq":"f","Title":"f","ToLower":"f","ToLowerSpecial":"f","ToTitle":"f","ToTitleSpecial":"f","ToUpper":"f","ToUpperSpecial":"f","ToValidUTF8":"f","Trim":"f","TrimFunc":"f","TrimLeft":"f","TrimLeftFunc":"f","TrimPrefix":"f","TrimRight":"f","TrimRightFunc":"f","TrimSpace":"f","TrimSuffix":"f"}},"structs":{"path":"structs","name":"structs","symbols":{"HostLayout":"t"}},"sync":{"path":"sync","name":"sync","symbols":{"Cond":"t","Cond.Broadcast":"m","Cond.Signal":"m","Cond.Wait":"m","Locker":"t","Map":"t","Map.Clear":"m","Map.CompareAndDelete":"m","Map.CompareAndSwap":"m","Map.Delete":"m","Map.Load":"m","Map.LoadAndDelete":"m","Map.LoadOrStore":"m","Map.Range":"m","Map.Store":"m","Map.Swap":"m","Mutex":"t","Mutex.Lock":"m","Mutex.TryLock":"m","Mutex.Unlock":"m","NewCond":"f","Once":"t","Once.Do":"m","OnceFunc":"f","OnceValue":"f","OnceValues":"f","Pool":"t","Pool.Get":"m","Pool.Put":"m","RWMutex":"t","RWMutex.Lock":"m","RWMutex.RLock":"m","RWMutex.RLocker":"m","RWMutex.RUnlock":"m","RWMutex.TryLock":"m","RWMutex.TryRLock":"m","RWMutex.Unlock":"m","WaitGroup":"t","WaitGroup.Add":"m","WaitGroup.Done":"m","WaitGroup.Go":"m","WaitGroup.Wait":"m"}},"sync/atomic":{"path":"sync/atomic","name":"atomic","symbols":{"AddInt32":"f","AddInt64":"f","AddUint32":"f","AddUint64":"f","AddUintptr":"f","AndInt32":"f","AndInt64":"f","AndUint32":"f","AndUint64":"f","AndUintptr":"f","Bool":"t","Bool.CompareAndSwap":"m","Bool.Load":"m","Bool.Store":"m","Bool.Swap":"m","CompareAndSwapInt32":"f","CompareAndSwapInt64":"f","CompareAndSwapPointer":"f","CompareAndSwapUint32":"f","CompareAndSwapUint64":"f","CompareAndSwapUintptr":"f","Int32":"t","Int32.Add":"m","Int32.And":"m","Int32.CompareAndSwap":"m","Int32.Load":"m","Int32.Or":"m","Int32.Store":"m","Int32.Swap":"m","Int64":"t","Int64.Add":"m","Int64.And":"m","Int64.CompareAndSwap":"m","Int64.Load":"m","Int64.Or":"m","Int64.Store":"m","Int64.Swap":"m","LoadInt32":"f","LoadInt64":"f","LoadPointer":"f","LoadUint32":"f","LoadUint64":"f","LoadUintptr":"f","OrInt32":"f","OrInt64":"f","OrUint32":"f","OrUint64":"f","OrUintptr":"f","Pointer":"t","StoreInt32":"f","StoreInt64":"f","StorePointer":"f","StoreUint32":"f","StoreUint64":"f","StoreUintptr":"f","SwapInt32":"f","SwapInt64":"f","SwapPointer":"f","SwapUint32":"f","SwapUint64":"f","SwapUintptr":"f","Uint32":"t","Uint32.Add":"m","Uint32.And":"m","Uint32.CompareAndSwap":"m","Uint32.Load":"m","Uint32.Or":"m","Uint32.Store":"m","Uint32.Swap":"m","Uint64":"t","Uint64.Add":"m","Uint64.And":"m","Uint64.CompareAndSwap":"m","Uint64.Load":"m","Uint64.Or":"m","Uint64.Store":"m","Uint64.Swap":"m","Uintptr":"t","Uintptr.Add":"m","Uintptr.And":"m","Uintptr.CompareAndSwap":"m","Uintptr.Load":"m","Uintptr.Or":"m","Uintptr.Store":"m","Uintptr.Swap":"m","Value":"t","Value.CompareAndSwap":"m","Value.Load":"m","Value.Store":"m","Value.Swap":"m"}},"syscall":{"path":"syscall","name":"syscall","symbols":{"AF_ALG":"c","AF_APPLETALK":"c","AF_ASH":"c","AF_ATMPVC":"c","AF_ATMSVC":"c","AF_AX25":"c","AF_BLUETOOTH":"c","AF_BRIDGE":"c","AF_CAIF":"c","AF_CAN":"c","AF_DECnet":"c","AF_ECONET":"c","AF_FILE":"c","AF_IEEE802154":"c","AF_INET":"c","AF_INET6":"c","AF_IPX":"c","AF_IRDA":"c","AF_ISDN":"c","AF_IUCV":"c","AF_KEY":"c","AF_LLC":"c","AF_LOCAL":"c","AF_MAX":"c","AF_NETBEUI":"c","AF_NETLINK":"c","AF_NETROM":"c","AF_PACKET":"c","AF_PHONET":"c","AF_PPPOX":"c","AF_RDS":"c","AF_ROSE":"c","AF_ROUTE":"c","AF_RXRPC":"c","AF_SECURITY":"c","AF_SNA":"c","AF_TIPC":"c","AF_UNIX":"c","AF_UNSPEC":"c","AF_WANPIPE":"c","AF_X25":"c","ARPHRD_ADAPT":"c","ARPHRD_APPLETLK":"c","ARPHRD_ARCNET":"c","ARPHRD_ASH":"c","ARPHRD_ATM":"c","ARPHRD_AX25":"c","ARPHRD_BIF":"c","ARPHRD_CHAOS":"c","ARPHRD_CISCO":"c","ARPHRD_CSLIP":"c","ARPHRD_CSLIP6":"c","ARPHRD_DDCMP":"c","ARPHRD_DLCI":"c","ARPHRD_ECONET":"c","ARPHRD_EETHER":"c","ARPHRD_ETHER":"c","ARPHRD_EUI64":"c","ARPHRD_FCAL":"c","ARPHRD_FCFABRIC":"c","ARPHRD_FCPL":"c","ARPHRD_FCPP":"c","ARPHRD_FDDI":"c","ARPHRD_FRAD":"c","ARPHRD_HDLC":"c","ARPHRD_HIPPI":"c","ARPHRD_HWX25":"c","ARPHRD_IEEE1394":"c","ARPHRD_IEEE802":"c","ARPHRD_IEEE80211":"c","ARPHRD_IEEE80211_PRISM":"c","ARPHRD_IEEE80211_RADIOTAP":"c","ARPHRD_IEEE802154":"c","ARPHRD_IEEE802154_PHY":"c","ARPHRD_IEEE802_TR":"c","ARPHRD_INFINIBAND":"c","ARPHRD_IPDDP":"c","ARPHRD_IPGRE":"c","ARPHRD_IRDA":"c","ARPHRD_LAPB":"c","ARPHRD_LOCALTLK":"c","ARPHRD_LOOPBACK":"c","ARPHRD_METRICOM":"c","ARPHRD_NETROM":"c","ARPHRD_NONE":"c","ARPHRD_PIMREG":"c","ARPHRD_PPP":"c","ARPHRD_PRONET":"c","ARPHRD_RAWHDLC":"c","ARPHRD_ROSE":"c","ARPHRD_RSRVD":"c","ARPHRD_SIT":"c","ARPHRD_SKIP":"c","ARPHRD_SLIP":"c","ARPHRD_SLIP6":"c","ARPHRD_TUNNEL":"c","ARPHRD_TUNNEL6":"c","ARPHRD_VOID":"c","ARPHRD_X25":"c","Accept":"f","Accept4":"f","Access":"f","Acct":"f","Adjtimex":"f","AllThreadsSyscall":"f","AllThreadsSyscall6":"f","AttachLsf":"f","B0":"c","B1000000":"c","B110":"c","B115200":"c","B1152000":"c","B1200":"c","B134":"c","B150":"c","B1500000":"c","B1800":"c","B19200":"c","B200":"c","B2000000":"c","B230400":"c","B2400":"c","B2500000":"c","B300":"c","B3000000":"c","B3500000":"c","B38400":"c","B4000000":"c","B460800":"c","B4800":"c","B50":"c","B500000":"c","B57600":"c","B576000":"c","B600":"c","B75":"c","B921600":"c","B9600":"c","BPF_A":"c","BPF_ABS":"c","BPF_ADD":"c","BPF_ALU":"c","BPF_AND":"c","BPF_B":"c","BPF_DIV":"c","BPF_H":"c","BPF_IMM":"c","BPF_IND":"c","BPF_JA":"c","BPF_JEQ":"c","BPF_JGE":"c","BPF_JGT":"c","BPF_JMP":"c","BPF_JSET":"c","BPF_K":"c","BPF_LD":"c","BPF_LDX":"c","BPF_LEN":"c","BPF_LSH":"c","BPF_MAJOR_VERSION":"c","BPF_MAXINSNS":"c","BPF_MEM":"c","BPF_MEMWORDS":"c","BPF_MINOR_VERSION":"c","BPF_MISC":"c","BPF_MSH":"c","BPF_MUL":"c","BPF_NEG":"c","BPF_OR":"c","BPF_RET":"c","BPF_RSH":"c","BPF_ST":"c","BPF_STX":"c","BPF_SUB":"c","BPF_TAX":"c","BPF_TXA":"c","BPF_W":"c","BPF_X":"c","BRKINT":"c","Bind":"f","BindToDevice":"f","BytePtrFromString":"f","ByteSliceFromString":"f","CLOCAL":"c","CLONE_CHILD_CLEARTID":"c","CLONE_CHILD_SETTID":"c","CLONE_CLEAR_SIGHAND":"c","CLONE_DETACHED":"c","CLONE_FILES":"c","CLONE_FS":"c","CLONE_INTO_CGROUP":"c","CLONE_IO":"c","CLONE_NEWCGROUP":"c","CLONE_NEWIPC":"c","CLONE_NEWNET":"c","CLONE_NEWNS":"c","CLONE_NEWPID":"c","CLONE_NEWTIME":"c","CLONE_NEWUSER":"c","CLONE_NEWUTS":"c","CLONE_PARENT":"c","CLONE_PARENT_SETTID":"c","CLONE_PIDFD":"c","CLONE_PTRACE":"c","CLONE_SETTLS":"c","CLONE_SIGHAND":"c","CLONE_SYSVSEM":"c","CLONE_THREAD":"c","CLONE_UNTRACED":"c","CLONE_VFORK":"c","CLONE_VM":"c","CREAD":"c","CS5":"c","CS6":"c","CS7":"c","CS8":"c","CSIZE":"c","CSTOPB":"c","Chdir":"f","Chmod":"f","Chown":"f","Chroot":"f","Clearenv":"f","Close":"f","CloseOnExec":"f","CmsgLen":"f","CmsgSpace":"f","Cmsghdr":"t","Cmsghdr.SetLen":"m","Conn":"t","Connect":"f","Creat":"f","Credential":"t","DT_BLK":"c","DT_CHR":"c","DT_DIR":"c","DT_FIFO":"c","DT_LNK":"c","DT_REG":"c","DT_SOCK":"c","DT_UNKNOWN":"c","DT_WHT":"c","DetachLsf":"f","Dirent":"t","Dup":"f","Dup2":"f","Dup3":"f","E2BIG":"c","EACCES":"c","EADDRINUSE":"c","EADDRNOTAVAIL":"c","EADV":"c","EAFNOSUPPORT":"c","EAGAIN":"c","EALREADY":"c","EBADE":"c","EBADF":"c","EBADFD":"c","EBADMSG":"c","EBADR":"c","EBADRQC":"c","EBADSLT":"c","EBFONT":"c","EBUSY":"c","ECANCELED":"c","ECHILD":"c","ECHO":"c","ECHOCTL":"c","ECHOE":"c","ECHOK":"c","ECHOKE":"c","ECHONL":"c","ECHOPRT":"c","ECHRNG":"c","ECOMM":"c","ECONNABORTED":"c","ECONNREFUSED":"c","ECONNRESET":"c","EDEADLK":"c","EDEADLOCK":"c","EDESTADDRREQ":"c","EDOM":"c","EDOTDOT":"c","EDQUOT":"c","EEXIST":"c","EFAULT":"c","EFBIG":"c","EHOSTDOWN":"c","EHOSTUNREACH":"c","EIDRM":"c","EILSEQ":"c","EINPROGRESS":"c","EINTR":"c","EINVAL":"c","EIO":"c","EISCONN":"c","EISDIR":"c","EISNAM":"c","EKEYEXPIRED":"c","EKEYREJECTED":"c","EKEYREVOKED":"c","EL2HLT":"c","EL2NSYNC":"c","EL3HLT":"c","EL3RST":"c","ELIBACC":"c","ELIBBAD":"c","ELIBEXEC":"c","ELIBMAX":"c","ELIBSCN":"c","ELNRNG":"c","ELOOP":"c","EMEDIUMTYPE":"c","EMFILE":"c","EMLINK":"c","EMSGSIZE":"c","EMULTIHOP":"c","ENAMETOOLONG":"c","ENAVAIL":"c","ENETDOWN":"c","ENETRESET":"c","ENETUNREACH":"c","ENFILE":"c","ENOANO":"c","ENOBUFS":"c","ENOCSI":"c","ENODATA":"c","ENODEV":"c","ENOENT":"c","ENOEXEC":"c","ENOKEY":"c","ENOLCK":"c","ENOLINK":"c","ENOMEDIUM":"c","ENOMEM":"c","ENOMSG":"c","ENONET":"c","ENOPKG":"c","ENOPROTOOPT":"c","ENOSPC":"c","ENOSR":"c","ENOSTR":"c","ENOSYS":"c","ENOTBLK":"c","ENOTCONN":"c","ENOTDIR":"c","ENOTEMPTY":"c","ENOTNAM":"c","ENOTRECOVERABLE":"c","ENOTSOCK":"c","ENOTSUP":"c","ENOTTY":"c","ENOTUNIQ":"c","ENXIO":"c","EOPNOTSUPP":"c","EOVERFLOW":"c","EOWNERDEAD":"c","EPERM":"c","EPFNOSUPPORT":"c","EPIPE":"c","EPOLLERR":"c","EPOLLET":"c","EPOLLHUP":"c","EPOLLIN":"c","EPOLLMSG":"c","EPOLLONESHOT":"c","EPOLLOUT":"c","EPOLLPRI":"c","EPOLLRDBAND":"c","EPOLLRDHUP":"c","EPOLLRDNORM":"c","EPOLLWRBAND":"c","EPOLLWRNORM":"c","EPOLL_CLOEXEC":"c","EPOLL_CTL_ADD":"c","EPOLL_CTL_DEL":"c","EPOLL_CTL_MOD":"c","EPOLL_NONBLOCK":"c","EPROTO":"c","EPROTONOSUPPORT":"c","EPROTOTYPE":"c","ERANGE":"c","EREMCHG":"c","EREMOTE":"c","EREMOTEIO":"c","ERESTART":"c","ERFKILL":"c","EROFS":"c","ESHUTDOWN":"c","ESOCKTNOSUPPORT":"c","ESPIPE":"c","ESRCH":"c","ESRMNT":"c","ESTALE":"c","ESTRPIPE":"c","ETH_P_1588":"c","ETH_P_8021Q":"c","ETH_P_802_2":"c","ETH_P_802_3":"c","ETH_P_AARP":"c","ETH_P_ALL":"c","ETH_P_AOE":"c","ETH_P_ARCNET":"c","ETH_P_ARP":"c","ETH_P_ATALK":"c","ETH_P_ATMFATE":"c","ETH_P_ATMMPOA":"c","ETH_P_AX25":"c","ETH_P_BPQ":"c","ETH_P_CAIF":"c","ETH_P_CAN":"c","ETH_P_CONTROL":"c","ETH_P_CUST":"c","ETH_P_DDCMP":"c","ETH_P_DEC":"c","ETH_P_DIAG":"c","ETH_P_DNA_DL":"c","ETH_P_DNA_RC":"c","ETH_P_DNA_RT":"c","ETH_P_DSA":"c","ETH_P_ECONET":"c","ETH_P_EDSA":"c","ETH_P_FCOE":"c","ETH_P_FIP":"c","ETH_P_HDLC":"c","ETH_P_IEEE802154":"c","ETH_P_IEEEPUP":"c","ETH_P_IEEEPUPAT":"c","ETH_P_IP":"c","ETH_P_IPV6":"c","ETH_P_IPX":"c","ETH_P_IRDA":"c","ETH_P_LAT":"c","ETH_P_LINK_CTL":"c","ETH_P_LOCALTALK":"c","ETH_P_LOOP":"c","ETH_P_MOBITEX":"c","ETH_P_MPLS_MC":"c","ETH_P_MPLS_UC":"c","ETH_P_PAE":"c","ETH_P_PAUSE":"c","ETH_P_PHONET":"c","ETH_P_PPPTALK":"c","ETH_P_PPP_DISC":"c","ETH_P_PPP_MP":"c","ETH_P_PPP_SES":"c","ETH_P_PUP":"c","ETH_P_PUPAT":"c","ETH_P_RARP":"c","ETH_P_SCA":"c","ETH_P_SLOW":"c","ETH_P_SNAP":"c","ETH_P_TEB":"c","ETH_P_TIPC":"c","ETH_P_TRAILER":"c","ETH_P_TR_802_2":"c","ETH_P_WAN_PPP":"c","ETH_P_WCCP":"c","ETH_P_X25":"c","ETIME":"c","ETIMEDOUT":"c","ETOOMANYREFS":"c","ETXTBSY":"c","EUCLEAN":"c","EUNATCH":"c","EUSERS":"c","EWOULDBLOCK":"c","EXDEV":"c","EXFULL":"c","Environ":"f","EpollCreate":"f","EpollCreate1":"f","EpollCtl":"f","EpollEvent":"t","EpollWait":"f","Errno":"t","Errno.Error":"m","Errno.Is":"m","Errno.Temporary":"m","Errno.Timeout":"m","Exec":"f","Exit":"f","FD_CLOEXEC":"c","FD_SETSIZE":"c","FLUSHO":"c","F_DUPFD":"c","F_DUPFD_CLOEXEC":"c","F_EXLCK":"c","F_GETFD":"c","F_GETFL":"c","F_GETLEASE":"c","F_GETLK":"c","F_GETLK64":"c","F_GETOWN":"c","F_GETOWN_EX":"c","F_GETPIPE_SZ":"c","F_GETSIG":"c","F_LOCK":"c","F_NOTIFY":"c","F_OK":"c","F_RDLCK":"c","F_SETFD":"c","F_SETFL":"c","F_SETLEASE":"c","F_SETLK":"c","F_SETLK64":"c","F_SETLKW":"c","F_SETLKW64":"c","F_SETOWN":"c","F_SETOWN_EX":"c","F_SETPIPE_SZ":"c","F_SETSIG":"c","F_SHLCK":"c","F_TEST":"c","F_TLOCK":"c","F_ULOCK":"c","F_UNLCK":"c","F_WRLCK":"c","Faccessat":"f","Fallocate":"f","Fchdir":"f","Fchmod":"f","Fchmodat":"f","Fchown":"f","Fchownat":"f","FcntlFlock":"f","FdSet":"t","Fdatasync":"f","Flock":"f","Flock_t":"t","ForkExec":"f","ForkLock":"v","Fsid":"t","Fstat":"f","Fstatfs":"f","Fsync":"f","Ftruncate":"f","Futimes":"f","Futimesat":"f","Getcwd":"f","Getdents":"f","Getegid":"f","Getenv":"f","Geteuid":"f","Getgid":"f","Getgroups":"f","Getpagesize":"f","Getpeername":"f","Getpgid":"f","Getpgrp":"f","Getpid":"f","Getppid":"f","Getpriority":"f","Getrlimit":"f","Getrusage":"f","Getsockname":"f","GetsockoptICMPv6Filter":"f","GetsockoptIPMreq":"f","GetsockoptIPMreqn":"f","GetsockoptIPv6MTUInfo":"f","GetsockoptIPv6Mreq":"f","GetsockoptInet4Addr":"f","GetsockoptInt":"f","GetsockoptUcred":"f","Gettid":"f","Gettimeofday":"f","Getuid":"f","Getwd":"f","Getxattr":"f","HUPCL":"c","ICANON":"c","ICMPV6_FILTER":"c","ICMPv6Filter":"t","ICRNL":"c","IEXTEN":"c","IFA_ADDRESS":"c","IFA_ANYCAST":"c","IFA_BROADCAST":"c","IFA_CACHEINFO":"c","IFA_F_DADFAILED":"c","IFA_F_DEPRECATED":"c","IFA_F_HOMEADDRESS":"c","IFA_F_NODAD":"c","IFA_F_OPTIMISTIC":"c","IFA_F_PERMANENT":"c","IFA_F_SECONDARY":"c","IFA_F_TEMPORARY":"c","IFA_F_TENTATIVE":"c","IFA_LABEL":"c","IFA_LOCAL":"c","IFA_MAX":"c","IFA_MULTICAST":"c","IFA_UNSPEC":"c","IFF_ALLMULTI":"c","IFF_AUTOMEDIA":"c","IFF_BROADCAST":"c","IFF_DEBUG":"c","IFF_DYNAMIC":"c","IFF_LOOPBACK":"c","IFF_MASTER":"c","IFF_MULTICAST":"c","IFF_NOARP":"c","IFF_NOTRAILERS":"c","IFF_NO_PI":"c","IFF_ONE_QUEUE":"c","IFF_POINTOPOINT":"c","IFF_PORTSEL":"c","IFF_PROMISC":"c","IFF_RUNNING":"c","IFF_SLAVE":"c","IFF_TAP":"c","IFF_TUN":"c","IFF_TUN_EXCL":"c","IFF_UP":"c","IFF_VNET_HDR":"c","IFLA_ADDRESS":"c","IFLA_BROADCAST":"c","IFLA_COST":"c","IFLA_IFALIAS":"c","IFLA_IFNAME":"c","IFLA_LINK":"c","IFLA_LINKINFO":"c","IFLA_LINKMODE":"c","IFLA_MAP":"c","IFLA_MASTER":"c","IFLA_MAX":"c","IFLA_MTU":"c","IFLA_NET_NS_PID":"c","IFLA_OPERSTATE":"c","IFLA_PRIORITY":"c","IFLA_PROTINFO":"c","IFLA_QDISC":"c","IFLA_STATS":"c","IFLA_TXQLEN":"c","IFLA_UNSPEC":"c","IFLA_WEIGHT":"c","IFLA_WIRELESS":"c","IFNAMSIZ":"c","IGNBRK":"c","IGNCR":"c","IGNPAR":"c","IMAXBEL":"c","INLCR":"c","INPCK":"c","IN_ACCESS":"c","IN_ALL_EVENTS":"c","IN_ATTRIB":"c","IN_CLASSA_HOST":"c","IN_CLASSA_MAX":"c","IN_CLASSA_NET":"c","IN_CLASSA_NSHIFT":"c","IN_CLASSB_HOST":"c","IN_CLASSB_MAX":"c","IN_CLASSB_NET":"c","IN_CLASSB_NSHIFT":"c","IN_CLASSC_HOST":"c","IN_CLASSC_NET":"c","IN_CLASSC_NSHIFT":"c","IN_CLOEXEC":"c","IN_CLOSE":"c","IN_CLOSE_NOWRITE":"c","IN_CLOSE_WRITE":"c","IN_CREATE":"c","IN_DELETE":"c","IN_DELETE_SELF":"c","IN_DONT_FOLLOW":"c","IN_EXCL_UNLINK":"c","IN_IGNORED":"c","IN_ISDIR":"c","IN_LOOPBACKNET":"c","IN_MASK_ADD":"c","IN_MODIFY":"c","IN_MOVE":"c","IN_MOVED_FROM":"c","IN_MOVED_TO":"c","IN_MOVE_SELF":"c","IN_NONBLOCK":"c","IN_ONESHOT":"c","IN_ONLYDIR":"c","IN_OPEN":"c","IN_Q_OVERFLOW":"c","IN_UNMOUNT":"c","IPMreq":"t","IPMreqn":"t","IPPROTO_AH":"c","IPPROTO_COMP":"c","IPPROTO_DCCP":"c","IPPROTO_DSTOPTS":"c","IPPROTO_EGP":"c","IPPROTO_ENCAP":"c","IPPROTO_ESP":"c","IPPROTO_FRAGMENT":"c","IPPROTO_GRE":"c","IPPROTO_HOPOPTS":"c","IPPROTO_ICMP":"c","IPPROTO_ICMPV6":"c","IPPROTO_IDP":"c","IPPROTO_IGMP":"c","IPPROTO_IP":"c","IPPROTO_IPIP":"c","IPPROTO_IPV6":"c","IPPROTO_MTP":"c","IPPROTO_NONE":"c","IPPROTO_PIM":"c","IPPROTO_PUP":"c","IPPROTO_RAW":"c","IPPROTO_ROUTING":"c","IPPROTO_RSVP":"c","IPPROTO_SCTP":"c","IPPROTO_TCP":"c","IPPROTO_TP":"c","IPPROTO_UDP":"c","IPPROTO_UDPLITE":"c","IPV6_2292DSTOPTS":"c","IPV6_2292HOPLIMIT":"c","IPV6_2292HOPOPTS":"c","IPV6_2292PKTINFO":"c","IPV6_2292PKTOPTIONS":"c","IPV6_2292RTHDR":"c","IPV6_ADDRFORM":"c","IPV6_ADD_MEMBERSHIP":"c","IPV6_AUTHHDR":"c","IPV6_CHECKSUM":"c","IPV6_DROP_MEMBERSHIP":"c","IPV6_DSTOPTS":"c","IPV6_HOPLIMIT":"c","IPV6_HOPOPTS":"c","IPV6_IPSEC_POLICY":"c","IPV6_JOIN_ANYCAST":"c","IPV6_JOIN_GROUP":"c","IPV6_LEAVE_ANYCAST":"c","IPV6_LEAVE_GROUP":"c","IPV6_MTU":"c","IPV6_MTU_DISCOVER":"c","IPV6_MULTICAST_HOPS":"c","IPV6_MULTICAST_IF":"c","IPV6_MULTICAST_LOOP":"c","IPV6_NEXTHOP":"c","IPV6_PKTINFO":"c","IPV6_PMTUDISC_DO":"c","IPV6_PMTUDISC_DONT":"c","IPV6_PMTUDISC_PROBE":"c","IPV6_PMTUDISC_WANT":"c","IPV6_RECVDSTOPTS":"c","IPV6_RECVERR":"c","IPV6_RECVHOPLIMIT":"c","IPV6_RECVHOPOPTS":"c","IPV6_RECVPKTINFO":"c","IPV6_RECVRTHDR":"c","IPV6_RECVTCLASS":"c","IPV6_ROUTER_ALERT":"c","IPV6_RTHDR":"c","IPV6_RTHDRDSTOPTS":"c","IPV6_RTHDR_LOOSE":"c","IPV6_RTHDR_STRICT":"c","IPV6_RTHDR_TYPE_0":"c","IPV6_RXDSTOPTS":"c","IPV6_RXHOPOPTS":"c","IPV6_TCLASS":"c","IPV6_UNICAST_HOPS":"c","IPV6_V6ONLY":"c","IPV6_XFRM_POLICY":"c","IP_ADD_MEMBERSHIP":"c","IP_ADD_SOURCE_MEMBERSHIP":"c","IP_BLOCK_SOURCE":"c","IP_DEFAULT_MULTICAST_LOOP":"c","IP_DEFAULT_MULTICAST_TTL":"c","IP_DF":"c","IP_DROP_MEMBERSHIP":"c","IP_DROP_SOURCE_MEMBERSHIP":"c","IP_FREEBIND":"c","IP_HDRINCL":"c","IP_IPSEC_POLICY":"c","IP_MAXPACKET":"c","IP_MAX_MEMBERSHIPS":"c","IP_MF":"c","IP_MINTTL":"c","IP_MSFILTER":"c","IP_MSS":"c","IP_MTU":"c","IP_MTU_DISCOVER":"c","IP_MULTICAST_IF":"c","IP_MULTICAST_LOOP":"c","IP_MULTICAST_TTL":"c","IP_OFFMASK":"c","IP_OPTIONS":"c","IP_ORIGDSTADDR":"c","IP_PASSSEC":"c","IP_PKTINFO":"c","IP_PKTOPTIONS":"c","IP_PMTUDISC":"c","IP_PMTUDISC_DO":"c","IP_PMTUDISC_DONT":"c","IP_PMTUDISC_PROBE":"c","IP_PMTUDISC_WANT":"c","IP_RECVERR":"c","IP_RECVOPTS":"c","IP_RECVORIGDSTADDR":"c","IP_RECVRETOPTS":"c","IP_RECVTOS":"c","IP_RECVTTL":"c","IP_RETOPTS":"c","IP_RF":"c","IP_ROUTER_ALERT":"c","IP_TOS":"c","IP_TRANSPARENT":"c","IP_TTL":"c","IP_UNBLOCK_SOURCE":"c","IP_XFRM_POLICY":"c","IPv6MTUInfo":"t","IPv6Mreq":"t","ISIG":"c","ISTRIP":"c","IUCLC":"c","IUTF8":"c","IXANY":"c","IXOFF":"c","IXON":"c","IfAddrmsg":"t","IfInfomsg":"t","ImplementsGetwd":"c","Inet4Pktinfo":"t","Inet6Pktinfo":"t","InotifyAddWatch":"f","InotifyEvent":"t","InotifyInit":"f","InotifyInit1":"f","InotifyRmWatch":"f","Ioperm":"f","Iopl":"f","Iovec":"t","Iovec.SetLen":"m","Kill":"f","Klogctl":"f","LINUX_REBOOT_CMD_CAD_OFF":"c","LINUX_REBOOT_CMD_CAD_ON":"c","LINUX_REBOOT_CMD_HALT":"c","LINUX_REBOOT_CMD_KEXEC":"c","LINUX_REBOOT_CMD_POWER_OFF":"c","LINUX_REBOOT_CMD_RESTART":"c","LINUX_REBOOT_CMD_RESTART2":"c","LINUX_REBOOT_CMD_SW_SUSPEND":"c","LINUX_REBOOT_MAGIC1":"c","LINUX_REBOOT_MAGIC2":"c","LOCK_EX":"c","LOCK_NB":"c","LOCK_SH":"c","LOCK_UN":"c","Lchown":"f","Linger":"t","Link":"f","Listen":"f","Listxattr":"f","LsfJump":"f","LsfSocket":"f","LsfStmt":"f","Lstat":"f","MADV_DOFORK":"c","MADV_DONTFORK":"c","MADV_DONTNEED":"c","MADV_HUGEPAGE":"c","MADV_HWPOISON":"c","MADV_MERGEABLE":"c","MADV_NOHUGEPAGE":"c","MADV_NORMAL":"c","MADV_RANDOM":"c","MADV_REMOVE":"c","MADV_SEQUENTIAL":"c","MADV_UNMERGEABLE":"c","MADV_WILLNEED":"c","MAP_32BIT":"c","MAP_ANON":"c","MAP_ANONYMOUS":"c","MAP_DENYWRITE":"c","MAP_EXECUTABLE":"c","MAP_FILE":"c","MAP_FIXED":"c","MAP_GROWSDOWN":"c","MAP_HUGETLB":"c","MAP_LOCKED":"c","MAP_NONBLOCK":"c","MAP_NORESERVE":"c","MAP_POPULATE":"c","MAP_PRIVATE":"c","MAP_SHARED":"c","MAP_STACK":"c","MAP_TYPE":"c","MCL_CURRENT":"c","MCL_FUTURE":"c","MNT_DETACH":"c","MNT_EXPIRE":"c","MNT_FORCE":"c","MSG_CMSG_CLOEXEC":"c","MSG_CONFIRM":"c","MSG_CTRUNC":"c","MSG_DONTROUTE":"c","MSG_DONTWAIT":"c","MSG_EOR":"c","MSG_ERRQUEUE":"c","MSG_FASTOPEN":"c","MSG_FIN":"c","MSG_MORE":"c","MSG_NOSIGNAL":"c","MSG_OOB":"c","MSG_PEEK":"c","MSG_PROXY":"c","MSG_RST":"c","MSG_SYN":"c","MSG_TRUNC":"c","MSG_TRYHARD":"c","MSG_WAITALL":"c","MSG_WAITFORONE":"c","MS_ACTIVE":"c","MS_ASYNC":"c","MS_BIND":"c","MS_DIRSYNC":"c","MS_INVALIDATE":"c","MS_I_VERSION":"c","MS_KERNMOUNT":"c","MS_MANDLOCK":"c","MS_MGC_MSK":"c","MS_MGC_VAL":"c","MS_MOVE":"c","MS_NOATIME":"c","MS_NODEV":"c","MS_NODIRATIME":"c","MS_NOEXEC":"c","MS_NOSUID":"c","MS_NOUSER":"c","MS_POSIXACL":"c","MS_PRIVATE":"c","MS_RDONLY":"c","MS_REC":"c","MS_RELATIME":"c","MS_REMOUNT":"c","MS_RMT_MASK":"c","MS_SHARED":"c","MS_SILENT":"c","MS_SLAVE":"c","MS_STRICTATIME":"c","MS_SYNC":"c","MS_SYNCHRONOUS":"c","MS_UNBINDABLE":"c","Madvise":"f","Mkdir":"f","Mkdirat":"f","Mkfifo":"f","Mknod":"f","Mknodat":"f","Mlock":"f","Mlockall":"f","Mmap":"f","Mount":"f","Mprotect":"f","Msghdr":"t","Msghdr.SetControllen":"m","Munlock":"f","Munlockall":"f","Munmap":"f","NAME_MAX":"c","NETLINK_ADD_MEMBERSHIP":"c","NETLINK_AUDIT":"c","NETLINK_BROADCAST_ERROR":"c","NETLINK_CONNECTOR":"c","NETLINK_DNRTMSG":"c","NETLINK_DROP_MEMBERSHIP":"c","NETLINK_ECRYPTFS":"c","NETLINK_FIB_LOOKUP":"c","NETLINK_FIREWALL":"c","NETLINK_GENERIC":"c","NETLINK_INET_DIAG":"c","NETLINK_IP6_FW":"c","NETLINK_ISCSI":"c","NETLINK_KOBJECT_UEVENT":"c","NETLINK_NETFILTER":"c","NETLINK_NFLOG":"c","NETLINK_NO_ENOBUFS":"c","NETLINK_PKTINFO":"c","NETLINK_ROUTE":"c","NETLINK_SCSITRANSPORT":"c","NETLINK_SELINUX":"c","NETLINK_UNUSED":"c","NETLINK_USERSOCK":"c","NETLINK_XFRM":"c","NLA_ALIGNTO":"c","NLA_F_NESTED":"c","NLA_F_NET_BYTEORDER":"c","NLA_HDRLEN":"c","NLMSG_ALIGNTO":"c","NLMSG_DONE":"c","NLMSG_ERROR":"c","NLMSG_HDRLEN":"c","NLMSG_MIN_TYPE":"c","NLMSG_NOOP":"c","NLMSG_OVERRUN":"c","NLM_F_ACK":"c","NLM_F_APPEND":"c","NLM_F_ATOMIC":"c","NLM_F_CREATE":"c","NLM_F_DUMP":"c","NLM_F_ECHO":"c","NLM_F_EXCL":"c","NLM_F_MATCH":"c","NLM_F_MULTI":"c","NLM_F_REPLACE":"c","NLM_F_REQUEST":"c","NLM_F_ROOT":"c","NOFLSH":"c","Nanosleep":"f","NetlinkMessage":"t","NetlinkRIB":"f","NetlinkRouteAttr":"t","NetlinkRouteRequest":"t","NlAttr":"t","NlMsgerr":"t","NlMsghdr":"t","NsecToTimespec":"f","NsecToTimeval":"f","OCRNL":"c","OFDEL":"c","OFILL":"c","OLCUC":"c","ONLCR":"c","ONLRET":"c","ONOCR":"c","OPOST":"c","O_ACCMODE":"c","O_APPEND":"c","O_ASYNC":"c","O_CLOEXEC":"c","O_CREAT":"c","O_DIRECT":"c","O_DIRECTORY":"c","O_DSYNC":"c","O_EXCL":"c","O_FSYNC":"c","O_LARGEFILE":"c","O_NDELAY":"c","O_NOATIME":"c","O_NOCTTY":"c","O_NOFOLLOW":"c","O_NONBLOCK":"c","O_RDONLY":"c","O_RDWR":"c","O_RSYNC":"c","O_SYNC":"c","O_TRUNC":"c","O_WRONLY":"c","Open":"f","Openat":"f","PACKET_ADD_MEMBERSHIP":"c","PACKET_BROADCAST":"c","PACKET_DROP_MEMBERSHIP":"c","PACKET_FASTROUTE":"c","PACKET_HOST":"c","PACKET_LOOPBACK":"c","PACKET_MR_ALLMULTI":"c","PACKET_MR_MULTICAST":"c","PACKET_MR_PROMISC":"c","PACKET_MULTICAST":"c","PACKET_OTHERHOST":"c","PACKET_OUTGOING":"c","PACKET_RECV_OUTPUT":"c","PACKET_RX_RING":"c","PACKET_STATISTICS":"c","PARENB":"c","PARMRK":"c","PARODD":"c","PENDIN":"c","PRIO_PGRP":"c","PRIO_PROCESS":"c","PRIO_USER":"c","PROT_EXEC":"c","PROT_GROWSDOWN":"c","PROT_GROWSUP":"c","PROT_NONE":"c","PROT_READ":"c","PROT_WRITE":"c","PR_CAPBSET_DROP":"c","PR_CAPBSET_READ":"c","PR_ENDIAN_BIG":"c","PR_ENDIAN_LITTLE":"c","PR_ENDIAN_PPC_LITTLE":"c","PR_FPEMU_NOPRINT":"c","PR_FPEMU_SIGFPE":"c","PR_FP_EXC_ASYNC":"c","PR_FP_EXC_DISABLED":"c","PR_FP_EXC_DIV":"c","PR_FP_EXC_INV":"c","PR_FP_EXC_NONRECOV":"c","PR_FP_EXC_OVF":"c","PR_FP_EXC_PRECISE":"c","PR_FP_EXC_RES":"c","PR_FP_EXC_SW_ENABLE":"c","PR_FP_EXC_UND":"c","PR_GET_DUMPABLE":"c","PR_GET_ENDIAN":"c","PR_GET_FPEMU":"c","PR_GET_FPEXC":"c","PR_GET_KEEPCAPS":"c","PR_GET_NAME":"c","PR_GET_PDEATHSIG":"c","PR_GET_SECCOMP":"c","PR_GET_SECUREBITS":"c","PR_GET_TIMERSLACK":"c","PR_GET_TIMING":"c","PR_GET_TSC":"c","PR_GET_UNALIGN":"c","PR_MCE_KILL":"c","PR_MCE_KILL_CLEAR":"c","PR_MCE_KILL_DEFAULT":"c","PR_MCE_KILL_EARLY":"c","PR_MCE_KILL_GET":"c","PR_MCE_KILL_LATE":"c","PR_MCE_KILL_SET":"c","PR_SET_DUMPABLE":"c","PR_SET_ENDIAN":"c","PR_SET_FPEMU":"c","PR_SET_FPEXC":"c","PR_SET_KEEPCAPS":"c","PR_SET_NAME":"c","PR_SET_PDEATHSIG":"c","PR_SET_PTRACER":"c","PR_SET_SECCOMP":"c","PR_SET_SECUREBITS":"c","PR_SET_TIMERSLACK":"c","PR_SET_TIMING":"c","PR_SET_TSC":"c","PR_SET_UNALIGN":"c","PR_TASK_PERF_EVENTS_DISABLE":"c","PR_TASK_PERF_EVENTS_ENABLE":"c","PR_TIMING_STATISTICAL":"c","PR_TIMING_TIMESTAMP":"c","PR_TSC_ENABLE":"c","PR_TSC_SIGSEGV":"c","PR_UNALIGN_NOPRINT":"c","PR_UNALIGN_SIGBUS":"c","PTRACE_ARCH_PRCTL":"c","PTRACE_ATTACH":"c","PTRACE_CONT":"c","PTRACE_DETACH":"c","PTRACE_EVENT_CLONE":"c","PTRACE_EVENT_EXEC":"c","PTRACE_EVENT_EXIT":"c","PTRACE_EVENT_FORK":"c","PTRACE_EVENT_VFORK":"c","PTRACE_EVENT_VFORK_DONE":"c","PTRACE_GETEVENTMSG":"c","PTRACE_GETFPREGS":"c","PTRACE_GETFPXREGS":"c","PTRACE_GETREGS":"c","PTRACE_GETREGSET":"c","PTRACE_GETSIGINFO":"c","PTRACE_GET_THREAD_AREA":"c","PTRACE_KILL":"c","PTRACE_OLDSETOPTIONS":"c","PTRACE_O_MASK":"c","PTRACE_O_TRACECLONE":"c","PTRACE_O_TRACEEXEC":"c","PTRACE_O_TRACEEXIT":"c","PTRACE_O_TRACEFORK":"c","PTRACE_O_TRACESYSGOOD":"c","PTRACE_O_TRACEVFORK":"c","PTRACE_O_TRACEVFORKDONE":"c","PTRACE_PEEKDATA":"c","PTRACE_PEEKTEXT":"c","PTRACE_PEEKUSR":"c","PTRACE_POKEDATA":"c","PTRACE_POKETEXT":"c","PTRACE_POKEUSR":"c","PTRACE_SETFPREGS":"c","PTRACE_SETFPXREGS":"c","PTRACE_SETOPTIONS":"c","PTRACE_SETREGS":"c","PTRACE_SETREGSET":"c","PTRACE_SETSIGINFO":"c","PTRACE_SET_THREAD_AREA":"c","PTRACE_SINGLEBLOCK":"c","PTRACE_SINGLESTEP":"c","PTRACE_SYSCALL":"c","PTRACE_SYSEMU":"c","PTRACE_SYSEMU_SINGLESTEP":"c","PTRACE_TRACEME":"c","ParseDirent":"f","ParseNetlinkMessage":"f","ParseNetlinkRouteAttr":"f","ParseSocketControlMessage":"f","ParseUnixCredentials":"f","ParseUnixRights":"f","PathMax":"c","Pause":"f","Pipe":"f","Pipe2":"f","PivotRoot":"f","Pread":"f","ProcAttr":"t","PtraceAttach":"f","PtraceCont":"f","PtraceDetach":"f","PtraceGetEventMsg":"f","PtraceGetRegs":"f","PtracePeekData":"f","PtracePeekText":"f","PtracePokeData":"f","PtracePokeText":"f","PtraceRegs":"t","PtraceRegs.PC":"m","PtraceRegs.SetPC":"m","PtraceSetOptions":"f","PtraceSetRegs":"f","PtraceSingleStep":"f","PtraceSyscall":"f","Pwrite":"f","RLIMIT_AS":"c","RLIMIT_CORE":"c","RLIMIT_CPU":"c","RLIMIT_DATA":"c","RLIMIT_FSIZE":"c","RLIMIT_NOFILE":"c","RLIMIT_STACK":"c","RLIM_INFINITY":"c","RTAX_ADVMSS":"c","RTAX_CWND":"c","RTAX_FEATURES":"c","RTAX_FEATURE_ALLFRAG":"c","RTAX_FEATURE_ECN":"c","RTAX_FEATURE_SACK":"c","RTAX_FEATURE_TIMESTAMP":"c","RTAX_HOPLIMIT":"c","RTAX_INITCWND":"c","RTAX_INITRWND":"c","RTAX_LOCK":"c","RTAX_MAX":"c","RTAX_MTU":"c","RTAX_REORDERING":"c","RTAX_RTO_MIN":"c","RTAX_RTT":"c","RTAX_RTTVAR":"c","RTAX_SSTHRESH":"c","RTAX_UNSPEC":"c","RTAX_WINDOW":"c","RTA_ALIGNTO":"c","RTA_CACHEINFO":"c","RTA_DST":"c","RTA_FLOW":"c","RTA_GATEWAY":"c","RTA_IIF":"c","RTA_MAX":"c","RTA_METRICS":"c","RTA_MULTIPATH":"c","RTA_OIF":"c","RTA_PREFSRC":"c","RTA_PRIORITY":"c","RTA_SRC":"c","RTA_TABLE":"c","RTA_UNSPEC":"c","RTCF_DIRECTSRC":"c","RTCF_DOREDIRECT":"c","RTCF_LOG":"c","RTCF_MASQ":"c","RTCF_NAT":"c","RTCF_VALVE":"c","RTF_ADDRCLASSMASK":"c","RTF_ADDRCONF":"c","RTF_ALLONLINK":"c","RTF_BROADCAST":"c","RTF_CACHE":"c","RTF_DEFAULT":"c","RTF_DYNAMIC":"c","RTF_FLOW":"c","RTF_GATEWAY":"c","RTF_HOST":"c","RTF_INTERFACE":"c","RTF_IRTT":"c","RTF_LINKRT":"c","RTF_LOCAL":"c","RTF_MODIFIED":"c","RTF_MSS":"c","RTF_MTU":"c","RTF_MULTICAST":"c","RTF_NAT":"c","RTF_NOFORWARD":"c","RTF_NONEXTHOP":"c","RTF_NOPMTUDISC":"c","RTF_POLICY":"c","RTF_REINSTATE":"c","RTF_REJECT":"c","RTF_STATIC":"c","RTF_THROW":"c","RTF_UP":"c","RTF_WINDOW":"c","RTF_XRESOLVE":"c","RTM_BASE":"c","RTM_DELACTION":"c","RTM_DELADDR":"c","RTM_DELADDRLABEL":"c","RTM_DELLINK":"c","RTM_DELNEIGH":"c","RTM_DELQDISC":"c","RTM_DELROUTE":"c","RTM_DELRULE":"c","RTM_DELTCLASS":"c","RTM_DELTFILTER":"c","RTM_F_CLONED":"c","RTM_F_EQUALIZE":"c","RTM_F_NOTIFY":"c","RTM_F_PREFIX":"c","RTM_GETACTION":"c","RTM_GETADDR":"c","RTM_GETADDRLABEL":"c","RTM_GETANYCAST":"c","RTM_GETDCB":"c","RTM_GETLINK":"c","RTM_GETMULTICAST":"c","RTM_GETNEIGH":"c","RTM_GETNEIGHTBL":"c","RTM_GETQDISC":"c","RTM_GETROUTE":"c","RTM_GETRULE":"c","RTM_GETTCLASS":"c","RTM_GETTFILTER":"c","RTM_MAX":"c","RTM_NEWACTION":"c","RTM_NEWADDR":"c","RTM_NEWADDRLABEL":"c","RTM_NEWLINK":"c","RTM_NEWNDUSEROPT":"c","RTM_NEWNEIGH":"c","RTM_NEWNEIGHTBL":"c","RTM_NEWPREFIX":"c","RTM_NEWQDISC":"c","RTM_NEWROUTE":"c","RTM_NEWRULE":"c","RTM_NEWTCLASS":"c","RTM_NEWTFILTER":"c","RTM_NR_FAMILIES":"c","RTM_NR_MSGTYPES":"c","RTM_SETDCB":"c","RTM_SETLINK":"c","RTM_SETNEIGHTBL":"c","RTNH_ALIGNTO":"c","RTNH_F_DEAD":"c","RTNH_F_ONLINK":"c","RTNH_F_PERVASIVE":"c","RTNLGRP_IPV4_IFADDR":"c","RTNLGRP_IPV4_MROUTE":"c","RTNLGRP_IPV4_ROUTE":"c","RTNLGRP_IPV4_RULE":"c","RTNLGRP_IPV6_IFADDR":"c","RTNLGRP_IPV6_IFINFO":"c","RTNLGRP_IPV6_MROUTE":"c","RTNLGRP_IPV6_PREFIX":"c","RTNLGRP_IPV6_ROUTE":"c","RTNLGRP_IPV6_RULE":"c","RTNLGRP_LINK":"c","RTNLGRP_ND_USEROPT":"c","RTNLGRP_NEIGH":"c","RTNLGRP_NONE":"c","RTNLGRP_NOTIFY":"c","RTNLGRP_TC":"c","RTN_ANYCAST":"c","RTN_BLACKHOLE":"c","RTN_BROADCAST":"c","RTN_LOCAL":"c","RTN_MAX":"c","RTN_MULTICAST":"c","RTN_NAT":"c","RTN_PROHIBIT":"c","RTN_THROW":"c","RTN_UNICAST":"c","RTN_UNREACHABLE":"c","RTN_UNSPEC":"c","RTN_XRESOLVE":"c","RTPROT_BIRD":"c","RTPROT_BOOT":"c","RTPROT_DHCP":"c","RTPROT_DNROUTED":"c","RTPROT_GATED":"c","RTPROT_KERNEL":"c","RTPROT_MRT":"c","RTPROT_NTK":"c","RTPROT_RA":"c","RTPROT_REDIRECT":"c","RTPROT_STATIC":"c","RTPROT_UNSPEC":"c","RTPROT_XORP":"c","RTPROT_ZEBRA":"c","RT_CLASS_DEFAULT":"c","RT_CLASS_LOCAL":"c","RT_CLASS_MAIN":"c","RT_CLASS_MAX":"c","RT_CLASS_UNSPEC":"c","RT_SCOPE_HOST":"c","RT_SCOPE_LINK":"c","RT_SCOPE_NOWHERE":"c","RT_SCOPE_SITE":"c","RT_SCOPE_UNIVERSE":"c","RT_TABLE_COMPAT":"c","RT_TABLE_DEFAULT":"c","RT_TABLE_LOCAL":"c","RT_TABLE_MAIN":"c","RT_TABLE_MAX":"c","RT_TABLE_UNSPEC":"c","RUSAGE_CHILDREN":"c","RUSAGE_SELF":"c","RUSAGE_THREAD":"c","RawConn":"t","RawSockaddr":"t","RawSockaddrAny":"t","RawSockaddrInet4":"t","RawSockaddrInet6":"t","RawSockaddrLinklayer":"t","RawSockaddrNetlink":"t","RawSockaddrUnix":"t","RawSyscall":"f","RawSyscall6":"f","Read":"f","ReadDirent":"f","Readlink":"f","Reboot":"f","Recvfrom":"f","Recvmsg":"f","Removexattr":"f","Rename":"f","Renameat":"f","Rlimit":"t","Rmdir":"f","RtAttr":"t","RtGenmsg":"t","RtMsg":"t","RtNexthop":"t","Rusage":"t","SCM_CREDENTIALS":"c","SCM_RIGHTS":"c","SCM_TIMESTAMP":"c","SCM_TIMESTAMPING":"c","SCM_TIMESTAMPNS":"c","SHUT_RD":"c","SHUT_RDWR":"c","SHUT_WR":"c","SIGABRT":"c","SIGALRM":"c","SIGBUS":"c","SIGCHLD":"c","SIGCLD":"c","SIGCONT":"c","SIGFPE":"c","SIGHUP":"c","SIGILL":"c","SIGINT":"c","SIGIO":"c","SIGIOT":"c","SIGKILL":"c","SIGPIPE":"c","SIGPOLL":"c","SIGPROF":"c","SIGPWR":"c","SIGQUIT":"c","SIGSEGV":"c","SIGSTKFLT":"c","SIGSTOP":"c","SIGSYS":"c","SIGTERM":"c","SIGTRAP":"c","SIGTSTP":"c","SIGTTIN":"c","SIGTTOU":"c","SIGUNUSED":"c","SIGURG":"c","SIGUSR1":"c","SIGUSR2":"c","SIGVTALRM":"c","SIGWINCH":"c","SIGXCPU":"c","SIGXFSZ":"c","SIOCADDDLCI":"c","SIOCADDMULTI":"c","SIOCADDRT":"c","SIOCATMARK":"c","SIOCDARP":"c","SIOCDELDLCI":"c","SIOCDELMULTI":"c","SIOCDELRT":"c","SIOCDEVPRIVATE":"c","SIOCDIFADDR":"c","SIOCDRARP":"c","SIOCGARP":"c","SIOCGIFADDR":"c","SIOCGIFBR":"c","SIOCGIFBRDADDR":"c","SIOCGIFCONF":"c","SIOCGIFCOUNT":"c","SIOCGIFDSTADDR":"c","SIOCGIFENCAP":"c","SIOCGIFFLAGS":"c","SIOCGIFHWADDR":"c","SIOCGIFINDEX":"c","SIOCGIFMAP":"c","SIOCGIFMEM":"c","SIOCGIFMETRIC":"c","SIOCGIFMTU":"c","SIOCGIFNAME":"c","SIOCGIFNETMASK":"c","SIOCGIFPFLAGS":"c","SIOCGIFSLAVE":"c","SIOCGIFTXQLEN":"c","SIOCGPGRP":"c","SIOCGRARP":"c","SIOCGSTAMP":"c","SIOCGSTAMPNS":"c","SIOCPROTOPRIVATE":"c","SIOCRTMSG":"c","SIOCSARP":"c","SIOCSIFADDR":"c","SIOCSIFBR":"c","SIOCSIFBRDADDR":"c","SIOCSIFDSTADDR":"c","SIOCSIFENCAP":"c","SIOCSIFFLAGS":"c","SIOCSIFHWADDR":"c","SIOCSIFHWBROADCAST":"c","SIOCSIFLINK":"c","SIOCSIFMAP":"c","SIOCSIFMEM":"c","SIOCSIFMETRIC":"c","SIOCSIFMTU":"c","SIOCSIFNAME":"c","SIOCSIFNETMASK":"c","SIOCSIFPFLAGS":"c","SIOCSIFSLAVE":"c","SIOCSIFTXQLEN":"c","SIOCSPGRP":"c","SIOCSRARP":"c","SOCK_CLOEXEC":"c","SOCK_DCCP":"c","SOCK_DGRAM":"c","SOCK_NONBLOCK":"c","SOCK_PACKET":"c","SOCK_RAW":"c","SOCK_RDM":"c","SOCK_SEQPACKET":"c","SOCK_STREAM":"c","SOL_AAL":"c","SOL_ATM":"c","SOL_DECNET":"c","SOL_ICMPV6":"c","SOL_IP":"c","SOL_IPV6":"c","SOL_IRDA":"c","SOL_PACKET":"c","SOL_RAW":"c","SOL_SOCKET":"c","SOL_TCP":"c","SOL_X25":"c","SOMAXCONN":"c","SO_ACCEPTCONN":"c","SO_ATTACH_FILTER":"c","SO_BINDTODEVICE":"c","SO_BROADCAST":"c","SO_BSDCOMPAT":"c","SO_DEBUG":"c","SO_DETACH_FILTER":"c","SO_DOMAIN":"c","SO_DONTROUTE":"c","SO_ERROR":"c","SO_KEEPALIVE":"c","SO_LINGER":"c","SO_MARK":"c","SO_NO_CHECK":"c","SO_OOBINLINE":"c","SO_PASSCRED":"c","SO_PASSSEC":"c","SO_PEERCRED":"c","SO_PEERNAME":"c","SO_PEERSEC":"c","SO_PRIORITY":"c","SO_PROTOCOL":"c","SO_RCVBUF":"c","SO_RCVBUFFORCE":"c","SO_RCVLOWAT":"c","SO_RCVTIMEO":"c","SO_REUSEADDR":"c","SO_RXQ_OVFL":"c","SO_SECURITY_AUTHENTICATION":"c","SO_SECURITY_ENCRYPTION_NETWORK":"c","SO_SECURITY_ENCRYPTION_TRANSPORT":"c","SO_SNDBUF":"c","SO_SNDBUFFORCE":"c","SO_SNDLOWAT":"c","SO_SNDTIMEO":"c","SO_TIMESTAMP":"c","SO_TIMESTAMPING":"c","SO_TIMESTAMPNS":"c","SO_TYPE":"c","SYS_ACCEPT":"c","SYS_ACCEPT4":"c","SYS_ACCESS":"c","SYS_ACCT":"c","SYS_ADD_KEY":"c","SYS_ADJTIMEX":"c","SYS_AFS_SYSCALL":"c","SYS_ALARM":"c","SYS_ARCH_PRCTL":"c","SYS_BIND":"c","SYS_BRK":"c","SYS_CAPGET":"c","SYS_CAPSET":"c","SYS_CHDIR":"c","SYS_CHMOD":"c","SYS_CHOWN":"c","SYS_CHROOT":"c","SYS_CLOCK_GETRES":"c","SYS_CLOCK_GETTIME":"c","SYS_CLOCK_NANOSLEEP":"c","SYS_CLOCK_SETTIME":"c","SYS_CLONE":"c","SYS_CLOSE":"c","SYS_CONNECT":"c","SYS_CREAT":"c","SYS_CREATE_MODULE":"c","SYS_DELETE_MODULE":"c","SYS_DUP":"c","SYS_DUP2":"c","SYS_DUP3":"c","SYS_EPOLL_CREATE":"c","SYS_EPOLL_CREATE1":"c","SYS_EPOLL_CTL":"c","SYS_EPOLL_CTL_OLD":"c","SYS_EPOLL_PWAIT":"c","SYS_EPOLL_WAIT":"c","SYS_EPOLL_WAIT_OLD":"c","SYS_EVENTFD":"c","SYS_EVENTFD2":"c","SYS_EXECVE":"c","SYS_EXIT":"c","SYS_EXIT_GROUP":"c","SYS_FACCESSAT":"c","SYS_FADVISE64":"c","SYS_FALLOCATE":"c","SYS_FANOTIFY_INIT":"c","SYS_FANOTIFY_MARK":"c","SYS_FCHDIR":"c","SYS_FCHMOD":"c","SYS_FCHMODAT":"c","SYS_FCHOWN":"c","SYS_FCHOWNAT":"c","SYS_FCNTL":"c","SYS_FDATASYNC":"c","SYS_FGETXATTR":"c","SYS_FLISTXATTR":"c","SYS_FLOCK":"c","SYS_FORK":"c","SYS_FREMOVEXATTR":"c","SYS_FSETXATTR":"c","SYS_FSTAT":"c","SYS_FSTATFS":"c","SYS_FSYNC":"c","SYS_FTRUNCATE":"c","SYS_FUTEX":"c","SYS_FUTIMESAT":"c","SYS_GETCWD":"c","SYS_GETDENTS":"c","SYS_GETDENTS64":"c","SYS_GETEGID":"c","SYS_GETEUID":"c","SYS_GETGID":"c","SYS_GETGROUPS":"c","SYS_GETITIMER":"c","SYS_GETPEERNAME":"c","SYS_GETPGID":"c","SYS_GETPGRP":"c","SYS_GETPID":"c","SYS_GETPMSG":"c","SYS_GETPPID":"c","SYS_GETPRIORITY":"c","SYS_GETRESGID":"c","SYS_GETRESUID":"c","SYS_GETRLIMIT":"c","SYS_GETRUSAGE":"c","SYS_GETSID":"c","SYS_GETSOCKNAME":"c","SYS_GETSOCKOPT":"c","SYS_GETTID":"c","SYS_GETTIMEOFDAY":"c","SYS_GETUID":"c","SYS_GETXATTR":"c","SYS_GET_KERNEL_SYMS":"c","SYS_GET_MEMPOLICY":"c","SYS_GET_ROBUST_LIST":"c","SYS_GET_THREAD_AREA":"c","SYS_INIT_MODULE":"c","SYS_INOTIFY_ADD_WATCH":"c","SYS_INOTIFY_INIT":"c","SYS_INOTIFY_INIT1":"c","SYS_INOTIFY_RM_WATCH":"c","SYS_IOCTL":"c","SYS_IOPERM":"c","SYS_IOPL":"c","SYS_IOPRIO_GET":"c","SYS_IOPRIO_SET":"c","SYS_IO_CANCEL":"c","SYS_IO_DESTROY":"c","SYS_IO_GETEVENTS":"c","SYS_IO_SETUP":"c","SYS_IO_SUBMIT":"c","SYS_KEXEC_LOAD":"c","SYS_KEYCTL":"c","SYS_KILL":"c","SYS_LCHOWN":"c","SYS_LGETXATTR":"c","SYS_LINK":"c","SYS_LINKAT":"c","SYS_LISTEN":"c","SYS_LISTXATTR":"c","SYS_LLISTXATTR":"c","SYS_LOOKUP_DCOOKIE":"c","SYS_LREMOVEXATTR":"c","SYS_LSEEK":"c","SYS_LSETXATTR":"c","SYS_LSTAT":"c","SYS_MADVISE":"c","SYS_MBIND":"c","SYS_MIGRATE_PAGES":"c","SYS_MINCORE":"c","SYS_MKDIR":"c","SYS_MKDIRAT":"c","SYS_MKNOD":"c","SYS_MKNODAT":"c","SYS_MLOCK":"c","SYS_MLOCKALL":"c","SYS_MMAP":"c","SYS_MODIFY_LDT":"c","SYS_MOUNT":"c","SYS_MOVE_PAGES":"c","SYS_MPROTECT":"c","SYS_MQ_GETSETATTR":"c","SYS_MQ_NOTIFY":"c","SYS_MQ_OPEN":"c","SYS_MQ_TIMEDRECEIVE":"c","SYS_MQ_TIMEDSEND":"c","SYS_MQ_UNLINK":"c","SYS_MREMAP":"c","SYS_MSGCTL":"c","SYS_MSGGET":"c","SYS_MSGRCV":"c","SYS_MSGSND":"c","SYS_MSYNC":"c","SYS_MUNLOCK":"c","SYS_MUNLOCKALL":"c","SYS_MUNMAP":"c","SYS_NANOSLEEP":"c","SYS_NEWFSTATAT":"c","SYS_NFSSERVCTL":"c","SYS_OPEN":"c","SYS_OPENAT":"c","SYS_PAUSE":"c","SYS_PERF_EVENT_OPEN":"c","SYS_PERSONALITY":"c","SYS_PIPE":"c","SYS_PIPE2":"c","SYS_PIVOT_ROOT":"c","SYS_POLL":"c","SYS_PPOLL":"c","SYS_PRCTL":"c","SYS_PREAD64":"c","SYS_PREADV":"c","SYS_PRLIMIT64":"c","SYS_PSELECT6":"c","SYS_PTRACE":"c","SYS_PUTPMSG":"c","SYS_PWRITE64":"c","SYS_PWRITEV":"c","SYS_QUERY_MODULE":"c","SYS_QUOTACTL":"c","SYS_READ":"c","SYS_READAHEAD":"c","SYS_READLINK":"c","SYS_READLINKAT":"c","SYS_READV":"c","SYS_REBOOT":"c","SYS_RECVFROM":"c","SYS_RECVMMSG":"c","SYS_RECVMSG":"c","SYS_REMAP_FILE_PAGES":"c","SYS_REMOVEXATTR":"c","SYS_RENAME":"c","SYS_RENAMEAT":"c","SYS_REQUEST_KEY":"c","SYS_RESTART_SYSCALL":"c","SYS_RMDIR":"c","SYS_RT_SIGACTION":"c","SYS_RT_SIGPENDING":"c","SYS_RT_SIGPROCMASK":"c","SYS_RT_SIGQUEUEINFO":"c","SYS_RT_SIGRETURN":"c","SYS_RT_SIGSUSPEND":"c","SYS_RT_SIGTIMEDWAIT":"c","SYS_RT_TGSIGQUEUEINFO":"c","SYS_SCHED_GETAFFINITY":"c","SYS_SCHED_GETPARAM":"c","SYS_SCHED_GETSCHEDULER":"c","SYS_SCHED_GET_PRIORITY_MAX":"c","SYS_SCHED_GET_PRIORITY_MIN":"c","SYS_SCHED_RR_GET_INTERVAL":"c","SYS_SCHED_SETAFFINITY":"c","SYS_SCHED_SETPARAM":"c","SYS_SCHED_SETSCHEDULER":"c","SYS_SCHED_YIELD":"c","SYS_SECURITY":"c","SYS_SELECT":"c","SYS_SEMCTL":"c","SYS_SEMGET":"c","SYS_SEMOP":"c","SYS_SEMTIMEDOP":"c","SYS_SENDFILE":"c","SYS_SENDMSG":"c","SYS_SENDTO":"c","SYS_SETDOMAINNAME":"c","SYS_SETFSGID":"c","SYS_SETFSUID":"c","SYS_SETGID":"c","SYS_SETGROUPS":"c","SYS_SETHOSTNAME":"c","SYS_SETITIMER":"c","SYS_SETPGID":"c","SYS_SETPRIORITY":"c","SYS_SETREGID":"c","SYS_SETRESGID":"c","SYS_SETRESUID":"c","SYS_SETREUID":"c","SYS_SETRLIMIT":"c","SYS_SETSID":"c","SYS_SETSOCKOPT":"c","SYS_SETTIMEOFDAY":"c","SYS_SETUID":"c","SYS_SETXATTR":"c","SYS_SET_MEMPOLICY":"c","SYS_SET_ROBUST_LIST":"c","SYS_SET_THREAD_AREA":"c","SYS_SET_TID_ADDRESS":"c","SYS_SHMAT":"c","SYS_SHMCTL":"c","SYS_SHMDT":"c","SYS_SHMGET":"c","SYS_SHUTDOWN":"c","SYS_SIGALTSTACK":"c","SYS_SIGNALFD":"c","SYS_SIGNALFD4":"c","SYS_SOCKET":"c","SYS_SOCKETPAIR":"c","SYS_SPLICE":"c","SYS_STAT":"c","SYS_STATFS":"c","SYS_SWAPOFF":"c","SYS_SWAPON":"c","SYS_SYMLINK":"c","SYS_SYMLINKAT":"c","SYS_SYNC":"c","SYS_SYNC_FILE_RANGE":"c","SYS_SYSFS":"c","SYS_SYSINFO":"c","SYS_SYSLOG":"c","SYS_TEE":"c","SYS_TGKILL":"c","SYS_TIME":"c","SYS_TIMERFD_CREATE":"c","SYS_TIMERFD_GETTIME":"c","SYS_TIMERFD_SETTIME":"c","SYS_TIMER_CREATE":"c","SYS_TIMER_DELETE":"c","SYS_TIMER_GETOVERRUN":"c","SYS_TIMER_GETTIME":"c","SYS_TIMER_SETTIME":"c","SYS_TIMES":"c","SYS_TKILL":"c","SYS_TRUNCATE":"c","SYS_TUXCALL":"c","SYS_UMASK":"c","SYS_UMOUNT2":"c","SYS_UNAME":"c","SYS_UNLINK":"c","SYS_UNLINKAT":"c","SYS_UNSHARE":"c","SYS_USELIB":"c","SYS_USTAT":"c","SYS_UTIME":"c","SYS_UTIMENSAT":"c","SYS_UTIMES":"c","SYS_VFORK":"c","SYS_VHANGUP":"c","SYS_VMSPLICE":"c","SYS_VSERVER":"c","SYS_WAIT4":"c","SYS_WAITID":"c","SYS_WRITE":"c","SYS_WRITEV":"c","SYS__SYSCTL":"c","S_BLKSIZE":"c","S_IEXEC":"c","S_IFBLK":"c","S_IFCHR":"c","S_IFDIR":"c","S_IFIFO":"c","S_IFLNK":"c","S_IFMT":"c","S_IFREG":"c","S_IFSOCK":"c","S_IREAD":"c","S_IRGRP":"c","S_IROTH":"c","S_IRUSR":"c","S_IRWXG":"c","S_IRWXO":"c","S_IRWXU":"c","S_ISGID":"c","S_ISUID":"c","S_ISVTX":"c","S_IWGRP":"c","S_IWOTH":"c","S_IWRITE":"c","S_IWUSR":"c","S_IXGRP":"c","S_IXOTH":"c","S_IXUSR":"c","Seek":"f","Select":"f","Sendfile":"f","Sendmsg":"f","SendmsgN":"f","Sendto":"f","SetLsfPromisc":"f","SetNonblock":"f","Setdomainname":"f","Setegid":"f","Setenv":"f","Seteuid":"f","Setfsgid":"f","Setfsuid":"f","Setgid":"f","Setgroups":"f","Sethostname":"f","Setpgid":"f","Setpriority":"f","Setregid":"f","Setresgid":"f","Setresuid":"f","Setreuid":"f","Setrlimit":"f","Setsid":"f","SetsockoptByte":"f","SetsockoptICMPv6Filter":"f","SetsockoptIPMreq":"f","SetsockoptIPMreqn":"f","SetsockoptIPv6Mreq":"f","SetsockoptInet4Addr":"f","SetsockoptInt":"f","SetsockoptLinger":"f","SetsockoptString":"f","SetsockoptTimeval":"f","Settimeofday":"f","Setuid":"f","Setxattr":"f","Shutdown":"f","Signal":"t","Signal.Signal":"m","Signal.String":"m","SizeofCmsghdr":"c","SizeofICMPv6Filter":"c","SizeofIPMreq":"c","SizeofIPMreqn":"c","SizeofIPv6MTUInfo":"c","SizeofIPv6Mreq":"c","SizeofIfAddrmsg":"c","SizeofIfInfomsg":"c","SizeofInet4Pktinfo":"c","SizeofInet6Pktinfo":"c","SizeofInotifyEvent":"c","SizeofLinger":"c","SizeofMsghdr":"c","SizeofNlAttr":"c","SizeofNlMsgerr":"c","SizeofNlMsghdr":"c","SizeofRtAttr":"c","SizeofRtGenmsg":"c","SizeofRtMsg":"c","SizeofRtNexthop":"c","SizeofSockFilter":"c","SizeofSockFprog":"c","SizeofSockaddrAny":"c","SizeofSockaddrInet4":"c","SizeofSockaddrInet6":"c","SizeofSockaddrLinklayer":"c","SizeofSockaddrNetlink":"c","SizeofSockaddrUnix":"c","SizeofTCPInfo":"c","SizeofUcred":"c","SlicePtrFromStrings":"f","SockFilter":"t","SockFprog":"t","Sockaddr":"t","SockaddrInet4":"t","SockaddrInet6":"t","SockaddrLinklayer":"t","SockaddrNetlink":"t","SockaddrUnix":"t","Socket":"f","SocketControlMessage":"t","SocketDisableIPv6":"v","Socketpair":"f","Splice":"f","StartProcess":"f","Stat":"f","Stat_t":"t","Statfs":"f","Statfs_t":"t","Stderr":"v","Stdin":"v","Stdout":"v","StringBytePtr":"f","StringByteSlice":"f","StringSlicePtr":"f","Symlink":"f","Sync":"f","SyncFileRange":"f","SysProcAttr":"t","SysProcIDMap":"t","Syscall":"f","Syscall6":"f","Sysinfo":"f","Sysinfo_t":"t","TCGETS":"c","TCIFLUSH":"c","TCIOFLUSH":"c","TCOFLUSH":"c","TCPInfo":"t","TCP_CONGESTION":"c","TCP_CORK":"c","TCP_DEFER_ACCEPT":"c","TCP_INFO":"c","TCP_KEEPCNT":"c","TCP_KEEPIDLE":"c","TCP_KEEPINTVL":"c","TCP_LINGER2":"c","TCP_MAXSEG":"c","TCP_MAXWIN":"c","TCP_MAX_WINSHIFT":"c","TCP_MD5SIG":"c","TCP_MD5SIG_MAXKEYLEN":"c","TCP_MSS":"c","TCP_NODELAY":"c","TCP_QUICKACK":"c","TCP_SYNCNT":"c","TCP_WINDOW_CLAMP":"c","TCSETS":"c","TIOCCBRK":"c","TIOCCONS":"c","TIOCEXCL":"c","TIOCGDEV":"c","TIOCGETD":"c","TIOCGICOUNT":"c","TIOCGLCKTRMIOS":"c","TIOCGPGRP":"c","TIOCGPTN":"c","TIOCGRS485":"c","TIOCGSERIAL":"c","TIOCGSID":"c","TIOCGSOFTCAR":"c","TIOCGWINSZ":"c","TIOCINQ":"c","TIOCLINUX":"c","TIOCMBIC":"c","TIOCMBIS":"c","TIOCMGET":"c","TIOCMIWAIT":"c","TIOCMSET":"c","TIOCM_CAR":"c","TIOCM_CD":"c","TIOCM_CTS":"c","TIOCM_DSR":"c","TIOCM_DTR":"c","TIOCM_LE":"c","TIOCM_RI":"c","TIOCM_RNG":"c","TIOCM_RTS":"c","TIOCM_SR":"c","TIOCM_ST":"c","TIOCNOTTY":"c","TIOCNXCL":"c","TIOCOUTQ":"c","TIOCPKT":"c","TIOCPKT_DATA":"c","TIOCPKT_DOSTOP":"c","TIOCPKT_FLUSHREAD":"c","TIOCPKT_FLUSHWRITE":"c","TIOCPKT_IOCTL":"c","TIOCPKT_NOSTOP":"c","TIOCPKT_START":"c","TIOCPKT_STOP":"c","TIOCSBRK":"c","TIOCSCTTY":"c","TIOCSERCONFIG":"c","TIOCSERGETLSR":"c","TIOCSERGETMULTI":"c","TIOCSERGSTRUCT":"c","TIOCSERGWILD":"c","TIOCSERSETMULTI":"c","TIOCSERSWILD":"c","TIOCSER_TEMT":"c","TIOCSETD":"c","TIOCSIG":"c","TIOCSLCKTRMIOS":"c","TIOCSPGRP":"c","TIOCSPTLCK":"c","TIOCSRS485":"c","TIOCSSERIAL":"c","TIOCSSOFTCAR":"c","TIOCSTI":"c","TIOCSWINSZ":"c","TOSTOP":"c","TUNATTACHFILTER":"c","TUNDETACHFILTER":"c","TUNGETFEATURES":"c","TUNGETIFF":"c","TUNGETSNDBUF":"c","TUNGETVNETHDRSZ":"c","TUNSETDEBUG":"c","TUNSETGROUP":"c","TUNSETIFF":"c","TUNSETLINK":"c","TUNSETNOCSUM":"c","TUNSETOFFLOAD":"c","TUNSETOWNER":"c","TUNSETPERSIST":"c","TUNSETSNDBUF":"c","TUNSETTXFILTER":"c","TUNSETVNETHDRSZ":"c","Tee":"f","Termios":"t","Tgkill":"f","Time":"f","Time_t":"t","Times":"f","Timespec":"t","Timespec.Nano":"m","Timespec.Unix":"m","TimespecToNsec":"f","Timeval":"t","Timeval.Nano":"m","Timeval.Unix":"m","TimevalToNsec":"f","Timex":"t","Tms":"t","Truncate":"f","Ucred":"t","Umask":"f","Uname":"f","UnixCredentials":"f","UnixRights":"f","Unlink":"f","Unlinkat":"f","Unmount":"f","Unsetenv":"f","Unshare":"f","Ustat":"f","Ustat_t":"t","Utimbuf":"t","Utime":"f","Utimes":"f","UtimesNano":"f","Utsname":"t","VDISCARD":"c","VEOF":"c","VEOL":"c","VEOL2":"c","VERASE":"c","VINTR":"c","VKILL":"c","VLNEXT":"c","VMIN":"c","VQUIT":"c","VREPRINT":"c","VSTART":"c","VSTOP":"c","VSUSP":"c","VSWTC":"c","VTIME":"c","VWERASE":"c","WALL":"c","WCLONE":"c","WCONTINUED":"c","WEXITED":"c","WNOHANG":"c","WNOTHREAD":"c","WNOWAIT":"c","WORDSIZE":"c","WSTOPPED":"c","WUNTRACED":"c","Wait4":"f","WaitStatus":"t","WaitStatus.Continued":"m","WaitStatus.CoreDump":"m","WaitStatus.ExitStatus":"m","WaitStatus.Exited":"m","WaitStatus.Signal":"m","WaitStatus.Signaled":"m","WaitStatus.StopSignal":"m","WaitStatus.Stopped":"m","WaitStatus.TrapCause":"m","Write":"f","XCASE":"c"}},"testing":{"path":"testing","name":"testing","symbols":{"AllocsPerRun":"f","B":"t","B.Elapsed":"m","B.Loop":"m","B.ReportAllocs":"m","B.ReportMetric":"m","B.ResetTimer":"m","B.Run":"m","B.RunParallel":"m","B.SetBytes":"m","B.SetParallelism":"m","B.StartTimer":"m","B.StopTimer":"m","Benchmark":"f","BenchmarkResult":"t","BenchmarkResult.AllocedBytesPerOp":"m","BenchmarkResult.AllocsPerOp":"m","BenchmarkResult.MemString":"m","BenchmarkResult.NsPerOp":"m","BenchmarkResult.String":"m","Cover":"t","CoverBlock":"t","CoverMode":"f","Coverage":"f","F":"t","F.Add":"m","F.Fail":"m","F.Fuzz":"m","F.Helper":"m","F.Skipped":"m","Init":"f","InternalBenchmark":"t","InternalExample":"t","InternalFuzzTarget":"t","InternalTest":"t","M":"t","M.Run":"m","Main":"f","MainStart":"f","PB":"t","PB.Next":"m","RegisterCover":"f","RunBenchmarks":"f","RunExamples":"f","RunTests":"f","Short":"f","T":"t","T.Chdir":"m","T.Deadline":"m","T.Parallel":"m","T.Run":"m","T.Setenv":"m","TB":"t","Testing":"f","Verbose":"f"}},"testing/cryptotest":{"path":"testing/cryptotest","name":"cryptotest","symbols":{"SetGlobalRandom":"f"}},"testing/fstest":{"path":"testing/fstest","name":"fstest","symbols":{"MapFS":"t","MapFS.Glob":"m","MapFS.Lstat":"m","MapFS.Open":"m","MapFS.ReadDir":"m","MapFS.ReadFile":"m","MapFS.ReadLink":"m","MapFS.Stat":"m","MapFS.Sub":"m","MapFile":"t","TestFS":"f"}},"testing/iotest":{"path":"testing/iotest","name":"iotest","symbols":{"DataErrReader":"f","ErrReader":"f","ErrTimeout":"v","HalfReader":"f","NewReadLogger":"f","NewWriteLogger":"f","OneByteReader":"f","TestReader":"f","TimeoutReader":"f","TruncateWriter":"f"}},"testing/quick":{"path":"testing/quick","name":"quick","symbols":{"Check":"f","CheckEqual":"f","CheckEqualError":"t","CheckEqualError.Error":"m","CheckError":"t","CheckError.Error":"m","Config":"t","Generator":"t","SetupError":"t","SetupError.Error":"m","Value":"f"}},"testing/slogtest":{"path":"testing/slogtest","name":"slogtest","symbols":{"Run":"f","TestHandler":"f"}},"testing/synctest":{"path":"testing/synctest","name":"synctest","symbols":{"Sleep":"f","Test":"f","Wait":"f"}},"text/scanner":{"path":"text/scanner","name":"scanner","symbols":{"Char":"c","Comment":"c","EOF":"c","Float":"c","GoTokens":"c","GoWhitespace":"c","Ident":"c","Int":"c","Position":"t","Position.IsValid":"m","Position.String":"m","RawString":"c","ScanChars":"c","ScanComments":"c","ScanFloats":"c","ScanIdents":"c","ScanInts":"c","ScanRawStrings":"c","ScanStrings":"c","Scanner":"t","Scanner.Init":"m","Scanner.Next":"m","Scanner.Peek":"m","Scanner.Pos":"m","Scanner.Scan":"m","Scanner.TokenText":"m","SkipComments":"c","String":"c","TokenString":"f"}},"text/tabwriter":{"path":"text/tabwriter","name":"tabwriter","symbols":{"AlignRight":"c","Debug":"c","DiscardEmptyColumns":"c","Escape":"c","FilterHTML":"c","NewWriter":"f","StripEscape":"c","TabIndent":"c","Writer":"t","Writer.Flush":"m","Writer.Init":"m","Writer.Write":"m"}},"text/template":{"path":"text/template","name":"template","symbols":{"ExecError":"t","ExecError.Error":"m","ExecError.Unwrap":"m","FuncMap":"t","HTMLEscape":"f","HTMLEscapeString":"f","HTMLEscaper":"f","IsTrue":"f","JSEscape":"f","JSEscapeString":"f","JSEscaper":"f","Must":"f","New":"f","ParseFS":"f","ParseFiles":"f","ParseGlob":"f","Template":"t","Template.AddParseTree":"m","Template.Clone":"m","Template.DefinedTemplates":"m","Template.Delims":"m","Template.Execute":"m","Template.ExecuteTemplate":"m","Template.Funcs":"m","Template.Lookup":"m","Template.Name":"m","Template.New":"m","Template.Option":"m","Template.Parse":"m","Template.ParseFS":"m","Template.ParseFiles":"m","Template.ParseGlob":"m","Template.Templates":"m","URLQueryEscaper":"f"}},"text/template/parse":{"path":"text/template/parse","name":"parse","symbols":{"ActionNode":"t","ActionNode.Copy":"m","ActionNode.String":"m","BoolNode":"t","BoolNode.Copy":"m","BoolNode.String":"m","BranchNode":"t","BranchNode.Copy":"m","BranchNode.String":"m","BreakNode":"t","BreakNode.Copy":"m","BreakNode.String":"m","ChainNode":"t","ChainNode.Add":"m","ChainNode.Copy":"m","ChainNode.String":"m","CommandNode":"t","CommandNode.Copy":"m","CommandNode.String":"m","CommentNode":"t","CommentNode.Copy":"m","CommentNode.String":"m","ContinueNode":"t","ContinueNode.Copy":"m","ContinueNode.String":"m","DotNode":"t","DotNode.Copy":"m","DotNode.String":"m","DotNode.Type":"m","FieldNode":"t","FieldNode.Copy":"m","FieldNode.String":"m","IdentifierNode":"t","IdentifierNode.Copy":"m","IdentifierNode.SetPos":"m","IdentifierNode.SetTree":"m","IdentifierNode.String":"m","IfNode":"t","IfNode.Copy":"m","IsEmptyTree":"f","ListNode":"t","ListNode.Copy":"m","ListNode.CopyList":"m","ListNode.String":"m","Mode":"t","New":"f","NewIdentifier":"f","NilNode":"t","NilNode.Copy":"m","NilNode.String":"m","NilNode.Type":"m","Node":"t","NodeAction":"c","NodeBool":"c","NodeBreak":"c","NodeChain":"c","NodeCommand":"c","NodeComment":"c","NodeContinue":"c","NodeDot":"c","NodeField":"c","NodeIdentifier":"c","NodeIf":"c","NodeList":"c","NodeNil":"c","NodeNumber":"c","NodePipe":"c","NodeRange":"c","NodeString":"c","NodeTemplate":"c","NodeText":"c","NodeType":"t","NodeType.Type":"m","NodeVariable":"c","NodeWith":"c","NumberNode":"t","NumberNode.Copy":"m","NumberNode.String":"m","Parse":"f","ParseComments":"c","PipeNode":"t","PipeNode.Copy":"m","PipeNode.CopyPipe":"m","PipeNode.String":"m","Pos":"t","Pos.Position":"m","RangeNode":"t","RangeNode.Copy":"m","SkipFuncCheck":"c","StringNode":"t","StringNode.Copy":"m","StringNode.String":"m","TemplateNode":"t","TemplateNode.Copy":"m","TemplateNode.String":"m","TextNode":"t","TextNode.Copy":"m","TextNode.String":"m","Tree":"t","Tree.Copy":"m","Tree.ErrorContext":"m","Tree.Parse":"m","VariableNode":"t","VariableNode.Copy":"m","VariableNode.String":"m","WithNode":"t","WithNode.Copy":"m"}},"time":{"path":"time","name":"time","symbols":{"ANSIC":"c","After":"f","AfterFunc":"f","April":"c","August":"c","Date":"f","DateOnly":"c","DateTime":"c","December":"c","Duration":"t","Duration.Abs":"m","Duration.Hours":"m","Duration.Microseconds":"m","Duration.Milliseconds":"m","Duration.Minutes":"m","Duration.Nanoseconds":"m","Duration.Round":"m","Duration.Seconds":"m","Duration.String":"m","Duration.Truncate":"m","February":"c","FixedZone":"f","Friday":"c","Hour":"c","January":"c","July":"c","June":"c","Kitchen":"c","Layout":"c","LoadLocation":"f","LoadLocationFromTZData":"f","Local":"v","Location":"t","Location.String":"m","March":"c","May":"c","Microsecond":"c","Millisecond":"c","Minute":"c","Monday":"c","Month":"t","Month.String":"m","Nanosecond":"c","NewTicker":"f","NewTimer":"f","November":"c","Now":"f","October":"c","Parse":"f","ParseDuration":"f","ParseError":"t","ParseError.Error":"m","ParseInLocation":"f","RFC1123":"c","RFC1123Z":"c","RFC3339":"c","RFC3339Nano":"c","RFC822":"c","RFC822Z":"c","RFC850":"c","RubyDate":"c","Saturday":"c","Second":"c","September":"c","Since":"f","Sleep":"f","Stamp":"c","StampMicro":"c","StampMilli":"c","StampNano":"c","Sunday":"c","Thursday":"c","Tick":"f","Ticker":"t","Ticker.Reset":"m","Ticker.Stop":"m","Time":"t","Time.Add":"m","Time.AddDate":"m","Time.After":"m","Time.AppendBinary":"m","Time.AppendFormat":"m","Time.AppendText":"m","Time.Before":"m","Time.Clock":"m","Time.Compare":"m","Time.Date":"m","Time.Day":"m","Time.Equal":"m","Time.Format":"m","Time.GoString":"m","Time.GobDecode":"m","Time.GobEncode":"m","Time.Hour":"m","Time.ISOWeek":"m","Time.In":"m","Time.IsDST":"m","Time.IsZero":"m","Time.Local":"m","Time.Location":"m","Time.MarshalBinary":"m","Time.MarshalJSON":"m","Time.MarshalText":"m","Time.Minute":"m","Time.Month":"m","Time.Nanosecond":"m","Time.Round":"m","Time.Second":"m","Time.String":"m","Time.Sub":"m","Time.Truncate":"m","Time.UTC":"m","Time.Unix":"m","Time.UnixMicro":"m","Time.UnixMilli":"m","Time.UnixNano":"m","Time.UnmarshalBinary":"m","Time.UnmarshalJSON":"m","Time.UnmarshalText":"m","Time.Weekday":"m","Time.Year":"m","Time.YearDay":"m","Time.Zone":"m","Time.ZoneBounds":"m","TimeOnly":"c","Timer":"t","Timer.Reset":"m","Timer.Stop":"m","Tuesday":"c","UTC":"v","Unix":"f","UnixDate":"c","UnixMicro":"f","UnixMilli":"f","Until":"f","Wednesday":"c","Weekday":"t","Weekday.String":"m"}},"unicode":{"path":"unicode","name":"unicode","symbols":{"ASCII_Hex_Digit":"v","Adlam":"v","Ahom":"v","Anatolian_Hieroglyphs":"v","Arabic":"v","Armenian":"v","Avestan":"v","AzeriCase":"v","Balinese":"v","Bamum":"v","Bassa_Vah":"v","Batak":"v","Bengali":"v","Beria_Erfe":"v","Bhaiksuki":"v","Bidi_Control":"v","Bopomofo":"v","Brahmi":"v","Braille":"v","Buginese":"v","Buhid":"v","C":"v","Canadian_Aboriginal":"v","Carian":"v","CaseRange":"t","CaseRanges":"v","Categories":"v","CategoryAliases":"v","Caucasian_Albanian":"v","Cc":"v","Cf":"v","Chakma":"v","Cham":"v","Cherokee":"v","Chorasmian":"v","Cn":"v","Co":"v","Common":"v","Coptic":"v","Cs":"v","Cuneiform":"v","Cypriot":"v","Cypro_Minoan":"v","Cyrillic":"v","Dash":"v","Deprecated":"v","Deseret":"v","Devanagari":"v","Diacritic":"v","Digit":"v","Dives_Akuru":"v","Dogra":"v","Duployan":"v","Egyptian_Hieroglyphs":"v","Elbasan":"v","Elymaic":"v","Ethiopic":"v","Extender":"v","FoldCategory":"v","FoldScript":"v","Garay":"v","Georgian":"v","Glagolitic":"v","Gothic":"v","Grantha":"v","GraphicRanges":"v","Greek":"v","Gujarati":"v","Gunjala_Gondi":"v","Gurmukhi":"v","Gurung_Khema":"v","Han":"v","Hangul":"v","Hanifi_Rohingya":"v","Hanunoo":"v","Hatran":"v","Hebrew":"v","Hex_Digit":"v","Hiragana":"v","Hyphen":"v","IDS_Binary_Operator":"v","IDS_Trinary_Operator":"v","IDS_Unary_Operator":"v","ID_Compat_Math_Continue":"v","ID_Compat_Math_Start":"v","Ideographic":"v","Imperial_Aramaic":"v","In":"f","Inherited":"v","Inscriptional_Pahlavi":"v","Inscriptional_Parthian":"v","Is":"f","IsControl":"f","IsDigit":"f","IsGraphic":"f","IsLetter":"f","IsLower":"f","IsMark":"f","IsNumber":"f","IsOneOf":"f","IsPrint":"f","IsPunct":"f","IsSpace":"f","IsSymbol":"f","IsTitle":"f","IsUpper":"f","Javanese":"v","Join_Control":"v","Kaithi":"v","Kannada":"v","Katakana":"v","Kawi":"v","Kayah_Li":"v","Kharoshthi":"v","Khitan_Small_Script":"v","Khmer":"v","Khojki":"v","Khudawadi":"v","Kirat_Rai":"v","L":"v","LC":"v","Lao":"v","Latin":"v","Lepcha":"v","Letter":"v","Limbu":"v","Linear_A":"v","Linear_B":"v","Lisu":"v","Ll":"v","Lm":"v","Lo":"v","Logical_Order_Exception":"v","Lower":"v","LowerCase":"c","Lt":"v","Lu":"v","Lycian":"v","Lydian":"v","M":"v","Mahajani":"v","Makasar":"v","Malayalam":"v","Mandaic":"v","Manichaean":"v","Marchen":"v","Mark":"v","Masaram_Gondi":"v","MaxASCII":"c","MaxCase":"c","MaxLatin1":"c","MaxRune":"c","Mc":"v","Me":"v","Medefaidrin":"v","Meetei_Mayek":"v","Mende_Kikakui":"v","Meroitic_Cursive":"v","Meroitic_Hieroglyphs":"v","Miao":"v","Mn":"v","Modi":"v","Modifier_Combining_Mark":"v","Mongolian":"v","Mro":"v","Multani":"v","Myanmar":"v","N":"v","Nabataean":"v","Nag_Mundari":"v","Nandinagari":"v","Nd":"v","New_Tai_Lue":"v","Newa":"v","Nko":"v","Nl":"v","No":"v","Noncharacter_Code_Point":"v","Number":"v","Nushu":"v","Nyiakeng_Puachue_Hmong":"v","Ogham":"v","Ol_Chiki":"v","Ol_Onal":"v","Old_Hungarian":"v","Old_Italic":"v","Old_North_Arabian":"v","Old_Permic":"v","Old_Persian":"v","Old_Sogdian":"v","Old_South_Arabian":"v","Old_Turkic":"v","Old_Uyghur":"v","Oriya":"v","Osage":"v","Osmanya":"v","Other":"v","Other_Alphabetic":"v","Other_Default_Ignorable_Code_Point":"v","Other_Grapheme_Extend":"v","Other_ID_Continue":"v","Other_ID_Start":"v","Other_Lowercase":"v","Other_Math":"v","Other_Uppercase":"v","P":"v","Pahawh_Hmong":"v","Palmyrene":"v","Pattern_Syntax":"v","Pattern_White_Space":"v","Pau_Cin_Hau":"v","Pc":"v","Pd":"v","Pe":"v","Pf":"v","Phags_Pa":"v","Phoenician":"v","Pi":"v","Po":"v","Prepended_Concatenation_Mark":"v","PrintRanges":"v","Properties":"v","Ps":"v","Psalter_Pahlavi":"v","Punct":"v","Quotation_Mark":"v","Radical":"v","Range16":"t","Range32":"t","RangeTable":"t","Regional_Indicator":"v","Rejang":"v","ReplacementChar":"c","Runic":"v","S":"v","STerm":"v","Samaritan":"v","Saurashtra":"v","Sc":"v","Scripts":"v","Sentence_Terminal":"v","Sharada":"v","Shavian":"v","Siddham":"v","Sidetic":"v","SignWriting":"v","SimpleFold":"f","Sinhala":"v","Sk":"v","Sm":"v","So":"v","Soft_Dotted":"v","Sogdian":"v","Sora_Sompeng":"v","Soyombo":"v","Space":"v","SpecialCase":"t","SpecialCase.ToLower":"m","SpecialCase.ToTitle":"m","SpecialCase.ToUpper":"m","Sundanese":"v","Sunuwar":"v","Syloti_Nagri":"v","Symbol":"v","Syriac":"v","Tagalog":"v","Tagbanwa":"v","Tai_Le":"v","Tai_Tham":"v","Tai_Viet":"v","Tai_Yo":"v","Takri":"v","Tamil":"v","Tangsa":"v","Tangut":"v","Telugu":"v","Terminal_Punctuation":"v","Thaana":"v","Thai":"v","Tibetan":"v","Tifinagh":"v","Tirhuta":"v","Title":"v","TitleCase":"c","To":"f","ToLower":"f","ToTitle":"f","ToUpper":"f","Todhri":"v","Tolong_Siki":"v","Toto":"v","Tulu_Tigalari":"v","TurkishCase":"v","Ugaritic":"v","Unified_Ideograph":"v","Upper":"v","UpperCase":"c","UpperLower":"c","Vai":"v","Variation_Selector":"v","Version":"c","Vithkuqi":"v","Wancho":"v","Warang_Citi":"v","White_Space":"v","Yezidi":"v","Yi":"v","Z":"v","Zanabazar_Square":"v","Zl":"v","Zp":"v","Zs":"v"}},"unicode/utf16":{"path":"unicode/utf16","name":"utf16","symbols":{"AppendRune":"f","Decode":"f","DecodeRune":"f","Encode":"f","EncodeRune":"f","IsSurrogate":"f","RuneLen":"f"}},"unicode/utf8":{"path":"unicode/utf8","name":"utf8","symbols":{"AppendRune":"f","DecodeLastRune":"f","DecodeLastRuneInString":"f","DecodeRune":"f","DecodeRuneInString":"f","EncodeRune":"f","FullRune":"f","FullRuneInString":"f","MaxRune":"c","RuneCount":"f","RuneCountInString":"f","RuneError":"c","RuneLen":"f","RuneSelf":"c","RuneStart":"f","UTFMax":"c","Valid":"f","ValidRune":"f","ValidString":"f"}},"unique":{"path":"unique","name":"unique","symbols":{"Handle":"t","Make":"f"}},"unsafe":{"path":"unsafe","name":"unsafe","symbols":{"Add":"f","Alignof":"f","ArbitraryType":"t","IntegerType":"t","Offsetof":"f","Pointer":"t","Sizeof":"f","Slice":"f","SliceData":"f","String":"f","StringData":"f"}},"uuid":{"path":"uuid","name":"uuid","symbols":{"Max":"f","MustParse":"f","New":"f","NewV4":"f","NewV7":"f","Nil":"f","Parse":"f","UUID":"t","UUID.AppendText":"m","UUID.Compare":"m","UUID.MarshalText":"m","UUID.String":"m","UUID.UnmarshalText":"m"}},"weak":{"path":"weak","name":"weak","symbols":{"Make":"f","Pointer":"t"}}}
\ No newline at end of file
diff --git a/vendor/github.com/godoc-lint/godoc-lint/pkg/check/stdlib_doclink/stdlib_doclink.go b/vendor/github.com/godoc-lint/godoc-lint/pkg/check/stdlib_doclink/stdlib_doclink.go
new file mode 100644
index 0000000000..03252c43ee
--- /dev/null
+++ b/vendor/github.com/godoc-lint/godoc-lint/pkg/check/stdlib_doclink/stdlib_doclink.go
@@ -0,0 +1,315 @@
+// Package stdlib_doclink provides a checker for detecting potential doc links
+// to standard library symbols.
+package stdlib_doclink
+
+import (
+ "fmt"
+ gdc "go/doc/comment"
+ "maps"
+ "regexp"
+ "slices"
+ "strconv"
+ "strings"
+
+ "github.com/godoc-lint/godoc-lint/pkg/check/stdlib_doclink/internal"
+ "github.com/godoc-lint/godoc-lint/pkg/model"
+ "github.com/godoc-lint/godoc-lint/pkg/util"
+)
+
+// RequireStdlibDoclinkRule is the corresponding rule name.
+const RequireStdlibDoclinkRule = model.RequireStdlibDoclinkRule
+
+var ruleSet = model.RuleSet{}.Add(RequireStdlibDoclinkRule)
+
+// StdlibDoclinkChecker checks for proper doc links to stdlib symbols.
+type StdlibDoclinkChecker struct{}
+
+// NewStdlibDoclinkChecker returns a new instance of the corresponding checker.
+func NewStdlibDoclinkChecker() *StdlibDoclinkChecker {
+ return &StdlibDoclinkChecker{}
+}
+
+// GetCoveredRules implements the corresponding interface method.
+func (r *StdlibDoclinkChecker) GetCoveredRules() model.RuleSet {
+ return ruleSet
+}
+
+// Apply implements the corresponding interface method.
+func (r *StdlibDoclinkChecker) Apply(actx *model.AnalysisContext) error {
+ includeTests := actx.Config.GetRuleOptions().RequireStdlibDoclinkIncludeTests
+
+ docs := make(map[*model.CommentGroup]struct{}, 10*len(actx.InspectorResult.Files))
+
+ for _, ir := range util.AnalysisApplicableFiles(actx, includeTests, model.RuleSet{}.Add(RequireStdlibDoclinkRule)) {
+ if ir.PackageDoc != nil {
+ docs[ir.PackageDoc] = struct{}{}
+ }
+
+ for _, sd := range ir.SymbolDecl {
+ if sd.ParentDoc != nil {
+ docs[sd.ParentDoc] = struct{}{}
+ }
+ if sd.Doc == nil {
+ continue
+ }
+ docs[sd.Doc] = struct{}{}
+ }
+ }
+
+ if len(docs) == 0 {
+ return nil
+ }
+
+ stdlib := stdlib()
+ pi := packageImports{
+ importAsMap: make(map[string]string, 10),
+ badImportAs: make(map[string]struct{}, 10),
+ }
+
+ for _, f := range actx.Pass.Files {
+ ft := util.GetPassFileToken(f, actx.Pass)
+ if ft == nil {
+ continue
+ }
+
+ for _, imp := range f.Imports {
+ path, _ := strconv.Unquote(imp.Path.Value)
+ s, ok := stdlib[path]
+ if !ok {
+ // It's not a stdlib package.
+ continue
+ }
+
+ var importedAs string
+ if imp.Name != nil {
+ alias := imp.Name.Name
+ if alias == "" || alias == "." || alias == "_" {
+ // We don't support _ or . imports.
+ continue
+ }
+ importedAs = alias
+ } else {
+ importedAs = s.Name
+ }
+
+ if alreadyImportedPath, ok := pi.importAsMap[importedAs]; ok && alreadyImportedPath != path {
+ // Different import paths with the same alias(es); we don't support this case.
+ // It happens when people do aliasing like this:
+ //
+ // (foo.go)
+ // import blah "path/to/package"
+ //
+ // (bar.go)
+ // import blah "path/to/another/package"
+ //
+ // It's not inherently wrong, but due to the go doc tool's package-wide way of
+ // resolving package names in doc links (i.e. pkg in [pkg.name] or [pkg.recv.name])
+ // it'll not work in such collision cases. As a result, doc links with colliding
+ // package aliases get rendered as plain text instead of links.
+ pi.badImportAs[importedAs] = struct{}{}
+ continue
+ }
+
+ pi.importAsMap[importedAs] = path
+ }
+ }
+
+ for doc := range docs {
+ checkStdlibDoclink(actx, &pi, doc)
+ }
+ return nil
+}
+
+type packageImports struct {
+ importAsMap map[string]string
+ badImportAs map[string]struct{}
+}
+
+func checkStdlibDoclink(
+ actx *model.AnalysisContext,
+ pi *packageImports,
+ doc *model.CommentGroup,
+) {
+ if doc.DisabledRules.All || doc.DisabledRules.Rules.Has(RequireStdlibDoclinkRule) {
+ return
+ }
+
+ applicableBlocks := make([]gdc.Block, 0, len(doc.Parsed.Content))
+ for _, b := range doc.Parsed.Content {
+ if _, ok := b.(*gdc.Code); ok {
+ continue
+ }
+ // Doc links are not picked up in headings.
+ if _, ok := b.(*gdc.Heading); ok {
+ continue
+ }
+ applicableBlocks = append(applicableBlocks, b)
+ }
+ strippedCodeAndLinks := &gdc.Doc{
+ Content: applicableBlocks,
+ }
+ text := string((&gdc.Printer{}).Comment(strippedCodeAndLinks))
+
+ pds := findPotentialDoclinks(pi, text)
+ if len(pds) == 0 {
+ return
+ }
+
+ for _, pd := range pds {
+ var count string
+ if pd.count > 1 {
+ count = fmt.Sprintf(" (%d instances)", pd.count)
+ }
+
+ actx.Pass.ReportRangef(&doc.CG, "text %q should be replaced with %q to link to stdlib %s%s", pd.originalNoStar, pd.doclink, kindTitle(pd.kind), count)
+ }
+}
+
+func kindTitle(kind internal.SymbolKind) string {
+ switch kind {
+ case internal.SymbolKindType:
+ return "type"
+ case internal.SymbolKindFunc:
+ return "function"
+ case internal.SymbolKindVar:
+ return "variable"
+ case internal.SymbolKindConst:
+ return "constant"
+ case internal.SymbolKindMethod:
+ return "method"
+ default:
+ return "symbol"
+ }
+}
+
+type potentialDoclink struct {
+ originalNoStar string // e.g. "encoding/json.Encoder" or "json.Encoder" (if imported as such)
+ count int
+ doclink string
+ kind internal.SymbolKind
+}
+
+var potentialDoclinkRE = regexp.MustCompile(`(?m)(?:^|\s)(\*?)([a-zA-Z_][a-zA-Z0-9_]*(?:/[a-zA-Z_][a-zA-Z0-9_]*)*)\.([a-zA-Z0-9_]+)(?:\.([a-zA-Z0-9_]+))?\b`)
+
+func findPotentialDoclinks(pi *packageImports, text string) []*potentialDoclink {
+ stdlib := stdlib()
+
+ m := make(map[string]*potentialDoclink, 5)
+
+ matches := potentialDoclinkRE.FindAllStringSubmatch(text, -1)
+ for _, match := range matches {
+ _ = match[1] // star, if any
+ pkg := match[2]
+ name1 := match[3]
+ name2 := match[4]
+
+ if pkg != "" && name1 != "" && name2 != "" {
+ // pkg.recv.name (= pkg.name1.name2)
+
+ path := pi.tryResolveImportPath(pkg)
+ if path == "" {
+ // Colliding import alias/name; skip.
+ continue
+ }
+
+ s, ok := stdlib[path]
+ if !ok {
+ continue
+ }
+
+ kind, ok := s.Symbols[name1+"."+name2]
+ if !ok {
+ continue
+ }
+
+ originalNoStar := fmt.Sprintf("%s.%s.%s", pkg, name1, name2)
+ if _, ok := m[originalNoStar]; !ok {
+ doclink := fmt.Sprintf("[%s]", originalNoStar)
+ m[originalNoStar] = &potentialDoclink{
+ originalNoStar: originalNoStar,
+ doclink: doclink,
+ kind: kind,
+ }
+ }
+ m[originalNoStar].count++
+ } else if pkg != "" && name1 != "" && name2 == "" {
+ // pkg.name (= pkg.name1)
+
+ path := pi.tryResolveImportPath(pkg)
+ if path == "" {
+ // Colliding import alias/name; skip.
+ continue
+ }
+
+ s, ok := stdlib[path]
+ if !ok {
+ continue
+ }
+
+ kind, ok := s.Symbols[name1]
+ if !ok {
+ continue
+ }
+
+ originalNoStar := fmt.Sprintf("%s.%s", pkg, name1)
+ if _, ok := m[originalNoStar]; !ok {
+ doclink := fmt.Sprintf("[%s]", originalNoStar)
+ m[originalNoStar] = &potentialDoclink{
+ originalNoStar: originalNoStar,
+ doclink: doclink,
+ kind: kind,
+ }
+ }
+ m[originalNoStar].count++
+ }
+ }
+
+ if len(m) == 0 {
+ return nil
+ }
+
+ return slices.SortedFunc(maps.Values(m), func(a, b *potentialDoclink) int {
+ return strings.Compare(a.originalNoStar, b.originalNoStar)
+ })
+}
+
+// tryResolveImportPath tries to resolve the given package alias/name to its
+// import path (package-wide lookup of imports). If the alias/name was among the
+// existing imports, the method will return the underlying import path;
+// otherwise it'll return the given argument as is.
+//
+// If the package alias/name is among bad/colliding imports, an empty string is
+// returned.
+//
+// When spotting potential doc links like "pkg.name" or "pkg.recv.name", we
+// should resolve the "pkg" part to the underlying import path. Not only that
+// users can have a totally new/unknown alias for a stdlib package import, like:
+//
+// import blah "encoding/json"
+//
+// they can also use another stdlib package's name as the alias, like:
+//
+// import fmt "encoding/json"
+//
+// This is obviously rare, but still a valid use of language.
+//
+// Additionally, when importing slashed package paths, like "encoding/json",
+// the package will be available as "json" by default; i.e.:
+//
+// import "encoding/json"
+//
+// So, the actual package is not always evident from the import alias/name, so
+// we need to carefully resolve the "pkg" part.
+func (pi *packageImports) tryResolveImportPath(pkg string) string {
+ path, ok := pi.importAsMap[pkg]
+ if ok {
+ if _, isBad := pi.badImportAs[pkg]; isBad {
+ // We have different import paths with the same alias.
+ return ""
+ }
+ return path
+ }
+
+ // Given "pkg" is not among existing imports.
+ return pkg
+}
diff --git a/vendor/github.com/godoc-lint/godoc-lint/pkg/compose/compose.go b/vendor/github.com/godoc-lint/godoc-lint/pkg/compose/compose.go
new file mode 100644
index 0000000000..7ec04e3494
--- /dev/null
+++ b/vendor/github.com/godoc-lint/godoc-lint/pkg/compose/compose.go
@@ -0,0 +1,53 @@
+// Package compose provides composition of the linter components.
+package compose
+
+import (
+ "os"
+
+ "github.com/godoc-lint/godoc-lint/pkg/analysis"
+ "github.com/godoc-lint/godoc-lint/pkg/check"
+ "github.com/godoc-lint/godoc-lint/pkg/config"
+ "github.com/godoc-lint/godoc-lint/pkg/inspect"
+ "github.com/godoc-lint/godoc-lint/pkg/model"
+)
+
+// Composition holds the composed components of the linter.
+type Composition struct {
+ Registry model.Registry
+ ConfigBuilder model.ConfigBuilder
+ Inspector model.Inspector
+ Analyzer model.Analyzer
+}
+
+// CompositionConfig holds the configuration for composing the linter.
+type CompositionConfig struct {
+ BaseDir string
+ ExitFunc func(int, error)
+
+ // BaseDirPlainConfig holds the plain configuration for the base directory.
+ //
+ // This is meant to be used for integrating with umbrella linters (e.g.
+ // golangci-lint) where the root config comes from a different source/format.
+ BaseDirPlainConfig *config.PlainConfig
+}
+
+// Compose composes the linter components based on the given configuration.
+func Compose(c CompositionConfig) *Composition {
+ if c.BaseDir == "" {
+ // It's a best effort to use the current working directory if not set.
+ c.BaseDir, _ = os.Getwd()
+ }
+
+ reg := check.NewPopulatedRegistry()
+ cb := config.NewConfigBuilder(c.BaseDir).WithBaseDirPlainConfig(c.BaseDirPlainConfig)
+ ocb := config.NewOnceConfigBuilder(cb)
+ inspector := inspect.NewInspector(ocb, c.ExitFunc)
+ analyzer := analysis.NewAnalyzer(c.BaseDir, ocb, reg, inspector, c.ExitFunc)
+
+ return &Composition{
+ Registry: reg,
+ ConfigBuilder: cb,
+ Inspector: inspector,
+ Analyzer: analyzer,
+ }
+}
diff --git a/vendor/github.com/godoc-lint/godoc-lint/pkg/config/builder.go b/vendor/github.com/godoc-lint/godoc-lint/pkg/config/builder.go
new file mode 100644
index 0000000000..6bee946a77
--- /dev/null
+++ b/vendor/github.com/godoc-lint/godoc-lint/pkg/config/builder.go
@@ -0,0 +1,327 @@
+package config
+
+import (
+ "errors"
+ "fmt"
+ "os"
+ "path/filepath"
+ "regexp"
+ "slices"
+
+ "github.com/godoc-lint/godoc-lint/pkg/model"
+ "github.com/godoc-lint/godoc-lint/pkg/util"
+)
+
+// ConfigBuilder implements a configuration builder.
+type ConfigBuilder struct {
+ baseDir string
+ override *model.ConfigOverride
+
+ // baseDirPlainConfig holds the plain config for the base directory.
+ //
+ // This is meant to be used for integrating with umbrella linters (e.g.
+ // golangci-lint) where the root config comes from a different
+ // source/format.
+ baseDirPlainConfig *PlainConfig
+}
+
+// NewConfigBuilder crates a new instance of the corresponding struct.
+func NewConfigBuilder(baseDir string) *ConfigBuilder {
+ return &ConfigBuilder{
+ baseDir: baseDir,
+ }
+}
+
+// WithBaseDirPlainConfig sets the plain config for the base directory. This is
+// meant to be used for integrating with umbrella linters (e.g. golangci-lint)
+// where the root config comes from a different source/format.
+func (cb *ConfigBuilder) WithBaseDirPlainConfig(baseDirPlainConfig *PlainConfig) *ConfigBuilder {
+ cb.baseDirPlainConfig = baseDirPlainConfig
+ return cb
+}
+
+// GetConfig implements the corresponding interface method.
+func (cb *ConfigBuilder) GetConfig(cwd string) (model.Config, error) {
+ return cb.build(cwd)
+}
+
+func (cb *ConfigBuilder) resolvePlainConfig(cwd string) (*PlainConfig, *PlainConfig, string, string, error) {
+ def := getDefaultPlainConfig()
+
+ if !util.IsPathUnderBaseDir(cb.baseDir, cwd) {
+ if pcfg, filePath, err := cb.resolvePlainConfigAtBaseDir(); err != nil {
+ return nil, nil, "", "", err
+ } else if pcfg != nil {
+ return pcfg, def, cb.baseDir, filePath, nil
+ }
+ return def, def, cb.baseDir, "", nil
+ }
+
+ path := cwd
+ for {
+ rel, err := filepath.Rel(cb.baseDir, path)
+ if err != nil {
+ return nil, nil, "", "", err
+ }
+
+ if rel == "." {
+ if pcfg, filePath, err := cb.resolvePlainConfigAtBaseDir(); err != nil {
+ return nil, nil, "", "", err
+ } else if pcfg != nil {
+ return pcfg, def, cb.baseDir, filePath, nil
+ }
+ return def, def, cb.baseDir, "", nil
+ }
+
+ if pcfg, filePath, err := findConventionalConfigFile(path); err != nil {
+ return nil, nil, "", "", err
+ } else if pcfg != nil {
+ return pcfg, def, path, filePath, nil
+ }
+
+ path = filepath.Dir(path)
+ }
+}
+
+func (cb *ConfigBuilder) resolvePlainConfigAtBaseDir() (*PlainConfig, string, error) {
+ // TODO(babakks): refactor this to a sync.OnceValue for performance
+
+ if cb.override != nil && cb.override.ConfigFilePath != nil {
+ pcfg, err := FromYAMLFile(*cb.override.ConfigFilePath)
+ if err != nil {
+ return nil, "", err
+ }
+ return pcfg, *cb.override.ConfigFilePath, nil
+ }
+
+ if pcfg, filePath, err := findConventionalConfigFile(cb.baseDir); err != nil {
+ return nil, "", err
+ } else if pcfg != nil {
+ return pcfg, filePath, nil
+ }
+
+ if cb.baseDirPlainConfig != nil {
+ return cb.baseDirPlainConfig, "", nil
+ }
+ return nil, "", nil
+}
+
+func findConventionalConfigFile(dir string) (*PlainConfig, string, error) {
+ for _, dcf := range defaultConfigFiles {
+ path := filepath.Join(dir, dcf)
+ if fi, err := os.Stat(path); err != nil || fi.IsDir() {
+ continue
+ }
+ pcfg, err := FromYAMLFile(path)
+ if err != nil {
+ return nil, "", err
+ }
+ return pcfg, path, nil
+ }
+ return nil, "", nil
+}
+
+// build creates the configuration struct.
+//
+// It checks a sequence of sources:
+// 1. Custom config file path
+// 2. Default configuration files (e.g., `.godoc-lint.yaml`)
+//
+// If none was available, the default configuration will be returned.
+//
+// The method also does the following:
+// - Applies override flags (e.g., enable, or disable).
+// - Validates the final configuration.
+func (cb *ConfigBuilder) build(cwd string) (*config, error) {
+ pcfg, def, configCWD, configFilePath, err := cb.resolvePlainConfig(cwd)
+ if err != nil {
+ return nil, err
+ }
+
+ if err := pcfg.Validate(); err != nil {
+ return nil, fmt.Errorf("invalid config at %q: %w", configFilePath, err)
+ }
+
+ toValidRuleSet := func(s []string) (*model.RuleSet, []string) {
+ if s == nil {
+ return nil, nil
+ }
+ invalids := make([]string, 0, len(s))
+ rules := make([]model.Rule, 0, len(s))
+ for _, v := range s {
+ if !model.AllRules.Has(model.Rule(v)) {
+ invalids = append(invalids, v)
+ continue
+ }
+ rules = append(rules, model.Rule(v))
+ }
+ set := model.RuleSet{}.Add(rules...)
+ return &set, invalids
+ }
+
+ toValidRegexpSlice := func(s []string) ([]*regexp.Regexp, []string) {
+ if s == nil {
+ return nil, nil
+ }
+ var invalids []string
+ var regexps []*regexp.Regexp
+ for _, v := range s {
+ re, err := regexp.Compile(v)
+ if err != nil {
+ invalids = append(invalids, v)
+ continue
+ }
+ regexps = append(regexps, re)
+ }
+ return regexps, invalids
+ }
+
+ var errs []error
+
+ result := &config{
+ cwd: configCWD,
+ configFilePath: configFilePath,
+ }
+
+ var enabledRules *model.RuleSet
+ if cb.override != nil && cb.override.Enable != nil {
+ enabledRules = cb.override.Enable
+ } else {
+ raw := pcfg.Enable
+ if raw == nil {
+ raw = def.Enable
+ }
+ rs, invalids := toValidRuleSet(raw)
+ if len(invalids) > 0 {
+ errs = append(errs, fmt.Errorf("invalid rule(s) name to enable: %q", invalids))
+ } else {
+ enabledRules = rs
+ }
+ }
+
+ var disabledRules *model.RuleSet
+ if cb.override != nil && cb.override.Disable != nil {
+ disabledRules = cb.override.Disable
+ } else {
+ raw := pcfg.Disable
+ if raw == nil {
+ raw = def.Disable
+ }
+ rs, invalids := toValidRuleSet(raw)
+ if len(invalids) > 0 {
+ errs = append(errs, fmt.Errorf("invalid rule(s) name to disable: %q", invalids))
+ } else {
+ disabledRules = rs
+ }
+ }
+
+ if cb.override != nil && cb.override.Include != nil {
+ result.includeAsRegexp = cb.override.Include
+ } else {
+ raw := pcfg.Include
+ if raw == nil {
+ raw = def.Include
+ }
+ rs, invalids := toValidRegexpSlice(raw)
+ if len(invalids) > 0 {
+ errs = append(errs, fmt.Errorf("invalid path pattern(s) to include: %q", invalids))
+ } else {
+ result.includeAsRegexp = rs
+ }
+ }
+
+ if cb.override != nil && cb.override.Exclude != nil {
+ result.excludeAsRegexp = cb.override.Exclude
+ } else {
+ raw := pcfg.Exclude
+ if raw == nil {
+ raw = def.Exclude
+ }
+ rs, invalids := toValidRegexpSlice(raw)
+ if len(invalids) > 0 {
+ errs = append(errs, fmt.Errorf("invalid path pattern(s) to exclude: %q", invalids))
+ } else {
+ result.excludeAsRegexp = rs
+ }
+ }
+
+ if cb.override != nil && cb.override.Default != nil {
+ result.rulesToApply = model.DefaultSetToRules[*cb.override.Default]
+ } else {
+ raw := pcfg.Default
+ if raw == nil {
+ raw = def.Default // never nil
+ }
+
+ if !slices.Contains(model.DefaultSetValues, model.DefaultSet(*raw)) {
+ errs = append(errs, fmt.Errorf("invalid default set %q; must be one of %q", *raw, model.DefaultSetValues))
+ } else {
+ result.rulesToApply = model.DefaultSetToRules[model.DefaultSet(*raw)]
+ }
+ }
+
+ var maxLenIgnore []*regexp.Regexp
+ rawMaxLenIgnore := def.Options.MaxLenIgnorePatterns
+ if pcfg.Options != nil && pcfg.Options.MaxLenIgnorePatterns != nil {
+ rawMaxLenIgnore = pcfg.Options.MaxLenIgnorePatterns
+ }
+ if len(rawMaxLenIgnore) > 0 {
+ rs, invalids := toValidRegexpSlice(rawMaxLenIgnore)
+ if len(invalids) > 0 {
+ errs = append(errs, fmt.Errorf("invalid max-len ignore pattern(s): %q", invalids))
+ } else {
+ maxLenIgnore = rs
+ }
+ }
+
+ if errs != nil {
+ return nil, errors.Join(errs...)
+ }
+
+ if enabledRules != nil {
+ result.rulesToApply = result.rulesToApply.Merge(*enabledRules)
+ }
+ if disabledRules != nil {
+ result.rulesToApply = result.rulesToApply.Remove(disabledRules.List()...)
+ }
+
+ // To avoid being too strict, we don't complain if a rule is enabled and disabled at the same time.
+
+ resolvedOptions := &model.RuleOptions{}
+ transferPrimitiveOptions(resolvedOptions, def.Options) // def.Options is never nil
+ if pcfg.Options != nil {
+ transferPrimitiveOptions(resolvedOptions, pcfg.Options)
+ }
+ resolvedOptions.MaxLenIgnorePatterns = maxLenIgnore
+
+ result.options = resolvedOptions
+
+ return result, nil
+}
+
+// SetOverride implements the corresponding interface method.
+func (cb *ConfigBuilder) SetOverride(override *model.ConfigOverride) {
+ cb.override = override
+}
+
+func transferPrimitiveOptions(target *model.RuleOptions, source *PlainRuleOptions) {
+ transferIfNotNil(&target.MaxLenLength, source.MaxLenLength)
+ transferIfNotNil(&target.MaxLenIncludeTests, source.MaxLenIncludeTests)
+ transferIfNotNil(&target.PkgDocIncludeTests, source.PkgDocIncludeTests)
+ transferIfNotNil(&target.SinglePkgDocIncludeTests, source.SinglePkgDocIncludeTests)
+ transferIfNotNil(&target.RequirePkgDocIncludeTests, source.RequirePkgDocIncludeTests)
+ transferIfNotNil(&target.RequireDocIncludeTests, source.RequireDocIncludeTests)
+ transferIfNotNil(&target.RequireDocIgnoreExported, source.RequireDocIgnoreExported)
+ transferIfNotNil(&target.RequireDocIgnoreUnexported, source.RequireDocIgnoreUnexported)
+ transferIfNotNil(&target.StartWithNameIncludeTests, source.StartWithNameIncludeTests)
+ transferIfNotNil(&target.StartWithNameIncludeUnexported, source.StartWithNameIncludeUnexported)
+ transferIfNotNil(&target.RequireStdlibDoclinkIncludeTests, source.RequireStdlibDoclinkIncludeTests)
+ transferIfNotNil(&target.NoUnusedLinkIncludeTests, source.NoUnusedLinkIncludeTests)
+}
+
+func transferIfNotNil[T any](dst, src *T) {
+ if src == nil {
+ return
+ }
+ *dst = *src
+}
diff --git a/vendor/github.com/godoc-lint/godoc-lint/pkg/config/config.go b/vendor/github.com/godoc-lint/godoc-lint/pkg/config/config.go
new file mode 100644
index 0000000000..9a2cdfc603
--- /dev/null
+++ b/vendor/github.com/godoc-lint/godoc-lint/pkg/config/config.go
@@ -0,0 +1,73 @@
+package config
+
+import (
+ "path/filepath"
+ "regexp"
+
+ "github.com/godoc-lint/godoc-lint/pkg/model"
+)
+
+// config represents the godoc-lint analyzer configuration.
+type config struct {
+ // cwd holds the directory that the configuration is applied to. This is the
+ // way to find out relative paths to include/exclude based on the config
+ // file.
+ cwd string
+
+ // configFilePath holds the path to the configuration file. If there is no
+ // configuration file, which is the case when the default is used, this will
+ // be an empty string.
+ configFilePath string
+
+ includeAsRegexp []*regexp.Regexp
+ excludeAsRegexp []*regexp.Regexp
+ rulesToApply model.RuleSet
+ options *model.RuleOptions
+}
+
+// GetConfigFilePath implements the corresponding interface method.
+func (c *config) GetConfigFilePath() string {
+ return c.configFilePath
+}
+
+// GetCWD implements the corresponding interface method.
+func (c *config) GetCWD() string {
+ return c.cwd
+}
+
+// IsAnyRuleApplicable implements the corresponding interface method.
+func (c *config) IsAnyRuleApplicable(rs model.RuleSet) bool {
+ return c.rulesToApply.HasCommonsWith(rs)
+}
+
+// IsPathApplicable implements the corresponding interface method.
+func (c *config) IsPathApplicable(path string) bool {
+ p, err := filepath.Rel(c.cwd, path)
+ if err != nil {
+ p = path
+ }
+
+ // To ensure a consistent behavior on different platform (with the same
+ // configuration), we convert the path to a Unix-style path.
+ asUnixPath := filepath.ToSlash(p)
+
+ for _, re := range c.excludeAsRegexp {
+ if re.MatchString(asUnixPath) {
+ return false
+ }
+ }
+ if c.includeAsRegexp == nil {
+ return true
+ }
+ for _, re := range c.includeAsRegexp {
+ if re.MatchString(asUnixPath) {
+ return true
+ }
+ }
+ return false
+}
+
+// GetRuleOptions implements the corresponding interface method.
+func (c *config) GetRuleOptions() *model.RuleOptions {
+ return c.options
+}
diff --git a/vendor/github.com/godoc-lint/godoc-lint/pkg/config/default.go b/vendor/github.com/godoc-lint/godoc-lint/pkg/config/default.go
new file mode 100644
index 0000000000..79ba8b670c
--- /dev/null
+++ b/vendor/github.com/godoc-lint/godoc-lint/pkg/config/default.go
@@ -0,0 +1,28 @@
+package config
+
+import (
+ _ "embed"
+ "sync"
+)
+
+// defaultConfigFiles is the list of default configuration file names.
+var defaultConfigFiles = []string{
+ ".godoc-lint.yaml",
+ ".godoc-lint.yml",
+ ".godoc-lint.json",
+ ".godoclint.yaml",
+ ".godoclint.yml",
+ ".godoclint.json",
+}
+
+// defaultConfigYAML is the default configuration (as YAML).
+//
+//go:embed default.yaml
+var defaultConfigYAML []byte
+
+// getDefaultPlainConfig returns the parsed default configuration.
+var getDefaultPlainConfig = sync.OnceValue(func() *PlainConfig {
+ // Error is nil due to tests.
+ pcfg, _ := FromYAML(defaultConfigYAML)
+ return pcfg
+})
diff --git a/vendor/github.com/godoc-lint/godoc-lint/pkg/config/default.yaml b/vendor/github.com/godoc-lint/godoc-lint/pkg/config/default.yaml
new file mode 100644
index 0000000000..967897836a
--- /dev/null
+++ b/vendor/github.com/godoc-lint/godoc-lint/pkg/config/default.yaml
@@ -0,0 +1,17 @@
+# Default configuration
+version: "1.0"
+default: basic
+options:
+ max-len/length: 77
+ max-len/include-tests: false
+ max-len/ignore-patterns: []
+ pkg-doc/include-tests: false
+ single-pkg-doc/include-tests: false
+ require-pkg-doc/include-tests: false
+ require-doc/include-tests: false
+ require-doc/ignore-exported: false
+ require-doc/ignore-unexported: true
+ start-with-name/include-tests: false
+ start-with-name/include-unexported: false
+ require-stdlib-doclink/include-tests: false
+ no-unused-link/include-tests: false
\ No newline at end of file
diff --git a/vendor/github.com/godoc-lint/godoc-lint/pkg/config/doc.go b/vendor/github.com/godoc-lint/godoc-lint/pkg/config/doc.go
new file mode 100644
index 0000000000..3a015d9899
--- /dev/null
+++ b/vendor/github.com/godoc-lint/godoc-lint/pkg/config/doc.go
@@ -0,0 +1,2 @@
+// Package config provides configuration building and management.
+package config
diff --git a/vendor/github.com/godoc-lint/godoc-lint/pkg/config/once.go b/vendor/github.com/godoc-lint/godoc-lint/pkg/config/once.go
new file mode 100644
index 0000000000..2d865d5570
--- /dev/null
+++ b/vendor/github.com/godoc-lint/godoc-lint/pkg/config/once.go
@@ -0,0 +1,59 @@
+package config
+
+import (
+ "sync"
+
+ "github.com/godoc-lint/godoc-lint/pkg/model"
+)
+
+// OnceConfigBuilder wraps a config builder and make it a one-time builder, so
+// that further attempts to build will return the same result.
+//
+// This type is concurrent-safe.
+type OnceConfigBuilder struct {
+ builder model.ConfigBuilder
+
+ mu sync.Mutex
+ m map[string]built
+}
+
+type built struct {
+ value model.Config
+ err error
+}
+
+// NewOnceConfigBuilder crates a new instance of the corresponding struct.
+func NewOnceConfigBuilder(builder model.ConfigBuilder) *OnceConfigBuilder {
+ return &OnceConfigBuilder{
+ builder: builder,
+ }
+}
+
+// GetConfig implements the corresponding interface method.
+func (ocb *OnceConfigBuilder) GetConfig(cwd string) (model.Config, error) {
+ ocb.mu.Lock()
+ defer ocb.mu.Unlock()
+
+ if b, ok := ocb.m[cwd]; ok {
+ return b.value, b.err
+ }
+
+ b := built{}
+ b.value, b.err = ocb.builder.GetConfig(cwd)
+ if ocb.m == nil {
+ ocb.m = make(map[string]built, 10)
+ }
+ ocb.m[cwd] = b
+ return b.value, b.err
+}
+
+// SetOverride implements the corresponding interface method.
+func (ocb *OnceConfigBuilder) SetOverride(override *model.ConfigOverride) {
+ ocb.mu.Lock()
+ defer ocb.mu.Unlock()
+
+ if len(ocb.m) > 0 {
+ return
+ }
+ ocb.builder.SetOverride(override)
+}
diff --git a/vendor/github.com/godoc-lint/godoc-lint/pkg/config/parser.go b/vendor/github.com/godoc-lint/godoc-lint/pkg/config/parser.go
new file mode 100644
index 0000000000..3db9398c27
--- /dev/null
+++ b/vendor/github.com/godoc-lint/godoc-lint/pkg/config/parser.go
@@ -0,0 +1,42 @@
+package config
+
+import (
+ "fmt"
+ "os"
+ "strings"
+
+ "go.yaml.in/yaml/v3"
+)
+
+// FromYAML parses configuration from given YAML content.
+func FromYAML(in []byte) (*PlainConfig, error) {
+ raw := PlainConfig{}
+ if err := yaml.Unmarshal(in, &raw); err != nil {
+ return nil, fmt.Errorf("cannot parse config from YAML file: %w", err)
+ }
+
+ if raw.Version != nil && !strings.HasPrefix(*raw.Version, "1.") {
+ return nil, fmt.Errorf("unsupported config version: %s", *raw.Version)
+ }
+
+ return &raw, nil
+}
+
+// FromYAMLFile parses configuration from given file path.
+func FromYAMLFile(path string) (*PlainConfig, error) {
+ in, err := os.ReadFile(path)
+ if err != nil {
+ return nil, fmt.Errorf("cannot read file (%s): %w", path, err)
+ }
+
+ raw := PlainConfig{}
+ if err := yaml.Unmarshal(in, &raw); err != nil {
+ return nil, fmt.Errorf("cannot parse config from YAML file: %w", err)
+ }
+
+ if raw.Version != nil && !strings.HasPrefix(*raw.Version, "1.") {
+ return nil, fmt.Errorf("unsupported config version: %s", *raw.Version)
+ }
+
+ return &raw, nil
+}
diff --git a/vendor/github.com/godoc-lint/godoc-lint/pkg/config/plain.go b/vendor/github.com/godoc-lint/godoc-lint/pkg/config/plain.go
new file mode 100644
index 0000000000..0ff0948557
--- /dev/null
+++ b/vendor/github.com/godoc-lint/godoc-lint/pkg/config/plain.go
@@ -0,0 +1,98 @@
+package config
+
+import (
+ "errors"
+ "fmt"
+ "regexp"
+ "slices"
+
+ "github.com/godoc-lint/godoc-lint/pkg/model"
+)
+
+// PlainConfig represents the plain configuration type as users would provide
+// via a config file (e.g., a YAML file).
+type PlainConfig struct {
+ Version *string `yaml:"version" mapstructure:"version"`
+ Exclude []string `yaml:"exclude" mapstructure:"exclude"`
+ Include []string `yaml:"include" mapstructure:"include"`
+ Default *string `yaml:"default" mapstructure:"default"`
+ Enable []string `yaml:"enable" mapstructure:"enable"`
+ Disable []string `yaml:"disable" mapstructure:"disable"`
+ Options *PlainRuleOptions `yaml:"options" mapstructure:"options"`
+}
+
+// PlainRuleOptions represents the plain rule options as users would provide via
+// a config file (e.g., a YAML file).
+type PlainRuleOptions struct {
+ MaxLenLength *uint `yaml:"max-len/length" mapstructure:"max-len/length"`
+ MaxLenIncludeTests *bool `yaml:"max-len/include-tests" mapstructure:"max-len/include-tests"`
+ MaxLenIgnorePatterns []string `yaml:"max-len/ignore-patterns" mapstructure:"max-len/ignore-patterns"`
+ PkgDocIncludeTests *bool `yaml:"pkg-doc/include-tests" mapstructure:"pkg-doc/include-tests"`
+ SinglePkgDocIncludeTests *bool `yaml:"single-pkg-doc/include-tests" mapstructure:"single-pkg-doc/include-tests"`
+ RequirePkgDocIncludeTests *bool `yaml:"require-pkg-doc/include-tests" mapstructure:"require-pkg-doc/include-tests"`
+ RequireDocIncludeTests *bool `yaml:"require-doc/include-tests" mapstructure:"require-doc/include-tests"`
+ RequireDocIgnoreExported *bool `yaml:"require-doc/ignore-exported" mapstructure:"require-doc/ignore-exported"`
+ RequireDocIgnoreUnexported *bool `yaml:"require-doc/ignore-unexported" mapstructure:"require-doc/ignore-unexported"`
+ StartWithNameIncludeTests *bool `yaml:"start-with-name/include-tests" mapstructure:"start-with-name/include-tests"`
+ StartWithNameIncludeUnexported *bool `yaml:"start-with-name/include-unexported" mapstructure:"start-with-name/include-unexported"`
+ RequireStdlibDoclinkIncludeTests *bool `yaml:"require-stdlib-doclink/include-tests" mapstructure:"require-stdlib-doclink/include-tests"`
+ NoUnusedLinkIncludeTests *bool `yaml:"no-unused-link/include-tests" mapstructure:"no-unused-link/include-tests"`
+}
+
+// Validate validates the plain configuration.
+func (pcfg *PlainConfig) Validate() error {
+ var errs []error
+
+ if pcfg.Default != nil && !slices.Contains(model.DefaultSetValues, model.DefaultSet(*pcfg.Default)) {
+ errs = append(errs, fmt.Errorf("invalid default set %q; must be one of %q", *pcfg.Default, model.DefaultSetValues))
+ }
+
+ if invalids := getInvalidRules(pcfg.Enable); len(invalids) > 0 {
+ errs = append(errs, fmt.Errorf("invalid rule name(s) to enable: %q", invalids))
+ }
+
+ if invalids := getInvalidRules(pcfg.Disable); len(invalids) > 0 {
+ errs = append(errs, fmt.Errorf("invalid rule name(s) to disable: %q", invalids))
+ }
+
+ // To avoid being too strict, we don't complain if a rule is enabled and disabled at the same time.
+
+ if invalids := getInvalidRegexps(pcfg.Include); len(invalids) > 0 {
+ errs = append(errs, fmt.Errorf("invalid inclusion pattern(s): %q", invalids))
+ }
+
+ if invalids := getInvalidRegexps(pcfg.Exclude); len(invalids) > 0 {
+ errs = append(errs, fmt.Errorf("invalid exclusion pattern(s): %q", invalids))
+ }
+
+ if pcfg.Options != nil {
+ if invalids := getInvalidRegexps(pcfg.Options.MaxLenIgnorePatterns); len(invalids) > 0 {
+ errs = append(errs, fmt.Errorf("invalid max-len ignore pattern(s): %q", invalids))
+ }
+ }
+
+ if len(errs) > 0 {
+ return errors.Join(errs...)
+ }
+ return nil
+}
+
+func getInvalidRules(names []string) []string {
+ invalids := make([]string, 0, len(names))
+ for _, element := range names {
+ if !model.AllRules.Has(model.Rule(element)) {
+ invalids = append(invalids, element)
+ }
+ }
+ return invalids
+}
+
+func getInvalidRegexps(values []string) []string {
+ invalids := make([]string, 0, len(values))
+ for _, element := range values {
+ if _, err := regexp.Compile(element); err != nil {
+ invalids = append(invalids, element)
+ }
+ }
+ return invalids
+}
diff --git a/vendor/github.com/godoc-lint/godoc-lint/pkg/inspect/inspector.go b/vendor/github.com/godoc-lint/godoc-lint/pkg/inspect/inspector.go
new file mode 100644
index 0000000000..cdddbcf9b9
--- /dev/null
+++ b/vendor/github.com/godoc-lint/godoc-lint/pkg/inspect/inspector.go
@@ -0,0 +1,340 @@
+// Package inspect provides the pre-run inspection analyzer.
+package inspect
+
+import (
+ "errors"
+ "fmt"
+ "go/ast"
+ gdc "go/doc/comment"
+ "go/token"
+ "path/filepath"
+ "reflect"
+ "regexp"
+ "strings"
+
+ "golang.org/x/tools/go/analysis"
+
+ "github.com/godoc-lint/godoc-lint/pkg/model"
+ "github.com/godoc-lint/godoc-lint/pkg/util"
+)
+
+const (
+ metaName = "godoclint_inspect"
+ metaDoc = "Pre-run inspector for godoclint"
+ metaURL = "https://github.com/godoc-lint/godoc-lint"
+)
+
+// Inspector implements the godoc-lint pre-run inspector.
+type Inspector struct {
+ cb model.ConfigBuilder
+ exitFunc func(int, error)
+
+ analyzer *analysis.Analyzer
+ parser gdc.Parser
+}
+
+// NewInspector returns a new instance of the inspector.
+func NewInspector(cb model.ConfigBuilder, exitFunc func(int, error)) *Inspector {
+ result := &Inspector{
+ cb: cb,
+ exitFunc: exitFunc,
+ analyzer: &analysis.Analyzer{
+ Name: metaName,
+ Doc: metaDoc,
+ URL: metaURL,
+ ResultType: reflect.TypeFor[*model.InspectorResult](),
+ },
+ }
+ result.analyzer.Run = result.run
+ return result
+}
+
+// GetAnalyzer returns the underlying analyzer.
+func (i *Inspector) GetAnalyzer() *analysis.Analyzer {
+ return i.analyzer
+}
+
+var (
+ topLevelOrphanCommentGroupPattern = regexp.MustCompile(`(?m)(?:^//.*\r?\n)+(?:\r?\n|\z)`)
+ disableDirectivePattern = regexp.MustCompile(`(?m)//godoclint:disable(?: *([^\r\n]+))?\r?$`)
+)
+
+func (i *Inspector) run(pass *analysis.Pass) (any, error) {
+ if len(pass.Files) == 0 {
+ return &model.InspectorResult{}, nil
+ }
+
+ ft := util.GetPassFileToken(pass.Files[0], pass)
+ if ft == nil {
+ err := errors.New("cannot prepare config")
+ if i.exitFunc != nil {
+ i.exitFunc(2, err)
+ }
+ return nil, err
+ }
+
+ pkgDir := filepath.Dir(ft.Name())
+ cfg, err := i.cb.GetConfig(pkgDir)
+ if err != nil {
+ if i.exitFunc != nil {
+ i.exitFunc(2, err)
+ }
+ return nil, err
+ }
+
+ inspect := func(f *ast.File) (*model.FileInspection, error) {
+ ft := util.GetPassFileToken(f, pass)
+ if ft == nil {
+ return nil, nil
+ }
+
+ raw, err := pass.ReadFile(ft.Name())
+ if err != nil {
+ return nil, fmt.Errorf("cannot read file %q: %v", ft.Name(), err)
+ }
+
+ // Extract package godoc, if any.
+ packageDoc := i.extractCommentGroup(f.Doc)
+
+ // Extract top-level //godoclint:disable directives.
+ disabledRules := model.InspectorResultDisableRules{}
+ for _, match := range topLevelOrphanCommentGroupPattern.FindAll(raw, -1) {
+ d := extractDisableDirectivesInComment(string(match))
+ disabledRules.All = disabledRules.All || d.All
+ disabledRules.Rules = disabledRules.Rules.Merge(d.Rules)
+ }
+
+ // Extract top-level symbol declarations.
+ decls := make([]model.SymbolDecl, 0, len(f.Decls))
+ for _, d := range f.Decls {
+ switch dt := d.(type) {
+ case *ast.FuncDecl:
+ var recvBaseTypeName string
+ var isMethod bool
+
+ if dt.Recv != nil {
+ isMethod = true
+ if len(dt.Recv.List) > 0 {
+ recvBaseTypeName = extractMethodRecvBaseTypeName(dt.Recv.List[0].Type)
+ }
+ }
+
+ decls = append(decls, model.SymbolDecl{
+ Decl: d,
+ Kind: model.SymbolDeclKindFunc,
+ Name: dt.Name.Name,
+ Ident: dt.Name,
+ IsMethod: isMethod,
+ MethodRecvBaseTypeName: recvBaseTypeName,
+ Doc: i.extractCommentGroup(dt.Doc),
+ })
+ case *ast.BadDecl:
+ decls = append(decls, model.SymbolDecl{
+ Decl: d,
+ Kind: model.SymbolDeclKindBad,
+ })
+ case *ast.GenDecl:
+ switch dt.Tok {
+ case token.CONST, token.VAR:
+ kind := model.SymbolDeclKindConst
+ if dt.Tok == token.VAR {
+ kind = model.SymbolDeclKindVar
+ }
+ if dt.Lparen == token.NoPos {
+ // cases:
+ // const ... (single line)
+ // var ... (single line)
+
+ spec := dt.Specs[0].(*ast.ValueSpec)
+ if len(spec.Names) == 1 {
+ // cases:
+ // const foo = 0
+ // var foo = 0
+ decls = append(decls, model.SymbolDecl{
+ Decl: d,
+ Kind: kind,
+ Name: spec.Names[0].Name,
+ Ident: spec.Names[0],
+ Doc: i.extractCommentGroup(dt.Doc),
+ TrailingDoc: i.extractCommentGroup(spec.Comment),
+ })
+ } else {
+ // cases:
+ // const foo, bar = 0, 0
+ // var foo, bar = 0, 0
+ doc := i.extractCommentGroup(dt.Doc)
+ trailingDoc := i.extractCommentGroup(spec.Comment)
+ for ix, n := range spec.Names {
+ decls = append(decls, model.SymbolDecl{
+ Decl: d,
+ Kind: kind,
+ Name: n.Name,
+ Ident: n,
+ Doc: doc,
+ TrailingDoc: trailingDoc,
+ MultiNameDecl: true,
+ MultiNameIndex: ix,
+ })
+ }
+ }
+ } else {
+ // cases:
+ // const (
+ // foo = 0
+ // )
+ // var (
+ // foo = 0
+ // )
+ // const (
+ // foo, bar = 0, 0
+ // )
+ // var (
+ // foo, bar = 0, 0
+ // )
+
+ parentDoc := i.extractCommentGroup(dt.Doc)
+ for spix, s := range dt.Specs {
+ spec := s.(*ast.ValueSpec)
+ doc := i.extractCommentGroup(spec.Doc)
+ trailingDoc := i.extractCommentGroup(spec.Comment)
+ for ix, n := range spec.Names {
+ decls = append(decls, model.SymbolDecl{
+ Decl: d,
+ Kind: kind,
+ Name: n.Name,
+ Ident: n,
+ Doc: doc,
+ TrailingDoc: trailingDoc,
+ ParentDoc: parentDoc,
+ MultiNameDecl: len(spec.Names) > 1,
+ MultiNameIndex: ix,
+ MultiSpecDecl: true,
+ MultiSpecIndex: spix,
+ })
+ }
+ }
+ }
+ case token.TYPE:
+ if dt.Lparen == token.NoPos {
+ // case:
+ // type foo int
+
+ spec := dt.Specs[0].(*ast.TypeSpec)
+ decls = append(decls, model.SymbolDecl{
+ Decl: d,
+ Kind: model.SymbolDeclKindType,
+ IsTypeAlias: spec.Assign != token.NoPos,
+ Name: spec.Name.Name,
+ Ident: spec.Name,
+ Doc: i.extractCommentGroup(dt.Doc),
+ TrailingDoc: i.extractCommentGroup(spec.Comment),
+ })
+ } else {
+ // case:
+ // type (
+ // foo int
+ // )
+
+ parentDoc := i.extractCommentGroup(dt.Doc)
+ for spix, s := range dt.Specs {
+ spec := s.(*ast.TypeSpec)
+ decls = append(decls, model.SymbolDecl{
+ Decl: d,
+ Kind: model.SymbolDeclKindType,
+ IsTypeAlias: spec.Assign != token.NoPos,
+ Name: spec.Name.Name,
+ Ident: spec.Name,
+ Doc: i.extractCommentGroup(spec.Doc),
+ TrailingDoc: i.extractCommentGroup(spec.Comment),
+ ParentDoc: parentDoc,
+ MultiSpecDecl: true,
+ MultiSpecIndex: spix,
+ })
+ }
+ }
+ default:
+ continue
+ }
+ }
+ }
+
+ return &model.FileInspection{
+ DisabledRules: disabledRules,
+ PackageDoc: packageDoc,
+ SymbolDecl: decls,
+ }, nil
+ }
+
+ result := &model.InspectorResult{
+ Files: make(map[*ast.File]*model.FileInspection, len(pass.Files)),
+ }
+
+ for _, f := range pass.Files {
+ ft := util.GetPassFileToken(f, pass)
+ if ft == nil {
+ continue
+ }
+ if !cfg.IsPathApplicable(ft.Name()) {
+ continue
+ }
+
+ if fi, err := inspect(f); err != nil {
+ return nil, fmt.Errorf("inspector failed: %w", err)
+ } else {
+ result.Files[f] = fi
+ }
+ }
+ return result, nil
+}
+
+func (i *Inspector) extractCommentGroup(cg *ast.CommentGroup) *model.CommentGroup {
+ if cg == nil {
+ return nil
+ }
+
+ lines := make([]string, 0, len(cg.List))
+ for _, l := range cg.List {
+ lines = append(lines, l.Text)
+ }
+ rawText := strings.Join(lines, "\n")
+
+ text := cg.Text()
+ return &model.CommentGroup{
+ CG: *cg,
+ Parsed: *i.parser.Parse(text),
+ Text: text,
+ DisabledRules: extractDisableDirectivesInComment(rawText),
+ }
+}
+
+func extractDisableDirectivesInComment(s string) model.InspectorResultDisableRules {
+ result := model.InspectorResultDisableRules{}
+ for _, directive := range disableDirectivePattern.FindAllStringSubmatch(s, -1) {
+ args := directive[1]
+ if args == "" {
+ result.All = true
+ continue
+ }
+
+ for name := range strings.SplitSeq(strings.TrimSpace(args), " ") {
+ if model.AllRules.Has(model.Rule(name)) {
+ result.Rules = result.Rules.Add(model.Rule(name))
+ }
+ }
+ }
+ return result
+}
+
+func extractMethodRecvBaseTypeName(expr ast.Expr) string {
+ switch tt := expr.(type) {
+ case *ast.Ident:
+ return tt.Name
+ case *ast.StarExpr:
+ return extractMethodRecvBaseTypeName(tt.X)
+ case *ast.IndexExpr:
+ return extractMethodRecvBaseTypeName(tt.X)
+ case *ast.IndexListExpr:
+ return extractMethodRecvBaseTypeName(tt.X)
+ }
+ return ""
+}
diff --git a/vendor/github.com/godoc-lint/godoc-lint/pkg/model/analyzer.go b/vendor/github.com/godoc-lint/godoc-lint/pkg/model/analyzer.go
new file mode 100644
index 0000000000..ded44c4e71
--- /dev/null
+++ b/vendor/github.com/godoc-lint/godoc-lint/pkg/model/analyzer.go
@@ -0,0 +1,11 @@
+package model
+
+import (
+ "golang.org/x/tools/go/analysis"
+)
+
+// Analyzer defines an analyzer.
+type Analyzer interface {
+ // GetAnalyzer returns the underlying analyzer.
+ GetAnalyzer() *analysis.Analyzer
+}
diff --git a/vendor/github.com/godoc-lint/godoc-lint/pkg/model/checker.go b/vendor/github.com/godoc-lint/godoc-lint/pkg/model/checker.go
new file mode 100644
index 0000000000..dca42e279c
--- /dev/null
+++ b/vendor/github.com/godoc-lint/godoc-lint/pkg/model/checker.go
@@ -0,0 +1,24 @@
+package model
+
+import "golang.org/x/tools/go/analysis"
+
+// AnalysisContext provides contextual information about the running analysis.
+type AnalysisContext struct {
+ // Config provides analyzer configuration.
+ Config Config
+
+ // InspectorResult is the analysis result of the pre-run inspector.
+ InspectorResult *InspectorResult
+
+ // Pass is the analysis Pass instance.
+ Pass *analysis.Pass
+}
+
+// Checker defines a rule checker.
+type Checker interface {
+ // GetCoveredRules returns the set of rules applied by the checker.
+ GetCoveredRules() RuleSet
+
+ // Apply checks for the rule(s).
+ Apply(actx *AnalysisContext) error
+}
diff --git a/vendor/github.com/godoc-lint/godoc-lint/pkg/model/config.go b/vendor/github.com/godoc-lint/godoc-lint/pkg/model/config.go
new file mode 100644
index 0000000000..5ba271a3cd
--- /dev/null
+++ b/vendor/github.com/godoc-lint/godoc-lint/pkg/model/config.go
@@ -0,0 +1,125 @@
+package model
+
+import (
+ "maps"
+ "regexp"
+ "slices"
+)
+
+// ConfigBuilder defines a configuration builder.
+type ConfigBuilder interface {
+ // SetOverride sets the configuration override.
+ SetOverride(override *ConfigOverride)
+
+ // GetConfig builds and returns the configuration object for the given path.
+ GetConfig(cwd string) (Config, error)
+}
+
+// DefaultSet defines the default set of rules to enable.
+type DefaultSet string
+
+const (
+ // DefaultSetAll enables all rules.
+ DefaultSetAll DefaultSet = "all"
+ // DefaultSetNone disables all rules.
+ DefaultSetNone DefaultSet = "none"
+ // DefaultSetBasic enables a basic set of rules.
+ DefaultSetBasic DefaultSet = "basic"
+
+ // DefaultDefaultSet is the default set of rules to enable.
+ DefaultDefaultSet = DefaultSetBasic
+)
+
+// DefaultSetToRules maps default sets to the corresponding rule sets.
+var DefaultSetToRules = map[DefaultSet]RuleSet{
+ DefaultSetAll: AllRules,
+ DefaultSetNone: {},
+ DefaultSetBasic: func() RuleSet {
+ return RuleSet{}.Add(
+ PkgDocRule,
+ SinglePkgDocRule,
+ StartWithNameRule,
+ DeprecatedRule,
+ )
+ }(),
+}
+
+// DefaultSetValues holds the valid values for DefaultSet.
+var DefaultSetValues = func() []DefaultSet {
+ values := slices.Collect(maps.Keys(DefaultSetToRules))
+ slices.Sort(values)
+ return values
+}()
+
+// ConfigOverride represents a configuration override.
+//
+// Non-nil values (including empty slices) indicate that the corresponding field
+// is overridden.
+type ConfigOverride struct {
+ // ConfigFilePath is the path to config file.
+ ConfigFilePath *string
+
+ // Include is the overridden list of regexp patterns matching the files that
+ // the linter should include.
+ Include []*regexp.Regexp
+
+ // Exclude is the overridden list of regexp patterns matching the files that
+ // the linter should exclude.
+ Exclude []*regexp.Regexp
+
+ // Default is the default set of rules to enable.
+ Default *DefaultSet
+
+ // Enable is the overridden list of rules to enable.
+ Enable *RuleSet
+
+ // Disable is the overridden list of rules to disable.
+ Disable *RuleSet
+}
+
+// NewConfigOverride returns a new config override instance.
+func NewConfigOverride() *ConfigOverride {
+ return &ConfigOverride{}
+}
+
+// Config defines an analyzer configuration.
+type Config interface {
+ // GetCWD returns the directory that the configuration is applied to. This
+ // is the base to compute relative paths to include/exclude files.
+ GetCWD() string
+
+ // GetConfigFilePath returns the path to the configuration file. If there is
+ // no configuration file, which is the case when the default is used, this
+ // will be an empty string.
+ GetConfigFilePath() string
+
+ // IsAnyRuleEnabled determines if any of the given rule names is among
+ // enabled rules, or not among disabled rules.
+ IsAnyRuleApplicable(RuleSet) bool
+
+ // IsPathApplicable determines if the given path matches the included path
+ // patterns, or does not match the excluded path patterns.
+ IsPathApplicable(path string) bool
+
+ // Returns the rule-specific options.
+ //
+ // It never returns a nil pointer.
+ GetRuleOptions() *RuleOptions
+}
+
+// RuleOptions represents individual linter rule configurations.
+type RuleOptions struct {
+ MaxLenLength uint
+ MaxLenIncludeTests bool
+ MaxLenIgnorePatterns []*regexp.Regexp
+ PkgDocIncludeTests bool
+ SinglePkgDocIncludeTests bool
+ RequirePkgDocIncludeTests bool
+ RequireDocIncludeTests bool
+ RequireDocIgnoreExported bool
+ RequireDocIgnoreUnexported bool
+ StartWithNameIncludeTests bool
+ StartWithNameIncludeUnexported bool
+ RequireStdlibDoclinkIncludeTests bool
+ NoUnusedLinkIncludeTests bool
+}
diff --git a/vendor/github.com/godoc-lint/godoc-lint/pkg/model/doc.go b/vendor/github.com/godoc-lint/godoc-lint/pkg/model/doc.go
new file mode 100644
index 0000000000..b4afa8d46c
--- /dev/null
+++ b/vendor/github.com/godoc-lint/godoc-lint/pkg/model/doc.go
@@ -0,0 +1,2 @@
+// Package model provides data models for the linter.
+package model
diff --git a/vendor/github.com/godoc-lint/godoc-lint/pkg/model/inspector.go b/vendor/github.com/godoc-lint/godoc-lint/pkg/model/inspector.go
new file mode 100644
index 0000000000..9b4846634b
--- /dev/null
+++ b/vendor/github.com/godoc-lint/godoc-lint/pkg/model/inspector.go
@@ -0,0 +1,217 @@
+package model
+
+import (
+ "go/ast"
+ "go/doc/comment"
+
+ "golang.org/x/tools/go/analysis"
+)
+
+// Inspector defines a pre-run inspector.
+type Inspector interface {
+ // GetAnalyzer returns the underlying analyzer.
+ GetAnalyzer() *analysis.Analyzer
+}
+
+// InspectorResult represents the result of the inspector analysis.
+type InspectorResult struct {
+ // Files provides extracted information per AST file.
+ Files map[*ast.File]*FileInspection
+}
+
+// FileInspection represents the inspection result for a single file.
+type FileInspection struct {
+ // DisabledRules contains information about rules disabled at top level.
+ DisabledRules InspectorResultDisableRules
+
+ // PackageDoc represents the package godoc, if any.
+ PackageDoc *CommentGroup
+
+ // SymbolDecl represents symbols declared in the package file.
+ SymbolDecl []SymbolDecl
+}
+
+// InspectorResultDisableRules contains the list of disabled rules.
+type InspectorResultDisableRules struct {
+ // All indicates whether all rules are disabled.
+ All bool
+
+ // Rules is the set of rules disabled.
+ Rules RuleSet
+}
+
+// SymbolDeclKind is the enum type for the symbol declarations.
+type SymbolDeclKind string
+
+const (
+ // SymbolDeclKindBad represents an unknown declaration kind.
+ SymbolDeclKindBad SymbolDeclKind = "bad"
+ // SymbolDeclKindFunc represents a function declaration kind.
+ SymbolDeclKindFunc SymbolDeclKind = "func"
+ // SymbolDeclKindConst represents a const declaration kind.
+ SymbolDeclKindConst SymbolDeclKind = "const"
+ // SymbolDeclKindType represents a type declaration kind.
+ SymbolDeclKindType SymbolDeclKind = "type"
+ // SymbolDeclKindVar represents a var declaration kind.
+ SymbolDeclKindVar SymbolDeclKind = "var"
+)
+
+// SymbolDecl represents a top level declaration.
+type SymbolDecl struct {
+ // Decl is the underlying declaration node.
+ Decl ast.Decl
+
+ // Kind is the declaration kind (e.g., func or type).
+ Kind SymbolDeclKind
+
+ // IsTypeAlias indicates that the type symbol is an alias. For example:
+ //
+ // type Foo = int
+ //
+ // This is always false for non-type declaration (e.g., const or var).
+ IsTypeAlias bool
+
+ // IsMethod indicates whether the symbol is a method. For example:
+ //
+ // func (Foo) Bar() {}
+ // func (*Foo) Bar() {}
+ // func (Foo[T]) Bar() {}
+ // func (*Foo[T]) Bar() {}
+ //
+ // This field is false for non-function declarations.
+ IsMethod bool
+
+ // Name is the name of the declared symbol.
+ Name string
+
+ // Ident is the symbol identifier node.
+ Ident *ast.Ident
+
+ // MethodRecvBaseTypeName is the base type name of the method receiver, if
+ // the symbol is a method (See [Go spec]).
+ //
+ // Note that although an empty value is unexpected for method declarations,
+ // it's still possible (e.g. due to new language features that we don't yet
+ // support). So, users of this field should always check for empty values.
+ //
+ // In the examples below the base type name is "Foo":
+ //
+ // func (Foo) Bar() {}
+ // func (*Foo) Bar() {}
+ // func (Foo[T]) BarFoo() {}
+ //
+ // This field is empty for non-method symbols.
+ //
+ // [Go spec]: https://go.dev/ref/spec#Method_declarations
+ MethodRecvBaseTypeName string
+
+ // MultiNameDecl determines whether the symbol is declared as part of a
+ // multi-name declaration spec; For example:
+ //
+ // const foo, bar = 0, 0
+ //
+ // This field is only valid for const, var, or type declarations.
+ MultiNameDecl bool
+
+ // MultiNameIndex is the index of the declared symbol within the spec. For
+ // example, in the below declaration, the index of "foo" and "bar" are 0 and
+ // 1, respectively:
+ //
+ // const foo, bar = 0, 0
+ //
+ // In single-name specs, this will be 0.
+ MultiNameIndex int
+
+ // MultiSpecDecl determines whether the symbol is declared as part of a
+ // multi-spec declaration. A multi spec declaration is const/var/type
+ // declaration with a pair of grouping brackets, even if there is only one
+ // spec between the brackets. For example, these are multi-spec
+ // declarations:
+ //
+ // const (
+ // foo = 0
+ // )
+ //
+ // const (
+ // foo, bar = 0, 0
+ // )
+ //
+ // const (
+ // foo = 0
+ // bar = 0
+ // )
+ //
+ // const (
+ // foo, bar = 0, 0
+ // baz = 0
+ // )
+ //
+ MultiSpecDecl bool
+
+ // SpecIndex is the index of the spec where the symbol is declared. For
+ // example, in the below declaration, the index of "foo" and "bar" are 0 and
+ // 1, respectively:
+ //
+ // const (
+ // foo = 0
+ // bar = 0
+ // )
+ //
+ // In single-spec declarations, this will be 0.
+ MultiSpecIndex int
+
+ // Doc is the comment group associated to the symbol. For example:
+ //
+ // // godoc
+ // const foo = 0
+ //
+ // const (
+ // // godoc
+ // foo = 0
+ // )
+ //
+ // Note that, as in the first example above, for single-spec declarations
+ // (i.e., single line declarations), the godoc above the const/var/type
+ // keyword is considered as the declaration doc, and the parent doc will be
+ // nil.
+ Doc *CommentGroup
+
+ // TrailingDoc is the comment group that is following the symbol
+ // declaration. For example, this is a trailing comment group:
+ //
+ // const (
+ // foo = 0 // trailing comment group.
+ // )
+ //
+ TrailingDoc *CommentGroup
+
+ // Doc is the comment group associated to the parent declaration. For
+ // instance:
+ //
+ // // parent godoc
+ // const (
+ // // godoc
+ // Foo = 0
+ // )
+ //
+ // Note that for single-spec declarations (i.e., single line declarations),
+ // the godoc above the const/var/type keyword is considered as the
+ // declaration doc, and the parent doc will be nil.
+ ParentDoc *CommentGroup
+}
+
+// CommentGroup represents an [ast.CommentGroup] and its parsed godoc instance.
+type CommentGroup struct {
+ // CG represents the AST comment group.
+ CG ast.CommentGroup
+
+ // Parsed represents the comment group parsed into a godoc.
+ Parsed comment.Doc
+
+ // Test is the comment group text.
+ Text string
+
+ // DisabledRules contains information about rules disabled in the comment
+ // group.
+ DisabledRules InspectorResultDisableRules
+}
diff --git a/vendor/github.com/godoc-lint/godoc-lint/pkg/model/registry.go b/vendor/github.com/godoc-lint/godoc-lint/pkg/model/registry.go
new file mode 100644
index 0000000000..64512291da
--- /dev/null
+++ b/vendor/github.com/godoc-lint/godoc-lint/pkg/model/registry.go
@@ -0,0 +1,14 @@
+package model
+
+// Registry defines a registry of checkers.
+type Registry interface {
+ // Add registers a new checker.
+ Add(Checker)
+
+ // List returns a slice of the registered checkers.
+ List() []Checker
+
+ // GetCoveredRules returns the set of rules covered by the registered
+ // checkers.
+ GetCoveredRules() RuleSet
+}
diff --git a/vendor/github.com/godoc-lint/godoc-lint/pkg/model/rule.go b/vendor/github.com/godoc-lint/godoc-lint/pkg/model/rule.go
new file mode 100644
index 0000000000..eb7a67ff42
--- /dev/null
+++ b/vendor/github.com/godoc-lint/godoc-lint/pkg/model/rule.go
@@ -0,0 +1,40 @@
+package model
+
+// Rule represents a rule.
+type Rule string
+
+const (
+ // PkgDocRule represents the "pkg-doc" rule.
+ PkgDocRule Rule = "pkg-doc"
+ // SinglePkgDocRule represents the "single-pkg-doc" rule.
+ SinglePkgDocRule Rule = "single-pkg-doc"
+ // RequirePkgDocRule represents the "require-pkg-doc" rule.
+ RequirePkgDocRule Rule = "require-pkg-doc"
+ // StartWithNameRule represents the "start-with-name" rule.
+ StartWithNameRule Rule = "start-with-name"
+ // RequireDocRule represents the "require-doc" rule.
+ RequireDocRule Rule = "require-doc"
+ // DeprecatedRule represents the "deprecated" rule.
+ DeprecatedRule Rule = "deprecated"
+ // RequireStdlibDoclinkRule represents the "require-stdlib-doclink" rule.
+ RequireStdlibDoclinkRule Rule = "require-stdlib-doclink"
+ // MaxLenRule represents the "max-len" rule.
+ MaxLenRule Rule = "max-len"
+ // NoUnusedLinkRule represents the "no-unused-link" rule.
+ NoUnusedLinkRule Rule = "no-unused-link"
+)
+
+// AllRules is the set of all supported rules.
+var AllRules = func() RuleSet {
+ return RuleSet{}.Add(
+ PkgDocRule,
+ SinglePkgDocRule,
+ RequirePkgDocRule,
+ StartWithNameRule,
+ RequireDocRule,
+ DeprecatedRule,
+ RequireStdlibDoclinkRule,
+ MaxLenRule,
+ NoUnusedLinkRule,
+ )
+}()
diff --git a/vendor/github.com/godoc-lint/godoc-lint/pkg/model/ruleset.go b/vendor/github.com/godoc-lint/godoc-lint/pkg/model/ruleset.go
new file mode 100644
index 0000000000..0cf195447c
--- /dev/null
+++ b/vendor/github.com/godoc-lint/godoc-lint/pkg/model/ruleset.go
@@ -0,0 +1,97 @@
+package model
+
+import "slices"
+
+// RuleSet represents an immutable set of rule names.
+//
+// A zero rule set represents an empty set.
+type RuleSet struct {
+ m map[Rule]struct{}
+}
+
+// Merge combines the rules in the current and the given rule sets into a new
+// set.
+func (rs RuleSet) Merge(another RuleSet) RuleSet {
+ result := RuleSet{
+ m: make(map[Rule]struct{}, len(rs.m)+len(another.m)),
+ }
+ for r := range rs.m {
+ result.m[r] = struct{}{}
+ }
+ for r := range another.m {
+ result.m[r] = struct{}{}
+ }
+ return result
+}
+
+// Add returns a new rule set containing the rules in the current set and the
+// rules provided as arguments.
+func (rs RuleSet) Add(rules ...Rule) RuleSet {
+ result := RuleSet{
+ m: make(map[Rule]struct{}, len(rs.m)+len(rules)),
+ }
+ for r := range rs.m {
+ result.m[r] = struct{}{}
+ }
+ for _, r := range rules {
+ result.m[r] = struct{}{}
+ }
+ return result
+}
+
+// Remove returns a new rule set containing the rules in the current set
+// excluding those provided as arguments.
+func (rs RuleSet) Remove(rules ...Rule) RuleSet {
+ result := RuleSet{
+ m: make(map[Rule]struct{}, len(rs.m)),
+ }
+ for r := range rs.m {
+ result.m[r] = struct{}{}
+ }
+ for _, r := range rules {
+ delete(result.m, r)
+ }
+ return result
+}
+
+// Has determines whether the given rule is in the set.
+func (rs RuleSet) Has(rule Rule) bool {
+ _, ok := rs.m[rule]
+ return ok
+}
+
+// HasCommonsWith indicates at least one rule is in common with the given rule
+// set.
+//
+// If the given set is empty/zero, the method will return false.
+func (rs RuleSet) HasCommonsWith(another RuleSet) bool {
+ for r := range another.m {
+ if _, ok := rs.m[r]; ok {
+ return true
+ }
+ }
+ return false
+}
+
+// IsSupersetOf indicates that all rules in the given set are in the current
+// set.
+//
+// If the given set is empty/zero, the method will return true.
+func (rs RuleSet) IsSupersetOf(another RuleSet) bool {
+ for r := range another.m {
+ if _, ok := rs.m[r]; !ok {
+ return false
+ }
+ }
+ return true
+}
+
+// List returns a slice of the rules in the set.
+func (rs RuleSet) List() []Rule {
+ rules := make([]Rule, 0, len(rs.m))
+ for r := range rs.m {
+ rules = append(rules, r)
+ }
+ slices.Sort(rules)
+ return rules
+}
diff --git a/vendor/github.com/godoc-lint/godoc-lint/pkg/util/ast.go b/vendor/github.com/godoc-lint/godoc-lint/pkg/util/ast.go
new file mode 100644
index 0000000000..1441001d01
--- /dev/null
+++ b/vendor/github.com/godoc-lint/godoc-lint/pkg/util/ast.go
@@ -0,0 +1,66 @@
+package util
+
+import (
+ "go/ast"
+ "go/token"
+ "iter"
+ "strings"
+
+ "golang.org/x/tools/go/analysis"
+
+ "github.com/godoc-lint/godoc-lint/pkg/model"
+)
+
+// GetPassFileToken is a helper function to return the file token associated
+// with the given AST file.
+func GetPassFileToken(f *ast.File, pass *analysis.Pass) *token.File {
+ if f.Pos() == token.NoPos {
+ return nil
+ }
+ ft := pass.Fset.File(f.Pos())
+ if ft == nil {
+ return nil
+ }
+ return ft
+}
+
+// AnalysisApplicableFiles returns an iterator looping over files that are ready
+// to be analyzed.
+//
+// The yield-ed arguments are never nil.
+func AnalysisApplicableFiles(actx *model.AnalysisContext, includeTests bool, ruleSet model.RuleSet) iter.Seq2[*ast.File, *model.FileInspection] {
+ return func(yield func(*ast.File, *model.FileInspection) bool) {
+ if actx.InspectorResult == nil {
+ return
+ }
+
+ for _, f := range actx.Pass.Files {
+ ir := actx.InspectorResult.Files[f]
+
+ if ir == nil {
+ continue
+ }
+
+ ft := GetPassFileToken(f, actx.Pass)
+ if ft == nil {
+ continue
+ }
+
+ if !actx.Config.IsPathApplicable(ft.Name()) {
+ continue
+ }
+
+ if !includeTests && strings.HasSuffix(ft.Name(), "_test.go") {
+ continue
+ }
+
+ if ir.DisabledRules.All || ir.DisabledRules.Rules.IsSupersetOf(ruleSet) {
+ continue
+ }
+
+ if !yield(f, ir) {
+ return
+ }
+ }
+ }
+}
diff --git a/vendor/github.com/godoc-lint/godoc-lint/pkg/util/doc.go b/vendor/github.com/godoc-lint/godoc-lint/pkg/util/doc.go
new file mode 100644
index 0000000000..1c40b74680
--- /dev/null
+++ b/vendor/github.com/godoc-lint/godoc-lint/pkg/util/doc.go
@@ -0,0 +1,2 @@
+// Package util provides utility functions for the linter.
+package util
diff --git a/vendor/github.com/godoc-lint/godoc-lint/pkg/util/path.go b/vendor/github.com/godoc-lint/godoc-lint/pkg/util/path.go
new file mode 100644
index 0000000000..b7dd451e2f
--- /dev/null
+++ b/vendor/github.com/godoc-lint/godoc-lint/pkg/util/path.go
@@ -0,0 +1,16 @@
+package util
+
+import (
+ "path/filepath"
+ "strings"
+)
+
+// IsPathUnderBaseDir determines whether the given path is a sub-directory of
+// the given base, lexicographically.
+func IsPathUnderBaseDir(baseDir, path string) bool {
+ rel, err := filepath.Rel(baseDir, path)
+ if err != nil {
+ return false
+ }
+ return rel == "." || rel != ".." && !strings.HasPrefix(filepath.ToSlash(rel), "../")
+}
diff --git a/vendor/github.com/gofrs/flock/.golangci.yml b/vendor/github.com/gofrs/flock/.golangci.yml
index bc837b266a..b35be7de81 100644
--- a/vendor/github.com/gofrs/flock/.golangci.yml
+++ b/vendor/github.com/gofrs/flock/.golangci.yml
@@ -6,7 +6,9 @@ formatters:
- goimports
settings:
gofumpt:
- extra-rules: true
+ extra:
+ clothe-returns: true
+ group-params: true
linters:
enable:
diff --git a/vendor/github.com/gofrs/flock/flock.go b/vendor/github.com/gofrs/flock/flock.go
index 4cb0746a71..156c4bf2b0 100644
--- a/vendor/github.com/gofrs/flock/flock.go
+++ b/vendor/github.com/gofrs/flock/flock.go
@@ -1,5 +1,5 @@
// Copyright 2015 Tim Heckman. All rights reserved.
-// Copyright 2018-2025 The Gofrs. All rights reserved.
+// Copyright 2018-2026 The Gofrs. All rights reserved.
// Use of this source code is governed by the BSD 3-Clause
// license that can be found in the LICENSE file.
@@ -100,7 +100,7 @@ func (f *Flock) Close() error {
return f.Unlock()
}
-// Path returns the path as provided in NewFlock().
+// Path returns the path as provided in New().
func (f *Flock) Path() string {
return f.path
}
diff --git a/vendor/github.com/gofrs/flock/flock_others.go b/vendor/github.com/gofrs/flock/flock_others.go
index 92d0f7e95a..822ace0da0 100644
--- a/vendor/github.com/gofrs/flock/flock_others.go
+++ b/vendor/github.com/gofrs/flock/flock_others.go
@@ -1,5 +1,5 @@
// Copyright 2015 Tim Heckman. All rights reserved.
-// Copyright 2018-2025 The Gofrs. All rights reserved.
+// Copyright 2018-2026 The Gofrs. All rights reserved.
// Use of this source code is governed by the BSD 3-Clause
// license that can be found in the LICENSE file.
diff --git a/vendor/github.com/gofrs/flock/flock_unix.go b/vendor/github.com/gofrs/flock/flock_unix.go
index 77de7a8837..c486c5e6be 100644
--- a/vendor/github.com/gofrs/flock/flock_unix.go
+++ b/vendor/github.com/gofrs/flock/flock_unix.go
@@ -1,5 +1,5 @@
// Copyright 2015 Tim Heckman. All rights reserved.
-// Copyright 2018-2025 The Gofrs. All rights reserved.
+// Copyright 2018-2026 The Gofrs. All rights reserved.
// Use of this source code is governed by the BSD 3-Clause
// license that can be found in the LICENSE file.
diff --git a/vendor/github.com/gofrs/flock/flock_unix_fcntl.go b/vendor/github.com/gofrs/flock/flock_unix_fcntl.go
index 05c2f88c65..76a29fc082 100644
--- a/vendor/github.com/gofrs/flock/flock_unix_fcntl.go
+++ b/vendor/github.com/gofrs/flock/flock_unix_fcntl.go
@@ -1,5 +1,5 @@
// Copyright 2015 Tim Heckman. All rights reserved.
-// Copyright 2018-2025 The Gofrs. All rights reserved.
+// Copyright 2018-2026 The Gofrs. All rights reserved.
// Use of this source code is governed by the BSD 3-Clause
// license that can be found in the LICENSE file.
diff --git a/vendor/github.com/gofrs/flock/flock_windows.go b/vendor/github.com/gofrs/flock/flock_windows.go
index aa144f156e..d9f9f88321 100644
--- a/vendor/github.com/gofrs/flock/flock_windows.go
+++ b/vendor/github.com/gofrs/flock/flock_windows.go
@@ -1,5 +1,5 @@
// Copyright 2015 Tim Heckman. All rights reserved.
-// Copyright 2018-2025 The Gofrs. All rights reserved.
+// Copyright 2018-2026 The Gofrs. All rights reserved.
// Use of this source code is governed by the BSD 3-Clause
// license that can be found in the LICENSE file.
diff --git a/vendor/github.com/gofrs/flock/zizmor.yml b/vendor/github.com/gofrs/flock/zizmor.yml
new file mode 100644
index 0000000000..39d1b180c5
--- /dev/null
+++ b/vendor/github.com/gofrs/flock/zizmor.yml
@@ -0,0 +1,3 @@
+rules:
+ secrets-outside-env:
+ disable: true
diff --git a/vendor/github.com/golangci/asciicheck/.gitignore b/vendor/github.com/golangci/asciicheck/.gitignore
new file mode 100644
index 0000000000..26938fd810
--- /dev/null
+++ b/vendor/github.com/golangci/asciicheck/.gitignore
@@ -0,0 +1,21 @@
+# IntelliJ project files
+.idea
+*.iml
+out
+gen
+
+# Go template
+# Binaries for programs and plugins
+*.exe
+*.exe~
+*.dll
+*.so
+*.dylib
+
+# Test binary, built with `go test -c`
+*.test
+
+# Output of the go coverage tool, specifically when used with LiteIDE
+*.out
+
+/asciicheck
diff --git a/vendor/github.com/golangci/asciicheck/.golangci.yml b/vendor/github.com/golangci/asciicheck/.golangci.yml
new file mode 100644
index 0000000000..e28845eb59
--- /dev/null
+++ b/vendor/github.com/golangci/asciicheck/.golangci.yml
@@ -0,0 +1,87 @@
+version: "2"
+
+formatters:
+ enable:
+ - gci
+ - gofumpt
+ settings:
+ gofumpt:
+ extra-rules: true
+
+linters:
+ default: all
+ disable:
+ - cyclop # duplicate of gocyclo
+ - dupl
+ - errchkjson
+ - exhaustive
+ - exhaustruct
+ - lll
+ - mnd
+ - nilnil
+ - nlreturn
+ - nonamedreturns
+ - paralleltest
+ - prealloc
+ - rowserrcheck # not relevant (SQL)
+ - sqlclosecheck # not relevant (SQL)
+ - testpackage
+ - tparallel
+ - varnamelen
+ - wsl # Deprecated
+ - forcetypeassert # recheck in the future.
+
+ settings:
+ depguard:
+ rules:
+ main:
+ deny:
+ - pkg: github.com/instana/testify
+ desc: not allowed
+ - pkg: github.com/pkg/errors
+ desc: Should be replaced by standard lib errors package
+ funlen:
+ lines: -1
+ statements: 40
+ goconst:
+ min-len: 5
+ min-occurrences: 3
+ gocritic:
+ disabled-checks:
+ - sloppyReassign
+ - rangeValCopy
+ - octalLiteral
+ - paramTypeCombine # already handle by gofumpt.extra-rules
+ enabled-tags:
+ - diagnostic
+ - style
+ - performance
+ settings:
+ hugeParam:
+ sizeThreshold: 100
+ gocyclo:
+ min-complexity: 20
+ godox:
+ keywords:
+ - FIXME
+ govet:
+ disable:
+ - fieldalignment
+ enable-all: true
+ misspell:
+ locale: US
+ mnd:
+ ignored-numbers:
+ - "124"
+ wsl:
+ force-case-trailing-whitespace: 1
+ allow-trailing-comment: true
+ exclusions:
+ presets:
+ - comments
+ - std-error-handling
+ - common-false-positives
+
+issues:
+ max-issues-per-linter: 0
+ max-same-issues: 0
diff --git a/vendor/github.com/tdakkota/asciicheck/LICENSE b/vendor/github.com/golangci/asciicheck/LICENSE
similarity index 100%
rename from vendor/github.com/tdakkota/asciicheck/LICENSE
rename to vendor/github.com/golangci/asciicheck/LICENSE
diff --git a/vendor/github.com/golangci/asciicheck/Makefile b/vendor/github.com/golangci/asciicheck/Makefile
new file mode 100644
index 0000000000..cdfc261144
--- /dev/null
+++ b/vendor/github.com/golangci/asciicheck/Makefile
@@ -0,0 +1,15 @@
+.PHONY: clean check test build
+
+default: clean check test build
+
+clean:
+ rm -rf dist/ cover.out
+
+test: clean
+ go test -v -cover ./...
+
+check:
+ golangci-lint run
+
+build:
+ go build -ldflags "-s -w" -trimpath ./cmd/asciicheck/
diff --git a/vendor/github.com/golangci/asciicheck/README.md b/vendor/github.com/golangci/asciicheck/README.md
new file mode 100644
index 0000000000..0d1da4b97c
--- /dev/null
+++ b/vendor/github.com/golangci/asciicheck/README.md
@@ -0,0 +1,82 @@
+# asciicheck
+
+[](https://goreportcard.com/report/github.com/golangci/asciicheck)
+
+Simple linter to check that your code does not contain non-ASCII identifiers
+
+The project has been moved to the golangci organization because the GitHub account of the original author (@tdakkota) is no longer available.
+
+## Install
+
+```bash
+go install github.com/golangci/asciicheck/cmd/asciicheck@latest
+```
+
+## Reason to use
+
+So, do you see this code? Looks correct, isn't it?
+
+```go
+package main
+
+import "fmt"
+
+type TеstStruct struct{}
+
+func main() {
+ s := TestStruct{}
+ fmt.Println(s)
+}
+```
+
+But if you try to run it, you will get an error:
+
+```
+./prog.go:8:7: undefined: TestStruct
+```
+What? `TestStruct` is defined above, but compiler thinks diffrent. Why?
+
+**Answer**:
+
+Because `TestStruct` is not `TеstStruct`.
+```
+type TеstStruct struct{}
+ ^ this 'e' (U+0435) is not 'e' (U+0065)
+```
+
+## Usage
+
+asciicheck uses [`singlechecker`](https://pkg.go.dev/golang.org/x/tools/go/analysis/singlechecker) package to run:
+
+```
+asciicheck: checks that all code identifiers does not have non-ASCII symbols in the name
+
+Usage: asciicheck [-flag] [package]
+
+
+Flags:
+ -V print version and exit
+ -all
+ no effect (deprecated)
+ -c int
+ display offending line with this many lines of context (default -1)
+ -cpuprofile string
+ write CPU profile to this file
+ -debug string
+ debug flags, any subset of "fpstv"
+ -fix
+ apply all suggested fixes
+ -flags
+ print analyzer flags in JSON
+ -json
+ emit JSON output
+ -memprofile string
+ write memory profile to this file
+ -source
+ no effect (deprecated)
+ -tags string
+ no effect (deprecated)
+ -trace string
+ write trace log to this file
+ -v no effect (deprecated)
+```
diff --git a/vendor/github.com/tdakkota/asciicheck/ascii.go b/vendor/github.com/golangci/asciicheck/ascii.go
similarity index 100%
rename from vendor/github.com/tdakkota/asciicheck/ascii.go
rename to vendor/github.com/golangci/asciicheck/ascii.go
diff --git a/vendor/github.com/golangci/asciicheck/asciicheck.go b/vendor/github.com/golangci/asciicheck/asciicheck.go
new file mode 100644
index 0000000000..0983c7270c
--- /dev/null
+++ b/vendor/github.com/golangci/asciicheck/asciicheck.go
@@ -0,0 +1,104 @@
+package asciicheck
+
+import (
+ "fmt"
+ "go/ast"
+ "go/token"
+
+ "golang.org/x/tools/go/analysis"
+ "golang.org/x/tools/go/analysis/passes/inspect"
+ "golang.org/x/tools/go/ast/inspector"
+)
+
+func NewAnalyzer() *analysis.Analyzer {
+ return &analysis.Analyzer{
+ Name: "asciicheck",
+ Doc: "checks that all code identifiers does not have non-ASCII symbols in the name",
+ Requires: []*analysis.Analyzer{inspect.Analyzer},
+ Run: run,
+ }
+}
+
+func run(pass *analysis.Pass) (any, error) {
+ insp := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
+
+ nodeFilter := []ast.Node{
+ (*ast.File)(nil),
+ (*ast.ImportSpec)(nil),
+ (*ast.TypeSpec)(nil),
+ (*ast.ValueSpec)(nil),
+ (*ast.FuncDecl)(nil),
+ (*ast.StructType)(nil),
+ (*ast.FuncType)(nil),
+ (*ast.InterfaceType)(nil),
+ (*ast.LabeledStmt)(nil),
+ (*ast.AssignStmt)(nil),
+ }
+
+ insp.Preorder(nodeFilter, func(n ast.Node) {
+ switch n := n.(type) {
+ case *ast.File:
+ checkIdent(pass, n.Name)
+ case *ast.ImportSpec:
+ checkIdent(pass, n.Name)
+ case *ast.TypeSpec:
+ checkIdent(pass, n.Name)
+ checkFieldList(pass, n.TypeParams)
+ case *ast.ValueSpec:
+ for _, name := range n.Names {
+ checkIdent(pass, name)
+ }
+ case *ast.FuncDecl:
+ checkIdent(pass, n.Name)
+ checkFieldList(pass, n.Recv)
+ case *ast.StructType:
+ checkFieldList(pass, n.Fields)
+ case *ast.FuncType:
+ checkFieldList(pass, n.TypeParams)
+ checkFieldList(pass, n.Params)
+ checkFieldList(pass, n.Results)
+ case *ast.InterfaceType:
+ checkFieldList(pass, n.Methods)
+ case *ast.LabeledStmt:
+ checkIdent(pass, n.Label)
+ case *ast.AssignStmt:
+ if n.Tok == token.DEFINE {
+ for _, expr := range n.Lhs {
+ if ident, ok := expr.(*ast.Ident); ok {
+ checkIdent(pass, ident)
+ }
+ }
+ }
+ }
+ })
+
+ return nil, nil
+}
+
+func checkIdent(pass *analysis.Pass, v *ast.Ident) {
+ if v == nil {
+ return
+ }
+
+ ch, ascii := isASCII(v.Name)
+ if !ascii {
+ pass.Report(
+ analysis.Diagnostic{
+ Pos: v.Pos(),
+ Message: fmt.Sprintf("identifier %q contain non-ASCII character: %#U", v.Name, ch),
+ },
+ )
+ }
+}
+
+func checkFieldList(pass *analysis.Pass, f *ast.FieldList) {
+ if f == nil {
+ return
+ }
+
+ for _, f := range f.List {
+ for _, name := range f.Names {
+ checkIdent(pass, name)
+ }
+ }
+}
diff --git a/vendor/github.com/lasiar/canonicalheader/.gitignore b/vendor/github.com/golangci/canonicalheader/.gitignore
similarity index 100%
rename from vendor/github.com/lasiar/canonicalheader/.gitignore
rename to vendor/github.com/golangci/canonicalheader/.gitignore
diff --git a/vendor/github.com/golangci/canonicalheader/.golangci.yaml b/vendor/github.com/golangci/canonicalheader/.golangci.yaml
new file mode 100644
index 0000000000..0344b05b97
--- /dev/null
+++ b/vendor/github.com/golangci/canonicalheader/.golangci.yaml
@@ -0,0 +1,410 @@
+version: "2"
+
+linters:
+ enable:
+ - asasalint
+ - asciicheck
+ - bidichk
+ - bodyclose
+ - contextcheck
+ - copyloopvar
+ - dupword
+ - durationcheck
+ - errname
+ - errorlint
+ - gochecknoglobals
+ - gochecknoinits
+ - gocritic
+ - godot
+ - gomoddirectives
+ - gosec
+ - intrange
+ - mirror
+ - misspell
+ - nakedret
+ - nilerr
+ - nilnil
+ - noctx
+ - nolintlint
+ - perfsprint
+ - prealloc
+ - predeclared
+ - promlinter
+ - reassign
+ - revive
+ - rowserrcheck
+ - sloglint
+ - sqlclosecheck
+ - staticcheck
+ - tagliatelle
+ - testableexamples
+ - testifylint
+ - thelper
+ - tparallel
+ - unconvert
+ - unparam
+ - usestdlibvars
+ - wastedassign
+ disable:
+ - containedctx
+ - cyclop
+ - decorder
+ - depguard
+ - dogsled
+ - dupl
+ - err113
+ - errchkjson
+ - exhaustive
+ - exhaustruct
+ - forbidigo
+ - forcetypeassert
+ - funlen
+ - ginkgolinter
+ - gocheckcompilerdirectives
+ - gocognit
+ - goconst
+ - gocyclo
+ - godox
+ - goheader
+ - gomodguard
+ - goprintffuncname
+ - grouper
+ - importas
+ - interfacebloat
+ - ireturn
+ - lll
+ - loggercheck
+ - maintidx
+ - makezero
+ - mnd
+ - musttag
+ - nestif
+ - nlreturn
+ - nonamedreturns
+ - nosprintfhostport
+ - paralleltest
+ - testpackage
+ - varnamelen
+ - whitespace
+ - wrapcheck
+ - wsl
+
+ settings:
+ errcheck:
+ check-type-assertions: true
+ check-blank: true
+ exclude-functions:
+ - io/ioutil.ReadFile
+ - io.Copy(*bytes.Buffer)
+ - io.Copy(os.Stdout)
+ gocritic:
+ disabled-checks:
+ - hugeParam
+ - rangeExprCopy
+ - rangeValCopy
+ enabled-tags:
+ - diagnostic
+ - experimental
+ - opinionated
+ - performance
+ - style
+ godot:
+ scope: all
+ govet:
+ disable:
+ - fieldalignment
+ nakedret:
+ max-func-lines: 1
+ revive:
+ max-open-files: 2048
+ confidence: 0.1
+ severity: error
+ enable-all-rules: true
+ rules:
+ - name: add-constant
+ arguments:
+ - allowFloats: 0.0,0.,1.0,1.,2.0,2.
+ allowInts: 0,1,2
+ allowStrs: '""'
+ maxLitCount: "3"
+ severity: warning
+ disabled: false
+ - name: argument-limit
+ arguments:
+ - 4
+ severity: warning
+ disabled: false
+ - name: atomic
+ severity: warning
+ disabled: false
+ - name: banned-characters
+ severity: warning
+ disabled: false
+ - name: bare-return
+ severity: warning
+ disabled: false
+ - name: blank-imports
+ severity: warning
+ disabled: false
+ - name: bool-literal-in-expr
+ severity: warning
+ disabled: false
+ - name: call-to-gc
+ severity: warning
+ disabled: false
+ - name: cognitive-complexity
+ arguments:
+ - 7
+ severity: warning
+ disabled: true
+ - name: comment-spacings
+ severity: warning
+ disabled: false
+ - name: confusing-naming
+ severity: warning
+ disabled: false
+ - name: confusing-results
+ severity: warning
+ disabled: false
+ - name: constant-logical-expr
+ severity: warning
+ disabled: false
+ - name: context-as-argument
+ severity: warning
+ disabled: false
+ - name: context-keys-type
+ severity: warning
+ disabled: false
+ - name: cyclomatic
+ arguments:
+ - 3
+ severity: warning
+ disabled: true
+ - name: datarace
+ severity: warning
+ disabled: false
+ - name: deep-exit
+ severity: warning
+ disabled: true
+ - name: defer
+ severity: warning
+ disabled: false
+ - name: dot-imports
+ severity: warning
+ disabled: false
+ - name: duplicated-imports
+ severity: warning
+ disabled: false
+ - name: early-return
+ severity: warning
+ disabled: false
+ - name: empty-block
+ severity: warning
+ disabled: false
+ - name: empty-lines
+ severity: warning
+ disabled: false
+ - name: enforce-map-style
+ severity: warning
+ disabled: false
+ - name: error-naming
+ severity: warning
+ disabled: false
+ - name: error-return
+ severity: warning
+ disabled: false
+ - name: function-length
+ arguments:
+ - 10
+ - 0
+ severity: warning
+ disabled: true
+ - name: error-strings
+ severity: warning
+ disabled: false
+ - name: errorf
+ severity: warning
+ disabled: false
+ - name: exported
+ severity: warning
+ disabled: false
+ - name: file-header
+ severity: warning
+ disabled: true
+ - name: flag-parameter
+ severity: warning
+ disabled: false
+ - name: function-result-limit
+ arguments:
+ - 2
+ severity: warning
+ disabled: false
+ - name: get-return
+ severity: warning
+ disabled: false
+ - name: identical-branches
+ severity: warning
+ disabled: false
+ - name: if-return
+ severity: warning
+ disabled: false
+ - name: increment-decrement
+ severity: warning
+ disabled: false
+ - name: indent-error-flow
+ severity: warning
+ disabled: false
+ - name: import-alias-naming
+ arguments:
+ - ^[a-z][a-z0-9]{0,}$
+ severity: warning
+ disabled: false
+ - name: imports-blocklist
+ severity: warning
+ disabled: false
+ - name: import-shadowing
+ severity: warning
+ disabled: false
+ - name: line-length-limit
+ arguments:
+ - 80
+ severity: warning
+ disabled: true
+ - name: max-public-structs
+ arguments:
+ - 3
+ severity: warning
+ disabled: false
+ - name: modifies-parameter
+ severity: warning
+ disabled: false
+ - name: modifies-value-receiver
+ severity: warning
+ disabled: false
+ - name: nested-structs
+ severity: warning
+ disabled: false
+ - name: optimize-operands-order
+ severity: warning
+ disabled: false
+ - name: package-comments
+ severity: warning
+ disabled: false
+ - name: range
+ severity: warning
+ disabled: false
+ - name: range-val-in-closure
+ severity: warning
+ disabled: false
+ - name: range-val-address
+ severity: warning
+ disabled: false
+ - name: receiver-naming
+ severity: warning
+ disabled: false
+ - name: redundant-import-alias
+ severity: warning
+ disabled: false
+ - name: redefines-builtin-id
+ severity: warning
+ disabled: false
+ - name: string-of-int
+ severity: warning
+ disabled: false
+ - name: string-format
+ arguments:
+ - - core.WriteError[1].Message
+ - /^([^A-Z]|$)/
+ - must not start with a capital letter
+ - - fmt.Errorf[0]
+ - /(^|[^\.!?])$/
+ - must not end in punctuation
+ - - panic
+ - /^[^\n]*$/
+ - must not contain line breaks
+ severity: warning
+ disabled: false
+ - name: struct-tag
+ arguments:
+ - json,inline
+ - bson,outline,gnu
+ severity: warning
+ disabled: false
+ - name: superfluous-else
+ severity: warning
+ disabled: false
+ - name: time-equal
+ severity: warning
+ disabled: false
+ - name: time-naming
+ severity: warning
+ disabled: false
+ - name: var-naming
+ severity: warning
+ disabled: false
+ - name: var-declaration
+ severity: warning
+ disabled: false
+ - name: unconditional-recursion
+ severity: warning
+ disabled: false
+ - name: unexported-naming
+ severity: warning
+ disabled: false
+ - name: unexported-return
+ severity: warning
+ disabled: false
+ - name: unhandled-error
+ severity: warning
+ disabled: false
+ - name: unnecessary-stmt
+ severity: warning
+ disabled: false
+ - name: unreachable-code
+ severity: warning
+ disabled: false
+ - name: unused-parameter
+ arguments:
+ - allowRegex: ^_
+ severity: warning
+ disabled: false
+ - name: unused-receiver
+ severity: warning
+ disabled: false
+ - name: useless-break
+ severity: warning
+ disabled: false
+ - name: waitgroup-by-value
+ severity: warning
+ disabled: false
+ tagliatelle:
+ case:
+ rules:
+ avro: snake
+ bson: camel
+ json: snake
+ mapstructure: kebab
+ xml: camel
+ yaml: snake
+ exclusions:
+ presets:
+ - comments
+ - common-false-positives
+ - std-error-handling
+
+issues:
+ max-issues-per-linter: 0
+ max-same-issues: 0
+
+formatters:
+ enable:
+ - gci
+ - gofmt
+ - gofumpt
+ - goimports
+ settings:
+ gci:
+ sections:
+ - standard
+ - default
+ - localmodule
diff --git a/vendor/github.com/lasiar/canonicalheader/.goreleaser.yaml b/vendor/github.com/golangci/canonicalheader/.goreleaser.yaml
similarity index 100%
rename from vendor/github.com/lasiar/canonicalheader/.goreleaser.yaml
rename to vendor/github.com/golangci/canonicalheader/.goreleaser.yaml
diff --git a/vendor/github.com/lasiar/canonicalheader/LICENCE b/vendor/github.com/golangci/canonicalheader/LICENCE
similarity index 100%
rename from vendor/github.com/lasiar/canonicalheader/LICENCE
rename to vendor/github.com/golangci/canonicalheader/LICENCE
diff --git a/vendor/github.com/lasiar/canonicalheader/README.md b/vendor/github.com/golangci/canonicalheader/README.md
similarity index 100%
rename from vendor/github.com/lasiar/canonicalheader/README.md
rename to vendor/github.com/golangci/canonicalheader/README.md
diff --git a/vendor/github.com/golangci/canonicalheader/analyzer.go b/vendor/github.com/golangci/canonicalheader/analyzer.go
new file mode 100644
index 0000000000..cf35199d2e
--- /dev/null
+++ b/vendor/github.com/golangci/canonicalheader/analyzer.go
@@ -0,0 +1,309 @@
+package canonicalheader
+
+import (
+ "flag"
+ "fmt"
+ "go/ast"
+ "go/types"
+ "net/http"
+
+ "github.com/go-toolsmith/astcast"
+ "golang.org/x/tools/go/analysis"
+ "golang.org/x/tools/go/analysis/passes/inspect"
+ "golang.org/x/tools/go/ast/inspector"
+ "golang.org/x/tools/go/types/typeutil"
+)
+
+const (
+ httpHeaderPkg = "net/http"
+ httpHeaderName = "Header"
+)
+
+//nolint:gochecknoglobals // for backward compatibility.
+var Analyzer = New()
+
+func New() *analysis.Analyzer {
+ c := &canonicalHeader{}
+
+ a := &analysis.Analyzer{
+ Name: "canonicalheader",
+ Doc: "canonicalheader checks whether net/http.Header uses canonical header",
+ Requires: []*analysis.Analyzer{inspect.Analyzer},
+ Run: c.run,
+ }
+
+ a.Flags.Init("canonicalheader", flag.ExitOnError)
+ a.Flags.Var(&c.exclusions, "exclusions", "comma-separated list of exclusion rules")
+ a.Flags.BoolVar(&c.useDefaultExclusion, "useDefaultExclusion", true, "use default exclusion rules")
+
+ return a
+}
+
+type canonicalHeader struct {
+ useDefaultExclusion bool
+ exclusions stringSet
+}
+
+type argumenter interface {
+ diagnostic(canonicalHeader string) analysis.Diagnostic
+ value() string
+}
+
+func (c *canonicalHeader) buildExclusions() map[string]string {
+ var defEx map[string]string
+ if c.useDefaultExclusion {
+ defEx = initialism()
+ }
+
+ result := make(map[string]string, len(c.exclusions)+len(defEx))
+
+ for canonical, noCanonical := range defEx {
+ result[canonical] = noCanonical
+ }
+
+ for _, ex := range c.exclusions {
+ result[http.CanonicalHeaderKey(ex)] = ex
+ }
+
+ return result
+}
+
+func (c *canonicalHeader) run(pass *analysis.Pass) (any, error) {
+ spctor, ok := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
+ if !ok {
+ return nil, fmt.Errorf("want %T, got %T", spctor, pass.ResultOf[inspect.Analyzer])
+ }
+
+ exclusions := c.buildExclusions()
+
+ nodeFilter := []ast.Node{
+ (*ast.CallExpr)(nil),
+ }
+
+ spctor.Preorder(nodeFilter, func(n ast.Node) {
+ callExp, ok := n.(*ast.CallExpr)
+ if !ok {
+ return
+ }
+
+ var (
+ // gotType type receiver.
+ gotType types.Type
+ gotMethodName string
+ )
+
+ switch t := typeutil.Callee(pass.TypesInfo, callExp).(type) {
+ // Direct call method.
+ case *types.Func:
+ fn := t
+ // Find net/http.Header{} by function call.
+ signature, ok := fn.Type().(*types.Signature)
+ if !ok {
+ return
+ }
+
+ recv := signature.Recv()
+
+ // It's a func, not a method.
+ if recv == nil {
+ return
+ }
+
+ gotType = recv.Type()
+
+ sel := astcast.ToSelectorExpr(callExp.Fun).Sel
+ if sel == nil {
+ return
+ }
+
+ gotMethodName = sel.Name
+
+ // h := http.Header{}
+ // f := h.Get
+ // v("Test-Value").
+ case *types.Var:
+ ident, ok := callExp.Fun.(*ast.Ident)
+ if !ok {
+ return
+ }
+
+ if ident.Obj == nil {
+ return
+ }
+
+ // f := h.Get.
+ assign, ok := ident.Obj.Decl.(*ast.AssignStmt)
+ if !ok {
+ return
+ }
+
+ // For case `i, v := 0, h.Get`.
+ // indexAssign--^.
+ indexAssign := -1
+ for i, lh := range assign.Lhs {
+ // Find by name of variable.
+ if astcast.ToIdent(lh).Name == ident.Name {
+ indexAssign = i
+ }
+ }
+
+ // Not found.
+ if indexAssign == -1 {
+ return
+ }
+
+ if len(assign.Rhs) <= indexAssign {
+ return
+ }
+
+ sel, ok := assign.Rhs[indexAssign].(*ast.SelectorExpr)
+ if !ok {
+ return
+ }
+
+ if sel.Sel == nil {
+ return
+ }
+
+ gotMethodName = sel.Sel.Name
+ ident, ok = sel.X.(*ast.Ident)
+ if !ok {
+ return
+ }
+
+ obj := pass.TypesInfo.ObjectOf(ident)
+ gotType = obj.Type()
+
+ default:
+ return
+ }
+
+ // It is not net/http.Header{}.
+ if !isHTTPHeader(gotType) {
+ return
+ }
+
+ // Search for known methods where the key is the first arg.
+ if !isValidMethod(gotMethodName) {
+ return
+ }
+
+ // Should be more than one. Because get the value by index it
+ // will not be superfluous.
+ if len(callExp.Args) == 0 {
+ return
+ }
+
+ callArg := callExp.Args[0]
+
+ // Check for type casting from myString to string.
+ // it could be: Get(string(string(string(myString)))).
+ // need this node------------------------^^^^^^^^.
+ for {
+ // If it is not *ast.CallExpr, this is a value.
+ c, ok := callArg.(*ast.CallExpr)
+ if !ok {
+ break
+ }
+
+ // Some function is called, skip this case.
+ if len(c.Args) == 0 {
+ return
+ }
+
+ f, ok := c.Fun.(*ast.Ident)
+ if !ok {
+ break
+ }
+
+ obj := pass.TypesInfo.ObjectOf(f)
+ // nil may be by code, but not by logic.
+ // TypeInfo should contain of type.
+ if obj == nil {
+ break
+ }
+
+ // This is function.
+ // Skip this method call.
+ _, ok = obj.Type().(*types.Signature)
+ if ok {
+ return
+ }
+
+ callArg = c.Args[0]
+ }
+
+ var arg argumenter
+ switch t := callArg.(type) {
+ case *ast.BasicLit:
+ lString, err := newLiteralString(t)
+ if err != nil {
+ return
+ }
+
+ arg = lString
+
+ case *ast.Ident:
+ constString, err := newConstantKey(pass.TypesInfo, t)
+ if err != nil {
+ return
+ }
+
+ arg = constString
+
+ default:
+ return
+ }
+
+ argValue := arg.value()
+
+ headerKeyCanonical := canonicalHeaderKey(argValue, exclusions)
+ if argValue == headerKeyCanonical {
+ return
+ }
+
+ pass.Report(arg.diagnostic(headerKeyCanonical))
+ })
+
+ //nolint:nilnil // This is expected by the signature of the callback.
+ return nil, nil
+}
+
+func canonicalHeaderKey(s string, m map[string]string) string {
+ canonical := http.CanonicalHeaderKey(s)
+
+ wellKnown, ok := m[canonical]
+ if !ok {
+ return canonical
+ }
+
+ return wellKnown
+}
+
+func isValidMethod(name string) bool {
+ switch name {
+ case "Get", "Set", "Add", "Del", "Values":
+ return true
+ default:
+ return false
+ }
+}
+
+func isHTTPHeader(t types.Type) bool {
+ named, ok := types.Unalias(t).(*types.Named)
+ if !ok {
+ return false
+ }
+
+ obj := named.Obj()
+ if obj == nil {
+ return false
+ }
+
+ pkg := obj.Pkg()
+ if pkg == nil {
+ return false
+ }
+
+ return pkg.Path() == httpHeaderPkg && obj.Name() == httpHeaderName
+}
diff --git a/vendor/github.com/golangci/canonicalheader/configure.go b/vendor/github.com/golangci/canonicalheader/configure.go
new file mode 100644
index 0000000000..302a5a0788
--- /dev/null
+++ b/vendor/github.com/golangci/canonicalheader/configure.go
@@ -0,0 +1,28 @@
+package canonicalheader
+
+import (
+ "strings"
+)
+
+// stringSet is a set-of-nonempty-strings-valued flag.
+type stringSet []string
+
+func (s *stringSet) String() string {
+ return strings.Join(*s, ",")
+}
+
+func (s *stringSet) Set(flag string) error {
+ list := strings.Split(flag, ",")
+
+ *s = make(stringSet, 0, len(list))
+
+ for _, element := range list {
+ element = strings.TrimSpace(element)
+ if element == "" {
+ continue
+ }
+
+ *s = append(*s, element)
+ }
+ return nil
+}
diff --git a/vendor/github.com/lasiar/canonicalheader/constant_string.go b/vendor/github.com/golangci/canonicalheader/constant_string.go
similarity index 90%
rename from vendor/github.com/lasiar/canonicalheader/constant_string.go
rename to vendor/github.com/golangci/canonicalheader/constant_string.go
index 27988f0d53..9df31361b4 100644
--- a/vendor/github.com/lasiar/canonicalheader/constant_string.go
+++ b/vendor/github.com/golangci/canonicalheader/constant_string.go
@@ -37,10 +37,9 @@ func (c constantString) diagnostic(canonicalHeader string) analysis.Diagnostic {
Pos: c.pos,
End: c.end,
Message: fmt.Sprintf(
- "const %q used as a key at http.Header, but %q is not canonical, want %q",
- c.nameOfConst,
- c.originalValue,
+ "use %q instead of %q",
canonicalHeader,
+ c.originalValue,
),
}
}
diff --git a/vendor/github.com/lasiar/canonicalheader/initialism.go b/vendor/github.com/golangci/canonicalheader/initialism.go
similarity index 100%
rename from vendor/github.com/lasiar/canonicalheader/initialism.go
rename to vendor/github.com/golangci/canonicalheader/initialism.go
diff --git a/vendor/github.com/lasiar/canonicalheader/literal_string.go b/vendor/github.com/golangci/canonicalheader/literal_string.go
similarity index 90%
rename from vendor/github.com/lasiar/canonicalheader/literal_string.go
rename to vendor/github.com/golangci/canonicalheader/literal_string.go
index 71cd5f3974..d1bd010f76 100644
--- a/vendor/github.com/lasiar/canonicalheader/literal_string.go
+++ b/vendor/github.com/golangci/canonicalheader/literal_string.go
@@ -59,10 +59,10 @@ func (l literalString) diagnostic(canonicalHeader string) analysis.Diagnostic {
return analysis.Diagnostic{
Pos: l.pos,
End: l.end,
- Message: fmt.Sprintf("non-canonical header %q, instead use: %q", l.originalValue, canonicalHeader),
+ Message: fmt.Sprintf("use %q instead of %q", canonicalHeader, l.originalValue),
SuggestedFixes: []analysis.SuggestedFix{
{
- Message: fmt.Sprintf("should replace %q with %q", l.originalValue, canonicalHeader),
+ Message: fmt.Sprintf("should be replaced %q with %q", l.originalValue, canonicalHeader),
TextEdits: []analysis.TextEdit{
{
Pos: l.pos,
diff --git a/vendor/github.com/golangci/canonicalheader/makefile b/vendor/github.com/golangci/canonicalheader/makefile
new file mode 100644
index 0000000000..0f7a912ad1
--- /dev/null
+++ b/vendor/github.com/golangci/canonicalheader/makefile
@@ -0,0 +1,13 @@
+.PHONY:
+
+test:
+ go test -v -race ./...
+
+linter:
+ golangci-lint -v run ./...
+
+generate:
+ go run ./cmd/initialismer/*.go -target="mapping" > ./initialism.go
+ go run ./cmd/initialismer/*.go -target="test" > ./testdata/src/initialism/initialism.go
+ go run ./cmd/initialismer/*.go -target="test-golden" > ./testdata/src/initialism/initialism.go.golden
+ gofmt -w ./initialism.go ./testdata/src/initialism/initialism.go ./testdata/src/initialism/initialism.go.golden
diff --git a/vendor/github.com/golangci/dupl/printer/html.go b/vendor/github.com/golangci/dupl/printer/html.go
index ac14741419..3c119e6380 100644
--- a/vendor/github.com/golangci/dupl/printer/html.go
+++ b/vendor/github.com/golangci/dupl/printer/html.go
@@ -26,10 +26,32 @@ func (p *htmlprinter) PrintHeader() error {
Duplicates
`)
diff --git a/vendor/github.com/golangci/dupl/suffixtree/dupl.go b/vendor/github.com/golangci/dupl/suffixtree/dupl.go
index ab145b4f3b..0263203edf 100644
--- a/vendor/github.com/golangci/dupl/suffixtree/dupl.go
+++ b/vendor/github.com/golangci/dupl/suffixtree/dupl.go
@@ -54,7 +54,7 @@ func (c *contextList) append(c2 *contextList) {
}
}
-// FindDuplOver find pairs of maximal duplicities over a threshold
+// FindDuplOver finds pairs of maximal duplicities over a threshold
// length.
func (t *STree) FindDuplOver(threshold int) <-chan Match {
auxTran := newTran(0, 0, t.root)
diff --git a/vendor/github.com/golangci/dupl/suffixtree/suffixtree.go b/vendor/github.com/golangci/dupl/suffixtree/suffixtree.go
index 871469e8d5..30aaa6f4e9 100644
--- a/vendor/github.com/golangci/dupl/suffixtree/suffixtree.go
+++ b/vendor/github.com/golangci/dupl/suffixtree/suffixtree.go
@@ -38,7 +38,7 @@ func New() *STree {
return t
}
-// Update refreshes the suffix tree to by new data.
+// Update refreshes the suffix tree with new data.
func (t *STree) Update(data ...Token) {
t.data = append(t.data, data...)
for range data {
@@ -79,8 +79,8 @@ func (t *STree) update() {
}
// testAndSplit tests whether a state with canonical ref. pair
-// (s, (start, end)) is the end point, that is, a state that have
-// a c-transition. If not, then state (exs, (start, end)) is made
+// (s, (start, end)) is the end point, that is, a state that has
+// a c-transition. If not, then the state (exs, (start, end)) is made
// explicit (if not already so).
func (t *STree) testAndSplit(s *state, start, end Pos) (exs *state, endPoint bool) {
c := t.data[t.end]
@@ -148,11 +148,11 @@ func (t *STree) String() string {
return buf.String()
}
-func printState(buf *bytes.Buffer, s *state, ident int) {
+func printState(buf *bytes.Buffer, s *state, indent int) {
for _, tr := range s.trans {
- fmt.Fprint(buf, strings.Repeat(" ", ident))
+ fmt.Fprint(buf, strings.Repeat(" ", indent))
fmt.Fprintf(buf, "* (%d, %d)\n", tr.start, tr.ActEnd())
- printState(buf, tr.state, ident+1)
+ printState(buf, tr.state, indent+1)
}
}
diff --git a/vendor/github.com/golangci/dupl/syntax/golang/golang.go b/vendor/github.com/golangci/dupl/syntax/golang/golang.go
index a0b1e77e13..ff3e51b2ee 100644
--- a/vendor/github.com/golangci/dupl/syntax/golang/golang.go
+++ b/vendor/github.com/golangci/dupl/syntax/golang/golang.go
@@ -39,6 +39,7 @@ const (
IfStmt
IncDecStmt
IndexExpr
+ IndexListExpr
InterfaceType
KeyValueExpr
LabeledStmt
@@ -234,6 +235,9 @@ func (t *transformer) trans(node ast.Node) (o *syntax.Node) {
case *ast.FuncType:
o.Type = FuncType
+ if n.TypeParams != nil {
+ o.AddChildren(t.trans(n.TypeParams))
+ }
o.AddChildren(t.trans(n.Params))
if n.Results != nil {
o.AddChildren(t.trans(n.Results))
@@ -270,6 +274,13 @@ func (t *transformer) trans(node ast.Node) (o *syntax.Node) {
o.Type = IndexExpr
o.AddChildren(t.trans(n.X), t.trans(n.Index))
+ case *ast.IndexListExpr:
+ o.Type = IndexListExpr
+ o.AddChildren(t.trans(n.X))
+ for _, idx := range n.Indices {
+ o.AddChildren(t.trans(idx))
+ }
+
case *ast.InterfaceType:
o.Type = InterfaceType
o.AddChildren(t.trans(n.Methods))
@@ -358,7 +369,11 @@ func (t *transformer) trans(node ast.Node) (o *syntax.Node) {
case *ast.TypeSpec:
o.Type = TypeSpec
- o.AddChildren(t.trans(n.Name), t.trans(n.Type))
+ o.AddChildren(t.trans(n.Name))
+ if n.TypeParams != nil {
+ o.AddChildren(t.trans(n.TypeParams))
+ }
+ o.AddChildren(t.trans(n.Type))
case *ast.TypeSwitchStmt:
o.Type = TypeSwitchStmt
diff --git a/vendor/github.com/golangci/dupl/syntax/syntax.go b/vendor/github.com/golangci/dupl/syntax/syntax.go
index 9b11d3119b..871f671864 100644
--- a/vendor/github.com/golangci/dupl/syntax/syntax.go
+++ b/vendor/github.com/golangci/dupl/syntax/syntax.go
@@ -129,8 +129,8 @@ func getUnitsIndexes(nodeSeq []*Node, threshold int) []int {
return indexes
}
-// isCyclic finds out whether there is a repetive pattern in the found clone. If positive,
-// it return false to point out that the clone would be redundant.
+// isCyclic finds out whether there is a repetitive pattern in the found clone. If positive,
+// it returns true to point out that the clone would be redundant.
func isCyclic(indexes []int, nodes []*Node) bool {
cnt := len(indexes)
if cnt <= 1 {
diff --git a/vendor/github.com/golangci/go-printf-func-name/pkg/analyzer/analyzer.go b/vendor/github.com/golangci/go-printf-func-name/pkg/analyzer/analyzer.go
index bce4b242ed..0b41500f24 100644
--- a/vendor/github.com/golangci/go-printf-func-name/pkg/analyzer/analyzer.go
+++ b/vendor/github.com/golangci/go-printf-func-name/pkg/analyzer/analyzer.go
@@ -16,7 +16,7 @@ var Analyzer = &analysis.Analyzer{
Requires: []*analysis.Analyzer{inspect.Analyzer},
}
-func run(pass *analysis.Pass) (interface{}, error) {
+func run(pass *analysis.Pass) (any, error) {
insp := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
nodeFilter := []ast.Node{
@@ -44,24 +44,21 @@ func run(pass *analysis.Pass) (interface{}, error) {
return
}
- if formatParamNames := params[len(params)-2].Names; len(formatParamNames) == 0 || formatParamNames[len(formatParamNames)-1].Name != "format" {
+ formatParamNames := params[len(params)-2].Names
+ if len(formatParamNames) == 0 || formatParamNames[len(formatParamNames)-1].Name != "format" {
return
}
argsParamType, ok := params[len(params)-1].Type.(*ast.Ellipsis)
- if !ok { // args are not ellipsis (...args)
+ if !ok {
+ // args are not ellipsis (...args)
return
}
- elementType, ok := argsParamType.Elt.(*ast.InterfaceType)
- if !ok { // args are not of interface type, but we need interface{}
+ if !isAny(argsParamType) {
return
}
- if elementType.Methods != nil && len(elementType.Methods.List) != 0 {
- return // has >= 1 method in interface, but we need an empty interface "interface{}"
- }
-
if strings.HasSuffix(funcDecl.Name.Name, "f") {
return
}
@@ -72,3 +69,22 @@ func run(pass *analysis.Pass) (interface{}, error) {
return nil, nil
}
+
+func isAny(ell *ast.Ellipsis) bool {
+ switch elt := ell.Elt.(type) {
+ case *ast.InterfaceType:
+ if elt.Methods != nil && len(elt.Methods.List) != 0 {
+ // has >= 1 method in interface, but we need an empty interface "interface{}"
+ return false
+ }
+
+ return true
+
+ case *ast.Ident:
+ if elt.Name == "any" {
+ return true
+ }
+ }
+
+ return false
+}
diff --git a/vendor/github.com/golangci/gofmt/Makefile b/vendor/github.com/golangci/gofmt/Makefile
new file mode 100644
index 0000000000..8375bf4007
--- /dev/null
+++ b/vendor/github.com/golangci/gofmt/Makefile
@@ -0,0 +1,9 @@
+.PHONY: build
+
+default: test build
+
+build:
+ go build .
+
+test:
+ go test ./...
diff --git a/vendor/github.com/golangci/gofmt/gofmt.go b/vendor/github.com/golangci/gofmt/gofmt.go
new file mode 100644
index 0000000000..430a1b8d75
--- /dev/null
+++ b/vendor/github.com/golangci/gofmt/gofmt.go
@@ -0,0 +1,73 @@
+package gofmt
+
+import (
+ "fmt"
+ "go/ast"
+ "go/parser"
+ "go/printer"
+ "go/token"
+
+ "github.com/golangci/gofmt/internal"
+)
+
+type Options struct {
+ NeedSimplify bool
+ RewriteRules []RewriteRule
+}
+
+type RewriteRule struct {
+ Pattern string
+ Replacement string
+}
+
+// Source formats the code like gofmt.
+// Empty string `rewrite` will be ignored.
+// https://github.com/golang/go/blob/1b291b70dff51732415da5b68debe323704d8e8d/src/cmd/gofmt/gofmt.go#L236-L300
+// https://github.com/golang/go/blob/1b291b70dff51732415da5b68debe323704d8e8d/src/go/format/format.go#L101-L115
+func Source(filename string, src []byte, opts Options) ([]byte, error) {
+ fset := token.NewFileSet()
+
+ file, sourceAdj, indentAdj, err := internal.Parse(fset, filename, src, false)
+ if err != nil {
+ return nil, err
+ }
+
+ file, err = rewriteFileContent(fset, file, opts.RewriteRules)
+ if err != nil {
+ return nil, err
+ }
+
+ ast.SortImports(fset, file)
+
+ if opts.NeedSimplify {
+ internal.Simplify(file)
+ }
+
+ return internal.Format(fset, file, sourceAdj, indentAdj, src, printer.Config{Mode: internal.PrinterMode, Tabwidth: internal.TabWidth})
+}
+
+func rewriteFileContent(fset *token.FileSet, file *ast.File, rewriteRules []RewriteRule) (*ast.File, error) {
+ for _, rewriteRule := range rewriteRules {
+ pattern, err := parseExpression(rewriteRule.Pattern, "pattern")
+ if err != nil {
+ return nil, err
+ }
+
+ replacement, err := parseExpression(rewriteRule.Replacement, "replacement")
+ if err != nil {
+ return nil, err
+ }
+
+ file = internal.RewriteFile(fset, pattern, replacement, file)
+ }
+
+ return file, nil
+}
+
+func parseExpression(s, what string) (ast.Expr, error) {
+ x, err := parser.ParseExpr(s)
+ if err != nil {
+ return nil, fmt.Errorf("parsing %s %q at %s\n", what, s, err)
+ }
+ return x, nil
+}
diff --git a/vendor/github.com/golangci/gofmt/gofmt/doc.go b/vendor/github.com/golangci/gofmt/gofmt/doc.go
deleted file mode 100644
index d0a4580219..0000000000
--- a/vendor/github.com/golangci/gofmt/gofmt/doc.go
+++ /dev/null
@@ -1,106 +0,0 @@
-// Copyright 2009 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-/*
-Gofmt formats Go programs.
-It uses tabs for indentation and blanks for alignment.
-Alignment assumes that an editor is using a fixed-width font.
-
-Without an explicit path, it processes the standard input. Given a file,
-it operates on that file; given a directory, it operates on all .go files in
-that directory, recursively. (Files starting with a period are ignored.)
-By default, gofmt prints the reformatted sources to standard output.
-
-Usage:
-
- gofmt [flags] [path ...]
-
-The flags are:
-
- -d
- Do not print reformatted sources to standard output.
- If a file's formatting is different than gofmt's, print diffs
- to standard output.
- -e
- Print all (including spurious) errors.
- -l
- Do not print reformatted sources to standard output.
- If a file's formatting is different from gofmt's, print its name
- to standard output.
- -r rule
- Apply the rewrite rule to the source before reformatting.
- -s
- Try to simplify code (after applying the rewrite rule, if any).
- -w
- Do not print reformatted sources to standard output.
- If a file's formatting is different from gofmt's, overwrite it
- with gofmt's version. If an error occurred during overwriting,
- the original file is restored from an automatic backup.
-
-Debugging support:
-
- -cpuprofile filename
- Write cpu profile to the specified file.
-
-The rewrite rule specified with the -r flag must be a string of the form:
-
- pattern -> replacement
-
-Both pattern and replacement must be valid Go expressions.
-In the pattern, single-character lowercase identifiers serve as
-wildcards matching arbitrary sub-expressions; those expressions
-will be substituted for the same identifiers in the replacement.
-
-When gofmt reads from standard input, it accepts either a full Go program
-or a program fragment. A program fragment must be a syntactically
-valid declaration list, statement list, or expression. When formatting
-such a fragment, gofmt preserves leading indentation as well as leading
-and trailing spaces, so that individual sections of a Go program can be
-formatted by piping them through gofmt.
-
-# Examples
-
-To check files for unnecessary parentheses:
-
- gofmt -r '(a) -> a' -l *.go
-
-To remove the parentheses:
-
- gofmt -r '(a) -> a' -w *.go
-
-To convert the package tree from explicit slice upper bounds to implicit ones:
-
- gofmt -r 'α[β:len(α)] -> α[β:]' -w $GOROOT/src
-
-# The simplify command
-
-When invoked with -s gofmt will make the following source transformations where possible.
-
- An array, slice, or map composite literal of the form:
- []T{T{}, T{}}
- will be simplified to:
- []T{{}, {}}
-
- A slice expression of the form:
- s[a:len(s)]
- will be simplified to:
- s[a:]
-
- A range of the form:
- for x, _ = range v {...}
- will be simplified to:
- for x = range v {...}
-
- A range of the form:
- for _ = range v {...}
- will be simplified to:
- for range v {...}
-
-This may result in changes that are incompatible with earlier versions of Go.
-*/
-package gofmt
-
-// BUG(rsc): The implementation of -r is a bit slow.
-// BUG(gri): If -w fails, the restored original file may not have some of the
-// original file attributes.
diff --git a/vendor/github.com/golangci/gofmt/gofmt/gofmt.go b/vendor/github.com/golangci/gofmt/gofmt/gofmt.go
deleted file mode 100644
index a4f252e86d..0000000000
--- a/vendor/github.com/golangci/gofmt/gofmt/gofmt.go
+++ /dev/null
@@ -1,570 +0,0 @@
-// Copyright 2009 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package gofmt
-
-import (
- "bytes"
- "context"
- "flag"
- "fmt"
- "go/ast"
- "go/parser"
- "go/printer"
- "go/scanner"
- "go/token"
- "io"
- "io/fs"
- "math/rand"
- "os"
- "path/filepath"
- "runtime"
- "runtime/pprof"
- "strconv"
- "strings"
-
- "github.com/rogpeppe/go-internal/diff"
- "golang.org/x/sync/semaphore"
-)
-
-var (
- // main operation modes
- list = flag.Bool("gofmt.l", false, "list files whose formatting differs from gofmt's")
- write = flag.Bool("gofmt.w", false, "write result to (source) file instead of stdout")
- rewriteRule = flag.String("gofmt.r", "", "rewrite rule (e.g., 'a[b:len(a)] -> a[b:]')")
- simplifyAST = flag.Bool("gofmt.s", false, "simplify code")
- doDiff = flag.Bool("gofmt.d", false, "display diffs instead of rewriting files")
- allErrors = flag.Bool("gofmt.e", false, "report all errors (not just the first 10 on different lines)")
-
- // debugging
- cpuprofile = flag.String("gofmt.cpuprofile", "", "write cpu profile to this file")
-)
-
-// Keep these in sync with go/format/format.go.
-const (
- tabWidth = 8
- printerMode = printer.UseSpaces | printer.TabIndent | printerNormalizeNumbers
-
- // printerNormalizeNumbers means to canonicalize number literal prefixes
- // and exponents while printing. See https://golang.org/doc/go1.13#gofmt.
- //
- // This value is defined in go/printer specifically for go/format and cmd/gofmt.
- printerNormalizeNumbers = 1 << 30
-)
-
-// fdSem guards the number of concurrently-open file descriptors.
-//
-// For now, this is arbitrarily set to 200, based on the observation that many
-// platforms default to a kernel limit of 256. Ideally, perhaps we should derive
-// it from rlimit on platforms that support that system call.
-//
-// File descriptors opened from outside of this package are not tracked,
-// so this limit may be approximate.
-var fdSem = make(chan bool, 200)
-
-var (
- rewrite func(*token.FileSet, *ast.File) *ast.File
- parserMode parser.Mode
-)
-
-func usage() {
- fmt.Fprintf(os.Stderr, "usage: gofmt [flags] [path ...]\n")
- flag.PrintDefaults()
-}
-
-func initParserMode() {
- parserMode = parser.ParseComments
- if *allErrors {
- parserMode |= parser.AllErrors
- }
- // It's only -r that makes use of go/ast's object resolution,
- // so avoid the unnecessary work if the flag isn't used.
- if *rewriteRule == "" {
- parserMode |= parser.SkipObjectResolution
- }
-}
-
-func isGoFile(f fs.DirEntry) bool {
- // ignore non-Go files
- name := f.Name()
- return !strings.HasPrefix(name, ".") && strings.HasSuffix(name, ".go") && !f.IsDir()
-}
-
-// A sequencer performs concurrent tasks that may write output, but emits that
-// output in a deterministic order.
-type sequencer struct {
- maxWeight int64
- sem *semaphore.Weighted // weighted by input bytes (an approximate proxy for memory overhead)
- prev <-chan *reporterState // 1-buffered
-}
-
-// newSequencer returns a sequencer that allows concurrent tasks up to maxWeight
-// and writes tasks' output to out and err.
-func newSequencer(maxWeight int64, out, err io.Writer) *sequencer {
- sem := semaphore.NewWeighted(maxWeight)
- prev := make(chan *reporterState, 1)
- prev <- &reporterState{out: out, err: err}
- return &sequencer{
- maxWeight: maxWeight,
- sem: sem,
- prev: prev,
- }
-}
-
-// exclusive is a weight that can be passed to a sequencer to cause
-// a task to be executed without any other concurrent tasks.
-const exclusive = -1
-
-// Add blocks until the sequencer has enough weight to spare, then adds f as a
-// task to be executed concurrently.
-//
-// If the weight is either negative or larger than the sequencer's maximum
-// weight, Add blocks until all other tasks have completed, then the task
-// executes exclusively (blocking all other calls to Add until it completes).
-//
-// f may run concurrently in a goroutine, but its output to the passed-in
-// reporter will be sequential relative to the other tasks in the sequencer.
-//
-// If f invokes a method on the reporter, execution of that method may block
-// until the previous task has finished. (To maximize concurrency, f should
-// avoid invoking the reporter until it has finished any parallelizable work.)
-//
-// If f returns a non-nil error, that error will be reported after f's output
-// (if any) and will cause a nonzero final exit code.
-func (s *sequencer) Add(weight int64, f func(*reporter) error) {
- if weight < 0 || weight > s.maxWeight {
- weight = s.maxWeight
- }
- if err := s.sem.Acquire(context.TODO(), weight); err != nil {
- // Change the task from "execute f" to "report err".
- weight = 0
- f = func(*reporter) error { return err }
- }
-
- r := &reporter{prev: s.prev}
- next := make(chan *reporterState, 1)
- s.prev = next
-
- // Start f in parallel: it can run until it invokes a method on r, at which
- // point it will block until the previous task releases the output state.
- go func() {
- if err := f(r); err != nil {
- r.Report(err)
- }
- next <- r.getState() // Release the next task.
- s.sem.Release(weight)
- }()
-}
-
-// AddReport prints an error to s after the output of any previously-added
-// tasks, causing the final exit code to be nonzero.
-func (s *sequencer) AddReport(err error) {
- s.Add(0, func(*reporter) error { return err })
-}
-
-// GetExitCode waits for all previously-added tasks to complete, then returns an
-// exit code for the sequence suitable for passing to os.Exit.
-func (s *sequencer) GetExitCode() int {
- c := make(chan int, 1)
- s.Add(0, func(r *reporter) error {
- c <- r.ExitCode()
- return nil
- })
- return <-c
-}
-
-// A reporter reports output, warnings, and errors.
-type reporter struct {
- prev <-chan *reporterState
- state *reporterState
-}
-
-// reporterState carries the state of a reporter instance.
-//
-// Only one reporter at a time may have access to a reporterState.
-type reporterState struct {
- out, err io.Writer
- exitCode int
-}
-
-// getState blocks until any prior reporters are finished with the reporter
-// state, then returns the state for manipulation.
-func (r *reporter) getState() *reporterState {
- if r.state == nil {
- r.state = <-r.prev
- }
- return r.state
-}
-
-// Warnf emits a warning message to the reporter's error stream,
-// without changing its exit code.
-func (r *reporter) Warnf(format string, args ...any) {
- fmt.Fprintf(r.getState().err, format, args...)
-}
-
-// Write emits a slice to the reporter's output stream.
-//
-// Any error is returned to the caller, and does not otherwise affect the
-// reporter's exit code.
-func (r *reporter) Write(p []byte) (int, error) {
- return r.getState().out.Write(p)
-}
-
-// Report emits a non-nil error to the reporter's error stream,
-// changing its exit code to a nonzero value.
-func (r *reporter) Report(err error) {
- if err == nil {
- panic("Report with nil error")
- }
- st := r.getState()
- scanner.PrintError(st.err, err)
- st.exitCode = 2
-}
-
-func (r *reporter) ExitCode() int {
- return r.getState().exitCode
-}
-
-// If info == nil, we are formatting stdin instead of a file.
-// If in == nil, the source is the contents of the file with the given filename.
-func processFile(filename string, info fs.FileInfo, in io.Reader, r *reporter) error {
- src, err := readFile(filename, info, in)
- if err != nil {
- return err
- }
-
- fileSet := token.NewFileSet()
- // If we are formatting stdin, we accept a program fragment in lieu of a
- // complete source file.
- fragmentOk := info == nil
- file, sourceAdj, indentAdj, err := parse(fileSet, filename, src, fragmentOk)
- if err != nil {
- return err
- }
-
- if rewrite != nil {
- if sourceAdj == nil {
- file = rewrite(fileSet, file)
- } else {
- r.Warnf("warning: rewrite ignored for incomplete programs\n")
- }
- }
-
- ast.SortImports(fileSet, file)
-
- if *simplifyAST {
- simplify(file)
- }
-
- res, err := format(fileSet, file, sourceAdj, indentAdj, src, printer.Config{Mode: printerMode, Tabwidth: tabWidth})
- if err != nil {
- return err
- }
-
- if !bytes.Equal(src, res) {
- // formatting has changed
- if *list {
- fmt.Fprintln(r, filename)
- }
- if *write {
- if info == nil {
- panic("-w should not have been allowed with stdin")
- }
-
- perm := info.Mode().Perm()
- if err := writeFile(filename, src, res, perm, info.Size()); err != nil {
- return err
- }
- }
- if *doDiff {
- newName := filepath.ToSlash(filename)
- oldName := newName + ".orig"
- r.Write(diff.Diff(oldName, src, newName, res))
- }
- }
-
- if !*list && !*write && !*doDiff {
- _, err = r.Write(res)
- }
-
- return err
-}
-
-// readFile reads the contents of filename, described by info.
-// If in is non-nil, readFile reads directly from it.
-// Otherwise, readFile opens and reads the file itself,
-// with the number of concurrently-open files limited by fdSem.
-func readFile(filename string, info fs.FileInfo, in io.Reader) ([]byte, error) {
- if in == nil {
- fdSem <- true
- var err error
- f, err := os.Open(filename)
- if err != nil {
- return nil, err
- }
- in = f
- defer func() {
- f.Close()
- <-fdSem
- }()
- }
-
- // Compute the file's size and read its contents with minimal allocations.
- //
- // If we have the FileInfo from filepath.WalkDir, use it to make
- // a buffer of the right size and avoid ReadAll's reallocations.
- //
- // If the size is unknown (or bogus, or overflows an int), fall back to
- // a size-independent ReadAll.
- size := -1
- if info != nil && info.Mode().IsRegular() && int64(int(info.Size())) == info.Size() {
- size = int(info.Size())
- }
- if size+1 <= 0 {
- // The file is not known to be regular, so we don't have a reliable size for it.
- var err error
- src, err := io.ReadAll(in)
- if err != nil {
- return nil, err
- }
- return src, nil
- }
-
- // We try to read size+1 bytes so that we can detect modifications: if we
- // read more than size bytes, then the file was modified concurrently.
- // (If that happens, we could, say, append to src to finish the read, or
- // proceed with a truncated buffer — but the fact that it changed at all
- // indicates a possible race with someone editing the file, so we prefer to
- // stop to avoid corrupting it.)
- src := make([]byte, size+1)
- n, err := io.ReadFull(in, src)
- switch err {
- case nil, io.EOF, io.ErrUnexpectedEOF:
- // io.ReadFull returns io.EOF (for an empty file) or io.ErrUnexpectedEOF
- // (for a non-empty file) if the file was changed unexpectedly. Continue
- // with comparing file sizes in those cases.
- default:
- return nil, err
- }
- if n < size {
- return nil, fmt.Errorf("error: size of %s changed during reading (from %d to %d bytes)", filename, size, n)
- } else if n > size {
- return nil, fmt.Errorf("error: size of %s changed during reading (from %d to >=%d bytes)", filename, size, len(src))
- }
- return src[:n], nil
-}
-
-func main() {
- // Arbitrarily limit in-flight work to 2MiB times the number of threads.
- //
- // The actual overhead for the parse tree and output will depend on the
- // specifics of the file, but this at least keeps the footprint of the process
- // roughly proportional to GOMAXPROCS.
- maxWeight := (2 << 20) * int64(runtime.GOMAXPROCS(0))
- s := newSequencer(maxWeight, os.Stdout, os.Stderr)
-
- // call gofmtMain in a separate function
- // so that it can use defer and have them
- // run before the exit.
- gofmtMain(s)
- os.Exit(s.GetExitCode())
-}
-
-func gofmtMain(s *sequencer) {
- flag.Usage = usage
- flag.Parse()
-
- if *cpuprofile != "" {
- fdSem <- true
- f, err := os.Create(*cpuprofile)
- if err != nil {
- s.AddReport(fmt.Errorf("creating cpu profile: %s", err))
- return
- }
- defer func() {
- f.Close()
- <-fdSem
- }()
- pprof.StartCPUProfile(f)
- defer pprof.StopCPUProfile()
- }
-
- initParserMode()
- initRewrite()
-
- args := flag.Args()
- if len(args) == 0 {
- if *write {
- s.AddReport(fmt.Errorf("error: cannot use -w with standard input"))
- return
- }
- s.Add(0, func(r *reporter) error {
- return processFile("", nil, os.Stdin, r)
- })
- return
- }
-
- for _, arg := range args {
- switch info, err := os.Stat(arg); {
- case err != nil:
- s.AddReport(err)
- case !info.IsDir():
- // Non-directory arguments are always formatted.
- arg := arg
- s.Add(fileWeight(arg, info), func(r *reporter) error {
- return processFile(arg, info, nil, r)
- })
- default:
- // Directories are walked, ignoring non-Go files.
- err := filepath.WalkDir(arg, func(path string, f fs.DirEntry, err error) error {
- if err != nil || !isGoFile(f) {
- return err
- }
- info, err := f.Info()
- if err != nil {
- s.AddReport(err)
- return nil
- }
- s.Add(fileWeight(path, info), func(r *reporter) error {
- return processFile(path, info, nil, r)
- })
- return nil
- })
- if err != nil {
- s.AddReport(err)
- }
- }
- }
-}
-
-func fileWeight(path string, info fs.FileInfo) int64 {
- if info == nil {
- return exclusive
- }
- if info.Mode().Type() == fs.ModeSymlink {
- var err error
- info, err = os.Stat(path)
- if err != nil {
- return exclusive
- }
- }
- if !info.Mode().IsRegular() {
- // For non-regular files, FileInfo.Size is system-dependent and thus not a
- // reliable indicator of weight.
- return exclusive
- }
- return info.Size()
-}
-
-// writeFile updates a file with the new formatted data.
-func writeFile(filename string, orig, formatted []byte, perm fs.FileMode, size int64) error {
- // Make a temporary backup file before rewriting the original file.
- bakname, err := backupFile(filename, orig, perm)
- if err != nil {
- return err
- }
-
- fdSem <- true
- defer func() { <-fdSem }()
-
- fout, err := os.OpenFile(filename, os.O_WRONLY, perm)
- if err != nil {
- // We couldn't even open the file, so it should
- // not have changed.
- os.Remove(bakname)
- return err
- }
- defer fout.Close() // for error paths
-
- restoreFail := func(err error) {
- fmt.Fprintf(os.Stderr, "gofmt: %s: error restoring file to original: %v; backup in %s\n", filename, err, bakname)
- }
-
- n, err := fout.Write(formatted)
- if err == nil && int64(n) < size {
- err = fout.Truncate(int64(n))
- }
-
- if err != nil {
- // Rewriting the file failed.
-
- if n == 0 {
- // Original file unchanged.
- os.Remove(bakname)
- return err
- }
-
- // Try to restore the original contents.
-
- no, erro := fout.WriteAt(orig, 0)
- if erro != nil {
- // That failed too.
- restoreFail(erro)
- return err
- }
-
- if no < n {
- // Original file is shorter. Truncate.
- if erro = fout.Truncate(int64(no)); erro != nil {
- restoreFail(erro)
- return err
- }
- }
-
- if erro := fout.Close(); erro != nil {
- restoreFail(erro)
- return err
- }
-
- // Original contents restored.
- os.Remove(bakname)
- return err
- }
-
- if err := fout.Close(); err != nil {
- restoreFail(err)
- return err
- }
-
- // File updated.
- os.Remove(bakname)
- return nil
-}
-
-// backupFile writes data to a new file named filename with permissions perm,
-// with randomly chosen such that the file name is unique. backupFile returns
-// the chosen file name.
-func backupFile(filename string, data []byte, perm fs.FileMode) (string, error) {
- fdSem <- true
- defer func() { <-fdSem }()
-
- nextRandom := func() string {
- return strconv.Itoa(rand.Int())
- }
-
- dir, base := filepath.Split(filename)
- var (
- bakname string
- f *os.File
- )
- for {
- bakname = filepath.Join(dir, base+"."+nextRandom())
- var err error
- f, err = os.OpenFile(bakname, os.O_RDWR|os.O_CREATE|os.O_EXCL, perm)
- if err == nil {
- break
- }
- if err != nil && !os.IsExist(err) {
- return "", err
- }
- }
-
- // write data to backup file
- _, err := f.Write(data)
- if err1 := f.Close(); err == nil {
- err = err1
- }
-
- return bakname, err
-}
diff --git a/vendor/github.com/golangci/gofmt/gofmt/golangci.go b/vendor/github.com/golangci/gofmt/gofmt/golangci.go
deleted file mode 100644
index a7f3ef6e73..0000000000
--- a/vendor/github.com/golangci/gofmt/gofmt/golangci.go
+++ /dev/null
@@ -1,133 +0,0 @@
-package gofmt
-
-import (
- "bytes"
- "fmt"
- "go/ast"
- "go/parser"
- "go/printer"
- "go/token"
- "os"
- "path/filepath"
- "sync"
-
- "github.com/rogpeppe/go-internal/diff"
-)
-
-type Options struct {
- NeedSimplify bool
- RewriteRules []RewriteRule
-}
-
-var parserModeMu sync.RWMutex
-
-type RewriteRule struct {
- Pattern string
- Replacement string
-}
-
-// Run runs gofmt.
-// Deprecated: use [Source] instead.
-func Run(filename string, needSimplify bool) ([]byte, error) {
- return RunRewrite(filename, needSimplify, nil)
-}
-
-// RunRewrite runs gofmt.
-// Deprecated: use [Source] instead.
-func RunRewrite(filename string, needSimplify bool, rewriteRules []RewriteRule) ([]byte, error) {
- src, err := os.ReadFile(filename)
- if err != nil {
- return nil, err
- }
-
- fset := token.NewFileSet()
-
- parserModeMu.Lock()
- initParserMode()
- parserModeMu.Unlock()
-
- file, sourceAdj, indentAdj, err := parse(fset, filename, src, false)
- if err != nil {
- return nil, err
- }
-
- file, err = rewriteFileContent(fset, file, rewriteRules)
- if err != nil {
- return nil, err
- }
-
- ast.SortImports(fset, file)
-
- if needSimplify {
- simplify(file)
- }
-
- res, err := format(fset, file, sourceAdj, indentAdj, src, printer.Config{Mode: printerMode, Tabwidth: tabWidth})
- if err != nil {
- return nil, err
- }
-
- if bytes.Equal(src, res) {
- return nil, nil
- }
-
- // formatting has changed
- newName := filepath.ToSlash(filename)
- oldName := newName + ".orig"
-
- return diff.Diff(oldName, src, newName, res), nil
-}
-
-// Source formats the code like gofmt.
-// Empty string `rewrite` will be ignored.
-func Source(filename string, src []byte, opts Options) ([]byte, error) {
- fset := token.NewFileSet()
-
- parserModeMu.Lock()
- initParserMode()
- parserModeMu.Unlock()
-
- file, sourceAdj, indentAdj, err := parse(fset, filename, src, false)
- if err != nil {
- return nil, err
- }
-
- file, err = rewriteFileContent(fset, file, opts.RewriteRules)
- if err != nil {
- return nil, err
- }
-
- ast.SortImports(fset, file)
-
- if opts.NeedSimplify {
- simplify(file)
- }
-
- return format(fset, file, sourceAdj, indentAdj, src, printer.Config{Mode: printerMode, Tabwidth: tabWidth})
-}
-
-func rewriteFileContent(fset *token.FileSet, file *ast.File, rewriteRules []RewriteRule) (*ast.File, error) {
- for _, rewriteRule := range rewriteRules {
- pattern, err := parseExpression(rewriteRule.Pattern, "pattern")
- if err != nil {
- return nil, err
- }
-
- replacement, err := parseExpression(rewriteRule.Replacement, "replacement")
- if err != nil {
- return nil, err
- }
-
- file = rewriteFile(fset, pattern, replacement, file)
- }
-
- return file, nil
-}
-
-func parseExpression(s, what string) (ast.Expr, error) {
- x, err := parser.ParseExpr(s)
- if err != nil {
- return nil, fmt.Errorf("parsing %s %q at %s\n", what, s, err)
- }
- return x, nil
-}
diff --git a/vendor/github.com/golangci/gofmt/gofmt/readme.md b/vendor/github.com/golangci/gofmt/gofmt/readme.md
deleted file mode 100644
index 907973116f..0000000000
--- a/vendor/github.com/golangci/gofmt/gofmt/readme.md
+++ /dev/null
@@ -1,15 +0,0 @@
-# Hard Fork of gofmt
-
-- https://github.com/golang/go/blob/master/src/cmd/gofmt/
-- https://github.com/golang/go/blob/master/src/internal/testenv
-- https://github.com/golang/go/blob/master/src/internal/platform
-- https://github.com/golang/go/blob/master/src/internal/diff -> replaced by `github.com/rogpeppe/go-internal/diff`
-- https://github.com/golang/go/blob/master/src/internal/cfg
-
-## Updates
-
-- 2024-08-17: Sync with go1.22.6
-- 2023-02-28: Sync with go1.21.7
-- 2023-10-04: Sync with go1.20.8
-- 2023-10-04: Sync with go1.19.13
-- 2022-08-31: Sync with go1.18.5
diff --git a/vendor/github.com/golangci/gofmt/gofmt/rewrite.go b/vendor/github.com/golangci/gofmt/gofmt/rewrite.go
deleted file mode 100644
index c95d44f61b..0000000000
--- a/vendor/github.com/golangci/gofmt/gofmt/rewrite.go
+++ /dev/null
@@ -1,309 +0,0 @@
-// Copyright 2009 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package gofmt
-
-import (
- "fmt"
- "go/ast"
- "go/parser"
- "go/token"
- "os"
- "reflect"
- "strings"
- "unicode"
- "unicode/utf8"
-)
-
-func initRewrite() {
- if *rewriteRule == "" {
- rewrite = nil // disable any previous rewrite
- return
- }
- f := strings.Split(*rewriteRule, "->")
- if len(f) != 2 {
- fmt.Fprintf(os.Stderr, "rewrite rule must be of the form 'pattern -> replacement'\n")
- os.Exit(2)
- }
- pattern := parseExpr(f[0], "pattern")
- replace := parseExpr(f[1], "replacement")
- rewrite = func(fset *token.FileSet, p *ast.File) *ast.File {
- return rewriteFile(fset, pattern, replace, p)
- }
-}
-
-// parseExpr parses s as an expression.
-// It might make sense to expand this to allow statement patterns,
-// but there are problems with preserving formatting and also
-// with what a wildcard for a statement looks like.
-func parseExpr(s, what string) ast.Expr {
- x, err := parser.ParseExpr(s)
- if err != nil {
- fmt.Fprintf(os.Stderr, "parsing %s %s at %s\n", what, s, err)
- os.Exit(2)
- }
- return x
-}
-
-// Keep this function for debugging.
-/*
-func dump(msg string, val reflect.Value) {
- fmt.Printf("%s:\n", msg)
- ast.Print(fileSet, val.Interface())
- fmt.Println()
-}
-*/
-
-// rewriteFile applies the rewrite rule 'pattern -> replace' to an entire file.
-func rewriteFile(fileSet *token.FileSet, pattern, replace ast.Expr, p *ast.File) *ast.File {
- cmap := ast.NewCommentMap(fileSet, p, p.Comments)
- m := make(map[string]reflect.Value)
- pat := reflect.ValueOf(pattern)
- repl := reflect.ValueOf(replace)
-
- var rewriteVal func(val reflect.Value) reflect.Value
- rewriteVal = func(val reflect.Value) reflect.Value {
- // don't bother if val is invalid to start with
- if !val.IsValid() {
- return reflect.Value{}
- }
- val = apply(rewriteVal, val)
- clear(m)
- if match(m, pat, val) {
- val = subst(m, repl, reflect.ValueOf(val.Interface().(ast.Node).Pos()))
- }
- return val
- }
-
- r := apply(rewriteVal, reflect.ValueOf(p)).Interface().(*ast.File)
- r.Comments = cmap.Filter(r).Comments() // recreate comments list
- return r
-}
-
-// set is a wrapper for x.Set(y); it protects the caller from panics if x cannot be changed to y.
-func set(x, y reflect.Value) {
- // don't bother if x cannot be set or y is invalid
- if !x.CanSet() || !y.IsValid() {
- return
- }
- defer func() {
- if x := recover(); x != nil {
- if s, ok := x.(string); ok &&
- (strings.Contains(s, "type mismatch") || strings.Contains(s, "not assignable")) {
- // x cannot be set to y - ignore this rewrite
- return
- }
- panic(x)
- }
- }()
- x.Set(y)
-}
-
-// Values/types for special cases.
-var (
- objectPtrNil = reflect.ValueOf((*ast.Object)(nil))
- scopePtrNil = reflect.ValueOf((*ast.Scope)(nil))
-
- identType = reflect.TypeOf((*ast.Ident)(nil))
- objectPtrType = reflect.TypeOf((*ast.Object)(nil))
- positionType = reflect.TypeOf(token.NoPos)
- callExprType = reflect.TypeOf((*ast.CallExpr)(nil))
- scopePtrType = reflect.TypeOf((*ast.Scope)(nil))
-)
-
-// apply replaces each AST field x in val with f(x), returning val.
-// To avoid extra conversions, f operates on the reflect.Value form.
-func apply(f func(reflect.Value) reflect.Value, val reflect.Value) reflect.Value {
- if !val.IsValid() {
- return reflect.Value{}
- }
-
- // *ast.Objects introduce cycles and are likely incorrect after
- // rewrite; don't follow them but replace with nil instead
- if val.Type() == objectPtrType {
- return objectPtrNil
- }
-
- // similarly for scopes: they are likely incorrect after a rewrite;
- // replace them with nil
- if val.Type() == scopePtrType {
- return scopePtrNil
- }
-
- switch v := reflect.Indirect(val); v.Kind() {
- case reflect.Slice:
- for i := 0; i < v.Len(); i++ {
- e := v.Index(i)
- set(e, f(e))
- }
- case reflect.Struct:
- for i := 0; i < v.NumField(); i++ {
- e := v.Field(i)
- set(e, f(e))
- }
- case reflect.Interface:
- e := v.Elem()
- set(v, f(e))
- }
- return val
-}
-
-func isWildcard(s string) bool {
- rune, size := utf8.DecodeRuneInString(s)
- return size == len(s) && unicode.IsLower(rune)
-}
-
-// match reports whether pattern matches val,
-// recording wildcard submatches in m.
-// If m == nil, match checks whether pattern == val.
-func match(m map[string]reflect.Value, pattern, val reflect.Value) bool {
- // Wildcard matches any expression. If it appears multiple
- // times in the pattern, it must match the same expression
- // each time.
- if m != nil && pattern.IsValid() && pattern.Type() == identType {
- name := pattern.Interface().(*ast.Ident).Name
- if isWildcard(name) && val.IsValid() {
- // wildcards only match valid (non-nil) expressions.
- if _, ok := val.Interface().(ast.Expr); ok && !val.IsNil() {
- if old, ok := m[name]; ok {
- return match(nil, old, val)
- }
- m[name] = val
- return true
- }
- }
- }
-
- // Otherwise, pattern and val must match recursively.
- if !pattern.IsValid() || !val.IsValid() {
- return !pattern.IsValid() && !val.IsValid()
- }
- if pattern.Type() != val.Type() {
- return false
- }
-
- // Special cases.
- switch pattern.Type() {
- case identType:
- // For identifiers, only the names need to match
- // (and none of the other *ast.Object information).
- // This is a common case, handle it all here instead
- // of recursing down any further via reflection.
- p := pattern.Interface().(*ast.Ident)
- v := val.Interface().(*ast.Ident)
- return p == nil && v == nil || p != nil && v != nil && p.Name == v.Name
- case objectPtrType, positionType:
- // object pointers and token positions always match
- return true
- case callExprType:
- // For calls, the Ellipsis fields (token.Pos) must
- // match since that is how f(x) and f(x...) are different.
- // Check them here but fall through for the remaining fields.
- p := pattern.Interface().(*ast.CallExpr)
- v := val.Interface().(*ast.CallExpr)
- if p.Ellipsis.IsValid() != v.Ellipsis.IsValid() {
- return false
- }
- }
-
- p := reflect.Indirect(pattern)
- v := reflect.Indirect(val)
- if !p.IsValid() || !v.IsValid() {
- return !p.IsValid() && !v.IsValid()
- }
-
- switch p.Kind() {
- case reflect.Slice:
- if p.Len() != v.Len() {
- return false
- }
- for i := 0; i < p.Len(); i++ {
- if !match(m, p.Index(i), v.Index(i)) {
- return false
- }
- }
- return true
-
- case reflect.Struct:
- for i := 0; i < p.NumField(); i++ {
- if !match(m, p.Field(i), v.Field(i)) {
- return false
- }
- }
- return true
-
- case reflect.Interface:
- return match(m, p.Elem(), v.Elem())
- }
-
- // Handle token integers, etc.
- return p.Interface() == v.Interface()
-}
-
-// subst returns a copy of pattern with values from m substituted in place
-// of wildcards and pos used as the position of tokens from the pattern.
-// if m == nil, subst returns a copy of pattern and doesn't change the line
-// number information.
-func subst(m map[string]reflect.Value, pattern reflect.Value, pos reflect.Value) reflect.Value {
- if !pattern.IsValid() {
- return reflect.Value{}
- }
-
- // Wildcard gets replaced with map value.
- if m != nil && pattern.Type() == identType {
- name := pattern.Interface().(*ast.Ident).Name
- if isWildcard(name) {
- if old, ok := m[name]; ok {
- return subst(nil, old, reflect.Value{})
- }
- }
- }
-
- if pos.IsValid() && pattern.Type() == positionType {
- // use new position only if old position was valid in the first place
- if old := pattern.Interface().(token.Pos); !old.IsValid() {
- return pattern
- }
- return pos
- }
-
- // Otherwise copy.
- switch p := pattern; p.Kind() {
- case reflect.Slice:
- if p.IsNil() {
- // Do not turn nil slices into empty slices. go/ast
- // guarantees that certain lists will be nil if not
- // populated.
- return reflect.Zero(p.Type())
- }
- v := reflect.MakeSlice(p.Type(), p.Len(), p.Len())
- for i := 0; i < p.Len(); i++ {
- v.Index(i).Set(subst(m, p.Index(i), pos))
- }
- return v
-
- case reflect.Struct:
- v := reflect.New(p.Type()).Elem()
- for i := 0; i < p.NumField(); i++ {
- v.Field(i).Set(subst(m, p.Field(i), pos))
- }
- return v
-
- case reflect.Pointer:
- v := reflect.New(p.Type()).Elem()
- if elem := p.Elem(); elem.IsValid() {
- v.Set(subst(m, elem, pos).Addr())
- }
- return v
-
- case reflect.Interface:
- v := reflect.New(p.Type()).Elem()
- if elem := p.Elem(); elem.IsValid() {
- v.Set(subst(m, elem, pos))
- }
- return v
- }
-
- return pattern
-}
diff --git a/vendor/github.com/golangci/gofmt/internal/.gitattributes b/vendor/github.com/golangci/gofmt/internal/.gitattributes
new file mode 100644
index 0000000000..19d80d28ec
--- /dev/null
+++ b/vendor/github.com/golangci/gofmt/internal/.gitattributes
@@ -0,0 +1 @@
+/testdata/crlf.input text eol=crlf
diff --git a/vendor/github.com/golangci/gofmt/gofmt/LICENSE b/vendor/github.com/golangci/gofmt/internal/LICENSE
similarity index 100%
rename from vendor/github.com/golangci/gofmt/gofmt/LICENSE
rename to vendor/github.com/golangci/gofmt/internal/LICENSE
diff --git a/vendor/github.com/golangci/gofmt/internal/doc.go b/vendor/github.com/golangci/gofmt/internal/doc.go
new file mode 100644
index 0000000000..6a25f1de1a
--- /dev/null
+++ b/vendor/github.com/golangci/gofmt/internal/doc.go
@@ -0,0 +1,106 @@
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+/*
+Gofmt formats Go programs.
+It uses tabs for indentation and blanks for alignment.
+Alignment assumes that an editor is using a fixed-width font.
+
+Without an explicit path, it processes the standard input. Given a file,
+it operates on that file; given a directory, it operates on all .go files in
+that directory, recursively. (Files starting with a period are ignored.)
+By default, gofmt prints the reformatted sources to standard output.
+
+Usage:
+
+ gofmt [flags] [path ...]
+
+The flags are:
+
+ -d
+ Do not print reformatted sources to standard output.
+ If a file's formatting is different than gofmt's, print diffs
+ to standard output.
+ -e
+ Print all (including spurious) errors.
+ -l
+ Do not print reformatted sources to standard output.
+ If a file's formatting is different from gofmt's, print its name
+ to standard output.
+ -r rule
+ Apply the rewrite rule to the source before reformatting.
+ -s
+ Try to simplify code (after applying the rewrite rule, if any).
+ -w
+ Do not print reformatted sources to standard output.
+ If a file's formatting is different from gofmt's, overwrite it
+ with gofmt's version. If an error occurred during overwriting,
+ the original file is restored from an automatic backup.
+
+Debugging support:
+
+ -cpuprofile filename
+ Write cpu profile to the specified file.
+
+The rewrite rule specified with the -r flag must be a string of the form:
+
+ pattern -> replacement
+
+Both pattern and replacement must be valid Go expressions.
+In the pattern, single-character lowercase identifiers serve as
+wildcards matching arbitrary sub-expressions; those expressions
+will be substituted for the same identifiers in the replacement.
+
+When gofmt reads from standard input, it accepts either a full Go program
+or a program fragment. A program fragment must be a syntactically
+valid declaration list, statement list, or expression. When formatting
+such a fragment, gofmt preserves leading indentation as well as leading
+and trailing spaces, so that individual sections of a Go program can be
+formatted by piping them through gofmt.
+
+# Examples
+
+To check files for unnecessary parentheses:
+
+ gofmt -r '(a) -> a' -l *.go
+
+To remove the parentheses:
+
+ gofmt -r '(a) -> a' -w *.go
+
+To convert the package tree from explicit slice upper bounds to implicit ones:
+
+ gofmt -r 'α[β:len(α)] -> α[β:]' -w $GOROOT/src
+
+# The simplify command
+
+When invoked with -s gofmt will make the following source transformations where possible.
+
+ An array, slice, or map composite literal of the form:
+ []T{T{}, T{}}
+ will be simplified to:
+ []T{{}, {}}
+
+ A slice expression of the form:
+ s[a:len(s)]
+ will be simplified to:
+ s[a:]
+
+ A range of the form:
+ for x, _ = range v {...}
+ will be simplified to:
+ for x = range v {...}
+
+ A range of the form:
+ for _ = range v {...}
+ will be simplified to:
+ for range v {...}
+
+This may result in changes that are incompatible with earlier versions of Go.
+*/
+package internal
+
+// BUG(rsc): The implementation of -r is a bit slow.
+// BUG(gri): If -w fails, the restored original file may not have some of the
+// original file attributes.
diff --git a/vendor/github.com/golangci/gofmt/internal/gofmt.go b/vendor/github.com/golangci/gofmt/internal/gofmt.go
new file mode 100644
index 0000000000..1fd62b8f28
--- /dev/null
+++ b/vendor/github.com/golangci/gofmt/internal/gofmt.go
@@ -0,0 +1,574 @@
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package internal
+
+import (
+ "bytes"
+ "context"
+ "flag"
+ "fmt"
+ "go/ast"
+ "go/printer"
+ "go/scanner"
+ "go/token"
+ "io"
+ "io/fs"
+ "math/rand"
+ "os"
+ "path/filepath"
+ "runtime"
+ "runtime/pprof"
+ "strconv"
+ "strings"
+
+ "github.com/rogpeppe/go-internal/diff"
+ "golang.org/x/sync/semaphore"
+)
+
+var (
+ // main operation modes
+ list = flag.Bool("gofmt.l", false, "list files whose formatting differs from gofmt's")
+ write = flag.Bool("gofmt.w", false, "write result to (source) file instead of stdout")
+ rewriteRule = flag.String("gofmt.r", "", "rewrite rule (e.g., 'a[b:len(a)] -> a[b:]')")
+ simplifyAST = flag.Bool("gofmt.s", false, "simplify code")
+ doDiff = flag.Bool("gofmt.d", false, "display diffs instead of rewriting files")
+ allErrors = flag.Bool("gofmt.e", false, "report all errors (not just the first 10 on different lines)")
+
+ // debugging
+ cpuprofile = flag.String("gofmt.cpuprofile", "", "write cpu profile to this file")
+
+ // errors
+ errFormattingDiffers = fmt.Errorf("formatting differs from gofmt's")
+)
+
+// Keep these in sync with go/format/format.go.
+const (
+ tabWidth = 8
+ printerMode = printer.UseSpaces | printer.TabIndent | printerNormalizeNumbers
+
+ // printerNormalizeNumbers means to canonicalize number literal prefixes
+ // and exponents while printing. See https://golang.org/doc/go1.13#gofmt.
+ //
+ // This value is defined in go/printer specifically for go/format and cmd/gofmt.
+ printerNormalizeNumbers = 1 << 30
+)
+
+// fdSem guards the number of concurrently-open file descriptors.
+//
+// For now, this is arbitrarily set to 200, based on the observation that many
+// platforms default to a kernel limit of 256. Ideally, perhaps we should derive
+// it from rlimit on platforms that support that system call.
+//
+// File descriptors opened from outside of this package are not tracked,
+// so this limit may be approximate.
+var fdSem = make(chan bool, 200)
+
+var (
+ rewrite func(*token.FileSet, *ast.File) *ast.File
+ // parserMode parser.Mode // NOTE(golangci-lint): replaced with a constant
+)
+
+func usage() {
+ fmt.Fprintf(os.Stderr, "usage: gofmt [flags] [path ...]\n")
+ flag.PrintDefaults()
+}
+
+// NOTE(golangci-lint): replaced with a constant
+func initParserMode() {
+ /*
+ parserMode = parser.ParseComments
+ if *allErrors {
+ parserMode |= parser.AllErrors
+ }
+ // It's only -r that makes use of go/ast's object resolution,
+ // so avoid the unnecessary work if the flag isn't used.
+ if *rewriteRule == "" {
+ parserMode |= parser.SkipObjectResolution
+ }
+ */
+}
+
+func isGoFilename(name string) bool {
+ return !strings.HasPrefix(name, ".") && strings.HasSuffix(name, ".go")
+}
+
+// A sequencer performs concurrent tasks that may write output, but emits that
+// output in a deterministic order.
+type sequencer struct {
+ maxWeight int64
+ sem *semaphore.Weighted // weighted by input bytes (an approximate proxy for memory overhead)
+ prev <-chan *reporterState // 1-buffered
+}
+
+// newSequencer returns a sequencer that allows concurrent tasks up to maxWeight
+// and writes tasks' output to out and err.
+func newSequencer(maxWeight int64, out, err io.Writer) *sequencer {
+ sem := semaphore.NewWeighted(maxWeight)
+ prev := make(chan *reporterState, 1)
+ prev <- &reporterState{out: out, err: err}
+ return &sequencer{
+ maxWeight: maxWeight,
+ sem: sem,
+ prev: prev,
+ }
+}
+
+// exclusive is a weight that can be passed to a sequencer to cause
+// a task to be executed without any other concurrent tasks.
+const exclusive = -1
+
+// Add blocks until the sequencer has enough weight to spare, then adds f as a
+// task to be executed concurrently.
+//
+// If the weight is either negative or larger than the sequencer's maximum
+// weight, Add blocks until all other tasks have completed, then the task
+// executes exclusively (blocking all other calls to Add until it completes).
+//
+// f may run concurrently in a goroutine, but its output to the passed-in
+// reporter will be sequential relative to the other tasks in the sequencer.
+//
+// If f invokes a method on the reporter, execution of that method may block
+// until the previous task has finished. (To maximize concurrency, f should
+// avoid invoking the reporter until it has finished any parallelizable work.)
+//
+// If f returns a non-nil error, that error will be reported after f's output
+// (if any) and will cause a nonzero final exit code.
+func (s *sequencer) Add(weight int64, f func(*reporter) error) {
+ if weight < 0 || weight > s.maxWeight {
+ weight = s.maxWeight
+ }
+ if err := s.sem.Acquire(context.TODO(), weight); err != nil {
+ // Change the task from "execute f" to "report err".
+ weight = 0
+ f = func(*reporter) error { return err }
+ }
+
+ r := &reporter{prev: s.prev}
+ next := make(chan *reporterState, 1)
+ s.prev = next
+
+ // Start f in parallel: it can run until it invokes a method on r, at which
+ // point it will block until the previous task releases the output state.
+ go func() {
+ if err := f(r); err != nil {
+ r.Report(err)
+ }
+ next <- r.getState() // Release the next task.
+ s.sem.Release(weight)
+ }()
+}
+
+// AddReport prints an error to s after the output of any previously-added
+// tasks, causing the final exit code to be nonzero.
+func (s *sequencer) AddReport(err error) {
+ s.Add(0, func(*reporter) error { return err })
+}
+
+// GetExitCode waits for all previously-added tasks to complete, then returns an
+// exit code for the sequence suitable for passing to os.Exit.
+func (s *sequencer) GetExitCode() int {
+ c := make(chan int, 1)
+ s.Add(0, func(r *reporter) error {
+ c <- r.ExitCode()
+ return nil
+ })
+ return <-c
+}
+
+// A reporter reports output, warnings, and errors.
+type reporter struct {
+ prev <-chan *reporterState
+ state *reporterState
+}
+
+// reporterState carries the state of a reporter instance.
+//
+// Only one reporter at a time may have access to a reporterState.
+type reporterState struct {
+ out, err io.Writer
+ exitCode int
+}
+
+// getState blocks until any prior reporters are finished with the reporter
+// state, then returns the state for manipulation.
+func (r *reporter) getState() *reporterState {
+ if r.state == nil {
+ r.state = <-r.prev
+ }
+ return r.state
+}
+
+// Warnf emits a warning message to the reporter's error stream,
+// without changing its exit code.
+func (r *reporter) Warnf(format string, args ...any) {
+ fmt.Fprintf(r.getState().err, format, args...)
+}
+
+// Write emits a slice to the reporter's output stream.
+//
+// Any error is returned to the caller, and does not otherwise affect the
+// reporter's exit code.
+func (r *reporter) Write(p []byte) (int, error) {
+ return r.getState().out.Write(p)
+}
+
+// Report emits a non-nil error to the reporter's error stream,
+// changing its exit code to a nonzero value.
+func (r *reporter) Report(err error) {
+ if err == nil {
+ panic("Report with nil error")
+ }
+ st := r.getState()
+ if err == errFormattingDiffers {
+ st.exitCode = 1
+ } else {
+ scanner.PrintError(st.err, err)
+ st.exitCode = 2
+ }
+}
+
+func (r *reporter) ExitCode() int {
+ return r.getState().exitCode
+}
+
+// If info == nil, we are formatting stdin instead of a file.
+// If in == nil, the source is the contents of the file with the given filename.
+func processFile(filename string, info fs.FileInfo, in io.Reader, r *reporter) error {
+ src, err := readFile(filename, info, in)
+ if err != nil {
+ return err
+ }
+
+ fileSet := token.NewFileSet()
+ // If we are formatting stdin, we accept a program fragment in lieu of a
+ // complete source file.
+ fragmentOk := info == nil
+ file, sourceAdj, indentAdj, err := parse(fileSet, filename, src, fragmentOk)
+ if err != nil {
+ return err
+ }
+
+ if rewrite != nil {
+ if sourceAdj == nil {
+ file = rewrite(fileSet, file)
+ } else {
+ r.Warnf("warning: rewrite ignored for incomplete programs\n")
+ }
+ }
+
+ ast.SortImports(fileSet, file)
+
+ if *simplifyAST {
+ simplify(file)
+ }
+
+ res, err := format(fileSet, file, sourceAdj, indentAdj, src, printer.Config{Mode: printerMode, Tabwidth: tabWidth})
+ if err != nil {
+ return err
+ }
+
+ if !bytes.Equal(src, res) {
+ // formatting has changed
+ if *list {
+ fmt.Fprintln(r, filename)
+ }
+ if *write {
+ if info == nil {
+ panic("-w should not have been allowed with stdin")
+ }
+
+ perm := info.Mode().Perm()
+ if err := writeFile(filename, src, res, perm); err != nil {
+ return err
+ }
+ }
+ if *doDiff {
+ newName := filepath.ToSlash(filename)
+ oldName := newName + ".orig"
+ r.Write(diff.Diff(oldName, src, newName, res))
+ return errFormattingDiffers
+ }
+ }
+
+ if !*list && !*write && !*doDiff {
+ _, err = r.Write(res)
+ }
+
+ return err
+}
+
+// readFile reads the contents of filename, described by info.
+// If in is non-nil, readFile reads directly from it.
+// Otherwise, readFile opens and reads the file itself,
+// with the number of concurrently-open files limited by fdSem.
+func readFile(filename string, info fs.FileInfo, in io.Reader) ([]byte, error) {
+ if in == nil {
+ fdSem <- true
+ var err error
+ f, err := os.Open(filename)
+ if err != nil {
+ return nil, err
+ }
+ in = f
+ defer func() {
+ f.Close()
+ <-fdSem
+ }()
+ }
+
+ // Compute the file's size and read its contents with minimal allocations.
+ //
+ // If we have the FileInfo from filepath.WalkDir, use it to make
+ // a buffer of the right size and avoid ReadAll's reallocations.
+ //
+ // If the size is unknown (or bogus, or overflows an int), fall back to
+ // a size-independent ReadAll.
+ size := -1
+ if info != nil && info.Mode().IsRegular() && int64(int(info.Size())) == info.Size() {
+ size = int(info.Size())
+ }
+ if size+1 <= 0 {
+ // The file is not known to be regular, so we don't have a reliable size for it.
+ var err error
+ src, err := io.ReadAll(in)
+ if err != nil {
+ return nil, err
+ }
+ return src, nil
+ }
+
+ // We try to read size+1 bytes so that we can detect modifications: if we
+ // read more than size bytes, then the file was modified concurrently.
+ // (If that happens, we could, say, append to src to finish the read, or
+ // proceed with a truncated buffer — but the fact that it changed at all
+ // indicates a possible race with someone editing the file, so we prefer to
+ // stop to avoid corrupting it.)
+ src := make([]byte, size+1)
+ n, err := io.ReadFull(in, src)
+ switch err {
+ case nil, io.EOF, io.ErrUnexpectedEOF:
+ // io.ReadFull returns io.EOF (for an empty file) or io.ErrUnexpectedEOF
+ // (for a non-empty file) if the file was changed unexpectedly. Continue
+ // with comparing file sizes in those cases.
+ default:
+ return nil, err
+ }
+ if n < size {
+ return nil, fmt.Errorf("error: size of %s changed during reading (from %d to %d bytes)", filename, size, n)
+ } else if n > size {
+ return nil, fmt.Errorf("error: size of %s changed during reading (from %d to >=%d bytes)", filename, size, len(src))
+ }
+ return src[:n], nil
+}
+
+func main() {
+ // Arbitrarily limit in-flight work to 2MiB times the number of threads.
+ //
+ // The actual overhead for the parse tree and output will depend on the
+ // specifics of the file, but this at least keeps the footprint of the process
+ // roughly proportional to GOMAXPROCS.
+ maxWeight := (2 << 20) * int64(runtime.GOMAXPROCS(0))
+ s := newSequencer(maxWeight, os.Stdout, os.Stderr)
+
+ // call gofmtMain in a separate function
+ // so that it can use defer and have them
+ // run before the exit.
+ gofmtMain(s)
+ os.Exit(s.GetExitCode())
+}
+
+func gofmtMain(s *sequencer) {
+ flag.Usage = usage
+ flag.Parse()
+
+ if *cpuprofile != "" {
+ fdSem <- true
+ f, err := os.Create(*cpuprofile)
+ if err != nil {
+ s.AddReport(fmt.Errorf("creating cpu profile: %s", err))
+ return
+ }
+ defer func() {
+ f.Close()
+ <-fdSem
+ }()
+ pprof.StartCPUProfile(f)
+ defer pprof.StopCPUProfile()
+ }
+
+ initParserMode()
+ initRewrite()
+
+ args := flag.Args()
+ if len(args) == 0 {
+ if *write {
+ s.AddReport(fmt.Errorf("error: cannot use -w with standard input"))
+ return
+ }
+ s.Add(0, func(r *reporter) error {
+ return processFile("", nil, os.Stdin, r)
+ })
+ return
+ }
+
+ for _, arg := range args {
+ // Walk each given argument as a directory tree.
+ // If the argument is not a directory, it's always formatted as a Go file.
+ // If the argument is a directory, we walk it, ignoring non-Go files.
+ if err := filepath.WalkDir(arg, func(path string, d fs.DirEntry, err error) error {
+ switch {
+ case err != nil:
+ return err
+ case d.IsDir():
+ return nil // simply recurse into directories
+ case path == arg:
+ // non-directories given as explicit arguments are always formatted
+ case !isGoFilename(d.Name()):
+ return nil // skip walked non-Go files
+ }
+ info, err := d.Info()
+ if err != nil {
+ return err
+ }
+ s.Add(fileWeight(path, info), func(r *reporter) error {
+ return processFile(path, info, nil, r)
+ })
+ return nil
+ }); err != nil {
+ s.AddReport(err)
+ }
+ }
+}
+
+func fileWeight(path string, info fs.FileInfo) int64 {
+ if info == nil {
+ return exclusive
+ }
+ if info.Mode().Type() == fs.ModeSymlink {
+ var err error
+ info, err = os.Stat(path)
+ if err != nil {
+ return exclusive
+ }
+ }
+ if !info.Mode().IsRegular() {
+ // For non-regular files, FileInfo.Size is system-dependent and thus not a
+ // reliable indicator of weight.
+ return exclusive
+ }
+ return info.Size()
+}
+
+// writeFile updates a file with the new formatted data.
+func writeFile(filename string, orig, formatted []byte, perm fs.FileMode) error {
+ // Make a temporary backup file before rewriting the original file.
+ bakname, err := backupFile(filename, orig, perm)
+ if err != nil {
+ return err
+ }
+
+ fdSem <- true
+ defer func() { <-fdSem }()
+
+ fout, err := os.OpenFile(filename, os.O_WRONLY, perm)
+ if err != nil {
+ // We couldn't even open the file, so it should
+ // not have changed.
+ os.Remove(bakname)
+ return err
+ }
+ defer fout.Close() // for error paths
+
+ restoreFail := func(err error) {
+ fmt.Fprintf(os.Stderr, "gofmt: %s: error restoring file to original: %v; backup in %s\n", filename, err, bakname)
+ }
+
+ n, err := fout.Write(formatted)
+ if err == nil {
+ err = fout.Truncate(int64(n))
+ }
+
+ if err != nil {
+ // Rewriting the file failed.
+
+ if n == 0 {
+ // Original file unchanged.
+ os.Remove(bakname)
+ return err
+ }
+
+ // Try to restore the original contents.
+
+ no, erro := fout.WriteAt(orig, 0)
+ if erro != nil {
+ // That failed too.
+ restoreFail(erro)
+ return err
+ }
+
+ if no < n {
+ // Original file is shorter. Truncate.
+ if erro = fout.Truncate(int64(no)); erro != nil {
+ restoreFail(erro)
+ return err
+ }
+ }
+
+ if erro := fout.Close(); erro != nil {
+ restoreFail(erro)
+ return err
+ }
+
+ // Original contents restored.
+ os.Remove(bakname)
+ return err
+ }
+
+ if err := fout.Close(); err != nil {
+ restoreFail(err)
+ return err
+ }
+
+ // File updated.
+ os.Remove(bakname)
+ return nil
+}
+
+// backupFile writes data to a new file named filename with permissions perm,
+// with randomly chosen such that the file name is unique. backupFile returns
+// the chosen file name.
+func backupFile(filename string, data []byte, perm fs.FileMode) (string, error) {
+ fdSem <- true
+ defer func() { <-fdSem }()
+
+ nextRandom := func() string {
+ return strconv.Itoa(rand.Int())
+ }
+
+ dir, base := filepath.Split(filename)
+ var (
+ bakname string
+ f *os.File
+ )
+ for {
+ bakname = filepath.Join(dir, base+"."+nextRandom())
+ var err error
+ f, err = os.OpenFile(bakname, os.O_RDWR|os.O_CREATE|os.O_EXCL, perm)
+ if err == nil {
+ break
+ }
+ if !os.IsExist(err) {
+ return "", err
+ }
+ }
+
+ // write data to backup file
+ _, err := f.Write(data)
+ if err1 := f.Close(); err == nil {
+ err = err1
+ }
+
+ return bakname, err
+}
diff --git a/vendor/github.com/golangci/gofmt/internal/golangci.go b/vendor/github.com/golangci/gofmt/internal/golangci.go
new file mode 100644
index 0000000000..b05e5aaf08
--- /dev/null
+++ b/vendor/github.com/golangci/gofmt/internal/golangci.go
@@ -0,0 +1,51 @@
+package internal
+
+import (
+ "go/ast"
+ "go/parser"
+ "go/printer"
+ "go/token"
+)
+
+/*
+ The goal of this file is:
+ - to expose the unexported constants and the function.
+ - set the parserMode.
+*/
+
+const (
+ TabWidth = tabWidth
+ PrinterMode = printerMode
+)
+
+// https://github.com/golang/go/blob/1b291b70dff51732415da5b68debe323704d8e8d/src/cmd/gofmt/gofmt.go#L81-L91
+// https://github.com/golang/go/blob/1b291b70dff51732415da5b68debe323704d8e8d/src/go/format/format.go#L41
+const parserMode = parser.ParseComments | parser.SkipObjectResolution
+
+func Parse(fset *token.FileSet, filename string, src []byte, fragmentOk bool) (
+ file *ast.File,
+ sourceAdj func(src []byte, indent int) []byte,
+ indentAdj int,
+ err error,
+) {
+ return parse(fset, filename, src, fragmentOk)
+}
+
+func Format(
+ fset *token.FileSet,
+ file *ast.File,
+ sourceAdj func(src []byte, indent int) []byte,
+ indentAdj int,
+ src []byte,
+ cfg printer.Config,
+) ([]byte, error) {
+ return format(fset, file, sourceAdj, indentAdj, src, cfg)
+}
+
+func Simplify(f *ast.File) {
+ simplify(f)
+}
+
+func RewriteFile(fileSet *token.FileSet, pattern, replace ast.Expr, p *ast.File) *ast.File {
+ return rewriteFile(fileSet, pattern, replace, p)
+}
diff --git a/vendor/github.com/golangci/gofmt/gofmt/internal.go b/vendor/github.com/golangci/gofmt/internal/internal.go
similarity index 96%
rename from vendor/github.com/golangci/gofmt/gofmt/internal.go
rename to vendor/github.com/golangci/gofmt/internal/internal.go
index 231a250915..ef60a14324 100644
--- a/vendor/github.com/golangci/gofmt/gofmt/internal.go
+++ b/vendor/github.com/golangci/gofmt/internal/internal.go
@@ -7,7 +7,7 @@
// one without the other. Determine if we can factor out functionality
// in a public API. See also #11844 for context.
-package gofmt
+package internal
import (
"bytes"
@@ -26,13 +26,6 @@ func parse(fset *token.FileSet, filename string, src []byte, fragmentOk bool) (
indentAdj int,
err error,
) {
-
- // START - Change related to usage inside golangci-lint
- parserModeMu.Lock()
- parserMode := parserMode
- parserModeMu.Unlock()
- // END - Change related to usage inside golangci-lint
-
// Try as whole source file.
file, err = parser.ParseFile(fset, filename, src, parserMode)
// If there's no error, return. If the error is that the source file didn't begin with a
diff --git a/vendor/github.com/golangci/gofmt/internal/rewrite.go b/vendor/github.com/golangci/gofmt/internal/rewrite.go
new file mode 100644
index 0000000000..0a399986b6
--- /dev/null
+++ b/vendor/github.com/golangci/gofmt/internal/rewrite.go
@@ -0,0 +1,309 @@
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package internal
+
+import (
+ "fmt"
+ "go/ast"
+ "go/parser"
+ "go/token"
+ "os"
+ "reflect"
+ "strings"
+ "unicode"
+ "unicode/utf8"
+)
+
+func initRewrite() {
+ if *rewriteRule == "" {
+ rewrite = nil // disable any previous rewrite
+ return
+ }
+ f := strings.Split(*rewriteRule, "->")
+ if len(f) != 2 {
+ fmt.Fprintf(os.Stderr, "rewrite rule must be of the form 'pattern -> replacement'\n")
+ os.Exit(2)
+ }
+ pattern := parseExpr(f[0], "pattern")
+ replace := parseExpr(f[1], "replacement")
+ rewrite = func(fset *token.FileSet, p *ast.File) *ast.File {
+ return rewriteFile(fset, pattern, replace, p)
+ }
+}
+
+// parseExpr parses s as an expression.
+// It might make sense to expand this to allow statement patterns,
+// but there are problems with preserving formatting and also
+// with what a wildcard for a statement looks like.
+func parseExpr(s, what string) ast.Expr {
+ x, err := parser.ParseExpr(s)
+ if err != nil {
+ fmt.Fprintf(os.Stderr, "parsing %s %s at %s\n", what, s, err)
+ os.Exit(2)
+ }
+ return x
+}
+
+// Keep this function for debugging.
+/*
+func dump(msg string, val reflect.Value) {
+ fmt.Printf("%s:\n", msg)
+ ast.Print(fileSet, val.Interface())
+ fmt.Println()
+}
+*/
+
+// rewriteFile applies the rewrite rule 'pattern -> replace' to an entire file.
+func rewriteFile(fileSet *token.FileSet, pattern, replace ast.Expr, p *ast.File) *ast.File {
+ cmap := ast.NewCommentMap(fileSet, p, p.Comments)
+ m := make(map[string]reflect.Value)
+ pat := reflect.ValueOf(pattern)
+ repl := reflect.ValueOf(replace)
+
+ var rewriteVal func(val reflect.Value) reflect.Value
+ rewriteVal = func(val reflect.Value) reflect.Value {
+ // don't bother if val is invalid to start with
+ if !val.IsValid() {
+ return reflect.Value{}
+ }
+ val = apply(rewriteVal, val)
+ clear(m)
+ if match(m, pat, val) {
+ val = subst(m, repl, reflect.ValueOf(val.Interface().(ast.Node).Pos()))
+ }
+ return val
+ }
+
+ r := apply(rewriteVal, reflect.ValueOf(p)).Interface().(*ast.File)
+ r.Comments = cmap.Filter(r).Comments() // recreate comments list
+ return r
+}
+
+// set is a wrapper for x.Set(y); it protects the caller from panics if x cannot be changed to y.
+func set(x, y reflect.Value) {
+ // don't bother if x cannot be set or y is invalid
+ if !x.CanSet() || !y.IsValid() {
+ return
+ }
+ defer func() {
+ if x := recover(); x != nil {
+ if s, ok := x.(string); ok &&
+ (strings.Contains(s, "type mismatch") || strings.Contains(s, "not assignable")) {
+ // x cannot be set to y - ignore this rewrite
+ return
+ }
+ panic(x)
+ }
+ }()
+ x.Set(y)
+}
+
+// Values/types for special cases.
+var (
+ objectPtrNil = reflect.ValueOf((*ast.Object)(nil))
+ scopePtrNil = reflect.ValueOf((*ast.Scope)(nil))
+
+ identType = reflect.TypeFor[*ast.Ident]()
+ objectPtrType = reflect.TypeFor[*ast.Object]()
+ positionType = reflect.TypeFor[token.Pos]()
+ callExprType = reflect.TypeFor[*ast.CallExpr]()
+ scopePtrType = reflect.TypeFor[*ast.Scope]()
+)
+
+// apply replaces each AST field x in val with f(x), returning val.
+// To avoid extra conversions, f operates on the reflect.Value form.
+func apply(f func(reflect.Value) reflect.Value, val reflect.Value) reflect.Value {
+ if !val.IsValid() {
+ return reflect.Value{}
+ }
+
+ // *ast.Objects introduce cycles and are likely incorrect after
+ // rewrite; don't follow them but replace with nil instead
+ if val.Type() == objectPtrType {
+ return objectPtrNil
+ }
+
+ // similarly for scopes: they are likely incorrect after a rewrite;
+ // replace them with nil
+ if val.Type() == scopePtrType {
+ return scopePtrNil
+ }
+
+ switch v := reflect.Indirect(val); v.Kind() {
+ case reflect.Slice:
+ for i := 0; i < v.Len(); i++ {
+ e := v.Index(i)
+ set(e, f(e))
+ }
+ case reflect.Struct:
+ for i := 0; i < v.NumField(); i++ {
+ e := v.Field(i)
+ set(e, f(e))
+ }
+ case reflect.Interface:
+ e := v.Elem()
+ set(v, f(e))
+ }
+ return val
+}
+
+func isWildcard(s string) bool {
+ rune, size := utf8.DecodeRuneInString(s)
+ return size == len(s) && unicode.IsLower(rune)
+}
+
+// match reports whether pattern matches val,
+// recording wildcard submatches in m.
+// If m == nil, match checks whether pattern == val.
+func match(m map[string]reflect.Value, pattern, val reflect.Value) bool {
+ // Wildcard matches any expression. If it appears multiple
+ // times in the pattern, it must match the same expression
+ // each time.
+ if m != nil && pattern.IsValid() && pattern.Type() == identType {
+ name := pattern.Interface().(*ast.Ident).Name
+ if isWildcard(name) && val.IsValid() {
+ // wildcards only match valid (non-nil) expressions.
+ if _, ok := val.Interface().(ast.Expr); ok && !val.IsNil() {
+ if old, ok := m[name]; ok {
+ return match(nil, old, val)
+ }
+ m[name] = val
+ return true
+ }
+ }
+ }
+
+ // Otherwise, pattern and val must match recursively.
+ if !pattern.IsValid() || !val.IsValid() {
+ return !pattern.IsValid() && !val.IsValid()
+ }
+ if pattern.Type() != val.Type() {
+ return false
+ }
+
+ // Special cases.
+ switch pattern.Type() {
+ case identType:
+ // For identifiers, only the names need to match
+ // (and none of the other *ast.Object information).
+ // This is a common case, handle it all here instead
+ // of recursing down any further via reflection.
+ p := pattern.Interface().(*ast.Ident)
+ v := val.Interface().(*ast.Ident)
+ return p == nil && v == nil || p != nil && v != nil && p.Name == v.Name
+ case objectPtrType, positionType:
+ // object pointers and token positions always match
+ return true
+ case callExprType:
+ // For calls, the Ellipsis fields (token.Pos) must
+ // match since that is how f(x) and f(x...) are different.
+ // Check them here but fall through for the remaining fields.
+ p := pattern.Interface().(*ast.CallExpr)
+ v := val.Interface().(*ast.CallExpr)
+ if p.Ellipsis.IsValid() != v.Ellipsis.IsValid() {
+ return false
+ }
+ }
+
+ p := reflect.Indirect(pattern)
+ v := reflect.Indirect(val)
+ if !p.IsValid() || !v.IsValid() {
+ return !p.IsValid() && !v.IsValid()
+ }
+
+ switch p.Kind() {
+ case reflect.Slice:
+ if p.Len() != v.Len() {
+ return false
+ }
+ for i := 0; i < p.Len(); i++ {
+ if !match(m, p.Index(i), v.Index(i)) {
+ return false
+ }
+ }
+ return true
+
+ case reflect.Struct:
+ for i := 0; i < p.NumField(); i++ {
+ if !match(m, p.Field(i), v.Field(i)) {
+ return false
+ }
+ }
+ return true
+
+ case reflect.Interface:
+ return match(m, p.Elem(), v.Elem())
+ }
+
+ // Handle token integers, etc.
+ return p.Interface() == v.Interface()
+}
+
+// subst returns a copy of pattern with values from m substituted in place
+// of wildcards and pos used as the position of tokens from the pattern.
+// if m == nil, subst returns a copy of pattern and doesn't change the line
+// number information.
+func subst(m map[string]reflect.Value, pattern reflect.Value, pos reflect.Value) reflect.Value {
+ if !pattern.IsValid() {
+ return reflect.Value{}
+ }
+
+ // Wildcard gets replaced with map value.
+ if m != nil && pattern.Type() == identType {
+ name := pattern.Interface().(*ast.Ident).Name
+ if isWildcard(name) {
+ if old, ok := m[name]; ok {
+ return subst(nil, old, reflect.Value{})
+ }
+ }
+ }
+
+ if pos.IsValid() && pattern.Type() == positionType {
+ // use new position only if old position was valid in the first place
+ if old := pattern.Interface().(token.Pos); !old.IsValid() {
+ return pattern
+ }
+ return pos
+ }
+
+ // Otherwise copy.
+ switch p := pattern; p.Kind() {
+ case reflect.Slice:
+ if p.IsNil() {
+ // Do not turn nil slices into empty slices. go/ast
+ // guarantees that certain lists will be nil if not
+ // populated.
+ return reflect.Zero(p.Type())
+ }
+ v := reflect.MakeSlice(p.Type(), p.Len(), p.Len())
+ for i := 0; i < p.Len(); i++ {
+ v.Index(i).Set(subst(m, p.Index(i), pos))
+ }
+ return v
+
+ case reflect.Struct:
+ v := reflect.New(p.Type()).Elem()
+ for i := 0; i < p.NumField(); i++ {
+ v.Field(i).Set(subst(m, p.Field(i), pos))
+ }
+ return v
+
+ case reflect.Pointer:
+ v := reflect.New(p.Type()).Elem()
+ if elem := p.Elem(); elem.IsValid() {
+ v.Set(subst(m, elem, pos).Addr())
+ }
+ return v
+
+ case reflect.Interface:
+ v := reflect.New(p.Type()).Elem()
+ if elem := p.Elem(); elem.IsValid() {
+ v.Set(subst(m, elem, pos))
+ }
+ return v
+ }
+
+ return pattern
+}
diff --git a/vendor/github.com/golangci/gofmt/gofmt/simplify.go b/vendor/github.com/golangci/gofmt/internal/simplify.go
similarity index 99%
rename from vendor/github.com/golangci/gofmt/gofmt/simplify.go
rename to vendor/github.com/golangci/gofmt/internal/simplify.go
index 3b34d562ba..d57e8cef06 100644
--- a/vendor/github.com/golangci/gofmt/gofmt/simplify.go
+++ b/vendor/github.com/golangci/gofmt/internal/simplify.go
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-package gofmt
+package internal
import (
"go/ast"
diff --git a/vendor/github.com/golangci/gofmt/readme.md b/vendor/github.com/golangci/gofmt/readme.md
new file mode 100644
index 0000000000..6e1b0036da
--- /dev/null
+++ b/vendor/github.com/golangci/gofmt/readme.md
@@ -0,0 +1,46 @@
+# Hard Fork of gofmt
+
+## Updates
+
+- 2026-08-20: Sync with go1.27.0
+- 2025-12-14: Sync with go1.26.0-pre-rc1
+ - except (because it uses go1.26 specific elements):
+ - `internal/testenv/testenv_unix.go`
+ - `internal/platform/zosarch.go`
+- 2025-07-04: Sync with go1.24.4
+- 2025-04-14: Sync with go1.23.8
+- 2024-08-17: Sync with go1.22.6
+- 2023-02-28: Sync with go1.21.7
+- 2023-10-04: Sync with go1.20.8
+- 2023-10-04: Sync with go1.19.13
+- 2022-08-31: Sync with go1.18.5
+
+## Notes
+
+### Packages
+
+- https://github.com/golang/go/blob/master/src/cmd/gofmt/
+- https://github.com/golang/go/blob/master/src/internal/cfg
+- https://github.com/golang/go/blob/master/src/internal/goarch
+- https://github.com/golang/go/blob/master/src/internal/testenv
+- https://github.com/golang/go/blob/master/src/internal/platform
+- https://github.com/golang/go/blob/master/src/internal/diff -> replaced by `github.com/rogpeppe/go-internal/diff`
+
+### Details
+
+`go/src/cmd/gofmt/internal.go` and `go/src/go/format/internal.go` are identical.
+The `parserMode` is a global variable for `gofmt` and a constant for `go/format`.
+
+The constants (`tabWidth`, `printerMode`, `printerNormalizeNumbers`) are duplicated inside:
+- [`go/src/cmd/gofmt/gofmt.go`](https://github.com/golang/go/blob/1b291b70dff51732415da5b68debe323704d8e8d/src/cmd/gofmt/gofmt.go#L49-L59)
+- [`go/src/go/format/format.go`](https://github.com/golang/go/blob/1b291b70dff51732415da5b68debe323704d8e8d/src/go/format/format.go#L27-L37)
+
+Theoretically, only the following files are required:
+- `gofmt.go` (only the constants (`tabWidth`, `printerMode`, `printerNormalizeNumbers`))
+- `internal.go`
+- `LICENSE`
+- `rewrite.go`
+- `simplify.go`
+
+But it's easier to synchronize everything to follow changes.
+But the isolation of `internal` packages from Go can be complex, so maybe, at some point, we will reduce the number of files and so remove the `internal/internal` directory (and the test files).
diff --git a/vendor/github.com/golangci/golangci-lint/cmd/golangci-lint/main.go b/vendor/github.com/golangci/golangci-lint/cmd/golangci-lint/main.go
deleted file mode 100644
index bf235bf17f..0000000000
--- a/vendor/github.com/golangci/golangci-lint/cmd/golangci-lint/main.go
+++ /dev/null
@@ -1,74 +0,0 @@
-package main
-
-import (
- "cmp"
- "fmt"
- "os"
- "runtime/debug"
-
- "github.com/golangci/golangci-lint/pkg/commands"
- "github.com/golangci/golangci-lint/pkg/exitcodes"
-)
-
-var (
- goVersion = "unknown"
-
- // Populated by goreleaser during build
- version = "unknown"
- commit = "?"
- date = ""
-)
-
-func main() {
- info := createBuildInfo()
-
- if err := commands.Execute(info); err != nil {
- _, _ = fmt.Fprintf(os.Stderr, "Failed executing command with error: %v\n", err)
- os.Exit(exitcodes.Failure)
- }
-}
-
-func createBuildInfo() commands.BuildInfo {
- info := commands.BuildInfo{
- Commit: commit,
- Version: version,
- GoVersion: goVersion,
- Date: date,
- }
-
- buildInfo, available := debug.ReadBuildInfo()
- if !available {
- return info
- }
-
- info.GoVersion = buildInfo.GoVersion
-
- if date != "" {
- return info
- }
-
- info.Version = buildInfo.Main.Version
-
- var revision string
- var modified string
- for _, setting := range buildInfo.Settings {
- // The `vcs.xxx` information is only available with `go build`.
- // This information is not available with `go install` or `go run`.
- switch setting.Key {
- case "vcs.time":
- info.Date = setting.Value
- case "vcs.revision":
- revision = setting.Value
- case "vcs.modified":
- modified = setting.Value
- }
- }
-
- revision = cmp.Or(revision, "unknown")
- modified = cmp.Or(modified, "?")
- info.Date = cmp.Or(info.Date, "(unknown)")
-
- info.Commit = fmt.Sprintf("(%s, modified: %s, mod sum: %q)", revision, modified, buildInfo.Main.Sum)
-
- return info
-}
diff --git a/vendor/github.com/golangci/golangci-lint/internal/cache/cache.go b/vendor/github.com/golangci/golangci-lint/internal/cache/cache.go
deleted file mode 100644
index 41eb5c82be..0000000000
--- a/vendor/github.com/golangci/golangci-lint/internal/cache/cache.go
+++ /dev/null
@@ -1,296 +0,0 @@
-package cache
-
-import (
- "bytes"
- "encoding/gob"
- "encoding/hex"
- "errors"
- "fmt"
- "maps"
- "runtime"
- "slices"
- "strings"
- "sync"
-
- "golang.org/x/tools/go/packages"
-
- "github.com/golangci/golangci-lint/internal/go/cache"
- "github.com/golangci/golangci-lint/pkg/logutils"
- "github.com/golangci/golangci-lint/pkg/timeutils"
-)
-
-type HashMode int
-
-const (
- HashModeNeedOnlySelf HashMode = iota
- HashModeNeedDirectDeps
- HashModeNeedAllDeps
-)
-
-var ErrMissing = errors.New("missing data")
-
-type hashResults map[HashMode]string
-
-// Cache is a per-package data cache.
-// A cached data is invalidated when package,
-// or it's dependencies change.
-type Cache struct {
- lowLevelCache cache.Cache
- pkgHashes sync.Map
- sw *timeutils.Stopwatch
- log logutils.Log
- ioSem chan struct{} // semaphore limiting parallel IO
-}
-
-func NewCache(sw *timeutils.Stopwatch, log logutils.Log) (*Cache, error) {
- return &Cache{
- lowLevelCache: cache.Default(),
- sw: sw,
- log: log,
- ioSem: make(chan struct{}, runtime.GOMAXPROCS(-1)),
- }, nil
-}
-
-func (c *Cache) Close() {
- err := c.sw.TrackStageErr("close", c.lowLevelCache.Close)
- if err != nil {
- c.log.Errorf("cache close: %v", err)
- }
-}
-
-func (c *Cache) Put(pkg *packages.Package, mode HashMode, key string, data any) error {
- buf, err := c.encode(data)
- if err != nil {
- return err
- }
-
- actionID, err := c.buildKey(pkg, mode, key)
- if err != nil {
- return fmt.Errorf("failed to calculate package %s action id: %w", pkg.Name, err)
- }
-
- err = c.putBytes(actionID, buf)
- if err != nil {
- return fmt.Errorf("failed to save data to low-level cache by key %s for package %s: %w", key, pkg.Name, err)
- }
-
- return nil
-}
-
-func (c *Cache) Get(pkg *packages.Package, mode HashMode, key string, data any) error {
- actionID, err := c.buildKey(pkg, mode, key)
- if err != nil {
- return fmt.Errorf("failed to calculate package %s action id: %w", pkg.Name, err)
- }
-
- cachedData, err := c.getBytes(actionID)
- if err != nil {
- if cache.IsErrMissing(err) {
- return ErrMissing
- }
- return fmt.Errorf("failed to get data from low-level cache by key %s for package %s: %w", key, pkg.Name, err)
- }
-
- return c.decode(cachedData, data)
-}
-
-func (c *Cache) buildKey(pkg *packages.Package, mode HashMode, key string) (cache.ActionID, error) {
- return timeutils.TrackStage(c.sw, "key build", func() (cache.ActionID, error) {
- actionID, err := c.pkgActionID(pkg, mode)
- if err != nil {
- return actionID, err
- }
-
- subkey, subkeyErr := cache.Subkey(actionID, key)
- if subkeyErr != nil {
- return actionID, fmt.Errorf("failed to build subkey: %w", subkeyErr)
- }
-
- return subkey, nil
- })
-}
-
-func (c *Cache) pkgActionID(pkg *packages.Package, mode HashMode) (cache.ActionID, error) {
- hash, err := c.packageHash(pkg, mode)
- if err != nil {
- return cache.ActionID{}, fmt.Errorf("failed to get package hash: %w", err)
- }
-
- key, err := cache.NewHash("action ID")
- if err != nil {
- return cache.ActionID{}, fmt.Errorf("failed to make a hash: %w", err)
- }
-
- fmt.Fprintf(key, "pkgpath %s\n", pkg.PkgPath)
- fmt.Fprintf(key, "pkghash %s\n", hash)
-
- return key.Sum(), nil
-}
-
-func (c *Cache) packageHash(pkg *packages.Package, mode HashMode) (string, error) {
- results, found := c.pkgHashes.Load(pkg)
- if found {
- hashRes := results.(hashResults)
- if result, ok := hashRes[mode]; ok {
- return result, nil
- }
-
- return "", fmt.Errorf("no mode %d in hash result", mode)
- }
-
- hashRes, err := c.computePkgHash(pkg)
- if err != nil {
- return "", err
- }
-
- result, found := hashRes[mode]
- if !found {
- return "", fmt.Errorf("invalid mode %d", mode)
- }
-
- c.pkgHashes.Store(pkg, hashRes)
-
- return result, nil
-}
-
-// computePkgHash computes a package's hash.
-// The hash is based on all Go files that make up the package,
-// as well as the hashes of imported packages.
-func (c *Cache) computePkgHash(pkg *packages.Package) (hashResults, error) {
- key, err := cache.NewHash("package hash")
- if err != nil {
- return nil, fmt.Errorf("failed to make a hash: %w", err)
- }
-
- hashRes := hashResults{}
-
- fmt.Fprintf(key, "pkgpath %s\n", pkg.PkgPath)
-
- for _, f := range pkg.CompiledGoFiles {
- h, fErr := c.fileHash(f)
- if fErr != nil {
- return nil, fmt.Errorf("failed to calculate file %s hash: %w", f, fErr)
- }
-
- fmt.Fprintf(key, "file %s %x\n", f, h)
- }
-
- curSum := key.Sum()
- hashRes[HashModeNeedOnlySelf] = hex.EncodeToString(curSum[:])
-
- imps := slices.SortedFunc(maps.Values(pkg.Imports), func(a, b *packages.Package) int {
- return strings.Compare(a.PkgPath, b.PkgPath)
- })
-
- if err := c.computeDepsHash(HashModeNeedOnlySelf, imps, key); err != nil {
- return nil, err
- }
-
- curSum = key.Sum()
- hashRes[HashModeNeedDirectDeps] = hex.EncodeToString(curSum[:])
-
- if err := c.computeDepsHash(HashModeNeedAllDeps, imps, key); err != nil {
- return nil, err
- }
-
- curSum = key.Sum()
- hashRes[HashModeNeedAllDeps] = hex.EncodeToString(curSum[:])
-
- return hashRes, nil
-}
-
-func (c *Cache) computeDepsHash(depMode HashMode, imps []*packages.Package, key *cache.Hash) error {
- for _, dep := range imps {
- if dep.PkgPath == "unsafe" {
- continue
- }
-
- depHash, err := c.packageHash(dep, depMode)
- if err != nil {
- return fmt.Errorf("failed to calculate hash for dependency %s with mode %d: %w", dep.Name, depMode, err)
- }
-
- fmt.Fprintf(key, "import %s %s\n", dep.PkgPath, depHash)
- }
-
- return nil
-}
-
-func (c *Cache) putBytes(actionID cache.ActionID, buf *bytes.Buffer) error {
- c.ioSem <- struct{}{}
-
- err := c.sw.TrackStageErr("cache io", func() error {
- return cache.PutBytes(c.lowLevelCache, actionID, buf.Bytes())
- })
-
- <-c.ioSem
-
- if err != nil {
- return err
- }
-
- return nil
-}
-
-func (c *Cache) getBytes(actionID cache.ActionID) ([]byte, error) {
- c.ioSem <- struct{}{}
-
- cachedData, err := timeutils.TrackStage(c.sw, "cache io", func() ([]byte, error) {
- b, _, errGB := cache.GetBytes(c.lowLevelCache, actionID)
- return b, errGB
- })
-
- <-c.ioSem
-
- if err != nil {
- return nil, err
- }
-
- return cachedData, nil
-}
-
-func (c *Cache) fileHash(f string) ([cache.HashSize]byte, error) {
- c.ioSem <- struct{}{}
-
- h, err := cache.FileHash(f)
-
- <-c.ioSem
-
- if err != nil {
- return [cache.HashSize]byte{}, err
- }
-
- return h, nil
-}
-
-func (c *Cache) encode(data any) (*bytes.Buffer, error) {
- buf := &bytes.Buffer{}
- err := c.sw.TrackStageErr("gob", func() error {
- return gob.NewEncoder(buf).Encode(data)
- })
- if err != nil {
- return nil, fmt.Errorf("failed to gob encode: %w", err)
- }
-
- return buf, nil
-}
-
-func (c *Cache) decode(b []byte, data any) error {
- err := c.sw.TrackStageErr("gob", func() error {
- return gob.NewDecoder(bytes.NewReader(b)).Decode(data)
- })
- if err != nil {
- return fmt.Errorf("failed to gob decode: %w", err)
- }
-
- return nil
-}
-
-func SetSalt(b *bytes.Buffer) {
- cache.SetSalt(b.Bytes())
-}
-
-func DefaultDir() string {
- cacheDir, _ := cache.DefaultDir()
- return cacheDir
-}
diff --git a/vendor/github.com/golangci/golangci-lint/internal/errorutil/errors.go b/vendor/github.com/golangci/golangci-lint/internal/errorutil/errors.go
deleted file mode 100644
index c8a3a0357e..0000000000
--- a/vendor/github.com/golangci/golangci-lint/internal/errorutil/errors.go
+++ /dev/null
@@ -1,23 +0,0 @@
-package errorutil
-
-import (
- "fmt"
-)
-
-// PanicError can be used to not print stacktrace twice
-type PanicError struct {
- recovered any
- stack []byte
-}
-
-func NewPanicError(recovered any, stack []byte) *PanicError {
- return &PanicError{recovered: recovered, stack: stack}
-}
-
-func (e PanicError) Error() string {
- return fmt.Sprint(e.recovered)
-}
-
-func (e PanicError) Stack() []byte {
- return e.stack
-}
diff --git a/vendor/github.com/golangci/golangci-lint/internal/go/cache/cache.go b/vendor/github.com/golangci/golangci-lint/internal/go/cache/cache.go
deleted file mode 100644
index 85899ebc92..0000000000
--- a/vendor/github.com/golangci/golangci-lint/internal/go/cache/cache.go
+++ /dev/null
@@ -1,663 +0,0 @@
-// Copyright 2017 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// Package cache implements a build artifact cache.
-//
-// This package is a slightly modified fork of Go's
-// cmd/go/internal/cache package.
-package cache
-
-import (
- "bytes"
- "crypto/sha256"
- "encoding/hex"
- "errors"
- "fmt"
- "io"
- "io/fs"
- "os"
- "path/filepath"
- "strconv"
- "strings"
- "time"
-
- "github.com/golangci/golangci-lint/internal/go/mmap"
- "github.com/golangci/golangci-lint/internal/go/robustio"
- "github.com/rogpeppe/go-internal/lockedfile"
-)
-
-// An ActionID is a cache action key, the hash of a complete description of a
-// repeatable computation (command line, environment variables,
-// input file contents, executable contents).
-type ActionID [HashSize]byte
-
-// An OutputID is a cache output key, the hash of an output of a computation.
-type OutputID [HashSize]byte
-
-// Cache is the interface as used by the cmd/go.
-type Cache interface {
- // Get returns the cache entry for the provided ActionID.
- // On miss, the error type should be of type *entryNotFoundError.
- //
- // After a success call to Get, OutputFile(Entry.OutputID) must
- // exist on disk for until Close is called (at the end of the process).
- Get(ActionID) (Entry, error)
-
- // Put adds an item to the cache.
- //
- // The seeker is only used to seek to the beginning. After a call to Put,
- // the seek position is not guaranteed to be in any particular state.
- //
- // As a special case, if the ReadSeeker is of type noVerifyReadSeeker,
- // the verification from GODEBUG=goverifycache=1 is skipped.
- //
- // After a success call to Get, OutputFile(Entry.OutputID) must
- // exist on disk for until Close is called (at the end of the process).
- Put(ActionID, io.ReadSeeker) (_ OutputID, size int64, _ error)
-
- // Close is called at the end of the go process. Implementations can do
- // cache cleanup work at this phase, or wait for and report any errors from
- // background cleanup work started earlier. Any cache trimming should in one
- // process should not violate cause the invariants of this interface to be
- // violated in another process. Namely, a cache trim from one process should
- // not delete an ObjectID from disk that was recently Get or Put from
- // another process. As a rule of thumb, don't trim things used in the last
- // day.
- Close() error
-
- // OutputFile returns the path on disk where OutputID is stored.
- //
- // It's only called after a successful get or put call so it doesn't need
- // to return an error; it's assumed that if the previous get or put succeeded,
- // it's already on disk.
- OutputFile(OutputID) string
-
- // FuzzDir returns where fuzz files are stored.
- FuzzDir() string
-}
-
-// A Cache is a package cache, backed by a file system directory tree.
-type DiskCache struct {
- dir string
- now func() time.Time
-}
-
-// Open opens and returns the cache in the given directory.
-//
-// It is safe for multiple processes on a single machine to use the
-// same cache directory in a local file system simultaneously.
-// They will coordinate using operating system file locks and may
-// duplicate effort but will not corrupt the cache.
-//
-// However, it is NOT safe for multiple processes on different machines
-// to share a cache directory (for example, if the directory were stored
-// in a network file system). File locking is notoriously unreliable in
-// network file systems and may not suffice to protect the cache.
-func Open(dir string) (*DiskCache, error) {
- info, err := os.Stat(dir)
- if err != nil {
- return nil, err
- }
- if !info.IsDir() {
- return nil, &fs.PathError{Op: "open", Path: dir, Err: fmt.Errorf("not a directory")}
- }
- for i := 0; i < 256; i++ {
- name := filepath.Join(dir, fmt.Sprintf("%02x", i))
- if err := os.MkdirAll(name, 0744); err != nil {
- return nil, err
- }
- }
- c := &DiskCache{
- dir: dir,
- now: time.Now,
- }
- return c, nil
-}
-
-// fileName returns the name of the file corresponding to the given id.
-func (c *DiskCache) fileName(id [HashSize]byte, key string) string {
- return filepath.Join(c.dir, fmt.Sprintf("%02x", id[0]), fmt.Sprintf("%x", id)+"-"+key)
-}
-
-// An entryNotFoundError indicates that a cache entry was not found, with an
-// optional underlying reason.
-type entryNotFoundError struct {
- Err error
-}
-
-func (e *entryNotFoundError) Error() string {
- if e.Err == nil {
- return "cache entry not found"
- }
- return fmt.Sprintf("cache entry not found: %v", e.Err)
-}
-
-func (e *entryNotFoundError) Unwrap() error {
- return e.Err
-}
-
-const (
- // action entry file is "v1 \n"
- hexSize = HashSize * 2
- entrySize = 2 + 1 + hexSize + 1 + hexSize + 1 + 20 + 1 + 20 + 1
-)
-
-// verify controls whether to run the cache in verify mode.
-// In verify mode, the cache always returns errMissing from Get
-// but then double-checks in Put that the data being written
-// exactly matches any existing entry. This provides an easy
-// way to detect program behavior that would have been different
-// had the cache entry been returned from Get.
-//
-// verify is enabled by setting the environment variable
-// GODEBUG=gocacheverify=1.
-var verify = false
-
-var errVerifyMode = errors.New("gocacheverify=1")
-
-// DebugTest is set when GODEBUG=gocachetest=1 is in the environment.
-var DebugTest = false
-
-// func init() { initEnv() }
-
-// var (
-// gocacheverify = godebug.New("gocacheverify")
-// gocachehash = godebug.New("gocachehash")
-// gocachetest = godebug.New("gocachetest")
-// )
-
-// func initEnv() {
-// if gocacheverify.Value() == "1" {
-// gocacheverify.IncNonDefault()
-// verify = true
-// }
-// if gocachehash.Value() == "1" {
-// gocachehash.IncNonDefault()
-// debugHash = true
-// }
-// if gocachetest.Value() == "1" {
-// gocachetest.IncNonDefault()
-// DebugTest = true
-// }
-// }
-
-// Get looks up the action ID in the cache,
-// returning the corresponding output ID and file size, if any.
-// Note that finding an output ID does not guarantee that the
-// saved file for that output ID is still available.
-func (c *DiskCache) Get(id ActionID) (Entry, error) {
- if verify {
- return Entry{}, &entryNotFoundError{Err: errVerifyMode}
- }
- return c.get(id)
-}
-
-type Entry struct {
- OutputID OutputID
- Size int64
- Time time.Time // when added to cache
-}
-
-// get is Get but does not respect verify mode, so that Put can use it.
-func (c *DiskCache) get(id ActionID) (Entry, error) {
- missing := func(reason error) (Entry, error) {
- return Entry{}, &entryNotFoundError{Err: reason}
- }
- f, err := os.Open(c.fileName(id, "a"))
- if err != nil {
- return missing(err)
- }
- defer f.Close()
- entry := make([]byte, entrySize+1) // +1 to detect whether f is too long
- if n, err := io.ReadFull(f, entry); n > entrySize {
- return missing(errors.New("too long"))
- } else if err != io.ErrUnexpectedEOF {
- if err == io.EOF {
- return missing(errors.New("file is empty"))
- }
- return missing(err)
- } else if n < entrySize {
- return missing(errors.New("entry file incomplete"))
- }
- if entry[0] != 'v' || entry[1] != '1' || entry[2] != ' ' || entry[3+hexSize] != ' ' || entry[3+hexSize+1+hexSize] != ' ' || entry[3+hexSize+1+hexSize+1+20] != ' ' || entry[entrySize-1] != '\n' {
- return missing(errors.New("invalid header"))
- }
- eid, entry := entry[3:3+hexSize], entry[3+hexSize:]
- eout, entry := entry[1:1+hexSize], entry[1+hexSize:]
- esize, entry := entry[1:1+20], entry[1+20:]
- etime, entry := entry[1:1+20], entry[1+20:]
- var buf [HashSize]byte
- if _, err := hex.Decode(buf[:], eid); err != nil {
- return missing(fmt.Errorf("decoding ID: %v", err))
- } else if buf != id {
- return missing(errors.New("mismatched ID"))
- }
- if _, err := hex.Decode(buf[:], eout); err != nil {
- return missing(fmt.Errorf("decoding output ID: %v", err))
- }
- i := 0
- for i < len(esize) && esize[i] == ' ' {
- i++
- }
- size, err := strconv.ParseInt(string(esize[i:]), 10, 64)
- if err != nil {
- return missing(fmt.Errorf("parsing size: %v", err))
- } else if size < 0 {
- return missing(errors.New("negative size"))
- }
- i = 0
- for i < len(etime) && etime[i] == ' ' {
- i++
- }
- tm, err := strconv.ParseInt(string(etime[i:]), 10, 64)
- if err != nil {
- return missing(fmt.Errorf("parsing timestamp: %v", err))
- } else if tm < 0 {
- return missing(errors.New("negative timestamp"))
- }
-
- err = c.used(c.fileName(id, "a"))
- if err != nil {
- return Entry{}, fmt.Errorf("failed to mark %s as used: %w", c.fileName(id, "a"), err)
- }
-
- return Entry{buf, size, time.Unix(0, tm)}, nil
-}
-
-// GetFile looks up the action ID in the cache and returns
-// the name of the corresponding data file.
-func GetFile(c Cache, id ActionID) (file string, entry Entry, err error) {
- entry, err = c.Get(id)
- if err != nil {
- return "", Entry{}, err
- }
- file = c.OutputFile(entry.OutputID)
- info, err := os.Stat(file)
- if err != nil {
- return "", Entry{}, &entryNotFoundError{Err: err}
- }
- if info.Size() != entry.Size {
- return "", Entry{}, &entryNotFoundError{Err: errors.New("file incomplete")}
- }
- return file, entry, nil
-}
-
-// GetBytes looks up the action ID in the cache and returns
-// the corresponding output bytes.
-// GetBytes should only be used for data that can be expected to fit in memory.
-func GetBytes(c Cache, id ActionID) ([]byte, Entry, error) {
- entry, err := c.Get(id)
- if err != nil {
- return nil, entry, err
- }
- data, err := robustio.ReadFile(c.OutputFile(entry.OutputID))
- if err != nil {
- return nil, entry, &entryNotFoundError{Err: err}
- }
- if sha256.Sum256(data) != entry.OutputID {
- return nil, entry, &entryNotFoundError{Err: errors.New("bad checksum")}
- }
- return data, entry, nil
-}
-
-// GetMmap looks up the action ID in the cache and returns
-// the corresponding output bytes.
-// GetMmap should only be used for data that can be expected to fit in memory.
-func GetMmap(c Cache, id ActionID) ([]byte, Entry, error) {
- entry, err := c.Get(id)
- if err != nil {
- return nil, entry, err
- }
- md, err := mmap.Mmap(c.OutputFile(entry.OutputID))
- if err != nil {
- return nil, Entry{}, err
- }
- if int64(len(md.Data)) != entry.Size {
- return nil, Entry{}, &entryNotFoundError{Err: errors.New("file incomplete")}
- }
- return md.Data, entry, nil
-}
-
-// OutputFile returns the name of the cache file storing output with the given OutputID.
-func (c *DiskCache) OutputFile(out OutputID) string {
- file := c.fileName(out, "d")
- c.used(file)
- return file
-}
-
-// Time constants for cache expiration.
-//
-// We set the mtime on a cache file on each use, but at most one per mtimeInterval (1 hour),
-// to avoid causing many unnecessary inode updates. The mtimes therefore
-// roughly reflect "time of last use" but may in fact be older by at most an hour.
-//
-// We scan the cache for entries to delete at most once per trimInterval (1 day).
-//
-// When we do scan the cache, we delete entries that have not been used for
-// at least trimLimit (5 days). Statistics gathered from a month of usage by
-// Go developers found that essentially all reuse of cached entries happened
-// within 5 days of the previous reuse. See golang.org/issue/22990.
-const (
- mtimeInterval = 1 * time.Hour
- trimInterval = 24 * time.Hour
- trimLimit = 5 * 24 * time.Hour
-)
-
-// used makes a best-effort attempt to update mtime on file,
-// so that mtime reflects cache access time.
-//
-// Because the reflection only needs to be approximate,
-// and to reduce the amount of disk activity caused by using
-// cache entries, used only updates the mtime if the current
-// mtime is more than an hour old. This heuristic eliminates
-// nearly all of the mtime updates that would otherwise happen,
-// while still keeping the mtimes useful for cache trimming.
-func (c *DiskCache) used(file string) error {
- info, err := os.Stat(file)
- if err == nil && c.now().Sub(info.ModTime()) < mtimeInterval {
- return nil
- }
-
- if err != nil {
- if os.IsNotExist(err) {
- return &entryNotFoundError{Err: err}
- }
- return &entryNotFoundError{Err: fmt.Errorf("failed to stat file %s: %w", file, err)}
- }
-
- err = os.Chtimes(file, c.now(), c.now())
- if err != nil {
- return fmt.Errorf("failed to change time of file %s: %w", file, err)
- }
-
- return nil
-}
-
-func (c *DiskCache) Close() error { return c.Trim() }
-
-// Trim removes old cache entries that are likely not to be reused.
-func (c *DiskCache) Trim() error {
- now := c.now()
-
- // We maintain in dir/trim.txt the time of the last completed cache trim.
- // If the cache has been trimmed recently enough, do nothing.
- // This is the common case.
- // If the trim file is corrupt, detected if the file can't be parsed, or the
- // trim time is too far in the future, attempt the trim anyway. It's possible that
- // the cache was full when the corruption happened. Attempting a trim on
- // an empty cache is cheap, so there wouldn't be a big performance hit in that case.
- if data, err := lockedfile.Read(filepath.Join(c.dir, "trim.txt")); err == nil {
- if t, err := strconv.ParseInt(strings.TrimSpace(string(data)), 10, 64); err == nil {
- lastTrim := time.Unix(t, 0)
- if d := now.Sub(lastTrim); d < trimInterval && d > -mtimeInterval {
- return nil
- }
- }
- }
-
- // Trim each of the 256 subdirectories.
- // We subtract an additional mtimeInterval
- // to account for the imprecision of our "last used" mtimes.
- cutoff := now.Add(-trimLimit - mtimeInterval)
- for i := 0; i < 256; i++ {
- subdir := filepath.Join(c.dir, fmt.Sprintf("%02x", i))
- c.trimSubdir(subdir, cutoff)
- }
-
- // Ignore errors from here: if we don't write the complete timestamp, the
- // cache will appear older than it is, and we'll trim it again next time.
- var b bytes.Buffer
- fmt.Fprintf(&b, "%d", now.Unix())
- if err := lockedfile.Write(filepath.Join(c.dir, "trim.txt"), &b, 0666); err != nil {
- return err
- }
-
- return nil
-}
-
-// trimSubdir trims a single cache subdirectory.
-func (c *DiskCache) trimSubdir(subdir string, cutoff time.Time) {
- // Read all directory entries from subdir before removing
- // any files, in case removing files invalidates the file offset
- // in the directory scan. Also, ignore error from f.Readdirnames,
- // because we don't care about reporting the error and we still
- // want to process any entries found before the error.
- f, err := os.Open(subdir)
- if err != nil {
- return
- }
- names, _ := f.Readdirnames(-1)
- f.Close()
-
- for _, name := range names {
- // Remove only cache entries (xxxx-a and xxxx-d).
- if !strings.HasSuffix(name, "-a") && !strings.HasSuffix(name, "-d") {
- continue
- }
- entry := filepath.Join(subdir, name)
- info, err := os.Stat(entry)
- if err == nil && info.ModTime().Before(cutoff) {
- os.Remove(entry)
- }
- }
-}
-
-// putIndexEntry adds an entry to the cache recording that executing the action
-// with the given id produces an output with the given output id (hash) and size.
-func (c *DiskCache) putIndexEntry(id ActionID, out OutputID, size int64, allowVerify bool) error {
- // Note: We expect that for one reason or another it may happen
- // that repeating an action produces a different output hash
- // (for example, if the output contains a time stamp or temp dir name).
- // While not ideal, this is also not a correctness problem, so we
- // don't make a big deal about it. In particular, we leave the action
- // cache entries writable specifically so that they can be overwritten.
- //
- // Setting GODEBUG=gocacheverify=1 does make a big deal:
- // in verify mode we are double-checking that the cache entries
- // are entirely reproducible. As just noted, this may be unrealistic
- // in some cases but the check is also useful for shaking out real bugs.
- entry := fmt.Sprintf("v1 %x %x %20d %20d\n", id, out, size, time.Now().UnixNano())
- if verify && allowVerify {
- old, err := c.get(id)
- if err == nil && (old.OutputID != out || old.Size != size) {
- // panic to show stack trace, so we can see what code is generating this cache entry.
- msg := fmt.Sprintf("go: internal cache error: cache verify failed: id=%x changed:<<<\n%s\n>>>\nold: %x %d\nnew: %x %d", id, reverseHash(id), out, size, old.OutputID, old.Size)
- panic(msg)
- }
- }
- file := c.fileName(id, "a")
-
- // Copy file to cache directory.
- mode := os.O_WRONLY | os.O_CREATE
- f, err := os.OpenFile(file, mode, 0666)
- if err != nil {
- return err
- }
- _, err = f.WriteString(entry)
- if err == nil {
- // Truncate the file only *after* writing it.
- // (This should be a no-op, but truncate just in case of previous corruption.)
- //
- // This differs from os.WriteFile, which truncates to 0 *before* writing
- // via os.O_TRUNC. Truncating only after writing ensures that a second write
- // of the same content to the same file is idempotent, and does not — even
- // temporarily! — undo the effect of the first write.
- err = f.Truncate(int64(len(entry)))
- }
- if closeErr := f.Close(); err == nil {
- err = closeErr
- }
- if err != nil {
- // TODO(bcmills): This Remove potentially races with another go command writing to file.
- // Can we eliminate it?
- os.Remove(file)
- return err
- }
- err = os.Chtimes(file, c.now(), c.now()) // mainly for tests
- if err != nil {
- return fmt.Errorf("failed to change time of file %s: %w", file, err)
- }
-
- return nil
-}
-
-// noVerifyReadSeeker is an io.ReadSeeker wrapper sentinel type
-// that says that Cache.Put should skip the verify check
-// (from GODEBUG=goverifycache=1).
-type noVerifyReadSeeker struct {
- io.ReadSeeker
-}
-
-// Put stores the given output in the cache as the output for the action ID.
-// It may read file twice. The content of file must not change between the two passes.
-func (c *DiskCache) Put(id ActionID, file io.ReadSeeker) (OutputID, int64, error) {
- wrapper, isNoVerify := file.(noVerifyReadSeeker)
- if isNoVerify {
- file = wrapper.ReadSeeker
- }
- return c.put(id, file, !isNoVerify)
-}
-
-// PutNoVerify is like Put but disables the verify check
-// when GODEBUG=goverifycache=1 is set.
-// It is meant for data that is OK to cache but that we expect to vary slightly from run to run,
-// like test output containing times and the like.
-func PutNoVerify(c Cache, id ActionID, file io.ReadSeeker) (OutputID, int64, error) {
- return c.Put(id, noVerifyReadSeeker{file})
-}
-
-func (c *DiskCache) put(id ActionID, file io.ReadSeeker, allowVerify bool) (OutputID, int64, error) {
- // Compute output ID.
- h := sha256.New()
- if _, err := file.Seek(0, 0); err != nil {
- return OutputID{}, 0, err
- }
- size, err := io.Copy(h, file)
- if err != nil {
- return OutputID{}, 0, err
- }
- var out OutputID
- h.Sum(out[:0])
-
- // Copy to cached output file (if not already present).
- if err := c.copyFile(file, out, size); err != nil {
- return out, size, err
- }
-
- // Add to cache index.
- return out, size, c.putIndexEntry(id, out, size, allowVerify)
-}
-
-// PutBytes stores the given bytes in the cache as the output for the action ID.
-func PutBytes(c Cache, id ActionID, data []byte) error {
- _, _, err := c.Put(id, bytes.NewReader(data))
- return err
-}
-
-// copyFile copies file into the cache, expecting it to have the given
-// output ID and size, if that file is not present already.
-func (c *DiskCache) copyFile(file io.ReadSeeker, out OutputID, size int64) error {
- name := c.fileName(out, "d")
- info, err := os.Stat(name)
- if err == nil && info.Size() == size {
- // Check hash.
- if f, err := os.Open(name); err == nil {
- h := sha256.New()
- _, copyErr := io.Copy(h, f)
- if copyErr != nil {
- return fmt.Errorf("failed to copy to sha256: %w", copyErr)
- }
-
- f.Close()
- var out2 OutputID
- h.Sum(out2[:0])
- if out == out2 {
- return nil
- }
- }
- // Hash did not match. Fall through and rewrite file.
- }
-
- // Copy file to cache directory.
- mode := os.O_RDWR | os.O_CREATE
- if err == nil && info.Size() > size { // shouldn't happen but fix in case
- mode |= os.O_TRUNC
- }
- f, err := os.OpenFile(name, mode, 0666)
- if err != nil {
- return err
- }
- defer f.Close()
- if size == 0 {
- // File now exists with correct size.
- // Only one possible zero-length file, so contents are OK too.
- // Early return here makes sure there's a "last byte" for code below.
- return nil
- }
-
- // From here on, if any of the I/O writing the file fails,
- // we make a best-effort attempt to truncate the file f
- // before returning, to avoid leaving bad bytes in the file.
-
- // Copy file to f, but also into h to double-check hash.
- if _, err := file.Seek(0, 0); err != nil {
- f.Truncate(0)
- return err
- }
- h := sha256.New()
- w := io.MultiWriter(f, h)
- if _, err := io.CopyN(w, file, size-1); err != nil {
- f.Truncate(0)
- return err
- }
- // Check last byte before writing it; writing it will make the size match
- // what other processes expect to find and might cause them to start
- // using the file.
- buf := make([]byte, 1)
- if _, err := file.Read(buf); err != nil {
- f.Truncate(0)
- return err
- }
- n, wErr := h.Write(buf)
- if n != len(buf) {
- return fmt.Errorf("wrote to hash %d/%d bytes with error %w", n, len(buf), wErr)
- }
-
- sum := h.Sum(nil)
- if !bytes.Equal(sum, out[:]) {
- f.Truncate(0)
- return fmt.Errorf("file content changed underfoot")
- }
-
- // Commit cache file entry.
- if _, err := f.Write(buf); err != nil {
- f.Truncate(0)
- return err
- }
- if err := f.Close(); err != nil {
- // Data might not have been written,
- // but file may look like it is the right size.
- // To be extra careful, remove cached file.
- os.Remove(name)
- return err
- }
- err = os.Chtimes(name, c.now(), c.now()) // mainly for tests
- if err != nil {
- return fmt.Errorf("failed to change time of file %s: %w", name, err)
- }
-
- return nil
-}
-
-// FuzzDir returns a subdirectory within the cache for storing fuzzing data.
-// The subdirectory may not exist.
-//
-// This directory is managed by the internal/fuzz package. Files in this
-// directory aren't removed by the 'go clean -cache' command or by Trim.
-// They may be removed with 'go clean -fuzzcache'.
-//
-// TODO(#48526): make Trim remove unused files from this directory.
-func (c *DiskCache) FuzzDir() string {
- return filepath.Join(c.dir, "fuzz")
-}
diff --git a/vendor/github.com/golangci/golangci-lint/internal/go/cache/default.go b/vendor/github.com/golangci/golangci-lint/internal/go/cache/default.go
deleted file mode 100644
index 7232f1ef3e..0000000000
--- a/vendor/github.com/golangci/golangci-lint/internal/go/cache/default.go
+++ /dev/null
@@ -1,105 +0,0 @@
-// Copyright 2017 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package cache
-
-import (
- "fmt"
- base "log"
- "os"
- "path/filepath"
- "sync"
-)
-
-// Default returns the default cache to use.
-// It never returns nil.
-func Default() Cache {
- defaultOnce.Do(initDefaultCache)
- return defaultCache
-}
-
-var (
- defaultOnce sync.Once
- defaultCache Cache
-)
-
-// cacheREADME is a message stored in a README in the cache directory.
-// Because the cache lives outside the normal Go trees, we leave the
-// README as a courtesy to explain where it came from.
-const cacheREADME = `This directory holds cached build artifacts from golangci-lint.
-`
-
-// initDefaultCache does the work of finding the default cache
-// the first time Default is called.
-func initDefaultCache() {
- dir, _ := DefaultDir()
- if dir == "off" {
- if defaultDirErr != nil {
- base.Fatalf("build cache is required, but could not be located: %v", defaultDirErr)
- }
- base.Fatalf("build cache is disabled by %s=off, but required", envGolangciLintCache)
- }
- if err := os.MkdirAll(dir, 0744); err != nil {
- base.Fatalf("failed to initialize build cache at %s: %s\n", dir, err)
- }
- if _, err := os.Stat(filepath.Join(dir, "README")); err != nil {
- // Best effort.
- if wErr := os.WriteFile(filepath.Join(dir, "README"), []byte(cacheREADME), 0666); wErr != nil {
- base.Fatalf("Failed to write README file to cache dir %s: %s", dir, err)
- }
- }
-
- diskCache, err := Open(dir)
- if err != nil {
- base.Fatalf("failed to initialize build cache at %s: %s\n", dir, err)
- }
-
- if v := os.Getenv(envGolangciLintCacheProg); v != "" {
- defaultCache = startCacheProg(v, diskCache)
- } else {
- defaultCache = diskCache
- }
-}
-
-var (
- defaultDirOnce sync.Once
- defaultDir string
- defaultDirChanged bool // effective value differs from $GOLANGCI_LINT_CACHE
- defaultDirErr error
-)
-
-// DefaultDir returns the effective GOLANGCI_LINT_CACHE setting.
-// It returns "off" if the cache is disabled,
-// and reports whether the effective value differs from GOLANGCI_LINT_CACHE.
-func DefaultDir() (string, bool) {
- // Save the result of the first call to DefaultDir for later use in
- // initDefaultCache. cmd/go/main.go explicitly sets GOCACHE so that
- // subprocesses will inherit it, but that means initDefaultCache can't
- // otherwise distinguish between an explicit "off" and a UserCacheDir error.
-
- defaultDirOnce.Do(func() {
- defaultDir = os.Getenv(envGolangciLintCache)
- if defaultDir != "" {
- defaultDirChanged = true
- if filepath.IsAbs(defaultDir) || defaultDir == "off" {
- return
- }
- defaultDir = "off"
- defaultDirErr = fmt.Errorf("%s is not an absolute path", envGolangciLintCache)
- return
- }
-
- // Compute default location.
- dir, err := os.UserCacheDir()
- if err != nil {
- defaultDir = "off"
- defaultDirChanged = true
- defaultDirErr = fmt.Errorf("%s is not defined and %w", envGolangciLintCache, err)
- return
- }
- defaultDir = filepath.Join(dir, "golangci-lint")
- })
-
- return defaultDir, defaultDirChanged
-}
diff --git a/vendor/github.com/golangci/golangci-lint/internal/go/cache/hash.go b/vendor/github.com/golangci/golangci-lint/internal/go/cache/hash.go
deleted file mode 100644
index d5169dd4c4..0000000000
--- a/vendor/github.com/golangci/golangci-lint/internal/go/cache/hash.go
+++ /dev/null
@@ -1,192 +0,0 @@
-// Copyright 2017 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package cache
-
-import (
- "bytes"
- "crypto/sha256"
- "fmt"
- "hash"
- "io"
- "os"
- "strings"
- "sync"
-)
-
-var debugHash = false // set when GODEBUG=gocachehash=1
-
-// HashSize is the number of bytes in a hash.
-const HashSize = 32
-
-// A Hash provides access to the canonical hash function used to index the cache.
-// The current implementation uses salted SHA256, but clients must not assume this.
-type Hash struct {
- h hash.Hash
- name string // for debugging
- buf *bytes.Buffer // for verify
-}
-
-// hashSalt is a salt string added to the beginning of every hash
-// created by NewHash. Using the golangci-lint version makes sure that different
-// versions of the command do not address the same cache
-// entries, so that a bug in one version does not affect the execution
-// of other versions. This salt will result in additional ActionID files
-// in the cache, but not additional copies of the large output files,
-// which are still addressed by unsalted SHA256.
-var hashSalt []byte
-
-// stripExperiment strips any GOEXPERIMENT configuration from the Go
-// version string.
-func stripExperiment(version string) string {
- if i := strings.Index(version, " X:"); i >= 0 {
- return version[:i]
- }
- return version
-}
-
-// Subkey returns an action ID corresponding to mixing a parent
-// action ID with a string description of the subkey.
-func Subkey(parent ActionID, desc string) (ActionID, error) {
- h := sha256.New()
- h.Write([]byte(("subkey:")))
- n, err := h.Write(parent[:])
- if n != len(parent) {
- return ActionID{}, fmt.Errorf("wrote %d/%d bytes of parent with error %s", n, len(parent), err)
- }
- n, err = h.Write([]byte(desc))
- if n != len(desc) {
- return ActionID{}, fmt.Errorf("wrote %d/%d bytes of desc with error %s", n, len(desc), err)
- }
-
- var out ActionID
- h.Sum(out[:0])
- if debugHash {
- fmt.Fprintf(os.Stderr, "HASH subkey %x %q = %x\n", parent, desc, out)
- }
- if verify {
- hashDebug.Lock()
- hashDebug.m[out] = fmt.Sprintf("subkey %x %q", parent, desc)
- hashDebug.Unlock()
- }
- return out, nil
-}
-
-// NewHash returns a new Hash.
-// The caller is expected to Write data to it and then call Sum.
-func NewHash(name string) (*Hash, error) {
- h := &Hash{h: sha256.New(), name: name}
- if debugHash {
- fmt.Fprintf(os.Stderr, "HASH[%s]\n", h.name)
- }
- n, err := h.Write(hashSalt)
- if n != len(hashSalt) {
- return nil, fmt.Errorf("wrote %d/%d bytes of hash salt with error %s", n, len(hashSalt), err)
- }
- if verify {
- h.buf = new(bytes.Buffer)
- }
- return h, nil
-}
-
-// Write writes data to the running hash.
-func (h *Hash) Write(b []byte) (int, error) {
- if debugHash {
- fmt.Fprintf(os.Stderr, "HASH[%s]: %q\n", h.name, b)
- }
- if h.buf != nil {
- h.buf.Write(b)
- }
- return h.h.Write(b)
-}
-
-// Sum returns the hash of the data written previously.
-func (h *Hash) Sum() [HashSize]byte {
- var out [HashSize]byte
- h.h.Sum(out[:0])
- if debugHash {
- fmt.Fprintf(os.Stderr, "HASH[%s]: %x\n", h.name, out)
- }
- if h.buf != nil {
- hashDebug.Lock()
- if hashDebug.m == nil {
- hashDebug.m = make(map[[HashSize]byte]string)
- }
- hashDebug.m[out] = h.buf.String()
- hashDebug.Unlock()
- }
- return out
-}
-
-// In GODEBUG=gocacheverify=1 mode,
-// hashDebug holds the input to every computed hash ID,
-// so that we can work backward from the ID involved in a
-// cache entry mismatch to a description of what should be there.
-var hashDebug struct {
- sync.Mutex
- m map[[HashSize]byte]string
-}
-
-// reverseHash returns the input used to compute the hash id.
-func reverseHash(id [HashSize]byte) string {
- hashDebug.Lock()
- s := hashDebug.m[id]
- hashDebug.Unlock()
- return s
-}
-
-var hashFileCache struct {
- sync.Mutex
- m map[string][HashSize]byte
-}
-
-// FileHash returns the hash of the named file.
-// It caches repeated lookups for a given file,
-// and the cache entry for a file can be initialized
-// using SetFileHash.
-// The hash used by FileHash is not the same as
-// the hash used by NewHash.
-func FileHash(file string) ([HashSize]byte, error) {
- hashFileCache.Lock()
- out, ok := hashFileCache.m[file]
- hashFileCache.Unlock()
-
- if ok {
- return out, nil
- }
-
- h := sha256.New()
- f, err := os.Open(file)
- if err != nil {
- if debugHash {
- fmt.Fprintf(os.Stderr, "HASH %s: %v\n", file, err)
- }
- return [HashSize]byte{}, err
- }
- _, err = io.Copy(h, f)
- f.Close()
- if err != nil {
- if debugHash {
- fmt.Fprintf(os.Stderr, "HASH %s: %v\n", file, err)
- }
- return [HashSize]byte{}, err
- }
- h.Sum(out[:0])
- if debugHash {
- fmt.Fprintf(os.Stderr, "HASH %s: %x\n", file, out)
- }
-
- SetFileHash(file, out)
- return out, nil
-}
-
-// SetFileHash sets the hash returned by FileHash for file.
-func SetFileHash(file string, sum [HashSize]byte) {
- hashFileCache.Lock()
- if hashFileCache.m == nil {
- hashFileCache.m = make(map[string][HashSize]byte)
- }
- hashFileCache.m[file] = sum
- hashFileCache.Unlock()
-}
diff --git a/vendor/github.com/golangci/golangci-lint/internal/go/cache/prog.go b/vendor/github.com/golangci/golangci-lint/internal/go/cache/prog.go
deleted file mode 100644
index a93740a3cf..0000000000
--- a/vendor/github.com/golangci/golangci-lint/internal/go/cache/prog.go
+++ /dev/null
@@ -1,428 +0,0 @@
-// Copyright 2023 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package cache
-
-import (
- "bufio"
- "context"
- "crypto/sha256"
- "encoding/base64"
- "encoding/json"
- "errors"
- "fmt"
- "io"
- "log"
- base "log"
- "os"
- "os/exec"
- "sync"
- "sync/atomic"
- "time"
-
- "github.com/golangci/golangci-lint/internal/go/quoted"
-)
-
-// ProgCache implements Cache via JSON messages over stdin/stdout to a child
-// helper process which can then implement whatever caching policy/mechanism it
-// wants.
-//
-// See https://github.com/golang/go/issues/59719
-type ProgCache struct {
- cmd *exec.Cmd
- stdout io.ReadCloser // from the child process
- stdin io.WriteCloser // to the child process
- bw *bufio.Writer // to stdin
- jenc *json.Encoder // to bw
-
- // can are the commands that the child process declared that it supports.
- // This is effectively the versioning mechanism.
- can map[ProgCmd]bool
-
- // fuzzDirCache is another Cache implementation to use for the FuzzDir
- // method. In practice this is the default GOCACHE disk-based
- // implementation.
- //
- // TODO(bradfitz): maybe this isn't ideal. But we'd need to extend the Cache
- // interface and the fuzzing callers to be less disk-y to do more here.
- fuzzDirCache Cache
-
- closing atomic.Bool
- ctx context.Context // valid until Close via ctxClose
- ctxCancel context.CancelFunc // called on Close
- readLoopDone chan struct{} // closed when readLoop returns
-
- mu sync.Mutex // guards following fields
- nextID int64
- inFlight map[int64]chan<- *ProgResponse
- outputFile map[OutputID]string // object => abs path on disk
-
- // writeMu serializes writing to the child process.
- // It must never be held at the same time as mu.
- writeMu sync.Mutex
-}
-
-// ProgCmd is a command that can be issued to a child process.
-//
-// If the interface needs to grow, we can add new commands or new versioned
-// commands like "get2".
-type ProgCmd string
-
-const (
- cmdGet = ProgCmd("get")
- cmdPut = ProgCmd("put")
- cmdClose = ProgCmd("close")
-)
-
-// ProgRequest is the JSON-encoded message that's sent from cmd/go to
-// the GOLANGCI_LINT_CACHEPROG child process over stdin. Each JSON object is on its
-// own line. A ProgRequest of Type "put" with BodySize > 0 will be followed
-// by a line containing a base64-encoded JSON string literal of the body.
-type ProgRequest struct {
- // ID is a unique number per process across all requests.
- // It must be echoed in the ProgResponse from the child.
- ID int64
-
- // Command is the type of request.
- // The cmd/go tool will only send commands that were declared
- // as supported by the child.
- Command ProgCmd
-
- // ActionID is non-nil for get and puts.
- ActionID []byte `json:",omitempty"` // or nil if not used
-
- // ObjectID is set for Type "put" and "output-file".
- ObjectID []byte `json:",omitempty"` // or nil if not used
-
- // Body is the body for "put" requests. It's sent after the JSON object
- // as a base64-encoded JSON string when BodySize is non-zero.
- // It's sent as a separate JSON value instead of being a struct field
- // send in this JSON object so large values can be streamed in both directions.
- // The base64 string body of a ProgRequest will always be written
- // immediately after the JSON object and a newline.
- Body io.Reader `json:"-"`
-
- // BodySize is the number of bytes of Body. If zero, the body isn't written.
- BodySize int64 `json:",omitempty"`
-}
-
-// ProgResponse is the JSON response from the child process to cmd/go.
-//
-// With the exception of the first protocol message that the child writes to its
-// stdout with ID==0 and KnownCommands populated, these are only sent in
-// response to a ProgRequest from cmd/go.
-//
-// ProgResponses can be sent in any order. The ID must match the request they're
-// replying to.
-type ProgResponse struct {
- ID int64 // that corresponds to ProgRequest; they can be answered out of order
- Err string `json:",omitempty"` // if non-empty, the error
-
- // KnownCommands is included in the first message that cache helper program
- // writes to stdout on startup (with ID==0). It includes the
- // ProgRequest.Command types that are supported by the program.
- //
- // This lets us extend the protocol gracefully over time (adding "get2",
- // etc), or fail gracefully when needed. It also lets us verify the program
- // wants to be a cache helper.
- KnownCommands []ProgCmd `json:",omitempty"`
-
- // For Get requests.
-
- Miss bool `json:",omitempty"` // cache miss
- OutputID []byte `json:",omitempty"`
- Size int64 `json:",omitempty"` // in bytes
- Time *time.Time `json:",omitempty"` // an Entry.Time; when the object was added to the docs
-
- // DiskPath is the absolute path on disk of the ObjectID corresponding
- // a "get" request's ActionID (on cache hit) or a "put" request's
- // provided ObjectID.
- DiskPath string `json:",omitempty"`
-}
-
-// startCacheProg starts the prog binary (with optional space-separated flags)
-// and returns a Cache implementation that talks to it.
-//
-// It blocks a few seconds to wait for the child process to successfully start
-// and advertise its capabilities.
-func startCacheProg(progAndArgs string, fuzzDirCache Cache) Cache {
- if fuzzDirCache == nil {
- panic("missing fuzzDirCache")
- }
- args, err := quoted.Split(progAndArgs)
- if err != nil {
- base.Fatalf("%s args: %v", envGolangciLintCacheProg, err)
- }
- var prog string
- if len(args) > 0 {
- prog = args[0]
- args = args[1:]
- }
-
- ctx, ctxCancel := context.WithCancel(context.Background())
-
- cmd := exec.CommandContext(ctx, prog, args...)
- out, err := cmd.StdoutPipe()
- if err != nil {
- base.Fatalf("StdoutPipe to %s: %v", envGolangciLintCacheProg, err)
- }
- in, err := cmd.StdinPipe()
- if err != nil {
- base.Fatalf("StdinPipe to %s: %v", envGolangciLintCacheProg, err)
- }
- cmd.Stderr = os.Stderr
- cmd.Cancel = in.Close
-
- if err := cmd.Start(); err != nil {
- base.Fatalf("error starting %s program %q: %v", envGolangciLintCacheProg, prog, err)
- }
-
- pc := &ProgCache{
- ctx: ctx,
- ctxCancel: ctxCancel,
- fuzzDirCache: fuzzDirCache,
- cmd: cmd,
- stdout: out,
- stdin: in,
- bw: bufio.NewWriter(in),
- inFlight: make(map[int64]chan<- *ProgResponse),
- outputFile: make(map[OutputID]string),
- readLoopDone: make(chan struct{}),
- }
-
- // Register our interest in the initial protocol message from the child to
- // us, saying what it can do.
- capResc := make(chan *ProgResponse, 1)
- pc.inFlight[0] = capResc
-
- pc.jenc = json.NewEncoder(pc.bw)
- go pc.readLoop(pc.readLoopDone)
-
- // Give the child process a few seconds to report its capabilities. This
- // should be instant and not require any slow work by the program.
- timer := time.NewTicker(5 * time.Second)
- defer timer.Stop()
- for {
- select {
- case <-timer.C:
- log.Printf("# still waiting for %s %v ...", envGolangciLintCacheProg, prog)
- case capRes := <-capResc:
- can := map[ProgCmd]bool{}
- for _, cmd := range capRes.KnownCommands {
- can[cmd] = true
- }
- if len(can) == 0 {
- base.Fatalf("%s %v declared no supported commands", envGolangciLintCacheProg, prog)
- }
- pc.can = can
- return pc
- }
- }
-}
-
-func (c *ProgCache) readLoop(readLoopDone chan<- struct{}) {
- defer close(readLoopDone)
- jd := json.NewDecoder(c.stdout)
- for {
- res := new(ProgResponse)
- if err := jd.Decode(res); err != nil {
- if c.closing.Load() {
- return // quietly
- }
- if err == io.EOF {
- c.mu.Lock()
- inFlight := len(c.inFlight)
- c.mu.Unlock()
- base.Fatalf("%s exited pre-Close with %v pending requests", envGolangciLintCacheProg, inFlight)
- }
- base.Fatalf("error reading JSON from %s: %v", envGolangciLintCacheProg, err)
- }
- c.mu.Lock()
- ch, ok := c.inFlight[res.ID]
- delete(c.inFlight, res.ID)
- c.mu.Unlock()
- if ok {
- ch <- res
- } else {
- base.Fatalf("%s sent response for unknown request ID %v", envGolangciLintCacheProg, res.ID)
- }
- }
-}
-
-func (c *ProgCache) send(ctx context.Context, req *ProgRequest) (*ProgResponse, error) {
- resc := make(chan *ProgResponse, 1)
- if err := c.writeToChild(req, resc); err != nil {
- return nil, err
- }
- select {
- case res := <-resc:
- if res.Err != "" {
- return nil, errors.New(res.Err)
- }
- return res, nil
- case <-ctx.Done():
- return nil, ctx.Err()
- }
-}
-
-func (c *ProgCache) writeToChild(req *ProgRequest, resc chan<- *ProgResponse) (err error) {
- c.mu.Lock()
- c.nextID++
- req.ID = c.nextID
- c.inFlight[req.ID] = resc
- c.mu.Unlock()
-
- defer func() {
- if err != nil {
- c.mu.Lock()
- delete(c.inFlight, req.ID)
- c.mu.Unlock()
- }
- }()
-
- c.writeMu.Lock()
- defer c.writeMu.Unlock()
-
- if err := c.jenc.Encode(req); err != nil {
- return err
- }
- if err := c.bw.WriteByte('\n'); err != nil {
- return err
- }
- if req.Body != nil && req.BodySize > 0 {
- if err := c.bw.WriteByte('"'); err != nil {
- return err
- }
- e := base64.NewEncoder(base64.StdEncoding, c.bw)
- wrote, err := io.Copy(e, req.Body)
- if err != nil {
- return err
- }
- if err := e.Close(); err != nil {
- return nil
- }
- if wrote != req.BodySize {
- return fmt.Errorf("short write writing body to %s for action %x, object %x: wrote %v; expected %v",
- envGolangciLintCacheProg, req.ActionID, req.ObjectID, wrote, req.BodySize)
- }
- if _, err := c.bw.WriteString("\"\n"); err != nil {
- return err
- }
- }
- if err := c.bw.Flush(); err != nil {
- return err
- }
- return nil
-}
-
-func (c *ProgCache) Get(a ActionID) (Entry, error) {
- if !c.can[cmdGet] {
- // They can't do a "get". Maybe they're a write-only cache.
- //
- // TODO(bradfitz,bcmills): figure out the proper error type here. Maybe
- // errors.ErrUnsupported? Is entryNotFoundError even appropriate? There
- // might be places where we rely on the fact that a recent Put can be
- // read through a corresponding Get. Audit callers and check, and document
- // error types on the Cache interface.
- return Entry{}, &entryNotFoundError{}
- }
- res, err := c.send(c.ctx, &ProgRequest{
- Command: cmdGet,
- ActionID: a[:],
- })
- if err != nil {
- return Entry{}, err // TODO(bradfitz): or entryNotFoundError? Audit callers.
- }
- if res.Miss {
- return Entry{}, &entryNotFoundError{}
- }
- e := Entry{
- Size: res.Size,
- }
- if res.Time != nil {
- e.Time = *res.Time
- } else {
- e.Time = time.Now()
- }
- if res.DiskPath == "" {
- return Entry{}, &entryNotFoundError{fmt.Errorf("%s didn't populate DiskPath on get hit", envGolangciLintCacheProg)}
- }
- if copy(e.OutputID[:], res.OutputID) != len(res.OutputID) {
- return Entry{}, &entryNotFoundError{errors.New("incomplete ProgResponse OutputID")}
- }
- c.noteOutputFile(e.OutputID, res.DiskPath)
- return e, nil
-}
-
-func (c *ProgCache) noteOutputFile(o OutputID, diskPath string) {
- c.mu.Lock()
- defer c.mu.Unlock()
- c.outputFile[o] = diskPath
-}
-
-func (c *ProgCache) OutputFile(o OutputID) string {
- c.mu.Lock()
- defer c.mu.Unlock()
- return c.outputFile[o]
-}
-
-func (c *ProgCache) Put(a ActionID, file io.ReadSeeker) (_ OutputID, size int64, _ error) {
- // Compute output ID.
- h := sha256.New()
- if _, err := file.Seek(0, 0); err != nil {
- return OutputID{}, 0, err
- }
- size, err := io.Copy(h, file)
- if err != nil {
- return OutputID{}, 0, err
- }
- var out OutputID
- h.Sum(out[:0])
-
- if _, err := file.Seek(0, 0); err != nil {
- return OutputID{}, 0, err
- }
-
- if !c.can[cmdPut] {
- // Child is a read-only cache. Do nothing.
- return out, size, nil
- }
-
- res, err := c.send(c.ctx, &ProgRequest{
- Command: cmdPut,
- ActionID: a[:],
- ObjectID: out[:],
- Body: file,
- BodySize: size,
- })
- if err != nil {
- return OutputID{}, 0, err
- }
- if res.DiskPath == "" {
- return OutputID{}, 0, fmt.Errorf("%s didn't return DiskPath in put response", envGolangciLintCacheProg)
- }
- c.noteOutputFile(out, res.DiskPath)
- return out, size, err
-}
-
-func (c *ProgCache) Close() error {
- c.closing.Store(true)
- var err error
-
- // First write a "close" message to the child so it can exit nicely
- // and clean up if it wants. Only after that exchange do we cancel
- // the context that kills the process.
- if c.can[cmdClose] {
- _, err = c.send(c.ctx, &ProgRequest{Command: cmdClose})
- }
- c.ctxCancel()
- <-c.readLoopDone
- return err
-}
-
-func (c *ProgCache) FuzzDir() string {
- // TODO(bradfitz): figure out what to do here. For now just use the
- // disk-based default.
- return c.fuzzDirCache.FuzzDir()
-}
diff --git a/vendor/github.com/golangci/golangci-lint/internal/go/cache/readme.md b/vendor/github.com/golangci/golangci-lint/internal/go/cache/readme.md
deleted file mode 100644
index 5be600e425..0000000000
--- a/vendor/github.com/golangci/golangci-lint/internal/go/cache/readme.md
+++ /dev/null
@@ -1,51 +0,0 @@
-# cache
-
-Extracted from `go/src/cmd/go/internal/cache/`.
-
-The main modifications are:
-- The errors management
- - Some methods return error.
- - Some errors are returned instead of being ignored.
-- The name of the env vars:
- - `GOCACHE` -> `GOLANGCI_LINT_CACHE`
- - `GOCACHEPROG` -> `GOLANGCI_LINT_CACHEPROG`
-
-## History
-
-- https://github.com/golangci/golangci-lint/pull/5100
- - Move package from `internal/cache` to `internal/go/cache`
-- https://github.com/golangci/golangci-lint/pull/5098
- - sync with go1.23.2
- - sync with go1.22.8
- - sync with go1.21.13
- - sync with go1.20.14
- - sync with go1.19.13
- - sync with go1.18.10
- - sync with go1.17.13
- - sync with go1.16.15
- - sync with go1.15.15
- - sync with go1.14.15
-
-## Previous History
-
-Based on the initial PR/commit the based in a mix between go1.12 and go1.13:
-- cache.go (go1.13)
-- cache_test.go (go1.12?)
-- default.go (go1.12?)
-- hash.go (go1.13 and go1.12 are identical)
-- hash_test.go -> (go1.12?)
-
-Adapted for golangci-lint:
-- https://github.com/golangci/golangci-lint/pull/699: initial code (contains modifications of the files)
-- https://github.com/golangci/golangci-lint/pull/779: just a nolint (`cache.go`)
-- https://github.com/golangci/golangci-lint/pull/788: only directory permissions changes (0777 -> 0744) (`cache.go`, `cache_test.go`, `default.go`)
-- https://github.com/golangci/golangci-lint/pull/808: mainly related to logs and errors (`cache.go`, `default.go`, `hash.go`, `hash_test.go`)
-- https://github.com/golangci/golangci-lint/pull/1063: `ioutil` -> `robustio` (`cache.go`)
-- https://github.com/golangci/golangci-lint/pull/1070: add `t.Parallel()` inside `cache_test.go`
-- https://github.com/golangci/golangci-lint/pull/1162: errors inside `cache.go`
-- https://github.com/golangci/golangci-lint/pull/2318: `ioutil` -> `os` (`cache.go`, `cache_test.go`, `default.go`, `hash_test.go`)
-- https://github.com/golangci/golangci-lint/pull/2352: Go doc typos
-- https://github.com/golangci/golangci-lint/pull/3012: errors inside `cache.go` (`cache.go`, `default.go`)
-- https://github.com/golangci/golangci-lint/pull/3196: constant for `GOLANGCI_LINT_CACHE` (`cache.go`)
-- https://github.com/golangci/golangci-lint/pull/3204: add this file and `%w` in `fmt.Errorf` (`cache.go`)
-- https://github.com/golangci/golangci-lint/pull/3604: remove `github.com/pkg/errors` (`cache.go`)
diff --git a/vendor/github.com/golangci/golangci-lint/internal/go/mmap/mmap.go b/vendor/github.com/golangci/golangci-lint/internal/go/mmap/mmap.go
deleted file mode 100644
index fcbd3e08c1..0000000000
--- a/vendor/github.com/golangci/golangci-lint/internal/go/mmap/mmap.go
+++ /dev/null
@@ -1,31 +0,0 @@
-// Copyright 2011 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// This package is a lightly modified version of the mmap code
-// in github.com/google/codesearch/index.
-
-// The mmap package provides an abstraction for memory mapping files
-// on different platforms.
-package mmap
-
-import (
- "os"
-)
-
-// Data is mmap'ed read-only data from a file.
-// The backing file is never closed, so Data
-// remains valid for the lifetime of the process.
-type Data struct {
- f *os.File
- Data []byte
-}
-
-// Mmap maps the given file into memory.
-func Mmap(file string) (Data, error) {
- f, err := os.Open(file)
- if err != nil {
- return Data{}, err
- }
- return mmapFile(f)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/internal/go/mmap/mmap_windows.go b/vendor/github.com/golangci/golangci-lint/internal/go/mmap/mmap_windows.go
deleted file mode 100644
index 479ee30754..0000000000
--- a/vendor/github.com/golangci/golangci-lint/internal/go/mmap/mmap_windows.go
+++ /dev/null
@@ -1,41 +0,0 @@
-// Copyright 2011 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package mmap
-
-import (
- "fmt"
- "os"
- "syscall"
- "unsafe"
-
- "golang.org/x/sys/windows"
-)
-
-func mmapFile(f *os.File) (Data, error) {
- st, err := f.Stat()
- if err != nil {
- return Data{}, err
- }
- size := st.Size()
- if size == 0 {
- return Data{f, nil}, nil
- }
- h, err := syscall.CreateFileMapping(syscall.Handle(f.Fd()), nil, syscall.PAGE_READONLY, 0, 0, nil)
- if err != nil {
- return Data{}, fmt.Errorf("CreateFileMapping %s: %w", f.Name(), err)
- }
-
- addr, err := syscall.MapViewOfFile(h, syscall.FILE_MAP_READ, 0, 0, 0)
- if err != nil {
- return Data{}, fmt.Errorf("MapViewOfFile %s: %w", f.Name(), err)
- }
- var info windows.MemoryBasicInformation
- err = windows.VirtualQuery(addr, &info, unsafe.Sizeof(info))
- if err != nil {
- return Data{}, fmt.Errorf("VirtualQuery %s: %w", f.Name(), err)
- }
- data := unsafe.Slice((*byte)(unsafe.Pointer(addr)), int(info.RegionSize))
- return Data{f, data}, nil
-}
diff --git a/vendor/github.com/golangci/golangci-lint/internal/go/mmap/readme.md b/vendor/github.com/golangci/golangci-lint/internal/go/mmap/readme.md
deleted file mode 100644
index f68aef097c..0000000000
--- a/vendor/github.com/golangci/golangci-lint/internal/go/mmap/readme.md
+++ /dev/null
@@ -1,15 +0,0 @@
-# mmap
-
-Extracted from `go/src/cmd/go/internal/mmap/` (related to `cache`).
-This is just a copy of the Go code without any changes.
-
-## History
-
-- https://github.com/golangci/golangci-lint/pull/5100
- - Move package from `internal/mmap` to `internal/go/mmap`
-- https://github.com/golangci/golangci-lint/pull/5098
- - sync with go1.23.2
- - sync with go1.22.8
- - sync with go1.21.13
- - sync with go1.20.14
- - sync with go1.19.13
diff --git a/vendor/github.com/golangci/golangci-lint/internal/go/quoted/readme.md b/vendor/github.com/golangci/golangci-lint/internal/go/quoted/readme.md
deleted file mode 100644
index a5e4c4bb3b..0000000000
--- a/vendor/github.com/golangci/golangci-lint/internal/go/quoted/readme.md
+++ /dev/null
@@ -1,13 +0,0 @@
-# quoted
-
-Extracted from `go/src/cmd/internal/quoted/` (related to `cache`).
-This is just a copy of the Go code without any changes.
-
-## History
-
-- https://github.com/golangci/golangci-lint/pull/5100
- - Move package from `internal/quoted` to `internal/go/quoted`
-- https://github.com/golangci/golangci-lint/pull/5098
- - sync go1.23.2
- - sync go1.22.8
- - sync go1.21.13
diff --git a/vendor/github.com/golangci/golangci-lint/internal/go/robustio/readme.md b/vendor/github.com/golangci/golangci-lint/internal/go/robustio/readme.md
deleted file mode 100644
index f4dbc16264..0000000000
--- a/vendor/github.com/golangci/golangci-lint/internal/go/robustio/readme.md
+++ /dev/null
@@ -1,11 +0,0 @@
-# robustio
-
-Extracted from go1.19.1/src/cmd/go/internal/robustio
-
-There is only one modification:
-- ERROR_SHARING_VIOLATION extracted from go1.19.1/src/internal/syscall/windows/syscall_windows.go to remove the dependencies to `internal/syscall/windows`
-
-## History
-
-- https://github.com/golangci/golangci-lint/pull/5100
- - Move package from `internal/robustio` to `internal/go/robustio`
diff --git a/vendor/github.com/golangci/golangci-lint/internal/go/robustio/robustio_windows.go b/vendor/github.com/golangci/golangci-lint/internal/go/robustio/robustio_windows.go
deleted file mode 100644
index fe1728954c..0000000000
--- a/vendor/github.com/golangci/golangci-lint/internal/go/robustio/robustio_windows.go
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright 2019 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package robustio
-
-import (
- "errors"
- "syscall"
-)
-
-const errFileNotFound = syscall.ERROR_FILE_NOT_FOUND
-
-// ERROR_SHARING_VIOLATION (ldez) extract from go1.19.1/src/internal/syscall/windows/syscall_windows.go.
-// This is the only modification of this file.
-const ERROR_SHARING_VIOLATION syscall.Errno = 32
-
-// isEphemeralError returns true if err may be resolved by waiting.
-func isEphemeralError(err error) bool {
- var errno syscall.Errno
- if errors.As(err, &errno) {
- switch errno {
- case syscall.ERROR_ACCESS_DENIED,
- syscall.ERROR_FILE_NOT_FOUND,
- ERROR_SHARING_VIOLATION:
- return true
- }
- }
- return false
-}
diff --git a/vendor/github.com/golangci/golangci-lint/internal/x/tools/analysisflags/readme.md b/vendor/github.com/golangci/golangci-lint/internal/x/tools/analysisflags/readme.md
deleted file mode 100644
index 4d221d4ca5..0000000000
--- a/vendor/github.com/golangci/golangci-lint/internal/x/tools/analysisflags/readme.md
+++ /dev/null
@@ -1,8 +0,0 @@
-# analysisflags
-
-Extracted from `/go/analysis/internal/analysisflags` (related to `checker`).
-This is just a copy of the code without any changes.
-
-## History
-
-- sync with https://github.com/golang/tools/blob/v0.28.0
diff --git a/vendor/github.com/golangci/golangci-lint/internal/x/tools/analysisflags/url.go b/vendor/github.com/golangci/golangci-lint/internal/x/tools/analysisflags/url.go
deleted file mode 100644
index 26a917a991..0000000000
--- a/vendor/github.com/golangci/golangci-lint/internal/x/tools/analysisflags/url.go
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright 2023 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package analysisflags
-
-import (
- "fmt"
- "net/url"
-
- "golang.org/x/tools/go/analysis"
-)
-
-// ResolveURL resolves the URL field for a Diagnostic from an Analyzer
-// and returns the URL. See Diagnostic.URL for details.
-func ResolveURL(a *analysis.Analyzer, d analysis.Diagnostic) (string, error) {
- if d.URL == "" && d.Category == "" && a.URL == "" {
- return "", nil // do nothing
- }
- raw := d.URL
- if d.URL == "" && d.Category != "" {
- raw = "#" + d.Category
- }
- u, err := url.Parse(raw)
- if err != nil {
- return "", fmt.Errorf("invalid Diagnostic.URL %q: %s", raw, err)
- }
- base, err := url.Parse(a.URL)
- if err != nil {
- return "", fmt.Errorf("invalid Analyzer.URL %q: %s", a.URL, err)
- }
- return base.ResolveReference(u).String(), nil
-}
diff --git a/vendor/github.com/golangci/golangci-lint/internal/x/tools/analysisinternal/analysis.go b/vendor/github.com/golangci/golangci-lint/internal/x/tools/analysisinternal/analysis.go
deleted file mode 100644
index bb12600dac..0000000000
--- a/vendor/github.com/golangci/golangci-lint/internal/x/tools/analysisinternal/analysis.go
+++ /dev/null
@@ -1,48 +0,0 @@
-// Copyright 2020 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// Package analysisinternal provides gopls' internal analyses with a
-// number of helper functions that operate on typed syntax trees.
-package analysisinternal
-
-import (
- "fmt"
- "os"
-
- "golang.org/x/tools/go/analysis"
-)
-
-// MakeReadFile returns a simple implementation of the Pass.ReadFile function.
-func MakeReadFile(pass *analysis.Pass) func(filename string) ([]byte, error) {
- return func(filename string) ([]byte, error) {
- if err := CheckReadable(pass, filename); err != nil {
- return nil, err
- }
- return os.ReadFile(filename)
- }
-}
-
-// CheckReadable enforces the access policy defined by the ReadFile field of [analysis.Pass].
-func CheckReadable(pass *analysis.Pass, filename string) error {
- if slicesContains(pass.OtherFiles, filename) ||
- slicesContains(pass.IgnoredFiles, filename) {
- return nil
- }
- for _, f := range pass.Files {
- if pass.Fset.File(f.FileStart).Name() == filename {
- return nil
- }
- }
- return fmt.Errorf("Pass.ReadFile: %s is not among OtherFiles, IgnoredFiles, or names of Files", filename)
-}
-
-// TODO(adonovan): use go1.21 slices.Contains.
-func slicesContains[S ~[]E, E comparable](slice S, x E) bool {
- for _, elem := range slice {
- if elem == x {
- return true
- }
- }
- return false
-}
diff --git a/vendor/github.com/golangci/golangci-lint/internal/x/tools/analysisinternal/readme.md b/vendor/github.com/golangci/golangci-lint/internal/x/tools/analysisinternal/readme.md
deleted file mode 100644
index f301cdbebb..0000000000
--- a/vendor/github.com/golangci/golangci-lint/internal/x/tools/analysisinternal/readme.md
+++ /dev/null
@@ -1,8 +0,0 @@
-# analysisinternal
-
-Extracted from `/internal/analysisinternal/` (related to `checker`).
-This is just a copy of the code without any changes.
-
-## History
-
-- sync with https://github.com/golang/tools/blob/v0.28.0
diff --git a/vendor/github.com/golangci/golangci-lint/internal/x/tools/diff/diff.go b/vendor/github.com/golangci/golangci-lint/internal/x/tools/diff/diff.go
deleted file mode 100644
index a13547b7a7..0000000000
--- a/vendor/github.com/golangci/golangci-lint/internal/x/tools/diff/diff.go
+++ /dev/null
@@ -1,176 +0,0 @@
-// Copyright 2019 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// Package diff computes differences between text files or strings.
-package diff
-
-import (
- "fmt"
- "sort"
- "strings"
-)
-
-// An Edit describes the replacement of a portion of a text file.
-type Edit struct {
- Start, End int // byte offsets of the region to replace
- New string // the replacement
-}
-
-func (e Edit) String() string {
- return fmt.Sprintf("{Start:%d,End:%d,New:%q}", e.Start, e.End, e.New)
-}
-
-// Apply applies a sequence of edits to the src buffer and returns the
-// result. Edits are applied in order of start offset; edits with the
-// same start offset are applied in they order they were provided.
-//
-// Apply returns an error if any edit is out of bounds,
-// or if any pair of edits is overlapping.
-func Apply(src string, edits []Edit) (string, error) {
- edits, size, err := validate(src, edits)
- if err != nil {
- return "", err
- }
-
- // Apply edits.
- out := make([]byte, 0, size)
- lastEnd := 0
- for _, edit := range edits {
- if lastEnd < edit.Start {
- out = append(out, src[lastEnd:edit.Start]...)
- }
- out = append(out, edit.New...)
- lastEnd = edit.End
- }
- out = append(out, src[lastEnd:]...)
-
- if len(out) != size {
- panic("wrong size")
- }
-
- return string(out), nil
-}
-
-// ApplyBytes is like Apply, but it accepts a byte slice.
-// The result is always a new array.
-func ApplyBytes(src []byte, edits []Edit) ([]byte, error) {
- res, err := Apply(string(src), edits)
- return []byte(res), err
-}
-
-// validate checks that edits are consistent with src,
-// and returns the size of the patched output.
-// It may return a different slice.
-func validate(src string, edits []Edit) ([]Edit, int, error) {
- if !sort.IsSorted(editsSort(edits)) {
- edits = append([]Edit(nil), edits...)
- SortEdits(edits)
- }
-
- // Check validity of edits and compute final size.
- size := len(src)
- lastEnd := 0
- for _, edit := range edits {
- if !(0 <= edit.Start && edit.Start <= edit.End && edit.End <= len(src)) {
- return nil, 0, fmt.Errorf("diff has out-of-bounds edits")
- }
- if edit.Start < lastEnd {
- return nil, 0, fmt.Errorf("diff has overlapping edits")
- }
- size += len(edit.New) + edit.Start - edit.End
- lastEnd = edit.End
- }
-
- return edits, size, nil
-}
-
-// SortEdits orders a slice of Edits by (start, end) offset.
-// This ordering puts insertions (end = start) before deletions
-// (end > start) at the same point, but uses a stable sort to preserve
-// the order of multiple insertions at the same point.
-// (Apply detects multiple deletions at the same point as an error.)
-func SortEdits(edits []Edit) {
- sort.Stable(editsSort(edits))
-}
-
-type editsSort []Edit
-
-func (a editsSort) Len() int { return len(a) }
-func (a editsSort) Less(i, j int) bool {
- if cmp := a[i].Start - a[j].Start; cmp != 0 {
- return cmp < 0
- }
- return a[i].End < a[j].End
-}
-func (a editsSort) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
-
-// lineEdits expands and merges a sequence of edits so that each
-// resulting edit replaces one or more complete lines.
-// See ApplyEdits for preconditions.
-func lineEdits(src string, edits []Edit) ([]Edit, error) {
- edits, _, err := validate(src, edits)
- if err != nil {
- return nil, err
- }
-
- // Do all deletions begin and end at the start of a line,
- // and all insertions end with a newline?
- // (This is merely a fast path.)
- for _, edit := range edits {
- if edit.Start >= len(src) || // insertion at EOF
- edit.Start > 0 && src[edit.Start-1] != '\n' || // not at line start
- edit.End > 0 && src[edit.End-1] != '\n' || // not at line start
- edit.New != "" && edit.New[len(edit.New)-1] != '\n' { // partial insert
- goto expand // slow path
- }
- }
- return edits, nil // aligned
-
-expand:
- if len(edits) == 0 {
- return edits, nil // no edits (unreachable due to fast path)
- }
- expanded := make([]Edit, 0, len(edits)) // a guess
- prev := edits[0]
- // TODO(adonovan): opt: start from the first misaligned edit.
- // TODO(adonovan): opt: avoid quadratic cost of string += string.
- for _, edit := range edits[1:] {
- between := src[prev.End:edit.Start]
- if !strings.Contains(between, "\n") {
- // overlapping lines: combine with previous edit.
- prev.New += between + edit.New
- prev.End = edit.End
- } else {
- // non-overlapping lines: flush previous edit.
- expanded = append(expanded, expandEdit(prev, src))
- prev = edit
- }
- }
- return append(expanded, expandEdit(prev, src)), nil // flush final edit
-}
-
-// expandEdit returns edit expanded to complete whole lines.
-func expandEdit(edit Edit, src string) Edit {
- // Expand start left to start of line.
- // (delta is the zero-based column number of start.)
- start := edit.Start
- if delta := start - 1 - strings.LastIndex(src[:start], "\n"); delta > 0 {
- edit.Start -= delta
- edit.New = src[start-delta:start] + edit.New
- }
-
- // Expand end right to end of line.
- end := edit.End
- if end > 0 && src[end-1] != '\n' ||
- edit.New != "" && edit.New[len(edit.New)-1] != '\n' {
- if nl := strings.IndexByte(src[end:], '\n'); nl < 0 {
- edit.End = len(src) // extend to EOF
- } else {
- edit.End = end + nl + 1 // extend beyond \n
- }
- }
- edit.New += src[end:edit.End]
-
- return edit
-}
diff --git a/vendor/github.com/golangci/golangci-lint/internal/x/tools/diff/lcs/common.go b/vendor/github.com/golangci/golangci-lint/internal/x/tools/diff/lcs/common.go
deleted file mode 100644
index c3e82dd268..0000000000
--- a/vendor/github.com/golangci/golangci-lint/internal/x/tools/diff/lcs/common.go
+++ /dev/null
@@ -1,179 +0,0 @@
-// Copyright 2022 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package lcs
-
-import (
- "log"
- "sort"
-)
-
-// lcs is a longest common sequence
-type lcs []diag
-
-// A diag is a piece of the edit graph where A[X+i] == B[Y+i], for 0<=i l[j].Len
- })
- return l
-}
-
-// validate that the elements of the lcs do not overlap
-// (can only happen when the two-sided algorithm ends early)
-// expects the lcs to be sorted
-func (l lcs) valid() bool {
- for i := 1; i < len(l); i++ {
- if l[i-1].X+l[i-1].Len > l[i].X {
- return false
- }
- if l[i-1].Y+l[i-1].Len > l[i].Y {
- return false
- }
- }
- return true
-}
-
-// repair overlapping lcs
-// only called if two-sided stops early
-func (l lcs) fix() lcs {
- // from the set of diagonals in l, find a maximal non-conflicting set
- // this problem may be NP-complete, but we use a greedy heuristic,
- // which is quadratic, but with a better data structure, could be D log D.
- // indepedent is not enough: {0,3,1} and {3,0,2} can't both occur in an lcs
- // which has to have monotone x and y
- if len(l) == 0 {
- return nil
- }
- sort.Slice(l, func(i, j int) bool { return l[i].Len > l[j].Len })
- tmp := make(lcs, 0, len(l))
- tmp = append(tmp, l[0])
- for i := 1; i < len(l); i++ {
- var dir direction
- nxt := l[i]
- for _, in := range tmp {
- if dir, nxt = overlap(in, nxt); dir == empty || dir == bad {
- break
- }
- }
- if nxt.Len > 0 && dir != bad {
- tmp = append(tmp, nxt)
- }
- }
- tmp.sort()
- if false && !tmp.valid() { // debug checking
- log.Fatalf("here %d", len(tmp))
- }
- return tmp
-}
-
-type direction int
-
-const (
- empty direction = iota // diag is empty (so not in lcs)
- leftdown // proposed acceptably to the left and below
- rightup // proposed diag is acceptably to the right and above
- bad // proposed diag is inconsistent with the lcs so far
-)
-
-// overlap trims the proposed diag prop so it doesn't overlap with
-// the existing diag that has already been added to the lcs.
-func overlap(exist, prop diag) (direction, diag) {
- if prop.X <= exist.X && exist.X < prop.X+prop.Len {
- // remove the end of prop where it overlaps with the X end of exist
- delta := prop.X + prop.Len - exist.X
- prop.Len -= delta
- if prop.Len <= 0 {
- return empty, prop
- }
- }
- if exist.X <= prop.X && prop.X < exist.X+exist.Len {
- // remove the beginning of prop where overlaps with exist
- delta := exist.X + exist.Len - prop.X
- prop.Len -= delta
- if prop.Len <= 0 {
- return empty, prop
- }
- prop.X += delta
- prop.Y += delta
- }
- if prop.Y <= exist.Y && exist.Y < prop.Y+prop.Len {
- // remove the end of prop that overlaps (in Y) with exist
- delta := prop.Y + prop.Len - exist.Y
- prop.Len -= delta
- if prop.Len <= 0 {
- return empty, prop
- }
- }
- if exist.Y <= prop.Y && prop.Y < exist.Y+exist.Len {
- // remove the beginning of peop that overlaps with exist
- delta := exist.Y + exist.Len - prop.Y
- prop.Len -= delta
- if prop.Len <= 0 {
- return empty, prop
- }
- prop.X += delta // no test reaches this code
- prop.Y += delta
- }
- if prop.X+prop.Len <= exist.X && prop.Y+prop.Len <= exist.Y {
- return leftdown, prop
- }
- if exist.X+exist.Len <= prop.X && exist.Y+exist.Len <= prop.Y {
- return rightup, prop
- }
- // prop can't be in an lcs that contains exist
- return bad, prop
-}
-
-// manipulating Diag and lcs
-
-// prepend a diagonal (x,y)-(x+1,y+1) segment either to an empty lcs
-// or to its first Diag. prepend is only called to extend diagonals
-// the backward direction.
-func (lcs lcs) prepend(x, y int) lcs {
- if len(lcs) > 0 {
- d := &lcs[0]
- if int(d.X) == x+1 && int(d.Y) == y+1 {
- // extend the diagonal down and to the left
- d.X, d.Y = int(x), int(y)
- d.Len++
- return lcs
- }
- }
-
- r := diag{X: int(x), Y: int(y), Len: 1}
- lcs = append([]diag{r}, lcs...)
- return lcs
-}
-
-// append appends a diagonal, or extends the existing one.
-// by adding the edge (x,y)-(x+1.y+1). append is only called
-// to extend diagonals in the forward direction.
-func (lcs lcs) append(x, y int) lcs {
- if len(lcs) > 0 {
- last := &lcs[len(lcs)-1]
- // Expand last element if adjoining.
- if last.X+last.Len == x && last.Y+last.Len == y {
- last.Len++
- return lcs
- }
- }
-
- return append(lcs, diag{X: x, Y: y, Len: 1})
-}
-
-// enforce constraint on d, k
-func ok(d, k int) bool {
- return d >= 0 && -d <= k && k <= d
-}
diff --git a/vendor/github.com/golangci/golangci-lint/internal/x/tools/diff/lcs/doc.go b/vendor/github.com/golangci/golangci-lint/internal/x/tools/diff/lcs/doc.go
deleted file mode 100644
index 9029dd20b3..0000000000
--- a/vendor/github.com/golangci/golangci-lint/internal/x/tools/diff/lcs/doc.go
+++ /dev/null
@@ -1,156 +0,0 @@
-// Copyright 2022 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// package lcs contains code to find longest-common-subsequences
-// (and diffs)
-package lcs
-
-/*
-Compute longest-common-subsequences of two slices A, B using
-algorithms from Myers' paper. A longest-common-subsequence
-(LCS from now on) of A and B is a maximal set of lexically increasing
-pairs of subscripts (x,y) with A[x]==B[y]. There may be many LCS, but
-they all have the same length. An LCS determines a sequence of edits
-that changes A into B.
-
-The key concept is the edit graph of A and B.
-If A has length N and B has length M, then the edit graph has
-vertices v[i][j] for 0 <= i <= N, 0 <= j <= M. There is a
-horizontal edge from v[i][j] to v[i+1][j] whenever both are in
-the graph, and a vertical edge from v[i][j] to f[i][j+1] similarly.
-When A[i] == B[j] there is a diagonal edge from v[i][j] to v[i+1][j+1].
-
-A path between in the graph between (0,0) and (N,M) determines a sequence
-of edits converting A into B: each horizontal edge corresponds to removing
-an element of A, and each vertical edge corresponds to inserting an
-element of B.
-
-A vertex (x,y) is on (forward) diagonal k if x-y=k. A path in the graph
-is of length D if it has D non-diagonal edges. The algorithms generate
-forward paths (in which at least one of x,y increases at each edge),
-or backward paths (in which at least one of x,y decreases at each edge),
-or a combination. (Note that the orientation is the traditional mathematical one,
-with the origin in the lower-left corner.)
-
-Here is the edit graph for A:"aabbaa", B:"aacaba". (I know the diagonals look weird.)
- ⊙ ------- ⊙ ------- ⊙ ------- ⊙ ------- ⊙ ------- ⊙ ------- ⊙
- a | ___/‾‾‾ | ___/‾‾‾ | | | ___/‾‾‾ | ___/‾‾‾ |
- ⊙ ------- ⊙ ------- ⊙ ------- ⊙ ------- ⊙ ------- ⊙ ------- ⊙
- b | | | ___/‾‾‾ | ___/‾‾‾ | | |
- ⊙ ------- ⊙ ------- ⊙ ------- ⊙ ------- ⊙ ------- ⊙ ------- ⊙
- a | ___/‾‾‾ | ___/‾‾‾ | | | ___/‾‾‾ | ___/‾‾‾ |
- ⊙ ------- ⊙ ------- ⊙ ------- ⊙ ------- ⊙ ------- ⊙ ------- ⊙
- c | | | | | | |
- ⊙ ------- ⊙ ------- ⊙ ------- ⊙ ------- ⊙ ------- ⊙ ------- ⊙
- a | ___/‾‾‾ | ___/‾‾‾ | | | ___/‾‾‾ | ___/‾‾‾ |
- ⊙ ------- ⊙ ------- ⊙ ------- ⊙ ------- ⊙ ------- ⊙ ------- ⊙
- a | ___/‾‾‾ | ___/‾‾‾ | | | ___/‾‾‾ | ___/‾‾‾ |
- ⊙ ------- ⊙ ------- ⊙ ------- ⊙ ------- ⊙ ------- ⊙ ------- ⊙
- a a b b a a
-
-
-The algorithm labels a vertex (x,y) with D,k if it is on diagonal k and at
-the end of a maximal path of length D. (Because x-y=k it suffices to remember
-only the x coordinate of the vertex.)
-
-The forward algorithm: Find the longest diagonal starting at (0,0) and
-label its end with D=0,k=0. From that vertex take a vertical step and
-then follow the longest diagonal (up and to the right), and label that vertex
-with D=1,k=-1. From the D=0,k=0 point take a horizontal step and the follow
-the longest diagonal (up and to the right) and label that vertex
-D=1,k=1. In the same way, having labelled all the D vertices,
-from a vertex labelled D,k find two vertices
-tentatively labelled D+1,k-1 and D+1,k+1. There may be two on the same
-diagonal, in which case take the one with the larger x.
-
-Eventually the path gets to (N,M), and the diagonals on it are the LCS.
-
-Here is the edit graph with the ends of D-paths labelled. (So, for instance,
-0/2,2 indicates that x=2,y=2 is labelled with 0, as it should be, since the first
-step is to go up the longest diagonal from (0,0).)
-A:"aabbaa", B:"aacaba"
- ⊙ ------- ⊙ ------- ⊙ -------(3/3,6)------- ⊙ -------(3/5,6)-------(4/6,6)
- a | ___/‾‾‾ | ___/‾‾‾ | | | ___/‾‾‾ | ___/‾‾‾ |
- ⊙ ------- ⊙ ------- ⊙ -------(2/3,5)------- ⊙ ------- ⊙ ------- ⊙
- b | | | ___/‾‾‾ | ___/‾‾‾ | | |
- ⊙ ------- ⊙ ------- ⊙ ------- ⊙ ------- ⊙ -------(3/5,4)------- ⊙
- a | ___/‾‾‾ | ___/‾‾‾ | | | ___/‾‾‾ | ___/‾‾‾ |
- ⊙ ------- ⊙ -------(1/2,3)-------(2/3,3)------- ⊙ ------- ⊙ ------- ⊙
- c | | | | | | |
- ⊙ ------- ⊙ -------(0/2,2)-------(1/3,2)-------(2/4,2)-------(3/5,2)-------(4/6,2)
- a | ___/‾‾‾ | ___/‾‾‾ | | | ___/‾‾‾ | ___/‾‾‾ |
- ⊙ ------- ⊙ ------- ⊙ ------- ⊙ ------- ⊙ ------- ⊙ ------- ⊙
- a | ___/‾‾‾ | ___/‾‾‾ | | | ___/‾‾‾ | ___/‾‾‾ |
- ⊙ ------- ⊙ ------- ⊙ ------- ⊙ ------- ⊙ ------- ⊙ ------- ⊙
- a a b b a a
-
-The 4-path is reconstructed starting at (4/6,6), horizontal to (3/5,6), diagonal to (3,4), vertical
-to (2/3,3), horizontal to (1/2,3), vertical to (0/2,2), and diagonal to (0,0). As expected,
-there are 4 non-diagonal steps, and the diagonals form an LCS.
-
-There is a symmetric backward algorithm, which gives (backwards labels are prefixed with a colon):
-A:"aabbaa", B:"aacaba"
- ⊙ -------- ⊙ -------- ⊙ -------- ⊙ -------- ⊙ -------- ⊙ -------- ⊙
- a | ____/‾‾‾ | ____/‾‾‾ | | | ____/‾‾‾ | ____/‾‾‾ |
- ⊙ -------- ⊙ -------- ⊙ -------- ⊙ -------- ⊙ --------(:0/5,5)-------- ⊙
- b | | | ____/‾‾‾ | ____/‾‾‾ | | |
- ⊙ -------- ⊙ -------- ⊙ --------(:1/3,4)-------- ⊙ -------- ⊙ -------- ⊙
- a | ____/‾‾‾ | ____/‾‾‾ | | | ____/‾‾‾ | ____/‾‾‾ |
- (:3/0,3)--------(:2/1,3)-------- ⊙ --------(:2/3,3)--------(:1/4,3)-------- ⊙ -------- ⊙
- c | | | | | | |
- ⊙ -------- ⊙ -------- ⊙ --------(:3/3,2)--------(:2/4,2)-------- ⊙ -------- ⊙
- a | ____/‾‾‾ | ____/‾‾‾ | | | ____/‾‾‾ | ____/‾‾‾ |
- (:3/0,1)-------- ⊙ -------- ⊙ -------- ⊙ --------(:3/4,1)-------- ⊙ -------- ⊙
- a | ____/‾‾‾ | ____/‾‾‾ | | | ____/‾‾‾ | ____/‾‾‾ |
- (:4/0,0)-------- ⊙ -------- ⊙ -------- ⊙ --------(:4/4,0)-------- ⊙ -------- ⊙
- a a b b a a
-
-Neither of these is ideal for use in an editor, where it is undesirable to send very long diffs to the
-front end. It's tricky to decide exactly what 'very long diffs' means, as "replace A by B" is very short.
-We want to control how big D can be, by stopping when it gets too large. The forward algorithm then
-privileges common prefixes, and the backward algorithm privileges common suffixes. Either is an undesirable
-asymmetry.
-
-Fortunately there is a two-sided algorithm, implied by results in Myers' paper. Here's what the labels in
-the edit graph look like.
-A:"aabbaa", B:"aacaba"
- ⊙ --------- ⊙ --------- ⊙ --------- ⊙ --------- ⊙ --------- ⊙ --------- ⊙
- a | ____/‾‾‾‾ | ____/‾‾‾‾ | | | ____/‾‾‾‾ | ____/‾‾‾‾ |
- ⊙ --------- ⊙ --------- ⊙ --------- (2/3,5) --------- ⊙ --------- (:0/5,5)--------- ⊙
- b | | | ____/‾‾‾‾ | ____/‾‾‾‾ | | |
- ⊙ --------- ⊙ --------- ⊙ --------- (:1/3,4)--------- ⊙ --------- ⊙ --------- ⊙
- a | ____/‾‾‾‾ | ____/‾‾‾‾ | | | ____/‾‾‾‾ | ____/‾‾‾‾ |
- ⊙ --------- (:2/1,3)--------- (1/2,3) ---------(2:2/3,3)--------- (:1/4,3)--------- ⊙ --------- ⊙
- c | | | | | | |
- ⊙ --------- ⊙ --------- (0/2,2) --------- (1/3,2) ---------(2:2/4,2)--------- ⊙ --------- ⊙
- a | ____/‾‾‾‾ | ____/‾‾‾‾ | | | ____/‾‾‾‾ | ____/‾‾‾‾ |
- ⊙ --------- ⊙ --------- ⊙ --------- ⊙ --------- ⊙ --------- ⊙ --------- ⊙
- a | ____/‾‾‾‾ | ____/‾‾‾‾ | | | ____/‾‾‾‾ | ____/‾‾‾‾ |
- ⊙ --------- ⊙ --------- ⊙ --------- ⊙ --------- ⊙ --------- ⊙ --------- ⊙
- a a b b a a
-
-The algorithm stopped when it saw the backwards 2-path ending at (1,3) and the forwards 2-path ending at (3,5). The criterion
-is a backwards path ending at (u,v) and a forward path ending at (x,y), where u <= x and the two points are on the same
-diagonal. (Here the edgegraph has a diagonal, but the criterion is x-y=u-v.) Myers proves there is a forward
-2-path from (0,0) to (1,3), and that together with the backwards 2-path ending at (1,3) gives the expected 4-path.
-Unfortunately the forward path has to be constructed by another run of the forward algorithm; it can't be found from the
-computed labels. That is the worst case. Had the code noticed (x,y)=(u,v)=(3,3) the whole path could be reconstructed
-from the edgegraph. The implementation looks for a number of special cases to try to avoid computing an extra forward path.
-
-If the two-sided algorithm has stop early (because D has become too large) it will have found a forward LCS and a
-backwards LCS. Ideally these go with disjoint prefixes and suffixes of A and B, but disjointness may fail and the two
-computed LCS may conflict. (An easy example is where A is a suffix of B, and shares a short prefix. The backwards LCS
-is all of A, and the forward LCS is a prefix of A.) The algorithm combines the two
-to form a best-effort LCS. In the worst case the forward partial LCS may have to
-be recomputed.
-*/
-
-/* Eugene Myers paper is titled
-"An O(ND) Difference Algorithm and Its Variations"
-and can be found at
-http://www.xmailserver.org/diff2.pdf
-
-(There is a generic implementation of the algorithm the repository with git hash
-b9ad7e4ade3a686d608e44475390ad428e60e7fc)
-*/
diff --git a/vendor/github.com/golangci/golangci-lint/internal/x/tools/diff/lcs/sequence.go b/vendor/github.com/golangci/golangci-lint/internal/x/tools/diff/lcs/sequence.go
deleted file mode 100644
index 2d72d26304..0000000000
--- a/vendor/github.com/golangci/golangci-lint/internal/x/tools/diff/lcs/sequence.go
+++ /dev/null
@@ -1,113 +0,0 @@
-// Copyright 2022 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package lcs
-
-// This file defines the abstract sequence over which the LCS algorithm operates.
-
-// sequences abstracts a pair of sequences, A and B.
-type sequences interface {
- lengths() (int, int) // len(A), len(B)
- commonPrefixLen(ai, aj, bi, bj int) int // len(commonPrefix(A[ai:aj], B[bi:bj]))
- commonSuffixLen(ai, aj, bi, bj int) int // len(commonSuffix(A[ai:aj], B[bi:bj]))
-}
-
-type stringSeqs struct{ a, b string }
-
-func (s stringSeqs) lengths() (int, int) { return len(s.a), len(s.b) }
-func (s stringSeqs) commonPrefixLen(ai, aj, bi, bj int) int {
- return commonPrefixLenString(s.a[ai:aj], s.b[bi:bj])
-}
-func (s stringSeqs) commonSuffixLen(ai, aj, bi, bj int) int {
- return commonSuffixLenString(s.a[ai:aj], s.b[bi:bj])
-}
-
-// The explicit capacity in s[i:j:j] leads to more efficient code.
-
-type bytesSeqs struct{ a, b []byte }
-
-func (s bytesSeqs) lengths() (int, int) { return len(s.a), len(s.b) }
-func (s bytesSeqs) commonPrefixLen(ai, aj, bi, bj int) int {
- return commonPrefixLenBytes(s.a[ai:aj:aj], s.b[bi:bj:bj])
-}
-func (s bytesSeqs) commonSuffixLen(ai, aj, bi, bj int) int {
- return commonSuffixLenBytes(s.a[ai:aj:aj], s.b[bi:bj:bj])
-}
-
-type runesSeqs struct{ a, b []rune }
-
-func (s runesSeqs) lengths() (int, int) { return len(s.a), len(s.b) }
-func (s runesSeqs) commonPrefixLen(ai, aj, bi, bj int) int {
- return commonPrefixLenRunes(s.a[ai:aj:aj], s.b[bi:bj:bj])
-}
-func (s runesSeqs) commonSuffixLen(ai, aj, bi, bj int) int {
- return commonSuffixLenRunes(s.a[ai:aj:aj], s.b[bi:bj:bj])
-}
-
-// TODO(adonovan): optimize these functions using ideas from:
-// - https://go.dev/cl/408116 common.go
-// - https://go.dev/cl/421435 xor_generic.go
-
-// TODO(adonovan): factor using generics when available,
-// but measure performance impact.
-
-// commonPrefixLen* returns the length of the common prefix of a[ai:aj] and b[bi:bj].
-func commonPrefixLenBytes(a, b []byte) int {
- n := min(len(a), len(b))
- i := 0
- for i < n && a[i] == b[i] {
- i++
- }
- return i
-}
-func commonPrefixLenRunes(a, b []rune) int {
- n := min(len(a), len(b))
- i := 0
- for i < n && a[i] == b[i] {
- i++
- }
- return i
-}
-func commonPrefixLenString(a, b string) int {
- n := min(len(a), len(b))
- i := 0
- for i < n && a[i] == b[i] {
- i++
- }
- return i
-}
-
-// commonSuffixLen* returns the length of the common suffix of a[ai:aj] and b[bi:bj].
-func commonSuffixLenBytes(a, b []byte) int {
- n := min(len(a), len(b))
- i := 0
- for i < n && a[len(a)-1-i] == b[len(b)-1-i] {
- i++
- }
- return i
-}
-func commonSuffixLenRunes(a, b []rune) int {
- n := min(len(a), len(b))
- i := 0
- for i < n && a[len(a)-1-i] == b[len(b)-1-i] {
- i++
- }
- return i
-}
-func commonSuffixLenString(a, b string) int {
- n := min(len(a), len(b))
- i := 0
- for i < n && a[len(a)-1-i] == b[len(b)-1-i] {
- i++
- }
- return i
-}
-
-func min(x, y int) int {
- if x < y {
- return x
- } else {
- return y
- }
-}
diff --git a/vendor/github.com/golangci/golangci-lint/internal/x/tools/diff/readme.md b/vendor/github.com/golangci/golangci-lint/internal/x/tools/diff/readme.md
deleted file mode 100644
index 4b97984989..0000000000
--- a/vendor/github.com/golangci/golangci-lint/internal/x/tools/diff/readme.md
+++ /dev/null
@@ -1,8 +0,0 @@
-# diff
-
-Extracted from `/internal/diff/` (related to `fixer`).
-This is just a copy of the code without any changes.
-
-## History
-
-- sync with https://github.com/golang/tools/blob/v0.28.0
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/commands/cache.go b/vendor/github.com/golangci/golangci-lint/pkg/commands/cache.go
deleted file mode 100644
index 4f2c812dce..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/commands/cache.go
+++ /dev/null
@@ -1,83 +0,0 @@
-package commands
-
-import (
- "fmt"
- "os"
- "path/filepath"
-
- "github.com/spf13/cobra"
-
- "github.com/golangci/golangci-lint/internal/cache"
- "github.com/golangci/golangci-lint/pkg/fsutils"
- "github.com/golangci/golangci-lint/pkg/logutils"
-)
-
-type cacheCommand struct {
- cmd *cobra.Command
-}
-
-func newCacheCommand() *cacheCommand {
- c := &cacheCommand{}
-
- cacheCmd := &cobra.Command{
- Use: "cache",
- Short: "Cache control and information",
- Args: cobra.NoArgs,
- RunE: func(cmd *cobra.Command, _ []string) error {
- return cmd.Help()
- },
- }
-
- cacheCmd.AddCommand(
- &cobra.Command{
- Use: "clean",
- Short: "Clean cache",
- Args: cobra.NoArgs,
- ValidArgsFunction: cobra.NoFileCompletions,
- RunE: c.executeClean,
- },
- &cobra.Command{
- Use: "status",
- Short: "Show cache status",
- Args: cobra.NoArgs,
- ValidArgsFunction: cobra.NoFileCompletions,
- Run: c.executeStatus,
- },
- )
-
- c.cmd = cacheCmd
-
- return c
-}
-
-func (*cacheCommand) executeClean(_ *cobra.Command, _ []string) error {
- cacheDir := cache.DefaultDir()
-
- if err := os.RemoveAll(cacheDir); err != nil {
- return fmt.Errorf("failed to remove dir %s: %w", cacheDir, err)
- }
-
- return nil
-}
-
-func (*cacheCommand) executeStatus(_ *cobra.Command, _ []string) {
- cacheDir := cache.DefaultDir()
-
- _, _ = fmt.Fprintf(logutils.StdOut, "Dir: %s\n", cacheDir)
-
- cacheSizeBytes, err := dirSizeBytes(cacheDir)
- if err == nil {
- _, _ = fmt.Fprintf(logutils.StdOut, "Size: %s\n", fsutils.PrettifyBytesCount(cacheSizeBytes))
- }
-}
-
-func dirSizeBytes(path string) (int64, error) {
- var size int64
- err := filepath.Walk(path, func(_ string, info os.FileInfo, err error) error {
- if err == nil && !info.IsDir() {
- size += info.Size()
- }
- return err
- })
- return size, err
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/commands/config.go b/vendor/github.com/golangci/golangci-lint/pkg/commands/config.go
deleted file mode 100644
index 935ec5e864..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/commands/config.go
+++ /dev/null
@@ -1,122 +0,0 @@
-package commands
-
-import (
- "fmt"
- "os"
-
- "github.com/fatih/color"
- "github.com/spf13/cobra"
- "github.com/spf13/viper"
-
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/exitcodes"
- "github.com/golangci/golangci-lint/pkg/fsutils"
- "github.com/golangci/golangci-lint/pkg/logutils"
-)
-
-type configCommand struct {
- viper *viper.Viper
- cmd *cobra.Command
-
- opts config.LoaderOptions
- verifyOpts verifyOptions
-
- buildInfo BuildInfo
-
- log logutils.Log
-}
-
-func newConfigCommand(log logutils.Log, info BuildInfo) *configCommand {
- c := &configCommand{
- viper: viper.New(),
- log: log,
- buildInfo: info,
- }
-
- configCmd := &cobra.Command{
- Use: "config",
- Short: "Config file information",
- Args: cobra.NoArgs,
- RunE: func(cmd *cobra.Command, _ []string) error {
- return cmd.Help()
- },
- PersistentPreRunE: c.preRunE,
- }
-
- verifyCommand := &cobra.Command{
- Use: "verify",
- Short: "Verify configuration against JSON schema",
- Args: cobra.NoArgs,
- ValidArgsFunction: cobra.NoFileCompletions,
- RunE: c.executeVerify,
- SilenceUsage: true,
- SilenceErrors: true,
- }
-
- configCmd.AddCommand(
- &cobra.Command{
- Use: "path",
- Short: "Print used config path",
- Args: cobra.NoArgs,
- ValidArgsFunction: cobra.NoFileCompletions,
- Run: c.executePath,
- },
- verifyCommand,
- )
-
- flagSet := configCmd.PersistentFlags()
- flagSet.SortFlags = false // sort them as they are defined here
-
- setupConfigFileFlagSet(flagSet, &c.opts)
-
- // ex: --schema jsonschema/golangci.next.jsonschema.json
- verifyFlagSet := verifyCommand.Flags()
- verifyFlagSet.StringVar(&c.verifyOpts.schemaURL, "schema", "", color.GreenString("JSON schema URL"))
- _ = verifyFlagSet.MarkHidden("schema")
-
- c.cmd = configCmd
-
- return c
-}
-
-func (c *configCommand) preRunE(cmd *cobra.Command, args []string) error {
- // The command doesn't depend on the real configuration.
- // It only needs to know the path of the configuration file.
- cfg := config.NewDefault()
-
- loader := config.NewLoader(c.log.Child(logutils.DebugKeyConfigReader), c.viper, cmd.Flags(), c.opts, cfg, args)
-
- err := loader.Load(config.LoadOptions{})
- if err != nil {
- return fmt.Errorf("can't load config: %w", err)
- }
-
- return nil
-}
-
-func (c *configCommand) executePath(cmd *cobra.Command, _ []string) {
- usedConfigFile := c.getUsedConfig()
- if usedConfigFile == "" {
- c.log.Warnf("No config file detected")
- os.Exit(exitcodes.NoConfigFileDetected)
- }
-
- cmd.Println(usedConfigFile)
-}
-
-// getUsedConfig returns the resolved path to the golangci config file,
-// or the empty string if no configuration could be found.
-func (c *configCommand) getUsedConfig() string {
- usedConfigFile := c.viper.ConfigFileUsed()
- if usedConfigFile == "" {
- return ""
- }
-
- prettyUsedConfigFile, err := fsutils.ShortestRelPath(usedConfigFile, "")
- if err != nil {
- c.log.Warnf("Can't pretty print config file path: %s", err)
- return usedConfigFile
- }
-
- return prettyUsedConfigFile
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/commands/config_verify.go b/vendor/github.com/golangci/golangci-lint/pkg/commands/config_verify.go
deleted file mode 100644
index 76e09581ca..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/commands/config_verify.go
+++ /dev/null
@@ -1,239 +0,0 @@
-package commands
-
-import (
- "context"
- "encoding/json"
- "errors"
- "fmt"
- "net/http"
- "os"
- "path/filepath"
- "strconv"
- "strings"
- "time"
-
- hcversion "github.com/hashicorp/go-version"
- "github.com/pelletier/go-toml/v2"
- "github.com/santhosh-tekuri/jsonschema/v6"
- "github.com/spf13/cobra"
- "github.com/spf13/pflag"
- "gopkg.in/yaml.v3"
-
- "github.com/golangci/golangci-lint/pkg/exitcodes"
-)
-
-type verifyOptions struct {
- schemaURL string // For debugging purpose only (Flag only).
-}
-
-func (c *configCommand) executeVerify(cmd *cobra.Command, _ []string) error {
- usedConfigFile := c.getUsedConfig()
- if usedConfigFile == "" {
- c.log.Warnf("No config file detected")
- os.Exit(exitcodes.NoConfigFileDetected)
- }
-
- schemaURL, err := createSchemaURL(cmd.Flags(), c.buildInfo)
- if err != nil {
- return fmt.Errorf("get JSON schema: %w", err)
- }
-
- err = validateConfiguration(schemaURL, usedConfigFile)
- if err != nil {
- var v *jsonschema.ValidationError
- if !errors.As(err, &v) {
- return fmt.Errorf("[%s] validate: %w", usedConfigFile, err)
- }
-
- printValidationDetail(cmd, v.DetailedOutput())
-
- return errors.New("the configuration contains invalid elements")
- }
-
- return nil
-}
-
-func createSchemaURL(flags *pflag.FlagSet, buildInfo BuildInfo) (string, error) {
- schemaURL, err := flags.GetString("schema")
- if err != nil {
- return "", fmt.Errorf("get schema flag: %w", err)
- }
-
- if schemaURL != "" {
- return schemaURL, nil
- }
-
- switch {
- case buildInfo.Version != "" && buildInfo.Version != "(devel)":
- version, err := hcversion.NewVersion(buildInfo.Version)
- if err != nil {
- return "", fmt.Errorf("parse version: %w", err)
- }
-
- if version.Core().Equal(hcversion.Must(hcversion.NewVersion("v0.0.0"))) {
- commit, err := extractCommitHash(buildInfo)
- if err != nil {
- return "", err
- }
-
- return fmt.Sprintf("https://raw.githubusercontent.com/golangci/golangci-lint/%s/jsonschema/golangci.next.jsonschema.json",
- commit), nil
- }
-
- return fmt.Sprintf("https://golangci-lint.run/jsonschema/golangci.v%d.%d.jsonschema.json",
- version.Segments()[0], version.Segments()[1]), nil
-
- case buildInfo.Commit != "" && buildInfo.Commit != "?":
- commit, err := extractCommitHash(buildInfo)
- if err != nil {
- return "", err
- }
-
- return fmt.Sprintf("https://raw.githubusercontent.com/golangci/golangci-lint/%s/jsonschema/golangci.next.jsonschema.json",
- commit), nil
-
- default:
- return "", errors.New("version not found")
- }
-}
-
-func extractCommitHash(buildInfo BuildInfo) (string, error) {
- if buildInfo.Commit == "" || buildInfo.Commit == "?" {
- return "", errors.New("empty commit information")
- }
-
- if buildInfo.Commit == "unknown" {
- return "", errors.New("unknown commit information")
- }
-
- commit := buildInfo.Commit
-
- if strings.HasPrefix(commit, "(") {
- c, _, ok := strings.Cut(strings.TrimPrefix(commit, "("), ",")
- if !ok {
- return "", errors.New("commit information not found")
- }
-
- commit = c
- }
-
- if commit == "unknown" {
- return "", errors.New("unknown commit information")
- }
-
- return commit, nil
-}
-
-func validateConfiguration(schemaPath, targetFile string) error {
- compiler := jsonschema.NewCompiler()
- compiler.UseLoader(jsonschema.SchemeURLLoader{
- "file": jsonschema.FileLoader{},
- "https": newJSONSchemaHTTPLoader(),
- })
- compiler.DefaultDraft(jsonschema.Draft7)
-
- schema, err := compiler.Compile(schemaPath)
- if err != nil {
- return fmt.Errorf("compile schema: %w", err)
- }
-
- var m any
-
- switch strings.ToLower(filepath.Ext(targetFile)) {
- case ".yaml", ".yml", ".json":
- m, err = decodeYamlFile(targetFile)
- if err != nil {
- return err
- }
-
- case ".toml":
- m, err = decodeTomlFile(targetFile)
- if err != nil {
- return err
- }
-
- default:
- // unsupported
- return errors.New("unsupported configuration format")
- }
-
- return schema.Validate(m)
-}
-
-func printValidationDetail(cmd *cobra.Command, detail *jsonschema.OutputUnit) {
- if detail.Error != nil {
- data, _ := json.Marshal(detail.Error)
- details, _ := strconv.Unquote(string(data))
-
- cmd.PrintErrf("jsonschema: %q does not validate with %q: %s\n",
- strings.ReplaceAll(strings.TrimPrefix(detail.InstanceLocation, "/"), "/", "."), detail.KeywordLocation, details)
- }
-
- for _, d := range detail.Errors {
- printValidationDetail(cmd, &d)
- }
-}
-
-func decodeYamlFile(filename string) (any, error) {
- file, err := os.Open(filename)
- if err != nil {
- return nil, fmt.Errorf("[%s] file open: %w", filename, err)
- }
-
- defer func() { _ = file.Close() }()
-
- var m any
- err = yaml.NewDecoder(file).Decode(&m)
- if err != nil {
- return nil, fmt.Errorf("[%s] YAML decode: %w", filename, err)
- }
-
- return m, nil
-}
-
-func decodeTomlFile(filename string) (any, error) {
- file, err := os.Open(filename)
- if err != nil {
- return nil, fmt.Errorf("[%s] file open: %w", filename, err)
- }
-
- defer func() { _ = file.Close() }()
-
- var m any
- err = toml.NewDecoder(file).Decode(&m)
- if err != nil {
- return nil, fmt.Errorf("[%s] TOML decode: %w", filename, err)
- }
-
- return m, nil
-}
-
-type jsonschemaHTTPLoader struct {
- *http.Client
-}
-
-func newJSONSchemaHTTPLoader() *jsonschemaHTTPLoader {
- return &jsonschemaHTTPLoader{Client: &http.Client{
- Timeout: 2 * time.Second,
- }}
-}
-
-func (l jsonschemaHTTPLoader) Load(url string) (any, error) {
- req, err := http.NewRequestWithContext(context.Background(), http.MethodGet, url, http.NoBody)
- if err != nil {
- return nil, err
- }
-
- resp, err := l.Do(req)
- if err != nil {
- return nil, err
- }
-
- defer resp.Body.Close()
-
- if resp.StatusCode != http.StatusOK {
- return nil, fmt.Errorf("%s returned status code %d", url, resp.StatusCode)
- }
-
- return jsonschema.UnmarshalJSON(resp.Body)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/commands/custom.go b/vendor/github.com/golangci/golangci-lint/pkg/commands/custom.go
deleted file mode 100644
index 1bc9f90146..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/commands/custom.go
+++ /dev/null
@@ -1,79 +0,0 @@
-package commands
-
-import (
- "fmt"
- "log"
- "os"
-
- "github.com/spf13/cobra"
-
- "github.com/golangci/golangci-lint/pkg/commands/internal"
- "github.com/golangci/golangci-lint/pkg/logutils"
-)
-
-const envKeepTempFiles = "CUSTOM_GCL_KEEP_TEMP_FILES"
-
-type customCommand struct {
- cmd *cobra.Command
-
- cfg *internal.Configuration
-
- log logutils.Log
-}
-
-func newCustomCommand(logger logutils.Log) *customCommand {
- c := &customCommand{log: logger}
-
- customCmd := &cobra.Command{
- Use: "custom",
- Short: "Build a version of golangci-lint with custom linters",
- Args: cobra.NoArgs,
- PreRunE: c.preRunE,
- RunE: c.runE,
- SilenceUsage: true,
- }
-
- c.cmd = customCmd
-
- return c
-}
-
-func (c *customCommand) preRunE(_ *cobra.Command, _ []string) error {
- cfg, err := internal.LoadConfiguration()
- if err != nil {
- return err
- }
-
- err = cfg.Validate()
- if err != nil {
- return err
- }
-
- c.cfg = cfg
-
- return nil
-}
-
-func (c *customCommand) runE(cmd *cobra.Command, _ []string) error {
- tmp, err := os.MkdirTemp(os.TempDir(), "custom-gcl")
- if err != nil {
- return fmt.Errorf("create temporary directory: %w", err)
- }
-
- defer func() {
- if os.Getenv(envKeepTempFiles) != "" {
- log.Printf("WARN: The env var %s has been detected: the temporary directory is preserved: %s", envKeepTempFiles, tmp)
-
- return
- }
-
- _ = os.RemoveAll(tmp)
- }()
-
- err = internal.NewBuilder(c.log, c.cfg, tmp).Build(cmd.Context())
- if err != nil {
- return fmt.Errorf("build process: %w", err)
- }
-
- return nil
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/commands/flagsets.go b/vendor/github.com/golangci/golangci-lint/pkg/commands/flagsets.go
deleted file mode 100644
index d514f12718..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/commands/flagsets.go
+++ /dev/null
@@ -1,155 +0,0 @@
-package commands
-
-import (
- "fmt"
- "strings"
-
- "github.com/fatih/color"
- "github.com/spf13/pflag"
- "github.com/spf13/viper"
-
- "github.com/golangci/golangci-lint/pkg/commands/internal"
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/exitcodes"
- "github.com/golangci/golangci-lint/pkg/lint/lintersdb"
- "github.com/golangci/golangci-lint/pkg/result/processors"
-)
-
-const defaultMaxIssuesPerLinter = 50
-
-func setupLintersFlagSet(v *viper.Viper, fs *pflag.FlagSet) {
- internal.AddHackedStringSliceP(fs, "disable", "D", color.GreenString("Disable specific linter"))
- internal.AddFlagAndBind(v, fs, fs.Bool, "disable-all", "linters.disable-all", false, color.GreenString("Disable all linters"))
-
- internal.AddHackedStringSliceP(fs, "enable", "E", color.GreenString("Enable specific linter"))
- internal.AddFlagAndBind(v, fs, fs.Bool, "enable-all", "linters.enable-all", false, color.GreenString("Enable all linters"))
-
- internal.AddFlagAndBind(v, fs, fs.Bool, "fast", "linters.fast", false,
- color.GreenString("Enable only fast linters from enabled linters set (first run won't be fast)"))
-
- internal.AddHackedStringSliceP(fs, "presets", "p",
- formatList("Enable presets of linters:", lintersdb.AllPresets(),
- "Run 'golangci-lint help linters' to see them.",
- "This option implies option --disable-all",
- ),
- )
-
- fs.StringSlice("enable-only", nil,
- color.GreenString("Override linters configuration section to only run the specific linter(s)")) // Flags only.
-}
-
-func setupRunFlagSet(v *viper.Viper, fs *pflag.FlagSet) {
- internal.AddFlagAndBindP(v, fs, fs.IntP, "concurrency", "j", "run.concurrency", getDefaultConcurrency(),
- color.GreenString("Number of CPUs to use (Default: number of logical CPUs)"))
-
- internal.AddFlagAndBind(v, fs, fs.String, "modules-download-mode", "run.modules-download-mode", "",
- color.GreenString("Modules download mode. If not empty, passed as -mod= to go tools"))
- internal.AddFlagAndBind(v, fs, fs.Int, "issues-exit-code", "run.issues-exit-code", exitcodes.IssuesFound,
- color.GreenString("Exit code when issues were found"))
- internal.AddFlagAndBind(v, fs, fs.String, "go", "run.go", "", color.GreenString("Targeted Go version"))
- internal.AddHackedStringSlice(fs, "build-tags", color.GreenString("Build tags"))
-
- internal.AddFlagAndBind(v, fs, fs.Duration, "timeout", "run.timeout", defaultTimeout,
- color.GreenString("Timeout for total work. If <= 0, the timeout is disabled"))
-
- internal.AddFlagAndBind(v, fs, fs.Bool, "tests", "run.tests", true, color.GreenString("Analyze tests (*_test.go)"))
-
- internal.AddDeprecatedHackedStringSlice(fs, "skip-files", color.GreenString("Regexps of files to skip"))
- internal.AddDeprecatedHackedStringSlice(fs, "skip-dirs", color.GreenString("Regexps of directories to skip"))
-
- const allowParallelDesc = "Allow multiple parallel golangci-lint instances running.\n" +
- "If false (default) - golangci-lint acquires file lock on start."
- internal.AddFlagAndBind(v, fs, fs.Bool, "allow-parallel-runners", "run.allow-parallel-runners", false,
- color.GreenString(allowParallelDesc))
- const allowSerialDesc = "Allow multiple golangci-lint instances running, but serialize them around a lock.\n" +
- "If false (default) - golangci-lint exits with an error if it fails to acquire file lock on start."
- internal.AddFlagAndBind(v, fs, fs.Bool, "allow-serial-runners", "run.allow-serial-runners", false, color.GreenString(allowSerialDesc))
-}
-
-func setupOutputFlagSet(v *viper.Viper, fs *pflag.FlagSet) {
- internal.AddFlagAndBind(v, fs, fs.String, "out-format", "output.formats", config.OutFormatColoredLineNumber,
- formatList("Formats of output:", config.AllOutputFormats))
- internal.AddFlagAndBind(v, fs, fs.Bool, "print-issued-lines", "output.print-issued-lines", true,
- color.GreenString("Print lines of code with issue"))
- internal.AddFlagAndBind(v, fs, fs.Bool, "print-linter-name", "output.print-linter-name", true,
- color.GreenString("Print linter name in issue line"))
- internal.AddFlagAndBind(v, fs, fs.Bool, "sort-results", "output.sort-results", false,
- color.GreenString("Sort linter results"))
- internal.AddFlagAndBind(v, fs, fs.StringSlice, "sort-order", "output.sort-order", nil,
- color.GreenString("Sort order of linter results"))
- internal.AddFlagAndBind(v, fs, fs.String, "path-prefix", "output.path-prefix", "",
- color.GreenString("Path prefix to add to output"))
- internal.AddFlagAndBind(v, fs, fs.Bool, "show-stats", "output.show-stats", false, color.GreenString("Show statistics per linter"))
-}
-
-//nolint:gomnd // magic numbers here is ok
-func setupIssuesFlagSet(v *viper.Viper, fs *pflag.FlagSet) {
- internal.AddHackedStringSliceP(fs, "exclude", "e", color.GreenString("Exclude issue by regexp"))
- internal.AddFlagAndBind(v, fs, fs.Bool, "exclude-use-default", "issues.exclude-use-default", true,
- getDefaultIssueExcludeHelp())
- internal.AddFlagAndBind(v, fs, fs.Bool, "exclude-case-sensitive", "issues.exclude-case-sensitive", false,
- color.GreenString("If set to true exclude and exclude rules regular expressions are case-sensitive"))
-
- internal.AddFlagAndBind(v, fs, fs.Int, "max-issues-per-linter", "issues.max-issues-per-linter", defaultMaxIssuesPerLinter,
- color.GreenString("Maximum issues count per one linter. Set to 0 to disable"))
- internal.AddFlagAndBind(v, fs, fs.Int, "max-same-issues", "issues.max-same-issues", 3,
- color.GreenString("Maximum count of issues with the same text. Set to 0 to disable"))
- internal.AddFlagAndBind(v, fs, fs.Bool, "uniq-by-line", "issues.uniq-by-line", true,
- color.GreenString("Make issues output unique by line"))
-
- internal.AddHackedStringSlice(fs, "exclude-files", color.GreenString("Regexps of files to exclude"))
- internal.AddHackedStringSlice(fs, "exclude-dirs", color.GreenString("Regexps of directories to exclude"))
- internal.AddFlagAndBind(v, fs, fs.Bool, "exclude-dirs-use-default", "issues.exclude-dirs-use-default", true,
- formatList("Use or not use default excluded directories:", processors.StdExcludeDirRegexps))
-
- internal.AddFlagAndBind(v, fs, fs.String, "exclude-generated", "issues.exclude-generated", processors.AutogeneratedModeLax,
- color.GreenString("Mode of the generated files analysis"))
-
- const newDesc = "Show only new issues: if there are unstaged changes or untracked files, only those changes " +
- "are analyzed, else only changes in HEAD~ are analyzed.\nIt's a super-useful option for integration " +
- "of golangci-lint into existing large codebase.\nIt's not practical to fix all existing issues at " +
- "the moment of integration: much better to not allow issues in new code.\nFor CI setups, prefer " +
- "--new-from-rev=HEAD~, as --new can skip linting the current patch if any scripts generate " +
- "unstaged files before golangci-lint runs."
- internal.AddFlagAndBindP(v, fs, fs.BoolP, "new", "n", "issues.new", false, color.GreenString(newDesc))
- internal.AddFlagAndBind(v, fs, fs.String, "new-from-rev", "issues.new-from-rev", "",
- color.GreenString("Show only new issues created after git revision `REV`"))
- internal.AddFlagAndBind(v, fs, fs.String, "new-from-patch", "issues.new-from-patch", "",
- color.GreenString("Show only new issues created in git patch with file path `PATH`"))
- internal.AddFlagAndBind(v, fs, fs.String, "new-from-merge-base", "issues.new-from-merge-base", "",
- color.GreenString("Show only new issues created after the best common ancestor (merge-base against HEAD)"))
- internal.AddFlagAndBind(v, fs, fs.Bool, "whole-files", "issues.whole-files", false,
- color.GreenString("Show issues in any part of update files (requires new-from-rev or new-from-patch)"))
- internal.AddFlagAndBind(v, fs, fs.Bool, "fix", "issues.fix", false,
- color.GreenString("Fix found issues (if it's supported by the linter)"))
-}
-
-func formatList(head string, items []string, foot ...string) string {
- parts := []string{color.GreenString(head)}
- for _, p := range items {
- parts = append(parts, fmt.Sprintf(" - %s", color.YellowString(p)))
- }
-
- for _, s := range foot {
- parts = append(parts, color.GreenString(s))
- }
-
- if len(foot) == 0 {
- parts = append(parts, "")
- }
-
- return strings.Join(parts, "\n")
-}
-
-func getDefaultIssueExcludeHelp() string {
- parts := []string{color.GreenString("Use or not use default excludes:")}
-
- for _, ep := range config.DefaultExcludePatterns {
- parts = append(parts,
- fmt.Sprintf(" - %s (%s): %s", color.BlueString(ep.ID), color.CyanString(ep.Linter), ep.Why),
- fmt.Sprintf(` Pattern: %s`, color.YellowString(`'`+ep.Pattern+`'`)),
- )
- }
-
- return strings.Join(parts, "\n")
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/commands/help.go b/vendor/github.com/golangci/golangci-lint/pkg/commands/help.go
deleted file mode 100644
index de4a9998fb..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/commands/help.go
+++ /dev/null
@@ -1,235 +0,0 @@
-package commands
-
-import (
- "encoding/json"
- "fmt"
- "slices"
- "sort"
- "strings"
- "unicode"
- "unicode/utf8"
-
- "github.com/fatih/color"
- "github.com/spf13/cobra"
-
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/lint/linter"
- "github.com/golangci/golangci-lint/pkg/lint/lintersdb"
- "github.com/golangci/golangci-lint/pkg/logutils"
-)
-
-type linterHelp struct {
- Name string `json:"name"`
- Desc string `json:"description"`
- Fast bool `json:"fast"`
- AutoFix bool `json:"autoFix"`
- Presets []string `json:"presets"`
- EnabledByDefault bool `json:"enabledByDefault"`
- Deprecated bool `json:"deprecated"`
- Since string `json:"since"`
- OriginalURL string `json:"originalURL,omitempty"`
-}
-
-type helpOptions struct {
- JSON bool
-}
-
-type helpCommand struct {
- cmd *cobra.Command
-
- opts helpOptions
-
- dbManager *lintersdb.Manager
-
- log logutils.Log
-}
-
-func newHelpCommand(logger logutils.Log) *helpCommand {
- c := &helpCommand{log: logger}
-
- helpCmd := &cobra.Command{
- Use: "help",
- Short: "Help",
- Args: cobra.NoArgs,
- RunE: func(cmd *cobra.Command, _ []string) error {
- return cmd.Help()
- },
- }
-
- lintersCmd := &cobra.Command{
- Use: "linters",
- Short: "Help about linters",
- Args: cobra.NoArgs,
- ValidArgsFunction: cobra.NoFileCompletions,
- RunE: c.execute,
- PreRunE: c.preRunE,
- }
-
- helpCmd.AddCommand(lintersCmd)
-
- fs := lintersCmd.Flags()
- fs.SortFlags = false // sort them as they are defined here
-
- fs.BoolVar(&c.opts.JSON, "json", false, color.GreenString("Display as JSON"))
-
- c.cmd = helpCmd
-
- return c
-}
-
-func (c *helpCommand) preRunE(_ *cobra.Command, _ []string) error {
- // The command doesn't depend on the real configuration.
- // It just needs the list of all plugins and all presets.
- dbManager, err := lintersdb.NewManager(c.log.Child(logutils.DebugKeyLintersDB), config.NewDefault(), lintersdb.NewLinterBuilder())
- if err != nil {
- return err
- }
-
- c.dbManager = dbManager
-
- return nil
-}
-
-func (c *helpCommand) execute(_ *cobra.Command, _ []string) error {
- if c.opts.JSON {
- return c.printJSON()
- }
-
- c.print()
-
- return nil
-}
-
-func (c *helpCommand) printJSON() error {
- var linters []linterHelp
-
- for _, lc := range c.dbManager.GetAllSupportedLinterConfigs() {
- if lc.Internal {
- continue
- }
-
- linters = append(linters, linterHelp{
- Name: lc.Name(),
- Desc: formatDescription(lc.Linter.Desc()),
- Fast: !lc.IsSlowLinter(),
- AutoFix: lc.CanAutoFix,
- Presets: lc.InPresets,
- EnabledByDefault: lc.EnabledByDefault,
- Deprecated: lc.IsDeprecated(),
- Since: lc.Since,
- OriginalURL: lc.OriginalURL,
- })
- }
-
- return json.NewEncoder(c.cmd.OutOrStdout()).Encode(linters)
-}
-
-func (c *helpCommand) print() {
- var enabledLCs, disabledLCs []*linter.Config
- for _, lc := range c.dbManager.GetAllSupportedLinterConfigs() {
- if lc.Internal {
- continue
- }
-
- if lc.EnabledByDefault {
- enabledLCs = append(enabledLCs, lc)
- } else {
- disabledLCs = append(disabledLCs, lc)
- }
- }
-
- color.Green("Enabled by default linters:\n")
- printLinters(enabledLCs)
-
- color.Red("\nDisabled by default linters:\n")
- printLinters(disabledLCs)
-
- color.Green("\nLinters presets:")
- c.printPresets()
-}
-
-func (c *helpCommand) printPresets() {
- for _, p := range lintersdb.AllPresets() {
- linters := c.dbManager.GetAllLinterConfigsForPreset(p)
-
- var linterNames []string
- for _, lc := range linters {
- if lc.Internal {
- continue
- }
-
- linterNames = append(linterNames, lc.Name())
- }
- sort.Strings(linterNames)
-
- _, _ = fmt.Fprintf(logutils.StdOut, "%s: %s\n", color.YellowString(p), strings.Join(linterNames, ", "))
- }
-}
-
-func printLinters(lcs []*linter.Config) {
- slices.SortFunc(lcs, func(a, b *linter.Config) int {
- if a.IsDeprecated() && b.IsDeprecated() {
- return strings.Compare(a.Name(), b.Name())
- }
-
- if a.IsDeprecated() {
- return 1
- }
-
- if b.IsDeprecated() {
- return -1
- }
-
- return strings.Compare(a.Name(), b.Name())
- })
-
- for _, lc := range lcs {
- desc := formatDescription(lc.Linter.Desc())
-
- deprecatedMark := ""
- if lc.IsDeprecated() {
- deprecatedMark = " [" + color.RedString("deprecated") + "]"
- }
-
- var capabilities []string
- if !lc.IsSlowLinter() {
- capabilities = append(capabilities, color.BlueString("fast"))
- }
- if lc.CanAutoFix {
- capabilities = append(capabilities, color.GreenString("auto-fix"))
- }
-
- var capability string
- if capabilities != nil {
- capability = " [" + strings.Join(capabilities, ", ") + "]"
- }
-
- _, _ = fmt.Fprintf(logutils.StdOut, "%s%s: %s%s\n",
- color.YellowString(lc.Name()), deprecatedMark, desc, capability)
- }
-}
-
-func formatDescription(desc string) string {
- desc = strings.TrimSpace(desc)
-
- if desc == "" {
- return desc
- }
-
- // If the linter description spans multiple lines, truncate everything following the first newline
- endFirstLine := strings.IndexRune(desc, '\n')
- if endFirstLine > 0 {
- desc = desc[:endFirstLine]
- }
-
- rawDesc := []rune(desc)
-
- r, _ := utf8.DecodeRuneInString(desc)
- rawDesc[0] = unicode.ToUpper(r)
-
- if rawDesc[len(rawDesc)-1] != '.' {
- rawDesc = append(rawDesc, '.')
- }
-
- return string(rawDesc)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/commands/internal/builder.go b/vendor/github.com/golangci/golangci-lint/pkg/commands/internal/builder.go
deleted file mode 100644
index f0e259fb02..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/commands/internal/builder.go
+++ /dev/null
@@ -1,250 +0,0 @@
-package internal
-
-import (
- "context"
- "fmt"
- "io"
- "os"
- "os/exec"
- "path/filepath"
- "runtime"
- "strings"
- "time"
- "unicode"
-
- "github.com/golangci/golangci-lint/pkg/logutils"
-)
-
-// Builder runs all the required commands to build a binary.
-type Builder struct {
- cfg *Configuration
-
- log logutils.Log
-
- root string
- repo string
-}
-
-// NewBuilder creates a new Builder.
-func NewBuilder(logger logutils.Log, cfg *Configuration, root string) *Builder {
- return &Builder{
- cfg: cfg,
- log: logger,
- root: root,
- repo: filepath.Join(root, "golangci-lint"),
- }
-}
-
-// Build builds the custom binary.
-func (b Builder) Build(ctx context.Context) error {
- b.log.Infof("Cloning golangci-lint repository")
-
- err := b.clone(ctx)
- if err != nil {
- return fmt.Errorf("clone golangci-lint: %w", err)
- }
-
- b.log.Infof("Adding plugin imports")
-
- err = b.updatePluginsFile()
- if err != nil {
- return fmt.Errorf("update plugin file: %w", err)
- }
-
- b.log.Infof("Adding replace directives")
-
- err = b.addToGoMod(ctx)
- if err != nil {
- return fmt.Errorf("add to go.mod: %w", err)
- }
-
- b.log.Infof("Running go mod tidy")
-
- err = b.goModTidy(ctx)
- if err != nil {
- return fmt.Errorf("go mod tidy: %w", err)
- }
-
- b.log.Infof("Building golangci-lint binary")
-
- binaryName := b.getBinaryName()
-
- err = b.goBuild(ctx, binaryName)
- if err != nil {
- return fmt.Errorf("build golangci-lint binary: %w", err)
- }
-
- b.log.Infof("Moving golangci-lint binary")
-
- err = b.copyBinary(binaryName)
- if err != nil {
- return fmt.Errorf("move golangci-lint binary: %w", err)
- }
-
- return nil
-}
-
-func (b Builder) clone(ctx context.Context) error {
- //nolint:gosec // the variable is sanitized.
- cmd := exec.CommandContext(ctx,
- "git", "clone", "--branch", sanitizeVersion(b.cfg.Version),
- "--single-branch", "--depth", "1", "-c advice.detachedHead=false", "-q",
- "https://github.com/golangci/golangci-lint.git",
- )
- cmd.Dir = b.root
-
- output, err := cmd.CombinedOutput()
- if err != nil {
- b.log.Infof("%s", string(output))
-
- return fmt.Errorf("%s: %w", strings.Join(cmd.Args, " "), err)
- }
-
- return nil
-}
-
-func (b Builder) addToGoMod(ctx context.Context) error {
- for _, plugin := range b.cfg.Plugins {
- if plugin.Path != "" {
- err := b.addReplaceDirective(ctx, plugin)
- if err != nil {
- return err
- }
-
- continue
- }
-
- err := b.goGet(ctx, plugin)
- if err != nil {
- return err
- }
- }
-
- return nil
-}
-
-func (b Builder) goGet(ctx context.Context, plugin *Plugin) error {
- //nolint:gosec // the variables are user related.
- cmd := exec.CommandContext(ctx, "go", "get", plugin.Module+"@"+plugin.Version)
- cmd.Dir = b.repo
-
- b.log.Infof("run: %s", strings.Join(cmd.Args, " "))
-
- output, err := cmd.CombinedOutput()
- if err != nil {
- b.log.Warnf("%s", string(output))
-
- return fmt.Errorf("%s: %w", strings.Join(cmd.Args, " "), err)
- }
-
- return nil
-}
-
-func (b Builder) addReplaceDirective(ctx context.Context, plugin *Plugin) error {
- replace := fmt.Sprintf("%s=%s", plugin.Module, plugin.Path)
-
- cmd := exec.CommandContext(ctx, "go", "mod", "edit", "-replace", replace)
- cmd.Dir = b.repo
-
- b.log.Infof("run: %s", strings.Join(cmd.Args, " "))
-
- output, err := cmd.CombinedOutput()
- if err != nil {
- b.log.Warnf("%s", string(output))
-
- return fmt.Errorf("%s: %w", strings.Join(cmd.Args, " "), err)
- }
-
- return nil
-}
-
-func (b Builder) goModTidy(ctx context.Context) error {
- cmd := exec.CommandContext(ctx, "go", "mod", "tidy")
- cmd.Dir = b.repo
-
- output, err := cmd.CombinedOutput()
- if err != nil {
- b.log.Warnf("%s", string(output))
-
- return fmt.Errorf("%s: %w", strings.Join(cmd.Args, " "), err)
- }
-
- return nil
-}
-
-func (b Builder) goBuild(ctx context.Context, binaryName string) error {
- //nolint:gosec // the variable is sanitized.
- cmd := exec.CommandContext(ctx, "go", "build",
- "-ldflags",
- fmt.Sprintf(
- "-s -w -X 'main.version=%s-custom-gcl' -X 'main.date=%s'",
- sanitizeVersion(b.cfg.Version), time.Now().UTC().String(),
- ),
- "-o", binaryName,
- "./cmd/golangci-lint",
- )
- cmd.Dir = b.repo
-
- output, err := cmd.CombinedOutput()
- if err != nil {
- b.log.Warnf("%s", string(output))
-
- return fmt.Errorf("%s: %w", strings.Join(cmd.Args, " "), err)
- }
-
- return nil
-}
-
-func (b Builder) copyBinary(binaryName string) error {
- src := filepath.Join(b.repo, binaryName)
-
- source, err := os.Open(filepath.Clean(src))
- if err != nil {
- return fmt.Errorf("open source file: %w", err)
- }
-
- defer func() { _ = source.Close() }()
-
- info, err := source.Stat()
- if err != nil {
- return fmt.Errorf("stat source file: %w", err)
- }
-
- if b.cfg.Destination != "" {
- err = os.MkdirAll(b.cfg.Destination, os.ModePerm)
- if err != nil {
- return fmt.Errorf("create destination directory: %w", err)
- }
- }
-
- dst, err := os.OpenFile(filepath.Join(b.cfg.Destination, binaryName), os.O_RDWR|os.O_CREATE|os.O_TRUNC, info.Mode())
- if err != nil {
- return fmt.Errorf("create destination file: %w", err)
- }
-
- defer func() { _ = dst.Close() }()
-
- _, err = io.Copy(dst, source)
- if err != nil {
- return fmt.Errorf("copy source to destination: %w", err)
- }
-
- return nil
-}
-
-func (b Builder) getBinaryName() string {
- name := b.cfg.Name
- if runtime.GOOS == "windows" {
- name += ".exe"
- }
-
- return name
-}
-
-func sanitizeVersion(v string) string {
- fn := func(c rune) bool {
- return !(unicode.IsLetter(c) || unicode.IsNumber(c) || c == '.' || c == '/')
- }
-
- return strings.Join(strings.FieldsFunc(v, fn), "")
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/commands/linters.go b/vendor/github.com/golangci/golangci-lint/pkg/commands/linters.go
deleted file mode 100644
index a93814f0f8..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/commands/linters.go
+++ /dev/null
@@ -1,107 +0,0 @@
-package commands
-
-import (
- "fmt"
-
- "github.com/fatih/color"
- "github.com/spf13/cobra"
- "github.com/spf13/viper"
-
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/lint/linter"
- "github.com/golangci/golangci-lint/pkg/lint/lintersdb"
- "github.com/golangci/golangci-lint/pkg/logutils"
-)
-
-type lintersOptions struct {
- config.LoaderOptions
-}
-
-type lintersCommand struct {
- viper *viper.Viper
- cmd *cobra.Command
-
- opts lintersOptions
-
- cfg *config.Config
-
- log logutils.Log
-
- dbManager *lintersdb.Manager
-}
-
-func newLintersCommand(logger logutils.Log) *lintersCommand {
- c := &lintersCommand{
- viper: viper.New(),
- cfg: config.NewDefault(),
- log: logger,
- }
-
- lintersCmd := &cobra.Command{
- Use: "linters",
- Short: "List current linters configuration",
- Args: cobra.NoArgs,
- ValidArgsFunction: cobra.NoFileCompletions,
- RunE: c.execute,
- PreRunE: c.preRunE,
- SilenceUsage: true,
- }
-
- fs := lintersCmd.Flags()
- fs.SortFlags = false // sort them as they are defined here
-
- setupConfigFileFlagSet(fs, &c.opts.LoaderOptions)
- setupLintersFlagSet(c.viper, fs)
-
- c.cmd = lintersCmd
-
- return c
-}
-
-func (c *lintersCommand) preRunE(cmd *cobra.Command, args []string) error {
- loader := config.NewLoader(c.log.Child(logutils.DebugKeyConfigReader), c.viper, cmd.Flags(), c.opts.LoaderOptions, c.cfg, args)
-
- err := loader.Load(config.LoadOptions{Validation: true})
- if err != nil {
- return fmt.Errorf("can't load config: %w", err)
- }
-
- dbManager, err := lintersdb.NewManager(c.log.Child(logutils.DebugKeyLintersDB), c.cfg,
- lintersdb.NewLinterBuilder(), lintersdb.NewPluginModuleBuilder(c.log), lintersdb.NewPluginGoBuilder(c.log))
- if err != nil {
- return err
- }
-
- c.dbManager = dbManager
-
- return nil
-}
-
-func (c *lintersCommand) execute(_ *cobra.Command, _ []string) error {
- enabledLintersMap, err := c.dbManager.GetEnabledLintersMap()
- if err != nil {
- return fmt.Errorf("can't get enabled linters: %w", err)
- }
-
- var enabledLinters []*linter.Config
- var disabledLCs []*linter.Config
-
- for _, lc := range c.dbManager.GetAllSupportedLinterConfigs() {
- if lc.Internal {
- continue
- }
-
- if enabledLintersMap[lc.Name()] == nil {
- disabledLCs = append(disabledLCs, lc)
- } else {
- enabledLinters = append(enabledLinters, lc)
- }
- }
-
- color.Green("Enabled by your configuration linters:\n")
- printLinters(enabledLinters)
- color.Red("\nDisabled by your configuration linters:\n")
- printLinters(disabledLCs)
-
- return nil
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/commands/run.go b/vendor/github.com/golangci/golangci-lint/pkg/commands/run.go
deleted file mode 100644
index 57f3cdd993..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/commands/run.go
+++ /dev/null
@@ -1,700 +0,0 @@
-package commands
-
-import (
- "bytes"
- "context"
- "crypto/sha256"
- "errors"
- "fmt"
- "io"
- "log"
- "maps"
- "os"
- "path/filepath"
- "runtime"
- "runtime/pprof"
- "runtime/trace"
- "slices"
- "strconv"
- "strings"
- "time"
-
- "github.com/fatih/color"
- "github.com/gofrs/flock"
- "github.com/spf13/cobra"
- "github.com/spf13/pflag"
- "github.com/spf13/viper"
- "go.uber.org/automaxprocs/maxprocs"
- "gopkg.in/yaml.v3"
-
- "github.com/golangci/golangci-lint/internal/cache"
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/exitcodes"
- "github.com/golangci/golangci-lint/pkg/fsutils"
- "github.com/golangci/golangci-lint/pkg/goanalysis/load"
- "github.com/golangci/golangci-lint/pkg/goutil"
- "github.com/golangci/golangci-lint/pkg/lint"
- "github.com/golangci/golangci-lint/pkg/lint/linter"
- "github.com/golangci/golangci-lint/pkg/lint/lintersdb"
- "github.com/golangci/golangci-lint/pkg/logutils"
- "github.com/golangci/golangci-lint/pkg/printers"
- "github.com/golangci/golangci-lint/pkg/report"
- "github.com/golangci/golangci-lint/pkg/result"
- "github.com/golangci/golangci-lint/pkg/timeutils"
-)
-
-const defaultTimeout = time.Minute
-
-const (
- // envFailOnWarnings value: "1"
- envFailOnWarnings = "FAIL_ON_WARNINGS"
- // envMemLogEvery value: "1"
- envMemLogEvery = "GL_MEM_LOG_EVERY"
-)
-
-const (
- // envHelpRun value: "1".
- envHelpRun = "HELP_RUN"
- envMemProfileRate = "GL_MEM_PROFILE_RATE"
-)
-
-type runOptions struct {
- config.LoaderOptions
-
- CPUProfilePath string // Flag only.
- MemProfilePath string // Flag only.
- TracePath string // Flag only.
-
- PrintResourcesUsage bool // Flag only.
-}
-
-type runCommand struct {
- viper *viper.Viper
- cmd *cobra.Command
-
- opts runOptions
-
- cfg *config.Config
-
- buildInfo BuildInfo
-
- dbManager *lintersdb.Manager
-
- printer *printers.Printer
-
- log logutils.Log
- debugf logutils.DebugFunc
- reportData *report.Data
-
- contextBuilder *lint.ContextBuilder
- goenv *goutil.Env
-
- fileCache *fsutils.FileCache
- lineCache *fsutils.LineCache
-
- flock *flock.Flock
-
- exitCode int
-}
-
-func newRunCommand(logger logutils.Log, info BuildInfo) *runCommand {
- reportData := &report.Data{}
-
- c := &runCommand{
- viper: viper.New(),
- log: report.NewLogWrapper(logger, reportData),
- debugf: logutils.Debug(logutils.DebugKeyExec),
- cfg: config.NewDefault(),
- reportData: reportData,
- buildInfo: info,
- }
-
- runCmd := &cobra.Command{
- Use: "run",
- Short: "Run the linters",
- Run: c.execute,
- PreRunE: c.preRunE,
- PostRun: c.postRun,
- PersistentPreRunE: c.persistentPreRunE,
- PersistentPostRunE: c.persistentPostRunE,
- SilenceUsage: true,
- }
-
- runCmd.SetOut(logutils.StdOut) // use custom output to properly color it in Windows terminals
- runCmd.SetErr(logutils.StdErr)
-
- fs := runCmd.Flags()
- fs.SortFlags = false // sort them as they are defined here
-
- // Only for testing purpose.
- // Don't add other flags here.
- fs.BoolVar(&c.cfg.InternalCmdTest, "internal-cmd-test", false,
- color.GreenString("Option is used only for testing golangci-lint command, don't use it"))
- _ = fs.MarkHidden("internal-cmd-test")
-
- setupConfigFileFlagSet(fs, &c.opts.LoaderOptions)
-
- setupLintersFlagSet(c.viper, fs)
- setupRunFlagSet(c.viper, fs)
- setupOutputFlagSet(c.viper, fs)
- setupIssuesFlagSet(c.viper, fs)
-
- setupRunPersistentFlags(runCmd.PersistentFlags(), &c.opts)
-
- c.cmd = runCmd
-
- return c
-}
-
-func (c *runCommand) persistentPreRunE(cmd *cobra.Command, args []string) error {
- if err := c.startTracing(); err != nil {
- return err
- }
-
- c.log.Infof("%s", c.buildInfo.String())
-
- loader := config.NewLoader(c.log.Child(logutils.DebugKeyConfigReader), c.viper, cmd.Flags(), c.opts.LoaderOptions, c.cfg, args)
-
- err := loader.Load(config.LoadOptions{CheckDeprecation: true, Validation: true})
- if err != nil {
- return fmt.Errorf("can't load config: %w", err)
- }
-
- if c.cfg.Run.Concurrency == 0 {
- backup := runtime.GOMAXPROCS(0)
-
- // Automatically set GOMAXPROCS to match Linux container CPU quota.
- _, err := maxprocs.Set(maxprocs.Logger(c.log.Infof))
- if err != nil {
- runtime.GOMAXPROCS(backup)
- }
- } else {
- runtime.GOMAXPROCS(c.cfg.Run.Concurrency)
- }
-
- return nil
-}
-
-func (c *runCommand) persistentPostRunE(_ *cobra.Command, _ []string) error {
- if err := c.stopTracing(); err != nil {
- return err
- }
-
- os.Exit(c.exitCode)
-
- return nil
-}
-
-func (c *runCommand) preRunE(_ *cobra.Command, args []string) error {
- if c.cfg.GetConfigDir() != "" && c.cfg.Version != "" {
- return errors.New("you are using a configuration file for golangci-lint v2 with golangci-lint v1: please use golangci-lint v2")
- }
-
- dbManager, err := lintersdb.NewManager(c.log.Child(logutils.DebugKeyLintersDB), c.cfg,
- lintersdb.NewLinterBuilder(), lintersdb.NewPluginModuleBuilder(c.log), lintersdb.NewPluginGoBuilder(c.log))
- if err != nil {
- return err
- }
-
- c.dbManager = dbManager
-
- printer, err := printers.NewPrinter(c.log, &c.cfg.Output, c.reportData, c.cfg.GetBasePath())
- if err != nil {
- return err
- }
-
- c.printer = printer
-
- c.goenv = goutil.NewEnv(c.log.Child(logutils.DebugKeyGoEnv))
-
- c.fileCache = fsutils.NewFileCache()
- c.lineCache = fsutils.NewLineCache(c.fileCache)
-
- sw := timeutils.NewStopwatch("pkgcache", c.log.Child(logutils.DebugKeyStopwatch))
-
- pkgCache, err := cache.NewCache(sw, c.log.Child(logutils.DebugKeyPkgCache))
- if err != nil {
- return fmt.Errorf("failed to build packages cache: %w", err)
- }
-
- guard := load.NewGuard()
-
- pkgLoader := lint.NewPackageLoader(c.log.Child(logutils.DebugKeyLoader), c.cfg, args, c.goenv, guard)
-
- c.contextBuilder = lint.NewContextBuilder(c.cfg, pkgLoader, pkgCache, guard)
-
- if err = initHashSalt(c.buildInfo.Version, c.cfg); err != nil {
- return fmt.Errorf("failed to init hash salt: %w", err)
- }
-
- if ok := c.acquireFileLock(); !ok {
- return errors.New("parallel golangci-lint is running")
- }
-
- return nil
-}
-
-func (c *runCommand) postRun(_ *cobra.Command, _ []string) {
- c.releaseFileLock()
-}
-
-func (c *runCommand) execute(_ *cobra.Command, args []string) {
- needTrackResources := logutils.IsVerbose() || c.opts.PrintResourcesUsage
-
- trackResourcesEndCh := make(chan struct{})
-
- // Note: this defer must be before ctx.cancel defer
- defer func() {
- // wait until resource tracking finished to print properly
- if needTrackResources {
- <-trackResourcesEndCh
- }
- }()
-
- ctx := context.Background()
- if c.cfg.Run.Timeout > 0 {
- var cancel context.CancelFunc
- ctx, cancel = context.WithTimeout(ctx, c.cfg.Run.Timeout)
- defer cancel()
- }
-
- if needTrackResources {
- go watchResources(ctx, trackResourcesEndCh, c.log, c.debugf)
- }
-
- if err := c.runAndPrint(ctx, args); err != nil {
- c.log.Errorf("Running error: %s", err)
- if c.exitCode == exitcodes.Success {
- var exitErr *exitcodes.ExitError
- if errors.As(err, &exitErr) {
- c.exitCode = exitErr.Code
- } else {
- c.exitCode = exitcodes.Failure
- }
- }
- }
-
- c.setupExitCode(ctx)
-}
-
-func (c *runCommand) startTracing() error {
- if c.opts.CPUProfilePath != "" {
- f, err := os.Create(c.opts.CPUProfilePath)
- if err != nil {
- return fmt.Errorf("can't create file %s: %w", c.opts.CPUProfilePath, err)
- }
- if err := pprof.StartCPUProfile(f); err != nil {
- return fmt.Errorf("can't start CPU profiling: %w", err)
- }
- }
-
- if c.opts.MemProfilePath != "" {
- if rate := os.Getenv(envMemProfileRate); rate != "" {
- runtime.MemProfileRate, _ = strconv.Atoi(rate)
- }
- }
-
- if c.opts.TracePath != "" {
- f, err := os.Create(c.opts.TracePath)
- if err != nil {
- return fmt.Errorf("can't create file %s: %w", c.opts.TracePath, err)
- }
- if err = trace.Start(f); err != nil {
- return fmt.Errorf("can't start tracing: %w", err)
- }
- }
-
- return nil
-}
-
-func (c *runCommand) stopTracing() error {
- if c.opts.CPUProfilePath != "" {
- pprof.StopCPUProfile()
- }
-
- if c.opts.MemProfilePath != "" {
- f, err := os.Create(c.opts.MemProfilePath)
- if err != nil {
- return fmt.Errorf("can't create file %s: %w", c.opts.MemProfilePath, err)
- }
-
- var ms runtime.MemStats
- runtime.ReadMemStats(&ms)
- printMemStats(&ms, c.log)
-
- if err := pprof.WriteHeapProfile(f); err != nil {
- return fmt.Errorf("can't write heap profile: %w", err)
- }
- _ = f.Close()
- }
-
- if c.opts.TracePath != "" {
- trace.Stop()
- }
-
- return nil
-}
-
-func (c *runCommand) runAndPrint(ctx context.Context, args []string) error {
- if err := c.goenv.Discover(ctx); err != nil {
- c.log.Warnf("Failed to discover go env: %s", err)
- }
-
- if !logutils.HaveDebugTag(logutils.DebugKeyLintersOutput) {
- // Don't allow linters and loader to print anything
- log.SetOutput(io.Discard)
- savedStdout, savedStderr := c.setOutputToDevNull()
- defer func() {
- os.Stdout, os.Stderr = savedStdout, savedStderr
- }()
- }
-
- enabledLintersMap, err := c.dbManager.GetEnabledLintersMap()
- if err != nil {
- return err
- }
-
- c.printDeprecatedLinterMessages(enabledLintersMap)
-
- issues, err := c.runAnalysis(ctx, args)
- if err != nil {
- return err // XXX: don't lose type
- }
-
- // Fills linters information for the JSON printer.
- for _, lc := range c.dbManager.GetAllSupportedLinterConfigs() {
- isEnabled := enabledLintersMap[lc.Name()] != nil
- c.reportData.AddLinter(lc.Name(), isEnabled, lc.EnabledByDefault)
- }
-
- err = c.printer.Print(issues)
- if err != nil {
- return err
- }
-
- c.printStats(issues)
-
- c.setExitCodeIfIssuesFound(issues)
-
- c.fileCache.PrintStats(c.log)
-
- return nil
-}
-
-// runAnalysis executes the linters that have been enabled in the configuration.
-func (c *runCommand) runAnalysis(ctx context.Context, args []string) ([]result.Issue, error) {
- lintersToRun, err := c.dbManager.GetOptimizedLinters()
- if err != nil {
- return nil, err
- }
-
- lintCtx, err := c.contextBuilder.Build(ctx, c.log.Child(logutils.DebugKeyLintersContext), lintersToRun)
- if err != nil {
- return nil, fmt.Errorf("context loading failed: %w", err)
- }
-
- runner, err := lint.NewRunner(c.log.Child(logutils.DebugKeyRunner), c.cfg, args,
- c.goenv, c.lineCache, c.fileCache, c.dbManager, lintCtx)
- if err != nil {
- return nil, err
- }
-
- return runner.Run(ctx, lintersToRun)
-}
-
-func (c *runCommand) setOutputToDevNull() (savedStdout, savedStderr *os.File) {
- savedStdout, savedStderr = os.Stdout, os.Stderr
- devNull, err := os.Open(os.DevNull)
- if err != nil {
- c.log.Warnf("Can't open null device %q: %s", os.DevNull, err)
- return
- }
-
- os.Stdout, os.Stderr = devNull, devNull
- return
-}
-
-func (c *runCommand) setExitCodeIfIssuesFound(issues []result.Issue) {
- if len(issues) != 0 {
- c.exitCode = c.cfg.Run.ExitCodeIfIssuesFound
- }
-}
-
-func (c *runCommand) printDeprecatedLinterMessages(enabledLinters map[string]*linter.Config) {
- if c.cfg.InternalCmdTest || os.Getenv(logutils.EnvTestRun) == "1" {
- return
- }
-
- for name, lc := range enabledLinters {
- if !lc.IsDeprecated() {
- continue
- }
-
- var extra string
- if lc.Deprecation.Replacement != "" {
- extra = fmt.Sprintf("Replaced by %s.", lc.Deprecation.Replacement)
- }
-
- c.log.Warnf("The linter '%s' is deprecated (since %s) due to: %s %s", name, lc.Deprecation.Since, lc.Deprecation.Message, extra)
- }
-}
-
-func (c *runCommand) printStats(issues []result.Issue) {
- if !c.cfg.Output.ShowStats {
- return
- }
-
- if len(issues) == 0 {
- c.cmd.Println("0 issues.")
- return
- }
-
- stats := map[string]int{}
- for idx := range issues {
- stats[issues[idx].FromLinter]++
- }
-
- c.cmd.Printf("%d issues:\n", len(issues))
-
- keys := slices.Sorted(maps.Keys(stats))
-
- for _, key := range keys {
- c.cmd.Printf("* %s: %d\n", key, stats[key])
- }
-}
-
-func (c *runCommand) setupExitCode(ctx context.Context) {
- if ctx.Err() != nil {
- c.exitCode = exitcodes.Timeout
- c.log.Errorf("Timeout exceeded: try increasing it by passing --timeout option")
- return
- }
-
- if c.exitCode != exitcodes.Success {
- return
- }
-
- needFailOnWarnings := os.Getenv(logutils.EnvTestRun) == "1" || os.Getenv(envFailOnWarnings) == "1"
- if needFailOnWarnings && len(c.reportData.Warnings) != 0 {
- c.exitCode = exitcodes.WarningInTest
- return
- }
-
- if c.reportData.Error != "" {
- // it's a case e.g. when typecheck linter couldn't parse and error and just logged it
- c.exitCode = exitcodes.ErrorWasLogged
- return
- }
-}
-
-func (c *runCommand) acquireFileLock() bool {
- if c.cfg.Run.AllowParallelRunners {
- c.debugf("Parallel runners are allowed, no locking")
- return true
- }
-
- lockFile := filepath.Join(os.TempDir(), "golangci-lint.lock")
- c.debugf("Locking on file %s...", lockFile)
- f := flock.New(lockFile)
- const retryDelay = time.Second
-
- ctx := context.Background()
- if !c.cfg.Run.AllowSerialRunners {
- const totalTimeout = 5 * time.Second
- var cancel context.CancelFunc
- ctx, cancel = context.WithTimeout(ctx, totalTimeout)
- defer cancel()
- }
- if ok, _ := f.TryLockContext(ctx, retryDelay); !ok {
- return false
- }
-
- c.flock = f
- return true
-}
-
-func (c *runCommand) releaseFileLock() {
- if c.cfg.Run.AllowParallelRunners {
- return
- }
-
- if err := c.flock.Unlock(); err != nil {
- c.debugf("Failed to unlock on file: %s", err)
- }
- if err := os.Remove(c.flock.Path()); err != nil {
- c.debugf("Failed to remove lock file: %s", err)
- }
-}
-
-func watchResources(ctx context.Context, done chan struct{}, logger logutils.Log, debugf logutils.DebugFunc) {
- startedAt := time.Now()
- debugf("Started tracking time")
-
- var maxRSSMB, totalRSSMB float64
- var iterationsCount int
-
- const intervalMS = 100
- ticker := time.NewTicker(intervalMS * time.Millisecond)
- defer ticker.Stop()
-
- logEveryRecord := os.Getenv(envMemLogEvery) == "1"
- const MB = 1024 * 1024
-
- track := func() {
- var m runtime.MemStats
- runtime.ReadMemStats(&m)
-
- if logEveryRecord {
- debugf("Stopping memory tracing iteration, printing ...")
- printMemStats(&m, logger)
- }
-
- rssMB := float64(m.Sys) / MB
- if rssMB > maxRSSMB {
- maxRSSMB = rssMB
- }
- totalRSSMB += rssMB
- iterationsCount++
- }
-
- for {
- track()
-
- stop := false
- select {
- case <-ctx.Done():
- stop = true
- debugf("Stopped resources tracking")
- case <-ticker.C:
- }
-
- if stop {
- break
- }
- }
- track()
-
- avgRSSMB := totalRSSMB / float64(iterationsCount)
-
- logger.Infof("Memory: %d samples, avg is %.1fMB, max is %.1fMB",
- iterationsCount, avgRSSMB, maxRSSMB)
- logger.Infof("Execution took %s", time.Since(startedAt))
- close(done)
-}
-
-func setupConfigFileFlagSet(fs *pflag.FlagSet, cfg *config.LoaderOptions) {
- fs.StringVarP(&cfg.Config, "config", "c", "", color.GreenString("Read config from file path `PATH`"))
- fs.BoolVar(&cfg.NoConfig, "no-config", false, color.GreenString("Don't read config file"))
-}
-
-func setupRunPersistentFlags(fs *pflag.FlagSet, opts *runOptions) {
- fs.BoolVar(&opts.PrintResourcesUsage, "print-resources-usage", false,
- color.GreenString("Print avg and max memory usage of golangci-lint and total time"))
-
- fs.StringVar(&opts.CPUProfilePath, "cpu-profile-path", "", color.GreenString("Path to CPU profile output file"))
- fs.StringVar(&opts.MemProfilePath, "mem-profile-path", "", color.GreenString("Path to memory profile output file"))
- fs.StringVar(&opts.TracePath, "trace-path", "", color.GreenString("Path to trace output file"))
-}
-
-func getDefaultConcurrency() int {
- if os.Getenv(envHelpRun) == "1" {
- // Make stable concurrency for generating help documentation.
- const prettyConcurrency = 8
- return prettyConcurrency
- }
-
- return runtime.NumCPU()
-}
-
-func printMemStats(ms *runtime.MemStats, logger logutils.Log) {
- logger.Infof("Mem stats: alloc=%s total_alloc=%s sys=%s "+
- "heap_alloc=%s heap_sys=%s heap_idle=%s heap_released=%s heap_in_use=%s "+
- "stack_in_use=%s stack_sys=%s "+
- "mspan_sys=%s mcache_sys=%s buck_hash_sys=%s gc_sys=%s other_sys=%s "+
- "mallocs_n=%d frees_n=%d heap_objects_n=%d gc_cpu_fraction=%.2f",
- formatMemory(ms.Alloc), formatMemory(ms.TotalAlloc), formatMemory(ms.Sys),
- formatMemory(ms.HeapAlloc), formatMemory(ms.HeapSys),
- formatMemory(ms.HeapIdle), formatMemory(ms.HeapReleased), formatMemory(ms.HeapInuse),
- formatMemory(ms.StackInuse), formatMemory(ms.StackSys),
- formatMemory(ms.MSpanSys), formatMemory(ms.MCacheSys), formatMemory(ms.BuckHashSys),
- formatMemory(ms.GCSys), formatMemory(ms.OtherSys),
- ms.Mallocs, ms.Frees, ms.HeapObjects, ms.GCCPUFraction)
-}
-
-func formatMemory(memBytes uint64) string {
- const Kb = 1024
- const Mb = Kb * 1024
-
- if memBytes < Kb {
- return fmt.Sprintf("%db", memBytes)
- }
- if memBytes < Mb {
- return fmt.Sprintf("%dkb", memBytes/Kb)
- }
- return fmt.Sprintf("%dmb", memBytes/Mb)
-}
-
-// Related to cache.
-
-func initHashSalt(version string, cfg *config.Config) error {
- binSalt, err := computeBinarySalt(version)
- if err != nil {
- return fmt.Errorf("failed to calculate binary salt: %w", err)
- }
-
- configSalt, err := computeConfigSalt(cfg)
- if err != nil {
- return fmt.Errorf("failed to calculate config salt: %w", err)
- }
-
- b := bytes.NewBuffer(binSalt)
- b.Write(configSalt)
- cache.SetSalt(b)
- return nil
-}
-
-func computeBinarySalt(version string) ([]byte, error) {
- if version != "" && version != "(devel)" {
- return []byte(version), nil
- }
-
- if logutils.HaveDebugTag(logutils.DebugKeyBinSalt) {
- return []byte("debug"), nil
- }
-
- p, err := os.Executable()
- if err != nil {
- return nil, err
- }
- f, err := os.Open(p)
- if err != nil {
- return nil, err
- }
- defer f.Close()
- h := sha256.New()
- if _, err := io.Copy(h, f); err != nil {
- return nil, err
- }
- return h.Sum(nil), nil
-}
-
-// computeConfigSalt computes configuration hash.
-// We don't hash all config fields to reduce meaningless cache invalidations.
-// At least, it has a huge impact on tests speed.
-// Fields: `LintersSettings` and `Run.BuildTags`.
-func computeConfigSalt(cfg *config.Config) ([]byte, error) {
- lintersSettingsBytes, err := yaml.Marshal(cfg.LintersSettings)
- if err != nil {
- return nil, fmt.Errorf("failed to JSON marshal config linter settings: %w", err)
- }
-
- configData := bytes.NewBufferString("linters-settings=")
- configData.Write(lintersSettingsBytes)
- configData.WriteString("\nbuild-tags=%s" + strings.Join(cfg.Run.BuildTags, ","))
-
- h := sha256.New()
- if _, err := h.Write(configData.Bytes()); err != nil {
- return nil, err
- }
- return h.Sum(nil), nil
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/commands/version.go b/vendor/github.com/golangci/golangci-lint/pkg/commands/version.go
deleted file mode 100644
index ac665f4c57..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/commands/version.go
+++ /dev/null
@@ -1,102 +0,0 @@
-package commands
-
-import (
- "encoding/json"
- "fmt"
- "io"
- "os"
- "runtime/debug"
- "strings"
-
- "github.com/fatih/color"
- "github.com/spf13/cobra"
-)
-
-type BuildInfo struct {
- GoVersion string `json:"goVersion"`
- Version string `json:"version"`
- Commit string `json:"commit"`
- Date string `json:"date"`
-}
-
-func (b BuildInfo) String() string {
- return fmt.Sprintf("golangci-lint has version %s built with %s from %s on %s",
- b.Version, b.GoVersion, b.Commit, b.Date)
-}
-
-type versionInfo struct {
- Info BuildInfo
- BuildInfo *debug.BuildInfo
-}
-
-type versionOptions struct {
- Format string
- Debug bool
-}
-
-type versionCommand struct {
- cmd *cobra.Command
- opts versionOptions
-
- info BuildInfo
-}
-
-func newVersionCommand(info BuildInfo) *versionCommand {
- c := &versionCommand{info: info}
-
- versionCmd := &cobra.Command{
- Use: "version",
- Short: "Version",
- Args: cobra.NoArgs,
- ValidArgsFunction: cobra.NoFileCompletions,
- RunE: c.execute,
- }
-
- fs := versionCmd.Flags()
- fs.SortFlags = false // sort them as they are defined here
-
- fs.StringVar(&c.opts.Format, "format", "", color.GreenString("The version's format can be: 'short', 'json'"))
- fs.BoolVar(&c.opts.Debug, "debug", false, color.GreenString("Add build information"))
-
- c.cmd = versionCmd
-
- return c
-}
-
-func (c *versionCommand) execute(_ *cobra.Command, _ []string) error {
- if c.opts.Debug {
- info, ok := debug.ReadBuildInfo()
- if !ok {
- return nil
- }
-
- switch strings.ToLower(c.opts.Format) {
- case "json":
- return json.NewEncoder(os.Stdout).Encode(versionInfo{
- Info: c.info,
- BuildInfo: info,
- })
-
- default:
- fmt.Println(info.String())
- return printVersion(os.Stdout, c.info)
- }
- }
-
- switch strings.ToLower(c.opts.Format) {
- case "short":
- fmt.Println(c.info.Version)
- return nil
-
- case "json":
- return json.NewEncoder(os.Stdout).Encode(c.info)
-
- default:
- return printVersion(os.Stdout, c.info)
- }
-}
-
-func printVersion(w io.Writer, info BuildInfo) error {
- _, err := fmt.Fprintln(w, info.String())
- return err
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/config/base_rule.go b/vendor/github.com/golangci/golangci-lint/pkg/config/base_rule.go
deleted file mode 100644
index 780c60cd24..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/config/base_rule.go
+++ /dev/null
@@ -1,75 +0,0 @@
-package config
-
-import (
- "errors"
- "fmt"
- "regexp"
-)
-
-type BaseRule struct {
- Linters []string
- Path string
- PathExcept string `mapstructure:"path-except"`
- Text string
- Source string
-
- // For compatibility with exclude-use-default/include.
- InternalReference string `mapstructure:"-"`
-}
-
-func (b *BaseRule) Validate(minConditionsCount int) error {
- if err := validateOptionalRegex(b.Path); err != nil {
- return fmt.Errorf("invalid path regex: %w", err)
- }
-
- if err := validateOptionalRegex(b.PathExcept); err != nil {
- return fmt.Errorf("invalid path-except regex: %w", err)
- }
-
- if err := validateOptionalRegex(b.Text); err != nil {
- return fmt.Errorf("invalid text regex: %w", err)
- }
-
- if err := validateOptionalRegex(b.Source); err != nil {
- return fmt.Errorf("invalid source regex: %w", err)
- }
-
- if b.Path != "" && b.PathExcept != "" {
- return errors.New("path and path-except should not be set at the same time")
- }
-
- nonBlank := 0
- if len(b.Linters) > 0 {
- nonBlank++
- }
-
- // Filtering by path counts as one condition, regardless how it is done (one or both).
- // Otherwise, a rule with Path and PathExcept set would pass validation
- // whereas before the introduction of path-except that wouldn't have been precise enough.
- if b.Path != "" || b.PathExcept != "" {
- nonBlank++
- }
-
- if b.Text != "" {
- nonBlank++
- }
-
- if b.Source != "" {
- nonBlank++
- }
-
- if nonBlank < minConditionsCount {
- return fmt.Errorf("at least %d of (text, source, path[-except], linters) should be set", minConditionsCount)
- }
-
- return nil
-}
-
-func validateOptionalRegex(value string) error {
- if value == "" {
- return nil
- }
-
- _, err := regexp.Compile(value)
- return err
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/config/config.go b/vendor/github.com/golangci/golangci-lint/pkg/config/config.go
deleted file mode 100644
index ee7a62b7e2..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/config/config.go
+++ /dev/null
@@ -1,181 +0,0 @@
-package config
-
-import (
- "cmp"
- "context"
- "fmt"
- "os"
- "path/filepath"
- "slices"
- "strings"
-
- hcversion "github.com/hashicorp/go-version"
- "github.com/ldez/grignotin/goenv"
- "github.com/ldez/grignotin/gomod"
- "golang.org/x/mod/modfile"
-)
-
-// Config encapsulates the config data specified in the golangci-lint YAML config file.
-type Config struct {
- cfgDir string // Path to the directory containing golangci-lint config file.
- basePath string // Path the root directory related to [Run.RelativePathMode].
-
- Version string `mapstructure:"version"` // From v2, to be able to detect v2 config file.
-
- Run Run `mapstructure:"run"`
-
- Output Output `mapstructure:"output"`
-
- LintersSettings LintersSettings `mapstructure:"linters-settings"`
- Linters Linters `mapstructure:"linters"`
- Issues Issues `mapstructure:"issues"`
- Severity Severity `mapstructure:"severity"`
-
- InternalCmdTest bool // Option is used only for testing golangci-lint command, don't use it
- InternalTest bool // Option is used only for testing golangci-lint code, don't use it
-}
-
-// GetConfigDir returns the directory that contains golangci-lint config file.
-func (c *Config) GetConfigDir() string {
- return c.cfgDir
-}
-
-func (c *Config) GetBasePath() string {
- return c.basePath
-}
-
-func (c *Config) Validate() error {
- validators := []func() error{
- c.Run.Validate,
- c.Output.Validate,
- c.LintersSettings.Validate,
- c.Linters.Validate,
- c.Issues.Validate,
- c.Severity.Validate,
- }
-
- for _, v := range validators {
- if err := v(); err != nil {
- return err
- }
- }
-
- return nil
-}
-
-func NewDefault() *Config {
- return &Config{
- LintersSettings: defaultLintersSettings,
- }
-}
-
-type Version struct {
- Format string `mapstructure:"format"`
- Debug bool `mapstructure:"debug"`
-}
-
-func IsGoGreaterThanOrEqual(current, limit string) bool {
- v1, err := hcversion.NewVersion(strings.TrimPrefix(current, "go"))
- if err != nil {
- return false
- }
-
- l, err := hcversion.NewVersion(limit)
- if err != nil {
- return false
- }
-
- return v1.GreaterThanOrEqual(l)
-}
-
-func detectGoVersion(ctx context.Context) string {
- return cmp.Or(detectGoVersionFromGoMod(ctx), "1.17")
-}
-
-// detectGoVersionFromGoMod tries to get Go version from go.mod.
-// It returns `toolchain` version if present,
-// else it returns `go` version if present,
-// else it returns `GOVERSION` version if present,
-// else it returns empty.
-func detectGoVersionFromGoMod(ctx context.Context) string {
- values, err := goenv.Get(ctx, goenv.GOMOD, goenv.GOVERSION)
- if err != nil {
- values = map[string]string{
- goenv.GOMOD: detectGoModFallback(ctx),
- }
- }
-
- if values[goenv.GOMOD] == "" {
- return parseGoVersion(values[goenv.GOVERSION])
- }
-
- file, err := parseGoMod(values[goenv.GOMOD])
- if err != nil {
- return parseGoVersion(values[goenv.GOVERSION])
- }
-
- // The toolchain exists only if 'toolchain' version > 'go' version.
- // If 'toolchain' version <= 'go' version, `go mod tidy` will remove 'toolchain' version from go.mod.
- if file.Toolchain != nil && file.Toolchain.Name != "" {
- return parseGoVersion(file.Toolchain.Name)
- }
-
- if file.Go != nil && file.Go.Version != "" {
- return file.Go.Version
- }
-
- return parseGoVersion(values[goenv.GOVERSION])
-}
-
-func parseGoVersion(v string) string {
- raw := strings.TrimPrefix(v, "go")
-
- // prerelease version (ex: go1.24rc1)
- idx := strings.IndexFunc(raw, func(r rune) bool {
- return (r < '0' || r > '9') && r != '.'
- })
-
- if idx != -1 {
- raw = raw[:idx]
- }
-
- return raw
-}
-
-func parseGoMod(goMod string) (*modfile.File, error) {
- raw, err := os.ReadFile(filepath.Clean(goMod))
- if err != nil {
- return nil, fmt.Errorf("reading go.mod file: %w", err)
- }
-
- return modfile.Parse("go.mod", raw, nil)
-}
-
-func detectGoModFallback(ctx context.Context) string {
- info, err := gomod.GetModuleInfo(ctx)
- if err != nil {
- return ""
- }
-
- wd, err := os.Getwd()
- if err != nil {
- return ""
- }
-
- slices.SortFunc(info, func(a, b gomod.ModInfo) int {
- return cmp.Compare(len(b.Path), len(a.Path))
- })
-
- goMod := info[0]
- for _, m := range info {
- if !strings.HasPrefix(wd, m.Dir) {
- continue
- }
-
- goMod = m
-
- break
- }
-
- return goMod.GoMod
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/config/issues.go b/vendor/github.com/golangci/golangci-lint/pkg/config/issues.go
deleted file mode 100644
index d5b6650f95..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/config/issues.go
+++ /dev/null
@@ -1,163 +0,0 @@
-package config
-
-import (
- "fmt"
-)
-
-var DefaultExcludePatterns = []ExcludePattern{
- {
- ID: "EXC0001",
- Pattern: "Error return value of .((os\\.)?std(out|err)\\..*|.*Close" +
- "|.*Flush|os\\.Remove(All)?|.*print(f|ln)?|os\\.(Un)?Setenv). is not checked",
- Linter: "errcheck",
- Why: "Almost all programs ignore errors on these functions and in most cases it's ok.",
- },
- {
- ID: "EXC0002", // TODO(ldez): should be remove in v2
- Pattern: "(comment on exported (method|function|type|const)|" +
- "should have( a package)? comment|comment should be of the form)",
- Linter: "golint",
- Why: "Annoying issue about not having a comment. The rare codebase has such comments.",
- },
- {
- ID: "EXC0003", // TODO(ldez): should be remove in v2
- Pattern: "func name will be used as test\\.Test.* by other packages, and that stutters; consider calling this",
- Linter: "golint",
- Why: "False positive when tests are defined in package 'test'.",
- },
- {
- ID: "EXC0004",
- Pattern: "(possible misuse of unsafe.Pointer|should have signature)",
- Linter: "govet",
- Why: "Common false positives.",
- },
- {
- ID: "EXC0005",
- Pattern: "SA4011", // CheckScopedBreak
- Linter: "staticcheck",
- Why: "Developers tend to write in C-style with an explicit 'break' in a 'switch', so it's ok to ignore.",
- },
- {
- ID: "EXC0006",
- Pattern: "G103: Use of unsafe calls should be audited",
- Linter: "gosec",
- Why: "Too many false-positives on 'unsafe' usage.",
- },
- {
- ID: "EXC0007",
- Pattern: "G204: Subprocess launched with variable",
- Linter: "gosec",
- Why: "Too many false-positives for parametrized shell calls.",
- },
- {
- ID: "EXC0008",
- Pattern: "G104", // Errors unhandled.
- Linter: "gosec",
- Why: "Duplicated errcheck checks.",
- },
- {
- ID: "EXC0009",
- Pattern: "(G301|G302|G307): Expect (directory permissions to be 0750|file permissions to be 0600) or less",
- Linter: "gosec",
- Why: "Too many issues in popular repos.",
- },
- {
- ID: "EXC0010",
- Pattern: "G304: Potential file inclusion via variable",
- Linter: "gosec",
- Why: "False positive is triggered by 'src, err := ioutil.ReadFile(filename)'.",
- },
- {
- ID: "EXC0011",
- Pattern: "(ST1000|ST1020|ST1021|ST1022)", // CheckPackageComment, CheckExportedFunctionDocs, CheckExportedTypeDocs, CheckExportedVarDocs
- Linter: "stylecheck",
- Why: "Annoying issue about not having a comment. The rare codebase has such comments.",
- },
- {
- ID: "EXC0012",
- Pattern: `exported (.+) should have comment( \(or a comment on this block\))? or be unexported`, // rule: exported
- Linter: "revive",
- Why: "Annoying issue about not having a comment. The rare codebase has such comments.",
- },
- {
- ID: "EXC0013",
- Pattern: `package comment should be of the form "(.+)..."`, // rule: package-comments
- Linter: "revive",
- Why: "Annoying issue about not having a comment. The rare codebase has such comments.",
- },
- {
- ID: "EXC0014",
- Pattern: `comment on exported (.+) should be of the form "(.+)..."`, // rule: exported
- Linter: "revive",
- Why: "Annoying issue about not having a comment. The rare codebase has such comments.",
- },
- {
- ID: "EXC0015",
- Pattern: `should have a package comment`, // rule: package-comments
- Linter: "revive",
- Why: "Annoying issue about not having a comment. The rare codebase has such comments.",
- },
-}
-
-type Issues struct {
- IncludeDefaultExcludes []string `mapstructure:"include"`
- ExcludeCaseSensitive bool `mapstructure:"exclude-case-sensitive"`
- ExcludePatterns []string `mapstructure:"exclude"`
- ExcludeRules []ExcludeRule `mapstructure:"exclude-rules"`
- UseDefaultExcludes bool `mapstructure:"exclude-use-default"`
-
- ExcludeGenerated string `mapstructure:"exclude-generated"`
-
- ExcludeFiles []string `mapstructure:"exclude-files"`
- ExcludeDirs []string `mapstructure:"exclude-dirs"`
-
- UseDefaultExcludeDirs bool `mapstructure:"exclude-dirs-use-default"`
-
- MaxIssuesPerLinter int `mapstructure:"max-issues-per-linter"`
- MaxSameIssues int `mapstructure:"max-same-issues"`
- UniqByLine bool `mapstructure:"uniq-by-line"`
-
- DiffFromRevision string `mapstructure:"new-from-rev"`
- DiffFromMergeBase string `mapstructure:"new-from-merge-base"`
- DiffPatchFilePath string `mapstructure:"new-from-patch"`
- WholeFiles bool `mapstructure:"whole-files"`
- Diff bool `mapstructure:"new"`
-
- NeedFix bool `mapstructure:"fix"`
-
- ExcludeGeneratedStrict *bool `mapstructure:"exclude-generated-strict"` // Deprecated: use ExcludeGenerated instead.
-}
-
-func (i *Issues) Validate() error {
- for i, rule := range i.ExcludeRules {
- if err := rule.Validate(); err != nil {
- return fmt.Errorf("error in exclude rule #%d: %w", i, err)
- }
- }
-
- return nil
-}
-
-type ExcludePattern struct {
- ID string
- Pattern string
- Linter string
- Why string
-}
-
-// TODO(ldez): this behavior must be changed in v2, because this is confusing.
-func GetExcludePatterns(include []string) []ExcludePattern {
- includeMap := make(map[string]struct{}, len(include))
- for _, inc := range include {
- includeMap[inc] = struct{}{}
- }
-
- var ret []ExcludePattern
- for _, p := range DefaultExcludePatterns {
- if _, ok := includeMap[p.ID]; !ok {
- ret = append(ret, p)
- }
- }
-
- return ret
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/config/linters.go b/vendor/github.com/golangci/golangci-lint/pkg/config/linters.go
deleted file mode 100644
index 4814d1eb24..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/config/linters.go
+++ /dev/null
@@ -1,71 +0,0 @@
-package config
-
-import (
- "errors"
- "fmt"
-)
-
-type Linters struct {
- Enable []string
- Disable []string
- EnableAll bool `mapstructure:"enable-all"`
- DisableAll bool `mapstructure:"disable-all"`
- Fast bool
-
- Presets []string
-
- LinterExclusions LinterExclusions `mapstructure:"exclusions"`
-}
-
-func (l *Linters) Validate() error {
- validators := []func() error{
- l.validateAllDisableEnableOptions,
- l.validateDisabledAndEnabledAtOneMoment,
- l.LinterExclusions.Validate,
- }
-
- for _, v := range validators {
- if err := v(); err != nil {
- return err
- }
- }
-
- return nil
-}
-
-func (l *Linters) validateAllDisableEnableOptions() error {
- if l.EnableAll && l.DisableAll {
- return errors.New("--enable-all and --disable-all options must not be combined")
- }
-
- if l.DisableAll {
- if len(l.Enable) == 0 && len(l.Presets) == 0 {
- return errors.New("all linters were disabled, but no one linter was enabled: must enable at least one")
- }
-
- if len(l.Disable) != 0 {
- return errors.New("can't combine options --disable-all and --disable")
- }
- }
-
- if l.EnableAll && len(l.Enable) != 0 && !l.Fast {
- return errors.New("can't combine options --enable-all and --enable")
- }
-
- return nil
-}
-
-func (l *Linters) validateDisabledAndEnabledAtOneMoment() error {
- enabledLintersSet := map[string]bool{}
- for _, name := range l.Enable {
- enabledLintersSet[name] = true
- }
-
- for _, name := range l.Disable {
- if enabledLintersSet[name] {
- return fmt.Errorf("linter %q can't be disabled and enabled at one moment", name)
- }
- }
-
- return nil
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/config/linters_exclusions.go b/vendor/github.com/golangci/golangci-lint/pkg/config/linters_exclusions.go
deleted file mode 100644
index 3bed6dfc15..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/config/linters_exclusions.go
+++ /dev/null
@@ -1,55 +0,0 @@
-package config
-
-import (
- "fmt"
- "slices"
-)
-
-const (
- ExclusionPresetComments = "comments"
- ExclusionPresetStdErrorHandling = "stdErrorHandling"
- ExclusionPresetCommonFalsePositives = "commonFalsePositives"
- ExclusionPresetLegacy = "legacy"
-)
-
-const excludeRuleMinConditionsCount = 2
-
-type LinterExclusions struct {
- Generated string `mapstructure:"generated"`
- WarnUnused bool `mapstructure:"warn-unused"`
- Presets []string `mapstructure:"preset"`
- Rules []ExcludeRule `mapstructure:"rules"`
- Paths []string `mapstructure:"paths"`
- PathsExcept []string `mapstructure:"paths-except"`
-}
-
-func (e *LinterExclusions) Validate() error {
- for i, rule := range e.Rules {
- if err := rule.Validate(); err != nil {
- return fmt.Errorf("error in exclude rule #%d: %w", i, err)
- }
- }
-
- allPresets := []string{
- ExclusionPresetComments,
- ExclusionPresetStdErrorHandling,
- ExclusionPresetCommonFalsePositives,
- ExclusionPresetLegacy,
- }
-
- for _, preset := range e.Presets {
- if !slices.Contains(allPresets, preset) {
- return fmt.Errorf("invalid preset: %s", preset)
- }
- }
-
- return nil
-}
-
-type ExcludeRule struct {
- BaseRule `mapstructure:",squash"`
-}
-
-func (e *ExcludeRule) Validate() error {
- return e.BaseRule.Validate(excludeRuleMinConditionsCount)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/config/linters_settings.go b/vendor/github.com/golangci/golangci-lint/pkg/config/linters_settings.go
deleted file mode 100644
index 94650a66de..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/config/linters_settings.go
+++ /dev/null
@@ -1,1123 +0,0 @@
-package config
-
-import (
- "encoding"
- "errors"
- "fmt"
- "runtime"
-
- "gopkg.in/yaml.v3"
-)
-
-var defaultLintersSettings = LintersSettings{
- Asasalint: AsasalintSettings{
- UseBuiltinExclusions: true,
- },
- Decorder: DecorderSettings{
- DecOrder: []string{"type", "const", "var", "func"},
- DisableDecNumCheck: true,
- DisableDecOrderCheck: true,
- DisableInitFuncFirstCheck: true,
- },
- Dogsled: DogsledSettings{
- MaxBlankIdentifiers: 2,
- },
- Dupl: DuplSettings{
- Threshold: 150,
- },
- ErrorLint: ErrorLintSettings{
- Errorf: true,
- ErrorfMulti: true,
- Asserts: true,
- Comparison: true,
- },
- Exhaustive: ExhaustiveSettings{
- Check: []string{"switch"},
- CheckGenerated: false,
- DefaultSignifiesExhaustive: false,
- IgnoreEnumMembers: "",
- PackageScopeOnly: false,
- ExplicitExhaustiveMap: false,
- ExplicitExhaustiveSwitch: false,
- },
- Forbidigo: ForbidigoSettings{
- ExcludeGodocExamples: true,
- },
- Gci: GciSettings{
- Sections: []string{"standard", "default"},
- SkipGenerated: true,
- },
- GoChecksumType: GoChecksumTypeSettings{
- DefaultSignifiesExhaustive: true,
- },
- Gocognit: GocognitSettings{
- MinComplexity: 30,
- },
- Goconst: GoConstSettings{
- MatchWithConstants: true,
- MinStringLen: 3,
- MinOccurrencesCount: 3,
- NumberMin: 3,
- NumberMax: 3,
- IgnoreCalls: true,
- },
- Gocritic: GoCriticSettings{
- SettingsPerCheck: map[string]GoCriticCheckSettings{},
- },
- Gocyclo: GoCycloSettings{
- MinComplexity: 30,
- },
- Godox: GodoxSettings{
- Keywords: []string{},
- },
- Godot: GodotSettings{
- Scope: "declarations",
- Period: true,
- },
- Gofmt: GoFmtSettings{
- Simplify: true,
- },
- Gofumpt: GofumptSettings{
- LangVersion: "",
- ModulePath: "",
- ExtraRules: false,
- },
- Gosec: GoSecSettings{
- Concurrency: runtime.NumCPU(),
- },
- Gosmopolitan: GosmopolitanSettings{
- AllowTimeLocal: false,
- EscapeHatches: []string{},
- IgnoreTests: true,
- WatchForScripts: []string{"Han"},
- },
- Inamedparam: INamedParamSettings{
- SkipSingleParam: false,
- },
- InterfaceBloat: InterfaceBloatSettings{
- Max: 10,
- },
- Lll: LllSettings{
- LineLength: 120,
- TabWidth: 1,
- },
- LoggerCheck: LoggerCheckSettings{
- Kitlog: true,
- Klog: true,
- Logr: true,
- Slog: true,
- Zap: true,
- RequireStringKey: false,
- NoPrintfLike: false,
- Rules: nil,
- },
- MaintIdx: MaintIdxSettings{
- Under: 20,
- },
- Nakedret: NakedretSettings{
- MaxFuncLines: 30,
- },
- Nestif: NestifSettings{
- MinComplexity: 5,
- },
- NoLintLint: NoLintLintSettings{
- RequireExplanation: false,
- RequireSpecific: false,
- AllowUnused: false,
- },
- PerfSprint: PerfSprintSettings{
- IntegerFormat: true,
- IntConversion: true,
- ErrorFormat: true,
- ErrError: false,
- ErrorF: true,
- StringFormat: true,
- SprintF1: true,
- StrConcat: true,
- BoolFormat: true,
- HexFormat: true,
- },
- Prealloc: PreallocSettings{
- Simple: true,
- RangeLoops: true,
- ForLoops: false,
- },
- Predeclared: PredeclaredSettings{
- Ignore: "",
- Qualified: false,
- },
- SlogLint: SlogLintSettings{
- NoMixedArgs: true,
- KVOnly: false,
- AttrOnly: false,
- NoGlobal: "",
- Context: "",
- StaticMsg: false,
- NoRawKeys: false,
- KeyNamingCase: "",
- ForbiddenKeys: nil,
- ArgsOnSepLines: false,
- },
- TagAlign: TagAlignSettings{
- Align: true,
- Sort: true,
- Order: nil,
- Strict: false,
- },
- Testpackage: TestpackageSettings{
- SkipRegexp: `(export|internal)_test\.go`,
- AllowPackages: []string{"main"},
- },
- Unparam: UnparamSettings{
- Algo: "cha",
- },
- Unused: UnusedSettings{
- FieldWritesAreUses: true,
- PostStatementsAreReads: false,
- ExportedFieldsAreUsed: true,
- ParametersAreUsed: true,
- LocalVariablesAreUsed: true,
- GeneratedIsUsed: true,
- },
- UseStdlibVars: UseStdlibVarsSettings{
- HTTPMethod: true,
- HTTPStatusCode: true,
- },
- UseTesting: UseTestingSettings{
- ContextBackground: true,
- ContextTodo: true,
- OSChdir: true,
- OSMkdirTemp: true,
- OSSetenv: true,
- OSTempDir: false,
- OSCreateTemp: true,
- },
- Varnamelen: VarnamelenSettings{
- MaxDistance: 5,
- MinNameLength: 3,
- },
- WSL: WSLSettings{
- StrictAppend: true,
- AllowAssignAndCallCuddle: true,
- AllowAssignAndAnythingCuddle: false,
- AllowMultiLineAssignCuddle: true,
- ForceCaseTrailingWhitespaceLimit: 0,
- AllowTrailingComment: false,
- AllowSeparatedLeadingComment: false,
- AllowCuddleDeclaration: false,
- AllowCuddleWithCalls: []string{"Lock", "RLock"},
- AllowCuddleWithRHS: []string{"Unlock", "RUnlock"},
- ForceCuddleErrCheckAndAssign: false,
- ErrorVariableNames: []string{"err"},
- ForceExclusiveShortDeclarations: false,
- },
-}
-
-type LintersSettings struct {
- Asasalint AsasalintSettings
- BiDiChk BiDiChkSettings
- CopyLoopVar CopyLoopVarSettings
- Cyclop Cyclop
- Decorder DecorderSettings
- Depguard DepGuardSettings
- Dogsled DogsledSettings
- Dupl DuplSettings
- DupWord DupWordSettings
- Errcheck ErrcheckSettings
- ErrChkJSON ErrChkJSONSettings
- ErrorLint ErrorLintSettings
- Exhaustive ExhaustiveSettings
- Exhaustruct ExhaustructSettings
- Fatcontext FatcontextSettings
- Forbidigo ForbidigoSettings
- Funlen FunlenSettings
- Gci GciSettings
- GinkgoLinter GinkgoLinterSettings
- Gocognit GocognitSettings
- GoChecksumType GoChecksumTypeSettings
- Goconst GoConstSettings
- Gocritic GoCriticSettings
- Gocyclo GoCycloSettings
- Godot GodotSettings
- Godox GodoxSettings
- Gofmt GoFmtSettings
- Gofumpt GofumptSettings
- Goheader GoHeaderSettings
- Goimports GoImportsSettings
- GoModDirectives GoModDirectivesSettings
- Gomodguard GoModGuardSettings
- Gosec GoSecSettings
- Gosimple StaticCheckSettings
- Gosmopolitan GosmopolitanSettings
- Govet GovetSettings
- Grouper GrouperSettings
- Iface IfaceSettings
- ImportAs ImportAsSettings
- Inamedparam INamedParamSettings
- InterfaceBloat InterfaceBloatSettings
- Ireturn IreturnSettings
- Lll LllSettings
- LoggerCheck LoggerCheckSettings
- MaintIdx MaintIdxSettings
- Makezero MakezeroSettings
- Misspell MisspellSettings
- Mnd MndSettings
- MustTag MustTagSettings
- Nakedret NakedretSettings
- Nestif NestifSettings
- NilNil NilNilSettings
- Nlreturn NlreturnSettings
- NoLintLint NoLintLintSettings
- NoNamedReturns NoNamedReturnsSettings
- ParallelTest ParallelTestSettings
- PerfSprint PerfSprintSettings
- Prealloc PreallocSettings
- Predeclared PredeclaredSettings
- Promlinter PromlinterSettings
- ProtoGetter ProtoGetterSettings
- Reassign ReassignSettings
- Recvcheck RecvcheckSettings
- Revive ReviveSettings
- RowsErrCheck RowsErrCheckSettings
- SlogLint SlogLintSettings
- Spancheck SpancheckSettings
- Staticcheck StaticCheckSettings
- Stylecheck StaticCheckSettings
- TagAlign TagAlignSettings
- Tagliatelle TagliatelleSettings
- Tenv TenvSettings
- Testifylint TestifylintSettings
- Testpackage TestpackageSettings
- Thelper ThelperSettings
- Unconvert UnconvertSettings
- Unparam UnparamSettings
- Unused UnusedSettings
- UseStdlibVars UseStdlibVarsSettings
- UseTesting UseTestingSettings
- Varnamelen VarnamelenSettings
- Whitespace WhitespaceSettings
- Wrapcheck WrapcheckSettings
- WSL WSLSettings
-
- Custom map[string]CustomLinterSettings
-}
-
-func (s *LintersSettings) Validate() error {
- if err := s.Govet.Validate(); err != nil {
- return err
- }
-
- for name, settings := range s.Custom {
- if err := settings.Validate(); err != nil {
- return fmt.Errorf("custom linter %q: %w", name, err)
- }
- }
-
- return nil
-}
-
-type AsasalintSettings struct {
- Exclude []string `mapstructure:"exclude"`
- UseBuiltinExclusions bool `mapstructure:"use-builtin-exclusions"`
- IgnoreTest bool `mapstructure:"ignore-test"`
-}
-
-type BiDiChkSettings struct {
- LeftToRightEmbedding bool `mapstructure:"left-to-right-embedding"`
- RightToLeftEmbedding bool `mapstructure:"right-to-left-embedding"`
- PopDirectionalFormatting bool `mapstructure:"pop-directional-formatting"`
- LeftToRightOverride bool `mapstructure:"left-to-right-override"`
- RightToLeftOverride bool `mapstructure:"right-to-left-override"`
- LeftToRightIsolate bool `mapstructure:"left-to-right-isolate"`
- RightToLeftIsolate bool `mapstructure:"right-to-left-isolate"`
- FirstStrongIsolate bool `mapstructure:"first-strong-isolate"`
- PopDirectionalIsolate bool `mapstructure:"pop-directional-isolate"`
-}
-
-type CopyLoopVarSettings struct {
- CheckAlias bool `mapstructure:"check-alias"`
-
- // Deprecated: use CheckAlias
- IgnoreAlias *bool `mapstructure:"ignore-alias"`
-}
-
-type Cyclop struct {
- MaxComplexity int `mapstructure:"max-complexity"`
- PackageAverage float64 `mapstructure:"package-average"`
- SkipTests bool `mapstructure:"skip-tests"`
-}
-
-type DepGuardSettings struct {
- Rules map[string]*DepGuardList `mapstructure:"rules"`
-}
-
-type DepGuardList struct {
- ListMode string `mapstructure:"list-mode"`
- Files []string `mapstructure:"files"`
- Allow []string `mapstructure:"allow"`
- Deny []DepGuardDeny `mapstructure:"deny"`
-}
-
-type DepGuardDeny struct {
- Pkg string `mapstructure:"pkg"`
- Desc string `mapstructure:"desc"`
-}
-
-type DecorderSettings struct {
- DecOrder []string `mapstructure:"dec-order"`
- IgnoreUnderscoreVars bool `mapstructure:"ignore-underscore-vars"`
- DisableDecNumCheck bool `mapstructure:"disable-dec-num-check"`
- DisableTypeDecNumCheck bool `mapstructure:"disable-type-dec-num-check"`
- DisableConstDecNumCheck bool `mapstructure:"disable-const-dec-num-check"`
- DisableVarDecNumCheck bool `mapstructure:"disable-var-dec-num-check"`
- DisableDecOrderCheck bool `mapstructure:"disable-dec-order-check"`
- DisableInitFuncFirstCheck bool `mapstructure:"disable-init-func-first-check"`
-}
-
-type DogsledSettings struct {
- MaxBlankIdentifiers int `mapstructure:"max-blank-identifiers"`
-}
-
-type DuplSettings struct {
- Threshold int
-}
-
-type DupWordSettings struct {
- Keywords []string `mapstructure:"keywords"`
- Ignore []string `mapstructure:"ignore"`
-}
-
-type ErrcheckSettings struct {
- DisableDefaultExclusions bool `mapstructure:"disable-default-exclusions"`
- CheckTypeAssertions bool `mapstructure:"check-type-assertions"`
- CheckAssignToBlank bool `mapstructure:"check-blank"`
- ExcludeFunctions []string `mapstructure:"exclude-functions"`
-
- // Deprecated: use ExcludeFunctions instead
- Exclude string `mapstructure:"exclude"`
-
- // Deprecated: use ExcludeFunctions instead
- Ignore string `mapstructure:"ignore"`
-}
-
-type ErrChkJSONSettings struct {
- CheckErrorFreeEncoding bool `mapstructure:"check-error-free-encoding"`
- ReportNoExported bool `mapstructure:"report-no-exported"`
-}
-
-type ErrorLintSettings struct {
- Errorf bool `mapstructure:"errorf"`
- ErrorfMulti bool `mapstructure:"errorf-multi"`
- Asserts bool `mapstructure:"asserts"`
- Comparison bool `mapstructure:"comparison"`
- AllowedErrors []ErrorLintAllowPair `mapstructure:"allowed-errors"`
- AllowedErrorsWildcard []ErrorLintAllowPair `mapstructure:"allowed-errors-wildcard"`
-}
-
-type ErrorLintAllowPair struct {
- Err string `mapstructure:"err"`
- Fun string `mapstructure:"fun"`
-}
-
-type ExhaustiveSettings struct {
- Check []string `mapstructure:"check"`
- CheckGenerated bool `mapstructure:"check-generated"`
- DefaultSignifiesExhaustive bool `mapstructure:"default-signifies-exhaustive"`
- IgnoreEnumMembers string `mapstructure:"ignore-enum-members"`
- IgnoreEnumTypes string `mapstructure:"ignore-enum-types"`
- PackageScopeOnly bool `mapstructure:"package-scope-only"`
- ExplicitExhaustiveMap bool `mapstructure:"explicit-exhaustive-map"`
- ExplicitExhaustiveSwitch bool `mapstructure:"explicit-exhaustive-switch"`
- DefaultCaseRequired bool `mapstructure:"default-case-required"`
-}
-
-type ExhaustructSettings struct {
- Include []string `mapstructure:"include"`
- Exclude []string `mapstructure:"exclude"`
-}
-
-type FatcontextSettings struct {
- CheckStructPointers bool `mapstructure:"check-struct-pointers"`
-}
-
-type ForbidigoSettings struct {
- Forbid []ForbidigoPattern `mapstructure:"forbid"`
- ExcludeGodocExamples bool `mapstructure:"exclude-godoc-examples"`
- AnalyzeTypes bool `mapstructure:"analyze-types"`
-}
-
-var _ encoding.TextUnmarshaler = &ForbidigoPattern{}
-
-// ForbidigoPattern corresponds to forbidigo.pattern and adds mapstructure support.
-// The YAML field names must match what forbidigo expects.
-type ForbidigoPattern struct {
- // patternString gets populated when the config contains a string as entry in ForbidigoSettings.Forbid[]
- // because ForbidigoPattern implements encoding.TextUnmarshaler
- // and the reader uses the mapstructure.TextUnmarshallerHookFunc as decoder hook.
- //
- // If the entry is a map, then the other fields are set as usual by mapstructure.
- patternString string
-
- Pattern string `yaml:"p" mapstructure:"p"`
- Package string `yaml:"pkg,omitempty" mapstructure:"pkg,omitempty"`
- Msg string `yaml:"msg,omitempty" mapstructure:"msg,omitempty"`
-}
-
-func (p *ForbidigoPattern) UnmarshalText(text []byte) error {
- // Validation happens when instantiating forbidigo.
- p.patternString = string(text)
- return nil
-}
-
-// MarshalString converts the pattern into a string as needed by forbidigo.NewLinter.
-//
-// MarshalString is intentionally not called MarshalText,
-// although it has the same signature
-// because implementing encoding.TextMarshaler led to infinite recursion when yaml.Marshal called MarshalText.
-func (p *ForbidigoPattern) MarshalString() ([]byte, error) {
- if p.patternString != "" {
- return []byte(p.patternString), nil
- }
-
- return yaml.Marshal(p)
-}
-
-type FunlenSettings struct {
- Lines int
- Statements int
- IgnoreComments bool `mapstructure:"ignore-comments"`
-}
-
-type GciSettings struct {
- Sections []string `mapstructure:"sections"`
- NoInlineComments bool `mapstructure:"no-inline-comments"`
- NoPrefixComments bool `mapstructure:"no-prefix-comments"`
- SkipGenerated bool `mapstructure:"skip-generated"`
- CustomOrder bool `mapstructure:"custom-order"`
- NoLexOrder bool `mapstructure:"no-lex-order"`
-
- // Deprecated: use Sections instead.
- LocalPrefixes string `mapstructure:"local-prefixes"`
-}
-
-type GinkgoLinterSettings struct {
- SuppressLenAssertion bool `mapstructure:"suppress-len-assertion"`
- SuppressNilAssertion bool `mapstructure:"suppress-nil-assertion"`
- SuppressErrAssertion bool `mapstructure:"suppress-err-assertion"`
- SuppressCompareAssertion bool `mapstructure:"suppress-compare-assertion"`
- SuppressAsyncAssertion bool `mapstructure:"suppress-async-assertion"`
- SuppressTypeCompareWarning bool `mapstructure:"suppress-type-compare-assertion"`
- ForbidFocusContainer bool `mapstructure:"forbid-focus-container"`
- AllowHaveLenZero bool `mapstructure:"allow-havelen-zero"`
- ForceExpectTo bool `mapstructure:"force-expect-to"`
- ValidateAsyncIntervals bool `mapstructure:"validate-async-intervals"`
- ForbidSpecPollution bool `mapstructure:"forbid-spec-pollution"`
- ForceSucceedForFuncs bool `mapstructure:"force-succeed"`
-}
-
-type GoChecksumTypeSettings struct {
- DefaultSignifiesExhaustive bool `mapstructure:"default-signifies-exhaustive"`
- IncludeSharedInterfaces bool `mapstructure:"include-shared-interfaces"`
-}
-
-type GocognitSettings struct {
- MinComplexity int `mapstructure:"min-complexity"`
-}
-
-type GoConstSettings struct {
- IgnoreStrings string `mapstructure:"ignore-strings"`
- IgnoreTests bool `mapstructure:"ignore-tests"`
- MatchWithConstants bool `mapstructure:"match-constant"`
- MinStringLen int `mapstructure:"min-len"`
- MinOccurrencesCount int `mapstructure:"min-occurrences"`
- ParseNumbers bool `mapstructure:"numbers"`
- NumberMin int `mapstructure:"min"`
- NumberMax int `mapstructure:"max"`
- IgnoreCalls bool `mapstructure:"ignore-calls"`
-}
-
-type GoCriticSettings struct {
- Go string `mapstructure:"-"`
- DisableAll bool `mapstructure:"disable-all"`
- EnabledChecks []string `mapstructure:"enabled-checks"`
- EnableAll bool `mapstructure:"enable-all"`
- DisabledChecks []string `mapstructure:"disabled-checks"`
- EnabledTags []string `mapstructure:"enabled-tags"`
- DisabledTags []string `mapstructure:"disabled-tags"`
- SettingsPerCheck map[string]GoCriticCheckSettings `mapstructure:"settings"`
-}
-
-type GoCriticCheckSettings map[string]any
-
-type GoCycloSettings struct {
- MinComplexity int `mapstructure:"min-complexity"`
-}
-
-type GodotSettings struct {
- Scope string `mapstructure:"scope"`
- Exclude []string `mapstructure:"exclude"`
- Capital bool `mapstructure:"capital"`
- Period bool `mapstructure:"period"`
-
- // Deprecated: use Scope instead
- CheckAll *bool `mapstructure:"check-all"`
-}
-
-type GodoxSettings struct {
- Keywords []string
-}
-
-type GoFmtSettings struct {
- Simplify bool
- RewriteRules []GoFmtRewriteRule `mapstructure:"rewrite-rules"`
-}
-
-type GoFmtRewriteRule struct {
- Pattern string
- Replacement string
-}
-
-type GofumptSettings struct {
- ModulePath string `mapstructure:"module-path"`
- ExtraRules bool `mapstructure:"extra-rules"`
-
- // Deprecated: use the global `run.go` instead.
- LangVersion string `mapstructure:"lang-version"`
-}
-
-type GoHeaderSettings struct {
- Values map[string]map[string]string `mapstructure:"values"`
- Template string `mapstructure:"template"`
- TemplatePath string `mapstructure:"template-path"`
-}
-
-type GoImportsSettings struct {
- LocalPrefixes string `mapstructure:"local-prefixes"`
-}
-
-type GoModDirectivesSettings struct {
- ReplaceAllowList []string `mapstructure:"replace-allow-list"`
- ReplaceLocal bool `mapstructure:"replace-local"`
- ExcludeForbidden bool `mapstructure:"exclude-forbidden"`
- RetractAllowNoExplanation bool `mapstructure:"retract-allow-no-explanation"`
- ToolchainForbidden bool `mapstructure:"toolchain-forbidden"`
- ToolchainPattern string `mapstructure:"toolchain-pattern"`
- ToolForbidden bool `mapstructure:"tool-forbidden"`
- GoDebugForbidden bool `mapstructure:"go-debug-forbidden"`
- GoVersionPattern string `mapstructure:"go-version-pattern"`
-}
-
-type GoModGuardSettings struct {
- Allowed struct {
- Modules []string `mapstructure:"modules"`
- Domains []string `mapstructure:"domains"`
- } `mapstructure:"allowed"`
- Blocked struct {
- Modules []map[string]struct {
- Recommendations []string `mapstructure:"recommendations"`
- Reason string `mapstructure:"reason"`
- } `mapstructure:"modules"`
- Versions []map[string]struct {
- Version string `mapstructure:"version"`
- Reason string `mapstructure:"reason"`
- } `mapstructure:"versions"`
- LocalReplaceDirectives bool `mapstructure:"local_replace_directives"`
- } `mapstructure:"blocked"`
-}
-
-type GoSecSettings struct {
- Includes []string `mapstructure:"includes"`
- Excludes []string `mapstructure:"excludes"`
- Severity string `mapstructure:"severity"`
- Confidence string `mapstructure:"confidence"`
- ExcludeGenerated bool `mapstructure:"exclude-generated"`
- Config map[string]any `mapstructure:"config"`
- Concurrency int `mapstructure:"concurrency"`
-}
-
-type GosmopolitanSettings struct {
- AllowTimeLocal bool `mapstructure:"allow-time-local"`
- EscapeHatches []string `mapstructure:"escape-hatches"`
- IgnoreTests bool `mapstructure:"ignore-tests"`
- WatchForScripts []string `mapstructure:"watch-for-scripts"`
-}
-
-type GovetSettings struct {
- Go string `mapstructure:"-"`
-
- Enable []string
- Disable []string
- EnableAll bool `mapstructure:"enable-all"`
- DisableAll bool `mapstructure:"disable-all"`
-
- Settings map[string]map[string]any
-
- // Deprecated: the linter should be enabled inside Enable.
- CheckShadowing *bool `mapstructure:"check-shadowing"`
-}
-
-func (cfg *GovetSettings) Validate() error {
- if cfg.EnableAll && cfg.DisableAll {
- return errors.New("govet: enable-all and disable-all can't be combined")
- }
- if cfg.EnableAll && len(cfg.Enable) != 0 {
- return errors.New("govet: enable-all and enable can't be combined")
- }
- if cfg.DisableAll && len(cfg.Disable) != 0 {
- return errors.New("govet: disable-all and disable can't be combined")
- }
- return nil
-}
-
-type GrouperSettings struct {
- ConstRequireSingleConst bool `mapstructure:"const-require-single-const"`
- ConstRequireGrouping bool `mapstructure:"const-require-grouping"`
- ImportRequireSingleImport bool `mapstructure:"import-require-single-import"`
- ImportRequireGrouping bool `mapstructure:"import-require-grouping"`
- TypeRequireSingleType bool `mapstructure:"type-require-single-type"`
- TypeRequireGrouping bool `mapstructure:"type-require-grouping"`
- VarRequireSingleVar bool `mapstructure:"var-require-single-var"`
- VarRequireGrouping bool `mapstructure:"var-require-grouping"`
-}
-
-type IfaceSettings struct {
- Enable []string `mapstructure:"enable"`
- Settings map[string]map[string]any `mapstructure:"settings"`
-}
-
-type ImportAsSettings struct {
- Alias []ImportAsAlias
- NoUnaliased bool `mapstructure:"no-unaliased"`
- NoExtraAliases bool `mapstructure:"no-extra-aliases"`
-}
-
-type ImportAsAlias struct {
- Pkg string
- Alias string
-}
-
-type INamedParamSettings struct {
- SkipSingleParam bool `mapstructure:"skip-single-param"`
-}
-
-type InterfaceBloatSettings struct {
- Max int `mapstructure:"max"`
-}
-
-type IreturnSettings struct {
- Allow []string `mapstructure:"allow"`
- Reject []string `mapstructure:"reject"`
-}
-
-type LllSettings struct {
- LineLength int `mapstructure:"line-length"`
- TabWidth int `mapstructure:"tab-width"`
-}
-
-type LoggerCheckSettings struct {
- Kitlog bool `mapstructure:"kitlog"`
- Klog bool `mapstructure:"klog"`
- Logr bool `mapstructure:"logr"`
- Slog bool `mapstructure:"slog"`
- Zap bool `mapstructure:"zap"`
- RequireStringKey bool `mapstructure:"require-string-key"`
- NoPrintfLike bool `mapstructure:"no-printf-like"`
- Rules []string `mapstructure:"rules"`
-}
-
-type MaintIdxSettings struct {
- Under int `mapstructure:"under"`
-}
-
-type MakezeroSettings struct {
- Always bool
-}
-
-type MisspellSettings struct {
- Mode string `mapstructure:"mode"`
- Locale string `mapstructure:"locale"`
- ExtraWords []MisspellExtraWords `mapstructure:"extra-words"`
- // TODO(ldez): v2 the option must be renamed to `IgnoredRules`.
- IgnoreWords []string `mapstructure:"ignore-words"`
-}
-
-type MisspellExtraWords struct {
- Typo string `mapstructure:"typo"`
- Correction string `mapstructure:"correction"`
-}
-
-type MustTagSettings struct {
- Functions []struct {
- Name string `mapstructure:"name"`
- Tag string `mapstructure:"tag"`
- ArgPos int `mapstructure:"arg-pos"`
- } `mapstructure:"functions"`
-}
-
-type NakedretSettings struct {
- MaxFuncLines uint `mapstructure:"max-func-lines"`
-}
-
-type NestifSettings struct {
- MinComplexity int `mapstructure:"min-complexity"`
-}
-
-type NilNilSettings struct {
- DetectOpposite bool `mapstructure:"detect-opposite"`
- CheckedTypes []string `mapstructure:"checked-types"`
-}
-
-type NlreturnSettings struct {
- BlockSize int `mapstructure:"block-size"`
-}
-
-type MndSettings struct {
- Checks []string `mapstructure:"checks"`
- IgnoredNumbers []string `mapstructure:"ignored-numbers"`
- IgnoredFiles []string `mapstructure:"ignored-files"`
- IgnoredFunctions []string `mapstructure:"ignored-functions"`
-}
-
-type NoLintLintSettings struct {
- RequireExplanation bool `mapstructure:"require-explanation"`
- RequireSpecific bool `mapstructure:"require-specific"`
- AllowNoExplanation []string `mapstructure:"allow-no-explanation"`
- AllowUnused bool `mapstructure:"allow-unused"`
-}
-
-type NoNamedReturnsSettings struct {
- ReportErrorInDefer bool `mapstructure:"report-error-in-defer"`
-}
-
-type ParallelTestSettings struct {
- Go string `mapstructure:"-"`
- IgnoreMissing bool `mapstructure:"ignore-missing"`
- IgnoreMissingSubtests bool `mapstructure:"ignore-missing-subtests"`
-}
-
-type PerfSprintSettings struct {
- IntegerFormat bool `mapstructure:"integer-format"`
- IntConversion bool `mapstructure:"int-conversion"`
-
- ErrorFormat bool `mapstructure:"error-format"`
- ErrError bool `mapstructure:"err-error"`
- ErrorF bool `mapstructure:"errorf"`
-
- StringFormat bool `mapstructure:"string-format"`
- SprintF1 bool `mapstructure:"sprintf1"`
- StrConcat bool `mapstructure:"strconcat"`
-
- BoolFormat bool `mapstructure:"bool-format"`
- HexFormat bool `mapstructure:"hex-format"`
-}
-
-type PreallocSettings struct {
- Simple bool
- RangeLoops bool `mapstructure:"range-loops"`
- ForLoops bool `mapstructure:"for-loops"`
-}
-
-type PredeclaredSettings struct {
- Ignore string `mapstructure:"ignore"`
- Qualified bool `mapstructure:"q"`
-}
-
-type PromlinterSettings struct {
- Strict bool `mapstructure:"strict"`
- DisabledLinters []string `mapstructure:"disabled-linters"`
-}
-
-type ProtoGetterSettings struct {
- SkipGeneratedBy []string `mapstructure:"skip-generated-by"`
- SkipFiles []string `mapstructure:"skip-files"`
- SkipAnyGenerated bool `mapstructure:"skip-any-generated"`
- ReplaceFirstArgInAppend bool `mapstructure:"replace-first-arg-in-append"`
-}
-
-type ReassignSettings struct {
- Patterns []string `mapstructure:"patterns"`
-}
-
-type RecvcheckSettings struct {
- DisableBuiltin bool `mapstructure:"disable-builtin"`
- Exclusions []string `mapstructure:"exclusions"`
-}
-
-type ReviveSettings struct {
- Go string `mapstructure:"-"`
- MaxOpenFiles int `mapstructure:"max-open-files"`
- IgnoreGeneratedHeader bool `mapstructure:"ignore-generated-header"`
- Confidence float64
- Severity string
- EnableAllRules bool `mapstructure:"enable-all-rules"`
- Rules []struct {
- Name string
- Arguments []any
- Severity string
- Disabled bool
- Exclude []string
- }
- ErrorCode int `mapstructure:"error-code"`
- WarningCode int `mapstructure:"warning-code"`
- Directives []struct {
- Name string
- Severity string
- }
-}
-
-type RowsErrCheckSettings struct {
- Packages []string
-}
-
-type SlogLintSettings struct {
- NoMixedArgs bool `mapstructure:"no-mixed-args"`
- KVOnly bool `mapstructure:"kv-only"`
- AttrOnly bool `mapstructure:"attr-only"`
- NoGlobal string `mapstructure:"no-global"`
- Context string `mapstructure:"context"`
- StaticMsg bool `mapstructure:"static-msg"`
- NoRawKeys bool `mapstructure:"no-raw-keys"`
- KeyNamingCase string `mapstructure:"key-naming-case"`
- ForbiddenKeys []string `mapstructure:"forbidden-keys"`
- ArgsOnSepLines bool `mapstructure:"args-on-sep-lines"`
-
- // Deprecated: use Context instead.
- ContextOnly *bool `mapstructure:"context-only"`
-}
-
-type SpancheckSettings struct {
- Checks []string `mapstructure:"checks"`
- IgnoreCheckSignatures []string `mapstructure:"ignore-check-signatures"`
- ExtraStartSpanSignatures []string `mapstructure:"extra-start-span-signatures"`
-}
-
-type StaticCheckSettings struct {
- Checks []string `mapstructure:"checks"`
- Initialisms []string `mapstructure:"initialisms"` // only for stylecheck
- DotImportWhitelist []string `mapstructure:"dot-import-whitelist"` // only for stylecheck
- HTTPStatusCodeWhitelist []string `mapstructure:"http-status-code-whitelist"` // only for stylecheck
-
- // Deprecated: use the global `run.go` instead.
- GoVersion string `mapstructure:"go"`
-}
-
-func (s *StaticCheckSettings) HasConfiguration() bool {
- return len(s.Initialisms) > 0 || len(s.HTTPStatusCodeWhitelist) > 0 || len(s.DotImportWhitelist) > 0 || len(s.Checks) > 0
-}
-
-type TagAlignSettings struct {
- Align bool `mapstructure:"align"`
- Sort bool `mapstructure:"sort"`
- Order []string `mapstructure:"order"`
- Strict bool `mapstructure:"strict"`
-}
-
-type TagliatelleSettings struct {
- Case TagliatelleCase
-}
-
-type TagliatelleCase struct {
- TagliatelleBase `mapstructure:",squash"`
- Overrides []TagliatelleOverrides
-}
-
-type TagliatelleOverrides struct {
- TagliatelleBase `mapstructure:",squash"`
- Package string `mapstructure:"pkg"`
- Ignore bool `mapstructure:"ignore"`
-}
-
-type TagliatelleBase struct {
- Rules map[string]string `mapstructure:"rules"`
- ExtendedRules map[string]TagliatelleExtendedRule `mapstructure:"extended-rules"`
- UseFieldName bool `mapstructure:"use-field-name"`
- IgnoredFields []string `mapstructure:"ignored-fields"`
-}
-
-type TagliatelleExtendedRule struct {
- Case string
- ExtraInitialisms bool
- InitialismOverrides map[string]bool
-}
-
-type TestifylintSettings struct {
- EnableAll bool `mapstructure:"enable-all"`
- DisableAll bool `mapstructure:"disable-all"`
- EnabledCheckers []string `mapstructure:"enable"`
- DisabledCheckers []string `mapstructure:"disable"`
-
- BoolCompare struct {
- IgnoreCustomTypes bool `mapstructure:"ignore-custom-types"`
- } `mapstructure:"bool-compare"`
-
- ExpectedActual struct {
- ExpVarPattern string `mapstructure:"pattern"`
- } `mapstructure:"expected-actual"`
-
- Formatter struct {
- CheckFormatString *bool `mapstructure:"check-format-string"`
- RequireFFuncs bool `mapstructure:"require-f-funcs"`
- } `mapstructure:"formatter"`
-
- GoRequire struct {
- IgnoreHTTPHandlers bool `mapstructure:"ignore-http-handlers"`
- } `mapstructure:"go-require"`
-
- RequireError struct {
- FnPattern string `mapstructure:"fn-pattern"`
- } `mapstructure:"require-error"`
-
- SuiteExtraAssertCall struct {
- Mode string `mapstructure:"mode"`
- } `mapstructure:"suite-extra-assert-call"`
-}
-
-type TestpackageSettings struct {
- SkipRegexp string `mapstructure:"skip-regexp"`
- AllowPackages []string `mapstructure:"allow-packages"`
-}
-
-type ThelperSettings struct {
- Test ThelperOptions `mapstructure:"test"`
- Fuzz ThelperOptions `mapstructure:"fuzz"`
- Benchmark ThelperOptions `mapstructure:"benchmark"`
- TB ThelperOptions `mapstructure:"tb"`
-}
-
-type ThelperOptions struct {
- First *bool `mapstructure:"first"`
- Name *bool `mapstructure:"name"`
- Begin *bool `mapstructure:"begin"`
-}
-
-type TenvSettings struct {
- All bool `mapstructure:"all"`
-}
-
-type UseStdlibVarsSettings struct {
- HTTPMethod bool `mapstructure:"http-method"`
- HTTPStatusCode bool `mapstructure:"http-status-code"`
- TimeWeekday bool `mapstructure:"time-weekday"`
- TimeMonth bool `mapstructure:"time-month"`
- TimeLayout bool `mapstructure:"time-layout"`
- CryptoHash bool `mapstructure:"crypto-hash"`
- DefaultRPCPath bool `mapstructure:"default-rpc-path"`
- SQLIsolationLevel bool `mapstructure:"sql-isolation-level"`
- TLSSignatureScheme bool `mapstructure:"tls-signature-scheme"`
- ConstantKind bool `mapstructure:"constant-kind"`
-
- // Deprecated
- OSDevNull *bool `mapstructure:"os-dev-null"`
- // Deprecated
- SyslogPriority *bool `mapstructure:"syslog-priority"`
-}
-
-type UseTestingSettings struct {
- ContextBackground bool `mapstructure:"context-background"`
- ContextTodo bool `mapstructure:"context-todo"`
- OSChdir bool `mapstructure:"os-chdir"`
- OSMkdirTemp bool `mapstructure:"os-mkdir-temp"`
- OSSetenv bool `mapstructure:"os-setenv"`
- OSTempDir bool `mapstructure:"os-temp-dir"`
- OSCreateTemp bool `mapstructure:"os-create-temp"`
-}
-
-type UnconvertSettings struct {
- FastMath bool `mapstructure:"fast-math"`
- Safe bool `mapstructure:"safe"`
-}
-
-type UnparamSettings struct {
- CheckExported bool `mapstructure:"check-exported"`
- Algo string
-}
-
-type UnusedSettings struct {
- FieldWritesAreUses bool `mapstructure:"field-writes-are-uses"`
- PostStatementsAreReads bool `mapstructure:"post-statements-are-reads"`
- ExportedFieldsAreUsed bool `mapstructure:"exported-fields-are-used"`
- ParametersAreUsed bool `mapstructure:"parameters-are-used"`
- LocalVariablesAreUsed bool `mapstructure:"local-variables-are-used"`
- GeneratedIsUsed bool `mapstructure:"generated-is-used"`
-
- // Deprecated
- ExportedIsUsed *bool `mapstructure:"exported-is-used"`
-}
-
-type VarnamelenSettings struct {
- MaxDistance int `mapstructure:"max-distance"`
- MinNameLength int `mapstructure:"min-name-length"`
- CheckReceiver bool `mapstructure:"check-receiver"`
- CheckReturn bool `mapstructure:"check-return"`
- CheckTypeParam bool `mapstructure:"check-type-param"`
- IgnoreNames []string `mapstructure:"ignore-names"`
- IgnoreTypeAssertOk bool `mapstructure:"ignore-type-assert-ok"`
- IgnoreMapIndexOk bool `mapstructure:"ignore-map-index-ok"`
- IgnoreChanRecvOk bool `mapstructure:"ignore-chan-recv-ok"`
- IgnoreDecls []string `mapstructure:"ignore-decls"`
-}
-
-type WhitespaceSettings struct {
- MultiIf bool `mapstructure:"multi-if"`
- MultiFunc bool `mapstructure:"multi-func"`
-}
-
-type WrapcheckSettings struct {
- ExtraIgnoreSigs []string `mapstructure:"extra-ignore-sigs"`
- // TODO(ldez): v2 the options must be renamed to use hyphen.
- IgnoreSigs []string `mapstructure:"ignoreSigs"`
- IgnoreSigRegexps []string `mapstructure:"ignoreSigRegexps"`
- IgnorePackageGlobs []string `mapstructure:"ignorePackageGlobs"`
- IgnoreInterfaceRegexps []string `mapstructure:"ignoreInterfaceRegexps"`
-}
-
-type WSLSettings struct {
- StrictAppend bool `mapstructure:"strict-append"`
- AllowAssignAndCallCuddle bool `mapstructure:"allow-assign-and-call"`
- AllowAssignAndAnythingCuddle bool `mapstructure:"allow-assign-and-anything"`
- AllowMultiLineAssignCuddle bool `mapstructure:"allow-multiline-assign"`
- ForceCaseTrailingWhitespaceLimit int `mapstructure:"force-case-trailing-whitespace"`
- AllowTrailingComment bool `mapstructure:"allow-trailing-comment"`
- AllowSeparatedLeadingComment bool `mapstructure:"allow-separated-leading-comment"`
- AllowCuddleDeclaration bool `mapstructure:"allow-cuddle-declarations"`
- AllowCuddleWithCalls []string `mapstructure:"allow-cuddle-with-calls"`
- AllowCuddleWithRHS []string `mapstructure:"allow-cuddle-with-rhs"`
- ForceCuddleErrCheckAndAssign bool `mapstructure:"force-err-cuddling"`
- ErrorVariableNames []string `mapstructure:"error-variable-names"`
- ForceExclusiveShortDeclarations bool `mapstructure:"force-short-decl-cuddling"`
-}
-
-// CustomLinterSettings encapsulates the meta-data of a private linter.
-type CustomLinterSettings struct {
- // Type plugin type.
- // It can be `goplugin` or `module`.
- Type string `mapstructure:"type"`
-
- // Path to a plugin *.so file that implements the private linter.
- // Only for Go plugin system.
- Path string
-
- // Description describes the purpose of the private linter.
- Description string
- // OriginalURL The URL containing the source code for the private linter.
- OriginalURL string `mapstructure:"original-url"`
-
- // Settings plugin settings only work with linterdb.PluginConstructor symbol.
- Settings any
-}
-
-func (s *CustomLinterSettings) Validate() error {
- if s.Type == "module" {
- if s.Path != "" {
- return errors.New("path not supported with module type")
- }
-
- return nil
- }
-
- if s.Path == "" {
- return errors.New("path is required")
- }
-
- return nil
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/config/loader.go b/vendor/github.com/golangci/golangci-lint/pkg/config/loader.go
deleted file mode 100644
index dc9ceeadd1..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/config/loader.go
+++ /dev/null
@@ -1,507 +0,0 @@
-package config
-
-import (
- "cmp"
- "context"
- "errors"
- "fmt"
- "os"
- "path/filepath"
- "slices"
-
- "github.com/go-viper/mapstructure/v2"
- "github.com/mitchellh/go-homedir"
- "github.com/spf13/pflag"
- "github.com/spf13/viper"
-
- "github.com/golangci/golangci-lint/pkg/exitcodes"
- "github.com/golangci/golangci-lint/pkg/fsutils"
- "github.com/golangci/golangci-lint/pkg/goutil"
- "github.com/golangci/golangci-lint/pkg/logutils"
-)
-
-var errConfigDisabled = errors.New("config is disabled by --no-config")
-
-type LoaderOptions struct {
- Config string // Flag only. The path to the golangci config file, as specified with the --config argument.
- NoConfig bool // Flag only.
-}
-
-type LoadOptions struct {
- CheckDeprecation bool
- Validation bool
-}
-
-type Loader struct {
- opts LoaderOptions
-
- viper *viper.Viper
- fs *pflag.FlagSet
-
- log logutils.Log
-
- cfg *Config
- args []string
-}
-
-func NewLoader(log logutils.Log, v *viper.Viper, fs *pflag.FlagSet, opts LoaderOptions, cfg *Config, args []string) *Loader {
- return &Loader{
- opts: opts,
- viper: v,
- fs: fs,
- log: log,
- cfg: cfg,
- args: args,
- }
-}
-
-func (l *Loader) Load(opts LoadOptions) error {
- err := l.setConfigFile()
- if err != nil {
- return err
- }
-
- err = l.parseConfig()
- if err != nil {
- return err
- }
-
- l.applyStringSliceHack()
-
- if l.cfg.Linters.LinterExclusions.Generated == "" {
- // `l.cfg.Issues.ExcludeGenerated` is always non-empty because of the flag default value.
- l.cfg.Linters.LinterExclusions.Generated = cmp.Or(l.cfg.Issues.ExcludeGenerated, "strict")
- }
-
- // Compatibility layer with v1.
- // TODO(ldez): should be removed in v2.
- if l.cfg.Issues.UseDefaultExcludes {
- l.cfg.Linters.LinterExclusions.Presets = []string{
- ExclusionPresetComments,
- ExclusionPresetStdErrorHandling,
- ExclusionPresetCommonFalsePositives,
- ExclusionPresetLegacy,
- }
- }
-
- if len(l.cfg.Issues.ExcludeRules) > 0 {
- l.cfg.Linters.LinterExclusions.Rules = append(l.cfg.Linters.LinterExclusions.Rules, l.cfg.Issues.ExcludeRules...)
- }
-
- if opts.CheckDeprecation {
- err = l.handleDeprecation()
- if err != nil {
- return err
- }
- }
-
- l.handleGoVersion()
-
- err = goutil.CheckGoVersion(l.cfg.Run.Go)
- if err != nil {
- return err
- }
-
- l.cfg.basePath, err = fsutils.GetBasePath(context.Background(), l.cfg.Run.RelativePathMode, l.cfg.cfgDir)
- if err != nil {
- return fmt.Errorf("get base path: %w", err)
- }
-
- err = l.handleEnableOnlyOption()
- if err != nil {
- return err
- }
-
- if opts.Validation {
- err = l.cfg.Validate()
- if err != nil {
- return err
- }
- }
-
- return nil
-}
-
-func (l *Loader) setConfigFile() error {
- configFile, err := l.evaluateOptions()
- if err != nil {
- if errors.Is(err, errConfigDisabled) {
- return nil
- }
-
- return fmt.Errorf("can't parse --config option: %w", err)
- }
-
- if configFile != "" {
- l.viper.SetConfigFile(configFile)
-
- // Assume YAML if the file has no extension.
- if filepath.Ext(configFile) == "" {
- l.viper.SetConfigType("yaml")
- }
- } else {
- l.setupConfigFileSearch()
- }
-
- return nil
-}
-
-func (l *Loader) evaluateOptions() (string, error) {
- if l.opts.NoConfig && l.opts.Config != "" {
- return "", errors.New("can't combine option --config and --no-config")
- }
-
- if l.opts.NoConfig {
- return "", errConfigDisabled
- }
-
- configFile, err := homedir.Expand(l.opts.Config)
- if err != nil {
- return "", errors.New("failed to expand configuration path")
- }
-
- return configFile, nil
-}
-
-func (l *Loader) setupConfigFileSearch() {
- l.viper.SetConfigName(".golangci")
-
- configSearchPaths := l.getConfigSearchPaths()
-
- l.log.Infof("Config search paths: %s", configSearchPaths)
-
- for _, p := range configSearchPaths {
- l.viper.AddConfigPath(p)
- }
-}
-
-func (l *Loader) getConfigSearchPaths() []string {
- firstArg := "./..."
- if len(l.args) > 0 {
- firstArg = l.args[0]
- }
-
- absPath, err := filepath.Abs(firstArg)
- if err != nil {
- l.log.Warnf("Can't make abs path for %q: %s", firstArg, err)
- absPath = filepath.Clean(firstArg)
- }
-
- // start from it
- var currentDir string
- if fsutils.IsDir(absPath) {
- currentDir = absPath
- } else {
- currentDir = filepath.Dir(absPath)
- }
-
- // find all dirs from it up to the root
- searchPaths := []string{"./"}
-
- for {
- searchPaths = append(searchPaths, currentDir)
-
- parent := filepath.Dir(currentDir)
- if currentDir == parent || parent == "" {
- break
- }
-
- currentDir = parent
- }
-
- // find home directory for global config
- if home, err := homedir.Dir(); err != nil {
- l.log.Warnf("Can't get user's home directory: %v", err)
- } else if !slices.Contains(searchPaths, home) {
- searchPaths = append(searchPaths, home)
- }
-
- return searchPaths
-}
-
-func (l *Loader) parseConfig() error {
- if err := l.viper.ReadInConfig(); err != nil {
- var configFileNotFoundError viper.ConfigFileNotFoundError
- if errors.As(err, &configFileNotFoundError) {
- // Load configuration from flags only.
- err = l.viper.Unmarshal(l.cfg, customDecoderHook())
- if err != nil {
- return fmt.Errorf("can't unmarshal config by viper (flags): %w", err)
- }
-
- return nil
- }
-
- return fmt.Errorf("can't read viper config: %w", err)
- }
-
- err := l.setConfigDir()
- if err != nil {
- return err
- }
-
- // Load configuration from all sources (flags, file).
- if err := l.viper.Unmarshal(l.cfg, customDecoderHook()); err != nil {
- return fmt.Errorf("can't unmarshal config by viper (flags, file): %w", err)
- }
-
- if l.cfg.InternalTest { // just for testing purposes: to detect config file usage
- _, _ = fmt.Fprintln(logutils.StdOut, "test")
- os.Exit(exitcodes.Success)
- }
-
- return nil
-}
-
-func (l *Loader) setConfigDir() error {
- usedConfigFile := l.viper.ConfigFileUsed()
- if usedConfigFile == "" {
- return nil
- }
-
- if usedConfigFile == os.Stdin.Name() {
- usedConfigFile = ""
- l.log.Infof("Reading config file stdin")
- } else {
- var err error
- usedConfigFile, err = fsutils.ShortestRelPath(usedConfigFile, "")
- if err != nil {
- l.log.Warnf("Can't pretty print config file path: %v", err)
- }
-
- l.log.Infof("Used config file %s", usedConfigFile)
- }
-
- usedConfigDir, err := filepath.Abs(filepath.Dir(usedConfigFile))
- if err != nil {
- return errors.New("can't get config directory")
- }
-
- l.cfg.cfgDir = usedConfigDir
-
- return nil
-}
-
-// Hack to append values from StringSlice flags.
-// Viper always overrides StringSlice values.
-// https://github.com/spf13/viper/issues/1448
-// So StringSlice flags are not bind to Viper like that their values are obtain via Cobra Flags.
-func (l *Loader) applyStringSliceHack() {
- if l.fs == nil {
- return
- }
-
- l.appendStringSlice("enable", &l.cfg.Linters.Enable)
- l.appendStringSlice("disable", &l.cfg.Linters.Disable)
- l.appendStringSlice("presets", &l.cfg.Linters.Presets)
- l.appendStringSlice("build-tags", &l.cfg.Run.BuildTags)
- l.appendStringSlice("exclude", &l.cfg.Issues.ExcludePatterns)
-
- l.appendStringSlice("skip-dirs", &l.cfg.Run.SkipDirs)
- l.appendStringSlice("skip-files", &l.cfg.Run.SkipFiles)
- l.appendStringSlice("exclude-dirs", &l.cfg.Issues.ExcludeDirs)
- l.appendStringSlice("exclude-files", &l.cfg.Issues.ExcludeFiles)
-}
-
-func (l *Loader) appendStringSlice(name string, current *[]string) {
- if l.fs.Changed(name) {
- val, _ := l.fs.GetStringSlice(name)
- *current = append(*current, val...)
- }
-}
-
-func (l *Loader) handleGoVersion() {
- if l.cfg.Run.Go == "" {
- l.cfg.Run.Go = detectGoVersion(context.Background())
- }
-
- l.cfg.LintersSettings.Govet.Go = l.cfg.Run.Go
-
- l.cfg.LintersSettings.ParallelTest.Go = l.cfg.Run.Go
-
- l.cfg.LintersSettings.Gofumpt.LangVersion = cmp.Or(l.cfg.LintersSettings.Gofumpt.LangVersion, l.cfg.Run.Go)
-
- trimmedGoVersion := goutil.TrimGoVersion(l.cfg.Run.Go)
-
- l.cfg.LintersSettings.Revive.Go = trimmedGoVersion
-
- l.cfg.LintersSettings.Gocritic.Go = trimmedGoVersion
-
- os.Setenv("GOSECGOVERSION", l.cfg.Run.Go)
-}
-
-func (l *Loader) handleDeprecation() error {
- if l.cfg.InternalTest || l.cfg.InternalCmdTest || os.Getenv(logutils.EnvTestRun) == "1" {
- return nil
- }
-
- // Deprecated since v1.57.0
- if len(l.cfg.Run.SkipFiles) > 0 {
- l.log.Warnf("The configuration option `run.skip-files` is deprecated, please use `issues.exclude-files`.")
- l.cfg.Issues.ExcludeFiles = l.cfg.Run.SkipFiles
- }
-
- // Deprecated since v1.57.0
- if len(l.cfg.Run.SkipDirs) > 0 {
- l.log.Warnf("The configuration option `run.skip-dirs` is deprecated, please use `issues.exclude-dirs`.")
- l.cfg.Issues.ExcludeDirs = l.cfg.Run.SkipDirs
- }
-
- // Deprecated since v1.57.0
- if l.cfg.Run.UseDefaultSkipDirs != nil {
- l.log.Warnf("The configuration option `run.skip-dirs-use-default` is deprecated, please use `issues.exclude-dirs-use-default`.")
- l.cfg.Issues.UseDefaultExcludeDirs = *l.cfg.Run.UseDefaultSkipDirs
- }
-
- // Deprecated since v1.57.0
- if l.cfg.Run.ShowStats != nil {
- l.log.Warnf("The configuration option `run.show-stats` is deprecated, please use `output.show-stats`")
- l.cfg.Output.ShowStats = *l.cfg.Run.ShowStats
- }
-
- // Deprecated since v1.63.0
- if l.cfg.Output.UniqByLine != nil {
- l.log.Warnf("The configuration option `output.uniq-by-line` is deprecated, please use `issues.uniq-by-line`")
- l.cfg.Issues.UniqByLine = *l.cfg.Output.UniqByLine
- }
-
- // Deprecated since v1.57.0
- if l.cfg.Output.Format != "" {
- l.log.Warnf("The configuration option `output.format` is deprecated, please use `output.formats`")
-
- var f OutputFormats
- err := f.UnmarshalText([]byte(l.cfg.Output.Format))
- if err != nil {
- return fmt.Errorf("unmarshal output format: %w", err)
- }
-
- l.cfg.Output.Formats = f
- }
-
- for _, format := range l.cfg.Output.Formats {
- if format.Format == OutFormatGithubActions {
- l.log.Warnf("The output format `%s` is deprecated, please use `%s`", OutFormatGithubActions, OutFormatColoredLineNumber)
- break // To avoid repeating the message if there are several usages of github-actions format.
- }
- }
-
- // Deprecated since v1.59.0
- if l.cfg.Issues.ExcludeGeneratedStrict != nil {
- l.log.Warnf("The configuration option `issues.exclude-generated-strict` is deprecated, please use `issues.exclude-generated`")
- if !*l.cfg.Issues.ExcludeGeneratedStrict {
- l.cfg.Issues.ExcludeGenerated = "strict" // Don't use the constants to avoid cyclic dependencies.
- }
- }
-
- l.handleLinterOptionDeprecations()
-
- return nil
-}
-
-func (l *Loader) handleLinterOptionDeprecations() {
- // Deprecated since v1.57.0,
- // but it was unofficially deprecated since v1.19 (2019) (https://github.com/golangci/golangci-lint/pull/697).
- if l.cfg.LintersSettings.Govet.CheckShadowing != nil {
- l.log.Warnf("The configuration option `linters.govet.check-shadowing` is deprecated. " +
- "Please enable `shadow` instead, if you are not using `enable-all`.")
- }
-
- if l.cfg.LintersSettings.CopyLoopVar.IgnoreAlias != nil {
- l.log.Warnf("The configuration option `linters.copyloopvar.ignore-alias` is deprecated and ignored," +
- "please use `linters.copyloopvar.check-alias`.")
- }
-
- // Deprecated since v1.42.0.
- if l.cfg.LintersSettings.Errcheck.Exclude != "" {
- l.log.Warnf("The configuration option `linters.errcheck.exclude` is deprecated, please use `linters.errcheck.exclude-functions`.")
- }
-
- // Deprecated since v1.59.0,
- // but it was unofficially deprecated since v1.13 (2018) (https://github.com/golangci/golangci-lint/pull/332).
- if l.cfg.LintersSettings.Errcheck.Ignore != "" {
- l.log.Warnf("The configuration option `linters.errcheck.ignore` is deprecated, please use `linters.errcheck.exclude-functions`.")
- }
-
- // Deprecated since v1.44.0.
- if l.cfg.LintersSettings.Gci.LocalPrefixes != "" {
- l.log.Warnf("The configuration option `linters.gci.local-prefixes` is deprecated, please use `prefix()` inside `linters.gci.sections`.")
- }
-
- // Deprecated since v1.33.0.
- if l.cfg.LintersSettings.Godot.CheckAll != nil {
- l.log.Warnf("The configuration option `linters.godot.check-all` is deprecated, please use `linters.godot.scope: all`.")
- }
-
- // Deprecated since v1.47.0
- if l.cfg.LintersSettings.Gofumpt.LangVersion != "" {
- l.log.Warnf("The configuration option `linters.gofumpt.lang-version` is deprecated, please use global `run.go`.")
- }
-
- // Deprecated since v1.47.0
- if l.cfg.LintersSettings.Staticcheck.GoVersion != "" {
- l.log.Warnf("The configuration option `linters.staticcheck.go` is deprecated, please use global `run.go`.")
- }
-
- // Deprecated since v1.47.0
- if l.cfg.LintersSettings.Gosimple.GoVersion != "" {
- l.log.Warnf("The configuration option `linters.gosimple.go` is deprecated, please use global `run.go`.")
- }
-
- // Deprecated since v1.47.0
- if l.cfg.LintersSettings.Stylecheck.GoVersion != "" {
- l.log.Warnf("The configuration option `linters.stylecheck.go` is deprecated, please use global `run.go`.")
- }
-
- // Deprecated since v1.60.0
- if l.cfg.LintersSettings.Unused.ExportedIsUsed != nil {
- l.log.Warnf("The configuration option `linters.unused.exported-is-used` is deprecated.")
- }
-
- // Deprecated since v1.58.0
- if l.cfg.LintersSettings.SlogLint.ContextOnly != nil {
- l.log.Warnf("The configuration option `linters.sloglint.context-only` is deprecated, please use `linters.sloglint.context`.")
- l.cfg.LintersSettings.SlogLint.Context = cmp.Or(l.cfg.LintersSettings.SlogLint.Context, "all")
- }
-
- // Deprecated since v1.51.0
- if l.cfg.LintersSettings.UseStdlibVars.OSDevNull != nil {
- l.log.Warnf("The configuration option `linters.usestdlibvars.os-dev-null` is deprecated.")
- }
-
- // Deprecated since v1.51.0
- if l.cfg.LintersSettings.UseStdlibVars.SyslogPriority != nil {
- l.log.Warnf("The configuration option `linters.usestdlibvars.syslog-priority` is deprecated.")
- }
-}
-
-func (l *Loader) handleEnableOnlyOption() error {
- lookup := l.fs.Lookup("enable-only")
- if lookup == nil {
- return nil
- }
-
- only, err := l.fs.GetStringSlice("enable-only")
- if err != nil {
- return err
- }
-
- if len(only) > 0 {
- l.cfg.Linters = Linters{
- Enable: only,
- DisableAll: true,
- }
- }
-
- return nil
-}
-
-func customDecoderHook() viper.DecoderConfigOption {
- return viper.DecodeHook(mapstructure.ComposeDecodeHookFunc(
- // Default hooks (https://github.com/spf13/viper/blob/518241257478c557633ab36e474dfcaeb9a3c623/viper.go#L135-L138).
- mapstructure.StringToTimeDurationHookFunc(),
- mapstructure.StringToSliceHookFunc(","),
-
- // Needed for forbidigo, and output.formats.
- mapstructure.TextUnmarshallerHookFunc(),
- ))
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/config/output.go b/vendor/github.com/golangci/golangci-lint/pkg/config/output.go
deleted file mode 100644
index caddb095c9..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/config/output.go
+++ /dev/null
@@ -1,119 +0,0 @@
-package config
-
-import (
- "errors"
- "fmt"
- "slices"
- "strings"
-)
-
-const (
- OutFormatJSON = "json"
- OutFormatLineNumber = "line-number"
- OutFormatColoredLineNumber = "colored-line-number"
- OutFormatTab = "tab"
- OutFormatColoredTab = "colored-tab"
- OutFormatCheckstyle = "checkstyle"
- OutFormatCodeClimate = "code-climate"
- OutFormatHTML = "html"
- OutFormatJUnitXML = "junit-xml"
- OutFormatJUnitXMLExtended = "junit-xml-extended"
- OutFormatGithubActions = "github-actions" // Deprecated
- OutFormatTeamCity = "teamcity"
- OutFormatSarif = "sarif"
-)
-
-var AllOutputFormats = []string{
- OutFormatJSON,
- OutFormatLineNumber,
- OutFormatColoredLineNumber,
- OutFormatTab,
- OutFormatColoredTab,
- OutFormatCheckstyle,
- OutFormatCodeClimate,
- OutFormatHTML,
- OutFormatJUnitXML,
- OutFormatJUnitXMLExtended,
- OutFormatGithubActions,
- OutFormatTeamCity,
- OutFormatSarif,
-}
-
-type Output struct {
- Formats OutputFormats `mapstructure:"formats"`
- PrintIssuedLine bool `mapstructure:"print-issued-lines"`
- PrintLinterName bool `mapstructure:"print-linter-name"`
- SortResults bool `mapstructure:"sort-results"`
- SortOrder []string `mapstructure:"sort-order"`
- PathPrefix string `mapstructure:"path-prefix"`
- ShowStats bool `mapstructure:"show-stats"`
-
- // Deprecated: use Formats instead.
- Format string `mapstructure:"format"`
-
- // Deprecated: use [Issues.UniqByLine] instead.
- UniqByLine *bool `mapstructure:"uniq-by-line"`
-}
-
-func (o *Output) Validate() error {
- if !o.SortResults && len(o.SortOrder) > 0 {
- return errors.New("sort-results should be 'true' to use sort-order")
- }
-
- validOrders := []string{"linter", "file", "severity"}
-
- all := strings.Join(o.SortOrder, " ")
-
- for _, order := range o.SortOrder {
- if strings.Count(all, order) > 1 {
- return fmt.Errorf("the sort-order name %q is repeated several times", order)
- }
-
- if !slices.Contains(validOrders, order) {
- return fmt.Errorf("unsupported sort-order name %q", order)
- }
- }
-
- for _, format := range o.Formats {
- err := format.Validate()
- if err != nil {
- return err
- }
- }
-
- return nil
-}
-
-type OutputFormat struct {
- Format string `mapstructure:"format"`
- Path string `mapstructure:"path"`
-}
-
-func (o *OutputFormat) Validate() error {
- if o.Format == "" {
- return errors.New("the format is required")
- }
-
- if !slices.Contains(AllOutputFormats, o.Format) {
- return fmt.Errorf("unsupported output format %q", o.Format)
- }
-
- return nil
-}
-
-type OutputFormats []OutputFormat
-
-func (p *OutputFormats) UnmarshalText(text []byte) error {
- formats := strings.Split(string(text), ",")
-
- for _, item := range formats {
- format, path, _ := strings.Cut(item, ":")
-
- *p = append(*p, OutputFormat{
- Path: path,
- Format: format,
- })
- }
-
- return nil
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/config/run.go b/vendor/github.com/golangci/golangci-lint/pkg/config/run.go
deleted file mode 100644
index 8e00f1e6dc..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/config/run.go
+++ /dev/null
@@ -1,57 +0,0 @@
-package config
-
-import (
- "fmt"
- "slices"
- "strings"
- "time"
-
- "github.com/golangci/golangci-lint/pkg/fsutils"
-)
-
-// Run encapsulates the config options for running the linter analysis.
-type Run struct {
- Timeout time.Duration `mapstructure:"timeout"`
-
- Concurrency int `mapstructure:"concurrency"`
-
- Go string `mapstructure:"go"`
-
- RelativePathMode string `mapstructure:"relative-path-mode"`
-
- BuildTags []string `mapstructure:"build-tags"`
- ModulesDownloadMode string `mapstructure:"modules-download-mode"`
-
- ExitCodeIfIssuesFound int `mapstructure:"issues-exit-code"`
- AnalyzeTests bool `mapstructure:"tests"`
-
- AllowParallelRunners bool `mapstructure:"allow-parallel-runners"`
- AllowSerialRunners bool `mapstructure:"allow-serial-runners"`
-
- // Deprecated: use Issues.ExcludeFiles instead.
- SkipFiles []string `mapstructure:"skip-files"`
- // Deprecated: use Issues.ExcludeDirs instead.
- SkipDirs []string `mapstructure:"skip-dirs"`
- // Deprecated: use Issues.UseDefaultExcludeDirs instead.
- UseDefaultSkipDirs *bool `mapstructure:"skip-dirs-use-default"`
-
- // Deprecated: use Output.ShowStats instead.
- ShowStats *bool `mapstructure:"show-stats"`
-}
-
-func (r *Run) Validate() error {
- // go help modules
- allowedModes := []string{"mod", "readonly", "vendor"}
-
- if r.ModulesDownloadMode != "" && !slices.Contains(allowedModes, r.ModulesDownloadMode) {
- return fmt.Errorf("invalid modules download path %s, only (%s) allowed", r.ModulesDownloadMode, strings.Join(allowedModes, "|"))
- }
-
- pathRelativeToModes := fsutils.AllRelativePathModes()
-
- if r.RelativePathMode != "" && !slices.Contains(pathRelativeToModes, r.RelativePathMode) {
- return fmt.Errorf("invalid relative path mode %s, only (%s) allowed", r.RelativePathMode, strings.Join(pathRelativeToModes, "|"))
- }
-
- return nil
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/config/severity.go b/vendor/github.com/golangci/golangci-lint/pkg/config/severity.go
deleted file mode 100644
index a6d2c9ec3f..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/config/severity.go
+++ /dev/null
@@ -1,41 +0,0 @@
-package config
-
-import (
- "errors"
- "fmt"
-)
-
-const severityRuleMinConditionsCount = 1
-
-type Severity struct {
- Default string `mapstructure:"default-severity"`
- CaseSensitive bool `mapstructure:"case-sensitive"`
- Rules []SeverityRule `mapstructure:"rules"`
-}
-
-func (s *Severity) Validate() error {
- if len(s.Rules) > 0 && s.Default == "" {
- return errors.New("can't set severity rule option: no default severity defined")
- }
-
- for i, rule := range s.Rules {
- if err := rule.Validate(); err != nil {
- return fmt.Errorf("error in severity rule #%d: %w", i, err)
- }
- }
-
- return nil
-}
-
-type SeverityRule struct {
- BaseRule `mapstructure:",squash"`
- Severity string
-}
-
-func (s *SeverityRule) Validate() error {
- if s.Severity == "" {
- return errors.New("severity should be set")
- }
-
- return s.BaseRule.Validate(severityRuleMinConditionsCount)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/fsutils/files.go b/vendor/github.com/golangci/golangci-lint/pkg/fsutils/files.go
deleted file mode 100644
index 4398ab9fc1..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/fsutils/files.go
+++ /dev/null
@@ -1,33 +0,0 @@
-package fsutils
-
-import "path/filepath"
-
-// Files combines different operations related to handling file paths and content.
-type Files struct {
- *LineCache
- pathPrefix string
-}
-
-func NewFiles(lc *LineCache, pathPrefix string) *Files {
- return &Files{
- LineCache: lc,
- pathPrefix: pathPrefix,
- }
-}
-
-// WithPathPrefix takes a path that is relative to the current directory (as used in issues)
-// and adds the configured path prefix, if there is one.
-// The resulting path then can be shown to the user or compared against paths specified in the configuration.
-func (f *Files) WithPathPrefix(relativePath string) string {
- return WithPathPrefix(f.pathPrefix, relativePath)
-}
-
-// WithPathPrefix takes a path that is relative to the current directory (as used in issues)
-// and adds the configured path prefix, if there is one.
-// The resulting path then can be shown to the user or compared against paths specified in the configuration.
-func WithPathPrefix(pathPrefix, relativePath string) string {
- if pathPrefix == "" {
- return relativePath
- }
- return filepath.Join(pathPrefix, relativePath)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/goanalysis/issue.go b/vendor/github.com/golangci/golangci-lint/pkg/goanalysis/issue.go
deleted file mode 100644
index 854e7d15f0..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/goanalysis/issue.go
+++ /dev/null
@@ -1,32 +0,0 @@
-package goanalysis
-
-import (
- "go/token"
-
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/result"
-)
-
-type Issue struct {
- result.Issue
- Pass *analysis.Pass
-}
-
-func NewIssue(issue *result.Issue, pass *analysis.Pass) Issue {
- return Issue{
- Issue: *issue,
- Pass: pass,
- }
-}
-
-type EncodingIssue struct {
- FromLinter string
- Text string
- Severity string
- Pos token.Position
- LineRange *result.Range
- SuggestedFixes []analysis.SuggestedFix
- ExpectNoLint bool
- ExpectedNoLintLinter string
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/goanalysis/linter.go b/vendor/github.com/golangci/golangci-lint/pkg/goanalysis/linter.go
deleted file mode 100644
index 13d3a09a58..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/goanalysis/linter.go
+++ /dev/null
@@ -1,217 +0,0 @@
-package goanalysis
-
-import (
- "context"
- "errors"
- "flag"
- "fmt"
- "strings"
-
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/lint/linter"
- "github.com/golangci/golangci-lint/pkg/result"
-)
-
-const (
- TheOnlyAnalyzerName = "the_only_name"
- TheOnlyanalyzerDoc = "the_only_doc"
-)
-
-type LoadMode int
-
-func (loadMode LoadMode) String() string {
- switch loadMode {
- case LoadModeNone:
- return "none"
- case LoadModeSyntax:
- return "syntax"
- case LoadModeTypesInfo:
- return "types info"
- case LoadModeWholeProgram:
- return "whole program"
- }
- panic(fmt.Sprintf("unknown load mode %d", loadMode))
-}
-
-const (
- LoadModeNone LoadMode = iota
- LoadModeSyntax
- LoadModeTypesInfo
- LoadModeWholeProgram
-)
-
-type Linter struct {
- name, desc string
- analyzers []*analysis.Analyzer
- cfg map[string]map[string]any
- issuesReporter func(*linter.Context) []Issue
- contextSetter func(*linter.Context)
- loadMode LoadMode
- needUseOriginalPackages bool
-}
-
-func NewLinter(name, desc string, analyzers []*analysis.Analyzer, cfg map[string]map[string]any) *Linter {
- return &Linter{name: name, desc: desc, analyzers: analyzers, cfg: cfg}
-}
-
-func (lnt *Linter) Run(_ context.Context, lintCtx *linter.Context) ([]result.Issue, error) {
- if err := lnt.preRun(lintCtx); err != nil {
- return nil, err
- }
-
- return runAnalyzers(lnt, lintCtx)
-}
-
-func (lnt *Linter) UseOriginalPackages() {
- lnt.needUseOriginalPackages = true
-}
-
-func (lnt *Linter) LoadMode() LoadMode {
- return lnt.loadMode
-}
-
-func (lnt *Linter) WithLoadMode(loadMode LoadMode) *Linter {
- lnt.loadMode = loadMode
- return lnt
-}
-
-func (lnt *Linter) WithIssuesReporter(r func(*linter.Context) []Issue) *Linter {
- lnt.issuesReporter = r
- return lnt
-}
-
-func (lnt *Linter) WithContextSetter(cs func(*linter.Context)) *Linter {
- lnt.contextSetter = cs
- return lnt
-}
-
-func (lnt *Linter) Name() string {
- return lnt.name
-}
-
-func (lnt *Linter) Desc() string {
- return lnt.desc
-}
-
-func (lnt *Linter) allAnalyzerNames() []string {
- var ret []string
- for _, a := range lnt.analyzers {
- ret = append(ret, a.Name)
- }
- return ret
-}
-
-func (*Linter) configureAnalyzer(a *analysis.Analyzer, cfg map[string]any) error {
- for k, v := range cfg {
- f := a.Flags.Lookup(k)
- if f == nil {
- validFlagNames := allFlagNames(&a.Flags)
- if len(validFlagNames) == 0 {
- return errors.New("analyzer doesn't have settings")
- }
-
- return fmt.Errorf("analyzer doesn't have setting %q, valid settings: %v",
- k, validFlagNames)
- }
-
- if err := f.Value.Set(valueToString(v)); err != nil {
- return fmt.Errorf("failed to set analyzer setting %q with value %q: %w", k, v, err)
- }
- }
-
- return nil
-}
-
-func (lnt *Linter) configure() error {
- analyzersMap := map[string]*analysis.Analyzer{}
- for _, a := range lnt.analyzers {
- analyzersMap[a.Name] = a
- }
-
- for analyzerName, analyzerSettings := range lnt.cfg {
- a := analyzersMap[analyzerName]
- if a == nil {
- return fmt.Errorf("settings key %q must be valid analyzer name, valid analyzers: %v",
- analyzerName, lnt.allAnalyzerNames())
- }
-
- if err := lnt.configureAnalyzer(a, analyzerSettings); err != nil {
- return fmt.Errorf("failed to configure analyzer %s: %w", analyzerName, err)
- }
- }
-
- return nil
-}
-
-func (lnt *Linter) preRun(lintCtx *linter.Context) error {
- if err := analysis.Validate(lnt.analyzers); err != nil {
- return fmt.Errorf("failed to validate analyzers: %w", err)
- }
-
- if err := lnt.configure(); err != nil {
- return fmt.Errorf("failed to configure analyzers: %w", err)
- }
-
- if lnt.contextSetter != nil {
- lnt.contextSetter(lintCtx)
- }
-
- return nil
-}
-
-func (lnt *Linter) getName() string {
- return lnt.name
-}
-
-func (lnt *Linter) getLinterNameForDiagnostic(*Diagnostic) string {
- return lnt.name
-}
-
-func (lnt *Linter) getAnalyzers() []*analysis.Analyzer {
- return lnt.analyzers
-}
-
-func (lnt *Linter) useOriginalPackages() bool {
- return lnt.needUseOriginalPackages
-}
-
-func (lnt *Linter) reportIssues(lintCtx *linter.Context) []Issue {
- if lnt.issuesReporter != nil {
- return lnt.issuesReporter(lintCtx)
- }
- return nil
-}
-
-func (lnt *Linter) getLoadMode() LoadMode {
- return lnt.loadMode
-}
-
-func allFlagNames(fs *flag.FlagSet) []string {
- var ret []string
- fs.VisitAll(func(f *flag.Flag) {
- ret = append(ret, f.Name)
- })
- return ret
-}
-
-func valueToString(v any) string {
- if ss, ok := v.([]string); ok {
- return strings.Join(ss, ",")
- }
-
- if is, ok := v.([]any); ok {
- var ss []string
- for _, i := range is {
- ss = append(ss, fmt.Sprint(i))
- }
-
- return valueToString(ss)
- }
-
- return fmt.Sprint(v)
-}
-
-func DummyRun(_ *analysis.Pass) (any, error) {
- return nil, nil
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/goanalysis/pkgerrors/errors.go b/vendor/github.com/golangci/golangci-lint/pkg/goanalysis/pkgerrors/errors.go
deleted file mode 100644
index 7da659e803..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/goanalysis/pkgerrors/errors.go
+++ /dev/null
@@ -1,56 +0,0 @@
-package pkgerrors
-
-import (
- "errors"
- "fmt"
-
- "golang.org/x/tools/go/packages"
-
- "github.com/golangci/golangci-lint/pkg/lint/linter"
- "github.com/golangci/golangci-lint/pkg/result"
-)
-
-type IllTypedError struct {
- Pkg *packages.Package
-}
-
-func (e *IllTypedError) Error() string {
- return fmt.Sprintf("errors in package: %v", e.Pkg.Errors)
-}
-
-func BuildIssuesFromIllTypedError(errs []error, lintCtx *linter.Context) ([]result.Issue, error) {
- var issues []result.Issue
- uniqReportedIssues := map[string]bool{}
-
- var other error
-
- for _, err := range errs {
- var ill *IllTypedError
- if !errors.As(err, &ill) {
- if other == nil {
- other = err
- }
- continue
- }
-
- for _, err := range extractErrors(ill.Pkg) {
- issue, perr := parseError(err)
- if perr != nil { // failed to parse
- if uniqReportedIssues[err.Msg] {
- continue
- }
- uniqReportedIssues[err.Msg] = true
- lintCtx.Log.Errorf("typechecking error: %s", err.Msg)
- } else {
- issue.Pkg = ill.Pkg // to save to cache later
- issues = append(issues, *issue)
- }
- }
- }
-
- if len(issues) == 0 && other != nil {
- return nil, other
- }
-
- return issues, nil
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/goanalysis/runner.go b/vendor/github.com/golangci/golangci-lint/pkg/goanalysis/runner.go
deleted file mode 100644
index 7cff0149a4..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/goanalysis/runner.go
+++ /dev/null
@@ -1,338 +0,0 @@
-// Package goanalysis defines the implementation of the checker commands.
-// The same code drives the multi-analysis driver, the single-analysis
-// driver that is conventionally provided for convenience along with
-// each analysis package, and the test driver.
-package goanalysis
-
-import (
- "encoding/gob"
- "fmt"
- "go/token"
- "maps"
- "runtime"
- "slices"
- "sync"
-
- "golang.org/x/tools/go/analysis"
- "golang.org/x/tools/go/packages"
-
- "github.com/golangci/golangci-lint/internal/cache"
- "github.com/golangci/golangci-lint/internal/errorutil"
- "github.com/golangci/golangci-lint/pkg/goanalysis/load"
- "github.com/golangci/golangci-lint/pkg/logutils"
- "github.com/golangci/golangci-lint/pkg/timeutils"
-)
-
-var (
- debugf = logutils.Debug(logutils.DebugKeyGoAnalysis)
-
- analyzeDebugf = logutils.Debug(logutils.DebugKeyGoAnalysisAnalyze)
- isMemoryDebug = logutils.HaveDebugTag(logutils.DebugKeyGoAnalysisMemory)
- issuesCacheDebugf = logutils.Debug(logutils.DebugKeyGoAnalysisIssuesCache)
-
- factsDebugf = logutils.Debug(logutils.DebugKeyGoAnalysisFacts)
- factsCacheDebugf = logutils.Debug(logutils.DebugKeyGoAnalysisFactsCache)
- factsInheritDebugf = logutils.Debug(logutils.DebugKeyGoAnalysisFactsInherit)
- factsExportDebugf = logutils.Debug(logutils.DebugKeyGoAnalysisFacts)
- isFactsExportDebug = logutils.HaveDebugTag(logutils.DebugKeyGoAnalysisFactsExport)
-)
-
-type Diagnostic struct {
- analysis.Diagnostic
- Analyzer *analysis.Analyzer
- Position token.Position
- Pkg *packages.Package
- File *token.File
-}
-
-type runner struct {
- log logutils.Log
- prefix string // ensure unique analyzer names
- pkgCache *cache.Cache
- loadGuard *load.Guard
- loadMode LoadMode
- passToPkg map[*analysis.Pass]*packages.Package
- passToPkgGuard sync.Mutex
- sw *timeutils.Stopwatch
-}
-
-func newRunner(prefix string, logger logutils.Log, pkgCache *cache.Cache, loadGuard *load.Guard,
- loadMode LoadMode, sw *timeutils.Stopwatch,
-) *runner {
- return &runner{
- prefix: prefix,
- log: logger,
- pkgCache: pkgCache,
- loadGuard: loadGuard,
- loadMode: loadMode,
- passToPkg: map[*analysis.Pass]*packages.Package{},
- sw: sw,
- }
-}
-
-// Run loads the packages specified by args using go/packages,
-// then applies the specified analyzers to them.
-// Analysis flags must already have been set.
-// It provides most of the logic for the main functions of both the
-// singlechecker and the multi-analysis commands.
-// It returns the appropriate exit code.
-func (r *runner) run(analyzers []*analysis.Analyzer, initialPackages []*packages.Package) ([]Diagnostic,
- []error, map[*analysis.Pass]*packages.Package,
-) {
- debugf("Analyzing %d packages on load mode %s", len(initialPackages), r.loadMode)
-
- roots := r.analyze(initialPackages, analyzers)
-
- diags, errs := extractDiagnostics(roots)
-
- return diags, errs, r.passToPkg
-}
-
-type actKey struct {
- *analysis.Analyzer
- *packages.Package
-}
-
-func (r *runner) markAllActions(a *analysis.Analyzer, pkg *packages.Package, markedActions map[actKey]struct{}) {
- k := actKey{a, pkg}
- if _, ok := markedActions[k]; ok {
- return
- }
-
- for _, req := range a.Requires {
- r.markAllActions(req, pkg, markedActions)
- }
-
- if len(a.FactTypes) != 0 {
- for path := range pkg.Imports {
- r.markAllActions(a, pkg.Imports[path], markedActions)
- }
- }
-
- markedActions[k] = struct{}{}
-}
-
-func (r *runner) makeAction(a *analysis.Analyzer, pkg *packages.Package,
- initialPkgs map[*packages.Package]bool, actions map[actKey]*action, actAlloc *actionAllocator,
-) *action {
- k := actKey{a, pkg}
- act, ok := actions[k]
- if ok {
- return act
- }
-
- act = actAlloc.alloc()
- act.Analyzer = a
- act.Package = pkg
- act.runner = r
- act.isInitialPkg = initialPkgs[pkg]
- act.needAnalyzeSource = initialPkgs[pkg]
- act.analysisDoneCh = make(chan struct{})
-
- depsCount := len(a.Requires)
- if len(a.FactTypes) > 0 {
- depsCount += len(pkg.Imports)
- }
- act.Deps = make([]*action, 0, depsCount)
-
- // Add a dependency on each required analyzers.
- for _, req := range a.Requires {
- act.Deps = append(act.Deps, r.makeAction(req, pkg, initialPkgs, actions, actAlloc))
- }
-
- r.buildActionFactDeps(act, a, pkg, initialPkgs, actions, actAlloc)
-
- actions[k] = act
-
- return act
-}
-
-func (r *runner) buildActionFactDeps(act *action, a *analysis.Analyzer, pkg *packages.Package,
- initialPkgs map[*packages.Package]bool, actions map[actKey]*action, actAlloc *actionAllocator,
-) {
- // An analysis that consumes/produces facts
- // must run on the package's dependencies too.
- if len(a.FactTypes) == 0 {
- return
- }
-
- act.objectFacts = make(map[objectFactKey]analysis.Fact)
- act.packageFacts = make(map[packageFactKey]analysis.Fact)
-
- paths := slices.Sorted(maps.Keys(pkg.Imports)) // for determinism
-
- for _, path := range paths {
- dep := r.makeAction(a, pkg.Imports[path], initialPkgs, actions, actAlloc)
- act.Deps = append(act.Deps, dep)
- }
-
- // Need to register fact types for pkgcache proper gob encoding.
- for _, f := range a.FactTypes {
- gob.Register(f)
- }
-}
-
-func (r *runner) prepareAnalysis(pkgs []*packages.Package,
- analyzers []*analysis.Analyzer,
-) (initialPkgs map[*packages.Package]bool, allActions, roots []*action) {
- // Construct the action graph.
-
- // Each graph node (action) is one unit of analysis.
- // Edges express package-to-package (vertical) dependencies,
- // and analysis-to-analysis (horizontal) dependencies.
-
- // This place is memory-intensive: e.g. Istio project has 120k total actions.
- // Therefore, optimize it carefully.
- markedActions := make(map[actKey]struct{}, len(analyzers)*len(pkgs))
- for _, a := range analyzers {
- for _, pkg := range pkgs {
- r.markAllActions(a, pkg, markedActions)
- }
- }
- totalActionsCount := len(markedActions)
-
- actions := make(map[actKey]*action, totalActionsCount)
- actAlloc := newActionAllocator(totalActionsCount)
-
- initialPkgs = make(map[*packages.Package]bool, len(pkgs))
- for _, pkg := range pkgs {
- initialPkgs[pkg] = true
- }
-
- // Build nodes for initial packages.
- roots = make([]*action, 0, len(pkgs)*len(analyzers))
- for _, a := range analyzers {
- for _, pkg := range pkgs {
- root := r.makeAction(a, pkg, initialPkgs, actions, actAlloc)
- root.IsRoot = true
- roots = append(roots, root)
- }
- }
-
- allActions = slices.Collect(maps.Values(actions))
-
- debugf("Built %d actions", len(actions))
-
- return initialPkgs, allActions, roots
-}
-
-func (r *runner) analyze(pkgs []*packages.Package, analyzers []*analysis.Analyzer) []*action {
- initialPkgs, actions, rootActions := r.prepareAnalysis(pkgs, analyzers)
-
- actionPerPkg := map[*packages.Package][]*action{}
- for _, act := range actions {
- actionPerPkg[act.Package] = append(actionPerPkg[act.Package], act)
- }
-
- // Fill Imports field.
- loadingPackages := map[*packages.Package]*loadingPackage{}
- var dfs func(pkg *packages.Package)
- dfs = func(pkg *packages.Package) {
- if loadingPackages[pkg] != nil {
- return
- }
-
- imports := map[string]*loadingPackage{}
- for impPath, imp := range pkg.Imports {
- dfs(imp)
- impLp := loadingPackages[imp]
- impLp.dependents++
- imports[impPath] = impLp
- }
-
- loadingPackages[pkg] = &loadingPackage{
- pkg: pkg,
- imports: imports,
- isInitial: initialPkgs[pkg],
- log: r.log,
- actions: actionPerPkg[pkg],
- loadGuard: r.loadGuard,
- dependents: 1, // self dependent
- }
- }
- for _, act := range actions {
- dfs(act.Package)
- }
-
- // Limit memory and IO usage.
- gomaxprocs := runtime.GOMAXPROCS(-1)
- debugf("Analyzing at most %d packages in parallel", gomaxprocs)
- loadSem := make(chan struct{}, gomaxprocs)
-
- var wg sync.WaitGroup
- debugf("There are %d initial and %d total packages", len(initialPkgs), len(loadingPackages))
- for _, lp := range loadingPackages {
- if lp.isInitial {
- wg.Add(1)
- go func(lp *loadingPackage) {
- lp.analyzeRecursive(r.loadMode, loadSem)
- wg.Done()
- }(lp)
- }
- }
- wg.Wait()
-
- return rootActions
-}
-
-func extractDiagnostics(roots []*action) (retDiags []Diagnostic, retErrors []error) {
- extracted := make(map[*action]bool)
- var extract func(*action)
- var visitAll func(actions []*action)
- visitAll = func(actions []*action) {
- for _, act := range actions {
- if !extracted[act] {
- extracted[act] = true
- visitAll(act.Deps)
- extract(act)
- }
- }
- }
-
- // De-duplicate diagnostics by position (not token.Pos) to
- // avoid double-reporting in source files that belong to
- // multiple packages, such as foo and foo.test.
- type key struct {
- token.Position
- *analysis.Analyzer
- message string
- }
- seen := make(map[key]bool)
-
- extract = func(act *action) {
- if act.Err != nil {
- if pe, ok := act.Err.(*errorutil.PanicError); ok {
- panic(pe)
- }
- retErrors = append(retErrors, fmt.Errorf("%s: %w", act.Analyzer.Name, act.Err))
- return
- }
-
- if act.IsRoot {
- for _, diag := range act.Diagnostics {
- // We don't display a.Name/f.Category
- // as most users don't care.
-
- position := GetFilePositionFor(act.Package.Fset, diag.Pos)
- file := act.Package.Fset.File(diag.Pos)
-
- k := key{Position: position, Analyzer: act.Analyzer, message: diag.Message}
- if seen[k] {
- continue // duplicate
- }
- seen[k] = true
-
- retDiag := Diagnostic{
- File: file,
- Diagnostic: diag,
- Analyzer: act.Analyzer,
- Position: position,
- Pkg: act.Package,
- }
- retDiags = append(retDiags, retDiag)
- }
- }
- }
- visitAll(roots)
- return retDiags, retErrors
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/goanalysis/runner_action_cache.go b/vendor/github.com/golangci/golangci-lint/pkg/goanalysis/runner_action_cache.go
deleted file mode 100644
index e06ea2979c..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/goanalysis/runner_action_cache.go
+++ /dev/null
@@ -1,127 +0,0 @@
-package goanalysis
-
-import (
- "errors"
- "fmt"
- "io"
-
- "golang.org/x/tools/go/analysis"
- "golang.org/x/tools/go/types/objectpath"
-
- "github.com/golangci/golangci-lint/internal/cache"
-)
-
-type Fact struct {
- Path string // non-empty only for object facts
- Fact analysis.Fact
-}
-
-func (act *action) loadCachedFacts() bool {
- if act.loadCachedFactsDone { // can't be set in parallel
- return act.loadCachedFactsOk
- }
-
- res := func() bool {
- if act.isInitialPkg {
- return true // load cached facts only for non-initial packages
- }
-
- if len(act.Analyzer.FactTypes) == 0 {
- return true // no need to load facts
- }
-
- return act.loadPersistedFacts()
- }()
- act.loadCachedFactsDone = true
- act.loadCachedFactsOk = res
- return res
-}
-
-func (act *action) persistFactsToCache() error {
- analyzer := act.Analyzer
- if len(analyzer.FactTypes) == 0 {
- return nil
- }
-
- // Merge new facts into the package and persist them.
- var facts []Fact
- for key, fact := range act.packageFacts {
- if key.pkg != act.Package.Types {
- // The fact is from inherited facts from another package
- continue
- }
- facts = append(facts, Fact{
- Path: "",
- Fact: fact,
- })
- }
- for key, fact := range act.objectFacts {
- obj := key.obj
- if obj.Pkg() != act.Package.Types {
- // The fact is from inherited facts from another package
- continue
- }
-
- path, err := objectpath.For(obj)
- if err != nil {
- // The object is not globally addressable
- continue
- }
-
- facts = append(facts, Fact{
- Path: string(path),
- Fact: fact,
- })
- }
-
- factsCacheDebugf("Caching %d facts for package %q and analyzer %s", len(facts), act.Package.Name, act.Analyzer.Name)
-
- return act.runner.pkgCache.Put(act.Package, cache.HashModeNeedAllDeps, factCacheKey(analyzer), facts)
-}
-
-func (act *action) loadPersistedFacts() bool {
- var facts []Fact
-
- err := act.runner.pkgCache.Get(act.Package, cache.HashModeNeedAllDeps, factCacheKey(act.Analyzer), &facts)
- if err != nil {
- if !errors.Is(err, cache.ErrMissing) && !errors.Is(err, io.EOF) {
- act.runner.log.Warnf("Failed to get persisted facts: %s", err)
- }
-
- factsCacheDebugf("No cached facts for package %q and analyzer %s", act.Package.Name, act.Analyzer.Name)
- return false
- }
-
- factsCacheDebugf("Loaded %d cached facts for package %q and analyzer %s", len(facts), act.Package.Name, act.Analyzer.Name)
-
- for _, f := range facts {
- if f.Path == "" { // this is a package fact
- key := packageFactKey{act.Package.Types, act.factType(f.Fact)}
- act.packageFacts[key] = f.Fact
- continue
- }
- obj, err := objectpath.Object(act.Package.Types, objectpath.Path(f.Path))
- if err != nil {
- // Be lenient about these errors. For example, when
- // analyzing io/ioutil from source, we may get a fact
- // for methods on the devNull type, and objectpath
- // will happily create a path for them. However, when
- // we later load io/ioutil from export data, the path
- // no longer resolves.
- //
- // If an exported type embeds the unexported type,
- // then (part of) the unexported type will become part
- // of the type information and our path will resolve
- // again.
- continue
- }
- factKey := objectFactKey{obj, act.factType(f.Fact)}
- act.objectFacts[factKey] = f.Fact
- }
-
- return true
-}
-
-func factCacheKey(a *analysis.Analyzer) string {
- return fmt.Sprintf("%s/facts", a.Name)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/goanalysis/runners.go b/vendor/github.com/golangci/golangci-lint/pkg/goanalysis/runners.go
deleted file mode 100644
index 3a9a35dec1..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/goanalysis/runners.go
+++ /dev/null
@@ -1,149 +0,0 @@
-package goanalysis
-
-import (
- "fmt"
- "go/token"
- "strings"
-
- "golang.org/x/tools/go/analysis"
- "golang.org/x/tools/go/packages"
-
- "github.com/golangci/golangci-lint/pkg/goanalysis/pkgerrors"
- "github.com/golangci/golangci-lint/pkg/lint/linter"
- "github.com/golangci/golangci-lint/pkg/logutils"
- "github.com/golangci/golangci-lint/pkg/result"
- "github.com/golangci/golangci-lint/pkg/timeutils"
-)
-
-type runAnalyzersConfig interface {
- getName() string
- getLinterNameForDiagnostic(*Diagnostic) string
- getAnalyzers() []*analysis.Analyzer
- useOriginalPackages() bool
- reportIssues(*linter.Context) []Issue
- getLoadMode() LoadMode
-}
-
-func runAnalyzers(cfg runAnalyzersConfig, lintCtx *linter.Context) ([]result.Issue, error) {
- log := lintCtx.Log.Child(logutils.DebugKeyGoAnalysis)
- sw := timeutils.NewStopwatch("analyzers", log)
-
- const stagesToPrint = 10
- defer sw.PrintTopStages(stagesToPrint)
-
- runner := newRunner(cfg.getName(), log, lintCtx.PkgCache, lintCtx.LoadGuard, cfg.getLoadMode(), sw)
-
- pkgs := lintCtx.Packages
- if cfg.useOriginalPackages() {
- pkgs = lintCtx.OriginalPackages
- }
-
- issues, pkgsFromCache := loadIssuesFromCache(pkgs, lintCtx, cfg.getAnalyzers())
- var pkgsToAnalyze []*packages.Package
- for _, pkg := range pkgs {
- if !pkgsFromCache[pkg] {
- pkgsToAnalyze = append(pkgsToAnalyze, pkg)
- }
- }
-
- diags, errs, passToPkg := runner.run(cfg.getAnalyzers(), pkgsToAnalyze)
-
- defer func() {
- if len(errs) == 0 {
- // If we try to save to cache even if we have compilation errors
- // we won't see them on repeated runs.
- saveIssuesToCache(pkgs, pkgsFromCache, issues, lintCtx, cfg.getAnalyzers())
- }
- }()
-
- buildAllIssues := func() []result.Issue {
- var retIssues []result.Issue
- reportedIssues := cfg.reportIssues(lintCtx)
- for i := range reportedIssues {
- issue := &reportedIssues[i].Issue
- if issue.Pkg == nil {
- issue.Pkg = passToPkg[reportedIssues[i].Pass]
- }
- retIssues = append(retIssues, *issue)
- }
- retIssues = append(retIssues, buildIssues(diags, cfg.getLinterNameForDiagnostic)...)
- return retIssues
- }
-
- errIssues, err := pkgerrors.BuildIssuesFromIllTypedError(errs, lintCtx)
- if err != nil {
- return nil, err
- }
-
- issues = append(issues, errIssues...)
- issues = append(issues, buildAllIssues()...)
-
- return issues, nil
-}
-
-func buildIssues(diags []Diagnostic, linterNameBuilder func(diag *Diagnostic) string) []result.Issue {
- var issues []result.Issue
-
- for i := range diags {
- diag := &diags[i]
- linterName := linterNameBuilder(diag)
-
- var text string
- if diag.Analyzer.Name == linterName {
- text = diag.Message
- } else {
- text = fmt.Sprintf("%s: %s", diag.Analyzer.Name, diag.Message)
- }
-
- var suggestedFixes []analysis.SuggestedFix
-
- for _, sf := range diag.SuggestedFixes {
- // Skip suggested fixes on cgo files.
- // The related error is: "diff has out-of-bounds edits"
- // This is a temporary workaround.
- if !strings.HasSuffix(diag.File.Name(), ".go") {
- continue
- }
-
- nsf := analysis.SuggestedFix{Message: sf.Message}
-
- for _, edit := range sf.TextEdits {
- end := edit.End
-
- if !end.IsValid() {
- end = edit.Pos
- }
-
- // To be applied the positions need to be "adjusted" based on the file.
- // This is the difference between the "displayed" positions and "effective" positions.
- nsf.TextEdits = append(nsf.TextEdits, analysis.TextEdit{
- Pos: token.Pos(diag.File.Offset(edit.Pos)),
- End: token.Pos(diag.File.Offset(end)),
- NewText: edit.NewText,
- })
- }
-
- suggestedFixes = append(suggestedFixes, nsf)
- }
-
- issues = append(issues, result.Issue{
- FromLinter: linterName,
- Text: text,
- Pos: diag.Position,
- Pkg: diag.Pkg,
- SuggestedFixes: suggestedFixes,
- })
-
- if len(diag.Related) > 0 {
- for _, info := range diag.Related {
- issues = append(issues, result.Issue{
- FromLinter: linterName,
- Text: fmt.Sprintf("%s(related information): %s", diag.Analyzer.Name, info.Message),
- Pos: diag.Pkg.Fset.Position(info.Pos),
- Pkg: diag.Pkg,
- })
- }
- }
- }
- return issues
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/goanalysis/runners_cache.go b/vendor/github.com/golangci/golangci-lint/pkg/goanalysis/runners_cache.go
deleted file mode 100644
index 4366155b02..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/goanalysis/runners_cache.go
+++ /dev/null
@@ -1,172 +0,0 @@
-package goanalysis
-
-import (
- "runtime"
- "sort"
- "strings"
- "sync"
- "sync/atomic"
- "time"
-
- "golang.org/x/tools/go/analysis"
- "golang.org/x/tools/go/packages"
-
- "github.com/golangci/golangci-lint/internal/cache"
- "github.com/golangci/golangci-lint/pkg/lint/linter"
- "github.com/golangci/golangci-lint/pkg/result"
-)
-
-func saveIssuesToCache(allPkgs []*packages.Package, pkgsFromCache map[*packages.Package]bool,
- issues []result.Issue, lintCtx *linter.Context, analyzers []*analysis.Analyzer,
-) {
- startedAt := time.Now()
- perPkgIssues := map[*packages.Package][]result.Issue{}
- for ind := range issues {
- i := &issues[ind]
- perPkgIssues[i.Pkg] = append(perPkgIssues[i.Pkg], *i)
- }
-
- var savedIssuesCount int64 = 0
- lintResKey := getIssuesCacheKey(analyzers)
-
- workerCount := runtime.GOMAXPROCS(-1)
- var wg sync.WaitGroup
- wg.Add(workerCount)
-
- pkgCh := make(chan *packages.Package, len(allPkgs))
- for i := 0; i < workerCount; i++ {
- go func() {
- defer wg.Done()
- for pkg := range pkgCh {
- pkgIssues := perPkgIssues[pkg]
- encodedIssues := make([]EncodingIssue, 0, len(pkgIssues))
- for ind := range pkgIssues {
- i := &pkgIssues[ind]
- encodedIssues = append(encodedIssues, EncodingIssue{
- FromLinter: i.FromLinter,
- Text: i.Text,
- Severity: i.Severity,
- Pos: i.Pos,
- LineRange: i.LineRange,
- SuggestedFixes: i.SuggestedFixes,
- ExpectNoLint: i.ExpectNoLint,
- ExpectedNoLintLinter: i.ExpectedNoLintLinter,
- })
- }
-
- atomic.AddInt64(&savedIssuesCount, int64(len(encodedIssues)))
- if err := lintCtx.PkgCache.Put(pkg, cache.HashModeNeedAllDeps, lintResKey, encodedIssues); err != nil {
- lintCtx.Log.Infof("Failed to save package %s issues (%d) to cache: %s", pkg, len(pkgIssues), err)
- } else {
- issuesCacheDebugf("Saved package %s issues (%d) to cache", pkg, len(pkgIssues))
- }
- }
- }()
- }
-
- for _, pkg := range allPkgs {
- if pkgsFromCache[pkg] {
- continue
- }
-
- pkgCh <- pkg
- }
- close(pkgCh)
- wg.Wait()
-
- lintCtx.PkgCache.Close()
-
- issuesCacheDebugf("Saved %d issues from %d packages to cache in %s", savedIssuesCount, len(allPkgs), time.Since(startedAt))
-}
-
-func loadIssuesFromCache(pkgs []*packages.Package, lintCtx *linter.Context,
- analyzers []*analysis.Analyzer,
-) (issuesFromCache []result.Issue, pkgsFromCache map[*packages.Package]bool) {
- startedAt := time.Now()
-
- lintResKey := getIssuesCacheKey(analyzers)
- type cacheRes struct {
- issues []result.Issue
- loadErr error
- }
- pkgToCacheRes := make(map[*packages.Package]*cacheRes, len(pkgs))
- for _, pkg := range pkgs {
- pkgToCacheRes[pkg] = &cacheRes{}
- }
-
- workerCount := runtime.GOMAXPROCS(-1)
- var wg sync.WaitGroup
- wg.Add(workerCount)
-
- pkgCh := make(chan *packages.Package, len(pkgs))
- for range workerCount {
- go func() {
- defer wg.Done()
- for pkg := range pkgCh {
- var pkgIssues []EncodingIssue
- err := lintCtx.PkgCache.Get(pkg, cache.HashModeNeedAllDeps, lintResKey, &pkgIssues)
- cacheRes := pkgToCacheRes[pkg]
- cacheRes.loadErr = err
- if err != nil {
- continue
- }
- if len(pkgIssues) == 0 {
- continue
- }
-
- issues := make([]result.Issue, 0, len(pkgIssues))
- for i := range pkgIssues {
- issue := &pkgIssues[i]
- issues = append(issues, result.Issue{
- FromLinter: issue.FromLinter,
- Text: issue.Text,
- Severity: issue.Severity,
- Pos: issue.Pos,
- LineRange: issue.LineRange,
- SuggestedFixes: issue.SuggestedFixes,
- Pkg: pkg,
- ExpectNoLint: issue.ExpectNoLint,
- ExpectedNoLintLinter: issue.ExpectedNoLintLinter,
- })
- }
- cacheRes.issues = issues
- }
- }()
- }
-
- for _, pkg := range pkgs {
- pkgCh <- pkg
- }
- close(pkgCh)
- wg.Wait()
-
- loadedIssuesCount := 0
- pkgsFromCache = map[*packages.Package]bool{}
- for pkg, cacheRes := range pkgToCacheRes {
- if cacheRes.loadErr == nil {
- loadedIssuesCount += len(cacheRes.issues)
- pkgsFromCache[pkg] = true
- issuesFromCache = append(issuesFromCache, cacheRes.issues...)
- issuesCacheDebugf("Loaded package %s issues (%d) from cache", pkg, len(cacheRes.issues))
- } else {
- issuesCacheDebugf("Didn't load package %s issues from cache: %s", pkg, cacheRes.loadErr)
- }
- }
- issuesCacheDebugf("Loaded %d issues from cache in %s, analyzing %d/%d packages",
- loadedIssuesCount, time.Since(startedAt), len(pkgs)-len(pkgsFromCache), len(pkgs))
- return issuesFromCache, pkgsFromCache
-}
-
-func getIssuesCacheKey(analyzers []*analysis.Analyzer) string {
- return "lint/result:" + analyzersHashID(analyzers)
-}
-
-func analyzersHashID(analyzers []*analysis.Analyzer) string {
- names := make([]string, 0, len(analyzers))
- for _, a := range analyzers {
- names = append(names, a.Name)
- }
-
- sort.Strings(names)
- return strings.Join(names, ",")
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/goformatters/analyzer.go b/vendor/github.com/golangci/golangci-lint/pkg/goformatters/analyzer.go
deleted file mode 100644
index c0ea66e7e6..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/goformatters/analyzer.go
+++ /dev/null
@@ -1,55 +0,0 @@
-package goformatters
-
-import (
- "bytes"
- "fmt"
- "os"
- "path/filepath"
-
- "github.com/rogpeppe/go-internal/diff"
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/goanalysis"
- "github.com/golangci/golangci-lint/pkg/goformatters/internal"
- "github.com/golangci/golangci-lint/pkg/logutils"
-)
-
-// NewAnalyzer converts a [Formatter] to an [analysis.Analyzer].
-func NewAnalyzer(logger logutils.Log, doc string, formatter Formatter) *analysis.Analyzer {
- return &analysis.Analyzer{
- Name: formatter.Name(),
- Doc: doc,
- Run: func(pass *analysis.Pass) (any, error) {
- for _, file := range pass.Files {
- position, isGoFile := goanalysis.GetGoFilePosition(pass, file)
- if !isGoFile {
- continue
- }
-
- input, err := os.ReadFile(position.Filename)
- if err != nil {
- return nil, fmt.Errorf("unable to open file %s: %w", position.Filename, err)
- }
-
- output, err := formatter.Format(position.Filename, input)
- if err != nil {
- return nil, fmt.Errorf("error while running %s: %w", formatter.Name(), err)
- }
-
- if !bytes.Equal(input, output) {
- newName := filepath.ToSlash(position.Filename)
- oldName := newName + ".orig"
-
- patch := diff.Diff(oldName, input, newName, output)
-
- err = internal.ExtractDiagnosticFromPatch(pass, file, patch, logger)
- if err != nil {
- return nil, fmt.Errorf("can't extract issues from %s diff output %q: %w", formatter.Name(), patch, err)
- }
- }
- }
-
- return nil, nil
- },
- }
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/goformatters/gci/gci.go b/vendor/github.com/golangci/golangci-lint/pkg/goformatters/gci/gci.go
deleted file mode 100644
index f28b5b98a9..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/goformatters/gci/gci.go
+++ /dev/null
@@ -1,71 +0,0 @@
-package gci
-
-import (
- "context"
- "fmt"
-
- gcicfg "github.com/daixiang0/gci/pkg/config"
- "github.com/daixiang0/gci/pkg/gci"
- "github.com/daixiang0/gci/pkg/log"
- "github.com/ldez/grignotin/gomod"
-
- "github.com/golangci/golangci-lint/pkg/config"
- gcicfgi "github.com/golangci/golangci-lint/pkg/goformatters/gci/internal/config"
- "github.com/golangci/golangci-lint/pkg/goformatters/internal"
-)
-
-const Name = "gci"
-
-type Formatter struct {
- config *gcicfg.Config
-}
-
-func New(settings *config.GciSettings) (*Formatter, error) {
- log.InitLogger()
- _ = log.L().Sync()
-
- modPath, err := gomod.GetModulePath(context.Background())
- if err != nil {
- internal.FormatterLogger.Errorf("gci: %v", err)
- }
-
- cfg := gcicfgi.YamlConfig{
- Cfg: gcicfg.BoolConfig{
- NoInlineComments: settings.NoInlineComments,
- NoPrefixComments: settings.NoPrefixComments,
- SkipGenerated: settings.SkipGenerated,
- CustomOrder: settings.CustomOrder,
- NoLexOrder: settings.NoLexOrder,
- },
- SectionStrings: settings.Sections,
- ModPath: modPath,
- }
-
- if settings.LocalPrefixes != "" {
- cfg.SectionStrings = []string{
- "standard",
- "default",
- fmt.Sprintf("prefix(%s)", settings.LocalPrefixes),
- }
- }
-
- parsedCfg, err := cfg.Parse()
- if err != nil {
- return nil, err
- }
-
- return &Formatter{config: &gcicfg.Config{
- BoolConfig: parsedCfg.BoolConfig,
- Sections: parsedCfg.Sections,
- SectionSeparators: parsedCfg.SectionSeparators,
- }}, nil
-}
-
-func (*Formatter) Name() string {
- return Name
-}
-
-func (f *Formatter) Format(filename string, src []byte) ([]byte, error) {
- _, formatted, err := gci.LoadFormat(src, filename, *f.config)
- return formatted, err
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/goformatters/gci/internal/config/config.go b/vendor/github.com/golangci/golangci-lint/pkg/goformatters/gci/internal/config/config.go
deleted file mode 100644
index 8140d96bf8..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/goformatters/gci/internal/config/config.go
+++ /dev/null
@@ -1,107 +0,0 @@
-package config
-
-import (
- "sort"
- "strings"
-
- "gopkg.in/yaml.v3"
-
- "github.com/daixiang0/gci/pkg/config"
- "github.com/daixiang0/gci/pkg/section"
- sectioni "github.com/golangci/golangci-lint/pkg/goformatters/gci/internal/section"
-)
-
-var defaultOrder = map[string]int{
- section.StandardType: 0,
- section.DefaultType: 1,
- section.CustomType: 2,
- section.BlankType: 3,
- section.DotType: 4,
- section.AliasType: 5,
- section.LocalModuleType: 6,
-}
-
-type Config struct {
- config.BoolConfig
- Sections section.SectionList
- SectionSeparators section.SectionList
-}
-
-type YamlConfig struct {
- Cfg config.BoolConfig `yaml:",inline"`
- SectionStrings []string `yaml:"sections"`
- SectionSeparatorStrings []string `yaml:"sectionseparators"`
-
- // Since history issue, Golangci-lint needs Analyzer to run and GCI add an Analyzer layer to integrate.
- // The ModPath param is only from analyzer.go, no need to set it in all other places.
- ModPath string `yaml:"-"`
-}
-
-func (g YamlConfig) Parse() (*Config, error) {
- var err error
-
- sections, err := sectioni.Parse(g.SectionStrings)
- if err != nil {
- return nil, err
- }
- if sections == nil {
- sections = sectioni.DefaultSections()
- }
- if err := configureSections(sections, g.ModPath); err != nil {
- return nil, err
- }
-
- // if default order sorted sections
- if !g.Cfg.CustomOrder {
- sort.Slice(sections, func(i, j int) bool {
- sectionI, sectionJ := sections[i].Type(), sections[j].Type()
-
- if g.Cfg.NoLexOrder || strings.Compare(sectionI, sectionJ) != 0 {
- return defaultOrder[sectionI] < defaultOrder[sectionJ]
- }
-
- return strings.Compare(sections[i].String(), sections[j].String()) < 0
- })
- }
-
- sectionSeparators, err := sectioni.Parse(g.SectionSeparatorStrings)
- if err != nil {
- return nil, err
- }
- if sectionSeparators == nil {
- sectionSeparators = section.DefaultSectionSeparators()
- }
-
- return &Config{g.Cfg, sections, sectionSeparators}, nil
-}
-
-func ParseConfig(in string) (*Config, error) {
- config := YamlConfig{}
-
- err := yaml.Unmarshal([]byte(in), &config)
- if err != nil {
- return nil, err
- }
-
- gciCfg, err := config.Parse()
- if err != nil {
- return nil, err
- }
-
- return gciCfg, nil
-}
-
-// configureSections now only do golang module path finding.
-// Since history issue, Golangci-lint needs Analyzer to run and GCI add an Analyzer layer to integrate.
-// The path param is from analyzer.go, in all other places should pass empty string.
-func configureSections(sections section.SectionList, path string) error {
- for _, sec := range sections {
- switch s := sec.(type) {
- case *section.LocalModule:
- if err := s.Configure(path); err != nil {
- return err
- }
- }
- }
- return nil
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/goformatters/gci/internal/section/standard_list.go b/vendor/github.com/golangci/golangci-lint/pkg/goformatters/gci/internal/section/standard_list.go
deleted file mode 100644
index 2fddded70c..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/goformatters/gci/internal/section/standard_list.go
+++ /dev/null
@@ -1,182 +0,0 @@
-package section
-
-// Code generated based on go1.24.0 X:boringcrypto,arenas,synctest. DO NOT EDIT.
-
-var standardPackages = map[string]struct{}{
- "archive/tar": {},
- "archive/zip": {},
- "arena": {},
- "bufio": {},
- "bytes": {},
- "cmp": {},
- "compress/bzip2": {},
- "compress/flate": {},
- "compress/gzip": {},
- "compress/lzw": {},
- "compress/zlib": {},
- "container/heap": {},
- "container/list": {},
- "container/ring": {},
- "context": {},
- "crypto": {},
- "crypto/aes": {},
- "crypto/boring": {},
- "crypto/cipher": {},
- "crypto/des": {},
- "crypto/dsa": {},
- "crypto/ecdh": {},
- "crypto/ecdsa": {},
- "crypto/ed25519": {},
- "crypto/elliptic": {},
- "crypto/fips140": {},
- "crypto/hkdf": {},
- "crypto/hmac": {},
- "crypto/md5": {},
- "crypto/mlkem": {},
- "crypto/pbkdf2": {},
- "crypto/rand": {},
- "crypto/rc4": {},
- "crypto/rsa": {},
- "crypto/sha1": {},
- "crypto/sha256": {},
- "crypto/sha3": {},
- "crypto/sha512": {},
- "crypto/subtle": {},
- "crypto/tls": {},
- "crypto/tls/fipsonly": {},
- "crypto/x509": {},
- "crypto/x509/pkix": {},
- "database/sql": {},
- "database/sql/driver": {},
- "debug/buildinfo": {},
- "debug/dwarf": {},
- "debug/elf": {},
- "debug/gosym": {},
- "debug/macho": {},
- "debug/pe": {},
- "debug/plan9obj": {},
- "embed": {},
- "encoding": {},
- "encoding/ascii85": {},
- "encoding/asn1": {},
- "encoding/base32": {},
- "encoding/base64": {},
- "encoding/binary": {},
- "encoding/csv": {},
- "encoding/gob": {},
- "encoding/hex": {},
- "encoding/json": {},
- "encoding/pem": {},
- "encoding/xml": {},
- "errors": {},
- "expvar": {},
- "flag": {},
- "fmt": {},
- "go/ast": {},
- "go/build": {},
- "go/build/constraint": {},
- "go/constant": {},
- "go/doc": {},
- "go/doc/comment": {},
- "go/format": {},
- "go/importer": {},
- "go/parser": {},
- "go/printer": {},
- "go/scanner": {},
- "go/token": {},
- "go/types": {},
- "go/version": {},
- "hash": {},
- "hash/adler32": {},
- "hash/crc32": {},
- "hash/crc64": {},
- "hash/fnv": {},
- "hash/maphash": {},
- "html": {},
- "html/template": {},
- "image": {},
- "image/color": {},
- "image/color/palette": {},
- "image/draw": {},
- "image/gif": {},
- "image/jpeg": {},
- "image/png": {},
- "index/suffixarray": {},
- "io": {},
- "io/fs": {},
- "io/ioutil": {},
- "iter": {},
- "log": {},
- "log/slog": {},
- "log/syslog": {},
- "maps": {},
- "math": {},
- "math/big": {},
- "math/bits": {},
- "math/cmplx": {},
- "math/rand": {},
- "math/rand/v2": {},
- "mime": {},
- "mime/multipart": {},
- "mime/quotedprintable": {},
- "net": {},
- "net/http": {},
- "net/http/cgi": {},
- "net/http/cookiejar": {},
- "net/http/fcgi": {},
- "net/http/httptest": {},
- "net/http/httptrace": {},
- "net/http/httputil": {},
- "net/http/pprof": {},
- "net/mail": {},
- "net/netip": {},
- "net/rpc": {},
- "net/rpc/jsonrpc": {},
- "net/smtp": {},
- "net/textproto": {},
- "net/url": {},
- "os": {},
- "os/exec": {},
- "os/signal": {},
- "os/user": {},
- "path": {},
- "path/filepath": {},
- "plugin": {},
- "reflect": {},
- "regexp": {},
- "regexp/syntax": {},
- "runtime": {},
- "runtime/cgo": {},
- "runtime/coverage": {},
- "runtime/debug": {},
- "runtime/metrics": {},
- "runtime/pprof": {},
- "runtime/race": {},
- "runtime/trace": {},
- "slices": {},
- "sort": {},
- "strconv": {},
- "strings": {},
- "structs": {},
- "sync": {},
- "sync/atomic": {},
- "syscall": {},
- "testing": {},
- "testing/fstest": {},
- "testing/iotest": {},
- "testing/quick": {},
- "testing/slogtest": {},
- "testing/synctest": {},
- "text/scanner": {},
- "text/tabwriter": {},
- "text/template": {},
- "text/template/parse": {},
- "time": {},
- "time/tzdata": {},
- "unicode": {},
- "unicode/utf16": {},
- "unicode/utf8": {},
- "unique": {},
- "unsafe": {},
- "weak": {},
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/goformatters/gofmt/gofmt.go b/vendor/github.com/golangci/golangci-lint/pkg/goformatters/gofmt/gofmt.go
deleted file mode 100644
index 9005c751d2..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/goformatters/gofmt/gofmt.go
+++ /dev/null
@@ -1,35 +0,0 @@
-package gofmt
-
-import (
- "github.com/golangci/gofmt/gofmt"
-
- "github.com/golangci/golangci-lint/pkg/config"
-)
-
-const Name = "gofmt"
-
-type Formatter struct {
- options gofmt.Options
-}
-
-func New(settings *config.GoFmtSettings) *Formatter {
- options := gofmt.Options{}
-
- if settings != nil {
- options.NeedSimplify = settings.Simplify
-
- for _, rule := range settings.RewriteRules {
- options.RewriteRules = append(options.RewriteRules, gofmt.RewriteRule(rule))
- }
- }
-
- return &Formatter{options: options}
-}
-
-func (*Formatter) Name() string {
- return Name
-}
-
-func (f *Formatter) Format(filename string, src []byte) ([]byte, error) {
- return gofmt.Source(filename, src, f.options)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/goformatters/gofumpt/gofumpt.go b/vendor/github.com/golangci/golangci-lint/pkg/goformatters/gofumpt/gofumpt.go
deleted file mode 100644
index 7c548a2afd..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/goformatters/gofumpt/gofumpt.go
+++ /dev/null
@@ -1,46 +0,0 @@
-package gofumpt
-
-import (
- "strings"
-
- gofumpt "mvdan.cc/gofumpt/format"
-
- "github.com/golangci/golangci-lint/pkg/config"
-)
-
-const Name = "gofumpt"
-
-type Formatter struct {
- options gofumpt.Options
-}
-
-func New(settings *config.GofumptSettings, goVersion string) *Formatter {
- var options gofumpt.Options
-
- if settings != nil {
- options = gofumpt.Options{
- LangVersion: getLangVersion(goVersion),
- ModulePath: settings.ModulePath,
- ExtraRules: settings.ExtraRules,
- }
- }
-
- return &Formatter{options: options}
-}
-
-func (*Formatter) Name() string {
- return Name
-}
-
-func (f *Formatter) Format(_ string, src []byte) ([]byte, error) {
- return gofumpt.Source(src, f.options)
-}
-
-func getLangVersion(v string) string {
- if v == "" {
- // TODO: defaults to "1.15", in the future (v2) must be removed.
- return "go1.15"
- }
-
- return "go" + strings.TrimPrefix(v, "go")
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/goformatters/goimports/goimports.go b/vendor/github.com/golangci/golangci-lint/pkg/goformatters/goimports/goimports.go
deleted file mode 100644
index fa0f1fc4f3..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/goformatters/goimports/goimports.go
+++ /dev/null
@@ -1,28 +0,0 @@
-package goimports
-
-import (
- "golang.org/x/tools/imports"
-
- "github.com/golangci/golangci-lint/pkg/config"
-)
-
-const Name = "goimports"
-
-type Formatter struct{}
-
-func New(settings *config.GoImportsSettings) *Formatter {
- if settings != nil {
- imports.LocalPrefix = settings.LocalPrefixes
- }
-
- return &Formatter{}
-}
-
-func (*Formatter) Name() string {
- return Name
-}
-
-func (*Formatter) Format(filename string, src []byte) ([]byte, error) {
- // The `imports.LocalPrefix` (`settings.LocalPrefixes`) is a global var.
- return imports.Process(filename, src, nil)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/goformatters/internal/commons.go b/vendor/github.com/golangci/golangci-lint/pkg/goformatters/internal/commons.go
deleted file mode 100644
index 5320e786b5..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/goformatters/internal/commons.go
+++ /dev/null
@@ -1,6 +0,0 @@
-package internal
-
-import "github.com/golangci/golangci-lint/pkg/logutils"
-
-// FormatterLogger must be used only when the context logger is not available.
-var FormatterLogger = logutils.NewStderrLog(logutils.DebugKeyFormatter)
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/goformatters/internal/diff.go b/vendor/github.com/golangci/golangci-lint/pkg/goformatters/internal/diff.go
deleted file mode 100644
index 75d65b73ad..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/goformatters/internal/diff.go
+++ /dev/null
@@ -1,274 +0,0 @@
-package internal
-
-import (
- "bytes"
- "fmt"
- "go/ast"
- "go/token"
- "slices"
- "strings"
-
- diffpkg "github.com/sourcegraph/go-diff/diff"
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/goanalysis"
- "github.com/golangci/golangci-lint/pkg/logutils"
-)
-
-type Change struct {
- From, To int
- NewLines []string
-}
-
-type diffLineType string
-
-const (
- diffLineAdded diffLineType = "added"
- diffLineOriginal diffLineType = "original"
- diffLineDeleted diffLineType = "deleted"
-)
-
-type diffLine struct {
- originalNumber int // 1-based original line number
- typ diffLineType
- data string // "+" or "-" stripped line
-}
-
-type hunkChangesParser struct {
- // needed because we merge currently added lines with the last original line
- lastOriginalLine *diffLine
-
- // if the first line of diff is an adding we save all additions to replacementLinesToPrepend
- replacementLinesToPrepend []string
-
- log logutils.Log
-
- changes []Change
-}
-
-func (p *hunkChangesParser) parse(h *diffpkg.Hunk) []Change {
- lines := parseDiffLines(h)
-
- for i := 0; i < len(lines); {
- line := lines[i]
-
- if line.typ == diffLineOriginal {
- p.handleOriginalLine(lines, line, &i)
- continue
- }
-
- var deletedLines []diffLine
- for ; i < len(lines) && lines[i].typ == diffLineDeleted; i++ {
- deletedLines = append(deletedLines, lines[i])
- }
-
- var addedLines []string
- for ; i < len(lines) && lines[i].typ == diffLineAdded; i++ {
- addedLines = append(addedLines, lines[i].data)
- }
-
- if len(deletedLines) != 0 {
- p.handleDeletedLines(deletedLines, addedLines)
- continue
- }
-
- // no deletions, only additions
- p.handleAddedOnlyLines(addedLines)
- }
-
- if len(p.replacementLinesToPrepend) != 0 {
- p.log.Infof("The diff contains only additions: no original or deleted lines: %#v", lines)
- return nil
- }
-
- return p.changes
-}
-
-func (p *hunkChangesParser) handleOriginalLine(lines []diffLine, line diffLine, i *int) {
- if len(p.replacementLinesToPrepend) == 0 {
- p.lastOriginalLine = &line
- *i++
- return
- }
-
- // check following added lines for the case:
- // + added line 1
- // original line
- // + added line 2
-
- *i++
- var followingAddedLines []string
- for ; *i < len(lines) && lines[*i].typ == diffLineAdded; *i++ {
- followingAddedLines = append(followingAddedLines, lines[*i].data)
- }
-
- change := Change{
- From: line.originalNumber,
- To: line.originalNumber,
- NewLines: slices.Concat(p.replacementLinesToPrepend, []string{line.data}, followingAddedLines),
- }
- p.changes = append(p.changes, change)
-
- p.replacementLinesToPrepend = nil
- p.lastOriginalLine = &line
-}
-
-func (p *hunkChangesParser) handleDeletedLines(deletedLines []diffLine, addedLines []string) {
- change := Change{
- From: deletedLines[0].originalNumber,
- To: deletedLines[len(deletedLines)-1].originalNumber,
- }
-
- switch {
- case len(addedLines) != 0:
- change.NewLines = slices.Concat(p.replacementLinesToPrepend, addedLines)
- p.replacementLinesToPrepend = nil
-
- case len(p.replacementLinesToPrepend) != 0:
- // delete-only change with possible prepending
- change.NewLines = slices.Clone(p.replacementLinesToPrepend)
- p.replacementLinesToPrepend = nil
- }
-
- p.changes = append(p.changes, change)
-}
-
-func (p *hunkChangesParser) handleAddedOnlyLines(addedLines []string) {
- if p.lastOriginalLine == nil {
- // the first line is added; the diff looks like:
- // 1. + ...
- // 2. - ...
- // or
- // 1. + ...
- // 2. ...
-
- p.replacementLinesToPrepend = addedLines
-
- return
- }
-
- // add-only change merged into the last original line with possible prepending
- change := Change{
- From: p.lastOriginalLine.originalNumber,
- To: p.lastOriginalLine.originalNumber,
- NewLines: slices.Concat(p.replacementLinesToPrepend, []string{p.lastOriginalLine.data}, addedLines),
- }
-
- p.changes = append(p.changes, change)
-
- p.replacementLinesToPrepend = nil
-}
-
-func parseDiffLines(h *diffpkg.Hunk) []diffLine {
- lines := bytes.Split(h.Body, []byte{'\n'})
-
- currentOriginalLineNumber := int(h.OrigStartLine)
-
- var diffLines []diffLine
-
- for i, line := range lines {
- dl := diffLine{
- originalNumber: currentOriginalLineNumber,
- }
-
- if i == len(lines)-1 && len(line) == 0 {
- // handle last \n: don't add an empty original line
- break
- }
-
- lineStr := string(line)
-
- switch {
- case strings.HasPrefix(lineStr, "-"):
- dl.typ = diffLineDeleted
- dl.data = strings.TrimPrefix(lineStr, "-")
- currentOriginalLineNumber++
-
- case strings.HasPrefix(lineStr, "+"):
- dl.typ = diffLineAdded
- dl.data = strings.TrimPrefix(lineStr, "+")
-
- default:
- dl.typ = diffLineOriginal
- dl.data = strings.TrimPrefix(lineStr, " ")
- currentOriginalLineNumber++
- }
-
- diffLines = append(diffLines, dl)
- }
-
- // if > 0, then the original file had a 'No newline at end of file' mark
- if h.OrigNoNewlineAt > 0 {
- dl := diffLine{
- originalNumber: currentOriginalLineNumber + 1,
- typ: diffLineAdded,
- data: "",
- }
- diffLines = append(diffLines, dl)
- }
-
- return diffLines
-}
-
-func ExtractDiagnosticFromPatch(
- pass *analysis.Pass,
- file *ast.File,
- patch []byte,
- logger logutils.Log,
-) error {
- diffs, err := diffpkg.ParseMultiFileDiff(patch)
- if err != nil {
- return fmt.Errorf("can't parse patch: %w", err)
- }
-
- if len(diffs) == 0 {
- return fmt.Errorf("got no diffs from patch parser: %s", patch)
- }
-
- ft := pass.Fset.File(file.Pos())
-
- adjLine := pass.Fset.PositionFor(file.Pos(), false).Line - pass.Fset.PositionFor(file.Pos(), true).Line
-
- for _, d := range diffs {
- if len(d.Hunks) == 0 {
- logger.Warnf("Got no hunks in diff %+v", d)
- continue
- }
-
- for _, hunk := range d.Hunks {
- p := hunkChangesParser{log: logger}
-
- changes := p.parse(hunk)
-
- for _, change := range changes {
- pass.Report(toDiagnostic(ft, change, adjLine))
- }
- }
- }
-
- return nil
-}
-
-func toDiagnostic(ft *token.File, change Change, adjLine int) analysis.Diagnostic {
- from := change.From + adjLine
- if from > ft.LineCount() {
- from = ft.LineCount()
- }
-
- start := ft.LineStart(from)
-
- end := goanalysis.EndOfLinePos(ft, change.To+adjLine)
-
- return analysis.Diagnostic{
- Pos: start,
- End: end,
- Message: "File is not properly formatted",
- SuggestedFixes: []analysis.SuggestedFix{{
- TextEdits: []analysis.TextEdit{{
- Pos: start,
- End: end,
- NewText: []byte(strings.Join(change.NewLines, "\n")),
- }},
- }},
- }
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/goformatters/meta_formatter.go b/vendor/github.com/golangci/golangci-lint/pkg/goformatters/meta_formatter.go
deleted file mode 100644
index d66878c7ab..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/goformatters/meta_formatter.go
+++ /dev/null
@@ -1,74 +0,0 @@
-package goformatters
-
-import (
- "bytes"
- "fmt"
- "go/format"
-
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/goformatters/gci"
- "github.com/golangci/golangci-lint/pkg/goformatters/gofmt"
- "github.com/golangci/golangci-lint/pkg/goformatters/gofumpt"
- "github.com/golangci/golangci-lint/pkg/goformatters/goimports"
- "github.com/golangci/golangci-lint/pkg/lint/linter"
- "github.com/golangci/golangci-lint/pkg/logutils"
-)
-
-type MetaFormatter struct {
- log logutils.Log
- formatters []Formatter
-}
-
-func NewMetaFormatter(log logutils.Log, cfg *config.Config, enabledLinters map[string]*linter.Config) (*MetaFormatter, error) {
- m := &MetaFormatter{log: log}
-
- if _, ok := enabledLinters[gofmt.Name]; ok {
- m.formatters = append(m.formatters, gofmt.New(&cfg.LintersSettings.Gofmt))
- }
-
- if _, ok := enabledLinters[gofumpt.Name]; ok {
- m.formatters = append(m.formatters, gofumpt.New(&cfg.LintersSettings.Gofumpt, cfg.Run.Go))
- }
-
- if _, ok := enabledLinters[goimports.Name]; ok {
- m.formatters = append(m.formatters, goimports.New(&cfg.LintersSettings.Goimports))
- }
-
- // gci is a last because the only goal of gci is to handle imports.
- if _, ok := enabledLinters[gci.Name]; ok {
- formatter, err := gci.New(&cfg.LintersSettings.Gci)
- if err != nil {
- return nil, fmt.Errorf("gci: creating formatter: %w", err)
- }
-
- m.formatters = append(m.formatters, formatter)
- }
-
- return m, nil
-}
-
-func (m *MetaFormatter) Format(filename string, src []byte) []byte {
- if len(m.formatters) == 0 {
- data, err := format.Source(src)
- if err != nil {
- m.log.Warnf("(fmt) formatting file %s: %v", filename, err)
- return src
- }
-
- return data
- }
-
- data := bytes.Clone(src)
-
- for _, formatter := range m.formatters {
- formatted, err := formatter.Format(filename, data)
- if err != nil {
- m.log.Warnf("(%s) formatting file %s: %v", formatter.Name(), filename, err)
- continue
- }
-
- data = formatted
- }
-
- return data
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/asasalint/asasalint.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/asasalint/asasalint.go
deleted file mode 100644
index ccc58fee40..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/asasalint/asasalint.go
+++ /dev/null
@@ -1,31 +0,0 @@
-package asasalint
-
-import (
- "github.com/alingse/asasalint"
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/goanalysis"
- "github.com/golangci/golangci-lint/pkg/golinters/internal"
-)
-
-func New(settings *config.AsasalintSettings) *goanalysis.Linter {
- cfg := asasalint.LinterSetting{}
- if settings != nil {
- cfg.Exclude = settings.Exclude
- cfg.NoBuiltinExclusions = !settings.UseBuiltinExclusions
- cfg.IgnoreTest = settings.IgnoreTest
- }
-
- a, err := asasalint.NewAnalyzer(cfg)
- if err != nil {
- internal.LinterLogger.Fatalf("asasalint: create analyzer: %v", err)
- }
-
- return goanalysis.NewLinter(
- a.Name,
- a.Doc,
- []*analysis.Analyzer{a},
- nil,
- ).WithLoadMode(goanalysis.LoadModeTypesInfo)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/asciicheck/asciicheck.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/asciicheck/asciicheck.go
deleted file mode 100644
index 675dfc4780..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/asciicheck/asciicheck.go
+++ /dev/null
@@ -1,19 +0,0 @@
-package asciicheck
-
-import (
- "github.com/tdakkota/asciicheck"
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/goanalysis"
-)
-
-func New() *goanalysis.Linter {
- a := asciicheck.NewAnalyzer()
-
- return goanalysis.NewLinter(
- a.Name,
- a.Doc,
- []*analysis.Analyzer{a},
- nil,
- ).WithLoadMode(goanalysis.LoadModeSyntax)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/bidichk/bidichk.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/bidichk/bidichk.go
deleted file mode 100644
index c6315965c4..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/bidichk/bidichk.go
+++ /dev/null
@@ -1,59 +0,0 @@
-package bidichk
-
-import (
- "strings"
-
- "github.com/breml/bidichk/pkg/bidichk"
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/goanalysis"
-)
-
-func New(settings *config.BiDiChkSettings) *goanalysis.Linter {
- a := bidichk.NewAnalyzer()
-
- cfg := map[string]map[string]any{}
- if settings != nil {
- var opts []string
-
- if settings.LeftToRightEmbedding {
- opts = append(opts, "LEFT-TO-RIGHT-EMBEDDING")
- }
- if settings.RightToLeftEmbedding {
- opts = append(opts, "RIGHT-TO-LEFT-EMBEDDING")
- }
- if settings.PopDirectionalFormatting {
- opts = append(opts, "POP-DIRECTIONAL-FORMATTING")
- }
- if settings.LeftToRightOverride {
- opts = append(opts, "LEFT-TO-RIGHT-OVERRIDE")
- }
- if settings.RightToLeftOverride {
- opts = append(opts, "RIGHT-TO-LEFT-OVERRIDE")
- }
- if settings.LeftToRightIsolate {
- opts = append(opts, "LEFT-TO-RIGHT-ISOLATE")
- }
- if settings.RightToLeftIsolate {
- opts = append(opts, "RIGHT-TO-LEFT-ISOLATE")
- }
- if settings.FirstStrongIsolate {
- opts = append(opts, "FIRST-STRONG-ISOLATE")
- }
- if settings.PopDirectionalIsolate {
- opts = append(opts, "POP-DIRECTIONAL-ISOLATE")
- }
-
- cfg[a.Name] = map[string]any{
- "disallowed-runes": strings.Join(opts, ","),
- }
- }
-
- return goanalysis.NewLinter(
- a.Name,
- "Checks for dangerous unicode character sequences",
- []*analysis.Analyzer{a},
- cfg,
- ).WithLoadMode(goanalysis.LoadModeSyntax)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/bodyclose/bodyclose.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/bodyclose/bodyclose.go
deleted file mode 100644
index c520e88db3..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/bodyclose/bodyclose.go
+++ /dev/null
@@ -1,19 +0,0 @@
-package bodyclose
-
-import (
- "github.com/timakin/bodyclose/passes/bodyclose"
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/goanalysis"
-)
-
-func New() *goanalysis.Linter {
- a := bodyclose.Analyzer
-
- return goanalysis.NewLinter(
- a.Name,
- a.Doc,
- []*analysis.Analyzer{a},
- nil,
- ).WithLoadMode(goanalysis.LoadModeTypesInfo)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/canonicalheader/canonicalheader.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/canonicalheader/canonicalheader.go
deleted file mode 100644
index d721916a49..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/canonicalheader/canonicalheader.go
+++ /dev/null
@@ -1,19 +0,0 @@
-package canonicalheader
-
-import (
- "github.com/lasiar/canonicalheader"
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/goanalysis"
-)
-
-func New() *goanalysis.Linter {
- a := canonicalheader.Analyzer
-
- return goanalysis.NewLinter(
- a.Name,
- a.Doc,
- []*analysis.Analyzer{a},
- nil,
- ).WithLoadMode(goanalysis.LoadModeTypesInfo)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/containedctx/containedctx.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/containedctx/containedctx.go
deleted file mode 100644
index 6fdb4ea6e1..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/containedctx/containedctx.go
+++ /dev/null
@@ -1,19 +0,0 @@
-package containedctx
-
-import (
- "github.com/sivchari/containedctx"
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/goanalysis"
-)
-
-func New() *goanalysis.Linter {
- a := containedctx.Analyzer
-
- return goanalysis.NewLinter(
- a.Name,
- a.Doc,
- []*analysis.Analyzer{a},
- nil,
- ).WithLoadMode(goanalysis.LoadModeTypesInfo)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/contextcheck/contextcheck.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/contextcheck/contextcheck.go
deleted file mode 100644
index a34c518b2c..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/contextcheck/contextcheck.go
+++ /dev/null
@@ -1,22 +0,0 @@
-package contextcheck
-
-import (
- "github.com/kkHAIKE/contextcheck"
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/goanalysis"
- "github.com/golangci/golangci-lint/pkg/lint/linter"
-)
-
-func New() *goanalysis.Linter {
- analyzer := contextcheck.NewAnalyzer(contextcheck.Configuration{})
-
- return goanalysis.NewLinter(
- analyzer.Name,
- analyzer.Doc,
- []*analysis.Analyzer{analyzer},
- nil,
- ).WithContextSetter(func(lintCtx *linter.Context) {
- analyzer.Run = contextcheck.NewRun(lintCtx.Packages, false)
- }).WithLoadMode(goanalysis.LoadModeTypesInfo)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/copyloopvar/copyloopvar.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/copyloopvar/copyloopvar.go
deleted file mode 100644
index adb4ee7284..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/copyloopvar/copyloopvar.go
+++ /dev/null
@@ -1,29 +0,0 @@
-package copyloopvar
-
-import (
- "github.com/karamaru-alpha/copyloopvar"
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/goanalysis"
-)
-
-func New(settings *config.CopyLoopVarSettings) *goanalysis.Linter {
- a := copyloopvar.NewAnalyzer()
-
- var cfg map[string]map[string]any
- if settings != nil {
- cfg = map[string]map[string]any{
- a.Name: {
- "check-alias": settings.CheckAlias,
- },
- }
- }
-
- return goanalysis.NewLinter(
- a.Name,
- a.Doc,
- []*analysis.Analyzer{a},
- cfg,
- ).WithLoadMode(goanalysis.LoadModeSyntax)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/cyclop/cyclop.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/cyclop/cyclop.go
deleted file mode 100644
index 772b5601ca..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/cyclop/cyclop.go
+++ /dev/null
@@ -1,37 +0,0 @@
-package cyclop
-
-import (
- "github.com/bkielbasa/cyclop/pkg/analyzer"
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/goanalysis"
-)
-
-func New(settings *config.Cyclop) *goanalysis.Linter {
- a := analyzer.NewAnalyzer()
-
- var cfg map[string]map[string]any
- if settings != nil {
- d := map[string]any{
- "skipTests": settings.SkipTests,
- }
-
- if settings.MaxComplexity != 0 {
- d["maxComplexity"] = settings.MaxComplexity
- }
-
- if settings.PackageAverage != 0 {
- d["packageAverage"] = settings.PackageAverage
- }
-
- cfg = map[string]map[string]any{a.Name: d}
- }
-
- return goanalysis.NewLinter(
- a.Name,
- a.Doc,
- []*analysis.Analyzer{a},
- cfg,
- ).WithLoadMode(goanalysis.LoadModeSyntax)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/depguard/depguard.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/depguard/depguard.go
deleted file mode 100644
index 1944059996..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/depguard/depguard.go
+++ /dev/null
@@ -1,58 +0,0 @@
-package depguard
-
-import (
- "strings"
-
- "github.com/OpenPeeDeeP/depguard/v2"
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/goanalysis"
- "github.com/golangci/golangci-lint/pkg/golinters/internal"
- "github.com/golangci/golangci-lint/pkg/lint/linter"
-)
-
-func New(settings *config.DepGuardSettings, basePath string) *goanalysis.Linter {
- conf := depguard.LinterSettings{}
-
- if settings != nil {
- for s, rule := range settings.Rules {
- var extendedPatterns []string
- for _, file := range rule.Files {
- extendedPatterns = append(extendedPatterns, strings.ReplaceAll(file, internal.PlaceholderBasePath, basePath))
- }
-
- list := &depguard.List{
- ListMode: rule.ListMode,
- Files: extendedPatterns,
- Allow: rule.Allow,
- }
-
- // because of bug with Viper parsing (split on dot) we use a list of struct instead of a map.
- // https://github.com/spf13/viper/issues/324
- // https://github.com/golangci/golangci-lint/issues/3749#issuecomment-1492536630
-
- deny := map[string]string{}
- for _, r := range rule.Deny {
- deny[r.Pkg] = r.Desc
- }
- list.Deny = deny
-
- conf[s] = list
- }
- }
-
- a := depguard.NewUncompiledAnalyzer(&conf)
-
- return goanalysis.NewLinter(
- a.Analyzer.Name,
- a.Analyzer.Doc,
- []*analysis.Analyzer{a.Analyzer},
- nil,
- ).WithContextSetter(func(lintCtx *linter.Context) {
- err := a.Compile()
- if err != nil {
- lintCtx.Log.Errorf("create analyzer: %v", err)
- }
- }).WithLoadMode(goanalysis.LoadModeSyntax)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/dogsled/dogsled.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/dogsled/dogsled.go
deleted file mode 100644
index afa8152fac..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/dogsled/dogsled.go
+++ /dev/null
@@ -1,78 +0,0 @@
-package dogsled
-
-import (
- "go/ast"
-
- "golang.org/x/tools/go/analysis"
- "golang.org/x/tools/go/analysis/passes/inspect"
- "golang.org/x/tools/go/ast/inspector"
-
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/goanalysis"
-)
-
-const linterName = "dogsled"
-
-func New(settings *config.DogsledSettings) *goanalysis.Linter {
- analyzer := &analysis.Analyzer{
- Name: linterName,
- Doc: goanalysis.TheOnlyanalyzerDoc,
- Run: func(pass *analysis.Pass) (any, error) {
- return run(pass, settings.MaxBlankIdentifiers)
- },
- Requires: []*analysis.Analyzer{inspect.Analyzer},
- }
-
- return goanalysis.NewLinter(
- linterName,
- "Checks assignments with too many blank identifiers (e.g. x, _, _, _, := f())",
- []*analysis.Analyzer{analyzer},
- nil,
- ).WithLoadMode(goanalysis.LoadModeSyntax)
-}
-
-func run(pass *analysis.Pass, maxBlanks int) (any, error) {
- insp, ok := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
- if !ok {
- return nil, nil
- }
-
- nodeFilter := []ast.Node{
- (*ast.FuncDecl)(nil),
- }
-
- insp.Preorder(nodeFilter, func(node ast.Node) {
- funcDecl, ok := node.(*ast.FuncDecl)
- if !ok {
- return
- }
-
- if funcDecl.Body == nil {
- return
- }
-
- for _, expr := range funcDecl.Body.List {
- assgnStmt, ok := expr.(*ast.AssignStmt)
- if !ok {
- continue
- }
-
- numBlank := 0
- for _, left := range assgnStmt.Lhs {
- ident, ok := left.(*ast.Ident)
- if !ok {
- continue
- }
- if ident.Name == "_" {
- numBlank++
- }
- }
-
- if numBlank > maxBlanks {
- pass.Reportf(assgnStmt.Pos(), "declaration has %v blank identifiers", numBlank)
- }
- }
- })
-
- return nil, nil
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/dupl/dupl.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/dupl/dupl.go
deleted file mode 100644
index 6d1a9809c7..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/dupl/dupl.go
+++ /dev/null
@@ -1,94 +0,0 @@
-package dupl
-
-import (
- "fmt"
- "go/token"
- "sync"
-
- duplAPI "github.com/golangci/dupl/lib"
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/fsutils"
- "github.com/golangci/golangci-lint/pkg/goanalysis"
- "github.com/golangci/golangci-lint/pkg/golinters/internal"
- "github.com/golangci/golangci-lint/pkg/lint/linter"
- "github.com/golangci/golangci-lint/pkg/result"
-)
-
-const linterName = "dupl"
-
-func New(settings *config.DuplSettings) *goanalysis.Linter {
- var mu sync.Mutex
- var resIssues []goanalysis.Issue
-
- analyzer := &analysis.Analyzer{
- Name: linterName,
- Doc: goanalysis.TheOnlyanalyzerDoc,
- Run: func(pass *analysis.Pass) (any, error) {
- issues, err := runDupl(pass, settings)
- if err != nil {
- return nil, err
- }
-
- if len(issues) == 0 {
- return nil, nil
- }
-
- mu.Lock()
- resIssues = append(resIssues, issues...)
- mu.Unlock()
-
- return nil, nil
- },
- }
-
- return goanalysis.NewLinter(
- linterName,
- "Detects duplicate fragments of code.",
- []*analysis.Analyzer{analyzer},
- nil,
- ).WithIssuesReporter(func(*linter.Context) []goanalysis.Issue {
- return resIssues
- }).WithLoadMode(goanalysis.LoadModeSyntax)
-}
-
-func runDupl(pass *analysis.Pass, settings *config.DuplSettings) ([]goanalysis.Issue, error) {
- issues, err := duplAPI.Run(internal.GetGoFileNames(pass), settings.Threshold)
- if err != nil {
- return nil, err
- }
-
- if len(issues) == 0 {
- return nil, nil
- }
-
- res := make([]goanalysis.Issue, 0, len(issues))
-
- for _, i := range issues {
- toFilename, err := fsutils.ShortestRelPath(i.To.Filename(), "")
- if err != nil {
- return nil, fmt.Errorf("failed to get shortest rel path for %q: %w", i.To.Filename(), err)
- }
-
- dupl := fmt.Sprintf("%s:%d-%d", toFilename, i.To.LineStart(), i.To.LineEnd())
- text := fmt.Sprintf("%d-%d lines are duplicate of %s",
- i.From.LineStart(), i.From.LineEnd(),
- internal.FormatCode(dupl, nil))
-
- res = append(res, goanalysis.NewIssue(&result.Issue{
- Pos: token.Position{
- Filename: i.From.Filename(),
- Line: i.From.LineStart(),
- },
- LineRange: &result.Range{
- From: i.From.LineStart(),
- To: i.From.LineEnd(),
- },
- Text: text,
- FromLinter: linterName,
- }, pass))
- }
-
- return res, nil
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/dupword/dupword.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/dupword/dupword.go
deleted file mode 100644
index a2bcc34d40..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/dupword/dupword.go
+++ /dev/null
@@ -1,30 +0,0 @@
-package dupword
-
-import (
- "strings"
-
- "github.com/Abirdcfly/dupword"
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/goanalysis"
-)
-
-func New(settings *config.DupWordSettings) *goanalysis.Linter {
- a := dupword.NewAnalyzer()
-
- cfg := map[string]map[string]any{}
- if settings != nil {
- cfg[a.Name] = map[string]any{
- "keyword": strings.Join(settings.Keywords, ","),
- "ignore": strings.Join(settings.Ignore, ","),
- }
- }
-
- return goanalysis.NewLinter(
- a.Name,
- "checks for duplicate words in the source code",
- []*analysis.Analyzer{a},
- cfg,
- ).WithLoadMode(goanalysis.LoadModeSyntax)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/durationcheck/durationcheck.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/durationcheck/durationcheck.go
deleted file mode 100644
index 88f22c27c0..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/durationcheck/durationcheck.go
+++ /dev/null
@@ -1,19 +0,0 @@
-package durationcheck
-
-import (
- "github.com/charithe/durationcheck"
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/goanalysis"
-)
-
-func New() *goanalysis.Linter {
- a := durationcheck.Analyzer
-
- return goanalysis.NewLinter(
- a.Name,
- a.Doc,
- []*analysis.Analyzer{a},
- nil,
- ).WithLoadMode(goanalysis.LoadModeTypesInfo)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/err113/err113.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/err113/err113.go
deleted file mode 100644
index 2600128be1..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/err113/err113.go
+++ /dev/null
@@ -1,19 +0,0 @@
-package err113
-
-import (
- "github.com/Djarvur/go-err113"
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/goanalysis"
-)
-
-func New() *goanalysis.Linter {
- a := err113.NewAnalyzer()
-
- return goanalysis.NewLinter(
- a.Name,
- "Go linter to check the errors handling expressions",
- []*analysis.Analyzer{a},
- nil,
- ).WithLoadMode(goanalysis.LoadModeTypesInfo)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/errcheck/errcheck.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/errcheck/errcheck.go
deleted file mode 100644
index 67a1b2ca8d..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/errcheck/errcheck.go
+++ /dev/null
@@ -1,269 +0,0 @@
-package errcheck
-
-import (
- "bufio"
- "cmp"
- "fmt"
- "os"
- "os/user"
- "path/filepath"
- "regexp"
- "strings"
- "sync"
-
- "github.com/kisielk/errcheck/errcheck"
- "golang.org/x/tools/go/analysis"
- "golang.org/x/tools/go/packages"
-
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/fsutils"
- "github.com/golangci/golangci-lint/pkg/goanalysis"
- "github.com/golangci/golangci-lint/pkg/golinters/internal"
- "github.com/golangci/golangci-lint/pkg/lint/linter"
- "github.com/golangci/golangci-lint/pkg/result"
-)
-
-const linterName = "errcheck"
-
-func New(settings *config.ErrcheckSettings) *goanalysis.Linter {
- var mu sync.Mutex
- var resIssues []goanalysis.Issue
-
- analyzer := &analysis.Analyzer{
- Name: linterName,
- Doc: goanalysis.TheOnlyanalyzerDoc,
- Run: goanalysis.DummyRun,
- }
-
- return goanalysis.NewLinter(
- linterName,
- "errcheck is a program for checking for unchecked errors in Go code. "+
- "These unchecked errors can be critical bugs in some cases",
- []*analysis.Analyzer{analyzer},
- nil,
- ).WithContextSetter(func(lintCtx *linter.Context) {
- // copied from errcheck
- checker, err := getChecker(settings)
- if err != nil {
- lintCtx.Log.Errorf("failed to get checker: %v", err)
- return
- }
-
- checker.Tags = lintCtx.Cfg.Run.BuildTags
-
- analyzer.Run = func(pass *analysis.Pass) (any, error) {
- issues := runErrCheck(lintCtx, pass, checker)
- if err != nil {
- return nil, err
- }
-
- if len(issues) == 0 {
- return nil, nil
- }
-
- mu.Lock()
- resIssues = append(resIssues, issues...)
- mu.Unlock()
-
- return nil, nil
- }
- }).WithIssuesReporter(func(*linter.Context) []goanalysis.Issue {
- return resIssues
- }).WithLoadMode(goanalysis.LoadModeTypesInfo)
-}
-
-func runErrCheck(lintCtx *linter.Context, pass *analysis.Pass, checker *errcheck.Checker) []goanalysis.Issue {
- pkg := &packages.Package{
- Fset: pass.Fset,
- Syntax: pass.Files,
- Types: pass.Pkg,
- TypesInfo: pass.TypesInfo,
- }
-
- lintIssues := checker.CheckPackage(pkg).Unique()
- if len(lintIssues.UncheckedErrors) == 0 {
- return nil
- }
-
- issues := make([]goanalysis.Issue, len(lintIssues.UncheckedErrors))
-
- for i, err := range lintIssues.UncheckedErrors {
- text := "Error return value is not checked"
-
- if err.FuncName != "" {
- code := cmp.Or(err.SelectorName, err.FuncName)
-
- text = fmt.Sprintf("Error return value of %s is not checked", internal.FormatCode(code, lintCtx.Cfg))
- }
-
- issues[i] = goanalysis.NewIssue(
- &result.Issue{
- FromLinter: linterName,
- Text: text,
- Pos: err.Pos,
- },
- pass,
- )
- }
-
- return issues
-}
-
-// parseIgnoreConfig was taken from errcheck in order to keep the API identical.
-// https://github.com/kisielk/errcheck/blob/1787c4bee836470bf45018cfbc783650db3c6501/main.go#L25-L60
-func parseIgnoreConfig(s string) (map[string]*regexp.Regexp, error) {
- if s == "" {
- return nil, nil
- }
-
- cfg := map[string]*regexp.Regexp{}
-
- for _, pair := range strings.Split(s, ",") {
- colonIndex := strings.Index(pair, ":")
- var pkg, re string
- if colonIndex == -1 {
- pkg = ""
- re = pair
- } else {
- pkg = pair[:colonIndex]
- re = pair[colonIndex+1:]
- }
- regex, err := regexp.Compile(re)
- if err != nil {
- return nil, err
- }
- cfg[pkg] = regex
- }
-
- return cfg, nil
-}
-
-func getChecker(errCfg *config.ErrcheckSettings) (*errcheck.Checker, error) {
- ignoreConfig, err := parseIgnoreConfig(errCfg.Ignore)
- if err != nil {
- return nil, fmt.Errorf("failed to parse 'ignore' directive: %w", err)
- }
-
- checker := errcheck.Checker{
- Exclusions: errcheck.Exclusions{
- BlankAssignments: !errCfg.CheckAssignToBlank,
- TypeAssertions: !errCfg.CheckTypeAssertions,
- SymbolRegexpsByPackage: map[string]*regexp.Regexp{},
- },
- }
-
- if !errCfg.DisableDefaultExclusions {
- checker.Exclusions.Symbols = append(checker.Exclusions.Symbols, errcheck.DefaultExcludedSymbols...)
- }
-
- for pkg, re := range ignoreConfig {
- checker.Exclusions.SymbolRegexpsByPackage[pkg] = re
- }
-
- if errCfg.Exclude != "" {
- exclude, err := readExcludeFile(errCfg.Exclude)
- if err != nil {
- return nil, err
- }
-
- checker.Exclusions.Symbols = append(checker.Exclusions.Symbols, exclude...)
- }
-
- checker.Exclusions.Symbols = append(checker.Exclusions.Symbols, errCfg.ExcludeFunctions...)
-
- return &checker, nil
-}
-
-func getFirstPathArg() string {
- args := os.Args
-
- // skip all args ([golangci-lint, run/linters]) before files/dirs list
- for len(args) != 0 {
- if args[0] == "run" {
- args = args[1:]
- break
- }
-
- args = args[1:]
- }
-
- // find first file/dir arg
- firstArg := "./..."
- for _, arg := range args {
- if !strings.HasPrefix(arg, "-") {
- firstArg = arg
- break
- }
- }
-
- return firstArg
-}
-
-func setupConfigFileSearch(name string) []string {
- if strings.HasPrefix(name, "~") {
- if u, err := user.Current(); err == nil {
- name = strings.Replace(name, "~", u.HomeDir, 1)
- }
- }
-
- if filepath.IsAbs(name) {
- return []string{name}
- }
-
- firstArg := getFirstPathArg()
-
- absStartPath, err := filepath.Abs(firstArg)
- if err != nil {
- absStartPath = filepath.Clean(firstArg)
- }
-
- // start from it
- var curDir string
- if fsutils.IsDir(absStartPath) {
- curDir = absStartPath
- } else {
- curDir = filepath.Dir(absStartPath)
- }
-
- // find all dirs from it up to the root
- configSearchPaths := []string{filepath.Join(".", name)}
- for {
- configSearchPaths = append(configSearchPaths, filepath.Join(curDir, name))
- newCurDir := filepath.Dir(curDir)
- if curDir == newCurDir || newCurDir == "" {
- break
- }
- curDir = newCurDir
- }
-
- return configSearchPaths
-}
-
-func readExcludeFile(name string) ([]string, error) {
- var err error
- var fh *os.File
-
- for _, path := range setupConfigFileSearch(name) {
- if fh, err = os.Open(path); err == nil {
- break
- }
- }
-
- if fh == nil {
- return nil, fmt.Errorf("failed reading exclude file: %s: %w", name, err)
- }
- defer func() { _ = fh.Close() }()
-
- scanner := bufio.NewScanner(fh)
-
- var excludes []string
- for scanner.Scan() {
- excludes = append(excludes, scanner.Text())
- }
-
- if err := scanner.Err(); err != nil {
- return nil, fmt.Errorf("failed scanning file: %s: %w", name, err)
- }
-
- return excludes, nil
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/errchkjson/errchkjson.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/errchkjson/errchkjson.go
deleted file mode 100644
index 506113d6d5..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/errchkjson/errchkjson.go
+++ /dev/null
@@ -1,31 +0,0 @@
-package errchkjson
-
-import (
- "github.com/breml/errchkjson"
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/goanalysis"
-)
-
-func New(settings *config.ErrChkJSONSettings) *goanalysis.Linter {
- a := errchkjson.NewAnalyzer()
-
- cfg := map[string]map[string]any{}
- cfg[a.Name] = map[string]any{
- "omit-safe": true,
- }
- if settings != nil {
- cfg[a.Name] = map[string]any{
- "omit-safe": !settings.CheckErrorFreeEncoding,
- "report-no-exported": settings.ReportNoExported,
- }
- }
-
- return goanalysis.NewLinter(
- a.Name,
- a.Doc,
- []*analysis.Analyzer{a},
- cfg,
- ).WithLoadMode(goanalysis.LoadModeTypesInfo)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/errname/errname.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/errname/errname.go
deleted file mode 100644
index f868854c12..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/errname/errname.go
+++ /dev/null
@@ -1,19 +0,0 @@
-package errname
-
-import (
- "github.com/Antonboom/errname/pkg/analyzer"
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/goanalysis"
-)
-
-func New() *goanalysis.Linter {
- a := analyzer.New()
-
- return goanalysis.NewLinter(
- a.Name,
- a.Doc,
- []*analysis.Analyzer{a},
- nil,
- ).WithLoadMode(goanalysis.LoadModeTypesInfo)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/errorlint/errorlint.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/errorlint/errorlint.go
deleted file mode 100644
index 14851adc28..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/errorlint/errorlint.go
+++ /dev/null
@@ -1,54 +0,0 @@
-package errorlint
-
-import (
- "github.com/polyfloyd/go-errorlint/errorlint"
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/goanalysis"
-)
-
-func New(settings *config.ErrorLintSettings) *goanalysis.Linter {
- var opts []errorlint.Option
-
- if settings != nil {
- ae := toAllowPairs(settings.AllowedErrors)
- if len(ae) > 0 {
- opts = append(opts, errorlint.WithAllowedErrors(ae))
- }
-
- aew := toAllowPairs(settings.AllowedErrorsWildcard)
- if len(aew) > 0 {
- opts = append(opts, errorlint.WithAllowedWildcard(aew))
- }
- }
-
- a := errorlint.NewAnalyzer(opts...)
-
- cfg := map[string]map[string]any{}
-
- if settings != nil {
- cfg[a.Name] = map[string]any{
- "errorf": settings.Errorf,
- "errorf-multi": settings.ErrorfMulti,
- "asserts": settings.Asserts,
- "comparison": settings.Comparison,
- }
- }
-
- return goanalysis.NewLinter(
- a.Name,
- "errorlint is a linter for that can be used to find code "+
- "that will cause problems with the error wrapping scheme introduced in Go 1.13.",
- []*analysis.Analyzer{a},
- cfg,
- ).WithLoadMode(goanalysis.LoadModeTypesInfo)
-}
-
-func toAllowPairs(data []config.ErrorLintAllowPair) []errorlint.AllowPair {
- var pairs []errorlint.AllowPair
- for _, allowedError := range data {
- pairs = append(pairs, errorlint.AllowPair(allowedError))
- }
- return pairs
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/exhaustive/exhaustive.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/exhaustive/exhaustive.go
deleted file mode 100644
index 9249efb69a..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/exhaustive/exhaustive.go
+++ /dev/null
@@ -1,37 +0,0 @@
-package exhaustive
-
-import (
- "github.com/nishanths/exhaustive"
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/goanalysis"
-)
-
-func New(settings *config.ExhaustiveSettings) *goanalysis.Linter {
- a := exhaustive.Analyzer
-
- var cfg map[string]map[string]any
- if settings != nil {
- cfg = map[string]map[string]any{
- a.Name: {
- exhaustive.CheckFlag: settings.Check,
- exhaustive.CheckGeneratedFlag: settings.CheckGenerated,
- exhaustive.DefaultSignifiesExhaustiveFlag: settings.DefaultSignifiesExhaustive,
- exhaustive.IgnoreEnumMembersFlag: settings.IgnoreEnumMembers,
- exhaustive.IgnoreEnumTypesFlag: settings.IgnoreEnumTypes,
- exhaustive.PackageScopeOnlyFlag: settings.PackageScopeOnly,
- exhaustive.ExplicitExhaustiveMapFlag: settings.ExplicitExhaustiveMap,
- exhaustive.ExplicitExhaustiveSwitchFlag: settings.ExplicitExhaustiveSwitch,
- exhaustive.DefaultCaseRequiredFlag: settings.DefaultCaseRequired,
- },
- }
- }
-
- return goanalysis.NewLinter(
- a.Name,
- a.Doc,
- []*analysis.Analyzer{a},
- cfg,
- ).WithLoadMode(goanalysis.LoadModeTypesInfo)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/exhaustruct/exhaustruct.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/exhaustruct/exhaustruct.go
deleted file mode 100644
index 53ad87154f..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/exhaustruct/exhaustruct.go
+++ /dev/null
@@ -1,30 +0,0 @@
-package exhaustruct
-
-import (
- "github.com/GaijinEntertainment/go-exhaustruct/v3/analyzer"
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/goanalysis"
- "github.com/golangci/golangci-lint/pkg/golinters/internal"
-)
-
-func New(settings *config.ExhaustructSettings) *goanalysis.Linter {
- var include, exclude []string
- if settings != nil {
- include = settings.Include
- exclude = settings.Exclude
- }
-
- a, err := analyzer.NewAnalyzer(include, exclude)
- if err != nil {
- internal.LinterLogger.Fatalf("exhaustruct configuration: %v", err)
- }
-
- return goanalysis.NewLinter(
- a.Name,
- a.Doc,
- []*analysis.Analyzer{a},
- nil,
- ).WithLoadMode(goanalysis.LoadModeTypesInfo)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/exptostd/exptostd.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/exptostd/exptostd.go
deleted file mode 100644
index 2de8ea98c2..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/exptostd/exptostd.go
+++ /dev/null
@@ -1,19 +0,0 @@
-package exptostd
-
-import (
- "github.com/ldez/exptostd"
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/goanalysis"
-)
-
-func New() *goanalysis.Linter {
- a := exptostd.NewAnalyzer()
-
- return goanalysis.NewLinter(
- a.Name,
- a.Doc,
- []*analysis.Analyzer{a},
- nil,
- ).WithLoadMode(goanalysis.LoadModeTypesInfo)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/fatcontext/fatcontext.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/fatcontext/fatcontext.go
deleted file mode 100644
index 2ffacacd39..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/fatcontext/fatcontext.go
+++ /dev/null
@@ -1,28 +0,0 @@
-package fatcontext
-
-import (
- "github.com/Crocmagnon/fatcontext/pkg/analyzer"
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/goanalysis"
-)
-
-func New(settings *config.FatcontextSettings) *goanalysis.Linter {
- a := analyzer.NewAnalyzer()
-
- cfg := map[string]map[string]any{}
-
- if settings != nil {
- cfg[a.Name] = map[string]any{
- analyzer.FlagCheckStructPointers: settings.CheckStructPointers,
- }
- }
-
- return goanalysis.NewLinter(
- a.Name,
- a.Doc,
- []*analysis.Analyzer{a},
- cfg,
- ).WithLoadMode(goanalysis.LoadModeTypesInfo)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/forbidigo/forbidigo.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/forbidigo/forbidigo.go
deleted file mode 100644
index 3b410359d0..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/forbidigo/forbidigo.go
+++ /dev/null
@@ -1,89 +0,0 @@
-package forbidigo
-
-import (
- "fmt"
-
- "github.com/ashanbrown/forbidigo/forbidigo"
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/goanalysis"
- "github.com/golangci/golangci-lint/pkg/logutils"
-)
-
-const linterName = "forbidigo"
-
-func New(settings *config.ForbidigoSettings) *goanalysis.Linter {
- analyzer := &analysis.Analyzer{
- Name: linterName,
- Doc: goanalysis.TheOnlyanalyzerDoc,
- Run: func(pass *analysis.Pass) (any, error) {
- err := runForbidigo(pass, settings)
- if err != nil {
- return nil, err
- }
-
- return nil, nil
- },
- }
-
- // Without AnalyzeTypes, LoadModeSyntax is enough.
- // But we cannot make this depend on the settings and have to mirror the mode chosen in GetAllSupportedLinterConfigs,
- // therefore we have to use LoadModeTypesInfo in all cases.
- return goanalysis.NewLinter(
- linterName,
- "Forbids identifiers",
- []*analysis.Analyzer{analyzer},
- nil,
- ).WithLoadMode(goanalysis.LoadModeTypesInfo)
-}
-
-func runForbidigo(pass *analysis.Pass, settings *config.ForbidigoSettings) error {
- options := []forbidigo.Option{
- forbidigo.OptionExcludeGodocExamples(settings.ExcludeGodocExamples),
- // disable "//permit" directives so only "//nolint" directives matters within golangci-lint
- forbidigo.OptionIgnorePermitDirectives(true),
- forbidigo.OptionAnalyzeTypes(settings.AnalyzeTypes),
- }
-
- // Convert patterns back to strings because that is what NewLinter accepts.
- var patterns []string
- for _, pattern := range settings.Forbid {
- buffer, err := pattern.MarshalString()
- if err != nil {
- return err
- }
-
- patterns = append(patterns, string(buffer))
- }
-
- forbid, err := forbidigo.NewLinter(patterns, options...)
- if err != nil {
- return fmt.Errorf("failed to create linter %q: %w", linterName, err)
- }
-
- for _, file := range pass.Files {
- runConfig := forbidigo.RunConfig{
- Fset: pass.Fset,
- DebugLog: logutils.Debug(logutils.DebugKeyForbidigo),
- }
-
- if settings.AnalyzeTypes {
- runConfig.TypesInfo = pass.TypesInfo
- }
-
- hints, err := forbid.RunWithConfig(runConfig, file)
- if err != nil {
- return fmt.Errorf("forbidigo linter failed on file %q: %w", file.Name.String(), err)
- }
-
- for _, hint := range hints {
- pass.Report(analysis.Diagnostic{
- Pos: hint.Pos(),
- Message: hint.Details(),
- })
- }
- }
-
- return nil
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/forcetypeassert/forcetypeassert.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/forcetypeassert/forcetypeassert.go
deleted file mode 100644
index 98abad7e0d..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/forcetypeassert/forcetypeassert.go
+++ /dev/null
@@ -1,19 +0,0 @@
-package forcetypeassert
-
-import (
- "github.com/gostaticanalysis/forcetypeassert"
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/goanalysis"
-)
-
-func New() *goanalysis.Linter {
- a := forcetypeassert.Analyzer
-
- return goanalysis.NewLinter(
- a.Name,
- "finds forced type assertions",
- []*analysis.Analyzer{a},
- nil,
- ).WithLoadMode(goanalysis.LoadModeTypesInfo)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/funlen/funlen.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/funlen/funlen.go
deleted file mode 100644
index bdadcece46..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/funlen/funlen.go
+++ /dev/null
@@ -1,33 +0,0 @@
-package funlen
-
-import (
- "github.com/ultraware/funlen"
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/goanalysis"
-)
-
-type Config struct {
- lineLimit int
- stmtLimit int
- ignoreComments bool
-}
-
-func New(settings *config.FunlenSettings) *goanalysis.Linter {
- cfg := Config{}
- if settings != nil {
- cfg.lineLimit = settings.Lines
- cfg.stmtLimit = settings.Statements
- cfg.ignoreComments = !settings.IgnoreComments
- }
-
- a := funlen.NewAnalyzer(cfg.lineLimit, cfg.stmtLimit, cfg.ignoreComments)
-
- return goanalysis.NewLinter(
- a.Name,
- a.Doc,
- []*analysis.Analyzer{a},
- nil,
- ).WithLoadMode(goanalysis.LoadModeSyntax)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/gci/gci.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/gci/gci.go
deleted file mode 100644
index b79f1a370c..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/gci/gci.go
+++ /dev/null
@@ -1,33 +0,0 @@
-package gci
-
-import (
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/goanalysis"
- "github.com/golangci/golangci-lint/pkg/goformatters"
- gcibase "github.com/golangci/golangci-lint/pkg/goformatters/gci"
- "github.com/golangci/golangci-lint/pkg/golinters/internal"
-)
-
-const linterName = "gci"
-
-func New(settings *config.GciSettings) *goanalysis.Linter {
- formatter, err := gcibase.New(settings)
- if err != nil {
- internal.LinterLogger.Fatalf("%s: create analyzer: %v", linterName, err)
- }
-
- a := goformatters.NewAnalyzer(
- internal.LinterLogger.Child(linterName),
- "Checks if code and import statements are formatted, with additional rules.",
- formatter,
- )
-
- return goanalysis.NewLinter(
- a.Name,
- a.Doc,
- []*analysis.Analyzer{a},
- nil,
- ).WithLoadMode(goanalysis.LoadModeSyntax)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/ginkgolinter/ginkgolinter.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/ginkgolinter/ginkgolinter.go
deleted file mode 100644
index 6826b77b6b..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/ginkgolinter/ginkgolinter.go
+++ /dev/null
@@ -1,40 +0,0 @@
-package ginkgolinter
-
-import (
- "github.com/nunnatsa/ginkgolinter"
- "github.com/nunnatsa/ginkgolinter/types"
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/goanalysis"
-)
-
-func New(settings *config.GinkgoLinterSettings) *goanalysis.Linter {
- cfg := &types.Config{}
-
- if settings != nil {
- cfg = &types.Config{
- SuppressLen: settings.SuppressLenAssertion,
- SuppressNil: settings.SuppressNilAssertion,
- SuppressErr: settings.SuppressErrAssertion,
- SuppressCompare: settings.SuppressCompareAssertion,
- SuppressAsync: settings.SuppressAsyncAssertion,
- ForbidFocus: settings.ForbidFocusContainer,
- SuppressTypeCompare: settings.SuppressTypeCompareWarning,
- AllowHaveLen0: settings.AllowHaveLenZero,
- ForceExpectTo: settings.ForceExpectTo,
- ValidateAsyncIntervals: settings.ValidateAsyncIntervals,
- ForbidSpecPollution: settings.ForbidSpecPollution,
- ForceSucceedForFuncs: settings.ForceSucceedForFuncs,
- }
- }
-
- a := ginkgolinter.NewAnalyzerWithConfig(cfg)
-
- return goanalysis.NewLinter(
- a.Name,
- "enforces standards of using ginkgo and gomega",
- []*analysis.Analyzer{a},
- nil,
- ).WithLoadMode(goanalysis.LoadModeTypesInfo)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/gocheckcompilerdirectives/gocheckcompilerdirectives.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/gocheckcompilerdirectives/gocheckcompilerdirectives.go
deleted file mode 100644
index be604d805b..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/gocheckcompilerdirectives/gocheckcompilerdirectives.go
+++ /dev/null
@@ -1,19 +0,0 @@
-package gocheckcompilerdirectives
-
-import (
- "4d63.com/gocheckcompilerdirectives/checkcompilerdirectives"
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/goanalysis"
-)
-
-func New() *goanalysis.Linter {
- a := checkcompilerdirectives.Analyzer()
-
- return goanalysis.NewLinter(
- a.Name,
- a.Doc,
- []*analysis.Analyzer{a},
- nil,
- ).WithLoadMode(goanalysis.LoadModeSyntax)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/gochecknoglobals/gochecknoglobals.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/gochecknoglobals/gochecknoglobals.go
deleted file mode 100644
index e893dfcbb6..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/gochecknoglobals/gochecknoglobals.go
+++ /dev/null
@@ -1,19 +0,0 @@
-package gochecknoglobals
-
-import (
- "4d63.com/gochecknoglobals/checknoglobals"
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/goanalysis"
-)
-
-func New() *goanalysis.Linter {
- a := checknoglobals.Analyzer()
-
- return goanalysis.NewLinter(
- a.Name,
- "Check that no global variables exist.",
- []*analysis.Analyzer{a},
- nil,
- ).WithLoadMode(goanalysis.LoadModeTypesInfo)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/gochecknoinits/gochecknoinits.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/gochecknoinits/gochecknoinits.go
deleted file mode 100644
index 510a06c91d..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/gochecknoinits/gochecknoinits.go
+++ /dev/null
@@ -1,55 +0,0 @@
-package gochecknoinits
-
-import (
- "go/ast"
-
- "golang.org/x/tools/go/analysis"
- "golang.org/x/tools/go/analysis/passes/inspect"
- "golang.org/x/tools/go/ast/inspector"
-
- "github.com/golangci/golangci-lint/pkg/goanalysis"
- "github.com/golangci/golangci-lint/pkg/golinters/internal"
-)
-
-const linterName = "gochecknoinits"
-
-func New() *goanalysis.Linter {
- analyzer := &analysis.Analyzer{
- Name: linterName,
- Doc: goanalysis.TheOnlyanalyzerDoc,
- Run: run,
- Requires: []*analysis.Analyzer{inspect.Analyzer},
- }
-
- return goanalysis.NewLinter(
- linterName,
- "Checks that no init functions are present in Go code",
- []*analysis.Analyzer{analyzer},
- nil,
- ).WithLoadMode(goanalysis.LoadModeSyntax)
-}
-
-func run(pass *analysis.Pass) (any, error) {
- insp, ok := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
- if !ok {
- return nil, nil
- }
-
- nodeFilter := []ast.Node{
- (*ast.FuncDecl)(nil),
- }
-
- insp.Preorder(nodeFilter, func(decl ast.Node) {
- funcDecl, ok := decl.(*ast.FuncDecl)
- if !ok {
- return
- }
-
- fnName := funcDecl.Name.Name
- if fnName == "init" && funcDecl.Recv.NumFields() == 0 {
- pass.Reportf(funcDecl.Pos(), "don't use %s function", internal.FormatCode(fnName, nil))
- }
- })
-
- return nil, nil
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/gochecksumtype/gochecksumtype.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/gochecksumtype/gochecksumtype.go
deleted file mode 100644
index cbc5873126..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/gochecksumtype/gochecksumtype.go
+++ /dev/null
@@ -1,86 +0,0 @@
-package gochecksumtype
-
-import (
- "strings"
- "sync"
-
- gochecksumtype "github.com/alecthomas/go-check-sumtype"
- "golang.org/x/tools/go/analysis"
- "golang.org/x/tools/go/packages"
-
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/goanalysis"
- "github.com/golangci/golangci-lint/pkg/lint/linter"
- "github.com/golangci/golangci-lint/pkg/result"
-)
-
-const linterName = "gochecksumtype"
-
-func New(settings *config.GoChecksumTypeSettings) *goanalysis.Linter {
- var mu sync.Mutex
- var resIssues []goanalysis.Issue
-
- analyzer := &analysis.Analyzer{
- Name: linterName,
- Doc: goanalysis.TheOnlyanalyzerDoc,
- Run: func(pass *analysis.Pass) (any, error) {
- issues, err := runGoCheckSumType(pass, settings)
- if err != nil {
- return nil, err
- }
-
- if len(issues) == 0 {
- return nil, nil
- }
-
- mu.Lock()
- resIssues = append(resIssues, issues...)
- mu.Unlock()
-
- return nil, nil
- },
- }
-
- return goanalysis.NewLinter(
- linterName,
- `Run exhaustiveness checks on Go "sum types"`,
- []*analysis.Analyzer{analyzer},
- nil,
- ).WithIssuesReporter(func(_ *linter.Context) []goanalysis.Issue {
- return resIssues
- }).WithLoadMode(goanalysis.LoadModeTypesInfo)
-}
-
-func runGoCheckSumType(pass *analysis.Pass, settings *config.GoChecksumTypeSettings) ([]goanalysis.Issue, error) {
- var resIssues []goanalysis.Issue
-
- pkg := &packages.Package{
- Fset: pass.Fset,
- Syntax: pass.Files,
- Types: pass.Pkg,
- TypesInfo: pass.TypesInfo,
- }
-
- cfg := gochecksumtype.Config{
- DefaultSignifiesExhaustive: settings.DefaultSignifiesExhaustive,
- IncludeSharedInterfaces: settings.IncludeSharedInterfaces,
- }
-
- var unknownError error
- errors := gochecksumtype.Run([]*packages.Package{pkg}, cfg)
- for _, err := range errors {
- err, ok := err.(gochecksumtype.Error)
- if !ok {
- unknownError = err
- continue
- }
-
- resIssues = append(resIssues, goanalysis.NewIssue(&result.Issue{
- FromLinter: linterName,
- Text: strings.TrimPrefix(err.Error(), err.Pos().String()+": "),
- Pos: err.Pos(),
- }, pass))
- }
-
- return resIssues, unknownError
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/gocognit/gocognit.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/gocognit/gocognit.go
deleted file mode 100644
index 5fe0f90f09..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/gocognit/gocognit.go
+++ /dev/null
@@ -1,80 +0,0 @@
-package gocognit
-
-import (
- "fmt"
- "sort"
- "sync"
-
- "github.com/uudashr/gocognit"
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/goanalysis"
- "github.com/golangci/golangci-lint/pkg/golinters/internal"
- "github.com/golangci/golangci-lint/pkg/lint/linter"
- "github.com/golangci/golangci-lint/pkg/result"
-)
-
-const linterName = "gocognit"
-
-func New(settings *config.GocognitSettings) *goanalysis.Linter {
- var mu sync.Mutex
- var resIssues []goanalysis.Issue
-
- analyzer := &analysis.Analyzer{
- Name: goanalysis.TheOnlyAnalyzerName,
- Doc: goanalysis.TheOnlyanalyzerDoc,
- Run: func(pass *analysis.Pass) (any, error) {
- issues := runGocognit(pass, settings)
-
- if len(issues) == 0 {
- return nil, nil
- }
-
- mu.Lock()
- resIssues = append(resIssues, issues...)
- mu.Unlock()
-
- return nil, nil
- },
- }
-
- return goanalysis.NewLinter(
- linterName,
- "Computes and checks the cognitive complexity of functions",
- []*analysis.Analyzer{analyzer},
- nil,
- ).WithIssuesReporter(func(*linter.Context) []goanalysis.Issue {
- return resIssues
- }).WithLoadMode(goanalysis.LoadModeSyntax)
-}
-
-func runGocognit(pass *analysis.Pass, settings *config.GocognitSettings) []goanalysis.Issue {
- var stats []gocognit.Stat
- for _, f := range pass.Files {
- stats = gocognit.ComplexityStats(f, pass.Fset, stats)
- }
- if len(stats) == 0 {
- return nil
- }
-
- sort.SliceStable(stats, func(i, j int) bool {
- return stats[i].Complexity > stats[j].Complexity
- })
-
- issues := make([]goanalysis.Issue, 0, len(stats))
- for _, s := range stats {
- if s.Complexity <= settings.MinComplexity {
- break // Break as the stats is already sorted from greatest to least
- }
-
- issues = append(issues, goanalysis.NewIssue(&result.Issue{
- Pos: s.Pos,
- Text: fmt.Sprintf("cognitive complexity %d of func %s is high (> %d)",
- s.Complexity, internal.FormatCode(s.FuncName, nil), settings.MinComplexity),
- FromLinter: linterName,
- }, pass))
- }
-
- return issues
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/goconst/goconst.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/goconst/goconst.go
deleted file mode 100644
index 07bed301f3..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/goconst/goconst.go
+++ /dev/null
@@ -1,98 +0,0 @@
-package goconst
-
-import (
- "fmt"
- "sync"
-
- goconstAPI "github.com/jgautheron/goconst"
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/goanalysis"
- "github.com/golangci/golangci-lint/pkg/golinters/internal"
- "github.com/golangci/golangci-lint/pkg/lint/linter"
- "github.com/golangci/golangci-lint/pkg/result"
-)
-
-const linterName = "goconst"
-
-func New(settings *config.GoConstSettings) *goanalysis.Linter {
- var mu sync.Mutex
- var resIssues []goanalysis.Issue
-
- analyzer := &analysis.Analyzer{
- Name: linterName,
- Doc: goanalysis.TheOnlyanalyzerDoc,
- Run: func(pass *analysis.Pass) (any, error) {
- issues, err := runGoconst(pass, settings)
- if err != nil {
- return nil, err
- }
-
- if len(issues) == 0 {
- return nil, nil
- }
-
- mu.Lock()
- resIssues = append(resIssues, issues...)
- mu.Unlock()
-
- return nil, nil
- },
- }
-
- return goanalysis.NewLinter(
- linterName,
- "Finds repeated strings that could be replaced by a constant",
- []*analysis.Analyzer{analyzer},
- nil,
- ).WithIssuesReporter(func(*linter.Context) []goanalysis.Issue {
- return resIssues
- }).WithLoadMode(goanalysis.LoadModeSyntax)
-}
-
-func runGoconst(pass *analysis.Pass, settings *config.GoConstSettings) ([]goanalysis.Issue, error) {
- cfg := goconstAPI.Config{
- IgnoreStrings: settings.IgnoreStrings,
- IgnoreTests: settings.IgnoreTests,
- MatchWithConstants: settings.MatchWithConstants,
- MinStringLength: settings.MinStringLen,
- MinOccurrences: settings.MinOccurrencesCount,
- ParseNumbers: settings.ParseNumbers,
- NumberMin: settings.NumberMin,
- NumberMax: settings.NumberMax,
- ExcludeTypes: map[goconstAPI.Type]bool{},
- }
-
- if settings.IgnoreCalls {
- cfg.ExcludeTypes[goconstAPI.Call] = true
- }
-
- lintIssues, err := goconstAPI.Run(pass.Files, pass.Fset, &cfg)
- if err != nil {
- return nil, err
- }
-
- if len(lintIssues) == 0 {
- return nil, nil
- }
-
- res := make([]goanalysis.Issue, 0, len(lintIssues))
- for _, i := range lintIssues {
- text := fmt.Sprintf("string %s has %d occurrences", internal.FormatCode(i.Str, nil), i.OccurrencesCount)
-
- if i.MatchingConst == "" {
- text += ", make it a constant"
- } else {
- text += fmt.Sprintf(", but such constant %s already exists", internal.FormatCode(i.MatchingConst, nil))
- }
-
- res = append(res, goanalysis.NewIssue(&result.Issue{
- Pos: i.Pos,
- Text: text,
- FromLinter: linterName,
- }, pass))
- }
-
- return res, nil
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/gocritic/gocritic.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/gocritic/gocritic.go
deleted file mode 100644
index 0fa4c63d1a..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/gocritic/gocritic.go
+++ /dev/null
@@ -1,561 +0,0 @@
-package gocritic
-
-import (
- "errors"
- "fmt"
- "go/ast"
- "go/types"
- "maps"
- "reflect"
- "runtime"
- "slices"
- "strings"
- "sync"
-
- "github.com/go-critic/go-critic/checkers"
- gocriticlinter "github.com/go-critic/go-critic/linter"
- _ "github.com/quasilyte/go-ruleguard/dsl"
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/goanalysis"
- "github.com/golangci/golangci-lint/pkg/golinters/internal"
- "github.com/golangci/golangci-lint/pkg/lint/linter"
- "github.com/golangci/golangci-lint/pkg/logutils"
-)
-
-const linterName = "gocritic"
-
-var (
- debugf = logutils.Debug(logutils.DebugKeyGoCritic)
- isDebug = logutils.HaveDebugTag(logutils.DebugKeyGoCritic)
-)
-
-func New(settings *config.GoCriticSettings) *goanalysis.Linter {
- wrapper := &goCriticWrapper{
- sizes: types.SizesFor("gc", runtime.GOARCH),
- }
-
- analyzer := &analysis.Analyzer{
- Name: linterName,
- Doc: goanalysis.TheOnlyanalyzerDoc,
- Run: func(pass *analysis.Pass) (any, error) {
- err := wrapper.run(pass)
- if err != nil {
- return nil, err
- }
-
- return nil, nil
- },
- }
-
- return goanalysis.NewLinter(
- linterName,
- `Provides diagnostics that check for bugs, performance and style issues.
-Extensible without recompilation through dynamic rules.
-Dynamic rules are written declaratively with AST patterns, filters, report message and optional suggestion.`,
- []*analysis.Analyzer{analyzer},
- nil,
- ).
- WithContextSetter(func(context *linter.Context) {
- wrapper.replacer = strings.NewReplacer(
- internal.PlaceholderBasePath, context.Cfg.GetBasePath(),
- internal.PlaceholderConfigDir, context.Cfg.GetConfigDir(), //nolint:staticcheck // It must be removed in v2.
- )
-
- wrapper.init(context.Log, settings)
- }).
- WithLoadMode(goanalysis.LoadModeTypesInfo)
-}
-
-type goCriticWrapper struct {
- settingsWrapper *settingsWrapper
- replacer *strings.Replacer
- sizes types.Sizes
- once sync.Once
-}
-
-func (w *goCriticWrapper) init(logger logutils.Log, settings *config.GoCriticSettings) {
- if settings == nil {
- return
- }
-
- w.once.Do(func() {
- err := checkers.InitEmbeddedRules()
- if err != nil {
- logger.Fatalf("%s: %v: setting an explicit GOROOT can fix this problem", linterName, err)
- }
- })
-
- settingsWrapper := newSettingsWrapper(settings, logger)
- settingsWrapper.InferEnabledChecks()
- // Validate must be after InferEnabledChecks, not before.
- // Because it uses gathered information about tags set and finally enabled checks.
- if err := settingsWrapper.Validate(); err != nil {
- logger.Fatalf("%s: invalid settings: %s", linterName, err)
- }
-
- w.settingsWrapper = settingsWrapper
-}
-
-func (w *goCriticWrapper) run(pass *analysis.Pass) error {
- if w.settingsWrapper == nil {
- return errors.New("the settings wrapper is nil")
- }
-
- linterCtx := gocriticlinter.NewContext(pass.Fset, w.sizes)
-
- linterCtx.SetGoVersion(w.settingsWrapper.Go)
-
- enabledCheckers, err := w.buildEnabledCheckers(linterCtx)
- if err != nil {
- return err
- }
-
- linterCtx.SetPackageInfo(pass.TypesInfo, pass.Pkg)
-
- runOnPackage(pass, enabledCheckers, pass.Files)
-
- return nil
-}
-
-func (w *goCriticWrapper) buildEnabledCheckers(linterCtx *gocriticlinter.Context) ([]*gocriticlinter.Checker, error) {
- allLowerCasedParams := w.settingsWrapper.GetLowerCasedParams()
-
- var enabledCheckers []*gocriticlinter.Checker
- for _, info := range gocriticlinter.GetCheckersInfo() {
- if !w.settingsWrapper.IsCheckEnabled(info.Name) {
- continue
- }
-
- if err := w.configureCheckerInfo(info, allLowerCasedParams); err != nil {
- return nil, err
- }
-
- c, err := gocriticlinter.NewChecker(linterCtx, info)
- if err != nil {
- return nil, err
- }
-
- enabledCheckers = append(enabledCheckers, c)
- }
-
- return enabledCheckers, nil
-}
-
-func (w *goCriticWrapper) configureCheckerInfo(
- info *gocriticlinter.CheckerInfo,
- allLowerCasedParams map[string]config.GoCriticCheckSettings,
-) error {
- params := allLowerCasedParams[strings.ToLower(info.Name)]
- if params == nil { // no config for this checker
- return nil
- }
-
- // To lowercase info param keys here because golangci-lint's config parser lowercases all strings.
- infoParams := normalizeMap(info.Params)
- for k, p := range params {
- v, ok := infoParams[k]
- if ok {
- v.Value = w.normalizeCheckerParamsValue(p)
- continue
- }
-
- // param `k` isn't supported
- if len(info.Params) == 0 {
- return fmt.Errorf("checker %s config param %s doesn't exist: checker doesn't have params",
- info.Name, k)
- }
-
- supportedKeys := slices.Sorted(maps.Keys(info.Params))
-
- return fmt.Errorf("checker %s config param %s doesn't exist, all existing: %s",
- info.Name, k, supportedKeys)
- }
-
- return nil
-}
-
-// normalizeCheckerParamsValue normalizes value types.
-// go-critic asserts that CheckerParam.Value has some specific types,
-// but the file parsers (TOML, YAML, JSON) don't create the same representation for raw type.
-// then we have to convert value types into the expected value types.
-// Maybe in the future, this kind of conversion will be done in go-critic itself.
-func (w *goCriticWrapper) normalizeCheckerParamsValue(p any) any {
- rv := reflect.ValueOf(p)
- switch rv.Type().Kind() {
- case reflect.Int64, reflect.Int32, reflect.Int16, reflect.Int8, reflect.Int:
- return int(rv.Int())
- case reflect.Bool:
- return rv.Bool()
- case reflect.String:
- // Perform variable substitution.
- return w.replacer.Replace(rv.String())
- default:
- return p
- }
-}
-
-func runOnPackage(pass *analysis.Pass, checks []*gocriticlinter.Checker, files []*ast.File) {
- for _, f := range files {
- runOnFile(pass, f, checks)
- }
-}
-
-func runOnFile(pass *analysis.Pass, f *ast.File, checks []*gocriticlinter.Checker) {
- for _, c := range checks {
- // All checkers are expected to use *lint.Context
- // as read-only structure, so no copying is required.
- for _, warn := range c.Check(f) {
- diag := analysis.Diagnostic{
- Pos: warn.Pos,
- Category: c.Info.Name,
- Message: fmt.Sprintf("%s: %s", c.Info.Name, warn.Text),
- }
-
- if warn.HasQuickFix() {
- diag.SuggestedFixes = []analysis.SuggestedFix{{
- TextEdits: []analysis.TextEdit{{
- Pos: warn.Suggestion.From,
- End: warn.Suggestion.To,
- NewText: warn.Suggestion.Replacement,
- }},
- }}
- }
-
- pass.Report(diag)
- }
- }
-}
-
-type goCriticChecks[T any] map[string]T
-
-func (m goCriticChecks[T]) has(name string) bool {
- _, ok := m[name]
- return ok
-}
-
-type settingsWrapper struct {
- *config.GoCriticSettings
-
- logger logutils.Log
-
- allCheckers []*gocriticlinter.CheckerInfo
-
- allChecks goCriticChecks[struct{}]
- allChecksByTag goCriticChecks[[]string]
- allTagsSorted []string
- inferredEnabledChecks goCriticChecks[struct{}]
-
- // *LowerCased fields are used for GoCriticSettings.SettingsPerCheck validation only.
-
- allChecksLowerCased goCriticChecks[struct{}]
- inferredEnabledChecksLowerCased goCriticChecks[struct{}]
-}
-
-func newSettingsWrapper(settings *config.GoCriticSettings, logger logutils.Log) *settingsWrapper {
- allCheckers := gocriticlinter.GetCheckersInfo()
-
- allChecks := make(goCriticChecks[struct{}], len(allCheckers))
- allChecksLowerCased := make(goCriticChecks[struct{}], len(allCheckers))
- allChecksByTag := make(goCriticChecks[[]string])
- for _, checker := range allCheckers {
- allChecks[checker.Name] = struct{}{}
- allChecksLowerCased[strings.ToLower(checker.Name)] = struct{}{}
-
- for _, tag := range checker.Tags {
- allChecksByTag[tag] = append(allChecksByTag[tag], checker.Name)
- }
- }
-
- allTagsSorted := slices.Sorted(maps.Keys(allChecksByTag))
-
- return &settingsWrapper{
- GoCriticSettings: settings,
- logger: logger,
- allCheckers: allCheckers,
- allChecks: allChecks,
- allChecksLowerCased: allChecksLowerCased,
- allChecksByTag: allChecksByTag,
- allTagsSorted: allTagsSorted,
- inferredEnabledChecks: make(goCriticChecks[struct{}]),
- inferredEnabledChecksLowerCased: make(goCriticChecks[struct{}]),
- }
-}
-
-func (s *settingsWrapper) IsCheckEnabled(name string) bool {
- return s.inferredEnabledChecks.has(name)
-}
-
-func (s *settingsWrapper) GetLowerCasedParams() map[string]config.GoCriticCheckSettings {
- return normalizeMap(s.SettingsPerCheck)
-}
-
-// InferEnabledChecks tries to be consistent with (lintersdb.Manager).build.
-func (s *settingsWrapper) InferEnabledChecks() {
- s.debugChecksInitialState()
-
- enabledByDefaultChecks, disabledByDefaultChecks := s.buildEnabledAndDisabledByDefaultChecks()
-
- debugChecksListf(enabledByDefaultChecks, "Enabled by default")
- debugChecksListf(disabledByDefaultChecks, "Disabled by default")
-
- enabledChecks := make(goCriticChecks[struct{}])
-
- if s.EnableAll {
- enabledChecks = make(goCriticChecks[struct{}], len(s.allCheckers))
- for _, info := range s.allCheckers {
- enabledChecks[info.Name] = struct{}{}
- }
- } else if !s.DisableAll {
- // enable-all/disable-all revokes the default settings.
- enabledChecks = make(goCriticChecks[struct{}], len(enabledByDefaultChecks))
- for _, check := range enabledByDefaultChecks {
- enabledChecks[check] = struct{}{}
- }
- }
-
- if len(s.EnabledTags) != 0 {
- enabledFromTags := s.expandTagsToChecks(s.EnabledTags)
-
- debugChecksListf(enabledFromTags, "Enabled by config tags %s", s.EnabledTags)
-
- for _, check := range enabledFromTags {
- enabledChecks[check] = struct{}{}
- }
- }
-
- if len(s.EnabledChecks) != 0 {
- debugChecksListf(s.EnabledChecks, "Enabled by config")
-
- for _, check := range s.EnabledChecks {
- if enabledChecks.has(check) {
- s.logger.Warnf("%s: no need to enable check %q: it's already enabled", linterName, check)
- continue
- }
- enabledChecks[check] = struct{}{}
- }
- }
-
- if len(s.DisabledTags) != 0 {
- disabledFromTags := s.expandTagsToChecks(s.DisabledTags)
-
- debugChecksListf(disabledFromTags, "Disabled by config tags %s", s.DisabledTags)
-
- for _, check := range disabledFromTags {
- delete(enabledChecks, check)
- }
- }
-
- if len(s.DisabledChecks) != 0 {
- debugChecksListf(s.DisabledChecks, "Disabled by config")
-
- for _, check := range s.DisabledChecks {
- if !enabledChecks.has(check) {
- s.logger.Warnf("%s: no need to disable check %q: it's already disabled", linterName, check)
- continue
- }
- delete(enabledChecks, check)
- }
- }
-
- s.inferredEnabledChecks = enabledChecks
- s.inferredEnabledChecksLowerCased = normalizeMap(s.inferredEnabledChecks)
-
- s.debugChecksFinalState()
-}
-
-func (s *settingsWrapper) buildEnabledAndDisabledByDefaultChecks() (enabled, disabled []string) {
- for _, info := range s.allCheckers {
- if enabledByDef := isEnabledByDefaultGoCriticChecker(info); enabledByDef {
- enabled = append(enabled, info.Name)
- } else {
- disabled = append(disabled, info.Name)
- }
- }
- return enabled, disabled
-}
-
-func (s *settingsWrapper) expandTagsToChecks(tags []string) []string {
- var checks []string
- for _, tag := range tags {
- checks = append(checks, s.allChecksByTag[tag]...)
- }
- return checks
-}
-
-func (s *settingsWrapper) debugChecksInitialState() {
- if !isDebug {
- return
- }
-
- debugf("All gocritic existing tags and checks:")
- for _, tag := range s.allTagsSorted {
- debugChecksListf(s.allChecksByTag[tag], " tag %q", tag)
- }
-}
-
-func (s *settingsWrapper) debugChecksFinalState() {
- if !isDebug {
- return
- }
-
- var enabledChecks []string
- var disabledChecks []string
-
- for _, checker := range s.allCheckers {
- check := checker.Name
- if s.inferredEnabledChecks.has(check) {
- enabledChecks = append(enabledChecks, check)
- } else {
- disabledChecks = append(disabledChecks, check)
- }
- }
-
- debugChecksListf(enabledChecks, "Final used")
-
- if len(disabledChecks) == 0 {
- debugf("All checks are enabled")
- } else {
- debugChecksListf(disabledChecks, "Final not used")
- }
-}
-
-// Validate tries to be consistent with (lintersdb.Validator).validateEnabledDisabledLintersConfig.
-func (s *settingsWrapper) Validate() error {
- for _, v := range []func() error{
- s.validateOptionsCombinations,
- s.validateCheckerTags,
- s.validateCheckerNames,
- s.validateDisabledAndEnabledAtOneMoment,
- s.validateAtLeastOneCheckerEnabled,
- } {
- if err := v(); err != nil {
- return err
- }
- }
- return nil
-}
-
-func (s *settingsWrapper) validateOptionsCombinations() error {
- if s.EnableAll {
- if s.DisableAll {
- return errors.New("enable-all and disable-all options must not be combined")
- }
-
- if len(s.EnabledTags) != 0 {
- return errors.New("enable-all and enabled-tags options must not be combined")
- }
-
- if len(s.EnabledChecks) != 0 {
- return errors.New("enable-all and enabled-checks options must not be combined")
- }
- }
-
- if s.DisableAll {
- if len(s.DisabledTags) != 0 {
- return errors.New("disable-all and disabled-tags options must not be combined")
- }
-
- if len(s.DisabledChecks) != 0 {
- return errors.New("disable-all and disabled-checks options must not be combined")
- }
-
- if len(s.EnabledTags) == 0 && len(s.EnabledChecks) == 0 {
- return errors.New("all checks were disabled, but no one check was enabled: at least one must be enabled")
- }
- }
-
- return nil
-}
-
-func (s *settingsWrapper) validateCheckerTags() error {
- for _, tag := range s.EnabledTags {
- if !s.allChecksByTag.has(tag) {
- return fmt.Errorf("enabled tag %q doesn't exist, see %s's documentation", tag, linterName)
- }
- }
-
- for _, tag := range s.DisabledTags {
- if !s.allChecksByTag.has(tag) {
- return fmt.Errorf("disabled tag %q doesn't exist, see %s's documentation", tag, linterName)
- }
- }
-
- return nil
-}
-
-func (s *settingsWrapper) validateCheckerNames() error {
- for _, check := range s.EnabledChecks {
- if !s.allChecks.has(check) {
- return fmt.Errorf("enabled check %q doesn't exist, see %s's documentation", check, linterName)
- }
- }
-
- for _, check := range s.DisabledChecks {
- if !s.allChecks.has(check) {
- return fmt.Errorf("disabled check %q doesn't exist, see %s documentation", check, linterName)
- }
- }
-
- for check := range s.SettingsPerCheck {
- lcName := strings.ToLower(check)
- if !s.allChecksLowerCased.has(lcName) {
- return fmt.Errorf("invalid check settings: check %q doesn't exist, see %s documentation", check, linterName)
- }
- if !s.inferredEnabledChecksLowerCased.has(lcName) {
- s.logger.Warnf("%s: settings were provided for disabled check %q", check, linterName)
- }
- }
-
- return nil
-}
-
-func (s *settingsWrapper) validateDisabledAndEnabledAtOneMoment() error {
- for _, tag := range s.DisabledTags {
- if slices.Contains(s.EnabledTags, tag) {
- return fmt.Errorf("tag %q disabled and enabled at one moment", tag)
- }
- }
-
- for _, check := range s.DisabledChecks {
- if slices.Contains(s.EnabledChecks, check) {
- return fmt.Errorf("check %q disabled and enabled at one moment", check)
- }
- }
-
- return nil
-}
-
-func (s *settingsWrapper) validateAtLeastOneCheckerEnabled() error {
- if len(s.inferredEnabledChecks) == 0 {
- return errors.New("eventually all checks were disabled: at least one must be enabled")
- }
- return nil
-}
-
-func normalizeMap[ValueT any](in map[string]ValueT) map[string]ValueT {
- ret := make(map[string]ValueT, len(in))
- for k, v := range in {
- ret[strings.ToLower(k)] = v
- }
- return ret
-}
-
-func isEnabledByDefaultGoCriticChecker(info *gocriticlinter.CheckerInfo) bool {
- // https://github.com/go-critic/go-critic/blob/5b67cfd487ae9fe058b4b19321901b3131810f65/cmd/gocritic/check.go#L342-L345
- return !info.HasTag(gocriticlinter.ExperimentalTag) &&
- !info.HasTag(gocriticlinter.OpinionatedTag) &&
- !info.HasTag(gocriticlinter.PerformanceTag) &&
- !info.HasTag(gocriticlinter.SecurityTag)
-}
-
-func debugChecksListf(checks []string, format string, args ...any) {
- if !isDebug {
- return
- }
-
- v := slices.Sorted(slices.Values(checks))
-
- debugf("%s checks (%d): %s", fmt.Sprintf(format, args...), len(checks), strings.Join(v, ", "))
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/gocyclo/gocyclo.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/gocyclo/gocyclo.go
deleted file mode 100644
index 51333dc154..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/gocyclo/gocyclo.go
+++ /dev/null
@@ -1,76 +0,0 @@
-package gocyclo
-
-import (
- "fmt"
- "sync"
-
- "github.com/fzipp/gocyclo"
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/goanalysis"
- "github.com/golangci/golangci-lint/pkg/golinters/internal"
- "github.com/golangci/golangci-lint/pkg/lint/linter"
- "github.com/golangci/golangci-lint/pkg/result"
-)
-
-const linterName = "gocyclo"
-
-func New(settings *config.GoCycloSettings) *goanalysis.Linter {
- var mu sync.Mutex
- var resIssues []goanalysis.Issue
-
- analyzer := &analysis.Analyzer{
- Name: linterName,
- Doc: goanalysis.TheOnlyanalyzerDoc,
- Run: func(pass *analysis.Pass) (any, error) {
- issues := runGoCyclo(pass, settings)
-
- if len(issues) == 0 {
- return nil, nil
- }
-
- mu.Lock()
- resIssues = append(resIssues, issues...)
- mu.Unlock()
-
- return nil, nil
- },
- }
-
- return goanalysis.NewLinter(
- linterName,
- "Computes and checks the cyclomatic complexity of functions",
- []*analysis.Analyzer{analyzer},
- nil,
- ).WithIssuesReporter(func(*linter.Context) []goanalysis.Issue {
- return resIssues
- }).WithLoadMode(goanalysis.LoadModeSyntax)
-}
-
-func runGoCyclo(pass *analysis.Pass, settings *config.GoCycloSettings) []goanalysis.Issue {
- var stats gocyclo.Stats
- for _, f := range pass.Files {
- stats = gocyclo.AnalyzeASTFile(f, pass.Fset, stats)
- }
- if len(stats) == 0 {
- return nil
- }
-
- stats = stats.SortAndFilter(-1, settings.MinComplexity)
-
- issues := make([]goanalysis.Issue, 0, len(stats))
-
- for _, s := range stats {
- text := fmt.Sprintf("cyclomatic complexity %d of func %s is high (> %d)",
- s.Complexity, internal.FormatCode(s.FuncName, nil), settings.MinComplexity)
-
- issues = append(issues, goanalysis.NewIssue(&result.Issue{
- Pos: s.Pos,
- Text: text,
- FromLinter: linterName,
- }, pass))
- }
-
- return issues
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/godot/godot.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/godot/godot.go
deleted file mode 100644
index 3194b3d3ac..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/godot/godot.go
+++ /dev/null
@@ -1,88 +0,0 @@
-package godot
-
-import (
- "cmp"
-
- "github.com/tetafro/godot"
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/goanalysis"
-)
-
-const linterName = "godot"
-
-func New(settings *config.GodotSettings) *goanalysis.Linter {
- var dotSettings godot.Settings
-
- if settings != nil {
- dotSettings = godot.Settings{
- Scope: godot.Scope(settings.Scope),
- Exclude: settings.Exclude,
- Period: settings.Period,
- Capital: settings.Capital,
- }
-
- // Convert deprecated setting
- if settings.CheckAll != nil && *settings.CheckAll {
- dotSettings.Scope = godot.AllScope
- }
- }
-
- dotSettings.Scope = cmp.Or(dotSettings.Scope, godot.DeclScope)
-
- analyzer := &analysis.Analyzer{
- Name: linterName,
- Doc: goanalysis.TheOnlyanalyzerDoc,
- Run: func(pass *analysis.Pass) (any, error) {
- err := runGodot(pass, dotSettings)
- if err != nil {
- return nil, err
- }
-
- return nil, nil
- },
- }
-
- return goanalysis.NewLinter(
- linterName,
- "Check if comments end in a period",
- []*analysis.Analyzer{analyzer},
- nil,
- ).WithLoadMode(goanalysis.LoadModeSyntax)
-}
-
-func runGodot(pass *analysis.Pass, settings godot.Settings) error {
- for _, file := range pass.Files {
- iss, err := godot.Run(file, pass.Fset, settings)
- if err != nil {
- return err
- }
-
- if len(iss) == 0 {
- continue
- }
-
- f := pass.Fset.File(file.Pos())
-
- for _, i := range iss {
- start := f.Pos(i.Pos.Offset)
- end := goanalysis.EndOfLinePos(f, i.Pos.Line)
-
- pass.Report(analysis.Diagnostic{
- Pos: start,
- End: end,
- Message: i.Message,
- SuggestedFixes: []analysis.SuggestedFix{{
- TextEdits: []analysis.TextEdit{{
- Pos: start,
- End: end,
- NewText: []byte(i.Replacement),
- }},
- }},
- })
- }
- }
-
- return nil
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/godox/godox.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/godox/godox.go
deleted file mode 100644
index 589789d146..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/godox/godox.go
+++ /dev/null
@@ -1,62 +0,0 @@
-package godox
-
-import (
- "go/token"
- "strings"
-
- "github.com/matoous/godox"
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/goanalysis"
-)
-
-const linterName = "godox"
-
-func New(settings *config.GodoxSettings) *goanalysis.Linter {
- analyzer := &analysis.Analyzer{
- Name: linterName,
- Doc: goanalysis.TheOnlyanalyzerDoc,
- Run: func(pass *analysis.Pass) (any, error) {
- return run(pass, settings), nil
- },
- }
-
- return goanalysis.NewLinter(
- linterName,
- "Detects usage of FIXME, TODO and other keywords inside comments",
- []*analysis.Analyzer{analyzer},
- nil,
- ).WithLoadMode(goanalysis.LoadModeSyntax)
-}
-
-func run(pass *analysis.Pass, settings *config.GodoxSettings) error {
- for _, file := range pass.Files {
- position, isGoFile := goanalysis.GetGoFilePosition(pass, file)
- if !isGoFile {
- continue
- }
-
- messages, err := godox.Run(file, pass.Fset, settings.Keywords...)
- if err != nil {
- return err
- }
-
- if len(messages) == 0 {
- continue
- }
-
- nonAdjPosition := pass.Fset.PositionFor(file.Pos(), false)
-
- ft := pass.Fset.File(file.Pos())
-
- for _, i := range messages {
- pass.Report(analysis.Diagnostic{
- Pos: ft.LineStart(goanalysis.AdjustPos(i.Pos.Line, nonAdjPosition.Line, position.Line)) + token.Pos(i.Pos.Column),
- Message: strings.TrimRight(i.Message, "\n"),
- })
- }
- }
-
- return nil
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/gofmt/gofmt.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/gofmt/gofmt.go
deleted file mode 100644
index 2212242949..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/gofmt/gofmt.go
+++ /dev/null
@@ -1,28 +0,0 @@
-package gofmt
-
-import (
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/goanalysis"
- "github.com/golangci/golangci-lint/pkg/goformatters"
- gofmtbase "github.com/golangci/golangci-lint/pkg/goformatters/gofmt"
- "github.com/golangci/golangci-lint/pkg/golinters/internal"
-)
-
-const linterName = "gofmt"
-
-func New(settings *config.GoFmtSettings) *goanalysis.Linter {
- a := goformatters.NewAnalyzer(
- internal.LinterLogger.Child(linterName),
- "Checks if the code is formatted according to 'gofmt' command.",
- gofmtbase.New(settings),
- )
-
- return goanalysis.NewLinter(
- a.Name,
- a.Doc,
- []*analysis.Analyzer{a},
- nil,
- ).WithLoadMode(goanalysis.LoadModeSyntax)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/gofumpt/gofumpt.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/gofumpt/gofumpt.go
deleted file mode 100644
index 878a5c79b0..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/gofumpt/gofumpt.go
+++ /dev/null
@@ -1,28 +0,0 @@
-package gofumpt
-
-import (
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/goanalysis"
- "github.com/golangci/golangci-lint/pkg/goformatters"
- gofumptbase "github.com/golangci/golangci-lint/pkg/goformatters/gofumpt"
- "github.com/golangci/golangci-lint/pkg/golinters/internal"
-)
-
-const linterName = "gofumpt"
-
-func New(settings *config.GofumptSettings) *goanalysis.Linter {
- a := goformatters.NewAnalyzer(
- internal.LinterLogger.Child(linterName),
- "Checks if code and import statements are formatted, with additional rules.",
- gofumptbase.New(settings, settings.LangVersion),
- )
-
- return goanalysis.NewLinter(
- a.Name,
- a.Doc,
- []*analysis.Analyzer{a},
- nil,
- ).WithLoadMode(goanalysis.LoadModeSyntax)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/goimports/goimports.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/goimports/goimports.go
deleted file mode 100644
index d7ba98559a..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/goimports/goimports.go
+++ /dev/null
@@ -1,28 +0,0 @@
-package goimports
-
-import (
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/goanalysis"
- "github.com/golangci/golangci-lint/pkg/goformatters"
- goimportsbase "github.com/golangci/golangci-lint/pkg/goformatters/goimports"
- "github.com/golangci/golangci-lint/pkg/golinters/internal"
-)
-
-const linterName = "goimports"
-
-func New(settings *config.GoImportsSettings) *goanalysis.Linter {
- a := goformatters.NewAnalyzer(
- internal.LinterLogger.Child(linterName),
- "Checks if the code and import statements are formatted according to the 'goimports' command.",
- goimportsbase.New(settings),
- )
-
- return goanalysis.NewLinter(
- a.Name,
- a.Doc,
- []*analysis.Analyzer{a},
- nil,
- ).WithLoadMode(goanalysis.LoadModeSyntax)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/gomoddirectives/gomoddirectives.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/gomoddirectives/gomoddirectives.go
deleted file mode 100644
index f8f47ba2b4..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/gomoddirectives/gomoddirectives.go
+++ /dev/null
@@ -1,87 +0,0 @@
-package gomoddirectives
-
-import (
- "regexp"
- "sync"
-
- "github.com/ldez/gomoddirectives"
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/goanalysis"
- "github.com/golangci/golangci-lint/pkg/golinters/internal"
- "github.com/golangci/golangci-lint/pkg/lint/linter"
- "github.com/golangci/golangci-lint/pkg/result"
-)
-
-const linterName = "gomoddirectives"
-
-func New(settings *config.GoModDirectivesSettings) *goanalysis.Linter {
- var issues []goanalysis.Issue
- var once sync.Once
-
- var opts gomoddirectives.Options
- if settings != nil {
- opts.ReplaceAllowLocal = settings.ReplaceLocal
- opts.ReplaceAllowList = settings.ReplaceAllowList
- opts.RetractAllowNoExplanation = settings.RetractAllowNoExplanation
- opts.ExcludeForbidden = settings.ExcludeForbidden
- opts.ToolchainForbidden = settings.ToolchainForbidden
- opts.ToolForbidden = settings.ToolForbidden
- opts.GoDebugForbidden = settings.GoDebugForbidden
-
- if settings.ToolchainPattern != "" {
- exp, err := regexp.Compile(settings.ToolchainPattern)
- if err != nil {
- internal.LinterLogger.Fatalf("%s: invalid toolchain pattern: %v", linterName, err)
- } else {
- opts.ToolchainPattern = exp
- }
- }
-
- if settings.GoVersionPattern != "" {
- exp, err := regexp.Compile(settings.GoVersionPattern)
- if err != nil {
- internal.LinterLogger.Fatalf("%s: invalid Go version pattern: %v", linterName, err)
- } else {
- opts.GoVersionPattern = exp
- }
- }
- }
-
- analyzer := &analysis.Analyzer{
- Name: goanalysis.TheOnlyAnalyzerName,
- Doc: goanalysis.TheOnlyanalyzerDoc,
- Run: goanalysis.DummyRun,
- }
-
- return goanalysis.NewLinter(
- linterName,
- "Manage the use of 'replace', 'retract', and 'excludes' directives in go.mod.",
- []*analysis.Analyzer{analyzer},
- nil,
- ).WithContextSetter(func(lintCtx *linter.Context) {
- analyzer.Run = func(pass *analysis.Pass) (any, error) {
- once.Do(func() {
- results, err := gomoddirectives.AnalyzePass(pass, opts)
- if err != nil {
- lintCtx.Log.Warnf("running %s failed: %s: "+
- "if you are not using go modules it is suggested to disable this linter", linterName, err)
- return
- }
-
- for _, p := range results {
- issues = append(issues, goanalysis.NewIssue(&result.Issue{
- FromLinter: linterName,
- Pos: p.Start,
- Text: p.Reason,
- }, pass))
- }
- })
-
- return nil, nil
- }
- }).WithIssuesReporter(func(*linter.Context) []goanalysis.Issue {
- return issues
- }).WithLoadMode(goanalysis.LoadModeSyntax)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/gomodguard/gomodguard.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/gomodguard/gomodguard.go
deleted file mode 100644
index 8bddebc162..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/gomodguard/gomodguard.go
+++ /dev/null
@@ -1,94 +0,0 @@
-package gomodguard
-
-import (
- "sync"
-
- "github.com/ryancurrah/gomodguard"
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/goanalysis"
- "github.com/golangci/golangci-lint/pkg/golinters/internal"
- "github.com/golangci/golangci-lint/pkg/lint/linter"
- "github.com/golangci/golangci-lint/pkg/result"
-)
-
-const (
- name = "gomodguard"
- desc = "Allow and block list linter for direct Go module dependencies. " +
- "This is different from depguard where there are different block " +
- "types for example version constraints and module recommendations."
-)
-
-func New(settings *config.GoModGuardSettings) *goanalysis.Linter {
- var issues []goanalysis.Issue
- var mu sync.Mutex
-
- processorCfg := &gomodguard.Configuration{}
- if settings != nil {
- processorCfg.Allowed.Modules = settings.Allowed.Modules
- processorCfg.Allowed.Domains = settings.Allowed.Domains
- processorCfg.Blocked.LocalReplaceDirectives = settings.Blocked.LocalReplaceDirectives
-
- for n := range settings.Blocked.Modules {
- for k, v := range settings.Blocked.Modules[n] {
- m := map[string]gomodguard.BlockedModule{k: {
- Recommendations: v.Recommendations,
- Reason: v.Reason,
- }}
- processorCfg.Blocked.Modules = append(processorCfg.Blocked.Modules, m)
- break
- }
- }
-
- for n := range settings.Blocked.Versions {
- for k, v := range settings.Blocked.Versions[n] {
- m := map[string]gomodguard.BlockedVersion{k: {
- Version: v.Version,
- Reason: v.Reason,
- }}
- processorCfg.Blocked.Versions = append(processorCfg.Blocked.Versions, m)
- break
- }
- }
- }
-
- analyzer := &analysis.Analyzer{
- Name: goanalysis.TheOnlyAnalyzerName,
- Doc: goanalysis.TheOnlyanalyzerDoc,
- Run: goanalysis.DummyRun,
- }
-
- return goanalysis.NewLinter(
- name,
- desc,
- []*analysis.Analyzer{analyzer},
- nil,
- ).WithContextSetter(func(lintCtx *linter.Context) {
- processor, err := gomodguard.NewProcessor(processorCfg)
- if err != nil {
- lintCtx.Log.Warnf("running gomodguard failed: %s: if you are not using go modules "+
- "it is suggested to disable this linter", err)
- return
- }
-
- analyzer.Run = func(pass *analysis.Pass) (any, error) {
- gomodguardIssues := processor.ProcessFiles(internal.GetGoFileNames(pass))
-
- mu.Lock()
- defer mu.Unlock()
-
- for _, gomodguardIssue := range gomodguardIssues {
- issues = append(issues, goanalysis.NewIssue(&result.Issue{
- FromLinter: name,
- Pos: gomodguardIssue.Position,
- Text: gomodguardIssue.Reason,
- }, pass))
- }
-
- return nil, nil
- }
- }).WithIssuesReporter(func(*linter.Context) []goanalysis.Issue {
- return issues
- }).WithLoadMode(goanalysis.LoadModeSyntax)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/goprintffuncname/goprintffuncname.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/goprintffuncname/goprintffuncname.go
deleted file mode 100644
index c206ffaa3e..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/goprintffuncname/goprintffuncname.go
+++ /dev/null
@@ -1,19 +0,0 @@
-package goprintffuncname
-
-import (
- "github.com/golangci/go-printf-func-name/pkg/analyzer"
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/goanalysis"
-)
-
-func New() *goanalysis.Linter {
- a := analyzer.Analyzer
-
- return goanalysis.NewLinter(
- a.Name,
- a.Doc,
- []*analysis.Analyzer{a},
- nil,
- ).WithLoadMode(goanalysis.LoadModeSyntax)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/gosimple/gosimple.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/gosimple/gosimple.go
deleted file mode 100644
index c03871adf9..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/gosimple/gosimple.go
+++ /dev/null
@@ -1,22 +0,0 @@
-package gosimple
-
-import (
- "honnef.co/go/tools/simple"
-
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/goanalysis"
- "github.com/golangci/golangci-lint/pkg/golinters/internal"
-)
-
-func New(settings *config.StaticCheckSettings) *goanalysis.Linter {
- cfg := internal.StaticCheckConfig(settings)
-
- analyzers := internal.SetupStaticCheckAnalyzers(simple.Analyzers, cfg.Checks)
-
- return goanalysis.NewLinter(
- "gosimple",
- "Linter for Go source code that specializes in simplifying code",
- analyzers,
- nil,
- ).WithLoadMode(goanalysis.LoadModeTypesInfo)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/gosmopolitan/gosmopolitan.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/gosmopolitan/gosmopolitan.go
deleted file mode 100644
index bf9b19f129..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/gosmopolitan/gosmopolitan.go
+++ /dev/null
@@ -1,32 +0,0 @@
-package gosmopolitan
-
-import (
- "strings"
-
- "github.com/xen0n/gosmopolitan"
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/goanalysis"
-)
-
-func New(settings *config.GosmopolitanSettings) *goanalysis.Linter {
- a := gosmopolitan.NewAnalyzer()
-
- cfg := map[string]map[string]any{}
- if settings != nil {
- cfg[a.Name] = map[string]any{
- "allowtimelocal": settings.AllowTimeLocal,
- "escapehatches": strings.Join(settings.EscapeHatches, ","),
- "lookattests": !settings.IgnoreTests,
- "watchforscripts": strings.Join(settings.WatchForScripts, ","),
- }
- }
-
- return goanalysis.NewLinter(
- a.Name,
- a.Doc,
- []*analysis.Analyzer{a},
- cfg,
- ).WithLoadMode(goanalysis.LoadModeTypesInfo)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/grouper/grouper.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/grouper/grouper.go
deleted file mode 100644
index e0a3f794a7..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/grouper/grouper.go
+++ /dev/null
@@ -1,34 +0,0 @@
-package grouper
-
-import (
- grouper "github.com/leonklingele/grouper/pkg/analyzer"
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/goanalysis"
-)
-
-func New(settings *config.GrouperSettings) *goanalysis.Linter {
- a := grouper.New()
-
- cfg := map[string]map[string]any{}
- if settings != nil {
- cfg[a.Name] = map[string]any{
- "const-require-single-const": settings.ConstRequireSingleConst,
- "const-require-grouping": settings.ConstRequireGrouping,
- "import-require-single-import": settings.ImportRequireSingleImport,
- "import-require-grouping": settings.ImportRequireGrouping,
- "type-require-single-type": settings.TypeRequireSingleType,
- "type-require-grouping": settings.TypeRequireGrouping,
- "var-require-single-var": settings.VarRequireSingleVar,
- "var-require-grouping": settings.VarRequireGrouping,
- }
- }
-
- return goanalysis.NewLinter(
- a.Name,
- "Analyze expression groups.",
- []*analysis.Analyzer{a},
- cfg,
- ).WithLoadMode(goanalysis.LoadModeSyntax)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/importas/importas.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/importas/importas.go
deleted file mode 100644
index b7c6c35aea..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/importas/importas.go
+++ /dev/null
@@ -1,70 +0,0 @@
-package importas
-
-import (
- "fmt"
- "strconv"
- "strings"
-
- "github.com/julz/importas"
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/goanalysis"
- "github.com/golangci/golangci-lint/pkg/lint/linter"
-)
-
-func New(settings *config.ImportAsSettings) *goanalysis.Linter {
- analyzer := importas.Analyzer
-
- return goanalysis.NewLinter(
- analyzer.Name,
- analyzer.Doc,
- []*analysis.Analyzer{analyzer},
- nil,
- ).WithContextSetter(func(lintCtx *linter.Context) {
- if settings == nil {
- return
- }
- if len(settings.Alias) == 0 {
- lintCtx.Log.Infof("importas settings found, but no aliases listed. List aliases under alias: key.")
- }
-
- if err := analyzer.Flags.Set("no-unaliased", strconv.FormatBool(settings.NoUnaliased)); err != nil {
- lintCtx.Log.Errorf("failed to parse configuration: %v", err)
- }
-
- if err := analyzer.Flags.Set("no-extra-aliases", strconv.FormatBool(settings.NoExtraAliases)); err != nil {
- lintCtx.Log.Errorf("failed to parse configuration: %v", err)
- }
-
- uniqPackages := make(map[string]config.ImportAsAlias)
- uniqAliases := make(map[string]config.ImportAsAlias)
- for _, a := range settings.Alias {
- if a.Pkg == "" {
- lintCtx.Log.Errorf("invalid configuration, empty package: pkg=%s alias=%s", a.Pkg, a.Alias)
- continue
- }
-
- if v, ok := uniqPackages[a.Pkg]; ok {
- lintCtx.Log.Errorf("invalid configuration, multiple aliases for the same package: pkg=%s aliases=[%s,%s]", a.Pkg, a.Alias, v.Alias)
- } else {
- uniqPackages[a.Pkg] = a
- }
-
- // Skips the duplication check when:
- // - the alias is empty.
- // - the alias is a regular expression replacement pattern (ie. contains `$`).
- v, ok := uniqAliases[a.Alias]
- if ok && a.Alias != "" && !strings.Contains(a.Alias, "$") {
- lintCtx.Log.Errorf("invalid configuration, multiple packages with the same alias: alias=%s packages=[%s,%s]", a.Alias, a.Pkg, v.Pkg)
- } else {
- uniqAliases[a.Alias] = a
- }
-
- err := analyzer.Flags.Set("alias", fmt.Sprintf("%s:%s", a.Pkg, a.Alias))
- if err != nil {
- lintCtx.Log.Errorf("failed to parse configuration: %v", err)
- }
- }
- }).WithLoadMode(goanalysis.LoadModeTypesInfo)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/inamedparam/inamedparam.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/inamedparam/inamedparam.go
deleted file mode 100644
index 5cf06a08cc..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/inamedparam/inamedparam.go
+++ /dev/null
@@ -1,30 +0,0 @@
-package inamedparam
-
-import (
- "github.com/macabu/inamedparam"
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/goanalysis"
-)
-
-func New(settings *config.INamedParamSettings) *goanalysis.Linter {
- a := inamedparam.Analyzer
-
- var cfg map[string]map[string]any
-
- if settings != nil {
- cfg = map[string]map[string]any{
- a.Name: {
- "skip-single-param": settings.SkipSingleParam,
- },
- }
- }
-
- return goanalysis.NewLinter(
- a.Name,
- a.Doc,
- []*analysis.Analyzer{a},
- cfg,
- ).WithLoadMode(goanalysis.LoadModeSyntax)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/ineffassign/ineffassign.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/ineffassign/ineffassign.go
deleted file mode 100644
index ba86fb90e3..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/ineffassign/ineffassign.go
+++ /dev/null
@@ -1,19 +0,0 @@
-package ineffassign
-
-import (
- "github.com/gordonklaus/ineffassign/pkg/ineffassign"
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/goanalysis"
-)
-
-func New() *goanalysis.Linter {
- a := ineffassign.Analyzer
-
- return goanalysis.NewLinter(
- a.Name,
- "Detects when assignments to existing variables are not used",
- []*analysis.Analyzer{a},
- nil,
- ).WithLoadMode(goanalysis.LoadModeSyntax)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/interfacebloat/interfacebloat.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/interfacebloat/interfacebloat.go
deleted file mode 100644
index 88927a3d9b..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/interfacebloat/interfacebloat.go
+++ /dev/null
@@ -1,29 +0,0 @@
-package interfacebloat
-
-import (
- "github.com/sashamelentyev/interfacebloat/pkg/analyzer"
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/goanalysis"
-)
-
-func New(settings *config.InterfaceBloatSettings) *goanalysis.Linter {
- a := analyzer.New()
-
- var cfg map[string]map[string]any
- if settings != nil {
- cfg = map[string]map[string]any{
- a.Name: {
- analyzer.InterfaceMaxMethodsFlag: settings.Max,
- },
- }
- }
-
- return goanalysis.NewLinter(
- a.Name,
- a.Doc,
- []*analysis.Analyzer{a},
- cfg,
- ).WithLoadMode(goanalysis.LoadModeSyntax)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/internal/commons.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/internal/commons.go
deleted file mode 100644
index ebb0b13a0d..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/internal/commons.go
+++ /dev/null
@@ -1,15 +0,0 @@
-package internal
-
-import "github.com/golangci/golangci-lint/pkg/logutils"
-
-// LinterLogger must be use only when the context logger is not available.
-var LinterLogger = logutils.NewStderrLog(logutils.DebugKeyLinter)
-
-// Placeholders used inside linters to evaluate relative paths.
-const (
- PlaceholderBasePath = "${base-path}"
- // Deprecated: it must be removed in v2.
- // [PlaceholderBasePath] will be the only one placeholder as it is a dynamic value based on
- // [github.com/golangci/golangci-lint/pkg/config.Run.RelativePathMode].
- PlaceholderConfigDir = "${configDir}"
-)
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/internal/staticcheck_common.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/internal/staticcheck_common.go
deleted file mode 100644
index e5a0e33b7d..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/internal/staticcheck_common.go
+++ /dev/null
@@ -1,143 +0,0 @@
-package internal
-
-import (
- "strings"
- "unicode"
-
- "golang.org/x/tools/go/analysis"
- "honnef.co/go/tools/analysis/lint"
- scconfig "honnef.co/go/tools/config"
-
- "github.com/golangci/golangci-lint/pkg/config"
-)
-
-func SetupStaticCheckAnalyzers(src []*lint.Analyzer, checks []string) []*analysis.Analyzer {
- var names []string
- for _, a := range src {
- names = append(names, a.Analyzer.Name)
- }
-
- filter := filterAnalyzerNames(names, checks)
-
- var ret []*analysis.Analyzer
- for _, a := range src {
- if filter[a.Analyzer.Name] {
- ret = append(ret, a.Analyzer)
- }
- }
-
- return ret
-}
-
-func StaticCheckConfig(settings *config.StaticCheckSettings) *scconfig.Config {
- var cfg *scconfig.Config
-
- if settings == nil || !settings.HasConfiguration() {
- return &scconfig.Config{
- Checks: []string{"*"}, // override for compatibility reason. Must drop in the next major version.
- Initialisms: scconfig.DefaultConfig.Initialisms,
- DotImportWhitelist: scconfig.DefaultConfig.DotImportWhitelist,
- HTTPStatusCodeWhitelist: scconfig.DefaultConfig.HTTPStatusCodeWhitelist,
- }
- }
-
- cfg = &scconfig.Config{
- Checks: settings.Checks,
- Initialisms: settings.Initialisms,
- DotImportWhitelist: settings.DotImportWhitelist,
- HTTPStatusCodeWhitelist: settings.HTTPStatusCodeWhitelist,
- }
-
- if len(cfg.Checks) == 0 {
- cfg.Checks = append(cfg.Checks, "*") // override for compatibility reason. Must drop in the next major version.
- }
-
- if len(cfg.Initialisms) == 0 {
- cfg.Initialisms = append(cfg.Initialisms, scconfig.DefaultConfig.Initialisms...)
- }
-
- if len(cfg.DotImportWhitelist) == 0 {
- cfg.DotImportWhitelist = append(cfg.DotImportWhitelist, scconfig.DefaultConfig.DotImportWhitelist...)
- }
-
- if len(cfg.HTTPStatusCodeWhitelist) == 0 {
- cfg.HTTPStatusCodeWhitelist = append(cfg.HTTPStatusCodeWhitelist, scconfig.DefaultConfig.HTTPStatusCodeWhitelist...)
- }
-
- cfg.Checks = normalizeList(cfg.Checks)
- cfg.Initialisms = normalizeList(cfg.Initialisms)
- cfg.DotImportWhitelist = normalizeList(cfg.DotImportWhitelist)
- cfg.HTTPStatusCodeWhitelist = normalizeList(cfg.HTTPStatusCodeWhitelist)
-
- return cfg
-}
-
-// https://github.com/dominikh/go-tools/blob/9bf17c0388a65710524ba04c2d821469e639fdc2/lintcmd/lint.go#L437-L477
-//
-//nolint:gocritic // Keep the original source code.
-func filterAnalyzerNames(analyzers []string, checks []string) map[string]bool {
- allowedChecks := map[string]bool{}
-
- for _, check := range checks {
- b := true
- if len(check) > 1 && check[0] == '-' {
- b = false
- check = check[1:]
- }
-
- if check == "*" || check == "all" {
- // Match all
- for _, c := range analyzers {
- allowedChecks[c] = b
- }
- } else if strings.HasSuffix(check, "*") {
- // Glob
- prefix := check[:len(check)-1]
- isCat := strings.IndexFunc(prefix, func(r rune) bool { return unicode.IsNumber(r) }) == -1
-
- for _, a := range analyzers {
- idx := strings.IndexFunc(a, func(r rune) bool { return unicode.IsNumber(r) })
- if isCat {
- // Glob is S*, which should match S1000 but not SA1000
- cat := a[:idx]
- if prefix == cat {
- allowedChecks[a] = b
- }
- } else {
- // Glob is S1*
- if strings.HasPrefix(a, prefix) {
- allowedChecks[a] = b
- }
- }
- }
- } else {
- // Literal check name
- allowedChecks[check] = b
- }
- }
- return allowedChecks
-}
-
-// https://github.com/dominikh/go-tools/blob/9bf17c0388a65710524ba04c2d821469e639fdc2/config/config.go#L95-L116
-func normalizeList(list []string) []string {
- if len(list) > 1 {
- nlist := make([]string, 0, len(list))
- nlist = append(nlist, list[0])
- for i, el := range list[1:] {
- if el != list[i] {
- nlist = append(nlist, el)
- }
- }
- list = nlist
- }
-
- for _, el := range list {
- if el == "inherit" {
- // This should never happen, because the default config
- // should not use "inherit"
- panic(`unresolved "inherit"`)
- }
- }
-
- return list
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/internal/util.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/internal/util.go
deleted file mode 100644
index 7525f2f2c5..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/internal/util.go
+++ /dev/null
@@ -1,34 +0,0 @@
-package internal
-
-import (
- "fmt"
- "strings"
-
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/goanalysis"
-)
-
-func FormatCode(code string, _ *config.Config) string {
- if strings.Contains(code, "`") {
- return code // TODO: properly escape or remove
- }
-
- return fmt.Sprintf("`%s`", code)
-}
-
-func GetGoFileNames(pass *analysis.Pass) []string {
- var filenames []string
-
- for _, f := range pass.Files {
- position, b := goanalysis.GetGoFilePosition(pass, f)
- if !b {
- continue
- }
-
- filenames = append(filenames, position.Filename)
- }
-
- return filenames
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/intrange/intrange.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/intrange/intrange.go
deleted file mode 100644
index d5ffd43453..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/intrange/intrange.go
+++ /dev/null
@@ -1,19 +0,0 @@
-package intrange
-
-import (
- "github.com/ckaznocha/intrange"
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/goanalysis"
-)
-
-func New() *goanalysis.Linter {
- a := intrange.Analyzer
-
- return goanalysis.NewLinter(
- a.Name,
- a.Doc,
- []*analysis.Analyzer{a},
- nil,
- ).WithLoadMode(goanalysis.LoadModeTypesInfo)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/ireturn/ireturn.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/ireturn/ireturn.go
deleted file mode 100644
index 57de57111e..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/ireturn/ireturn.go
+++ /dev/null
@@ -1,31 +0,0 @@
-package ireturn
-
-import (
- "strings"
-
- "github.com/butuzov/ireturn/analyzer"
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/goanalysis"
-)
-
-func New(settings *config.IreturnSettings) *goanalysis.Linter {
- a := analyzer.NewAnalyzer()
-
- cfg := map[string]map[string]any{}
- if settings != nil {
- cfg[a.Name] = map[string]any{
- "allow": strings.Join(settings.Allow, ","),
- "reject": strings.Join(settings.Reject, ","),
- "nonolint": true,
- }
- }
-
- return goanalysis.NewLinter(
- a.Name,
- a.Doc,
- []*analysis.Analyzer{a},
- cfg,
- ).WithLoadMode(goanalysis.LoadModeTypesInfo)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/loggercheck/loggercheck.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/loggercheck/loggercheck.go
deleted file mode 100644
index 84c8d73635..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/loggercheck/loggercheck.go
+++ /dev/null
@@ -1,47 +0,0 @@
-package loggercheck
-
-import (
- "github.com/timonwong/loggercheck"
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/goanalysis"
-)
-
-func New(settings *config.LoggerCheckSettings) *goanalysis.Linter {
- var opts []loggercheck.Option
-
- if settings != nil {
- var disable []string
- if !settings.Kitlog {
- disable = append(disable, "kitlog")
- }
- if !settings.Klog {
- disable = append(disable, "klog")
- }
- if !settings.Logr {
- disable = append(disable, "logr")
- }
- if !settings.Slog {
- disable = append(disable, "slog")
- }
- if !settings.Zap {
- disable = append(disable, "zap")
- }
-
- opts = []loggercheck.Option{
- loggercheck.WithDisable(disable),
- loggercheck.WithRequireStringKey(settings.RequireStringKey),
- loggercheck.WithRules(settings.Rules),
- loggercheck.WithNoPrintfLike(settings.NoPrintfLike),
- }
- }
-
- analyzer := loggercheck.NewAnalyzer(opts...)
- return goanalysis.NewLinter(
- analyzer.Name,
- analyzer.Doc,
- []*analysis.Analyzer{analyzer},
- nil,
- ).WithLoadMode(goanalysis.LoadModeTypesInfo)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/maintidx/maintidx.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/maintidx/maintidx.go
deleted file mode 100644
index 799c51c874..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/maintidx/maintidx.go
+++ /dev/null
@@ -1,30 +0,0 @@
-package maintidx
-
-import (
- "github.com/yagipy/maintidx"
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/goanalysis"
-)
-
-func New(settings *config.MaintIdxSettings) *goanalysis.Linter {
- analyzer := maintidx.Analyzer
-
- cfg := map[string]map[string]any{
- analyzer.Name: {"under": 20},
- }
-
- if settings != nil {
- cfg[analyzer.Name] = map[string]any{
- "under": settings.Under,
- }
- }
-
- return goanalysis.NewLinter(
- analyzer.Name,
- analyzer.Doc,
- []*analysis.Analyzer{analyzer},
- cfg,
- ).WithLoadMode(goanalysis.LoadModeSyntax)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/makezero/makezero.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/makezero/makezero.go
deleted file mode 100644
index b5ab4515e5..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/makezero/makezero.go
+++ /dev/null
@@ -1,55 +0,0 @@
-package makezero
-
-import (
- "fmt"
-
- "github.com/ashanbrown/makezero/makezero"
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/goanalysis"
-)
-
-const linterName = "makezero"
-
-func New(settings *config.MakezeroSettings) *goanalysis.Linter {
- analyzer := &analysis.Analyzer{
- Name: linterName,
- Doc: goanalysis.TheOnlyanalyzerDoc,
- Run: func(pass *analysis.Pass) (any, error) {
- err := runMakeZero(pass, settings)
- if err != nil {
- return nil, err
- }
-
- return nil, nil
- },
- }
-
- return goanalysis.NewLinter(
- linterName,
- "Finds slice declarations with non-zero initial length",
- []*analysis.Analyzer{analyzer},
- nil,
- ).WithLoadMode(goanalysis.LoadModeTypesInfo)
-}
-
-func runMakeZero(pass *analysis.Pass, settings *config.MakezeroSettings) error {
- zero := makezero.NewLinter(settings.Always)
-
- for _, file := range pass.Files {
- hints, err := zero.Run(pass.Fset, pass.TypesInfo, file)
- if err != nil {
- return fmt.Errorf("makezero linter failed on file %q: %w", file.Name.String(), err)
- }
-
- for _, hint := range hints {
- pass.Report(analysis.Diagnostic{
- Pos: hint.Pos(),
- Message: hint.Details(),
- })
- }
- }
-
- return nil
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/mirror/mirror.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/mirror/mirror.go
deleted file mode 100644
index e15dfa3a5a..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/mirror/mirror.go
+++ /dev/null
@@ -1,30 +0,0 @@
-package mirror
-
-import (
- "github.com/butuzov/mirror"
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/goanalysis"
-)
-
-func New() *goanalysis.Linter {
- a := mirror.NewAnalyzer()
-
- // mirror only lints test files if the `--with-tests` flag is passed,
- // so we pass the `with-tests` flag as true to the analyzer before running it.
- // This can be turned off by using the regular golangci-lint flags such as `--tests` or `--skip-files`
- // or can be disabled per linter via exclude rules.
- // (see https://github.com/golangci/golangci-lint/issues/2527#issuecomment-1023707262)
- linterCfg := map[string]map[string]any{
- a.Name: {
- "with-tests": true,
- },
- }
-
- return goanalysis.NewLinter(
- a.Name,
- a.Doc,
- []*analysis.Analyzer{a},
- linterCfg,
- ).WithLoadMode(goanalysis.LoadModeTypesInfo)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/mnd/mnd.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/mnd/mnd.go
deleted file mode 100644
index fe64653b91..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/mnd/mnd.go
+++ /dev/null
@@ -1,42 +0,0 @@
-package mnd
-
-import (
- mnd "github.com/tommy-muehle/go-mnd/v2"
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/goanalysis"
-)
-
-func New(settings *config.MndSettings) *goanalysis.Linter {
- return newMND(mnd.Analyzer, settings, nil)
-}
-
-func newMND(a *analysis.Analyzer, settings *config.MndSettings, linterCfg map[string]map[string]any) *goanalysis.Linter {
- if len(linterCfg) == 0 && settings != nil {
- cfg := make(map[string]any)
- if len(settings.Checks) > 0 {
- cfg["checks"] = settings.Checks
- }
- if len(settings.IgnoredNumbers) > 0 {
- cfg["ignored-numbers"] = settings.IgnoredNumbers
- }
- if len(settings.IgnoredFiles) > 0 {
- cfg["ignored-files"] = settings.IgnoredFiles
- }
- if len(settings.IgnoredFunctions) > 0 {
- cfg["ignored-functions"] = settings.IgnoredFunctions
- }
-
- linterCfg = map[string]map[string]any{
- a.Name: cfg,
- }
- }
-
- return goanalysis.NewLinter(
- a.Name,
- "An analyzer to detect magic numbers.",
- []*analysis.Analyzer{a},
- linterCfg,
- ).WithLoadMode(goanalysis.LoadModeSyntax)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/musttag/musttag.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/musttag/musttag.go
deleted file mode 100644
index a4e9ceff28..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/musttag/musttag.go
+++ /dev/null
@@ -1,29 +0,0 @@
-package musttag
-
-import (
- "go-simpler.org/musttag"
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/goanalysis"
-)
-
-func New(settings *config.MustTagSettings) *goanalysis.Linter {
- var funcs []musttag.Func
-
- if settings != nil {
- for _, fn := range settings.Functions {
- funcs = append(funcs, musttag.Func{
- Name: fn.Name,
- Tag: fn.Tag,
- ArgPos: fn.ArgPos,
- })
- }
- }
-
- a := musttag.New(funcs...)
-
- return goanalysis.
- NewLinter(a.Name, a.Doc, []*analysis.Analyzer{a}, nil).
- WithLoadMode(goanalysis.LoadModeTypesInfo)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/nakedret/nakedret.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/nakedret/nakedret.go
deleted file mode 100644
index e69fa5e9f5..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/nakedret/nakedret.go
+++ /dev/null
@@ -1,25 +0,0 @@
-package nakedret
-
-import (
- "github.com/alexkohler/nakedret/v2"
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/goanalysis"
-)
-
-func New(settings *config.NakedretSettings) *goanalysis.Linter {
- var maxLines uint
- if settings != nil {
- maxLines = settings.MaxFuncLines
- }
-
- a := nakedret.NakedReturnAnalyzer(maxLines, false)
-
- return goanalysis.NewLinter(
- a.Name,
- a.Doc,
- []*analysis.Analyzer{a},
- nil,
- ).WithLoadMode(goanalysis.LoadModeSyntax)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/nestif/nestif.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/nestif/nestif.go
deleted file mode 100644
index b72538fd16..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/nestif/nestif.go
+++ /dev/null
@@ -1,59 +0,0 @@
-package nestif
-
-import (
- "github.com/nakabonne/nestif"
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/goanalysis"
-)
-
-const linterName = "nestif"
-
-func New(settings *config.NestifSettings) *goanalysis.Linter {
- analyzer := &analysis.Analyzer{
- Name: linterName,
- Doc: goanalysis.TheOnlyanalyzerDoc,
- Run: func(pass *analysis.Pass) (any, error) {
- runNestIf(pass, settings)
-
- return nil, nil
- },
- }
-
- return goanalysis.NewLinter(
- linterName,
- "Reports deeply nested if statements",
- []*analysis.Analyzer{analyzer},
- nil,
- ).WithLoadMode(goanalysis.LoadModeSyntax)
-}
-
-func runNestIf(pass *analysis.Pass, settings *config.NestifSettings) {
- checker := &nestif.Checker{
- MinComplexity: settings.MinComplexity,
- }
-
- for _, file := range pass.Files {
- position, isGoFile := goanalysis.GetGoFilePosition(pass, file)
- if !isGoFile {
- continue
- }
-
- issues := checker.Check(file, pass.Fset)
- if len(issues) == 0 {
- continue
- }
-
- nonAdjPosition := pass.Fset.PositionFor(file.Pos(), false)
-
- f := pass.Fset.File(file.Pos())
-
- for _, issue := range issues {
- pass.Report(analysis.Diagnostic{
- Pos: f.LineStart(goanalysis.AdjustPos(issue.Pos.Line, nonAdjPosition.Line, position.Line)),
- Message: issue.Message,
- })
- }
- }
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/nilerr/nilerr.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/nilerr/nilerr.go
deleted file mode 100644
index c9e466905e..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/nilerr/nilerr.go
+++ /dev/null
@@ -1,19 +0,0 @@
-package nilerr
-
-import (
- "github.com/gostaticanalysis/nilerr"
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/goanalysis"
-)
-
-func New() *goanalysis.Linter {
- a := nilerr.Analyzer
-
- return goanalysis.NewLinter(
- a.Name,
- "Finds the code that returns nil even if it checks that the error is not nil.",
- []*analysis.Analyzer{a},
- nil,
- ).WithLoadMode(goanalysis.LoadModeTypesInfo)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/nilnesserr/nilnesserr.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/nilnesserr/nilnesserr.go
deleted file mode 100644
index 8349377b7b..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/nilnesserr/nilnesserr.go
+++ /dev/null
@@ -1,23 +0,0 @@
-package nilnesserr
-
-import (
- "github.com/alingse/nilnesserr"
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/goanalysis"
- "github.com/golangci/golangci-lint/pkg/golinters/internal"
-)
-
-func New() *goanalysis.Linter {
- a, err := nilnesserr.NewAnalyzer(nilnesserr.LinterSetting{})
- if err != nil {
- internal.LinterLogger.Fatalf("nilnesserr: create analyzer: %v", err)
- }
-
- return goanalysis.NewLinter(
- a.Name,
- a.Doc,
- []*analysis.Analyzer{a},
- nil,
- ).WithLoadMode(goanalysis.LoadModeTypesInfo)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/nilnil/nilnil.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/nilnil/nilnil.go
deleted file mode 100644
index ed25dec71f..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/nilnil/nilnil.go
+++ /dev/null
@@ -1,31 +0,0 @@
-package nilnil
-
-import (
- "github.com/Antonboom/nilnil/pkg/analyzer"
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/goanalysis"
-)
-
-func New(settings *config.NilNilSettings) *goanalysis.Linter {
- a := analyzer.New()
-
- cfg := make(map[string]map[string]any)
- if settings != nil {
- cfg[a.Name] = map[string]any{
- "detect-opposite": settings.DetectOpposite,
- }
- if len(settings.CheckedTypes) != 0 {
- cfg[a.Name]["checked-types"] = settings.CheckedTypes
- }
- }
-
- return goanalysis.NewLinter(
- a.Name,
- a.Doc,
- []*analysis.Analyzer{a},
- cfg,
- ).
- WithLoadMode(goanalysis.LoadModeTypesInfo)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/nlreturn/nlreturn.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/nlreturn/nlreturn.go
deleted file mode 100644
index 5092188085..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/nlreturn/nlreturn.go
+++ /dev/null
@@ -1,27 +0,0 @@
-package nlreturn
-
-import (
- "github.com/ssgreg/nlreturn/v2/pkg/nlreturn"
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/goanalysis"
-)
-
-func New(settings *config.NlreturnSettings) *goanalysis.Linter {
- a := nlreturn.NewAnalyzer()
-
- cfg := map[string]map[string]any{}
- if settings != nil {
- cfg[a.Name] = map[string]any{
- "block-size": settings.BlockSize,
- }
- }
-
- return goanalysis.NewLinter(
- a.Name,
- "nlreturn checks for a new line before return and branch statements to increase code clarity",
- []*analysis.Analyzer{a},
- cfg,
- ).WithLoadMode(goanalysis.LoadModeSyntax)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/noctx/noctx.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/noctx/noctx.go
deleted file mode 100644
index 8a063c613c..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/noctx/noctx.go
+++ /dev/null
@@ -1,19 +0,0 @@
-package noctx
-
-import (
- "github.com/sonatard/noctx"
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/goanalysis"
-)
-
-func New() *goanalysis.Linter {
- a := noctx.Analyzer
-
- return goanalysis.NewLinter(
- a.Name,
- "Finds sending http request without context.Context",
- []*analysis.Analyzer{a},
- nil,
- ).WithLoadMode(goanalysis.LoadModeTypesInfo)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/nolintlint/internal/issues.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/nolintlint/internal/issues.go
deleted file mode 100644
index 5e9ba4117c..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/nolintlint/internal/issues.go
+++ /dev/null
@@ -1,41 +0,0 @@
-package internal
-
-import (
- "fmt"
- "strings"
- "unicode"
-)
-
-func formatExtraLeadingSpace(fullDirective string) string {
- return fmt.Sprintf("directive `%s` should not have more than one leading space", fullDirective)
-}
-
-func formatNotMachine(fullDirective string) string {
- expected := fullDirective[:2] + strings.TrimLeftFunc(fullDirective[2:], unicode.IsSpace)
- return fmt.Sprintf("directive `%s` should be written without leading space as `%s`",
- fullDirective, expected)
-}
-
-func formatNotSpecific(fullDirective, directiveWithOptionalLeadingSpace string) string {
- return fmt.Sprintf("directive `%s` should mention specific linter such as `%s:my-linter`",
- fullDirective, directiveWithOptionalLeadingSpace)
-}
-
-func formatParseError(fullDirective, directiveWithOptionalLeadingSpace string) string {
- return fmt.Sprintf("directive `%s` should match `%s[:] [// ]`",
- fullDirective,
- directiveWithOptionalLeadingSpace)
-}
-
-func formatNoExplanation(fullDirective, fullDirectiveWithoutExplanation string) string {
- return fmt.Sprintf("directive `%s` should provide explanation such as `%s // this is why`",
- fullDirective, fullDirectiveWithoutExplanation)
-}
-
-func formatUnusedCandidate(fullDirective, expectedLinter string) string {
- details := fmt.Sprintf("directive `%s` is unused", fullDirective)
- if expectedLinter != "" {
- details += fmt.Sprintf(" for linter %q", expectedLinter)
- }
- return details
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/nolintlint/internal/nolintlint.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/nolintlint/internal/nolintlint.go
deleted file mode 100644
index 21cd20124f..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/nolintlint/internal/nolintlint.go
+++ /dev/null
@@ -1,232 +0,0 @@
-// Package internal provides a linter to ensure that all //nolint directives are followed by explanations
-package internal
-
-import (
- "go/token"
- "regexp"
- "strings"
-
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/goanalysis"
- "github.com/golangci/golangci-lint/pkg/result"
-)
-
-const LinterName = "nolintlint"
-
-const (
- NeedsMachineOnly Needs = 1 << iota
- NeedsSpecific
- NeedsExplanation
- NeedsUnused
- NeedsAll = NeedsMachineOnly | NeedsSpecific | NeedsExplanation
-)
-
-type Needs uint
-
-const commentMark = "//"
-
-var commentPattern = regexp.MustCompile(`^//\s*(nolint)(:\s*[\w-]+\s*(?:,\s*[\w-]+\s*)*)?\b`)
-
-// matches a complete nolint directive
-var fullDirectivePattern = regexp.MustCompile(`^//\s*nolint(?::(\s*[\w-]+\s*(?:,\s*[\w-]+\s*)*))?\s*(//.*)?\s*\n?$`)
-
-type Linter struct {
- needs Needs // indicates which linter checks to perform
- excludeByLinter map[string]bool
-}
-
-// NewLinter creates a linter that enforces that the provided directives fulfill the provided requirements
-func NewLinter(needs Needs, excludes []string) (*Linter, error) {
- excludeByName := make(map[string]bool)
- for _, e := range excludes {
- excludeByName[e] = true
- }
-
- return &Linter{
- needs: needs | NeedsMachineOnly,
- excludeByLinter: excludeByName,
- }, nil
-}
-
-var (
- leadingSpacePattern = regexp.MustCompile(`^//(\s*)`)
- trailingBlankExplanation = regexp.MustCompile(`\s*(//\s*)?$`)
-)
-
-//nolint:funlen,gocyclo // the function is going to be refactored in the future
-func (l Linter) Run(pass *analysis.Pass) ([]goanalysis.Issue, error) {
- var issues []goanalysis.Issue
-
- for _, file := range pass.Files {
- for _, c := range file.Comments {
- for _, comment := range c.List {
- if !commentPattern.MatchString(comment.Text) {
- continue
- }
-
- // check for a space between the "//" and the directive
- leadingSpaceMatches := leadingSpacePattern.FindStringSubmatch(comment.Text)
-
- var leadingSpace string
- if len(leadingSpaceMatches) > 0 {
- leadingSpace = leadingSpaceMatches[1]
- }
-
- directiveWithOptionalLeadingSpace := commentMark
- if leadingSpace != "" {
- directiveWithOptionalLeadingSpace += " "
- }
-
- split := strings.Split(strings.SplitN(comment.Text, ":", 2)[0], commentMark)
- directiveWithOptionalLeadingSpace += strings.TrimSpace(split[1])
-
- pos := pass.Fset.Position(comment.Pos())
- end := pass.Fset.Position(comment.End())
-
- // check for, report and eliminate leading spaces, so we can check for other issues
- if leadingSpace != "" {
- removeWhitespace := []analysis.SuggestedFix{{
- TextEdits: []analysis.TextEdit{{
- Pos: token.Pos(pos.Offset),
- End: token.Pos(pos.Offset + len(commentMark) + len(leadingSpace)),
- NewText: []byte(commentMark),
- }},
- }}
-
- if (l.needs & NeedsMachineOnly) != 0 {
- issue := &result.Issue{
- FromLinter: LinterName,
- Text: formatNotMachine(comment.Text),
- Pos: pos,
- SuggestedFixes: removeWhitespace,
- }
-
- issues = append(issues, goanalysis.NewIssue(issue, pass))
- } else if len(leadingSpace) > 1 {
- issue := &result.Issue{
- FromLinter: LinterName,
- Text: formatExtraLeadingSpace(comment.Text),
- Pos: pos,
- SuggestedFixes: removeWhitespace,
- }
-
- issues = append(issues, goanalysis.NewIssue(issue, pass))
- }
- }
-
- fullMatches := fullDirectivePattern.FindStringSubmatch(comment.Text)
- if len(fullMatches) == 0 {
- issue := &result.Issue{
- FromLinter: LinterName,
- Text: formatParseError(comment.Text, directiveWithOptionalLeadingSpace),
- Pos: pos,
- }
-
- issues = append(issues, goanalysis.NewIssue(issue, pass))
-
- continue
- }
-
- lintersText, explanation := fullMatches[1], fullMatches[2]
-
- var linters []string
- if lintersText != "" && !strings.HasPrefix(lintersText, "all") {
- lls := strings.Split(lintersText, ",")
- linters = make([]string, 0, len(lls))
- rangeStart := (pos.Column - 1) + len(commentMark) + len(leadingSpace) + len("nolint:")
- for i, ll := range lls {
- rangeEnd := rangeStart + len(ll)
- if i < len(lls)-1 {
- rangeEnd++ // include trailing comma
- }
- trimmedLinterName := strings.TrimSpace(ll)
- if trimmedLinterName != "" {
- linters = append(linters, trimmedLinterName)
- }
- rangeStart = rangeEnd
- }
- }
-
- if (l.needs & NeedsSpecific) != 0 {
- if len(linters) == 0 {
- issue := &result.Issue{
- FromLinter: LinterName,
- Text: formatNotSpecific(comment.Text, directiveWithOptionalLeadingSpace),
- Pos: pos,
- }
-
- issues = append(issues, goanalysis.NewIssue(issue, pass))
- }
- }
-
- // when detecting unused directives, we send all the directives through and filter them out in the nolint processor
- if (l.needs & NeedsUnused) != 0 {
- removeNolintCompletely := []analysis.SuggestedFix{{
- TextEdits: []analysis.TextEdit{{
- Pos: token.Pos(pos.Offset),
- End: token.Pos(end.Offset),
- NewText: nil,
- }},
- }}
-
- if len(linters) == 0 {
- issue := &result.Issue{
- FromLinter: LinterName,
- Text: formatUnusedCandidate(comment.Text, ""),
- Pos: pos,
- ExpectNoLint: true,
- SuggestedFixes: removeNolintCompletely,
- }
-
- issues = append(issues, goanalysis.NewIssue(issue, pass))
- } else {
- for _, linter := range linters {
- issue := &result.Issue{
- FromLinter: LinterName,
- Text: formatUnusedCandidate(comment.Text, linter),
- Pos: pos,
- ExpectNoLint: true,
- ExpectedNoLintLinter: linter,
- }
-
- // only offer SuggestedFix if there is a single linter
- // because of issues around commas and the possibility of all
- // linters being removed
- if len(linters) == 1 {
- issue.SuggestedFixes = removeNolintCompletely
- }
-
- issues = append(issues, goanalysis.NewIssue(issue, pass))
- }
- }
- }
-
- if (l.needs&NeedsExplanation) != 0 && (explanation == "" || strings.TrimSpace(explanation) == commentMark) {
- needsExplanation := len(linters) == 0 // if no linters are mentioned, we must have explanation
- // otherwise, check if we are excluding all the mentioned linters
- for _, ll := range linters {
- if !l.excludeByLinter[ll] { // if a linter does require explanation
- needsExplanation = true
- break
- }
- }
-
- if needsExplanation {
- fullDirectiveWithoutExplanation := trailingBlankExplanation.ReplaceAllString(comment.Text, "")
-
- issue := &result.Issue{
- FromLinter: LinterName,
- Text: formatNoExplanation(comment.Text, fullDirectiveWithoutExplanation),
- Pos: pos,
- }
-
- issues = append(issues, goanalysis.NewIssue(issue, pass))
- }
- }
- }
- }
- }
-
- return issues, nil
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/nolintlint/nolintlint.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/nolintlint/nolintlint.go
deleted file mode 100644
index e1c878628d..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/nolintlint/nolintlint.go
+++ /dev/null
@@ -1,68 +0,0 @@
-package nolintlint
-
-import (
- "fmt"
- "sync"
-
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/golinters/internal"
-
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/goanalysis"
- nolintlint "github.com/golangci/golangci-lint/pkg/golinters/nolintlint/internal"
- "github.com/golangci/golangci-lint/pkg/lint/linter"
-)
-
-const LinterName = nolintlint.LinterName
-
-func New(settings *config.NoLintLintSettings) *goanalysis.Linter {
- var mu sync.Mutex
- var resIssues []goanalysis.Issue
-
- var needs nolintlint.Needs
- if settings.RequireExplanation {
- needs |= nolintlint.NeedsExplanation
- }
- if settings.RequireSpecific {
- needs |= nolintlint.NeedsSpecific
- }
- if !settings.AllowUnused {
- needs |= nolintlint.NeedsUnused
- }
-
- lnt, err := nolintlint.NewLinter(needs, settings.AllowNoExplanation)
- if err != nil {
- internal.LinterLogger.Fatalf("%s: create analyzer: %v", nolintlint.LinterName, err)
- }
-
- analyzer := &analysis.Analyzer{
- Name: nolintlint.LinterName,
- Doc: goanalysis.TheOnlyanalyzerDoc,
- Run: func(pass *analysis.Pass) (any, error) {
- issues, err := lnt.Run(pass)
- if err != nil {
- return nil, fmt.Errorf("linter failed to run: %w", err)
- }
-
- if len(issues) == 0 {
- return nil, nil
- }
-
- mu.Lock()
- resIssues = append(resIssues, issues...)
- mu.Unlock()
-
- return nil, nil
- },
- }
-
- return goanalysis.NewLinter(
- nolintlint.LinterName,
- "Reports ill-formed or insufficient nolint directives",
- []*analysis.Analyzer{analyzer},
- nil,
- ).WithIssuesReporter(func(*linter.Context) []goanalysis.Issue {
- return resIssues
- }).WithLoadMode(goanalysis.LoadModeSyntax)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/nonamedreturns/nonamedreturns.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/nonamedreturns/nonamedreturns.go
deleted file mode 100644
index 42a618e641..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/nonamedreturns/nonamedreturns.go
+++ /dev/null
@@ -1,29 +0,0 @@
-package nonamedreturns
-
-import (
- "github.com/firefart/nonamedreturns/analyzer"
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/goanalysis"
-)
-
-func New(settings *config.NoNamedReturnsSettings) *goanalysis.Linter {
- a := analyzer.Analyzer
-
- var cfg map[string]map[string]any
- if settings != nil {
- cfg = map[string]map[string]any{
- a.Name: {
- analyzer.FlagReportErrorInDefer: settings.ReportErrorInDefer,
- },
- }
- }
-
- return goanalysis.NewLinter(
- a.Name,
- a.Doc,
- []*analysis.Analyzer{a},
- cfg,
- ).WithLoadMode(goanalysis.LoadModeTypesInfo)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/nosprintfhostport/nosprintfhostport.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/nosprintfhostport/nosprintfhostport.go
deleted file mode 100644
index 8f06ae1f6d..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/nosprintfhostport/nosprintfhostport.go
+++ /dev/null
@@ -1,19 +0,0 @@
-package nosprintfhostport
-
-import (
- "github.com/stbenjam/no-sprintf-host-port/pkg/analyzer"
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/goanalysis"
-)
-
-func New() *goanalysis.Linter {
- a := analyzer.Analyzer
-
- return goanalysis.NewLinter(
- a.Name,
- a.Doc,
- []*analysis.Analyzer{a},
- nil,
- ).WithLoadMode(goanalysis.LoadModeSyntax)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/paralleltest/paralleltest.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/paralleltest/paralleltest.go
deleted file mode 100644
index 0c908fa38f..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/paralleltest/paralleltest.go
+++ /dev/null
@@ -1,34 +0,0 @@
-package paralleltest
-
-import (
- "github.com/kunwardeep/paralleltest/pkg/paralleltest"
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/goanalysis"
-)
-
-func New(settings *config.ParallelTestSettings) *goanalysis.Linter {
- a := paralleltest.NewAnalyzer()
-
- var cfg map[string]map[string]any
- if settings != nil {
- d := map[string]any{
- "i": settings.IgnoreMissing,
- "ignoremissingsubtests": settings.IgnoreMissingSubtests,
- }
-
- if config.IsGoGreaterThanOrEqual(settings.Go, "1.22") {
- d["ignoreloopVar"] = true
- }
-
- cfg = map[string]map[string]any{a.Name: d}
- }
-
- return goanalysis.NewLinter(
- a.Name,
- "Detects missing usage of t.Parallel() method in your Go test",
- []*analysis.Analyzer{a},
- cfg,
- ).WithLoadMode(goanalysis.LoadModeTypesInfo)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/perfsprint/perfsprint.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/perfsprint/perfsprint.go
deleted file mode 100644
index c34f7e4c62..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/perfsprint/perfsprint.go
+++ /dev/null
@@ -1,40 +0,0 @@
-package perfsprint
-
-import (
- "github.com/catenacyber/perfsprint/analyzer"
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/goanalysis"
-)
-
-func New(settings *config.PerfSprintSettings) *goanalysis.Linter {
- a := analyzer.New()
-
- cfg := map[string]map[string]any{
- a.Name: {"fiximports": false},
- }
-
- if settings != nil {
- cfg[a.Name]["integer-format"] = settings.IntegerFormat
- cfg[a.Name]["int-conversion"] = settings.IntConversion
-
- cfg[a.Name]["error-format"] = settings.ErrorFormat
- cfg[a.Name]["err-error"] = settings.ErrError
- cfg[a.Name]["errorf"] = settings.ErrorF
-
- cfg[a.Name]["string-format"] = settings.StringFormat
- cfg[a.Name]["sprintf1"] = settings.SprintF1
- cfg[a.Name]["strconcat"] = settings.StrConcat
-
- cfg[a.Name]["bool-format"] = settings.BoolFormat
- cfg[a.Name]["hex-format"] = settings.HexFormat
- }
-
- return goanalysis.NewLinter(
- a.Name,
- a.Doc,
- []*analysis.Analyzer{a},
- cfg,
- ).WithLoadMode(goanalysis.LoadModeTypesInfo)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/prealloc/prealloc.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/prealloc/prealloc.go
deleted file mode 100644
index 17e86c98ee..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/prealloc/prealloc.go
+++ /dev/null
@@ -1,44 +0,0 @@
-package prealloc
-
-import (
- "fmt"
-
- "github.com/alexkohler/prealloc/pkg"
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/goanalysis"
- "github.com/golangci/golangci-lint/pkg/golinters/internal"
-)
-
-const linterName = "prealloc"
-
-func New(settings *config.PreallocSettings) *goanalysis.Linter {
- analyzer := &analysis.Analyzer{
- Name: linterName,
- Doc: goanalysis.TheOnlyanalyzerDoc,
- Run: func(pass *analysis.Pass) (any, error) {
- runPreAlloc(pass, settings)
-
- return nil, nil
- },
- }
-
- return goanalysis.NewLinter(
- linterName,
- "Finds slice declarations that could potentially be pre-allocated",
- []*analysis.Analyzer{analyzer},
- nil,
- ).WithLoadMode(goanalysis.LoadModeSyntax)
-}
-
-func runPreAlloc(pass *analysis.Pass, settings *config.PreallocSettings) {
- hints := pkg.Check(pass.Files, settings.Simple, settings.RangeLoops, settings.ForLoops)
-
- for _, hint := range hints {
- pass.Report(analysis.Diagnostic{
- Pos: hint.Pos,
- Message: fmt.Sprintf("Consider pre-allocating %s", internal.FormatCode(hint.DeclaredSliceName, nil)),
- })
- }
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/predeclared/predeclared.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/predeclared/predeclared.go
deleted file mode 100644
index b8d189fd55..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/predeclared/predeclared.go
+++ /dev/null
@@ -1,26 +0,0 @@
-package predeclared
-
-import (
- "github.com/nishanths/predeclared/passes/predeclared"
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/goanalysis"
-)
-
-func New(settings *config.PredeclaredSettings) *goanalysis.Linter {
- a := predeclared.Analyzer
-
- var cfg map[string]map[string]any
- if settings != nil {
- cfg = map[string]map[string]any{
- a.Name: {
- predeclared.IgnoreFlag: settings.Ignore,
- predeclared.QualifiedFlag: settings.Qualified,
- },
- }
- }
-
- return goanalysis.NewLinter(a.Name, a.Doc, []*analysis.Analyzer{a}, cfg).
- WithLoadMode(goanalysis.LoadModeSyntax)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/promlinter/promlinter.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/promlinter/promlinter.go
deleted file mode 100644
index 5decbbc7c3..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/promlinter/promlinter.go
+++ /dev/null
@@ -1,77 +0,0 @@
-package promlinter
-
-import (
- "fmt"
- "sync"
-
- "github.com/yeya24/promlinter"
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/goanalysis"
- "github.com/golangci/golangci-lint/pkg/lint/linter"
- "github.com/golangci/golangci-lint/pkg/result"
-)
-
-const linterName = "promlinter"
-
-func New(settings *config.PromlinterSettings) *goanalysis.Linter {
- var mu sync.Mutex
- var resIssues []goanalysis.Issue
-
- var promSettings promlinter.Setting
- if settings != nil {
- promSettings = promlinter.Setting{
- Strict: settings.Strict,
- DisabledLintFuncs: settings.DisabledLinters,
- }
- }
-
- analyzer := &analysis.Analyzer{
- Name: linterName,
- Doc: goanalysis.TheOnlyanalyzerDoc,
- Run: func(pass *analysis.Pass) (any, error) {
- issues := runPromLinter(pass, promSettings)
-
- if len(issues) == 0 {
- return nil, nil
- }
-
- mu.Lock()
- resIssues = append(resIssues, issues...)
- mu.Unlock()
-
- return nil, nil
- },
- }
-
- return goanalysis.NewLinter(
- linterName,
- "Check Prometheus metrics naming via promlint",
- []*analysis.Analyzer{analyzer},
- nil,
- ).WithIssuesReporter(func(*linter.Context) []goanalysis.Issue {
- return resIssues
- }).WithLoadMode(goanalysis.LoadModeSyntax)
-}
-
-func runPromLinter(pass *analysis.Pass, promSettings promlinter.Setting) []goanalysis.Issue {
- lintIssues := promlinter.RunLint(pass.Fset, pass.Files, promSettings)
-
- if len(lintIssues) == 0 {
- return nil
- }
-
- issues := make([]goanalysis.Issue, len(lintIssues))
- for k, i := range lintIssues {
- issue := result.Issue{
- Pos: i.Pos,
- Text: fmt.Sprintf("Metric: %s Error: %s", i.Metric, i.Text),
- FromLinter: linterName,
- }
-
- issues[k] = goanalysis.NewIssue(&issue, pass)
- }
-
- return issues
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/protogetter/protogetter.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/protogetter/protogetter.go
deleted file mode 100644
index 423e4ca9ef..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/protogetter/protogetter.go
+++ /dev/null
@@ -1,30 +0,0 @@
-package protogetter
-
-import (
- "github.com/ghostiam/protogetter"
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/goanalysis"
-)
-
-func New(settings *config.ProtoGetterSettings) *goanalysis.Linter {
- var cfg protogetter.Config
- if settings != nil {
- cfg = protogetter.Config{
- SkipGeneratedBy: settings.SkipGeneratedBy,
- SkipFiles: settings.SkipFiles,
- SkipAnyGenerated: settings.SkipAnyGenerated,
- ReplaceFirstArgInAppend: settings.ReplaceFirstArgInAppend,
- }
- }
-
- a := protogetter.NewAnalyzer(&cfg)
-
- return goanalysis.NewLinter(
- a.Name,
- a.Doc,
- []*analysis.Analyzer{a},
- nil,
- ).WithLoadMode(goanalysis.LoadModeTypesInfo)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/reassign/reassign.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/reassign/reassign.go
deleted file mode 100644
index cfc85635e2..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/reassign/reassign.go
+++ /dev/null
@@ -1,32 +0,0 @@
-package reassign
-
-import (
- "fmt"
- "strings"
-
- "github.com/curioswitch/go-reassign"
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/goanalysis"
-)
-
-func New(settings *config.ReassignSettings) *goanalysis.Linter {
- a := reassign.NewAnalyzer()
-
- var cfg map[string]map[string]any
- if settings != nil && len(settings.Patterns) > 0 {
- cfg = map[string]map[string]any{
- a.Name: {
- reassign.FlagPattern: fmt.Sprintf("^(%s)$", strings.Join(settings.Patterns, "|")),
- },
- }
- }
-
- return goanalysis.NewLinter(
- a.Name,
- a.Doc,
- []*analysis.Analyzer{a},
- cfg,
- ).WithLoadMode(goanalysis.LoadModeTypesInfo)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/recvcheck/recvcheck.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/recvcheck/recvcheck.go
deleted file mode 100644
index 3af4885b40..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/recvcheck/recvcheck.go
+++ /dev/null
@@ -1,27 +0,0 @@
-package recvcheck
-
-import (
- "github.com/raeperd/recvcheck"
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/goanalysis"
-)
-
-func New(settings *config.RecvcheckSettings) *goanalysis.Linter {
- var cfg recvcheck.Settings
-
- if settings != nil {
- cfg.DisableBuiltin = settings.DisableBuiltin
- cfg.Exclusions = settings.Exclusions
- }
-
- a := recvcheck.NewAnalyzer(cfg)
-
- return goanalysis.NewLinter(
- a.Name,
- a.Doc,
- []*analysis.Analyzer{a},
- nil,
- ).WithLoadMode(goanalysis.LoadModeTypesInfo)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/revive/revive.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/revive/revive.go
deleted file mode 100644
index 460281287f..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/revive/revive.go
+++ /dev/null
@@ -1,489 +0,0 @@
-package revive
-
-import (
- "bytes"
- "cmp"
- "encoding/json"
- "fmt"
- "go/token"
- "os"
- "reflect"
- "slices"
- "strings"
- "sync"
-
- "github.com/BurntSushi/toml"
- hcversion "github.com/hashicorp/go-version"
- reviveConfig "github.com/mgechev/revive/config"
- "github.com/mgechev/revive/lint"
- "github.com/mgechev/revive/rule"
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/goanalysis"
- "github.com/golangci/golangci-lint/pkg/golinters/internal"
- "github.com/golangci/golangci-lint/pkg/lint/linter"
- "github.com/golangci/golangci-lint/pkg/logutils"
- "github.com/golangci/golangci-lint/pkg/result"
-)
-
-const linterName = "revive"
-
-var (
- debugf = logutils.Debug(logutils.DebugKeyRevive)
- isDebug = logutils.HaveDebugTag(logutils.DebugKeyRevive)
-)
-
-// jsonObject defines a JSON object of a failure
-type jsonObject struct {
- Severity lint.Severity
- lint.Failure `json:",inline"`
-}
-
-func New(settings *config.ReviveSettings) *goanalysis.Linter {
- var mu sync.Mutex
- var resIssues []goanalysis.Issue
-
- analyzer := &analysis.Analyzer{
- Name: goanalysis.TheOnlyAnalyzerName,
- Doc: goanalysis.TheOnlyanalyzerDoc,
- Run: goanalysis.DummyRun,
- }
-
- return goanalysis.NewLinter(
- linterName,
- "Fast, configurable, extensible, flexible, and beautiful linter for Go. Drop-in replacement of golint.",
- []*analysis.Analyzer{analyzer},
- nil,
- ).WithContextSetter(func(lintCtx *linter.Context) {
- w, err := newWrapper(settings)
- if err != nil {
- lintCtx.Log.Errorf("setup revive: %v", err)
- return
- }
-
- analyzer.Run = func(pass *analysis.Pass) (any, error) {
- issues, err := w.run(lintCtx, pass)
- if err != nil {
- return nil, err
- }
-
- if len(issues) == 0 {
- return nil, nil
- }
-
- mu.Lock()
- resIssues = append(resIssues, issues...)
- mu.Unlock()
-
- return nil, nil
- }
- }).WithIssuesReporter(func(*linter.Context) []goanalysis.Issue {
- return resIssues
- }).WithLoadMode(goanalysis.LoadModeSyntax)
-}
-
-type wrapper struct {
- revive lint.Linter
- formatter lint.Formatter
- lintingRules []lint.Rule
- conf *lint.Config
-}
-
-func newWrapper(settings *config.ReviveSettings) (*wrapper, error) {
- conf, err := getConfig(settings)
- if err != nil {
- return nil, err
- }
-
- displayRules(conf)
-
- conf.GoVersion, err = hcversion.NewVersion(settings.Go)
- if err != nil {
- return nil, err
- }
-
- formatter, err := reviveConfig.GetFormatter("json")
- if err != nil {
- return nil, err
- }
-
- lintingRules, err := reviveConfig.GetLintingRules(conf, []lint.Rule{})
- if err != nil {
- return nil, err
- }
-
- return &wrapper{
- revive: lint.New(os.ReadFile, settings.MaxOpenFiles),
- formatter: formatter,
- lintingRules: lintingRules,
- conf: conf,
- }, nil
-}
-
-func (w *wrapper) run(lintCtx *linter.Context, pass *analysis.Pass) ([]goanalysis.Issue, error) {
- packages := [][]string{internal.GetGoFileNames(pass)}
-
- failures, err := w.revive.Lint(packages, w.lintingRules, *w.conf)
- if err != nil {
- return nil, err
- }
-
- formatChan := make(chan lint.Failure)
- exitChan := make(chan bool)
-
- var output string
- go func() {
- output, err = w.formatter.Format(formatChan, *w.conf)
- if err != nil {
- lintCtx.Log.Errorf("Format error: %v", err)
- }
- exitChan <- true
- }()
-
- for f := range failures {
- if f.Confidence < w.conf.Confidence {
- continue
- }
-
- formatChan <- f
- }
-
- close(formatChan)
- <-exitChan
-
- var results []jsonObject
- err = json.Unmarshal([]byte(output), &results)
- if err != nil {
- return nil, err
- }
-
- var issues []goanalysis.Issue
- for i := range results {
- issues = append(issues, toIssue(pass, &results[i]))
- }
-
- return issues, nil
-}
-
-func toIssue(pass *analysis.Pass, object *jsonObject) goanalysis.Issue {
- lineRangeTo := object.Position.End.Line
- if object.RuleName == (&rule.ExportedRule{}).Name() {
- lineRangeTo = object.Position.Start.Line
- }
-
- issue := &result.Issue{
- Severity: string(object.Severity),
- Text: fmt.Sprintf("%s: %s", object.RuleName, object.Failure.Failure),
- Pos: token.Position{
- Filename: object.Position.Start.Filename,
- Line: object.Position.Start.Line,
- Offset: object.Position.Start.Offset,
- Column: object.Position.Start.Column,
- },
- LineRange: &result.Range{
- From: object.Position.Start.Line,
- To: lineRangeTo,
- },
- FromLinter: linterName,
- }
-
- if object.ReplacementLine != "" {
- f := pass.Fset.File(token.Pos(object.Position.Start.Offset))
-
- // Skip cgo files because the positions are wrong.
- if object.GetFilename() == f.Name() {
- issue.SuggestedFixes = []analysis.SuggestedFix{{
- TextEdits: []analysis.TextEdit{{
- Pos: f.LineStart(object.Position.Start.Line),
- End: goanalysis.EndOfLinePos(f, object.Position.End.Line),
- NewText: []byte(object.ReplacementLine),
- }},
- }}
- }
- }
-
- return goanalysis.NewIssue(issue, pass)
-}
-
-// This function mimics the GetConfig function of revive.
-// This allows to get default values and right types.
-// https://github.com/golangci/golangci-lint/issues/1745
-// https://github.com/mgechev/revive/blob/v1.6.0/config/config.go#L230
-// https://github.com/mgechev/revive/blob/v1.6.0/config/config.go#L182-L188
-func getConfig(cfg *config.ReviveSettings) (*lint.Config, error) {
- conf := defaultConfig()
-
- // Since the Go version is dynamic, this value must be neutralized in order to compare with a "zero value" of the configuration structure.
- zero := &config.ReviveSettings{Go: cfg.Go}
-
- if !reflect.DeepEqual(cfg, zero) {
- rawRoot := createConfigMap(cfg)
- buf := bytes.NewBuffer(nil)
-
- err := toml.NewEncoder(buf).Encode(rawRoot)
- if err != nil {
- return nil, fmt.Errorf("failed to encode configuration: %w", err)
- }
-
- conf = &lint.Config{}
- _, err = toml.NewDecoder(buf).Decode(conf)
- if err != nil {
- return nil, fmt.Errorf("failed to decode configuration: %w", err)
- }
- }
-
- normalizeConfig(conf)
-
- for k, r := range conf.Rules {
- err := r.Initialize()
- if err != nil {
- return nil, fmt.Errorf("error in config of rule %q: %w", k, err)
- }
- conf.Rules[k] = r
- }
-
- return conf, nil
-}
-
-func createConfigMap(cfg *config.ReviveSettings) map[string]any {
- rawRoot := map[string]any{
- "ignoreGeneratedHeader": cfg.IgnoreGeneratedHeader,
- "confidence": cfg.Confidence,
- "severity": cfg.Severity,
- "errorCode": cfg.ErrorCode,
- "warningCode": cfg.WarningCode,
- "enableAllRules": cfg.EnableAllRules,
- }
-
- rawDirectives := map[string]map[string]any{}
- for _, directive := range cfg.Directives {
- rawDirectives[directive.Name] = map[string]any{
- "severity": directive.Severity,
- }
- }
-
- if len(rawDirectives) > 0 {
- rawRoot["directive"] = rawDirectives
- }
-
- rawRules := map[string]map[string]any{}
- for _, s := range cfg.Rules {
- rawRules[s.Name] = map[string]any{
- "severity": s.Severity,
- "arguments": safeTomlSlice(s.Arguments),
- "disabled": s.Disabled,
- "exclude": s.Exclude,
- }
- }
-
- if len(rawRules) > 0 {
- rawRoot["rule"] = rawRules
- }
-
- return rawRoot
-}
-
-func safeTomlSlice(r []any) []any {
- if len(r) == 0 {
- return nil
- }
-
- if _, ok := r[0].(map[any]any); !ok {
- return r
- }
-
- var typed []any
- for _, elt := range r {
- item := map[string]any{}
- for k, v := range elt.(map[any]any) {
- item[k.(string)] = v
- }
-
- typed = append(typed, item)
- }
-
- return typed
-}
-
-// This element is not exported by revive, so we need copy the code.
-// Extracted from https://github.com/mgechev/revive/blob/v1.6.0/config/config.go#L16
-var defaultRules = []lint.Rule{
- &rule.VarDeclarationsRule{},
- &rule.PackageCommentsRule{},
- &rule.DotImportsRule{},
- &rule.BlankImportsRule{},
- &rule.ExportedRule{},
- &rule.VarNamingRule{},
- &rule.IndentErrorFlowRule{},
- &rule.RangeRule{},
- &rule.ErrorfRule{},
- &rule.ErrorNamingRule{},
- &rule.ErrorStringsRule{},
- &rule.ReceiverNamingRule{},
- &rule.IncrementDecrementRule{},
- &rule.ErrorReturnRule{},
- &rule.UnexportedReturnRule{},
- &rule.TimeNamingRule{},
- &rule.ContextKeysType{},
- &rule.ContextAsArgumentRule{},
- &rule.EmptyBlockRule{},
- &rule.SuperfluousElseRule{},
- &rule.UnusedParamRule{},
- &rule.UnreachableCodeRule{},
- &rule.RedefinesBuiltinIDRule{},
-}
-
-var allRules = append([]lint.Rule{
- &rule.ArgumentsLimitRule{},
- &rule.CyclomaticRule{},
- &rule.FileHeaderRule{},
- &rule.ConfusingNamingRule{},
- &rule.GetReturnRule{},
- &rule.ModifiesParamRule{},
- &rule.ConfusingResultsRule{},
- &rule.DeepExitRule{},
- &rule.AddConstantRule{},
- &rule.FlagParamRule{},
- &rule.UnnecessaryStmtRule{},
- &rule.StructTagRule{},
- &rule.ModifiesValRecRule{},
- &rule.ConstantLogicalExprRule{},
- &rule.BoolLiteralRule{},
- &rule.ImportsBlocklistRule{},
- &rule.FunctionResultsLimitRule{},
- &rule.MaxPublicStructsRule{},
- &rule.RangeValInClosureRule{},
- &rule.RangeValAddress{},
- &rule.WaitGroupByValueRule{},
- &rule.AtomicRule{},
- &rule.EmptyLinesRule{},
- &rule.LineLengthLimitRule{},
- &rule.CallToGCRule{},
- &rule.DuplicatedImportsRule{},
- &rule.ImportShadowingRule{},
- &rule.BareReturnRule{},
- &rule.UnusedReceiverRule{},
- &rule.UnhandledErrorRule{},
- &rule.CognitiveComplexityRule{},
- &rule.StringOfIntRule{},
- &rule.StringFormatRule{},
- &rule.EarlyReturnRule{},
- &rule.UnconditionalRecursionRule{},
- &rule.IdenticalBranchesRule{},
- &rule.DeferRule{},
- &rule.UnexportedNamingRule{},
- &rule.FunctionLength{},
- &rule.NestedStructs{},
- &rule.UselessBreak{},
- &rule.UncheckedTypeAssertionRule{},
- &rule.TimeEqualRule{},
- &rule.BannedCharsRule{},
- &rule.OptimizeOperandsOrderRule{},
- &rule.UseAnyRule{},
- &rule.DataRaceRule{},
- &rule.CommentSpacingsRule{},
- &rule.IfReturnRule{},
- &rule.RedundantImportAlias{},
- &rule.ImportAliasNamingRule{},
- &rule.EnforceMapStyleRule{},
- &rule.EnforceRepeatedArgTypeStyleRule{},
- &rule.EnforceSliceStyleRule{},
- &rule.MaxControlNestingRule{},
- &rule.CommentsDensityRule{},
- &rule.FileLengthLimitRule{},
- &rule.FilenameFormatRule{},
- &rule.RedundantBuildTagRule{},
- &rule.UseErrorsNewRule{},
-}, defaultRules...)
-
-const defaultConfidence = 0.8
-
-// This element is not exported by revive, so we need copy the code.
-// Extracted from https://github.com/mgechev/revive/blob/v1.5.0/config/config.go#L183
-func normalizeConfig(cfg *lint.Config) {
- // NOTE(ldez): this custom section for golangci-lint should be kept.
- // ---
- cfg.Confidence = cmp.Or(cfg.Confidence, defaultConfidence)
- cfg.Severity = cmp.Or(cfg.Severity, lint.SeverityWarning)
- // ---
-
- if len(cfg.Rules) == 0 {
- cfg.Rules = map[string]lint.RuleConfig{}
- }
- if cfg.EnableAllRules {
- // Add to the configuration all rules not yet present in it
- for _, r := range allRules {
- ruleName := r.Name()
- _, alreadyInConf := cfg.Rules[ruleName]
- if alreadyInConf {
- continue
- }
- // Add the rule with an empty conf for
- cfg.Rules[ruleName] = lint.RuleConfig{}
- }
- }
-
- severity := cfg.Severity
- if severity != "" {
- for k, v := range cfg.Rules {
- if v.Severity == "" {
- v.Severity = severity
- }
- cfg.Rules[k] = v
- }
- for k, v := range cfg.Directives {
- if v.Severity == "" {
- v.Severity = severity
- }
- cfg.Directives[k] = v
- }
- }
-}
-
-// This element is not exported by revive, so we need copy the code.
-// Extracted from https://github.com/mgechev/revive/blob/v1.5.0/config/config.go#L252
-func defaultConfig() *lint.Config {
- defaultConfig := lint.Config{
- Confidence: defaultConfidence,
- Severity: lint.SeverityWarning,
- Rules: map[string]lint.RuleConfig{},
- }
- for _, r := range defaultRules {
- defaultConfig.Rules[r.Name()] = lint.RuleConfig{}
- }
- return &defaultConfig
-}
-
-func displayRules(conf *lint.Config) {
- if !isDebug {
- return
- }
-
- var enabledRules []string
- for k, r := range conf.Rules {
- if !r.Disabled {
- enabledRules = append(enabledRules, k)
- }
- }
-
- slices.Sort(enabledRules)
-
- debugf("All available rules (%d): %s.", len(allRules), strings.Join(extractRulesName(allRules), ", "))
- debugf("Default rules (%d): %s.", len(allRules), strings.Join(extractRulesName(allRules), ", "))
- debugf("Enabled by config rules (%d): %s.", len(enabledRules), strings.Join(enabledRules, ", "))
-
- debugf("revive configuration: %#v", conf)
-}
-
-func extractRulesName(rules []lint.Rule) []string {
- var names []string
-
- for _, r := range rules {
- names = append(names, r.Name())
- }
-
- slices.Sort(names)
-
- return names
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/rowserrcheck/rowserrcheck.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/rowserrcheck/rowserrcheck.go
deleted file mode 100644
index 3fe8244673..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/rowserrcheck/rowserrcheck.go
+++ /dev/null
@@ -1,25 +0,0 @@
-package rowserrcheck
-
-import (
- "github.com/jingyugao/rowserrcheck/passes/rowserr"
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/goanalysis"
-)
-
-func New(settings *config.RowsErrCheckSettings) *goanalysis.Linter {
- var pkgs []string
- if settings != nil {
- pkgs = settings.Packages
- }
-
- a := rowserr.NewAnalyzer(pkgs...)
-
- return goanalysis.NewLinter(
- a.Name,
- "checks whether Rows.Err of rows is checked successfully",
- []*analysis.Analyzer{a},
- nil,
- ).WithLoadMode(goanalysis.LoadModeTypesInfo)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/sloglint/sloglint.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/sloglint/sloglint.go
deleted file mode 100644
index 4866625779..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/sloglint/sloglint.go
+++ /dev/null
@@ -1,33 +0,0 @@
-package sloglint
-
-import (
- "go-simpler.org/sloglint"
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/goanalysis"
-)
-
-func New(settings *config.SlogLintSettings) *goanalysis.Linter {
- var opts *sloglint.Options
- if settings != nil {
- opts = &sloglint.Options{
- NoMixedArgs: settings.NoMixedArgs,
- KVOnly: settings.KVOnly,
- AttrOnly: settings.AttrOnly,
- NoGlobal: settings.NoGlobal,
- ContextOnly: settings.Context,
- StaticMsg: settings.StaticMsg,
- NoRawKeys: settings.NoRawKeys,
- KeyNamingCase: settings.KeyNamingCase,
- ForbiddenKeys: settings.ForbiddenKeys,
- ArgsOnSepLines: settings.ArgsOnSepLines,
- }
- }
-
- a := sloglint.New(opts)
-
- return goanalysis.
- NewLinter(a.Name, a.Doc, []*analysis.Analyzer{a}, nil).
- WithLoadMode(goanalysis.LoadModeTypesInfo)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/spancheck/spancheck.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/spancheck/spancheck.go
deleted file mode 100644
index efdc1d0bf6..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/spancheck/spancheck.go
+++ /dev/null
@@ -1,33 +0,0 @@
-package spancheck
-
-import (
- "github.com/jjti/go-spancheck"
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/goanalysis"
-)
-
-func New(settings *config.SpancheckSettings) *goanalysis.Linter {
- cfg := spancheck.NewDefaultConfig()
-
- if settings != nil {
- if len(settings.Checks) > 0 {
- cfg.EnabledChecks = settings.Checks
- }
-
- if len(settings.IgnoreCheckSignatures) > 0 {
- cfg.IgnoreChecksSignaturesSlice = settings.IgnoreCheckSignatures
- }
-
- if len(settings.ExtraStartSpanSignatures) > 0 {
- cfg.StartSpanMatchersSlice = append(cfg.StartSpanMatchersSlice, settings.ExtraStartSpanSignatures...)
- }
- }
-
- a := spancheck.NewAnalyzerWithConfig(cfg)
-
- return goanalysis.
- NewLinter(a.Name, a.Doc, []*analysis.Analyzer{a}, nil).
- WithLoadMode(goanalysis.LoadModeTypesInfo)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/sqlclosecheck/sqlclosecheck.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/sqlclosecheck/sqlclosecheck.go
deleted file mode 100644
index 5eb32ff9db..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/sqlclosecheck/sqlclosecheck.go
+++ /dev/null
@@ -1,19 +0,0 @@
-package sqlclosecheck
-
-import (
- "github.com/ryanrolds/sqlclosecheck/pkg/analyzer"
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/goanalysis"
-)
-
-func New() *goanalysis.Linter {
- a := analyzer.NewAnalyzer()
-
- return goanalysis.NewLinter(
- a.Name,
- a.Doc,
- []*analysis.Analyzer{a},
- nil,
- ).WithLoadMode(goanalysis.LoadModeTypesInfo)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/staticcheck/staticcheck.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/staticcheck/staticcheck.go
deleted file mode 100644
index 79394bdb7f..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/staticcheck/staticcheck.go
+++ /dev/null
@@ -1,22 +0,0 @@
-package staticcheck
-
-import (
- "honnef.co/go/tools/staticcheck"
-
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/goanalysis"
- "github.com/golangci/golangci-lint/pkg/golinters/internal"
-)
-
-func New(settings *config.StaticCheckSettings) *goanalysis.Linter {
- cfg := internal.StaticCheckConfig(settings)
- analyzers := internal.SetupStaticCheckAnalyzers(staticcheck.Analyzers, cfg.Checks)
-
- return goanalysis.NewLinter(
- "staticcheck",
- "It's a set of rules from staticcheck. It's not the same thing as the staticcheck binary."+
- " The author of staticcheck doesn't support or approve the use of staticcheck as a library inside golangci-lint.",
- analyzers,
- nil,
- ).WithLoadMode(goanalysis.LoadModeTypesInfo)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/stylecheck/stylecheck.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/stylecheck/stylecheck.go
deleted file mode 100644
index 60859f28af..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/stylecheck/stylecheck.go
+++ /dev/null
@@ -1,31 +0,0 @@
-package stylecheck
-
-import (
- "golang.org/x/tools/go/analysis"
- scconfig "honnef.co/go/tools/config"
- "honnef.co/go/tools/stylecheck"
-
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/goanalysis"
- "github.com/golangci/golangci-lint/pkg/golinters/internal"
-)
-
-func New(settings *config.StaticCheckSettings) *goanalysis.Linter {
- cfg := internal.StaticCheckConfig(settings)
-
- // `scconfig.Analyzer` is a singleton, then it's not possible to have more than one instance for all staticcheck "sub-linters".
- // When we will merge the 4 "sub-linters", the problem will disappear: https://github.com/golangci/golangci-lint/issues/357
- // Currently only stylecheck analyzer has a configuration in staticcheck.
- scconfig.Analyzer.Run = func(_ *analysis.Pass) (any, error) {
- return cfg, nil
- }
-
- analyzers := internal.SetupStaticCheckAnalyzers(stylecheck.Analyzers, cfg.Checks)
-
- return goanalysis.NewLinter(
- "stylecheck",
- "Stylecheck is a replacement for golint",
- analyzers,
- nil,
- ).WithLoadMode(goanalysis.LoadModeTypesInfo)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/tagalign/tagalign.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/tagalign/tagalign.go
deleted file mode 100644
index 7c8a0c8b02..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/tagalign/tagalign.go
+++ /dev/null
@@ -1,35 +0,0 @@
-package tagalign
-
-import (
- "github.com/4meepo/tagalign"
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/goanalysis"
-)
-
-func New(settings *config.TagAlignSettings) *goanalysis.Linter {
- var options []tagalign.Option
-
- if settings != nil {
- options = append(options, tagalign.WithAlign(settings.Align))
-
- if settings.Sort || len(settings.Order) > 0 {
- options = append(options, tagalign.WithSort(settings.Order...))
- }
-
- // Strict style will be applied only if Align and Sort are enabled together.
- if settings.Strict && settings.Align && settings.Sort {
- options = append(options, tagalign.WithStrictStyle())
- }
- }
-
- analyzer := tagalign.NewAnalyzer(options...)
-
- return goanalysis.NewLinter(
- analyzer.Name,
- analyzer.Doc,
- []*analysis.Analyzer{analyzer},
- nil,
- ).WithLoadMode(goanalysis.LoadModeSyntax)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/tagliatelle/tagliatelle.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/tagliatelle/tagliatelle.go
deleted file mode 100644
index 08215c3a53..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/tagliatelle/tagliatelle.go
+++ /dev/null
@@ -1,67 +0,0 @@
-package tagliatelle
-
-import (
- "github.com/ldez/tagliatelle"
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/goanalysis"
-)
-
-func New(settings *config.TagliatelleSettings) *goanalysis.Linter {
- cfg := tagliatelle.Config{
- Base: tagliatelle.Base{
- Rules: map[string]string{
- "json": "camel",
- "yaml": "camel",
- "header": "header",
- },
- },
- }
-
- if settings != nil {
- for k, v := range settings.Case.Rules {
- cfg.Rules[k] = v
- }
-
- cfg.ExtendedRules = toExtendedRules(settings.Case.ExtendedRules)
- cfg.UseFieldName = settings.Case.UseFieldName
- cfg.IgnoredFields = settings.Case.IgnoredFields
-
- for _, override := range settings.Case.Overrides {
- cfg.Overrides = append(cfg.Overrides, tagliatelle.Overrides{
- Base: tagliatelle.Base{
- Rules: override.Rules,
- ExtendedRules: toExtendedRules(override.ExtendedRules),
- UseFieldName: override.UseFieldName,
- IgnoredFields: override.IgnoredFields,
- Ignore: override.Ignore,
- },
- Package: override.Package,
- })
- }
- }
-
- a := tagliatelle.New(cfg)
-
- return goanalysis.NewLinter(
- a.Name,
- a.Doc,
- []*analysis.Analyzer{a},
- nil,
- ).WithLoadMode(goanalysis.LoadModeTypesInfo)
-}
-
-func toExtendedRules(src map[string]config.TagliatelleExtendedRule) map[string]tagliatelle.ExtendedRule {
- result := make(map[string]tagliatelle.ExtendedRule, len(src))
-
- for k, v := range src {
- result[k] = tagliatelle.ExtendedRule{
- Case: v.Case,
- ExtraInitialisms: v.ExtraInitialisms,
- InitialismOverrides: v.InitialismOverrides,
- }
- }
-
- return result
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/tenv/tenv.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/tenv/tenv.go
deleted file mode 100644
index 2fc247fab8..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/tenv/tenv.go
+++ /dev/null
@@ -1,29 +0,0 @@
-package tenv
-
-import (
- "github.com/sivchari/tenv"
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/goanalysis"
-)
-
-func New(settings *config.TenvSettings) *goanalysis.Linter {
- a := tenv.Analyzer
-
- var cfg map[string]map[string]any
- if settings != nil {
- cfg = map[string]map[string]any{
- a.Name: {
- tenv.A: settings.All,
- },
- }
- }
-
- return goanalysis.NewLinter(
- a.Name,
- a.Doc,
- []*analysis.Analyzer{a},
- cfg,
- ).WithLoadMode(goanalysis.LoadModeTypesInfo)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/testableexamples/testableexamples.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/testableexamples/testableexamples.go
deleted file mode 100644
index 6b76271dba..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/testableexamples/testableexamples.go
+++ /dev/null
@@ -1,19 +0,0 @@
-package testableexamples
-
-import (
- "github.com/maratori/testableexamples/pkg/testableexamples"
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/goanalysis"
-)
-
-func New() *goanalysis.Linter {
- a := testableexamples.NewAnalyzer()
-
- return goanalysis.NewLinter(
- a.Name,
- a.Doc,
- []*analysis.Analyzer{a},
- nil,
- ).WithLoadMode(goanalysis.LoadModeSyntax)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/testifylint/testifylint.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/testifylint/testifylint.go
deleted file mode 100644
index b3f2f0bd46..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/testifylint/testifylint.go
+++ /dev/null
@@ -1,51 +0,0 @@
-package testifylint
-
-import (
- "github.com/Antonboom/testifylint/analyzer"
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/goanalysis"
-)
-
-func New(settings *config.TestifylintSettings) *goanalysis.Linter {
- a := analyzer.New()
-
- cfg := make(map[string]map[string]any)
- if settings != nil {
- cfg[a.Name] = map[string]any{
- "enable-all": settings.EnableAll,
- "disable-all": settings.DisableAll,
-
- "bool-compare.ignore-custom-types": settings.BoolCompare.IgnoreCustomTypes,
- "formatter.require-f-funcs": settings.Formatter.RequireFFuncs,
- "go-require.ignore-http-handlers": settings.GoRequire.IgnoreHTTPHandlers,
- }
- if len(settings.EnabledCheckers) > 0 {
- cfg[a.Name]["enable"] = settings.EnabledCheckers
- }
- if len(settings.DisabledCheckers) > 0 {
- cfg[a.Name]["disable"] = settings.DisabledCheckers
- }
-
- if b := settings.Formatter.CheckFormatString; b != nil {
- cfg[a.Name]["formatter.check-format-string"] = *b
- }
- if p := settings.ExpectedActual.ExpVarPattern; p != "" {
- cfg[a.Name]["expected-actual.pattern"] = p
- }
- if p := settings.RequireError.FnPattern; p != "" {
- cfg[a.Name]["require-error.fn-pattern"] = p
- }
- if m := settings.SuiteExtraAssertCall.Mode; m != "" {
- cfg[a.Name]["suite-extra-assert-call.mode"] = m
- }
- }
-
- return goanalysis.NewLinter(
- a.Name,
- a.Doc,
- []*analysis.Analyzer{a},
- cfg,
- ).WithLoadMode(goanalysis.LoadModeTypesInfo)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/testpackage/testpackage.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/testpackage/testpackage.go
deleted file mode 100644
index f617da5536..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/testpackage/testpackage.go
+++ /dev/null
@@ -1,28 +0,0 @@
-package testpackage
-
-import (
- "strings"
-
- "github.com/maratori/testpackage/pkg/testpackage"
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/goanalysis"
-)
-
-func New(settings *config.TestpackageSettings) *goanalysis.Linter {
- a := testpackage.NewAnalyzer()
-
- var cfg map[string]map[string]any
- if settings != nil {
- cfg = map[string]map[string]any{
- a.Name: {
- testpackage.SkipRegexpFlagName: settings.SkipRegexp,
- testpackage.AllowPackagesFlagName: strings.Join(settings.AllowPackages, ","),
- },
- }
- }
-
- return goanalysis.NewLinter(a.Name, a.Doc, []*analysis.Analyzer{a}, cfg).
- WithLoadMode(goanalysis.LoadModeSyntax)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/thelper/thelper.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/thelper/thelper.go
deleted file mode 100644
index 04503b9ce0..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/thelper/thelper.go
+++ /dev/null
@@ -1,82 +0,0 @@
-package thelper
-
-import (
- "maps"
- "slices"
- "strings"
-
- "github.com/kulti/thelper/pkg/analyzer"
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/goanalysis"
- "github.com/golangci/golangci-lint/pkg/golinters/internal"
-)
-
-func New(settings *config.ThelperSettings) *goanalysis.Linter {
- a := analyzer.NewAnalyzer()
-
- opts := map[string]struct{}{
- "t_name": {},
- "t_begin": {},
- "t_first": {},
-
- "f_name": {},
- "f_begin": {},
- "f_first": {},
-
- "b_name": {},
- "b_begin": {},
- "b_first": {},
-
- "tb_name": {},
- "tb_begin": {},
- "tb_first": {},
- }
-
- if settings != nil {
- applyTHelperOptions(settings.Test, "t_", opts)
- applyTHelperOptions(settings.Fuzz, "f_", opts)
- applyTHelperOptions(settings.Benchmark, "b_", opts)
- applyTHelperOptions(settings.TB, "tb_", opts)
- }
-
- if len(opts) == 0 {
- internal.LinterLogger.Fatalf("thelper: at least one option must be enabled")
- }
-
- args := slices.Collect(maps.Keys(opts))
-
- cfg := map[string]map[string]any{
- a.Name: {
- "checks": strings.Join(args, ","),
- },
- }
-
- return goanalysis.NewLinter(
- a.Name,
- a.Doc,
- []*analysis.Analyzer{a},
- cfg,
- ).WithLoadMode(goanalysis.LoadModeTypesInfo)
-}
-
-func applyTHelperOptions(o config.ThelperOptions, prefix string, opts map[string]struct{}) {
- if o.Name != nil {
- if !*o.Name {
- delete(opts, prefix+"name")
- }
- }
-
- if o.Begin != nil {
- if !*o.Begin {
- delete(opts, prefix+"begin")
- }
- }
-
- if o.First != nil {
- if !*o.First {
- delete(opts, prefix+"first")
- }
- }
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/tparallel/tparallel.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/tparallel/tparallel.go
deleted file mode 100644
index 4f7c43a99d..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/tparallel/tparallel.go
+++ /dev/null
@@ -1,18 +0,0 @@
-package tparallel
-
-import (
- "github.com/moricho/tparallel"
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/goanalysis"
-)
-
-func New() *goanalysis.Linter {
- a := tparallel.Analyzer
- return goanalysis.NewLinter(
- a.Name,
- a.Doc,
- []*analysis.Analyzer{a},
- nil,
- ).WithLoadMode(goanalysis.LoadModeTypesInfo)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/typecheck.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/typecheck.go
deleted file mode 100644
index d0eaa00d0c..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/typecheck.go
+++ /dev/null
@@ -1,24 +0,0 @@
-package golinters
-
-import (
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/goanalysis"
-)
-
-func NewTypecheck() *goanalysis.Linter {
- const linterName = "typecheck"
-
- analyzer := &analysis.Analyzer{
- Name: linterName,
- Doc: goanalysis.TheOnlyanalyzerDoc,
- Run: goanalysis.DummyRun,
- }
-
- return goanalysis.NewLinter(
- linterName,
- "Like the front-end of a Go compiler, parses and type-checks Go code",
- []*analysis.Analyzer{analyzer},
- nil,
- ).WithLoadMode(goanalysis.LoadModeNone)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/unconvert/unconvert.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/unconvert/unconvert.go
deleted file mode 100644
index 954cc9eb34..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/unconvert/unconvert.go
+++ /dev/null
@@ -1,62 +0,0 @@
-package unconvert
-
-import (
- "sync"
-
- "github.com/golangci/unconvert"
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/goanalysis"
- "github.com/golangci/golangci-lint/pkg/lint/linter"
- "github.com/golangci/golangci-lint/pkg/result"
-)
-
-const linterName = "unconvert"
-
-func New(settings *config.UnconvertSettings) *goanalysis.Linter {
- var mu sync.Mutex
- var resIssues []goanalysis.Issue
-
- analyzer := &analysis.Analyzer{
- Name: linterName,
- Doc: goanalysis.TheOnlyanalyzerDoc,
- Run: func(pass *analysis.Pass) (any, error) {
- issues := runUnconvert(pass, settings)
-
- if len(issues) == 0 {
- return nil, nil
- }
-
- mu.Lock()
- resIssues = append(resIssues, issues...)
- mu.Unlock()
-
- return nil, nil
- },
- }
-
- return goanalysis.NewLinter(
- linterName,
- "Remove unnecessary type conversions",
- []*analysis.Analyzer{analyzer},
- nil,
- ).WithIssuesReporter(func(*linter.Context) []goanalysis.Issue {
- return resIssues
- }).WithLoadMode(goanalysis.LoadModeTypesInfo)
-}
-
-func runUnconvert(pass *analysis.Pass, settings *config.UnconvertSettings) []goanalysis.Issue {
- positions := unconvert.Run(pass, settings.FastMath, settings.Safe)
-
- var issues []goanalysis.Issue
- for _, position := range positions {
- issues = append(issues, goanalysis.NewIssue(&result.Issue{
- Pos: position,
- Text: "unnecessary conversion",
- FromLinter: linterName,
- }, pass))
- }
-
- return issues
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/unparam/unparam.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/unparam/unparam.go
deleted file mode 100644
index 04c9a223e5..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/unparam/unparam.go
+++ /dev/null
@@ -1,72 +0,0 @@
-package unparam
-
-import (
- "golang.org/x/tools/go/analysis"
- "golang.org/x/tools/go/analysis/passes/buildssa"
- "golang.org/x/tools/go/packages"
- "mvdan.cc/unparam/check"
-
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/goanalysis"
- "github.com/golangci/golangci-lint/pkg/lint/linter"
-)
-
-const linterName = "unparam"
-
-func New(settings *config.UnparamSettings) *goanalysis.Linter {
- analyzer := &analysis.Analyzer{
- Name: linterName,
- Doc: goanalysis.TheOnlyanalyzerDoc,
- Requires: []*analysis.Analyzer{buildssa.Analyzer},
- Run: func(pass *analysis.Pass) (any, error) {
- err := runUnparam(pass, settings)
- if err != nil {
- return nil, err
- }
-
- return nil, nil
- },
- }
-
- return goanalysis.NewLinter(
- linterName,
- "Reports unused function parameters",
- []*analysis.Analyzer{analyzer},
- nil,
- ).WithContextSetter(func(lintCtx *linter.Context) {
- if settings.Algo != "cha" {
- lintCtx.Log.Warnf("`linters-settings.unparam.algo` isn't supported by the newest `unparam`")
- }
- }).WithLoadMode(goanalysis.LoadModeTypesInfo)
-}
-
-func runUnparam(pass *analysis.Pass, settings *config.UnparamSettings) error {
- ssa := pass.ResultOf[buildssa.Analyzer].(*buildssa.SSA)
- ssaPkg := ssa.Pkg
-
- pkg := &packages.Package{
- Fset: pass.Fset,
- Syntax: pass.Files,
- Types: pass.Pkg,
- TypesInfo: pass.TypesInfo,
- }
-
- c := &check.Checker{}
- c.CheckExportedFuncs(settings.CheckExported)
- c.Packages([]*packages.Package{pkg})
- c.ProgramSSA(ssaPkg.Prog)
-
- unparamIssues, err := c.Check()
- if err != nil {
- return err
- }
-
- for _, i := range unparamIssues {
- pass.Report(analysis.Diagnostic{
- Pos: i.Pos(),
- Message: i.Message(),
- })
- }
-
- return nil
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/usestdlibvars/usestdlibvars.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/usestdlibvars/usestdlibvars.go
deleted file mode 100644
index 00f7d9742a..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/usestdlibvars/usestdlibvars.go
+++ /dev/null
@@ -1,38 +0,0 @@
-package usestdlibvars
-
-import (
- "github.com/sashamelentyev/usestdlibvars/pkg/analyzer"
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/goanalysis"
-)
-
-func New(settings *config.UseStdlibVarsSettings) *goanalysis.Linter {
- a := analyzer.New()
-
- cfg := make(map[string]map[string]any)
- if settings != nil {
- cfg[a.Name] = map[string]any{
- analyzer.ConstantKindFlag: settings.ConstantKind,
- analyzer.CryptoHashFlag: settings.CryptoHash,
- analyzer.HTTPMethodFlag: settings.HTTPMethod,
- analyzer.HTTPStatusCodeFlag: settings.HTTPStatusCode,
- analyzer.OSDevNullFlag: settings.OSDevNull != nil && *settings.OSDevNull,
- analyzer.RPCDefaultPathFlag: settings.DefaultRPCPath,
- analyzer.SQLIsolationLevelFlag: settings.SQLIsolationLevel,
- analyzer.SyslogPriorityFlag: settings.SyslogPriority != nil && *settings.SyslogPriority,
- analyzer.TimeLayoutFlag: settings.TimeLayout,
- analyzer.TimeMonthFlag: settings.TimeMonth,
- analyzer.TimeWeekdayFlag: settings.TimeWeekday,
- analyzer.TLSSignatureSchemeFlag: settings.TLSSignatureScheme,
- }
- }
-
- return goanalysis.NewLinter(
- a.Name,
- a.Doc,
- []*analysis.Analyzer{a},
- cfg,
- ).WithLoadMode(goanalysis.LoadModeSyntax)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/usetesting/usetesting.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/usetesting/usetesting.go
deleted file mode 100644
index a21742fbd6..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/usetesting/usetesting.go
+++ /dev/null
@@ -1,33 +0,0 @@
-package usetesting
-
-import (
- "github.com/ldez/usetesting"
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/goanalysis"
-)
-
-func New(settings *config.UseTestingSettings) *goanalysis.Linter {
- a := usetesting.NewAnalyzer()
-
- cfg := make(map[string]map[string]any)
- if settings != nil {
- cfg[a.Name] = map[string]any{
- "contextbackground": settings.ContextBackground,
- "contexttodo": settings.ContextTodo,
- "oschdir": settings.OSChdir,
- "osmkdirtemp": settings.OSMkdirTemp,
- "ossetenv": settings.OSSetenv,
- "ostempdir": settings.OSTempDir,
- "oscreatetemp": settings.OSCreateTemp,
- }
- }
-
- return goanalysis.NewLinter(
- a.Name,
- a.Doc,
- []*analysis.Analyzer{a},
- cfg,
- ).WithLoadMode(goanalysis.LoadModeTypesInfo)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/varnamelen/varnamelen.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/varnamelen/varnamelen.go
deleted file mode 100644
index 6cb57ffa57..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/varnamelen/varnamelen.go
+++ /dev/null
@@ -1,46 +0,0 @@
-package varnamelen
-
-import (
- "strconv"
- "strings"
-
- "github.com/blizzy78/varnamelen"
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/goanalysis"
-)
-
-func New(settings *config.VarnamelenSettings) *goanalysis.Linter {
- analyzer := varnamelen.NewAnalyzer()
- cfg := map[string]map[string]any{}
-
- if settings != nil {
- vnlCfg := map[string]any{
- "checkReceiver": strconv.FormatBool(settings.CheckReceiver),
- "checkReturn": strconv.FormatBool(settings.CheckReturn),
- "checkTypeParam": strconv.FormatBool(settings.CheckTypeParam),
- "ignoreNames": strings.Join(settings.IgnoreNames, ","),
- "ignoreTypeAssertOk": strconv.FormatBool(settings.IgnoreTypeAssertOk),
- "ignoreMapIndexOk": strconv.FormatBool(settings.IgnoreMapIndexOk),
- "ignoreChanRecvOk": strconv.FormatBool(settings.IgnoreChanRecvOk),
- "ignoreDecls": strings.Join(settings.IgnoreDecls, ","),
- }
-
- if settings.MaxDistance > 0 {
- vnlCfg["maxDistance"] = strconv.Itoa(settings.MaxDistance)
- }
- if settings.MinNameLength > 0 {
- vnlCfg["minNameLength"] = strconv.Itoa(settings.MinNameLength)
- }
-
- cfg[analyzer.Name] = vnlCfg
- }
-
- return goanalysis.NewLinter(
- analyzer.Name,
- "checks that the length of a variable's name matches its scope",
- []*analysis.Analyzer{analyzer},
- cfg,
- ).WithLoadMode(goanalysis.LoadModeTypesInfo)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/wastedassign/wastedassign.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/wastedassign/wastedassign.go
deleted file mode 100644
index 094fa95c29..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/wastedassign/wastedassign.go
+++ /dev/null
@@ -1,19 +0,0 @@
-package wastedassign
-
-import (
- "github.com/sanposhiho/wastedassign/v2"
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/goanalysis"
-)
-
-func New() *goanalysis.Linter {
- a := wastedassign.Analyzer
-
- return goanalysis.NewLinter(
- a.Name,
- "Finds wasted assignment statements",
- []*analysis.Analyzer{a},
- nil,
- ).WithLoadMode(goanalysis.LoadModeTypesInfo)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/whitespace/whitespace.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/whitespace/whitespace.go
deleted file mode 100644
index d45969efce..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/whitespace/whitespace.go
+++ /dev/null
@@ -1,28 +0,0 @@
-package whitespace
-
-import (
- "github.com/ultraware/whitespace"
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/goanalysis"
-)
-
-func New(settings *config.WhitespaceSettings) *goanalysis.Linter {
- var wsSettings whitespace.Settings
- if settings != nil {
- wsSettings = whitespace.Settings{
- MultiIf: settings.MultiIf,
- MultiFunc: settings.MultiFunc,
- }
- }
-
- a := whitespace.NewAnalyzer(&wsSettings)
-
- return goanalysis.NewLinter(
- a.Name,
- a.Doc,
- []*analysis.Analyzer{a},
- nil,
- ).WithLoadMode(goanalysis.LoadModeSyntax)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/wrapcheck/wrapcheck.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/wrapcheck/wrapcheck.go
deleted file mode 100644
index b2f5ec7420..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/wrapcheck/wrapcheck.go
+++ /dev/null
@@ -1,38 +0,0 @@
-package wrapcheck
-
-import (
- "github.com/tomarrell/wrapcheck/v2/wrapcheck"
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/goanalysis"
-)
-
-func New(settings *config.WrapcheckSettings) *goanalysis.Linter {
- cfg := wrapcheck.NewDefaultConfig()
- if settings != nil {
- cfg.ExtraIgnoreSigs = settings.ExtraIgnoreSigs
-
- if len(settings.IgnoreSigs) != 0 {
- cfg.IgnoreSigs = settings.IgnoreSigs
- }
- if len(settings.IgnoreSigRegexps) != 0 {
- cfg.IgnoreSigRegexps = settings.IgnoreSigRegexps
- }
- if len(settings.IgnorePackageGlobs) != 0 {
- cfg.IgnorePackageGlobs = settings.IgnorePackageGlobs
- }
- if len(settings.IgnoreInterfaceRegexps) != 0 {
- cfg.IgnoreInterfaceRegexps = settings.IgnoreInterfaceRegexps
- }
- }
-
- a := wrapcheck.NewAnalyzer(cfg)
-
- return goanalysis.NewLinter(
- a.Name,
- a.Doc,
- []*analysis.Analyzer{a},
- nil,
- ).WithLoadMode(goanalysis.LoadModeTypesInfo)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/wsl/wsl.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/wsl/wsl.go
deleted file mode 100644
index c728340ece..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/wsl/wsl.go
+++ /dev/null
@@ -1,40 +0,0 @@
-package wsl
-
-import (
- "github.com/bombsimon/wsl/v4"
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/goanalysis"
-)
-
-func New(settings *config.WSLSettings) *goanalysis.Linter {
- var conf *wsl.Configuration
- if settings != nil {
- conf = &wsl.Configuration{
- StrictAppend: settings.StrictAppend,
- AllowAssignAndCallCuddle: settings.AllowAssignAndCallCuddle,
- AllowAssignAndAnythingCuddle: settings.AllowAssignAndAnythingCuddle,
- AllowMultiLineAssignCuddle: settings.AllowMultiLineAssignCuddle,
- ForceCaseTrailingWhitespaceLimit: settings.ForceCaseTrailingWhitespaceLimit,
- AllowTrailingComment: settings.AllowTrailingComment,
- AllowSeparatedLeadingComment: settings.AllowSeparatedLeadingComment,
- AllowCuddleDeclaration: settings.AllowCuddleDeclaration,
- AllowCuddleWithCalls: settings.AllowCuddleWithCalls,
- AllowCuddleWithRHS: settings.AllowCuddleWithRHS,
- ForceCuddleErrCheckAndAssign: settings.ForceCuddleErrCheckAndAssign,
- ErrorVariableNames: settings.ErrorVariableNames,
- ForceExclusiveShortDeclarations: settings.ForceExclusiveShortDeclarations,
- IncludeGenerated: true, // force to true because golangci-lint already have a way to filter generated files.
- }
- }
-
- a := wsl.NewAnalyzer(conf)
-
- return goanalysis.NewLinter(
- a.Name,
- a.Doc,
- []*analysis.Analyzer{a},
- nil,
- ).WithLoadMode(goanalysis.LoadModeSyntax)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/zerologlint/zerologlint.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/zerologlint/zerologlint.go
deleted file mode 100644
index 6ca74020c8..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/zerologlint/zerologlint.go
+++ /dev/null
@@ -1,19 +0,0 @@
-package zerologlint
-
-import (
- "github.com/ykadowak/zerologlint"
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/goanalysis"
-)
-
-func New() *goanalysis.Linter {
- a := zerologlint.Analyzer
-
- return goanalysis.NewLinter(
- a.Name,
- a.Doc,
- []*analysis.Analyzer{a},
- nil,
- ).WithLoadMode(goanalysis.LoadModeTypesInfo)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/goutil/env.go b/vendor/github.com/golangci/golangci-lint/pkg/goutil/env.go
deleted file mode 100644
index beb71f722e..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/goutil/env.go
+++ /dev/null
@@ -1,49 +0,0 @@
-package goutil
-
-import (
- "context"
- "fmt"
- "os"
- "time"
-
- "github.com/ldez/grignotin/goenv"
-
- "github.com/golangci/golangci-lint/pkg/logutils"
-)
-
-type EnvKey string
-
-type Env struct {
- vars map[string]string
- log logutils.Log
-}
-
-func NewEnv(log logutils.Log) *Env {
- return &Env{
- vars: map[string]string{},
- log: log,
- }
-}
-
-func (e Env) Discover(ctx context.Context) error {
- startedAt := time.Now()
-
- var err error
- e.vars, err = goenv.Get(ctx, goenv.GOCACHE, goenv.GOROOT)
- if err != nil {
- return fmt.Errorf("%w", err)
- }
-
- e.log.Infof("Read go env for %s: %#v", time.Since(startedAt), e.vars)
-
- return nil
-}
-
-func (e Env) Get(k EnvKey) string {
- envValue := os.Getenv(string(k))
- if envValue != "" {
- return envValue
- }
-
- return e.vars[string(k)]
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/goutil/version.go b/vendor/github.com/golangci/golangci-lint/pkg/goutil/version.go
deleted file mode 100644
index 4f42ebd1bf..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/goutil/version.go
+++ /dev/null
@@ -1,75 +0,0 @@
-package goutil
-
-import (
- "fmt"
- "go/version"
- "regexp"
- "runtime"
- "strings"
-
- hcversion "github.com/hashicorp/go-version"
-)
-
-func CheckGoVersion(goVersion string) error {
- rv, err := CleanRuntimeVersion()
- if err != nil {
- return fmt.Errorf("clean runtime version: %w", err)
- }
-
- langVersion := version.Lang(rv)
-
- runtimeVersion, err := hcversion.NewVersion(strings.TrimPrefix(langVersion, "go"))
- if err != nil {
- return err
- }
-
- targetedVersion, err := hcversion.NewVersion(TrimGoVersion(goVersion))
- if err != nil {
- return err
- }
-
- if runtimeVersion.LessThan(targetedVersion) {
- return fmt.Errorf("the Go language version (%s) used to build golangci-lint is lower than the targeted Go version (%s)",
- langVersion, goVersion)
- }
-
- return nil
-}
-
-// TrimGoVersion Trims the Go version to keep only M.m.
-// Since Go 1.21 the version inside the go.mod can be a patched version (ex: 1.21.0).
-// The version can also include information which we want to remove (ex: 1.21alpha1)
-// https://go.dev/doc/toolchain#versions
-// This a problem with staticcheck and gocritic.
-func TrimGoVersion(v string) string {
- if v == "" {
- return ""
- }
-
- exp := regexp.MustCompile(`(\d\.\d+)(?:\.\d+|[a-z]+\d)`)
-
- if exp.MatchString(v) {
- return exp.FindStringSubmatch(v)[1]
- }
-
- return v
-}
-
-func CleanRuntimeVersion() (string, error) {
- return cleanRuntimeVersion(runtime.Version())
-}
-
-func cleanRuntimeVersion(rv string) (string, error) {
- parts := strings.Fields(rv)
-
- for _, part := range parts {
- // Allow to handle:
- // - GOEXPERIMENT -> "go1.23.0 X:boringcrypto"
- // - devel -> "devel go1.24-e705a2d Wed Aug 7 01:16:42 2024 +0000 linux/amd64"
- if strings.HasPrefix(part, "go1.") {
- return part, nil
- }
- }
-
- return "", fmt.Errorf("invalid Go runtime version: %s", rv)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/lint/context.go b/vendor/github.com/golangci/golangci-lint/pkg/lint/context.go
deleted file mode 100644
index 2ac5a2d2c4..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/lint/context.go
+++ /dev/null
@@ -1,60 +0,0 @@
-package lint
-
-import (
- "context"
- "fmt"
-
- "github.com/golangci/golangci-lint/internal/cache"
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/exitcodes"
- "github.com/golangci/golangci-lint/pkg/goanalysis/load"
- "github.com/golangci/golangci-lint/pkg/lint/linter"
- "github.com/golangci/golangci-lint/pkg/logutils"
-)
-
-type ContextBuilder struct {
- cfg *config.Config
-
- pkgLoader *PackageLoader
-
- pkgCache *cache.Cache
-
- loadGuard *load.Guard
-}
-
-func NewContextBuilder(cfg *config.Config, pkgLoader *PackageLoader,
- pkgCache *cache.Cache, loadGuard *load.Guard,
-) *ContextBuilder {
- return &ContextBuilder{
- cfg: cfg,
- pkgLoader: pkgLoader,
- pkgCache: pkgCache,
- loadGuard: loadGuard,
- }
-}
-
-func (cl *ContextBuilder) Build(ctx context.Context, log logutils.Log, linters []*linter.Config) (*linter.Context, error) {
- pkgs, deduplicatedPkgs, err := cl.pkgLoader.Load(ctx, linters)
- if err != nil {
- return nil, fmt.Errorf("failed to load packages: %w", err)
- }
-
- if len(deduplicatedPkgs) == 0 {
- return nil, fmt.Errorf("%w: running `go mod tidy` may solve the problem", exitcodes.ErrNoGoFiles)
- }
-
- ret := &linter.Context{
- Packages: deduplicatedPkgs,
-
- // At least `unused` linters works properly only on original (not deduplicated) packages,
- // see https://github.com/golangci/golangci-lint/pull/585.
- OriginalPackages: pkgs,
-
- Cfg: cl.cfg,
- Log: log,
- PkgCache: cl.pkgCache,
- LoadGuard: cl.loadGuard,
- }
-
- return ret, nil
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/lint/linter/config.go b/vendor/github.com/golangci/golangci-lint/pkg/lint/linter/config.go
deleted file mode 100644
index 20bed6a711..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/lint/linter/config.go
+++ /dev/null
@@ -1,185 +0,0 @@
-package linter
-
-import (
- "fmt"
-
- "golang.org/x/tools/go/packages"
-
- "github.com/golangci/golangci-lint/pkg/config"
-)
-
-const (
- PresetBugs = "bugs" // Related to bugs detection.
- PresetComment = "comment" // Related to comments analysis.
- PresetComplexity = "complexity" // Related to code complexity analysis.
- PresetError = "error" // Related to error handling analysis.
- PresetFormatting = "format" // Related to code formatting.
- PresetImport = "import" // Related to imports analysis.
- PresetMetaLinter = "metalinter" // Related to linter that contains multiple rules or multiple linters.
- PresetModule = "module" // Related to Go modules analysis.
- PresetPerformance = "performance" // Related to performance.
- PresetSQL = "sql" // Related to SQL.
- PresetStyle = "style" // Related to coding style.
- PresetTest = "test" // Related to the analysis of the code of the tests.
- PresetUnused = "unused" // Related to the detection of unused code.
-)
-
-// LastLinter nolintlint must be last because it looks at the results of all the previous linters for unused nolint directives.
-const LastLinter = "nolintlint"
-
-type DeprecationLevel int
-
-const (
- DeprecationNone DeprecationLevel = iota
- DeprecationWarning
- DeprecationError
-)
-
-type Deprecation struct {
- Since string
- Message string
- Replacement string
- Level DeprecationLevel
-}
-
-type Config struct {
- Linter Linter
- EnabledByDefault bool
-
- LoadMode packages.LoadMode
-
- InPresets []string
- AlternativeNames []string
-
- OriginalURL string // URL of original (not forked) repo, needed for autogenerated README
- Internal bool // Internal linters cannot be disabled (ex: typecheck).
- CanAutoFix bool
- IsSlow bool
- DoesChangeTypes bool
-
- Since string
- Deprecation *Deprecation
-}
-
-func (lc *Config) WithEnabledByDefault() *Config {
- lc.EnabledByDefault = true
- return lc
-}
-
-func (lc *Config) WithInternal() *Config {
- lc.Internal = true
- return lc
-}
-
-func (lc *Config) ConsiderSlow() *Config {
- lc.IsSlow = true
- return lc
-}
-
-func (lc *Config) IsSlowLinter() bool {
- return lc.IsSlow
-}
-
-func (lc *Config) WithLoadFiles() *Config {
- lc.LoadMode |= packages.NeedName | packages.NeedFiles | packages.NeedCompiledGoFiles | packages.NeedModule
- return lc
-}
-
-func (lc *Config) WithLoadForGoAnalysis() *Config {
- lc = lc.WithLoadFiles()
- lc.LoadMode |= packages.NeedImports | packages.NeedDeps | packages.NeedExportFile | packages.NeedTypesSizes
- lc.IsSlow = true
- return lc
-}
-
-func (lc *Config) WithPresets(presets ...string) *Config {
- lc.InPresets = presets
- return lc
-}
-
-func (lc *Config) WithURL(url string) *Config {
- lc.OriginalURL = url
- return lc
-}
-
-func (lc *Config) WithAlternativeNames(names ...string) *Config {
- lc.AlternativeNames = names
- return lc
-}
-
-func (lc *Config) WithAutoFix() *Config {
- lc.CanAutoFix = true
- return lc
-}
-
-func (lc *Config) WithChangeTypes() *Config {
- lc.DoesChangeTypes = true
- return lc
-}
-
-func (lc *Config) WithSince(version string) *Config {
- lc.Since = version
- return lc
-}
-
-func (lc *Config) Deprecated(message, version, replacement string, level DeprecationLevel) *Config {
- lc.Deprecation = &Deprecation{
- Since: version,
- Message: message,
- Replacement: replacement,
- Level: level,
- }
- return lc
-}
-
-func (lc *Config) DeprecatedWarning(message, version, replacement string) *Config {
- return lc.Deprecated(message, version, replacement, DeprecationWarning)
-}
-
-func (lc *Config) DeprecatedError(message, version, replacement string) *Config {
- return lc.Deprecated(message, version, replacement, DeprecationError)
-}
-
-func (lc *Config) IsDeprecated() bool {
- return lc.Deprecation != nil
-}
-
-func (lc *Config) AllNames() []string {
- return append([]string{lc.Name()}, lc.AlternativeNames...)
-}
-
-func (lc *Config) Name() string {
- return lc.Linter.Name()
-}
-
-func (lc *Config) WithNoopFallback(cfg *config.Config, cond func(cfg *config.Config) error) *Config {
- if err := cond(cfg); err != nil {
- lc.Linter = NewNoop(lc.Linter, err.Error())
- lc.LoadMode = 0
-
- return lc.WithLoadFiles()
- }
-
- return lc
-}
-
-func IsGoLowerThanGo122() func(cfg *config.Config) error {
- return isGoLowerThanGo("1.22")
-}
-
-func isGoLowerThanGo(v string) func(cfg *config.Config) error {
- return func(cfg *config.Config) error {
- if cfg == nil || config.IsGoGreaterThanOrEqual(cfg.Run.Go, v) {
- return nil
- }
-
- return fmt.Errorf("this linter is disabled because the Go version (%s) of your project is lower than Go %s", cfg.Run.Go, v)
- }
-}
-
-func NewConfig(linter Linter) *Config {
- lc := &Config{
- Linter: linter,
- }
- return lc.WithLoadFiles()
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/lint/linter/context.go b/vendor/github.com/golangci/golangci-lint/pkg/lint/linter/context.go
deleted file mode 100644
index 6986b62314..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/lint/linter/context.go
+++ /dev/null
@@ -1,46 +0,0 @@
-package linter
-
-import (
- "go/ast"
-
- "golang.org/x/tools/go/packages"
-
- "github.com/golangci/golangci-lint/internal/cache"
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/goanalysis/load"
- "github.com/golangci/golangci-lint/pkg/logutils"
-)
-
-type Context struct {
- // Packages are deduplicated (test and normal packages) packages
- Packages []*packages.Package
-
- // OriginalPackages aren't deduplicated: they contain both normal and test
- // version for each of packages
- OriginalPackages []*packages.Package
-
- Cfg *config.Config
- Log logutils.Log
-
- PkgCache *cache.Cache
- LoadGuard *load.Guard
-}
-
-func (c *Context) Settings() *config.LintersSettings {
- return &c.Cfg.LintersSettings
-}
-
-func (c *Context) ClearTypesInPackages() {
- for _, p := range c.Packages {
- clearTypes(p)
- }
- for _, p := range c.OriginalPackages {
- clearTypes(p)
- }
-}
-
-func clearTypes(p *packages.Package) {
- p.Types = nil
- p.TypesInfo = nil
- p.Syntax = []*ast.File{}
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/lint/linter/linter.go b/vendor/github.com/golangci/golangci-lint/pkg/lint/linter/linter.go
deleted file mode 100644
index 088aa3d78b..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/lint/linter/linter.go
+++ /dev/null
@@ -1,67 +0,0 @@
-package linter
-
-import (
- "context"
-
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/result"
-)
-
-type Linter interface {
- Run(ctx context.Context, lintCtx *Context) ([]result.Issue, error)
- Name() string
- Desc() string
-}
-
-type Noop struct {
- name string
- desc string
- reason string
- level DeprecationLevel
-}
-
-func NewNoop(l Linter, reason string) Noop {
- return Noop{
- name: l.Name(),
- desc: l.Desc(),
- reason: reason,
- }
-}
-
-func NewNoopDeprecated(name string, cfg *config.Config, level DeprecationLevel) Noop {
- noop := Noop{
- name: name,
- desc: "Deprecated",
- reason: "This linter is fully inactivated: it will not produce any reports.",
- level: level,
- }
-
- if cfg.InternalCmdTest {
- noop.reason = ""
- }
-
- return noop
-}
-
-func (n Noop) Run(_ context.Context, lintCtx *Context) ([]result.Issue, error) {
- if n.reason == "" {
- return nil, nil
- }
-
- switch n.level {
- case DeprecationError:
- lintCtx.Log.Errorf("%s: %s", n.name, n.reason)
- default:
- lintCtx.Log.Warnf("%s: %s", n.name, n.reason)
- }
-
- return nil, nil
-}
-
-func (n Noop) Name() string {
- return n.name
-}
-
-func (n Noop) Desc() string {
- return n.desc
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/lint/lintersdb/builder_linter.go b/vendor/github.com/golangci/golangci-lint/pkg/lint/lintersdb/builder_linter.go
deleted file mode 100644
index ddeb99e144..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/lint/lintersdb/builder_linter.go
+++ /dev/null
@@ -1,893 +0,0 @@
-package lintersdb
-
-import (
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/golinters"
- "github.com/golangci/golangci-lint/pkg/golinters/asasalint"
- "github.com/golangci/golangci-lint/pkg/golinters/asciicheck"
- "github.com/golangci/golangci-lint/pkg/golinters/bidichk"
- "github.com/golangci/golangci-lint/pkg/golinters/bodyclose"
- "github.com/golangci/golangci-lint/pkg/golinters/canonicalheader"
- "github.com/golangci/golangci-lint/pkg/golinters/containedctx"
- "github.com/golangci/golangci-lint/pkg/golinters/contextcheck"
- "github.com/golangci/golangci-lint/pkg/golinters/copyloopvar"
- "github.com/golangci/golangci-lint/pkg/golinters/cyclop"
- "github.com/golangci/golangci-lint/pkg/golinters/decorder"
- "github.com/golangci/golangci-lint/pkg/golinters/depguard"
- "github.com/golangci/golangci-lint/pkg/golinters/dogsled"
- "github.com/golangci/golangci-lint/pkg/golinters/dupl"
- "github.com/golangci/golangci-lint/pkg/golinters/dupword"
- "github.com/golangci/golangci-lint/pkg/golinters/durationcheck"
- "github.com/golangci/golangci-lint/pkg/golinters/err113"
- "github.com/golangci/golangci-lint/pkg/golinters/errcheck"
- "github.com/golangci/golangci-lint/pkg/golinters/errchkjson"
- "github.com/golangci/golangci-lint/pkg/golinters/errname"
- "github.com/golangci/golangci-lint/pkg/golinters/errorlint"
- "github.com/golangci/golangci-lint/pkg/golinters/exhaustive"
- "github.com/golangci/golangci-lint/pkg/golinters/exhaustruct"
- "github.com/golangci/golangci-lint/pkg/golinters/exptostd"
- "github.com/golangci/golangci-lint/pkg/golinters/fatcontext"
- "github.com/golangci/golangci-lint/pkg/golinters/forbidigo"
- "github.com/golangci/golangci-lint/pkg/golinters/forcetypeassert"
- "github.com/golangci/golangci-lint/pkg/golinters/funlen"
- "github.com/golangci/golangci-lint/pkg/golinters/gci"
- "github.com/golangci/golangci-lint/pkg/golinters/ginkgolinter"
- "github.com/golangci/golangci-lint/pkg/golinters/gocheckcompilerdirectives"
- "github.com/golangci/golangci-lint/pkg/golinters/gochecknoglobals"
- "github.com/golangci/golangci-lint/pkg/golinters/gochecknoinits"
- "github.com/golangci/golangci-lint/pkg/golinters/gochecksumtype"
- "github.com/golangci/golangci-lint/pkg/golinters/gocognit"
- "github.com/golangci/golangci-lint/pkg/golinters/goconst"
- "github.com/golangci/golangci-lint/pkg/golinters/gocritic"
- "github.com/golangci/golangci-lint/pkg/golinters/gocyclo"
- "github.com/golangci/golangci-lint/pkg/golinters/godot"
- "github.com/golangci/golangci-lint/pkg/golinters/godox"
- "github.com/golangci/golangci-lint/pkg/golinters/gofmt"
- "github.com/golangci/golangci-lint/pkg/golinters/gofumpt"
- "github.com/golangci/golangci-lint/pkg/golinters/goheader"
- "github.com/golangci/golangci-lint/pkg/golinters/goimports"
- "github.com/golangci/golangci-lint/pkg/golinters/gomoddirectives"
- "github.com/golangci/golangci-lint/pkg/golinters/gomodguard"
- "github.com/golangci/golangci-lint/pkg/golinters/goprintffuncname"
- "github.com/golangci/golangci-lint/pkg/golinters/gosec"
- "github.com/golangci/golangci-lint/pkg/golinters/gosimple"
- "github.com/golangci/golangci-lint/pkg/golinters/gosmopolitan"
- "github.com/golangci/golangci-lint/pkg/golinters/govet"
- "github.com/golangci/golangci-lint/pkg/golinters/grouper"
- "github.com/golangci/golangci-lint/pkg/golinters/iface"
- "github.com/golangci/golangci-lint/pkg/golinters/importas"
- "github.com/golangci/golangci-lint/pkg/golinters/inamedparam"
- "github.com/golangci/golangci-lint/pkg/golinters/ineffassign"
- "github.com/golangci/golangci-lint/pkg/golinters/interfacebloat"
- "github.com/golangci/golangci-lint/pkg/golinters/intrange"
- "github.com/golangci/golangci-lint/pkg/golinters/ireturn"
- "github.com/golangci/golangci-lint/pkg/golinters/lll"
- "github.com/golangci/golangci-lint/pkg/golinters/loggercheck"
- "github.com/golangci/golangci-lint/pkg/golinters/maintidx"
- "github.com/golangci/golangci-lint/pkg/golinters/makezero"
- "github.com/golangci/golangci-lint/pkg/golinters/mirror"
- "github.com/golangci/golangci-lint/pkg/golinters/misspell"
- "github.com/golangci/golangci-lint/pkg/golinters/mnd"
- "github.com/golangci/golangci-lint/pkg/golinters/musttag"
- "github.com/golangci/golangci-lint/pkg/golinters/nakedret"
- "github.com/golangci/golangci-lint/pkg/golinters/nestif"
- "github.com/golangci/golangci-lint/pkg/golinters/nilerr"
- "github.com/golangci/golangci-lint/pkg/golinters/nilnesserr"
- "github.com/golangci/golangci-lint/pkg/golinters/nilnil"
- "github.com/golangci/golangci-lint/pkg/golinters/nlreturn"
- "github.com/golangci/golangci-lint/pkg/golinters/noctx"
- "github.com/golangci/golangci-lint/pkg/golinters/nolintlint"
- "github.com/golangci/golangci-lint/pkg/golinters/nonamedreturns"
- "github.com/golangci/golangci-lint/pkg/golinters/nosprintfhostport"
- "github.com/golangci/golangci-lint/pkg/golinters/paralleltest"
- "github.com/golangci/golangci-lint/pkg/golinters/perfsprint"
- "github.com/golangci/golangci-lint/pkg/golinters/prealloc"
- "github.com/golangci/golangci-lint/pkg/golinters/predeclared"
- "github.com/golangci/golangci-lint/pkg/golinters/promlinter"
- "github.com/golangci/golangci-lint/pkg/golinters/protogetter"
- "github.com/golangci/golangci-lint/pkg/golinters/reassign"
- "github.com/golangci/golangci-lint/pkg/golinters/recvcheck"
- "github.com/golangci/golangci-lint/pkg/golinters/revive"
- "github.com/golangci/golangci-lint/pkg/golinters/rowserrcheck"
- "github.com/golangci/golangci-lint/pkg/golinters/sloglint"
- "github.com/golangci/golangci-lint/pkg/golinters/spancheck"
- "github.com/golangci/golangci-lint/pkg/golinters/sqlclosecheck"
- "github.com/golangci/golangci-lint/pkg/golinters/staticcheck"
- "github.com/golangci/golangci-lint/pkg/golinters/stylecheck"
- "github.com/golangci/golangci-lint/pkg/golinters/tagalign"
- "github.com/golangci/golangci-lint/pkg/golinters/tagliatelle"
- "github.com/golangci/golangci-lint/pkg/golinters/tenv"
- "github.com/golangci/golangci-lint/pkg/golinters/testableexamples"
- "github.com/golangci/golangci-lint/pkg/golinters/testifylint"
- "github.com/golangci/golangci-lint/pkg/golinters/testpackage"
- "github.com/golangci/golangci-lint/pkg/golinters/thelper"
- "github.com/golangci/golangci-lint/pkg/golinters/tparallel"
- "github.com/golangci/golangci-lint/pkg/golinters/unconvert"
- "github.com/golangci/golangci-lint/pkg/golinters/unparam"
- "github.com/golangci/golangci-lint/pkg/golinters/unused"
- "github.com/golangci/golangci-lint/pkg/golinters/usestdlibvars"
- "github.com/golangci/golangci-lint/pkg/golinters/usetesting"
- "github.com/golangci/golangci-lint/pkg/golinters/varnamelen"
- "github.com/golangci/golangci-lint/pkg/golinters/wastedassign"
- "github.com/golangci/golangci-lint/pkg/golinters/whitespace"
- "github.com/golangci/golangci-lint/pkg/golinters/wrapcheck"
- "github.com/golangci/golangci-lint/pkg/golinters/wsl"
- "github.com/golangci/golangci-lint/pkg/golinters/zerologlint"
- "github.com/golangci/golangci-lint/pkg/lint/linter"
-)
-
-// LinterBuilder builds the "internal" linters based on the configuration.
-type LinterBuilder struct{}
-
-// NewLinterBuilder creates a new LinterBuilder.
-func NewLinterBuilder() *LinterBuilder {
- return &LinterBuilder{}
-}
-
-// Build loads all the "internal" linters.
-// The configuration is use for the linter settings.
-func (LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) {
- if cfg == nil {
- return nil, nil
- }
-
- const megacheckName = "megacheck"
-
- // The linters are sorted in the alphabetical order (case-insensitive).
- // When a new linter is added the version in `WithSince(...)` must be the next minor version of golangci-lint.
- return []*linter.Config{
- linter.NewConfig(asasalint.New(&cfg.LintersSettings.Asasalint)).
- WithSince("v1.47.0").
- WithPresets(linter.PresetBugs).
- WithLoadForGoAnalysis().
- WithURL("https://github.com/alingse/asasalint"),
-
- linter.NewConfig(asciicheck.New()).
- WithSince("v1.26.0").
- WithPresets(linter.PresetBugs, linter.PresetStyle).
- WithURL("https://github.com/tdakkota/asciicheck"),
-
- linter.NewConfig(bidichk.New(&cfg.LintersSettings.BiDiChk)).
- WithSince("v1.43.0").
- WithPresets(linter.PresetBugs).
- WithURL("https://github.com/breml/bidichk"),
-
- linter.NewConfig(bodyclose.New()).
- WithSince("v1.18.0").
- WithLoadForGoAnalysis().
- WithPresets(linter.PresetPerformance, linter.PresetBugs).
- WithURL("https://github.com/timakin/bodyclose"),
-
- linter.NewConfig(canonicalheader.New()).
- WithSince("v1.58.0").
- WithPresets(linter.PresetStyle).
- WithLoadForGoAnalysis().
- WithAutoFix().
- WithURL("https://github.com/lasiar/canonicalheader"),
-
- linter.NewConfig(containedctx.New()).
- WithSince("v1.44.0").
- WithLoadForGoAnalysis().
- WithPresets(linter.PresetStyle).
- WithURL("https://github.com/sivchari/containedctx"),
-
- linter.NewConfig(contextcheck.New()).
- WithSince("v1.43.0").
- WithPresets(linter.PresetBugs).
- WithLoadForGoAnalysis().
- WithURL("https://github.com/kkHAIKE/contextcheck"),
-
- linter.NewConfig(copyloopvar.New(&cfg.LintersSettings.CopyLoopVar)).
- WithSince("v1.57.0").
- WithPresets(linter.PresetStyle).
- WithAutoFix().
- WithURL("https://github.com/karamaru-alpha/copyloopvar").
- WithNoopFallback(cfg, linter.IsGoLowerThanGo122()),
-
- linter.NewConfig(cyclop.New(&cfg.LintersSettings.Cyclop)).
- WithSince("v1.37.0").
- WithPresets(linter.PresetComplexity).
- WithURL("https://github.com/bkielbasa/cyclop"),
-
- linter.NewConfig(decorder.New(&cfg.LintersSettings.Decorder)).
- WithSince("v1.44.0").
- WithPresets(linter.PresetStyle).
- WithURL("https://gitlab.com/bosi/decorder"),
-
- linter.NewConfig(linter.NewNoopDeprecated("deadcode", cfg, linter.DeprecationError)).
- WithSince("v1.0.0").
- WithPresets(linter.PresetUnused).
- WithURL("https://github.com/remyoudompheng/go-misc/tree/HEAD/deadcode").
- DeprecatedError("The owner seems to have abandoned the linter.", "v1.49.0", "unused"),
-
- linter.NewConfig(depguard.New(&cfg.LintersSettings.Depguard, cfg.GetBasePath())).
- WithSince("v1.4.0").
- WithPresets(linter.PresetStyle, linter.PresetImport, linter.PresetModule).
- WithURL("https://github.com/OpenPeeDeeP/depguard"),
-
- linter.NewConfig(dogsled.New(&cfg.LintersSettings.Dogsled)).
- WithSince("v1.19.0").
- WithPresets(linter.PresetStyle).
- WithURL("https://github.com/alexkohler/dogsled"),
-
- linter.NewConfig(dupl.New(&cfg.LintersSettings.Dupl)).
- WithSince("v1.0.0").
- WithPresets(linter.PresetStyle).
- WithURL("https://github.com/mibk/dupl"),
-
- linter.NewConfig(dupword.New(&cfg.LintersSettings.DupWord)).
- WithSince("v1.50.0").
- WithPresets(linter.PresetComment).
- WithAutoFix().
- WithURL("https://github.com/Abirdcfly/dupword"),
-
- linter.NewConfig(durationcheck.New()).
- WithSince("v1.37.0").
- WithPresets(linter.PresetBugs).
- WithLoadForGoAnalysis().
- WithURL("https://github.com/charithe/durationcheck"),
-
- linter.NewConfig(errcheck.New(&cfg.LintersSettings.Errcheck)).
- WithEnabledByDefault().
- WithSince("v1.0.0").
- WithLoadForGoAnalysis().
- WithPresets(linter.PresetBugs, linter.PresetError).
- WithURL("https://github.com/kisielk/errcheck"),
-
- linter.NewConfig(errchkjson.New(&cfg.LintersSettings.ErrChkJSON)).
- WithSince("v1.44.0").
- WithPresets(linter.PresetBugs).
- WithLoadForGoAnalysis().
- WithURL("https://github.com/breml/errchkjson"),
-
- linter.NewConfig(errname.New()).
- WithSince("v1.42.0").
- WithPresets(linter.PresetStyle).
- WithLoadForGoAnalysis().
- WithURL("https://github.com/Antonboom/errname"),
-
- linter.NewConfig(errorlint.New(&cfg.LintersSettings.ErrorLint)).
- WithSince("v1.32.0").
- WithPresets(linter.PresetBugs, linter.PresetError).
- WithLoadForGoAnalysis().
- WithAutoFix().
- WithURL("https://github.com/polyfloyd/go-errorlint"),
-
- linter.NewConfig(linter.NewNoopDeprecated("execinquery", cfg, linter.DeprecationError)).
- WithSince("v1.46.0").
- WithPresets(linter.PresetSQL).
- WithURL("https://github.com/1uf3/execinquery").
- DeprecatedError("The repository of the linter has been archived by the owner.", "v1.58.0", ""),
-
- linter.NewConfig(exhaustive.New(&cfg.LintersSettings.Exhaustive)).
- WithSince(" v1.28.0").
- WithPresets(linter.PresetBugs).
- WithLoadForGoAnalysis().
- WithURL("https://github.com/nishanths/exhaustive"),
-
- linter.NewConfig(linter.NewNoopDeprecated("exhaustivestruct", cfg, linter.DeprecationError)).
- WithSince("v1.32.0").
- WithPresets(linter.PresetStyle, linter.PresetTest).
- WithURL("https://github.com/mbilski/exhaustivestruct").
- DeprecatedError("The repository of the linter has been deprecated by the owner.", "v1.46.0", "exhaustruct"),
-
- linter.NewConfig(exhaustruct.New(&cfg.LintersSettings.Exhaustruct)).
- WithSince("v1.46.0").
- WithPresets(linter.PresetStyle, linter.PresetTest).
- WithLoadForGoAnalysis().
- WithURL("https://github.com/GaijinEntertainment/go-exhaustruct"),
-
- linter.NewConfig(linter.NewNoopDeprecated("exportloopref", cfg, linter.DeprecationError)).
- WithSince("v1.28.0").
- WithPresets(linter.PresetBugs).
- WithLoadForGoAnalysis().
- WithURL("https://github.com/kyoh86/exportloopref").
- DeprecatedError("Since Go1.22 (loopvar) this linter is no longer relevant.", "v1.60.2", "copyloopvar"),
-
- linter.NewConfig(exptostd.New()).
- WithSince("v1.63.0").
- WithPresets(linter.PresetStyle).
- WithLoadForGoAnalysis().
- WithAutoFix().
- WithURL("https://github.com/ldez/exptostd"),
-
- linter.NewConfig(forbidigo.New(&cfg.LintersSettings.Forbidigo)).
- WithSince("v1.34.0").
- WithPresets(linter.PresetStyle).
- // Strictly speaking,
- // the additional information is only needed when forbidigoCfg.AnalyzeTypes is chosen by the user.
- // But we don't know that here in all cases (sometimes config is not loaded),
- // so we have to assume that it is needed to be on the safe side.
- WithLoadForGoAnalysis().
- WithURL("https://github.com/ashanbrown/forbidigo"),
-
- linter.NewConfig(forcetypeassert.New()).
- WithSince("v1.38.0").
- WithPresets(linter.PresetStyle).
- WithLoadForGoAnalysis().
- WithURL("https://github.com/gostaticanalysis/forcetypeassert"),
-
- linter.NewConfig(fatcontext.New(&cfg.LintersSettings.Fatcontext)).
- WithSince("v1.58.0").
- WithPresets(linter.PresetPerformance).
- WithLoadForGoAnalysis().
- WithAutoFix().
- WithURL("https://github.com/Crocmagnon/fatcontext"),
-
- linter.NewConfig(funlen.New(&cfg.LintersSettings.Funlen)).
- WithSince("v1.18.0").
- WithPresets(linter.PresetComplexity).
- WithURL("https://github.com/ultraware/funlen"),
-
- linter.NewConfig(gci.New(&cfg.LintersSettings.Gci)).
- WithSince("v1.30.0").
- WithPresets(linter.PresetFormatting, linter.PresetImport).
- WithAutoFix().
- WithURL("https://github.com/daixiang0/gci"),
-
- linter.NewConfig(ginkgolinter.New(&cfg.LintersSettings.GinkgoLinter)).
- WithSince("v1.51.0").
- WithLoadForGoAnalysis().
- WithPresets(linter.PresetStyle).
- WithAutoFix().
- WithURL("https://github.com/nunnatsa/ginkgolinter"),
-
- linter.NewConfig(gocheckcompilerdirectives.New()).
- WithSince("v1.51.0").
- WithPresets(linter.PresetBugs).
- WithURL("https://github.com/leighmcculloch/gocheckcompilerdirectives"),
-
- linter.NewConfig(gochecknoglobals.New()).
- WithSince("v1.12.0").
- WithPresets(linter.PresetStyle).
- WithLoadForGoAnalysis().
- WithURL("https://github.com/leighmcculloch/gochecknoglobals"),
-
- linter.NewConfig(gochecknoinits.New()).
- WithSince("v1.12.0").
- WithPresets(linter.PresetStyle),
-
- linter.NewConfig(gochecksumtype.New(&cfg.LintersSettings.GoChecksumType)).
- WithSince("v1.55.0").
- WithPresets(linter.PresetBugs).
- WithLoadForGoAnalysis().
- WithURL("https://github.com/alecthomas/go-check-sumtype"),
-
- linter.NewConfig(gocognit.New(&cfg.LintersSettings.Gocognit)).
- WithSince("v1.20.0").
- WithPresets(linter.PresetComplexity).
- WithURL("https://github.com/uudashr/gocognit"),
-
- linter.NewConfig(goconst.New(&cfg.LintersSettings.Goconst)).
- WithSince("v1.0.0").
- WithPresets(linter.PresetStyle).
- WithURL("https://github.com/jgautheron/goconst"),
-
- linter.NewConfig(gocritic.New(&cfg.LintersSettings.Gocritic)).
- WithSince("v1.12.0").
- WithPresets(linter.PresetStyle, linter.PresetMetaLinter).
- WithLoadForGoAnalysis().
- WithAutoFix().
- WithURL("https://github.com/go-critic/go-critic"),
-
- linter.NewConfig(gocyclo.New(&cfg.LintersSettings.Gocyclo)).
- WithSince("v1.0.0").
- WithPresets(linter.PresetComplexity).
- WithURL("https://github.com/fzipp/gocyclo"),
-
- linter.NewConfig(godot.New(&cfg.LintersSettings.Godot)).
- WithSince("v1.25.0").
- WithPresets(linter.PresetStyle, linter.PresetComment).
- WithAutoFix().
- WithURL("https://github.com/tetafro/godot"),
-
- linter.NewConfig(godox.New(&cfg.LintersSettings.Godox)).
- WithSince("v1.19.0").
- WithPresets(linter.PresetStyle, linter.PresetComment).
- WithURL("https://github.com/matoous/godox"),
-
- linter.NewConfig(err113.New()).
- WithSince("v1.26.0").
- WithPresets(linter.PresetStyle, linter.PresetError).
- WithLoadForGoAnalysis().
- WithAlternativeNames("goerr113").
- WithAutoFix().
- WithURL("https://github.com/Djarvur/go-err113"),
-
- linter.NewConfig(gofmt.New(&cfg.LintersSettings.Gofmt)).
- WithSince("v1.0.0").
- WithPresets(linter.PresetFormatting).
- WithAutoFix().
- WithURL("https://pkg.go.dev/cmd/gofmt"),
-
- linter.NewConfig(gofumpt.New(&cfg.LintersSettings.Gofumpt)).
- WithSince("v1.28.0").
- WithPresets(linter.PresetFormatting).
- WithAutoFix().
- WithURL("https://github.com/mvdan/gofumpt"),
-
- linter.NewConfig(goheader.New(&cfg.LintersSettings.Goheader, cfg.GetBasePath())).
- WithSince("v1.28.0").
- WithPresets(linter.PresetStyle).
- WithAutoFix().
- WithURL("https://github.com/denis-tingaikin/go-header"),
-
- linter.NewConfig(goimports.New(&cfg.LintersSettings.Goimports)).
- WithSince("v1.20.0").
- WithPresets(linter.PresetFormatting, linter.PresetImport).
- WithAutoFix().
- WithURL("https://pkg.go.dev/golang.org/x/tools/cmd/goimports"),
-
- linter.NewConfig(linter.NewNoopDeprecated("golint", cfg, linter.DeprecationError)).
- WithSince("v1.0.0").
- WithPresets(linter.PresetStyle).
- WithURL("https://github.com/golang/lint").
- DeprecatedError("The repository of the linter has been archived by the owner.", "v1.41.0", "revive"),
-
- linter.NewConfig(mnd.New(&cfg.LintersSettings.Mnd)).
- WithSince("v1.22.0").
- WithPresets(linter.PresetStyle).
- WithURL("https://github.com/tommy-muehle/go-mnd"),
-
- linter.NewConfig(linter.NewNoopDeprecated("gomnd", cfg, linter.DeprecationError)).
- WithSince("v1.22.0").
- WithPresets(linter.PresetStyle).
- WithURL("https://github.com/tommy-muehle/go-mnd").
- DeprecatedError("The linter has been renamed.", "v1.58.0", "mnd"),
-
- linter.NewConfig(gomoddirectives.New(&cfg.LintersSettings.GoModDirectives)).
- WithSince("v1.39.0").
- WithPresets(linter.PresetStyle, linter.PresetModule).
- WithURL("https://github.com/ldez/gomoddirectives"),
-
- linter.NewConfig(gomodguard.New(&cfg.LintersSettings.Gomodguard)).
- WithSince("v1.25.0").
- WithPresets(linter.PresetStyle, linter.PresetImport, linter.PresetModule).
- WithURL("https://github.com/ryancurrah/gomodguard"),
-
- linter.NewConfig(goprintffuncname.New()).
- WithSince("v1.23.0").
- WithPresets(linter.PresetStyle).
- WithURL("https://github.com/golangci/go-printf-func-name"),
-
- linter.NewConfig(gosec.New(&cfg.LintersSettings.Gosec)).
- WithSince("v1.0.0").
- WithLoadForGoAnalysis().
- WithPresets(linter.PresetBugs).
- WithURL("https://github.com/securego/gosec").
- WithAlternativeNames("gas"),
-
- linter.NewConfig(gosimple.New(&cfg.LintersSettings.Gosimple)).
- WithEnabledByDefault().
- WithSince("v1.20.0").
- WithLoadForGoAnalysis().
- WithPresets(linter.PresetStyle).
- WithAlternativeNames(megacheckName).
- WithAutoFix().
- WithURL("https://github.com/dominikh/go-tools/tree/HEAD/simple"),
-
- linter.NewConfig(gosmopolitan.New(&cfg.LintersSettings.Gosmopolitan)).
- WithSince("v1.53.0").
- WithLoadForGoAnalysis().
- WithPresets(linter.PresetBugs).
- WithURL("https://github.com/xen0n/gosmopolitan"),
-
- linter.NewConfig(govet.New(&cfg.LintersSettings.Govet)).
- WithEnabledByDefault().
- WithSince("v1.0.0").
- WithLoadForGoAnalysis().
- WithPresets(linter.PresetBugs, linter.PresetMetaLinter).
- WithAutoFix().
- WithAlternativeNames("vet", "vetshadow").
- WithURL("https://pkg.go.dev/cmd/vet"),
-
- linter.NewConfig(grouper.New(&cfg.LintersSettings.Grouper)).
- WithSince("v1.44.0").
- WithPresets(linter.PresetStyle).
- WithURL("https://github.com/leonklingele/grouper"),
-
- linter.NewConfig(linter.NewNoopDeprecated("ifshort", cfg, linter.DeprecationError)).
- WithSince("v1.36.0").
- WithPresets(linter.PresetStyle).
- WithURL("https://github.com/esimonov/ifshort").
- DeprecatedError("The repository of the linter has been deprecated by the owner.", "v1.48.0", ""),
-
- linter.NewConfig(iface.New(&cfg.LintersSettings.Iface)).
- WithSince("v1.62.0").
- WithLoadForGoAnalysis().
- WithPresets(linter.PresetStyle).
- WithAutoFix().
- WithURL("https://github.com/uudashr/iface"),
-
- linter.NewConfig(importas.New(&cfg.LintersSettings.ImportAs)).
- WithSince("v1.38.0").
- WithPresets(linter.PresetStyle).
- WithLoadForGoAnalysis().
- WithAutoFix().
- WithURL("https://github.com/julz/importas"),
-
- linter.NewConfig(inamedparam.New(&cfg.LintersSettings.Inamedparam)).
- WithSince("v1.55.0").
- WithPresets(linter.PresetStyle).
- WithURL("https://github.com/macabu/inamedparam"),
-
- linter.NewConfig(ineffassign.New()).
- WithEnabledByDefault().
- WithSince("v1.0.0").
- WithPresets(linter.PresetUnused).
- WithURL("https://github.com/gordonklaus/ineffassign"),
-
- linter.NewConfig(interfacebloat.New(&cfg.LintersSettings.InterfaceBloat)).
- WithSince("v1.49.0").
- WithPresets(linter.PresetStyle).
- WithURL("https://github.com/sashamelentyev/interfacebloat"),
-
- linter.NewConfig(linter.NewNoopDeprecated("interfacer", cfg, linter.DeprecationError)).
- WithSince("v1.0.0").
- WithPresets(linter.PresetStyle).
- WithURL("https://github.com/mvdan/interfacer").
- DeprecatedError("The repository of the linter has been archived by the owner.", "v1.38.0", ""),
-
- linter.NewConfig(intrange.New()).
- WithSince("v1.57.0").
- WithLoadForGoAnalysis().
- WithPresets(linter.PresetStyle).
- WithAutoFix().
- WithURL("https://github.com/ckaznocha/intrange").
- WithNoopFallback(cfg, linter.IsGoLowerThanGo122()),
-
- linter.NewConfig(ireturn.New(&cfg.LintersSettings.Ireturn)).
- WithSince("v1.43.0").
- WithPresets(linter.PresetStyle).
- WithLoadForGoAnalysis().
- WithURL("https://github.com/butuzov/ireturn"),
-
- linter.NewConfig(lll.New(&cfg.LintersSettings.Lll)).
- WithSince("v1.8.0").
- WithPresets(linter.PresetStyle),
-
- linter.NewConfig(loggercheck.New(&cfg.LintersSettings.LoggerCheck)).
- WithSince("v1.49.0").
- WithLoadForGoAnalysis().
- WithPresets(linter.PresetStyle, linter.PresetBugs).
- WithAlternativeNames("logrlint").
- WithURL("https://github.com/timonwong/loggercheck"),
-
- linter.NewConfig(maintidx.New(&cfg.LintersSettings.MaintIdx)).
- WithSince("v1.44.0").
- WithPresets(linter.PresetComplexity).
- WithURL("https://github.com/yagipy/maintidx"),
-
- linter.NewConfig(makezero.New(&cfg.LintersSettings.Makezero)).
- WithSince("v1.34.0").
- WithPresets(linter.PresetStyle, linter.PresetBugs).
- WithLoadForGoAnalysis().
- WithURL("https://github.com/ashanbrown/makezero"),
-
- linter.NewConfig(linter.NewNoopDeprecated("maligned", cfg, linter.DeprecationError)).
- WithSince("v1.0.0").
- WithPresets(linter.PresetPerformance).
- WithURL("https://github.com/mdempsky/maligned").
- DeprecatedError("The repository of the linter has been archived by the owner.", "v1.38.0", "govet 'fieldalignment'"),
-
- linter.NewConfig(mirror.New()).
- WithSince("v1.53.0").
- WithPresets(linter.PresetStyle).
- WithLoadForGoAnalysis().
- WithAutoFix().
- WithURL("https://github.com/butuzov/mirror"),
-
- linter.NewConfig(misspell.New(&cfg.LintersSettings.Misspell)).
- WithSince("v1.8.0").
- WithPresets(linter.PresetStyle, linter.PresetComment).
- WithAutoFix().
- WithURL("https://github.com/client9/misspell"),
-
- linter.NewConfig(musttag.New(&cfg.LintersSettings.MustTag)).
- WithSince("v1.51.0").
- WithLoadForGoAnalysis().
- WithPresets(linter.PresetStyle, linter.PresetBugs).
- WithURL("https://github.com/go-simpler/musttag"),
-
- linter.NewConfig(nakedret.New(&cfg.LintersSettings.Nakedret)).
- WithSince("v1.19.0").
- WithPresets(linter.PresetStyle).
- WithAutoFix().
- WithURL("https://github.com/alexkohler/nakedret"),
-
- linter.NewConfig(nestif.New(&cfg.LintersSettings.Nestif)).
- WithSince("v1.25.0").
- WithPresets(linter.PresetComplexity).
- WithURL("https://github.com/nakabonne/nestif"),
-
- linter.NewConfig(nilerr.New()).
- WithSince("v1.38.0").
- WithLoadForGoAnalysis().
- WithPresets(linter.PresetBugs).
- WithURL("https://github.com/gostaticanalysis/nilerr"),
-
- linter.NewConfig(nilnesserr.New()).
- WithSince("v1.63.0").
- WithLoadForGoAnalysis().
- WithPresets(linter.PresetBugs).
- WithURL("https://github.com/alingse/nilnesserr"),
-
- linter.NewConfig(nilnil.New(&cfg.LintersSettings.NilNil)).
- WithSince("v1.43.0").
- WithPresets(linter.PresetStyle).
- WithLoadForGoAnalysis().
- WithURL("https://github.com/Antonboom/nilnil"),
-
- linter.NewConfig(nlreturn.New(&cfg.LintersSettings.Nlreturn)).
- WithSince("v1.30.0").
- WithPresets(linter.PresetStyle).
- WithAutoFix().
- WithURL("https://github.com/ssgreg/nlreturn"),
-
- linter.NewConfig(noctx.New()).
- WithSince("v1.28.0").
- WithLoadForGoAnalysis().
- WithPresets(linter.PresetPerformance, linter.PresetBugs).
- WithURL("https://github.com/sonatard/noctx"),
-
- linter.NewConfig(nonamedreturns.New(&cfg.LintersSettings.NoNamedReturns)).
- WithSince("v1.46.0").
- WithLoadForGoAnalysis().
- WithPresets(linter.PresetStyle).
- WithURL("https://github.com/firefart/nonamedreturns"),
-
- linter.NewConfig(linter.NewNoopDeprecated("nosnakecase", cfg, linter.DeprecationError)).
- WithSince("v1.47.0").
- WithPresets(linter.PresetStyle).
- WithURL("https://github.com/sivchari/nosnakecase").
- DeprecatedError("The repository of the linter has been deprecated by the owner.", "v1.48.1", "revive 'var-naming'"),
-
- linter.NewConfig(nosprintfhostport.New()).
- WithSince("v1.46.0").
- WithPresets(linter.PresetStyle).
- WithURL("https://github.com/stbenjam/no-sprintf-host-port"),
-
- linter.NewConfig(paralleltest.New(&cfg.LintersSettings.ParallelTest)).
- WithSince("v1.33.0").
- WithLoadForGoAnalysis().
- WithPresets(linter.PresetStyle, linter.PresetTest).
- WithURL("https://github.com/kunwardeep/paralleltest"),
-
- linter.NewConfig(perfsprint.New(&cfg.LintersSettings.PerfSprint)).
- WithSince("v1.55.0").
- WithLoadForGoAnalysis().
- WithPresets(linter.PresetPerformance).
- WithAutoFix().
- WithURL("https://github.com/catenacyber/perfsprint"),
-
- linter.NewConfig(prealloc.New(&cfg.LintersSettings.Prealloc)).
- WithSince("v1.19.0").
- WithPresets(linter.PresetPerformance).
- WithURL("https://github.com/alexkohler/prealloc"),
-
- linter.NewConfig(predeclared.New(&cfg.LintersSettings.Predeclared)).
- WithSince("v1.35.0").
- WithPresets(linter.PresetStyle).
- WithURL("https://github.com/nishanths/predeclared"),
-
- linter.NewConfig(promlinter.New(&cfg.LintersSettings.Promlinter)).
- WithSince("v1.40.0").
- WithPresets(linter.PresetStyle).
- WithURL("https://github.com/yeya24/promlinter"),
-
- linter.NewConfig(protogetter.New(&cfg.LintersSettings.ProtoGetter)).
- WithSince("v1.55.0").
- WithPresets(linter.PresetBugs).
- WithLoadForGoAnalysis().
- WithAutoFix().
- WithURL("https://github.com/ghostiam/protogetter"),
-
- linter.NewConfig(reassign.New(&cfg.LintersSettings.Reassign)).
- WithSince("v1.49.0").
- WithPresets(linter.PresetBugs).
- WithLoadForGoAnalysis().
- WithURL("https://github.com/curioswitch/go-reassign"),
-
- linter.NewConfig(recvcheck.New(&cfg.LintersSettings.Recvcheck)).
- WithSince("v1.62.0").
- WithPresets(linter.PresetBugs).
- WithLoadForGoAnalysis().
- WithURL("https://github.com/raeperd/recvcheck"),
-
- linter.NewConfig(revive.New(&cfg.LintersSettings.Revive)).
- WithSince("v1.37.0").
- WithPresets(linter.PresetStyle, linter.PresetMetaLinter).
- ConsiderSlow().
- WithAutoFix().
- WithURL("https://github.com/mgechev/revive"),
-
- linter.NewConfig(rowserrcheck.New(&cfg.LintersSettings.RowsErrCheck)).
- WithSince("v1.23.0").
- WithLoadForGoAnalysis().
- WithPresets(linter.PresetBugs, linter.PresetSQL).
- WithURL("https://github.com/jingyugao/rowserrcheck"),
-
- linter.NewConfig(sloglint.New(&cfg.LintersSettings.SlogLint)).
- WithSince("v1.55.0").
- WithLoadForGoAnalysis().
- WithPresets(linter.PresetStyle).
- WithURL("https://github.com/go-simpler/sloglint"),
-
- linter.NewConfig(linter.NewNoopDeprecated("scopelint", cfg, linter.DeprecationError)).
- WithSince("v1.12.0").
- WithPresets(linter.PresetBugs).
- WithURL("https://github.com/kyoh86/scopelint").
- DeprecatedError("The repository of the linter has been deprecated by the owner.", "v1.39.0", "exportloopref"),
-
- linter.NewConfig(sqlclosecheck.New()).
- WithSince("v1.28.0").
- WithPresets(linter.PresetBugs, linter.PresetSQL).
- WithLoadForGoAnalysis().
- WithURL("https://github.com/ryanrolds/sqlclosecheck"),
-
- linter.NewConfig(spancheck.New(&cfg.LintersSettings.Spancheck)).
- WithSince("v1.56.0").
- WithLoadForGoAnalysis().
- WithPresets(linter.PresetBugs).
- WithURL("https://github.com/jjti/go-spancheck"),
-
- linter.NewConfig(staticcheck.New(&cfg.LintersSettings.Staticcheck)).
- WithEnabledByDefault().
- WithSince("v1.0.0").
- WithLoadForGoAnalysis().
- WithPresets(linter.PresetBugs, linter.PresetMetaLinter).
- WithAlternativeNames(megacheckName).
- WithAutoFix().
- WithURL("https://staticcheck.dev/"),
-
- linter.NewConfig(linter.NewNoopDeprecated("structcheck", cfg, linter.DeprecationError)).
- WithSince("v1.0.0").
- WithPresets(linter.PresetUnused).
- WithURL("https://github.com/opennota/check").
- DeprecatedError("The owner seems to have abandoned the linter.", "v1.49.0", "unused"),
-
- linter.NewConfig(stylecheck.New(&cfg.LintersSettings.Stylecheck)).
- WithSince("v1.20.0").
- WithLoadForGoAnalysis().
- WithPresets(linter.PresetStyle).
- WithAutoFix().
- WithURL("https://github.com/dominikh/go-tools/tree/HEAD/stylecheck"),
-
- linter.NewConfig(tagalign.New(&cfg.LintersSettings.TagAlign)).
- WithSince("v1.53.0").
- WithPresets(linter.PresetStyle).
- WithAutoFix().
- WithURL("https://github.com/4meepo/tagalign"),
-
- linter.NewConfig(tagliatelle.New(&cfg.LintersSettings.Tagliatelle)).
- WithSince("v1.40.0").
- WithPresets(linter.PresetStyle).
- WithLoadForGoAnalysis().
- WithURL("https://github.com/ldez/tagliatelle"),
-
- linter.NewConfig(tenv.New(&cfg.LintersSettings.Tenv)).
- WithSince("v1.43.0").
- WithPresets(linter.PresetTest).
- WithLoadForGoAnalysis().
- WithURL("https://github.com/sivchari/tenv").
- DeprecatedWarning("Duplicate feature in another linter.", "v1.64.0", "usetesting"),
-
- linter.NewConfig(testableexamples.New()).
- WithSince("v1.50.0").
- WithPresets(linter.PresetTest).
- WithURL("https://github.com/maratori/testableexamples"),
-
- linter.NewConfig(testifylint.New(&cfg.LintersSettings.Testifylint)).
- WithSince("v1.55.0").
- WithPresets(linter.PresetTest, linter.PresetBugs).
- WithLoadForGoAnalysis().
- WithAutoFix().
- WithURL("https://github.com/Antonboom/testifylint"),
-
- linter.NewConfig(testpackage.New(&cfg.LintersSettings.Testpackage)).
- WithSince("v1.25.0").
- WithPresets(linter.PresetStyle, linter.PresetTest).
- WithURL("https://github.com/maratori/testpackage"),
-
- linter.NewConfig(thelper.New(&cfg.LintersSettings.Thelper)).
- WithSince("v1.34.0").
- WithPresets(linter.PresetTest).
- WithLoadForGoAnalysis().
- WithURL("https://github.com/kulti/thelper"),
-
- linter.NewConfig(tparallel.New()).
- WithSince("v1.32.0").
- WithPresets(linter.PresetStyle, linter.PresetTest).
- WithLoadForGoAnalysis().
- WithURL("https://github.com/moricho/tparallel"),
-
- linter.NewConfig(golinters.NewTypecheck()).
- WithInternal().
- WithEnabledByDefault().
- WithSince("v1.3.0"),
-
- linter.NewConfig(unconvert.New(&cfg.LintersSettings.Unconvert)).
- WithSince("v1.0.0").
- WithLoadForGoAnalysis().
- WithPresets(linter.PresetStyle).
- WithURL("https://github.com/mdempsky/unconvert"),
-
- linter.NewConfig(unparam.New(&cfg.LintersSettings.Unparam)).
- WithSince("v1.9.0").
- WithPresets(linter.PresetUnused).
- WithLoadForGoAnalysis().
- WithURL("https://github.com/mvdan/unparam"),
-
- linter.NewConfig(unused.New(&cfg.LintersSettings.Unused)).
- WithEnabledByDefault().
- WithSince("v1.20.0").
- WithLoadForGoAnalysis().
- WithPresets(linter.PresetUnused).
- WithAlternativeNames(megacheckName).
- ConsiderSlow().
- WithChangeTypes().
- WithURL("https://github.com/dominikh/go-tools/tree/HEAD/unused"),
-
- linter.NewConfig(usestdlibvars.New(&cfg.LintersSettings.UseStdlibVars)).
- WithSince("v1.48.0").
- WithPresets(linter.PresetStyle).
- WithAutoFix().
- WithURL("https://github.com/sashamelentyev/usestdlibvars"),
-
- linter.NewConfig(usetesting.New(&cfg.LintersSettings.UseTesting)).
- WithSince("v1.63.0").
- WithPresets(linter.PresetTest).
- WithLoadForGoAnalysis().
- WithAutoFix().
- WithURL("https://github.com/ldez/usetesting"),
-
- linter.NewConfig(linter.NewNoopDeprecated("varcheck", cfg, linter.DeprecationError)).
- WithSince("v1.0.0").
- WithPresets(linter.PresetUnused).
- WithURL("https://github.com/opennota/check").
- DeprecatedError("The owner seems to have abandoned the linter.", "v1.49.0", "unused"),
-
- linter.NewConfig(varnamelen.New(&cfg.LintersSettings.Varnamelen)).
- WithSince("v1.43.0").
- WithPresets(linter.PresetStyle).
- WithLoadForGoAnalysis().
- WithURL("https://github.com/blizzy78/varnamelen"),
-
- linter.NewConfig(wastedassign.New()).
- WithSince("v1.38.0").
- WithPresets(linter.PresetStyle).
- WithLoadForGoAnalysis().
- WithURL("https://github.com/sanposhiho/wastedassign"),
-
- linter.NewConfig(whitespace.New(&cfg.LintersSettings.Whitespace)).
- WithSince("v1.19.0").
- WithPresets(linter.PresetStyle).
- WithAutoFix().
- WithURL("https://github.com/ultraware/whitespace"),
-
- linter.NewConfig(wrapcheck.New(&cfg.LintersSettings.Wrapcheck)).
- WithSince("v1.32.0").
- WithPresets(linter.PresetStyle, linter.PresetError).
- WithLoadForGoAnalysis().
- WithURL("https://github.com/tomarrell/wrapcheck"),
-
- linter.NewConfig(wsl.New(&cfg.LintersSettings.WSL)).
- WithSince("v1.20.0").
- WithPresets(linter.PresetStyle).
- WithAutoFix().
- WithURL("https://github.com/bombsimon/wsl"),
-
- linter.NewConfig(zerologlint.New()).
- WithSince("v1.53.0").
- WithPresets(linter.PresetBugs).
- WithLoadForGoAnalysis().
- WithURL("https://github.com/ykadowak/zerologlint"),
-
- // nolintlint must be last because it looks at the results of all the previous linters for unused nolint directives
- linter.NewConfig(nolintlint.New(&cfg.LintersSettings.NoLintLint)).
- WithSince("v1.26.0").
- WithPresets(linter.PresetStyle).
- WithAutoFix().
- WithURL("https://github.com/golangci/golangci-lint/tree/HEAD/pkg/golinters/nolintlint/internal"),
- }, nil
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/lint/lintersdb/manager.go b/vendor/github.com/golangci/golangci-lint/pkg/lint/lintersdb/manager.go
deleted file mode 100644
index 4fe57a3b48..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/lint/lintersdb/manager.go
+++ /dev/null
@@ -1,314 +0,0 @@
-package lintersdb
-
-import (
- "fmt"
- "maps"
- "os"
- "slices"
- "sort"
- "strings"
-
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/goanalysis"
- "github.com/golangci/golangci-lint/pkg/lint/linter"
- "github.com/golangci/golangci-lint/pkg/logutils"
-)
-
-type Builder interface {
- Build(cfg *config.Config) ([]*linter.Config, error)
-}
-
-// Manager is a type of database for all linters (internals or plugins).
-// It provides methods to access to the linter sets.
-type Manager struct {
- log logutils.Log
- debugf logutils.DebugFunc
-
- cfg *config.Config
-
- linters []*linter.Config
-
- nameToLCs map[string][]*linter.Config
-}
-
-// NewManager creates a new Manager.
-// This constructor will call the builders to build and store the linters.
-func NewManager(log logutils.Log, cfg *config.Config, builders ...Builder) (*Manager, error) {
- m := &Manager{
- log: log,
- debugf: logutils.Debug(logutils.DebugKeyEnabledLinters),
- nameToLCs: make(map[string][]*linter.Config),
- }
-
- m.cfg = cfg
- if cfg == nil {
- m.cfg = config.NewDefault()
- }
-
- for _, builder := range builders {
- linters, err := builder.Build(m.cfg)
- if err != nil {
- return nil, fmt.Errorf("build linters: %w", err)
- }
-
- m.linters = append(m.linters, linters...)
- }
-
- for _, lc := range m.linters {
- for _, name := range lc.AllNames() {
- m.nameToLCs[name] = append(m.nameToLCs[name], lc)
- }
- }
-
- err := NewValidator(m).Validate(m.cfg)
- if err != nil {
- return nil, err
- }
-
- return m, nil
-}
-
-func (m *Manager) GetLinterConfigs(name string) []*linter.Config {
- return m.nameToLCs[name]
-}
-
-func (m *Manager) GetAllSupportedLinterConfigs() []*linter.Config {
- return m.linters
-}
-
-func (m *Manager) GetAllLinterConfigsForPreset(p string) []*linter.Config {
- var ret []*linter.Config
- for _, lc := range m.linters {
- if lc.IsDeprecated() {
- continue
- }
-
- if slices.Contains(lc.InPresets, p) {
- ret = append(ret, lc)
- }
- }
-
- return ret
-}
-
-func (m *Manager) GetEnabledLintersMap() (map[string]*linter.Config, error) {
- enabledLinters := m.build(m.GetAllEnabledByDefaultLinters())
-
- if os.Getenv(logutils.EnvTestRun) == "1" {
- m.verbosePrintLintersStatus(enabledLinters)
- }
-
- return enabledLinters, nil
-}
-
-// GetOptimizedLinters returns enabled linters after optimization (merging) of multiple linters into a fewer number of linters.
-// E.g. some go/analysis linters can be optimized into one metalinter for data reuse and speed up.
-func (m *Manager) GetOptimizedLinters() ([]*linter.Config, error) {
- resultLintersSet := m.build(m.GetAllEnabledByDefaultLinters())
- m.verbosePrintLintersStatus(resultLintersSet)
-
- m.combineGoAnalysisLinters(resultLintersSet)
-
- // Make order of execution of linters (go/analysis metalinter and unused) stable.
- resultLinters := slices.SortedFunc(maps.Values(resultLintersSet), func(a *linter.Config, b *linter.Config) int {
- if b.Name() == linter.LastLinter {
- return -1
- }
-
- if a.Name() == linter.LastLinter {
- return 1
- }
-
- if a.DoesChangeTypes != b.DoesChangeTypes {
- // move type-changing linters to the end to optimize speed
- if b.DoesChangeTypes {
- return -1
- }
- return 1
- }
-
- return strings.Compare(a.Name(), b.Name())
- })
-
- return resultLinters, nil
-}
-
-func (m *Manager) GetAllEnabledByDefaultLinters() []*linter.Config {
- var ret []*linter.Config
- for _, lc := range m.linters {
- if lc.EnabledByDefault {
- ret = append(ret, lc)
- }
- }
-
- return ret
-}
-
-//nolint:gocyclo // the complexity cannot be reduced.
-func (m *Manager) build(enabledByDefaultLinters []*linter.Config) map[string]*linter.Config {
- m.debugf("Linters config: %#v", m.cfg.Linters)
-
- resultLintersSet := map[string]*linter.Config{}
- switch {
- case m.cfg.Linters.DisableAll:
- // no default linters
- case len(m.cfg.Linters.Presets) != 0:
- // imply --disable-all
- case m.cfg.Linters.EnableAll:
- resultLintersSet = linterConfigsToMap(m.linters)
- default:
- resultLintersSet = linterConfigsToMap(enabledByDefaultLinters)
- }
-
- // --presets can only add linters to default set
- for _, p := range m.cfg.Linters.Presets {
- for _, lc := range m.GetAllLinterConfigsForPreset(p) {
- resultLintersSet[lc.Name()] = lc
- }
- }
-
- // --fast removes slow linters from current set.
- // It should be after --presets to be able to run only fast linters in preset.
- // It should be before --enable and --disable to be able to enable or disable specific linter.
- if m.cfg.Linters.Fast {
- for name, lc := range resultLintersSet {
- if lc.IsSlowLinter() {
- delete(resultLintersSet, name)
- }
- }
- }
-
- for _, name := range m.cfg.Linters.Enable {
- for _, lc := range m.GetLinterConfigs(name) {
- // it's important to use lc.Name() nor name because name can be alias
- resultLintersSet[lc.Name()] = lc
- }
- }
-
- for _, name := range m.cfg.Linters.Disable {
- for _, lc := range m.GetLinterConfigs(name) {
- // it's important to use lc.Name() nor name because name can be alias
- delete(resultLintersSet, lc.Name())
- }
- }
-
- // typecheck is not a real linter and cannot be disabled.
- if _, ok := resultLintersSet["typecheck"]; !ok && (m.cfg == nil || !m.cfg.InternalCmdTest) {
- for _, lc := range m.GetLinterConfigs("typecheck") {
- // it's important to use lc.Name() nor name because name can be alias
- resultLintersSet[lc.Name()] = lc
- }
- }
-
- return resultLintersSet
-}
-
-func (m *Manager) combineGoAnalysisLinters(linters map[string]*linter.Config) {
- mlConfig := &linter.Config{}
-
- var goanalysisLinters []*goanalysis.Linter
-
- for _, lc := range linters {
- lnt, ok := lc.Linter.(*goanalysis.Linter)
- if !ok {
- continue
- }
-
- if lnt.LoadMode() == goanalysis.LoadModeWholeProgram {
- // It's ineffective by CPU and memory to run whole-program and incremental analyzers at once.
- continue
- }
-
- mlConfig.LoadMode |= lc.LoadMode
-
- if lc.IsSlowLinter() {
- mlConfig.ConsiderSlow()
- }
-
- mlConfig.InPresets = append(mlConfig.InPresets, lc.InPresets...)
-
- goanalysisLinters = append(goanalysisLinters, lnt)
- }
-
- if len(goanalysisLinters) <= 1 {
- m.debugf("Didn't combine go/analysis linters: got only %d linters", len(goanalysisLinters))
- return
- }
-
- for _, lnt := range goanalysisLinters {
- delete(linters, lnt.Name())
- }
-
- // Make order of execution of go/analysis analyzers stable.
- sort.Slice(goanalysisLinters, func(i, j int) bool {
- a, b := goanalysisLinters[i], goanalysisLinters[j]
-
- if b.Name() == linter.LastLinter {
- return true
- }
-
- if a.Name() == linter.LastLinter {
- return false
- }
-
- return a.Name() <= b.Name()
- })
-
- mlConfig.Linter = goanalysis.NewMetaLinter(goanalysisLinters)
-
- sort.Strings(mlConfig.InPresets)
- mlConfig.InPresets = slices.Compact(mlConfig.InPresets)
-
- linters[mlConfig.Linter.Name()] = mlConfig
-
- m.debugf("Combined %d go/analysis linters into one metalinter", len(goanalysisLinters))
-}
-
-func (m *Manager) verbosePrintLintersStatus(lcs map[string]*linter.Config) {
- var linterNames []string
- for _, lc := range lcs {
- if lc.Internal {
- continue
- }
-
- linterNames = append(linterNames, lc.Name())
- }
- sort.Strings(linterNames)
- m.log.Infof("Active %d linters: %s", len(linterNames), linterNames)
-
- if len(m.cfg.Linters.Presets) != 0 {
- sort.Strings(m.cfg.Linters.Presets)
- m.log.Infof("Active presets: %s", m.cfg.Linters.Presets)
- }
-}
-
-func AllPresets() []string {
- return []string{
- linter.PresetBugs,
- linter.PresetComment,
- linter.PresetComplexity,
- linter.PresetError,
- linter.PresetFormatting,
- linter.PresetImport,
- linter.PresetMetaLinter,
- linter.PresetModule,
- linter.PresetPerformance,
- linter.PresetSQL,
- linter.PresetStyle,
- linter.PresetTest,
- linter.PresetUnused,
- }
-}
-
-func linterConfigsToMap(lcs []*linter.Config) map[string]*linter.Config {
- ret := map[string]*linter.Config{}
- for _, lc := range lcs {
- if lc.IsDeprecated() && lc.Deprecation.Level > linter.DeprecationWarning {
- continue
- }
-
- ret[lc.Name()] = lc
- }
-
- return ret
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/lint/runner.go b/vendor/github.com/golangci/golangci-lint/pkg/lint/runner.go
deleted file mode 100644
index 4e6d4692b5..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/lint/runner.go
+++ /dev/null
@@ -1,263 +0,0 @@
-package lint
-
-import (
- "context"
- "errors"
- "fmt"
- "runtime/debug"
- "strings"
-
- "github.com/golangci/golangci-lint/internal/errorutil"
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/fsutils"
- "github.com/golangci/golangci-lint/pkg/goformatters"
- "github.com/golangci/golangci-lint/pkg/goutil"
- "github.com/golangci/golangci-lint/pkg/lint/linter"
- "github.com/golangci/golangci-lint/pkg/lint/lintersdb"
- "github.com/golangci/golangci-lint/pkg/logutils"
- "github.com/golangci/golangci-lint/pkg/result"
- "github.com/golangci/golangci-lint/pkg/result/processors"
- "github.com/golangci/golangci-lint/pkg/timeutils"
-)
-
-type processorStat struct {
- inCount int
- outCount int
-}
-
-type Runner struct {
- Log logutils.Log
-
- lintCtx *linter.Context
- Processors []processors.Processor
-}
-
-func NewRunner(log logutils.Log, cfg *config.Config, args []string, goenv *goutil.Env,
- lineCache *fsutils.LineCache, fileCache *fsutils.FileCache,
- dbManager *lintersdb.Manager, lintCtx *linter.Context,
-) (*Runner, error) {
- // Beware that some processors need to add the path prefix when working with paths
- // because they get invoked before the path prefixer (exclude and severity rules)
- // or process other paths (skip files).
- files := fsutils.NewFiles(lineCache, cfg.Output.PathPrefix)
-
- pathRelativity, err := processors.NewPathRelativity(log, cfg.GetBasePath())
- if err != nil {
- return nil, fmt.Errorf("error creating path relativity processor: %w", err)
- }
-
- exclusionPaths, err := processors.NewExclusionPaths(log, &cfg.Linters.LinterExclusions)
- if err != nil {
- return nil, err
- }
-
- skipFilesProcessor, err := processors.NewSkipFiles(cfg.Issues.ExcludeFiles, cfg.Output.PathPrefix)
- if err != nil {
- return nil, err
- }
-
- skipDirs := cfg.Issues.ExcludeDirs
- if cfg.Issues.UseDefaultExcludeDirs {
- skipDirs = append(skipDirs, processors.StdExcludeDirRegexps...)
- }
-
- skipDirsProcessor, err := processors.NewSkipDirs(log.Child(logutils.DebugKeySkipDirs), skipDirs, args, cfg.Output.PathPrefix)
- if err != nil {
- return nil, err
- }
-
- enabledLinters, err := dbManager.GetEnabledLintersMap()
- if err != nil {
- return nil, fmt.Errorf("failed to get enabled linters: %w", err)
- }
-
- metaFormatter, err := goformatters.NewMetaFormatter(log, cfg, enabledLinters)
- if err != nil {
- return nil, fmt.Errorf("failed to create meta-formatter: %w", err)
- }
-
- return &Runner{
- Processors: []processors.Processor{
- // Must be the first processor.
- processors.NewPathAbsoluter(log),
-
- processors.NewCgo(goenv),
-
- // Must be after Cgo.
- processors.NewFilenameUnadjuster(lintCtx.Packages, log.Child(logutils.DebugKeyFilenameUnadjuster)),
-
- // Must be after FilenameUnadjuster.
- processors.NewInvalidIssue(log.Child(logutils.DebugKeyInvalidIssue)),
-
- // Must be after PathAbsoluter, Cgo, FilenameUnadjuster InvalidIssue.
- pathRelativity,
-
- // Must be after PathRelativity.
- exclusionPaths,
- skipFilesProcessor,
- skipDirsProcessor,
-
- processors.NewGeneratedFileFilter(cfg.Linters.LinterExclusions.Generated),
-
- // Must be before exclude because users see already marked output and configure excluding by it.
- processors.NewIdentifierMarker(),
-
- processors.NewExclusionRules(log.Child(logutils.DebugKeyExclusionRules), files,
- &cfg.Linters.LinterExclusions, &cfg.Issues),
-
- processors.NewNolintFilter(log.Child(logutils.DebugKeyNolintFilter), dbManager, enabledLinters),
-
- processors.NewDiff(&cfg.Issues),
-
- // The fixer still needs to see paths for the issues that are relative to the current directory.
- processors.NewFixer(cfg, log, fileCache, metaFormatter),
-
- // Must be after the Fixer.
- processors.NewUniqByLine(cfg.Issues.UniqByLine),
- processors.NewMaxPerFileFromLinter(cfg),
- processors.NewMaxSameIssues(cfg.Issues.MaxSameIssues, log.Child(logutils.DebugKeyMaxSameIssues), cfg),
- processors.NewMaxFromLinter(cfg.Issues.MaxIssuesPerLinter, log.Child(logutils.DebugKeyMaxFromLinter), cfg),
-
- // Now we can modify the issues for output.
- processors.NewSourceCode(lineCache, log.Child(logutils.DebugKeySourceCode)),
- processors.NewPathShortener(),
- processors.NewSeverity(log.Child(logutils.DebugKeySeverityRules), files, &cfg.Severity),
- processors.NewPathPrettifier(log, cfg.Output.PathPrefix),
- processors.NewSortResults(&cfg.Output),
- },
- lintCtx: lintCtx,
- Log: log,
- }, nil
-}
-
-func (r *Runner) Run(ctx context.Context, linters []*linter.Config) ([]result.Issue, error) {
- sw := timeutils.NewStopwatch("linters", r.Log)
- defer sw.Print()
-
- var (
- lintErrors error
- issues []result.Issue
- )
-
- for _, lc := range linters {
- linterIssues, err := timeutils.TrackStage(sw, lc.Name(), func() ([]result.Issue, error) {
- return r.runLinterSafe(ctx, r.lintCtx, lc)
- })
- if err != nil {
- lintErrors = errors.Join(lintErrors, fmt.Errorf("can't run linter %s", lc.Linter.Name()), err)
- r.Log.Warnf("Can't run linter %s: %v", lc.Linter.Name(), err)
-
- continue
- }
-
- issues = append(issues, linterIssues...)
- }
-
- return r.processLintResults(issues), lintErrors
-}
-
-func (r *Runner) runLinterSafe(ctx context.Context, lintCtx *linter.Context,
- lc *linter.Config,
-) (ret []result.Issue, err error) {
- defer func() {
- if panicData := recover(); panicData != nil {
- if pe, ok := panicData.(*errorutil.PanicError); ok {
- err = fmt.Errorf("%s: %w", lc.Name(), pe)
-
- // Don't print stacktrace from goroutines twice
- r.Log.Errorf("Panic: %s: %s", pe, pe.Stack())
- } else {
- err = fmt.Errorf("panic occurred: %s", panicData)
- r.Log.Errorf("Panic stack trace: %s", debug.Stack())
- }
- }
- }()
-
- issues, err := lc.Linter.Run(ctx, lintCtx)
-
- if lc.DoesChangeTypes {
- // Packages in lintCtx might be dirty due to the last analysis,
- // which affects to the next analysis.
- // To avoid this issue, we clear type information from the packages.
- // See https://github.com/golangci/golangci-lint/pull/944.
- // Currently, DoesChangeTypes is true only for `unused`.
- lintCtx.ClearTypesInPackages()
- }
-
- if err != nil {
- return nil, err
- }
-
- for i := range issues {
- if issues[i].FromLinter == "" {
- issues[i].FromLinter = lc.Name()
- }
- }
-
- return issues, nil
-}
-
-func (r *Runner) processLintResults(inIssues []result.Issue) []result.Issue {
- sw := timeutils.NewStopwatch("processing", r.Log)
-
- var issuesBefore, issuesAfter int
- statPerProcessor := map[string]processorStat{}
-
- var outIssues []result.Issue
- if len(inIssues) != 0 {
- issuesBefore += len(inIssues)
- outIssues = r.processIssues(inIssues, sw, statPerProcessor)
- issuesAfter += len(outIssues)
- }
-
- // finalize processors: logging, clearing, no heavy work here
-
- for _, p := range r.Processors {
- sw.TrackStage(p.Name(), p.Finish)
- }
-
- if issuesBefore != issuesAfter {
- r.Log.Infof("Issues before processing: %d, after processing: %d", issuesBefore, issuesAfter)
- }
- r.printPerProcessorStat(statPerProcessor)
- sw.PrintStages()
-
- return outIssues
-}
-
-func (r *Runner) printPerProcessorStat(stat map[string]processorStat) {
- parts := make([]string, 0, len(stat))
- for name, ps := range stat {
- if ps.inCount != 0 {
- parts = append(parts, fmt.Sprintf("%s: %d/%d", name, ps.inCount, ps.outCount))
- }
- }
- if len(parts) != 0 {
- r.Log.Infof("Processors filtering stat (in/out): %s", strings.Join(parts, ", "))
- }
-}
-
-func (r *Runner) processIssues(issues []result.Issue, sw *timeutils.Stopwatch, statPerProcessor map[string]processorStat) []result.Issue {
- for _, p := range r.Processors {
- newIssues, err := timeutils.TrackStage(sw, p.Name(), func() ([]result.Issue, error) {
- return p.Process(issues)
- })
-
- if err != nil {
- r.Log.Warnf("Can't process result by %s processor: %s", p.Name(), err)
- } else {
- stat := statPerProcessor[p.Name()]
- stat.inCount += len(issues)
- stat.outCount += len(newIssues)
- statPerProcessor[p.Name()] = stat
- issues = newIssues
- }
-
- // This is required by JSON serialization
- if issues == nil {
- issues = []result.Issue{}
- }
- }
-
- return issues
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/logutils/logutils.go b/vendor/github.com/golangci/golangci-lint/pkg/logutils/logutils.go
deleted file mode 100644
index 0454d79271..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/logutils/logutils.go
+++ /dev/null
@@ -1,135 +0,0 @@
-package logutils
-
-import (
- "os"
- "strings"
-)
-
-// EnvTestRun value: "1"
-const EnvTestRun = "GL_TEST_RUN"
-
-// envDebug value: one or several debug keys.
-// examples:
-// - Remove output to `/dev/null`: `GL_DEBUG=linters_output ./golangci-lint run`
-// - Show linters configuration: `GL_DEBUG=enabled_linters golangci-lint run`
-// - Some analysis details: `GL_DEBUG=goanalysis/analyze,goanalysis/facts golangci-lint run`
-const envDebug = "GL_DEBUG"
-
-const (
- DebugKeyBinSalt = "bin_salt"
- DebugKeyConfigReader = "config_reader"
- DebugKeyEmpty = ""
- DebugKeyEnabledLinters = "enabled_linters"
- DebugKeyExec = "exec"
- DebugKeyFormatter = "formatter"
- DebugKeyGoEnv = "goenv"
- DebugKeyLinter = "linter"
- DebugKeyLintersContext = "linters_context"
- DebugKeyLintersDB = "lintersdb"
- DebugKeyLintersOutput = "linters_output"
- DebugKeyLoader = "loader" // Debugs packages loading (including `go/packages` internal debugging).
- DebugKeyPkgCache = "pkgcache"
- DebugKeyRunner = "runner"
- DebugKeyStopwatch = "stopwatch"
- DebugKeyTest = "test"
-)
-
-// Printers.
-const (
- DebugKeyCheckstylePrinter = "checkstyle_printer"
- DebugKeyCodeClimatePrinter = "codeclimate_printer"
- DebugKeySarifPrinter = "sarif_printer"
- DebugKeyTabPrinter = "tab_printer"
- DebugKeyTeamCityPrinter = "teamcity_printer"
- DebugKeyTextPrinter = "text_printer"
-)
-
-// Processors.
-const (
- DebugKeyExclusionPaths = "exclusion_paths"
- DebugKeyExclusionRules = "exclusion_rules"
- DebugKeyFilenameUnadjuster = "filename_unadjuster"
- DebugKeyGeneratedFileFilter = "generated_file_filter" // Debugs a filter excluding autogenerated source code.
- DebugKeyInvalidIssue = "invalid_issue"
- DebugKeyMaxFromLinter = "max_from_linter"
- DebugKeyMaxSameIssues = "max_same_issues"
- DebugKeyNolintFilter = "nolint_filter" // Debugs a filter excluding issues by `//nolint` comments.
- DebugKeyPathAbsoluter = "path_absoluter"
- DebugKeyPathPrettifier = "path_prettifier"
- DebugKeyPathRelativity = "path_relativity"
- DebugKeySeverityRules = "severity_rules"
- DebugKeySkipDirs = "skip_dirs"
- DebugKeySourceCode = "source_code"
-)
-
-// Analysis.
-const (
- DebugKeyGoAnalysis = "goanalysis"
-
- DebugKeyGoAnalysisAnalyze = DebugKeyGoAnalysis + "/analyze"
- DebugKeyGoAnalysisIssuesCache = DebugKeyGoAnalysis + "/issues/cache"
- DebugKeyGoAnalysisMemory = DebugKeyGoAnalysis + "/memory"
-
- DebugKeyGoAnalysisFacts = DebugKeyGoAnalysis + "/facts"
- DebugKeyGoAnalysisFactsCache = DebugKeyGoAnalysisFacts + "/cache"
- DebugKeyGoAnalysisFactsExport = DebugKeyGoAnalysisFacts + "/export"
- DebugKeyGoAnalysisFactsInherit = DebugKeyGoAnalysisFacts + "/inherit"
-)
-
-// Linters.
-const (
- DebugKeyForbidigo = "forbidigo" // Debugs `forbidigo` linter.
- DebugKeyGoCritic = "gocritic" // Debugs `gocritic` linter.
- DebugKeyGovet = "govet" // Debugs `govet` linter.
- DebugKeyRevive = "revive" // Debugs `revive` linter.
-)
-
-func getEnabledDebugs() map[string]bool {
- ret := map[string]bool{}
- debugVar := os.Getenv(envDebug)
- if debugVar == "" {
- return ret
- }
-
- for _, tag := range strings.Split(debugVar, ",") {
- ret[tag] = true
- }
-
- return ret
-}
-
-var enabledDebugs = getEnabledDebugs()
-
-type DebugFunc func(format string, args ...any)
-
-func nopDebugf(_ string, _ ...any) {}
-
-func Debug(tag string) DebugFunc {
- if !enabledDebugs[tag] {
- return nopDebugf
- }
-
- logger := NewStderrLog(tag)
- logger.SetLevel(LogLevelDebug)
-
- return func(format string, args ...any) {
- logger.Debugf(format, args...)
- }
-}
-
-func HaveDebugTag(tag string) bool {
- return enabledDebugs[tag]
-}
-
-var verbose bool
-
-func SetupVerboseLog(log Log, isVerbose bool) {
- if isVerbose {
- verbose = isVerbose
- log.SetLevel(LogLevelInfo)
- }
-}
-
-func IsVerbose() bool {
- return verbose
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/printers/githubaction.go b/vendor/github.com/golangci/golangci-lint/pkg/printers/githubaction.go
deleted file mode 100644
index d9cdb1e6e6..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/printers/githubaction.go
+++ /dev/null
@@ -1,52 +0,0 @@
-package printers
-
-import (
- "fmt"
- "io"
- "path/filepath"
-
- "github.com/golangci/golangci-lint/pkg/result"
-)
-
-const defaultGithubSeverity = "error"
-
-type GitHubAction struct {
- w io.Writer
-}
-
-// NewGitHubAction output format outputs issues according to GitHub Action.
-// Deprecated
-func NewGitHubAction(w io.Writer) *GitHubAction {
- return &GitHubAction{w: w}
-}
-
-func (p *GitHubAction) Print(issues []result.Issue) error {
- for ind := range issues {
- _, err := fmt.Fprintln(p.w, formatIssueAsGitHub(&issues[ind]))
- if err != nil {
- return err
- }
- }
- return nil
-}
-
-// print each line as: ::error file=app.js,line=10,col=15::Something went wrong
-func formatIssueAsGitHub(issue *result.Issue) string {
- severity := defaultGithubSeverity
- if issue.Severity != "" {
- severity = issue.Severity
- }
-
- // Convert backslashes to forward slashes.
- // This is needed when running on windows.
- // Otherwise, GitHub won't be able to show the annotations pointing to the file path with backslashes.
- file := filepath.ToSlash(issue.FilePath())
-
- ret := fmt.Sprintf("::%s file=%s,line=%d", severity, file, issue.Line())
- if issue.Pos.Column != 0 {
- ret += fmt.Sprintf(",col=%d", issue.Pos.Column)
- }
-
- ret += fmt.Sprintf("::%s (%s)", issue.Text, issue.FromLinter)
- return ret
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/printers/html.go b/vendor/github.com/golangci/golangci-lint/pkg/printers/html.go
deleted file mode 100644
index 6fc6bc62a2..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/printers/html.go
+++ /dev/null
@@ -1,158 +0,0 @@
-package printers
-
-import (
- "fmt"
- "html/template"
- "io"
- "strings"
-
- "github.com/golangci/golangci-lint/pkg/result"
-)
-
-const templateContent = `
-
-
-
- golangci-lint
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-`
-
-type htmlIssue struct {
- Title string
- Pos string
- Linter string
- Code string
-}
-
-// HTML prints issues in an HTML page.
-// It uses the Cloudflare CDN (cdnjs) and React.
-type HTML struct {
- w io.Writer
-}
-
-func NewHTML(w io.Writer) *HTML {
- return &HTML{w: w}
-}
-
-func (p HTML) Print(issues []result.Issue) error {
- var htmlIssues []htmlIssue
-
- for i := range issues {
- pos := fmt.Sprintf("%s:%d", issues[i].FilePath(), issues[i].Line())
- if issues[i].Pos.Column != 0 {
- pos += fmt.Sprintf(":%d", issues[i].Pos.Column)
- }
-
- htmlIssues = append(htmlIssues, htmlIssue{
- Title: strings.TrimSpace(issues[i].Text),
- Pos: pos,
- Linter: issues[i].FromLinter,
- Code: strings.Join(issues[i].SourceLines, "\n"),
- })
- }
-
- t, err := template.New("golangci-lint").Parse(templateContent)
- if err != nil {
- return err
- }
-
- return t.Execute(p.w, struct{ Issues []htmlIssue }{Issues: htmlIssues})
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/printers/json.go b/vendor/github.com/golangci/golangci-lint/pkg/printers/json.go
deleted file mode 100644
index 8fc94649f7..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/printers/json.go
+++ /dev/null
@@ -1,39 +0,0 @@
-package printers
-
-import (
- "encoding/json"
- "io"
-
- "github.com/golangci/golangci-lint/pkg/report"
- "github.com/golangci/golangci-lint/pkg/result"
-)
-
-// JSON prints issues in a JSON representation.
-type JSON struct {
- rd *report.Data
- w io.Writer
-}
-
-func NewJSON(w io.Writer, rd *report.Data) *JSON {
- return &JSON{
- rd: rd,
- w: w,
- }
-}
-
-type JSONResult struct {
- Issues []result.Issue
- Report *report.Data
-}
-
-func (p JSON) Print(issues []result.Issue) error {
- res := JSONResult{
- Issues: issues,
- Report: p.rd,
- }
- if res.Issues == nil {
- res.Issues = []result.Issue{}
- }
-
- return json.NewEncoder(p.w).Encode(res)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/printers/printer.go b/vendor/github.com/golangci/golangci-lint/pkg/printers/printer.go
deleted file mode 100644
index 613e4abec8..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/printers/printer.go
+++ /dev/null
@@ -1,184 +0,0 @@
-package printers
-
-import (
- "errors"
- "fmt"
- "io"
- "os"
- "path/filepath"
- "slices"
- "strings"
-
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/logutils"
- "github.com/golangci/golangci-lint/pkg/report"
- "github.com/golangci/golangci-lint/pkg/result"
-)
-
-const defaultFileMode = 0o644
-
-type issuePrinter interface {
- Print(issues []result.Issue) error
-}
-
-// Printer prints issues
-type Printer struct {
- cfg *config.Output
- reportData *report.Data
- basePath string
-
- log logutils.Log
-
- stdOut io.Writer
- stdErr io.Writer
-}
-
-// NewPrinter creates a new Printer.
-func NewPrinter(log logutils.Log, cfg *config.Output, reportData *report.Data, basePath string) (*Printer, error) {
- if log == nil {
- return nil, errors.New("missing log argument in constructor")
- }
- if cfg == nil {
- return nil, errors.New("missing config argument in constructor")
- }
- if reportData == nil {
- return nil, errors.New("missing reportData argument in constructor")
- }
-
- return &Printer{
- cfg: cfg,
- reportData: reportData,
- basePath: basePath,
- log: log,
- stdOut: logutils.StdOut,
- stdErr: logutils.StdErr,
- }, nil
-}
-
-// Print prints issues based on the formats defined
-func (c *Printer) Print(issues []result.Issue) error {
- for _, format := range c.cfg.Formats {
- err := c.printReports(issues, format)
- if err != nil {
- return err
- }
- }
-
- return nil
-}
-
-func (c *Printer) printReports(issues []result.Issue, format config.OutputFormat) error {
- w, shouldClose, err := c.createWriter(format.Path)
- if err != nil {
- return fmt.Errorf("can't create output for %s: %w", format.Path, err)
- }
-
- defer func() {
- if file, ok := w.(io.Closer); shouldClose && ok {
- _ = file.Close()
- }
- }()
-
- p, err := c.createPrinter(format.Format, w)
- if err != nil {
- return err
- }
-
- if err = p.Print(issues); err != nil {
- return fmt.Errorf("can't print %d issues: %w", len(issues), err)
- }
-
- return nil
-}
-
-func (c *Printer) createWriter(path string) (io.Writer, bool, error) {
- if path == "" || path == "stdout" {
- return c.stdOut, false, nil
- }
-
- if path == "stderr" {
- return c.stdErr, false, nil
- }
-
- if !filepath.IsAbs(path) {
- path = filepath.Join(c.basePath, path)
- }
-
- err := os.MkdirAll(filepath.Dir(path), os.ModePerm)
- if err != nil {
- return nil, false, err
- }
-
- f, err := os.OpenFile(path, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, defaultFileMode)
- if err != nil {
- return nil, false, err
- }
-
- return f, true, nil
-}
-
-func (c *Printer) createPrinter(format string, w io.Writer) (issuePrinter, error) {
- var p issuePrinter
-
- switch format {
- case config.OutFormatJSON:
- p = NewJSON(w, c.reportData)
- case config.OutFormatLineNumber, config.OutFormatColoredLineNumber:
- p = NewText(c.log, w, c.cfg.PrintLinterName, c.cfg.PrintIssuedLine, format == config.OutFormatColoredLineNumber)
- case config.OutFormatTab, config.OutFormatColoredTab:
- p = NewTab(c.log, w, c.cfg.PrintLinterName, format == config.OutFormatColoredTab)
- case config.OutFormatCheckstyle:
- p = NewCheckstyle(c.log, w)
- case config.OutFormatCodeClimate:
- p = NewCodeClimate(c.log, w)
- case config.OutFormatHTML:
- p = NewHTML(w)
- case config.OutFormatJUnitXML, config.OutFormatJUnitXMLExtended:
- p = NewJUnitXML(w, format == config.OutFormatJUnitXMLExtended)
- case config.OutFormatGithubActions:
- p = NewGitHubAction(w)
- case config.OutFormatTeamCity:
- p = NewTeamCity(c.log, w)
- case config.OutFormatSarif:
- p = NewSarif(c.log, w)
- default:
- return nil, fmt.Errorf("unknown output format %q", format)
- }
-
- return p, nil
-}
-
-type severitySanitizer struct {
- allowedSeverities []string
- defaultSeverity string
-
- unsupportedSeverities map[string]struct{}
-}
-
-func (s *severitySanitizer) Sanitize(severity string) string {
- if slices.Contains(s.allowedSeverities, severity) {
- return severity
- }
-
- if s.unsupportedSeverities == nil {
- s.unsupportedSeverities = make(map[string]struct{})
- }
-
- s.unsupportedSeverities[severity] = struct{}{}
-
- return s.defaultSeverity
-}
-
-func (s *severitySanitizer) Err() error {
- if len(s.unsupportedSeverities) == 0 {
- return nil
- }
-
- var names []string
- for k := range s.unsupportedSeverities {
- names = append(names, "'"+k+"'")
- }
-
- return fmt.Errorf("severities (%v) are not inside supported values (%v), fallback to '%s'",
- strings.Join(names, ", "), strings.Join(s.allowedSeverities, ", "), s.defaultSeverity)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/printers/tab.go b/vendor/github.com/golangci/golangci-lint/pkg/printers/tab.go
deleted file mode 100644
index ac04ab0fbe..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/printers/tab.go
+++ /dev/null
@@ -1,68 +0,0 @@
-package printers
-
-import (
- "fmt"
- "io"
- "text/tabwriter"
-
- "github.com/fatih/color"
-
- "github.com/golangci/golangci-lint/pkg/logutils"
- "github.com/golangci/golangci-lint/pkg/result"
-)
-
-// Tab prints issues using tabulation as a field separator.
-type Tab struct {
- printLinterName bool
- useColors bool
-
- log logutils.Log
- w io.Writer
-}
-
-func NewTab(log logutils.Log, w io.Writer, printLinterName, useColors bool) *Tab {
- return &Tab{
- printLinterName: printLinterName,
- useColors: useColors,
- log: log.Child(logutils.DebugKeyTabPrinter),
- w: w,
- }
-}
-
-func (p *Tab) SprintfColored(ca color.Attribute, format string, args ...any) string {
- c := color.New(ca)
-
- if !p.useColors {
- c.DisableColor()
- }
-
- return c.Sprintf(format, args...)
-}
-
-func (p *Tab) Print(issues []result.Issue) error {
- w := tabwriter.NewWriter(p.w, 0, 0, 2, ' ', 0)
-
- for i := range issues {
- p.printIssue(&issues[i], w)
- }
-
- if err := w.Flush(); err != nil {
- p.log.Warnf("Can't flush tab writer: %s", err)
- }
-
- return nil
-}
-
-func (p *Tab) printIssue(issue *result.Issue, w io.Writer) {
- text := p.SprintfColored(color.FgRed, "%s", issue.Text)
- if p.printLinterName {
- text = fmt.Sprintf("%s\t%s", issue.FromLinter, text)
- }
-
- pos := p.SprintfColored(color.Bold, "%s:%d", issue.FilePath(), issue.Line())
- if issue.Pos.Column != 0 {
- pos += fmt.Sprintf(":%d", issue.Pos.Column)
- }
-
- fmt.Fprintf(w, "%s\t%s\n", pos, text)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/report/data.go b/vendor/github.com/golangci/golangci-lint/pkg/report/data.go
deleted file mode 100644
index f083fa9f51..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/report/data.go
+++ /dev/null
@@ -1,26 +0,0 @@
-package report
-
-type Warning struct {
- Tag string `json:",omitempty"`
- Text string
-}
-
-type LinterData struct {
- Name string
- Enabled bool `json:",omitempty"`
- EnabledByDefault bool `json:",omitempty"`
-}
-
-type Data struct {
- Warnings []Warning `json:",omitempty"`
- Linters []LinterData `json:",omitempty"`
- Error string `json:",omitempty"`
-}
-
-func (d *Data) AddLinter(name string, enabled, enabledByDefault bool) {
- d.Linters = append(d.Linters, LinterData{
- Name: name,
- Enabled: enabled,
- EnabledByDefault: enabledByDefault,
- })
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/report/log.go b/vendor/github.com/golangci/golangci-lint/pkg/report/log.go
deleted file mode 100644
index 61665f28b7..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/report/log.go
+++ /dev/null
@@ -1,64 +0,0 @@
-package report
-
-import (
- "fmt"
- "strings"
-
- "github.com/golangci/golangci-lint/pkg/logutils"
-)
-
-type LogWrapper struct {
- rd *Data
- tags []string
- origLog logutils.Log
-}
-
-func NewLogWrapper(log logutils.Log, reportData *Data) *LogWrapper {
- return &LogWrapper{
- rd: reportData,
- origLog: log,
- }
-}
-
-func (lw LogWrapper) Fatalf(format string, args ...any) {
- lw.origLog.Fatalf(format, args...)
-}
-
-func (lw LogWrapper) Panicf(format string, args ...any) {
- lw.origLog.Panicf(format, args...)
-}
-
-func (lw LogWrapper) Errorf(format string, args ...any) {
- lw.origLog.Errorf(format, args...)
- lw.rd.Error = fmt.Sprintf(format, args...)
-}
-
-func (lw LogWrapper) Warnf(format string, args ...any) {
- lw.origLog.Warnf(format, args...)
- w := Warning{
- Tag: strings.Join(lw.tags, "/"),
- Text: fmt.Sprintf(format, args...),
- }
-
- lw.rd.Warnings = append(lw.rd.Warnings, w)
-}
-
-func (lw LogWrapper) Infof(format string, args ...any) {
- lw.origLog.Infof(format, args...)
-}
-
-func (lw LogWrapper) Child(name string) logutils.Log {
- c := lw
- c.origLog = lw.origLog.Child(name)
- c.tags = append([]string{}, lw.tags...)
- c.tags = append(c.tags, name)
- return c
-}
-
-func (lw LogWrapper) SetLevel(level logutils.LogLevel) {
- lw.origLog.SetLevel(level)
-}
-
-func (lw LogWrapper) GoString() string {
- return fmt.Sprintf("lw: %+v, orig log: %#v", lw, lw.origLog)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/result/issue.go b/vendor/github.com/golangci/golangci-lint/pkg/result/issue.go
deleted file mode 100644
index 86a4ef3b73..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/result/issue.go
+++ /dev/null
@@ -1,93 +0,0 @@
-package result
-
-import (
- "crypto/md5" //nolint:gosec // for md5 hash
- "fmt"
- "go/token"
-
- "golang.org/x/tools/go/analysis"
- "golang.org/x/tools/go/packages"
-)
-
-type Range struct {
- From, To int
-}
-
-type Issue struct {
- FromLinter string
- Text string
-
- Severity string
-
- // Source lines of a code with the issue to show
- SourceLines []string
-
- // Pkg is needed for proper caching of linting results
- Pkg *packages.Package `json:"-"`
-
- Pos token.Position
-
- LineRange *Range `json:",omitempty"`
-
- // HunkPos is used only when golangci-lint is run over a diff
- HunkPos int `json:",omitempty"`
-
- // If we know how to fix the issue we can provide replacement lines
- SuggestedFixes []analysis.SuggestedFix `json:",omitempty"`
-
- // If we are expecting a nolint (because this is from nolintlint), record the expected linter
- ExpectNoLint bool
- ExpectedNoLintLinter string
-
- // Only for Diff processor needs.
- WorkingDirectoryRelativePath string `json:"-"`
-
- // Only for processor that need relative paths evaluation.
- RelativePath string `json:"-"`
-}
-
-func (i *Issue) FilePath() string {
- return i.Pos.Filename
-}
-
-func (i *Issue) Line() int {
- return i.Pos.Line
-}
-
-func (i *Issue) Column() int {
- return i.Pos.Column
-}
-
-func (i *Issue) GetLineRange() Range {
- if i.LineRange == nil {
- return Range{
- From: i.Line(),
- To: i.Line(),
- }
- }
-
- if i.LineRange.From == 0 {
- return Range{
- From: i.Line(),
- To: i.Line(),
- }
- }
-
- return *i.LineRange
-}
-
-func (i *Issue) Description() string {
- return fmt.Sprintf("%s: %s", i.FromLinter, i.Text)
-}
-
-func (i *Issue) Fingerprint() string {
- firstLine := ""
- if len(i.SourceLines) > 0 {
- firstLine = i.SourceLines[0]
- }
-
- hash := md5.New() //nolint:gosec // we don't need a strong hash here
- _, _ = fmt.Fprintf(hash, "%s%s%s", i.Pos.Filename, i.Text, firstLine)
-
- return fmt.Sprintf("%X", hash.Sum(nil))
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/result/processors/base_rule.go b/vendor/github.com/golangci/golangci-lint/pkg/result/processors/base_rule.go
deleted file mode 100644
index 72dc202847..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/result/processors/base_rule.go
+++ /dev/null
@@ -1,109 +0,0 @@
-package processors
-
-import (
- "regexp"
-
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/fsutils"
- "github.com/golangci/golangci-lint/pkg/logutils"
- "github.com/golangci/golangci-lint/pkg/result"
-)
-
-const caseInsensitivePrefix = "(?i)"
-
-type baseRule struct {
- text *regexp.Regexp
- source *regexp.Regexp
- path *regexp.Regexp
- pathExcept *regexp.Regexp
- linters []string
-}
-
-// The usage of `regexp.MustCompile()` is safe here,
-// because the regular expressions are checked before inside [config.BaseRule.Validate].
-func newBaseRule(rule *config.BaseRule, prefix string) baseRule {
- base := baseRule{
- linters: rule.Linters,
- }
-
- if rule.Text != "" {
- base.text = regexp.MustCompile(prefix + rule.Text)
- }
-
- if rule.Source != "" {
- base.source = regexp.MustCompile(prefix + rule.Source)
- }
-
- if rule.Path != "" {
- base.path = regexp.MustCompile(fsutils.NormalizePathInRegex(rule.Path))
- }
-
- if rule.PathExcept != "" {
- base.pathExcept = regexp.MustCompile(fsutils.NormalizePathInRegex(rule.PathExcept))
- }
-
- return base
-}
-
-func (r *baseRule) isEmpty() bool {
- return r.text == nil && r.source == nil && r.path == nil && r.pathExcept == nil && len(r.linters) == 0
-}
-
-func (r *baseRule) match(issue *result.Issue, files *fsutils.Files, log logutils.Log) bool {
- if r.isEmpty() {
- return false
- }
- if r.text != nil && !r.text.MatchString(issue.Text) {
- return false
- }
- if r.path != nil && !r.path.MatchString(files.WithPathPrefix(issue.RelativePath)) {
- return false
- }
- if r.pathExcept != nil && r.pathExcept.MatchString(issue.RelativePath) {
- return false
- }
- if len(r.linters) != 0 && !r.matchLinter(issue) {
- return false
- }
-
- // the most heavyweight checking last
- if r.source != nil && !r.matchSource(issue, files.LineCache, log) {
- return false
- }
-
- return true
-}
-
-func (r *baseRule) matchLinter(issue *result.Issue) bool {
- for _, linter := range r.linters {
- if linter == issue.FromLinter {
- return true
- }
- }
-
- return false
-}
-
-func (r *baseRule) matchSource(issue *result.Issue, lineCache *fsutils.LineCache, log logutils.Log) bool {
- sourceLine, errSourceLine := lineCache.GetLine(issue.RelativePath, issue.Line())
- if errSourceLine != nil {
- log.Warnf("Failed to get line %s:%d from line cache: %s", issue.RelativePath, issue.Line(), errSourceLine)
- return false // can't properly match
- }
-
- return r.source.MatchString(sourceLine)
-}
-
-func parseRules[T, V any](rules []T, prefix string, newFn func(*T, string) V) []V {
- if len(rules) == 0 {
- return nil
- }
-
- parsedRules := make([]V, 0, len(rules))
-
- for _, r := range rules {
- parsedRules = append(parsedRules, newFn(&r, prefix))
- }
-
- return parsedRules
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/result/processors/diff.go b/vendor/github.com/golangci/golangci-lint/pkg/result/processors/diff.go
deleted file mode 100644
index a7e268b4b7..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/result/processors/diff.go
+++ /dev/null
@@ -1,100 +0,0 @@
-package processors
-
-import (
- "bytes"
- "context"
- "fmt"
- "io"
- "os"
- "strings"
-
- "github.com/golangci/revgrep"
-
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/result"
-)
-
-const envGolangciDiffProcessorPatch = "GOLANGCI_DIFF_PROCESSOR_PATCH"
-
-var _ Processor = (*Diff)(nil)
-
-// Diff filters issues based on options `new`, `new-from-rev`, etc.
-//
-// Uses `git`.
-// The paths inside the patch are relative to the path where git is run (the same location where golangci-lint is run).
-//
-// Warning: it doesn't use `path-prefix` option.
-type Diff struct {
- onlyNew bool
- fromRev string
- fromMergeBase string
- patchFilePath string
- wholeFiles bool
- patch string
-}
-
-func NewDiff(cfg *config.Issues) *Diff {
- return &Diff{
- onlyNew: cfg.Diff,
- fromRev: cfg.DiffFromRevision,
- fromMergeBase: cfg.DiffFromMergeBase,
- patchFilePath: cfg.DiffPatchFilePath,
- wholeFiles: cfg.WholeFiles,
- patch: os.Getenv(envGolangciDiffProcessorPatch),
- }
-}
-
-func (*Diff) Name() string {
- return "diff"
-}
-
-func (p *Diff) Process(issues []result.Issue) ([]result.Issue, error) {
- if !p.onlyNew && p.fromRev == "" && p.fromMergeBase == "" && p.patchFilePath == "" && p.patch == "" {
- return issues, nil
- }
-
- var patchReader io.Reader
- switch {
- case p.patchFilePath != "":
- patch, err := os.ReadFile(p.patchFilePath)
- if err != nil {
- return nil, fmt.Errorf("can't read from patch file %s: %w", p.patchFilePath, err)
- }
-
- patchReader = bytes.NewReader(patch)
-
- case p.patch != "":
- patchReader = strings.NewReader(p.patch)
- }
-
- checker := revgrep.Checker{
- Patch: patchReader,
- RevisionFrom: p.fromRev,
- MergeBase: p.fromMergeBase,
- WholeFiles: p.wholeFiles,
- }
-
- err := checker.Prepare(context.Background())
- if err != nil {
- return nil, fmt.Errorf("can't prepare diff by revgrep: %w", err)
- }
-
- return transformIssues(issues, func(issue *result.Issue) *result.Issue {
- if issue.FromLinter == typeCheckName {
- // Never hide typechecking errors.
- return issue
- }
-
- hunkPos, isNew := checker.IsNew(issue.WorkingDirectoryRelativePath, issue.Line())
- if !isNew {
- return nil
- }
-
- newIssue := *issue
- newIssue.HunkPos = hunkPos
-
- return &newIssue
- }), nil
-}
-
-func (*Diff) Finish() {}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/result/processors/exclusion_generated_file_filter.go b/vendor/github.com/golangci/golangci-lint/pkg/result/processors/exclusion_generated_file_filter.go
deleted file mode 100644
index ce4e2e2146..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/result/processors/exclusion_generated_file_filter.go
+++ /dev/null
@@ -1,181 +0,0 @@
-package processors
-
-import (
- "fmt"
- "go/parser"
- "go/token"
- "path/filepath"
- "regexp"
- "strings"
-
- "github.com/golangci/golangci-lint/pkg/logutils"
- "github.com/golangci/golangci-lint/pkg/result"
-)
-
-const (
- AutogeneratedModeLax = "lax"
- AutogeneratedModeStrict = "strict"
- AutogeneratedModeDisable = "disable"
-)
-
-// The values must be in lowercase.
-const (
- genCodeGenerated = "code generated"
- genDoNotEdit = "do not edit"
-
- // Related to easyjson.
- genAutoFile = "autogenerated file"
-
- //nolint:lll // Long URL
- // Related to Swagger Codegen.
- // https://github.com/swagger-api/swagger-codegen/blob/61cfeac3b9d855b4eb8bffa0d118bece117bcb7d/modules/swagger-codegen/src/main/resources/go/partial_header.mustache#L16
- // https://github.com/swagger-api/swagger-codegen/issues/12358
- genSwaggerCodegen = "* generated by: swagger codegen "
-)
-
-var _ Processor = (*GeneratedFileFilter)(nil)
-
-type fileSummary struct {
- generated bool
-}
-
-// GeneratedFileFilter filters generated files.
-// - mode "lax": see `isGeneratedFileLax` documentation.
-// - mode "strict": see `isGeneratedFileStrict` documentation.
-// - mode "disable": skips this processor.
-type GeneratedFileFilter struct {
- debugf logutils.DebugFunc
-
- mode string
- strictPattern *regexp.Regexp
-
- fileSummaryCache map[string]*fileSummary
-}
-
-func NewGeneratedFileFilter(mode string) *GeneratedFileFilter {
- return &GeneratedFileFilter{
- debugf: logutils.Debug(logutils.DebugKeyGeneratedFileFilter),
- mode: mode,
- strictPattern: regexp.MustCompile(`^// Code generated .* DO NOT EDIT\.$`),
- fileSummaryCache: map[string]*fileSummary{},
- }
-}
-
-func (*GeneratedFileFilter) Name() string {
- return "generated_file_filter"
-}
-
-func (p *GeneratedFileFilter) Process(issues []result.Issue) ([]result.Issue, error) {
- if p.mode == AutogeneratedModeDisable {
- return issues, nil
- }
-
- return filterIssuesErr(issues, p.shouldPassIssue)
-}
-
-func (*GeneratedFileFilter) Finish() {}
-
-func (p *GeneratedFileFilter) shouldPassIssue(issue *result.Issue) (bool, error) {
- if filepath.Base(issue.FilePath()) == "go.mod" {
- return true, nil
- }
-
- // The file is already known.
- fs := p.fileSummaryCache[issue.FilePath()]
- if fs != nil {
- return !fs.generated, nil
- }
-
- fs = &fileSummary{}
- p.fileSummaryCache[issue.FilePath()] = fs
-
- if p.mode == AutogeneratedModeStrict {
- var err error
- fs.generated, err = p.isGeneratedFileStrict(issue.FilePath())
- if err != nil {
- return false, fmt.Errorf("failed to get doc (strict) of file %s: %w", issue.FilePath(), err)
- }
- } else {
- doc, err := getComments(issue.FilePath())
- if err != nil {
- return false, fmt.Errorf("failed to get doc (lax) of file %s: %w", issue.FilePath(), err)
- }
-
- fs.generated = p.isGeneratedFileLax(doc)
- }
-
- p.debugf("file %q is generated: %t", issue.FilePath(), fs.generated)
-
- // don't report issues for autogenerated files
- return !fs.generated, nil
-}
-
-// isGeneratedFileLax reports whether the source file is generated code.
-// The function uses a bit laxer rules than isGeneratedFileStrict to match more generated code.
-// See https://github.com/golangci/golangci-lint/issues/48 and https://github.com/golangci/golangci-lint/issues/72.
-func (p *GeneratedFileFilter) isGeneratedFileLax(doc string) bool {
- markers := []string{genCodeGenerated, genDoNotEdit, genAutoFile, genSwaggerCodegen}
-
- doc = strings.ToLower(doc)
-
- for _, marker := range markers {
- if strings.Contains(doc, marker) {
- p.debugf("doc contains marker %q: file is generated", marker)
-
- return true
- }
- }
-
- p.debugf("doc of len %d doesn't contain any of markers: %s", len(doc), markers)
-
- return false
-}
-
-// isGeneratedFileStrict returns true if the source file has a line that matches the regular expression:
-//
-// ^// Code generated .* DO NOT EDIT\.$
-//
-// This line must appear before the first non-comment, non-blank text in the file.
-// Based on https://go.dev/s/generatedcode.
-func (p *GeneratedFileFilter) isGeneratedFileStrict(filePath string) (bool, error) {
- file, err := parser.ParseFile(token.NewFileSet(), filePath, nil, parser.PackageClauseOnly|parser.ParseComments)
- if err != nil {
- return false, fmt.Errorf("failed to parse file: %w", err)
- }
-
- if file == nil || len(file.Comments) == 0 {
- return false, nil
- }
-
- for _, comment := range file.Comments {
- if comment.Pos() > file.Package {
- return false, nil
- }
-
- for _, line := range comment.List {
- generated := p.strictPattern.MatchString(line.Text)
- if generated {
- p.debugf("doc contains ignore expression: file is generated")
-
- return true, nil
- }
- }
- }
-
- return false, nil
-}
-
-func getComments(filePath string) (string, error) {
- fset := token.NewFileSet()
- syntax, err := parser.ParseFile(fset, filePath, nil, parser.PackageClauseOnly|parser.ParseComments)
- if err != nil {
- return "", fmt.Errorf("failed to parse file: %w", err)
- }
-
- var docLines []string
- for _, c := range syntax.Comments {
- docLines = append(docLines, strings.TrimSpace(c.Text()))
- }
-
- return strings.Join(docLines, "\n"), nil
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/result/processors/exclusion_rules.go b/vendor/github.com/golangci/golangci-lint/pkg/result/processors/exclusion_rules.go
deleted file mode 100644
index 7730a53dd0..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/result/processors/exclusion_rules.go
+++ /dev/null
@@ -1,164 +0,0 @@
-package processors
-
-import (
- "fmt"
- "slices"
- "strings"
-
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/fsutils"
- "github.com/golangci/golangci-lint/pkg/logutils"
- "github.com/golangci/golangci-lint/pkg/result"
-)
-
-var _ Processor = (*ExclusionRules)(nil)
-
-type ExclusionRules struct {
- log logutils.Log
- files *fsutils.Files
-
- warnUnused bool
- skippedCounter map[string]int
-
- rules []excludeRule
-}
-
-func NewExclusionRules(log logutils.Log, files *fsutils.Files,
- cfg *config.LinterExclusions, oldCfg *config.Issues) *ExclusionRules {
- p := &ExclusionRules{
- log: log,
- files: files,
- warnUnused: cfg.WarnUnused,
- skippedCounter: map[string]int{},
- }
-
- // TODO(ldez) remove prefix in v2: the matching must be case sensitive, users can add `(?i)` inside the patterns if needed.
- prefix := caseInsensitivePrefix
- if oldCfg.ExcludeCaseSensitive {
- prefix = ""
- }
-
- excludeRules := slices.Concat(slices.Clone(cfg.Rules),
- filterInclude(getLinterExclusionPresets(cfg.Presets), oldCfg.IncludeDefaultExcludes))
-
- p.rules = parseRules(excludeRules, prefix, newExcludeRule)
-
- // TODO(ldez): should be removed in v2.
- for _, pattern := range oldCfg.ExcludePatterns {
- if pattern == "" {
- continue
- }
-
- r := &config.ExcludeRule{
- BaseRule: config.BaseRule{
- Path: `.+\.go`,
- Text: pattern,
- },
- }
-
- rule := newExcludeRule(r, prefix)
-
- p.rules = append(p.rules, rule)
- }
-
- for _, rule := range p.rules {
- if rule.internalReference == "" {
- p.skippedCounter[rule.String()] = 0
- }
- }
-
- return p
-}
-
-func (*ExclusionRules) Name() string {
- return "exclusion_rules"
-}
-
-func (p *ExclusionRules) Process(issues []result.Issue) ([]result.Issue, error) {
- if len(p.rules) == 0 {
- return issues, nil
- }
-
- return filterIssues(issues, func(issue *result.Issue) bool {
- for _, rule := range p.rules {
- if !rule.match(issue, p.files, p.log) {
- continue
- }
-
- // Ignore default rules.
- if rule.internalReference == "" {
- p.skippedCounter[rule.String()]++
- }
-
- return false
- }
-
- return true
- }), nil
-}
-
-func (p *ExclusionRules) Finish() {
- for rule, count := range p.skippedCounter {
- if p.warnUnused && count == 0 {
- p.log.Warnf("Skipped %d issues by rules: [%s]", count, rule)
- } else {
- p.log.Infof("Skipped %d issues by rules: [%s]", count, rule)
- }
- }
-}
-
-type excludeRule struct {
- baseRule
-
- // For compatibility with exclude-use-default/include.
- internalReference string `mapstructure:"-"`
-}
-
-func newExcludeRule(rule *config.ExcludeRule, prefix string) excludeRule {
- return excludeRule{
- baseRule: newBaseRule(&rule.BaseRule, prefix),
- internalReference: rule.InternalReference,
- }
-}
-
-func (e excludeRule) String() string {
- var msg []string
-
- if e.text != nil && e.text.String() != "" {
- msg = append(msg, fmt.Sprintf("Text: %q", e.text))
- }
-
- if e.source != nil && e.source.String() != "" {
- msg = append(msg, fmt.Sprintf("Source: %q", e.source))
- }
-
- if e.path != nil && e.path.String() != "" {
- msg = append(msg, fmt.Sprintf("Path: %q", e.path))
- }
-
- if e.pathExcept != nil && e.pathExcept.String() != "" {
- msg = append(msg, fmt.Sprintf("Path Except: %q", e.pathExcept))
- }
-
- if len(e.linters) > 0 {
- msg = append(msg, fmt.Sprintf("Linters: %q", strings.Join(e.linters, ", ")))
- }
-
- return strings.Join(msg, ", ")
-}
-
-// TODO(ldez): must be removed in v2, only for compatibility with exclude-use-default/include.
-func filterInclude(rules []config.ExcludeRule, refs []string) []config.ExcludeRule {
- if len(refs) == 0 {
- return rules
- }
-
- var filteredRules []config.ExcludeRule
- for _, rule := range rules {
- if !slices.Contains(refs, rule.InternalReference) {
- filteredRules = append(filteredRules, rule)
- }
- }
-
- return filteredRules
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/result/processors/identifier_marker.go b/vendor/github.com/golangci/golangci-lint/pkg/result/processors/identifier_marker.go
deleted file mode 100644
index 9f332705e1..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/result/processors/identifier_marker.go
+++ /dev/null
@@ -1,145 +0,0 @@
-package processors
-
-import (
- "regexp"
-
- "github.com/golangci/golangci-lint/pkg/result"
-)
-
-var _ Processor = (*IdentifierMarker)(nil)
-
-type replacePattern struct {
- exp *regexp.Regexp
- repl string
-}
-
-// IdentifierMarker modifies report text.
-// It must be before [Exclude] and [ExcludeRules]:
-// users configure exclusions based on the modified text.
-type IdentifierMarker struct {
- patterns map[string][]replacePattern
-}
-
-func NewIdentifierMarker() *IdentifierMarker {
- return &IdentifierMarker{
- patterns: map[string][]replacePattern{
- "unparam": {
- {
- exp: regexp.MustCompile(`^(\S+) - (\S+) is unused$`),
- repl: "`${1}` - `${2}` is unused",
- },
- {
- exp: regexp.MustCompile(`^(\S+) - (\S+) always receives (\S+) \((.*)\)$`),
- repl: "`${1}` - `${2}` always receives `${3}` (`${4}`)",
- },
- {
- exp: regexp.MustCompile(`^(\S+) - (\S+) always receives (.*)$`),
- repl: "`${1}` - `${2}` always receives `${3}`",
- },
- {
- exp: regexp.MustCompile(`^(\S+) - result (\S+) is always (\S+)`),
- repl: "`${1}` - result `${2}` is always `${3}`",
- },
- },
- "govet": {
- {
- // printf
- exp: regexp.MustCompile(`^printf: (\S+) arg list ends with redundant newline$`),
- repl: "printf: `${1}` arg list ends with redundant newline",
- },
- },
- "gosec": {
- {
- exp: regexp.MustCompile(`^TLS InsecureSkipVerify set true.$`),
- repl: "TLS `InsecureSkipVerify` set true.",
- },
- },
- "gosimple": {
- {
- // s1011
- exp: regexp.MustCompile(`should replace loop with (.*)$`),
- repl: "should replace loop with `${1}`",
- },
- {
- // s1000
- exp: regexp.MustCompile(`should use a simple channel send/receive instead of select with a single case`),
- repl: "should use a simple channel send/receive instead of `select` with a single case",
- },
- {
- // s1002
- exp: regexp.MustCompile(`should omit comparison to bool constant, can be simplified to (.+)$`),
- repl: "should omit comparison to bool constant, can be simplified to `${1}`",
- },
- {
- // s1023
- exp: regexp.MustCompile(`redundant return statement$`),
- repl: "redundant `return` statement",
- },
- {
- // s1017
- exp: regexp.MustCompile(`should replace this if statement with an unconditional strings.TrimPrefix`),
- repl: "should replace this `if` statement with an unconditional `strings.TrimPrefix`",
- },
- },
- "staticcheck": {
- {
- // sa4006
- exp: regexp.MustCompile(`this value of (\S+) is never used$`),
- repl: "this value of `${1}` is never used",
- },
- {
- // s1012
- exp: regexp.MustCompile(`should use time.Since instead of time.Now\(\).Sub$`),
- repl: "should use `time.Since` instead of `time.Now().Sub`",
- },
- {
- // sa5001
- exp: regexp.MustCompile(`should check returned error before deferring response.Close\(\)$`),
- repl: "should check returned error before deferring `response.Close()`",
- },
- {
- // sa4003
- exp: regexp.MustCompile(`no value of type uint is less than 0$`),
- repl: "no value of type `uint` is less than `0`",
- },
- },
- "unused": {
- {
- exp: regexp.MustCompile(`(func|const|field|type|var) (\S+) is unused$`),
- repl: "${1} `${2}` is unused",
- },
- },
- },
- }
-}
-
-func (*IdentifierMarker) Name() string {
- return "identifier_marker"
-}
-
-func (p *IdentifierMarker) Process(issues []result.Issue) ([]result.Issue, error) {
- return transformIssues(issues, func(issue *result.Issue) *result.Issue {
- re, ok := p.patterns[issue.FromLinter]
- if !ok {
- return issue
- }
-
- newIssue := *issue
- newIssue.Text = markIdentifiers(re, newIssue.Text)
-
- return &newIssue
- }), nil
-}
-
-func (*IdentifierMarker) Finish() {}
-
-func markIdentifiers(re []replacePattern, text string) string {
- for _, rr := range re {
- rs := rr.exp.ReplaceAllString(text, rr.repl)
- if rs != text {
- return rs
- }
- }
-
- return text
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/result/processors/issues.go b/vendor/github.com/golangci/golangci-lint/pkg/result/processors/issues.go
deleted file mode 100644
index ab443b87d7..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/result/processors/issues.go
+++ /dev/null
@@ -1,69 +0,0 @@
-package processors
-
-import (
- "fmt"
-
- "github.com/golangci/golangci-lint/pkg/result"
-)
-
-func filterIssues(issues []result.Issue, filter func(issue *result.Issue) bool) []result.Issue {
- retIssues := make([]result.Issue, 0, len(issues))
- for i := range issues {
- if issues[i].FromLinter == typeCheckName {
- // don't hide typechecking errors in generated files: users expect to see why the project isn't compiling
- retIssues = append(retIssues, issues[i])
- continue
- }
-
- if filter(&issues[i]) {
- retIssues = append(retIssues, issues[i])
- }
- }
-
- return retIssues
-}
-
-func filterIssuesUnsafe(issues []result.Issue, filter func(issue *result.Issue) bool) []result.Issue {
- retIssues := make([]result.Issue, 0, len(issues))
- for i := range issues {
- if filter(&issues[i]) {
- retIssues = append(retIssues, issues[i])
- }
- }
-
- return retIssues
-}
-
-func filterIssuesErr(issues []result.Issue, filter func(issue *result.Issue) (bool, error)) ([]result.Issue, error) {
- retIssues := make([]result.Issue, 0, len(issues))
- for i := range issues {
- if issues[i].FromLinter == typeCheckName {
- // don't hide typechecking errors in generated files: users expect to see why the project isn't compiling
- retIssues = append(retIssues, issues[i])
- continue
- }
-
- ok, err := filter(&issues[i])
- if err != nil {
- return nil, fmt.Errorf("can't filter issue %#v: %w", issues[i], err)
- }
-
- if ok {
- retIssues = append(retIssues, issues[i])
- }
- }
-
- return retIssues, nil
-}
-
-func transformIssues(issues []result.Issue, transform func(issue *result.Issue) *result.Issue) []result.Issue {
- retIssues := make([]result.Issue, 0, len(issues))
- for i := range issues {
- newIssue := transform(&issues[i])
- if newIssue != nil {
- retIssues = append(retIssues, *newIssue)
- }
- }
-
- return retIssues
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/result/processors/max_per_file_from_linter.go b/vendor/github.com/golangci/golangci-lint/pkg/result/processors/max_per_file_from_linter.go
deleted file mode 100644
index 7c59b5dd60..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/result/processors/max_per_file_from_linter.go
+++ /dev/null
@@ -1,75 +0,0 @@
-package processors
-
-import (
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/result"
-)
-
-var _ Processor = (*MaxPerFileFromLinter)(nil)
-
-// MaxPerFileFromLinter limits the number of reports by file and by linter.
-type MaxPerFileFromLinter struct {
- fileLinterCounter fileLinterCounter
- maxPerFileFromLinterConfig map[string]int
-}
-
-func NewMaxPerFileFromLinter(cfg *config.Config) *MaxPerFileFromLinter {
- maxPerFileFromLinterConfig := map[string]int{}
-
- if !cfg.Issues.NeedFix {
- // if we don't fix we do this limiting to not annoy user;
- // otherwise we need to fix all issues in the file at once
- maxPerFileFromLinterConfig["gofmt"] = 1
- maxPerFileFromLinterConfig["goimports"] = 1
- maxPerFileFromLinterConfig["gci"] = 1
- }
-
- return &MaxPerFileFromLinter{
- fileLinterCounter: fileLinterCounter{},
- maxPerFileFromLinterConfig: maxPerFileFromLinterConfig,
- }
-}
-
-func (*MaxPerFileFromLinter) Name() string {
- return "max_per_file_from_linter"
-}
-
-func (p *MaxPerFileFromLinter) Process(issues []result.Issue) ([]result.Issue, error) {
- return filterIssuesUnsafe(issues, func(issue *result.Issue) bool {
- limit := p.maxPerFileFromLinterConfig[issue.FromLinter]
- if limit == 0 {
- return true
- }
-
- if p.fileLinterCounter.GetCount(issue) >= limit {
- return false
- }
-
- p.fileLinterCounter.Increment(issue)
-
- return true
- }), nil
-}
-
-func (*MaxPerFileFromLinter) Finish() {}
-
-type fileLinterCounter map[string]map[string]int
-
-func (f fileLinterCounter) GetCount(issue *result.Issue) int {
- return f.getCounter(issue)[issue.FromLinter]
-}
-
-func (f fileLinterCounter) Increment(issue *result.Issue) {
- f.getCounter(issue)[issue.FromLinter]++
-}
-
-func (f fileLinterCounter) getCounter(issue *result.Issue) map[string]int {
- lc := f[issue.FilePath()]
-
- if lc == nil {
- lc = map[string]int{}
- f[issue.FilePath()] = lc
- }
-
- return lc
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/result/processors/path_prettifier.go b/vendor/github.com/golangci/golangci-lint/pkg/result/processors/path_prettifier.go
deleted file mode 100644
index 6a04b1c359..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/result/processors/path_prettifier.go
+++ /dev/null
@@ -1,39 +0,0 @@
-package processors
-
-import (
- "github.com/golangci/golangci-lint/pkg/fsutils"
- "github.com/golangci/golangci-lint/pkg/logutils"
- "github.com/golangci/golangci-lint/pkg/result"
-)
-
-var _ Processor = (*PathPrettifier)(nil)
-
-// PathPrettifier modifies report file path to be relative to the base path.
-// Also handles the `output.path-prefix` option.
-type PathPrettifier struct {
- prefix string
- log logutils.Log
-}
-
-func NewPathPrettifier(log logutils.Log, prefix string) *PathPrettifier {
- return &PathPrettifier{
- prefix: prefix,
- log: log.Child(logutils.DebugKeyPathPrettifier),
- }
-}
-
-func (*PathPrettifier) Name() string {
- return "path_prettifier"
-}
-
-func (p *PathPrettifier) Process(issues []result.Issue) ([]result.Issue, error) {
- return transformIssues(issues, func(issue *result.Issue) *result.Issue {
- newIssue := issue
-
- newIssue.Pos.Filename = fsutils.WithPathPrefix(p.prefix, issue.RelativePath)
-
- return newIssue
- }), nil
-}
-
-func (*PathPrettifier) Finish() {}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/result/processors/processor.go b/vendor/github.com/golangci/golangci-lint/pkg/result/processors/processor.go
deleted file mode 100644
index 13e63d6046..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/result/processors/processor.go
+++ /dev/null
@@ -1,13 +0,0 @@
-package processors
-
-import (
- "github.com/golangci/golangci-lint/pkg/result"
-)
-
-const typeCheckName = "typecheck"
-
-type Processor interface {
- Process(issues []result.Issue) ([]result.Issue, error)
- Name() string
- Finish()
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/result/processors/severity.go b/vendor/github.com/golangci/golangci-lint/pkg/result/processors/severity.go
deleted file mode 100644
index 2dacf66387..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/result/processors/severity.go
+++ /dev/null
@@ -1,92 +0,0 @@
-package processors
-
-import (
- "cmp"
-
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/fsutils"
- "github.com/golangci/golangci-lint/pkg/logutils"
- "github.com/golangci/golangci-lint/pkg/result"
-)
-
-const severityFromLinter = "@linter"
-
-var _ Processor = (*Severity)(nil)
-
-// Severity modifies report severity.
-// It uses the same `baseRule` structure as [ExcludeRules] processor.
-//
-// Warning: it doesn't use `path-prefix` option.
-type Severity struct {
- name string
-
- log logutils.Log
-
- files *fsutils.Files
-
- defaultSeverity string
- rules []severityRule
-}
-
-func NewSeverity(log logutils.Log, files *fsutils.Files, cfg *config.Severity) *Severity {
- p := &Severity{
- name: "severity-rules",
- files: files,
- log: log,
- defaultSeverity: cfg.Default,
- }
-
- prefix := caseInsensitivePrefix
- if cfg.CaseSensitive {
- prefix = ""
- p.name = "severity-rules-case-sensitive"
- }
-
- p.rules = parseRules(cfg.Rules, prefix, newSeverityRule)
-
- return p
-}
-
-func (p *Severity) Name() string { return p.name }
-
-func (p *Severity) Process(issues []result.Issue) ([]result.Issue, error) {
- if len(p.rules) == 0 && p.defaultSeverity == "" {
- return issues, nil
- }
-
- return transformIssues(issues, p.transform), nil
-}
-
-func (*Severity) Finish() {}
-
-func (p *Severity) transform(issue *result.Issue) *result.Issue {
- for _, rule := range p.rules {
- if rule.match(issue, p.files, p.log) {
- if rule.severity == severityFromLinter || (rule.severity == "" && p.defaultSeverity == severityFromLinter) {
- return issue
- }
-
- issue.Severity = cmp.Or(rule.severity, p.defaultSeverity)
-
- return issue
- }
- }
-
- if p.defaultSeverity != severityFromLinter {
- issue.Severity = p.defaultSeverity
- }
-
- return issue
-}
-
-type severityRule struct {
- baseRule
- severity string
-}
-
-func newSeverityRule(rule *config.SeverityRule, prefix string) severityRule {
- return severityRule{
- baseRule: newBaseRule(&rule.BaseRule, prefix),
- severity: rule.Severity,
- }
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/result/processors/skip_dirs.go b/vendor/github.com/golangci/golangci-lint/pkg/result/processors/skip_dirs.go
deleted file mode 100644
index 8900c96a92..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/result/processors/skip_dirs.go
+++ /dev/null
@@ -1,180 +0,0 @@
-package processors
-
-import (
- "fmt"
- "path/filepath"
- "regexp"
-
- "github.com/golangci/golangci-lint/pkg/fsutils"
- "github.com/golangci/golangci-lint/pkg/logutils"
- "github.com/golangci/golangci-lint/pkg/result"
-)
-
-var _ Processor = (*SkipDirs)(nil)
-
-var StdExcludeDirRegexps = []string{
- normalizePathRegex("vendor"),
- normalizePathRegex("third_party"),
- normalizePathRegex("testdata"),
- normalizePathRegex("examples"),
- normalizePathRegex("Godeps"),
- normalizePathRegex("builtin"),
-}
-
-type skipStat struct {
- pattern string
- count int
-}
-
-// SkipDirs filters reports based on directory names.
-// It uses the shortest relative paths and `path-prefix` option.
-// TODO(ldez): should be removed in v2.
-type SkipDirs struct {
- patterns []*regexp.Regexp
- pathPrefix string
-
- log logutils.Log
-
- skippedDirs map[string]*skipStat
- absArgsDirs []string
- skippedDirsCache map[string]bool
-}
-
-func NewSkipDirs(log logutils.Log, patterns, args []string, pathPrefix string) (*SkipDirs, error) {
- var patternsRe []*regexp.Regexp
- for _, p := range patterns {
- p = fsutils.NormalizePathInRegex(p)
-
- patternRe, err := regexp.Compile(p)
- if err != nil {
- return nil, fmt.Errorf("can't compile regexp %q: %w", p, err)
- }
-
- patternsRe = append(patternsRe, patternRe)
- }
-
- absArgsDirs, err := absDirs(args)
- if err != nil {
- return nil, err
- }
-
- return &SkipDirs{
- patterns: patternsRe,
- pathPrefix: pathPrefix,
- log: log,
- skippedDirs: map[string]*skipStat{},
- absArgsDirs: absArgsDirs,
- skippedDirsCache: map[string]bool{},
- }, nil
-}
-
-func (*SkipDirs) Name() string {
- return "skip_dirs"
-}
-
-func (p *SkipDirs) Process(issues []result.Issue) ([]result.Issue, error) {
- if len(p.patterns) == 0 {
- return issues, nil
- }
-
- return filterIssues(issues, p.shouldPassIssue), nil
-}
-
-func (p *SkipDirs) Finish() {
- for dir, stat := range p.skippedDirs {
- p.log.Infof("Skipped %d issues from dir %s by pattern %s", stat.count, dir, stat.pattern)
- }
-}
-
-func (p *SkipDirs) shouldPassIssue(issue *result.Issue) bool {
- issueRelDir := filepath.Dir(issue.RelativePath)
-
- if toPass, ok := p.skippedDirsCache[issueRelDir]; ok {
- if !toPass {
- p.skippedDirs[issueRelDir].count++
- }
-
- return toPass
- }
-
- issueAbsDir, err := filepath.Abs(issueRelDir)
- if err != nil {
- p.log.Warnf("Can't abs-ify path %q: %s", issueRelDir, err)
-
- return true
- }
-
- toPass := p.shouldPassIssueDirs(issueRelDir, issueAbsDir)
-
- p.skippedDirsCache[issueRelDir] = toPass
-
- return toPass
-}
-
-func (p *SkipDirs) shouldPassIssueDirs(issueRelDir, issueAbsDir string) bool {
- for _, absArgDir := range p.absArgsDirs {
- if absArgDir == issueAbsDir {
- // we must not skip issues if they are from explicitly set dirs
- // even if they match skip patterns
- return true
- }
- }
-
- // We use issueRelDir for matching: it's the relative to the current
- // work dir path of directory of source file with the issue. It can lead
- // to unexpected behavior if we're analyzing files out of current work dir.
- // The alternative solution is to find relative to args path, but it has
- // disadvantages (https://github.com/golangci/golangci-lint/pull/313).
-
- path := fsutils.WithPathPrefix(p.pathPrefix, issueRelDir)
-
- for _, pattern := range p.patterns {
- if pattern.MatchString(path) {
- ps := pattern.String()
-
- if p.skippedDirs[issueRelDir] == nil {
- p.skippedDirs[issueRelDir] = &skipStat{
- pattern: ps,
- }
- }
-
- p.skippedDirs[issueRelDir].count++
-
- return false
- }
- }
-
- return true
-}
-
-func absDirs(args []string) ([]string, error) {
- if len(args) == 0 {
- args = append(args, "./...")
- }
-
- var absArgsDirs []string
- for _, arg := range args {
- base := filepath.Base(arg)
- if base == "..." || isGoFile(base) {
- arg = filepath.Dir(arg)
- }
-
- absArg, err := filepath.Abs(arg)
- if err != nil {
- return nil, fmt.Errorf("failed to abs-ify arg %q: %w", arg, err)
- }
-
- absArgsDirs = append(absArgsDirs, absArg)
- }
-
- return absArgsDirs, nil
-}
-
-func normalizePathRegex(e string) string {
- return createPathRegex(e, filepath.Separator)
-}
-
-func createPathRegex(e string, sep rune) string {
- escapedSep := regexp.QuoteMeta(string(sep)) // needed for windows sep '\\'
- return fmt.Sprintf(`(^|%[1]s)%[2]s($|%[1]s)`, escapedSep, e)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/result/processors/skip_files.go b/vendor/github.com/golangci/golangci-lint/pkg/result/processors/skip_files.go
deleted file mode 100644
index 5907cf6777..0000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/result/processors/skip_files.go
+++ /dev/null
@@ -1,65 +0,0 @@
-package processors
-
-import (
- "fmt"
- "regexp"
-
- "github.com/golangci/golangci-lint/pkg/fsutils"
- "github.com/golangci/golangci-lint/pkg/result"
-)
-
-var _ Processor = (*SkipFiles)(nil)
-
-// SkipFiles filters reports based on filename.
-//
-// It uses the shortest relative paths and `path-prefix` option.
-// TODO(ldez): should be removed in v2.
-type SkipFiles struct {
- patterns []*regexp.Regexp
- pathPrefix string
-}
-
-func NewSkipFiles(patterns []string, pathPrefix string) (*SkipFiles, error) {
- var patternsRe []*regexp.Regexp
- for _, p := range patterns {
- p = fsutils.NormalizePathInRegex(p)
-
- patternRe, err := regexp.Compile(p)
- if err != nil {
- return nil, fmt.Errorf("can't compile regexp %q: %w", p, err)
- }
-
- patternsRe = append(patternsRe, patternRe)
- }
-
- return &SkipFiles{
- patterns: patternsRe,
- pathPrefix: pathPrefix,
- }, nil
-}
-
-func (*SkipFiles) Name() string {
- return "skip_files"
-}
-
-func (p *SkipFiles) Process(issues []result.Issue) ([]result.Issue, error) {
- if len(p.patterns) == 0 {
- return issues, nil
- }
-
- return filterIssues(issues, p.shouldPassIssue), nil
-}
-
-func (*SkipFiles) Finish() {}
-
-func (p *SkipFiles) shouldPassIssue(issue *result.Issue) bool {
- path := fsutils.WithPathPrefix(p.pathPrefix, issue.RelativePath)
-
- for _, pattern := range p.patterns {
- if pattern.MatchString(path) {
- return false
- }
- }
-
- return true
-}
diff --git a/vendor/github.com/golangci/golangci-lint/LICENSE b/vendor/github.com/golangci/golangci-lint/v2/LICENSE
similarity index 100%
rename from vendor/github.com/golangci/golangci-lint/LICENSE
rename to vendor/github.com/golangci/golangci-lint/v2/LICENSE
diff --git a/vendor/github.com/golangci/golangci-lint/v2/cmd/golangci-lint/main.go b/vendor/github.com/golangci/golangci-lint/v2/cmd/golangci-lint/main.go
new file mode 100644
index 0000000000..acb09cd8c0
--- /dev/null
+++ b/vendor/github.com/golangci/golangci-lint/v2/cmd/golangci-lint/main.go
@@ -0,0 +1,80 @@
+package main
+
+import (
+ "cmp"
+ "fmt"
+ "os"
+ "regexp"
+ "runtime/debug"
+ "strings"
+
+ "github.com/golangci/golangci-lint/v2/pkg/commands"
+ "github.com/golangci/golangci-lint/v2/pkg/exitcodes"
+)
+
+var (
+ goVersion = "unknown"
+
+ // Populated by goreleaser during build
+ version = "unknown"
+ commit = "?"
+ date = ""
+)
+
+func main() {
+ info := createBuildInfo()
+
+ if err := commands.Execute(info); err != nil {
+ _, _ = fmt.Fprintf(os.Stderr, "The command is terminated due to an error: %v\n", err)
+ os.Exit(exitcodes.Failure)
+ }
+}
+
+func createBuildInfo() commands.BuildInfo {
+ info := commands.BuildInfo{
+ Commit: commit,
+ Version: version,
+ GoVersion: goVersion,
+ Date: date,
+ }
+
+ buildInfo, available := debug.ReadBuildInfo()
+ if !available {
+ return info
+ }
+
+ info.GoVersion = buildInfo.GoVersion
+
+ if date != "" {
+ return info
+ }
+
+ info.Version = buildInfo.Main.Version
+
+ matched, _ := regexp.MatchString(`v\d+\.\d+\.\d+`, buildInfo.Main.Version)
+ if matched {
+ info.Version = strings.TrimPrefix(buildInfo.Main.Version, "v")
+ }
+
+ var revision string
+ var modified string
+ for _, setting := range buildInfo.Settings {
+ // The `vcs.xxx` information is only available with `go build`.
+ // This information is not available with `go install` or `go run`.
+ switch setting.Key {
+ case "vcs.time":
+ info.Date = setting.Value
+ case "vcs.revision":
+ revision = setting.Value
+ case "vcs.modified":
+ modified = setting.Value
+ }
+ }
+
+ info.Date = cmp.Or(info.Date, "(unknown)")
+
+ info.Commit = fmt.Sprintf("(%s, modified: %s, mod sum: %q)",
+ cmp.Or(revision, "unknown"), cmp.Or(modified, "?"), buildInfo.Main.Sum)
+
+ return info
+}
diff --git a/vendor/github.com/golangci/golangci-lint/cmd/golangci-lint/plugins.go b/vendor/github.com/golangci/golangci-lint/v2/cmd/golangci-lint/plugins.go
similarity index 100%
rename from vendor/github.com/golangci/golangci-lint/cmd/golangci-lint/plugins.go
rename to vendor/github.com/golangci/golangci-lint/v2/cmd/golangci-lint/plugins.go
diff --git a/vendor/github.com/golangci/golangci-lint/v2/internal/cache/cache.go b/vendor/github.com/golangci/golangci-lint/v2/internal/cache/cache.go
new file mode 100644
index 0000000000..e681b6ee46
--- /dev/null
+++ b/vendor/github.com/golangci/golangci-lint/v2/internal/cache/cache.go
@@ -0,0 +1,300 @@
+package cache
+
+import (
+ "bytes"
+ "encoding/gob"
+ "encoding/hex"
+ "errors"
+ "fmt"
+ "maps"
+ "runtime"
+ "slices"
+ "strings"
+ "sync"
+
+ "golang.org/x/tools/go/packages"
+
+ "github.com/golangci/golangci-lint/v2/internal/go/cache"
+ "github.com/golangci/golangci-lint/v2/pkg/logutils"
+ "github.com/golangci/golangci-lint/v2/pkg/timeutils"
+)
+
+type HashMode int
+
+const (
+ HashModeNeedOnlySelf HashMode = iota
+ HashModeNeedDirectDeps
+ HashModeNeedAllDeps
+)
+
+var ErrMissing = errors.New("missing data")
+
+type hashResults map[HashMode]string
+
+// Cache is a per-package data cache.
+// A cached data is invalidated when package,
+// or it's dependencies change.
+type Cache struct {
+ lowLevelCache cache.Cache
+ pkgHashes sync.Map
+ sw *timeutils.Stopwatch
+ log logutils.Log
+ ioSem chan struct{} // semaphore limiting parallel IO
+}
+
+func NewCache(sw *timeutils.Stopwatch, log logutils.Log) (*Cache, error) {
+ return &Cache{
+ lowLevelCache: cache.Default(),
+ sw: sw,
+ log: log,
+ ioSem: make(chan struct{}, runtime.GOMAXPROCS(-1)),
+ }, nil
+}
+
+func (c *Cache) Close() {
+ err := c.sw.TrackStageErr("close", c.lowLevelCache.Close)
+ if err != nil {
+ c.log.Errorf("cache close: %v", err)
+ }
+}
+
+func (c *Cache) Put(pkg *packages.Package, mode HashMode, key string, data any) error {
+ buf, err := c.encode(data)
+ if err != nil {
+ return err
+ }
+
+ actionID, err := c.buildKey(pkg, mode, key)
+ if err != nil {
+ return fmt.Errorf("failed to calculate package %s action id: %w", pkg.Name, err)
+ }
+
+ err = c.putBytes(actionID, buf)
+ if err != nil {
+ return fmt.Errorf("failed to save data to low-level cache by key %s for package %s: %w", key, pkg.Name, err)
+ }
+
+ return nil
+}
+
+func (c *Cache) Get(pkg *packages.Package, mode HashMode, key string, data any) error {
+ actionID, err := c.buildKey(pkg, mode, key)
+ if err != nil {
+ return fmt.Errorf("failed to calculate package %s action id: %w", pkg.Name, err)
+ }
+
+ cachedData, err := c.getBytes(actionID)
+ if err != nil {
+ if cache.IsErrMissing(err) {
+ return ErrMissing
+ }
+ return fmt.Errorf("failed to get data from low-level cache by key %s for package %s: %w", key, pkg.Name, err)
+ }
+
+ return c.decode(cachedData, data)
+}
+
+func (c *Cache) buildKey(pkg *packages.Package, mode HashMode, key string) (cache.ActionID, error) {
+ return timeutils.TrackStage(c.sw, "key build", func() (cache.ActionID, error) {
+ actionID, err := c.pkgActionID(pkg, mode)
+ if err != nil {
+ return actionID, err
+ }
+
+ subkey, subkeyErr := cache.Subkey(actionID, key)
+ if subkeyErr != nil {
+ return actionID, fmt.Errorf("failed to build subkey: %w", subkeyErr)
+ }
+
+ return subkey, nil
+ })
+}
+
+func (c *Cache) pkgActionID(pkg *packages.Package, mode HashMode) (cache.ActionID, error) {
+ hash, err := c.packageHash(pkg, mode)
+ if err != nil {
+ return cache.ActionID{}, fmt.Errorf("failed to get package hash: %w", err)
+ }
+
+ key, err := cache.NewHash("action ID")
+ if err != nil {
+ return cache.ActionID{}, fmt.Errorf("failed to make a hash: %w", err)
+ }
+
+ fmt.Fprintf(key, "pkgpath %s\n", pkg.PkgPath)
+ fmt.Fprintf(key, "pkghash %s\n", hash)
+
+ return key.Sum(), nil
+}
+
+func (c *Cache) packageHash(pkg *packages.Package, mode HashMode) (string, error) {
+ results, found := c.pkgHashes.Load(pkg)
+ if found {
+ hashRes := results.(hashResults)
+ if result, ok := hashRes[mode]; ok {
+ return result, nil
+ }
+
+ return "", fmt.Errorf("no mode %d in hash result", mode)
+ }
+
+ hashRes, err := c.computePkgHash(pkg)
+ if err != nil {
+ return "", err
+ }
+
+ result, found := hashRes[mode]
+ if !found {
+ return "", fmt.Errorf("invalid mode %d", mode)
+ }
+
+ c.pkgHashes.Store(pkg, hashRes)
+
+ return result, nil
+}
+
+// computePkgHash computes a package's hash.
+// The hash is based on all Go files that make up the package,
+// as well as the hashes of imported packages.
+func (c *Cache) computePkgHash(pkg *packages.Package) (hashResults, error) {
+ key, err := cache.NewHash("package hash")
+ if err != nil {
+ return nil, fmt.Errorf("failed to make a hash: %w", err)
+ }
+
+ hashRes := hashResults{}
+
+ fmt.Fprintf(key, "pkgpath %s\n", pkg.PkgPath)
+
+ for _, f := range slices.Concat(pkg.CompiledGoFiles, pkg.IgnoredFiles) {
+ h, fErr := c.fileHash(f)
+ if fErr != nil {
+ return nil, fmt.Errorf("failed to calculate file %s hash: %w", f, fErr)
+ }
+
+ if rel, ok := toRelativePath(pkg.Module, f); ok {
+ f = pkg.Module.Path + "/" + rel
+ }
+
+ fmt.Fprintf(key, "file %s %x\n", f, h)
+ }
+
+ curSum := key.Sum()
+ hashRes[HashModeNeedOnlySelf] = hex.EncodeToString(curSum[:])
+
+ imps := slices.SortedFunc(maps.Values(pkg.Imports), func(a, b *packages.Package) int {
+ return strings.Compare(a.PkgPath, b.PkgPath)
+ })
+
+ if err := c.computeDepsHash(HashModeNeedOnlySelf, imps, key); err != nil {
+ return nil, err
+ }
+
+ curSum = key.Sum()
+ hashRes[HashModeNeedDirectDeps] = hex.EncodeToString(curSum[:])
+
+ if err := c.computeDepsHash(HashModeNeedAllDeps, imps, key); err != nil {
+ return nil, err
+ }
+
+ curSum = key.Sum()
+ hashRes[HashModeNeedAllDeps] = hex.EncodeToString(curSum[:])
+
+ return hashRes, nil
+}
+
+func (c *Cache) computeDepsHash(depMode HashMode, imps []*packages.Package, key *cache.Hash) error {
+ for _, dep := range imps {
+ if dep.PkgPath == "unsafe" {
+ continue
+ }
+
+ depHash, err := c.packageHash(dep, depMode)
+ if err != nil {
+ return fmt.Errorf("failed to calculate hash for dependency %s with mode %d: %w", dep.Name, depMode, err)
+ }
+
+ fmt.Fprintf(key, "import %s %s\n", dep.PkgPath, depHash)
+ }
+
+ return nil
+}
+
+func (c *Cache) putBytes(actionID cache.ActionID, buf *bytes.Buffer) error {
+ c.ioSem <- struct{}{}
+
+ err := c.sw.TrackStageErr("cache io", func() error {
+ return cache.PutBytes(c.lowLevelCache, actionID, buf.Bytes())
+ })
+
+ <-c.ioSem
+
+ if err != nil {
+ return err
+ }
+
+ return nil
+}
+
+func (c *Cache) getBytes(actionID cache.ActionID) ([]byte, error) {
+ c.ioSem <- struct{}{}
+
+ cachedData, err := timeutils.TrackStage(c.sw, "cache io", func() ([]byte, error) {
+ b, _, errGB := cache.GetBytes(c.lowLevelCache, actionID)
+ return b, errGB
+ })
+
+ <-c.ioSem
+
+ if err != nil {
+ return nil, err
+ }
+
+ return cachedData, nil
+}
+
+func (c *Cache) fileHash(f string) ([cache.HashSize]byte, error) {
+ c.ioSem <- struct{}{}
+
+ h, err := cache.FileHash(f)
+
+ <-c.ioSem
+
+ if err != nil {
+ return [cache.HashSize]byte{}, err
+ }
+
+ return h, nil
+}
+
+func (c *Cache) encode(data any) (*bytes.Buffer, error) {
+ buf := &bytes.Buffer{}
+ err := c.sw.TrackStageErr("gob", func() error {
+ return gob.NewEncoder(buf).Encode(data)
+ })
+ if err != nil {
+ return nil, fmt.Errorf("failed to gob encode: %w", err)
+ }
+
+ return buf, nil
+}
+
+func (c *Cache) decode(b []byte, data any) error {
+ err := c.sw.TrackStageErr("gob", func() error {
+ return gob.NewDecoder(bytes.NewReader(b)).Decode(data)
+ })
+ if err != nil {
+ return fmt.Errorf("failed to gob decode: %w", err)
+ }
+
+ return nil
+}
+
+func SetSalt(b *bytes.Buffer) {
+ cache.SetSalt(b.Bytes())
+}
+
+func DefaultDir() (string, error) {
+ cacheDir, _, err := cache.DefaultDir()
+ return cacheDir, err
+}
diff --git a/vendor/github.com/golangci/golangci-lint/v2/internal/cache/position.go b/vendor/github.com/golangci/golangci-lint/v2/internal/cache/position.go
new file mode 100644
index 0000000000..88cf2b4a40
--- /dev/null
+++ b/vendor/github.com/golangci/golangci-lint/v2/internal/cache/position.go
@@ -0,0 +1,54 @@
+package cache
+
+import (
+ "go/token"
+ "path/filepath"
+ "strings"
+
+ "golang.org/x/tools/go/packages"
+)
+
+// RelativePosition creates a [token.Position] with a filename relative to the module directory.
+func RelativePosition(mod *packages.Module, pos token.Position) token.Position {
+ pos.Filename, _ = toRelativePath(mod, pos.Filename)
+
+ return pos
+}
+
+// AbsolutionPosition creates the absolute path base on the module directory.
+func AbsolutionPosition(mod *packages.Module, pos token.Position) token.Position {
+ pos.Filename = toAbsolutePath(mod, pos.Filename)
+
+ return pos
+}
+
+func toRelativePath(mod *packages.Module, filename string) (string, bool) {
+ if filename == "" || !isCurrentModule(mod) {
+ return filename, false
+ }
+
+ rel, err := filepath.Rel(mod.Dir, filename)
+ if err != nil {
+ return filename, false
+ }
+
+ rel = filepath.ToSlash(rel)
+
+ if rel == ".." || strings.HasPrefix(rel, "../") {
+ return filename, false
+ }
+
+ return rel, true
+}
+
+func toAbsolutePath(mod *packages.Module, filename string) string {
+ if filename == "" || !isCurrentModule(mod) || filepath.IsAbs(filename) {
+ return filename
+ }
+
+ return filepath.Join(mod.Dir, filepath.FromSlash(filename))
+}
+
+func isCurrentModule(mod *packages.Module) bool {
+ return mod != nil && mod.Dir != "" && mod.Version == ""
+}
diff --git a/vendor/github.com/golangci/golangci-lint/v2/internal/errorutil/errors.go b/vendor/github.com/golangci/golangci-lint/v2/internal/errorutil/errors.go
new file mode 100644
index 0000000000..42d4225b78
--- /dev/null
+++ b/vendor/github.com/golangci/golangci-lint/v2/internal/errorutil/errors.go
@@ -0,0 +1,23 @@
+package errorutil
+
+import (
+ "fmt"
+)
+
+// PanicError can be used to not print stacktrace twice
+type PanicError struct {
+ recovered any
+ stack []byte
+}
+
+func NewPanicError(recovered any, stack []byte) *PanicError {
+ return &PanicError{recovered: recovered, stack: stack}
+}
+
+func (e *PanicError) Error() string {
+ return fmt.Sprint(e.recovered)
+}
+
+func (e *PanicError) Stack() []byte {
+ return e.stack
+}
diff --git a/vendor/github.com/golangci/golangci-lint/internal/go/LICENSE b/vendor/github.com/golangci/golangci-lint/v2/internal/go/LICENSE
similarity index 100%
rename from vendor/github.com/golangci/golangci-lint/internal/go/LICENSE
rename to vendor/github.com/golangci/golangci-lint/v2/internal/go/LICENSE
diff --git a/vendor/github.com/golangci/golangci-lint/v2/internal/go/base/error_notunix.go b/vendor/github.com/golangci/golangci-lint/v2/internal/go/base/error_notunix.go
new file mode 100644
index 0000000000..c7780fa300
--- /dev/null
+++ b/vendor/github.com/golangci/golangci-lint/v2/internal/go/base/error_notunix.go
@@ -0,0 +1,12 @@
+// Copyright 2023 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+//go:build !unix
+
+package base
+
+func IsETXTBSY(err error) bool {
+ // syscall.ETXTBSY is only meaningful on Unix platforms.
+ return false
+}
diff --git a/vendor/github.com/golangci/golangci-lint/v2/internal/go/base/error_unix.go b/vendor/github.com/golangci/golangci-lint/v2/internal/go/base/error_unix.go
new file mode 100644
index 0000000000..2dcd75e5f3
--- /dev/null
+++ b/vendor/github.com/golangci/golangci-lint/v2/internal/go/base/error_unix.go
@@ -0,0 +1,16 @@
+// Copyright 2023 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+//go:build unix
+
+package base
+
+import (
+ "errors"
+ "syscall"
+)
+
+func IsETXTBSY(err error) bool {
+ return errors.Is(err, syscall.ETXTBSY)
+}
diff --git a/vendor/github.com/golangci/golangci-lint/v2/internal/go/base/readme.md b/vendor/github.com/golangci/golangci-lint/v2/internal/go/base/readme.md
new file mode 100644
index 0000000000..49ba0c699d
--- /dev/null
+++ b/vendor/github.com/golangci/golangci-lint/v2/internal/go/base/readme.md
@@ -0,0 +1,12 @@
+# quoted
+
+Extracted from `go/src/cmd/go/internal/base/` (related to `cache`).
+
+Only the function `IsETXTBSY` is extracted.
+
+## History
+
+- https://github.com/golangci/golangci-lint/pull/6642
+ - sync go1.26.4 (no change)
+- https://github.com/golangci/golangci-lint/pull/5576
+ - sync go1.24.1
diff --git a/vendor/github.com/golangci/golangci-lint/v2/internal/go/cache/cache.go b/vendor/github.com/golangci/golangci-lint/v2/internal/go/cache/cache.go
new file mode 100644
index 0000000000..1ac3f0febb
--- /dev/null
+++ b/vendor/github.com/golangci/golangci-lint/v2/internal/go/cache/cache.go
@@ -0,0 +1,741 @@
+// Copyright 2017 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Package cache implements a build artifact cache.
+//
+// This package is a slightly modified fork of Go's
+// cmd/go/internal/cache package.
+package cache
+
+import (
+ "bytes"
+ "crypto/sha256"
+ "encoding/hex"
+ "errors"
+ "fmt"
+ "io"
+ "io/fs"
+ "os"
+ "path/filepath"
+ "strconv"
+ "strings"
+ "time"
+
+ "github.com/rogpeppe/go-internal/lockedfile"
+ "github.com/rogpeppe/go-internal/robustio"
+
+ "github.com/golangci/golangci-lint/v2/internal/go/base"
+ "github.com/golangci/golangci-lint/v2/internal/go/mmap"
+)
+
+// An ActionID is a cache action key, the hash of a complete description of a
+// repeatable computation (command line, environment variables,
+// input file contents, executable contents).
+type ActionID [HashSize]byte
+
+// An OutputID is a cache output key, the hash of an output of a computation.
+type OutputID [HashSize]byte
+
+// Cache is the interface as used by the cmd/go.
+type Cache interface {
+ // Get returns the cache entry for the provided ActionID.
+ // On miss, the error type should be of type *entryNotFoundError.
+ //
+ // After a successful call to Get, OutputFile(Entry.OutputID) must
+ // exist on disk until Close is called (at the end of the process).
+ Get(ActionID) (Entry, error)
+
+ // Put adds an item to the cache.
+ //
+ // The seeker is only used to seek to the beginning. After a call to Put,
+ // the seek position is not guaranteed to be in any particular state.
+ //
+ // As a special case, if the ReadSeeker is of type noVerifyReadSeeker,
+ // the verification from GODEBUG=goverifycache=1 is skipped.
+ //
+ // After a successful call to Put, OutputFile(OutputID) must
+ // exist on disk until Close is called (at the end of the process).
+ Put(ActionID, io.ReadSeeker) (_ OutputID, size int64, _ error)
+
+ // Close is called at the end of the go process. Implementations can do
+ // cache cleanup work at this phase, or wait for and report any errors from
+ // background cleanup work started earlier. Any cache trimming in one
+ // process should not cause the invariants of this interface to be
+ // violated in another process. Namely, a cache trim from one process should
+ // not delete an ObjectID from disk that was recently Get or Put from
+ // another process. As a rule of thumb, don't trim things used in the last
+ // day.
+ Close() error
+
+ // OutputFile returns the path on disk where OutputID is stored.
+ //
+ // It's only called after a successful get or put call so it doesn't need
+ // to return an error; it's assumed that if the previous get or put succeeded,
+ // it's already on disk.
+ OutputFile(OutputID) string
+
+ // FuzzDir returns where fuzz files are stored.
+ FuzzDir() string
+}
+
+// A Cache is a package cache, backed by a file system directory tree.
+type DiskCache struct {
+ dir string
+ now func() time.Time
+}
+
+// Open opens and returns the cache in the given directory.
+//
+// It is safe for multiple processes on a single machine to use the
+// same cache directory in a local file system simultaneously.
+// They will coordinate using operating system file locks and may
+// duplicate effort but will not corrupt the cache.
+//
+// However, it is NOT safe for multiple processes on different machines
+// to share a cache directory (for example, if the directory were stored
+// in a network file system). File locking is notoriously unreliable in
+// network file systems and may not suffice to protect the cache.
+func Open(dir string) (*DiskCache, error) {
+ info, err := os.Stat(dir)
+ if err != nil {
+ return nil, err
+ }
+ if !info.IsDir() {
+ return nil, &fs.PathError{Op: "open", Path: dir, Err: fmt.Errorf("not a directory")}
+ }
+ for i := 0; i < 256; i++ {
+ name := filepath.Join(dir, fmt.Sprintf("%02x", i))
+ if err := os.MkdirAll(name, 0o777); err != nil {
+ return nil, err
+ }
+ }
+ c := &DiskCache{
+ dir: dir,
+ now: time.Now,
+ }
+ return c, nil
+}
+
+// fileName returns the name of the file corresponding to the given id.
+func (c *DiskCache) fileName(id [HashSize]byte, key string) string {
+ return filepath.Join(c.dir, fmt.Sprintf("%02x", id[0]), fmt.Sprintf("%x", id)+"-"+key)
+}
+
+// An entryNotFoundError indicates that a cache entry was not found, with an
+// optional underlying reason.
+type entryNotFoundError struct {
+ Err error
+}
+
+func (e *entryNotFoundError) Error() string {
+ if e.Err == nil {
+ return "cache entry not found"
+ }
+ return fmt.Sprintf("cache entry not found: %v", e.Err)
+}
+
+func (e *entryNotFoundError) Unwrap() error {
+ return e.Err
+}
+
+const (
+ // action entry file is "v1 \n"
+ hexSize = HashSize * 2
+ entrySize = 2 + 1 + hexSize + 1 + hexSize + 1 + 20 + 1 + 20 + 1
+)
+
+// verify controls whether to run the cache in verify mode.
+// In verify mode, the cache always returns errMissing from Get
+// but then double-checks in Put that the data being written
+// exactly matches any existing entry. This provides an easy
+// way to detect program behavior that would have been different
+// had the cache entry been returned from Get.
+//
+// verify is enabled by setting the environment variable
+// GODEBUG=gocacheverify=1.
+var verify = false
+
+var errVerifyMode = errors.New("gocacheverify=1")
+
+// DebugTest is set when GODEBUG=gocachetest=1 is in the environment.
+var DebugTest = false
+
+// func init() { initEnv() }
+//
+// var (
+// gocacheverify = godebug.New("gocacheverify")
+// gocachehash = godebug.New("gocachehash")
+// gocachetest = godebug.New("gocachetest")
+// )
+//
+// func initEnv() {
+// if gocacheverify.Value() == "1" {
+// gocacheverify.IncNonDefault()
+// verify = true
+// }
+// if gocachehash.Value() == "1" {
+// gocachehash.IncNonDefault()
+// debugHash = true
+// }
+// if gocachetest.Value() == "1" {
+// gocachetest.IncNonDefault()
+// DebugTest = true
+// }
+// }
+
+// Get looks up the action ID in the cache,
+// returning the corresponding output ID and file size, if any.
+// Note that finding an output ID does not guarantee that the
+// saved file for that output ID is still available.
+func (c *DiskCache) Get(id ActionID) (Entry, error) {
+ if verify {
+ return Entry{}, &entryNotFoundError{Err: errVerifyMode}
+ }
+ return c.get(id)
+}
+
+type Entry struct {
+ OutputID OutputID
+ Size int64
+ Time time.Time // when added to cache
+}
+
+// get is Get but does not respect verify mode, so that Put can use it.
+func (c *DiskCache) get(id ActionID) (Entry, error) {
+ missing := func(reason error) (Entry, error) {
+ return Entry{}, &entryNotFoundError{Err: reason}
+ }
+ f, err := os.Open(c.fileName(id, "a"))
+ if err != nil {
+ return missing(err)
+ }
+ defer f.Close()
+ entry := make([]byte, entrySize+1) // +1 to detect whether f is too long
+ if n, err := io.ReadFull(f, entry); n > entrySize {
+ return missing(errors.New("too long"))
+ } else if err != io.ErrUnexpectedEOF {
+ if err == io.EOF {
+ return missing(errors.New("file is empty"))
+ }
+ return missing(err)
+ } else if n < entrySize {
+ return missing(errors.New("entry file incomplete"))
+ }
+ if entry[0] != 'v' || entry[1] != '1' || entry[2] != ' ' || entry[3+hexSize] != ' ' || entry[3+hexSize+1+hexSize] != ' ' || entry[3+hexSize+1+hexSize+1+20] != ' ' || entry[entrySize-1] != '\n' {
+ return missing(errors.New("invalid header"))
+ }
+ eid, entry := entry[3:3+hexSize], entry[3+hexSize:]
+ eout, entry := entry[1:1+hexSize], entry[1+hexSize:]
+ esize, entry := entry[1:1+20], entry[1+20:]
+ etime, entry := entry[1:1+20], entry[1+20:]
+ var buf [HashSize]byte
+ if _, err := hex.Decode(buf[:], eid); err != nil {
+ return missing(fmt.Errorf("decoding ID: %v", err))
+ } else if buf != id {
+ return missing(errors.New("mismatched ID"))
+ }
+ if _, err := hex.Decode(buf[:], eout); err != nil {
+ return missing(fmt.Errorf("decoding output ID: %v", err))
+ }
+ i := 0
+ for i < len(esize) && esize[i] == ' ' {
+ i++
+ }
+ size, err := strconv.ParseInt(string(esize[i:]), 10, 64)
+ if err != nil {
+ return missing(fmt.Errorf("parsing size: %v", err))
+ } else if size < 0 {
+ return missing(errors.New("negative size"))
+ }
+ i = 0
+ for i < len(etime) && etime[i] == ' ' {
+ i++
+ }
+ tm, err := strconv.ParseInt(string(etime[i:]), 10, 64)
+ if err != nil {
+ return missing(fmt.Errorf("parsing timestamp: %v", err))
+ } else if tm < 0 {
+ return missing(errors.New("negative timestamp"))
+ }
+
+ c.markUsed(c.fileName(id, "a"))
+
+ return Entry{buf, size, time.Unix(0, tm)}, nil
+}
+
+// GetFile looks up the action ID in the cache and returns
+// the name of the corresponding data file.
+func GetFile(c Cache, id ActionID) (file string, entry Entry, err error) {
+ entry, err = c.Get(id)
+ if err != nil {
+ return "", Entry{}, err
+ }
+ file = c.OutputFile(entry.OutputID)
+ info, err := os.Stat(file)
+ if err != nil {
+ return "", Entry{}, &entryNotFoundError{Err: err}
+ }
+ if info.Size() != entry.Size {
+ return "", Entry{}, &entryNotFoundError{Err: errors.New("file incomplete")}
+ }
+ return file, entry, nil
+}
+
+// GetBytes looks up the action ID in the cache and returns
+// the corresponding output bytes.
+// GetBytes should only be used for data that can be expected to fit in memory.
+func GetBytes(c Cache, id ActionID) ([]byte, Entry, error) {
+ entry, err := c.Get(id)
+ if err != nil {
+ return nil, entry, err
+ }
+ data, err := robustio.ReadFile(c.OutputFile(entry.OutputID))
+ if err != nil {
+ return nil, entry, &entryNotFoundError{Err: err}
+ }
+ if sha256.Sum256(data) != entry.OutputID {
+ return nil, entry, &entryNotFoundError{Err: errors.New("bad checksum")}
+ }
+ return data, entry, nil
+}
+
+// GetMmap looks up the action ID in the cache and returns
+// the corresponding output bytes.
+// GetMmap should only be used for data that can be expected to fit in memory.
+// The boolean result indicates whether the file was opened.
+// If it is true, the caller should avoid attempting
+// to write to the file on Windows, because Windows locks
+// the open file, and writes to it will fail.
+func GetMmap(c Cache, id ActionID) ([]byte, Entry, bool, error) {
+ entry, err := c.Get(id)
+ if err != nil {
+ return nil, entry, false, err
+ }
+ md, opened, err := mmap.Mmap(c.OutputFile(entry.OutputID))
+ if err != nil {
+ return nil, Entry{}, opened, err
+ }
+ if int64(len(md.Data)) != entry.Size {
+ return nil, Entry{}, true, &entryNotFoundError{Err: errors.New("file incomplete")}
+ }
+ return md.Data, entry, true, nil
+}
+
+// OutputFile returns the name of the cache file storing output with the given OutputID.
+func (c *DiskCache) OutputFile(out OutputID) string {
+ file := c.fileName(out, "d")
+ isDir := c.markUsed(file)
+ if isDir { // => cached executable
+ entries, err := os.ReadDir(file)
+ if err != nil {
+ return fmt.Sprintf("DO NOT USE - missing binary cache entry: %v", err)
+ }
+ if len(entries) != 1 {
+ return "DO NOT USE - invalid binary cache entry"
+ }
+ return filepath.Join(file, entries[0].Name())
+ }
+ return file
+}
+
+// Time constants for cache expiration.
+//
+// We set the mtime on a cache file on each use, but at most one per mtimeInterval (1 hour),
+// to avoid causing many unnecessary inode updates. The mtimes therefore
+// roughly reflect "time of last use" but may in fact be older by at most an hour.
+//
+// We scan the cache for entries to delete at most once per trimInterval (1 day).
+//
+// When we do scan the cache, we delete entries that have not been used for
+// at least trimLimit (5 days). Statistics gathered from a month of usage by
+// Go developers found that essentially all reuse of cached entries happened
+// within 5 days of the previous reuse. See golang.org/issue/22990.
+const (
+ mtimeInterval = 1 * time.Hour
+ trimInterval = 24 * time.Hour
+ trimLimit = 5 * 24 * time.Hour
+)
+
+// markUsed makes a best-effort attempt to update mtime on file,
+// so that mtime reflects cache access time.
+//
+// Because the reflection only needs to be approximate,
+// and to reduce the amount of disk activity caused by using
+// cache entries, used only updates the mtime if the current
+// mtime is more than an hour old. This heuristic eliminates
+// nearly all of the mtime updates that would otherwise happen,
+// while still keeping the mtimes useful for cache trimming.
+//
+// markUsed reports whether the file is a directory (an executable cache entry).
+func (c *DiskCache) markUsed(file string) (isDir bool) {
+ info, err := os.Stat(file)
+ if err != nil {
+ return false
+ }
+ if now := c.now(); now.Sub(info.ModTime()) >= mtimeInterval {
+ os.Chtimes(file, now, now)
+ }
+ return info.IsDir()
+}
+
+func (c *DiskCache) Close() error { return c.Trim() }
+
+// Trim removes old cache entries that are likely not to be reused.
+func (c *DiskCache) Trim() error {
+ now := c.now()
+
+ // We maintain in dir/trim.txt the time of the last completed cache trim.
+ // If the cache has been trimmed recently enough, do nothing.
+ // This is the common case.
+ // If the trim file is corrupt, detected if the file can't be parsed, or the
+ // trim time is too far in the future, attempt the trim anyway. It's possible that
+ // the cache was full when the corruption happened. Attempting a trim on
+ // an empty cache is cheap, so there wouldn't be a big performance hit in that case.
+ skipTrim := func(data []byte) bool {
+ if t, err := strconv.ParseInt(strings.TrimSpace(string(data)), 10, 64); err == nil {
+ lastTrim := time.Unix(t, 0)
+ if d := now.Sub(lastTrim); d < trimInterval && d > -mtimeInterval {
+ return true
+ }
+ }
+ return false
+ }
+ // Check to see if we need a trim. Do this check separately from the lockedfile.Transform
+ // so that we can skip getting an exclusive lock in the common case.
+ if data, err := lockedfile.Read(filepath.Join(c.dir, "trim.txt")); err == nil {
+ if skipTrim(data) {
+ return nil
+ }
+ }
+
+ errFileChanged := errors.New("file changed")
+
+ // Write the new timestamp before we start trimming to reduce the chance that multiple invocations
+ // try to trim at the same time, causing contention in CI (#76314).
+ err := lockedfile.Transform(filepath.Join(c.dir, "trim.txt"), func(data []byte) ([]byte, error) {
+ if skipTrim(data) {
+ // The timestamp in the file no longer meets the criteria for us to
+ // do a trim. It must have been updated by another go command invocation
+ // since we last read it. Skip the trim.
+ return nil, errFileChanged
+ }
+ return fmt.Appendf(nil, "%d", now.Unix()), nil
+ })
+ if errors.Is(err, errors.ErrUnsupported) {
+ return err
+ }
+ if errors.Is(err, errFileChanged) {
+ // Skip the trim because we don't need it anymore.
+ return nil
+ }
+
+ // Trim each of the 256 subdirectories.
+ // We subtract an additional mtimeInterval
+ // to account for the imprecision of our "last used" mtimes.
+ cutoff := now.Add(-trimLimit - mtimeInterval)
+ for i := 0; i < 256; i++ {
+ subdir := filepath.Join(c.dir, fmt.Sprintf("%02x", i))
+ c.trimSubdir(subdir, cutoff)
+ }
+
+ return nil
+}
+
+// trimSubdir trims a single cache subdirectory.
+func (c *DiskCache) trimSubdir(subdir string, cutoff time.Time) {
+ // Read all directory entries from subdir before removing
+ // any files, in case removing files invalidates the file offset
+ // in the directory scan. Also, ignore error from f.Readdirnames,
+ // because we don't care about reporting the error and we still
+ // want to process any entries found before the error.
+ f, err := os.Open(subdir)
+ if err != nil {
+ return
+ }
+ names, _ := f.Readdirnames(-1)
+ f.Close()
+
+ for _, name := range names {
+ // Remove only cache entries (xxxx-a and xxxx-d).
+ if !strings.HasSuffix(name, "-a") && !strings.HasSuffix(name, "-d") {
+ continue
+ }
+ entry := filepath.Join(subdir, name)
+ info, err := os.Stat(entry)
+ if err == nil && info.ModTime().Before(cutoff) {
+ if info.IsDir() { // executable cache entry
+ os.RemoveAll(entry)
+ continue
+ }
+ os.Remove(entry)
+ }
+ }
+}
+
+// putIndexEntry adds an entry to the cache recording that executing the action
+// with the given id produces an output with the given output id (hash) and size.
+func (c *DiskCache) putIndexEntry(id ActionID, out OutputID, size int64, allowVerify bool) error {
+ // Note: We expect that for one reason or another it may happen
+ // that repeating an action produces a different output hash
+ // (for example, if the output contains a time stamp or temp dir name).
+ // While not ideal, this is also not a correctness problem, so we
+ // don't make a big deal about it. In particular, we leave the action
+ // cache entries writable specifically so that they can be overwritten.
+ //
+ // Setting GODEBUG=gocacheverify=1 does make a big deal:
+ // in verify mode we are double-checking that the cache entries
+ // are entirely reproducible. As just noted, this may be unrealistic
+ // in some cases but the check is also useful for shaking out real bugs.
+ entry := fmt.Sprintf("v1 %x %x %20d %20d\n", id, out, size, time.Now().UnixNano())
+ if verify && allowVerify {
+ old, err := c.get(id)
+ if err == nil && (old.OutputID != out || old.Size != size) {
+ // panic to show stack trace, so we can see what code is generating this cache entry.
+ msg := fmt.Sprintf("go: internal cache error: cache verify failed: id=%x changed:<<<\n%s\n>>>\nold: %x %d\nnew: %x %d", id, reverseHash(id), out, size, old.OutputID, old.Size)
+ panic(msg)
+ }
+ }
+ file := c.fileName(id, "a")
+
+ // Copy file to cache directory.
+ mode := os.O_WRONLY | os.O_CREATE
+ f, err := os.OpenFile(file, mode, 0o666)
+ if err != nil {
+ return err
+ }
+ _, err = f.WriteString(entry)
+ if err == nil {
+ // Truncate the file only *after* writing it.
+ // (This should be a no-op, but truncate just in case of previous corruption.)
+ //
+ // This differs from os.WriteFile, which truncates to 0 *before* writing
+ // via os.O_TRUNC. Truncating only after writing ensures that a second write
+ // of the same content to the same file is idempotent, and does not — even
+ // temporarily! — undo the effect of the first write.
+ err = f.Truncate(int64(len(entry)))
+ }
+ if closeErr := f.Close(); err == nil {
+ err = closeErr
+ }
+ if err != nil {
+ // TODO(bcmills): This Remove potentially races with another go command writing to file.
+ // Can we eliminate it?
+ os.Remove(file)
+ return err
+ }
+ err = os.Chtimes(file, c.now(), c.now()) // mainly for tests
+ if err != nil {
+ return fmt.Errorf("failed to change time of file %s: %w", file, err)
+ }
+
+ return nil
+}
+
+// noVerifyReadSeeker is an io.ReadSeeker wrapper sentinel type
+// that says that Cache.Put should skip the verify check
+// (from GODEBUG=goverifycache=1).
+type noVerifyReadSeeker struct {
+ io.ReadSeeker
+}
+
+// Put stores the given output in the cache as the output for the action ID.
+// It may read file twice. The content of file must not change between the two passes.
+func (c *DiskCache) Put(id ActionID, file io.ReadSeeker) (OutputID, int64, error) {
+ wrapper, isNoVerify := file.(noVerifyReadSeeker)
+ if isNoVerify {
+ file = wrapper.ReadSeeker
+ }
+ return c.put(id, "", file, !isNoVerify)
+}
+
+// PutExecutable is used to store the output as the output for the action ID into a
+// file with the given base name, with the executable mode bit set.
+// It may read file twice. The content of file must not change between the two passes.
+func (c *DiskCache) PutExecutable(id ActionID, name string, file io.ReadSeeker) (OutputID, int64, error) {
+ if name == "" {
+ panic("PutExecutable called without a name")
+ }
+ wrapper, isNoVerify := file.(noVerifyReadSeeker)
+ if isNoVerify {
+ file = wrapper.ReadSeeker
+ }
+ return c.put(id, name, file, !isNoVerify)
+}
+
+// PutNoVerify is like Put but disables the verify check
+// when GODEBUG=goverifycache=1 is set.
+// It is meant for data that is OK to cache but that we expect to vary slightly from run to run,
+// like test output containing times and the like.
+func PutNoVerify(c Cache, id ActionID, file io.ReadSeeker) (OutputID, int64, error) {
+ return c.Put(id, noVerifyReadSeeker{file})
+}
+
+func (c *DiskCache) put(id ActionID, executableName string, file io.ReadSeeker, allowVerify bool) (OutputID, int64, error) {
+ // Compute output ID.
+ h := sha256.New()
+ if _, err := file.Seek(0, 0); err != nil {
+ return OutputID{}, 0, err
+ }
+ size, err := io.Copy(h, file)
+ if err != nil {
+ return OutputID{}, 0, err
+ }
+ var out OutputID
+ h.Sum(out[:0])
+
+ // Copy to cached output file (if not already present).
+ fileMode := fs.FileMode(0o666)
+ if executableName != "" {
+ fileMode = 0o777
+ }
+ if err := c.copyFile(file, executableName, out, size, fileMode); err != nil {
+ return out, size, err
+ }
+
+ // Add to cache index.
+ return out, size, c.putIndexEntry(id, out, size, allowVerify)
+}
+
+// PutBytes stores the given bytes in the cache as the output for the action ID.
+func PutBytes(c Cache, id ActionID, data []byte) error {
+ _, _, err := c.Put(id, bytes.NewReader(data))
+ return err
+}
+
+// copyFile copies file into the cache, expecting it to have the given
+// output ID and size, if that file is not present already.
+func (c *DiskCache) copyFile(file io.ReadSeeker, executableName string, out OutputID, size int64, perm os.FileMode) error {
+ name := c.fileName(out, "d") // TODO(matloob): use a different suffix for the executable cache?
+ info, err := os.Stat(name)
+ if executableName != "" {
+ // This is an executable file. The file at name won't hold the output itself, but will
+ // be a directory that holds the output, named according to executableName. Check to see
+ // if the directory already exists, and if it does not, create it. Then reset name
+ // to the name we want the output written to.
+ if err != nil {
+ if !os.IsNotExist(err) {
+ return err
+ }
+ if err := os.Mkdir(name, 0o777); err != nil {
+ return err
+ }
+ if info, err = os.Stat(name); err != nil {
+ return err
+ }
+ }
+ if !info.IsDir() {
+ return errors.New("internal error: invalid binary cache entry: not a directory")
+ }
+
+ // directory exists. now set name to the inner file
+ name = filepath.Join(name, executableName)
+ info, err = os.Stat(name)
+ }
+ if err == nil && info.Size() == size {
+ // Check hash.
+ if f, err := os.Open(name); err == nil {
+ h := sha256.New()
+ _, copyErr := io.Copy(h, f)
+ if copyErr != nil {
+ return fmt.Errorf("failed to copy to sha256: %w", copyErr)
+ }
+
+ f.Close()
+ var out2 OutputID
+ h.Sum(out2[:0])
+ if out == out2 {
+ return nil
+ }
+ }
+ // Hash did not match. Fall through and rewrite file.
+ }
+
+ // Copy file to cache directory.
+ mode := os.O_RDWR | os.O_CREATE
+ if err == nil && info.Size() > size { // shouldn't happen but fix in case
+ mode |= os.O_TRUNC
+ }
+ f, err := os.OpenFile(name, mode, perm)
+ if err != nil {
+ if base.IsETXTBSY(err) {
+ // This file is being used by an executable. It must have
+ // already been written by another go process and then run.
+ // return without an error.
+ return nil
+ }
+ return err
+ }
+ defer f.Close()
+ if size == 0 {
+ // File now exists with correct size.
+ // Only one possible zero-length file, so contents are OK too.
+ // Early return here makes sure there's a "last byte" for code below.
+ return nil
+ }
+
+ // From here on, if any of the I/O writing the file fails,
+ // we make a best-effort attempt to truncate the file f
+ // before returning, to avoid leaving bad bytes in the file.
+
+ // Copy file to f, but also into h to double-check hash.
+ if _, err := file.Seek(0, 0); err != nil {
+ f.Truncate(0)
+ return err
+ }
+ h := sha256.New()
+ w := io.MultiWriter(f, h)
+ if _, err := io.CopyN(w, file, size-1); err != nil {
+ f.Truncate(0)
+ return err
+ }
+ // Check last byte before writing it; writing it will make the size match
+ // what other processes expect to find and might cause them to start
+ // using the file.
+ buf := make([]byte, 1)
+ if _, err := file.Read(buf); err != nil {
+ f.Truncate(0)
+ return err
+ }
+ n, wErr := h.Write(buf)
+ if n != len(buf) {
+ return fmt.Errorf("wrote to hash %d/%d bytes with error %w", n, len(buf), wErr)
+ }
+
+ sum := h.Sum(nil)
+ if !bytes.Equal(sum, out[:]) {
+ f.Truncate(0)
+ return fmt.Errorf("file content changed underfoot")
+ }
+
+ // Commit cache file entry.
+ if _, err := f.Write(buf); err != nil {
+ f.Truncate(0)
+ return err
+ }
+ if err := f.Close(); err != nil {
+ // Data might not have been written,
+ // but file may look like it is the right size.
+ // To be extra careful, remove cached file.
+ os.Remove(name)
+ return err
+ }
+ err = os.Chtimes(name, c.now(), c.now()) // mainly for tests
+ if err != nil {
+ return fmt.Errorf("failed to change time of file %s: %w", name, err)
+ }
+
+ return nil
+}
+
+// FuzzDir returns a subdirectory within the cache for storing fuzzing data.
+// The subdirectory may not exist.
+//
+// This directory is managed by the internal/fuzz package. Files in this
+// directory aren't removed by the 'go clean -cache' command or by Trim.
+// They may be removed with 'go clean -fuzzcache'.
+//
+// TODO(#48526): make Trim remove unused files from this directory.
+func (c *DiskCache) FuzzDir() string {
+ return filepath.Join(c.dir, "fuzz")
+}
diff --git a/vendor/github.com/golangci/golangci-lint/internal/go/cache/cache_gcil.go b/vendor/github.com/golangci/golangci-lint/v2/internal/go/cache/cache_gcil.go
similarity index 100%
rename from vendor/github.com/golangci/golangci-lint/internal/go/cache/cache_gcil.go
rename to vendor/github.com/golangci/golangci-lint/v2/internal/go/cache/cache_gcil.go
diff --git a/vendor/github.com/golangci/golangci-lint/v2/internal/go/cache/default.go b/vendor/github.com/golangci/golangci-lint/v2/internal/go/cache/default.go
new file mode 100644
index 0000000000..a6cacaf183
--- /dev/null
+++ b/vendor/github.com/golangci/golangci-lint/v2/internal/go/cache/default.go
@@ -0,0 +1,103 @@
+// Copyright 2017 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package cache
+
+import (
+ "fmt"
+ base "log"
+ "os"
+ "path/filepath"
+ "sync"
+)
+
+// Default returns the default cache to use.
+// It never returns nil.
+func Default() Cache {
+ return initDefaultCacheOnce()
+}
+
+var initDefaultCacheOnce = sync.OnceValue(initDefaultCache)
+
+// cacheREADME is a message stored in a README in the cache directory.
+// Because the cache lives outside the normal Go trees, we leave the
+// README as a courtesy to explain where it came from.
+const cacheREADME = `This directory holds cached build artifacts from golangci-lint.
+`
+
+// initDefaultCache does the work of finding the default cache
+// the first time Default is called.
+func initDefaultCache() Cache {
+ dir, _, err := DefaultDir()
+ if err != nil {
+ base.Fatalf("build cache is required, but could not be located: %v", err)
+ }
+ if dir == "off" {
+ if defaultDirErr != nil {
+ base.Fatalf("build cache is required, but could not be located: %v", defaultDirErr)
+ }
+ base.Fatalf("build cache is disabled by %s=off, but required as of Go 1.12", envGolangciLintCache)
+ }
+ if err := os.MkdirAll(dir, 0o777); err != nil {
+ base.Fatalf("failed to initialize build cache at %s: %s\n", dir, err)
+ }
+ if _, err := os.Stat(filepath.Join(dir, "README")); err != nil {
+ // Best effort.
+ os.WriteFile(filepath.Join(dir, "README"), []byte(cacheREADME), 0666)
+ }
+
+ diskCache, err := Open(dir)
+ if err != nil {
+ base.Fatalf("failed to initialize build cache at %s: %s\n", dir, err)
+ }
+
+ if v := os.Getenv(envGolangciLintCacheProg); v != "" {
+ return startCacheProg(v, diskCache)
+ }
+
+ return diskCache
+}
+
+var (
+ defaultDirOnce sync.Once
+ defaultDir string
+ defaultDirChanged bool // effective value differs from $GOLANGCI_LINT_CACHE
+ defaultDirErr error
+)
+
+// DefaultDir returns the effective GOLANGCI_LINT_CACHE setting.
+// It returns "off" if the cache is disabled,
+// and reports whether the effective value differs from GOLANGCI_LINT_CACHE.
+func DefaultDir() (string, bool, error) {
+ // Save the result of the first call to DefaultDir for later use in
+ // initDefaultCache. cmd/go/main.go explicitly sets GOLANGCI_LINT_CACHE so that
+ // subprocesses will inherit it, but that means initDefaultCache can't
+ // otherwise distinguish between an explicit "off" and a UserCacheDir error.
+
+ defaultDirOnce.Do(func() {
+ // Compute default location.
+ dir, err := os.UserCacheDir()
+ if err != nil {
+ defaultDir = "off"
+ defaultDirErr = fmt.Errorf("%s is not defined and %v", envGolangciLintCache, err)
+ } else {
+ defaultDir = filepath.Join(dir, "golangci-lint")
+ }
+
+ newDir := os.Getenv(envGolangciLintCache)
+ if newDir != "" {
+ defaultDirErr = nil
+ defaultDirChanged = newDir != defaultDir
+ defaultDir = newDir
+ if filepath.IsAbs(defaultDir) || defaultDir == "off" {
+ return
+ }
+ defaultDir = "off"
+ defaultDirErr = fmt.Errorf("%s is not an absolute path", envGolangciLintCache)
+ return
+ }
+ })
+
+ return defaultDir, defaultDirChanged, defaultDirErr
+}
diff --git a/vendor/github.com/golangci/golangci-lint/internal/go/cache/default_gcil.go b/vendor/github.com/golangci/golangci-lint/v2/internal/go/cache/default_gcil.go
similarity index 100%
rename from vendor/github.com/golangci/golangci-lint/internal/go/cache/default_gcil.go
rename to vendor/github.com/golangci/golangci-lint/v2/internal/go/cache/default_gcil.go
diff --git a/vendor/github.com/golangci/golangci-lint/v2/internal/go/cache/hash.go b/vendor/github.com/golangci/golangci-lint/v2/internal/go/cache/hash.go
new file mode 100644
index 0000000000..3fa2422f59
--- /dev/null
+++ b/vendor/github.com/golangci/golangci-lint/v2/internal/go/cache/hash.go
@@ -0,0 +1,195 @@
+// Copyright 2017 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package cache
+
+import (
+ "bytes"
+ "crypto/sha256"
+ "fmt"
+ "hash"
+ "io"
+ "os"
+ "strings"
+ "sync"
+)
+
+var debugHash = false // set when GODEBUG=gocachehash=1
+
+// HashSize is the number of bytes in a hash.
+const HashSize = 32
+
+// A Hash provides access to the canonical hash function used to index the cache.
+// The current implementation uses salted SHA256, but clients must not assume this.
+type Hash struct {
+ h hash.Hash
+ name string // for debugging
+ buf *bytes.Buffer // for verify
+}
+
+// hashSalt is a salt string added to the beginning of every hash
+// created by NewHash. Using the golangci-lint version makes sure that different
+// versions of the command do not address the same cache
+// entries, so that a bug in one version does not affect the execution
+// of other versions. This salt will result in additional ActionID files
+// in the cache, but not additional copies of the large output files,
+// which are still addressed by unsalted SHA256.
+var hashSalt []byte
+
+// stripExperiment strips any GOEXPERIMENT configuration from the Go
+// version string.
+func stripExperiment(version string) string {
+ if i := strings.Index(version, " X:"); i >= 0 {
+ return version[:i]
+ }
+ if i := strings.Index(version, "-X:"); i >= 0 {
+ return version[:i]
+ }
+ return version
+}
+
+// Subkey returns an action ID corresponding to mixing a parent
+// action ID with a string description of the subkey.
+func Subkey(parent ActionID, desc string) (ActionID, error) {
+ h := sha256.New()
+ h.Write([]byte("subkey:"))
+ n, err := h.Write(parent[:])
+ if n != len(parent) {
+ return ActionID{}, fmt.Errorf("wrote %d/%d bytes of parent with error %s", n, len(parent), err)
+ }
+ n, err = h.Write([]byte(desc))
+ if n != len(desc) {
+ return ActionID{}, fmt.Errorf("wrote %d/%d bytes of desc with error %s", n, len(desc), err)
+ }
+
+ var out ActionID
+ h.Sum(out[:0])
+ if debugHash {
+ fmt.Fprintf(os.Stderr, "HASH subkey %x %q = %x\n", parent, desc, out)
+ }
+ if verify {
+ hashDebug.Lock()
+ hashDebug.m[out] = fmt.Sprintf("subkey %x %q", parent, desc)
+ hashDebug.Unlock()
+ }
+ return out, nil
+}
+
+// NewHash returns a new Hash.
+// The caller is expected to Write data to it and then call Sum.
+func NewHash(name string) (*Hash, error) {
+ h := &Hash{h: sha256.New(), name: name}
+ if debugHash {
+ fmt.Fprintf(os.Stderr, "HASH[%s]\n", h.name)
+ }
+ n, err := h.Write(hashSalt)
+ if n != len(hashSalt) {
+ return nil, fmt.Errorf("wrote %d/%d bytes of hash salt with error %s", n, len(hashSalt), err)
+ }
+ if verify {
+ h.buf = new(bytes.Buffer)
+ }
+ return h, nil
+}
+
+// Write writes data to the running hash.
+func (h *Hash) Write(b []byte) (int, error) {
+ if debugHash {
+ fmt.Fprintf(os.Stderr, "HASH[%s]: %q\n", h.name, b)
+ }
+ if h.buf != nil {
+ h.buf.Write(b)
+ }
+ return h.h.Write(b)
+}
+
+// Sum returns the hash of the data written previously.
+func (h *Hash) Sum() [HashSize]byte {
+ var out [HashSize]byte
+ h.h.Sum(out[:0])
+ if debugHash {
+ fmt.Fprintf(os.Stderr, "HASH[%s]: %x\n", h.name, out)
+ }
+ if h.buf != nil {
+ hashDebug.Lock()
+ if hashDebug.m == nil {
+ hashDebug.m = make(map[[HashSize]byte]string)
+ }
+ hashDebug.m[out] = h.buf.String()
+ hashDebug.Unlock()
+ }
+ return out
+}
+
+// In GODEBUG=gocacheverify=1 mode,
+// hashDebug holds the input to every computed hash ID,
+// so that we can work backward from the ID involved in a
+// cache entry mismatch to a description of what should be there.
+var hashDebug struct {
+ sync.Mutex
+ m map[[HashSize]byte]string
+}
+
+// reverseHash returns the input used to compute the hash id.
+func reverseHash(id [HashSize]byte) string {
+ hashDebug.Lock()
+ s := hashDebug.m[id]
+ hashDebug.Unlock()
+ return s
+}
+
+var hashFileCache struct {
+ sync.Mutex
+ m map[string][HashSize]byte
+}
+
+// FileHash returns the hash of the named file.
+// It caches repeated lookups for a given file,
+// and the cache entry for a file can be initialized
+// using SetFileHash.
+// The hash used by FileHash is not the same as
+// the hash used by NewHash.
+func FileHash(file string) ([HashSize]byte, error) {
+ hashFileCache.Lock()
+ out, ok := hashFileCache.m[file]
+ hashFileCache.Unlock()
+
+ if ok {
+ return out, nil
+ }
+
+ h := sha256.New()
+ f, err := os.Open(file)
+ if err != nil {
+ if debugHash {
+ fmt.Fprintf(os.Stderr, "HASH %s: %v\n", file, err)
+ }
+ return [HashSize]byte{}, err
+ }
+ _, err = io.Copy(h, f)
+ f.Close()
+ if err != nil {
+ if debugHash {
+ fmt.Fprintf(os.Stderr, "HASH %s: %v\n", file, err)
+ }
+ return [HashSize]byte{}, err
+ }
+ h.Sum(out[:0])
+ if debugHash {
+ fmt.Fprintf(os.Stderr, "HASH %s: %x\n", file, out)
+ }
+
+ SetFileHash(file, out)
+ return out, nil
+}
+
+// SetFileHash sets the hash returned by FileHash for file.
+func SetFileHash(file string, sum [HashSize]byte) {
+ hashFileCache.Lock()
+ if hashFileCache.m == nil {
+ hashFileCache.m = make(map[string][HashSize]byte)
+ }
+ hashFileCache.m[file] = sum
+ hashFileCache.Unlock()
+}
diff --git a/vendor/github.com/golangci/golangci-lint/internal/go/cache/hash_gcil.go b/vendor/github.com/golangci/golangci-lint/v2/internal/go/cache/hash_gcil.go
similarity index 100%
rename from vendor/github.com/golangci/golangci-lint/internal/go/cache/hash_gcil.go
rename to vendor/github.com/golangci/golangci-lint/v2/internal/go/cache/hash_gcil.go
diff --git a/vendor/github.com/golangci/golangci-lint/v2/internal/go/cache/prog.go b/vendor/github.com/golangci/golangci-lint/v2/internal/go/cache/prog.go
new file mode 100644
index 0000000000..dc44e1385b
--- /dev/null
+++ b/vendor/github.com/golangci/golangci-lint/v2/internal/go/cache/prog.go
@@ -0,0 +1,375 @@
+// Copyright 2023 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package cache
+
+import (
+ "bufio"
+ "context"
+ "crypto/sha256"
+ "encoding/base64"
+ "encoding/json"
+ "errors"
+ "fmt"
+ "io"
+ "log"
+ base "log"
+ "os"
+ "os/exec"
+ "sync"
+ "sync/atomic"
+ "time"
+
+ "github.com/golangci/golangci-lint/v2/internal/go/cacheprog"
+ "github.com/golangci/golangci-lint/v2/internal/go/quoted"
+)
+
+// ProgCache implements Cache via JSON messages over stdin/stdout to a child
+// helper process which can then implement whatever caching policy/mechanism it
+// wants.
+//
+// See https://github.com/golang/go/issues/59719
+type ProgCache struct {
+ cmd *exec.Cmd
+ stdout io.ReadCloser // from the child process
+ stdin io.WriteCloser // to the child process
+ bw *bufio.Writer // to stdin
+ jenc *json.Encoder // to bw
+
+ // can are the commands that the child process declared that it supports.
+ // This is effectively the versioning mechanism.
+ can map[cacheprog.Cmd]bool
+
+ // fuzzDirCache is another Cache implementation to use for the FuzzDir
+ // method. In practice this is the default GOCACHE disk-based
+ // implementation.
+ //
+ // TODO(bradfitz): maybe this isn't ideal. But we'd need to extend the Cache
+ // interface and the fuzzing callers to be less disk-y to do more here.
+ fuzzDirCache Cache
+
+ closing atomic.Bool
+ ctx context.Context // valid until Close via ctxClose
+ ctxCancel context.CancelFunc // called on Close
+ readLoopDone chan struct{} // closed when readLoop returns
+
+ mu sync.Mutex // guards following fields
+ nextID int64
+ inFlight map[int64]chan<- *cacheprog.Response
+ outputFile map[OutputID]string // object => abs path on disk
+
+ // writeMu serializes writing to the child process.
+ // It must never be held at the same time as mu.
+ writeMu sync.Mutex
+}
+
+// startCacheProg starts the prog binary (with optional space-separated flags)
+// and returns a Cache implementation that talks to it.
+//
+// It blocks a few seconds to wait for the child process to successfully start
+// and advertise its capabilities.
+func startCacheProg(progAndArgs string, fuzzDirCache Cache) Cache {
+ if fuzzDirCache == nil {
+ panic("missing fuzzDirCache")
+ }
+ args, err := quoted.Split(progAndArgs)
+ if err != nil {
+ base.Fatalf("%s args: %v", envGolangciLintCacheProg, err)
+ }
+ var prog string
+ if len(args) > 0 {
+ prog = args[0]
+ args = args[1:]
+ }
+
+ ctx, ctxCancel := context.WithCancel(context.Background())
+
+ cmd := exec.CommandContext(ctx, prog, args...)
+ out, err := cmd.StdoutPipe()
+ if err != nil {
+ base.Fatalf("StdoutPipe to %s: envGolangciLintCacheProg, %v", envGolangciLintCacheProg, err)
+ }
+ in, err := cmd.StdinPipe()
+ if err != nil {
+ base.Fatalf("StdinPipe to %s: envGolangciLintCacheProg, %v", envGolangciLintCacheProg, err)
+ }
+ cmd.Stderr = os.Stderr
+ // On close, we cancel the context. Rather than killing the helper,
+ // close its stdin.
+ cmd.Cancel = in.Close
+
+ if err := cmd.Start(); err != nil {
+ base.Fatalf("error starting %s program %q: %v", envGolangciLintCacheProg, prog, err)
+ }
+
+ pc := &ProgCache{
+ ctx: ctx,
+ ctxCancel: ctxCancel,
+ fuzzDirCache: fuzzDirCache,
+ cmd: cmd,
+ stdout: out,
+ stdin: in,
+ bw: bufio.NewWriter(in),
+ inFlight: make(map[int64]chan<- *cacheprog.Response),
+ outputFile: make(map[OutputID]string),
+ readLoopDone: make(chan struct{}),
+ }
+
+ // Register our interest in the initial protocol message from the child to
+ // us, saying what it can do.
+ capResc := make(chan *cacheprog.Response, 1)
+ pc.inFlight[0] = capResc
+
+ pc.jenc = json.NewEncoder(pc.bw)
+ go pc.readLoop(pc.readLoopDone)
+
+ // Give the child process a few seconds to report its capabilities. This
+ // should be instant and not require any slow work by the program.
+ timer := time.NewTicker(5 * time.Second)
+ defer timer.Stop()
+ for {
+ select {
+ case <-timer.C:
+ log.Printf("# still waiting for %s %v ...", envGolangciLintCacheProg, prog)
+ case capRes := <-capResc:
+ can := map[cacheprog.Cmd]bool{}
+ for _, cmd := range capRes.KnownCommands {
+ can[cmd] = true
+ }
+ if len(can) == 0 {
+ base.Fatalf("%s %v declared no supported commands", envGolangciLintCacheProg, prog)
+ }
+ pc.can = can
+ return pc
+ }
+ }
+}
+
+func (c *ProgCache) readLoop(readLoopDone chan<- struct{}) {
+ defer close(readLoopDone)
+ jd := json.NewDecoder(c.stdout)
+ for {
+ res := new(cacheprog.Response)
+ if err := jd.Decode(res); err != nil {
+ if c.closing.Load() {
+ c.mu.Lock()
+ for _, ch := range c.inFlight {
+ close(ch)
+ }
+ c.inFlight = nil
+ c.mu.Unlock()
+ return // quietly
+ }
+ if err == io.EOF {
+ c.mu.Lock()
+ inFlight := len(c.inFlight)
+ c.mu.Unlock()
+ base.Fatalf("%s exited pre-Close with %v pending requests", envGolangciLintCacheProg, inFlight)
+ }
+ base.Fatalf("error reading JSON from %s: %v", envGolangciLintCacheProg, err)
+ }
+ c.mu.Lock()
+ ch, ok := c.inFlight[res.ID]
+ delete(c.inFlight, res.ID)
+ c.mu.Unlock()
+ if ok {
+ ch <- res
+ } else {
+ base.Fatalf("%s sent response for unknown request ID %v", envGolangciLintCacheProg, res.ID)
+ }
+ }
+}
+
+var errCacheprogClosed = fmt.Errorf("%s program closed unexpectedly", envGolangciLintCacheProg)
+
+func (c *ProgCache) send(ctx context.Context, req *cacheprog.Request) (*cacheprog.Response, error) {
+ resc := make(chan *cacheprog.Response, 1)
+ if err := c.writeToChild(req, resc); err != nil {
+ return nil, err
+ }
+ select {
+ case res := <-resc:
+ if res == nil {
+ return nil, errCacheprogClosed
+ }
+ if res.Err != "" {
+ return nil, errors.New(res.Err)
+ }
+ return res, nil
+ case <-ctx.Done():
+ return nil, ctx.Err()
+ }
+}
+
+func (c *ProgCache) writeToChild(req *cacheprog.Request, resc chan<- *cacheprog.Response) (err error) {
+ c.mu.Lock()
+ if c.inFlight == nil {
+ return errCacheprogClosed
+ }
+ c.nextID++
+ req.ID = c.nextID
+ c.inFlight[req.ID] = resc
+ c.mu.Unlock()
+
+ defer func() {
+ if err != nil {
+ c.mu.Lock()
+ if c.inFlight != nil {
+ delete(c.inFlight, req.ID)
+ }
+ c.mu.Unlock()
+ }
+ }()
+
+ c.writeMu.Lock()
+ defer c.writeMu.Unlock()
+
+ if err := c.jenc.Encode(req); err != nil {
+ return err
+ }
+ if err := c.bw.WriteByte('\n'); err != nil {
+ return err
+ }
+ if req.Body != nil && req.BodySize > 0 {
+ if err := c.bw.WriteByte('"'); err != nil {
+ return err
+ }
+ e := base64.NewEncoder(base64.StdEncoding, c.bw)
+ wrote, err := io.Copy(e, req.Body)
+ if err != nil {
+ return err
+ }
+ if err := e.Close(); err != nil {
+ return nil
+ }
+ if wrote != req.BodySize {
+ return fmt.Errorf("short write writing body to %s for action %x, output %x: wrote %v; expected %v",
+ envGolangciLintCacheProg, req.ActionID, req.OutputID, wrote, req.BodySize)
+ }
+ if _, err := c.bw.WriteString("\"\n"); err != nil {
+ return err
+ }
+ }
+ if err := c.bw.Flush(); err != nil {
+ return err
+ }
+ return nil
+}
+
+func (c *ProgCache) Get(a ActionID) (Entry, error) {
+ if !c.can[cacheprog.CmdGet] {
+ // They can't do a "get". Maybe they're a write-only cache.
+ //
+ // TODO(bradfitz,bcmills): figure out the proper error type here. Maybe
+ // errors.ErrUnsupported? Is entryNotFoundError even appropriate? There
+ // might be places where we rely on the fact that a recent Put can be
+ // read through a corresponding Get. Audit callers and check, and document
+ // error types on the Cache interface.
+ return Entry{}, &entryNotFoundError{}
+ }
+ res, err := c.send(c.ctx, &cacheprog.Request{
+ Command: cacheprog.CmdGet,
+ ActionID: a[:],
+ })
+ if err != nil {
+ return Entry{}, err // TODO(bradfitz): or entryNotFoundError? Audit callers.
+ }
+ if res.Miss {
+ return Entry{}, &entryNotFoundError{}
+ }
+ e := Entry{
+ Size: res.Size,
+ }
+ if res.Time != nil {
+ e.Time = *res.Time
+ } else {
+ e.Time = time.Now()
+ }
+ if res.DiskPath == "" {
+ return Entry{}, &entryNotFoundError{fmt.Errorf("%s didn't populate DiskPath on get hit", envGolangciLintCacheProg)}
+ }
+ if copy(e.OutputID[:], res.OutputID) != len(res.OutputID) {
+ return Entry{}, &entryNotFoundError{errors.New("incomplete ProgResponse OutputID")}
+ }
+ c.noteOutputFile(e.OutputID, res.DiskPath)
+ return e, nil
+}
+
+func (c *ProgCache) noteOutputFile(o OutputID, diskPath string) {
+ c.mu.Lock()
+ defer c.mu.Unlock()
+ c.outputFile[o] = diskPath
+}
+
+func (c *ProgCache) OutputFile(o OutputID) string {
+ c.mu.Lock()
+ defer c.mu.Unlock()
+ return c.outputFile[o]
+}
+
+func (c *ProgCache) Put(a ActionID, file io.ReadSeeker) (_ OutputID, size int64, _ error) {
+ // Compute output ID.
+ h := sha256.New()
+ if _, err := file.Seek(0, 0); err != nil {
+ return OutputID{}, 0, err
+ }
+ size, err := io.Copy(h, file)
+ if err != nil {
+ return OutputID{}, 0, err
+ }
+ var out OutputID
+ h.Sum(out[:0])
+
+ if _, err := file.Seek(0, 0); err != nil {
+ return OutputID{}, 0, err
+ }
+
+ if !c.can[cacheprog.CmdPut] {
+ // Child is a read-only cache. Do nothing.
+ return out, size, nil
+ }
+
+ res, err := c.send(c.ctx, &cacheprog.Request{
+ Command: cacheprog.CmdPut,
+ ActionID: a[:],
+ OutputID: out[:],
+ Body: file,
+ BodySize: size,
+ })
+ if err != nil {
+ return OutputID{}, 0, err
+ }
+ if res.DiskPath == "" {
+ return OutputID{}, 0, fmt.Errorf("%s didn't return DiskPath in put response", envGolangciLintCacheProg)
+ }
+ c.noteOutputFile(out, res.DiskPath)
+ return out, size, err
+}
+
+func (c *ProgCache) Close() error {
+ c.closing.Store(true)
+ var err error
+
+ // First write a "close" message to the child so it can exit nicely
+ // and clean up if it wants. Only after that exchange do we cancel
+ // the context that kills the process.
+ if c.can[cacheprog.CmdClose] {
+ _, err = c.send(c.ctx, &cacheprog.Request{Command: cacheprog.CmdClose})
+ if errors.Is(err, errCacheprogClosed) {
+ // Allow the child to quit without responding to close.
+ err = nil
+ }
+ }
+ // Cancel the context, which will close the helper's stdin.
+ c.ctxCancel()
+ // Wait until the helper closes its stdout.
+ <-c.readLoopDone
+ return err
+}
+
+func (c *ProgCache) FuzzDir() string {
+ // TODO(bradfitz): figure out what to do here. For now just use the
+ // disk-based default.
+ return c.fuzzDirCache.FuzzDir()
+}
diff --git a/vendor/github.com/golangci/golangci-lint/v2/internal/go/cache/readme.md b/vendor/github.com/golangci/golangci-lint/v2/internal/go/cache/readme.md
new file mode 100644
index 0000000000..6d33419f04
--- /dev/null
+++ b/vendor/github.com/golangci/golangci-lint/v2/internal/go/cache/readme.md
@@ -0,0 +1,55 @@
+# cache
+
+Extracted from `go/src/cmd/go/internal/cache/`.
+
+The main modifications are:
+- The error management
+ - Some methods return error.
+ - Some errors are returned instead of being ignored.
+- The name of the env vars:
+ - `GOCACHE` -> `GOLANGCI_LINT_CACHE`
+ - `GOCACHEPROG` -> `GOLANGCI_LINT_CACHEPROG`
+
+## History
+
+- https://github.com/golangci/golangci-lint/pull/6642
+ - sync go1.26.4
+- https://github.com/golangci/golangci-lint/pull/5576
+ - sync go1.24.1
+- https://github.com/golangci/golangci-lint/pull/5100
+ - Move package from `internal/cache` to `internal/go/cache`
+- https://github.com/golangci/golangci-lint/pull/5098
+ - sync with go1.23.2
+ - sync with go1.22.8
+ - sync with go1.21.13
+ - sync with go1.20.14
+ - sync with go1.19.13
+ - sync with go1.18.10
+ - sync with go1.17.13
+ - sync with go1.16.15
+ - sync with go1.15.15
+ - sync with go1.14.15
+
+## Previous History
+
+Based on the initial PR/commit this was based in a mix between go1.12 and go1.13:
+- cache.go (go1.13)
+- cache_test.go (go1.12?)
+- default.go (go1.12?)
+- hash.go (go1.13 and go1.12 are identical)
+- hash_test.go -> (go1.12?)
+
+Adapted for golangci-lint:
+- https://github.com/golangci/golangci-lint/pull/699: initial code (contains modifications of the files)
+- https://github.com/golangci/golangci-lint/pull/779: just a nolint (`cache.go`)
+- https://github.com/golangci/golangci-lint/pull/788: only directory permissions changes (0777 -> 0744) (`cache.go`, `cache_test.go`, `default.go`)
+- https://github.com/golangci/golangci-lint/pull/808: mainly related to logs and errors (`cache.go`, `default.go`, `hash.go`, `hash_test.go`)
+- https://github.com/golangci/golangci-lint/pull/1063: `ioutil` -> `robustio` (`cache.go`)
+- https://github.com/golangci/golangci-lint/pull/1070: add `t.Parallel()` inside `cache_test.go`
+- https://github.com/golangci/golangci-lint/pull/1162: errors inside `cache.go`
+- https://github.com/golangci/golangci-lint/pull/2318: `ioutil` -> `os` (`cache.go`, `cache_test.go`, `default.go`, `hash_test.go`)
+- https://github.com/golangci/golangci-lint/pull/2352: Go doc typos
+- https://github.com/golangci/golangci-lint/pull/3012: errors inside `cache.go` (`cache.go`, `default.go`)
+- https://github.com/golangci/golangci-lint/pull/3196: constant for `GOLANGCI_LINT_CACHE` (`cache.go`)
+- https://github.com/golangci/golangci-lint/pull/3204: add this file and `%w` in `fmt.Errorf` (`cache.go`)
+- https://github.com/golangci/golangci-lint/pull/3604: remove `github.com/pkg/errors` (`cache.go`)
diff --git a/vendor/github.com/golangci/golangci-lint/v2/internal/go/cacheprog/cacheprog.go b/vendor/github.com/golangci/golangci-lint/v2/internal/go/cacheprog/cacheprog.go
new file mode 100644
index 0000000000..9379636e5a
--- /dev/null
+++ b/vendor/github.com/golangci/golangci-lint/v2/internal/go/cacheprog/cacheprog.go
@@ -0,0 +1,126 @@
+// Copyright 2024 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Package cacheprog defines the protocol for a GOCACHEPROG program.
+//
+// By default, the go command manages a build cache stored in the file system
+// itself. GOCACHEPROG can be set to the name of a command (with optional
+// space-separated flags) that implements the go command build cache externally.
+// This permits defining a different cache policy.
+//
+// The go command will start the GOCACHEPROG as a subprocess and communicate
+// with it via JSON messages over stdin/stdout. The subprocess's stderr will be
+// connected to the go command's stderr.
+//
+// The subprocess should immediately send a [Response] with its capabilities.
+// After that, the go command will send a stream of [Request] messages and the
+// subprocess should reply to each [Request] with a [Response] message.
+package cacheprog
+
+import (
+ "io"
+ "time"
+)
+
+// Cmd is a command that can be issued to a child process.
+//
+// If the interface needs to grow, the go command can add new commands or new
+// versioned commands like "get2" in the future. The initial [Response] from
+// the child process indicates which commands it supports.
+type Cmd string
+
+const (
+ // CmdPut tells the cache program to store an object in the cache.
+ //
+ // [Request.ActionID] is the cache key of this object. The cache should
+ // store [Request.OutputID] and [Request.Body] under this key for a
+ // later "get" request. It must also store the Body in a file in the local
+ // file system and return the path to that file in [Response.DiskPath],
+ // which must exist at least until a "close" request.
+ CmdPut = Cmd("put")
+
+ // CmdGet tells the cache program to retrieve an object from the cache.
+ //
+ // [Request.ActionID] specifies the key of the object to get. If the
+ // cache does not contain this object, it should set [Response.Miss] to
+ // true. Otherwise, it should populate the fields of [Response],
+ // including setting [Response.OutputID] to the OutputID of the original
+ // "put" request and [Response.DiskPath] to the path of a local file
+ // containing the Body of the original "put" request. That file must
+ // continue to exist at least until a "close" request.
+ CmdGet = Cmd("get")
+
+ // CmdClose requests that the cache program exit gracefully.
+ //
+ // The cache program should reply to this request and then exit
+ // (thus closing its stdout).
+ CmdClose = Cmd("close")
+)
+
+// Request is the JSON-encoded message that's sent from the go command to
+// the GOCACHEPROG child process over stdin. Each JSON object is on its own
+// line. A ProgRequest of Type "put" with BodySize > 0 will be followed by a
+// line containing a base64-encoded JSON string literal of the body.
+type Request struct {
+ // ID is a unique number per process across all requests.
+ // It must be echoed in the Response from the child.
+ ID int64
+
+ // Command is the type of request.
+ // The go command will only send commands that were declared
+ // as supported by the child.
+ Command Cmd
+
+ // ActionID is the cache key for "put" and "get" requests.
+ ActionID []byte `json:",omitempty"` // or nil if not used
+
+ // OutputID is stored with the body for "put" requests.
+ OutputID []byte `json:",omitempty"` // or nil if not used
+
+ // Body is the body for "put" requests. It's sent after the JSON object
+ // as a base64-encoded JSON string when BodySize is non-zero.
+ // It's sent as a separate JSON value instead of being a struct field
+ // send in this JSON object so large values can be streamed in both directions.
+ // The base64 string body of a Request will always be written
+ // immediately after the JSON object and a newline.
+ Body io.Reader `json:"-"`
+
+ // BodySize is the number of bytes of Body. If zero, the body isn't written.
+ BodySize int64 `json:",omitempty"`
+}
+
+// Response is the JSON response from the child process to the go command.
+//
+// With the exception of the first protocol message that the child writes to its
+// stdout with ID==0 and KnownCommands populated, these are only sent in
+// response to a Request from the go command.
+//
+// Responses can be sent in any order. The ID must match the request they're
+// replying to.
+type Response struct {
+ ID int64 // that corresponds to Request; they can be answered out of order
+ Err string `json:",omitempty"` // if non-empty, the error
+
+ // KnownCommands is included in the first message that cache helper program
+ // writes to stdout on startup (with ID==0). It includes the
+ // Request.Command types that are supported by the program.
+ //
+ // This lets the go command extend the protocol gracefully over time (adding
+ // "get2", etc), or fail gracefully when needed. It also lets the go command
+ // verify the program wants to be a cache helper.
+ KnownCommands []Cmd `json:",omitempty"`
+
+ // For "get" requests.
+
+ Miss bool `json:",omitempty"` // cache miss
+ OutputID []byte `json:",omitempty"` // the OutputID stored with the body
+ Size int64 `json:",omitempty"` // body size in bytes
+ Time *time.Time `json:",omitempty"` // when the object was put in the cache (optional; used for cache expiration)
+
+ // For "get" and "put" requests.
+
+ // DiskPath is the absolute path on disk of the body corresponding to a
+ // "get" (on cache hit) or "put" request's ActionID.
+ DiskPath string `json:",omitempty"`
+}
diff --git a/vendor/github.com/golangci/golangci-lint/v2/internal/go/cacheprog/readme.md b/vendor/github.com/golangci/golangci-lint/v2/internal/go/cacheprog/readme.md
new file mode 100644
index 0000000000..defb1adae4
--- /dev/null
+++ b/vendor/github.com/golangci/golangci-lint/v2/internal/go/cacheprog/readme.md
@@ -0,0 +1,11 @@
+# quoted
+
+Extracted from `go/src/cmd/go/internal/cacheprog/` (related to `cache`).
+This is just a copy of the Go code without any changes.
+
+## History
+
+- https://github.com/golangci/golangci-lint/pull/6642
+ - sync go1.26.4
+- https://github.com/golangci/golangci-lint/pull/5576
+ - sync go1.24.1
diff --git a/vendor/github.com/golangci/golangci-lint/v2/internal/go/mmap/mmap.go b/vendor/github.com/golangci/golangci-lint/v2/internal/go/mmap/mmap.go
new file mode 100644
index 0000000000..cd7ea80f2d
--- /dev/null
+++ b/vendor/github.com/golangci/golangci-lint/v2/internal/go/mmap/mmap.go
@@ -0,0 +1,51 @@
+// Copyright 2011 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// This package is a lightly modified version of the mmap code
+// in github.com/google/codesearch/index.
+
+// The mmap package provides an abstraction for memory mapping files
+// on different platforms.
+package mmap
+
+import (
+ "os"
+)
+
+// Data is mmap'ed read-only data from a file.
+// The backing file is never closed, so Data
+// remains valid for the lifetime of the process.
+type Data struct {
+ f *os.File
+ Data []byte
+}
+
+// Mmap maps the given file into memory.
+// The boolean result indicates whether the file was opened.
+// If it is true, the caller should avoid attempting
+// to write to the file on Windows, because Windows locks
+// the open file, and writes to it will fail.
+func Mmap(file string) (Data, bool, error) {
+ f, err := os.Open(file)
+ if err != nil {
+ return Data{}, false, err
+ }
+ data, err := mmapFile(f)
+
+ // Closing the file causes it not to count against this process's
+ // limit on open files; however, the mapping still counts against
+ // the system-wide limit, which is typically higher. Examples:
+ //
+ // macOS process (sysctl kern.maxfilesperproc): 61440
+ // macOS system (sysctl kern.maxfiles): 122880
+ // linux process (ulimit -n) 1048576
+ // linux system (/proc/sys/fs/file-max) 100000
+ if cerr := f.Close(); cerr != nil && err == nil {
+ return data, true, cerr
+ }
+
+ // The file is still considered to be in use on Windows after
+ // it's closed because of the mapping.
+ return data, true, err
+}
diff --git a/vendor/github.com/golangci/golangci-lint/internal/go/mmap/mmap_other.go b/vendor/github.com/golangci/golangci-lint/v2/internal/go/mmap/mmap_other.go
similarity index 100%
rename from vendor/github.com/golangci/golangci-lint/internal/go/mmap/mmap_other.go
rename to vendor/github.com/golangci/golangci-lint/v2/internal/go/mmap/mmap_other.go
diff --git a/vendor/github.com/golangci/golangci-lint/internal/go/mmap/mmap_unix.go b/vendor/github.com/golangci/golangci-lint/v2/internal/go/mmap/mmap_unix.go
similarity index 100%
rename from vendor/github.com/golangci/golangci-lint/internal/go/mmap/mmap_unix.go
rename to vendor/github.com/golangci/golangci-lint/v2/internal/go/mmap/mmap_unix.go
diff --git a/vendor/github.com/golangci/golangci-lint/v2/internal/go/mmap/mmap_windows.go b/vendor/github.com/golangci/golangci-lint/v2/internal/go/mmap/mmap_windows.go
new file mode 100644
index 0000000000..256fab4b49
--- /dev/null
+++ b/vendor/github.com/golangci/golangci-lint/v2/internal/go/mmap/mmap_windows.go
@@ -0,0 +1,47 @@
+// Copyright 2011 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package mmap
+
+import (
+ "fmt"
+ "os"
+ "syscall"
+ "unsafe"
+
+ "golang.org/x/sys/windows"
+)
+
+func mmapFile(f *os.File) (Data, error) {
+ st, err := f.Stat()
+ if err != nil {
+ return Data{}, err
+ }
+ size := st.Size()
+ if size == 0 {
+ return Data{f, nil}, nil
+ }
+ h, err := syscall.CreateFileMapping(syscall.Handle(f.Fd()), nil, syscall.PAGE_READONLY, 0, 0, nil)
+ if err != nil {
+ return Data{}, fmt.Errorf("CreateFileMapping %s: %w", f.Name(), err)
+ }
+
+ addr, err := syscall.MapViewOfFile(h, syscall.FILE_MAP_READ, 0, 0, 0)
+ if err != nil {
+ return Data{}, fmt.Errorf("MapViewOfFile %s: %w", f.Name(), err)
+ }
+ var info windows.MemoryBasicInformation
+ err = windows.VirtualQuery(addr, &info, unsafe.Sizeof(info))
+ if err != nil {
+ return Data{}, fmt.Errorf("VirtualQuery %s: %w", f.Name(), err)
+ }
+ data := unsafe.Slice((*byte)(unsafe.Pointer(addr)), int(info.RegionSize))
+ if len(data) < int(size) {
+ // In some cases, especially on 386, we may not receive a in incomplete mapping:
+ // one that is shorter than the file itself. Return an error in those cases because
+ // incomplete mappings are not useful.
+ return Data{}, fmt.Errorf("mmapFile: received incomplete mapping of file")
+ }
+ return Data{f, data[:int(size)]}, nil
+}
diff --git a/vendor/github.com/golangci/golangci-lint/v2/internal/go/mmap/readme.md b/vendor/github.com/golangci/golangci-lint/v2/internal/go/mmap/readme.md
new file mode 100644
index 0000000000..764c2444ad
--- /dev/null
+++ b/vendor/github.com/golangci/golangci-lint/v2/internal/go/mmap/readme.md
@@ -0,0 +1,19 @@
+# mmap
+
+Extracted from `go/src/cmd/go/internal/mmap/` (related to `cache`).
+This is just a copy of the Go code without any changes.
+
+## History
+
+- https://github.com/golangci/golangci-lint/pull/6642
+ - sync go1.26.4
+- https://github.com/golangci/golangci-lint/pull/5576
+ - sync go1.24.1
+- https://github.com/golangci/golangci-lint/pull/5100
+ - Move package from `internal/mmap` to `internal/go/mmap`
+- https://github.com/golangci/golangci-lint/pull/5098
+ - sync with go1.23.2
+ - sync with go1.22.8
+ - sync with go1.21.13
+ - sync with go1.20.14
+ - sync with go1.19.13
diff --git a/vendor/github.com/golangci/golangci-lint/internal/go/quoted/quoted.go b/vendor/github.com/golangci/golangci-lint/v2/internal/go/quoted/quoted.go
similarity index 100%
rename from vendor/github.com/golangci/golangci-lint/internal/go/quoted/quoted.go
rename to vendor/github.com/golangci/golangci-lint/v2/internal/go/quoted/quoted.go
diff --git a/vendor/github.com/golangci/golangci-lint/v2/internal/go/quoted/readme.md b/vendor/github.com/golangci/golangci-lint/v2/internal/go/quoted/readme.md
new file mode 100644
index 0000000000..45467e928a
--- /dev/null
+++ b/vendor/github.com/golangci/golangci-lint/v2/internal/go/quoted/readme.md
@@ -0,0 +1,17 @@
+# quoted
+
+Extracted from `go/src/cmd/internal/quoted/` (related to `cache`).
+This is just a copy of the Go code without any changes.
+
+## History
+
+- https://github.com/golangci/golangci-lint/pull/6642
+ - sync go1.26.4 (no change)
+- https://github.com/golangci/golangci-lint/pull/5576
+ - sync go1.24.1 (no change)
+- https://github.com/golangci/golangci-lint/pull/5100
+ - Move package from `internal/quoted` to `internal/go/quoted`
+- https://github.com/golangci/golangci-lint/pull/5098
+ - sync go1.23.2
+ - sync go1.22.8
+ - sync go1.21.13
diff --git a/vendor/github.com/golangci/golangci-lint/internal/x/LICENSE b/vendor/github.com/golangci/golangci-lint/v2/internal/x/LICENSE
similarity index 100%
rename from vendor/github.com/golangci/golangci-lint/internal/x/LICENSE
rename to vendor/github.com/golangci/golangci-lint/v2/internal/x/LICENSE
diff --git a/vendor/github.com/golangci/golangci-lint/v2/internal/x/tools/diff/diff.go b/vendor/github.com/golangci/golangci-lint/v2/internal/x/tools/diff/diff.go
new file mode 100644
index 0000000000..c12bdfd2ac
--- /dev/null
+++ b/vendor/github.com/golangci/golangci-lint/v2/internal/x/tools/diff/diff.go
@@ -0,0 +1,177 @@
+// Copyright 2019 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Package diff computes differences between text files or strings.
+package diff
+
+import (
+ "fmt"
+ "slices"
+ "sort"
+ "strings"
+)
+
+// An Edit describes the replacement of a portion of a text file.
+type Edit struct {
+ Start, End int // byte offsets of the region to replace
+ New string // the replacement
+}
+
+func (e Edit) String() string {
+ return fmt.Sprintf("{Start:%d,End:%d,New:%q}", e.Start, e.End, e.New)
+}
+
+// Apply applies a sequence of edits to the src buffer and returns the
+// result. Edits are applied in order of start offset; edits with the
+// same start offset are applied in they order they were provided.
+//
+// Apply returns an error if any edit is out of bounds,
+// or if any pair of edits is overlapping.
+func Apply(src string, edits []Edit) (string, error) {
+ edits, size, err := validate(src, edits)
+ if err != nil {
+ return "", err
+ }
+
+ // Apply edits.
+ out := make([]byte, 0, size)
+ lastEnd := 0
+ for _, edit := range edits {
+ if lastEnd < edit.Start {
+ out = append(out, src[lastEnd:edit.Start]...)
+ }
+ out = append(out, edit.New...)
+ lastEnd = edit.End
+ }
+ out = append(out, src[lastEnd:]...)
+
+ if len(out) != size {
+ panic("wrong size")
+ }
+
+ return string(out), nil
+}
+
+// ApplyBytes is like Apply, but it accepts a byte slice.
+// The result is always a new array.
+func ApplyBytes(src []byte, edits []Edit) ([]byte, error) {
+ res, err := Apply(string(src), edits)
+ return []byte(res), err
+}
+
+// validate checks that edits are consistent with src,
+// and returns the size of the patched output.
+// It may return a different slice.
+func validate(src string, edits []Edit) ([]Edit, int, error) {
+ if !sort.IsSorted(editsSort(edits)) {
+ edits = slices.Clone(edits)
+ SortEdits(edits)
+ }
+
+ // Check validity of edits and compute final size.
+ size := len(src)
+ lastEnd := 0
+ for _, edit := range edits {
+ if !(0 <= edit.Start && edit.Start <= edit.End && edit.End <= len(src)) {
+ return nil, 0, fmt.Errorf("diff has out-of-bounds edits")
+ }
+ if edit.Start < lastEnd {
+ return nil, 0, fmt.Errorf("diff has overlapping edits")
+ }
+ size += len(edit.New) + edit.Start - edit.End
+ lastEnd = edit.End
+ }
+
+ return edits, size, nil
+}
+
+// SortEdits orders a slice of Edits by (start, end) offset.
+// This ordering puts insertions (end = start) before deletions
+// (end > start) at the same point, but uses a stable sort to preserve
+// the order of multiple insertions at the same point.
+// (Apply detects multiple deletions at the same point as an error.)
+func SortEdits(edits []Edit) {
+ sort.Stable(editsSort(edits))
+}
+
+type editsSort []Edit
+
+func (a editsSort) Len() int { return len(a) }
+func (a editsSort) Less(i, j int) bool {
+ if cmp := a[i].Start - a[j].Start; cmp != 0 {
+ return cmp < 0
+ }
+ return a[i].End < a[j].End
+}
+func (a editsSort) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
+
+// lineEdits expands and merges a sequence of edits so that each
+// resulting edit replaces one or more complete lines.
+// See ApplyEdits for preconditions.
+func lineEdits(src string, edits []Edit) ([]Edit, error) {
+ edits, _, err := validate(src, edits)
+ if err != nil {
+ return nil, err
+ }
+
+ // Do all deletions begin and end at the start of a line,
+ // and all insertions end with a newline?
+ // (This is merely a fast path.)
+ for _, edit := range edits {
+ if edit.Start >= len(src) || // insertion at EOF
+ edit.Start > 0 && src[edit.Start-1] != '\n' || // not at line start
+ edit.End > 0 && src[edit.End-1] != '\n' || // not at line start
+ edit.New != "" && edit.New[len(edit.New)-1] != '\n' { // partial insert
+ goto expand // slow path
+ }
+ }
+ return edits, nil // aligned
+
+expand:
+ if len(edits) == 0 {
+ return edits, nil // no edits (unreachable due to fast path)
+ }
+ expanded := make([]Edit, 0, len(edits)) // a guess
+ prev := edits[0]
+ // TODO(adonovan): opt: start from the first misaligned edit.
+ // TODO(adonovan): opt: avoid quadratic cost of string += string.
+ for _, edit := range edits[1:] {
+ between := src[prev.End:edit.Start]
+ if !strings.Contains(between, "\n") {
+ // overlapping lines: combine with previous edit.
+ prev.New += between + edit.New
+ prev.End = edit.End
+ } else {
+ // non-overlapping lines: flush previous edit.
+ expanded = append(expanded, expandEdit(prev, src))
+ prev = edit
+ }
+ }
+ return append(expanded, expandEdit(prev, src)), nil // flush final edit
+}
+
+// expandEdit returns edit expanded to complete whole lines.
+func expandEdit(edit Edit, src string) Edit {
+ // Expand start left to start of line.
+ // (delta is the zero-based column number of start.)
+ start := edit.Start
+ if delta := start - 1 - strings.LastIndex(src[:start], "\n"); delta > 0 {
+ edit.Start -= delta
+ edit.New = src[start-delta:start] + edit.New
+ }
+
+ // Expand end right to end of line.
+ end := edit.End
+ if end > 0 && src[end-1] != '\n' ||
+ edit.New != "" && edit.New[len(edit.New)-1] != '\n' {
+ if nl := strings.IndexByte(src[end:], '\n'); nl < 0 {
+ edit.End = len(src) // extend to EOF
+ } else {
+ edit.End = end + nl + 1 // extend beyond \n
+ }
+ }
+ edit.New += src[end:edit.End]
+
+ return edit
+}
diff --git a/vendor/github.com/golangci/golangci-lint/v2/internal/x/tools/diff/lcs/common.go b/vendor/github.com/golangci/golangci-lint/v2/internal/x/tools/diff/lcs/common.go
new file mode 100644
index 0000000000..27fa9ecbd5
--- /dev/null
+++ b/vendor/github.com/golangci/golangci-lint/v2/internal/x/tools/diff/lcs/common.go
@@ -0,0 +1,179 @@
+// Copyright 2022 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package lcs
+
+import (
+ "log"
+ "sort"
+)
+
+// lcs is a longest common sequence
+type lcs []diag
+
+// A diag is a piece of the edit graph where A[X+i] == B[Y+i], for 0<=i l[j].Len
+ })
+ return l
+}
+
+// validate that the elements of the lcs do not overlap
+// (can only happen when the two-sided algorithm ends early)
+// expects the lcs to be sorted
+func (l lcs) valid() bool {
+ for i := 1; i < len(l); i++ {
+ if l[i-1].X+l[i-1].Len > l[i].X {
+ return false
+ }
+ if l[i-1].Y+l[i-1].Len > l[i].Y {
+ return false
+ }
+ }
+ return true
+}
+
+// repair overlapping lcs
+// only called if two-sided stops early
+func (l lcs) fix() lcs {
+ // from the set of diagonals in l, find a maximal non-conflicting set
+ // this problem may be NP-complete, but we use a greedy heuristic,
+ // which is quadratic, but with a better data structure, could be D log D.
+ // independent is not enough: {0,3,1} and {3,0,2} can't both occur in an lcs
+ // which has to have monotone x and y
+ if len(l) == 0 {
+ return nil
+ }
+ sort.Slice(l, func(i, j int) bool { return l[i].Len > l[j].Len })
+ tmp := make(lcs, 0, len(l))
+ tmp = append(tmp, l[0])
+ for i := 1; i < len(l); i++ {
+ var dir direction
+ nxt := l[i]
+ for _, in := range tmp {
+ if dir, nxt = overlap(in, nxt); dir == empty || dir == bad {
+ break
+ }
+ }
+ if nxt.Len > 0 && dir != bad {
+ tmp = append(tmp, nxt)
+ }
+ }
+ tmp.sort()
+ if false && !tmp.valid() { // debug checking
+ log.Fatalf("here %d", len(tmp))
+ }
+ return tmp
+}
+
+type direction int
+
+const (
+ empty direction = iota // diag is empty (so not in lcs)
+ leftdown // proposed acceptably to the left and below
+ rightup // proposed diag is acceptably to the right and above
+ bad // proposed diag is inconsistent with the lcs so far
+)
+
+// overlap trims the proposed diag prop so it doesn't overlap with
+// the existing diag that has already been added to the lcs.
+func overlap(exist, prop diag) (direction, diag) {
+ if prop.X <= exist.X && exist.X < prop.X+prop.Len {
+ // remove the end of prop where it overlaps with the X end of exist
+ delta := prop.X + prop.Len - exist.X
+ prop.Len -= delta
+ if prop.Len <= 0 {
+ return empty, prop
+ }
+ }
+ if exist.X <= prop.X && prop.X < exist.X+exist.Len {
+ // remove the beginning of prop where overlaps with exist
+ delta := exist.X + exist.Len - prop.X
+ prop.Len -= delta
+ if prop.Len <= 0 {
+ return empty, prop
+ }
+ prop.X += delta
+ prop.Y += delta
+ }
+ if prop.Y <= exist.Y && exist.Y < prop.Y+prop.Len {
+ // remove the end of prop that overlaps (in Y) with exist
+ delta := prop.Y + prop.Len - exist.Y
+ prop.Len -= delta
+ if prop.Len <= 0 {
+ return empty, prop
+ }
+ }
+ if exist.Y <= prop.Y && prop.Y < exist.Y+exist.Len {
+ // remove the beginning of peop that overlaps with exist
+ delta := exist.Y + exist.Len - prop.Y
+ prop.Len -= delta
+ if prop.Len <= 0 {
+ return empty, prop
+ }
+ prop.X += delta // no test reaches this code
+ prop.Y += delta
+ }
+ if prop.X+prop.Len <= exist.X && prop.Y+prop.Len <= exist.Y {
+ return leftdown, prop
+ }
+ if exist.X+exist.Len <= prop.X && exist.Y+exist.Len <= prop.Y {
+ return rightup, prop
+ }
+ // prop can't be in an lcs that contains exist
+ return bad, prop
+}
+
+// manipulating Diag and lcs
+
+// prepend a diagonal (x,y)-(x+1,y+1) segment either to an empty lcs
+// or to its first Diag. prepend is only called to extend diagonals
+// the backward direction.
+func (lcs lcs) prepend(x, y int) lcs {
+ if len(lcs) > 0 {
+ d := &lcs[0]
+ if int(d.X) == x+1 && int(d.Y) == y+1 {
+ // extend the diagonal down and to the left
+ d.X, d.Y = int(x), int(y)
+ d.Len++
+ return lcs
+ }
+ }
+
+ r := diag{X: int(x), Y: int(y), Len: 1}
+ lcs = append([]diag{r}, lcs...)
+ return lcs
+}
+
+// append appends a diagonal, or extends the existing one.
+// by adding the edge (x,y)-(x+1.y+1). append is only called
+// to extend diagonals in the forward direction.
+func (lcs lcs) append(x, y int) lcs {
+ if len(lcs) > 0 {
+ last := &lcs[len(lcs)-1]
+ // Expand last element if adjoining.
+ if last.X+last.Len == x && last.Y+last.Len == y {
+ last.Len++
+ return lcs
+ }
+ }
+
+ return append(lcs, diag{X: x, Y: y, Len: 1})
+}
+
+// enforce constraint on d, k
+func ok(d, k int) bool {
+ return d >= 0 && -d <= k && k <= d
+}
diff --git a/vendor/github.com/golangci/golangci-lint/v2/internal/x/tools/diff/lcs/doc.go b/vendor/github.com/golangci/golangci-lint/v2/internal/x/tools/diff/lcs/doc.go
new file mode 100644
index 0000000000..aa4b0fb591
--- /dev/null
+++ b/vendor/github.com/golangci/golangci-lint/v2/internal/x/tools/diff/lcs/doc.go
@@ -0,0 +1,156 @@
+// Copyright 2022 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// package lcs contains code to find longest-common-subsequences
+// (and diffs)
+package lcs
+
+/*
+Compute longest-common-subsequences of two slices A, B using
+algorithms from Myers' paper. A longest-common-subsequence
+(LCS from now on) of A and B is a maximal set of lexically increasing
+pairs of subscripts (x,y) with A[x]==B[y]. There may be many LCS, but
+they all have the same length. An LCS determines a sequence of edits
+that changes A into B.
+
+The key concept is the edit graph of A and B.
+If A has length N and B has length M, then the edit graph has
+vertices v[i][j] for 0 <= i <= N, 0 <= j <= M. There is a
+horizontal edge from v[i][j] to v[i+1][j] whenever both are in
+the graph, and a vertical edge from v[i][j] to f[i][j+1] similarly.
+When A[i] == B[j] there is a diagonal edge from v[i][j] to v[i+1][j+1].
+
+A path between in the graph between (0,0) and (N,M) determines a sequence
+of edits converting A into B: each horizontal edge corresponds to removing
+an element of A, and each vertical edge corresponds to inserting an
+element of B.
+
+A vertex (x,y) is on (forward) diagonal k if x-y=k. A path in the graph
+is of length D if it has D non-diagonal edges. The algorithms generate
+forward paths (in which at least one of x,y increases at each edge),
+or backward paths (in which at least one of x,y decreases at each edge),
+or a combination. (Note that the orientation is the traditional mathematical one,
+with the origin in the lower-left corner.)
+
+Here is the edit graph for A:"aabbaa", B:"aacaba". (I know the diagonals look weird.)
+ ⊙ ------- ⊙ ------- ⊙ ------- ⊙ ------- ⊙ ------- ⊙ ------- ⊙
+ a | ___/‾‾‾ | ___/‾‾‾ | | | ___/‾‾‾ | ___/‾‾‾ |
+ ⊙ ------- ⊙ ------- ⊙ ------- ⊙ ------- ⊙ ------- ⊙ ------- ⊙
+ b | | | ___/‾‾‾ | ___/‾‾‾ | | |
+ ⊙ ------- ⊙ ------- ⊙ ------- ⊙ ------- ⊙ ------- ⊙ ------- ⊙
+ a | ___/‾‾‾ | ___/‾‾‾ | | | ___/‾‾‾ | ___/‾‾‾ |
+ ⊙ ------- ⊙ ------- ⊙ ------- ⊙ ------- ⊙ ------- ⊙ ------- ⊙
+ c | | | | | | |
+ ⊙ ------- ⊙ ------- ⊙ ------- ⊙ ------- ⊙ ------- ⊙ ------- ⊙
+ a | ___/‾‾‾ | ___/‾‾‾ | | | ___/‾‾‾ | ___/‾‾‾ |
+ ⊙ ------- ⊙ ------- ⊙ ------- ⊙ ------- ⊙ ------- ⊙ ------- ⊙
+ a | ___/‾‾‾ | ___/‾‾‾ | | | ___/‾‾‾ | ___/‾‾‾ |
+ ⊙ ------- ⊙ ------- ⊙ ------- ⊙ ------- ⊙ ------- ⊙ ------- ⊙
+ a a b b a a
+
+
+The algorithm labels a vertex (x,y) with D,k if it is on diagonal k and at
+the end of a maximal path of length D. (Because x-y=k it suffices to remember
+only the x coordinate of the vertex.)
+
+The forward algorithm: Find the longest diagonal starting at (0,0) and
+label its end with D=0,k=0. From that vertex take a vertical step and
+then follow the longest diagonal (up and to the right), and label that vertex
+with D=1,k=-1. From the D=0,k=0 point take a horizontal step and the follow
+the longest diagonal (up and to the right) and label that vertex
+D=1,k=1. In the same way, having labelled all the D vertices,
+from a vertex labelled D,k find two vertices
+tentatively labelled D+1,k-1 and D+1,k+1. There may be two on the same
+diagonal, in which case take the one with the larger x.
+
+Eventually the path gets to (N,M), and the diagonals on it are the LCS.
+
+Here is the edit graph with the ends of D-paths labelled. (So, for instance,
+0/2,2 indicates that x=2,y=2 is labelled with 0, as it should be, since the first
+step is to go up the longest diagonal from (0,0).)
+A:"aabbaa", B:"aacaba"
+ ⊙ ------- ⊙ ------- ⊙ -------(3/3,6)------- ⊙ -------(3/5,6)-------(4/6,6)
+ a | ___/‾‾‾ | ___/‾‾‾ | | | ___/‾‾‾ | ___/‾‾‾ |
+ ⊙ ------- ⊙ ------- ⊙ -------(2/3,5)------- ⊙ ------- ⊙ ------- ⊙
+ b | | | ___/‾‾‾ | ___/‾‾‾ | | |
+ ⊙ ------- ⊙ ------- ⊙ ------- ⊙ ------- ⊙ -------(3/5,4)------- ⊙
+ a | ___/‾‾‾ | ___/‾‾‾ | | | ___/‾‾‾ | ___/‾‾‾ |
+ ⊙ ------- ⊙ -------(1/2,3)-------(2/3,3)------- ⊙ ------- ⊙ ------- ⊙
+ c | | | | | | |
+ ⊙ ------- ⊙ -------(0/2,2)-------(1/3,2)-------(2/4,2)-------(3/5,2)-------(4/6,2)
+ a | ___/‾‾‾ | ___/‾‾‾ | | | ___/‾‾‾ | ___/‾‾‾ |
+ ⊙ ------- ⊙ ------- ⊙ ------- ⊙ ------- ⊙ ------- ⊙ ------- ⊙
+ a | ___/‾‾‾ | ___/‾‾‾ | | | ___/‾‾‾ | ___/‾‾‾ |
+ ⊙ ------- ⊙ ------- ⊙ ------- ⊙ ------- ⊙ ------- ⊙ ------- ⊙
+ a a b b a a
+
+The 4-path is reconstructed starting at (4/6,6), horizontal to (3/5,6), diagonal to (3,4), vertical
+to (2/3,3), horizontal to (1/2,3), vertical to (0/2,2), and diagonal to (0,0). As expected,
+there are 4 non-diagonal steps, and the diagonals form an LCS.
+
+There is a symmetric backward algorithm, which gives (backwards labels are prefixed with a colon):
+A:"aabbaa", B:"aacaba"
+ ⊙ -------- ⊙ -------- ⊙ -------- ⊙ -------- ⊙ -------- ⊙ -------- ⊙
+ a | ____/‾‾‾ | ____/‾‾‾ | | | ____/‾‾‾ | ____/‾‾‾ |
+ ⊙ -------- ⊙ -------- ⊙ -------- ⊙ -------- ⊙ --------(:0/5,5)-------- ⊙
+ b | | | ____/‾‾‾ | ____/‾‾‾ | | |
+ ⊙ -------- ⊙ -------- ⊙ --------(:1/3,4)-------- ⊙ -------- ⊙ -------- ⊙
+ a | ____/‾‾‾ | ____/‾‾‾ | | | ____/‾‾‾ | ____/‾‾‾ |
+ (:3/0,3)--------(:2/1,3)-------- ⊙ --------(:2/3,3)--------(:1/4,3)-------- ⊙ -------- ⊙
+ c | | | | | | |
+ ⊙ -------- ⊙ -------- ⊙ --------(:3/3,2)--------(:2/4,2)-------- ⊙ -------- ⊙
+ a | ____/‾‾‾ | ____/‾‾‾ | | | ____/‾‾‾ | ____/‾‾‾ |
+ (:3/0,1)-------- ⊙ -------- ⊙ -------- ⊙ --------(:3/4,1)-------- ⊙ -------- ⊙
+ a | ____/‾‾‾ | ____/‾‾‾ | | | ____/‾‾‾ | ____/‾‾‾ |
+ (:4/0,0)-------- ⊙ -------- ⊙ -------- ⊙ --------(:4/4,0)-------- ⊙ -------- ⊙
+ a a b b a a
+
+Neither of these is ideal for use in an editor, where it is undesirable to send very long diffs to the
+front end. It's tricky to decide exactly what 'very long diffs' means, as "replace A by B" is very short.
+We want to control how big D can be, by stopping when it gets too large. The forward algorithm then
+privileges common prefixes, and the backward algorithm privileges common suffixes. Either is an undesirable
+asymmetry.
+
+Fortunately there is a two-sided algorithm, implied by results in Myers' paper. Here's what the labels in
+the edit graph look like.
+A:"aabbaa", B:"aacaba"
+ ⊙ --------- ⊙ --------- ⊙ --------- ⊙ --------- ⊙ --------- ⊙ --------- ⊙
+ a | ____/‾‾‾‾ | ____/‾‾‾‾ | | | ____/‾‾‾‾ | ____/‾‾‾‾ |
+ ⊙ --------- ⊙ --------- ⊙ --------- (2/3,5) --------- ⊙ --------- (:0/5,5)--------- ⊙
+ b | | | ____/‾‾‾‾ | ____/‾‾‾‾ | | |
+ ⊙ --------- ⊙ --------- ⊙ --------- (:1/3,4)--------- ⊙ --------- ⊙ --------- ⊙
+ a | ____/‾‾‾‾ | ____/‾‾‾‾ | | | ____/‾‾‾‾ | ____/‾‾‾‾ |
+ ⊙ --------- (:2/1,3)--------- (1/2,3) ---------(2:2/3,3)--------- (:1/4,3)--------- ⊙ --------- ⊙
+ c | | | | | | |
+ ⊙ --------- ⊙ --------- (0/2,2) --------- (1/3,2) ---------(2:2/4,2)--------- ⊙ --------- ⊙
+ a | ____/‾‾‾‾ | ____/‾‾‾‾ | | | ____/‾‾‾‾ | ____/‾‾‾‾ |
+ ⊙ --------- ⊙ --------- ⊙ --------- ⊙ --------- ⊙ --------- ⊙ --------- ⊙
+ a | ____/‾‾‾‾ | ____/‾‾‾‾ | | | ____/‾‾‾‾ | ____/‾‾‾‾ |
+ ⊙ --------- ⊙ --------- ⊙ --------- ⊙ --------- ⊙ --------- ⊙ --------- ⊙
+ a a b b a a
+
+The algorithm stopped when it saw the backwards 2-path ending at (1,3) and the forwards 2-path ending at (3,5). The criterion
+is a backwards path ending at (u,v) and a forward path ending at (x,y), where u <= x and the two points are on the same
+diagonal. (Here the edgegraph has a diagonal, but the criterion is x-y=u-v.) Myers proves there is a forward
+2-path from (0,0) to (1,3), and that together with the backwards 2-path ending at (1,3) gives the expected 4-path.
+Unfortunately the forward path has to be constructed by another run of the forward algorithm; it can't be found from the
+computed labels. That is the worst case. Had the code noticed (x,y)=(u,v)=(3,3) the whole path could be reconstructed
+from the edgegraph. The implementation looks for a number of special cases to try to avoid computing an extra forward path.
+
+If the two-sided algorithm has stop early (because D has become too large) it will have found a forward LCS and a
+backwards LCS. Ideally these go with disjoint prefixes and suffixes of A and B, but disjointedness may fail and the two
+computed LCS may conflict. (An easy example is where A is a suffix of B, and shares a short prefix. The backwards LCS
+is all of A, and the forward LCS is a prefix of A.) The algorithm combines the two
+to form a best-effort LCS. In the worst case the forward partial LCS may have to
+be recomputed.
+*/
+
+/* Eugene Myers paper is titled
+"An O(ND) Difference Algorithm and Its Variations"
+and can be found at
+http://www.xmailserver.org/diff2.pdf
+
+(There is a generic implementation of the algorithm the repository with git hash
+b9ad7e4ade3a686d608e44475390ad428e60e7fc)
+*/
diff --git a/vendor/github.com/golangci/golangci-lint/internal/x/tools/diff/lcs/git.sh b/vendor/github.com/golangci/golangci-lint/v2/internal/x/tools/diff/lcs/git.sh
similarity index 100%
rename from vendor/github.com/golangci/golangci-lint/internal/x/tools/diff/lcs/git.sh
rename to vendor/github.com/golangci/golangci-lint/v2/internal/x/tools/diff/lcs/git.sh
diff --git a/vendor/github.com/golangci/golangci-lint/internal/x/tools/diff/lcs/labels.go b/vendor/github.com/golangci/golangci-lint/v2/internal/x/tools/diff/lcs/labels.go
similarity index 100%
rename from vendor/github.com/golangci/golangci-lint/internal/x/tools/diff/lcs/labels.go
rename to vendor/github.com/golangci/golangci-lint/v2/internal/x/tools/diff/lcs/labels.go
diff --git a/vendor/github.com/golangci/golangci-lint/internal/x/tools/diff/lcs/old.go b/vendor/github.com/golangci/golangci-lint/v2/internal/x/tools/diff/lcs/old.go
similarity index 96%
rename from vendor/github.com/golangci/golangci-lint/internal/x/tools/diff/lcs/old.go
rename to vendor/github.com/golangci/golangci-lint/v2/internal/x/tools/diff/lcs/old.go
index 4353da15ba..d6265c8c7f 100644
--- a/vendor/github.com/golangci/golangci-lint/internal/x/tools/diff/lcs/old.go
+++ b/vendor/github.com/golangci/golangci-lint/v2/internal/x/tools/diff/lcs/old.go
@@ -16,10 +16,6 @@ type Diff struct {
ReplStart, ReplEnd int // offset of replacement text in B
}
-// DiffStrings returns the differences between two strings.
-// It does not respect rune boundaries.
-func DiffStrings(a, b string) []Diff { return diff(stringSeqs{a, b}) }
-
// DiffBytes returns the differences between two byte sequences.
// It does not respect rune boundaries.
func DiffBytes(a, b []byte) []Diff { return diff(bytesSeqs{a, b}) }
@@ -27,9 +23,13 @@ func DiffBytes(a, b []byte) []Diff { return diff(bytesSeqs{a, b}) }
// DiffRunes returns the differences between two rune sequences.
func DiffRunes(a, b []rune) []Diff { return diff(runesSeqs{a, b}) }
+// DiffLines returns the differences between two string sequences.
+func DiffLines(a, b []string) []Diff { return diff(linesSeqs{a, b}) }
+
+// A limit on how deeply the LCS algorithm should search. The value is just a guess.
+var maxDiffs = 100
+
func diff(seqs sequences) []Diff {
- // A limit on how deeply the LCS algorithm should search. The value is just a guess.
- const maxDiffs = 100
diff, _ := compute(seqs, twosided, maxDiffs/2)
return diff
}
@@ -105,7 +105,7 @@ func forward(e *editGraph) lcs {
return ans
}
// from D to D+1
- for D := 0; D < e.limit; D++ {
+ for D := range e.limit {
e.setForward(D+1, -(D + 1), e.getForward(D, -D))
if ok, ans := e.fdone(D+1, -(D + 1)); ok {
return ans
@@ -199,13 +199,14 @@ func (e *editGraph) bdone(D, k int) (bool, lcs) {
}
// run the backward algorithm, until success or up to the limit on D.
+// (used only by tests)
func backward(e *editGraph) lcs {
e.setBackward(0, 0, e.ux)
if ok, ans := e.bdone(0, 0); ok {
return ans
}
// from D to D+1
- for D := 0; D < e.limit; D++ {
+ for D := range e.limit {
e.setBackward(D+1, -(D + 1), e.getBackward(D, -D)-1)
if ok, ans := e.bdone(D+1, -(D + 1)); ok {
return ans
@@ -299,7 +300,7 @@ func twosided(e *editGraph) lcs {
e.setBackward(0, 0, e.ux)
// from D to D+1
- for D := 0; D < e.limit; D++ {
+ for D := range e.limit {
// just finished a backwards pass, so check
if got, ok := e.twoDone(D, D); ok {
return e.twolcs(D, D, got)
@@ -376,14 +377,8 @@ func (e *editGraph) twoDone(df, db int) (int, bool) {
if (df+db+e.delta)%2 != 0 {
return 0, false // diagonals cannot overlap
}
- kmin := -db + e.delta
- if -df > kmin {
- kmin = -df
- }
- kmax := db + e.delta
- if df < kmax {
- kmax = df
- }
+ kmin := max(-df, -db+e.delta)
+ kmax := min(df, db+e.delta)
for k := kmin; k <= kmax; k += 2 {
x := e.vf.get(df, k)
u := e.vb.get(db, k-e.delta)
diff --git a/vendor/github.com/golangci/golangci-lint/v2/internal/x/tools/diff/lcs/sequence.go b/vendor/github.com/golangci/golangci-lint/v2/internal/x/tools/diff/lcs/sequence.go
new file mode 100644
index 0000000000..429e8c6192
--- /dev/null
+++ b/vendor/github.com/golangci/golangci-lint/v2/internal/x/tools/diff/lcs/sequence.go
@@ -0,0 +1,70 @@
+// Copyright 2022 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package lcs
+
+// This file defines the abstract sequence over which the LCS algorithm operates.
+
+// sequences abstracts a pair of sequences, A and B.
+type sequences interface {
+ lengths() (int, int) // len(A), len(B)
+ commonPrefixLen(ai, aj, bi, bj int) int // len(commonPrefix(A[ai:aj], B[bi:bj]))
+ commonSuffixLen(ai, aj, bi, bj int) int // len(commonSuffix(A[ai:aj], B[bi:bj]))
+}
+
+// The explicit capacity in s[i:j:j] leads to more efficient code.
+
+type bytesSeqs struct{ a, b []byte }
+
+func (s bytesSeqs) lengths() (int, int) { return len(s.a), len(s.b) }
+func (s bytesSeqs) commonPrefixLen(ai, aj, bi, bj int) int {
+ return commonPrefixLen(s.a[ai:aj:aj], s.b[bi:bj:bj])
+}
+func (s bytesSeqs) commonSuffixLen(ai, aj, bi, bj int) int {
+ return commonSuffixLen(s.a[ai:aj:aj], s.b[bi:bj:bj])
+}
+
+type runesSeqs struct{ a, b []rune }
+
+func (s runesSeqs) lengths() (int, int) { return len(s.a), len(s.b) }
+func (s runesSeqs) commonPrefixLen(ai, aj, bi, bj int) int {
+ return commonPrefixLen(s.a[ai:aj:aj], s.b[bi:bj:bj])
+}
+func (s runesSeqs) commonSuffixLen(ai, aj, bi, bj int) int {
+ return commonSuffixLen(s.a[ai:aj:aj], s.b[bi:bj:bj])
+}
+
+type linesSeqs struct{ a, b []string }
+
+func (s linesSeqs) lengths() (int, int) { return len(s.a), len(s.b) }
+func (s linesSeqs) commonPrefixLen(ai, aj, bi, bj int) int {
+ return commonPrefixLen(s.a[ai:aj], s.b[bi:bj])
+}
+func (s linesSeqs) commonSuffixLen(ai, aj, bi, bj int) int {
+ return commonSuffixLen(s.a[ai:aj], s.b[bi:bj])
+}
+
+// TODO(adonovan): optimize these functions using ideas from:
+// - https://go.dev/cl/408116 common.go
+// - https://go.dev/cl/421435 xor_generic.go
+
+// commonPrefixLen returns the length of the common prefix of a[ai:aj] and b[bi:bj].
+func commonPrefixLen[T comparable](a, b []T) int {
+ n := min(len(a), len(b))
+ i := 0
+ for i < n && a[i] == b[i] {
+ i++
+ }
+ return i
+}
+
+// commonSuffixLen returns the length of the common suffix of a[ai:aj] and b[bi:bj].
+func commonSuffixLen[T comparable](a, b []T) int {
+ n := min(len(a), len(b))
+ i := 0
+ for i < n && a[len(a)-1-i] == b[len(b)-1-i] {
+ i++
+ }
+ return i
+}
diff --git a/vendor/github.com/golangci/golangci-lint/internal/x/tools/diff/ndiff.go b/vendor/github.com/golangci/golangci-lint/v2/internal/x/tools/diff/ndiff.go
similarity index 79%
rename from vendor/github.com/golangci/golangci-lint/internal/x/tools/diff/ndiff.go
rename to vendor/github.com/golangci/golangci-lint/v2/internal/x/tools/diff/ndiff.go
index f7aa2b79f6..5083a7ea7a 100644
--- a/vendor/github.com/golangci/golangci-lint/internal/x/tools/diff/ndiff.go
+++ b/vendor/github.com/golangci/golangci-lint/v2/internal/x/tools/diff/ndiff.go
@@ -6,11 +6,30 @@ package diff
import (
"bytes"
+ "strings"
"unicode/utf8"
- "github.com/golangci/golangci-lint/internal/x/tools/diff/lcs"
+ "github.com/golangci/golangci-lint/v2/internal/x/tools/diff/lcs"
)
+// Lines computes differences between two strings. All edits are at line boundaries.
+func Lines(before, after string) []Edit {
+ beforeLines, bOffsets := splitLines(before)
+ afterLines, _ := splitLines(after)
+ diffs := lcs.DiffLines(beforeLines, afterLines)
+
+ // Convert from LCS diffs to Edits
+ res := make([]Edit, len(diffs))
+ for i, d := range diffs {
+ res[i] = Edit{
+ Start: bOffsets[d.Start],
+ End: bOffsets[d.End],
+ New: strings.Join(afterLines[d.ReplStart:d.ReplEnd], ""),
+ }
+ }
+ return res
+}
+
// Strings computes the differences between two strings.
// The resulting edits respect rune boundaries.
func Strings(before, after string) []Edit {
@@ -72,7 +91,7 @@ func diffRunes(before, after []rune) []Edit {
func runes(bytes []byte) []rune {
n := utf8.RuneCount(bytes)
runes := make([]rune, n)
- for i := 0; i < n; i++ {
+ for i := range n {
r, sz := utf8.DecodeRune(bytes)
bytes = bytes[sz:]
runes[i] = r
diff --git a/vendor/github.com/golangci/golangci-lint/v2/internal/x/tools/diff/readme.md b/vendor/github.com/golangci/golangci-lint/v2/internal/x/tools/diff/readme.md
new file mode 100644
index 0000000000..7262b45aa5
--- /dev/null
+++ b/vendor/github.com/golangci/golangci-lint/v2/internal/x/tools/diff/readme.md
@@ -0,0 +1,13 @@
+# diff
+
+Extracted from `/internal/diff/` (related to `fixer`).
+This is just a copy of the code without any changes.
+
+## History
+
+- https://github.com/golangci/golangci-lint/pull/6642
+ - sync with https://github.com/golang/tools/blob/v0.48.0/internal/diff/
+- https://github.com/golangci/golangci-lint/pull/6076
+ - sync with https://github.com/golang/tools/blob/v0.37.0/internal/diff/
+- https://github.com/golangci/golangci-lint/pull/5576
+ - sync with https://github.com/golang/tools/blob/v0.28.0/internal/diff/
diff --git a/vendor/github.com/golangci/golangci-lint/internal/x/tools/diff/unified.go b/vendor/github.com/golangci/golangci-lint/v2/internal/x/tools/diff/unified.go
similarity index 76%
rename from vendor/github.com/golangci/golangci-lint/internal/x/tools/diff/unified.go
rename to vendor/github.com/golangci/golangci-lint/v2/internal/x/tools/diff/unified.go
index cfbda61020..8fc011e4d8 100644
--- a/vendor/github.com/golangci/golangci-lint/internal/x/tools/diff/unified.go
+++ b/vendor/github.com/golangci/golangci-lint/v2/internal/x/tools/diff/unified.go
@@ -7,6 +7,8 @@ package diff
import (
"fmt"
"log"
+ "regexp"
+ "strconv"
"strings"
)
@@ -18,7 +20,7 @@ const DefaultContextLines = 3
// The old and new labels are the names of the old and new files.
// If the strings are equal, it returns the empty string.
func Unified(oldLabel, newLabel, old, new string) string {
- edits := Strings(old, new)
+ edits := Lines(old, new)
unified, err := ToUnified(oldLabel, newLabel, old, edits, DefaultContextLines)
if err != nil {
// Can't happen: edits are consistent.
@@ -114,7 +116,7 @@ func toUnified(fromName, toName string, content string, edits []Edit, contextLin
if err != nil {
return u, err
}
- lines := splitLines(content)
+ lines, _ := splitLines(content)
var h *hunk
last := 0
toLine := 0
@@ -129,12 +131,12 @@ func toUnified(fromName, toName string, content string, edits []Edit, contextLin
switch {
case h != nil && start == last:
- //direct extension
+ // direct extension
case h != nil && start <= last+gap:
- //within range of previous lines, add the joiners
+ // within range of previous lines, add the joiners
addEqualLines(h, lines, last, start)
default:
- //need to start a new hunk
+ // need to start a new hunk
if h != nil {
// add the edge to the previous hunk
addEqualLines(h, lines, last, last+contextLines)
@@ -156,7 +158,8 @@ func toUnified(fromName, toName string, content string, edits []Edit, contextLin
last++
}
if edit.New != "" {
- for _, content := range splitLines(edit.New) {
+ v, _ := splitLines(edit.New)
+ for _, content := range v {
h.lines = append(h.lines, line{kind: opInsert, content: content})
toLine++
}
@@ -170,12 +173,24 @@ func toUnified(fromName, toName string, content string, edits []Edit, contextLin
return u, nil
}
-func splitLines(text string) []string {
- lines := strings.SplitAfter(text, "\n")
- if lines[len(lines)-1] == "" {
- lines = lines[:len(lines)-1]
+// split into lines removing a final empty line,
+// and also return the offsets of the line beginnings.
+func splitLines(text string) ([]string, []int) {
+ var lines []string
+ offsets := []int{0}
+ start := 0
+ for i, r := range text {
+ if r == '\n' {
+ lines = append(lines, text[start:i+1])
+ start = i + 1
+ offsets = append(offsets, start)
+ }
+ }
+ if start < len(text) {
+ lines = append(lines, text[start:])
+ offsets = append(offsets, len(text))
}
- return lines
+ return lines, offsets
}
func addEqualLines(h *hunk, lines []string, start, end int) int {
@@ -249,3 +264,51 @@ func (u unified) String() string {
}
return b.String()
}
+
+// ApplyUnified applies the unified diffs.
+func ApplyUnified(udiffs, bef string) (string, error) {
+ before := strings.Split(bef, "\n")
+ unif := strings.Split(udiffs, "\n")
+ var got []string
+ left := 0
+ // parse and apply the unified diffs
+ for _, l := range unif {
+ if len(l) == 0 {
+ continue // probably the last line (from Split)
+ }
+ switch l[0] {
+ case '@': // The @@ line
+ m := atregexp.FindStringSubmatch(l)
+ fromLine, err := strconv.Atoi(m[1])
+ if err != nil {
+ return "", fmt.Errorf("missing line number in %q", l)
+ }
+ // before is a slice, so0-based; fromLine is 1-based
+ for ; left < fromLine-1; left++ {
+ got = append(got, before[left])
+ }
+ case '+': // add this line
+ if strings.HasPrefix(l, "+++ ") {
+ continue
+ }
+ got = append(got, l[1:])
+ case '-': // delete this line
+ if strings.HasPrefix(l, "--- ") {
+ continue
+ }
+ left++
+ case ' ':
+ return "", fmt.Errorf("unexpected line %q", l)
+ default:
+ return "", fmt.Errorf("invalid unified diff: <<%s>>", udiffs)
+ }
+ }
+ // copy any remaining lines
+ for ; left < len(before); left++ {
+ got = append(got, before[left])
+ }
+ return strings.Join(got, "\n"), nil
+}
+
+// The first number in the @@ lines is the line number in the 'before' data
+var atregexp = regexp.MustCompile(`@@ -(\d+).* @@`)
diff --git a/vendor/github.com/golangci/golangci-lint/v2/internal/x/tools/driverutil/readfile.go b/vendor/github.com/golangci/golangci-lint/v2/internal/x/tools/driverutil/readfile.go
new file mode 100644
index 0000000000..dc1d54dd8b
--- /dev/null
+++ b/vendor/github.com/golangci/golangci-lint/v2/internal/x/tools/driverutil/readfile.go
@@ -0,0 +1,43 @@
+// Copyright 2020 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package driverutil
+
+// This file defines helpers for implementing [analysis.Pass.ReadFile].
+
+import (
+ "fmt"
+ "slices"
+
+ "golang.org/x/tools/go/analysis"
+)
+
+// A ReadFileFunc is a function that returns the
+// contents of a file, such as [os.ReadFile].
+type ReadFileFunc = func(filename string) ([]byte, error)
+
+// CheckedReadFile returns a wrapper around a Pass.ReadFile
+// function that performs the appropriate checks.
+func CheckedReadFile(pass *analysis.Pass, readFile ReadFileFunc) ReadFileFunc {
+ return func(filename string) ([]byte, error) {
+ if err := CheckReadable(pass, filename); err != nil {
+ return nil, err
+ }
+ return readFile(filename)
+ }
+}
+
+// CheckReadable enforces the access policy defined by the ReadFile field of [analysis.Pass].
+func CheckReadable(pass *analysis.Pass, filename string) error {
+ if slices.Contains(pass.OtherFiles, filename) ||
+ slices.Contains(pass.IgnoredFiles, filename) {
+ return nil
+ }
+ for _, f := range pass.Files {
+ if pass.Fset.File(f.FileStart).Name() == filename {
+ return nil
+ }
+ }
+ return fmt.Errorf("Pass.ReadFile: %s is not among OtherFiles, IgnoredFiles, or names of Files", filename)
+}
diff --git a/vendor/github.com/golangci/golangci-lint/v2/internal/x/tools/driverutil/readme.md b/vendor/github.com/golangci/golangci-lint/v2/internal/x/tools/driverutil/readme.md
new file mode 100644
index 0000000000..1ee6259d36
--- /dev/null
+++ b/vendor/github.com/golangci/golangci-lint/v2/internal/x/tools/driverutil/readme.md
@@ -0,0 +1,28 @@
+# driverutil
+
+Extracted from `/internal/analysis/driverutil/` (related to `checker`).
+This is just a copy of `readfile.go` and `url.go` without any changes.
+
+Previously, it was `analysisinternal` and `analysisflags` packages.
+
+## History
+
+- https://github.com/golangci/golangci-lint/pull/6642 (no changes)
+ - sync with https://github.com/golang/tools/blob/v0.48.0/internal/analysis/driverutil/readfile.go
+
+- https://github.com/golangci/golangci-lint/pull/6434
+ - sync with https://github.com/golang/tools/blob/v0.43.0/internal/analysis/driverutil/readfile.go
+
+## analysisinternal History
+
+- https://github.com/golangci/golangci-lint/pull/6076
+ - sync with https://github.com/golang/tools/blob/v0.37.0/internal/analysisinternal/
+- https://github.com/golangci/golangci-lint/pull/5576
+ - sync with https://github.com/golang/tools/blob/v0.28.0/internal/analysisinternal/
+
+## analysisflags History
+
+- https://github.com/golangci/golangci-lint/pull/6076
+ - sync with https://github.com/golang/tools/blob/v0.37.0/go/analysis/internal/analysisflags
+- https://github.com/golangci/golangci-lint/pull/5576
+ - sync with https://github.com/golang/tools/blob/v0.28.0/go/analysis/internal/analysisflags
diff --git a/vendor/github.com/golangci/golangci-lint/v2/internal/x/tools/driverutil/url.go b/vendor/github.com/golangci/golangci-lint/v2/internal/x/tools/driverutil/url.go
new file mode 100644
index 0000000000..93b3ecfd49
--- /dev/null
+++ b/vendor/github.com/golangci/golangci-lint/v2/internal/x/tools/driverutil/url.go
@@ -0,0 +1,33 @@
+// Copyright 2023 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package driverutil
+
+import (
+ "fmt"
+ "net/url"
+
+ "golang.org/x/tools/go/analysis"
+)
+
+// ResolveURL resolves the URL field for a Diagnostic from an Analyzer
+// and returns the URL. See Diagnostic.URL for details.
+func ResolveURL(a *analysis.Analyzer, d analysis.Diagnostic) (string, error) {
+ if d.URL == "" && d.Category == "" && a.URL == "" {
+ return "", nil // do nothing
+ }
+ raw := d.URL
+ if d.URL == "" && d.Category != "" {
+ raw = "#" + d.Category
+ }
+ u, err := url.Parse(raw)
+ if err != nil {
+ return "", fmt.Errorf("invalid Diagnostic.URL %q: %s", raw, err)
+ }
+ base, err := url.Parse(a.URL)
+ if err != nil {
+ return "", fmt.Errorf("invalid Analyzer.URL %q: %s", a.URL, err)
+ }
+ return base.ResolveReference(u).String(), nil
+}
diff --git a/vendor/github.com/golangci/golangci-lint/v2/jsonschema/custom-gcl.jsonschema.json b/vendor/github.com/golangci/golangci-lint/v2/jsonschema/custom-gcl.jsonschema.json
new file mode 100644
index 0000000000..71ea3e98df
--- /dev/null
+++ b/vendor/github.com/golangci/golangci-lint/v2/jsonschema/custom-gcl.jsonschema.json
@@ -0,0 +1,76 @@
+{
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "$ref": "#/$defs/Configuration",
+ "$defs": {
+ "Configuration": {
+ "properties": {
+ "version": {
+ "type": "string",
+ "description": "golangci-lint version."
+ },
+ "name": {
+ "type": "string",
+ "description": "Name of the binary."
+ },
+ "destination": {
+ "type": "string",
+ "description": "Destination is the path to a directory to store the binary."
+ },
+ "plugins": {
+ "items": {
+ "$ref": "#/$defs/Plugin"
+ },
+ "type": "array",
+ "description": "Plugins information."
+ }
+ },
+ "additionalProperties": false,
+ "type": "object",
+ "required": [
+ "version"
+ ],
+ "description": "Configuration represents the configuration file."
+ },
+ "Plugin": {
+ "oneOf": [
+ {
+ "required": [
+ "version"
+ ],
+ "title": "version"
+ },
+ {
+ "required": [
+ "path"
+ ],
+ "title": "path"
+ }
+ ],
+ "properties": {
+ "module": {
+ "type": "string",
+ "description": "Module name."
+ },
+ "import": {
+ "type": "string",
+ "description": "Import to use."
+ },
+ "version": {
+ "type": "string",
+ "description": "Version of the module.\nOnly for module available through a Go proxy."
+ },
+ "path": {
+ "type": "string",
+ "description": "Path to the local module.\nOnly for local module."
+ }
+ },
+ "additionalProperties": false,
+ "type": "object",
+ "required": [
+ "module"
+ ],
+ "description": "Plugin represents information about a plugin."
+ }
+ },
+ "description": "mygcl configuration definition file"
+}
\ No newline at end of file
diff --git a/vendor/github.com/golangci/golangci-lint/v2/jsonschema/golangci.jsonschema.json b/vendor/github.com/golangci/golangci-lint/v2/jsonschema/golangci.jsonschema.json
new file mode 100644
index 0000000000..249a94645e
--- /dev/null
+++ b/vendor/github.com/golangci/golangci-lint/v2/jsonschema/golangci.jsonschema.json
@@ -0,0 +1,5604 @@
+{
+ "$schema": "http://json-schema.org/draft-07/schema#",
+ "$id": "https://json.schemastore.org/golangci-lint.json",
+ "definitions": {
+ "gocritic-checks": {
+ "enum": [
+ "appendAssign",
+ "appendCombine",
+ "argOrder",
+ "assignOp",
+ "badCall",
+ "badCond",
+ "badLock",
+ "badRegexp",
+ "badSorting",
+ "badSyncOnceFunc",
+ "boolExprSimplify",
+ "builtinShadow",
+ "builtinShadowDecl",
+ "captLocal",
+ "caseOrder",
+ "codegenComment",
+ "commentFormatting",
+ "commentedOutCode",
+ "commentedOutImport",
+ "defaultCaseOrder",
+ "deferInLoop",
+ "deferUnlambda",
+ "deprecatedComment",
+ "docStub",
+ "dupArg",
+ "dupBranchBody",
+ "dupCase",
+ "dupImport",
+ "dupOption",
+ "dupSubExpr",
+ "dynamicFmtString",
+ "elseif",
+ "emptyDecl",
+ "emptyFallthrough",
+ "emptyStringTest",
+ "equalFold",
+ "evalOrder",
+ "exitAfterDefer",
+ "exposedSyncMutex",
+ "externalErrorReassign",
+ "filepathJoin",
+ "flagDeref",
+ "flagName",
+ "hexLiteral",
+ "httpNoBody",
+ "hugeParam",
+ "ifElseChain",
+ "importShadow",
+ "indexAlloc",
+ "initClause",
+ "mapKey",
+ "methodExprCall",
+ "nestingReduce",
+ "newDeref",
+ "nilValReturn",
+ "octalLiteral",
+ "offBy1",
+ "paramTypeCombine",
+ "preferDecodeRune",
+ "preferFilepathJoin",
+ "preferFprint",
+ "preferStringWriter",
+ "preferWriteByte",
+ "ptrToRefParam",
+ "rangeAppendAll",
+ "rangeExprCopy",
+ "rangeValCopy",
+ "redundantSprint",
+ "regexpMust",
+ "regexpPattern",
+ "regexpSimplify",
+ "returnAfterHttpError",
+ "ruleguard",
+ "singleCaseSwitch",
+ "sliceClear",
+ "sloppyLen",
+ "sloppyReassign",
+ "sloppyTypeAssert",
+ "sortSlice",
+ "sprintfQuotedString",
+ "sqlQuery",
+ "stringConcatSimplify",
+ "stringXbytes",
+ "stringsCompare",
+ "switchTrue",
+ "syncMapLoadAndDelete",
+ "timeExprSimplify",
+ "todoCommentWithoutDetail",
+ "tooManyResultsChecker",
+ "truncateCmp",
+ "typeAssertChain",
+ "typeDefFirst",
+ "typeSwitchVar",
+ "typeUnparen",
+ "uncheckedInlineErr",
+ "underef",
+ "unlabelStmt",
+ "unlambda",
+ "unnamedResult",
+ "unnecessaryBlock",
+ "unnecessaryDefer",
+ "unslice",
+ "valSwap",
+ "weakCond",
+ "whyNoLint",
+ "wrapperFunc",
+ "yodaStyleExpr",
+ "zeroByteRepeat"
+ ]
+ },
+ "gocritic-tags": {
+ "enum": [
+ "diagnostic",
+ "style",
+ "performance",
+ "experimental",
+ "opinionated",
+ "security"
+ ]
+ },
+ "staticcheck-checks": {
+ "enum": [
+ "*",
+ "all",
+ "SA*",
+ "-SA*",
+ "SA1*",
+ "-SA1*",
+ "SA1000",
+ "-SA1000",
+ "SA1001",
+ "-SA1001",
+ "SA1002",
+ "-SA1002",
+ "SA1003",
+ "-SA1003",
+ "SA1004",
+ "-SA1004",
+ "SA1005",
+ "-SA1005",
+ "SA1006",
+ "-SA1006",
+ "SA1007",
+ "-SA1007",
+ "SA1008",
+ "-SA1008",
+ "SA1010",
+ "-SA1010",
+ "SA1011",
+ "-SA1011",
+ "SA1012",
+ "-SA1012",
+ "SA1013",
+ "-SA1013",
+ "SA1014",
+ "-SA1014",
+ "SA1015",
+ "-SA1015",
+ "SA1016",
+ "-SA1016",
+ "SA1017",
+ "-SA1017",
+ "SA1018",
+ "-SA1018",
+ "SA1019",
+ "-SA1019",
+ "SA1020",
+ "-SA1020",
+ "SA1021",
+ "-SA1021",
+ "SA1023",
+ "-SA1023",
+ "SA1024",
+ "-SA1024",
+ "SA1025",
+ "-SA1025",
+ "SA1026",
+ "-SA1026",
+ "SA1027",
+ "-SA1027",
+ "SA1028",
+ "-SA1028",
+ "SA1029",
+ "-SA1029",
+ "SA1030",
+ "-SA1030",
+ "SA1031",
+ "-SA1031",
+ "SA1032",
+ "-SA1032",
+ "SA2*",
+ "-SA2*",
+ "SA2000",
+ "-SA2000",
+ "SA2001",
+ "-SA2001",
+ "SA2002",
+ "-SA2002",
+ "SA2003",
+ "-SA2003",
+ "SA3*",
+ "-SA3*",
+ "SA3000",
+ "-SA3000",
+ "SA3001",
+ "-SA3001",
+ "SA4*",
+ "-SA4*",
+ "SA4000",
+ "-SA4000",
+ "SA4001",
+ "-SA4001",
+ "SA4003",
+ "-SA4003",
+ "SA4004",
+ "-SA4004",
+ "SA4005",
+ "-SA4005",
+ "SA4006",
+ "-SA4006",
+ "SA4008",
+ "-SA4008",
+ "SA4009",
+ "-SA4009",
+ "SA4010",
+ "-SA4010",
+ "SA4011",
+ "-SA4011",
+ "SA4012",
+ "-SA4012",
+ "SA4013",
+ "-SA4013",
+ "SA4014",
+ "-SA4014",
+ "SA4015",
+ "-SA4015",
+ "SA4016",
+ "-SA4016",
+ "SA4017",
+ "-SA4017",
+ "SA4018",
+ "-SA4018",
+ "SA4019",
+ "-SA4019",
+ "SA4020",
+ "-SA4020",
+ "SA4021",
+ "-SA4021",
+ "SA4022",
+ "-SA4022",
+ "SA4023",
+ "-SA4023",
+ "SA4024",
+ "-SA4024",
+ "SA4025",
+ "-SA4025",
+ "SA4026",
+ "-SA4026",
+ "SA4027",
+ "-SA4027",
+ "SA4028",
+ "-SA4028",
+ "SA4029",
+ "-SA4029",
+ "SA4030",
+ "-SA4030",
+ "SA4031",
+ "-SA4031",
+ "SA4032",
+ "-SA4032",
+ "SA5*",
+ "-SA5*",
+ "SA5000",
+ "-SA5000",
+ "SA5001",
+ "-SA5001",
+ "SA5002",
+ "-SA5002",
+ "SA5003",
+ "-SA5003",
+ "SA5004",
+ "-SA5004",
+ "SA5005",
+ "-SA5005",
+ "SA5007",
+ "-SA5007",
+ "SA5008",
+ "-SA5008",
+ "SA5009",
+ "-SA5009",
+ "SA5010",
+ "-SA5010",
+ "SA5011",
+ "-SA5011",
+ "SA5012",
+ "-SA5012",
+ "SA6*",
+ "-SA6*",
+ "SA6000",
+ "-SA6000",
+ "SA6001",
+ "-SA6001",
+ "SA6002",
+ "-SA6002",
+ "SA6003",
+ "-SA6003",
+ "SA6005",
+ "-SA6005",
+ "SA6006",
+ "-SA6006",
+ "SA9*",
+ "-SA9*",
+ "SA9001",
+ "-SA9001",
+ "SA9002",
+ "-SA9002",
+ "SA9003",
+ "-SA9003",
+ "SA9004",
+ "-SA9004",
+ "SA9005",
+ "-SA9005",
+ "SA9006",
+ "-SA9006",
+ "SA9007",
+ "-SA9007",
+ "SA9008",
+ "-SA9008",
+ "SA9009",
+ "-SA9009",
+ "ST*",
+ "-ST*",
+ "ST1*",
+ "-ST1*",
+ "ST1000",
+ "-ST1000",
+ "ST1001",
+ "-ST1001",
+ "ST1003",
+ "-ST1003",
+ "ST1005",
+ "-ST1005",
+ "ST1006",
+ "-ST1006",
+ "ST1008",
+ "-ST1008",
+ "ST1011",
+ "-ST1011",
+ "ST1012",
+ "-ST1012",
+ "ST1013",
+ "-ST1013",
+ "ST1015",
+ "-ST1015",
+ "ST1016",
+ "-ST1016",
+ "ST1017",
+ "-ST1017",
+ "ST1018",
+ "-ST1018",
+ "ST1019",
+ "-ST1019",
+ "ST1020",
+ "-ST1020",
+ "ST1021",
+ "-ST1021",
+ "ST1022",
+ "-ST1022",
+ "ST1023",
+ "-ST1023",
+ "S*",
+ "-S*",
+ "S1*",
+ "-S1*",
+ "S1000",
+ "-S1000",
+ "S1001",
+ "-S1001",
+ "S1002",
+ "-S1002",
+ "S1003",
+ "-S1003",
+ "S1004",
+ "-S1004",
+ "S1005",
+ "-S1005",
+ "S1006",
+ "-S1006",
+ "S1007",
+ "-S1007",
+ "S1008",
+ "-S1008",
+ "S1009",
+ "-S1009",
+ "S1010",
+ "-S1010",
+ "S1011",
+ "-S1011",
+ "S1012",
+ "-S1012",
+ "S1016",
+ "-S1016",
+ "S1017",
+ "-S1017",
+ "S1018",
+ "-S1018",
+ "S1019",
+ "-S1019",
+ "S1020",
+ "-S1020",
+ "S1021",
+ "-S1021",
+ "S1023",
+ "-S1023",
+ "S1024",
+ "-S1024",
+ "S1025",
+ "-S1025",
+ "S1028",
+ "-S1028",
+ "S1029",
+ "-S1029",
+ "S1030",
+ "-S1030",
+ "S1031",
+ "-S1031",
+ "S1032",
+ "-S1032",
+ "S1033",
+ "-S1033",
+ "S1034",
+ "-S1034",
+ "S1035",
+ "-S1035",
+ "S1036",
+ "-S1036",
+ "S1037",
+ "-S1037",
+ "S1038",
+ "-S1038",
+ "S1039",
+ "-S1039",
+ "S1040",
+ "-S1040",
+ "QF*",
+ "-QF*",
+ "QF1*",
+ "-QF1*",
+ "QF1001",
+ "-QF1001",
+ "QF1002",
+ "-QF1002",
+ "QF1003",
+ "-QF1003",
+ "QF1004",
+ "-QF1004",
+ "QF1005",
+ "-QF1005",
+ "QF1006",
+ "-QF1006",
+ "QF1007",
+ "-QF1007",
+ "QF1008",
+ "-QF1008",
+ "QF1009",
+ "-QF1009",
+ "QF1010",
+ "-QF1010",
+ "QF1011",
+ "-QF1011",
+ "QF1012",
+ "-QF1012"
+ ]
+ },
+ "godoclint-rules": {
+ "enum": [
+ "pkg-doc",
+ "single-pkg-doc",
+ "require-pkg-doc",
+ "start-with-name",
+ "require-doc",
+ "deprecated",
+ "max-len",
+ "no-unused-link",
+ "require-stdlib-doclink"
+ ]
+ },
+ "gosec-rules": {
+ "enum": [
+ "G101",
+ "G102",
+ "G103",
+ "G104",
+ "G106",
+ "G107",
+ "G108",
+ "G109",
+ "G110",
+ "G111",
+ "G112",
+ "G113",
+ "G114",
+ "G115",
+ "G116",
+ "G117",
+ "G118",
+ "G119",
+ "G120",
+ "G121",
+ "G122",
+ "G123",
+ "G124",
+ "G201",
+ "G202",
+ "G203",
+ "G204",
+ "G301",
+ "G302",
+ "G303",
+ "G304",
+ "G305",
+ "G306",
+ "G307",
+ "G401",
+ "G402",
+ "G403",
+ "G404",
+ "G405",
+ "G406",
+ "G407",
+ "G408",
+ "G501",
+ "G502",
+ "G503",
+ "G504",
+ "G505",
+ "G506",
+ "G507",
+ "G601",
+ "G602",
+ "G701",
+ "G702",
+ "G703",
+ "G704",
+ "G705",
+ "G706",
+ "G707",
+ "G708",
+ "G709",
+ "G710"
+ ]
+ },
+ "govet-analyzers": {
+ "enum": [
+ "appends",
+ "asmdecl",
+ "assign",
+ "atomic",
+ "atomicalign",
+ "bools",
+ "buildtag",
+ "cgocall",
+ "composites",
+ "copylocks",
+ "deepequalerrors",
+ "defers",
+ "directive",
+ "errorsas",
+ "fieldalignment",
+ "findcall",
+ "framepointer",
+ "hostport",
+ "httpmux",
+ "httpresponse",
+ "ifaceassert",
+ "inline",
+ "loopclosure",
+ "lostcancel",
+ "nilfunc",
+ "nilness",
+ "printf",
+ "reflectvaluecompare",
+ "shadow",
+ "shift",
+ "sigchanyzer",
+ "slog",
+ "sortslice",
+ "stdmethods",
+ "stdversion",
+ "stringintconv",
+ "structtag",
+ "testinggoroutine",
+ "tests",
+ "timeformat",
+ "unmarshal",
+ "unreachable",
+ "unsafeptr",
+ "unusedresult",
+ "unusedwrite",
+ "waitgroup"
+ ]
+ },
+ "revive-rules": {
+ "enum": [
+ "add-constant",
+ "argument-limit",
+ "atomic",
+ "banned-characters",
+ "bare-return",
+ "blank-imports",
+ "bool-literal-in-expr",
+ "call-to-gc",
+ "cognitive-complexity",
+ "comment-spacings",
+ "comments-density",
+ "confusing-naming",
+ "confusing-results",
+ "constant-logical-expr",
+ "context-as-argument",
+ "context-keys-type",
+ "cyclomatic",
+ "datarace",
+ "deep-exit",
+ "defer",
+ "dot-imports",
+ "duplicated-imports",
+ "early-return",
+ "empty-block",
+ "empty-lines",
+ "enforce-map-style",
+ "enforce-repeated-arg-type-style",
+ "enforce-slice-style",
+ "enforce-switch-style",
+ "epoch-naming",
+ "error-naming",
+ "error-return",
+ "error-strings",
+ "errorf",
+ "exported",
+ "file-header",
+ "file-length-limit",
+ "filename-format",
+ "flag-parameter",
+ "forbidden-call-in-wg-go",
+ "function-length",
+ "function-result-limit",
+ "get-return",
+ "identical-branches",
+ "identical-ifelseif-branches",
+ "identical-ifelseif-conditions",
+ "identical-switch-branches",
+ "identical-switch-conditions",
+ "if-return",
+ "import-alias-naming",
+ "import-shadowing",
+ "imports-blocklist",
+ "increment-decrement",
+ "indent-error-flow",
+ "inefficient-map-lookup",
+ "line-length-limit",
+ "marshal-receiver",
+ "max-control-nesting",
+ "max-public-structs",
+ "modifies-parameter",
+ "modifies-value-receiver",
+ "multiline-if-init",
+ "nested-structs",
+ "optimize-operands-order",
+ "package-comments",
+ "package-directory-mismatch",
+ "package-naming",
+ "range",
+ "range-val-address",
+ "range-val-in-closure",
+ "receiver-naming",
+ "redefines-builtin-id",
+ "redundant-build-tag",
+ "redundant-import-alias",
+ "redundant-test-main-exit",
+ "string-format",
+ "string-of-int",
+ "struct-tag",
+ "superfluous-else",
+ "time-date",
+ "time-equal",
+ "time-naming",
+ "unchecked-type-assertion",
+ "unconditional-recursion",
+ "unexported-naming",
+ "unexported-return",
+ "unhandled-error",
+ "unnecessary-format",
+ "unnecessary-if",
+ "unnecessary-stmt",
+ "unreachable-code",
+ "unsecure-url-scheme",
+ "unused-parameter",
+ "unused-receiver",
+ "use-any",
+ "use-errors-new",
+ "use-fmt-print",
+ "use-slices-concat",
+ "use-slices-sort",
+ "use-waitgroup-go",
+ "useless-break",
+ "useless-fallthrough",
+ "var-declaration",
+ "var-naming",
+ "waitgroup-by-value"
+ ]
+ },
+ "iface-analyzers": {
+ "enum": [
+ "identical",
+ "unused",
+ "opaque",
+ "unexported",
+ "unusedmethod"
+ ]
+ },
+ "tagliatelle-cases": {
+ "enum": [
+ "",
+ "camel",
+ "pascal",
+ "kebab",
+ "snake",
+ "goCamel",
+ "goPascal",
+ "goKebab",
+ "goSnake",
+ "upper",
+ "upperSnake",
+ "lower",
+ "header"
+ ]
+ },
+ "modernize-analyzers": {
+ "enum": [
+ "any",
+ "atomictypes",
+ "embedlit",
+ "errorsastype",
+ "forvar",
+ "importcomment",
+ "mapsloop",
+ "minmax",
+ "newexpr",
+ "omitzero",
+ "plusbuild",
+ "rangeint",
+ "reflecttypeassert",
+ "reflecttypefor",
+ "slicesbackward",
+ "slicesclip",
+ "slicescontains",
+ "slicessort",
+ "stditerators",
+ "stringscut",
+ "stringscutprefix",
+ "stringsseq",
+ "stringsbuilder",
+ "testingcontext",
+ "unsafefuncs",
+ "waitgroupgo"
+ ]
+ },
+ "wsl-checks": {
+ "enum": [
+ "after-block",
+ "after-decl",
+ "after-defer",
+ "after-expr",
+ "after-go",
+ "append",
+ "assign-exclusive",
+ "assign-expr",
+ "assign",
+ "branch",
+ "cuddle-group",
+ "decl",
+ "defer",
+ "err",
+ "expr",
+ "for",
+ "go",
+ "if",
+ "inc-dec",
+ "label",
+ "leading-whitespace",
+ "range",
+ "return",
+ "select",
+ "send",
+ "switch",
+ "trailing-whitespace",
+ "type-switch"
+ ]
+ },
+ "relative-path-modes": {
+ "enum": [
+ "gomod",
+ "gitroot",
+ "cfg",
+ "wd"
+ ]
+ },
+ "simple-format": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "path": {
+ "$ref": "#/definitions/formats-path",
+ "default": "stdout"
+ }
+ }
+ },
+ "formats-path" : {
+ "anyOf": [
+ {
+ "enum": [
+ "stdout",
+ "stderr"
+ ]
+ },
+ {
+ "type": "string"
+ }
+ ]
+ },
+ "linter-names": {
+ "$comment": "anyOf with enum is used to allow auto-completion of non-custom linters",
+ "description": "Usable linter names.",
+ "anyOf": [
+ {
+ "enum": [
+ "arangolint",
+ "asasalint",
+ "asciicheck",
+ "bidichk",
+ "bodyclose",
+ "canonicalheader",
+ "clickhouselint",
+ "containedctx",
+ "contextcheck",
+ "copyloopvar",
+ "cyclop",
+ "decorder",
+ "depguard",
+ "dogsled",
+ "dupl",
+ "dupword",
+ "durationcheck",
+ "embeddedstructfieldcheck",
+ "errcheck",
+ "errchkjson",
+ "errname",
+ "errorlint",
+ "exhaustive",
+ "exhaustruct",
+ "exhaustruct_v5",
+ "exptostd",
+ "fatcontext",
+ "forbidigo",
+ "forcetypeassert",
+ "funcorder",
+ "funlen",
+ "ginkgolinter",
+ "gocheckcompilerdirectives",
+ "gochecknoglobals",
+ "gochecknoinits",
+ "gochecksumtype",
+ "gocognit",
+ "goconst",
+ "gocritic",
+ "gocyclo",
+ "godoclint",
+ "godot",
+ "godox",
+ "err113",
+ "goheader",
+ "gomoddirectives",
+ "gomodguard",
+ "gomodguard_v2",
+ "goprintffuncname",
+ "gosec",
+ "gosimple",
+ "gosmopolitan",
+ "govet",
+ "grouper",
+ "iface",
+ "importas",
+ "inamedparam",
+ "ineffassign",
+ "interfacebloat",
+ "intrange",
+ "iotamixing",
+ "ireturn",
+ "lll",
+ "loggercheck",
+ "maintidx",
+ "makezero",
+ "mirror",
+ "misspell",
+ "mnd",
+ "modernize",
+ "musttag",
+ "nakedret",
+ "nestif",
+ "nilerr",
+ "nilnesserr",
+ "nilnil",
+ "nlreturn",
+ "noctx",
+ "noinlineerr",
+ "nolintlint",
+ "nonamedreturns",
+ "nosprintfhostport",
+ "paralleltest",
+ "perfsprint",
+ "prealloc",
+ "predeclared",
+ "promlinter",
+ "protogetter",
+ "reassign",
+ "recvcheck",
+ "revive",
+ "rowserrcheck",
+ "sloglint",
+ "sqlclosecheck",
+ "staticcheck",
+ "stylecheck",
+ "tagalign",
+ "tagliatelle",
+ "testableexamples",
+ "testifylint",
+ "testpackage",
+ "thelper",
+ "tparallel",
+ "unconvert",
+ "unparam",
+ "unused",
+ "usestdlibvars",
+ "usetesting",
+ "varnamelen",
+ "wastedassign",
+ "whitespace",
+ "wrapcheck",
+ "wsl",
+ "wsl_v5",
+ "zerologlint"
+ ]
+ },
+ {
+ "type": "string"
+ }
+ ]
+ },
+ "formatter-names": {
+ "description": "Usable formatter names.",
+ "enum": [
+ "gci",
+ "gofmt",
+ "gofumpt",
+ "goimports",
+ "golines",
+ "swaggo"
+ ]
+ },
+ "settings": {
+ "definitions": {
+ "dupwordSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "keywords": {
+ "description": "Keywords for detecting duplicate words. If this list is not empty, only the words defined in this list will be detected.",
+ "type": "array",
+ "uniqueItems": true,
+ "items": {
+ "type": "string",
+ "examples": ["the", "and", "a"]
+ }
+ },
+ "ignore": {
+ "description": "Keywords used to ignore detection.",
+ "type": "array",
+ "uniqueItems": true,
+ "items": {
+ "type": "string",
+ "examples": ["0C0C"]
+ }
+ },
+ "comments-only": {
+ "description": "Checks only comments, skip strings.",
+ "type": "boolean",
+ "default": false
+ },
+ "skip-raw-strings": {
+ "description": "Skip raw string literals (backtick-delimited) from duplicate word checking.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "asasalintSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "exclude": {
+ "description": "To specify a set of function names to exclude.",
+ "type": "array",
+ "uniqueItems": true,
+ "items": {
+ "type": "string",
+ "examples": ["\\.Wrapf"]
+ }
+ },
+ "use-builtin-exclusions": {
+ "description": "To enable/disable the asasalint builtin exclusions of function names.",
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "bidichkSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "left-to-right-embedding": {
+ "description": "Disallow: LEFT-TO-RIGHT-EMBEDDING",
+ "type": "boolean",
+ "default": false
+ },
+ "right-to-left-embedding": {
+ "description": "Disallow: RIGHT-TO-LEFT-EMBEDDING",
+ "type": "boolean",
+ "default": false
+ },
+ "pop-directional-formatting": {
+ "description": "Disallow: POP-DIRECTIONAL-FORMATTING",
+ "type": "boolean",
+ "default": false
+ },
+ "left-to-right-override": {
+ "description": "Disallow: LEFT-TO-RIGHT-OVERRIDE",
+ "type": "boolean",
+ "default": false
+ },
+ "right-to-left-override": {
+ "description": "Disallow: RIGHT-TO-LEFT-OVERRIDE",
+ "type": "boolean",
+ "default": false
+ },
+ "left-to-right-isolate": {
+ "description": "Disallow: LEFT-TO-RIGHT-ISOLATE",
+ "type": "boolean",
+ "default": false
+ },
+ "right-to-left-isolate": {
+ "description": "Disallow: RIGHT-TO-LEFT-ISOLATE",
+ "type": "boolean",
+ "default": false
+ },
+ "first-strong-isolate": {
+ "description": "Disallow: FIRST-STRONG-ISOLATE",
+ "type": "boolean",
+ "default": false
+ },
+ "pop-directional-isolate": {
+ "description": "Disallow: POP-DIRECTIONAL-ISOLATE",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "bodycloseSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "check-consumption": {
+ "description": "Check that the response body is consumed.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "canonicalheaderSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "use-default-exclusions": {
+ "type": "boolean",
+ "default": true
+ },
+ "exclusions": {
+ "additionalProperties": false,
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "cyclopSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "max-complexity": {
+ "description": "Max complexity the function can have",
+ "type": "integer",
+ "default": 10,
+ "minimum": 0
+ },
+ "package-average": {
+ "description": "Max average complexity in package",
+ "type": "number",
+ "default": 0,
+ "minimum": 0
+ }
+ }
+ },
+ "decorderSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "dec-order": {
+ "type": "array",
+ "default": [["type", "const", "var", "func"]],
+ "items": {
+ "enum": ["type", "const", "var", "func"]
+ }
+ },
+ "ignore-underscore-vars": {
+ "description": "Underscore vars (vars with \"_\" as the name) will be ignored at all checks",
+ "default": true,
+ "type": "boolean"
+ },
+ "disable-dec-order-check": {
+ "description": "Order of declarations is not checked",
+ "default": true,
+ "type": "boolean"
+ },
+ "disable-init-func-first-check": {
+ "description": "Allow init func to be anywhere in file",
+ "default": true,
+ "type": "boolean"
+ },
+ "disable-dec-num-check": {
+ "description": "Multiple global type, const and var declarations are allowed",
+ "default": true,
+ "type": "boolean"
+ },
+ "disable-type-dec-num-check": {
+ "description": "Type declarations will be ignored for dec num check",
+ "default": true,
+ "type": "boolean"
+ },
+ "disable-const-dec-num-check": {
+ "description": "Const declarations will be ignored for dec num check",
+ "default": true,
+ "type": "boolean"
+ },
+ "disable-var-dec-num-check": {
+ "description": "Var declarations will be ignored for dec num check",
+ "default": true,
+ "type": "boolean"
+ }
+ }
+ },
+ "depguardSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "rules": {
+ "description": "Rules to apply.",
+ "type": "object",
+ "additionalProperties": false,
+ "patternProperties": {
+ "^[^.]+$": {
+ "description": "Name of a rule.",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "list-mode": {
+ "description": "Used to determine the package matching priority.",
+ "enum": ["original", "strict", "lax"],
+ "default": "original"
+ },
+ "files": {
+ "description": "List of file globs that will match this list of settings to compare against.",
+ "additionalProperties": false,
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "allow": {
+ "description": "List of allowed packages.",
+ "additionalProperties": false,
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "deny": {
+ "description": "Packages that are not allowed where the value is a suggestion.",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "desc": {
+ "description": "Description",
+ "type": "string"
+ },
+ "pkg": {
+ "description": "Package",
+ "type": "string"
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "dogsledSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "max-blank-identifiers": {
+ "description": "Check assignments with too many blank identifiers.",
+ "type": "integer",
+ "default": 2,
+ "minimum": 0
+ }
+ }
+ },
+ "duplSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "threshold": {
+ "description": "Tokens count to trigger issue.",
+ "type": "integer",
+ "default": 150,
+ "minimum": 0
+ }
+ }
+ },
+ "embeddedstructfieldcheckSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "empty-line": {
+ "description": "Checks that there is an empty space between the embedded fields and regular fields.",
+ "type": "boolean",
+ "default": false
+ },
+ "forbid-mutex": {
+ "description": "Checks that sync.Mutex and sync.RWMutex are not used as embedded fields.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "errcheckSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "check-type-assertions": {
+ "description": "Report about not checking errors in type assertions, i.e.: `a := b.(MyStruct)`",
+ "type": "boolean",
+ "default": false
+ },
+ "check-blank": {
+ "description": "Report about assignment of errors to blank identifier",
+ "type": "boolean",
+ "default": false
+ },
+ "exclude-functions": {
+ "description": "List of functions to exclude from checking, where each entry is a single function to exclude",
+ "type": "array",
+ "examples": ["io/ioutil.ReadFile", "io.Copy(*bytes.Buffer)"],
+ "items": {
+ "type": "string"
+ }
+ },
+ "disable-default-exclusions": {
+ "description": "To disable the errcheck built-in exclude list",
+ "type": "boolean",
+ "default": false
+ },
+ "verbose": {
+ "description": "Display function signature instead of selector",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "errchkjsonSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "check-error-free-encoding": {
+ "type": "boolean",
+ "default": false
+ },
+ "report-no-exported": {
+ "description": "Issue on struct that doesn't have exported fields.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "errorlintSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "errorf": {
+ "description": "Check whether fmt.Errorf uses the %w verb for formatting errors",
+ "type": "boolean",
+ "default": true
+ },
+ "errorf-multi": {
+ "description": "Permit more than 1 %w verb, valid per Go 1.20",
+ "type": "boolean",
+ "default": true
+ },
+ "asserts": {
+ "description": "Check for plain type assertions and type switches.",
+ "type": "boolean",
+ "default": true
+ },
+ "comparison": {
+ "description": "Check for plain error comparisons",
+ "type": "boolean",
+ "default": true
+ },
+ "allowed-errors": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "err": {
+ "type": "string"
+ },
+ "fun": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "allowed-errors-wildcard": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "err": {
+ "type": "string"
+ },
+ "fun": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ }
+ },
+ "exhaustiveSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "check": {
+ "description": "Program elements to check for exhaustiveness.",
+ "type": "array",
+ "uniqueItems": true,
+ "items": {
+ "type": "string",
+ "examples": ["switch", "map"]
+ }
+ },
+ "explicit-exhaustive-switch": {
+ "description": "Only run exhaustive check on switches with \"//exhaustive:enforce\" comment.",
+ "type": "boolean",
+ "default": false
+ },
+ "explicit-exhaustive-map": {
+ "description": "Only run exhaustive check on map literals with \"//exhaustive:enforce\" comment.",
+ "type": "boolean",
+ "default": false
+ },
+ "default-case-required": {
+ "description": "Switch statement requires default case even if exhaustive.",
+ "type": "boolean",
+ "default": false
+ },
+ "default-signifies-exhaustive": {
+ "description": "Presence of `default` case in switch statements satisfies exhaustiveness, even if all enum members are not listed.",
+ "type": "boolean",
+ "default": false
+ },
+ "ignore-enum-members": {
+ "description": "Enum members matching `regex` do not have to be listed in switch statements to satisfy exhaustiveness",
+ "type": "string"
+ },
+ "ignore-enum-types": {
+ "description": "Enum types matching the supplied regex do not have to be listed in switch statements to satisfy exhaustiveness.",
+ "type": "string"
+ },
+ "package-scope-only": {
+ "description": "Consider enums only in package scopes, not in inner scopes.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "exhaustructSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "include": {
+ "description": "List of regular expressions to match struct packages and names.",
+ "type": "array",
+ "examples": [".*\\.Test"],
+ "items": {
+ "type": "string"
+ }
+ },
+ "exclude": {
+ "description": "List of regular expressions to exclude struct packages and names from check.",
+ "type": "array",
+ "examples": ["cobra\\.Command$"],
+ "items": {
+ "type": "string"
+ }
+ },
+ "allow-empty": {
+ "description": "Allows empty structures, effectively excluding them from the check.",
+ "type": "boolean",
+ "default": false
+ },
+ "allow-empty-rx": {
+ "description": "List of regular expressions to match type names that should be allowed to be empty.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "allow-empty-returns": {
+ "description": "Allows empty structures in return statements.",
+ "type": "boolean",
+ "default": false
+ },
+ "allow-empty-declarations": {
+ "description": "Allows empty structures in variable declarations.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "exhaustructv5Settings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "enforce-patterns": {
+ "description": "List of regular expressions to match type names that should be checked.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ignore-patterns":{
+ "description": "List of regular expressions to match type names that should be skipped from checking.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "optional-patterns": {
+ "description": "List of regular expressions to match type names where all fields are treated as optional.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "allow-empty":{
+ "description": "Allows empty structures, effectively excluding them from the check.",
+ "type": "boolean",
+ "default": false
+ },
+ "allow-empty-patterns": {
+ "description": "List of regular expressions to match type names that should be allowed to be empty.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "allow-empty-returns": {
+ "description": "Allows empty structures in return statements.",
+ "type": "boolean",
+ "default": false
+ },
+ "allow-empty-declarations": {
+ "description": "Allows empty structures in variable declarations.",
+ "type": "boolean",
+ "default": false
+ },
+ "allow-empty-blank-assignments": {
+ "description": "Allow empty literals the blank identifier receives.",
+ "type": "boolean",
+ "default": false
+ },
+ "explicit-mode":{
+ "description": "When true, only types marked with //exhaustruct:enforce directive or matching enforce-rx patterns are checked.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "fatcontextSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "check-struct-pointers": {
+ "description": "Check for potential fat contexts in struct pointers.",
+ "type": "boolean",
+ "default": false
+ },
+ "check-loops": {
+ "description": "Disable detection of fat contexts in function literals.",
+ "type": "boolean",
+ "default": true
+ },
+ "check-function-literals": {
+ "description": "Disable detection of fat contexts in function literals.",
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "forbidigoSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "exclude-godoc-examples": {
+ "description": "Exclude code in godoc examples.",
+ "type": "boolean",
+ "default": true
+ },
+ "analyze-types": {
+ "description": "Instead of matching the literal source code, use type information to replace expressions with strings that contain the package name and (for methods and fields) the type name.",
+ "type": "boolean",
+ "default": true
+ },
+ "forbid": {
+ "description": "List of identifiers to forbid (written using `regexp`)",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "pattern": {
+ "description": "Pattern",
+ "type": "string"
+ },
+ "pkg": {
+ "description": "Package",
+ "type": "string"
+ },
+ "msg": {
+ "description": "Message",
+ "type": "string"
+ }
+ }
+ }
+ }
+ }
+ },
+ "funcorderSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "constructor": {
+ "description": "Checks that constructors are placed after the structure declaration.",
+ "type": "boolean",
+ "default": true
+ },
+ "struct-method": {
+ "description": "Checks if the exported methods of a structure are placed before the non-exported ones.",
+ "type": "boolean",
+ "default": true
+ },
+ "alphabetical": {
+ "description": "Checks if the constructors and/or structure methods are sorted alphabetically.",
+ "type": "boolean",
+ "default": false
+ },
+ "function": {
+ "description": "Checks that exported functions are placed before unexported functions.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "funlenSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "lines": {
+ "description": "Limit lines number per function.",
+ "type": "integer",
+ "default": 60
+ },
+ "statements": {
+ "description": "Limit statements number per function.",
+ "type": "integer",
+ "default": 40
+ },
+ "ignore-comments": {
+ "description": "Ignore comments when counting lines.",
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "gciSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "sections": {
+ "description": "Section configuration to compare against.",
+ "type": "array",
+ "items": {
+ "anyOf": [
+ {
+ "enum": [
+ "standard",
+ "default",
+ "blank",
+ "dot",
+ "alias",
+ "localmodule"
+ ]
+ },
+ {
+ "type": "string"
+ }
+ ]
+ },
+ "default": ["standard", "default"]
+ },
+ "no-inline-comments": {
+ "description": "Checks that no inline Comments are present.",
+ "type": "boolean",
+ "default": false
+ },
+ "no-prefix-comments": {
+ "description": "Checks that no prefix Comments(comment lines above an import) are present.",
+ "type": "boolean",
+ "default": false
+ },
+ "custom-order": {
+ "description": "Enable custom order of sections.",
+ "type": "boolean",
+ "default": false
+ },
+ "no-lex-order": {
+ "description": "Drops lexical ordering for custom sections.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "ginkgolinterSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "suppress-len-assertion": {
+ "description": "Suppress the wrong length assertion warning.",
+ "type": "boolean",
+ "default": false
+ },
+ "suppress-nil-assertion": {
+ "description": "Suppress the wrong nil assertion warning.",
+ "type": "boolean",
+ "default": false
+ },
+ "suppress-err-assertion": {
+ "description": "Suppress the wrong error assertion warning.",
+ "type": "boolean",
+ "default": false
+ },
+ "suppress-compare-assertion": {
+ "description": "Suppress the wrong comparison assertion warning.",
+ "type": "boolean",
+ "default": false
+ },
+ "suppress-async-assertion": {
+ "description": "Suppress the function all in async assertion warning.",
+ "type": "boolean",
+ "default": false
+ },
+ "suppress-type-compare-assertion": {
+ "description": "Suppress warning for comparing values from different types, like int32 and uint32.",
+ "type": "boolean",
+ "default": false
+ },
+ "forbid-focus-container": {
+ "description": "Trigger warning for ginkgo focus containers like FDescribe, FContext, FWhen or FIt.",
+ "type": "boolean",
+ "default": false
+ },
+ "allow-havelen-zero": {
+ "description": "Don't trigger warnings for HaveLen(0).",
+ "type": "boolean",
+ "default": false
+ },
+ "force-expect-to": {
+ "description": "Force using `Expect` with `To`, `ToNot` or `NotTo`",
+ "type": "boolean",
+ "default": false
+ },
+ "validate-async-intervals": {
+ "description": "Best effort validation of async intervals (timeout and polling).",
+ "type": "boolean",
+ "default": false
+ },
+ "forbid-spec-pollution": {
+ "description": "Trigger a warning for variable assignments in ginkgo containers like `Describe`, `Context` and `When`, instead of in `BeforeEach()`.",
+ "type": "boolean",
+ "default": false
+ },
+ "force-succeed": {
+ "description": "Force using the Succeed matcher for error functions, and the HaveOccurred matcher for non-function error values.",
+ "type": "boolean",
+ "default": false
+ },
+ "force-assertion-description": {
+ "description": "Force adding assertion descriptions to gomega matchers.",
+ "type": "boolean",
+ "default": false
+ },
+ "force-tonot": {
+ "description": "Force using `ToNot`, `ShouldNot` instead of `To(Not())`.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "gochecksumtypeSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "default-signifies-exhaustive": {
+ "description": "Presence of `default` case in switch statements satisfies exhaustiveness, if all members are not listed.",
+ "type": "boolean",
+ "default": true
+ },
+ "include-shared-interfaces": {
+ "description": "Include shared interfaces in the exhaustiviness check.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "gocognitSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "min-complexity": {
+ "description": "Minimal code complexity to report (we recommend 10-20).",
+ "type": "integer",
+ "default": 30
+ }
+ }
+ },
+ "goconstSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "match-constant": {
+ "description": "Look for existing constants matching the values",
+ "type": "boolean",
+ "default": true
+ },
+ "min-len": {
+ "description": "Minimum length of string constant.",
+ "type": "integer",
+ "default": 3
+ },
+ "min-occurrences": {
+ "description": "Minimum occurrences count to trigger.",
+ "type": "integer",
+ "default": 3
+ },
+ "exclude-types": {
+ "type": "array",
+ "items": {
+ "enum": [
+ "Assignment",
+ "Binary",
+ "Case",
+ "Return",
+ "Call",
+ "CompositeLit"
+ ]
+ }
+ },
+ "ignore-calls": {
+ "description": "Ignore when constant is not used as function argument",
+ "type": "boolean",
+ "default": true
+ },
+ "ignore-string-values": {
+ "description": "Exclude strings matching the given regular expression",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "numbers": {
+ "description": "Search also for duplicated numbers.",
+ "type": "boolean",
+ "default": false
+ },
+ "min": {
+ "description": "Minimum value, only works with `numbers`",
+ "type": "integer",
+ "default": 3
+ },
+ "max": {
+ "description": "Maximum value, only works with `numbers`",
+ "type": "integer",
+ "default": 3
+ },
+ "find-duplicates": {
+ "description": "Detects constants with identical values",
+ "type": "boolean",
+ "default": false
+ },
+ "eval-const-expressions": {
+ "description": "Evaluates of constant expressions like Prefix + \"suffix\"",
+ "type": "boolean",
+ "default": false
+ },
+ "ignore-tests": {
+ "description": "Ignore strings from test files",
+ "type": "boolean",
+ "default": false
+ },
+ "ignore-functions": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ignore-map-keys": {
+ "description": "Ignore string literals used as map keys",
+ "type": "boolean"
+ }
+ }
+ },
+ "gocriticSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "enabled-checks": {
+ "description": "Which checks should be enabled. By default, a list of stable checks is used. To see it, run `GL_DEBUG=gocritic golangci-lint run`.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/gocritic-checks"
+ }
+ },
+ "disabled-checks": {
+ "description": "Which checks should be disabled.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/gocritic-checks"
+ },
+ "default": []
+ },
+ "enabled-tags": {
+ "description": "Enable multiple checks by tags, run `GL_DEBUG=gocritic golangci-lint run` to see all tags and checks.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/gocritic-tags"
+ }
+ },
+ "disabled-tags": {
+ "description": "Disable multiple checks by tags, run `GL_DEBUG=gocritic golangci-lint run` to see all tags and checks.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/gocritic-tags"
+ }
+ },
+ "settings": {
+ "description": "Settings passed to gocritic. Properties must be valid and enabled check names.",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "captLocal": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "paramsOnly" : {
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "commentedOutCode": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "minLength" : {
+ "type": "number",
+ "default": 15
+ }
+ }
+ },
+ "elseif": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "skipBalanced" : {
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "hugeParam": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "sizeThreshold" : {
+ "type": "number",
+ "default": 80
+ }
+ }
+ },
+ "ifElseChain": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "minThreshold" : {
+ "type": "number",
+ "default": 2
+ }
+ }
+ },
+ "nestingReduce": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "bodyWidth" : {
+ "type": "number",
+ "default": 5
+ }
+ }
+ },
+ "rangeExprCopy": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "sizeThreshold" : {
+ "type": "number",
+ "default": 512
+ },
+ "skipTestFuncs" : {
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "rangeValCopy": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "sizeThreshold" : {
+ "type": "number",
+ "default": 128
+ },
+ "skipTestFuncs" : {
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "ruleguard": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "debug" : {
+ "type": "string"
+ },
+ "enable" : {
+ "type": "string"
+ },
+ "disable" : {
+ "type": "string"
+ },
+ "failOn" : {
+ "type": "string"
+ },
+ "rules" : {
+ "type": "string"
+ }
+ }
+ },
+ "tooManyResultsChecker": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "maxResults" : {
+ "type": "number",
+ "default": 5
+ }
+ }
+ },
+ "truncateCmp": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "skipArchDependent" : {
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "underef": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "skipRecvDeref" : {
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "unnamedResult": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "checkExported" : {
+ "type": "boolean",
+ "default": false
+ }
+ }
+ }
+ }
+ },
+ "disable-all": {
+ "type": "boolean",
+ "default": false
+ },
+ "enable-all": {
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "gocycloSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "min-complexity": {
+ "description": "Minimum code complexity to report (we recommend 10-20).",
+ "type": "integer",
+ "default": 30
+ }
+ }
+ },
+ "godoclintSettings": {
+ "type": "object",
+ "properties": {
+ "default": {
+ "type": "string",
+ "enum": ["all", "basic", "none"],
+ "default": "basic",
+ "description": "Default set of rules to enable."
+ },
+ "enable": {
+ "description": "List of rules to enable in addition to the default set.",
+ "type": "array",
+ "uniqueItems": true,
+ "items": {
+ "$ref": "#/definitions/godoclint-rules"
+ }
+ },
+ "disable": {
+ "description": "List of rules to disable.",
+ "type": "array",
+ "uniqueItems": true,
+ "items": {
+ "$ref": "#/definitions/godoclint-rules"
+ }
+ },
+ "options": {
+ "type": "object",
+ "description": "A map for setting individual rule options.",
+ "properties": {
+ "max-len": {
+ "type": "object",
+ "properties": {
+ "length": {
+ "type": "integer",
+ "description": "Maximum line length for godocs, not including the `//`, `/*` or `*/` tokens.",
+ "default": 77
+ }
+ }
+ },
+ "require-doc": {
+ "type": "object",
+ "properties": {
+ "ignore-exported": {
+ "type": "boolean",
+ "description": "Ignore exported (public) symbols when applying the `require-doc` rule.",
+ "default": false
+ },
+ "ignore-unexported": {
+ "type": "boolean",
+ "description": "Ignore unexported (private) symbols when applying the `require-doc` rule.",
+ "default": true
+ }
+ }
+ },
+ "start-with-name": {
+ "type": "object",
+ "properties": {
+ "include-unexported": {
+ "type": "boolean",
+ "description": "Include unexported symbols when applying the `start-with-name` rule.",
+ "default": false
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "godotSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "scope": {
+ "description": "Comments to be checked.",
+ "enum": ["declarations", "toplevel", "all", "noinline"],
+ "default": "declarations"
+ },
+ "exclude": {
+ "description": "List of regexps for excluding particular comment lines from check.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "period": {
+ "description": "Check that each sentence ends with a period.",
+ "type": "boolean",
+ "default": true
+ },
+ "capital": {
+ "description": "Check that each sentence starts with a capital letter.",
+ "type": "boolean",
+ "default": false
+ },
+ "check-all": {
+ "description": "DEPRECATED: Check all top-level comments, not only declarations.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "godoxSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "keywords": {
+ "description": "Report any comments starting with one of these keywords. This is useful for TODO or FIXME comments that might be left in the code accidentally and should be resolved before merging.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "default": ["TODO", "BUG", "FIXME"]
+ }
+ }
+ },
+ "gofmtSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "simplify": {
+ "description": "Simplify code.",
+ "type": "boolean",
+ "default": true
+ },
+ "rewrite-rules": {
+ "description": "Apply the rewrite rules to the source before reformatting.",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "pattern": {
+ "type": "string"
+ },
+ "replacement": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ }
+ },
+ "golinesSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "max-len": {
+ "type": "integer",
+ "default": 100
+ },
+ "tab-len": {
+ "type": "integer",
+ "default": 4
+ },
+ "shorten-comments": {
+ "type": "boolean",
+ "default": false
+ },
+ "reformat-tags": {
+ "type": "boolean",
+ "default": true
+ },
+ "chain-split-dots": {
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "interfacebloatSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "max": {
+ "description": "The maximum number of methods allowed for an interface.",
+ "type": "integer"
+ }
+ }
+ },
+ "gofumptSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "extra-rules": {
+ "description": "Choose whether or not to use the extra rules that are disabled by default.",
+ "type": "boolean",
+ "default": false
+ },
+ "module-path": {
+ "description": " Module path which contains the source code being formatted.",
+ "type": "string"
+ },
+ "extra": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "group-params": {
+ "type": "boolean",
+ "default": false
+ },
+ "clothe-returns": {
+ "type": "boolean",
+ "default": false
+ },
+ "balance-calls": {
+ "type": "boolean",
+ "default": false
+ }
+ }
+ }
+ }
+ },
+ "goheaderSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "values": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "const": {
+ "description": "Constants to use in the template.",
+ "type": "object",
+ "patternProperties": {
+ "^.+$": {
+ "description": "Value for the constant.",
+ "type": "string"
+ }
+ },
+ "additionalProperties": false,
+ "examples": [
+ {
+ "YEAR": "2030",
+ "COMPANY": "MY FUTURISTIC COMPANY"
+ }
+ ]
+ },
+ "regexp": {
+ "description": "Regular expressions to use in your template.",
+ "type": "object",
+ "additionalProperties": false,
+ "patternProperties": {
+ "^.+$": {
+ "type": "string"
+ }
+ },
+ "examples": [
+ {
+ "AUTHOR": ".*@mycompany\\.com"
+ }
+ ]
+ }
+ }
+ },
+ "template": {
+ "description": "Template to put on top of every file.",
+ "type": "string",
+ "examples": [
+ "{{ MY COMPANY }}\nSPDX-License-Identifier: Apache-2.0\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at:\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License."
+ ]
+ },
+ "template-path": {
+ "description": "Path to the file containing the template source.",
+ "type": "string",
+ "examples": ["my_header_template.txt"]
+ }
+ },
+ "oneOf": [
+ { "required": ["template"] },
+ { "required": ["template-path"] }
+ ]
+ },
+ "goimportsSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "local-prefixes": {
+ "description": "Put imports beginning with prefix after 3rd-party packages. It is a list of prefixes.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "gomoddirectivesSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "replace-local": {
+ "description": "Allow local `replace` directives.",
+ "type": "boolean",
+ "default": true
+ },
+ "replace-allow-list": {
+ "description": "List of allowed `replace` directives.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "replace-allow-all": {
+ "description": "Allow all `replace` directives.",
+ "type": "boolean",
+ "default": false
+ },
+ "retract-allow-no-explanation": {
+ "description": "Allow to not explain why the version has been retracted in the `retract` directives.",
+ "type": "boolean",
+ "default": false
+ },
+ "exclude-forbidden": {
+ "description": "Forbid the use of the `exclude` directives.",
+ "type": "boolean",
+ "default": false
+ },
+ "ignore-forbidden": {
+ "description": "Forbid the use of the `ignore` directives. (>= go1.25)",
+ "type": "boolean",
+ "default": false
+ },
+ "toolchain-forbidden": {
+ "description": "Forbid the use of the `toolchain` directive.",
+ "type": "boolean",
+ "default": false
+ },
+ "toolchain-pattern": {
+ "description": "Defines a pattern to validate `toolchain` directive.",
+ "type": "string"
+ },
+ "tool-forbidden": {
+ "description": "Forbid the use of the `tool` directives.",
+ "type": "boolean",
+ "default": false
+ },
+ "go-debug-forbidden": {
+ "description": "Forbid the use of the `godebug` directive.",
+ "type": "boolean",
+ "default": false
+ },
+ "go-version-pattern": {
+ "description": "Defines a pattern to validate `go` minimum version directive.",
+ "type": "string",
+ "default": ""
+ },
+ "check-module-path": {
+ "description": "Check the validity of the module path.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "gomodguardv2Settings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "local-replace-directives": {
+ "type": "boolean"
+ },
+ "allowed": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "required": ["module"],
+ "properties": {
+ "module": {
+ "type": "string"
+ },
+ "version": {
+ "type": "string"
+ },
+ "match-type": {
+ "enum": ["", "exact", "prefix", "regex"],
+ "default": "exact"
+ }
+ }
+ }
+ },
+ "blocked": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "required": ["module"],
+ "properties": {
+ "module": {
+ "type": "string"
+ },
+ "version": {
+ "type": "string"
+ },
+ "match-type": {
+ "type": "string"
+ },
+ "reason": {
+ "type": "string"
+ },
+ "recommendations": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "gomodguardSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "allowed": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "modules": {
+ "description": "List of allowed modules.",
+ "type": "array",
+ "items": {
+ "type": "string",
+ "examples": ["gopkg.in/yaml.v2"]
+ }
+ },
+ "domains": {
+ "description": "List of allowed module domains.",
+ "type": "array",
+ "items": {
+ "type": "string",
+ "examples": ["golang.org"]
+ }
+ }
+ }
+ },
+ "blocked": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "modules": {
+ "description": "List of blocked modules.",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "patternProperties": {
+ "^.+$": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "recommendations": {
+ "description": "Recommended modules that should be used instead.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "reason": {
+ "description": "Reason why the recommended module should be used.",
+ "type": "string"
+ }
+ }
+ }
+ },
+ "additionalProperties": false
+ }
+ },
+ "versions": {
+ "description": "List of blocked module version constraints.",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "patternProperties": {
+ "^.*$": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "version": {
+ "description": "Version constraint.",
+ "type": "string"
+ },
+ "reason": {
+ "description": "Reason why the version constraint exists.",
+ "type": "string"
+ }
+ },
+ "required": ["reason"]
+ }
+ }
+ }
+ },
+ "local-replace-directives": {
+ "description": "Raise lint issues if loading local path with replace directive",
+ "type": "boolean",
+ "default": true
+ }
+ }
+ }
+ }
+ },
+ "gosecSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "includes": {
+ "type": "array",
+ "description": "To select a subset of rules to run",
+ "examples": [["G401"]],
+ "items": {
+ "$ref": "#/definitions/gosec-rules"
+ }
+ },
+ "excludes": {
+ "type": "array",
+ "description": "To specify a set of rules to explicitly exclude",
+ "examples": [["G401"]],
+ "items": {
+ "$ref": "#/definitions/gosec-rules"
+ }
+ },
+ "severity": {
+ "description": "Filter out the issues with a lower severity than the given value",
+ "type": "string",
+ "enum": ["low", "medium", "high"],
+ "default": "low"
+ },
+ "confidence": {
+ "description": "Filter out the issues with a lower confidence than the given value",
+ "type": "string",
+ "enum": ["low", "medium", "high"],
+ "default": "low"
+ },
+ "config": {
+ "description": "To specify the configuration of rules",
+ "type": "object"
+ },
+ "concurrency": {
+ "description": "Concurrency value",
+ "type": "integer"
+ }
+ }
+ },
+ "gosmopolitanSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "allow-time-local": {
+ "description": "Allow and ignore `time.Local` usages.",
+ "type": "boolean",
+ "default": false
+ },
+ "escape-hatches": {
+ "description": "List of fully qualified names in the `full/pkg/path.name` form, to act as \"i18n escape hatches\".",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "watch-for-scripts": {
+ "description": "List of Unicode scripts to watch for any usage in string literals.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "govetSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "settings": {
+ "description": "Settings per analyzer. Map of analyzer name to specific settings.\nRun `go tool vet help` to find out more.",
+ "type": "object",
+ "propertyNames": {
+ "$ref": "#/definitions/govet-analyzers"
+ },
+ "patternProperties": {
+ "^.*$": {
+ "description": "Run `go tool vet help ` to see all settings.",
+ "type": "object"
+ }
+ }
+ },
+ "enable": {
+ "description": "Enable analyzers by name.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/govet-analyzers"
+ }
+ },
+ "disable": {
+ "description": "Disable analyzers by name.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/govet-analyzers"
+ }
+ },
+ "enable-all": {
+ "description": "Enable all analyzers.",
+ "type": "boolean",
+ "default": false
+ },
+ "disable-all": {
+ "description": "Disable all analyzers.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "grouperSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "const-require-single-const": {
+ "type": "boolean",
+ "default": false
+ },
+ "const-require-grouping": {
+ "type": "boolean",
+ "default": false
+ },
+ "import-require-single-import": {
+ "type": "boolean",
+ "default": false
+ },
+ "import-require-grouping": {
+ "type": "boolean",
+ "default": false
+ },
+ "type-require-single-type": {
+ "type": "boolean",
+ "default": false
+ },
+ "type-require-grouping": {
+ "type": "boolean",
+ "default": false
+ },
+ "var-require-single-var": {
+ "type": "boolean",
+ "default": false
+ },
+ "var-require-grouping": {
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "ifaceSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "enable": {
+ "description": "Enable analyzers by name.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/iface-analyzers"
+ }
+ },
+ "settings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "unused": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "exclude": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "unusedmethod": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "exclude": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "importasSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "no-unaliased": {
+ "description": "Do not allow unaliased imports of aliased packages.",
+ "type": "boolean",
+ "default": false
+ },
+ "no-extra-aliases": {
+ "description": "Do not allow non-required aliases.",
+ "type": "boolean",
+ "default": false
+ },
+ "alias": {
+ "description": "List of aliases",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "pkg": {
+ "description": "Package path e.g. knative.dev/serving/pkg/apis/autoscaling/v1alpha1",
+ "type": "string"
+ },
+ "alias": {
+ "description": "Package alias e.g. autoscalingv1alpha1",
+ "type": "string"
+ }
+ },
+ "required": ["pkg", "alias"]
+ }
+ }
+ }
+ },
+ "inamedparamSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "skip-single-param": {
+ "description": "Skips check for interface methods with only a single parameter.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "ineffassignSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "check-escaping-errors": {
+ "description": "Check escaping variables of type error, may cause false positives.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "iotamixingSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "report-individual": {
+ "description": "Whether to report individual consts rather than just the const block.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "ireturnSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "description": "Use either `reject` or `allow` properties for interfaces matching.",
+ "properties": {
+ "allow": {
+ "type": "array",
+ "items": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "enum": ["anon", "error", "empty", "stdlib"]
+ }
+ ]
+ }
+ },
+ "reject": {
+ "type": "array",
+ "items": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "enum": ["anon", "error", "empty", "stdlib"]
+ }
+ ]
+ }
+ }
+ },
+ "anyOf": [
+ {
+ "not": {
+ "properties": {
+ "allow": {
+ "const": "reject"
+ }
+ }
+ },
+ "required": ["allow"]
+ },
+ {
+ "required": ["reject"]
+ }
+ ]
+ },
+ "lllSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "tab-width": {
+ "description": "Width of \"\\t\" in spaces.",
+ "type": "integer",
+ "minimum": 0,
+ "default": 1
+ },
+ "line-length": {
+ "description": "Maximum allowed line length, lines longer will be reported.",
+ "type": "integer",
+ "minimum": 1,
+ "default": 120
+ }
+ }
+ },
+ "maintidxSettings": {
+ "description": "Maintainability index https://docs.microsoft.com/en-us/visualstudio/code-quality/code-metrics-maintainability-index-range-and-meaning?view=vs-2022",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "under": {
+ "description": "Minimum accatpable maintainability index level (see https://docs.microsoft.com/en-us/visualstudio/code-quality/code-metrics-maintainability-index-range-and-meaning?view=vs-2022)",
+ "type": "number",
+ "default": 20
+ }
+ }
+ },
+ "makezeroSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "always": {
+ "description": "Allow only slices initialized with a length of zero.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "loggercheckSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "kitlog": {
+ "description": "Allow check for the github.com/go-kit/log library.",
+ "type": "boolean",
+ "default": true
+ },
+ "klog": {
+ "description": "Allow check for the k8s.io/klog/v2 library.",
+ "type": "boolean",
+ "default": true
+ },
+ "logr": {
+ "description": "Allow check for the github.com/go-logr/logr library.",
+ "type": "boolean",
+ "default": true
+ },
+ "slog": {
+ "description": "Allow check for the log/slog library.",
+ "type": "boolean",
+ "default": true
+ },
+ "zap": {
+ "description": "Allow check for the \"sugar logger\" from go.uber.org/zap library.",
+ "type": "boolean",
+ "default": true
+ },
+ "require-string-key": {
+ "description": "Require all logging keys to be inlined constant strings.",
+ "type": "boolean",
+ "default": false
+ },
+ "no-printf-like": {
+ "description": "Require printf-like format specifier (%s, %d for example) not present.",
+ "type": "boolean",
+ "default": false
+ },
+ "rules": {
+ "description": "List of custom rules to check against, where each rule is a single logger pattern, useful for wrapped loggers.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "misspellSettings": {
+ "description": "Correct spellings using locale preferences for US or UK. Default is to use a neutral variety of English.",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "locale": {
+ "enum": ["US", "UK"]
+ },
+ "ignore-rules": {
+ "description": "List of rules to ignore.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "mode": {
+ "description": "Mode of the analysis.",
+ "enum": ["restricted", "", "default"],
+ "default": ""
+ },
+ "extra-words": {
+ "description": "Extra word corrections.",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "correction": {
+ "type": "string"
+ },
+ "typo": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ }
+ },
+ "musttagSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "functions": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "name": {
+ "type": "string"
+ },
+ "tag": {
+ "type": "string"
+ },
+ "arg-pos": {
+ "type": "integer"
+ }
+ }
+ }
+ }
+ }
+ },
+ "nakedretSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "max-func-lines": {
+ "description": "Report if a function has more lines of code than this value and it has naked returns.",
+ "type": "integer",
+ "minimum": 0,
+ "default": 30
+ }
+ }
+ },
+ "nestifSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "min-complexity": {
+ "description": "Minimum complexity of \"if\" statements to report.",
+ "type": "integer",
+ "default": 5
+ }
+ }
+ },
+ "nilnilSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "only-two": {
+ "type": "boolean",
+ "description": "To check functions with only two return values.",
+ "default": true
+ },
+ "detect-opposite": {
+ "type": "boolean",
+ "description": "In addition, detect opposite situation (simultaneous return of non-nil error and valid value).",
+ "default": false
+ },
+ "checked-types": {
+ "type": "array",
+ "description": "List of return types to check.",
+ "items": {
+ "enum": ["chan", "func", "iface", "map", "ptr", "uintptr", "unsafeptr"]
+ },
+ "default": ["chan", "func", "iface", "map", "ptr", "uintptr", "unsafeptr"]
+ }
+ }
+ },
+ "nlreturnSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "block-size": {
+ "description": "set block size that is still ok",
+ "type": "number",
+ "default": 0,
+ "minimum": 0
+ }
+ }
+ },
+ "mndSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "ignored-files": {
+ "description": "List of file patterns to exclude from analysis.",
+ "examples": [["magic1_.*.go"]],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ignored-functions": {
+ "description": "Comma-separated list of function patterns to exclude from the analysis.",
+ "examples": [["math.*", "http.StatusText", "make"]],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ignored-numbers": {
+ "description": "List of numbers to exclude from analysis.",
+ "examples": [["1000", "1234_567_890", "3.14159264"]],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "checks": {
+ "description": "The list of enabled checks, see https://github.com/tommy-muehle/go-mnd/#checks for description.",
+ "type": "array",
+ "items": {
+ "enum": [
+ "argument",
+ "case",
+ "condition",
+ "operation",
+ "return",
+ "assign"
+ ]
+ }
+ }
+ }
+ },
+ "modernizeSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "disable": {
+ "description": "List of analyzers to disable.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/modernize-analyzers"
+ }
+ }
+ }
+ },
+ "nolintlintSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "allow-unused": {
+ "description": "Enable to ensure that nolint directives are all used.",
+ "type": "boolean",
+ "default": true
+ },
+ "allow-no-explanation": {
+ "description": "Exclude these linters from requiring an explanation.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/linter-names"
+ },
+ "default": []
+ },
+ "require-explanation": {
+ "description": "Enable to require an explanation of nonzero length after each nolint directive.",
+ "type": "boolean",
+ "default": false
+ },
+ "require-specific": {
+ "description": "Enable to require nolint directives to mention the specific linter being suppressed.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "reassignSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "patterns": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "recvcheckSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "disable-builtin": {
+ "description": "Disables the built-in method exclusions.",
+ "type": "boolean",
+ "default": true
+ },
+ "exclusions": {
+ "description": "User-defined method exclusions.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "nonamedreturnsSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "report-error-in-defer": {
+ "description": "Report named error if it is assigned inside defer.",
+ "type": "boolean",
+ "default": false
+ },
+ "allow-unused-named-returns": {
+ "description": "Allow named returns in the signature but report them if referenced in the body or used by a naked return.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "paralleltestSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "ignore-missing": {
+ "description": "Ignore missing calls to `t.Parallel()` and only report incorrect uses of it.",
+ "type": "boolean",
+ "default": false
+ },
+ "ignore-missing-subtests": {
+ "description": "Ignore missing calls to `t.Parallel()` in subtests. Top-level tests are still required to have `t.Parallel`, but subtests are allowed to skip it.",
+ "type": "boolean",
+ "default": false
+ },
+ "check-cleanup": {
+ "description": "Check that defer is not used with t.Parallel (use t.Cleanup instead).",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "perfsprintSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "integer-format": {
+ "description": "Enable/disable optimization of integer formatting.",
+ "type": "boolean",
+ "default": true
+ },
+ "int-conversion": {
+ "description": "Optimizes even if it requires an int or uint type cast.",
+ "type": "boolean",
+ "default": true
+ },
+ "error-format": {
+ "description": "Enable/disable optimization of error formatting.",
+ "type": "boolean",
+ "default": true
+ },
+ "err-error": {
+ "description": "Optimizes into `err.Error()` even if it is only equivalent for non-nil errors.",
+ "type": "boolean",
+ "default": false
+ },
+ "errorf": {
+ "description": "Optimizes `fmt.Errorf`.",
+ "type": "boolean",
+ "default": true
+ },
+ "string-format": {
+ "description": "Enable/disable optimization of string formatting.",
+ "type": "boolean",
+ "default": true
+ },
+ "sprintf1": {
+ "description": "Optimizes `fmt.Sprintf` with only one argument.",
+ "type": "boolean",
+ "default": true
+ },
+ "strconcat": {
+ "description": "Optimizes into strings concatenation.",
+ "type": "boolean",
+ "default": true
+ },
+ "bool-format": {
+ "description": "Enable/disable optimization of bool formatting.",
+ "type": "boolean",
+ "default": true
+ },
+ "hex-format": {
+ "description": "Enable/disable optimization of hex formatting.",
+ "type": "boolean",
+ "default": true
+ },
+ "concat-loop": {
+ "description": "Enable/disable optimization of concat loop.",
+ "type": "boolean",
+ "default": true
+ },
+ "loop-other-ops": {
+ "description": "Optimization of `concat-loop` even with other operations.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "preallocSettings": {
+ "description": "We do not recommend using this linter before doing performance profiling.\nFor most programs usage of `prealloc` will be premature optimization.",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "simple": {
+ "description": "Report preallocation suggestions only on simple loops that have no returns/breaks/continues/gotos in them.",
+ "type": "boolean",
+ "default": true
+ },
+ "range-loops": {
+ "description": "Report preallocation suggestions on range loops.",
+ "type": "boolean",
+ "default": true
+ },
+ "for-loops": {
+ "description": "Report preallocation suggestions on for loops.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "predeclaredSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "ignore": {
+ "description": "List of predeclared identifiers to not report on.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "qualified-name": {
+ "description": "Include method names and field names in checks.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "promlinterSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "strict": {},
+ "disabled-linters": {
+ "type": "array",
+ "items": {
+ "enum": [
+ "Help",
+ "MetricUnits",
+ "Counter",
+ "HistogramSummaryReserved",
+ "MetricTypeInName",
+ "ReservedChars",
+ "CamelCase",
+ "UnitAbbreviations"
+ ]
+ }
+ }
+ }
+ },
+ "protogetterSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "skip-generated-by": {
+ "type": "array",
+ "items": {
+ "type": "string",
+ "examples": ["protoc-gen-go-my-own-generator"]
+ }
+ },
+ "skip-files": {
+ "type": "array",
+ "items": {
+ "type": "string",
+ "examples": ["*.pb.go"]
+ }
+ },
+ "skip-any-generated": {
+ "description": "Skip any generated files from the checking.",
+ "type": "boolean",
+ "default": false
+ },
+ "replace-first-arg-in-append": {
+ "description": "Skip first argument of append function.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "reviveSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "examples": [
+ {
+ "ignore-generated-header": true,
+ "severity": "warning",
+ "rules": [
+ {
+ "name": "indent-error-flow",
+ "severity": "warning"
+ },
+ {
+ "name": "add-constant",
+ "severity": "warning",
+ "arguments": [
+ {
+ "maxLitCount": "3",
+ "allowStrs": "\"\"",
+ "allowInts": "0,1,2",
+ "allowFloats": "0.0,0.,1.0,1.,2.0,2."
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ "properties": {
+ "max-open-files": {
+ "type": "integer"
+ },
+ "confidence": {
+ "type": "number"
+ },
+ "severity": {
+ "type": "string",
+ "enum": ["warning", "error"]
+ },
+ "enable-all-rules": {
+ "type": "boolean",
+ "default": false
+ },
+ "enable-default-rules": {
+ "type": "boolean",
+ "default": false
+ },
+ "directives": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "name": {
+ "type": "string",
+ "enum": ["specify-disable-reason", "specify-disable-rule"]
+ },
+ "severity": {
+ "type": "string",
+ "enum": ["warning", "error"]
+ },
+ "exclude": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "arguments": {
+ "type": "array"
+ }
+ }
+ }
+ },
+ "rules": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "required": ["name"],
+ "properties": {
+ "name": {
+ "$ref": "#/definitions/revive-rules",
+ "title": "The rule name"
+ },
+ "disabled": {
+ "type": "boolean"
+ },
+ "severity": {
+ "type": "string",
+ "enum": ["warning", "error"]
+ },
+ "exclude": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "arguments": {
+ "type": "array"
+ }
+ }
+ }
+ }
+ }
+ },
+ "rowserrcheckSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "packages": {
+ "type": "array",
+ "items": {
+ "description": "",
+ "type": "string",
+ "examples": ["github.com/jmoiron/sqlx"]
+ }
+ }
+ }
+ },
+ "sloglintSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "no-global": {
+ "description": "Report the use of global loggers.",
+ "enum": ["", "all", "default"],
+ "default": ""
+ },
+ "context": {
+ "description": "Report the use of functions without a context.Context.",
+ "enum": ["", "all", "scope"],
+ "default": ""
+ },
+ "static-msg": {
+ "description": "Report dynamic log messages, such as those that are built with fmt.Sprintf.",
+ "type": "boolean",
+ "default": false
+ },
+ "msg-style": {
+ "description": "Report log messages that do not match a particular style.",
+ "enum": ["", "lowercased", "capitalized"],
+ "default": ""
+ },
+ "no-mixed-args": {
+ "description": "Report the use of both key-value pairs and attributes within a single function call.",
+ "type": "boolean",
+ "default": true
+ },
+ "kv-only": {
+ "description": "Report any use of attributes as function call arguments.",
+ "type": "boolean",
+ "default": false
+ },
+ "attr-only": {
+ "description": "Report any use of key-value pairs as function call arguments.",
+ "type": "boolean",
+ "default": false
+ },
+ "args-on-sep-lines": {
+ "description": "Report two or more arguments on the same line.",
+ "type": "boolean",
+ "default": false
+ },
+ "no-raw-keys": {
+ "description": "Report the use of string literals as log keys.",
+ "type": "boolean",
+ "default": false
+ },
+ "allowed-keys": {
+ "description": "Report the use of log keys that are not explicitly allowed.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "forbidden-keys": {
+ "description": "Report the use of forbidden log keys.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "key-naming-case": {
+ "description": "Report log keys that do not match a particular naming case.",
+ "enum": ["snake", "kebab", "camel", "pascal"]
+ },
+ "custom-funcs": {
+ "description": "Analyze custom functions in addition to the standard log/slog functions.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/settings/definitions/sloglintCustomFunc"
+ }
+ }
+ }
+ },
+ "sloglintCustomFunc": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "name": {
+ "description": "The full name of the function, including the package. If the function is a method, the receiver type must be wrapped in parentheses.",
+ "type": "string"
+ },
+ "msg-pos": {
+ "description": "The position of the \"msg string\" argument in the function signature, starting from 0. If there is no message in the function, a negative value must be passed.",
+ "type": "integer"
+ },
+ "args-pos": {
+ "description": "The position of the \"args ...any\" argument in the function signature, starting from 0. If there are no arguments in the function, a negative value must be passed.",
+ "type": "integer"
+ }
+ }
+ },
+ "spancheckSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "checks": {
+ "description": "Checks to enable.",
+ "type": "array",
+ "items": {
+ "enum": ["end", "record-error", "set-status"]
+ }
+ },
+ "ignore-check-signatures": {
+ "description": "A list of regexes for function signatures that silence `record-error` and `set-status` reports if found in the call path to a returned error.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "extra-start-span-signatures": {
+ "description": "A list of regexes for additional function signatures that create spans.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "staticcheckSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "checks": {
+ "type": "array",
+ "items": {
+ "anyOf": [
+ {
+ "$ref": "#/definitions/staticcheck-checks"
+ },
+ {
+ "type": "string"
+ }
+ ]
+ }
+ },
+ "dot-import-whitelist": {
+ "description": "By default, ST1001 forbids all uses of dot imports in non-test packages. This setting allows setting a whitelist of import paths that can be dot-imported anywhere.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "http-status-code-whitelist": {
+ "description": "ST1013 recommends using constants from the net/http package instead of hard-coding numeric HTTP status codes. This setting specifies a list of numeric status codes that this check does not complain about.",
+ "default": ["200", "400", "404", "500"],
+ "type": "array",
+ "items": {
+ "enum": [
+ "100",
+ "101",
+ "102",
+ "103",
+ "200",
+ "201",
+ "202",
+ "203",
+ "204",
+ "205",
+ "206",
+ "207",
+ "208",
+ "226",
+ "300",
+ "301",
+ "302",
+ "303",
+ "304",
+ "305",
+ "306",
+ "307",
+ "308",
+ "400",
+ "401",
+ "402",
+ "403",
+ "404",
+ "405",
+ "406",
+ "407",
+ "408",
+ "409",
+ "410",
+ "411",
+ "412",
+ "413",
+ "414",
+ "415",
+ "416",
+ "417",
+ "418",
+ "421",
+ "422",
+ "423",
+ "424",
+ "425",
+ "426",
+ "428",
+ "429",
+ "431",
+ "451",
+ "500",
+ "501",
+ "502",
+ "503",
+ "504",
+ "505",
+ "506",
+ "507",
+ "508",
+ "510",
+ "511"
+ ]
+ }
+ },
+ "initialisms": {
+ "description": "ST1003 check, among other things, for the correct capitalization of initialisms. The set of known initialisms can be configured with this option.",
+ "type": "array",
+ "items": {
+ "type": "string",
+ "default": [
+ "ACL",
+ "API",
+ "ASCII",
+ "CPU",
+ "CSS",
+ "DNS",
+ "EOF",
+ "GUID",
+ "HTML",
+ "HTTP",
+ "HTTPS",
+ "ID",
+ "IP",
+ "JSON",
+ "QPS",
+ "RAM",
+ "RPC",
+ "SLA",
+ "SMTP",
+ "SQL",
+ "SSH",
+ "TCP",
+ "TLS",
+ "TTL",
+ "UDP",
+ "UI",
+ "GID",
+ "UID",
+ "UUID",
+ "URI",
+ "URL",
+ "UTF8",
+ "VM",
+ "XML",
+ "XMPP",
+ "XSRF",
+ "XSS",
+ "SIP",
+ "RTP",
+ "AMQP",
+ "DB",
+ "TS"
+ ]
+ }
+ }
+ }
+ },
+ "tagalignSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "align": {
+ "description": "Align and sort can be used together or separately.",
+ "type": "boolean",
+ "default": true
+ },
+ "sort": {
+ "description": "Whether enable tags sort.",
+ "type": "boolean",
+ "default": true
+ },
+ "order": {
+ "description": "Specify the order of tags, the other tags will be sorted by name.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "default": [],
+ "examples": [
+ [
+ "json",
+ "yaml",
+ "yml",
+ "toml",
+ "mapstructure",
+ "binding",
+ "validate"
+ ]
+ ]
+ },
+ "strict": {
+ "description": "Whether enable strict style.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "tagliatelleSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "case": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "use-field-name": {
+ "description": "Use the struct field name to check the name of the struct tag.",
+ "type": "boolean",
+ "default": false
+ },
+ "ignored-fields": {
+ "description": "The field names to ignore.",
+ "type": "array",
+ "items": {
+ "type": "string",
+ "examples": ["example"]
+ }
+ },
+ "rules": {
+ "type": "object",
+ "patternProperties": {
+ "^.+$": {
+ "$ref": "#/definitions/tagliatelle-cases"
+ }
+ }
+ },
+ "extended-rules": {
+ "description": "Defines the association between tag name and case.",
+ "type": "object",
+ "patternProperties": {
+ "^.+$": {
+ "type": "object",
+ "additionalProperties": false,
+ "required": ["case"],
+ "properties": {
+ "case": {
+ "$ref": "#/definitions/tagliatelle-cases"
+ },
+ "extra-initialisms": {
+ "type": "boolean",
+ "default": false
+ },
+ "initialism-overrides": {
+ "type": "object",
+ "patternProperties": {
+ "^.+$": {
+ "type": "boolean",
+ "default": false
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "overrides": {
+ "description": "Overrides the default/root configuration.",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "required": ["pkg"],
+ "properties": {
+ "pkg": {
+ "description": "A package path.",
+ "type": "string"
+ },
+ "use-field-name": {
+ "description": "Use the struct field name to check the name of the struct tag.",
+ "type": "boolean",
+ "default": false
+ },
+ "ignored-fields": {
+ "description": "The field names to ignore.",
+ "type": "array",
+ "items": {
+ "type": "string",
+ "examples": ["example"]
+ }
+ },
+ "ignore": {
+ "description": "Ignore the package (takes precedence over all other configurations).",
+ "type": "boolean",
+ "default": false
+ },
+ "rules": {
+ "type": "object",
+ "patternProperties": {
+ "^.+$": {
+ "$ref": "#/definitions/tagliatelle-cases"
+ }
+ }
+ },
+ "extended-rules": {
+ "description": "Defines the association between tag name and case.",
+ "type": "object",
+ "patternProperties": {
+ "^.+$": {
+ "type": "object",
+ "additionalProperties": false,
+ "required": ["case"],
+ "properties": {
+ "case": {
+ "$ref": "#/definitions/tagliatelle-cases"
+ },
+ "extra-initialisms": {
+ "type": "boolean",
+ "default": false
+ },
+ "initialism-overrides": {
+ "type": "object",
+ "patternProperties": {
+ "^.+$": {
+ "type": "boolean",
+ "default": false
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "testifylintSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "enable-all": {
+ "description": "Enable all checkers.",
+ "type": "boolean",
+ "default": false
+ },
+ "disable-all": {
+ "description": "Disable all checkers.",
+ "type": "boolean",
+ "default": false
+ },
+ "enable": {
+ "description": "Enable specific checkers.",
+ "type": "array",
+ "items": {
+ "enum": [
+ "blank-import",
+ "bool-compare",
+ "compares",
+ "contains",
+ "empty",
+ "encoded-compare",
+ "equal-values",
+ "error-is-as",
+ "error-nil",
+ "expected-actual",
+ "float-compare",
+ "formatter",
+ "go-require",
+ "len",
+ "negative-positive",
+ "nil-compare",
+ "regexp",
+ "require-error",
+ "suite-broken-parallel",
+ "suite-dont-use-pkg",
+ "suite-extra-assert-call",
+ "suite-method-signature",
+ "suite-subtest-run",
+ "suite-thelper",
+ "useless-assert"
+ ]
+ },
+ "default": [
+ "blank-import",
+ "bool-compare",
+ "compares",
+ "contains",
+ "empty",
+ "encoded-compare",
+ "equal-values",
+ "error-is-as",
+ "error-nil",
+ "expected-actual",
+ "float-compare",
+ "formatter",
+ "go-require",
+ "len",
+ "negative-positive",
+ "nil-compare",
+ "regexp",
+ "require-error",
+ "suite-broken-parallel",
+ "suite-dont-use-pkg",
+ "suite-extra-assert-call",
+ "suite-method-signature",
+ "suite-subtest-run",
+ "useless-assert"
+ ]
+ },
+ "disable": {
+ "description": "Disable specific checkers.",
+ "type": "array",
+ "items": {
+ "enum": [
+ "blank-import",
+ "bool-compare",
+ "compares",
+ "contains",
+ "empty",
+ "encoded-compare",
+ "equal-values",
+ "error-is-as",
+ "error-nil",
+ "expected-actual",
+ "float-compare",
+ "formatter",
+ "go-require",
+ "len",
+ "negative-positive",
+ "nil-compare",
+ "regexp",
+ "require-error",
+ "suite-broken-parallel",
+ "suite-dont-use-pkg",
+ "suite-extra-assert-call",
+ "suite-method-signature",
+ "suite-subtest-run",
+ "suite-thelper",
+ "useless-assert"
+ ],
+ "default": [
+ "suite-thelper"
+ ]
+ }
+ },
+ "bool-compare": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "ignore-custom-types": {
+ "description": "To ignore user defined types (over builtin bool).",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "expected-actual": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "pattern": {
+ "description": "Regexp for expected variable name.",
+ "type": "string",
+ "default": "(^(exp(ected)?|want(ed)?)([A-Z]\\w*)?$)|(^(\\w*[a-z])?(Exp(ected)?|Want(ed)?)$)"
+ }
+ }
+ },
+ "formatter": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "check-format-string": {
+ "description": "To enable go vet's printf checks.",
+ "type": "boolean",
+ "default": true
+ },
+ "require-f-funcs": {
+ "description": "To require f-assertions (e.g. assert.Equalf) if format string is used, even if there are no variable-length variables.",
+ "type": "boolean",
+ "default": false
+ },
+ "require-string-msg": {
+ "description": "To require that the first element of msgAndArgs (msg) has a string type.",
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "go-require": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "ignore-http-handlers": {
+ "description": "To ignore HTTP handlers (like http.HandlerFunc).",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "require-error": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "fn-pattern": {
+ "description": "Regexp for assertions to analyze. If defined, then only matched error assertions will be reported.",
+ "type": "string",
+ "default": ""
+ }
+ }
+ },
+ "suite-extra-assert-call": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "mode": {
+ "description": "To require or remove extra Assert() call?",
+ "type": "string",
+ "enum": ["remove", "require"],
+ "default": "remove"
+ }
+ }
+ }
+ }
+ },
+ "testpackageSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "skip-regexp": {
+ "description": "Files with names matching this regular expression are skipped.",
+ "type": "string",
+ "examples": ["(export|internal)_test\\.go"]
+ },
+ "allow-packages": {
+ "description": "List of packages that don't end with _test that tests are allowed to be in.",
+ "type": "array",
+ "uniqueItems": true,
+ "items": {
+ "type": "string",
+ "examples": ["example"]
+ }
+ }
+ }
+ },
+ "thelperSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "test": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "begin": {
+ "description": "Check if `t.Helper()` begins helper function.",
+ "default": true,
+ "type": "boolean"
+ },
+ "first": {
+ "description": "Check if *testing.T is first param of helper function.",
+ "default": true,
+ "type": "boolean"
+ },
+ "name": {
+ "description": "Check if *testing.T param has t name.",
+ "default": true,
+ "type": "boolean"
+ }
+ }
+ },
+ "benchmark": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "begin": {
+ "description": "Check if `b.Helper()` begins helper function.",
+ "default": true,
+ "type": "boolean"
+ },
+ "first": {
+ "description": "Check if *testing.B is first param of helper function.",
+ "default": true,
+ "type": "boolean"
+ },
+ "name": {
+ "description": "Check if *testing.B param has b name.",
+ "default": true,
+ "type": "boolean"
+ }
+ }
+ },
+ "tb": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "begin": {
+ "description": "Check if `tb.Helper()` begins helper function.",
+ "default": true,
+ "type": "boolean"
+ },
+ "first": {
+ "description": "Check if *testing.TB is first param of helper function.",
+ "default": true,
+ "type": "boolean"
+ },
+ "name": {
+ "description": "Check if *testing.TB param has tb name.",
+ "default": true,
+ "type": "boolean"
+ }
+ }
+ },
+ "fuzz": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "begin": {
+ "description": "Check if `f.Helper()` begins helper function.",
+ "default": true,
+ "type": "boolean"
+ },
+ "first": {
+ "description": "Check if *testing.F is first param of helper function.",
+ "default": true,
+ "type": "boolean"
+ },
+ "name": {
+ "description": "Check if *testing.F param has f name.",
+ "default": true,
+ "type": "boolean"
+ }
+ }
+ }
+ }
+ },
+ "usestdlibvarsSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "http-method": {
+ "description": "Suggest the use of http.MethodXX.",
+ "type": "boolean",
+ "default": true
+ },
+ "http-status-code": {
+ "description": "Suggest the use of http.StatusXX.",
+ "type": "boolean",
+ "default": true
+ },
+ "time-weekday": {
+ "description": "Suggest the use of time.Weekday.String().",
+ "type": "boolean",
+ "default": false
+ },
+ "time-month": {
+ "description": "Suggest the use of time.Month.String().",
+ "type": "boolean",
+ "default": false
+ },
+ "time-layout": {
+ "description": "Suggest the use of time.Layout.",
+ "type": "boolean",
+ "default": false
+ },
+ "time-date-month": {
+ "description": "Suggest the use of time.Month in time.Date.",
+ "type": "boolean",
+ "default": false
+ },
+ "crypto-hash": {
+ "description": "Suggest the use of crypto.Hash.String().",
+ "type": "boolean",
+ "default": false
+ },
+ "default-rpc-path": {
+ "description": "Suggest the use of rpc.DefaultXXPath.",
+ "type": "boolean",
+ "default": false
+ },
+ "sql-isolation-level": {
+ "description": "Suggest the use of sql.LevelXX.String().",
+ "type": "boolean",
+ "default": false
+ },
+ "tls-signature-scheme": {
+ "description": "Suggest the use of tls.SignatureScheme.String().",
+ "type": "boolean",
+ "default": false
+ },
+ "constant-kind": {
+ "description": "Suggest the use of constant.Kind.String().",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "usetestingSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "context-background": {
+ "type": "boolean",
+ "default": false
+ },
+ "context-todo": {
+ "type": "boolean",
+ "default": false
+ },
+ "os-chdir": {
+ "type": "boolean",
+ "default": true
+ },
+ "os-mkdir-temp": {
+ "type": "boolean",
+ "default": true
+ },
+ "os-setenv": {
+ "type": "boolean",
+ "default": true
+ },
+ "os-create-temp": {
+ "type": "boolean",
+ "default": true
+ },
+ "os-temp-dir": {
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "unconvertSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "fast-math": {
+ "type": "boolean",
+ "default": false
+ },
+ "safe": {
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "unparamSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "check-exported": {
+ "description": "Inspect exported functions. Set to true if no external program/library imports your code.\n\nWARNING: if you enable this setting, unparam will report a lot of false-positives in text editors:\nif it's called for subdir of a project it can't find external interfaces. All text editor integrations\nwith golangci-lint call it on a directory with the changed file.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "unqueryvetSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "check-sql-builders": {
+ "description": "Enable SQL builder checking.",
+ "type": "boolean",
+ "default": true
+ },
+ "check-aliased-wildcard": {
+ "description": "Enable aliased wildcard detection like SELECT t.*.",
+ "type": "boolean",
+ "default": true
+ },
+ "check-string-concat": {
+ "description": "Enable string concatenation analysis.",
+ "type": "boolean",
+ "default": true
+ },
+ "check-format-strings": {
+ "description": "Enable format string analysis like fmt.Sprintf.",
+ "type": "boolean",
+ "default": true
+ },
+ "check-string-builder": {
+ "description": "Enable strings.Builder analysis.",
+ "type": "boolean",
+ "default": true
+ },
+ "check-subqueries": {
+ "description": "Enable subquery analysis.",
+ "type": "boolean",
+ "default": true
+ },
+ "check-n1": {
+ "type": "boolean",
+ "default": false
+ },
+ "check-sql-injection": {
+ "type": "boolean",
+ "default": false
+ },
+ "check-tx-leaks": {
+ "type": "boolean",
+ "default": false
+ },
+ "allowed-patterns": {
+ "description": "Regex patterns for acceptable SELECT * usage.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "allow": {
+ "description": "Allow is a list of SQL patterns to allow (whitelist).",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ignored-functions": {
+ "description": "Functions to ignore.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "sql-builders": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "squirrel": {
+ "type": "boolean",
+ "default": true
+ },
+ "gorm": {
+ "type": "boolean",
+ "default": true
+ },
+ "sqlx": {
+ "type": "boolean",
+ "default": true
+ },
+ "ent": {
+ "type": "boolean",
+ "default": true
+ },
+ "pgx": {
+ "type": "boolean",
+ "default": true
+ },
+ "bun": {
+ "type": "boolean",
+ "default": true
+ },
+ "sqlboiler": {
+ "type": "boolean",
+ "default": true
+ },
+ "jet": {
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "custom-rules": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "id": {
+ "type": "string"
+ },
+ "pattern": {
+ "type": "string"
+ },
+ "patterns": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "when": {
+ "type": "string"
+ },
+ "message": {
+ "type": "string"
+ },
+ "action": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ }
+ },
+ "unusedSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "field-writes-are-uses": {
+ "description": "",
+ "type": "boolean",
+ "default": true
+ },
+ "post-statements-are-reads": {
+ "description": "",
+ "type": "boolean",
+ "default": false
+ },
+ "exported-fields-are-used": {
+ "description": "",
+ "type": "boolean",
+ "default": true
+ },
+ "parameters-are-used": {
+ "description": "",
+ "type": "boolean",
+ "default": true
+ },
+ "local-variables-are-used": {
+ "description": "",
+ "type": "boolean",
+ "default": true
+ },
+ "generated-is-used": {
+ "description": "",
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "varnamelenSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "max-distance": {
+ "description": "Variables used in at most this N-many lines will be ignored.",
+ "type": "integer",
+ "default": 5
+ },
+ "min-name-length": {
+ "description": "The minimum length of a variable's name that is considered `long`.",
+ "type": "integer",
+ "default": 3
+ },
+ "check-receiver": {
+ "description": "Check method receiver names.",
+ "default": false,
+ "type": "boolean"
+ },
+ "check-return": {
+ "description": "Check named return values.",
+ "default": false,
+ "type": "boolean"
+ },
+ "check-type-param": {
+ "description": "Check type parameters.",
+ "default": false,
+ "type": "boolean"
+ },
+ "ignore-type-assert-ok": {
+ "description": "Ignore `ok` variables that hold the bool return value of a type assertion",
+ "default": false,
+ "type": "boolean"
+ },
+ "ignore-map-index-ok": {
+ "description": "Ignore `ok` variables that hold the bool return value of a map index.",
+ "default": false,
+ "type": "boolean"
+ },
+ "ignore-chan-recv-ok": {
+ "description": "Ignore `ok` variables that hold the bool return value of a channel receive.",
+ "default": false,
+ "type": "boolean"
+ },
+ "ignore-names": {
+ "description": "Optional list of variable names that should be ignored completely.",
+ "default": [[]],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ignore-decls": {
+ "description": "Optional list of variable declarations that should be ignored completely.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "examples": [
+ ["c echo.Context", "t testing.T", "f *foo.Bar", "const C"]
+ ]
+ }
+ }
+ },
+ "whitespaceSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "multi-if": {
+ "description": "Enforces newlines (or comments) after every multi-line if statement",
+ "type": "boolean",
+ "default": false
+ },
+ "multi-func": {
+ "description": "Enforces newlines (or comments) after every multi-line function signature",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "wrapcheckSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "extra-ignore-sigs": {
+ "description": "An array of strings specifying additional substrings of signatures to ignore.",
+ "default": [
+ ".CustomError(",
+ ".SpecificWrap("
+ ],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ignore-sigs": {
+ "description": "An array of strings which specify substrings of signatures to ignore.",
+ "default": [
+ ".Errorf(",
+ "errors.New(",
+ "errors.Unwrap(",
+ ".Wrap(",
+ ".Wrapf(",
+ ".WithMessage(",
+ ".WithMessagef(",
+ ".WithStack("
+ ],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ignore-sig-regexps": {
+ "description": "An array of strings which specify regular expressions of signatures to ignore.",
+ "default": [""],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ignore-package-globs": {
+ "description": "An array of glob patterns which, if any match the package of the function returning the error, will skip wrapcheck analysis for this error.",
+ "default": [""],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ignore-interface-regexps": {
+ "description": "An array of glob patterns which, if matched to an underlying interface name, will ignore unwrapped errors returned from a function whose call is defined on the given interface.",
+ "default": [""],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "report-internal-errors": {
+ "description": "Determines whether wrapcheck should report errors returned from inside the package.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "wslSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "allow-assign-and-anything": {
+ "description": "Controls if you may cuddle assignments and anything without needing an empty line between them.",
+ "type": "boolean",
+ "default": false
+ },
+ "allow-assign-and-call": {
+ "description": "Allow calls and assignments to be cuddled as long as the lines have any matching variables, fields or types.",
+ "type": "boolean",
+ "default": true
+ },
+ "allow-cuddle-declarations": {
+ "description": "Allow declarations (var) to be cuddled.",
+ "type": "boolean",
+ "default": false
+ },
+ "allow-cuddle-with-calls": {
+ "description": "A list of call idents that everything can be cuddled with.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "allow-cuddle-with-rhs": {
+ "description": "AllowCuddleWithRHS is a list of right hand side variables that is allowed to be cuddled with anything.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "allow-cuddle-used-in-block": {
+ "description": "Allow cuddling with any block as long as the variable is used somewhere in the block",
+ "type": "boolean",
+ "default": false
+ },
+ "allow-multiline-assign": {
+ "description": "Allow multiline assignments to be cuddled.",
+ "type": "boolean",
+ "default": true
+ },
+ "allow-separated-leading-comment": {
+ "description": "Allow leading comments to be separated with empty lines.",
+ "type": "boolean",
+ "default": false
+ },
+ "allow-trailing-comment": {
+ "description": "Allow trailing comments in ending of blocks.",
+ "type": "boolean",
+ "default": false
+ },
+ "error-variable-names": {
+ "description": "When force-err-cuddling is enabled this is a list of names used for error variables to check for in the conditional.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "force-case-trailing-whitespace": {
+ "description": "Force newlines in end of case at this limit (0 = never).",
+ "type": "integer",
+ "minimum": 0,
+ "default": 0
+ },
+ "force-err-cuddling": {
+ "description": "Causes an error when an If statement that checks an error variable doesn't cuddle with the assignment of that variable.",
+ "type": "boolean",
+ "default": false
+ },
+ "force-short-decl-cuddling": {
+ "description": "Causes an error if a short declaration (:=) cuddles with anything other than another short declaration.",
+ "type": "boolean",
+ "default": false
+ },
+ "strict-append": {
+ "description": "If true, append is only allowed to be cuddled if appending value is matching variables, fields or types on line above.",
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "wslSettingsV5": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "allow-first-in-block": {
+ "type": "boolean",
+ "default": true
+ },
+ "allow-whole-block": {
+ "type": "boolean",
+ "default": false
+ },
+ "branch-max-lines": {
+ "type": "integer",
+ "default": 2
+ },
+ "case-max-lines": {
+ "type": "integer",
+ "default": 0
+ },
+ "cuddle-max-statements": {
+ "type": "integer",
+ "default": 1
+ },
+ "default": {
+ "enum": ["all", "none", "default", ""],
+ "default": "default"
+ },
+ "enable": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/wsl-checks"
+ }
+ },
+ "disable": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/wsl-checks"
+ }
+ }
+ }
+ },
+ "copyloopvarSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "check-alias": {
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "customSettings": {
+ "description": "The custom section can be used to define linter plugins to be loaded at runtime. See README of golangci-lint for more information.\nEach custom linter should have a unique name.",
+ "type": "object",
+ "patternProperties": {
+ "^.*$": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "type": {
+ "description": "The plugin type.",
+ "enum": ["module", "goplugin"],
+ "default": "goplugin"
+ },
+ "path": {
+ "description": "The path to the plugin *.so. Can be absolute or local.",
+ "type": "string",
+ "examples": ["/path/to/example.so"]
+ },
+ "description": {
+ "description": "The description of the linter, for documentation purposes only.",
+ "type": "string"
+ },
+ "original-url": {
+ "description": "Intended to point to the repo location of the linter, for documentation purposes only.",
+ "type": "string"
+ },
+ "settings": {
+ "description": "Plugins settings/configuration. Only work with plugin based on `linterdb.PluginConstructor`.",
+ "type": "object"
+ }
+ },
+ "oneOf": [
+ {
+ "properties": {
+ "type": {"enum": ["module"] }
+ },
+ "required": ["type"]
+ },
+ {
+ "required": ["path"]
+ }
+ ]
+ }
+ }
+ }
+ }
+ }
+ },
+ "type": "object",
+ "additionalProperties": false,
+ "required": ["version"],
+ "properties": {
+ "version": {
+ "type": "string",
+ "default": "2"
+ },
+ "run": {
+ "description": "Options for analysis running,",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "concurrency": {
+ "description": "Number of concurrent runners. Defaults to the number of available CPU cores.",
+ "type": "integer",
+ "minimum": 0,
+ "examples": [4]
+ },
+ "timeout": {
+ "description": "Timeout for the analysis.",
+ "type": "string",
+ "pattern": "^((\\d+h)?(\\d+m)?(\\d+(?:\\.\\d)?s)?|0)$",
+ "default": "1m",
+ "examples": ["30s", "5m", "5m30s"]
+ },
+ "issues-exit-code": {
+ "description": "Exit code when at least one issue was found.",
+ "type": "integer",
+ "default": 1
+ },
+ "tests": {
+ "description": "Enable inclusion of test files.",
+ "type": "boolean",
+ "default": true
+ },
+ "build-tags": {
+ "description": "List of build tags to pass to all linters.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "default": [],
+ "examples": [["mytag"]]
+ },
+ "modules-download-mode": {
+ "description": "Option to pass to \"go list -mod={option}\".\nSee \"go help modules\" for more information.",
+ "enum": ["mod", "readonly", "vendor"]
+ },
+ "enable-build-vcs": {
+ "type": "boolean",
+ "default": false
+ },
+ "allow-parallel-runners": {
+ "description": "Allow multiple parallel golangci-lint instances running. If disabled, golangci-lint acquires file lock on start.",
+ "type": "boolean",
+ "default": false
+ },
+ "allow-serial-runners": {
+ "description": "Allow multiple golangci-lint instances running, but serialize them around a lock.",
+ "type": "boolean",
+ "default": false
+ },
+ "go": {
+ "description": "Targeted Go version.",
+ "type": "string",
+ "default": "1.17"
+ },
+ "relative-path-mode": {
+ "description": "The mode used to evaluate relative paths.",
+ "type": "string",
+ "$ref": "#/definitions/relative-path-modes",
+ "default": "wd"
+ }
+ }
+ },
+ "output": {
+ "description": "Output configuration options.",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "formats": {
+ "description": "Output formats to use.",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "text": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "path": {
+ "$ref": "#/definitions/formats-path",
+ "default": "stdout"
+ },
+ "print-linter-name": {
+ "type": "boolean",
+ "default": true
+ },
+ "print-issued-lines": {
+ "type": "boolean",
+ "default": true
+ },
+ "colors": {
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "json": {
+ "$ref": "#/definitions/simple-format"
+ },
+ "tab": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "path": {
+ "$ref": "#/definitions/formats-path",
+ "default": "stdout"
+ },
+ "print-linter-name": {
+ "type": "boolean",
+ "default": true
+ },
+ "colors": {
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "html": {
+ "$ref": "#/definitions/simple-format"
+ },
+ "checkstyle": {
+ "$ref": "#/definitions/simple-format"
+ },
+ "code-climate": {
+ "$ref": "#/definitions/simple-format"
+ },
+ "junit-xml": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "path": {
+ "$ref": "#/definitions/formats-path",
+ "default": "stdout"
+ },
+ "extended": {
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "teamcity": {
+ "$ref": "#/definitions/simple-format"
+ },
+ "sarif": {
+ "$ref": "#/definitions/simple-format"
+ }
+ }
+ },
+ "path-mode": {
+ "type": "string",
+ "default": "",
+ "examples": ["abs"]
+ },
+ "path-prefix": {
+ "description": "Add a prefix to the output file references.",
+ "type": "string",
+ "default": ""
+ },
+ "show-stats": {
+ "description": "Show statistics per linter.",
+ "type": "boolean",
+ "default": true
+ },
+ "sort-order": {
+ "type": "array",
+ "items": {
+ "enum": ["linter", "severity", "file"]
+ }
+ }
+ }
+ },
+ "linters": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "default": {
+ "enum": [
+ "standard",
+ "all",
+ "none",
+ "fast"
+ ]
+ },
+ "enable": {
+ "description": "List of enabled linters.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/linter-names"
+ }
+ },
+ "disable": {
+ "description": "List of disabled linters.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/linter-names"
+ }
+ },
+ "settings": {
+ "description": "All available settings of specific linters.",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "dupword": {
+ "$ref": "#/definitions/settings/definitions/dupwordSettings"
+ },
+ "asasalint": {
+ "$ref": "#/definitions/settings/definitions/asasalintSettings"
+ },
+ "bidichk": {
+ "$ref": "#/definitions/settings/definitions/bidichkSettings"
+ },
+ "bodyclose": {
+ "$ref": "#/definitions/settings/definitions/bodycloseSettings"
+ },
+ "canonicalheader": {
+ "$ref": "#/definitions/settings/definitions/canonicalheaderSettings"
+ },
+ "cyclop": {
+ "$ref": "#/definitions/settings/definitions/cyclopSettings"
+ },
+ "decorder": {
+ "$ref": "#/definitions/settings/definitions/decorderSettings"
+ },
+ "depguard":{
+ "$ref": "#/definitions/settings/definitions/depguardSettings"
+ },
+ "dogsled": {
+ "$ref": "#/definitions/settings/definitions/dogsledSettings"
+ },
+ "dupl": {
+ "$ref": "#/definitions/settings/definitions/duplSettings"
+ },
+ "embeddedstructfieldcheck": {
+ "$ref": "#/definitions/settings/definitions/embeddedstructfieldcheckSettings"
+ },
+ "errcheck": {
+ "$ref": "#/definitions/settings/definitions/errcheckSettings"
+ },
+ "errchkjson": {
+ "$ref": "#/definitions/settings/definitions/errchkjsonSettings"
+ },
+ "errorlint": {
+ "$ref": "#/definitions/settings/definitions/errorlintSettings"
+ },
+ "exhaustive": {
+ "$ref": "#/definitions/settings/definitions/exhaustiveSettings"
+ },
+ "exhaustruct": {
+ "$ref": "#/definitions/settings/definitions/exhaustructSettings"
+ },
+ "exhaustruct_v5": {
+ "$ref": "#/definitions/settings/definitions/exhaustructv5Settings"
+ },
+ "fatcontext": {
+ "$ref": "#/definitions/settings/definitions/fatcontextSettings"
+ },
+ "forbidigo": {
+ "$ref": "#/definitions/settings/definitions/forbidigoSettings"
+ },
+ "funcorder": {
+ "$ref": "#/definitions/settings/definitions/funcorderSettings"
+ },
+ "funlen": {
+ "$ref": "#/definitions/settings/definitions/funlenSettings"
+ },
+ "ginkgolinter": {
+ "$ref": "#/definitions/settings/definitions/ginkgolinterSettings"
+ },
+ "gochecksumtype": {
+ "$ref": "#/definitions/settings/definitions/gochecksumtypeSettings"
+ },
+ "gocognit": {
+ "$ref": "#/definitions/settings/definitions/gocognitSettings"
+ },
+ "goconst": {
+ "$ref": "#/definitions/settings/definitions/goconstSettings"
+ },
+ "gocritic": {
+ "$ref": "#/definitions/settings/definitions/gocriticSettings"
+ },
+ "gocyclo": {
+ "$ref": "#/definitions/settings/definitions/gocycloSettings"
+ },
+ "godoclint": {
+ "$ref": "#/definitions/settings/definitions/godoclintSettings"
+ },
+ "godot": {
+ "$ref": "#/definitions/settings/definitions/godotSettings"
+ },
+ "godox": {
+ "$ref": "#/definitions/settings/definitions/godoxSettings"
+ },
+ "interfacebloat":{
+ "$ref": "#/definitions/settings/definitions/interfacebloatSettings"
+ },
+ "goheader": {
+ "$ref": "#/definitions/settings/definitions/goheaderSettings"
+ },
+ "gomoddirectives": {
+ "$ref": "#/definitions/settings/definitions/gomoddirectivesSettings"
+ },
+ "gomodguard": {
+ "$ref": "#/definitions/settings/definitions/gomodguardSettings"
+ },
+ "gomodguard_v2": {
+ "$ref": "#/definitions/settings/definitions/gomodguardv2Settings"
+ },
+ "gosec": {
+ "$ref": "#/definitions/settings/definitions/gosecSettings"
+ },
+ "gosmopolitan": {
+ "$ref": "#/definitions/settings/definitions/gosmopolitanSettings"
+ },
+ "govet": {
+ "$ref": "#/definitions/settings/definitions/govetSettings"
+ },
+ "grouper": {
+ "$ref": "#/definitions/settings/definitions/grouperSettings"
+ },
+ "iface": {
+ "$ref": "#/definitions/settings/definitions/ifaceSettings"
+ },
+ "importas": {
+ "$ref": "#/definitions/settings/definitions/importasSettings"
+ },
+ "inamedparam": {
+ "$ref": "#/definitions/settings/definitions/inamedparamSettings"
+ },
+ "ineffassign": {
+ "$ref": "#/definitions/settings/definitions/ineffassignSettings"
+ },
+ "iotamixing": {
+ "$ref": "#/definitions/settings/definitions/iotamixingSettings"
+ },
+ "ireturn": {
+ "$ref": "#/definitions/settings/definitions/ireturnSettings"
+ },
+ "lll": {
+ "$ref": "#/definitions/settings/definitions/lllSettings"
+ },
+ "maintidx": {
+ "$ref": "#/definitions/settings/definitions/maintidxSettings"
+ },
+ "makezero":{
+ "$ref": "#/definitions/settings/definitions/makezeroSettings"
+ },
+ "loggercheck": {
+ "$ref": "#/definitions/settings/definitions/loggercheckSettings"
+ },
+ "misspell": {
+ "$ref": "#/definitions/settings/definitions/misspellSettings"
+ },
+ "musttag": {
+ "$ref": "#/definitions/settings/definitions/musttagSettings"
+ },
+ "nakedret": {
+ "$ref": "#/definitions/settings/definitions/nakedretSettings"
+ },
+ "nestif": {
+ "$ref": "#/definitions/settings/definitions/nestifSettings"
+ },
+ "nilnil": {
+ "$ref": "#/definitions/settings/definitions/nilnilSettings"
+ },
+ "nlreturn": {
+ "$ref": "#/definitions/settings/definitions/nlreturnSettings"
+ },
+ "mnd": {
+ "$ref": "#/definitions/settings/definitions/mndSettings"
+ },
+ "modernize": {
+ "$ref": "#/definitions/settings/definitions/modernizeSettings"
+ },
+ "nolintlint":{
+ "$ref": "#/definitions/settings/definitions/nolintlintSettings"
+ },
+ "reassign": {
+ "$ref": "#/definitions/settings/definitions/reassignSettings"
+ },
+ "recvcheck": {
+ "$ref": "#/definitions/settings/definitions/recvcheckSettings"
+ },
+ "nonamedreturns": {
+ "$ref": "#/definitions/settings/definitions/nonamedreturnsSettings"
+ },
+ "paralleltest": {
+ "$ref": "#/definitions/settings/definitions/paralleltestSettings"
+ },
+ "perfsprint": {
+ "$ref": "#/definitions/settings/definitions/perfsprintSettings"
+ },
+ "prealloc": {
+ "$ref": "#/definitions/settings/definitions/preallocSettings"
+ },
+ "predeclared": {
+ "$ref": "#/definitions/settings/definitions/predeclaredSettings"
+ },
+ "promlinter": {
+ "$ref": "#/definitions/settings/definitions/promlinterSettings"
+ },
+ "protogetter": {
+ "$ref": "#/definitions/settings/definitions/protogetterSettings"
+ },
+ "revive": {
+ "$ref": "#/definitions/settings/definitions/reviveSettings"
+ },
+ "rowserrcheck": {
+ "$ref": "#/definitions/settings/definitions/rowserrcheckSettings"
+ },
+ "sloglint": {
+ "$ref": "#/definitions/settings/definitions/sloglintSettings"
+ },
+ "spancheck": {
+ "$ref": "#/definitions/settings/definitions/spancheckSettings"
+ },
+ "staticcheck":{
+ "$ref": "#/definitions/settings/definitions/staticcheckSettings"
+ },
+ "tagalign": {
+ "$ref": "#/definitions/settings/definitions/tagalignSettings"
+ },
+ "tagliatelle": {
+ "$ref": "#/definitions/settings/definitions/tagliatelleSettings"
+ },
+ "testifylint": {
+ "$ref": "#/definitions/settings/definitions/testifylintSettings"
+ },
+ "testpackage": {
+ "$ref": "#/definitions/settings/definitions/testpackageSettings"
+ },
+ "thelper": {
+ "$ref": "#/definitions/settings/definitions/thelperSettings"
+ },
+ "usestdlibvars": {
+ "$ref": "#/definitions/settings/definitions/usestdlibvarsSettings"
+ },
+ "usetesting": {
+ "$ref": "#/definitions/settings/definitions/usetestingSettings"
+ },
+ "unconvert": {
+ "$ref": "#/definitions/settings/definitions/unconvertSettings"
+ },
+ "unparam": {
+ "$ref": "#/definitions/settings/definitions/unparamSettings"
+ },
+ "unqueryvet": {
+ "$ref": "#/definitions/settings/definitions/unqueryvetSettings"
+ },
+ "unused": {
+ "$ref": "#/definitions/settings/definitions/unusedSettings"
+ },
+ "varnamelen": {
+ "$ref": "#/definitions/settings/definitions/varnamelenSettings"
+ },
+ "whitespace": {
+ "$ref": "#/definitions/settings/definitions/whitespaceSettings"
+ },
+ "wrapcheck": {
+ "$ref": "#/definitions/settings/definitions/wrapcheckSettings"
+ },
+ "wsl": {
+ "$ref": "#/definitions/settings/definitions/wslSettings"
+ },
+ "wsl_v5": {
+ "$ref": "#/definitions/settings/definitions/wslSettingsV5"
+ },
+ "copyloopvar": {
+ "$ref": "#/definitions/settings/definitions/copyloopvarSettings"
+ },
+ "custom":{
+ "$ref": "#/definitions/settings/definitions/customSettings"
+ }
+ }
+ },
+ "exclusions":{
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "generated": {
+ "enum": ["strict", "lax", "disable"],
+ "default": "strict"
+ },
+ "warn-unused": {
+ "type": "boolean",
+ "default": false
+ },
+ "presets": {
+ "type": "array",
+ "items": {
+ "enum": [
+ "comments",
+ "std-error-handling",
+ "common-false-positives",
+ "legacy"
+ ]
+ }
+ },
+ "rules": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "properties": {
+ "path": {
+ "type": "string"
+ },
+ "path-except": {
+ "type": "string"
+ },
+ "linters": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/linter-names"
+ }
+ },
+ "text": {
+ "type": "string"
+ },
+ "source": {
+ "type": "string"
+ }
+ },
+ "anyOf": [
+ { "required": ["path"] },
+ { "required": ["path-except"] },
+ { "required": ["linters"] },
+ { "required": ["text"] },
+ { "required": ["source"] }
+ ]
+ }
+ },
+ "paths": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "paths-except": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ }
+ },
+ "formatters": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "enable": {
+ "description": "List of enabled formatters.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/formatter-names"
+ }
+ },
+ "settings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "gci": {
+ "$ref": "#/definitions/settings/definitions/gciSettings"
+ },
+ "gofmt": {
+ "$ref": "#/definitions/settings/definitions/gofmtSettings"
+ },
+ "gofumpt": {
+ "$ref": "#/definitions/settings/definitions/gofumptSettings"
+ },
+ "goimports": {
+ "$ref": "#/definitions/settings/definitions/goimportsSettings"
+ },
+ "golines": {
+ "$ref": "#/definitions/settings/definitions/golinesSettings"
+ }
+ }
+ },
+ "exclusions": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "generated": {
+ "enum": ["strict", "lax", "disable"],
+ "default": "strict"
+ },
+ "paths": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "warn-unused": {
+ "type": "boolean",
+ "default": false
+ }
+ }
+ }
+ }
+ },
+ "issues": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "max-issues-per-linter": {
+ "description": "Maximum issues count per one linter. Set to 0 to disable.",
+ "type": "integer",
+ "default": 50,
+ "minimum": 0
+ },
+ "max-same-issues": {
+ "description": "Maximum count of issues with the same text. Set to 0 to disable.",
+ "type": "integer",
+ "default": 3,
+ "minimum": 0
+ },
+ "new": {
+ "description": "Show only new issues: if there are unstaged changes or untracked files, only those changes are analyzed, else only changes in HEAD~ are analyzed.",
+ "type": "boolean",
+ "default": false
+ },
+ "new-from-merge-base": {
+ "description": "Show only new issues created after the best common ancestor (merge-base against HEAD).",
+ "type": "string"
+ },
+ "new-from-rev": {
+ "description": "Show only new issues created after this git revision.",
+ "type": "string"
+ },
+ "new-from-patch": {
+ "description": "Show only new issues created in git patch with this file path.",
+ "type": "string",
+ "examples": ["path/to/patch/file"]
+ },
+ "fix": {
+ "description": "Apply the fixes detected by the linters and formatters (if it's supported by the linter).",
+ "type": "boolean",
+ "default": false
+ },
+ "uniq-by-line": {
+ "description": "Make issues output unique by line.",
+ "type": "boolean",
+ "default": true
+ },
+ "whole-files": {
+ "description": "Show issues in any part of update files (requires new-from-rev or new-from-patch).",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "severity": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "default": {
+ "description": "Set the default severity for issues. If severity rules are defined and the issues do not match or no severity is provided to the rule this will be the default severity applied. Severities should match the supported severity names of the selected out format.",
+ "type": "string",
+ "default": ""
+ },
+ "rules": {
+ "description": "When a list of severity rules are provided, severity information will be added to lint issues. Severity rules have the same filtering capability as exclude rules except you are allowed to specify one matcher per severity rule.\nOnly affects out formats that support setting severity information.",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "severity": {
+ "type": "string"
+ },
+ "path": {
+ "type": "string"
+ },
+ "path-except": {
+ "type": "string"
+ },
+ "linters": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/linter-names"
+ }
+ },
+ "text": {
+ "type": "string"
+ },
+ "source": {
+ "type": "string"
+ }
+ },
+ "required": ["severity"],
+ "anyOf": [
+ { "required": ["path"] },
+ { "required": ["path-except"] },
+ { "required": ["linters"] },
+ { "required": ["text"] },
+ { "required": ["source"] }
+ ]
+ },
+ "default": []
+ }
+ },
+ "required": ["default"]
+ }
+ }
+}
diff --git a/vendor/github.com/golangci/golangci-lint/v2/jsonschema/golangci.next.jsonschema.json b/vendor/github.com/golangci/golangci-lint/v2/jsonschema/golangci.next.jsonschema.json
new file mode 100644
index 0000000000..4cae3a4b1c
--- /dev/null
+++ b/vendor/github.com/golangci/golangci-lint/v2/jsonschema/golangci.next.jsonschema.json
@@ -0,0 +1,5620 @@
+{
+ "$schema": "http://json-schema.org/draft-07/schema#",
+ "$id": "https://json.schemastore.org/golangci-lint.json",
+ "definitions": {
+ "gocritic-checks": {
+ "enum": [
+ "appendAssign",
+ "appendCombine",
+ "argOrder",
+ "assignOp",
+ "badCall",
+ "badCond",
+ "badLock",
+ "badRegexp",
+ "badSorting",
+ "badSyncOnceFunc",
+ "boolExprSimplify",
+ "builtinShadow",
+ "builtinShadowDecl",
+ "captLocal",
+ "caseOrder",
+ "codegenComment",
+ "commentFormatting",
+ "commentedOutCode",
+ "commentedOutImport",
+ "defaultCaseOrder",
+ "deferInLoop",
+ "deferUnlambda",
+ "deprecatedComment",
+ "docStub",
+ "dupArg",
+ "dupBranchBody",
+ "dupCase",
+ "dupImport",
+ "dupOption",
+ "dupSubExpr",
+ "dynamicFmtString",
+ "elseif",
+ "emptyDecl",
+ "emptyFallthrough",
+ "emptyStringTest",
+ "equalFold",
+ "evalOrder",
+ "exitAfterDefer",
+ "exposedSyncMutex",
+ "externalErrorReassign",
+ "filepathJoin",
+ "flagDeref",
+ "flagName",
+ "hexLiteral",
+ "httpNoBody",
+ "hugeParam",
+ "ifElseChain",
+ "importShadow",
+ "indexAlloc",
+ "initClause",
+ "mapKey",
+ "methodExprCall",
+ "nestingReduce",
+ "newDeref",
+ "nilValReturn",
+ "octalLiteral",
+ "offBy1",
+ "paramTypeCombine",
+ "preferDecodeRune",
+ "preferFilepathJoin",
+ "preferFprint",
+ "preferStringWriter",
+ "preferWriteByte",
+ "ptrToRefParam",
+ "rangeAppendAll",
+ "rangeExprCopy",
+ "rangeValCopy",
+ "redundantSprint",
+ "regexpMust",
+ "regexpPattern",
+ "regexpSimplify",
+ "returnAfterHttpError",
+ "ruleguard",
+ "singleCaseSwitch",
+ "sliceClear",
+ "sloppyLen",
+ "sloppyReassign",
+ "sloppyTypeAssert",
+ "sortSlice",
+ "sprintfQuotedString",
+ "sqlQuery",
+ "stringConcatSimplify",
+ "stringXbytes",
+ "stringsCompare",
+ "switchTrue",
+ "syncMapLoadAndDelete",
+ "timeExprSimplify",
+ "todoCommentWithoutDetail",
+ "tooManyResultsChecker",
+ "truncateCmp",
+ "typeAssertChain",
+ "typeDefFirst",
+ "typeSwitchVar",
+ "typeUnparen",
+ "uncheckedInlineErr",
+ "underef",
+ "unlabelStmt",
+ "unlambda",
+ "unnamedResult",
+ "unnecessaryBlock",
+ "unnecessaryDefer",
+ "unslice",
+ "valSwap",
+ "weakCond",
+ "whyNoLint",
+ "wrapperFunc",
+ "yodaStyleExpr",
+ "zeroByteRepeat"
+ ]
+ },
+ "gocritic-tags": {
+ "enum": [
+ "diagnostic",
+ "style",
+ "performance",
+ "experimental",
+ "opinionated",
+ "security"
+ ]
+ },
+ "staticcheck-checks": {
+ "enum": [
+ "*",
+ "all",
+ "SA*",
+ "-SA*",
+ "SA1*",
+ "-SA1*",
+ "SA1000",
+ "-SA1000",
+ "SA1001",
+ "-SA1001",
+ "SA1002",
+ "-SA1002",
+ "SA1003",
+ "-SA1003",
+ "SA1004",
+ "-SA1004",
+ "SA1005",
+ "-SA1005",
+ "SA1006",
+ "-SA1006",
+ "SA1007",
+ "-SA1007",
+ "SA1008",
+ "-SA1008",
+ "SA1010",
+ "-SA1010",
+ "SA1011",
+ "-SA1011",
+ "SA1012",
+ "-SA1012",
+ "SA1013",
+ "-SA1013",
+ "SA1014",
+ "-SA1014",
+ "SA1015",
+ "-SA1015",
+ "SA1016",
+ "-SA1016",
+ "SA1017",
+ "-SA1017",
+ "SA1018",
+ "-SA1018",
+ "SA1019",
+ "-SA1019",
+ "SA1020",
+ "-SA1020",
+ "SA1021",
+ "-SA1021",
+ "SA1023",
+ "-SA1023",
+ "SA1024",
+ "-SA1024",
+ "SA1025",
+ "-SA1025",
+ "SA1026",
+ "-SA1026",
+ "SA1027",
+ "-SA1027",
+ "SA1028",
+ "-SA1028",
+ "SA1029",
+ "-SA1029",
+ "SA1030",
+ "-SA1030",
+ "SA1031",
+ "-SA1031",
+ "SA1032",
+ "-SA1032",
+ "SA2*",
+ "-SA2*",
+ "SA2000",
+ "-SA2000",
+ "SA2001",
+ "-SA2001",
+ "SA2002",
+ "-SA2002",
+ "SA2003",
+ "-SA2003",
+ "SA3*",
+ "-SA3*",
+ "SA3000",
+ "-SA3000",
+ "SA3001",
+ "-SA3001",
+ "SA4*",
+ "-SA4*",
+ "SA4000",
+ "-SA4000",
+ "SA4001",
+ "-SA4001",
+ "SA4003",
+ "-SA4003",
+ "SA4004",
+ "-SA4004",
+ "SA4005",
+ "-SA4005",
+ "SA4006",
+ "-SA4006",
+ "SA4008",
+ "-SA4008",
+ "SA4009",
+ "-SA4009",
+ "SA4010",
+ "-SA4010",
+ "SA4011",
+ "-SA4011",
+ "SA4012",
+ "-SA4012",
+ "SA4013",
+ "-SA4013",
+ "SA4014",
+ "-SA4014",
+ "SA4015",
+ "-SA4015",
+ "SA4016",
+ "-SA4016",
+ "SA4017",
+ "-SA4017",
+ "SA4018",
+ "-SA4018",
+ "SA4019",
+ "-SA4019",
+ "SA4020",
+ "-SA4020",
+ "SA4021",
+ "-SA4021",
+ "SA4022",
+ "-SA4022",
+ "SA4023",
+ "-SA4023",
+ "SA4024",
+ "-SA4024",
+ "SA4025",
+ "-SA4025",
+ "SA4026",
+ "-SA4026",
+ "SA4027",
+ "-SA4027",
+ "SA4028",
+ "-SA4028",
+ "SA4029",
+ "-SA4029",
+ "SA4030",
+ "-SA4030",
+ "SA4031",
+ "-SA4031",
+ "SA4032",
+ "-SA4032",
+ "SA5*",
+ "-SA5*",
+ "SA5000",
+ "-SA5000",
+ "SA5001",
+ "-SA5001",
+ "SA5002",
+ "-SA5002",
+ "SA5003",
+ "-SA5003",
+ "SA5004",
+ "-SA5004",
+ "SA5005",
+ "-SA5005",
+ "SA5007",
+ "-SA5007",
+ "SA5008",
+ "-SA5008",
+ "SA5009",
+ "-SA5009",
+ "SA5010",
+ "-SA5010",
+ "SA5011",
+ "-SA5011",
+ "SA5012",
+ "-SA5012",
+ "SA6*",
+ "-SA6*",
+ "SA6000",
+ "-SA6000",
+ "SA6001",
+ "-SA6001",
+ "SA6002",
+ "-SA6002",
+ "SA6003",
+ "-SA6003",
+ "SA6005",
+ "-SA6005",
+ "SA6006",
+ "-SA6006",
+ "SA9*",
+ "-SA9*",
+ "SA9001",
+ "-SA9001",
+ "SA9002",
+ "-SA9002",
+ "SA9003",
+ "-SA9003",
+ "SA9004",
+ "-SA9004",
+ "SA9005",
+ "-SA9005",
+ "SA9006",
+ "-SA9006",
+ "SA9007",
+ "-SA9007",
+ "SA9008",
+ "-SA9008",
+ "SA9009",
+ "-SA9009",
+ "ST*",
+ "-ST*",
+ "ST1*",
+ "-ST1*",
+ "ST1000",
+ "-ST1000",
+ "ST1001",
+ "-ST1001",
+ "ST1003",
+ "-ST1003",
+ "ST1005",
+ "-ST1005",
+ "ST1006",
+ "-ST1006",
+ "ST1008",
+ "-ST1008",
+ "ST1011",
+ "-ST1011",
+ "ST1012",
+ "-ST1012",
+ "ST1013",
+ "-ST1013",
+ "ST1015",
+ "-ST1015",
+ "ST1016",
+ "-ST1016",
+ "ST1017",
+ "-ST1017",
+ "ST1018",
+ "-ST1018",
+ "ST1019",
+ "-ST1019",
+ "ST1020",
+ "-ST1020",
+ "ST1021",
+ "-ST1021",
+ "ST1022",
+ "-ST1022",
+ "ST1023",
+ "-ST1023",
+ "S*",
+ "-S*",
+ "S1*",
+ "-S1*",
+ "S1000",
+ "-S1000",
+ "S1001",
+ "-S1001",
+ "S1002",
+ "-S1002",
+ "S1003",
+ "-S1003",
+ "S1004",
+ "-S1004",
+ "S1005",
+ "-S1005",
+ "S1006",
+ "-S1006",
+ "S1007",
+ "-S1007",
+ "S1008",
+ "-S1008",
+ "S1009",
+ "-S1009",
+ "S1010",
+ "-S1010",
+ "S1011",
+ "-S1011",
+ "S1012",
+ "-S1012",
+ "S1016",
+ "-S1016",
+ "S1017",
+ "-S1017",
+ "S1018",
+ "-S1018",
+ "S1019",
+ "-S1019",
+ "S1020",
+ "-S1020",
+ "S1021",
+ "-S1021",
+ "S1023",
+ "-S1023",
+ "S1024",
+ "-S1024",
+ "S1025",
+ "-S1025",
+ "S1028",
+ "-S1028",
+ "S1029",
+ "-S1029",
+ "S1030",
+ "-S1030",
+ "S1031",
+ "-S1031",
+ "S1032",
+ "-S1032",
+ "S1033",
+ "-S1033",
+ "S1034",
+ "-S1034",
+ "S1035",
+ "-S1035",
+ "S1036",
+ "-S1036",
+ "S1037",
+ "-S1037",
+ "S1038",
+ "-S1038",
+ "S1039",
+ "-S1039",
+ "S1040",
+ "-S1040",
+ "QF*",
+ "-QF*",
+ "QF1*",
+ "-QF1*",
+ "QF1001",
+ "-QF1001",
+ "QF1002",
+ "-QF1002",
+ "QF1003",
+ "-QF1003",
+ "QF1004",
+ "-QF1004",
+ "QF1005",
+ "-QF1005",
+ "QF1006",
+ "-QF1006",
+ "QF1007",
+ "-QF1007",
+ "QF1008",
+ "-QF1008",
+ "QF1009",
+ "-QF1009",
+ "QF1010",
+ "-QF1010",
+ "QF1011",
+ "-QF1011",
+ "QF1012",
+ "-QF1012"
+ ]
+ },
+ "godoclint-rules": {
+ "enum": [
+ "pkg-doc",
+ "single-pkg-doc",
+ "require-pkg-doc",
+ "start-with-name",
+ "require-doc",
+ "deprecated",
+ "max-len",
+ "no-unused-link",
+ "require-stdlib-doclink"
+ ]
+ },
+ "gosec-rules": {
+ "enum": [
+ "G101",
+ "G102",
+ "G103",
+ "G104",
+ "G106",
+ "G107",
+ "G108",
+ "G109",
+ "G110",
+ "G111",
+ "G112",
+ "G113",
+ "G114",
+ "G115",
+ "G116",
+ "G117",
+ "G118",
+ "G119",
+ "G120",
+ "G121",
+ "G122",
+ "G123",
+ "G124",
+ "G201",
+ "G202",
+ "G203",
+ "G204",
+ "G301",
+ "G302",
+ "G303",
+ "G304",
+ "G305",
+ "G306",
+ "G307",
+ "G401",
+ "G402",
+ "G403",
+ "G404",
+ "G405",
+ "G406",
+ "G407",
+ "G408",
+ "G501",
+ "G502",
+ "G503",
+ "G504",
+ "G505",
+ "G506",
+ "G507",
+ "G601",
+ "G602",
+ "G701",
+ "G702",
+ "G703",
+ "G704",
+ "G705",
+ "G706",
+ "G707",
+ "G708",
+ "G709",
+ "G710"
+ ]
+ },
+ "govet-analyzers": {
+ "enum": [
+ "appends",
+ "asmdecl",
+ "assign",
+ "atomic",
+ "atomicalign",
+ "bools",
+ "buildtag",
+ "cgocall",
+ "composites",
+ "copylocks",
+ "deepequalerrors",
+ "defers",
+ "directive",
+ "errorsas",
+ "fieldalignment",
+ "findcall",
+ "framepointer",
+ "hostport",
+ "httpmux",
+ "httpresponse",
+ "ifaceassert",
+ "inline",
+ "loopclosure",
+ "lostcancel",
+ "nilfunc",
+ "nilness",
+ "printf",
+ "reflectvaluecompare",
+ "shadow",
+ "shift",
+ "sigchanyzer",
+ "slog",
+ "sortslice",
+ "stdmethods",
+ "stdversion",
+ "stringintconv",
+ "structtag",
+ "testinggoroutine",
+ "tests",
+ "timeformat",
+ "unmarshal",
+ "unreachable",
+ "unsafeptr",
+ "unusedresult",
+ "unusedwrite",
+ "waitgroup"
+ ]
+ },
+ "revive-rules": {
+ "enum": [
+ "add-constant",
+ "argument-limit",
+ "atomic",
+ "banned-characters",
+ "bare-return",
+ "blank-imports",
+ "bool-literal-in-expr",
+ "call-to-gc",
+ "cognitive-complexity",
+ "comment-spacings",
+ "comments-density",
+ "confusing-naming",
+ "confusing-results",
+ "constant-logical-expr",
+ "context-as-argument",
+ "context-keys-type",
+ "cyclomatic",
+ "datarace",
+ "deep-exit",
+ "defer",
+ "dot-imports",
+ "duplicated-imports",
+ "early-return",
+ "empty-block",
+ "empty-lines",
+ "enforce-map-style",
+ "enforce-repeated-arg-type-style",
+ "enforce-slice-style",
+ "enforce-switch-style",
+ "epoch-naming",
+ "error-naming",
+ "error-return",
+ "error-strings",
+ "errorf",
+ "exported",
+ "file-header",
+ "file-length-limit",
+ "filename-format",
+ "flag-parameter",
+ "forbidden-call-in-wg-go",
+ "function-length",
+ "function-result-limit",
+ "get-return",
+ "identical-branches",
+ "identical-ifelseif-branches",
+ "identical-ifelseif-conditions",
+ "identical-switch-branches",
+ "identical-switch-conditions",
+ "if-return",
+ "import-alias-naming",
+ "import-shadowing",
+ "imports-blocklist",
+ "increment-decrement",
+ "indent-error-flow",
+ "inefficient-map-lookup",
+ "line-length-limit",
+ "marshal-receiver",
+ "max-control-nesting",
+ "max-public-structs",
+ "modifies-parameter",
+ "modifies-value-receiver",
+ "multiline-if-init",
+ "nested-structs",
+ "optimize-operands-order",
+ "package-comments",
+ "package-directory-mismatch",
+ "package-naming",
+ "range",
+ "range-val-address",
+ "range-val-in-closure",
+ "receiver-naming",
+ "redefines-builtin-id",
+ "redundant-build-tag",
+ "redundant-import-alias",
+ "redundant-test-main-exit",
+ "string-format",
+ "string-of-int",
+ "struct-tag",
+ "superfluous-else",
+ "time-date",
+ "time-equal",
+ "time-naming",
+ "unchecked-type-assertion",
+ "unconditional-recursion",
+ "unexported-naming",
+ "unexported-return",
+ "unhandled-error",
+ "unnecessary-format",
+ "unnecessary-if",
+ "unnecessary-stmt",
+ "unreachable-code",
+ "unsecure-url-scheme",
+ "unused-parameter",
+ "unused-receiver",
+ "use-any",
+ "use-errors-new",
+ "use-fmt-print",
+ "use-slices-concat",
+ "use-slices-sort",
+ "use-waitgroup-go",
+ "useless-break",
+ "useless-fallthrough",
+ "var-declaration",
+ "var-naming",
+ "waitgroup-by-value"
+ ]
+ },
+ "iface-analyzers": {
+ "enum": [
+ "identical",
+ "unused",
+ "opaque",
+ "unexported",
+ "unusedmethod"
+ ]
+ },
+ "tagliatelle-cases": {
+ "enum": [
+ "",
+ "camel",
+ "pascal",
+ "kebab",
+ "snake",
+ "goCamel",
+ "goPascal",
+ "goKebab",
+ "goSnake",
+ "upper",
+ "upperSnake",
+ "lower",
+ "header"
+ ]
+ },
+ "modernize-analyzers": {
+ "enum": [
+ "any",
+ "atomictypes",
+ "embedlit",
+ "errorsastype",
+ "forvar",
+ "importcomment",
+ "mapsloop",
+ "minmax",
+ "newexpr",
+ "omitzero",
+ "plusbuild",
+ "rangeint",
+ "reflecttypeassert",
+ "reflecttypefor",
+ "slicesbackward",
+ "slicesclip",
+ "slicescontains",
+ "slicessort",
+ "stditerators",
+ "stringscut",
+ "stringscutprefix",
+ "stringsseq",
+ "stringsbuilder",
+ "testingcontext",
+ "unsafefuncs",
+ "waitgroupgo"
+ ]
+ },
+ "wsl-checks": {
+ "enum": [
+ "after-block",
+ "after-decl",
+ "after-defer",
+ "after-expr",
+ "after-go",
+ "append",
+ "assign-exclusive",
+ "assign-expr",
+ "assign",
+ "branch",
+ "cuddle-group",
+ "decl",
+ "defer",
+ "err",
+ "expr",
+ "for",
+ "go",
+ "if",
+ "inc-dec",
+ "label",
+ "leading-whitespace",
+ "range",
+ "return",
+ "select",
+ "send",
+ "switch",
+ "trailing-whitespace",
+ "type-switch"
+ ]
+ },
+ "relative-path-modes": {
+ "enum": [
+ "gomod",
+ "gitroot",
+ "cfg",
+ "wd"
+ ]
+ },
+ "simple-format": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "path": {
+ "$ref": "#/definitions/formats-path",
+ "default": "stdout"
+ }
+ }
+ },
+ "formats-path" : {
+ "anyOf": [
+ {
+ "enum": [
+ "stdout",
+ "stderr"
+ ]
+ },
+ {
+ "type": "string"
+ }
+ ]
+ },
+ "linter-names": {
+ "$comment": "anyOf with enum is used to allow auto-completion of non-custom linters",
+ "description": "Usable linter names.",
+ "anyOf": [
+ {
+ "enum": [
+ "arangolint",
+ "asasalint",
+ "asciicheck",
+ "bidichk",
+ "bodyclose",
+ "canonicalheader",
+ "clickhouselint",
+ "containedctx",
+ "contextcheck",
+ "copyloopvar",
+ "cyclop",
+ "decorder",
+ "depguard",
+ "dogsled",
+ "dupl",
+ "dupword",
+ "durationcheck",
+ "embeddedstructfieldcheck",
+ "errcheck",
+ "errchkjson",
+ "errname",
+ "errorlint",
+ "exhaustive",
+ "exhaustruct",
+ "exhaustruct_v5",
+ "exptostd",
+ "fatcontext",
+ "forbidigo",
+ "forcetypeassert",
+ "funcorder",
+ "funlen",
+ "ginkgolinter",
+ "gocheckcompilerdirectives",
+ "gochecknoglobals",
+ "gochecknoinits",
+ "gochecksumtype",
+ "gocognit",
+ "goconst",
+ "gocritic",
+ "gocyclo",
+ "godoclint",
+ "godot",
+ "godox",
+ "err113",
+ "goheader",
+ "gomoddirectives",
+ "gomodguard",
+ "gomodguard_v2",
+ "goprintffuncname",
+ "gosec",
+ "gosimple",
+ "gosmopolitan",
+ "govet",
+ "grouper",
+ "iface",
+ "importas",
+ "inamedparam",
+ "ineffassign",
+ "interfacebloat",
+ "intrange",
+ "iotamixing",
+ "ireturn",
+ "lll",
+ "loggercheck",
+ "maintidx",
+ "makezero",
+ "mirror",
+ "misspell",
+ "mnd",
+ "modernize",
+ "musttag",
+ "nakedret",
+ "nestif",
+ "nilerr",
+ "nilnesserr",
+ "nilnil",
+ "nlreturn",
+ "noctx",
+ "noinlineerr",
+ "nolintlint",
+ "nonamedreturns",
+ "nosprintfhostport",
+ "paralleltest",
+ "perfsprint",
+ "prealloc",
+ "predeclared",
+ "promlinter",
+ "protogetter",
+ "reassign",
+ "recvcheck",
+ "revive",
+ "rowserrcheck",
+ "sloglint",
+ "sqlclosecheck",
+ "staticcheck",
+ "stylecheck",
+ "tagalign",
+ "tagliatelle",
+ "testableexamples",
+ "testifylint",
+ "testpackage",
+ "thelper",
+ "tparallel",
+ "unconvert",
+ "unparam",
+ "unused",
+ "usestdlibvars",
+ "usetesting",
+ "varnamelen",
+ "wastedassign",
+ "whitespace",
+ "wrapcheck",
+ "wsl",
+ "wsl_v5",
+ "zerologlint"
+ ]
+ },
+ {
+ "type": "string"
+ }
+ ]
+ },
+ "formatter-names": {
+ "description": "Usable formatter names.",
+ "enum": [
+ "gci",
+ "gofmt",
+ "gofumpt",
+ "goimports",
+ "golines",
+ "swaggo"
+ ]
+ },
+ "settings": {
+ "definitions": {
+ "dupwordSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "keywords": {
+ "description": "Keywords for detecting duplicate words. If this list is not empty, only the words defined in this list will be detected.",
+ "type": "array",
+ "uniqueItems": true,
+ "items": {
+ "type": "string",
+ "examples": ["the", "and", "a"]
+ }
+ },
+ "ignore": {
+ "description": "Keywords used to ignore detection.",
+ "type": "array",
+ "uniqueItems": true,
+ "items": {
+ "type": "string",
+ "examples": ["0C0C"]
+ }
+ },
+ "comments-only": {
+ "description": "Checks only comments, skip strings.",
+ "type": "boolean",
+ "default": false
+ },
+ "skip-raw-strings": {
+ "description": "Skip raw string literals (backtick-delimited) from duplicate word checking.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "asasalintSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "exclude": {
+ "description": "To specify a set of function names to exclude.",
+ "type": "array",
+ "uniqueItems": true,
+ "items": {
+ "type": "string",
+ "examples": ["\\.Wrapf"]
+ }
+ },
+ "use-builtin-exclusions": {
+ "description": "To enable/disable the asasalint builtin exclusions of function names.",
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "bidichkSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "left-to-right-embedding": {
+ "description": "Disallow: LEFT-TO-RIGHT-EMBEDDING",
+ "type": "boolean",
+ "default": false
+ },
+ "right-to-left-embedding": {
+ "description": "Disallow: RIGHT-TO-LEFT-EMBEDDING",
+ "type": "boolean",
+ "default": false
+ },
+ "pop-directional-formatting": {
+ "description": "Disallow: POP-DIRECTIONAL-FORMATTING",
+ "type": "boolean",
+ "default": false
+ },
+ "left-to-right-override": {
+ "description": "Disallow: LEFT-TO-RIGHT-OVERRIDE",
+ "type": "boolean",
+ "default": false
+ },
+ "right-to-left-override": {
+ "description": "Disallow: RIGHT-TO-LEFT-OVERRIDE",
+ "type": "boolean",
+ "default": false
+ },
+ "left-to-right-isolate": {
+ "description": "Disallow: LEFT-TO-RIGHT-ISOLATE",
+ "type": "boolean",
+ "default": false
+ },
+ "right-to-left-isolate": {
+ "description": "Disallow: RIGHT-TO-LEFT-ISOLATE",
+ "type": "boolean",
+ "default": false
+ },
+ "first-strong-isolate": {
+ "description": "Disallow: FIRST-STRONG-ISOLATE",
+ "type": "boolean",
+ "default": false
+ },
+ "pop-directional-isolate": {
+ "description": "Disallow: POP-DIRECTIONAL-ISOLATE",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "bodycloseSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "check-consumption": {
+ "description": "Check that the response body is consumed.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "canonicalheaderSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "use-default-exclusions": {
+ "type": "boolean",
+ "default": true
+ },
+ "exclusions": {
+ "additionalProperties": false,
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "cyclopSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "max-complexity": {
+ "description": "Max complexity the function can have",
+ "type": "integer",
+ "default": 10,
+ "minimum": 0
+ },
+ "package-average": {
+ "description": "Max average complexity in package",
+ "type": "number",
+ "default": 0,
+ "minimum": 0
+ }
+ }
+ },
+ "decorderSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "dec-order": {
+ "type": "array",
+ "default": [["type", "const", "var", "func"]],
+ "items": {
+ "enum": ["type", "const", "var", "func"]
+ }
+ },
+ "ignore-underscore-vars": {
+ "description": "Underscore vars (vars with \"_\" as the name) will be ignored at all checks",
+ "default": true,
+ "type": "boolean"
+ },
+ "disable-dec-order-check": {
+ "description": "Order of declarations is not checked",
+ "default": true,
+ "type": "boolean"
+ },
+ "disable-init-func-first-check": {
+ "description": "Allow init func to be anywhere in file",
+ "default": true,
+ "type": "boolean"
+ },
+ "disable-dec-num-check": {
+ "description": "Multiple global type, const and var declarations are allowed",
+ "default": true,
+ "type": "boolean"
+ },
+ "disable-type-dec-num-check": {
+ "description": "Type declarations will be ignored for dec num check",
+ "default": true,
+ "type": "boolean"
+ },
+ "disable-const-dec-num-check": {
+ "description": "Const declarations will be ignored for dec num check",
+ "default": true,
+ "type": "boolean"
+ },
+ "disable-var-dec-num-check": {
+ "description": "Var declarations will be ignored for dec num check",
+ "default": true,
+ "type": "boolean"
+ }
+ }
+ },
+ "depguardSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "rules": {
+ "description": "Rules to apply.",
+ "type": "object",
+ "additionalProperties": false,
+ "patternProperties": {
+ "^[^.]+$": {
+ "description": "Name of a rule.",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "list-mode": {
+ "description": "Used to determine the package matching priority.",
+ "enum": ["original", "strict", "lax"],
+ "default": "original"
+ },
+ "files": {
+ "description": "List of file globs that will match this list of settings to compare against.",
+ "additionalProperties": false,
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "allow": {
+ "description": "List of allowed packages.",
+ "additionalProperties": false,
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "deny": {
+ "description": "Packages that are not allowed where the value is a suggestion.",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "desc": {
+ "description": "Description",
+ "type": "string"
+ },
+ "pkg": {
+ "description": "Package",
+ "type": "string"
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "dogsledSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "max-blank-identifiers": {
+ "description": "Check assignments with too many blank identifiers.",
+ "type": "integer",
+ "default": 2,
+ "minimum": 0
+ }
+ }
+ },
+ "duplSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "threshold": {
+ "description": "Tokens count to trigger issue.",
+ "type": "integer",
+ "default": 150,
+ "minimum": 0
+ }
+ }
+ },
+ "embeddedstructfieldcheckSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "empty-line": {
+ "description": "Checks that there is an empty space between the embedded fields and regular fields.",
+ "type": "boolean",
+ "default": false
+ },
+ "forbid-mutex": {
+ "description": "Checks that sync.Mutex and sync.RWMutex are not used as embedded fields.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "errcheckSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "check-type-assertions": {
+ "description": "Report about not checking errors in type assertions, i.e.: `a := b.(MyStruct)`",
+ "type": "boolean",
+ "default": false
+ },
+ "check-blank": {
+ "description": "Report about assignment of errors to blank identifier",
+ "type": "boolean",
+ "default": false
+ },
+ "exclude-functions": {
+ "description": "List of functions to exclude from checking, where each entry is a single function to exclude",
+ "type": "array",
+ "examples": ["io/ioutil.ReadFile", "io.Copy(*bytes.Buffer)"],
+ "items": {
+ "type": "string"
+ }
+ },
+ "disable-default-exclusions": {
+ "description": "To disable the errcheck built-in exclude list",
+ "type": "boolean",
+ "default": false
+ },
+ "verbose": {
+ "description": "Display function signature instead of selector",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "errchkjsonSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "check-error-free-encoding": {
+ "type": "boolean",
+ "default": false
+ },
+ "report-no-exported": {
+ "description": "Issue on struct that doesn't have exported fields.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "errorlintSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "errorf": {
+ "description": "Check whether fmt.Errorf uses the %w verb for formatting errors",
+ "type": "boolean",
+ "default": true
+ },
+ "errorf-multi": {
+ "description": "Permit more than 1 %w verb, valid per Go 1.20",
+ "type": "boolean",
+ "default": true
+ },
+ "asserts": {
+ "description": "Check for plain type assertions and type switches.",
+ "type": "boolean",
+ "default": true
+ },
+ "comparison": {
+ "description": "Check for plain error comparisons",
+ "type": "boolean",
+ "default": true
+ },
+ "allowed-errors": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "err": {
+ "type": "string"
+ },
+ "fun": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "allowed-errors-wildcard": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "err": {
+ "type": "string"
+ },
+ "fun": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ }
+ },
+ "exhaustiveSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "check": {
+ "description": "Specify the syntax tree elements that the analysis should check.",
+ "type": "array",
+ "uniqueItems": true,
+ "items": {
+ "enum": ["switch", "mapliteral", "typeswitch"]
+ }
+ },
+ "explicit-exhaustive": {
+ "description": "Check only if it has '//exhaustive:enforce' comment.",
+ "type": "boolean",
+ "default": false
+ },
+ "default-case-required": {
+ "description": "Switch statement requires default case even if exhaustive.",
+ "type": "boolean",
+ "default": false
+ },
+ "default-signifies-exhaustive": {
+ "description": "Presence of `default` case in switch statements satisfies exhaustiveness, even if all enum members are not listed.",
+ "type": "boolean",
+ "default": false
+ },
+ "ignore-constants": {
+ "description": "Constant names matched by `regexp` do not have to be included in case expressions.",
+ "type": "array",
+ "uniqueItems": true,
+ "items": {
+ "type": "string"
+ }
+ },
+ "ignore-types": {
+ "description": "Switch statements in which the type name is matched by `regexp` are not checked.",
+ "type": "array",
+ "uniqueItems": true,
+ "items": {
+ "type": "string"
+ }
+ },
+ "only-types": {
+ "description": "Only switch statements in which the type name is matched by `regexp` are checked.",
+ "type": "array",
+ "uniqueItems": true,
+ "items": {
+ "type": "string"
+ }
+ },
+ "package-scope-only": {
+ "description": "Consider enums only in package scopes, not in inner scopes.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "exhaustructSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "include": {
+ "description": "List of regular expressions to match struct packages and names.",
+ "type": "array",
+ "examples": [".*\\.Test"],
+ "items": {
+ "type": "string"
+ }
+ },
+ "exclude": {
+ "description": "List of regular expressions to exclude struct packages and names from check.",
+ "type": "array",
+ "examples": ["cobra\\.Command$"],
+ "items": {
+ "type": "string"
+ }
+ },
+ "allow-empty": {
+ "description": "Allows empty structures, effectively excluding them from the check.",
+ "type": "boolean",
+ "default": false
+ },
+ "allow-empty-rx": {
+ "description": "List of regular expressions to match type names that should be allowed to be empty.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "allow-empty-returns": {
+ "description": "Allows empty structures in return statements.",
+ "type": "boolean",
+ "default": false
+ },
+ "allow-empty-declarations": {
+ "description": "Allows empty structures in variable declarations.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "exhaustructv5Settings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "enforce-patterns": {
+ "description": "List of regular expressions to match type names that should be checked.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ignore-patterns":{
+ "description": "List of regular expressions to match type names that should be skipped from checking.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "optional-patterns": {
+ "description": "List of regular expressions to match type names where all fields are treated as optional.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "allow-empty":{
+ "description": "Allows empty structures, effectively excluding them from the check.",
+ "type": "boolean",
+ "default": false
+ },
+ "allow-empty-patterns": {
+ "description": "List of regular expressions to match type names that should be allowed to be empty.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "allow-empty-returns": {
+ "description": "Allows empty structures in return statements.",
+ "type": "boolean",
+ "default": false
+ },
+ "allow-empty-declarations": {
+ "description": "Allows empty structures in variable declarations.",
+ "type": "boolean",
+ "default": false
+ },
+ "allow-empty-blank-assignments": {
+ "description": "Allow empty literals the blank identifier receives.",
+ "type": "boolean",
+ "default": false
+ },
+ "explicit-mode":{
+ "description": "When true, only types marked with //exhaustruct:enforce directive or matching enforce-rx patterns are checked.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "fatcontextSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "check-struct-pointers": {
+ "description": "Check for potential fat contexts in struct pointers.",
+ "type": "boolean",
+ "default": false
+ },
+ "check-loops": {
+ "description": "Disable detection of fat contexts in function literals.",
+ "type": "boolean",
+ "default": true
+ },
+ "check-function-literals": {
+ "description": "Disable detection of fat contexts in function literals.",
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "forbidigoSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "exclude-godoc-examples": {
+ "description": "Exclude code in godoc examples.",
+ "type": "boolean",
+ "default": true
+ },
+ "analyze-types": {
+ "description": "Instead of matching the literal source code, use type information to replace expressions with strings that contain the package name and (for methods and fields) the type name.",
+ "type": "boolean",
+ "default": true
+ },
+ "forbid": {
+ "description": "List of identifiers to forbid (written using `regexp`)",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "pattern": {
+ "description": "Pattern",
+ "type": "string"
+ },
+ "pkg": {
+ "description": "Package",
+ "type": "string"
+ },
+ "msg": {
+ "description": "Message",
+ "type": "string"
+ }
+ }
+ }
+ }
+ }
+ },
+ "funcorderSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "constructor": {
+ "description": "Checks that constructors are placed after the structure declaration.",
+ "type": "boolean",
+ "default": true
+ },
+ "struct-method": {
+ "description": "Checks if the exported methods of a structure are placed before the non-exported ones.",
+ "type": "boolean",
+ "default": true
+ },
+ "alphabetical": {
+ "description": "Checks if the constructors and/or structure methods are sorted alphabetically.",
+ "type": "boolean",
+ "default": false
+ },
+ "function": {
+ "description": "Checks that exported functions are placed before unexported functions.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "funlenSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "lines": {
+ "description": "Limit lines number per function.",
+ "type": "integer",
+ "default": 60
+ },
+ "statements": {
+ "description": "Limit statements number per function.",
+ "type": "integer",
+ "default": 40
+ },
+ "ignore-comments": {
+ "description": "Ignore comments when counting lines.",
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "gciSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "sections": {
+ "description": "Section configuration to compare against.",
+ "type": "array",
+ "items": {
+ "anyOf": [
+ {
+ "enum": [
+ "standard",
+ "default",
+ "blank",
+ "dot",
+ "alias",
+ "localmodule"
+ ]
+ },
+ {
+ "type": "string"
+ }
+ ]
+ },
+ "default": ["standard", "default"]
+ },
+ "no-inline-comments": {
+ "description": "Checks that no inline Comments are present.",
+ "type": "boolean",
+ "default": false
+ },
+ "no-prefix-comments": {
+ "description": "Checks that no prefix Comments(comment lines above an import) are present.",
+ "type": "boolean",
+ "default": false
+ },
+ "custom-order": {
+ "description": "Enable custom order of sections.",
+ "type": "boolean",
+ "default": false
+ },
+ "no-lex-order": {
+ "description": "Drops lexical ordering for custom sections.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "ginkgolinterSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "suppress-len-assertion": {
+ "description": "Suppress the wrong length assertion warning.",
+ "type": "boolean",
+ "default": false
+ },
+ "suppress-nil-assertion": {
+ "description": "Suppress the wrong nil assertion warning.",
+ "type": "boolean",
+ "default": false
+ },
+ "suppress-err-assertion": {
+ "description": "Suppress the wrong error assertion warning.",
+ "type": "boolean",
+ "default": false
+ },
+ "suppress-compare-assertion": {
+ "description": "Suppress the wrong comparison assertion warning.",
+ "type": "boolean",
+ "default": false
+ },
+ "suppress-async-assertion": {
+ "description": "Suppress the function all in async assertion warning.",
+ "type": "boolean",
+ "default": false
+ },
+ "suppress-type-compare-assertion": {
+ "description": "Suppress warning for comparing values from different types, like int32 and uint32.",
+ "type": "boolean",
+ "default": false
+ },
+ "forbid-focus-container": {
+ "description": "Trigger warning for ginkgo focus containers like FDescribe, FContext, FWhen or FIt.",
+ "type": "boolean",
+ "default": false
+ },
+ "allow-havelen-zero": {
+ "description": "Don't trigger warnings for HaveLen(0).",
+ "type": "boolean",
+ "default": false
+ },
+ "force-expect-to": {
+ "description": "Force using `Expect` with `To`, `ToNot` or `NotTo`",
+ "type": "boolean",
+ "default": false
+ },
+ "validate-async-intervals": {
+ "description": "Best effort validation of async intervals (timeout and polling).",
+ "type": "boolean",
+ "default": false
+ },
+ "forbid-spec-pollution": {
+ "description": "Trigger a warning for variable assignments in ginkgo containers like `Describe`, `Context` and `When`, instead of in `BeforeEach()`.",
+ "type": "boolean",
+ "default": false
+ },
+ "force-succeed": {
+ "description": "Force using the Succeed matcher for error functions, and the HaveOccurred matcher for non-function error values.",
+ "type": "boolean",
+ "default": false
+ },
+ "force-assertion-description": {
+ "description": "Force adding assertion descriptions to gomega matchers.",
+ "type": "boolean",
+ "default": false
+ },
+ "force-tonot": {
+ "description": "Force using `ToNot`, `ShouldNot` instead of `To(Not())`.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "gochecksumtypeSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "default-signifies-exhaustive": {
+ "description": "Presence of `default` case in switch statements satisfies exhaustiveness, if all members are not listed.",
+ "type": "boolean",
+ "default": true
+ },
+ "include-shared-interfaces": {
+ "description": "Include shared interfaces in the exhaustiviness check.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "gocognitSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "min-complexity": {
+ "description": "Minimal code complexity to report (we recommend 10-20).",
+ "type": "integer",
+ "default": 30
+ }
+ }
+ },
+ "goconstSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "match-constant": {
+ "description": "Look for existing constants matching the values",
+ "type": "boolean",
+ "default": true
+ },
+ "min-len": {
+ "description": "Minimum length of string constant.",
+ "type": "integer",
+ "default": 3
+ },
+ "min-occurrences": {
+ "description": "Minimum occurrences count to trigger.",
+ "type": "integer",
+ "default": 3
+ },
+ "exclude-types": {
+ "type": "array",
+ "items": {
+ "enum": [
+ "Assignment",
+ "Binary",
+ "Case",
+ "Return",
+ "Call",
+ "CompositeLit"
+ ]
+ }
+ },
+ "ignore-calls": {
+ "description": "Ignore when constant is not used as function argument",
+ "type": "boolean",
+ "default": true
+ },
+ "ignore-string-values": {
+ "description": "Exclude strings matching the given regular expression",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "numbers": {
+ "description": "Search also for duplicated numbers.",
+ "type": "boolean",
+ "default": false
+ },
+ "min": {
+ "description": "Minimum value, only works with `numbers`",
+ "type": "integer",
+ "default": 3
+ },
+ "max": {
+ "description": "Maximum value, only works with `numbers`",
+ "type": "integer",
+ "default": 3
+ },
+ "find-duplicates": {
+ "description": "Detects constants with identical values",
+ "type": "boolean",
+ "default": false
+ },
+ "eval-const-expressions": {
+ "description": "Evaluates of constant expressions like Prefix + \"suffix\"",
+ "type": "boolean",
+ "default": false
+ },
+ "ignore-tests": {
+ "description": "Ignore strings from test files",
+ "type": "boolean",
+ "default": false
+ },
+ "ignore-functions": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ignore-map-keys": {
+ "description": "Ignore string literals used as map keys",
+ "type": "boolean"
+ }
+ }
+ },
+ "gocriticSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "enabled-checks": {
+ "description": "Which checks should be enabled. By default, a list of stable checks is used. To see it, run `GL_DEBUG=gocritic golangci-lint run`.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/gocritic-checks"
+ }
+ },
+ "disabled-checks": {
+ "description": "Which checks should be disabled.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/gocritic-checks"
+ },
+ "default": []
+ },
+ "enabled-tags": {
+ "description": "Enable multiple checks by tags, run `GL_DEBUG=gocritic golangci-lint run` to see all tags and checks.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/gocritic-tags"
+ }
+ },
+ "disabled-tags": {
+ "description": "Disable multiple checks by tags, run `GL_DEBUG=gocritic golangci-lint run` to see all tags and checks.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/gocritic-tags"
+ }
+ },
+ "settings": {
+ "description": "Settings passed to gocritic. Properties must be valid and enabled check names.",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "captLocal": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "paramsOnly" : {
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "commentedOutCode": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "minLength" : {
+ "type": "number",
+ "default": 15
+ }
+ }
+ },
+ "elseif": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "skipBalanced" : {
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "hugeParam": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "sizeThreshold" : {
+ "type": "number",
+ "default": 80
+ }
+ }
+ },
+ "ifElseChain": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "minThreshold" : {
+ "type": "number",
+ "default": 2
+ }
+ }
+ },
+ "nestingReduce": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "bodyWidth" : {
+ "type": "number",
+ "default": 5
+ }
+ }
+ },
+ "rangeExprCopy": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "sizeThreshold" : {
+ "type": "number",
+ "default": 512
+ },
+ "skipTestFuncs" : {
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "rangeValCopy": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "sizeThreshold" : {
+ "type": "number",
+ "default": 128
+ },
+ "skipTestFuncs" : {
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "ruleguard": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "debug" : {
+ "type": "string"
+ },
+ "enable" : {
+ "type": "string"
+ },
+ "disable" : {
+ "type": "string"
+ },
+ "failOn" : {
+ "type": "string"
+ },
+ "rules" : {
+ "type": "string"
+ }
+ }
+ },
+ "tooManyResultsChecker": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "maxResults" : {
+ "type": "number",
+ "default": 5
+ }
+ }
+ },
+ "truncateCmp": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "skipArchDependent" : {
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "underef": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "skipRecvDeref" : {
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "unnamedResult": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "checkExported" : {
+ "type": "boolean",
+ "default": false
+ }
+ }
+ }
+ }
+ },
+ "disable-all": {
+ "type": "boolean",
+ "default": false
+ },
+ "enable-all": {
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "gocycloSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "min-complexity": {
+ "description": "Minimum code complexity to report (we recommend 10-20).",
+ "type": "integer",
+ "default": 30
+ }
+ }
+ },
+ "godoclintSettings": {
+ "type": "object",
+ "properties": {
+ "default": {
+ "type": "string",
+ "enum": ["all", "basic", "none"],
+ "default": "basic",
+ "description": "Default set of rules to enable."
+ },
+ "enable": {
+ "description": "List of rules to enable in addition to the default set.",
+ "type": "array",
+ "uniqueItems": true,
+ "items": {
+ "$ref": "#/definitions/godoclint-rules"
+ }
+ },
+ "disable": {
+ "description": "List of rules to disable.",
+ "type": "array",
+ "uniqueItems": true,
+ "items": {
+ "$ref": "#/definitions/godoclint-rules"
+ }
+ },
+ "options": {
+ "type": "object",
+ "description": "A map for setting individual rule options.",
+ "properties": {
+ "max-len": {
+ "type": "object",
+ "properties": {
+ "length": {
+ "type": "integer",
+ "description": "Maximum line length for godocs, not including the `//`, `/*` or `*/` tokens.",
+ "default": 77
+ }
+ }
+ },
+ "require-doc": {
+ "type": "object",
+ "properties": {
+ "ignore-exported": {
+ "type": "boolean",
+ "description": "Ignore exported (public) symbols when applying the `require-doc` rule.",
+ "default": false
+ },
+ "ignore-unexported": {
+ "type": "boolean",
+ "description": "Ignore unexported (private) symbols when applying the `require-doc` rule.",
+ "default": true
+ }
+ }
+ },
+ "start-with-name": {
+ "type": "object",
+ "properties": {
+ "include-unexported": {
+ "type": "boolean",
+ "description": "Include unexported symbols when applying the `start-with-name` rule.",
+ "default": false
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "godotSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "scope": {
+ "description": "Comments to be checked.",
+ "enum": ["declarations", "toplevel", "all", "noinline"],
+ "default": "declarations"
+ },
+ "exclude": {
+ "description": "List of regexps for excluding particular comment lines from check.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "period": {
+ "description": "Check that each sentence ends with a period.",
+ "type": "boolean",
+ "default": true
+ },
+ "capital": {
+ "description": "Check that each sentence starts with a capital letter.",
+ "type": "boolean",
+ "default": false
+ },
+ "check-all": {
+ "description": "DEPRECATED: Check all top-level comments, not only declarations.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "godoxSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "keywords": {
+ "description": "Report any comments starting with one of these keywords. This is useful for TODO or FIXME comments that might be left in the code accidentally and should be resolved before merging.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "default": ["TODO", "BUG", "FIXME"]
+ }
+ }
+ },
+ "gofmtSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "simplify": {
+ "description": "Simplify code.",
+ "type": "boolean",
+ "default": true
+ },
+ "rewrite-rules": {
+ "description": "Apply the rewrite rules to the source before reformatting.",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "pattern": {
+ "type": "string"
+ },
+ "replacement": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ }
+ },
+ "golinesSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "max-len": {
+ "type": "integer",
+ "default": 100
+ },
+ "tab-len": {
+ "type": "integer",
+ "default": 4
+ },
+ "shorten-comments": {
+ "type": "boolean",
+ "default": false
+ },
+ "reformat-tags": {
+ "type": "boolean",
+ "default": true
+ },
+ "chain-split-dots": {
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "interfacebloatSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "max": {
+ "description": "The maximum number of methods allowed for an interface.",
+ "type": "integer"
+ }
+ }
+ },
+ "gofumptSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "extra-rules": {
+ "description": "Choose whether or not to use the extra rules that are disabled by default.",
+ "type": "boolean",
+ "default": false
+ },
+ "module-path": {
+ "description": " Module path which contains the source code being formatted.",
+ "type": "string"
+ },
+ "extra": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "group-params": {
+ "type": "boolean",
+ "default": false
+ },
+ "clothe-returns": {
+ "type": "boolean",
+ "default": false
+ },
+ "balance-calls": {
+ "type": "boolean",
+ "default": false
+ }
+ }
+ }
+ }
+ },
+ "goheaderSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "values": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "const": {
+ "description": "Constants to use in the template.",
+ "type": "object",
+ "patternProperties": {
+ "^.+$": {
+ "description": "Value for the constant.",
+ "type": "string"
+ }
+ },
+ "additionalProperties": false,
+ "examples": [
+ {
+ "YEAR": "2030",
+ "COMPANY": "MY FUTURISTIC COMPANY"
+ }
+ ]
+ },
+ "regexp": {
+ "description": "Regular expressions to use in your template.",
+ "type": "object",
+ "additionalProperties": false,
+ "patternProperties": {
+ "^.+$": {
+ "type": "string"
+ }
+ },
+ "examples": [
+ {
+ "AUTHOR": ".*@mycompany\\.com"
+ }
+ ]
+ }
+ }
+ },
+ "template": {
+ "description": "Template to put on top of every file.",
+ "type": "string",
+ "examples": [
+ "{{ MY COMPANY }}\nSPDX-License-Identifier: Apache-2.0\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at:\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License."
+ ]
+ },
+ "template-path": {
+ "description": "Path to the file containing the template source.",
+ "type": "string",
+ "examples": ["my_header_template.txt"]
+ }
+ },
+ "oneOf": [
+ { "required": ["template"] },
+ { "required": ["template-path"] }
+ ]
+ },
+ "goimportsSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "local-prefixes": {
+ "description": "Put imports beginning with prefix after 3rd-party packages. It is a list of prefixes.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "gomoddirectivesSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "replace-local": {
+ "description": "Allow local `replace` directives.",
+ "type": "boolean",
+ "default": true
+ },
+ "replace-allow-list": {
+ "description": "List of allowed `replace` directives.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "replace-allow-all": {
+ "description": "Allow all `replace` directives.",
+ "type": "boolean",
+ "default": false
+ },
+ "retract-allow-no-explanation": {
+ "description": "Allow to not explain why the version has been retracted in the `retract` directives.",
+ "type": "boolean",
+ "default": false
+ },
+ "exclude-forbidden": {
+ "description": "Forbid the use of the `exclude` directives.",
+ "type": "boolean",
+ "default": false
+ },
+ "ignore-forbidden": {
+ "description": "Forbid the use of the `ignore` directives. (>= go1.25)",
+ "type": "boolean",
+ "default": false
+ },
+ "toolchain-forbidden": {
+ "description": "Forbid the use of the `toolchain` directive.",
+ "type": "boolean",
+ "default": false
+ },
+ "toolchain-pattern": {
+ "description": "Defines a pattern to validate `toolchain` directive.",
+ "type": "string"
+ },
+ "tool-forbidden": {
+ "description": "Forbid the use of the `tool` directives.",
+ "type": "boolean",
+ "default": false
+ },
+ "go-debug-forbidden": {
+ "description": "Forbid the use of the `godebug` directive.",
+ "type": "boolean",
+ "default": false
+ },
+ "go-version-pattern": {
+ "description": "Defines a pattern to validate `go` minimum version directive.",
+ "type": "string",
+ "default": ""
+ },
+ "check-module-path": {
+ "description": "Check the validity of the module path.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "gomodguardv2Settings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "local-replace-directives": {
+ "type": "boolean"
+ },
+ "allowed": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "required": ["module"],
+ "properties": {
+ "module": {
+ "type": "string"
+ },
+ "version": {
+ "type": "string"
+ },
+ "match-type": {
+ "enum": ["", "exact", "prefix", "regex"],
+ "default": "exact"
+ }
+ }
+ }
+ },
+ "blocked": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "required": ["module"],
+ "properties": {
+ "module": {
+ "type": "string"
+ },
+ "version": {
+ "type": "string"
+ },
+ "match-type": {
+ "type": "string"
+ },
+ "reason": {
+ "type": "string"
+ },
+ "recommendations": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "gomodguardSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "allowed": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "modules": {
+ "description": "List of allowed modules.",
+ "type": "array",
+ "items": {
+ "type": "string",
+ "examples": ["gopkg.in/yaml.v2"]
+ }
+ },
+ "domains": {
+ "description": "List of allowed module domains.",
+ "type": "array",
+ "items": {
+ "type": "string",
+ "examples": ["golang.org"]
+ }
+ }
+ }
+ },
+ "blocked": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "modules": {
+ "description": "List of blocked modules.",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "patternProperties": {
+ "^.+$": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "recommendations": {
+ "description": "Recommended modules that should be used instead.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "reason": {
+ "description": "Reason why the recommended module should be used.",
+ "type": "string"
+ }
+ }
+ }
+ },
+ "additionalProperties": false
+ }
+ },
+ "versions": {
+ "description": "List of blocked module version constraints.",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "patternProperties": {
+ "^.*$": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "version": {
+ "description": "Version constraint.",
+ "type": "string"
+ },
+ "reason": {
+ "description": "Reason why the version constraint exists.",
+ "type": "string"
+ }
+ },
+ "required": ["reason"]
+ }
+ }
+ }
+ },
+ "local-replace-directives": {
+ "description": "Raise lint issues if loading local path with replace directive",
+ "type": "boolean",
+ "default": true
+ }
+ }
+ }
+ }
+ },
+ "gosecSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "includes": {
+ "type": "array",
+ "description": "To select a subset of rules to run",
+ "examples": [["G401"]],
+ "items": {
+ "$ref": "#/definitions/gosec-rules"
+ }
+ },
+ "excludes": {
+ "type": "array",
+ "description": "To specify a set of rules to explicitly exclude",
+ "examples": [["G401"]],
+ "items": {
+ "$ref": "#/definitions/gosec-rules"
+ }
+ },
+ "severity": {
+ "description": "Filter out the issues with a lower severity than the given value",
+ "type": "string",
+ "enum": ["low", "medium", "high"],
+ "default": "low"
+ },
+ "confidence": {
+ "description": "Filter out the issues with a lower confidence than the given value",
+ "type": "string",
+ "enum": ["low", "medium", "high"],
+ "default": "low"
+ },
+ "config": {
+ "description": "To specify the configuration of rules",
+ "type": "object"
+ },
+ "concurrency": {
+ "description": "Concurrency value",
+ "type": "integer"
+ }
+ }
+ },
+ "gosmopolitanSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "allow-time-local": {
+ "description": "Allow and ignore `time.Local` usages.",
+ "type": "boolean",
+ "default": false
+ },
+ "escape-hatches": {
+ "description": "List of fully qualified names in the `full/pkg/path.name` form, to act as \"i18n escape hatches\".",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "watch-for-scripts": {
+ "description": "List of Unicode scripts to watch for any usage in string literals.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "govetSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "settings": {
+ "description": "Settings per analyzer. Map of analyzer name to specific settings.\nRun `go tool vet help` to find out more.",
+ "type": "object",
+ "propertyNames": {
+ "$ref": "#/definitions/govet-analyzers"
+ },
+ "patternProperties": {
+ "^.*$": {
+ "description": "Run `go tool vet help ` to see all settings.",
+ "type": "object"
+ }
+ }
+ },
+ "enable": {
+ "description": "Enable analyzers by name.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/govet-analyzers"
+ }
+ },
+ "disable": {
+ "description": "Disable analyzers by name.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/govet-analyzers"
+ }
+ },
+ "enable-all": {
+ "description": "Enable all analyzers.",
+ "type": "boolean",
+ "default": false
+ },
+ "disable-all": {
+ "description": "Disable all analyzers.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "grouperSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "const-require-single-const": {
+ "type": "boolean",
+ "default": false
+ },
+ "const-require-grouping": {
+ "type": "boolean",
+ "default": false
+ },
+ "import-require-single-import": {
+ "type": "boolean",
+ "default": false
+ },
+ "import-require-grouping": {
+ "type": "boolean",
+ "default": false
+ },
+ "type-require-single-type": {
+ "type": "boolean",
+ "default": false
+ },
+ "type-require-grouping": {
+ "type": "boolean",
+ "default": false
+ },
+ "var-require-single-var": {
+ "type": "boolean",
+ "default": false
+ },
+ "var-require-grouping": {
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "ifaceSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "enable": {
+ "description": "Enable analyzers by name.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/iface-analyzers"
+ }
+ },
+ "settings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "unused": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "exclude": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "unusedmethod": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "exclude": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "importasSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "no-unaliased": {
+ "description": "Do not allow unaliased imports of aliased packages.",
+ "type": "boolean",
+ "default": false
+ },
+ "no-extra-aliases": {
+ "description": "Do not allow non-required aliases.",
+ "type": "boolean",
+ "default": false
+ },
+ "alias": {
+ "description": "List of aliases",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "pkg": {
+ "description": "Package path e.g. knative.dev/serving/pkg/apis/autoscaling/v1alpha1",
+ "type": "string"
+ },
+ "alias": {
+ "description": "Package alias e.g. autoscalingv1alpha1",
+ "type": "string"
+ }
+ },
+ "required": ["pkg", "alias"]
+ }
+ }
+ }
+ },
+ "inamedparamSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "skip-single-param": {
+ "description": "Skips check for interface methods with only a single parameter.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "ineffassignSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "check-escaping-errors": {
+ "description": "Check escaping variables of type error, may cause false positives.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "iotamixingSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "report-individual": {
+ "description": "Whether to report individual consts rather than just the const block.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "ireturnSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "description": "Use either `reject` or `allow` properties for interfaces matching.",
+ "properties": {
+ "allow": {
+ "type": "array",
+ "items": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "enum": ["anon", "error", "empty", "stdlib"]
+ }
+ ]
+ }
+ },
+ "reject": {
+ "type": "array",
+ "items": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "enum": ["anon", "error", "empty", "stdlib"]
+ }
+ ]
+ }
+ }
+ },
+ "anyOf": [
+ {
+ "not": {
+ "properties": {
+ "allow": {
+ "const": "reject"
+ }
+ }
+ },
+ "required": ["allow"]
+ },
+ {
+ "required": ["reject"]
+ }
+ ]
+ },
+ "lllSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "tab-width": {
+ "description": "Width of \"\\t\" in spaces.",
+ "type": "integer",
+ "minimum": 0,
+ "default": 1
+ },
+ "line-length": {
+ "description": "Maximum allowed line length, lines longer will be reported.",
+ "type": "integer",
+ "minimum": 1,
+ "default": 120
+ }
+ }
+ },
+ "maintidxSettings": {
+ "description": "Maintainability index https://docs.microsoft.com/en-us/visualstudio/code-quality/code-metrics-maintainability-index-range-and-meaning?view=vs-2022",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "under": {
+ "description": "Minimum accatpable maintainability index level (see https://docs.microsoft.com/en-us/visualstudio/code-quality/code-metrics-maintainability-index-range-and-meaning?view=vs-2022)",
+ "type": "number",
+ "default": 20
+ }
+ }
+ },
+ "makezeroSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "always": {
+ "description": "Allow only slices initialized with a length of zero.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "loggercheckSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "kitlog": {
+ "description": "Allow check for the github.com/go-kit/log library.",
+ "type": "boolean",
+ "default": true
+ },
+ "klog": {
+ "description": "Allow check for the k8s.io/klog/v2 library.",
+ "type": "boolean",
+ "default": true
+ },
+ "logr": {
+ "description": "Allow check for the github.com/go-logr/logr library.",
+ "type": "boolean",
+ "default": true
+ },
+ "slog": {
+ "description": "Allow check for the log/slog library.",
+ "type": "boolean",
+ "default": true
+ },
+ "zap": {
+ "description": "Allow check for the \"sugar logger\" from go.uber.org/zap library.",
+ "type": "boolean",
+ "default": true
+ },
+ "require-string-key": {
+ "description": "Require all logging keys to be inlined constant strings.",
+ "type": "boolean",
+ "default": false
+ },
+ "no-printf-like": {
+ "description": "Require printf-like format specifier (%s, %d for example) not present.",
+ "type": "boolean",
+ "default": false
+ },
+ "rules": {
+ "description": "List of custom rules to check against, where each rule is a single logger pattern, useful for wrapped loggers.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "misspellSettings": {
+ "description": "Correct spellings using locale preferences for US or UK. Default is to use a neutral variety of English.",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "locale": {
+ "enum": ["US", "UK"]
+ },
+ "ignore-rules": {
+ "description": "List of rules to ignore.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "mode": {
+ "description": "Mode of the analysis.",
+ "enum": ["restricted", "", "default"],
+ "default": ""
+ },
+ "extra-words": {
+ "description": "Extra word corrections.",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "correction": {
+ "type": "string"
+ },
+ "typo": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ }
+ },
+ "musttagSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "functions": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "name": {
+ "type": "string"
+ },
+ "tag": {
+ "type": "string"
+ },
+ "arg-pos": {
+ "type": "integer"
+ }
+ }
+ }
+ }
+ }
+ },
+ "nakedretSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "max-func-lines": {
+ "description": "Report if a function has more lines of code than this value and it has naked returns.",
+ "type": "integer",
+ "minimum": 0,
+ "default": 30
+ }
+ }
+ },
+ "nestifSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "min-complexity": {
+ "description": "Minimum complexity of \"if\" statements to report.",
+ "type": "integer",
+ "default": 5
+ }
+ }
+ },
+ "nilnilSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "only-two": {
+ "type": "boolean",
+ "description": "To check functions with only two return values.",
+ "default": true
+ },
+ "detect-opposite": {
+ "type": "boolean",
+ "description": "In addition, detect opposite situation (simultaneous return of non-nil error and valid value).",
+ "default": false
+ },
+ "checked-types": {
+ "type": "array",
+ "description": "List of return types to check.",
+ "items": {
+ "enum": ["chan", "func", "iface", "map", "ptr", "uintptr", "unsafeptr"]
+ },
+ "default": ["chan", "func", "iface", "map", "ptr", "uintptr", "unsafeptr"]
+ }
+ }
+ },
+ "nlreturnSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "block-size": {
+ "description": "set block size that is still ok",
+ "type": "number",
+ "default": 0,
+ "minimum": 0
+ }
+ }
+ },
+ "mndSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "ignored-files": {
+ "description": "List of file patterns to exclude from analysis.",
+ "examples": [["magic1_.*.go"]],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ignored-functions": {
+ "description": "Comma-separated list of function patterns to exclude from the analysis.",
+ "examples": [["math.*", "http.StatusText", "make"]],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ignored-numbers": {
+ "description": "List of numbers to exclude from analysis.",
+ "examples": [["1000", "1234_567_890", "3.14159264"]],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "checks": {
+ "description": "The list of enabled checks, see https://github.com/tommy-muehle/go-mnd/#checks for description.",
+ "type": "array",
+ "items": {
+ "enum": [
+ "argument",
+ "case",
+ "condition",
+ "operation",
+ "return",
+ "assign"
+ ]
+ }
+ }
+ }
+ },
+ "modernizeSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "disable": {
+ "description": "List of analyzers to disable.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/modernize-analyzers"
+ }
+ }
+ }
+ },
+ "nolintlintSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "allow-unused": {
+ "description": "Enable to ensure that nolint directives are all used.",
+ "type": "boolean",
+ "default": true
+ },
+ "allow-no-explanation": {
+ "description": "Exclude these linters from requiring an explanation.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/linter-names"
+ },
+ "default": []
+ },
+ "require-explanation": {
+ "description": "Enable to require an explanation of nonzero length after each nolint directive.",
+ "type": "boolean",
+ "default": false
+ },
+ "require-specific": {
+ "description": "Enable to require nolint directives to mention the specific linter being suppressed.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "reassignSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "patterns": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "recvcheckSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "disable-builtin": {
+ "description": "Disables the built-in method exclusions.",
+ "type": "boolean",
+ "default": true
+ },
+ "exclusions": {
+ "description": "User-defined method exclusions.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "nonamedreturnsSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "report-error-in-defer": {
+ "description": "Report named error if it is assigned inside defer.",
+ "type": "boolean",
+ "default": false
+ },
+ "allow-unused-named-returns": {
+ "description": "Allow named returns in the signature but report them if referenced in the body or used by a naked return.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "paralleltestSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "ignore-missing": {
+ "description": "Ignore missing calls to `t.Parallel()` and only report incorrect uses of it.",
+ "type": "boolean",
+ "default": false
+ },
+ "ignore-missing-subtests": {
+ "description": "Ignore missing calls to `t.Parallel()` in subtests. Top-level tests are still required to have `t.Parallel`, but subtests are allowed to skip it.",
+ "type": "boolean",
+ "default": false
+ },
+ "check-cleanup": {
+ "description": "Check that defer is not used with t.Parallel (use t.Cleanup instead).",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "perfsprintSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "integer-format": {
+ "description": "Enable/disable optimization of integer formatting.",
+ "type": "boolean",
+ "default": true
+ },
+ "int-conversion": {
+ "description": "Optimizes even if it requires an int or uint type cast.",
+ "type": "boolean",
+ "default": true
+ },
+ "error-format": {
+ "description": "Enable/disable optimization of error formatting.",
+ "type": "boolean",
+ "default": true
+ },
+ "err-error": {
+ "description": "Optimizes into `err.Error()` even if it is only equivalent for non-nil errors.",
+ "type": "boolean",
+ "default": false
+ },
+ "errorf": {
+ "description": "Optimizes `fmt.Errorf`.",
+ "type": "boolean",
+ "default": true
+ },
+ "string-format": {
+ "description": "Enable/disable optimization of string formatting.",
+ "type": "boolean",
+ "default": true
+ },
+ "sprintf1": {
+ "description": "Optimizes `fmt.Sprintf` with only one argument.",
+ "type": "boolean",
+ "default": true
+ },
+ "strconcat": {
+ "description": "Optimizes into strings concatenation.",
+ "type": "boolean",
+ "default": true
+ },
+ "bool-format": {
+ "description": "Enable/disable optimization of bool formatting.",
+ "type": "boolean",
+ "default": true
+ },
+ "hex-format": {
+ "description": "Enable/disable optimization of hex formatting.",
+ "type": "boolean",
+ "default": true
+ },
+ "concat-loop": {
+ "description": "Enable/disable optimization of concat loop.",
+ "type": "boolean",
+ "default": true
+ },
+ "loop-other-ops": {
+ "description": "Optimization of `concat-loop` even with other operations.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "preallocSettings": {
+ "description": "We do not recommend using this linter before doing performance profiling.\nFor most programs usage of `prealloc` will be premature optimization.",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "simple": {
+ "description": "Report preallocation suggestions only on simple loops that have no returns/breaks/continues/gotos in them.",
+ "type": "boolean",
+ "default": true
+ },
+ "range-loops": {
+ "description": "Report preallocation suggestions on range loops.",
+ "type": "boolean",
+ "default": true
+ },
+ "for-loops": {
+ "description": "Report preallocation suggestions on for loops.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "predeclaredSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "ignore": {
+ "description": "List of predeclared identifiers to not report on.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "qualified-name": {
+ "description": "Include method names and field names in checks.",
+ "type": "boolean",
+ "default": false
+ },
+ "mode": {
+ "type": "array",
+ "items": {
+ "enum": ["shadow", "declare"]
+ }
+ }
+ }
+ },
+ "promlinterSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "strict": {},
+ "disabled-linters": {
+ "type": "array",
+ "items": {
+ "enum": [
+ "Help",
+ "MetricUnits",
+ "Counter",
+ "HistogramSummaryReserved",
+ "MetricTypeInName",
+ "ReservedChars",
+ "CamelCase",
+ "UnitAbbreviations"
+ ]
+ }
+ }
+ }
+ },
+ "protogetterSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "skip-generated-by": {
+ "type": "array",
+ "items": {
+ "type": "string",
+ "examples": ["protoc-gen-go-my-own-generator"]
+ }
+ },
+ "skip-files": {
+ "type": "array",
+ "items": {
+ "type": "string",
+ "examples": ["*.pb.go"]
+ }
+ },
+ "skip-any-generated": {
+ "description": "Skip any generated files from the checking.",
+ "type": "boolean",
+ "default": false
+ },
+ "replace-first-arg-in-append": {
+ "description": "Skip first argument of append function.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "reviveSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "examples": [
+ {
+ "ignore-generated-header": true,
+ "severity": "warning",
+ "rules": [
+ {
+ "name": "indent-error-flow",
+ "severity": "warning"
+ },
+ {
+ "name": "add-constant",
+ "severity": "warning",
+ "arguments": [
+ {
+ "maxLitCount": "3",
+ "allowStrs": "\"\"",
+ "allowInts": "0,1,2",
+ "allowFloats": "0.0,0.,1.0,1.,2.0,2."
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ "properties": {
+ "max-open-files": {
+ "type": "integer"
+ },
+ "confidence": {
+ "type": "number"
+ },
+ "severity": {
+ "type": "string",
+ "enum": ["warning", "error"]
+ },
+ "enable-all-rules": {
+ "type": "boolean",
+ "default": false
+ },
+ "enable-default-rules": {
+ "type": "boolean",
+ "default": false
+ },
+ "directives": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "name": {
+ "type": "string",
+ "enum": ["specify-disable-reason", "specify-disable-rule"]
+ },
+ "severity": {
+ "type": "string",
+ "enum": ["warning", "error"]
+ },
+ "exclude": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "arguments": {
+ "type": "array"
+ }
+ }
+ }
+ },
+ "rules": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "required": ["name"],
+ "properties": {
+ "name": {
+ "$ref": "#/definitions/revive-rules",
+ "title": "The rule name"
+ },
+ "disabled": {
+ "type": "boolean"
+ },
+ "severity": {
+ "type": "string",
+ "enum": ["warning", "error"]
+ },
+ "exclude": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "arguments": {
+ "type": "array"
+ }
+ }
+ }
+ }
+ }
+ },
+ "rowserrcheckSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "packages": {
+ "type": "array",
+ "items": {
+ "description": "",
+ "type": "string",
+ "examples": ["github.com/jmoiron/sqlx"]
+ }
+ }
+ }
+ },
+ "sloglintSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "no-global": {
+ "description": "Report the use of global loggers.",
+ "enum": ["", "all", "default"],
+ "default": ""
+ },
+ "context": {
+ "description": "Report the use of functions without a context.Context.",
+ "enum": ["", "all", "scope"],
+ "default": ""
+ },
+ "static-msg": {
+ "description": "Report dynamic log messages, such as those that are built with fmt.Sprintf.",
+ "type": "boolean",
+ "default": false
+ },
+ "msg-style": {
+ "description": "Report log messages that do not match a particular style.",
+ "enum": ["", "lowercased", "capitalized"],
+ "default": ""
+ },
+ "no-mixed-args": {
+ "description": "Report the use of both key-value pairs and attributes within a single function call.",
+ "type": "boolean",
+ "default": true
+ },
+ "kv-only": {
+ "description": "Report any use of attributes as function call arguments.",
+ "type": "boolean",
+ "default": false
+ },
+ "attr-only": {
+ "description": "Report any use of key-value pairs as function call arguments.",
+ "type": "boolean",
+ "default": false
+ },
+ "args-on-sep-lines": {
+ "description": "Report two or more arguments on the same line.",
+ "type": "boolean",
+ "default": false
+ },
+ "no-raw-keys": {
+ "description": "Report the use of string literals as log keys.",
+ "type": "boolean",
+ "default": false
+ },
+ "allowed-keys": {
+ "description": "Report the use of log keys that are not explicitly allowed.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "forbidden-keys": {
+ "description": "Report the use of forbidden log keys.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "key-naming-case": {
+ "description": "Report log keys that do not match a particular naming case.",
+ "enum": ["snake", "kebab", "camel", "pascal"]
+ },
+ "custom-funcs": {
+ "description": "Analyze custom functions in addition to the standard log/slog functions.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/settings/definitions/sloglintCustomFunc"
+ }
+ }
+ }
+ },
+ "sloglintCustomFunc": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "name": {
+ "description": "The full name of the function, including the package. If the function is a method, the receiver type must be wrapped in parentheses.",
+ "type": "string"
+ },
+ "msg-pos": {
+ "description": "The position of the \"msg string\" argument in the function signature, starting from 0. If there is no message in the function, a negative value must be passed.",
+ "type": "integer"
+ },
+ "args-pos": {
+ "description": "The position of the \"args ...any\" argument in the function signature, starting from 0. If there are no arguments in the function, a negative value must be passed.",
+ "type": "integer"
+ }
+ }
+ },
+ "spancheckSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "checks": {
+ "description": "Checks to enable.",
+ "type": "array",
+ "items": {
+ "enum": ["end", "record-error", "set-status"]
+ }
+ },
+ "ignore-check-signatures": {
+ "description": "A list of regexes for function signatures that silence `record-error` and `set-status` reports if found in the call path to a returned error.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "extra-start-span-signatures": {
+ "description": "A list of regexes for additional function signatures that create spans.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "staticcheckSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "checks": {
+ "type": "array",
+ "items": {
+ "anyOf": [
+ {
+ "$ref": "#/definitions/staticcheck-checks"
+ },
+ {
+ "type": "string"
+ }
+ ]
+ }
+ },
+ "dot-import-whitelist": {
+ "description": "By default, ST1001 forbids all uses of dot imports in non-test packages. This setting allows setting a whitelist of import paths that can be dot-imported anywhere.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "http-status-code-whitelist": {
+ "description": "ST1013 recommends using constants from the net/http package instead of hard-coding numeric HTTP status codes. This setting specifies a list of numeric status codes that this check does not complain about.",
+ "default": ["200", "400", "404", "500"],
+ "type": "array",
+ "items": {
+ "enum": [
+ "100",
+ "101",
+ "102",
+ "103",
+ "200",
+ "201",
+ "202",
+ "203",
+ "204",
+ "205",
+ "206",
+ "207",
+ "208",
+ "226",
+ "300",
+ "301",
+ "302",
+ "303",
+ "304",
+ "305",
+ "306",
+ "307",
+ "308",
+ "400",
+ "401",
+ "402",
+ "403",
+ "404",
+ "405",
+ "406",
+ "407",
+ "408",
+ "409",
+ "410",
+ "411",
+ "412",
+ "413",
+ "414",
+ "415",
+ "416",
+ "417",
+ "418",
+ "421",
+ "422",
+ "423",
+ "424",
+ "425",
+ "426",
+ "428",
+ "429",
+ "431",
+ "451",
+ "500",
+ "501",
+ "502",
+ "503",
+ "504",
+ "505",
+ "506",
+ "507",
+ "508",
+ "510",
+ "511"
+ ]
+ }
+ },
+ "initialisms": {
+ "description": "ST1003 check, among other things, for the correct capitalization of initialisms. The set of known initialisms can be configured with this option.",
+ "type": "array",
+ "items": {
+ "type": "string",
+ "default": [
+ "ACL",
+ "API",
+ "ASCII",
+ "CPU",
+ "CSS",
+ "DNS",
+ "EOF",
+ "GUID",
+ "HTML",
+ "HTTP",
+ "HTTPS",
+ "ID",
+ "IP",
+ "JSON",
+ "QPS",
+ "RAM",
+ "RPC",
+ "SLA",
+ "SMTP",
+ "SQL",
+ "SSH",
+ "TCP",
+ "TLS",
+ "TTL",
+ "UDP",
+ "UI",
+ "GID",
+ "UID",
+ "UUID",
+ "URI",
+ "URL",
+ "UTF8",
+ "VM",
+ "XML",
+ "XMPP",
+ "XSRF",
+ "XSS",
+ "SIP",
+ "RTP",
+ "AMQP",
+ "DB",
+ "TS"
+ ]
+ }
+ }
+ }
+ },
+ "tagalignSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "align": {
+ "description": "Align and sort can be used together or separately.",
+ "type": "boolean",
+ "default": true
+ },
+ "sort": {
+ "description": "Whether enable tags sort.",
+ "type": "boolean",
+ "default": true
+ },
+ "order": {
+ "description": "Specify the order of tags, the other tags will be sorted by name.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "default": [],
+ "examples": [
+ [
+ "json",
+ "yaml",
+ "yml",
+ "toml",
+ "mapstructure",
+ "binding",
+ "validate"
+ ]
+ ]
+ },
+ "strict": {
+ "description": "Whether enable strict style.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "tagliatelleSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "case": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "use-field-name": {
+ "description": "Use the struct field name to check the name of the struct tag.",
+ "type": "boolean",
+ "default": false
+ },
+ "ignored-fields": {
+ "description": "The field names to ignore.",
+ "type": "array",
+ "items": {
+ "type": "string",
+ "examples": ["example"]
+ }
+ },
+ "rules": {
+ "type": "object",
+ "patternProperties": {
+ "^.+$": {
+ "$ref": "#/definitions/tagliatelle-cases"
+ }
+ }
+ },
+ "extended-rules": {
+ "description": "Defines the association between tag name and case.",
+ "type": "object",
+ "patternProperties": {
+ "^.+$": {
+ "type": "object",
+ "additionalProperties": false,
+ "required": ["case"],
+ "properties": {
+ "case": {
+ "$ref": "#/definitions/tagliatelle-cases"
+ },
+ "extra-initialisms": {
+ "type": "boolean",
+ "default": false
+ },
+ "initialism-overrides": {
+ "type": "object",
+ "patternProperties": {
+ "^.+$": {
+ "type": "boolean",
+ "default": false
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "overrides": {
+ "description": "Overrides the default/root configuration.",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "required": ["pkg"],
+ "properties": {
+ "pkg": {
+ "description": "A package path.",
+ "type": "string"
+ },
+ "use-field-name": {
+ "description": "Use the struct field name to check the name of the struct tag.",
+ "type": "boolean",
+ "default": false
+ },
+ "ignored-fields": {
+ "description": "The field names to ignore.",
+ "type": "array",
+ "items": {
+ "type": "string",
+ "examples": ["example"]
+ }
+ },
+ "ignore": {
+ "description": "Ignore the package (takes precedence over all other configurations).",
+ "type": "boolean",
+ "default": false
+ },
+ "rules": {
+ "type": "object",
+ "patternProperties": {
+ "^.+$": {
+ "$ref": "#/definitions/tagliatelle-cases"
+ }
+ }
+ },
+ "extended-rules": {
+ "description": "Defines the association between tag name and case.",
+ "type": "object",
+ "patternProperties": {
+ "^.+$": {
+ "type": "object",
+ "additionalProperties": false,
+ "required": ["case"],
+ "properties": {
+ "case": {
+ "$ref": "#/definitions/tagliatelle-cases"
+ },
+ "extra-initialisms": {
+ "type": "boolean",
+ "default": false
+ },
+ "initialism-overrides": {
+ "type": "object",
+ "patternProperties": {
+ "^.+$": {
+ "type": "boolean",
+ "default": false
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "testifylintSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "enable-all": {
+ "description": "Enable all checkers.",
+ "type": "boolean",
+ "default": false
+ },
+ "disable-all": {
+ "description": "Disable all checkers.",
+ "type": "boolean",
+ "default": false
+ },
+ "enable": {
+ "description": "Enable specific checkers.",
+ "type": "array",
+ "items": {
+ "enum": [
+ "blank-import",
+ "bool-compare",
+ "compares",
+ "contains",
+ "empty",
+ "encoded-compare",
+ "equal-values",
+ "error-is-as",
+ "error-nil",
+ "expected-actual",
+ "float-compare",
+ "formatter",
+ "go-require",
+ "len",
+ "negative-positive",
+ "nil-compare",
+ "regexp",
+ "require-error",
+ "suite-broken-parallel",
+ "suite-dont-use-pkg",
+ "suite-extra-assert-call",
+ "suite-method-signature",
+ "suite-subtest-run",
+ "suite-thelper",
+ "useless-assert"
+ ]
+ },
+ "default": [
+ "blank-import",
+ "bool-compare",
+ "compares",
+ "contains",
+ "empty",
+ "encoded-compare",
+ "equal-values",
+ "error-is-as",
+ "error-nil",
+ "expected-actual",
+ "float-compare",
+ "formatter",
+ "go-require",
+ "len",
+ "negative-positive",
+ "nil-compare",
+ "regexp",
+ "require-error",
+ "suite-broken-parallel",
+ "suite-dont-use-pkg",
+ "suite-extra-assert-call",
+ "suite-method-signature",
+ "suite-subtest-run",
+ "useless-assert"
+ ]
+ },
+ "disable": {
+ "description": "Disable specific checkers.",
+ "type": "array",
+ "items": {
+ "enum": [
+ "blank-import",
+ "bool-compare",
+ "compares",
+ "contains",
+ "empty",
+ "encoded-compare",
+ "equal-values",
+ "error-is-as",
+ "error-nil",
+ "expected-actual",
+ "float-compare",
+ "formatter",
+ "go-require",
+ "len",
+ "negative-positive",
+ "nil-compare",
+ "regexp",
+ "require-error",
+ "suite-broken-parallel",
+ "suite-dont-use-pkg",
+ "suite-extra-assert-call",
+ "suite-method-signature",
+ "suite-subtest-run",
+ "suite-thelper",
+ "useless-assert"
+ ],
+ "default": [
+ "suite-thelper"
+ ]
+ }
+ },
+ "bool-compare": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "ignore-custom-types": {
+ "description": "To ignore user defined types (over builtin bool).",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "expected-actual": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "pattern": {
+ "description": "Regexp for expected variable name.",
+ "type": "string",
+ "default": "(^(exp(ected)?|want(ed)?)([A-Z]\\w*)?$)|(^(\\w*[a-z])?(Exp(ected)?|Want(ed)?)$)"
+ }
+ }
+ },
+ "formatter": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "check-format-string": {
+ "description": "To enable go vet's printf checks.",
+ "type": "boolean",
+ "default": true
+ },
+ "require-f-funcs": {
+ "description": "To require f-assertions (e.g. assert.Equalf) if format string is used, even if there are no variable-length variables.",
+ "type": "boolean",
+ "default": false
+ },
+ "require-string-msg": {
+ "description": "To require that the first element of msgAndArgs (msg) has a string type.",
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "go-require": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "ignore-http-handlers": {
+ "description": "To ignore HTTP handlers (like http.HandlerFunc).",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "require-error": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "fn-pattern": {
+ "description": "Regexp for assertions to analyze. If defined, then only matched error assertions will be reported.",
+ "type": "string",
+ "default": ""
+ }
+ }
+ },
+ "suite-extra-assert-call": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "mode": {
+ "description": "To require or remove extra Assert() call?",
+ "type": "string",
+ "enum": ["remove", "require"],
+ "default": "remove"
+ }
+ }
+ }
+ }
+ },
+ "testpackageSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "skip-regexp": {
+ "description": "Files with names matching this regular expression are skipped.",
+ "type": "string",
+ "examples": ["(export|internal)_test\\.go"]
+ },
+ "allow-packages": {
+ "description": "List of packages that don't end with _test that tests are allowed to be in.",
+ "type": "array",
+ "uniqueItems": true,
+ "items": {
+ "type": "string",
+ "examples": ["example"]
+ }
+ }
+ }
+ },
+ "thelperSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "test": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "begin": {
+ "description": "Check if `t.Helper()` begins helper function.",
+ "default": true,
+ "type": "boolean"
+ },
+ "first": {
+ "description": "Check if *testing.T is first param of helper function.",
+ "default": true,
+ "type": "boolean"
+ },
+ "name": {
+ "description": "Check if *testing.T param has t name.",
+ "default": true,
+ "type": "boolean"
+ }
+ }
+ },
+ "benchmark": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "begin": {
+ "description": "Check if `b.Helper()` begins helper function.",
+ "default": true,
+ "type": "boolean"
+ },
+ "first": {
+ "description": "Check if *testing.B is first param of helper function.",
+ "default": true,
+ "type": "boolean"
+ },
+ "name": {
+ "description": "Check if *testing.B param has b name.",
+ "default": true,
+ "type": "boolean"
+ }
+ }
+ },
+ "tb": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "begin": {
+ "description": "Check if `tb.Helper()` begins helper function.",
+ "default": true,
+ "type": "boolean"
+ },
+ "first": {
+ "description": "Check if *testing.TB is first param of helper function.",
+ "default": true,
+ "type": "boolean"
+ },
+ "name": {
+ "description": "Check if *testing.TB param has tb name.",
+ "default": true,
+ "type": "boolean"
+ }
+ }
+ },
+ "fuzz": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "begin": {
+ "description": "Check if `f.Helper()` begins helper function.",
+ "default": true,
+ "type": "boolean"
+ },
+ "first": {
+ "description": "Check if *testing.F is first param of helper function.",
+ "default": true,
+ "type": "boolean"
+ },
+ "name": {
+ "description": "Check if *testing.F param has f name.",
+ "default": true,
+ "type": "boolean"
+ }
+ }
+ }
+ }
+ },
+ "usestdlibvarsSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "http-method": {
+ "description": "Suggest the use of http.MethodXX.",
+ "type": "boolean",
+ "default": true
+ },
+ "http-status-code": {
+ "description": "Suggest the use of http.StatusXX.",
+ "type": "boolean",
+ "default": true
+ },
+ "time-weekday": {
+ "description": "Suggest the use of time.Weekday.String().",
+ "type": "boolean",
+ "default": false
+ },
+ "time-month": {
+ "description": "Suggest the use of time.Month.String().",
+ "type": "boolean",
+ "default": false
+ },
+ "time-layout": {
+ "description": "Suggest the use of time.Layout.",
+ "type": "boolean",
+ "default": false
+ },
+ "time-date-month": {
+ "description": "Suggest the use of time.Month in time.Date.",
+ "type": "boolean",
+ "default": false
+ },
+ "crypto-hash": {
+ "description": "Suggest the use of crypto.Hash.String().",
+ "type": "boolean",
+ "default": false
+ },
+ "default-rpc-path": {
+ "description": "Suggest the use of rpc.DefaultXXPath.",
+ "type": "boolean",
+ "default": false
+ },
+ "sql-isolation-level": {
+ "description": "Suggest the use of sql.LevelXX.String().",
+ "type": "boolean",
+ "default": false
+ },
+ "tls-signature-scheme": {
+ "description": "Suggest the use of tls.SignatureScheme.String().",
+ "type": "boolean",
+ "default": false
+ },
+ "constant-kind": {
+ "description": "Suggest the use of constant.Kind.String().",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "usetestingSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "context-background": {
+ "type": "boolean",
+ "default": false
+ },
+ "context-todo": {
+ "type": "boolean",
+ "default": false
+ },
+ "os-chdir": {
+ "type": "boolean",
+ "default": true
+ },
+ "os-mkdir-temp": {
+ "type": "boolean",
+ "default": true
+ },
+ "os-setenv": {
+ "type": "boolean",
+ "default": true
+ },
+ "os-create-temp": {
+ "type": "boolean",
+ "default": true
+ },
+ "os-temp-dir": {
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "unconvertSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "fast-math": {
+ "type": "boolean",
+ "default": false
+ },
+ "safe": {
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "unparamSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "check-exported": {
+ "description": "Inspect exported functions. Set to true if no external program/library imports your code.\n\nWARNING: if you enable this setting, unparam will report a lot of false-positives in text editors:\nif it's called for subdir of a project it can't find external interfaces. All text editor integrations\nwith golangci-lint call it on a directory with the changed file.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "unqueryvetSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "check-sql-builders": {
+ "description": "Enable SQL builder checking.",
+ "type": "boolean",
+ "default": true
+ },
+ "check-aliased-wildcard": {
+ "description": "Enable aliased wildcard detection like SELECT t.*.",
+ "type": "boolean",
+ "default": true
+ },
+ "check-string-concat": {
+ "description": "Enable string concatenation analysis.",
+ "type": "boolean",
+ "default": true
+ },
+ "check-format-strings": {
+ "description": "Enable format string analysis like fmt.Sprintf.",
+ "type": "boolean",
+ "default": true
+ },
+ "check-string-builder": {
+ "description": "Enable strings.Builder analysis.",
+ "type": "boolean",
+ "default": true
+ },
+ "check-subqueries": {
+ "description": "Enable subquery analysis.",
+ "type": "boolean",
+ "default": true
+ },
+ "check-n1": {
+ "type": "boolean",
+ "default": false
+ },
+ "check-sql-injection": {
+ "type": "boolean",
+ "default": false
+ },
+ "check-tx-leaks": {
+ "type": "boolean",
+ "default": false
+ },
+ "allowed-patterns": {
+ "description": "Regex patterns for acceptable SELECT * usage.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "allow": {
+ "description": "Allow is a list of SQL patterns to allow (whitelist).",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ignored-functions": {
+ "description": "Functions to ignore.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "sql-builders": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "squirrel": {
+ "type": "boolean",
+ "default": true
+ },
+ "gorm": {
+ "type": "boolean",
+ "default": true
+ },
+ "sqlx": {
+ "type": "boolean",
+ "default": true
+ },
+ "ent": {
+ "type": "boolean",
+ "default": true
+ },
+ "pgx": {
+ "type": "boolean",
+ "default": true
+ },
+ "bun": {
+ "type": "boolean",
+ "default": true
+ },
+ "sqlboiler": {
+ "type": "boolean",
+ "default": true
+ },
+ "jet": {
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "custom-rules": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "id": {
+ "type": "string"
+ },
+ "pattern": {
+ "type": "string"
+ },
+ "patterns": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "when": {
+ "type": "string"
+ },
+ "message": {
+ "type": "string"
+ },
+ "action": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ }
+ },
+ "unusedSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "field-writes-are-uses": {
+ "description": "",
+ "type": "boolean",
+ "default": true
+ },
+ "post-statements-are-reads": {
+ "description": "",
+ "type": "boolean",
+ "default": false
+ },
+ "exported-fields-are-used": {
+ "description": "",
+ "type": "boolean",
+ "default": true
+ },
+ "parameters-are-used": {
+ "description": "",
+ "type": "boolean",
+ "default": true
+ },
+ "local-variables-are-used": {
+ "description": "",
+ "type": "boolean",
+ "default": true
+ },
+ "generated-is-used": {
+ "description": "",
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "varnamelenSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "max-distance": {
+ "description": "Variables used in at most this N-many lines will be ignored.",
+ "type": "integer",
+ "default": 5
+ },
+ "min-name-length": {
+ "description": "The minimum length of a variable's name that is considered `long`.",
+ "type": "integer",
+ "default": 3
+ },
+ "check-receiver": {
+ "description": "Check method receiver names.",
+ "default": false,
+ "type": "boolean"
+ },
+ "check-return": {
+ "description": "Check named return values.",
+ "default": false,
+ "type": "boolean"
+ },
+ "check-type-param": {
+ "description": "Check type parameters.",
+ "default": false,
+ "type": "boolean"
+ },
+ "ignore-type-assert-ok": {
+ "description": "Ignore `ok` variables that hold the bool return value of a type assertion",
+ "default": false,
+ "type": "boolean"
+ },
+ "ignore-map-index-ok": {
+ "description": "Ignore `ok` variables that hold the bool return value of a map index.",
+ "default": false,
+ "type": "boolean"
+ },
+ "ignore-chan-recv-ok": {
+ "description": "Ignore `ok` variables that hold the bool return value of a channel receive.",
+ "default": false,
+ "type": "boolean"
+ },
+ "ignore-names": {
+ "description": "Optional list of variable names that should be ignored completely.",
+ "default": [[]],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ignore-decls": {
+ "description": "Optional list of variable declarations that should be ignored completely.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "examples": [
+ ["c echo.Context", "t testing.T", "f *foo.Bar", "const C"]
+ ]
+ }
+ }
+ },
+ "whitespaceSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "multi-if": {
+ "description": "Enforces newlines (or comments) after every multi-line if statement",
+ "type": "boolean",
+ "default": false
+ },
+ "multi-func": {
+ "description": "Enforces newlines (or comments) after every multi-line function signature",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "wrapcheckSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "extra-ignore-sigs": {
+ "description": "An array of strings specifying additional substrings of signatures to ignore.",
+ "default": [
+ ".CustomError(",
+ ".SpecificWrap("
+ ],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ignore-sigs": {
+ "description": "An array of strings which specify substrings of signatures to ignore.",
+ "default": [
+ ".Errorf(",
+ "errors.New(",
+ "errors.Unwrap(",
+ ".Wrap(",
+ ".Wrapf(",
+ ".WithMessage(",
+ ".WithMessagef(",
+ ".WithStack("
+ ],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ignore-sig-regexps": {
+ "description": "An array of strings which specify regular expressions of signatures to ignore.",
+ "default": [""],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ignore-package-globs": {
+ "description": "An array of glob patterns which, if any match the package of the function returning the error, will skip wrapcheck analysis for this error.",
+ "default": [""],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ignore-interface-regexps": {
+ "description": "An array of glob patterns which, if matched to an underlying interface name, will ignore unwrapped errors returned from a function whose call is defined on the given interface.",
+ "default": [""],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "report-internal-errors": {
+ "description": "Determines whether wrapcheck should report errors returned from inside the package.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "wslSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "allow-assign-and-anything": {
+ "description": "Controls if you may cuddle assignments and anything without needing an empty line between them.",
+ "type": "boolean",
+ "default": false
+ },
+ "allow-assign-and-call": {
+ "description": "Allow calls and assignments to be cuddled as long as the lines have any matching variables, fields or types.",
+ "type": "boolean",
+ "default": true
+ },
+ "allow-cuddle-declarations": {
+ "description": "Allow declarations (var) to be cuddled.",
+ "type": "boolean",
+ "default": false
+ },
+ "allow-cuddle-with-calls": {
+ "description": "A list of call idents that everything can be cuddled with.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "allow-cuddle-with-rhs": {
+ "description": "AllowCuddleWithRHS is a list of right hand side variables that is allowed to be cuddled with anything.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "allow-cuddle-used-in-block": {
+ "description": "Allow cuddling with any block as long as the variable is used somewhere in the block",
+ "type": "boolean",
+ "default": false
+ },
+ "allow-multiline-assign": {
+ "description": "Allow multiline assignments to be cuddled.",
+ "type": "boolean",
+ "default": true
+ },
+ "allow-separated-leading-comment": {
+ "description": "Allow leading comments to be separated with empty lines.",
+ "type": "boolean",
+ "default": false
+ },
+ "allow-trailing-comment": {
+ "description": "Allow trailing comments in ending of blocks.",
+ "type": "boolean",
+ "default": false
+ },
+ "error-variable-names": {
+ "description": "When force-err-cuddling is enabled this is a list of names used for error variables to check for in the conditional.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "force-case-trailing-whitespace": {
+ "description": "Force newlines in end of case at this limit (0 = never).",
+ "type": "integer",
+ "minimum": 0,
+ "default": 0
+ },
+ "force-err-cuddling": {
+ "description": "Causes an error when an If statement that checks an error variable doesn't cuddle with the assignment of that variable.",
+ "type": "boolean",
+ "default": false
+ },
+ "force-short-decl-cuddling": {
+ "description": "Causes an error if a short declaration (:=) cuddles with anything other than another short declaration.",
+ "type": "boolean",
+ "default": false
+ },
+ "strict-append": {
+ "description": "If true, append is only allowed to be cuddled if appending value is matching variables, fields or types on line above.",
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "wslSettingsV5": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "allow-first-in-block": {
+ "type": "boolean",
+ "default": true
+ },
+ "allow-whole-block": {
+ "type": "boolean",
+ "default": false
+ },
+ "branch-max-lines": {
+ "type": "integer",
+ "default": 2
+ },
+ "case-max-lines": {
+ "type": "integer",
+ "default": 0
+ },
+ "cuddle-max-statements": {
+ "type": "integer",
+ "default": 1
+ },
+ "default": {
+ "enum": ["all", "none", "default", ""],
+ "default": "default"
+ },
+ "enable": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/wsl-checks"
+ }
+ },
+ "disable": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/wsl-checks"
+ }
+ }
+ }
+ },
+ "copyloopvarSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "check-alias": {
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "customSettings": {
+ "description": "The custom section can be used to define linter plugins to be loaded at runtime. See README of golangci-lint for more information.\nEach custom linter should have a unique name.",
+ "type": "object",
+ "patternProperties": {
+ "^.*$": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "type": {
+ "description": "The plugin type.",
+ "enum": ["module", "goplugin"],
+ "default": "goplugin"
+ },
+ "path": {
+ "description": "The path to the plugin *.so. Can be absolute or local.",
+ "type": "string",
+ "examples": ["/path/to/example.so"]
+ },
+ "description": {
+ "description": "The description of the linter, for documentation purposes only.",
+ "type": "string"
+ },
+ "original-url": {
+ "description": "Intended to point to the repo location of the linter, for documentation purposes only.",
+ "type": "string"
+ },
+ "settings": {
+ "description": "Plugins settings/configuration. Only work with plugin based on `linterdb.PluginConstructor`.",
+ "type": "object"
+ }
+ },
+ "oneOf": [
+ {
+ "properties": {
+ "type": {"enum": ["module"] }
+ },
+ "required": ["type"]
+ },
+ {
+ "required": ["path"]
+ }
+ ]
+ }
+ }
+ }
+ }
+ }
+ },
+ "type": "object",
+ "additionalProperties": false,
+ "required": ["version"],
+ "properties": {
+ "version": {
+ "type": "string",
+ "default": "2"
+ },
+ "run": {
+ "description": "Options for analysis running,",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "concurrency": {
+ "description": "Number of concurrent runners. Defaults to the number of available CPU cores.",
+ "type": "integer",
+ "minimum": 0,
+ "examples": [4]
+ },
+ "timeout": {
+ "description": "Timeout for the analysis.",
+ "type": "string",
+ "pattern": "^((\\d+h)?(\\d+m)?(\\d+(?:\\.\\d)?s)?|0)$",
+ "default": "1m",
+ "examples": ["30s", "5m", "5m30s"]
+ },
+ "issues-exit-code": {
+ "description": "Exit code when at least one issue was found.",
+ "type": "integer",
+ "default": 1
+ },
+ "tests": {
+ "description": "Enable inclusion of test files.",
+ "type": "boolean",
+ "default": true
+ },
+ "build-tags": {
+ "description": "List of build tags to pass to all linters.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "default": [],
+ "examples": [["mytag"]]
+ },
+ "modules-download-mode": {
+ "description": "Option to pass to \"go list -mod={option}\".\nSee \"go help modules\" for more information.",
+ "enum": ["mod", "readonly", "vendor"]
+ },
+ "enable-build-vcs": {
+ "type": "boolean",
+ "default": false
+ },
+ "allow-parallel-runners": {
+ "description": "Allow multiple parallel golangci-lint instances running. If disabled, golangci-lint acquires file lock on start.",
+ "type": "boolean",
+ "default": false
+ },
+ "allow-serial-runners": {
+ "description": "Allow multiple golangci-lint instances running, but serialize them around a lock.",
+ "type": "boolean",
+ "default": false
+ },
+ "go": {
+ "description": "Targeted Go version.",
+ "type": "string",
+ "default": "1.17"
+ },
+ "relative-path-mode": {
+ "description": "The mode used to evaluate relative paths.",
+ "type": "string",
+ "$ref": "#/definitions/relative-path-modes",
+ "default": "wd"
+ }
+ }
+ },
+ "output": {
+ "description": "Output configuration options.",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "formats": {
+ "description": "Output formats to use.",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "text": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "path": {
+ "$ref": "#/definitions/formats-path",
+ "default": "stdout"
+ },
+ "print-linter-name": {
+ "type": "boolean",
+ "default": true
+ },
+ "print-issued-lines": {
+ "type": "boolean",
+ "default": true
+ },
+ "colors": {
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "json": {
+ "$ref": "#/definitions/simple-format"
+ },
+ "tab": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "path": {
+ "$ref": "#/definitions/formats-path",
+ "default": "stdout"
+ },
+ "print-linter-name": {
+ "type": "boolean",
+ "default": true
+ },
+ "colors": {
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "html": {
+ "$ref": "#/definitions/simple-format"
+ },
+ "checkstyle": {
+ "$ref": "#/definitions/simple-format"
+ },
+ "code-climate": {
+ "$ref": "#/definitions/simple-format"
+ },
+ "junit-xml": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "path": {
+ "$ref": "#/definitions/formats-path",
+ "default": "stdout"
+ },
+ "extended": {
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "teamcity": {
+ "$ref": "#/definitions/simple-format"
+ },
+ "sarif": {
+ "$ref": "#/definitions/simple-format"
+ }
+ }
+ },
+ "path-mode": {
+ "type": "string",
+ "default": "",
+ "examples": ["abs"]
+ },
+ "path-prefix": {
+ "description": "Add a prefix to the output file references.",
+ "type": "string",
+ "default": ""
+ },
+ "show-stats": {
+ "description": "Show statistics per linter.",
+ "type": "boolean",
+ "default": true
+ },
+ "sort-order": {
+ "type": "array",
+ "items": {
+ "enum": ["linter", "severity", "file"]
+ }
+ }
+ }
+ },
+ "linters": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "default": {
+ "enum": [
+ "standard",
+ "all",
+ "none",
+ "fast"
+ ]
+ },
+ "enable": {
+ "description": "List of enabled linters.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/linter-names"
+ }
+ },
+ "disable": {
+ "description": "List of disabled linters.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/linter-names"
+ }
+ },
+ "settings": {
+ "description": "All available settings of specific linters.",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "dupword": {
+ "$ref": "#/definitions/settings/definitions/dupwordSettings"
+ },
+ "asasalint": {
+ "$ref": "#/definitions/settings/definitions/asasalintSettings"
+ },
+ "bidichk": {
+ "$ref": "#/definitions/settings/definitions/bidichkSettings"
+ },
+ "bodyclose": {
+ "$ref": "#/definitions/settings/definitions/bodycloseSettings"
+ },
+ "canonicalheader": {
+ "$ref": "#/definitions/settings/definitions/canonicalheaderSettings"
+ },
+ "cyclop": {
+ "$ref": "#/definitions/settings/definitions/cyclopSettings"
+ },
+ "decorder": {
+ "$ref": "#/definitions/settings/definitions/decorderSettings"
+ },
+ "depguard":{
+ "$ref": "#/definitions/settings/definitions/depguardSettings"
+ },
+ "dogsled": {
+ "$ref": "#/definitions/settings/definitions/dogsledSettings"
+ },
+ "dupl": {
+ "$ref": "#/definitions/settings/definitions/duplSettings"
+ },
+ "embeddedstructfieldcheck": {
+ "$ref": "#/definitions/settings/definitions/embeddedstructfieldcheckSettings"
+ },
+ "errcheck": {
+ "$ref": "#/definitions/settings/definitions/errcheckSettings"
+ },
+ "errchkjson": {
+ "$ref": "#/definitions/settings/definitions/errchkjsonSettings"
+ },
+ "errorlint": {
+ "$ref": "#/definitions/settings/definitions/errorlintSettings"
+ },
+ "exhaustive": {
+ "$ref": "#/definitions/settings/definitions/exhaustiveSettings"
+ },
+ "exhaustruct": {
+ "$ref": "#/definitions/settings/definitions/exhaustructSettings"
+ },
+ "exhaustruct_v5": {
+ "$ref": "#/definitions/settings/definitions/exhaustructv5Settings"
+ },
+ "fatcontext": {
+ "$ref": "#/definitions/settings/definitions/fatcontextSettings"
+ },
+ "forbidigo": {
+ "$ref": "#/definitions/settings/definitions/forbidigoSettings"
+ },
+ "funcorder": {
+ "$ref": "#/definitions/settings/definitions/funcorderSettings"
+ },
+ "funlen": {
+ "$ref": "#/definitions/settings/definitions/funlenSettings"
+ },
+ "ginkgolinter": {
+ "$ref": "#/definitions/settings/definitions/ginkgolinterSettings"
+ },
+ "gochecksumtype": {
+ "$ref": "#/definitions/settings/definitions/gochecksumtypeSettings"
+ },
+ "gocognit": {
+ "$ref": "#/definitions/settings/definitions/gocognitSettings"
+ },
+ "goconst": {
+ "$ref": "#/definitions/settings/definitions/goconstSettings"
+ },
+ "gocritic": {
+ "$ref": "#/definitions/settings/definitions/gocriticSettings"
+ },
+ "gocyclo": {
+ "$ref": "#/definitions/settings/definitions/gocycloSettings"
+ },
+ "godoclint": {
+ "$ref": "#/definitions/settings/definitions/godoclintSettings"
+ },
+ "godot": {
+ "$ref": "#/definitions/settings/definitions/godotSettings"
+ },
+ "godox": {
+ "$ref": "#/definitions/settings/definitions/godoxSettings"
+ },
+ "interfacebloat":{
+ "$ref": "#/definitions/settings/definitions/interfacebloatSettings"
+ },
+ "goheader": {
+ "$ref": "#/definitions/settings/definitions/goheaderSettings"
+ },
+ "gomoddirectives": {
+ "$ref": "#/definitions/settings/definitions/gomoddirectivesSettings"
+ },
+ "gomodguard": {
+ "$ref": "#/definitions/settings/definitions/gomodguardSettings"
+ },
+ "gomodguard_v2": {
+ "$ref": "#/definitions/settings/definitions/gomodguardv2Settings"
+ },
+ "gosec": {
+ "$ref": "#/definitions/settings/definitions/gosecSettings"
+ },
+ "gosmopolitan": {
+ "$ref": "#/definitions/settings/definitions/gosmopolitanSettings"
+ },
+ "govet": {
+ "$ref": "#/definitions/settings/definitions/govetSettings"
+ },
+ "grouper": {
+ "$ref": "#/definitions/settings/definitions/grouperSettings"
+ },
+ "iface": {
+ "$ref": "#/definitions/settings/definitions/ifaceSettings"
+ },
+ "importas": {
+ "$ref": "#/definitions/settings/definitions/importasSettings"
+ },
+ "inamedparam": {
+ "$ref": "#/definitions/settings/definitions/inamedparamSettings"
+ },
+ "ineffassign": {
+ "$ref": "#/definitions/settings/definitions/ineffassignSettings"
+ },
+ "iotamixing": {
+ "$ref": "#/definitions/settings/definitions/iotamixingSettings"
+ },
+ "ireturn": {
+ "$ref": "#/definitions/settings/definitions/ireturnSettings"
+ },
+ "lll": {
+ "$ref": "#/definitions/settings/definitions/lllSettings"
+ },
+ "maintidx": {
+ "$ref": "#/definitions/settings/definitions/maintidxSettings"
+ },
+ "makezero":{
+ "$ref": "#/definitions/settings/definitions/makezeroSettings"
+ },
+ "loggercheck": {
+ "$ref": "#/definitions/settings/definitions/loggercheckSettings"
+ },
+ "misspell": {
+ "$ref": "#/definitions/settings/definitions/misspellSettings"
+ },
+ "musttag": {
+ "$ref": "#/definitions/settings/definitions/musttagSettings"
+ },
+ "nakedret": {
+ "$ref": "#/definitions/settings/definitions/nakedretSettings"
+ },
+ "nestif": {
+ "$ref": "#/definitions/settings/definitions/nestifSettings"
+ },
+ "nilnil": {
+ "$ref": "#/definitions/settings/definitions/nilnilSettings"
+ },
+ "nlreturn": {
+ "$ref": "#/definitions/settings/definitions/nlreturnSettings"
+ },
+ "mnd": {
+ "$ref": "#/definitions/settings/definitions/mndSettings"
+ },
+ "modernize": {
+ "$ref": "#/definitions/settings/definitions/modernizeSettings"
+ },
+ "nolintlint":{
+ "$ref": "#/definitions/settings/definitions/nolintlintSettings"
+ },
+ "reassign": {
+ "$ref": "#/definitions/settings/definitions/reassignSettings"
+ },
+ "recvcheck": {
+ "$ref": "#/definitions/settings/definitions/recvcheckSettings"
+ },
+ "nonamedreturns": {
+ "$ref": "#/definitions/settings/definitions/nonamedreturnsSettings"
+ },
+ "paralleltest": {
+ "$ref": "#/definitions/settings/definitions/paralleltestSettings"
+ },
+ "perfsprint": {
+ "$ref": "#/definitions/settings/definitions/perfsprintSettings"
+ },
+ "prealloc": {
+ "$ref": "#/definitions/settings/definitions/preallocSettings"
+ },
+ "predeclared": {
+ "$ref": "#/definitions/settings/definitions/predeclaredSettings"
+ },
+ "promlinter": {
+ "$ref": "#/definitions/settings/definitions/promlinterSettings"
+ },
+ "protogetter": {
+ "$ref": "#/definitions/settings/definitions/protogetterSettings"
+ },
+ "revive": {
+ "$ref": "#/definitions/settings/definitions/reviveSettings"
+ },
+ "rowserrcheck": {
+ "$ref": "#/definitions/settings/definitions/rowserrcheckSettings"
+ },
+ "sloglint": {
+ "$ref": "#/definitions/settings/definitions/sloglintSettings"
+ },
+ "spancheck": {
+ "$ref": "#/definitions/settings/definitions/spancheckSettings"
+ },
+ "staticcheck":{
+ "$ref": "#/definitions/settings/definitions/staticcheckSettings"
+ },
+ "tagalign": {
+ "$ref": "#/definitions/settings/definitions/tagalignSettings"
+ },
+ "tagliatelle": {
+ "$ref": "#/definitions/settings/definitions/tagliatelleSettings"
+ },
+ "testifylint": {
+ "$ref": "#/definitions/settings/definitions/testifylintSettings"
+ },
+ "testpackage": {
+ "$ref": "#/definitions/settings/definitions/testpackageSettings"
+ },
+ "thelper": {
+ "$ref": "#/definitions/settings/definitions/thelperSettings"
+ },
+ "usestdlibvars": {
+ "$ref": "#/definitions/settings/definitions/usestdlibvarsSettings"
+ },
+ "usetesting": {
+ "$ref": "#/definitions/settings/definitions/usetestingSettings"
+ },
+ "unconvert": {
+ "$ref": "#/definitions/settings/definitions/unconvertSettings"
+ },
+ "unparam": {
+ "$ref": "#/definitions/settings/definitions/unparamSettings"
+ },
+ "unqueryvet": {
+ "$ref": "#/definitions/settings/definitions/unqueryvetSettings"
+ },
+ "unused": {
+ "$ref": "#/definitions/settings/definitions/unusedSettings"
+ },
+ "varnamelen": {
+ "$ref": "#/definitions/settings/definitions/varnamelenSettings"
+ },
+ "whitespace": {
+ "$ref": "#/definitions/settings/definitions/whitespaceSettings"
+ },
+ "wrapcheck": {
+ "$ref": "#/definitions/settings/definitions/wrapcheckSettings"
+ },
+ "wsl": {
+ "$ref": "#/definitions/settings/definitions/wslSettings"
+ },
+ "wsl_v5": {
+ "$ref": "#/definitions/settings/definitions/wslSettingsV5"
+ },
+ "copyloopvar": {
+ "$ref": "#/definitions/settings/definitions/copyloopvarSettings"
+ },
+ "custom":{
+ "$ref": "#/definitions/settings/definitions/customSettings"
+ }
+ }
+ },
+ "exclusions":{
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "generated": {
+ "enum": ["strict", "lax", "disable"],
+ "default": "strict"
+ },
+ "warn-unused": {
+ "type": "boolean",
+ "default": false
+ },
+ "presets": {
+ "type": "array",
+ "items": {
+ "enum": [
+ "comments",
+ "std-error-handling",
+ "common-false-positives",
+ "legacy"
+ ]
+ }
+ },
+ "rules": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "properties": {
+ "path": {
+ "type": "string"
+ },
+ "path-except": {
+ "type": "string"
+ },
+ "linters": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/linter-names"
+ }
+ },
+ "text": {
+ "type": "string"
+ },
+ "source": {
+ "type": "string"
+ }
+ },
+ "anyOf": [
+ { "required": ["path"] },
+ { "required": ["path-except"] },
+ { "required": ["linters"] },
+ { "required": ["text"] },
+ { "required": ["source"] }
+ ]
+ }
+ },
+ "paths": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "paths-except": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ }
+ },
+ "formatters": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "enable": {
+ "description": "List of enabled formatters.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/formatter-names"
+ }
+ },
+ "settings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "gci": {
+ "$ref": "#/definitions/settings/definitions/gciSettings"
+ },
+ "gofmt": {
+ "$ref": "#/definitions/settings/definitions/gofmtSettings"
+ },
+ "gofumpt": {
+ "$ref": "#/definitions/settings/definitions/gofumptSettings"
+ },
+ "goimports": {
+ "$ref": "#/definitions/settings/definitions/goimportsSettings"
+ },
+ "golines": {
+ "$ref": "#/definitions/settings/definitions/golinesSettings"
+ }
+ }
+ },
+ "exclusions": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "generated": {
+ "enum": ["strict", "lax", "disable"],
+ "default": "strict"
+ },
+ "paths": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "warn-unused": {
+ "type": "boolean",
+ "default": false
+ }
+ }
+ }
+ }
+ },
+ "issues": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "max-issues-per-linter": {
+ "description": "Maximum issues count per one linter. Set to 0 to disable.",
+ "type": "integer",
+ "default": 50,
+ "minimum": 0
+ },
+ "max-same-issues": {
+ "description": "Maximum count of issues with the same text. Set to 0 to disable.",
+ "type": "integer",
+ "default": 3,
+ "minimum": 0
+ },
+ "new": {
+ "description": "Show only new issues: if there are unstaged changes or untracked files, only those changes are analyzed, else only changes in HEAD~ are analyzed.",
+ "type": "boolean",
+ "default": false
+ },
+ "new-from-merge-base": {
+ "description": "Show only new issues created after the best common ancestor (merge-base against HEAD).",
+ "type": "string"
+ },
+ "new-from-rev": {
+ "description": "Show only new issues created after this git revision.",
+ "type": "string"
+ },
+ "new-from-patch": {
+ "description": "Show only new issues created in git patch with this file path.",
+ "type": "string",
+ "examples": ["path/to/patch/file"]
+ },
+ "fix": {
+ "description": "Apply the fixes detected by the linters and formatters (if it's supported by the linter).",
+ "type": "boolean",
+ "default": false
+ },
+ "uniq-by-line": {
+ "description": "Make issues output unique by line.",
+ "type": "boolean",
+ "default": true
+ },
+ "whole-files": {
+ "description": "Show issues in any part of update files (requires new-from-rev or new-from-patch).",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "severity": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "default": {
+ "description": "Set the default severity for issues. If severity rules are defined and the issues do not match or no severity is provided to the rule this will be the default severity applied. Severities should match the supported severity names of the selected out format.",
+ "type": "string",
+ "default": ""
+ },
+ "rules": {
+ "description": "When a list of severity rules are provided, severity information will be added to lint issues. Severity rules have the same filtering capability as exclude rules except you are allowed to specify one matcher per severity rule.\nOnly affects out formats that support setting severity information.",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "severity": {
+ "type": "string"
+ },
+ "path": {
+ "type": "string"
+ },
+ "path-except": {
+ "type": "string"
+ },
+ "linters": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/linter-names"
+ }
+ },
+ "text": {
+ "type": "string"
+ },
+ "source": {
+ "type": "string"
+ }
+ },
+ "required": ["severity"],
+ "anyOf": [
+ { "required": ["path"] },
+ { "required": ["path-except"] },
+ { "required": ["linters"] },
+ { "required": ["text"] },
+ { "required": ["source"] }
+ ]
+ },
+ "default": []
+ }
+ },
+ "required": ["default"]
+ }
+ }
+}
diff --git a/vendor/github.com/golangci/golangci-lint/v2/jsonschema/golangci.v1.57.jsonschema.json b/vendor/github.com/golangci/golangci-lint/v2/jsonschema/golangci.v1.57.jsonschema.json
new file mode 100644
index 0000000000..a97c0d4291
--- /dev/null
+++ b/vendor/github.com/golangci/golangci-lint/v2/jsonschema/golangci.v1.57.jsonschema.json
@@ -0,0 +1,3480 @@
+{
+ "$schema": "http://json-schema.org/draft-07/schema#",
+ "$id": "https://json.schemastore.org/golangci-lint.json",
+ "definitions": {
+ "gocritic-checks": {
+ "enum": [
+ "appendAssign",
+ "appendCombine",
+ "argOrder",
+ "assignOp",
+ "badCall",
+ "badCond",
+ "badLock",
+ "badRegexp",
+ "badSorting",
+ "boolExprSimplify",
+ "builtinShadow",
+ "builtinShadowDecl",
+ "captLocal",
+ "caseOrder",
+ "codegenComment",
+ "commentedOutCode",
+ "commentedOutImport",
+ "commentFormatting",
+ "defaultCaseOrder",
+ "deferUnlambda",
+ "deferInLoop",
+ "deprecatedComment",
+ "docStub",
+ "dupArg",
+ "dupBranchBody",
+ "dupCase",
+ "dupImport",
+ "dupSubExpr",
+ "dynamicFmtString",
+ "elseif",
+ "emptyDecl",
+ "emptyFallthrough",
+ "emptyStringTest",
+ "equalFold",
+ "evalOrder",
+ "exitAfterDefer",
+ "exposedSyncMutex",
+ "externalErrorReassign",
+ "filepathJoin",
+ "flagDeref",
+ "flagName",
+ "hexLiteral",
+ "httpNoBody",
+ "hugeParam",
+ "ifElseChain",
+ "importShadow",
+ "indexAlloc",
+ "initClause",
+ "ioutilDeprecated",
+ "mapKey",
+ "methodExprCall",
+ "nestingReduce",
+ "newDeref",
+ "nilValReturn",
+ "octalLiteral",
+ "offBy1",
+ "paramTypeCombine",
+ "preferDecodeRune",
+ "preferFilepathJoin",
+ "preferFprint",
+ "preferStringWriter",
+ "preferWriteByte",
+ "ptrToRefParam",
+ "rangeExprCopy",
+ "rangeValCopy",
+ "redundantSprint",
+ "regexpMust",
+ "regexpPattern",
+ "regexpSimplify",
+ "returnAfterHttpError",
+ "ruleguard",
+ "singleCaseSwitch",
+ "sliceClear",
+ "sloppyLen",
+ "sloppyReassign",
+ "sloppyTypeAssert",
+ "sortSlice",
+ "sprintfQuotedString",
+ "sqlQuery",
+ "stringConcatSimplify",
+ "stringsCompare",
+ "stringXbytes",
+ "suspiciousSorting",
+ "switchTrue",
+ "syncMapLoadAndDelete",
+ "timeCmpSimplify",
+ "timeExprSimplify",
+ "tooManyResultsChecker",
+ "truncateCmp",
+ "typeAssertChain",
+ "typeDefFirst",
+ "typeSwitchVar",
+ "typeUnparen",
+ "uncheckedInlineErr",
+ "underef",
+ "unlabelStmt",
+ "unlambda",
+ "unnamedResult",
+ "unnecessaryBlock",
+ "unnecessaryDefer",
+ "unslice",
+ "valSwap",
+ "weakCond",
+ "whyNoLint",
+ "wrapperFunc",
+ "yodaStyleExpr"
+ ]
+ },
+ "gocritic-tags": {
+ "enum": [
+ "diagnostic",
+ "style",
+ "performance",
+ "experimental",
+ "opinionated",
+ "security"
+ ]
+ },
+ "gosec-rules": {
+ "enum": [
+ "G101",
+ "G102",
+ "G103",
+ "G104",
+ "G106",
+ "G107",
+ "G108",
+ "G109",
+ "G110",
+ "G111",
+ "G112",
+ "G113",
+ "G114",
+ "G201",
+ "G202",
+ "G203",
+ "G204",
+ "G301",
+ "G302",
+ "G303",
+ "G304",
+ "G305",
+ "G306",
+ "G307",
+ "G401",
+ "G402",
+ "G403",
+ "G404",
+ "G501",
+ "G502",
+ "G503",
+ "G504",
+ "G505",
+ "G601",
+ "G602"
+ ]
+ },
+ "govet-analyzers": {
+ "enum": [
+ "appends",
+ "asmdecl",
+ "assign",
+ "atomic",
+ "atomicalign",
+ "bools",
+ "buildtag",
+ "cgocall",
+ "composites",
+ "copylocks",
+ "deepequalerrors",
+ "defers",
+ "directive",
+ "errorsas",
+ "fieldalignment",
+ "findcall",
+ "framepointer",
+ "httpresponse",
+ "ifaceassert",
+ "loopclosure",
+ "lostcancel",
+ "nilfunc",
+ "nilness",
+ "printf",
+ "reflectvaluecompare",
+ "shadow",
+ "shift",
+ "sigchanyzer",
+ "slog",
+ "sortslice",
+ "stdmethods",
+ "stringintconv",
+ "structtag",
+ "testinggoroutine",
+ "tests",
+ "unmarshal",
+ "unreachable",
+ "unsafeptr",
+ "unusedresult",
+ "unusedwrite"
+ ]
+ },
+ "linters": {
+ "$comment": "anyOf with enum is used to allow auto completion of non-custom linters",
+ "description": "Linters usable.",
+ "anyOf": [
+ {
+ "enum": [
+ "asasalint",
+ "asciicheck",
+ "bidichk",
+ "bodyclose",
+ "containedctx",
+ "contextcheck",
+ "copyloopvar",
+ "cyclop",
+ "deadcode",
+ "decorder",
+ "depguard",
+ "dogsled",
+ "dupl",
+ "dupword",
+ "durationcheck",
+ "errcheck",
+ "errchkjson",
+ "errname",
+ "errorlint",
+ "execinquery",
+ "exhaustive",
+ "exhaustivestruct",
+ "exhaustruct",
+ "exportloopref",
+ "forbidigo",
+ "forcetypeassert",
+ "funlen",
+ "gci",
+ "ginkgolinter",
+ "gocheckcompilerdirectives",
+ "gochecknoglobals",
+ "gochecknoinits",
+ "gochecksumtype",
+ "gocognit",
+ "goconst",
+ "gocritic",
+ "gocyclo",
+ "godot",
+ "godox",
+ "goerr113",
+ "gofmt",
+ "gofumpt",
+ "goheader",
+ "goimports",
+ "golint",
+ "gomnd",
+ "gomoddirectives",
+ "gomodguard",
+ "goprintffuncname",
+ "gosec",
+ "gosimple",
+ "gosmopolitan",
+ "govet",
+ "grouper",
+ "ifshort",
+ "importas",
+ "inamedparam",
+ "ineffassign",
+ "interfacebloat",
+ "interfacer",
+ "intrange",
+ "ireturn",
+ "lll",
+ "loggercheck",
+ "maintidx",
+ "makezero",
+ "maligned",
+ "mirror",
+ "misspell",
+ "musttag",
+ "nakedret",
+ "nestif",
+ "nilerr",
+ "nilnil",
+ "nlreturn",
+ "noctx",
+ "nolintlint",
+ "nonamedreturns",
+ "nosnakecase",
+ "nosprintfhostport",
+ "paralleltest",
+ "perfsprint",
+ "prealloc",
+ "predeclared",
+ "promlinter",
+ "protogetter",
+ "reassign",
+ "revive",
+ "rowserrcheck",
+ "scopelint",
+ "sloglint",
+ "sqlclosecheck",
+ "staticcheck",
+ "structcheck",
+ "stylecheck",
+ "tagalign",
+ "tagliatelle",
+ "tenv",
+ "testableexamples",
+ "testifylint",
+ "testpackage",
+ "thelper",
+ "tparallel",
+ "typecheck",
+ "unconvert",
+ "unparam",
+ "unused",
+ "usestdlibvars",
+ "varcheck",
+ "varnamelen",
+ "wastedassign",
+ "whitespace",
+ "wrapcheck",
+ "wsl",
+ "zerologlint"
+ ]
+ },
+ {
+ "type": "string"
+ }
+ ]
+ }
+ },
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "run": {
+ "description": "Options for analysis running,",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "concurrency": {
+ "description": "Number of concurrent runners. Defaults to the number of available CPU cores.",
+ "type": "integer",
+ "minimum": 0,
+ "examples": [4]
+ },
+ "timeout": {
+ "description": "Timeout for the analysis.",
+ "type": "string",
+ "pattern": "^((\\d+h)?(\\d+m)?(\\d+(?:\\.\\d)?s)?|0)$",
+ "default": "1m",
+ "examples": ["30s", "5m", "5m30s"]
+ },
+ "issues-exit-code": {
+ "description": "Exit code when at least one issue was found.",
+ "type": "integer",
+ "default": 1
+ },
+ "tests": {
+ "description": "Enable inclusion of test files.",
+ "type": "boolean",
+ "default": true
+ },
+ "build-tags": {
+ "description": "List of build tags to pass to all linters.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "default": [],
+ "examples": [["mytag"]]
+ },
+ "modules-download-mode": {
+ "description": "Option to pass to \"go list -mod={option}\".\nSee \"go help modules\" for more information.",
+ "enum": ["mod", "readonly", "vendor"]
+ },
+ "allow-parallel-runners": {
+ "description": "Allow multiple parallel golangci-lint instances running. If disabled, golangci-lint acquires file lock on start.",
+ "type": "boolean",
+ "default": false
+ },
+ "allow-serial-runners": {
+ "description": "Allow multiple golangci-lint instances running, but serialize them around a lock.",
+ "type": "boolean",
+ "default": false
+ },
+ "go": {
+ "description": "Targeted Go version.",
+ "type": "string",
+ "default": "1.17"
+ }
+ }
+ },
+ "output": {
+ "description": "Output configuration options.",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "formats": {
+ "description": "Output formats to use.",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "path": {
+ "default": "stdout",
+ "anyOf": [
+ {
+ "enum": [ "stdout", "stderr" ]
+ },
+ {
+ "type": "string"
+ }
+ ]
+ },
+ "format": {
+ "default": "colored-line-number",
+ "enum": [
+ "colored-line-number",
+ "line-number",
+ "json",
+ "colored-tab",
+ "tab",
+ "checkstyle",
+ "code-climate",
+ "junit-xml",
+ "github-actions",
+ "teamcity"
+ ]
+ }
+ },
+ "required": ["format"]
+ }
+ },
+ "print-issued-lines": {
+ "description": "Print lines of code with issue.",
+ "type": "boolean",
+ "default": true
+ },
+ "print-linter-name": {
+ "description": "Print linter name in the end of issue text.",
+ "type": "boolean",
+ "default": true
+ },
+ "uniq-by-line": {
+ "description": "Make issues output unique by line.",
+ "type": "boolean",
+ "default": true
+ },
+ "path-prefix": {
+ "description": "Add a prefix to the output file references.",
+ "type": "string",
+ "default": ""
+ },
+ "show-stats": {
+ "description": "Show statistics per linter.",
+ "type": "boolean",
+ "default": false
+ },
+ "sort-order": {
+ "type": "array",
+ "items": {
+ "enum": ["linter", "severity", "file"]
+ }
+ },
+ "sort-results": {
+ "description": "Sort results by: filepath, line and column.",
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "linters-settings": {
+ "description": "All available settings of specific linters.",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "dupword": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "keywords": {
+ "description": "Keywords for detecting duplicate words. If this list is not empty, only the words defined in this list will be detected.",
+ "type": "array",
+ "uniqueItems": true,
+ "items": {
+ "type": "string",
+ "examples": ["the", "and", "a"]
+ }
+ },
+ "ignore": {
+ "description": "Keywords used to ignore detection.",
+ "type": "array",
+ "uniqueItems": true,
+ "items": {
+ "type": "string",
+ "examples": ["0C0C"]
+ }
+ }
+ }
+ },
+ "asasalint": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "exclude": {
+ "description": "To specify a set of function names to exclude.",
+ "type": "array",
+ "uniqueItems": true,
+ "items": {
+ "type": "string",
+ "examples": ["\\.Wrapf"]
+ }
+ },
+ "use-builtin-exclusions": {
+ "description": "To enable/disable the asasalint builtin exclusions of function names.",
+ "type": "boolean",
+ "default": true
+ },
+ "ignore-test": {
+ "description": "Ignore *_test.go files.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "bidichk": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "left-to-right-embedding": {
+ "description": "Disallow: LEFT-TO-RIGHT-EMBEDDING",
+ "type": "boolean",
+ "default": false
+ },
+ "right-to-left-embedding": {
+ "description": "Disallow: RIGHT-TO-LEFT-EMBEDDING",
+ "type": "boolean",
+ "default": false
+ },
+ "pop-directional-formatting": {
+ "description": "Disallow: POP-DIRECTIONAL-FORMATTING",
+ "type": "boolean",
+ "default": false
+ },
+ "left-to-right-override": {
+ "description": "Disallow: LEFT-TO-RIGHT-OVERRIDE",
+ "type": "boolean",
+ "default": false
+ },
+ "right-to-left-override": {
+ "description": "Disallow: RIGHT-TO-LEFT-OVERRIDE",
+ "type": "boolean",
+ "default": false
+ },
+ "left-to-right-isolate": {
+ "description": "Disallow: LEFT-TO-RIGHT-ISOLATE",
+ "type": "boolean",
+ "default": false
+ },
+ "right-to-left-isolate": {
+ "description": "Disallow: RIGHT-TO-LEFT-ISOLATE",
+ "type": "boolean",
+ "default": false
+ },
+ "first-strong-isolate": {
+ "description": "Disallow: FIRST-STRONG-ISOLATE",
+ "type": "boolean",
+ "default": false
+ },
+ "pop-directional-isolate": {
+ "description": "Disallow: POP-DIRECTIONAL-ISOLATE",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "cyclop": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "skip-tests": {
+ "description": "Should the linter execute on test files as well",
+ "type": "boolean",
+ "default": false
+ },
+ "max-complexity": {
+ "description": "Max complexity the function can have",
+ "type": "integer",
+ "default": 10,
+ "minimum": 0
+ },
+ "package-average": {
+ "description": "Max average complexity in package",
+ "type": "number",
+ "default": 0,
+ "minimum": 0
+ }
+ }
+ },
+ "decorder": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "dec-order": {
+ "type": "array",
+ "default": [["type", "const", "var", "func"]],
+ "items": {
+ "enum": ["type", "const", "var", "func"]
+ }
+ },
+ "ignore-underscore-vars": {
+ "description": "Underscore vars (vars with \"_\" as the name) will be ignored at all checks",
+ "default": true,
+ "type": "boolean"
+ },
+ "disable-dec-order-check": {
+ "description": "Order of declarations is not checked",
+ "default": true,
+ "type": "boolean"
+ },
+ "disable-init-func-first-check": {
+ "description": "Allow init func to be anywhere in file",
+ "default": true,
+ "type": "boolean"
+ },
+ "disable-dec-num-check": {
+ "description": "Multiple global type, const and var declarations are allowed",
+ "default": true,
+ "type": "boolean"
+ },
+ "disable-type-dec-num-check": {
+ "description": "Type declarations will be ignored for dec num check",
+ "default": true,
+ "type": "boolean"
+ },
+ "disable-const-dec-num-check": {
+ "description": "Const declarations will be ignored for dec num check",
+ "default": true,
+ "type": "boolean"
+ },
+ "disable-var-dec-num-check": {
+ "description": "Var declarations will be ignored for dec num check",
+ "default": true,
+ "type": "boolean"
+ }
+ }
+ },
+ "depguard": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "rules": {
+ "description": "Rules to apply.",
+ "type": "object",
+ "additionalProperties": false,
+ "patternProperties": {
+ "^[^.]+$": {
+ "description": "Name of a rule.",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "list-mode": {
+ "description": "Used to determine the package matching priority.",
+ "enum": ["original", "strict", "lax"],
+ "default": "original"
+ },
+ "files": {
+ "description": "List of file globs that will match this list of settings to compare against.",
+ "additionalProperties": false,
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "allow": {
+ "description": "List of allowed packages.",
+ "additionalProperties": false,
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "deny": {
+ "description": "Packages that are not allowed where the value is a suggestion.",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "desc": {
+ "description": "Description",
+ "type": "string"
+ },
+ "pkg": {
+ "description": "Package",
+ "type": "string"
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "dogsled": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "max-blank-identifiers": {
+ "description": "Check assignments with too many blank identifiers.",
+ "type": "integer",
+ "default": 2,
+ "minimum": 0
+ }
+ }
+ },
+ "dupl": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "threshold": {
+ "description": "Tokens count to trigger issue.",
+ "type": "integer",
+ "default": 150,
+ "minimum": 0
+ }
+ }
+ },
+ "errcheck": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "check-type-assertions": {
+ "description": "Report about not checking errors in type assertions, i.e.: `a := b.(MyStruct)`",
+ "type": "boolean",
+ "default": false
+ },
+ "check-blank": {
+ "description": "Report about assignment of errors to blank identifier",
+ "type": "boolean",
+ "default": false
+ },
+ "ignore": {
+ "description": "DEPRECATED: use `exclude-functions` instead. Comma-separated list of pairs of the form \"pkg:regex\".",
+ "type": "string",
+ "default": "fmt:.*"
+ },
+ "exclude": {
+ "description": "DEPRECATED: use `exclude-functions` instead. Path to a file containing a list of functions to exclude from checking.",
+ "type": "string",
+ "examples": ["/path/to/file.txt"]
+ },
+ "exclude-functions": {
+ "description": "List of functions to exclude from checking, where each entry is a single function to exclude",
+ "type": "array",
+ "examples": ["io/ioutil.ReadFile", "io.Copy(*bytes.Buffer)"],
+ "items": {
+ "type": "string"
+ }
+ },
+ "disable-default-exclusions": {
+ "description": "To disable the errcheck built-in exclude list",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "errchkjson": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "check-error-free-encoding": {
+ "type": "boolean",
+ "default": false
+ },
+ "report-no-exported": {
+ "description": "Issue on struct that doesn't have exported fields.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "errorlint": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "errorf": {
+ "description": "Check whether fmt.Errorf uses the %w verb for formatting errors",
+ "type": "boolean",
+ "default": true
+ },
+ "errorf-multi": {
+ "description": "Permit more than 1 %w verb, valid per Go 1.20",
+ "type": "boolean",
+ "default": true
+ },
+ "asserts": {
+ "description": "Check for plain type assertions and type switches.",
+ "type": "boolean",
+ "default": true
+ },
+ "comparison": {
+ "description": "Check for plain error comparisons",
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "exhaustive": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "check": {
+ "description": "Program elements to check for exhaustiveness.",
+ "type": "array",
+ "uniqueItems": true,
+ "items": {
+ "type": "string",
+ "examples": ["switch", "map"]
+ }
+ },
+ "check-generated": {
+ "description": "Check switch statements in generated files",
+ "type": "boolean",
+ "default": false
+ },
+ "explicit-exhaustive-switch": {
+ "description": "Only run exhaustive check on switches with \"//exhaustive:enforce\" comment.",
+ "type": "boolean",
+ "default": false
+ },
+ "explicit-exhaustive-map": {
+ "description": "Only run exhaustive check on map literals with \"//exhaustive:enforce\" comment.",
+ "type": "boolean",
+ "default": false
+ },
+ "default-case-required": {
+ "description": "Switch statement requires default case even if exhaustive.",
+ "type": "boolean",
+ "default": false
+ },
+ "default-signifies-exhaustive": {
+ "description": "Presence of `default` case in switch statements satisfies exhaustiveness, even if all enum members are not listed.",
+ "type": "boolean",
+ "default": false
+ },
+ "ignore-enum-members": {
+ "description": "Enum members matching `regex` do not have to be listed in switch statements to satisfy exhaustiveness",
+ "type": "string"
+ },
+ "ignore-enum-types": {
+ "description": "Enum types matching the supplied regex do not have to be listed in switch statements to satisfy exhaustiveness.",
+ "type": "string"
+ },
+ "package-scope-only": {
+ "description": "Consider enums only in package scopes, not in inner scopes.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "exhaustruct": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "include": {
+ "description": "List of regular expressions to match struct packages and names.",
+ "type": "array",
+ "examples": [".*\\.Test"],
+ "items": {
+ "type": "string"
+ }
+ },
+ "exclude": {
+ "description": "List of regular expressions to exclude struct packages and names from check.",
+ "type": "array",
+ "examples": ["cobra\\.Command$"],
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "forbidigo": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "exclude-godoc-examples": {
+ "description": "Exclude code in godoc examples.",
+ "type": "boolean",
+ "default": true
+ },
+ "analyze-types": {
+ "description": "Instead of matching the literal source code, use type information to replace expressions with strings that contain the package name and (for methods and fields) the type name.",
+ "type": "boolean",
+ "default": true
+ },
+ "forbid": {
+ "description": "List of identifiers to forbid (written using `regexp`)",
+ "type": "array",
+ "examples": ["^print.*$"],
+ "items": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "p": {
+ "description": "Pattern",
+ "type": "string"
+ },
+ "pkg": {
+ "description": "Package",
+ "type": "string"
+ },
+ "msg": {
+ "description": "Message",
+ "type": "string"
+ }
+ }
+ }
+ ]
+ }
+ }
+ }
+ },
+ "funlen": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "lines": {
+ "description": "Limit lines number per function.",
+ "type": "integer",
+ "default": 60
+ },
+ "statements": {
+ "description": "Limit statements number per function.",
+ "type": "integer",
+ "default": 40
+ },
+ "ignore-comments": {
+ "description": "Ignore comments when counting lines.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "gci": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "local-prefixes": {
+ "description": "DEPRECATED: use 'sections' and 'prefix(github.com/org/project)' instead.",
+ "type": "string",
+ "examples": ["github.com/org/project"]
+ },
+ "sections": {
+ "description": "Section configuration to compare against.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "default": ["standard", "default"]
+ },
+ "skip-generated": {
+ "description": "Skip generated files.",
+ "type": "boolean",
+ "default": true
+ },
+ "custom-order": {
+ "description": "Enable custom order of sections.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "ginkgolinter": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "suppress-len-assertion": {
+ "description": "Suppress the wrong length assertion warning.",
+ "type": "boolean",
+ "default": false
+ },
+ "suppress-nil-assertion": {
+ "description": "Suppress the wrong nil assertion warning.",
+ "type": "boolean",
+ "default": false
+ },
+ "suppress-err-assertion": {
+ "description": "Suppress the wrong error assertion warning.",
+ "type": "boolean",
+ "default": false
+ },
+ "suppress-compare-assertion": {
+ "description": "Suppress the wrong comparison assertion warning.",
+ "type": "boolean",
+ "default": false
+ },
+ "suppress-async-assertion": {
+ "description": "Suppress the function all in async assertion warning.",
+ "type": "boolean",
+ "default": false
+ },
+ "suppress-type-compare-assertion": {
+ "description": "Suppress warning for comparing values from different types, like int32 and uint32.",
+ "type": "boolean",
+ "default": false
+ },
+ "forbid-focus-container": {
+ "description": "Trigger warning for ginkgo focus containers like FDescribe, FContext, FWhen or FIt.",
+ "type": "boolean",
+ "default": false
+ },
+ "allow-havelen-zero": {
+ "description": "Don't trigger warnings for HaveLen(0).",
+ "type": "boolean",
+ "default": false
+ },
+ "force-expect-to": {
+ "description": "Force using `Expect` with `To`, `ToNot` or `NotTo`",
+ "type": "boolean",
+ "default": false
+ },
+ "validate-async-intervals": {
+ "description": "Best effort validation of async intervals (timeout and polling).",
+ "type": "boolean",
+ "default": false
+ },
+ "forbid-spec-pollution": {
+ "description": "Trigger a warning for variable assignments in ginkgo containers like `Describe`, `Context` and `When`, instead of in `BeforeEach()`.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "gocognit": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "min-complexity": {
+ "description": "Minimal code complexity to report (we recommend 10-20).",
+ "type": "integer",
+ "default": 30
+ }
+ }
+ },
+ "goconst": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "match-constant": {
+ "description": "Look for existing constants matching the values",
+ "type": "boolean",
+ "default": true
+ },
+ "min-len": {
+ "description": "Minimum length of string constant.",
+ "type": "integer",
+ "default": 3
+ },
+ "min-occurrences": {
+ "description": "Minimum occurrences count to trigger.",
+ "type": "integer",
+ "default": 3
+ },
+ "ignore-tests": {
+ "description": "Ignore test files.",
+ "type": "boolean",
+ "default": false
+ },
+ "ignore-calls": {
+ "description": "Ignore when constant is not used as function argument",
+ "type": "boolean",
+ "default": true
+ },
+ "ignore-strings": {
+ "description": "Exclude strings matching the given regular expression",
+ "type": "string"
+ },
+ "numbers": {
+ "description": "Search also for duplicated numbers.",
+ "type": "boolean",
+ "default": false
+ },
+ "min": {
+ "description": "Minimum value, only works with `numbers`",
+ "type": "integer",
+ "default": 3
+ },
+ "max": {
+ "description": "Maximum value, only works with `numbers`",
+ "type": "integer",
+ "default": 3
+ }
+ }
+ },
+ "gocritic": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "enabled-checks": {
+ "description": "Which checks should be enabled. By default, a list of stable checks is used. To see it, run `GL_DEBUG=gocritic golangci-lint run`.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/gocritic-checks"
+ }
+ },
+ "disabled-checks": {
+ "description": "Which checks should be disabled.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/gocritic-checks"
+ },
+ "default": []
+ },
+ "enabled-tags": {
+ "description": "Enable multiple checks by tags, run `GL_DEBUG=gocritic golangci-lint run` to see all tags and checks.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/gocritic-tags"
+ }
+ },
+ "disabled-tags": {
+ "description": "Disable multiple checks by tags, run `GL_DEBUG=gocritic golangci-lint run` to see all tags and checks.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/gocritic-tags"
+ }
+ },
+ "settings": {
+ "description": "Settings passed to gocritic. Properties must be valid and enabled check names.",
+ "type": "object",
+ "propertyNames": {
+ "$ref": "#/definitions/gocritic-checks"
+ }
+ },
+ "disable-all": {
+ "type": "boolean",
+ "default": false
+ },
+ "enable-all": {
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "gocyclo": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "min-complexity": {
+ "description": "Minimum code complexity to report (we recommend 10-20).",
+ "type": "integer",
+ "default": 30
+ }
+ }
+ },
+ "godot": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "scope": {
+ "description": "Comments to be checked.",
+ "enum": ["declarations", "toplevel", "all"],
+ "default": "declarations"
+ },
+ "exclude": {
+ "description": "List of regexps for excluding particular comment lines from check.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "period": {
+ "description": "Check that each sentence ends with a period.",
+ "type": "boolean",
+ "default": true
+ },
+ "capital": {
+ "description": "Check that each sentence starts with a capital letter.",
+ "type": "boolean",
+ "default": false
+ },
+ "check-all": {
+ "description": "DEPRECATED: Check all top-level comments, not only declarations.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "godox": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "keywords": {
+ "description": "Report any comments starting with one of these keywords. This is useful for TODO or FIXME comments that might be left in the code accidentally and should be resolved before merging.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "default": ["TODO", "BUG", "FIXME"]
+ }
+ }
+ },
+ "gofmt": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "simplify": {
+ "description": "Simplify code.",
+ "type": "boolean",
+ "default": true
+ },
+ "rewrite-rules": {
+ "description": "Apply the rewrite rules to the source before reformatting.",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "pattern": {
+ "type": "string"
+ },
+ "replacement": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ }
+ },
+ "interfacebloat": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "max": {
+ "description": "The maximum number of methods allowed for an interface.",
+ "type": "integer"
+ }
+ }
+ },
+ "gofumpt": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "extra-rules": {
+ "description": "Choose whether or not to use the extra rules that are disabled by default.",
+ "type": "boolean",
+ "default": false
+ },
+ "lang-version": {
+ "description": "Select the Go version to target.",
+ "type": "string",
+ "default": "1.15"
+ },
+ "module-path": {
+ "description": " Module path which contains the source code being formatted.",
+ "type": "string"
+ }
+ }
+ },
+ "goheader": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "values": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "const": {
+ "description": "Constants to use in the template.",
+ "type": "object",
+ "patternProperties": {
+ "^.+$": {
+ "description": "Value for the constant.",
+ "type": "string"
+ }
+ },
+ "additionalProperties": false,
+ "examples": [
+ {
+ "YEAR": "2030",
+ "COMPANY": "MY FUTURISTIC COMPANY"
+ }
+ ]
+ },
+ "regexp": {
+ "description": "Regular expressions to use in your template.",
+ "type": "object",
+ "additionalProperties": false,
+ "patternProperties": {
+ "^.+$": {
+ "type": "string"
+ }
+ },
+ "examples": [
+ {
+ "AUTHOR": ".*@mycompany\\.com"
+ }
+ ]
+ }
+ }
+ },
+ "template": {
+ "description": "Template to put on top of every file.",
+ "type": "string",
+ "examples": [
+ "{{ MY COMPANY }}\nSPDX-License-Identifier: Apache-2.0\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at:\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License."
+ ]
+ },
+ "template-path": {
+ "description": "Path to the file containing the template source.",
+ "type": "string",
+ "examples": ["my_header_template.txt"]
+ }
+ },
+ "oneOf": [
+ { "required": ["template"] },
+ { "required": ["template-path"] }
+ ]
+ },
+ "goimports": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "local-prefixes": {
+ "description": "Put imports beginning with prefix after 3rd-party packages. It is a comma-separated list of prefixes.",
+ "type": "string",
+ "examples": ["github.com/org/project"]
+ }
+ }
+ },
+ "gomnd": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "ignored-files": {
+ "description": "List of file patterns to exclude from analysis.",
+ "examples": [["magic1_.*.go"]],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ignored-functions": {
+ "description": "Comma-separated list of function patterns to exclude from the analysis.",
+ "examples": [["math.*", "http.StatusText", "make"]],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ignored-numbers": {
+ "description": "List of numbers to exclude from analysis.",
+ "examples": [["1000", "1234_567_890", "3.14159264"]],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "checks": {
+ "description": "The list of enabled checks, see https://github.com/tommy-muehle/go-mnd/#checks for description.",
+ "type": "array",
+ "items": {
+ "enum": [
+ "argument",
+ "case",
+ "condition",
+ "operation",
+ "return",
+ "assign"
+ ]
+ }
+ }
+ }
+ },
+ "gomoddirectives": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "replace-local": {
+ "description": "Allow local `replace` directives.",
+ "type": "boolean",
+ "default": true
+ },
+ "replace-allow-list": {
+ "description": "List of allowed `replace` directives.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "retract-allow-no-explanation": {
+ "description": "Allow to not explain why the version has been retracted in the `retract` directives.",
+ "type": "boolean",
+ "default": true
+ },
+ "exclude-forbidden": {
+ "description": "Forbid the use of the `exclude` directives.",
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "gomodguard": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "allowed": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "modules": {
+ "description": "List of allowed modules.",
+ "type": "array",
+ "items": {
+ "type": "string",
+ "examples": ["gopkg.in/yaml.v2"]
+ }
+ },
+ "domains": {
+ "description": "List of allowed module domains.",
+ "type": "array",
+ "items": {
+ "type": "string",
+ "examples": ["golang.org"]
+ }
+ }
+ }
+ },
+ "blocked": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "modules": {
+ "description": "List of blocked modules.",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "patternProperties": {
+ "^.+$": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "recommendations": {
+ "description": "Recommended modules that should be used instead.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "reason": {
+ "description": "Reason why the recommended module should be used.",
+ "type": "string"
+ }
+ }
+ }
+ },
+ "additionalProperties": false
+ }
+ },
+ "versions": {
+ "description": "List of blocked module version constraints.",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "patternProperties": {
+ "^.*$": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "version": {
+ "description": "Version constraint.",
+ "type": "string"
+ },
+ "reason": {
+ "description": "Reason why the version constraint exists.",
+ "type": "string"
+ }
+ },
+ "required": ["reason"]
+ }
+ }
+ }
+ },
+ "local_replace_directives": {
+ "description": "Raise lint issues if loading local path with replace directive",
+ "type": "boolean",
+ "default": true
+ }
+ }
+ }
+ }
+ },
+ "gosimple": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "go": {
+ "description": "Targeted Go version",
+ "type": "string",
+ "default": "1.13"
+ },
+ "checks": {
+ "type": "array",
+ "items": {
+ "anyOf": [
+ {
+ "enum": ["all"]
+ },
+ {
+ "type": "string"
+ }
+ ]
+ }
+ }
+ }
+ },
+ "gosec": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "includes": {
+ "type": "array",
+ "description": "To select a subset of rules to run",
+ "examples": [["G401"]],
+ "items": {
+ "$ref": "#/definitions/gosec-rules"
+ }
+ },
+ "excludes": {
+ "type": "array",
+ "description": "To specify a set of rules to explicitly exclude",
+ "examples": [["G401"]],
+ "items": {
+ "$ref": "#/definitions/gosec-rules"
+ }
+ },
+ "exclude-generated": {
+ "description": "Exclude generated files",
+ "type": "boolean",
+ "default": false
+ },
+ "severity": {
+ "description": "Filter out the issues with a lower severity than the given value",
+ "type": "string",
+ "enum": ["low", "medium", "high"],
+ "default": "low"
+ },
+ "confidence": {
+ "description": "Filter out the issues with a lower confidence than the given value",
+ "type": "string",
+ "enum": ["low", "medium", "high"],
+ "default": "low"
+ },
+ "config": {
+ "description": "To specify the configuration of rules",
+ "type": "object"
+ },
+ "concurrency": {
+ "description": "Concurrency value",
+ "type": "integer"
+ }
+ }
+ },
+ "gosmopolitan": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "allow-time-local": {
+ "description": "Allow and ignore `time.Local` usages.",
+ "type": "boolean",
+ "default": false
+ },
+ "escape-hatches": {
+ "description": "List of fully qualified names in the `full/pkg/path.name` form, to act as \"i18n escape hatches\".",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ignore-tests": {
+ "description": "Ignore test files.",
+ "type": "boolean",
+ "default": false
+ },
+ "watch-for-scripts": {
+ "description": "List of Unicode scripts to watch for any usage in string literals.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "govet": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "settings": {
+ "description": "Settings per analyzer. Map of analyzer name to specific settings.\nRun `go tool vet help` to find out more.",
+ "type": "object",
+ "propertyNames": {
+ "$ref": "#/definitions/govet-analyzers"
+ },
+ "patternProperties": {
+ "^.*$": {
+ "description": "Run `go tool vet help ` to see all settings.",
+ "type": "object"
+ }
+ }
+ },
+ "enable": {
+ "description": "Enable analyzers by name.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/govet-analyzers"
+ }
+ },
+ "disable": {
+ "description": "Disable analyzers by name.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/govet-analyzers"
+ }
+ },
+ "enable-all": {
+ "description": "Enable all analyzers.",
+ "type": "boolean",
+ "default": false
+ },
+ "disable-all": {
+ "description": "Disable all analyzers.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "grouper": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "const-require-single-const": {
+ "type": "boolean",
+ "default": false
+ },
+ "const-require-grouping": {
+ "type": "boolean",
+ "default": false
+ },
+ "import-require-single-import": {
+ "type": "boolean",
+ "default": false
+ },
+ "import-require-grouping": {
+ "type": "boolean",
+ "default": false
+ },
+ "type-require-single-type": {
+ "type": "boolean",
+ "default": false
+ },
+ "type-require-grouping": {
+ "type": "boolean",
+ "default": false
+ },
+ "var-require-single-var": {
+ "type": "boolean",
+ "default": false
+ },
+ "var-require-grouping": {
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "importas": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "no-unaliased": {
+ "description": "Do not allow unaliased imports of aliased packages.",
+ "type": "boolean",
+ "default": false
+ },
+ "no-extra-aliases": {
+ "description": "Do not allow non-required aliases.",
+ "type": "boolean",
+ "default": false
+ },
+ "alias": {
+ "description": "List of aliases",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "pkg": {
+ "description": "Package path e.g. knative.dev/serving/pkg/apis/autoscaling/v1alpha1",
+ "type": "string"
+ },
+ "alias": {
+ "description": "Package alias e.g. autoscalingv1alpha1",
+ "type": "string"
+ }
+ },
+ "required": ["pkg", "alias"]
+ }
+ }
+ }
+ },
+ "inamedparam": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "skip-single-param": {
+ "description": "Skips check for interface methods with only a single parameter.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "ireturn": {
+ "type": "object",
+ "additionalProperties": false,
+ "description": "Use either `reject` or `allow` properties for interfaces matching.",
+ "properties": {
+ "allow": {
+ "type": "array",
+ "items": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "enum": ["anon", "error", "empty", "stdlib"]
+ }
+ ]
+ }
+ },
+ "reject": {
+ "type": "array",
+ "items": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "enum": ["anon", "error", "empty", "stdlib"]
+ }
+ ]
+ }
+ }
+ },
+ "anyOf": [
+ {
+ "not": {
+ "properties": {
+ "allow": {
+ "const": "reject"
+ }
+ }
+ },
+ "required": ["allow"]
+ },
+ {
+ "required": ["reject"]
+ }
+ ]
+ },
+ "lll": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "tab-width": {
+ "description": "Width of \"\\t\" in spaces.",
+ "type": "integer",
+ "minimum": 0,
+ "default": 1
+ },
+ "line-length": {
+ "description": "Maximum allowed line length, lines longer will be reported.",
+ "type": "integer",
+ "minimum": 1,
+ "default": 120
+ }
+ }
+ },
+ "maintidx": {
+ "description": "Maintainability index https://docs.microsoft.com/en-us/visualstudio/code-quality/code-metrics-maintainability-index-range-and-meaning?view=vs-2022",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "under": {
+ "description": "Minimum accatpable maintainability index level (see https://docs.microsoft.com/en-us/visualstudio/code-quality/code-metrics-maintainability-index-range-and-meaning?view=vs-2022)",
+ "type": "number",
+ "default": 20
+ }
+ }
+ },
+ "makezero": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "always": {
+ "description": "Allow only slices initialized with a length of zero.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "loggercheck": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "kitlog": {
+ "description": "Allow check for the github.com/go-kit/log library.",
+ "type": "boolean",
+ "default": true
+ },
+ "klog": {
+ "description": "Allow check for the k8s.io/klog/v2 library.",
+ "type": "boolean",
+ "default": true
+ },
+ "logr": {
+ "description": "Allow check for the github.com/go-logr/logr library.",
+ "type": "boolean",
+ "default": true
+ },
+ "zap": {
+ "description": "Allow check for the \"sugar logger\" from go.uber.org/zap library.",
+ "type": "boolean",
+ "default": true
+ },
+ "require-string-key": {
+ "description": "Require all logging keys to be inlined constant strings.",
+ "type": "boolean",
+ "default": false
+ },
+ "no-printf-like": {
+ "description": "Require printf-like format specifier (%s, %d for example) not present.",
+ "type": "boolean",
+ "default": false
+ },
+ "rules": {
+ "description": "List of custom rules to check against, where each rule is a single logger pattern, useful for wrapped loggers.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "misspell": {
+ "description": "Correct spellings using locale preferences for US or UK. Default is to use a neutral variety of English.",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "locale": {
+ "enum": ["US", "UK"]
+ },
+ "ignore-words": {
+ "description": "List of words to ignore.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "mode": {
+ "description": "Mode of the analysis.",
+ "enum": ["restricted", "", "default"],
+ "default": ""
+ },
+ "extra-words": {
+ "description": "Extra word corrections.",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "correction": {
+ "type": "string"
+ },
+ "typo": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ }
+ },
+ "musttag": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "functions": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "name": {
+ "type": "string"
+ },
+ "tag": {
+ "type": "string"
+ },
+ "arg-pos": {
+ "type": "integer"
+ }
+ }
+ }
+ }
+ }
+ },
+ "nakedret": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "max-func-lines": {
+ "description": "Report if a function has more lines of code than this value and it has naked returns.",
+ "type": "integer",
+ "minimum": 0,
+ "default": 30
+ }
+ }
+ },
+ "nestif": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "min-complexity": {
+ "description": "Minimum complexity of \"if\" statements to report.",
+ "type": "integer",
+ "default": 5
+ }
+ }
+ },
+ "nilnil": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "checked-types": {
+ "type": "array",
+ "description": "Order of return types to check.",
+ "items": {
+ "enum": ["ptr", "func", "iface", "map", "chan"]
+ },
+ "default": ["ptr", "func", "iface", "map", "chan"]
+ }
+ }
+ },
+ "nlreturn": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "block-size": {
+ "description": "set block size that is still ok",
+ "type": "number",
+ "default": 0,
+ "minimum": 0
+ }
+ }
+ },
+ "nolintlint": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "allow-unused": {
+ "description": "Enable to ensure that nolint directives are all used.",
+ "type": "boolean",
+ "default": true
+ },
+ "allow-no-explanation": {
+ "description": "Exclude these linters from requiring an explanation.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/linters"
+ },
+ "default": []
+ },
+ "require-explanation": {
+ "description": "Enable to require an explanation of nonzero length after each nolint directive.",
+ "type": "boolean",
+ "default": false
+ },
+ "require-specific": {
+ "description": "Enable to require nolint directives to mention the specific linter being suppressed.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "reassign": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "patterns": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "nonamedreturns": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "report-error-in-defer": {
+ "description": "Report named error if it is assigned inside defer.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "paralleltest": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "ignore-missing": {
+ "description": "Ignore missing calls to `t.Parallel()` and only report incorrect uses of it.",
+ "type": "boolean",
+ "default": false
+ },
+ "ignore-missing-subtests": {
+ "description": "Ignore missing calls to `t.Parallel()` in subtests. Top-level tests are still required to have `t.Parallel`, but subtests are allowed to skip it.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "perfsprint": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "int-conversion": {
+ "description": "Optimizes even if it requires an int or uint type cast.",
+ "type": "boolean",
+ "default": true
+ },
+ "err-error": {
+ "description": "Optimizes into `err.Error()` even if it is only equivalent for non-nil errors.",
+ "type": "boolean",
+ "default": false
+ },
+ "errorf": {
+ "description": "Optimizes `fmt.Errorf`.",
+ "type": "boolean",
+ "default": true
+ },
+ "sprintf1": {
+ "description": "Optimizes `fmt.Sprintf` with only one argument.",
+ "type": "boolean",
+ "default": true
+ },
+ "strconcat": {
+ "description": "Optimizes into strings concatenation.",
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "prealloc": {
+ "description": "We do not recommend using this linter before doing performance profiling.\nFor most programs usage of `prealloc` will be premature optimization.",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "simple": {
+ "description": "Report preallocation suggestions only on simple loops that have no returns/breaks/continues/gotos in them.",
+ "type": "boolean",
+ "default": true
+ },
+ "range-loops": {
+ "description": "Report preallocation suggestions on range loops.",
+ "type": "boolean",
+ "default": true
+ },
+ "for-loops": {
+ "description": "Report preallocation suggestions on for loops.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "predeclared": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "ignore": {
+ "description": "Comma-separated list of predeclared identifiers to not report on.",
+ "type": "string"
+ },
+ "q": {
+ "description": "Include method names and field names (i.e., qualified names) in checks.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "promlinter": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "strict": {},
+ "disabled-linters": {
+ "type": "array",
+ "items": {
+ "enum": [
+ "Help",
+ "MetricUnits",
+ "Counter",
+ "HistogramSummaryReserved",
+ "MetricTypeInName",
+ "ReservedChars",
+ "CamelCase",
+ "UnitAbbreviations"
+ ]
+ }
+ }
+ }
+ },
+ "protogetter": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "skip-generated-by": {
+ "type": "array",
+ "items": {
+ "type": "string",
+ "examples": ["protoc-gen-go-my-own-generator"]
+ }
+ },
+ "skip-files": {
+ "type": "array",
+ "items": {
+ "type": "string",
+ "examples": ["*.pb.go"]
+ }
+ },
+ "skip-any-generated": {
+ "description": "Skip any generated files from the checking.",
+ "type": "boolean",
+ "default": false
+ },
+ "replace-first-arg-in-append": {
+ "description": "Skip first argument of append function.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "revive": {
+ "type": "object",
+ "additionalProperties": false,
+ "examples": [
+ {
+ "ignore-generated-header": true,
+ "severity": "warning",
+ "rules": [
+ {
+ "name": "indent-error-flow",
+ "severity": "warning"
+ },
+ {
+ "name": "add-constant",
+ "severity": "warning",
+ "arguments": [
+ {
+ "maxLitCount": "3",
+ "allowStrs": "\"\"",
+ "allowInts": "0,1,2",
+ "allowFloats": "0.0,0.,1.0,1.,2.0,2."
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ "properties": {
+ "max-open-files": {
+ "type": "integer"
+ },
+ "ignore-generated-header": {
+ "type": "boolean"
+ },
+ "confidence": {
+ "type": "number"
+ },
+ "severity": {
+ "type": "string",
+ "enum": ["warning", "error"]
+ },
+ "enable-all-rules": {
+ "type": "boolean",
+ "default": false
+ },
+ "directives": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "name": {
+ "type": "string",
+ "enum": ["specify-disable-reason"]
+ },
+ "severity": {
+ "type": "string",
+ "enum": ["warning", "error"]
+ },
+ "exclude": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "arguments": {
+ "type": "array"
+ }
+ }
+ }
+ },
+ "rules": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "required": ["name"],
+ "properties": {
+ "name": {
+ "type": "string",
+ "title": "The rule name"
+ },
+ "disabled": {
+ "type": "boolean"
+ },
+ "severity": {
+ "type": "string",
+ "enum": ["warning", "error"]
+ },
+ "exclude": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "arguments": {
+ "type": "array"
+ }
+ }
+ }
+ }
+ }
+ },
+ "rowserrcheck": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "packages": {
+ "type": "array",
+ "items": {
+ "description": "",
+ "type": "string",
+ "examples": ["github.com/jmoiron/sqlx"]
+ }
+ }
+ }
+ },
+ "sloglint": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "kv-only": {
+ "description": "Enforce using key-value pairs only (incompatible with attr-only).",
+ "type": "boolean",
+ "default": false
+ },
+ "no-global": {
+ "description": "Enforce not using global loggers.",
+ "enum": ["", "all", "default"],
+ "default": ""
+ },
+ "no-mixed-args": {
+ "description": "Enforce not mixing key-value pairs and attributes.",
+ "type": "boolean",
+ "default": true
+ },
+ "context-only": {
+ "description": "Enforce using methods that accept a context.",
+ "type": "boolean",
+ "default": false
+ },
+ "static-msg": {
+ "description": "Enforce using static values for log messages.",
+ "type": "boolean",
+ "default": false
+ },
+ "key-naming-case": {
+ "description": "Enforce a single key naming convention.",
+ "enum": ["snake", "kebab", "camel", "pascal"]
+ },
+ "attr-only": {
+ "description": "Enforce using attributes only (incompatible with kv-only).",
+ "type": "boolean",
+ "default": false
+ },
+ "no-raw-keys": {
+ "description": "Enforce using constants instead of raw keys.",
+ "type": "boolean",
+ "default": false
+ },
+ "args-on-sep-lines": {
+ "description": "Enforce putting arguments on separate lines.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "spancheck": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "checks": {
+ "description": "Checks to enable.",
+ "type": "array",
+ "items": {
+ "enum": ["end", "record-error", "set-status"]
+ }
+ },
+ "ignore-check-signatures": {
+ "description": "A list of regexes for function signatures that silence `record-error` and `set-status` reports if found in the call path to a returned error.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "staticcheck": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "go": {
+ "description": "Targeted Go version",
+ "type": "string",
+ "default": "1.13"
+ },
+ "checks": {
+ "type": "array",
+ "items": {
+ "anyOf": [
+ {
+ "enum": ["all"]
+ },
+ {
+ "type": "string"
+ }
+ ]
+ }
+ }
+ }
+ },
+ "stylecheck": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "go": {
+ "description": "Targeted Go version",
+ "type": "string",
+ "default": "1.13"
+ },
+ "checks": {
+ "type": "array",
+ "items": {
+ "anyOf": [
+ {
+ "enum": ["all"]
+ },
+ {
+ "type": "string"
+ }
+ ]
+ },
+ "default": [
+ "all",
+ "-ST1000",
+ "-ST1003",
+ "-ST1016",
+ "-ST1020",
+ "-ST1021",
+ "-ST1022"
+ ]
+ },
+ "dot-import-whitelist": {
+ "description": "By default, ST1001 forbids all uses of dot imports in non-test packages. This setting allows setting a whitelist of import paths that can be dot-imported anywhere.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "http-status-code-whitelist": {
+ "description": "ST1013 recommends using constants from the net/http package instead of hard-coding numeric HTTP status codes. This setting specifies a list of numeric status codes that this check does not complain about.",
+ "default": ["200", "400", "404", "500"],
+ "type": "array",
+ "items": {
+ "enum": [
+ "100",
+ "101",
+ "102",
+ "103",
+ "200",
+ "201",
+ "202",
+ "203",
+ "204",
+ "205",
+ "206",
+ "207",
+ "208",
+ "226",
+ "300",
+ "301",
+ "302",
+ "303",
+ "304",
+ "305",
+ "306",
+ "307",
+ "308",
+ "400",
+ "401",
+ "402",
+ "403",
+ "404",
+ "405",
+ "406",
+ "407",
+ "408",
+ "409",
+ "410",
+ "411",
+ "412",
+ "413",
+ "414",
+ "415",
+ "416",
+ "417",
+ "418",
+ "421",
+ "422",
+ "423",
+ "424",
+ "425",
+ "426",
+ "428",
+ "429",
+ "431",
+ "451",
+ "500",
+ "501",
+ "502",
+ "503",
+ "504",
+ "505",
+ "506",
+ "507",
+ "508",
+ "510",
+ "511"
+ ]
+ }
+ },
+ "initialisms": {
+ "description": "ST1003 check, among other things, for the correct capitalization of initialisms. The set of known initialisms can be configured with this option.",
+ "type": "array",
+ "items": {
+ "type": "string",
+ "default": [
+ "ACL",
+ "API",
+ "ASCII",
+ "CPU",
+ "CSS",
+ "DNS",
+ "EOF",
+ "GUID",
+ "HTML",
+ "HTTP",
+ "HTTPS",
+ "ID",
+ "IP",
+ "JSON",
+ "QPS",
+ "RAM",
+ "RPC",
+ "SLA",
+ "SMTP",
+ "SQL",
+ "SSH",
+ "TCP",
+ "TLS",
+ "TTL",
+ "UDP",
+ "UI",
+ "GID",
+ "UID",
+ "UUID",
+ "URI",
+ "URL",
+ "UTF8",
+ "VM",
+ "XML",
+ "XMPP",
+ "XSRF",
+ "XSS",
+ "SIP",
+ "RTP",
+ "AMQP",
+ "DB",
+ "TS"
+ ]
+ }
+ }
+ }
+ },
+ "tagalign": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "align": {
+ "description": "Align and sort can be used together or separately.",
+ "type": "boolean",
+ "default": true
+ },
+ "sort": {
+ "description": "Whether enable tags sort.",
+ "type": "boolean",
+ "default": true
+ },
+ "order": {
+ "description": "Specify the order of tags, the other tags will be sorted by name.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "default": [],
+ "examples": [
+ [
+ "json",
+ "yaml",
+ "yml",
+ "toml",
+ "mapstructure",
+ "binding",
+ "validate"
+ ]
+ ]
+ },
+ "strict": {
+ "description": "Whether enable strict style.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "tagliatelle": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "case": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "use-field-name": {
+ "description": "Use the struct field name to check the name of the struct tag.",
+ "type": "boolean",
+ "default": false
+ },
+ "rules": {
+ "type": "object",
+ "patternProperties": {
+ "^.+$": {
+ "enum": [
+ "camel",
+ "pascal",
+ "kebab",
+ "snake",
+ "goCamel",
+ "goPascal",
+ "goKebab",
+ "goSnake",
+ "upper",
+ "upperSnake",
+ "lower",
+ "header"
+ ]
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "tenv": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "all": {
+ "description": "The option `all` will run against whole test files (`_test.go`) regardless of method/function signatures.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "testifylint": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "bool-compare": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "ignore-custom-types": {
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "enable-all": {
+ "description": "Enable all checkers.",
+ "type": "boolean",
+ "default": false
+ },
+ "disable-all": {
+ "description": "Disable all checkers.",
+ "type": "boolean",
+ "default": false
+ },
+ "enable": {
+ "description": "Enable specific checkers.",
+ "type": "array",
+ "items": {
+ "enum": [
+ "blank-import",
+ "bool-compare",
+ "compares",
+ "empty",
+ "error-is-as",
+ "error-nil",
+ "expected-actual",
+ "go-require",
+ "float-compare",
+ "len",
+ "nil-compare",
+ "require-error",
+ "suite-dont-use-pkg",
+ "suite-extra-assert-call",
+ "suite-thelper",
+ "useless-assert"
+ ]
+ }
+ },
+ "disable": {
+ "description": "Enable specific checkers.",
+ "type": "array",
+ "items": {
+ "enum": [
+ "blank-import",
+ "bool-compare",
+ "compares",
+ "empty",
+ "error-is-as",
+ "error-nil",
+ "expected-actual",
+ "go-require",
+ "float-compare",
+ "len",
+ "nil-compare",
+ "require-error",
+ "suite-dont-use-pkg",
+ "suite-extra-assert-call",
+ "suite-thelper",
+ "useless-assert"
+ ]
+ }
+ },
+ "expected-actual": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "pattern": {
+ "description": "Regexp for expected variable name.",
+ "type": "string"
+ }
+ }
+ },
+ "require-error": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "fn-pattern": {
+ "description": "Regexp for expected variable name.",
+ "type": "string"
+ }
+ }
+ },
+ "suite-extra-assert-call": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "mode": {
+ "description": "To require or remove extra Assert() call?",
+ "type": "string",
+ "enum": ["remove", "require"]
+ }
+ }
+ }
+ }
+ },
+ "testpackage": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "skip-regexp": {
+ "description": "Files with names matching this regular expression are skipped.",
+ "type": "string",
+ "examples": ["(export|internal)_test\\.go"]
+ },
+ "allow-packages": {
+ "description": "List of packages that don't end with _test that tests are allowed to be in.",
+ "type": "array",
+ "uniqueItems": true,
+ "items": {
+ "type": "string",
+ "examples": ["example"]
+ }
+ }
+ }
+ },
+ "thelper": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "test": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "begin": {
+ "description": "Check if `t.Helper()` begins helper function.",
+ "default": true,
+ "type": "boolean"
+ },
+ "first": {
+ "description": "Check if *testing.T is first param of helper function.",
+ "default": true,
+ "type": "boolean"
+ },
+ "name": {
+ "description": "Check if *testing.T param has t name.",
+ "default": true,
+ "type": "boolean"
+ }
+ }
+ },
+ "benchmark": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "begin": {
+ "description": "Check if `b.Helper()` begins helper function.",
+ "default": true,
+ "type": "boolean"
+ },
+ "first": {
+ "description": "Check if *testing.B is first param of helper function.",
+ "default": true,
+ "type": "boolean"
+ },
+ "name": {
+ "description": "Check if *testing.B param has b name.",
+ "default": true,
+ "type": "boolean"
+ }
+ }
+ },
+ "tb": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "begin": {
+ "description": "Check if `tb.Helper()` begins helper function.",
+ "default": true,
+ "type": "boolean"
+ },
+ "first": {
+ "description": "Check if *testing.TB is first param of helper function.",
+ "default": true,
+ "type": "boolean"
+ },
+ "name": {
+ "description": "Check if *testing.TB param has tb name.",
+ "default": true,
+ "type": "boolean"
+ }
+ }
+ },
+ "fuzz": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "begin": {
+ "description": "Check if `f.Helper()` begins helper function.",
+ "default": true,
+ "type": "boolean"
+ },
+ "first": {
+ "description": "Check if *testing.F is first param of helper function.",
+ "default": true,
+ "type": "boolean"
+ },
+ "name": {
+ "description": "Check if *testing.F param has f name.",
+ "default": true,
+ "type": "boolean"
+ }
+ }
+ }
+ }
+ },
+ "usestdlibvars": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "http-method": {
+ "description": "Suggest the use of http.MethodXX.",
+ "type": "boolean",
+ "default": true
+ },
+ "http-status-code": {
+ "description": "Suggest the use of http.StatusXX.",
+ "type": "boolean",
+ "default": true
+ },
+ "time-weekday": {
+ "description": "Suggest the use of time.Weekday.String().",
+ "type": "boolean",
+ "default": false
+ },
+ "time-month": {
+ "description": "Suggest the use of time.Month.String().",
+ "type": "boolean",
+ "default": false
+ },
+ "time-layout": {
+ "description": "Suggest the use of time.Layout.",
+ "type": "boolean",
+ "default": false
+ },
+ "crypto-hash": {
+ "description": "Suggest the use of crypto.Hash.String().",
+ "type": "boolean",
+ "default": false
+ },
+ "default-rpc-path": {
+ "description": "Suggest the use of rpc.DefaultXXPath.",
+ "type": "boolean",
+ "default": false
+ },
+ "os-dev-null": {
+ "description": "Suggest the use of os.DevNull.",
+ "type": "boolean",
+ "default": false
+ },
+ "sql-isolation-level": {
+ "description": "Suggest the use of sql.LevelXX.String().",
+ "type": "boolean",
+ "default": false
+ },
+ "tls-signature-scheme": {
+ "description": "Suggest the use of tls.SignatureScheme.String().",
+ "type": "boolean",
+ "default": false
+ },
+ "constant-kind": {
+ "description": "Suggest the use of constant.Kind.String().",
+ "type": "boolean",
+ "default": false
+ },
+ "syslog-priority": {
+ "description": "Suggest the use of syslog.Priority.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "unconvert": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "fast-math": {
+ "type": "boolean",
+ "default": false
+ },
+ "safe": {
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "unparam": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "check-exported": {
+ "description": "Inspect exported functions. Set to true if no external program/library imports your code.\n\nWARNING: if you enable this setting, unparam will report a lot of false-positives in text editors:\nif it's called for subdir of a project it can't find external interfaces. All text editor integrations\nwith golangci-lint call it on a directory with the changed file.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "unused": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "field-writes-are-uses": {
+ "description": "",
+ "type": "boolean",
+ "default": true
+ },
+ "post-statements-are-reads": {
+ "description": "",
+ "type": "boolean",
+ "default": false
+ },
+ "exported-is-used": {
+ "description": "",
+ "type": "boolean",
+ "default": true
+ },
+ "exported-fields-are-used": {
+ "description": "",
+ "type": "boolean",
+ "default": true
+ },
+ "parameters-are-used": {
+ "description": "",
+ "type": "boolean",
+ "default": true
+ },
+ "local-variables-are-used": {
+ "description": "",
+ "type": "boolean",
+ "default": true
+ },
+ "generated-is-used": {
+ "description": "",
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "varnamelen": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "max-distance": {
+ "description": "Variables used in at most this N-many lines will be ignored.",
+ "type": "integer",
+ "default": 5
+ },
+ "min-name-length": {
+ "description": "The minimum length of a variable's name that is considered `long`.",
+ "type": "integer",
+ "default": 3
+ },
+ "check-receiver": {
+ "description": "Check method receiver names.",
+ "default": false,
+ "type": "boolean"
+ },
+ "check-return": {
+ "description": "Check named return values.",
+ "default": false,
+ "type": "boolean"
+ },
+ "check-type-param": {
+ "description": "Check type parameters.",
+ "default": false,
+ "type": "boolean"
+ },
+ "ignore-type-assert-ok": {
+ "description": "Ignore `ok` variables that hold the bool return value of a type assertion",
+ "default": false,
+ "type": "boolean"
+ },
+ "ignore-map-index-ok": {
+ "description": "Ignore `ok` variables that hold the bool return value of a map index.",
+ "default": false,
+ "type": "boolean"
+ },
+ "ignore-chan-recv-ok": {
+ "description": "Ignore `ok` variables that hold the bool return value of a channel receive.",
+ "default": false,
+ "type": "boolean"
+ },
+ "ignore-names": {
+ "description": "Optional list of variable names that should be ignored completely.",
+ "default": [[]],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ignore-decls": {
+ "description": "Optional list of variable declarations that should be ignored completely.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "examples": [
+ ["c echo.Context", "t testing.T", "f *foo.Bar", "const C"]
+ ]
+ }
+ }
+ },
+ "whitespace": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "multi-if": {
+ "description": "Enforces newlines (or comments) after every multi-line if statement",
+ "type": "boolean",
+ "default": false
+ },
+ "multi-func": {
+ "description": "Enforces newlines (or comments) after every multi-line function signature",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "wrapcheck": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "ignoreSigs": {
+ "description": "An array of strings which specify substrings of signatures to ignore.",
+ "default": [
+ ".Errorf(",
+ "errors.New(",
+ "errors.Unwrap(",
+ ".Wrap(",
+ ".Wrapf(",
+ ".WithMessage(",
+ ".WithMessagef(",
+ ".WithStack("
+ ],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ignoreSigRegexps": {
+ "description": "An array of strings which specify regular expressions of signatures to ignore.",
+ "default": [""],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ignorePackageGlobs": {
+ "description": "An array of glob patterns which, if any match the package of the function returning the error, will skip wrapcheck analysis for this error.",
+ "default": [""],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ignoreInterfaceRegexps": {
+ "description": "An array of glob patterns which, if matched to an underlying interface name, will ignore unwrapped errors returned from a function whose call is defined on the given interface.",
+ "default": [""],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "wsl": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "allow-assign-and-anything": {
+ "description": "Controls if you may cuddle assignments and anything without needing an empty line between them.",
+ "type": "boolean",
+ "default": false
+ },
+ "allow-assign-and-call": {
+ "description": "Allow calls and assignments to be cuddled as long as the lines have any matching variables, fields or types.",
+ "type": "boolean",
+ "default": true
+ },
+ "allow-cuddle-declarations": {
+ "description": "Allow declarations (var) to be cuddled.",
+ "type": "boolean",
+ "default": false
+ },
+ "allow-cuddle-with-calls": {
+ "description": "A list of call idents that everything can be cuddled with.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "allow-cuddle-with-rhs": {
+ "description": "AllowCuddleWithRHS is a list of right hand side variables that is allowed to be cuddled with anything.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "allow-multiline-assign": {
+ "description": "Allow multiline assignments to be cuddled.",
+ "type": "boolean",
+ "default": true
+ },
+ "allow-separated-leading-comment": {
+ "description": "Allow leading comments to be separated with empty lines.",
+ "type": "boolean",
+ "default": false
+ },
+ "allow-trailing-comment": {
+ "description": "Allow trailing comments in ending of blocks.",
+ "type": "boolean",
+ "default": false
+ },
+ "error-variable-names": {
+ "description": "When force-err-cuddling is enabled this is a list of names used for error variables to check for in the conditional.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "force-case-trailing-whitespace": {
+ "description": "Force newlines in end of case at this limit (0 = never).",
+ "type": "integer",
+ "minimum": 0,
+ "default": 0
+ },
+ "force-err-cuddling": {
+ "description": "Causes an error when an If statement that checks an error variable doesn't cuddle with the assignment of that variable.",
+ "type": "boolean",
+ "default": false
+ },
+ "force-short-decl-cuddling": {
+ "description": "Causes an error if a short declaration (:=) cuddles with anything other than another short declaration.",
+ "type": "boolean",
+ "default": false
+ },
+ "strict-append": {
+ "description": "If true, append is only allowed to be cuddled if appending value is matching variables, fields or types on line above.",
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "copyloopvar": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "ignore-alias": {
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "custom": {
+ "description": "The custom section can be used to define linter plugins to be loaded at runtime. See README of golangci-lint for more information.\nEach custom linter should have a unique name.",
+ "type": "object",
+ "patternProperties": {
+ "^.*$": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "type": {
+ "description": "The plugin type.",
+ "enum": ["module", "goplugin"],
+ "default": "goplugin"
+ },
+ "path": {
+ "description": "The path to the plugin *.so. Can be absolute or local.",
+ "type": "string",
+ "examples": ["/path/to/example.so"]
+ },
+ "description": {
+ "description": "The description of the linter, for documentation purposes only.",
+ "type": "string"
+ },
+ "original-url": {
+ "description": "Intended to point to the repo location of the linter, for documentation purposes only.",
+ "type": "string"
+ },
+ "settings": {
+ "description": "Plugins settings/configuration. Only work with plugin based on `linterdb.PluginConstructor`.",
+ "type": "object"
+ }
+ },
+ "oneOf": [
+ {
+ "properties": {
+ "type": {"enum": ["module"] }
+ },
+ "required": ["type"]
+ },
+ {
+ "required": ["path"]
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
+ "linters": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "enable": {
+ "description": "List of enabled linters.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/linters"
+ }
+ },
+ "disable": {
+ "description": "List of disabled linters.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/linters"
+ }
+ },
+ "enable-all": {
+ "description": "Whether to enable all linters. You can re-disable them with `disable` explicitly.",
+ "type": "boolean",
+ "default": false
+ },
+ "disable-all": {
+ "description": "Whether to disable all linters. You can re-enable them with `enable` explicitly.",
+ "type": "boolean",
+ "default": false
+ },
+ "presets": {
+ "description": "Allow to use different presets of linters",
+ "type": "array",
+ "items": {
+ "enum": [
+ "bugs",
+ "comment",
+ "complexity",
+ "error",
+ "format",
+ "import",
+ "metalinter",
+ "module",
+ "performance",
+ "sql",
+ "style",
+ "test",
+ "unused"
+ ]
+ }
+ },
+ "fast": {
+ "description": "Enable run of fast linters.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "issues": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "exclude": {
+ "description": "List of regular expressions of issue texts to exclude.\nBut independently from this option we use default exclude patterns. Their usage can be controlled through `exclude-use-default`.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "exclude-rules": {
+ "description": "Exclude configuration per-path, per-linter, per-text and per-source",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "path": {
+ "type": "string"
+ },
+ "path-except": {
+ "type": "string"
+ },
+ "linters": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/linters"
+ }
+ },
+ "text": {
+ "type": "string"
+ },
+ "source": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "exclude-use-default": {
+ "description": "Independently from option `exclude` we use default exclude patterns. This behavior can be disabled by this option.",
+ "type": "boolean",
+ "default": true
+ },
+ "exclude-case-sensitive": {
+ "description": "If set to true, exclude and exclude-rules regular expressions become case sensitive.",
+ "type": "boolean",
+ "default": false
+ },
+ "exclude-generated-strict": {
+ "description": "To follow strict Go generated file convention",
+ "type": "boolean",
+ "default": false
+ },
+ "exclude-dirs": {
+ "description": "Which directories to exclude: issues from them won't be reported.",
+ "type": "array",
+ "items": {
+ "description": "You can use regexp here. The regexp is applied on the full path.\n\"/\" will be replaced by current OS file path separator to properly work on Windows.",
+ "type": "string",
+ "examples": ["generated.*"]
+ },
+ "default": [],
+ "examples": [["src/external_libs", "autogenerated_by_my_lib"]]
+ },
+ "exclude-dirs-use-default": {
+ "description": "Enable exclusion of directories \"vendor\", \"third_party\", \"testdata\", \"examples\", \"Godeps\", and \"builtin\".",
+ "type": "boolean",
+ "default": true
+ },
+ "exclude-files": {
+ "description": "Which files to exclude: they will be analyzed, but issues from them will not be reported.",
+ "type": "array",
+ "items": {
+ "description": "You can use regexp here. There is no need to include all autogenerated files, we confidently recognize them. If that is not the case, please let us know.\n\"/\" will be replaced by current OS file path separator to properly work on Windows.",
+ "type": "string",
+ "examples": [".*\\.my\\.go$"]
+ },
+ "default": [],
+ "examples": [[".*\\.my\\.go$", "lib/bad.go"]]
+ },
+ "include": {
+ "description": "The list of ids of default excludes to include or disable.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "default": []
+ },
+ "max-issues-per-linter": {
+ "description": "Maximum issues count per one linter. Set to 0 to disable.",
+ "type": "integer",
+ "default": 50,
+ "minimum": 0
+ },
+ "max-same-issues": {
+ "description": "Maximum count of issues with the same text. Set to 0 to disable.",
+ "type": "integer",
+ "default": 3,
+ "minimum": 0
+ },
+ "new": {
+ "description": "Show only new issues: if there are unstaged changes or untracked files, only those changes are analyzed, else only changes in HEAD~ are analyzed.",
+ "type": "boolean",
+ "default": false
+ },
+ "new-from-rev": {
+ "description": "Show only new issues created after this git revision.",
+ "type": "string"
+ },
+ "new-from-patch": {
+ "description": "Show only new issues created in git patch with this file path.",
+ "type": "string",
+ "examples": ["path/to/patch/file"]
+ },
+ "fix": {
+ "description": "Fix found issues (if it's supported by the linter).",
+ "type": "boolean",
+ "default": false
+ },
+ "whole-files": {
+ "description": "Show issues in any part of update files (requires new-from-rev or new-from-patch).",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "severity": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "default-severity": {
+ "description": "Set the default severity for issues. If severity rules are defined and the issues do not match or no severity is provided to the rule this will be the default severity applied. Severities should match the supported severity names of the selected out format.",
+ "type": "string",
+ "default": ""
+ },
+ "case-sensitive": {
+ "description": "If set to true, severity-rules regular expressions become case sensitive.",
+ "type": "boolean",
+ "default": false
+ },
+ "rules": {
+ "description": "When a list of severity rules are provided, severity information will be added to lint issues. Severity rules have the same filtering capability as exclude rules except you are allowed to specify one matcher per severity rule.\nOnly affects out formats that support setting severity information.",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "severity": {
+ "type": "string"
+ },
+ "path": {
+ "type": "string"
+ },
+ "path-except": {
+ "type": "string"
+ },
+ "linters": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/linters"
+ }
+ },
+ "text": {
+ "type": "string"
+ },
+ "source": {
+ "type": "string"
+ }
+ },
+ "required": ["severity"],
+ "anyOf": [
+ { "required": ["path"] },
+ { "required": ["path-except"] },
+ { "required": ["linters"] },
+ { "required": ["text"] },
+ { "required": ["source"] }
+ ]
+ },
+ "default": []
+ }
+ },
+ "required": ["default-severity"]
+ }
+ }
+}
diff --git a/vendor/github.com/golangci/golangci-lint/v2/jsonschema/golangci.v1.58.jsonschema.json b/vendor/github.com/golangci/golangci-lint/v2/jsonschema/golangci.v1.58.jsonschema.json
new file mode 100644
index 0000000000..d0bdc8d7b9
--- /dev/null
+++ b/vendor/github.com/golangci/golangci-lint/v2/jsonschema/golangci.v1.58.jsonschema.json
@@ -0,0 +1,3638 @@
+{
+ "$schema": "http://json-schema.org/draft-07/schema#",
+ "$id": "https://json.schemastore.org/golangci-lint.json",
+ "definitions": {
+ "gocritic-checks": {
+ "enum": [
+ "appendAssign",
+ "appendCombine",
+ "argOrder",
+ "assignOp",
+ "badCall",
+ "badCond",
+ "badLock",
+ "badRegexp",
+ "badSorting",
+ "boolExprSimplify",
+ "builtinShadow",
+ "builtinShadowDecl",
+ "captLocal",
+ "caseOrder",
+ "codegenComment",
+ "commentedOutCode",
+ "commentedOutImport",
+ "commentFormatting",
+ "defaultCaseOrder",
+ "deferUnlambda",
+ "deferInLoop",
+ "deprecatedComment",
+ "docStub",
+ "dupArg",
+ "dupBranchBody",
+ "dupCase",
+ "dupImport",
+ "dupSubExpr",
+ "dynamicFmtString",
+ "elseif",
+ "emptyDecl",
+ "emptyFallthrough",
+ "emptyStringTest",
+ "equalFold",
+ "evalOrder",
+ "exitAfterDefer",
+ "exposedSyncMutex",
+ "externalErrorReassign",
+ "filepathJoin",
+ "flagDeref",
+ "flagName",
+ "hexLiteral",
+ "httpNoBody",
+ "hugeParam",
+ "ifElseChain",
+ "importShadow",
+ "indexAlloc",
+ "initClause",
+ "ioutilDeprecated",
+ "mapKey",
+ "methodExprCall",
+ "nestingReduce",
+ "newDeref",
+ "nilValReturn",
+ "octalLiteral",
+ "offBy1",
+ "paramTypeCombine",
+ "preferDecodeRune",
+ "preferFilepathJoin",
+ "preferFprint",
+ "preferStringWriter",
+ "preferWriteByte",
+ "ptrToRefParam",
+ "rangeExprCopy",
+ "rangeValCopy",
+ "redundantSprint",
+ "regexpMust",
+ "regexpPattern",
+ "regexpSimplify",
+ "returnAfterHttpError",
+ "ruleguard",
+ "singleCaseSwitch",
+ "sliceClear",
+ "sloppyLen",
+ "sloppyReassign",
+ "sloppyTypeAssert",
+ "sortSlice",
+ "sprintfQuotedString",
+ "sqlQuery",
+ "stringConcatSimplify",
+ "stringsCompare",
+ "stringXbytes",
+ "suspiciousSorting",
+ "switchTrue",
+ "syncMapLoadAndDelete",
+ "timeCmpSimplify",
+ "timeExprSimplify",
+ "tooManyResultsChecker",
+ "truncateCmp",
+ "typeAssertChain",
+ "typeDefFirst",
+ "typeSwitchVar",
+ "typeUnparen",
+ "uncheckedInlineErr",
+ "underef",
+ "unlabelStmt",
+ "unlambda",
+ "unnamedResult",
+ "unnecessaryBlock",
+ "unnecessaryDefer",
+ "unslice",
+ "valSwap",
+ "weakCond",
+ "whyNoLint",
+ "wrapperFunc",
+ "yodaStyleExpr"
+ ]
+ },
+ "gocritic-tags": {
+ "enum": [
+ "diagnostic",
+ "style",
+ "performance",
+ "experimental",
+ "opinionated",
+ "security"
+ ]
+ },
+ "gosec-rules": {
+ "enum": [
+ "G101",
+ "G102",
+ "G103",
+ "G104",
+ "G106",
+ "G107",
+ "G108",
+ "G109",
+ "G110",
+ "G111",
+ "G112",
+ "G113",
+ "G114",
+ "G201",
+ "G202",
+ "G203",
+ "G204",
+ "G301",
+ "G302",
+ "G303",
+ "G304",
+ "G305",
+ "G306",
+ "G307",
+ "G401",
+ "G402",
+ "G403",
+ "G404",
+ "G501",
+ "G502",
+ "G503",
+ "G504",
+ "G505",
+ "G601",
+ "G602"
+ ]
+ },
+ "govet-analyzers": {
+ "enum": [
+ "appends",
+ "asmdecl",
+ "assign",
+ "atomic",
+ "atomicalign",
+ "bools",
+ "buildtag",
+ "cgocall",
+ "composites",
+ "copylocks",
+ "deepequalerrors",
+ "defers",
+ "directive",
+ "errorsas",
+ "fieldalignment",
+ "findcall",
+ "framepointer",
+ "httpresponse",
+ "ifaceassert",
+ "loopclosure",
+ "lostcancel",
+ "nilfunc",
+ "nilness",
+ "printf",
+ "reflectvaluecompare",
+ "shadow",
+ "shift",
+ "sigchanyzer",
+ "slog",
+ "sortslice",
+ "stdmethods",
+ "stringintconv",
+ "structtag",
+ "testinggoroutine",
+ "tests",
+ "unmarshal",
+ "unreachable",
+ "unsafeptr",
+ "unusedresult",
+ "unusedwrite"
+ ]
+ },
+ "linters": {
+ "$comment": "anyOf with enum is used to allow auto completion of non-custom linters",
+ "description": "Linters usable.",
+ "anyOf": [
+ {
+ "enum": [
+ "asasalint",
+ "asciicheck",
+ "bidichk",
+ "bodyclose",
+ "canonicalheader",
+ "containedctx",
+ "contextcheck",
+ "copyloopvar",
+ "cyclop",
+ "deadcode",
+ "decorder",
+ "depguard",
+ "dogsled",
+ "dupl",
+ "dupword",
+ "durationcheck",
+ "errcheck",
+ "errchkjson",
+ "errname",
+ "errorlint",
+ "execinquery",
+ "exhaustive",
+ "exhaustivestruct",
+ "exhaustruct",
+ "exportloopref",
+ "fatcontext",
+ "forbidigo",
+ "forcetypeassert",
+ "funlen",
+ "gci",
+ "ginkgolinter",
+ "gocheckcompilerdirectives",
+ "gochecknoglobals",
+ "gochecknoinits",
+ "gochecksumtype",
+ "gocognit",
+ "goconst",
+ "gocritic",
+ "gocyclo",
+ "godot",
+ "godox",
+ "err113",
+ "gofmt",
+ "gofumpt",
+ "goheader",
+ "goimports",
+ "golint",
+ "gomoddirectives",
+ "gomodguard",
+ "goprintffuncname",
+ "gosec",
+ "gosimple",
+ "gosmopolitan",
+ "govet",
+ "grouper",
+ "ifshort",
+ "importas",
+ "inamedparam",
+ "ineffassign",
+ "interfacebloat",
+ "interfacer",
+ "intrange",
+ "ireturn",
+ "lll",
+ "loggercheck",
+ "maintidx",
+ "makezero",
+ "maligned",
+ "mirror",
+ "misspell",
+ "mnd",
+ "musttag",
+ "nakedret",
+ "nestif",
+ "nilerr",
+ "nilnil",
+ "nlreturn",
+ "noctx",
+ "nolintlint",
+ "nonamedreturns",
+ "nosnakecase",
+ "nosprintfhostport",
+ "paralleltest",
+ "perfsprint",
+ "prealloc",
+ "predeclared",
+ "promlinter",
+ "protogetter",
+ "reassign",
+ "revive",
+ "rowserrcheck",
+ "scopelint",
+ "sloglint",
+ "sqlclosecheck",
+ "staticcheck",
+ "structcheck",
+ "stylecheck",
+ "tagalign",
+ "tagliatelle",
+ "tenv",
+ "testableexamples",
+ "testifylint",
+ "testpackage",
+ "thelper",
+ "tparallel",
+ "typecheck",
+ "unconvert",
+ "unparam",
+ "unused",
+ "usestdlibvars",
+ "varcheck",
+ "varnamelen",
+ "wastedassign",
+ "whitespace",
+ "wrapcheck",
+ "wsl",
+ "zerologlint"
+ ]
+ },
+ {
+ "type": "string"
+ }
+ ]
+ }
+ },
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "run": {
+ "description": "Options for analysis running,",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "concurrency": {
+ "description": "Number of concurrent runners. Defaults to the number of available CPU cores.",
+ "type": "integer",
+ "minimum": 0,
+ "examples": [4]
+ },
+ "timeout": {
+ "description": "Timeout for the analysis.",
+ "type": "string",
+ "pattern": "^((\\d+h)?(\\d+m)?(\\d+(?:\\.\\d)?s)?|0)$",
+ "default": "1m",
+ "examples": ["30s", "5m", "5m30s"]
+ },
+ "issues-exit-code": {
+ "description": "Exit code when at least one issue was found.",
+ "type": "integer",
+ "default": 1
+ },
+ "tests": {
+ "description": "Enable inclusion of test files.",
+ "type": "boolean",
+ "default": true
+ },
+ "build-tags": {
+ "description": "List of build tags to pass to all linters.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "default": [],
+ "examples": [["mytag"]]
+ },
+ "modules-download-mode": {
+ "description": "Option to pass to \"go list -mod={option}\".\nSee \"go help modules\" for more information.",
+ "enum": ["mod", "readonly", "vendor"]
+ },
+ "allow-parallel-runners": {
+ "description": "Allow multiple parallel golangci-lint instances running. If disabled, golangci-lint acquires file lock on start.",
+ "type": "boolean",
+ "default": false
+ },
+ "allow-serial-runners": {
+ "description": "Allow multiple golangci-lint instances running, but serialize them around a lock.",
+ "type": "boolean",
+ "default": false
+ },
+ "go": {
+ "description": "Targeted Go version.",
+ "type": "string",
+ "default": "1.17"
+ }
+ }
+ },
+ "output": {
+ "description": "Output configuration options.",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "formats": {
+ "description": "Output formats to use.",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "path": {
+ "default": "stdout",
+ "anyOf": [
+ {
+ "enum": [ "stdout", "stderr" ]
+ },
+ {
+ "type": "string"
+ }
+ ]
+ },
+ "format": {
+ "default": "colored-line-number",
+ "enum": [
+ "colored-line-number",
+ "line-number",
+ "json",
+ "colored-tab",
+ "tab",
+ "html",
+ "checkstyle",
+ "code-climate",
+ "junit-xml",
+ "github-actions",
+ "teamcity"
+ ]
+ }
+ },
+ "required": ["format"]
+ }
+ },
+ "print-issued-lines": {
+ "description": "Print lines of code with issue.",
+ "type": "boolean",
+ "default": true
+ },
+ "print-linter-name": {
+ "description": "Print linter name in the end of issue text.",
+ "type": "boolean",
+ "default": true
+ },
+ "uniq-by-line": {
+ "description": "Make issues output unique by line.",
+ "type": "boolean",
+ "default": true
+ },
+ "path-prefix": {
+ "description": "Add a prefix to the output file references.",
+ "type": "string",
+ "default": ""
+ },
+ "show-stats": {
+ "description": "Show statistics per linter.",
+ "type": "boolean",
+ "default": false
+ },
+ "sort-order": {
+ "type": "array",
+ "items": {
+ "enum": ["linter", "severity", "file"]
+ }
+ },
+ "sort-results": {
+ "description": "Sort results by: filepath, line and column.",
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "linters-settings": {
+ "description": "All available settings of specific linters.",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "dupword": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "keywords": {
+ "description": "Keywords for detecting duplicate words. If this list is not empty, only the words defined in this list will be detected.",
+ "type": "array",
+ "uniqueItems": true,
+ "items": {
+ "type": "string",
+ "examples": ["the", "and", "a"]
+ }
+ },
+ "ignore": {
+ "description": "Keywords used to ignore detection.",
+ "type": "array",
+ "uniqueItems": true,
+ "items": {
+ "type": "string",
+ "examples": ["0C0C"]
+ }
+ }
+ }
+ },
+ "asasalint": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "exclude": {
+ "description": "To specify a set of function names to exclude.",
+ "type": "array",
+ "uniqueItems": true,
+ "items": {
+ "type": "string",
+ "examples": ["\\.Wrapf"]
+ }
+ },
+ "use-builtin-exclusions": {
+ "description": "To enable/disable the asasalint builtin exclusions of function names.",
+ "type": "boolean",
+ "default": true
+ },
+ "ignore-test": {
+ "description": "Ignore *_test.go files.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "bidichk": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "left-to-right-embedding": {
+ "description": "Disallow: LEFT-TO-RIGHT-EMBEDDING",
+ "type": "boolean",
+ "default": false
+ },
+ "right-to-left-embedding": {
+ "description": "Disallow: RIGHT-TO-LEFT-EMBEDDING",
+ "type": "boolean",
+ "default": false
+ },
+ "pop-directional-formatting": {
+ "description": "Disallow: POP-DIRECTIONAL-FORMATTING",
+ "type": "boolean",
+ "default": false
+ },
+ "left-to-right-override": {
+ "description": "Disallow: LEFT-TO-RIGHT-OVERRIDE",
+ "type": "boolean",
+ "default": false
+ },
+ "right-to-left-override": {
+ "description": "Disallow: RIGHT-TO-LEFT-OVERRIDE",
+ "type": "boolean",
+ "default": false
+ },
+ "left-to-right-isolate": {
+ "description": "Disallow: LEFT-TO-RIGHT-ISOLATE",
+ "type": "boolean",
+ "default": false
+ },
+ "right-to-left-isolate": {
+ "description": "Disallow: RIGHT-TO-LEFT-ISOLATE",
+ "type": "boolean",
+ "default": false
+ },
+ "first-strong-isolate": {
+ "description": "Disallow: FIRST-STRONG-ISOLATE",
+ "type": "boolean",
+ "default": false
+ },
+ "pop-directional-isolate": {
+ "description": "Disallow: POP-DIRECTIONAL-ISOLATE",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "cyclop": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "skip-tests": {
+ "description": "Should the linter execute on test files as well",
+ "type": "boolean",
+ "default": false
+ },
+ "max-complexity": {
+ "description": "Max complexity the function can have",
+ "type": "integer",
+ "default": 10,
+ "minimum": 0
+ },
+ "package-average": {
+ "description": "Max average complexity in package",
+ "type": "number",
+ "default": 0,
+ "minimum": 0
+ }
+ }
+ },
+ "decorder": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "dec-order": {
+ "type": "array",
+ "default": [["type", "const", "var", "func"]],
+ "items": {
+ "enum": ["type", "const", "var", "func"]
+ }
+ },
+ "ignore-underscore-vars": {
+ "description": "Underscore vars (vars with \"_\" as the name) will be ignored at all checks",
+ "default": true,
+ "type": "boolean"
+ },
+ "disable-dec-order-check": {
+ "description": "Order of declarations is not checked",
+ "default": true,
+ "type": "boolean"
+ },
+ "disable-init-func-first-check": {
+ "description": "Allow init func to be anywhere in file",
+ "default": true,
+ "type": "boolean"
+ },
+ "disable-dec-num-check": {
+ "description": "Multiple global type, const and var declarations are allowed",
+ "default": true,
+ "type": "boolean"
+ },
+ "disable-type-dec-num-check": {
+ "description": "Type declarations will be ignored for dec num check",
+ "default": true,
+ "type": "boolean"
+ },
+ "disable-const-dec-num-check": {
+ "description": "Const declarations will be ignored for dec num check",
+ "default": true,
+ "type": "boolean"
+ },
+ "disable-var-dec-num-check": {
+ "description": "Var declarations will be ignored for dec num check",
+ "default": true,
+ "type": "boolean"
+ }
+ }
+ },
+ "depguard": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "rules": {
+ "description": "Rules to apply.",
+ "type": "object",
+ "additionalProperties": false,
+ "patternProperties": {
+ "^[^.]+$": {
+ "description": "Name of a rule.",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "list-mode": {
+ "description": "Used to determine the package matching priority.",
+ "enum": ["original", "strict", "lax"],
+ "default": "original"
+ },
+ "files": {
+ "description": "List of file globs that will match this list of settings to compare against.",
+ "additionalProperties": false,
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "allow": {
+ "description": "List of allowed packages.",
+ "additionalProperties": false,
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "deny": {
+ "description": "Packages that are not allowed where the value is a suggestion.",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "desc": {
+ "description": "Description",
+ "type": "string"
+ },
+ "pkg": {
+ "description": "Package",
+ "type": "string"
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "dogsled": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "max-blank-identifiers": {
+ "description": "Check assignments with too many blank identifiers.",
+ "type": "integer",
+ "default": 2,
+ "minimum": 0
+ }
+ }
+ },
+ "dupl": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "threshold": {
+ "description": "Tokens count to trigger issue.",
+ "type": "integer",
+ "default": 150,
+ "minimum": 0
+ }
+ }
+ },
+ "errcheck": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "check-type-assertions": {
+ "description": "Report about not checking errors in type assertions, i.e.: `a := b.(MyStruct)`",
+ "type": "boolean",
+ "default": false
+ },
+ "check-blank": {
+ "description": "Report about assignment of errors to blank identifier",
+ "type": "boolean",
+ "default": false
+ },
+ "exclude-functions": {
+ "description": "List of functions to exclude from checking, where each entry is a single function to exclude",
+ "type": "array",
+ "examples": ["io/ioutil.ReadFile", "io.Copy(*bytes.Buffer)"],
+ "items": {
+ "type": "string"
+ }
+ },
+ "disable-default-exclusions": {
+ "description": "To disable the errcheck built-in exclude list",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "errchkjson": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "check-error-free-encoding": {
+ "type": "boolean",
+ "default": false
+ },
+ "report-no-exported": {
+ "description": "Issue on struct that doesn't have exported fields.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "errorlint": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "errorf": {
+ "description": "Check whether fmt.Errorf uses the %w verb for formatting errors",
+ "type": "boolean",
+ "default": true
+ },
+ "errorf-multi": {
+ "description": "Permit more than 1 %w verb, valid per Go 1.20",
+ "type": "boolean",
+ "default": true
+ },
+ "asserts": {
+ "description": "Check for plain type assertions and type switches.",
+ "type": "boolean",
+ "default": true
+ },
+ "comparison": {
+ "description": "Check for plain error comparisons",
+ "type": "boolean",
+ "default": true
+ },
+ "allowed-errors": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "err": {
+ "type": "string"
+ },
+ "fun": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "allowed-errors-wildcard": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "err": {
+ "type": "string"
+ },
+ "fun": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ }
+ },
+ "exhaustive": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "check": {
+ "description": "Program elements to check for exhaustiveness.",
+ "type": "array",
+ "uniqueItems": true,
+ "items": {
+ "type": "string",
+ "examples": ["switch", "map"]
+ }
+ },
+ "check-generated": {
+ "description": "Check switch statements in generated files",
+ "type": "boolean",
+ "default": false
+ },
+ "explicit-exhaustive-switch": {
+ "description": "Only run exhaustive check on switches with \"//exhaustive:enforce\" comment.",
+ "type": "boolean",
+ "default": false
+ },
+ "explicit-exhaustive-map": {
+ "description": "Only run exhaustive check on map literals with \"//exhaustive:enforce\" comment.",
+ "type": "boolean",
+ "default": false
+ },
+ "default-case-required": {
+ "description": "Switch statement requires default case even if exhaustive.",
+ "type": "boolean",
+ "default": false
+ },
+ "default-signifies-exhaustive": {
+ "description": "Presence of `default` case in switch statements satisfies exhaustiveness, even if all enum members are not listed.",
+ "type": "boolean",
+ "default": false
+ },
+ "ignore-enum-members": {
+ "description": "Enum members matching `regex` do not have to be listed in switch statements to satisfy exhaustiveness",
+ "type": "string"
+ },
+ "ignore-enum-types": {
+ "description": "Enum types matching the supplied regex do not have to be listed in switch statements to satisfy exhaustiveness.",
+ "type": "string"
+ },
+ "package-scope-only": {
+ "description": "Consider enums only in package scopes, not in inner scopes.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "exhaustruct": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "include": {
+ "description": "List of regular expressions to match struct packages and names.",
+ "type": "array",
+ "examples": [".*\\.Test"],
+ "items": {
+ "type": "string"
+ }
+ },
+ "exclude": {
+ "description": "List of regular expressions to exclude struct packages and names from check.",
+ "type": "array",
+ "examples": ["cobra\\.Command$"],
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "forbidigo": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "exclude-godoc-examples": {
+ "description": "Exclude code in godoc examples.",
+ "type": "boolean",
+ "default": true
+ },
+ "analyze-types": {
+ "description": "Instead of matching the literal source code, use type information to replace expressions with strings that contain the package name and (for methods and fields) the type name.",
+ "type": "boolean",
+ "default": true
+ },
+ "forbid": {
+ "description": "List of identifiers to forbid (written using `regexp`)",
+ "type": "array",
+ "examples": ["^print.*$"],
+ "items": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "p": {
+ "description": "Pattern",
+ "type": "string"
+ },
+ "pkg": {
+ "description": "Package",
+ "type": "string"
+ },
+ "msg": {
+ "description": "Message",
+ "type": "string"
+ }
+ }
+ }
+ ]
+ }
+ }
+ }
+ },
+ "funlen": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "lines": {
+ "description": "Limit lines number per function.",
+ "type": "integer",
+ "default": 60
+ },
+ "statements": {
+ "description": "Limit statements number per function.",
+ "type": "integer",
+ "default": 40
+ },
+ "ignore-comments": {
+ "description": "Ignore comments when counting lines.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "gci": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "sections": {
+ "description": "Section configuration to compare against.",
+ "type": "array",
+ "items": {
+ "anyOf": [
+ {
+ "enum": [
+ "standard",
+ "default",
+ "blank",
+ "dot",
+ "alias",
+ "localmodule"
+ ]
+ },
+ {
+ "type": "string"
+ }
+ ]
+ },
+ "default": ["standard", "default"]
+ },
+ "skip-generated": {
+ "description": "Skip generated files.",
+ "type": "boolean",
+ "default": true
+ },
+ "custom-order": {
+ "description": "Enable custom order of sections.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "ginkgolinter": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "suppress-len-assertion": {
+ "description": "Suppress the wrong length assertion warning.",
+ "type": "boolean",
+ "default": false
+ },
+ "suppress-nil-assertion": {
+ "description": "Suppress the wrong nil assertion warning.",
+ "type": "boolean",
+ "default": false
+ },
+ "suppress-err-assertion": {
+ "description": "Suppress the wrong error assertion warning.",
+ "type": "boolean",
+ "default": false
+ },
+ "suppress-compare-assertion": {
+ "description": "Suppress the wrong comparison assertion warning.",
+ "type": "boolean",
+ "default": false
+ },
+ "suppress-async-assertion": {
+ "description": "Suppress the function all in async assertion warning.",
+ "type": "boolean",
+ "default": false
+ },
+ "suppress-type-compare-assertion": {
+ "description": "Suppress warning for comparing values from different types, like int32 and uint32.",
+ "type": "boolean",
+ "default": false
+ },
+ "forbid-focus-container": {
+ "description": "Trigger warning for ginkgo focus containers like FDescribe, FContext, FWhen or FIt.",
+ "type": "boolean",
+ "default": false
+ },
+ "allow-havelen-zero": {
+ "description": "Don't trigger warnings for HaveLen(0).",
+ "type": "boolean",
+ "default": false
+ },
+ "force-expect-to": {
+ "description": "Force using `Expect` with `To`, `ToNot` or `NotTo`",
+ "type": "boolean",
+ "default": false
+ },
+ "validate-async-intervals": {
+ "description": "Best effort validation of async intervals (timeout and polling).",
+ "type": "boolean",
+ "default": false
+ },
+ "forbid-spec-pollution": {
+ "description": "Trigger a warning for variable assignments in ginkgo containers like `Describe`, `Context` and `When`, instead of in `BeforeEach()`.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "gocognit": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "min-complexity": {
+ "description": "Minimal code complexity to report (we recommend 10-20).",
+ "type": "integer",
+ "default": 30
+ }
+ }
+ },
+ "goconst": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "match-constant": {
+ "description": "Look for existing constants matching the values",
+ "type": "boolean",
+ "default": true
+ },
+ "min-len": {
+ "description": "Minimum length of string constant.",
+ "type": "integer",
+ "default": 3
+ },
+ "min-occurrences": {
+ "description": "Minimum occurrences count to trigger.",
+ "type": "integer",
+ "default": 3
+ },
+ "ignore-tests": {
+ "description": "Ignore test files.",
+ "type": "boolean",
+ "default": false
+ },
+ "ignore-calls": {
+ "description": "Ignore when constant is not used as function argument",
+ "type": "boolean",
+ "default": true
+ },
+ "ignore-strings": {
+ "description": "Exclude strings matching the given regular expression",
+ "type": "string"
+ },
+ "numbers": {
+ "description": "Search also for duplicated numbers.",
+ "type": "boolean",
+ "default": false
+ },
+ "min": {
+ "description": "Minimum value, only works with `numbers`",
+ "type": "integer",
+ "default": 3
+ },
+ "max": {
+ "description": "Maximum value, only works with `numbers`",
+ "type": "integer",
+ "default": 3
+ }
+ }
+ },
+ "gocritic": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "enabled-checks": {
+ "description": "Which checks should be enabled. By default, a list of stable checks is used. To see it, run `GL_DEBUG=gocritic golangci-lint run`.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/gocritic-checks"
+ }
+ },
+ "disabled-checks": {
+ "description": "Which checks should be disabled.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/gocritic-checks"
+ },
+ "default": []
+ },
+ "enabled-tags": {
+ "description": "Enable multiple checks by tags, run `GL_DEBUG=gocritic golangci-lint run` to see all tags and checks.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/gocritic-tags"
+ }
+ },
+ "disabled-tags": {
+ "description": "Disable multiple checks by tags, run `GL_DEBUG=gocritic golangci-lint run` to see all tags and checks.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/gocritic-tags"
+ }
+ },
+ "settings": {
+ "description": "Settings passed to gocritic. Properties must be valid and enabled check names.",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "captLocal": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "paramsOnly" : {
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "commentedOutCode": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "minLength" : {
+ "type": "number",
+ "default": 15
+ }
+ }
+ },
+ "elseif": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "skipBalanced" : {
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "hugeParam": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "sizeThreshold" : {
+ "type": "number",
+ "default": 80
+ }
+ }
+ },
+ "ifElseChain": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "minThreshold" : {
+ "type": "number",
+ "default": 2
+ }
+ }
+ },
+ "nestingReduce": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "bodyWidth" : {
+ "type": "number",
+ "default": 5
+ }
+ }
+ },
+ "rangeExprCopy": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "sizeThreshold" : {
+ "type": "number",
+ "default": 512
+ },
+ "skipTestFuncs" : {
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "rangeValCopy": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "sizeThreshold" : {
+ "type": "number",
+ "default": 128
+ },
+ "skipTestFuncs" : {
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "ruleguard": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "debug" : {
+ "type": "string"
+ },
+ "enable" : {
+ "type": "string"
+ },
+ "disable" : {
+ "type": "string"
+ },
+ "failOn" : {
+ "type": "string"
+ },
+ "rules" : {
+ "type": "string"
+ }
+ }
+ },
+ "tooManyResultsChecker": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "maxResults" : {
+ "type": "number",
+ "default": 5
+ }
+ }
+ },
+ "truncateCmp": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "skipArchDependent" : {
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "underef": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "skipRecvDeref" : {
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "unnamedResult": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "checkExported" : {
+ "type": "boolean",
+ "default": false
+ }
+ }
+ }
+ }
+ },
+ "disable-all": {
+ "type": "boolean",
+ "default": false
+ },
+ "enable-all": {
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "gocyclo": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "min-complexity": {
+ "description": "Minimum code complexity to report (we recommend 10-20).",
+ "type": "integer",
+ "default": 30
+ }
+ }
+ },
+ "godot": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "scope": {
+ "description": "Comments to be checked.",
+ "enum": ["declarations", "toplevel", "all"],
+ "default": "declarations"
+ },
+ "exclude": {
+ "description": "List of regexps for excluding particular comment lines from check.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "period": {
+ "description": "Check that each sentence ends with a period.",
+ "type": "boolean",
+ "default": true
+ },
+ "capital": {
+ "description": "Check that each sentence starts with a capital letter.",
+ "type": "boolean",
+ "default": false
+ },
+ "check-all": {
+ "description": "DEPRECATED: Check all top-level comments, not only declarations.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "godox": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "keywords": {
+ "description": "Report any comments starting with one of these keywords. This is useful for TODO or FIXME comments that might be left in the code accidentally and should be resolved before merging.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "default": ["TODO", "BUG", "FIXME"]
+ }
+ }
+ },
+ "gofmt": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "simplify": {
+ "description": "Simplify code.",
+ "type": "boolean",
+ "default": true
+ },
+ "rewrite-rules": {
+ "description": "Apply the rewrite rules to the source before reformatting.",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "pattern": {
+ "type": "string"
+ },
+ "replacement": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ }
+ },
+ "interfacebloat": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "max": {
+ "description": "The maximum number of methods allowed for an interface.",
+ "type": "integer"
+ }
+ }
+ },
+ "gofumpt": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "extra-rules": {
+ "description": "Choose whether or not to use the extra rules that are disabled by default.",
+ "type": "boolean",
+ "default": false
+ },
+ "module-path": {
+ "description": " Module path which contains the source code being formatted.",
+ "type": "string"
+ }
+ }
+ },
+ "goheader": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "values": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "const": {
+ "description": "Constants to use in the template.",
+ "type": "object",
+ "patternProperties": {
+ "^.+$": {
+ "description": "Value for the constant.",
+ "type": "string"
+ }
+ },
+ "additionalProperties": false,
+ "examples": [
+ {
+ "YEAR": "2030",
+ "COMPANY": "MY FUTURISTIC COMPANY"
+ }
+ ]
+ },
+ "regexp": {
+ "description": "Regular expressions to use in your template.",
+ "type": "object",
+ "additionalProperties": false,
+ "patternProperties": {
+ "^.+$": {
+ "type": "string"
+ }
+ },
+ "examples": [
+ {
+ "AUTHOR": ".*@mycompany\\.com"
+ }
+ ]
+ }
+ }
+ },
+ "template": {
+ "description": "Template to put on top of every file.",
+ "type": "string",
+ "examples": [
+ "{{ MY COMPANY }}\nSPDX-License-Identifier: Apache-2.0\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at:\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License."
+ ]
+ },
+ "template-path": {
+ "description": "Path to the file containing the template source.",
+ "type": "string",
+ "examples": ["my_header_template.txt"]
+ }
+ },
+ "oneOf": [
+ { "required": ["template"] },
+ { "required": ["template-path"] }
+ ]
+ },
+ "goimports": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "local-prefixes": {
+ "description": "Put imports beginning with prefix after 3rd-party packages. It is a comma-separated list of prefixes.",
+ "type": "string",
+ "examples": ["github.com/org/project"]
+ }
+ }
+ },
+ "gomoddirectives": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "replace-local": {
+ "description": "Allow local `replace` directives.",
+ "type": "boolean",
+ "default": true
+ },
+ "replace-allow-list": {
+ "description": "List of allowed `replace` directives.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "retract-allow-no-explanation": {
+ "description": "Allow to not explain why the version has been retracted in the `retract` directives.",
+ "type": "boolean",
+ "default": true
+ },
+ "exclude-forbidden": {
+ "description": "Forbid the use of the `exclude` directives.",
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "gomodguard": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "allowed": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "modules": {
+ "description": "List of allowed modules.",
+ "type": "array",
+ "items": {
+ "type": "string",
+ "examples": ["gopkg.in/yaml.v2"]
+ }
+ },
+ "domains": {
+ "description": "List of allowed module domains.",
+ "type": "array",
+ "items": {
+ "type": "string",
+ "examples": ["golang.org"]
+ }
+ }
+ }
+ },
+ "blocked": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "modules": {
+ "description": "List of blocked modules.",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "patternProperties": {
+ "^.+$": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "recommendations": {
+ "description": "Recommended modules that should be used instead.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "reason": {
+ "description": "Reason why the recommended module should be used.",
+ "type": "string"
+ }
+ }
+ }
+ },
+ "additionalProperties": false
+ }
+ },
+ "versions": {
+ "description": "List of blocked module version constraints.",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "patternProperties": {
+ "^.*$": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "version": {
+ "description": "Version constraint.",
+ "type": "string"
+ },
+ "reason": {
+ "description": "Reason why the version constraint exists.",
+ "type": "string"
+ }
+ },
+ "required": ["reason"]
+ }
+ }
+ }
+ },
+ "local_replace_directives": {
+ "description": "Raise lint issues if loading local path with replace directive",
+ "type": "boolean",
+ "default": true
+ }
+ }
+ }
+ }
+ },
+ "gosimple": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "checks": {
+ "type": "array",
+ "items": {
+ "anyOf": [
+ {
+ "enum": ["all"]
+ },
+ {
+ "type": "string"
+ }
+ ]
+ }
+ }
+ }
+ },
+ "gosec": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "includes": {
+ "type": "array",
+ "description": "To select a subset of rules to run",
+ "examples": [["G401"]],
+ "items": {
+ "$ref": "#/definitions/gosec-rules"
+ }
+ },
+ "excludes": {
+ "type": "array",
+ "description": "To specify a set of rules to explicitly exclude",
+ "examples": [["G401"]],
+ "items": {
+ "$ref": "#/definitions/gosec-rules"
+ }
+ },
+ "exclude-generated": {
+ "description": "Exclude generated files",
+ "type": "boolean",
+ "default": false
+ },
+ "severity": {
+ "description": "Filter out the issues with a lower severity than the given value",
+ "type": "string",
+ "enum": ["low", "medium", "high"],
+ "default": "low"
+ },
+ "confidence": {
+ "description": "Filter out the issues with a lower confidence than the given value",
+ "type": "string",
+ "enum": ["low", "medium", "high"],
+ "default": "low"
+ },
+ "config": {
+ "description": "To specify the configuration of rules",
+ "type": "object"
+ },
+ "concurrency": {
+ "description": "Concurrency value",
+ "type": "integer"
+ }
+ }
+ },
+ "gosmopolitan": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "allow-time-local": {
+ "description": "Allow and ignore `time.Local` usages.",
+ "type": "boolean",
+ "default": false
+ },
+ "escape-hatches": {
+ "description": "List of fully qualified names in the `full/pkg/path.name` form, to act as \"i18n escape hatches\".",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ignore-tests": {
+ "description": "Ignore test files.",
+ "type": "boolean",
+ "default": false
+ },
+ "watch-for-scripts": {
+ "description": "List of Unicode scripts to watch for any usage in string literals.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "govet": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "settings": {
+ "description": "Settings per analyzer. Map of analyzer name to specific settings.\nRun `go tool vet help` to find out more.",
+ "type": "object",
+ "propertyNames": {
+ "$ref": "#/definitions/govet-analyzers"
+ },
+ "patternProperties": {
+ "^.*$": {
+ "description": "Run `go tool vet help ` to see all settings.",
+ "type": "object"
+ }
+ }
+ },
+ "enable": {
+ "description": "Enable analyzers by name.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/govet-analyzers"
+ }
+ },
+ "disable": {
+ "description": "Disable analyzers by name.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/govet-analyzers"
+ }
+ },
+ "enable-all": {
+ "description": "Enable all analyzers.",
+ "type": "boolean",
+ "default": false
+ },
+ "disable-all": {
+ "description": "Disable all analyzers.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "grouper": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "const-require-single-const": {
+ "type": "boolean",
+ "default": false
+ },
+ "const-require-grouping": {
+ "type": "boolean",
+ "default": false
+ },
+ "import-require-single-import": {
+ "type": "boolean",
+ "default": false
+ },
+ "import-require-grouping": {
+ "type": "boolean",
+ "default": false
+ },
+ "type-require-single-type": {
+ "type": "boolean",
+ "default": false
+ },
+ "type-require-grouping": {
+ "type": "boolean",
+ "default": false
+ },
+ "var-require-single-var": {
+ "type": "boolean",
+ "default": false
+ },
+ "var-require-grouping": {
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "importas": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "no-unaliased": {
+ "description": "Do not allow unaliased imports of aliased packages.",
+ "type": "boolean",
+ "default": false
+ },
+ "no-extra-aliases": {
+ "description": "Do not allow non-required aliases.",
+ "type": "boolean",
+ "default": false
+ },
+ "alias": {
+ "description": "List of aliases",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "pkg": {
+ "description": "Package path e.g. knative.dev/serving/pkg/apis/autoscaling/v1alpha1",
+ "type": "string"
+ },
+ "alias": {
+ "description": "Package alias e.g. autoscalingv1alpha1",
+ "type": "string"
+ }
+ },
+ "required": ["pkg", "alias"]
+ }
+ }
+ }
+ },
+ "inamedparam": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "skip-single-param": {
+ "description": "Skips check for interface methods with only a single parameter.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "ireturn": {
+ "type": "object",
+ "additionalProperties": false,
+ "description": "Use either `reject` or `allow` properties for interfaces matching.",
+ "properties": {
+ "allow": {
+ "type": "array",
+ "items": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "enum": ["anon", "error", "empty", "stdlib"]
+ }
+ ]
+ }
+ },
+ "reject": {
+ "type": "array",
+ "items": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "enum": ["anon", "error", "empty", "stdlib"]
+ }
+ ]
+ }
+ }
+ },
+ "anyOf": [
+ {
+ "not": {
+ "properties": {
+ "allow": {
+ "const": "reject"
+ }
+ }
+ },
+ "required": ["allow"]
+ },
+ {
+ "required": ["reject"]
+ }
+ ]
+ },
+ "lll": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "tab-width": {
+ "description": "Width of \"\\t\" in spaces.",
+ "type": "integer",
+ "minimum": 0,
+ "default": 1
+ },
+ "line-length": {
+ "description": "Maximum allowed line length, lines longer will be reported.",
+ "type": "integer",
+ "minimum": 1,
+ "default": 120
+ }
+ }
+ },
+ "maintidx": {
+ "description": "Maintainability index https://docs.microsoft.com/en-us/visualstudio/code-quality/code-metrics-maintainability-index-range-and-meaning?view=vs-2022",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "under": {
+ "description": "Minimum accatpable maintainability index level (see https://docs.microsoft.com/en-us/visualstudio/code-quality/code-metrics-maintainability-index-range-and-meaning?view=vs-2022)",
+ "type": "number",
+ "default": 20
+ }
+ }
+ },
+ "makezero": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "always": {
+ "description": "Allow only slices initialized with a length of zero.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "loggercheck": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "kitlog": {
+ "description": "Allow check for the github.com/go-kit/log library.",
+ "type": "boolean",
+ "default": true
+ },
+ "klog": {
+ "description": "Allow check for the k8s.io/klog/v2 library.",
+ "type": "boolean",
+ "default": true
+ },
+ "logr": {
+ "description": "Allow check for the github.com/go-logr/logr library.",
+ "type": "boolean",
+ "default": true
+ },
+ "zap": {
+ "description": "Allow check for the \"sugar logger\" from go.uber.org/zap library.",
+ "type": "boolean",
+ "default": true
+ },
+ "require-string-key": {
+ "description": "Require all logging keys to be inlined constant strings.",
+ "type": "boolean",
+ "default": false
+ },
+ "no-printf-like": {
+ "description": "Require printf-like format specifier (%s, %d for example) not present.",
+ "type": "boolean",
+ "default": false
+ },
+ "rules": {
+ "description": "List of custom rules to check against, where each rule is a single logger pattern, useful for wrapped loggers.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "misspell": {
+ "description": "Correct spellings using locale preferences for US or UK. Default is to use a neutral variety of English.",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "locale": {
+ "enum": ["US", "UK"]
+ },
+ "ignore-words": {
+ "description": "List of words to ignore.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "mode": {
+ "description": "Mode of the analysis.",
+ "enum": ["restricted", "", "default"],
+ "default": ""
+ },
+ "extra-words": {
+ "description": "Extra word corrections.",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "correction": {
+ "type": "string"
+ },
+ "typo": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ }
+ },
+ "musttag": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "functions": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "name": {
+ "type": "string"
+ },
+ "tag": {
+ "type": "string"
+ },
+ "arg-pos": {
+ "type": "integer"
+ }
+ }
+ }
+ }
+ }
+ },
+ "nakedret": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "max-func-lines": {
+ "description": "Report if a function has more lines of code than this value and it has naked returns.",
+ "type": "integer",
+ "minimum": 0,
+ "default": 30
+ }
+ }
+ },
+ "nestif": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "min-complexity": {
+ "description": "Minimum complexity of \"if\" statements to report.",
+ "type": "integer",
+ "default": 5
+ }
+ }
+ },
+ "nilnil": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "checked-types": {
+ "type": "array",
+ "description": "Order of return types to check.",
+ "items": {
+ "enum": ["ptr", "func", "iface", "map", "chan"]
+ },
+ "default": ["ptr", "func", "iface", "map", "chan"]
+ }
+ }
+ },
+ "nlreturn": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "block-size": {
+ "description": "set block size that is still ok",
+ "type": "number",
+ "default": 0,
+ "minimum": 0
+ }
+ }
+ },
+ "mnd": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "ignored-files": {
+ "description": "List of file patterns to exclude from analysis.",
+ "examples": [["magic1_.*.go"]],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ignored-functions": {
+ "description": "Comma-separated list of function patterns to exclude from the analysis.",
+ "examples": [["math.*", "http.StatusText", "make"]],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ignored-numbers": {
+ "description": "List of numbers to exclude from analysis.",
+ "examples": [["1000", "1234_567_890", "3.14159264"]],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "checks": {
+ "description": "The list of enabled checks, see https://github.com/tommy-muehle/go-mnd/#checks for description.",
+ "type": "array",
+ "items": {
+ "enum": [
+ "argument",
+ "case",
+ "condition",
+ "operation",
+ "return",
+ "assign"
+ ]
+ }
+ }
+ }
+ },
+ "nolintlint": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "allow-unused": {
+ "description": "Enable to ensure that nolint directives are all used.",
+ "type": "boolean",
+ "default": true
+ },
+ "allow-no-explanation": {
+ "description": "Exclude these linters from requiring an explanation.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/linters"
+ },
+ "default": []
+ },
+ "require-explanation": {
+ "description": "Enable to require an explanation of nonzero length after each nolint directive.",
+ "type": "boolean",
+ "default": false
+ },
+ "require-specific": {
+ "description": "Enable to require nolint directives to mention the specific linter being suppressed.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "reassign": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "patterns": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "nonamedreturns": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "report-error-in-defer": {
+ "description": "Report named error if it is assigned inside defer.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "paralleltest": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "ignore-missing": {
+ "description": "Ignore missing calls to `t.Parallel()` and only report incorrect uses of it.",
+ "type": "boolean",
+ "default": false
+ },
+ "ignore-missing-subtests": {
+ "description": "Ignore missing calls to `t.Parallel()` in subtests. Top-level tests are still required to have `t.Parallel`, but subtests are allowed to skip it.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "perfsprint": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "int-conversion": {
+ "description": "Optimizes even if it requires an int or uint type cast.",
+ "type": "boolean",
+ "default": true
+ },
+ "err-error": {
+ "description": "Optimizes into `err.Error()` even if it is only equivalent for non-nil errors.",
+ "type": "boolean",
+ "default": false
+ },
+ "errorf": {
+ "description": "Optimizes `fmt.Errorf`.",
+ "type": "boolean",
+ "default": true
+ },
+ "sprintf1": {
+ "description": "Optimizes `fmt.Sprintf` with only one argument.",
+ "type": "boolean",
+ "default": true
+ },
+ "strconcat": {
+ "description": "Optimizes into strings concatenation.",
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "prealloc": {
+ "description": "We do not recommend using this linter before doing performance profiling.\nFor most programs usage of `prealloc` will be premature optimization.",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "simple": {
+ "description": "Report preallocation suggestions only on simple loops that have no returns/breaks/continues/gotos in them.",
+ "type": "boolean",
+ "default": true
+ },
+ "range-loops": {
+ "description": "Report preallocation suggestions on range loops.",
+ "type": "boolean",
+ "default": true
+ },
+ "for-loops": {
+ "description": "Report preallocation suggestions on for loops.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "predeclared": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "ignore": {
+ "description": "Comma-separated list of predeclared identifiers to not report on.",
+ "type": "string"
+ },
+ "q": {
+ "description": "Include method names and field names (i.e., qualified names) in checks.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "promlinter": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "strict": {},
+ "disabled-linters": {
+ "type": "array",
+ "items": {
+ "enum": [
+ "Help",
+ "MetricUnits",
+ "Counter",
+ "HistogramSummaryReserved",
+ "MetricTypeInName",
+ "ReservedChars",
+ "CamelCase",
+ "UnitAbbreviations"
+ ]
+ }
+ }
+ }
+ },
+ "protogetter": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "skip-generated-by": {
+ "type": "array",
+ "items": {
+ "type": "string",
+ "examples": ["protoc-gen-go-my-own-generator"]
+ }
+ },
+ "skip-files": {
+ "type": "array",
+ "items": {
+ "type": "string",
+ "examples": ["*.pb.go"]
+ }
+ },
+ "skip-any-generated": {
+ "description": "Skip any generated files from the checking.",
+ "type": "boolean",
+ "default": false
+ },
+ "replace-first-arg-in-append": {
+ "description": "Skip first argument of append function.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "revive": {
+ "type": "object",
+ "additionalProperties": false,
+ "examples": [
+ {
+ "ignore-generated-header": true,
+ "severity": "warning",
+ "rules": [
+ {
+ "name": "indent-error-flow",
+ "severity": "warning"
+ },
+ {
+ "name": "add-constant",
+ "severity": "warning",
+ "arguments": [
+ {
+ "maxLitCount": "3",
+ "allowStrs": "\"\"",
+ "allowInts": "0,1,2",
+ "allowFloats": "0.0,0.,1.0,1.,2.0,2."
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ "properties": {
+ "max-open-files": {
+ "type": "integer"
+ },
+ "ignore-generated-header": {
+ "type": "boolean"
+ },
+ "confidence": {
+ "type": "number"
+ },
+ "severity": {
+ "type": "string",
+ "enum": ["warning", "error"]
+ },
+ "enable-all-rules": {
+ "type": "boolean",
+ "default": false
+ },
+ "directives": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "name": {
+ "type": "string",
+ "enum": ["specify-disable-reason"]
+ },
+ "severity": {
+ "type": "string",
+ "enum": ["warning", "error"]
+ },
+ "exclude": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "arguments": {
+ "type": "array"
+ }
+ }
+ }
+ },
+ "rules": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "required": ["name"],
+ "properties": {
+ "name": {
+ "type": "string",
+ "title": "The rule name"
+ },
+ "disabled": {
+ "type": "boolean"
+ },
+ "severity": {
+ "type": "string",
+ "enum": ["warning", "error"]
+ },
+ "exclude": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "arguments": {
+ "type": "array"
+ }
+ }
+ }
+ }
+ }
+ },
+ "rowserrcheck": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "packages": {
+ "type": "array",
+ "items": {
+ "description": "",
+ "type": "string",
+ "examples": ["github.com/jmoiron/sqlx"]
+ }
+ }
+ }
+ },
+ "sloglint": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "kv-only": {
+ "description": "Enforce using key-value pairs only (incompatible with attr-only).",
+ "type": "boolean",
+ "default": false
+ },
+ "no-global": {
+ "description": "Enforce not using global loggers.",
+ "enum": ["", "all", "default"],
+ "default": ""
+ },
+ "no-mixed-args": {
+ "description": "Enforce not mixing key-value pairs and attributes.",
+ "type": "boolean",
+ "default": true
+ },
+ "context": {
+ "description": "Enforce using methods that accept a context.",
+ "enum": ["", "all", "scope"],
+ "default": ""
+ },
+ "static-msg": {
+ "description": "Enforce using static values for log messages.",
+ "type": "boolean",
+ "default": false
+ },
+ "key-naming-case": {
+ "description": "Enforce a single key naming convention.",
+ "enum": ["snake", "kebab", "camel", "pascal"]
+ },
+ "attr-only": {
+ "description": "Enforce using attributes only (incompatible with kv-only).",
+ "type": "boolean",
+ "default": false
+ },
+ "no-raw-keys": {
+ "description": "Enforce using constants instead of raw keys.",
+ "type": "boolean",
+ "default": false
+ },
+ "args-on-sep-lines": {
+ "description": "Enforce putting arguments on separate lines.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "spancheck": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "checks": {
+ "description": "Checks to enable.",
+ "type": "array",
+ "items": {
+ "enum": ["end", "record-error", "set-status"]
+ }
+ },
+ "ignore-check-signatures": {
+ "description": "A list of regexes for function signatures that silence `record-error` and `set-status` reports if found in the call path to a returned error.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "extra-start-span-signatures": {
+ "description": "A list of regexes for additional function signatures that create spans.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "staticcheck": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "checks": {
+ "type": "array",
+ "items": {
+ "anyOf": [
+ {
+ "enum": ["all"]
+ },
+ {
+ "type": "string"
+ }
+ ]
+ }
+ }
+ }
+ },
+ "stylecheck": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "checks": {
+ "type": "array",
+ "items": {
+ "anyOf": [
+ {
+ "enum": ["all"]
+ },
+ {
+ "type": "string"
+ }
+ ]
+ },
+ "default": [
+ "all",
+ "-ST1000",
+ "-ST1003",
+ "-ST1016",
+ "-ST1020",
+ "-ST1021",
+ "-ST1022"
+ ]
+ },
+ "dot-import-whitelist": {
+ "description": "By default, ST1001 forbids all uses of dot imports in non-test packages. This setting allows setting a whitelist of import paths that can be dot-imported anywhere.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "http-status-code-whitelist": {
+ "description": "ST1013 recommends using constants from the net/http package instead of hard-coding numeric HTTP status codes. This setting specifies a list of numeric status codes that this check does not complain about.",
+ "default": ["200", "400", "404", "500"],
+ "type": "array",
+ "items": {
+ "enum": [
+ "100",
+ "101",
+ "102",
+ "103",
+ "200",
+ "201",
+ "202",
+ "203",
+ "204",
+ "205",
+ "206",
+ "207",
+ "208",
+ "226",
+ "300",
+ "301",
+ "302",
+ "303",
+ "304",
+ "305",
+ "306",
+ "307",
+ "308",
+ "400",
+ "401",
+ "402",
+ "403",
+ "404",
+ "405",
+ "406",
+ "407",
+ "408",
+ "409",
+ "410",
+ "411",
+ "412",
+ "413",
+ "414",
+ "415",
+ "416",
+ "417",
+ "418",
+ "421",
+ "422",
+ "423",
+ "424",
+ "425",
+ "426",
+ "428",
+ "429",
+ "431",
+ "451",
+ "500",
+ "501",
+ "502",
+ "503",
+ "504",
+ "505",
+ "506",
+ "507",
+ "508",
+ "510",
+ "511"
+ ]
+ }
+ },
+ "initialisms": {
+ "description": "ST1003 check, among other things, for the correct capitalization of initialisms. The set of known initialisms can be configured with this option.",
+ "type": "array",
+ "items": {
+ "type": "string",
+ "default": [
+ "ACL",
+ "API",
+ "ASCII",
+ "CPU",
+ "CSS",
+ "DNS",
+ "EOF",
+ "GUID",
+ "HTML",
+ "HTTP",
+ "HTTPS",
+ "ID",
+ "IP",
+ "JSON",
+ "QPS",
+ "RAM",
+ "RPC",
+ "SLA",
+ "SMTP",
+ "SQL",
+ "SSH",
+ "TCP",
+ "TLS",
+ "TTL",
+ "UDP",
+ "UI",
+ "GID",
+ "UID",
+ "UUID",
+ "URI",
+ "URL",
+ "UTF8",
+ "VM",
+ "XML",
+ "XMPP",
+ "XSRF",
+ "XSS",
+ "SIP",
+ "RTP",
+ "AMQP",
+ "DB",
+ "TS"
+ ]
+ }
+ }
+ }
+ },
+ "tagalign": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "align": {
+ "description": "Align and sort can be used together or separately.",
+ "type": "boolean",
+ "default": true
+ },
+ "sort": {
+ "description": "Whether enable tags sort.",
+ "type": "boolean",
+ "default": true
+ },
+ "order": {
+ "description": "Specify the order of tags, the other tags will be sorted by name.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "default": [],
+ "examples": [
+ [
+ "json",
+ "yaml",
+ "yml",
+ "toml",
+ "mapstructure",
+ "binding",
+ "validate"
+ ]
+ ]
+ },
+ "strict": {
+ "description": "Whether enable strict style.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "tagliatelle": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "case": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "use-field-name": {
+ "description": "Use the struct field name to check the name of the struct tag.",
+ "type": "boolean",
+ "default": false
+ },
+ "rules": {
+ "type": "object",
+ "patternProperties": {
+ "^.+$": {
+ "enum": [
+ "camel",
+ "pascal",
+ "kebab",
+ "snake",
+ "goCamel",
+ "goPascal",
+ "goKebab",
+ "goSnake",
+ "upper",
+ "upperSnake",
+ "lower",
+ "header"
+ ]
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "tenv": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "all": {
+ "description": "The option `all` will run against whole test files (`_test.go`) regardless of method/function signatures.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "testifylint": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "bool-compare": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "ignore-custom-types": {
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "enable-all": {
+ "description": "Enable all checkers.",
+ "type": "boolean",
+ "default": false
+ },
+ "disable-all": {
+ "description": "Disable all checkers.",
+ "type": "boolean",
+ "default": false
+ },
+ "enable": {
+ "description": "Enable specific checkers.",
+ "type": "array",
+ "items": {
+ "enum": [
+ "blank-import",
+ "bool-compare",
+ "compares",
+ "empty",
+ "error-is-as",
+ "error-nil",
+ "expected-actual",
+ "go-require",
+ "float-compare",
+ "len",
+ "nil-compare",
+ "require-error",
+ "suite-dont-use-pkg",
+ "suite-extra-assert-call",
+ "suite-thelper",
+ "useless-assert"
+ ]
+ }
+ },
+ "disable": {
+ "description": "Enable specific checkers.",
+ "type": "array",
+ "items": {
+ "enum": [
+ "blank-import",
+ "bool-compare",
+ "compares",
+ "empty",
+ "error-is-as",
+ "error-nil",
+ "expected-actual",
+ "go-require",
+ "float-compare",
+ "len",
+ "nil-compare",
+ "require-error",
+ "suite-dont-use-pkg",
+ "suite-extra-assert-call",
+ "suite-thelper",
+ "useless-assert"
+ ]
+ }
+ },
+ "expected-actual": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "pattern": {
+ "description": "Regexp for expected variable name.",
+ "type": "string"
+ }
+ }
+ },
+ "require-error": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "fn-pattern": {
+ "description": "Regexp for expected variable name.",
+ "type": "string"
+ }
+ }
+ },
+ "suite-extra-assert-call": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "mode": {
+ "description": "To require or remove extra Assert() call?",
+ "type": "string",
+ "enum": ["remove", "require"]
+ }
+ }
+ }
+ }
+ },
+ "testpackage": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "skip-regexp": {
+ "description": "Files with names matching this regular expression are skipped.",
+ "type": "string",
+ "examples": ["(export|internal)_test\\.go"]
+ },
+ "allow-packages": {
+ "description": "List of packages that don't end with _test that tests are allowed to be in.",
+ "type": "array",
+ "uniqueItems": true,
+ "items": {
+ "type": "string",
+ "examples": ["example"]
+ }
+ }
+ }
+ },
+ "thelper": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "test": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "begin": {
+ "description": "Check if `t.Helper()` begins helper function.",
+ "default": true,
+ "type": "boolean"
+ },
+ "first": {
+ "description": "Check if *testing.T is first param of helper function.",
+ "default": true,
+ "type": "boolean"
+ },
+ "name": {
+ "description": "Check if *testing.T param has t name.",
+ "default": true,
+ "type": "boolean"
+ }
+ }
+ },
+ "benchmark": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "begin": {
+ "description": "Check if `b.Helper()` begins helper function.",
+ "default": true,
+ "type": "boolean"
+ },
+ "first": {
+ "description": "Check if *testing.B is first param of helper function.",
+ "default": true,
+ "type": "boolean"
+ },
+ "name": {
+ "description": "Check if *testing.B param has b name.",
+ "default": true,
+ "type": "boolean"
+ }
+ }
+ },
+ "tb": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "begin": {
+ "description": "Check if `tb.Helper()` begins helper function.",
+ "default": true,
+ "type": "boolean"
+ },
+ "first": {
+ "description": "Check if *testing.TB is first param of helper function.",
+ "default": true,
+ "type": "boolean"
+ },
+ "name": {
+ "description": "Check if *testing.TB param has tb name.",
+ "default": true,
+ "type": "boolean"
+ }
+ }
+ },
+ "fuzz": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "begin": {
+ "description": "Check if `f.Helper()` begins helper function.",
+ "default": true,
+ "type": "boolean"
+ },
+ "first": {
+ "description": "Check if *testing.F is first param of helper function.",
+ "default": true,
+ "type": "boolean"
+ },
+ "name": {
+ "description": "Check if *testing.F param has f name.",
+ "default": true,
+ "type": "boolean"
+ }
+ }
+ }
+ }
+ },
+ "usestdlibvars": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "http-method": {
+ "description": "Suggest the use of http.MethodXX.",
+ "type": "boolean",
+ "default": true
+ },
+ "http-status-code": {
+ "description": "Suggest the use of http.StatusXX.",
+ "type": "boolean",
+ "default": true
+ },
+ "time-weekday": {
+ "description": "Suggest the use of time.Weekday.String().",
+ "type": "boolean",
+ "default": false
+ },
+ "time-month": {
+ "description": "Suggest the use of time.Month.String().",
+ "type": "boolean",
+ "default": false
+ },
+ "time-layout": {
+ "description": "Suggest the use of time.Layout.",
+ "type": "boolean",
+ "default": false
+ },
+ "crypto-hash": {
+ "description": "Suggest the use of crypto.Hash.String().",
+ "type": "boolean",
+ "default": false
+ },
+ "default-rpc-path": {
+ "description": "Suggest the use of rpc.DefaultXXPath.",
+ "type": "boolean",
+ "default": false
+ },
+ "sql-isolation-level": {
+ "description": "Suggest the use of sql.LevelXX.String().",
+ "type": "boolean",
+ "default": false
+ },
+ "tls-signature-scheme": {
+ "description": "Suggest the use of tls.SignatureScheme.String().",
+ "type": "boolean",
+ "default": false
+ },
+ "constant-kind": {
+ "description": "Suggest the use of constant.Kind.String().",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "unconvert": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "fast-math": {
+ "type": "boolean",
+ "default": false
+ },
+ "safe": {
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "unparam": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "check-exported": {
+ "description": "Inspect exported functions. Set to true if no external program/library imports your code.\n\nWARNING: if you enable this setting, unparam will report a lot of false-positives in text editors:\nif it's called for subdir of a project it can't find external interfaces. All text editor integrations\nwith golangci-lint call it on a directory with the changed file.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "unused": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "field-writes-are-uses": {
+ "description": "",
+ "type": "boolean",
+ "default": true
+ },
+ "post-statements-are-reads": {
+ "description": "",
+ "type": "boolean",
+ "default": false
+ },
+ "exported-is-used": {
+ "description": "",
+ "type": "boolean",
+ "default": true
+ },
+ "exported-fields-are-used": {
+ "description": "",
+ "type": "boolean",
+ "default": true
+ },
+ "parameters-are-used": {
+ "description": "",
+ "type": "boolean",
+ "default": true
+ },
+ "local-variables-are-used": {
+ "description": "",
+ "type": "boolean",
+ "default": true
+ },
+ "generated-is-used": {
+ "description": "",
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "varnamelen": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "max-distance": {
+ "description": "Variables used in at most this N-many lines will be ignored.",
+ "type": "integer",
+ "default": 5
+ },
+ "min-name-length": {
+ "description": "The minimum length of a variable's name that is considered `long`.",
+ "type": "integer",
+ "default": 3
+ },
+ "check-receiver": {
+ "description": "Check method receiver names.",
+ "default": false,
+ "type": "boolean"
+ },
+ "check-return": {
+ "description": "Check named return values.",
+ "default": false,
+ "type": "boolean"
+ },
+ "check-type-param": {
+ "description": "Check type parameters.",
+ "default": false,
+ "type": "boolean"
+ },
+ "ignore-type-assert-ok": {
+ "description": "Ignore `ok` variables that hold the bool return value of a type assertion",
+ "default": false,
+ "type": "boolean"
+ },
+ "ignore-map-index-ok": {
+ "description": "Ignore `ok` variables that hold the bool return value of a map index.",
+ "default": false,
+ "type": "boolean"
+ },
+ "ignore-chan-recv-ok": {
+ "description": "Ignore `ok` variables that hold the bool return value of a channel receive.",
+ "default": false,
+ "type": "boolean"
+ },
+ "ignore-names": {
+ "description": "Optional list of variable names that should be ignored completely.",
+ "default": [[]],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ignore-decls": {
+ "description": "Optional list of variable declarations that should be ignored completely.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "examples": [
+ ["c echo.Context", "t testing.T", "f *foo.Bar", "const C"]
+ ]
+ }
+ }
+ },
+ "whitespace": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "multi-if": {
+ "description": "Enforces newlines (or comments) after every multi-line if statement",
+ "type": "boolean",
+ "default": false
+ },
+ "multi-func": {
+ "description": "Enforces newlines (or comments) after every multi-line function signature",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "wrapcheck": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "ignoreSigs": {
+ "description": "An array of strings which specify substrings of signatures to ignore.",
+ "default": [
+ ".Errorf(",
+ "errors.New(",
+ "errors.Unwrap(",
+ ".Wrap(",
+ ".Wrapf(",
+ ".WithMessage(",
+ ".WithMessagef(",
+ ".WithStack("
+ ],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ignoreSigRegexps": {
+ "description": "An array of strings which specify regular expressions of signatures to ignore.",
+ "default": [""],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ignorePackageGlobs": {
+ "description": "An array of glob patterns which, if any match the package of the function returning the error, will skip wrapcheck analysis for this error.",
+ "default": [""],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ignoreInterfaceRegexps": {
+ "description": "An array of glob patterns which, if matched to an underlying interface name, will ignore unwrapped errors returned from a function whose call is defined on the given interface.",
+ "default": [""],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "wsl": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "allow-assign-and-anything": {
+ "description": "Controls if you may cuddle assignments and anything without needing an empty line between them.",
+ "type": "boolean",
+ "default": false
+ },
+ "allow-assign-and-call": {
+ "description": "Allow calls and assignments to be cuddled as long as the lines have any matching variables, fields or types.",
+ "type": "boolean",
+ "default": true
+ },
+ "allow-cuddle-declarations": {
+ "description": "Allow declarations (var) to be cuddled.",
+ "type": "boolean",
+ "default": false
+ },
+ "allow-cuddle-with-calls": {
+ "description": "A list of call idents that everything can be cuddled with.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "allow-cuddle-with-rhs": {
+ "description": "AllowCuddleWithRHS is a list of right hand side variables that is allowed to be cuddled with anything.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "allow-multiline-assign": {
+ "description": "Allow multiline assignments to be cuddled.",
+ "type": "boolean",
+ "default": true
+ },
+ "allow-separated-leading-comment": {
+ "description": "Allow leading comments to be separated with empty lines.",
+ "type": "boolean",
+ "default": false
+ },
+ "allow-trailing-comment": {
+ "description": "Allow trailing comments in ending of blocks.",
+ "type": "boolean",
+ "default": false
+ },
+ "error-variable-names": {
+ "description": "When force-err-cuddling is enabled this is a list of names used for error variables to check for in the conditional.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "force-case-trailing-whitespace": {
+ "description": "Force newlines in end of case at this limit (0 = never).",
+ "type": "integer",
+ "minimum": 0,
+ "default": 0
+ },
+ "force-err-cuddling": {
+ "description": "Causes an error when an If statement that checks an error variable doesn't cuddle with the assignment of that variable.",
+ "type": "boolean",
+ "default": false
+ },
+ "force-short-decl-cuddling": {
+ "description": "Causes an error if a short declaration (:=) cuddles with anything other than another short declaration.",
+ "type": "boolean",
+ "default": false
+ },
+ "strict-append": {
+ "description": "If true, append is only allowed to be cuddled if appending value is matching variables, fields or types on line above.",
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "copyloopvar": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "check-alias": {
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "custom": {
+ "description": "The custom section can be used to define linter plugins to be loaded at runtime. See README of golangci-lint for more information.\nEach custom linter should have a unique name.",
+ "type": "object",
+ "patternProperties": {
+ "^.*$": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "type": {
+ "description": "The plugin type.",
+ "enum": ["module", "goplugin"],
+ "default": "goplugin"
+ },
+ "path": {
+ "description": "The path to the plugin *.so. Can be absolute or local.",
+ "type": "string",
+ "examples": ["/path/to/example.so"]
+ },
+ "description": {
+ "description": "The description of the linter, for documentation purposes only.",
+ "type": "string"
+ },
+ "original-url": {
+ "description": "Intended to point to the repo location of the linter, for documentation purposes only.",
+ "type": "string"
+ },
+ "settings": {
+ "description": "Plugins settings/configuration. Only work with plugin based on `linterdb.PluginConstructor`.",
+ "type": "object"
+ }
+ },
+ "oneOf": [
+ {
+ "properties": {
+ "type": {"enum": ["module"] }
+ },
+ "required": ["type"]
+ },
+ {
+ "required": ["path"]
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
+ "linters": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "enable": {
+ "description": "List of enabled linters.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/linters"
+ }
+ },
+ "disable": {
+ "description": "List of disabled linters.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/linters"
+ }
+ },
+ "enable-all": {
+ "description": "Whether to enable all linters. You can re-disable them with `disable` explicitly.",
+ "type": "boolean",
+ "default": false
+ },
+ "disable-all": {
+ "description": "Whether to disable all linters. You can re-enable them with `enable` explicitly.",
+ "type": "boolean",
+ "default": false
+ },
+ "presets": {
+ "description": "Allow to use different presets of linters",
+ "type": "array",
+ "items": {
+ "enum": [
+ "bugs",
+ "comment",
+ "complexity",
+ "error",
+ "format",
+ "import",
+ "metalinter",
+ "module",
+ "performance",
+ "sql",
+ "style",
+ "test",
+ "unused"
+ ]
+ }
+ },
+ "fast": {
+ "description": "Enable run of fast linters.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "issues": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "exclude": {
+ "description": "List of regular expressions of issue texts to exclude.\nBut independently from this option we use default exclude patterns. Their usage can be controlled through `exclude-use-default`.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "exclude-rules": {
+ "description": "Exclude configuration per-path, per-linter, per-text and per-source",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "path": {
+ "type": "string"
+ },
+ "path-except": {
+ "type": "string"
+ },
+ "linters": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/linters"
+ }
+ },
+ "text": {
+ "type": "string"
+ },
+ "source": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "exclude-use-default": {
+ "description": "Independently from option `exclude` we use default exclude patterns. This behavior can be disabled by this option.",
+ "type": "boolean",
+ "default": true
+ },
+ "exclude-case-sensitive": {
+ "description": "If set to true, exclude and exclude-rules regular expressions become case sensitive.",
+ "type": "boolean",
+ "default": false
+ },
+ "exclude-generated-strict": {
+ "description": "To follow strict Go generated file convention",
+ "type": "boolean",
+ "default": false
+ },
+ "exclude-dirs": {
+ "description": "Which directories to exclude: issues from them won't be reported.",
+ "type": "array",
+ "items": {
+ "description": "You can use regexp here. The regexp is applied on the full path.\n\"/\" will be replaced by current OS file path separator to properly work on Windows.",
+ "type": "string",
+ "examples": ["generated.*"]
+ },
+ "default": [],
+ "examples": [["src/external_libs", "autogenerated_by_my_lib"]]
+ },
+ "exclude-dirs-use-default": {
+ "description": "Enable exclusion of directories \"vendor\", \"third_party\", \"testdata\", \"examples\", \"Godeps\", and \"builtin\".",
+ "type": "boolean",
+ "default": true
+ },
+ "exclude-files": {
+ "description": "Which files to exclude: they will be analyzed, but issues from them will not be reported.",
+ "type": "array",
+ "items": {
+ "description": "You can use regexp here. There is no need to include all autogenerated files, we confidently recognize them. If that is not the case, please let us know.\n\"/\" will be replaced by current OS file path separator to properly work on Windows.",
+ "type": "string",
+ "examples": [".*\\.my\\.go$"]
+ },
+ "default": [],
+ "examples": [[".*\\.my\\.go$", "lib/bad.go"]]
+ },
+ "include": {
+ "description": "The list of ids of default excludes to include or disable.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "default": []
+ },
+ "max-issues-per-linter": {
+ "description": "Maximum issues count per one linter. Set to 0 to disable.",
+ "type": "integer",
+ "default": 50,
+ "minimum": 0
+ },
+ "max-same-issues": {
+ "description": "Maximum count of issues with the same text. Set to 0 to disable.",
+ "type": "integer",
+ "default": 3,
+ "minimum": 0
+ },
+ "new": {
+ "description": "Show only new issues: if there are unstaged changes or untracked files, only those changes are analyzed, else only changes in HEAD~ are analyzed.",
+ "type": "boolean",
+ "default": false
+ },
+ "new-from-rev": {
+ "description": "Show only new issues created after this git revision.",
+ "type": "string"
+ },
+ "new-from-patch": {
+ "description": "Show only new issues created in git patch with this file path.",
+ "type": "string",
+ "examples": ["path/to/patch/file"]
+ },
+ "fix": {
+ "description": "Fix found issues (if it's supported by the linter).",
+ "type": "boolean",
+ "default": false
+ },
+ "whole-files": {
+ "description": "Show issues in any part of update files (requires new-from-rev or new-from-patch).",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "severity": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "default-severity": {
+ "description": "Set the default severity for issues. If severity rules are defined and the issues do not match or no severity is provided to the rule this will be the default severity applied. Severities should match the supported severity names of the selected out format.",
+ "type": "string",
+ "default": ""
+ },
+ "case-sensitive": {
+ "description": "If set to true, severity-rules regular expressions become case sensitive.",
+ "type": "boolean",
+ "default": false
+ },
+ "rules": {
+ "description": "When a list of severity rules are provided, severity information will be added to lint issues. Severity rules have the same filtering capability as exclude rules except you are allowed to specify one matcher per severity rule.\nOnly affects out formats that support setting severity information.",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "severity": {
+ "type": "string"
+ },
+ "path": {
+ "type": "string"
+ },
+ "path-except": {
+ "type": "string"
+ },
+ "linters": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/linters"
+ }
+ },
+ "text": {
+ "type": "string"
+ },
+ "source": {
+ "type": "string"
+ }
+ },
+ "required": ["severity"],
+ "anyOf": [
+ { "required": ["path"] },
+ { "required": ["path-except"] },
+ { "required": ["linters"] },
+ { "required": ["text"] },
+ { "required": ["source"] }
+ ]
+ },
+ "default": []
+ }
+ },
+ "required": ["default-severity"]
+ }
+ }
+}
diff --git a/vendor/github.com/golangci/golangci-lint/v2/jsonschema/golangci.v1.59.jsonschema.json b/vendor/github.com/golangci/golangci-lint/v2/jsonschema/golangci.v1.59.jsonschema.json
new file mode 100644
index 0000000000..cc3e63655b
--- /dev/null
+++ b/vendor/github.com/golangci/golangci-lint/v2/jsonschema/golangci.v1.59.jsonschema.json
@@ -0,0 +1,3766 @@
+{
+ "$schema": "http://json-schema.org/draft-07/schema#",
+ "$id": "https://json.schemastore.org/golangci-lint.json",
+ "definitions": {
+ "gocritic-checks": {
+ "enum": [
+ "appendAssign",
+ "appendCombine",
+ "argOrder",
+ "assignOp",
+ "badCall",
+ "badCond",
+ "badLock",
+ "badRegexp",
+ "badSorting",
+ "boolExprSimplify",
+ "builtinShadow",
+ "builtinShadowDecl",
+ "captLocal",
+ "caseOrder",
+ "codegenComment",
+ "commentedOutCode",
+ "commentedOutImport",
+ "commentFormatting",
+ "defaultCaseOrder",
+ "deferUnlambda",
+ "deferInLoop",
+ "deprecatedComment",
+ "docStub",
+ "dupArg",
+ "dupBranchBody",
+ "dupCase",
+ "dupImport",
+ "dupSubExpr",
+ "dynamicFmtString",
+ "elseif",
+ "emptyDecl",
+ "emptyFallthrough",
+ "emptyStringTest",
+ "equalFold",
+ "evalOrder",
+ "exitAfterDefer",
+ "exposedSyncMutex",
+ "externalErrorReassign",
+ "filepathJoin",
+ "flagDeref",
+ "flagName",
+ "hexLiteral",
+ "httpNoBody",
+ "hugeParam",
+ "ifElseChain",
+ "importShadow",
+ "indexAlloc",
+ "initClause",
+ "ioutilDeprecated",
+ "mapKey",
+ "methodExprCall",
+ "nestingReduce",
+ "newDeref",
+ "nilValReturn",
+ "octalLiteral",
+ "offBy1",
+ "paramTypeCombine",
+ "preferDecodeRune",
+ "preferFilepathJoin",
+ "preferFprint",
+ "preferStringWriter",
+ "preferWriteByte",
+ "ptrToRefParam",
+ "rangeExprCopy",
+ "rangeValCopy",
+ "redundantSprint",
+ "regexpMust",
+ "regexpPattern",
+ "regexpSimplify",
+ "returnAfterHttpError",
+ "ruleguard",
+ "singleCaseSwitch",
+ "sliceClear",
+ "sloppyLen",
+ "sloppyReassign",
+ "sloppyTypeAssert",
+ "sortSlice",
+ "sprintfQuotedString",
+ "sqlQuery",
+ "stringConcatSimplify",
+ "stringsCompare",
+ "stringXbytes",
+ "suspiciousSorting",
+ "switchTrue",
+ "syncMapLoadAndDelete",
+ "timeCmpSimplify",
+ "timeExprSimplify",
+ "tooManyResultsChecker",
+ "truncateCmp",
+ "typeAssertChain",
+ "typeDefFirst",
+ "typeSwitchVar",
+ "typeUnparen",
+ "uncheckedInlineErr",
+ "underef",
+ "unlabelStmt",
+ "unlambda",
+ "unnamedResult",
+ "unnecessaryBlock",
+ "unnecessaryDefer",
+ "unslice",
+ "valSwap",
+ "weakCond",
+ "whyNoLint",
+ "wrapperFunc",
+ "yodaStyleExpr"
+ ]
+ },
+ "gocritic-tags": {
+ "enum": [
+ "diagnostic",
+ "style",
+ "performance",
+ "experimental",
+ "opinionated",
+ "security"
+ ]
+ },
+ "gosec-rules": {
+ "enum": [
+ "G101",
+ "G102",
+ "G103",
+ "G104",
+ "G106",
+ "G107",
+ "G108",
+ "G109",
+ "G110",
+ "G111",
+ "G112",
+ "G113",
+ "G114",
+ "G201",
+ "G202",
+ "G203",
+ "G204",
+ "G301",
+ "G302",
+ "G303",
+ "G304",
+ "G305",
+ "G306",
+ "G307",
+ "G401",
+ "G402",
+ "G403",
+ "G404",
+ "G501",
+ "G502",
+ "G503",
+ "G504",
+ "G505",
+ "G601",
+ "G602"
+ ]
+ },
+ "govet-analyzers": {
+ "enum": [
+ "appends",
+ "asmdecl",
+ "assign",
+ "atomic",
+ "atomicalign",
+ "bools",
+ "buildtag",
+ "cgocall",
+ "composites",
+ "copylocks",
+ "deepequalerrors",
+ "defers",
+ "directive",
+ "errorsas",
+ "fieldalignment",
+ "findcall",
+ "framepointer",
+ "httpresponse",
+ "ifaceassert",
+ "loopclosure",
+ "lostcancel",
+ "nilfunc",
+ "nilness",
+ "printf",
+ "reflectvaluecompare",
+ "shadow",
+ "shift",
+ "sigchanyzer",
+ "slog",
+ "sortslice",
+ "stdmethods",
+ "stringintconv",
+ "structtag",
+ "testinggoroutine",
+ "tests",
+ "unmarshal",
+ "unreachable",
+ "unsafeptr",
+ "unusedresult",
+ "unusedwrite"
+ ]
+ },
+ "revive-rules": {
+ "enum": [
+ "add-constant",
+ "argument-limit",
+ "atomic",
+ "banned-characters",
+ "bare-return",
+ "blank-imports",
+ "bool-literal-in-expr",
+ "call-to-gc",
+ "cognitive-complexity",
+ "comment-spacings",
+ "confusing-naming",
+ "confusing-results",
+ "constant-logical-expr",
+ "context-as-argument",
+ "context-keys-type",
+ "cyclomatic",
+ "datarace",
+ "deep-exit",
+ "defer",
+ "dot-imports",
+ "duplicated-imports",
+ "early-return",
+ "empty-block",
+ "empty-lines",
+ "enforce-map-style",
+ "enforce-repeated-arg-type-style",
+ "enforce-slice-style",
+ "error-naming",
+ "error-return",
+ "error-strings",
+ "errorf",
+ "exported",
+ "file-header",
+ "flag-parameter",
+ "function-length",
+ "function-result-limit",
+ "get-return",
+ "identical-branches",
+ "if-return",
+ "import-alias-naming",
+ "import-shadowing",
+ "imports-blocklist",
+ "increment-decrement",
+ "indent-error-flow",
+ "line-length-limit",
+ "max-control-nesting",
+ "max-public-structs",
+ "modifies-parameter",
+ "modifies-value-receiver",
+ "nested-structs",
+ "optimize-operands-order",
+ "package-comments",
+ "range",
+ "range-val-address",
+ "range-val-in-closure",
+ "receiver-naming",
+ "redefines-builtin-id",
+ "redundant-import-alias",
+ "string-format",
+ "string-of-int",
+ "struct-tag",
+ "superfluous-else",
+ "time-equal",
+ "time-naming",
+ "unchecked-type-assertion",
+ "unconditional-recursion",
+ "unexported-naming",
+ "unexported-return",
+ "unhandled-error",
+ "unnecessary-stmt",
+ "unreachable-code",
+ "unused-parameter",
+ "unused-receiver",
+ "use-any",
+ "useless-break",
+ "var-declaration",
+ "var-naming",
+ "waitgroup-by-value"
+ ]
+ },
+ "linters": {
+ "$comment": "anyOf with enum is used to allow auto completion of non-custom linters",
+ "description": "Linters usable.",
+ "anyOf": [
+ {
+ "enum": [
+ "asasalint",
+ "asciicheck",
+ "bidichk",
+ "bodyclose",
+ "canonicalheader",
+ "containedctx",
+ "contextcheck",
+ "copyloopvar",
+ "cyclop",
+ "deadcode",
+ "decorder",
+ "depguard",
+ "dogsled",
+ "dupl",
+ "dupword",
+ "durationcheck",
+ "errcheck",
+ "errchkjson",
+ "errname",
+ "errorlint",
+ "execinquery",
+ "exhaustive",
+ "exhaustivestruct",
+ "exhaustruct",
+ "exportloopref",
+ "fatcontext",
+ "forbidigo",
+ "forcetypeassert",
+ "funlen",
+ "gci",
+ "ginkgolinter",
+ "gocheckcompilerdirectives",
+ "gochecknoglobals",
+ "gochecknoinits",
+ "gochecksumtype",
+ "gocognit",
+ "goconst",
+ "gocritic",
+ "gocyclo",
+ "godot",
+ "godox",
+ "err113",
+ "gofmt",
+ "gofumpt",
+ "goheader",
+ "goimports",
+ "golint",
+ "gomoddirectives",
+ "gomodguard",
+ "goprintffuncname",
+ "gosec",
+ "gosimple",
+ "gosmopolitan",
+ "govet",
+ "grouper",
+ "ifshort",
+ "importas",
+ "inamedparam",
+ "ineffassign",
+ "interfacebloat",
+ "interfacer",
+ "intrange",
+ "ireturn",
+ "lll",
+ "loggercheck",
+ "maintidx",
+ "makezero",
+ "maligned",
+ "mirror",
+ "misspell",
+ "mnd",
+ "musttag",
+ "nakedret",
+ "nestif",
+ "nilerr",
+ "nilnil",
+ "nlreturn",
+ "noctx",
+ "nolintlint",
+ "nonamedreturns",
+ "nosnakecase",
+ "nosprintfhostport",
+ "paralleltest",
+ "perfsprint",
+ "prealloc",
+ "predeclared",
+ "promlinter",
+ "protogetter",
+ "reassign",
+ "revive",
+ "rowserrcheck",
+ "scopelint",
+ "sloglint",
+ "sqlclosecheck",
+ "staticcheck",
+ "structcheck",
+ "stylecheck",
+ "tagalign",
+ "tagliatelle",
+ "tenv",
+ "testableexamples",
+ "testifylint",
+ "testpackage",
+ "thelper",
+ "tparallel",
+ "typecheck",
+ "unconvert",
+ "unparam",
+ "unused",
+ "usestdlibvars",
+ "varcheck",
+ "varnamelen",
+ "wastedassign",
+ "whitespace",
+ "wrapcheck",
+ "wsl",
+ "zerologlint"
+ ]
+ },
+ {
+ "type": "string"
+ }
+ ]
+ }
+ },
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "run": {
+ "description": "Options for analysis running,",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "concurrency": {
+ "description": "Number of concurrent runners. Defaults to the number of available CPU cores.",
+ "type": "integer",
+ "minimum": 0,
+ "examples": [4]
+ },
+ "timeout": {
+ "description": "Timeout for the analysis.",
+ "type": "string",
+ "pattern": "^((\\d+h)?(\\d+m)?(\\d+(?:\\.\\d)?s)?|0)$",
+ "default": "1m",
+ "examples": ["30s", "5m", "5m30s"]
+ },
+ "issues-exit-code": {
+ "description": "Exit code when at least one issue was found.",
+ "type": "integer",
+ "default": 1
+ },
+ "tests": {
+ "description": "Enable inclusion of test files.",
+ "type": "boolean",
+ "default": true
+ },
+ "build-tags": {
+ "description": "List of build tags to pass to all linters.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "default": [],
+ "examples": [["mytag"]]
+ },
+ "modules-download-mode": {
+ "description": "Option to pass to \"go list -mod={option}\".\nSee \"go help modules\" for more information.",
+ "enum": ["mod", "readonly", "vendor"]
+ },
+ "allow-parallel-runners": {
+ "description": "Allow multiple parallel golangci-lint instances running. If disabled, golangci-lint acquires file lock on start.",
+ "type": "boolean",
+ "default": false
+ },
+ "allow-serial-runners": {
+ "description": "Allow multiple golangci-lint instances running, but serialize them around a lock.",
+ "type": "boolean",
+ "default": false
+ },
+ "go": {
+ "description": "Targeted Go version.",
+ "type": "string",
+ "default": "1.17"
+ }
+ }
+ },
+ "output": {
+ "description": "Output configuration options.",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "formats": {
+ "description": "Output formats to use.",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "path": {
+ "default": "stdout",
+ "anyOf": [
+ {
+ "enum": [ "stdout", "stderr" ]
+ },
+ {
+ "type": "string"
+ }
+ ]
+ },
+ "format": {
+ "default": "colored-line-number",
+ "enum": [
+ "colored-line-number",
+ "line-number",
+ "json",
+ "colored-tab",
+ "tab",
+ "html",
+ "checkstyle",
+ "code-climate",
+ "junit-xml",
+ "github-actions",
+ "teamcity",
+ "sarif"
+ ]
+ }
+ },
+ "required": ["format"]
+ }
+ },
+ "print-issued-lines": {
+ "description": "Print lines of code with issue.",
+ "type": "boolean",
+ "default": true
+ },
+ "print-linter-name": {
+ "description": "Print linter name in the end of issue text.",
+ "type": "boolean",
+ "default": true
+ },
+ "uniq-by-line": {
+ "description": "Make issues output unique by line.",
+ "type": "boolean",
+ "default": true
+ },
+ "path-prefix": {
+ "description": "Add a prefix to the output file references.",
+ "type": "string",
+ "default": ""
+ },
+ "show-stats": {
+ "description": "Show statistics per linter.",
+ "type": "boolean",
+ "default": false
+ },
+ "sort-order": {
+ "type": "array",
+ "items": {
+ "enum": ["linter", "severity", "file"]
+ }
+ },
+ "sort-results": {
+ "description": "Sort results by: filepath, line and column.",
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "linters-settings": {
+ "description": "All available settings of specific linters.",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "dupword": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "keywords": {
+ "description": "Keywords for detecting duplicate words. If this list is not empty, only the words defined in this list will be detected.",
+ "type": "array",
+ "uniqueItems": true,
+ "items": {
+ "type": "string",
+ "examples": ["the", "and", "a"]
+ }
+ },
+ "ignore": {
+ "description": "Keywords used to ignore detection.",
+ "type": "array",
+ "uniqueItems": true,
+ "items": {
+ "type": "string",
+ "examples": ["0C0C"]
+ }
+ }
+ }
+ },
+ "asasalint": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "exclude": {
+ "description": "To specify a set of function names to exclude.",
+ "type": "array",
+ "uniqueItems": true,
+ "items": {
+ "type": "string",
+ "examples": ["\\.Wrapf"]
+ }
+ },
+ "use-builtin-exclusions": {
+ "description": "To enable/disable the asasalint builtin exclusions of function names.",
+ "type": "boolean",
+ "default": true
+ },
+ "ignore-test": {
+ "description": "Ignore *_test.go files.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "bidichk": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "left-to-right-embedding": {
+ "description": "Disallow: LEFT-TO-RIGHT-EMBEDDING",
+ "type": "boolean",
+ "default": false
+ },
+ "right-to-left-embedding": {
+ "description": "Disallow: RIGHT-TO-LEFT-EMBEDDING",
+ "type": "boolean",
+ "default": false
+ },
+ "pop-directional-formatting": {
+ "description": "Disallow: POP-DIRECTIONAL-FORMATTING",
+ "type": "boolean",
+ "default": false
+ },
+ "left-to-right-override": {
+ "description": "Disallow: LEFT-TO-RIGHT-OVERRIDE",
+ "type": "boolean",
+ "default": false
+ },
+ "right-to-left-override": {
+ "description": "Disallow: RIGHT-TO-LEFT-OVERRIDE",
+ "type": "boolean",
+ "default": false
+ },
+ "left-to-right-isolate": {
+ "description": "Disallow: LEFT-TO-RIGHT-ISOLATE",
+ "type": "boolean",
+ "default": false
+ },
+ "right-to-left-isolate": {
+ "description": "Disallow: RIGHT-TO-LEFT-ISOLATE",
+ "type": "boolean",
+ "default": false
+ },
+ "first-strong-isolate": {
+ "description": "Disallow: FIRST-STRONG-ISOLATE",
+ "type": "boolean",
+ "default": false
+ },
+ "pop-directional-isolate": {
+ "description": "Disallow: POP-DIRECTIONAL-ISOLATE",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "cyclop": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "skip-tests": {
+ "description": "Should the linter execute on test files as well",
+ "type": "boolean",
+ "default": false
+ },
+ "max-complexity": {
+ "description": "Max complexity the function can have",
+ "type": "integer",
+ "default": 10,
+ "minimum": 0
+ },
+ "package-average": {
+ "description": "Max average complexity in package",
+ "type": "number",
+ "default": 0,
+ "minimum": 0
+ }
+ }
+ },
+ "decorder": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "dec-order": {
+ "type": "array",
+ "default": [["type", "const", "var", "func"]],
+ "items": {
+ "enum": ["type", "const", "var", "func"]
+ }
+ },
+ "ignore-underscore-vars": {
+ "description": "Underscore vars (vars with \"_\" as the name) will be ignored at all checks",
+ "default": true,
+ "type": "boolean"
+ },
+ "disable-dec-order-check": {
+ "description": "Order of declarations is not checked",
+ "default": true,
+ "type": "boolean"
+ },
+ "disable-init-func-first-check": {
+ "description": "Allow init func to be anywhere in file",
+ "default": true,
+ "type": "boolean"
+ },
+ "disable-dec-num-check": {
+ "description": "Multiple global type, const and var declarations are allowed",
+ "default": true,
+ "type": "boolean"
+ },
+ "disable-type-dec-num-check": {
+ "description": "Type declarations will be ignored for dec num check",
+ "default": true,
+ "type": "boolean"
+ },
+ "disable-const-dec-num-check": {
+ "description": "Const declarations will be ignored for dec num check",
+ "default": true,
+ "type": "boolean"
+ },
+ "disable-var-dec-num-check": {
+ "description": "Var declarations will be ignored for dec num check",
+ "default": true,
+ "type": "boolean"
+ }
+ }
+ },
+ "depguard": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "rules": {
+ "description": "Rules to apply.",
+ "type": "object",
+ "additionalProperties": false,
+ "patternProperties": {
+ "^[^.]+$": {
+ "description": "Name of a rule.",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "list-mode": {
+ "description": "Used to determine the package matching priority.",
+ "enum": ["original", "strict", "lax"],
+ "default": "original"
+ },
+ "files": {
+ "description": "List of file globs that will match this list of settings to compare against.",
+ "additionalProperties": false,
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "allow": {
+ "description": "List of allowed packages.",
+ "additionalProperties": false,
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "deny": {
+ "description": "Packages that are not allowed where the value is a suggestion.",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "desc": {
+ "description": "Description",
+ "type": "string"
+ },
+ "pkg": {
+ "description": "Package",
+ "type": "string"
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "dogsled": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "max-blank-identifiers": {
+ "description": "Check assignments with too many blank identifiers.",
+ "type": "integer",
+ "default": 2,
+ "minimum": 0
+ }
+ }
+ },
+ "dupl": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "threshold": {
+ "description": "Tokens count to trigger issue.",
+ "type": "integer",
+ "default": 150,
+ "minimum": 0
+ }
+ }
+ },
+ "errcheck": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "check-type-assertions": {
+ "description": "Report about not checking errors in type assertions, i.e.: `a := b.(MyStruct)`",
+ "type": "boolean",
+ "default": false
+ },
+ "check-blank": {
+ "description": "Report about assignment of errors to blank identifier",
+ "type": "boolean",
+ "default": false
+ },
+ "exclude-functions": {
+ "description": "List of functions to exclude from checking, where each entry is a single function to exclude",
+ "type": "array",
+ "examples": ["io/ioutil.ReadFile", "io.Copy(*bytes.Buffer)"],
+ "items": {
+ "type": "string"
+ }
+ },
+ "disable-default-exclusions": {
+ "description": "To disable the errcheck built-in exclude list",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "errchkjson": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "check-error-free-encoding": {
+ "type": "boolean",
+ "default": false
+ },
+ "report-no-exported": {
+ "description": "Issue on struct that doesn't have exported fields.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "errorlint": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "errorf": {
+ "description": "Check whether fmt.Errorf uses the %w verb for formatting errors",
+ "type": "boolean",
+ "default": true
+ },
+ "errorf-multi": {
+ "description": "Permit more than 1 %w verb, valid per Go 1.20",
+ "type": "boolean",
+ "default": true
+ },
+ "asserts": {
+ "description": "Check for plain type assertions and type switches.",
+ "type": "boolean",
+ "default": true
+ },
+ "comparison": {
+ "description": "Check for plain error comparisons",
+ "type": "boolean",
+ "default": true
+ },
+ "allowed-errors": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "err": {
+ "type": "string"
+ },
+ "fun": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "allowed-errors-wildcard": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "err": {
+ "type": "string"
+ },
+ "fun": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ }
+ },
+ "exhaustive": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "check": {
+ "description": "Program elements to check for exhaustiveness.",
+ "type": "array",
+ "uniqueItems": true,
+ "items": {
+ "type": "string",
+ "examples": ["switch", "map"]
+ }
+ },
+ "check-generated": {
+ "description": "Check switch statements in generated files",
+ "type": "boolean",
+ "default": false
+ },
+ "explicit-exhaustive-switch": {
+ "description": "Only run exhaustive check on switches with \"//exhaustive:enforce\" comment.",
+ "type": "boolean",
+ "default": false
+ },
+ "explicit-exhaustive-map": {
+ "description": "Only run exhaustive check on map literals with \"//exhaustive:enforce\" comment.",
+ "type": "boolean",
+ "default": false
+ },
+ "default-case-required": {
+ "description": "Switch statement requires default case even if exhaustive.",
+ "type": "boolean",
+ "default": false
+ },
+ "default-signifies-exhaustive": {
+ "description": "Presence of `default` case in switch statements satisfies exhaustiveness, even if all enum members are not listed.",
+ "type": "boolean",
+ "default": false
+ },
+ "ignore-enum-members": {
+ "description": "Enum members matching `regex` do not have to be listed in switch statements to satisfy exhaustiveness",
+ "type": "string"
+ },
+ "ignore-enum-types": {
+ "description": "Enum types matching the supplied regex do not have to be listed in switch statements to satisfy exhaustiveness.",
+ "type": "string"
+ },
+ "package-scope-only": {
+ "description": "Consider enums only in package scopes, not in inner scopes.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "exhaustruct": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "include": {
+ "description": "List of regular expressions to match struct packages and names.",
+ "type": "array",
+ "examples": [".*\\.Test"],
+ "items": {
+ "type": "string"
+ }
+ },
+ "exclude": {
+ "description": "List of regular expressions to exclude struct packages and names from check.",
+ "type": "array",
+ "examples": ["cobra\\.Command$"],
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "forbidigo": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "exclude-godoc-examples": {
+ "description": "Exclude code in godoc examples.",
+ "type": "boolean",
+ "default": true
+ },
+ "analyze-types": {
+ "description": "Instead of matching the literal source code, use type information to replace expressions with strings that contain the package name and (for methods and fields) the type name.",
+ "type": "boolean",
+ "default": true
+ },
+ "forbid": {
+ "description": "List of identifiers to forbid (written using `regexp`)",
+ "type": "array",
+ "examples": ["^print.*$"],
+ "items": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "p": {
+ "description": "Pattern",
+ "type": "string"
+ },
+ "pkg": {
+ "description": "Package",
+ "type": "string"
+ },
+ "msg": {
+ "description": "Message",
+ "type": "string"
+ }
+ }
+ }
+ ]
+ }
+ }
+ }
+ },
+ "funlen": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "lines": {
+ "description": "Limit lines number per function.",
+ "type": "integer",
+ "default": 60
+ },
+ "statements": {
+ "description": "Limit statements number per function.",
+ "type": "integer",
+ "default": 40
+ },
+ "ignore-comments": {
+ "description": "Ignore comments when counting lines.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "gci": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "sections": {
+ "description": "Section configuration to compare against.",
+ "type": "array",
+ "items": {
+ "anyOf": [
+ {
+ "enum": [
+ "standard",
+ "default",
+ "blank",
+ "dot",
+ "alias",
+ "localmodule"
+ ]
+ },
+ {
+ "type": "string"
+ }
+ ]
+ },
+ "default": ["standard", "default"]
+ },
+ "skip-generated": {
+ "description": "Skip generated files.",
+ "type": "boolean",
+ "default": true
+ },
+ "custom-order": {
+ "description": "Enable custom order of sections.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "ginkgolinter": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "suppress-len-assertion": {
+ "description": "Suppress the wrong length assertion warning.",
+ "type": "boolean",
+ "default": false
+ },
+ "suppress-nil-assertion": {
+ "description": "Suppress the wrong nil assertion warning.",
+ "type": "boolean",
+ "default": false
+ },
+ "suppress-err-assertion": {
+ "description": "Suppress the wrong error assertion warning.",
+ "type": "boolean",
+ "default": false
+ },
+ "suppress-compare-assertion": {
+ "description": "Suppress the wrong comparison assertion warning.",
+ "type": "boolean",
+ "default": false
+ },
+ "suppress-async-assertion": {
+ "description": "Suppress the function all in async assertion warning.",
+ "type": "boolean",
+ "default": false
+ },
+ "suppress-type-compare-assertion": {
+ "description": "Suppress warning for comparing values from different types, like int32 and uint32.",
+ "type": "boolean",
+ "default": false
+ },
+ "forbid-focus-container": {
+ "description": "Trigger warning for ginkgo focus containers like FDescribe, FContext, FWhen or FIt.",
+ "type": "boolean",
+ "default": false
+ },
+ "allow-havelen-zero": {
+ "description": "Don't trigger warnings for HaveLen(0).",
+ "type": "boolean",
+ "default": false
+ },
+ "force-expect-to": {
+ "description": "Force using `Expect` with `To`, `ToNot` or `NotTo`",
+ "type": "boolean",
+ "default": false
+ },
+ "validate-async-intervals": {
+ "description": "Best effort validation of async intervals (timeout and polling).",
+ "type": "boolean",
+ "default": false
+ },
+ "forbid-spec-pollution": {
+ "description": "Trigger a warning for variable assignments in ginkgo containers like `Describe`, `Context` and `When`, instead of in `BeforeEach()`.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "gocognit": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "min-complexity": {
+ "description": "Minimal code complexity to report (we recommend 10-20).",
+ "type": "integer",
+ "default": 30
+ }
+ }
+ },
+ "goconst": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "match-constant": {
+ "description": "Look for existing constants matching the values",
+ "type": "boolean",
+ "default": true
+ },
+ "min-len": {
+ "description": "Minimum length of string constant.",
+ "type": "integer",
+ "default": 3
+ },
+ "min-occurrences": {
+ "description": "Minimum occurrences count to trigger.",
+ "type": "integer",
+ "default": 3
+ },
+ "ignore-tests": {
+ "description": "Ignore test files.",
+ "type": "boolean",
+ "default": false
+ },
+ "ignore-calls": {
+ "description": "Ignore when constant is not used as function argument",
+ "type": "boolean",
+ "default": true
+ },
+ "ignore-strings": {
+ "description": "Exclude strings matching the given regular expression",
+ "type": "string"
+ },
+ "numbers": {
+ "description": "Search also for duplicated numbers.",
+ "type": "boolean",
+ "default": false
+ },
+ "min": {
+ "description": "Minimum value, only works with `numbers`",
+ "type": "integer",
+ "default": 3
+ },
+ "max": {
+ "description": "Maximum value, only works with `numbers`",
+ "type": "integer",
+ "default": 3
+ }
+ }
+ },
+ "gocritic": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "enabled-checks": {
+ "description": "Which checks should be enabled. By default, a list of stable checks is used. To see it, run `GL_DEBUG=gocritic golangci-lint run`.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/gocritic-checks"
+ }
+ },
+ "disabled-checks": {
+ "description": "Which checks should be disabled.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/gocritic-checks"
+ },
+ "default": []
+ },
+ "enabled-tags": {
+ "description": "Enable multiple checks by tags, run `GL_DEBUG=gocritic golangci-lint run` to see all tags and checks.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/gocritic-tags"
+ }
+ },
+ "disabled-tags": {
+ "description": "Disable multiple checks by tags, run `GL_DEBUG=gocritic golangci-lint run` to see all tags and checks.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/gocritic-tags"
+ }
+ },
+ "settings": {
+ "description": "Settings passed to gocritic. Properties must be valid and enabled check names.",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "captLocal": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "paramsOnly" : {
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "commentedOutCode": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "minLength" : {
+ "type": "number",
+ "default": 15
+ }
+ }
+ },
+ "elseif": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "skipBalanced" : {
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "hugeParam": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "sizeThreshold" : {
+ "type": "number",
+ "default": 80
+ }
+ }
+ },
+ "ifElseChain": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "minThreshold" : {
+ "type": "number",
+ "default": 2
+ }
+ }
+ },
+ "nestingReduce": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "bodyWidth" : {
+ "type": "number",
+ "default": 5
+ }
+ }
+ },
+ "rangeExprCopy": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "sizeThreshold" : {
+ "type": "number",
+ "default": 512
+ },
+ "skipTestFuncs" : {
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "rangeValCopy": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "sizeThreshold" : {
+ "type": "number",
+ "default": 128
+ },
+ "skipTestFuncs" : {
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "ruleguard": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "debug" : {
+ "type": "string"
+ },
+ "enable" : {
+ "type": "string"
+ },
+ "disable" : {
+ "type": "string"
+ },
+ "failOn" : {
+ "type": "string"
+ },
+ "rules" : {
+ "type": "string"
+ }
+ }
+ },
+ "tooManyResultsChecker": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "maxResults" : {
+ "type": "number",
+ "default": 5
+ }
+ }
+ },
+ "truncateCmp": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "skipArchDependent" : {
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "underef": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "skipRecvDeref" : {
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "unnamedResult": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "checkExported" : {
+ "type": "boolean",
+ "default": false
+ }
+ }
+ }
+ }
+ },
+ "disable-all": {
+ "type": "boolean",
+ "default": false
+ },
+ "enable-all": {
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "gocyclo": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "min-complexity": {
+ "description": "Minimum code complexity to report (we recommend 10-20).",
+ "type": "integer",
+ "default": 30
+ }
+ }
+ },
+ "godot": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "scope": {
+ "description": "Comments to be checked.",
+ "enum": ["declarations", "toplevel", "all"],
+ "default": "declarations"
+ },
+ "exclude": {
+ "description": "List of regexps for excluding particular comment lines from check.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "period": {
+ "description": "Check that each sentence ends with a period.",
+ "type": "boolean",
+ "default": true
+ },
+ "capital": {
+ "description": "Check that each sentence starts with a capital letter.",
+ "type": "boolean",
+ "default": false
+ },
+ "check-all": {
+ "description": "DEPRECATED: Check all top-level comments, not only declarations.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "godox": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "keywords": {
+ "description": "Report any comments starting with one of these keywords. This is useful for TODO or FIXME comments that might be left in the code accidentally and should be resolved before merging.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "default": ["TODO", "BUG", "FIXME"]
+ }
+ }
+ },
+ "gofmt": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "simplify": {
+ "description": "Simplify code.",
+ "type": "boolean",
+ "default": true
+ },
+ "rewrite-rules": {
+ "description": "Apply the rewrite rules to the source before reformatting.",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "pattern": {
+ "type": "string"
+ },
+ "replacement": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ }
+ },
+ "interfacebloat": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "max": {
+ "description": "The maximum number of methods allowed for an interface.",
+ "type": "integer"
+ }
+ }
+ },
+ "gofumpt": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "extra-rules": {
+ "description": "Choose whether or not to use the extra rules that are disabled by default.",
+ "type": "boolean",
+ "default": false
+ },
+ "module-path": {
+ "description": " Module path which contains the source code being formatted.",
+ "type": "string"
+ }
+ }
+ },
+ "goheader": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "values": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "const": {
+ "description": "Constants to use in the template.",
+ "type": "object",
+ "patternProperties": {
+ "^.+$": {
+ "description": "Value for the constant.",
+ "type": "string"
+ }
+ },
+ "additionalProperties": false,
+ "examples": [
+ {
+ "YEAR": "2030",
+ "COMPANY": "MY FUTURISTIC COMPANY"
+ }
+ ]
+ },
+ "regexp": {
+ "description": "Regular expressions to use in your template.",
+ "type": "object",
+ "additionalProperties": false,
+ "patternProperties": {
+ "^.+$": {
+ "type": "string"
+ }
+ },
+ "examples": [
+ {
+ "AUTHOR": ".*@mycompany\\.com"
+ }
+ ]
+ }
+ }
+ },
+ "template": {
+ "description": "Template to put on top of every file.",
+ "type": "string",
+ "examples": [
+ "{{ MY COMPANY }}\nSPDX-License-Identifier: Apache-2.0\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at:\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License."
+ ]
+ },
+ "template-path": {
+ "description": "Path to the file containing the template source.",
+ "type": "string",
+ "examples": ["my_header_template.txt"]
+ }
+ },
+ "oneOf": [
+ { "required": ["template"] },
+ { "required": ["template-path"] }
+ ]
+ },
+ "goimports": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "local-prefixes": {
+ "description": "Put imports beginning with prefix after 3rd-party packages. It is a comma-separated list of prefixes.",
+ "type": "string",
+ "examples": ["github.com/org/project"]
+ }
+ }
+ },
+ "gomoddirectives": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "replace-local": {
+ "description": "Allow local `replace` directives.",
+ "type": "boolean",
+ "default": true
+ },
+ "replace-allow-list": {
+ "description": "List of allowed `replace` directives.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "retract-allow-no-explanation": {
+ "description": "Allow to not explain why the version has been retracted in the `retract` directives.",
+ "type": "boolean",
+ "default": true
+ },
+ "exclude-forbidden": {
+ "description": "Forbid the use of the `exclude` directives.",
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "gomodguard": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "allowed": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "modules": {
+ "description": "List of allowed modules.",
+ "type": "array",
+ "items": {
+ "type": "string",
+ "examples": ["gopkg.in/yaml.v2"]
+ }
+ },
+ "domains": {
+ "description": "List of allowed module domains.",
+ "type": "array",
+ "items": {
+ "type": "string",
+ "examples": ["golang.org"]
+ }
+ }
+ }
+ },
+ "blocked": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "modules": {
+ "description": "List of blocked modules.",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "patternProperties": {
+ "^.+$": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "recommendations": {
+ "description": "Recommended modules that should be used instead.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "reason": {
+ "description": "Reason why the recommended module should be used.",
+ "type": "string"
+ }
+ }
+ }
+ },
+ "additionalProperties": false
+ }
+ },
+ "versions": {
+ "description": "List of blocked module version constraints.",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "patternProperties": {
+ "^.*$": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "version": {
+ "description": "Version constraint.",
+ "type": "string"
+ },
+ "reason": {
+ "description": "Reason why the version constraint exists.",
+ "type": "string"
+ }
+ },
+ "required": ["reason"]
+ }
+ }
+ }
+ },
+ "local_replace_directives": {
+ "description": "Raise lint issues if loading local path with replace directive",
+ "type": "boolean",
+ "default": true
+ }
+ }
+ }
+ }
+ },
+ "gosimple": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "checks": {
+ "type": "array",
+ "items": {
+ "anyOf": [
+ {
+ "enum": ["all"]
+ },
+ {
+ "type": "string"
+ }
+ ]
+ }
+ }
+ }
+ },
+ "gosec": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "includes": {
+ "type": "array",
+ "description": "To select a subset of rules to run",
+ "examples": [["G401"]],
+ "items": {
+ "$ref": "#/definitions/gosec-rules"
+ }
+ },
+ "excludes": {
+ "type": "array",
+ "description": "To specify a set of rules to explicitly exclude",
+ "examples": [["G401"]],
+ "items": {
+ "$ref": "#/definitions/gosec-rules"
+ }
+ },
+ "exclude-generated": {
+ "description": "Exclude generated files",
+ "type": "boolean",
+ "default": false
+ },
+ "severity": {
+ "description": "Filter out the issues with a lower severity than the given value",
+ "type": "string",
+ "enum": ["low", "medium", "high"],
+ "default": "low"
+ },
+ "confidence": {
+ "description": "Filter out the issues with a lower confidence than the given value",
+ "type": "string",
+ "enum": ["low", "medium", "high"],
+ "default": "low"
+ },
+ "config": {
+ "description": "To specify the configuration of rules",
+ "type": "object"
+ },
+ "concurrency": {
+ "description": "Concurrency value",
+ "type": "integer"
+ }
+ }
+ },
+ "gosmopolitan": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "allow-time-local": {
+ "description": "Allow and ignore `time.Local` usages.",
+ "type": "boolean",
+ "default": false
+ },
+ "escape-hatches": {
+ "description": "List of fully qualified names in the `full/pkg/path.name` form, to act as \"i18n escape hatches\".",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ignore-tests": {
+ "description": "Ignore test files.",
+ "type": "boolean",
+ "default": false
+ },
+ "watch-for-scripts": {
+ "description": "List of Unicode scripts to watch for any usage in string literals.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "govet": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "settings": {
+ "description": "Settings per analyzer. Map of analyzer name to specific settings.\nRun `go tool vet help` to find out more.",
+ "type": "object",
+ "propertyNames": {
+ "$ref": "#/definitions/govet-analyzers"
+ },
+ "patternProperties": {
+ "^.*$": {
+ "description": "Run `go tool vet help ` to see all settings.",
+ "type": "object"
+ }
+ }
+ },
+ "enable": {
+ "description": "Enable analyzers by name.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/govet-analyzers"
+ }
+ },
+ "disable": {
+ "description": "Disable analyzers by name.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/govet-analyzers"
+ }
+ },
+ "enable-all": {
+ "description": "Enable all analyzers.",
+ "type": "boolean",
+ "default": false
+ },
+ "disable-all": {
+ "description": "Disable all analyzers.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "grouper": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "const-require-single-const": {
+ "type": "boolean",
+ "default": false
+ },
+ "const-require-grouping": {
+ "type": "boolean",
+ "default": false
+ },
+ "import-require-single-import": {
+ "type": "boolean",
+ "default": false
+ },
+ "import-require-grouping": {
+ "type": "boolean",
+ "default": false
+ },
+ "type-require-single-type": {
+ "type": "boolean",
+ "default": false
+ },
+ "type-require-grouping": {
+ "type": "boolean",
+ "default": false
+ },
+ "var-require-single-var": {
+ "type": "boolean",
+ "default": false
+ },
+ "var-require-grouping": {
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "importas": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "no-unaliased": {
+ "description": "Do not allow unaliased imports of aliased packages.",
+ "type": "boolean",
+ "default": false
+ },
+ "no-extra-aliases": {
+ "description": "Do not allow non-required aliases.",
+ "type": "boolean",
+ "default": false
+ },
+ "alias": {
+ "description": "List of aliases",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "pkg": {
+ "description": "Package path e.g. knative.dev/serving/pkg/apis/autoscaling/v1alpha1",
+ "type": "string"
+ },
+ "alias": {
+ "description": "Package alias e.g. autoscalingv1alpha1",
+ "type": "string"
+ }
+ },
+ "required": ["pkg", "alias"]
+ }
+ }
+ }
+ },
+ "inamedparam": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "skip-single-param": {
+ "description": "Skips check for interface methods with only a single parameter.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "ireturn": {
+ "type": "object",
+ "additionalProperties": false,
+ "description": "Use either `reject` or `allow` properties for interfaces matching.",
+ "properties": {
+ "allow": {
+ "type": "array",
+ "items": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "enum": ["anon", "error", "empty", "stdlib"]
+ }
+ ]
+ }
+ },
+ "reject": {
+ "type": "array",
+ "items": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "enum": ["anon", "error", "empty", "stdlib"]
+ }
+ ]
+ }
+ }
+ },
+ "anyOf": [
+ {
+ "not": {
+ "properties": {
+ "allow": {
+ "const": "reject"
+ }
+ }
+ },
+ "required": ["allow"]
+ },
+ {
+ "required": ["reject"]
+ }
+ ]
+ },
+ "lll": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "tab-width": {
+ "description": "Width of \"\\t\" in spaces.",
+ "type": "integer",
+ "minimum": 0,
+ "default": 1
+ },
+ "line-length": {
+ "description": "Maximum allowed line length, lines longer will be reported.",
+ "type": "integer",
+ "minimum": 1,
+ "default": 120
+ }
+ }
+ },
+ "maintidx": {
+ "description": "Maintainability index https://docs.microsoft.com/en-us/visualstudio/code-quality/code-metrics-maintainability-index-range-and-meaning?view=vs-2022",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "under": {
+ "description": "Minimum accatpable maintainability index level (see https://docs.microsoft.com/en-us/visualstudio/code-quality/code-metrics-maintainability-index-range-and-meaning?view=vs-2022)",
+ "type": "number",
+ "default": 20
+ }
+ }
+ },
+ "makezero": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "always": {
+ "description": "Allow only slices initialized with a length of zero.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "loggercheck": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "kitlog": {
+ "description": "Allow check for the github.com/go-kit/log library.",
+ "type": "boolean",
+ "default": true
+ },
+ "klog": {
+ "description": "Allow check for the k8s.io/klog/v2 library.",
+ "type": "boolean",
+ "default": true
+ },
+ "logr": {
+ "description": "Allow check for the github.com/go-logr/logr library.",
+ "type": "boolean",
+ "default": true
+ },
+ "zap": {
+ "description": "Allow check for the \"sugar logger\" from go.uber.org/zap library.",
+ "type": "boolean",
+ "default": true
+ },
+ "require-string-key": {
+ "description": "Require all logging keys to be inlined constant strings.",
+ "type": "boolean",
+ "default": false
+ },
+ "no-printf-like": {
+ "description": "Require printf-like format specifier (%s, %d for example) not present.",
+ "type": "boolean",
+ "default": false
+ },
+ "rules": {
+ "description": "List of custom rules to check against, where each rule is a single logger pattern, useful for wrapped loggers.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "misspell": {
+ "description": "Correct spellings using locale preferences for US or UK. Default is to use a neutral variety of English.",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "locale": {
+ "enum": ["US", "UK"]
+ },
+ "ignore-words": {
+ "description": "List of words to ignore.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "mode": {
+ "description": "Mode of the analysis.",
+ "enum": ["restricted", "", "default"],
+ "default": ""
+ },
+ "extra-words": {
+ "description": "Extra word corrections.",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "correction": {
+ "type": "string"
+ },
+ "typo": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ }
+ },
+ "musttag": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "functions": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "name": {
+ "type": "string"
+ },
+ "tag": {
+ "type": "string"
+ },
+ "arg-pos": {
+ "type": "integer"
+ }
+ }
+ }
+ }
+ }
+ },
+ "nakedret": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "max-func-lines": {
+ "description": "Report if a function has more lines of code than this value and it has naked returns.",
+ "type": "integer",
+ "minimum": 0,
+ "default": 30
+ }
+ }
+ },
+ "nestif": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "min-complexity": {
+ "description": "Minimum complexity of \"if\" statements to report.",
+ "type": "integer",
+ "default": 5
+ }
+ }
+ },
+ "nilnil": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "checked-types": {
+ "type": "array",
+ "description": "List of return types to check.",
+ "items": {
+ "enum": ["ptr", "func", "iface", "map", "chan", "uintptr", "unsafeptr"]
+ },
+ "default": ["ptr", "func", "iface", "map", "chan", "uintptr", "unsafeptr"]
+ }
+ }
+ },
+ "nlreturn": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "block-size": {
+ "description": "set block size that is still ok",
+ "type": "number",
+ "default": 0,
+ "minimum": 0
+ }
+ }
+ },
+ "mnd": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "ignored-files": {
+ "description": "List of file patterns to exclude from analysis.",
+ "examples": [["magic1_.*.go"]],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ignored-functions": {
+ "description": "Comma-separated list of function patterns to exclude from the analysis.",
+ "examples": [["math.*", "http.StatusText", "make"]],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ignored-numbers": {
+ "description": "List of numbers to exclude from analysis.",
+ "examples": [["1000", "1234_567_890", "3.14159264"]],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "checks": {
+ "description": "The list of enabled checks, see https://github.com/tommy-muehle/go-mnd/#checks for description.",
+ "type": "array",
+ "items": {
+ "enum": [
+ "argument",
+ "case",
+ "condition",
+ "operation",
+ "return",
+ "assign"
+ ]
+ }
+ }
+ }
+ },
+ "nolintlint": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "allow-unused": {
+ "description": "Enable to ensure that nolint directives are all used.",
+ "type": "boolean",
+ "default": true
+ },
+ "allow-no-explanation": {
+ "description": "Exclude these linters from requiring an explanation.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/linters"
+ },
+ "default": []
+ },
+ "require-explanation": {
+ "description": "Enable to require an explanation of nonzero length after each nolint directive.",
+ "type": "boolean",
+ "default": false
+ },
+ "require-specific": {
+ "description": "Enable to require nolint directives to mention the specific linter being suppressed.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "reassign": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "patterns": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "nonamedreturns": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "report-error-in-defer": {
+ "description": "Report named error if it is assigned inside defer.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "paralleltest": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "ignore-missing": {
+ "description": "Ignore missing calls to `t.Parallel()` and only report incorrect uses of it.",
+ "type": "boolean",
+ "default": false
+ },
+ "ignore-missing-subtests": {
+ "description": "Ignore missing calls to `t.Parallel()` in subtests. Top-level tests are still required to have `t.Parallel`, but subtests are allowed to skip it.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "perfsprint": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "int-conversion": {
+ "description": "Optimizes even if it requires an int or uint type cast.",
+ "type": "boolean",
+ "default": true
+ },
+ "err-error": {
+ "description": "Optimizes into `err.Error()` even if it is only equivalent for non-nil errors.",
+ "type": "boolean",
+ "default": false
+ },
+ "errorf": {
+ "description": "Optimizes `fmt.Errorf`.",
+ "type": "boolean",
+ "default": true
+ },
+ "sprintf1": {
+ "description": "Optimizes `fmt.Sprintf` with only one argument.",
+ "type": "boolean",
+ "default": true
+ },
+ "strconcat": {
+ "description": "Optimizes into strings concatenation.",
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "prealloc": {
+ "description": "We do not recommend using this linter before doing performance profiling.\nFor most programs usage of `prealloc` will be premature optimization.",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "simple": {
+ "description": "Report preallocation suggestions only on simple loops that have no returns/breaks/continues/gotos in them.",
+ "type": "boolean",
+ "default": true
+ },
+ "range-loops": {
+ "description": "Report preallocation suggestions on range loops.",
+ "type": "boolean",
+ "default": true
+ },
+ "for-loops": {
+ "description": "Report preallocation suggestions on for loops.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "predeclared": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "ignore": {
+ "description": "Comma-separated list of predeclared identifiers to not report on.",
+ "type": "string"
+ },
+ "q": {
+ "description": "Include method names and field names (i.e., qualified names) in checks.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "promlinter": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "strict": {},
+ "disabled-linters": {
+ "type": "array",
+ "items": {
+ "enum": [
+ "Help",
+ "MetricUnits",
+ "Counter",
+ "HistogramSummaryReserved",
+ "MetricTypeInName",
+ "ReservedChars",
+ "CamelCase",
+ "UnitAbbreviations"
+ ]
+ }
+ }
+ }
+ },
+ "protogetter": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "skip-generated-by": {
+ "type": "array",
+ "items": {
+ "type": "string",
+ "examples": ["protoc-gen-go-my-own-generator"]
+ }
+ },
+ "skip-files": {
+ "type": "array",
+ "items": {
+ "type": "string",
+ "examples": ["*.pb.go"]
+ }
+ },
+ "skip-any-generated": {
+ "description": "Skip any generated files from the checking.",
+ "type": "boolean",
+ "default": false
+ },
+ "replace-first-arg-in-append": {
+ "description": "Skip first argument of append function.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "revive": {
+ "type": "object",
+ "additionalProperties": false,
+ "examples": [
+ {
+ "ignore-generated-header": true,
+ "severity": "warning",
+ "rules": [
+ {
+ "name": "indent-error-flow",
+ "severity": "warning"
+ },
+ {
+ "name": "add-constant",
+ "severity": "warning",
+ "arguments": [
+ {
+ "maxLitCount": "3",
+ "allowStrs": "\"\"",
+ "allowInts": "0,1,2",
+ "allowFloats": "0.0,0.,1.0,1.,2.0,2."
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ "properties": {
+ "max-open-files": {
+ "type": "integer"
+ },
+ "ignore-generated-header": {
+ "type": "boolean"
+ },
+ "confidence": {
+ "type": "number"
+ },
+ "severity": {
+ "type": "string",
+ "enum": ["warning", "error"]
+ },
+ "enable-all-rules": {
+ "type": "boolean",
+ "default": false
+ },
+ "directives": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "name": {
+ "type": "string",
+ "enum": ["specify-disable-reason"]
+ },
+ "severity": {
+ "type": "string",
+ "enum": ["warning", "error"]
+ },
+ "exclude": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "arguments": {
+ "type": "array"
+ }
+ }
+ }
+ },
+ "rules": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "required": ["name"],
+ "properties": {
+ "name": {
+ "$ref": "#/definitions/revive-rules",
+ "title": "The rule name"
+ },
+ "disabled": {
+ "type": "boolean"
+ },
+ "severity": {
+ "type": "string",
+ "enum": ["warning", "error"]
+ },
+ "exclude": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "arguments": {
+ "type": "array"
+ }
+ }
+ }
+ }
+ }
+ },
+ "rowserrcheck": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "packages": {
+ "type": "array",
+ "items": {
+ "description": "",
+ "type": "string",
+ "examples": ["github.com/jmoiron/sqlx"]
+ }
+ }
+ }
+ },
+ "sloglint": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "kv-only": {
+ "description": "Enforce using key-value pairs only (incompatible with attr-only).",
+ "type": "boolean",
+ "default": false
+ },
+ "no-global": {
+ "description": "Enforce not using global loggers.",
+ "enum": ["", "all", "default"],
+ "default": ""
+ },
+ "no-mixed-args": {
+ "description": "Enforce not mixing key-value pairs and attributes.",
+ "type": "boolean",
+ "default": true
+ },
+ "context": {
+ "description": "Enforce using methods that accept a context.",
+ "enum": ["", "all", "scope"],
+ "default": ""
+ },
+ "static-msg": {
+ "description": "Enforce using static values for log messages.",
+ "type": "boolean",
+ "default": false
+ },
+ "key-naming-case": {
+ "description": "Enforce a single key naming convention.",
+ "enum": ["snake", "kebab", "camel", "pascal"]
+ },
+ "attr-only": {
+ "description": "Enforce using attributes only (incompatible with kv-only).",
+ "type": "boolean",
+ "default": false
+ },
+ "no-raw-keys": {
+ "description": "Enforce using constants instead of raw keys.",
+ "type": "boolean",
+ "default": false
+ },
+ "forbidden-keys": {
+ "description": "Enforce not using specific keys.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "args-on-sep-lines": {
+ "description": "Enforce putting arguments on separate lines.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "spancheck": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "checks": {
+ "description": "Checks to enable.",
+ "type": "array",
+ "items": {
+ "enum": ["end", "record-error", "set-status"]
+ }
+ },
+ "ignore-check-signatures": {
+ "description": "A list of regexes for function signatures that silence `record-error` and `set-status` reports if found in the call path to a returned error.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "extra-start-span-signatures": {
+ "description": "A list of regexes for additional function signatures that create spans.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "staticcheck": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "checks": {
+ "type": "array",
+ "items": {
+ "anyOf": [
+ {
+ "enum": ["all"]
+ },
+ {
+ "type": "string"
+ }
+ ]
+ }
+ }
+ }
+ },
+ "stylecheck": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "checks": {
+ "type": "array",
+ "items": {
+ "anyOf": [
+ {
+ "enum": ["all"]
+ },
+ {
+ "type": "string"
+ }
+ ]
+ },
+ "default": [
+ "all",
+ "-ST1000",
+ "-ST1003",
+ "-ST1016",
+ "-ST1020",
+ "-ST1021",
+ "-ST1022"
+ ]
+ },
+ "dot-import-whitelist": {
+ "description": "By default, ST1001 forbids all uses of dot imports in non-test packages. This setting allows setting a whitelist of import paths that can be dot-imported anywhere.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "http-status-code-whitelist": {
+ "description": "ST1013 recommends using constants from the net/http package instead of hard-coding numeric HTTP status codes. This setting specifies a list of numeric status codes that this check does not complain about.",
+ "default": ["200", "400", "404", "500"],
+ "type": "array",
+ "items": {
+ "enum": [
+ "100",
+ "101",
+ "102",
+ "103",
+ "200",
+ "201",
+ "202",
+ "203",
+ "204",
+ "205",
+ "206",
+ "207",
+ "208",
+ "226",
+ "300",
+ "301",
+ "302",
+ "303",
+ "304",
+ "305",
+ "306",
+ "307",
+ "308",
+ "400",
+ "401",
+ "402",
+ "403",
+ "404",
+ "405",
+ "406",
+ "407",
+ "408",
+ "409",
+ "410",
+ "411",
+ "412",
+ "413",
+ "414",
+ "415",
+ "416",
+ "417",
+ "418",
+ "421",
+ "422",
+ "423",
+ "424",
+ "425",
+ "426",
+ "428",
+ "429",
+ "431",
+ "451",
+ "500",
+ "501",
+ "502",
+ "503",
+ "504",
+ "505",
+ "506",
+ "507",
+ "508",
+ "510",
+ "511"
+ ]
+ }
+ },
+ "initialisms": {
+ "description": "ST1003 check, among other things, for the correct capitalization of initialisms. The set of known initialisms can be configured with this option.",
+ "type": "array",
+ "items": {
+ "type": "string",
+ "default": [
+ "ACL",
+ "API",
+ "ASCII",
+ "CPU",
+ "CSS",
+ "DNS",
+ "EOF",
+ "GUID",
+ "HTML",
+ "HTTP",
+ "HTTPS",
+ "ID",
+ "IP",
+ "JSON",
+ "QPS",
+ "RAM",
+ "RPC",
+ "SLA",
+ "SMTP",
+ "SQL",
+ "SSH",
+ "TCP",
+ "TLS",
+ "TTL",
+ "UDP",
+ "UI",
+ "GID",
+ "UID",
+ "UUID",
+ "URI",
+ "URL",
+ "UTF8",
+ "VM",
+ "XML",
+ "XMPP",
+ "XSRF",
+ "XSS",
+ "SIP",
+ "RTP",
+ "AMQP",
+ "DB",
+ "TS"
+ ]
+ }
+ }
+ }
+ },
+ "tagalign": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "align": {
+ "description": "Align and sort can be used together or separately.",
+ "type": "boolean",
+ "default": true
+ },
+ "sort": {
+ "description": "Whether enable tags sort.",
+ "type": "boolean",
+ "default": true
+ },
+ "order": {
+ "description": "Specify the order of tags, the other tags will be sorted by name.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "default": [],
+ "examples": [
+ [
+ "json",
+ "yaml",
+ "yml",
+ "toml",
+ "mapstructure",
+ "binding",
+ "validate"
+ ]
+ ]
+ },
+ "strict": {
+ "description": "Whether enable strict style.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "tagliatelle": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "case": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "use-field-name": {
+ "description": "Use the struct field name to check the name of the struct tag.",
+ "type": "boolean",
+ "default": false
+ },
+ "rules": {
+ "type": "object",
+ "patternProperties": {
+ "^.+$": {
+ "enum": [
+ "camel",
+ "pascal",
+ "kebab",
+ "snake",
+ "goCamel",
+ "goPascal",
+ "goKebab",
+ "goSnake",
+ "upper",
+ "upperSnake",
+ "lower",
+ "header"
+ ]
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "tenv": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "all": {
+ "description": "The option `all` will run against whole test files (`_test.go`) regardless of method/function signatures.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "testifylint": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "enable-all": {
+ "description": "Enable all checkers.",
+ "type": "boolean",
+ "default": false
+ },
+ "disable-all": {
+ "description": "Disable all checkers.",
+ "type": "boolean",
+ "default": false
+ },
+ "enable": {
+ "description": "Enable specific checkers.",
+ "type": "array",
+ "items": {
+ "enum": [
+ "blank-import",
+ "bool-compare",
+ "compares",
+ "empty",
+ "error-is-as",
+ "error-nil",
+ "expected-actual",
+ "float-compare",
+ "go-require",
+ "len",
+ "negative-positive",
+ "nil-compare",
+ "require-error",
+ "suite-dont-use-pkg",
+ "suite-extra-assert-call",
+ "suite-thelper",
+ "useless-assert"
+ ]
+ },
+ "default": [
+ "blank-import",
+ "bool-compare",
+ "compares",
+ "empty",
+ "error-is-as",
+ "error-nil",
+ "expected-actual",
+ "float-compare",
+ "go-require",
+ "len",
+ "negative-positive",
+ "nil-compare",
+ "require-error",
+ "suite-dont-use-pkg",
+ "suite-extra-assert-call",
+ "useless-assert"
+ ]
+ },
+ "disable": {
+ "description": "Disable specific checkers.",
+ "type": "array",
+ "items": {
+ "enum": [
+ "blank-import",
+ "bool-compare",
+ "compares",
+ "empty",
+ "error-is-as",
+ "error-nil",
+ "expected-actual",
+ "float-compare",
+ "go-require",
+ "len",
+ "negative-positive",
+ "nil-compare",
+ "require-error",
+ "suite-dont-use-pkg",
+ "suite-extra-assert-call",
+ "suite-thelper",
+ "useless-assert"
+ ],
+ "default": [
+ "suite-thelper"
+ ]
+ }
+ },
+ "bool-compare": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "ignore-custom-types": {
+ "description": "To ignore user defined types (over builtin bool).",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "expected-actual": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "pattern": {
+ "description": "Regexp for expected variable name.",
+ "type": "string",
+ "default": "(^(exp(ected)?|want(ed)?)([A-Z]\\w*)?$)|(^(\\w*[a-z])?(Exp(ected)?|Want(ed)?)$)"
+ }
+ }
+ },
+ "go-require": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "ignore-http-handlers": {
+ "description": "To ignore HTTP handlers (like http.HandlerFunc).",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "require-error": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "fn-pattern": {
+ "description": "Regexp for assertions to analyze. If defined, then only matched error assertions will be reported.",
+ "type": "string",
+ "default": ""
+ }
+ }
+ },
+ "suite-extra-assert-call": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "mode": {
+ "description": "To require or remove extra Assert() call?",
+ "type": "string",
+ "enum": ["remove", "require"],
+ "default": "remove"
+ }
+ }
+ }
+ }
+ },
+ "testpackage": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "skip-regexp": {
+ "description": "Files with names matching this regular expression are skipped.",
+ "type": "string",
+ "examples": ["(export|internal)_test\\.go"]
+ },
+ "allow-packages": {
+ "description": "List of packages that don't end with _test that tests are allowed to be in.",
+ "type": "array",
+ "uniqueItems": true,
+ "items": {
+ "type": "string",
+ "examples": ["example"]
+ }
+ }
+ }
+ },
+ "thelper": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "test": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "begin": {
+ "description": "Check if `t.Helper()` begins helper function.",
+ "default": true,
+ "type": "boolean"
+ },
+ "first": {
+ "description": "Check if *testing.T is first param of helper function.",
+ "default": true,
+ "type": "boolean"
+ },
+ "name": {
+ "description": "Check if *testing.T param has t name.",
+ "default": true,
+ "type": "boolean"
+ }
+ }
+ },
+ "benchmark": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "begin": {
+ "description": "Check if `b.Helper()` begins helper function.",
+ "default": true,
+ "type": "boolean"
+ },
+ "first": {
+ "description": "Check if *testing.B is first param of helper function.",
+ "default": true,
+ "type": "boolean"
+ },
+ "name": {
+ "description": "Check if *testing.B param has b name.",
+ "default": true,
+ "type": "boolean"
+ }
+ }
+ },
+ "tb": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "begin": {
+ "description": "Check if `tb.Helper()` begins helper function.",
+ "default": true,
+ "type": "boolean"
+ },
+ "first": {
+ "description": "Check if *testing.TB is first param of helper function.",
+ "default": true,
+ "type": "boolean"
+ },
+ "name": {
+ "description": "Check if *testing.TB param has tb name.",
+ "default": true,
+ "type": "boolean"
+ }
+ }
+ },
+ "fuzz": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "begin": {
+ "description": "Check if `f.Helper()` begins helper function.",
+ "default": true,
+ "type": "boolean"
+ },
+ "first": {
+ "description": "Check if *testing.F is first param of helper function.",
+ "default": true,
+ "type": "boolean"
+ },
+ "name": {
+ "description": "Check if *testing.F param has f name.",
+ "default": true,
+ "type": "boolean"
+ }
+ }
+ }
+ }
+ },
+ "usestdlibvars": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "http-method": {
+ "description": "Suggest the use of http.MethodXX.",
+ "type": "boolean",
+ "default": true
+ },
+ "http-status-code": {
+ "description": "Suggest the use of http.StatusXX.",
+ "type": "boolean",
+ "default": true
+ },
+ "time-weekday": {
+ "description": "Suggest the use of time.Weekday.String().",
+ "type": "boolean",
+ "default": false
+ },
+ "time-month": {
+ "description": "Suggest the use of time.Month.String().",
+ "type": "boolean",
+ "default": false
+ },
+ "time-layout": {
+ "description": "Suggest the use of time.Layout.",
+ "type": "boolean",
+ "default": false
+ },
+ "crypto-hash": {
+ "description": "Suggest the use of crypto.Hash.String().",
+ "type": "boolean",
+ "default": false
+ },
+ "default-rpc-path": {
+ "description": "Suggest the use of rpc.DefaultXXPath.",
+ "type": "boolean",
+ "default": false
+ },
+ "sql-isolation-level": {
+ "description": "Suggest the use of sql.LevelXX.String().",
+ "type": "boolean",
+ "default": false
+ },
+ "tls-signature-scheme": {
+ "description": "Suggest the use of tls.SignatureScheme.String().",
+ "type": "boolean",
+ "default": false
+ },
+ "constant-kind": {
+ "description": "Suggest the use of constant.Kind.String().",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "unconvert": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "fast-math": {
+ "type": "boolean",
+ "default": false
+ },
+ "safe": {
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "unparam": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "check-exported": {
+ "description": "Inspect exported functions. Set to true if no external program/library imports your code.\n\nWARNING: if you enable this setting, unparam will report a lot of false-positives in text editors:\nif it's called for subdir of a project it can't find external interfaces. All text editor integrations\nwith golangci-lint call it on a directory with the changed file.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "unused": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "field-writes-are-uses": {
+ "description": "",
+ "type": "boolean",
+ "default": true
+ },
+ "post-statements-are-reads": {
+ "description": "",
+ "type": "boolean",
+ "default": false
+ },
+ "exported-is-used": {
+ "description": "",
+ "type": "boolean",
+ "default": true
+ },
+ "exported-fields-are-used": {
+ "description": "",
+ "type": "boolean",
+ "default": true
+ },
+ "parameters-are-used": {
+ "description": "",
+ "type": "boolean",
+ "default": true
+ },
+ "local-variables-are-used": {
+ "description": "",
+ "type": "boolean",
+ "default": true
+ },
+ "generated-is-used": {
+ "description": "",
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "varnamelen": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "max-distance": {
+ "description": "Variables used in at most this N-many lines will be ignored.",
+ "type": "integer",
+ "default": 5
+ },
+ "min-name-length": {
+ "description": "The minimum length of a variable's name that is considered `long`.",
+ "type": "integer",
+ "default": 3
+ },
+ "check-receiver": {
+ "description": "Check method receiver names.",
+ "default": false,
+ "type": "boolean"
+ },
+ "check-return": {
+ "description": "Check named return values.",
+ "default": false,
+ "type": "boolean"
+ },
+ "check-type-param": {
+ "description": "Check type parameters.",
+ "default": false,
+ "type": "boolean"
+ },
+ "ignore-type-assert-ok": {
+ "description": "Ignore `ok` variables that hold the bool return value of a type assertion",
+ "default": false,
+ "type": "boolean"
+ },
+ "ignore-map-index-ok": {
+ "description": "Ignore `ok` variables that hold the bool return value of a map index.",
+ "default": false,
+ "type": "boolean"
+ },
+ "ignore-chan-recv-ok": {
+ "description": "Ignore `ok` variables that hold the bool return value of a channel receive.",
+ "default": false,
+ "type": "boolean"
+ },
+ "ignore-names": {
+ "description": "Optional list of variable names that should be ignored completely.",
+ "default": [[]],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ignore-decls": {
+ "description": "Optional list of variable declarations that should be ignored completely.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "examples": [
+ ["c echo.Context", "t testing.T", "f *foo.Bar", "const C"]
+ ]
+ }
+ }
+ },
+ "whitespace": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "multi-if": {
+ "description": "Enforces newlines (or comments) after every multi-line if statement",
+ "type": "boolean",
+ "default": false
+ },
+ "multi-func": {
+ "description": "Enforces newlines (or comments) after every multi-line function signature",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "wrapcheck": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "ignoreSigs": {
+ "description": "An array of strings which specify substrings of signatures to ignore.",
+ "default": [
+ ".Errorf(",
+ "errors.New(",
+ "errors.Unwrap(",
+ ".Wrap(",
+ ".Wrapf(",
+ ".WithMessage(",
+ ".WithMessagef(",
+ ".WithStack("
+ ],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ignoreSigRegexps": {
+ "description": "An array of strings which specify regular expressions of signatures to ignore.",
+ "default": [""],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ignorePackageGlobs": {
+ "description": "An array of glob patterns which, if any match the package of the function returning the error, will skip wrapcheck analysis for this error.",
+ "default": [""],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ignoreInterfaceRegexps": {
+ "description": "An array of glob patterns which, if matched to an underlying interface name, will ignore unwrapped errors returned from a function whose call is defined on the given interface.",
+ "default": [""],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "wsl": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "allow-assign-and-anything": {
+ "description": "Controls if you may cuddle assignments and anything without needing an empty line between them.",
+ "type": "boolean",
+ "default": false
+ },
+ "allow-assign-and-call": {
+ "description": "Allow calls and assignments to be cuddled as long as the lines have any matching variables, fields or types.",
+ "type": "boolean",
+ "default": true
+ },
+ "allow-cuddle-declarations": {
+ "description": "Allow declarations (var) to be cuddled.",
+ "type": "boolean",
+ "default": false
+ },
+ "allow-cuddle-with-calls": {
+ "description": "A list of call idents that everything can be cuddled with.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "allow-cuddle-with-rhs": {
+ "description": "AllowCuddleWithRHS is a list of right hand side variables that is allowed to be cuddled with anything.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "allow-multiline-assign": {
+ "description": "Allow multiline assignments to be cuddled.",
+ "type": "boolean",
+ "default": true
+ },
+ "allow-separated-leading-comment": {
+ "description": "Allow leading comments to be separated with empty lines.",
+ "type": "boolean",
+ "default": false
+ },
+ "allow-trailing-comment": {
+ "description": "Allow trailing comments in ending of blocks.",
+ "type": "boolean",
+ "default": false
+ },
+ "error-variable-names": {
+ "description": "When force-err-cuddling is enabled this is a list of names used for error variables to check for in the conditional.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "force-case-trailing-whitespace": {
+ "description": "Force newlines in end of case at this limit (0 = never).",
+ "type": "integer",
+ "minimum": 0,
+ "default": 0
+ },
+ "force-err-cuddling": {
+ "description": "Causes an error when an If statement that checks an error variable doesn't cuddle with the assignment of that variable.",
+ "type": "boolean",
+ "default": false
+ },
+ "force-short-decl-cuddling": {
+ "description": "Causes an error if a short declaration (:=) cuddles with anything other than another short declaration.",
+ "type": "boolean",
+ "default": false
+ },
+ "strict-append": {
+ "description": "If true, append is only allowed to be cuddled if appending value is matching variables, fields or types on line above.",
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "copyloopvar": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "check-alias": {
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "custom": {
+ "description": "The custom section can be used to define linter plugins to be loaded at runtime. See README of golangci-lint for more information.\nEach custom linter should have a unique name.",
+ "type": "object",
+ "patternProperties": {
+ "^.*$": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "type": {
+ "description": "The plugin type.",
+ "enum": ["module", "goplugin"],
+ "default": "goplugin"
+ },
+ "path": {
+ "description": "The path to the plugin *.so. Can be absolute or local.",
+ "type": "string",
+ "examples": ["/path/to/example.so"]
+ },
+ "description": {
+ "description": "The description of the linter, for documentation purposes only.",
+ "type": "string"
+ },
+ "original-url": {
+ "description": "Intended to point to the repo location of the linter, for documentation purposes only.",
+ "type": "string"
+ },
+ "settings": {
+ "description": "Plugins settings/configuration. Only work with plugin based on `linterdb.PluginConstructor`.",
+ "type": "object"
+ }
+ },
+ "oneOf": [
+ {
+ "properties": {
+ "type": {"enum": ["module"] }
+ },
+ "required": ["type"]
+ },
+ {
+ "required": ["path"]
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
+ "linters": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "enable": {
+ "description": "List of enabled linters.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/linters"
+ }
+ },
+ "disable": {
+ "description": "List of disabled linters.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/linters"
+ }
+ },
+ "enable-all": {
+ "description": "Whether to enable all linters. You can re-disable them with `disable` explicitly.",
+ "type": "boolean",
+ "default": false
+ },
+ "disable-all": {
+ "description": "Whether to disable all linters. You can re-enable them with `enable` explicitly.",
+ "type": "boolean",
+ "default": false
+ },
+ "presets": {
+ "description": "Allow to use different presets of linters",
+ "type": "array",
+ "items": {
+ "enum": [
+ "bugs",
+ "comment",
+ "complexity",
+ "error",
+ "format",
+ "import",
+ "metalinter",
+ "module",
+ "performance",
+ "sql",
+ "style",
+ "test",
+ "unused"
+ ]
+ }
+ },
+ "fast": {
+ "description": "Enable run of fast linters.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "issues": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "exclude": {
+ "description": "List of regular expressions of issue texts to exclude.\nBut independently from this option we use default exclude patterns. Their usage can be controlled through `exclude-use-default`.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "exclude-rules": {
+ "description": "Exclude configuration per-path, per-linter, per-text and per-source",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "path": {
+ "type": "string"
+ },
+ "path-except": {
+ "type": "string"
+ },
+ "linters": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/linters"
+ }
+ },
+ "text": {
+ "type": "string"
+ },
+ "source": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "exclude-use-default": {
+ "description": "Independently from option `exclude` we use default exclude patterns. This behavior can be disabled by this option.",
+ "type": "boolean",
+ "default": true
+ },
+ "exclude-case-sensitive": {
+ "description": "If set to true, exclude and exclude-rules regular expressions become case sensitive.",
+ "type": "boolean",
+ "default": false
+ },
+ "exclude-generated": {
+ "description": "Mode of the generated files analysis.",
+ "enum": ["lax", "strict", "disable"],
+ "default": "lax"
+ },
+ "exclude-dirs": {
+ "description": "Which directories to exclude: issues from them won't be reported.",
+ "type": "array",
+ "items": {
+ "description": "You can use regexp here. The regexp is applied on the full path.\n\"/\" will be replaced by current OS file path separator to properly work on Windows.",
+ "type": "string",
+ "examples": ["generated.*"]
+ },
+ "default": [],
+ "examples": [["src/external_libs", "autogenerated_by_my_lib"]]
+ },
+ "exclude-dirs-use-default": {
+ "description": "Enable exclusion of directories \"vendor\", \"third_party\", \"testdata\", \"examples\", \"Godeps\", and \"builtin\".",
+ "type": "boolean",
+ "default": true
+ },
+ "exclude-files": {
+ "description": "Which files to exclude: they will be analyzed, but issues from them will not be reported.",
+ "type": "array",
+ "items": {
+ "description": "You can use regexp here. There is no need to include all autogenerated files, we confidently recognize them. If that is not the case, please let us know.\n\"/\" will be replaced by current OS file path separator to properly work on Windows.",
+ "type": "string",
+ "examples": [".*\\.my\\.go$"]
+ },
+ "default": [],
+ "examples": [[".*\\.my\\.go$", "lib/bad.go"]]
+ },
+ "include": {
+ "description": "The list of ids of default excludes to include or disable.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "default": []
+ },
+ "max-issues-per-linter": {
+ "description": "Maximum issues count per one linter. Set to 0 to disable.",
+ "type": "integer",
+ "default": 50,
+ "minimum": 0
+ },
+ "max-same-issues": {
+ "description": "Maximum count of issues with the same text. Set to 0 to disable.",
+ "type": "integer",
+ "default": 3,
+ "minimum": 0
+ },
+ "new": {
+ "description": "Show only new issues: if there are unstaged changes or untracked files, only those changes are analyzed, else only changes in HEAD~ are analyzed.",
+ "type": "boolean",
+ "default": false
+ },
+ "new-from-rev": {
+ "description": "Show only new issues created after this git revision.",
+ "type": "string"
+ },
+ "new-from-patch": {
+ "description": "Show only new issues created in git patch with this file path.",
+ "type": "string",
+ "examples": ["path/to/patch/file"]
+ },
+ "fix": {
+ "description": "Fix found issues (if it's supported by the linter).",
+ "type": "boolean",
+ "default": false
+ },
+ "whole-files": {
+ "description": "Show issues in any part of update files (requires new-from-rev or new-from-patch).",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "severity": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "default-severity": {
+ "description": "Set the default severity for issues. If severity rules are defined and the issues do not match or no severity is provided to the rule this will be the default severity applied. Severities should match the supported severity names of the selected out format.",
+ "type": "string",
+ "default": ""
+ },
+ "case-sensitive": {
+ "description": "If set to true, severity-rules regular expressions become case sensitive.",
+ "type": "boolean",
+ "default": false
+ },
+ "rules": {
+ "description": "When a list of severity rules are provided, severity information will be added to lint issues. Severity rules have the same filtering capability as exclude rules except you are allowed to specify one matcher per severity rule.\nOnly affects out formats that support setting severity information.",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "severity": {
+ "type": "string"
+ },
+ "path": {
+ "type": "string"
+ },
+ "path-except": {
+ "type": "string"
+ },
+ "linters": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/linters"
+ }
+ },
+ "text": {
+ "type": "string"
+ },
+ "source": {
+ "type": "string"
+ }
+ },
+ "required": ["severity"],
+ "anyOf": [
+ { "required": ["path"] },
+ { "required": ["path-except"] },
+ { "required": ["linters"] },
+ { "required": ["text"] },
+ { "required": ["source"] }
+ ]
+ },
+ "default": []
+ }
+ },
+ "required": ["default-severity"]
+ }
+ }
+}
diff --git a/vendor/github.com/golangci/golangci-lint/v2/jsonschema/golangci.v1.60.jsonschema.json b/vendor/github.com/golangci/golangci-lint/v2/jsonschema/golangci.v1.60.jsonschema.json
new file mode 100644
index 0000000000..b8920ae06f
--- /dev/null
+++ b/vendor/github.com/golangci/golangci-lint/v2/jsonschema/golangci.v1.60.jsonschema.json
@@ -0,0 +1,3792 @@
+{
+ "$schema": "http://json-schema.org/draft-07/schema#",
+ "$id": "https://json.schemastore.org/golangci-lint.json",
+ "definitions": {
+ "gocritic-checks": {
+ "enum": [
+ "appendAssign",
+ "appendCombine",
+ "argOrder",
+ "assignOp",
+ "badCall",
+ "badCond",
+ "badLock",
+ "badRegexp",
+ "badSorting",
+ "boolExprSimplify",
+ "builtinShadow",
+ "builtinShadowDecl",
+ "captLocal",
+ "caseOrder",
+ "codegenComment",
+ "commentedOutCode",
+ "commentedOutImport",
+ "commentFormatting",
+ "defaultCaseOrder",
+ "deferUnlambda",
+ "deferInLoop",
+ "deprecatedComment",
+ "docStub",
+ "dupArg",
+ "dupBranchBody",
+ "dupCase",
+ "dupImport",
+ "dupSubExpr",
+ "dynamicFmtString",
+ "elseif",
+ "emptyDecl",
+ "emptyFallthrough",
+ "emptyStringTest",
+ "equalFold",
+ "evalOrder",
+ "exitAfterDefer",
+ "exposedSyncMutex",
+ "externalErrorReassign",
+ "filepathJoin",
+ "flagDeref",
+ "flagName",
+ "hexLiteral",
+ "httpNoBody",
+ "hugeParam",
+ "ifElseChain",
+ "importShadow",
+ "indexAlloc",
+ "initClause",
+ "ioutilDeprecated",
+ "mapKey",
+ "methodExprCall",
+ "nestingReduce",
+ "newDeref",
+ "nilValReturn",
+ "octalLiteral",
+ "offBy1",
+ "paramTypeCombine",
+ "preferDecodeRune",
+ "preferFilepathJoin",
+ "preferFprint",
+ "preferStringWriter",
+ "preferWriteByte",
+ "ptrToRefParam",
+ "rangeExprCopy",
+ "rangeValCopy",
+ "redundantSprint",
+ "regexpMust",
+ "regexpPattern",
+ "regexpSimplify",
+ "returnAfterHttpError",
+ "ruleguard",
+ "singleCaseSwitch",
+ "sliceClear",
+ "sloppyLen",
+ "sloppyReassign",
+ "sloppyTypeAssert",
+ "sortSlice",
+ "sprintfQuotedString",
+ "sqlQuery",
+ "stringConcatSimplify",
+ "stringsCompare",
+ "stringXbytes",
+ "suspiciousSorting",
+ "switchTrue",
+ "syncMapLoadAndDelete",
+ "timeCmpSimplify",
+ "timeExprSimplify",
+ "tooManyResultsChecker",
+ "truncateCmp",
+ "typeAssertChain",
+ "typeDefFirst",
+ "typeSwitchVar",
+ "typeUnparen",
+ "uncheckedInlineErr",
+ "underef",
+ "unlabelStmt",
+ "unlambda",
+ "unnamedResult",
+ "unnecessaryBlock",
+ "unnecessaryDefer",
+ "unslice",
+ "valSwap",
+ "weakCond",
+ "whyNoLint",
+ "wrapperFunc",
+ "yodaStyleExpr"
+ ]
+ },
+ "gocritic-tags": {
+ "enum": [
+ "diagnostic",
+ "style",
+ "performance",
+ "experimental",
+ "opinionated",
+ "security"
+ ]
+ },
+ "gosec-rules": {
+ "enum": [
+ "G101",
+ "G102",
+ "G103",
+ "G104",
+ "G106",
+ "G107",
+ "G108",
+ "G109",
+ "G110",
+ "G111",
+ "G112",
+ "G113",
+ "G114",
+ "G115",
+ "G201",
+ "G202",
+ "G203",
+ "G204",
+ "G301",
+ "G302",
+ "G303",
+ "G304",
+ "G305",
+ "G306",
+ "G307",
+ "G401",
+ "G402",
+ "G403",
+ "G404",
+ "G405",
+ "G406",
+ "G501",
+ "G502",
+ "G503",
+ "G504",
+ "G505",
+ "G506",
+ "G507",
+ "G601",
+ "G602"
+ ]
+ },
+ "govet-analyzers": {
+ "enum": [
+ "appends",
+ "asmdecl",
+ "assign",
+ "atomic",
+ "atomicalign",
+ "bools",
+ "buildtag",
+ "cgocall",
+ "composites",
+ "copylocks",
+ "deepequalerrors",
+ "defers",
+ "directive",
+ "errorsas",
+ "fieldalignment",
+ "findcall",
+ "framepointer",
+ "httpresponse",
+ "ifaceassert",
+ "loopclosure",
+ "lostcancel",
+ "nilfunc",
+ "nilness",
+ "printf",
+ "reflectvaluecompare",
+ "shadow",
+ "shift",
+ "sigchanyzer",
+ "slog",
+ "sortslice",
+ "stdmethods",
+ "stringintconv",
+ "structtag",
+ "testinggoroutine",
+ "tests",
+ "unmarshal",
+ "unreachable",
+ "unsafeptr",
+ "unusedresult",
+ "unusedwrite"
+ ]
+ },
+ "revive-rules": {
+ "enum": [
+ "add-constant",
+ "argument-limit",
+ "atomic",
+ "banned-characters",
+ "bare-return",
+ "blank-imports",
+ "bool-literal-in-expr",
+ "call-to-gc",
+ "cognitive-complexity",
+ "comment-spacings",
+ "comments-density",
+ "confusing-naming",
+ "confusing-results",
+ "constant-logical-expr",
+ "context-as-argument",
+ "context-keys-type",
+ "cyclomatic",
+ "datarace",
+ "deep-exit",
+ "defer",
+ "dot-imports",
+ "duplicated-imports",
+ "early-return",
+ "empty-block",
+ "empty-lines",
+ "enforce-map-style",
+ "enforce-repeated-arg-type-style",
+ "enforce-slice-style",
+ "error-naming",
+ "error-return",
+ "error-strings",
+ "errorf",
+ "exported",
+ "file-header",
+ "flag-parameter",
+ "function-length",
+ "function-result-limit",
+ "get-return",
+ "identical-branches",
+ "if-return",
+ "import-alias-naming",
+ "import-shadowing",
+ "imports-blocklist",
+ "increment-decrement",
+ "indent-error-flow",
+ "line-length-limit",
+ "max-control-nesting",
+ "max-public-structs",
+ "modifies-parameter",
+ "modifies-value-receiver",
+ "nested-structs",
+ "optimize-operands-order",
+ "package-comments",
+ "range",
+ "range-val-address",
+ "range-val-in-closure",
+ "receiver-naming",
+ "redefines-builtin-id",
+ "redundant-import-alias",
+ "string-format",
+ "string-of-int",
+ "struct-tag",
+ "superfluous-else",
+ "time-equal",
+ "time-naming",
+ "unchecked-type-assertion",
+ "unconditional-recursion",
+ "unexported-naming",
+ "unexported-return",
+ "unhandled-error",
+ "unnecessary-stmt",
+ "unreachable-code",
+ "unused-parameter",
+ "unused-receiver",
+ "use-any",
+ "useless-break",
+ "var-declaration",
+ "var-naming",
+ "waitgroup-by-value"
+ ]
+ },
+ "linters": {
+ "$comment": "anyOf with enum is used to allow auto completion of non-custom linters",
+ "description": "Linters usable.",
+ "anyOf": [
+ {
+ "enum": [
+ "asasalint",
+ "asciicheck",
+ "bidichk",
+ "bodyclose",
+ "canonicalheader",
+ "containedctx",
+ "contextcheck",
+ "copyloopvar",
+ "cyclop",
+ "deadcode",
+ "decorder",
+ "depguard",
+ "dogsled",
+ "dupl",
+ "dupword",
+ "durationcheck",
+ "errcheck",
+ "errchkjson",
+ "errname",
+ "errorlint",
+ "execinquery",
+ "exhaustive",
+ "exhaustivestruct",
+ "exhaustruct",
+ "exportloopref",
+ "fatcontext",
+ "forbidigo",
+ "forcetypeassert",
+ "funlen",
+ "gci",
+ "ginkgolinter",
+ "gocheckcompilerdirectives",
+ "gochecknoglobals",
+ "gochecknoinits",
+ "gochecksumtype",
+ "gocognit",
+ "goconst",
+ "gocritic",
+ "gocyclo",
+ "godot",
+ "godox",
+ "err113",
+ "gofmt",
+ "gofumpt",
+ "goheader",
+ "goimports",
+ "golint",
+ "gomoddirectives",
+ "gomodguard",
+ "goprintffuncname",
+ "gosec",
+ "gosimple",
+ "gosmopolitan",
+ "govet",
+ "grouper",
+ "ifshort",
+ "importas",
+ "inamedparam",
+ "ineffassign",
+ "interfacebloat",
+ "interfacer",
+ "intrange",
+ "ireturn",
+ "lll",
+ "loggercheck",
+ "maintidx",
+ "makezero",
+ "maligned",
+ "mirror",
+ "misspell",
+ "mnd",
+ "musttag",
+ "nakedret",
+ "nestif",
+ "nilerr",
+ "nilnil",
+ "nlreturn",
+ "noctx",
+ "nolintlint",
+ "nonamedreturns",
+ "nosnakecase",
+ "nosprintfhostport",
+ "paralleltest",
+ "perfsprint",
+ "prealloc",
+ "predeclared",
+ "promlinter",
+ "protogetter",
+ "reassign",
+ "revive",
+ "rowserrcheck",
+ "scopelint",
+ "sloglint",
+ "sqlclosecheck",
+ "staticcheck",
+ "structcheck",
+ "stylecheck",
+ "tagalign",
+ "tagliatelle",
+ "tenv",
+ "testableexamples",
+ "testifylint",
+ "testpackage",
+ "thelper",
+ "tparallel",
+ "typecheck",
+ "unconvert",
+ "unparam",
+ "unused",
+ "usestdlibvars",
+ "varcheck",
+ "varnamelen",
+ "wastedassign",
+ "whitespace",
+ "wrapcheck",
+ "wsl",
+ "zerologlint"
+ ]
+ },
+ {
+ "type": "string"
+ }
+ ]
+ }
+ },
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "run": {
+ "description": "Options for analysis running,",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "concurrency": {
+ "description": "Number of concurrent runners. Defaults to the number of available CPU cores.",
+ "type": "integer",
+ "minimum": 0,
+ "examples": [4]
+ },
+ "timeout": {
+ "description": "Timeout for the analysis.",
+ "type": "string",
+ "pattern": "^((\\d+h)?(\\d+m)?(\\d+(?:\\.\\d)?s)?|0)$",
+ "default": "1m",
+ "examples": ["30s", "5m", "5m30s"]
+ },
+ "issues-exit-code": {
+ "description": "Exit code when at least one issue was found.",
+ "type": "integer",
+ "default": 1
+ },
+ "tests": {
+ "description": "Enable inclusion of test files.",
+ "type": "boolean",
+ "default": true
+ },
+ "build-tags": {
+ "description": "List of build tags to pass to all linters.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "default": [],
+ "examples": [["mytag"]]
+ },
+ "modules-download-mode": {
+ "description": "Option to pass to \"go list -mod={option}\".\nSee \"go help modules\" for more information.",
+ "enum": ["mod", "readonly", "vendor"]
+ },
+ "allow-parallel-runners": {
+ "description": "Allow multiple parallel golangci-lint instances running. If disabled, golangci-lint acquires file lock on start.",
+ "type": "boolean",
+ "default": false
+ },
+ "allow-serial-runners": {
+ "description": "Allow multiple golangci-lint instances running, but serialize them around a lock.",
+ "type": "boolean",
+ "default": false
+ },
+ "go": {
+ "description": "Targeted Go version.",
+ "type": "string",
+ "default": "1.17"
+ }
+ }
+ },
+ "output": {
+ "description": "Output configuration options.",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "formats": {
+ "description": "Output formats to use.",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "path": {
+ "default": "stdout",
+ "anyOf": [
+ {
+ "enum": [ "stdout", "stderr" ]
+ },
+ {
+ "type": "string"
+ }
+ ]
+ },
+ "format": {
+ "default": "colored-line-number",
+ "enum": [
+ "colored-line-number",
+ "line-number",
+ "json",
+ "colored-tab",
+ "tab",
+ "html",
+ "checkstyle",
+ "code-climate",
+ "junit-xml",
+ "github-actions",
+ "teamcity",
+ "sarif"
+ ]
+ }
+ },
+ "required": ["format"]
+ }
+ },
+ "print-issued-lines": {
+ "description": "Print lines of code with issue.",
+ "type": "boolean",
+ "default": true
+ },
+ "print-linter-name": {
+ "description": "Print linter name in the end of issue text.",
+ "type": "boolean",
+ "default": true
+ },
+ "uniq-by-line": {
+ "description": "Make issues output unique by line.",
+ "type": "boolean",
+ "default": true
+ },
+ "path-prefix": {
+ "description": "Add a prefix to the output file references.",
+ "type": "string",
+ "default": ""
+ },
+ "show-stats": {
+ "description": "Show statistics per linter.",
+ "type": "boolean",
+ "default": false
+ },
+ "sort-order": {
+ "type": "array",
+ "items": {
+ "enum": ["linter", "severity", "file"]
+ }
+ },
+ "sort-results": {
+ "description": "Sort results by: filepath, line and column.",
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "linters-settings": {
+ "description": "All available settings of specific linters.",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "dupword": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "keywords": {
+ "description": "Keywords for detecting duplicate words. If this list is not empty, only the words defined in this list will be detected.",
+ "type": "array",
+ "uniqueItems": true,
+ "items": {
+ "type": "string",
+ "examples": ["the", "and", "a"]
+ }
+ },
+ "ignore": {
+ "description": "Keywords used to ignore detection.",
+ "type": "array",
+ "uniqueItems": true,
+ "items": {
+ "type": "string",
+ "examples": ["0C0C"]
+ }
+ }
+ }
+ },
+ "asasalint": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "exclude": {
+ "description": "To specify a set of function names to exclude.",
+ "type": "array",
+ "uniqueItems": true,
+ "items": {
+ "type": "string",
+ "examples": ["\\.Wrapf"]
+ }
+ },
+ "use-builtin-exclusions": {
+ "description": "To enable/disable the asasalint builtin exclusions of function names.",
+ "type": "boolean",
+ "default": true
+ },
+ "ignore-test": {
+ "description": "Ignore *_test.go files.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "bidichk": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "left-to-right-embedding": {
+ "description": "Disallow: LEFT-TO-RIGHT-EMBEDDING",
+ "type": "boolean",
+ "default": false
+ },
+ "right-to-left-embedding": {
+ "description": "Disallow: RIGHT-TO-LEFT-EMBEDDING",
+ "type": "boolean",
+ "default": false
+ },
+ "pop-directional-formatting": {
+ "description": "Disallow: POP-DIRECTIONAL-FORMATTING",
+ "type": "boolean",
+ "default": false
+ },
+ "left-to-right-override": {
+ "description": "Disallow: LEFT-TO-RIGHT-OVERRIDE",
+ "type": "boolean",
+ "default": false
+ },
+ "right-to-left-override": {
+ "description": "Disallow: RIGHT-TO-LEFT-OVERRIDE",
+ "type": "boolean",
+ "default": false
+ },
+ "left-to-right-isolate": {
+ "description": "Disallow: LEFT-TO-RIGHT-ISOLATE",
+ "type": "boolean",
+ "default": false
+ },
+ "right-to-left-isolate": {
+ "description": "Disallow: RIGHT-TO-LEFT-ISOLATE",
+ "type": "boolean",
+ "default": false
+ },
+ "first-strong-isolate": {
+ "description": "Disallow: FIRST-STRONG-ISOLATE",
+ "type": "boolean",
+ "default": false
+ },
+ "pop-directional-isolate": {
+ "description": "Disallow: POP-DIRECTIONAL-ISOLATE",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "cyclop": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "skip-tests": {
+ "description": "Should the linter execute on test files as well",
+ "type": "boolean",
+ "default": false
+ },
+ "max-complexity": {
+ "description": "Max complexity the function can have",
+ "type": "integer",
+ "default": 10,
+ "minimum": 0
+ },
+ "package-average": {
+ "description": "Max average complexity in package",
+ "type": "number",
+ "default": 0,
+ "minimum": 0
+ }
+ }
+ },
+ "decorder": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "dec-order": {
+ "type": "array",
+ "default": [["type", "const", "var", "func"]],
+ "items": {
+ "enum": ["type", "const", "var", "func"]
+ }
+ },
+ "ignore-underscore-vars": {
+ "description": "Underscore vars (vars with \"_\" as the name) will be ignored at all checks",
+ "default": true,
+ "type": "boolean"
+ },
+ "disable-dec-order-check": {
+ "description": "Order of declarations is not checked",
+ "default": true,
+ "type": "boolean"
+ },
+ "disable-init-func-first-check": {
+ "description": "Allow init func to be anywhere in file",
+ "default": true,
+ "type": "boolean"
+ },
+ "disable-dec-num-check": {
+ "description": "Multiple global type, const and var declarations are allowed",
+ "default": true,
+ "type": "boolean"
+ },
+ "disable-type-dec-num-check": {
+ "description": "Type declarations will be ignored for dec num check",
+ "default": true,
+ "type": "boolean"
+ },
+ "disable-const-dec-num-check": {
+ "description": "Const declarations will be ignored for dec num check",
+ "default": true,
+ "type": "boolean"
+ },
+ "disable-var-dec-num-check": {
+ "description": "Var declarations will be ignored for dec num check",
+ "default": true,
+ "type": "boolean"
+ }
+ }
+ },
+ "depguard": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "rules": {
+ "description": "Rules to apply.",
+ "type": "object",
+ "additionalProperties": false,
+ "patternProperties": {
+ "^[^.]+$": {
+ "description": "Name of a rule.",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "list-mode": {
+ "description": "Used to determine the package matching priority.",
+ "enum": ["original", "strict", "lax"],
+ "default": "original"
+ },
+ "files": {
+ "description": "List of file globs that will match this list of settings to compare against.",
+ "additionalProperties": false,
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "allow": {
+ "description": "List of allowed packages.",
+ "additionalProperties": false,
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "deny": {
+ "description": "Packages that are not allowed where the value is a suggestion.",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "desc": {
+ "description": "Description",
+ "type": "string"
+ },
+ "pkg": {
+ "description": "Package",
+ "type": "string"
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "dogsled": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "max-blank-identifiers": {
+ "description": "Check assignments with too many blank identifiers.",
+ "type": "integer",
+ "default": 2,
+ "minimum": 0
+ }
+ }
+ },
+ "dupl": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "threshold": {
+ "description": "Tokens count to trigger issue.",
+ "type": "integer",
+ "default": 150,
+ "minimum": 0
+ }
+ }
+ },
+ "errcheck": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "check-type-assertions": {
+ "description": "Report about not checking errors in type assertions, i.e.: `a := b.(MyStruct)`",
+ "type": "boolean",
+ "default": false
+ },
+ "check-blank": {
+ "description": "Report about assignment of errors to blank identifier",
+ "type": "boolean",
+ "default": false
+ },
+ "exclude-functions": {
+ "description": "List of functions to exclude from checking, where each entry is a single function to exclude",
+ "type": "array",
+ "examples": ["io/ioutil.ReadFile", "io.Copy(*bytes.Buffer)"],
+ "items": {
+ "type": "string"
+ }
+ },
+ "disable-default-exclusions": {
+ "description": "To disable the errcheck built-in exclude list",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "errchkjson": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "check-error-free-encoding": {
+ "type": "boolean",
+ "default": false
+ },
+ "report-no-exported": {
+ "description": "Issue on struct that doesn't have exported fields.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "errorlint": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "errorf": {
+ "description": "Check whether fmt.Errorf uses the %w verb for formatting errors",
+ "type": "boolean",
+ "default": true
+ },
+ "errorf-multi": {
+ "description": "Permit more than 1 %w verb, valid per Go 1.20",
+ "type": "boolean",
+ "default": true
+ },
+ "asserts": {
+ "description": "Check for plain type assertions and type switches.",
+ "type": "boolean",
+ "default": true
+ },
+ "comparison": {
+ "description": "Check for plain error comparisons",
+ "type": "boolean",
+ "default": true
+ },
+ "allowed-errors": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "err": {
+ "type": "string"
+ },
+ "fun": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "allowed-errors-wildcard": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "err": {
+ "type": "string"
+ },
+ "fun": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ }
+ },
+ "exhaustive": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "check": {
+ "description": "Program elements to check for exhaustiveness.",
+ "type": "array",
+ "uniqueItems": true,
+ "items": {
+ "type": "string",
+ "examples": ["switch", "map"]
+ }
+ },
+ "check-generated": {
+ "description": "Check switch statements in generated files",
+ "type": "boolean",
+ "default": false
+ },
+ "explicit-exhaustive-switch": {
+ "description": "Only run exhaustive check on switches with \"//exhaustive:enforce\" comment.",
+ "type": "boolean",
+ "default": false
+ },
+ "explicit-exhaustive-map": {
+ "description": "Only run exhaustive check on map literals with \"//exhaustive:enforce\" comment.",
+ "type": "boolean",
+ "default": false
+ },
+ "default-case-required": {
+ "description": "Switch statement requires default case even if exhaustive.",
+ "type": "boolean",
+ "default": false
+ },
+ "default-signifies-exhaustive": {
+ "description": "Presence of `default` case in switch statements satisfies exhaustiveness, even if all enum members are not listed.",
+ "type": "boolean",
+ "default": false
+ },
+ "ignore-enum-members": {
+ "description": "Enum members matching `regex` do not have to be listed in switch statements to satisfy exhaustiveness",
+ "type": "string"
+ },
+ "ignore-enum-types": {
+ "description": "Enum types matching the supplied regex do not have to be listed in switch statements to satisfy exhaustiveness.",
+ "type": "string"
+ },
+ "package-scope-only": {
+ "description": "Consider enums only in package scopes, not in inner scopes.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "exhaustruct": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "include": {
+ "description": "List of regular expressions to match struct packages and names.",
+ "type": "array",
+ "examples": [".*\\.Test"],
+ "items": {
+ "type": "string"
+ }
+ },
+ "exclude": {
+ "description": "List of regular expressions to exclude struct packages and names from check.",
+ "type": "array",
+ "examples": ["cobra\\.Command$"],
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "forbidigo": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "exclude-godoc-examples": {
+ "description": "Exclude code in godoc examples.",
+ "type": "boolean",
+ "default": true
+ },
+ "analyze-types": {
+ "description": "Instead of matching the literal source code, use type information to replace expressions with strings that contain the package name and (for methods and fields) the type name.",
+ "type": "boolean",
+ "default": true
+ },
+ "forbid": {
+ "description": "List of identifiers to forbid (written using `regexp`)",
+ "type": "array",
+ "examples": ["^print.*$"],
+ "items": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "p": {
+ "description": "Pattern",
+ "type": "string"
+ },
+ "pkg": {
+ "description": "Package",
+ "type": "string"
+ },
+ "msg": {
+ "description": "Message",
+ "type": "string"
+ }
+ }
+ }
+ ]
+ }
+ }
+ }
+ },
+ "funlen": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "lines": {
+ "description": "Limit lines number per function.",
+ "type": "integer",
+ "default": 60
+ },
+ "statements": {
+ "description": "Limit statements number per function.",
+ "type": "integer",
+ "default": 40
+ },
+ "ignore-comments": {
+ "description": "Ignore comments when counting lines.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "gci": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "sections": {
+ "description": "Section configuration to compare against.",
+ "type": "array",
+ "items": {
+ "anyOf": [
+ {
+ "enum": [
+ "standard",
+ "default",
+ "blank",
+ "dot",
+ "alias",
+ "localmodule"
+ ]
+ },
+ {
+ "type": "string"
+ }
+ ]
+ },
+ "default": ["standard", "default"]
+ },
+ "skip-generated": {
+ "description": "Skip generated files.",
+ "type": "boolean",
+ "default": true
+ },
+ "custom-order": {
+ "description": "Enable custom order of sections.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "ginkgolinter": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "suppress-len-assertion": {
+ "description": "Suppress the wrong length assertion warning.",
+ "type": "boolean",
+ "default": false
+ },
+ "suppress-nil-assertion": {
+ "description": "Suppress the wrong nil assertion warning.",
+ "type": "boolean",
+ "default": false
+ },
+ "suppress-err-assertion": {
+ "description": "Suppress the wrong error assertion warning.",
+ "type": "boolean",
+ "default": false
+ },
+ "suppress-compare-assertion": {
+ "description": "Suppress the wrong comparison assertion warning.",
+ "type": "boolean",
+ "default": false
+ },
+ "suppress-async-assertion": {
+ "description": "Suppress the function all in async assertion warning.",
+ "type": "boolean",
+ "default": false
+ },
+ "suppress-type-compare-assertion": {
+ "description": "Suppress warning for comparing values from different types, like int32 and uint32.",
+ "type": "boolean",
+ "default": false
+ },
+ "forbid-focus-container": {
+ "description": "Trigger warning for ginkgo focus containers like FDescribe, FContext, FWhen or FIt.",
+ "type": "boolean",
+ "default": false
+ },
+ "allow-havelen-zero": {
+ "description": "Don't trigger warnings for HaveLen(0).",
+ "type": "boolean",
+ "default": false
+ },
+ "force-expect-to": {
+ "description": "Force using `Expect` with `To`, `ToNot` or `NotTo`",
+ "type": "boolean",
+ "default": false
+ },
+ "validate-async-intervals": {
+ "description": "Best effort validation of async intervals (timeout and polling).",
+ "type": "boolean",
+ "default": false
+ },
+ "forbid-spec-pollution": {
+ "description": "Trigger a warning for variable assignments in ginkgo containers like `Describe`, `Context` and `When`, instead of in `BeforeEach()`.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "gocognit": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "min-complexity": {
+ "description": "Minimal code complexity to report (we recommend 10-20).",
+ "type": "integer",
+ "default": 30
+ }
+ }
+ },
+ "goconst": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "match-constant": {
+ "description": "Look for existing constants matching the values",
+ "type": "boolean",
+ "default": true
+ },
+ "min-len": {
+ "description": "Minimum length of string constant.",
+ "type": "integer",
+ "default": 3
+ },
+ "min-occurrences": {
+ "description": "Minimum occurrences count to trigger.",
+ "type": "integer",
+ "default": 3
+ },
+ "ignore-tests": {
+ "description": "Ignore test files.",
+ "type": "boolean",
+ "default": false
+ },
+ "ignore-calls": {
+ "description": "Ignore when constant is not used as function argument",
+ "type": "boolean",
+ "default": true
+ },
+ "ignore-strings": {
+ "description": "Exclude strings matching the given regular expression",
+ "type": "string"
+ },
+ "numbers": {
+ "description": "Search also for duplicated numbers.",
+ "type": "boolean",
+ "default": false
+ },
+ "min": {
+ "description": "Minimum value, only works with `numbers`",
+ "type": "integer",
+ "default": 3
+ },
+ "max": {
+ "description": "Maximum value, only works with `numbers`",
+ "type": "integer",
+ "default": 3
+ }
+ }
+ },
+ "gocritic": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "enabled-checks": {
+ "description": "Which checks should be enabled. By default, a list of stable checks is used. To see it, run `GL_DEBUG=gocritic golangci-lint run`.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/gocritic-checks"
+ }
+ },
+ "disabled-checks": {
+ "description": "Which checks should be disabled.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/gocritic-checks"
+ },
+ "default": []
+ },
+ "enabled-tags": {
+ "description": "Enable multiple checks by tags, run `GL_DEBUG=gocritic golangci-lint run` to see all tags and checks.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/gocritic-tags"
+ }
+ },
+ "disabled-tags": {
+ "description": "Disable multiple checks by tags, run `GL_DEBUG=gocritic golangci-lint run` to see all tags and checks.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/gocritic-tags"
+ }
+ },
+ "settings": {
+ "description": "Settings passed to gocritic. Properties must be valid and enabled check names.",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "captLocal": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "paramsOnly" : {
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "commentedOutCode": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "minLength" : {
+ "type": "number",
+ "default": 15
+ }
+ }
+ },
+ "elseif": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "skipBalanced" : {
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "hugeParam": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "sizeThreshold" : {
+ "type": "number",
+ "default": 80
+ }
+ }
+ },
+ "ifElseChain": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "minThreshold" : {
+ "type": "number",
+ "default": 2
+ }
+ }
+ },
+ "nestingReduce": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "bodyWidth" : {
+ "type": "number",
+ "default": 5
+ }
+ }
+ },
+ "rangeExprCopy": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "sizeThreshold" : {
+ "type": "number",
+ "default": 512
+ },
+ "skipTestFuncs" : {
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "rangeValCopy": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "sizeThreshold" : {
+ "type": "number",
+ "default": 128
+ },
+ "skipTestFuncs" : {
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "ruleguard": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "debug" : {
+ "type": "string"
+ },
+ "enable" : {
+ "type": "string"
+ },
+ "disable" : {
+ "type": "string"
+ },
+ "failOn" : {
+ "type": "string"
+ },
+ "rules" : {
+ "type": "string"
+ }
+ }
+ },
+ "tooManyResultsChecker": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "maxResults" : {
+ "type": "number",
+ "default": 5
+ }
+ }
+ },
+ "truncateCmp": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "skipArchDependent" : {
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "underef": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "skipRecvDeref" : {
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "unnamedResult": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "checkExported" : {
+ "type": "boolean",
+ "default": false
+ }
+ }
+ }
+ }
+ },
+ "disable-all": {
+ "type": "boolean",
+ "default": false
+ },
+ "enable-all": {
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "gocyclo": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "min-complexity": {
+ "description": "Minimum code complexity to report (we recommend 10-20).",
+ "type": "integer",
+ "default": 30
+ }
+ }
+ },
+ "godot": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "scope": {
+ "description": "Comments to be checked.",
+ "enum": ["declarations", "toplevel", "all"],
+ "default": "declarations"
+ },
+ "exclude": {
+ "description": "List of regexps for excluding particular comment lines from check.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "period": {
+ "description": "Check that each sentence ends with a period.",
+ "type": "boolean",
+ "default": true
+ },
+ "capital": {
+ "description": "Check that each sentence starts with a capital letter.",
+ "type": "boolean",
+ "default": false
+ },
+ "check-all": {
+ "description": "DEPRECATED: Check all top-level comments, not only declarations.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "godox": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "keywords": {
+ "description": "Report any comments starting with one of these keywords. This is useful for TODO or FIXME comments that might be left in the code accidentally and should be resolved before merging.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "default": ["TODO", "BUG", "FIXME"]
+ }
+ }
+ },
+ "gofmt": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "simplify": {
+ "description": "Simplify code.",
+ "type": "boolean",
+ "default": true
+ },
+ "rewrite-rules": {
+ "description": "Apply the rewrite rules to the source before reformatting.",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "pattern": {
+ "type": "string"
+ },
+ "replacement": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ }
+ },
+ "interfacebloat": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "max": {
+ "description": "The maximum number of methods allowed for an interface.",
+ "type": "integer"
+ }
+ }
+ },
+ "gofumpt": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "extra-rules": {
+ "description": "Choose whether or not to use the extra rules that are disabled by default.",
+ "type": "boolean",
+ "default": false
+ },
+ "module-path": {
+ "description": " Module path which contains the source code being formatted.",
+ "type": "string"
+ }
+ }
+ },
+ "goheader": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "values": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "const": {
+ "description": "Constants to use in the template.",
+ "type": "object",
+ "patternProperties": {
+ "^.+$": {
+ "description": "Value for the constant.",
+ "type": "string"
+ }
+ },
+ "additionalProperties": false,
+ "examples": [
+ {
+ "YEAR": "2030",
+ "COMPANY": "MY FUTURISTIC COMPANY"
+ }
+ ]
+ },
+ "regexp": {
+ "description": "Regular expressions to use in your template.",
+ "type": "object",
+ "additionalProperties": false,
+ "patternProperties": {
+ "^.+$": {
+ "type": "string"
+ }
+ },
+ "examples": [
+ {
+ "AUTHOR": ".*@mycompany\\.com"
+ }
+ ]
+ }
+ }
+ },
+ "template": {
+ "description": "Template to put on top of every file.",
+ "type": "string",
+ "examples": [
+ "{{ MY COMPANY }}\nSPDX-License-Identifier: Apache-2.0\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at:\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License."
+ ]
+ },
+ "template-path": {
+ "description": "Path to the file containing the template source.",
+ "type": "string",
+ "examples": ["my_header_template.txt"]
+ }
+ },
+ "oneOf": [
+ { "required": ["template"] },
+ { "required": ["template-path"] }
+ ]
+ },
+ "goimports": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "local-prefixes": {
+ "description": "Put imports beginning with prefix after 3rd-party packages. It is a comma-separated list of prefixes.",
+ "type": "string",
+ "examples": ["github.com/org/project"]
+ }
+ }
+ },
+ "gomoddirectives": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "replace-local": {
+ "description": "Allow local `replace` directives.",
+ "type": "boolean",
+ "default": true
+ },
+ "replace-allow-list": {
+ "description": "List of allowed `replace` directives.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "retract-allow-no-explanation": {
+ "description": "Allow to not explain why the version has been retracted in the `retract` directives.",
+ "type": "boolean",
+ "default": true
+ },
+ "exclude-forbidden": {
+ "description": "Forbid the use of the `exclude` directives.",
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "gomodguard": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "allowed": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "modules": {
+ "description": "List of allowed modules.",
+ "type": "array",
+ "items": {
+ "type": "string",
+ "examples": ["gopkg.in/yaml.v2"]
+ }
+ },
+ "domains": {
+ "description": "List of allowed module domains.",
+ "type": "array",
+ "items": {
+ "type": "string",
+ "examples": ["golang.org"]
+ }
+ }
+ }
+ },
+ "blocked": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "modules": {
+ "description": "List of blocked modules.",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "patternProperties": {
+ "^.+$": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "recommendations": {
+ "description": "Recommended modules that should be used instead.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "reason": {
+ "description": "Reason why the recommended module should be used.",
+ "type": "string"
+ }
+ }
+ }
+ },
+ "additionalProperties": false
+ }
+ },
+ "versions": {
+ "description": "List of blocked module version constraints.",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "patternProperties": {
+ "^.*$": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "version": {
+ "description": "Version constraint.",
+ "type": "string"
+ },
+ "reason": {
+ "description": "Reason why the version constraint exists.",
+ "type": "string"
+ }
+ },
+ "required": ["reason"]
+ }
+ }
+ }
+ },
+ "local_replace_directives": {
+ "description": "Raise lint issues if loading local path with replace directive",
+ "type": "boolean",
+ "default": true
+ }
+ }
+ }
+ }
+ },
+ "gosimple": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "checks": {
+ "type": "array",
+ "items": {
+ "anyOf": [
+ {
+ "enum": ["all"]
+ },
+ {
+ "type": "string"
+ }
+ ]
+ }
+ }
+ }
+ },
+ "gosec": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "includes": {
+ "type": "array",
+ "description": "To select a subset of rules to run",
+ "examples": [["G401"]],
+ "items": {
+ "$ref": "#/definitions/gosec-rules"
+ }
+ },
+ "excludes": {
+ "type": "array",
+ "description": "To specify a set of rules to explicitly exclude",
+ "examples": [["G401"]],
+ "items": {
+ "$ref": "#/definitions/gosec-rules"
+ }
+ },
+ "exclude-generated": {
+ "description": "Exclude generated files",
+ "type": "boolean",
+ "default": false
+ },
+ "severity": {
+ "description": "Filter out the issues with a lower severity than the given value",
+ "type": "string",
+ "enum": ["low", "medium", "high"],
+ "default": "low"
+ },
+ "confidence": {
+ "description": "Filter out the issues with a lower confidence than the given value",
+ "type": "string",
+ "enum": ["low", "medium", "high"],
+ "default": "low"
+ },
+ "config": {
+ "description": "To specify the configuration of rules",
+ "type": "object"
+ },
+ "concurrency": {
+ "description": "Concurrency value",
+ "type": "integer"
+ }
+ }
+ },
+ "gosmopolitan": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "allow-time-local": {
+ "description": "Allow and ignore `time.Local` usages.",
+ "type": "boolean",
+ "default": false
+ },
+ "escape-hatches": {
+ "description": "List of fully qualified names in the `full/pkg/path.name` form, to act as \"i18n escape hatches\".",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ignore-tests": {
+ "description": "Ignore test files.",
+ "type": "boolean",
+ "default": false
+ },
+ "watch-for-scripts": {
+ "description": "List of Unicode scripts to watch for any usage in string literals.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "govet": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "settings": {
+ "description": "Settings per analyzer. Map of analyzer name to specific settings.\nRun `go tool vet help` to find out more.",
+ "type": "object",
+ "propertyNames": {
+ "$ref": "#/definitions/govet-analyzers"
+ },
+ "patternProperties": {
+ "^.*$": {
+ "description": "Run `go tool vet help ` to see all settings.",
+ "type": "object"
+ }
+ }
+ },
+ "enable": {
+ "description": "Enable analyzers by name.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/govet-analyzers"
+ }
+ },
+ "disable": {
+ "description": "Disable analyzers by name.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/govet-analyzers"
+ }
+ },
+ "enable-all": {
+ "description": "Enable all analyzers.",
+ "type": "boolean",
+ "default": false
+ },
+ "disable-all": {
+ "description": "Disable all analyzers.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "grouper": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "const-require-single-const": {
+ "type": "boolean",
+ "default": false
+ },
+ "const-require-grouping": {
+ "type": "boolean",
+ "default": false
+ },
+ "import-require-single-import": {
+ "type": "boolean",
+ "default": false
+ },
+ "import-require-grouping": {
+ "type": "boolean",
+ "default": false
+ },
+ "type-require-single-type": {
+ "type": "boolean",
+ "default": false
+ },
+ "type-require-grouping": {
+ "type": "boolean",
+ "default": false
+ },
+ "var-require-single-var": {
+ "type": "boolean",
+ "default": false
+ },
+ "var-require-grouping": {
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "importas": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "no-unaliased": {
+ "description": "Do not allow unaliased imports of aliased packages.",
+ "type": "boolean",
+ "default": false
+ },
+ "no-extra-aliases": {
+ "description": "Do not allow non-required aliases.",
+ "type": "boolean",
+ "default": false
+ },
+ "alias": {
+ "description": "List of aliases",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "pkg": {
+ "description": "Package path e.g. knative.dev/serving/pkg/apis/autoscaling/v1alpha1",
+ "type": "string"
+ },
+ "alias": {
+ "description": "Package alias e.g. autoscalingv1alpha1",
+ "type": "string"
+ }
+ },
+ "required": ["pkg", "alias"]
+ }
+ }
+ }
+ },
+ "inamedparam": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "skip-single-param": {
+ "description": "Skips check for interface methods with only a single parameter.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "ireturn": {
+ "type": "object",
+ "additionalProperties": false,
+ "description": "Use either `reject` or `allow` properties for interfaces matching.",
+ "properties": {
+ "allow": {
+ "type": "array",
+ "items": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "enum": ["anon", "error", "empty", "stdlib"]
+ }
+ ]
+ }
+ },
+ "reject": {
+ "type": "array",
+ "items": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "enum": ["anon", "error", "empty", "stdlib"]
+ }
+ ]
+ }
+ }
+ },
+ "anyOf": [
+ {
+ "not": {
+ "properties": {
+ "allow": {
+ "const": "reject"
+ }
+ }
+ },
+ "required": ["allow"]
+ },
+ {
+ "required": ["reject"]
+ }
+ ]
+ },
+ "lll": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "tab-width": {
+ "description": "Width of \"\\t\" in spaces.",
+ "type": "integer",
+ "minimum": 0,
+ "default": 1
+ },
+ "line-length": {
+ "description": "Maximum allowed line length, lines longer will be reported.",
+ "type": "integer",
+ "minimum": 1,
+ "default": 120
+ }
+ }
+ },
+ "maintidx": {
+ "description": "Maintainability index https://docs.microsoft.com/en-us/visualstudio/code-quality/code-metrics-maintainability-index-range-and-meaning?view=vs-2022",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "under": {
+ "description": "Minimum accatpable maintainability index level (see https://docs.microsoft.com/en-us/visualstudio/code-quality/code-metrics-maintainability-index-range-and-meaning?view=vs-2022)",
+ "type": "number",
+ "default": 20
+ }
+ }
+ },
+ "makezero": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "always": {
+ "description": "Allow only slices initialized with a length of zero.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "loggercheck": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "kitlog": {
+ "description": "Allow check for the github.com/go-kit/log library.",
+ "type": "boolean",
+ "default": true
+ },
+ "klog": {
+ "description": "Allow check for the k8s.io/klog/v2 library.",
+ "type": "boolean",
+ "default": true
+ },
+ "logr": {
+ "description": "Allow check for the github.com/go-logr/logr library.",
+ "type": "boolean",
+ "default": true
+ },
+ "zap": {
+ "description": "Allow check for the \"sugar logger\" from go.uber.org/zap library.",
+ "type": "boolean",
+ "default": true
+ },
+ "require-string-key": {
+ "description": "Require all logging keys to be inlined constant strings.",
+ "type": "boolean",
+ "default": false
+ },
+ "no-printf-like": {
+ "description": "Require printf-like format specifier (%s, %d for example) not present.",
+ "type": "boolean",
+ "default": false
+ },
+ "rules": {
+ "description": "List of custom rules to check against, where each rule is a single logger pattern, useful for wrapped loggers.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "misspell": {
+ "description": "Correct spellings using locale preferences for US or UK. Default is to use a neutral variety of English.",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "locale": {
+ "enum": ["US", "UK"]
+ },
+ "ignore-words": {
+ "description": "List of words to ignore.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "mode": {
+ "description": "Mode of the analysis.",
+ "enum": ["restricted", "", "default"],
+ "default": ""
+ },
+ "extra-words": {
+ "description": "Extra word corrections.",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "correction": {
+ "type": "string"
+ },
+ "typo": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ }
+ },
+ "musttag": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "functions": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "name": {
+ "type": "string"
+ },
+ "tag": {
+ "type": "string"
+ },
+ "arg-pos": {
+ "type": "integer"
+ }
+ }
+ }
+ }
+ }
+ },
+ "nakedret": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "max-func-lines": {
+ "description": "Report if a function has more lines of code than this value and it has naked returns.",
+ "type": "integer",
+ "minimum": 0,
+ "default": 30
+ }
+ }
+ },
+ "nestif": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "min-complexity": {
+ "description": "Minimum complexity of \"if\" statements to report.",
+ "type": "integer",
+ "default": 5
+ }
+ }
+ },
+ "nilnil": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "checked-types": {
+ "type": "array",
+ "description": "List of return types to check.",
+ "items": {
+ "enum": ["ptr", "func", "iface", "map", "chan", "uintptr", "unsafeptr"]
+ },
+ "default": ["ptr", "func", "iface", "map", "chan", "uintptr", "unsafeptr"]
+ }
+ }
+ },
+ "nlreturn": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "block-size": {
+ "description": "set block size that is still ok",
+ "type": "number",
+ "default": 0,
+ "minimum": 0
+ }
+ }
+ },
+ "mnd": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "ignored-files": {
+ "description": "List of file patterns to exclude from analysis.",
+ "examples": [["magic1_.*.go"]],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ignored-functions": {
+ "description": "Comma-separated list of function patterns to exclude from the analysis.",
+ "examples": [["math.*", "http.StatusText", "make"]],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ignored-numbers": {
+ "description": "List of numbers to exclude from analysis.",
+ "examples": [["1000", "1234_567_890", "3.14159264"]],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "checks": {
+ "description": "The list of enabled checks, see https://github.com/tommy-muehle/go-mnd/#checks for description.",
+ "type": "array",
+ "items": {
+ "enum": [
+ "argument",
+ "case",
+ "condition",
+ "operation",
+ "return",
+ "assign"
+ ]
+ }
+ }
+ }
+ },
+ "nolintlint": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "allow-unused": {
+ "description": "Enable to ensure that nolint directives are all used.",
+ "type": "boolean",
+ "default": true
+ },
+ "allow-no-explanation": {
+ "description": "Exclude these linters from requiring an explanation.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/linters"
+ },
+ "default": []
+ },
+ "require-explanation": {
+ "description": "Enable to require an explanation of nonzero length after each nolint directive.",
+ "type": "boolean",
+ "default": false
+ },
+ "require-specific": {
+ "description": "Enable to require nolint directives to mention the specific linter being suppressed.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "reassign": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "patterns": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "nonamedreturns": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "report-error-in-defer": {
+ "description": "Report named error if it is assigned inside defer.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "paralleltest": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "ignore-missing": {
+ "description": "Ignore missing calls to `t.Parallel()` and only report incorrect uses of it.",
+ "type": "boolean",
+ "default": false
+ },
+ "ignore-missing-subtests": {
+ "description": "Ignore missing calls to `t.Parallel()` in subtests. Top-level tests are still required to have `t.Parallel`, but subtests are allowed to skip it.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "perfsprint": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "int-conversion": {
+ "description": "Optimizes even if it requires an int or uint type cast.",
+ "type": "boolean",
+ "default": true
+ },
+ "err-error": {
+ "description": "Optimizes into `err.Error()` even if it is only equivalent for non-nil errors.",
+ "type": "boolean",
+ "default": false
+ },
+ "errorf": {
+ "description": "Optimizes `fmt.Errorf`.",
+ "type": "boolean",
+ "default": true
+ },
+ "sprintf1": {
+ "description": "Optimizes `fmt.Sprintf` with only one argument.",
+ "type": "boolean",
+ "default": true
+ },
+ "strconcat": {
+ "description": "Optimizes into strings concatenation.",
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "prealloc": {
+ "description": "We do not recommend using this linter before doing performance profiling.\nFor most programs usage of `prealloc` will be premature optimization.",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "simple": {
+ "description": "Report preallocation suggestions only on simple loops that have no returns/breaks/continues/gotos in them.",
+ "type": "boolean",
+ "default": true
+ },
+ "range-loops": {
+ "description": "Report preallocation suggestions on range loops.",
+ "type": "boolean",
+ "default": true
+ },
+ "for-loops": {
+ "description": "Report preallocation suggestions on for loops.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "predeclared": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "ignore": {
+ "description": "Comma-separated list of predeclared identifiers to not report on.",
+ "type": "string"
+ },
+ "q": {
+ "description": "Include method names and field names (i.e., qualified names) in checks.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "promlinter": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "strict": {},
+ "disabled-linters": {
+ "type": "array",
+ "items": {
+ "enum": [
+ "Help",
+ "MetricUnits",
+ "Counter",
+ "HistogramSummaryReserved",
+ "MetricTypeInName",
+ "ReservedChars",
+ "CamelCase",
+ "UnitAbbreviations"
+ ]
+ }
+ }
+ }
+ },
+ "protogetter": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "skip-generated-by": {
+ "type": "array",
+ "items": {
+ "type": "string",
+ "examples": ["protoc-gen-go-my-own-generator"]
+ }
+ },
+ "skip-files": {
+ "type": "array",
+ "items": {
+ "type": "string",
+ "examples": ["*.pb.go"]
+ }
+ },
+ "skip-any-generated": {
+ "description": "Skip any generated files from the checking.",
+ "type": "boolean",
+ "default": false
+ },
+ "replace-first-arg-in-append": {
+ "description": "Skip first argument of append function.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "revive": {
+ "type": "object",
+ "additionalProperties": false,
+ "examples": [
+ {
+ "ignore-generated-header": true,
+ "severity": "warning",
+ "rules": [
+ {
+ "name": "indent-error-flow",
+ "severity": "warning"
+ },
+ {
+ "name": "add-constant",
+ "severity": "warning",
+ "arguments": [
+ {
+ "maxLitCount": "3",
+ "allowStrs": "\"\"",
+ "allowInts": "0,1,2",
+ "allowFloats": "0.0,0.,1.0,1.,2.0,2."
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ "properties": {
+ "max-open-files": {
+ "type": "integer"
+ },
+ "ignore-generated-header": {
+ "type": "boolean"
+ },
+ "confidence": {
+ "type": "number"
+ },
+ "severity": {
+ "type": "string",
+ "enum": ["warning", "error"]
+ },
+ "enable-all-rules": {
+ "type": "boolean",
+ "default": false
+ },
+ "directives": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "name": {
+ "type": "string",
+ "enum": ["specify-disable-reason"]
+ },
+ "severity": {
+ "type": "string",
+ "enum": ["warning", "error"]
+ },
+ "exclude": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "arguments": {
+ "type": "array"
+ }
+ }
+ }
+ },
+ "rules": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "required": ["name"],
+ "properties": {
+ "name": {
+ "$ref": "#/definitions/revive-rules",
+ "title": "The rule name"
+ },
+ "disabled": {
+ "type": "boolean"
+ },
+ "severity": {
+ "type": "string",
+ "enum": ["warning", "error"]
+ },
+ "exclude": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "arguments": {
+ "type": "array"
+ }
+ }
+ }
+ }
+ }
+ },
+ "rowserrcheck": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "packages": {
+ "type": "array",
+ "items": {
+ "description": "",
+ "type": "string",
+ "examples": ["github.com/jmoiron/sqlx"]
+ }
+ }
+ }
+ },
+ "sloglint": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "kv-only": {
+ "description": "Enforce using key-value pairs only (incompatible with attr-only).",
+ "type": "boolean",
+ "default": false
+ },
+ "no-global": {
+ "description": "Enforce not using global loggers.",
+ "enum": ["", "all", "default"],
+ "default": ""
+ },
+ "no-mixed-args": {
+ "description": "Enforce not mixing key-value pairs and attributes.",
+ "type": "boolean",
+ "default": true
+ },
+ "context": {
+ "description": "Enforce using methods that accept a context.",
+ "enum": ["", "all", "scope"],
+ "default": ""
+ },
+ "static-msg": {
+ "description": "Enforce using static values for log messages.",
+ "type": "boolean",
+ "default": false
+ },
+ "key-naming-case": {
+ "description": "Enforce a single key naming convention.",
+ "enum": ["snake", "kebab", "camel", "pascal"]
+ },
+ "attr-only": {
+ "description": "Enforce using attributes only (incompatible with kv-only).",
+ "type": "boolean",
+ "default": false
+ },
+ "no-raw-keys": {
+ "description": "Enforce using constants instead of raw keys.",
+ "type": "boolean",
+ "default": false
+ },
+ "forbidden-keys": {
+ "description": "Enforce not using specific keys.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "args-on-sep-lines": {
+ "description": "Enforce putting arguments on separate lines.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "spancheck": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "checks": {
+ "description": "Checks to enable.",
+ "type": "array",
+ "items": {
+ "enum": ["end", "record-error", "set-status"]
+ }
+ },
+ "ignore-check-signatures": {
+ "description": "A list of regexes for function signatures that silence `record-error` and `set-status` reports if found in the call path to a returned error.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "extra-start-span-signatures": {
+ "description": "A list of regexes for additional function signatures that create spans.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "staticcheck": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "checks": {
+ "type": "array",
+ "items": {
+ "anyOf": [
+ {
+ "enum": ["all"]
+ },
+ {
+ "type": "string"
+ }
+ ]
+ }
+ }
+ }
+ },
+ "stylecheck": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "checks": {
+ "type": "array",
+ "items": {
+ "anyOf": [
+ {
+ "enum": ["all"]
+ },
+ {
+ "type": "string"
+ }
+ ]
+ },
+ "default": [
+ "all",
+ "-ST1000",
+ "-ST1003",
+ "-ST1016",
+ "-ST1020",
+ "-ST1021",
+ "-ST1022"
+ ]
+ },
+ "dot-import-whitelist": {
+ "description": "By default, ST1001 forbids all uses of dot imports in non-test packages. This setting allows setting a whitelist of import paths that can be dot-imported anywhere.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "http-status-code-whitelist": {
+ "description": "ST1013 recommends using constants from the net/http package instead of hard-coding numeric HTTP status codes. This setting specifies a list of numeric status codes that this check does not complain about.",
+ "default": ["200", "400", "404", "500"],
+ "type": "array",
+ "items": {
+ "enum": [
+ "100",
+ "101",
+ "102",
+ "103",
+ "200",
+ "201",
+ "202",
+ "203",
+ "204",
+ "205",
+ "206",
+ "207",
+ "208",
+ "226",
+ "300",
+ "301",
+ "302",
+ "303",
+ "304",
+ "305",
+ "306",
+ "307",
+ "308",
+ "400",
+ "401",
+ "402",
+ "403",
+ "404",
+ "405",
+ "406",
+ "407",
+ "408",
+ "409",
+ "410",
+ "411",
+ "412",
+ "413",
+ "414",
+ "415",
+ "416",
+ "417",
+ "418",
+ "421",
+ "422",
+ "423",
+ "424",
+ "425",
+ "426",
+ "428",
+ "429",
+ "431",
+ "451",
+ "500",
+ "501",
+ "502",
+ "503",
+ "504",
+ "505",
+ "506",
+ "507",
+ "508",
+ "510",
+ "511"
+ ]
+ }
+ },
+ "initialisms": {
+ "description": "ST1003 check, among other things, for the correct capitalization of initialisms. The set of known initialisms can be configured with this option.",
+ "type": "array",
+ "items": {
+ "type": "string",
+ "default": [
+ "ACL",
+ "API",
+ "ASCII",
+ "CPU",
+ "CSS",
+ "DNS",
+ "EOF",
+ "GUID",
+ "HTML",
+ "HTTP",
+ "HTTPS",
+ "ID",
+ "IP",
+ "JSON",
+ "QPS",
+ "RAM",
+ "RPC",
+ "SLA",
+ "SMTP",
+ "SQL",
+ "SSH",
+ "TCP",
+ "TLS",
+ "TTL",
+ "UDP",
+ "UI",
+ "GID",
+ "UID",
+ "UUID",
+ "URI",
+ "URL",
+ "UTF8",
+ "VM",
+ "XML",
+ "XMPP",
+ "XSRF",
+ "XSS",
+ "SIP",
+ "RTP",
+ "AMQP",
+ "DB",
+ "TS"
+ ]
+ }
+ }
+ }
+ },
+ "tagalign": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "align": {
+ "description": "Align and sort can be used together or separately.",
+ "type": "boolean",
+ "default": true
+ },
+ "sort": {
+ "description": "Whether enable tags sort.",
+ "type": "boolean",
+ "default": true
+ },
+ "order": {
+ "description": "Specify the order of tags, the other tags will be sorted by name.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "default": [],
+ "examples": [
+ [
+ "json",
+ "yaml",
+ "yml",
+ "toml",
+ "mapstructure",
+ "binding",
+ "validate"
+ ]
+ ]
+ },
+ "strict": {
+ "description": "Whether enable strict style.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "tagliatelle": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "case": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "use-field-name": {
+ "description": "Use the struct field name to check the name of the struct tag.",
+ "type": "boolean",
+ "default": false
+ },
+ "rules": {
+ "type": "object",
+ "patternProperties": {
+ "^.+$": {
+ "enum": [
+ "camel",
+ "pascal",
+ "kebab",
+ "snake",
+ "goCamel",
+ "goPascal",
+ "goKebab",
+ "goSnake",
+ "upper",
+ "upperSnake",
+ "lower",
+ "header"
+ ]
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "tenv": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "all": {
+ "description": "The option `all` will run against whole test files (`_test.go`) regardless of method/function signatures.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "testifylint": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "enable-all": {
+ "description": "Enable all checkers.",
+ "type": "boolean",
+ "default": false
+ },
+ "disable-all": {
+ "description": "Disable all checkers.",
+ "type": "boolean",
+ "default": false
+ },
+ "enable": {
+ "description": "Enable specific checkers.",
+ "type": "array",
+ "items": {
+ "enum": [
+ "blank-import",
+ "bool-compare",
+ "compares",
+ "empty",
+ "error-is-as",
+ "error-nil",
+ "expected-actual",
+ "float-compare",
+ "formatter",
+ "go-require",
+ "len",
+ "negative-positive",
+ "nil-compare",
+ "require-error",
+ "suite-broken-parallel",
+ "suite-dont-use-pkg",
+ "suite-extra-assert-call",
+ "suite-subtest-run",
+ "suite-thelper",
+ "useless-assert"
+ ]
+ },
+ "default": [
+ "blank-import",
+ "bool-compare",
+ "compares",
+ "empty",
+ "error-is-as",
+ "error-nil",
+ "expected-actual",
+ "float-compare",
+ "float-compare",
+ "go-require",
+ "len",
+ "negative-positive",
+ "nil-compare",
+ "require-error",
+ "suite-broken-parallel",
+ "suite-dont-use-pkg",
+ "suite-extra-assert-call",
+ "suite-subtest-run",
+ "useless-assert"
+ ]
+ },
+ "disable": {
+ "description": "Disable specific checkers.",
+ "type": "array",
+ "items": {
+ "enum": [
+ "blank-import",
+ "bool-compare",
+ "compares",
+ "empty",
+ "error-is-as",
+ "error-nil",
+ "expected-actual",
+ "float-compare",
+ "formatter",
+ "go-require",
+ "len",
+ "negative-positive",
+ "nil-compare",
+ "require-error",
+ "suite-broken-parallel",
+ "suite-dont-use-pkg",
+ "suite-extra-assert-call",
+ "suite-subtest-run",
+ "suite-thelper",
+ "useless-assert"
+ ],
+ "default": [
+ "suite-thelper"
+ ]
+ }
+ },
+ "bool-compare": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "ignore-custom-types": {
+ "description": "To ignore user defined types (over builtin bool).",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "expected-actual": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "pattern": {
+ "description": "Regexp for expected variable name.",
+ "type": "string",
+ "default": "(^(exp(ected)?|want(ed)?)([A-Z]\\w*)?$)|(^(\\w*[a-z])?(Exp(ected)?|Want(ed)?)$)"
+ }
+ }
+ },
+ "formatter": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "check-format-string": {
+ "description": "To enable go vet's printf checks.",
+ "type": "boolean",
+ "default": true
+ },
+ "require-f-funcs": {
+ "description": "To require f-assertions if format string is used.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "go-require": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "ignore-http-handlers": {
+ "description": "To ignore HTTP handlers (like http.HandlerFunc).",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "require-error": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "fn-pattern": {
+ "description": "Regexp for assertions to analyze. If defined, then only matched error assertions will be reported.",
+ "type": "string",
+ "default": ""
+ }
+ }
+ },
+ "suite-extra-assert-call": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "mode": {
+ "description": "To require or remove extra Assert() call?",
+ "type": "string",
+ "enum": ["remove", "require"],
+ "default": "remove"
+ }
+ }
+ }
+ }
+ },
+ "testpackage": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "skip-regexp": {
+ "description": "Files with names matching this regular expression are skipped.",
+ "type": "string",
+ "examples": ["(export|internal)_test\\.go"]
+ },
+ "allow-packages": {
+ "description": "List of packages that don't end with _test that tests are allowed to be in.",
+ "type": "array",
+ "uniqueItems": true,
+ "items": {
+ "type": "string",
+ "examples": ["example"]
+ }
+ }
+ }
+ },
+ "thelper": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "test": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "begin": {
+ "description": "Check if `t.Helper()` begins helper function.",
+ "default": true,
+ "type": "boolean"
+ },
+ "first": {
+ "description": "Check if *testing.T is first param of helper function.",
+ "default": true,
+ "type": "boolean"
+ },
+ "name": {
+ "description": "Check if *testing.T param has t name.",
+ "default": true,
+ "type": "boolean"
+ }
+ }
+ },
+ "benchmark": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "begin": {
+ "description": "Check if `b.Helper()` begins helper function.",
+ "default": true,
+ "type": "boolean"
+ },
+ "first": {
+ "description": "Check if *testing.B is first param of helper function.",
+ "default": true,
+ "type": "boolean"
+ },
+ "name": {
+ "description": "Check if *testing.B param has b name.",
+ "default": true,
+ "type": "boolean"
+ }
+ }
+ },
+ "tb": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "begin": {
+ "description": "Check if `tb.Helper()` begins helper function.",
+ "default": true,
+ "type": "boolean"
+ },
+ "first": {
+ "description": "Check if *testing.TB is first param of helper function.",
+ "default": true,
+ "type": "boolean"
+ },
+ "name": {
+ "description": "Check if *testing.TB param has tb name.",
+ "default": true,
+ "type": "boolean"
+ }
+ }
+ },
+ "fuzz": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "begin": {
+ "description": "Check if `f.Helper()` begins helper function.",
+ "default": true,
+ "type": "boolean"
+ },
+ "first": {
+ "description": "Check if *testing.F is first param of helper function.",
+ "default": true,
+ "type": "boolean"
+ },
+ "name": {
+ "description": "Check if *testing.F param has f name.",
+ "default": true,
+ "type": "boolean"
+ }
+ }
+ }
+ }
+ },
+ "usestdlibvars": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "http-method": {
+ "description": "Suggest the use of http.MethodXX.",
+ "type": "boolean",
+ "default": true
+ },
+ "http-status-code": {
+ "description": "Suggest the use of http.StatusXX.",
+ "type": "boolean",
+ "default": true
+ },
+ "time-weekday": {
+ "description": "Suggest the use of time.Weekday.String().",
+ "type": "boolean",
+ "default": false
+ },
+ "time-month": {
+ "description": "Suggest the use of time.Month.String().",
+ "type": "boolean",
+ "default": false
+ },
+ "time-layout": {
+ "description": "Suggest the use of time.Layout.",
+ "type": "boolean",
+ "default": false
+ },
+ "crypto-hash": {
+ "description": "Suggest the use of crypto.Hash.String().",
+ "type": "boolean",
+ "default": false
+ },
+ "default-rpc-path": {
+ "description": "Suggest the use of rpc.DefaultXXPath.",
+ "type": "boolean",
+ "default": false
+ },
+ "sql-isolation-level": {
+ "description": "Suggest the use of sql.LevelXX.String().",
+ "type": "boolean",
+ "default": false
+ },
+ "tls-signature-scheme": {
+ "description": "Suggest the use of tls.SignatureScheme.String().",
+ "type": "boolean",
+ "default": false
+ },
+ "constant-kind": {
+ "description": "Suggest the use of constant.Kind.String().",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "unconvert": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "fast-math": {
+ "type": "boolean",
+ "default": false
+ },
+ "safe": {
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "unparam": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "check-exported": {
+ "description": "Inspect exported functions. Set to true if no external program/library imports your code.\n\nWARNING: if you enable this setting, unparam will report a lot of false-positives in text editors:\nif it's called for subdir of a project it can't find external interfaces. All text editor integrations\nwith golangci-lint call it on a directory with the changed file.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "unused": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "field-writes-are-uses": {
+ "description": "",
+ "type": "boolean",
+ "default": true
+ },
+ "post-statements-are-reads": {
+ "description": "",
+ "type": "boolean",
+ "default": false
+ },
+ "exported-fields-are-used": {
+ "description": "",
+ "type": "boolean",
+ "default": true
+ },
+ "parameters-are-used": {
+ "description": "",
+ "type": "boolean",
+ "default": true
+ },
+ "local-variables-are-used": {
+ "description": "",
+ "type": "boolean",
+ "default": true
+ },
+ "generated-is-used": {
+ "description": "",
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "varnamelen": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "max-distance": {
+ "description": "Variables used in at most this N-many lines will be ignored.",
+ "type": "integer",
+ "default": 5
+ },
+ "min-name-length": {
+ "description": "The minimum length of a variable's name that is considered `long`.",
+ "type": "integer",
+ "default": 3
+ },
+ "check-receiver": {
+ "description": "Check method receiver names.",
+ "default": false,
+ "type": "boolean"
+ },
+ "check-return": {
+ "description": "Check named return values.",
+ "default": false,
+ "type": "boolean"
+ },
+ "check-type-param": {
+ "description": "Check type parameters.",
+ "default": false,
+ "type": "boolean"
+ },
+ "ignore-type-assert-ok": {
+ "description": "Ignore `ok` variables that hold the bool return value of a type assertion",
+ "default": false,
+ "type": "boolean"
+ },
+ "ignore-map-index-ok": {
+ "description": "Ignore `ok` variables that hold the bool return value of a map index.",
+ "default": false,
+ "type": "boolean"
+ },
+ "ignore-chan-recv-ok": {
+ "description": "Ignore `ok` variables that hold the bool return value of a channel receive.",
+ "default": false,
+ "type": "boolean"
+ },
+ "ignore-names": {
+ "description": "Optional list of variable names that should be ignored completely.",
+ "default": [[]],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ignore-decls": {
+ "description": "Optional list of variable declarations that should be ignored completely.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "examples": [
+ ["c echo.Context", "t testing.T", "f *foo.Bar", "const C"]
+ ]
+ }
+ }
+ },
+ "whitespace": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "multi-if": {
+ "description": "Enforces newlines (or comments) after every multi-line if statement",
+ "type": "boolean",
+ "default": false
+ },
+ "multi-func": {
+ "description": "Enforces newlines (or comments) after every multi-line function signature",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "wrapcheck": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "ignoreSigs": {
+ "description": "An array of strings which specify substrings of signatures to ignore.",
+ "default": [
+ ".Errorf(",
+ "errors.New(",
+ "errors.Unwrap(",
+ ".Wrap(",
+ ".Wrapf(",
+ ".WithMessage(",
+ ".WithMessagef(",
+ ".WithStack("
+ ],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ignoreSigRegexps": {
+ "description": "An array of strings which specify regular expressions of signatures to ignore.",
+ "default": [""],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ignorePackageGlobs": {
+ "description": "An array of glob patterns which, if any match the package of the function returning the error, will skip wrapcheck analysis for this error.",
+ "default": [""],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ignoreInterfaceRegexps": {
+ "description": "An array of glob patterns which, if matched to an underlying interface name, will ignore unwrapped errors returned from a function whose call is defined on the given interface.",
+ "default": [""],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "wsl": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "allow-assign-and-anything": {
+ "description": "Controls if you may cuddle assignments and anything without needing an empty line between them.",
+ "type": "boolean",
+ "default": false
+ },
+ "allow-assign-and-call": {
+ "description": "Allow calls and assignments to be cuddled as long as the lines have any matching variables, fields or types.",
+ "type": "boolean",
+ "default": true
+ },
+ "allow-cuddle-declarations": {
+ "description": "Allow declarations (var) to be cuddled.",
+ "type": "boolean",
+ "default": false
+ },
+ "allow-cuddle-with-calls": {
+ "description": "A list of call idents that everything can be cuddled with.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "allow-cuddle-with-rhs": {
+ "description": "AllowCuddleWithRHS is a list of right hand side variables that is allowed to be cuddled with anything.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "allow-multiline-assign": {
+ "description": "Allow multiline assignments to be cuddled.",
+ "type": "boolean",
+ "default": true
+ },
+ "allow-separated-leading-comment": {
+ "description": "Allow leading comments to be separated with empty lines.",
+ "type": "boolean",
+ "default": false
+ },
+ "allow-trailing-comment": {
+ "description": "Allow trailing comments in ending of blocks.",
+ "type": "boolean",
+ "default": false
+ },
+ "error-variable-names": {
+ "description": "When force-err-cuddling is enabled this is a list of names used for error variables to check for in the conditional.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "force-case-trailing-whitespace": {
+ "description": "Force newlines in end of case at this limit (0 = never).",
+ "type": "integer",
+ "minimum": 0,
+ "default": 0
+ },
+ "force-err-cuddling": {
+ "description": "Causes an error when an If statement that checks an error variable doesn't cuddle with the assignment of that variable.",
+ "type": "boolean",
+ "default": false
+ },
+ "force-short-decl-cuddling": {
+ "description": "Causes an error if a short declaration (:=) cuddles with anything other than another short declaration.",
+ "type": "boolean",
+ "default": false
+ },
+ "strict-append": {
+ "description": "If true, append is only allowed to be cuddled if appending value is matching variables, fields or types on line above.",
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "copyloopvar": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "check-alias": {
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "custom": {
+ "description": "The custom section can be used to define linter plugins to be loaded at runtime. See README of golangci-lint for more information.\nEach custom linter should have a unique name.",
+ "type": "object",
+ "patternProperties": {
+ "^.*$": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "type": {
+ "description": "The plugin type.",
+ "enum": ["module", "goplugin"],
+ "default": "goplugin"
+ },
+ "path": {
+ "description": "The path to the plugin *.so. Can be absolute or local.",
+ "type": "string",
+ "examples": ["/path/to/example.so"]
+ },
+ "description": {
+ "description": "The description of the linter, for documentation purposes only.",
+ "type": "string"
+ },
+ "original-url": {
+ "description": "Intended to point to the repo location of the linter, for documentation purposes only.",
+ "type": "string"
+ },
+ "settings": {
+ "description": "Plugins settings/configuration. Only work with plugin based on `linterdb.PluginConstructor`.",
+ "type": "object"
+ }
+ },
+ "oneOf": [
+ {
+ "properties": {
+ "type": {"enum": ["module"] }
+ },
+ "required": ["type"]
+ },
+ {
+ "required": ["path"]
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
+ "linters": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "enable": {
+ "description": "List of enabled linters.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/linters"
+ }
+ },
+ "disable": {
+ "description": "List of disabled linters.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/linters"
+ }
+ },
+ "enable-all": {
+ "description": "Whether to enable all linters. You can re-disable them with `disable` explicitly.",
+ "type": "boolean",
+ "default": false
+ },
+ "disable-all": {
+ "description": "Whether to disable all linters. You can re-enable them with `enable` explicitly.",
+ "type": "boolean",
+ "default": false
+ },
+ "presets": {
+ "description": "Allow to use different presets of linters",
+ "type": "array",
+ "items": {
+ "enum": [
+ "bugs",
+ "comment",
+ "complexity",
+ "error",
+ "format",
+ "import",
+ "metalinter",
+ "module",
+ "performance",
+ "sql",
+ "style",
+ "test",
+ "unused"
+ ]
+ }
+ },
+ "fast": {
+ "description": "Enable run of fast linters.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "issues": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "exclude": {
+ "description": "List of regular expressions of issue texts to exclude.\nBut independently from this option we use default exclude patterns. Their usage can be controlled through `exclude-use-default`.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "exclude-rules": {
+ "description": "Exclude configuration per-path, per-linter, per-text and per-source",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "path": {
+ "type": "string"
+ },
+ "path-except": {
+ "type": "string"
+ },
+ "linters": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/linters"
+ }
+ },
+ "text": {
+ "type": "string"
+ },
+ "source": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "exclude-use-default": {
+ "description": "Independently from option `exclude` we use default exclude patterns. This behavior can be disabled by this option.",
+ "type": "boolean",
+ "default": true
+ },
+ "exclude-case-sensitive": {
+ "description": "If set to true, exclude and exclude-rules regular expressions become case sensitive.",
+ "type": "boolean",
+ "default": false
+ },
+ "exclude-generated": {
+ "description": "Mode of the generated files analysis.",
+ "enum": ["lax", "strict", "disable"],
+ "default": "lax"
+ },
+ "exclude-dirs": {
+ "description": "Which directories to exclude: issues from them won't be reported.",
+ "type": "array",
+ "items": {
+ "description": "You can use regexp here. The regexp is applied on the full path.\n\"/\" will be replaced by current OS file path separator to properly work on Windows.",
+ "type": "string",
+ "examples": ["generated.*"]
+ },
+ "default": [],
+ "examples": [["src/external_libs", "autogenerated_by_my_lib"]]
+ },
+ "exclude-dirs-use-default": {
+ "description": "Enable exclusion of directories \"vendor\", \"third_party\", \"testdata\", \"examples\", \"Godeps\", and \"builtin\".",
+ "type": "boolean",
+ "default": true
+ },
+ "exclude-files": {
+ "description": "Which files to exclude: they will be analyzed, but issues from them will not be reported.",
+ "type": "array",
+ "items": {
+ "description": "You can use regexp here. There is no need to include all autogenerated files, we confidently recognize them. If that is not the case, please let us know.\n\"/\" will be replaced by current OS file path separator to properly work on Windows.",
+ "type": "string",
+ "examples": [".*\\.my\\.go$"]
+ },
+ "default": [],
+ "examples": [[".*\\.my\\.go$", "lib/bad.go"]]
+ },
+ "include": {
+ "description": "The list of ids of default excludes to include or disable.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "default": []
+ },
+ "max-issues-per-linter": {
+ "description": "Maximum issues count per one linter. Set to 0 to disable.",
+ "type": "integer",
+ "default": 50,
+ "minimum": 0
+ },
+ "max-same-issues": {
+ "description": "Maximum count of issues with the same text. Set to 0 to disable.",
+ "type": "integer",
+ "default": 3,
+ "minimum": 0
+ },
+ "new": {
+ "description": "Show only new issues: if there are unstaged changes or untracked files, only those changes are analyzed, else only changes in HEAD~ are analyzed.",
+ "type": "boolean",
+ "default": false
+ },
+ "new-from-rev": {
+ "description": "Show only new issues created after this git revision.",
+ "type": "string"
+ },
+ "new-from-patch": {
+ "description": "Show only new issues created in git patch with this file path.",
+ "type": "string",
+ "examples": ["path/to/patch/file"]
+ },
+ "fix": {
+ "description": "Fix found issues (if it's supported by the linter).",
+ "type": "boolean",
+ "default": false
+ },
+ "whole-files": {
+ "description": "Show issues in any part of update files (requires new-from-rev or new-from-patch).",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "severity": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "default-severity": {
+ "description": "Set the default severity for issues. If severity rules are defined and the issues do not match or no severity is provided to the rule this will be the default severity applied. Severities should match the supported severity names of the selected out format.",
+ "type": "string",
+ "default": ""
+ },
+ "case-sensitive": {
+ "description": "If set to true, severity-rules regular expressions become case sensitive.",
+ "type": "boolean",
+ "default": false
+ },
+ "rules": {
+ "description": "When a list of severity rules are provided, severity information will be added to lint issues. Severity rules have the same filtering capability as exclude rules except you are allowed to specify one matcher per severity rule.\nOnly affects out formats that support setting severity information.",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "severity": {
+ "type": "string"
+ },
+ "path": {
+ "type": "string"
+ },
+ "path-except": {
+ "type": "string"
+ },
+ "linters": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/linters"
+ }
+ },
+ "text": {
+ "type": "string"
+ },
+ "source": {
+ "type": "string"
+ }
+ },
+ "required": ["severity"],
+ "anyOf": [
+ { "required": ["path"] },
+ { "required": ["path-except"] },
+ { "required": ["linters"] },
+ { "required": ["text"] },
+ { "required": ["source"] }
+ ]
+ },
+ "default": []
+ }
+ },
+ "required": ["default-severity"]
+ }
+ }
+}
diff --git a/vendor/github.com/golangci/golangci-lint/v2/jsonschema/golangci.v1.61.jsonschema.json b/vendor/github.com/golangci/golangci-lint/v2/jsonschema/golangci.v1.61.jsonschema.json
new file mode 100644
index 0000000000..a574b0195b
--- /dev/null
+++ b/vendor/github.com/golangci/golangci-lint/v2/jsonschema/golangci.v1.61.jsonschema.json
@@ -0,0 +1,3797 @@
+{
+ "$schema": "http://json-schema.org/draft-07/schema#",
+ "$id": "https://json.schemastore.org/golangci-lint.json",
+ "definitions": {
+ "gocritic-checks": {
+ "enum": [
+ "appendAssign",
+ "appendCombine",
+ "argOrder",
+ "assignOp",
+ "badCall",
+ "badCond",
+ "badLock",
+ "badRegexp",
+ "badSorting",
+ "boolExprSimplify",
+ "builtinShadow",
+ "builtinShadowDecl",
+ "captLocal",
+ "caseOrder",
+ "codegenComment",
+ "commentedOutCode",
+ "commentedOutImport",
+ "commentFormatting",
+ "defaultCaseOrder",
+ "deferUnlambda",
+ "deferInLoop",
+ "deprecatedComment",
+ "docStub",
+ "dupArg",
+ "dupBranchBody",
+ "dupCase",
+ "dupImport",
+ "dupSubExpr",
+ "dynamicFmtString",
+ "elseif",
+ "emptyDecl",
+ "emptyFallthrough",
+ "emptyStringTest",
+ "equalFold",
+ "evalOrder",
+ "exitAfterDefer",
+ "exposedSyncMutex",
+ "externalErrorReassign",
+ "filepathJoin",
+ "flagDeref",
+ "flagName",
+ "hexLiteral",
+ "httpNoBody",
+ "hugeParam",
+ "ifElseChain",
+ "importShadow",
+ "indexAlloc",
+ "initClause",
+ "ioutilDeprecated",
+ "mapKey",
+ "methodExprCall",
+ "nestingReduce",
+ "newDeref",
+ "nilValReturn",
+ "octalLiteral",
+ "offBy1",
+ "paramTypeCombine",
+ "preferDecodeRune",
+ "preferFilepathJoin",
+ "preferFprint",
+ "preferStringWriter",
+ "preferWriteByte",
+ "ptrToRefParam",
+ "rangeExprCopy",
+ "rangeValCopy",
+ "redundantSprint",
+ "regexpMust",
+ "regexpPattern",
+ "regexpSimplify",
+ "returnAfterHttpError",
+ "ruleguard",
+ "singleCaseSwitch",
+ "sliceClear",
+ "sloppyLen",
+ "sloppyReassign",
+ "sloppyTypeAssert",
+ "sortSlice",
+ "sprintfQuotedString",
+ "sqlQuery",
+ "stringConcatSimplify",
+ "stringsCompare",
+ "stringXbytes",
+ "suspiciousSorting",
+ "switchTrue",
+ "syncMapLoadAndDelete",
+ "timeCmpSimplify",
+ "timeExprSimplify",
+ "tooManyResultsChecker",
+ "truncateCmp",
+ "typeAssertChain",
+ "typeDefFirst",
+ "typeSwitchVar",
+ "typeUnparen",
+ "uncheckedInlineErr",
+ "underef",
+ "unlabelStmt",
+ "unlambda",
+ "unnamedResult",
+ "unnecessaryBlock",
+ "unnecessaryDefer",
+ "unslice",
+ "valSwap",
+ "weakCond",
+ "whyNoLint",
+ "wrapperFunc",
+ "yodaStyleExpr"
+ ]
+ },
+ "gocritic-tags": {
+ "enum": [
+ "diagnostic",
+ "style",
+ "performance",
+ "experimental",
+ "opinionated",
+ "security"
+ ]
+ },
+ "gosec-rules": {
+ "enum": [
+ "G101",
+ "G102",
+ "G103",
+ "G104",
+ "G106",
+ "G107",
+ "G108",
+ "G109",
+ "G110",
+ "G111",
+ "G112",
+ "G113",
+ "G114",
+ "G115",
+ "G201",
+ "G202",
+ "G203",
+ "G204",
+ "G301",
+ "G302",
+ "G303",
+ "G304",
+ "G305",
+ "G306",
+ "G307",
+ "G401",
+ "G402",
+ "G403",
+ "G404",
+ "G405",
+ "G406",
+ "G501",
+ "G502",
+ "G503",
+ "G504",
+ "G505",
+ "G506",
+ "G507",
+ "G601",
+ "G602"
+ ]
+ },
+ "govet-analyzers": {
+ "enum": [
+ "appends",
+ "asmdecl",
+ "assign",
+ "atomic",
+ "atomicalign",
+ "bools",
+ "buildtag",
+ "cgocall",
+ "composites",
+ "copylocks",
+ "deepequalerrors",
+ "defers",
+ "directive",
+ "errorsas",
+ "fieldalignment",
+ "findcall",
+ "framepointer",
+ "httpresponse",
+ "ifaceassert",
+ "loopclosure",
+ "lostcancel",
+ "nilfunc",
+ "nilness",
+ "printf",
+ "reflectvaluecompare",
+ "shadow",
+ "shift",
+ "sigchanyzer",
+ "slog",
+ "sortslice",
+ "stdmethods",
+ "stringintconv",
+ "structtag",
+ "testinggoroutine",
+ "tests",
+ "unmarshal",
+ "unreachable",
+ "unsafeptr",
+ "unusedresult",
+ "unusedwrite"
+ ]
+ },
+ "revive-rules": {
+ "enum": [
+ "add-constant",
+ "argument-limit",
+ "atomic",
+ "banned-characters",
+ "bare-return",
+ "blank-imports",
+ "bool-literal-in-expr",
+ "call-to-gc",
+ "cognitive-complexity",
+ "comment-spacings",
+ "comments-density",
+ "confusing-naming",
+ "confusing-results",
+ "constant-logical-expr",
+ "context-as-argument",
+ "context-keys-type",
+ "cyclomatic",
+ "datarace",
+ "deep-exit",
+ "defer",
+ "dot-imports",
+ "duplicated-imports",
+ "early-return",
+ "empty-block",
+ "empty-lines",
+ "enforce-map-style",
+ "enforce-repeated-arg-type-style",
+ "enforce-slice-style",
+ "error-naming",
+ "error-return",
+ "error-strings",
+ "errorf",
+ "exported",
+ "file-header",
+ "flag-parameter",
+ "function-length",
+ "function-result-limit",
+ "get-return",
+ "identical-branches",
+ "if-return",
+ "import-alias-naming",
+ "import-shadowing",
+ "imports-blocklist",
+ "increment-decrement",
+ "indent-error-flow",
+ "line-length-limit",
+ "max-control-nesting",
+ "max-public-structs",
+ "modifies-parameter",
+ "modifies-value-receiver",
+ "nested-structs",
+ "optimize-operands-order",
+ "package-comments",
+ "range",
+ "range-val-address",
+ "range-val-in-closure",
+ "receiver-naming",
+ "redefines-builtin-id",
+ "redundant-import-alias",
+ "string-format",
+ "string-of-int",
+ "struct-tag",
+ "superfluous-else",
+ "time-equal",
+ "time-naming",
+ "unchecked-type-assertion",
+ "unconditional-recursion",
+ "unexported-naming",
+ "unexported-return",
+ "unhandled-error",
+ "unnecessary-stmt",
+ "unreachable-code",
+ "unused-parameter",
+ "unused-receiver",
+ "use-any",
+ "useless-break",
+ "var-declaration",
+ "var-naming",
+ "waitgroup-by-value"
+ ]
+ },
+ "linters": {
+ "$comment": "anyOf with enum is used to allow auto completion of non-custom linters",
+ "description": "Linters usable.",
+ "anyOf": [
+ {
+ "enum": [
+ "asasalint",
+ "asciicheck",
+ "bidichk",
+ "bodyclose",
+ "canonicalheader",
+ "containedctx",
+ "contextcheck",
+ "copyloopvar",
+ "cyclop",
+ "deadcode",
+ "decorder",
+ "depguard",
+ "dogsled",
+ "dupl",
+ "dupword",
+ "durationcheck",
+ "errcheck",
+ "errchkjson",
+ "errname",
+ "errorlint",
+ "execinquery",
+ "exhaustive",
+ "exhaustivestruct",
+ "exhaustruct",
+ "exportloopref",
+ "fatcontext",
+ "forbidigo",
+ "forcetypeassert",
+ "funlen",
+ "gci",
+ "ginkgolinter",
+ "gocheckcompilerdirectives",
+ "gochecknoglobals",
+ "gochecknoinits",
+ "gochecksumtype",
+ "gocognit",
+ "goconst",
+ "gocritic",
+ "gocyclo",
+ "godot",
+ "godox",
+ "err113",
+ "gofmt",
+ "gofumpt",
+ "goheader",
+ "goimports",
+ "golint",
+ "gomoddirectives",
+ "gomodguard",
+ "goprintffuncname",
+ "gosec",
+ "gosimple",
+ "gosmopolitan",
+ "govet",
+ "grouper",
+ "ifshort",
+ "importas",
+ "inamedparam",
+ "ineffassign",
+ "interfacebloat",
+ "interfacer",
+ "intrange",
+ "ireturn",
+ "lll",
+ "loggercheck",
+ "maintidx",
+ "makezero",
+ "maligned",
+ "mirror",
+ "misspell",
+ "mnd",
+ "musttag",
+ "nakedret",
+ "nestif",
+ "nilerr",
+ "nilnil",
+ "nlreturn",
+ "noctx",
+ "nolintlint",
+ "nonamedreturns",
+ "nosnakecase",
+ "nosprintfhostport",
+ "paralleltest",
+ "perfsprint",
+ "prealloc",
+ "predeclared",
+ "promlinter",
+ "protogetter",
+ "reassign",
+ "revive",
+ "rowserrcheck",
+ "scopelint",
+ "sloglint",
+ "sqlclosecheck",
+ "staticcheck",
+ "structcheck",
+ "stylecheck",
+ "tagalign",
+ "tagliatelle",
+ "tenv",
+ "testableexamples",
+ "testifylint",
+ "testpackage",
+ "thelper",
+ "tparallel",
+ "unconvert",
+ "unparam",
+ "unused",
+ "usestdlibvars",
+ "varcheck",
+ "varnamelen",
+ "wastedassign",
+ "whitespace",
+ "wrapcheck",
+ "wsl",
+ "zerologlint"
+ ]
+ },
+ {
+ "type": "string"
+ }
+ ]
+ }
+ },
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "run": {
+ "description": "Options for analysis running,",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "concurrency": {
+ "description": "Number of concurrent runners. Defaults to the number of available CPU cores.",
+ "type": "integer",
+ "minimum": 0,
+ "examples": [4]
+ },
+ "timeout": {
+ "description": "Timeout for the analysis.",
+ "type": "string",
+ "pattern": "^((\\d+h)?(\\d+m)?(\\d+(?:\\.\\d)?s)?|0)$",
+ "default": "1m",
+ "examples": ["30s", "5m", "5m30s"]
+ },
+ "issues-exit-code": {
+ "description": "Exit code when at least one issue was found.",
+ "type": "integer",
+ "default": 1
+ },
+ "tests": {
+ "description": "Enable inclusion of test files.",
+ "type": "boolean",
+ "default": true
+ },
+ "build-tags": {
+ "description": "List of build tags to pass to all linters.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "default": [],
+ "examples": [["mytag"]]
+ },
+ "modules-download-mode": {
+ "description": "Option to pass to \"go list -mod={option}\".\nSee \"go help modules\" for more information.",
+ "enum": ["mod", "readonly", "vendor"]
+ },
+ "allow-parallel-runners": {
+ "description": "Allow multiple parallel golangci-lint instances running. If disabled, golangci-lint acquires file lock on start.",
+ "type": "boolean",
+ "default": false
+ },
+ "allow-serial-runners": {
+ "description": "Allow multiple golangci-lint instances running, but serialize them around a lock.",
+ "type": "boolean",
+ "default": false
+ },
+ "go": {
+ "description": "Targeted Go version.",
+ "type": "string",
+ "default": "1.17"
+ }
+ }
+ },
+ "output": {
+ "description": "Output configuration options.",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "formats": {
+ "description": "Output formats to use.",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "path": {
+ "default": "stdout",
+ "anyOf": [
+ {
+ "enum": [ "stdout", "stderr" ]
+ },
+ {
+ "type": "string"
+ }
+ ]
+ },
+ "format": {
+ "default": "colored-line-number",
+ "enum": [
+ "colored-line-number",
+ "line-number",
+ "json",
+ "colored-tab",
+ "tab",
+ "html",
+ "checkstyle",
+ "code-climate",
+ "junit-xml",
+ "junit-xml-extended",
+ "github-actions",
+ "teamcity",
+ "sarif"
+ ]
+ }
+ },
+ "required": ["format"]
+ }
+ },
+ "print-issued-lines": {
+ "description": "Print lines of code with issue.",
+ "type": "boolean",
+ "default": true
+ },
+ "print-linter-name": {
+ "description": "Print linter name in the end of issue text.",
+ "type": "boolean",
+ "default": true
+ },
+ "uniq-by-line": {
+ "description": "Make issues output unique by line.",
+ "type": "boolean",
+ "default": true
+ },
+ "path-prefix": {
+ "description": "Add a prefix to the output file references.",
+ "type": "string",
+ "default": ""
+ },
+ "show-stats": {
+ "description": "Show statistics per linter.",
+ "type": "boolean",
+ "default": false
+ },
+ "sort-order": {
+ "type": "array",
+ "items": {
+ "enum": ["linter", "severity", "file"]
+ }
+ },
+ "sort-results": {
+ "description": "Sort results by: filepath, line and column.",
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "linters-settings": {
+ "description": "All available settings of specific linters.",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "dupword": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "keywords": {
+ "description": "Keywords for detecting duplicate words. If this list is not empty, only the words defined in this list will be detected.",
+ "type": "array",
+ "uniqueItems": true,
+ "items": {
+ "type": "string",
+ "examples": ["the", "and", "a"]
+ }
+ },
+ "ignore": {
+ "description": "Keywords used to ignore detection.",
+ "type": "array",
+ "uniqueItems": true,
+ "items": {
+ "type": "string",
+ "examples": ["0C0C"]
+ }
+ }
+ }
+ },
+ "asasalint": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "exclude": {
+ "description": "To specify a set of function names to exclude.",
+ "type": "array",
+ "uniqueItems": true,
+ "items": {
+ "type": "string",
+ "examples": ["\\.Wrapf"]
+ }
+ },
+ "use-builtin-exclusions": {
+ "description": "To enable/disable the asasalint builtin exclusions of function names.",
+ "type": "boolean",
+ "default": true
+ },
+ "ignore-test": {
+ "description": "Ignore *_test.go files.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "bidichk": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "left-to-right-embedding": {
+ "description": "Disallow: LEFT-TO-RIGHT-EMBEDDING",
+ "type": "boolean",
+ "default": false
+ },
+ "right-to-left-embedding": {
+ "description": "Disallow: RIGHT-TO-LEFT-EMBEDDING",
+ "type": "boolean",
+ "default": false
+ },
+ "pop-directional-formatting": {
+ "description": "Disallow: POP-DIRECTIONAL-FORMATTING",
+ "type": "boolean",
+ "default": false
+ },
+ "left-to-right-override": {
+ "description": "Disallow: LEFT-TO-RIGHT-OVERRIDE",
+ "type": "boolean",
+ "default": false
+ },
+ "right-to-left-override": {
+ "description": "Disallow: RIGHT-TO-LEFT-OVERRIDE",
+ "type": "boolean",
+ "default": false
+ },
+ "left-to-right-isolate": {
+ "description": "Disallow: LEFT-TO-RIGHT-ISOLATE",
+ "type": "boolean",
+ "default": false
+ },
+ "right-to-left-isolate": {
+ "description": "Disallow: RIGHT-TO-LEFT-ISOLATE",
+ "type": "boolean",
+ "default": false
+ },
+ "first-strong-isolate": {
+ "description": "Disallow: FIRST-STRONG-ISOLATE",
+ "type": "boolean",
+ "default": false
+ },
+ "pop-directional-isolate": {
+ "description": "Disallow: POP-DIRECTIONAL-ISOLATE",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "cyclop": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "skip-tests": {
+ "description": "Should the linter execute on test files as well",
+ "type": "boolean",
+ "default": false
+ },
+ "max-complexity": {
+ "description": "Max complexity the function can have",
+ "type": "integer",
+ "default": 10,
+ "minimum": 0
+ },
+ "package-average": {
+ "description": "Max average complexity in package",
+ "type": "number",
+ "default": 0,
+ "minimum": 0
+ }
+ }
+ },
+ "decorder": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "dec-order": {
+ "type": "array",
+ "default": [["type", "const", "var", "func"]],
+ "items": {
+ "enum": ["type", "const", "var", "func"]
+ }
+ },
+ "ignore-underscore-vars": {
+ "description": "Underscore vars (vars with \"_\" as the name) will be ignored at all checks",
+ "default": true,
+ "type": "boolean"
+ },
+ "disable-dec-order-check": {
+ "description": "Order of declarations is not checked",
+ "default": true,
+ "type": "boolean"
+ },
+ "disable-init-func-first-check": {
+ "description": "Allow init func to be anywhere in file",
+ "default": true,
+ "type": "boolean"
+ },
+ "disable-dec-num-check": {
+ "description": "Multiple global type, const and var declarations are allowed",
+ "default": true,
+ "type": "boolean"
+ },
+ "disable-type-dec-num-check": {
+ "description": "Type declarations will be ignored for dec num check",
+ "default": true,
+ "type": "boolean"
+ },
+ "disable-const-dec-num-check": {
+ "description": "Const declarations will be ignored for dec num check",
+ "default": true,
+ "type": "boolean"
+ },
+ "disable-var-dec-num-check": {
+ "description": "Var declarations will be ignored for dec num check",
+ "default": true,
+ "type": "boolean"
+ }
+ }
+ },
+ "depguard": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "rules": {
+ "description": "Rules to apply.",
+ "type": "object",
+ "additionalProperties": false,
+ "patternProperties": {
+ "^[^.]+$": {
+ "description": "Name of a rule.",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "list-mode": {
+ "description": "Used to determine the package matching priority.",
+ "enum": ["original", "strict", "lax"],
+ "default": "original"
+ },
+ "files": {
+ "description": "List of file globs that will match this list of settings to compare against.",
+ "additionalProperties": false,
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "allow": {
+ "description": "List of allowed packages.",
+ "additionalProperties": false,
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "deny": {
+ "description": "Packages that are not allowed where the value is a suggestion.",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "desc": {
+ "description": "Description",
+ "type": "string"
+ },
+ "pkg": {
+ "description": "Package",
+ "type": "string"
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "dogsled": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "max-blank-identifiers": {
+ "description": "Check assignments with too many blank identifiers.",
+ "type": "integer",
+ "default": 2,
+ "minimum": 0
+ }
+ }
+ },
+ "dupl": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "threshold": {
+ "description": "Tokens count to trigger issue.",
+ "type": "integer",
+ "default": 150,
+ "minimum": 0
+ }
+ }
+ },
+ "errcheck": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "check-type-assertions": {
+ "description": "Report about not checking errors in type assertions, i.e.: `a := b.(MyStruct)`",
+ "type": "boolean",
+ "default": false
+ },
+ "check-blank": {
+ "description": "Report about assignment of errors to blank identifier",
+ "type": "boolean",
+ "default": false
+ },
+ "exclude-functions": {
+ "description": "List of functions to exclude from checking, where each entry is a single function to exclude",
+ "type": "array",
+ "examples": ["io/ioutil.ReadFile", "io.Copy(*bytes.Buffer)"],
+ "items": {
+ "type": "string"
+ }
+ },
+ "disable-default-exclusions": {
+ "description": "To disable the errcheck built-in exclude list",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "errchkjson": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "check-error-free-encoding": {
+ "type": "boolean",
+ "default": false
+ },
+ "report-no-exported": {
+ "description": "Issue on struct that doesn't have exported fields.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "errorlint": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "errorf": {
+ "description": "Check whether fmt.Errorf uses the %w verb for formatting errors",
+ "type": "boolean",
+ "default": true
+ },
+ "errorf-multi": {
+ "description": "Permit more than 1 %w verb, valid per Go 1.20",
+ "type": "boolean",
+ "default": true
+ },
+ "asserts": {
+ "description": "Check for plain type assertions and type switches.",
+ "type": "boolean",
+ "default": true
+ },
+ "comparison": {
+ "description": "Check for plain error comparisons",
+ "type": "boolean",
+ "default": true
+ },
+ "allowed-errors": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "err": {
+ "type": "string"
+ },
+ "fun": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "allowed-errors-wildcard": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "err": {
+ "type": "string"
+ },
+ "fun": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ }
+ },
+ "exhaustive": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "check": {
+ "description": "Program elements to check for exhaustiveness.",
+ "type": "array",
+ "uniqueItems": true,
+ "items": {
+ "type": "string",
+ "examples": ["switch", "map"]
+ }
+ },
+ "check-generated": {
+ "description": "Check switch statements in generated files",
+ "type": "boolean",
+ "default": false
+ },
+ "explicit-exhaustive-switch": {
+ "description": "Only run exhaustive check on switches with \"//exhaustive:enforce\" comment.",
+ "type": "boolean",
+ "default": false
+ },
+ "explicit-exhaustive-map": {
+ "description": "Only run exhaustive check on map literals with \"//exhaustive:enforce\" comment.",
+ "type": "boolean",
+ "default": false
+ },
+ "default-case-required": {
+ "description": "Switch statement requires default case even if exhaustive.",
+ "type": "boolean",
+ "default": false
+ },
+ "default-signifies-exhaustive": {
+ "description": "Presence of `default` case in switch statements satisfies exhaustiveness, even if all enum members are not listed.",
+ "type": "boolean",
+ "default": false
+ },
+ "ignore-enum-members": {
+ "description": "Enum members matching `regex` do not have to be listed in switch statements to satisfy exhaustiveness",
+ "type": "string"
+ },
+ "ignore-enum-types": {
+ "description": "Enum types matching the supplied regex do not have to be listed in switch statements to satisfy exhaustiveness.",
+ "type": "string"
+ },
+ "package-scope-only": {
+ "description": "Consider enums only in package scopes, not in inner scopes.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "exhaustruct": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "include": {
+ "description": "List of regular expressions to match struct packages and names.",
+ "type": "array",
+ "examples": [".*\\.Test"],
+ "items": {
+ "type": "string"
+ }
+ },
+ "exclude": {
+ "description": "List of regular expressions to exclude struct packages and names from check.",
+ "type": "array",
+ "examples": ["cobra\\.Command$"],
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "forbidigo": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "exclude-godoc-examples": {
+ "description": "Exclude code in godoc examples.",
+ "type": "boolean",
+ "default": true
+ },
+ "analyze-types": {
+ "description": "Instead of matching the literal source code, use type information to replace expressions with strings that contain the package name and (for methods and fields) the type name.",
+ "type": "boolean",
+ "default": true
+ },
+ "forbid": {
+ "description": "List of identifiers to forbid (written using `regexp`)",
+ "type": "array",
+ "examples": ["^print(ln)?$"],
+ "items": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "p": {
+ "description": "Pattern",
+ "type": "string"
+ },
+ "pkg": {
+ "description": "Package",
+ "type": "string"
+ },
+ "msg": {
+ "description": "Message",
+ "type": "string"
+ }
+ }
+ }
+ ]
+ }
+ }
+ }
+ },
+ "funlen": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "lines": {
+ "description": "Limit lines number per function.",
+ "type": "integer",
+ "default": 60
+ },
+ "statements": {
+ "description": "Limit statements number per function.",
+ "type": "integer",
+ "default": 40
+ },
+ "ignore-comments": {
+ "description": "Ignore comments when counting lines.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "gci": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "sections": {
+ "description": "Section configuration to compare against.",
+ "type": "array",
+ "items": {
+ "anyOf": [
+ {
+ "enum": [
+ "standard",
+ "default",
+ "blank",
+ "dot",
+ "alias",
+ "localmodule"
+ ]
+ },
+ {
+ "type": "string"
+ }
+ ]
+ },
+ "default": ["standard", "default"]
+ },
+ "skip-generated": {
+ "description": "Skip generated files.",
+ "type": "boolean",
+ "default": true
+ },
+ "custom-order": {
+ "description": "Enable custom order of sections.",
+ "type": "boolean",
+ "default": false
+ },
+ "no-lex-order": {
+ "description": "Drops lexical ordering for custom sections.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "ginkgolinter": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "suppress-len-assertion": {
+ "description": "Suppress the wrong length assertion warning.",
+ "type": "boolean",
+ "default": false
+ },
+ "suppress-nil-assertion": {
+ "description": "Suppress the wrong nil assertion warning.",
+ "type": "boolean",
+ "default": false
+ },
+ "suppress-err-assertion": {
+ "description": "Suppress the wrong error assertion warning.",
+ "type": "boolean",
+ "default": false
+ },
+ "suppress-compare-assertion": {
+ "description": "Suppress the wrong comparison assertion warning.",
+ "type": "boolean",
+ "default": false
+ },
+ "suppress-async-assertion": {
+ "description": "Suppress the function all in async assertion warning.",
+ "type": "boolean",
+ "default": false
+ },
+ "suppress-type-compare-assertion": {
+ "description": "Suppress warning for comparing values from different types, like int32 and uint32.",
+ "type": "boolean",
+ "default": false
+ },
+ "forbid-focus-container": {
+ "description": "Trigger warning for ginkgo focus containers like FDescribe, FContext, FWhen or FIt.",
+ "type": "boolean",
+ "default": false
+ },
+ "allow-havelen-zero": {
+ "description": "Don't trigger warnings for HaveLen(0).",
+ "type": "boolean",
+ "default": false
+ },
+ "force-expect-to": {
+ "description": "Force using `Expect` with `To`, `ToNot` or `NotTo`",
+ "type": "boolean",
+ "default": false
+ },
+ "validate-async-intervals": {
+ "description": "Best effort validation of async intervals (timeout and polling).",
+ "type": "boolean",
+ "default": false
+ },
+ "forbid-spec-pollution": {
+ "description": "Trigger a warning for variable assignments in ginkgo containers like `Describe`, `Context` and `When`, instead of in `BeforeEach()`.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "gocognit": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "min-complexity": {
+ "description": "Minimal code complexity to report (we recommend 10-20).",
+ "type": "integer",
+ "default": 30
+ }
+ }
+ },
+ "goconst": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "match-constant": {
+ "description": "Look for existing constants matching the values",
+ "type": "boolean",
+ "default": true
+ },
+ "min-len": {
+ "description": "Minimum length of string constant.",
+ "type": "integer",
+ "default": 3
+ },
+ "min-occurrences": {
+ "description": "Minimum occurrences count to trigger.",
+ "type": "integer",
+ "default": 3
+ },
+ "ignore-tests": {
+ "description": "Ignore test files.",
+ "type": "boolean",
+ "default": false
+ },
+ "ignore-calls": {
+ "description": "Ignore when constant is not used as function argument",
+ "type": "boolean",
+ "default": true
+ },
+ "ignore-strings": {
+ "description": "Exclude strings matching the given regular expression",
+ "type": "string"
+ },
+ "numbers": {
+ "description": "Search also for duplicated numbers.",
+ "type": "boolean",
+ "default": false
+ },
+ "min": {
+ "description": "Minimum value, only works with `numbers`",
+ "type": "integer",
+ "default": 3
+ },
+ "max": {
+ "description": "Maximum value, only works with `numbers`",
+ "type": "integer",
+ "default": 3
+ }
+ }
+ },
+ "gocritic": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "enabled-checks": {
+ "description": "Which checks should be enabled. By default, a list of stable checks is used. To see it, run `GL_DEBUG=gocritic golangci-lint run`.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/gocritic-checks"
+ }
+ },
+ "disabled-checks": {
+ "description": "Which checks should be disabled.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/gocritic-checks"
+ },
+ "default": []
+ },
+ "enabled-tags": {
+ "description": "Enable multiple checks by tags, run `GL_DEBUG=gocritic golangci-lint run` to see all tags and checks.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/gocritic-tags"
+ }
+ },
+ "disabled-tags": {
+ "description": "Disable multiple checks by tags, run `GL_DEBUG=gocritic golangci-lint run` to see all tags and checks.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/gocritic-tags"
+ }
+ },
+ "settings": {
+ "description": "Settings passed to gocritic. Properties must be valid and enabled check names.",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "captLocal": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "paramsOnly" : {
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "commentedOutCode": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "minLength" : {
+ "type": "number",
+ "default": 15
+ }
+ }
+ },
+ "elseif": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "skipBalanced" : {
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "hugeParam": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "sizeThreshold" : {
+ "type": "number",
+ "default": 80
+ }
+ }
+ },
+ "ifElseChain": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "minThreshold" : {
+ "type": "number",
+ "default": 2
+ }
+ }
+ },
+ "nestingReduce": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "bodyWidth" : {
+ "type": "number",
+ "default": 5
+ }
+ }
+ },
+ "rangeExprCopy": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "sizeThreshold" : {
+ "type": "number",
+ "default": 512
+ },
+ "skipTestFuncs" : {
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "rangeValCopy": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "sizeThreshold" : {
+ "type": "number",
+ "default": 128
+ },
+ "skipTestFuncs" : {
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "ruleguard": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "debug" : {
+ "type": "string"
+ },
+ "enable" : {
+ "type": "string"
+ },
+ "disable" : {
+ "type": "string"
+ },
+ "failOn" : {
+ "type": "string"
+ },
+ "rules" : {
+ "type": "string"
+ }
+ }
+ },
+ "tooManyResultsChecker": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "maxResults" : {
+ "type": "number",
+ "default": 5
+ }
+ }
+ },
+ "truncateCmp": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "skipArchDependent" : {
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "underef": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "skipRecvDeref" : {
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "unnamedResult": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "checkExported" : {
+ "type": "boolean",
+ "default": false
+ }
+ }
+ }
+ }
+ },
+ "disable-all": {
+ "type": "boolean",
+ "default": false
+ },
+ "enable-all": {
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "gocyclo": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "min-complexity": {
+ "description": "Minimum code complexity to report (we recommend 10-20).",
+ "type": "integer",
+ "default": 30
+ }
+ }
+ },
+ "godot": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "scope": {
+ "description": "Comments to be checked.",
+ "enum": ["declarations", "toplevel", "all"],
+ "default": "declarations"
+ },
+ "exclude": {
+ "description": "List of regexps for excluding particular comment lines from check.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "period": {
+ "description": "Check that each sentence ends with a period.",
+ "type": "boolean",
+ "default": true
+ },
+ "capital": {
+ "description": "Check that each sentence starts with a capital letter.",
+ "type": "boolean",
+ "default": false
+ },
+ "check-all": {
+ "description": "DEPRECATED: Check all top-level comments, not only declarations.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "godox": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "keywords": {
+ "description": "Report any comments starting with one of these keywords. This is useful for TODO or FIXME comments that might be left in the code accidentally and should be resolved before merging.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "default": ["TODO", "BUG", "FIXME"]
+ }
+ }
+ },
+ "gofmt": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "simplify": {
+ "description": "Simplify code.",
+ "type": "boolean",
+ "default": true
+ },
+ "rewrite-rules": {
+ "description": "Apply the rewrite rules to the source before reformatting.",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "pattern": {
+ "type": "string"
+ },
+ "replacement": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ }
+ },
+ "interfacebloat": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "max": {
+ "description": "The maximum number of methods allowed for an interface.",
+ "type": "integer"
+ }
+ }
+ },
+ "gofumpt": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "extra-rules": {
+ "description": "Choose whether or not to use the extra rules that are disabled by default.",
+ "type": "boolean",
+ "default": false
+ },
+ "module-path": {
+ "description": " Module path which contains the source code being formatted.",
+ "type": "string"
+ }
+ }
+ },
+ "goheader": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "values": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "const": {
+ "description": "Constants to use in the template.",
+ "type": "object",
+ "patternProperties": {
+ "^.+$": {
+ "description": "Value for the constant.",
+ "type": "string"
+ }
+ },
+ "additionalProperties": false,
+ "examples": [
+ {
+ "YEAR": "2030",
+ "COMPANY": "MY FUTURISTIC COMPANY"
+ }
+ ]
+ },
+ "regexp": {
+ "description": "Regular expressions to use in your template.",
+ "type": "object",
+ "additionalProperties": false,
+ "patternProperties": {
+ "^.+$": {
+ "type": "string"
+ }
+ },
+ "examples": [
+ {
+ "AUTHOR": ".*@mycompany\\.com"
+ }
+ ]
+ }
+ }
+ },
+ "template": {
+ "description": "Template to put on top of every file.",
+ "type": "string",
+ "examples": [
+ "{{ MY COMPANY }}\nSPDX-License-Identifier: Apache-2.0\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at:\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License."
+ ]
+ },
+ "template-path": {
+ "description": "Path to the file containing the template source.",
+ "type": "string",
+ "examples": ["my_header_template.txt"]
+ }
+ },
+ "oneOf": [
+ { "required": ["template"] },
+ { "required": ["template-path"] }
+ ]
+ },
+ "goimports": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "local-prefixes": {
+ "description": "Put imports beginning with prefix after 3rd-party packages. It is a comma-separated list of prefixes.",
+ "type": "string",
+ "examples": ["github.com/org/project"]
+ }
+ }
+ },
+ "gomoddirectives": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "replace-local": {
+ "description": "Allow local `replace` directives.",
+ "type": "boolean",
+ "default": true
+ },
+ "replace-allow-list": {
+ "description": "List of allowed `replace` directives.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "retract-allow-no-explanation": {
+ "description": "Allow to not explain why the version has been retracted in the `retract` directives.",
+ "type": "boolean",
+ "default": true
+ },
+ "exclude-forbidden": {
+ "description": "Forbid the use of the `exclude` directives.",
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "gomodguard": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "allowed": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "modules": {
+ "description": "List of allowed modules.",
+ "type": "array",
+ "items": {
+ "type": "string",
+ "examples": ["gopkg.in/yaml.v2"]
+ }
+ },
+ "domains": {
+ "description": "List of allowed module domains.",
+ "type": "array",
+ "items": {
+ "type": "string",
+ "examples": ["golang.org"]
+ }
+ }
+ }
+ },
+ "blocked": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "modules": {
+ "description": "List of blocked modules.",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "patternProperties": {
+ "^.+$": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "recommendations": {
+ "description": "Recommended modules that should be used instead.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "reason": {
+ "description": "Reason why the recommended module should be used.",
+ "type": "string"
+ }
+ }
+ }
+ },
+ "additionalProperties": false
+ }
+ },
+ "versions": {
+ "description": "List of blocked module version constraints.",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "patternProperties": {
+ "^.*$": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "version": {
+ "description": "Version constraint.",
+ "type": "string"
+ },
+ "reason": {
+ "description": "Reason why the version constraint exists.",
+ "type": "string"
+ }
+ },
+ "required": ["reason"]
+ }
+ }
+ }
+ },
+ "local_replace_directives": {
+ "description": "Raise lint issues if loading local path with replace directive",
+ "type": "boolean",
+ "default": true
+ }
+ }
+ }
+ }
+ },
+ "gosimple": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "checks": {
+ "type": "array",
+ "items": {
+ "anyOf": [
+ {
+ "enum": ["all"]
+ },
+ {
+ "type": "string"
+ }
+ ]
+ }
+ }
+ }
+ },
+ "gosec": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "includes": {
+ "type": "array",
+ "description": "To select a subset of rules to run",
+ "examples": [["G401"]],
+ "items": {
+ "$ref": "#/definitions/gosec-rules"
+ }
+ },
+ "excludes": {
+ "type": "array",
+ "description": "To specify a set of rules to explicitly exclude",
+ "examples": [["G401"]],
+ "items": {
+ "$ref": "#/definitions/gosec-rules"
+ }
+ },
+ "exclude-generated": {
+ "description": "Exclude generated files",
+ "type": "boolean",
+ "default": false
+ },
+ "severity": {
+ "description": "Filter out the issues with a lower severity than the given value",
+ "type": "string",
+ "enum": ["low", "medium", "high"],
+ "default": "low"
+ },
+ "confidence": {
+ "description": "Filter out the issues with a lower confidence than the given value",
+ "type": "string",
+ "enum": ["low", "medium", "high"],
+ "default": "low"
+ },
+ "config": {
+ "description": "To specify the configuration of rules",
+ "type": "object"
+ },
+ "concurrency": {
+ "description": "Concurrency value",
+ "type": "integer"
+ }
+ }
+ },
+ "gosmopolitan": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "allow-time-local": {
+ "description": "Allow and ignore `time.Local` usages.",
+ "type": "boolean",
+ "default": false
+ },
+ "escape-hatches": {
+ "description": "List of fully qualified names in the `full/pkg/path.name` form, to act as \"i18n escape hatches\".",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ignore-tests": {
+ "description": "Ignore test files.",
+ "type": "boolean",
+ "default": false
+ },
+ "watch-for-scripts": {
+ "description": "List of Unicode scripts to watch for any usage in string literals.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "govet": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "settings": {
+ "description": "Settings per analyzer. Map of analyzer name to specific settings.\nRun `go tool vet help` to find out more.",
+ "type": "object",
+ "propertyNames": {
+ "$ref": "#/definitions/govet-analyzers"
+ },
+ "patternProperties": {
+ "^.*$": {
+ "description": "Run `go tool vet help ` to see all settings.",
+ "type": "object"
+ }
+ }
+ },
+ "enable": {
+ "description": "Enable analyzers by name.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/govet-analyzers"
+ }
+ },
+ "disable": {
+ "description": "Disable analyzers by name.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/govet-analyzers"
+ }
+ },
+ "enable-all": {
+ "description": "Enable all analyzers.",
+ "type": "boolean",
+ "default": false
+ },
+ "disable-all": {
+ "description": "Disable all analyzers.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "grouper": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "const-require-single-const": {
+ "type": "boolean",
+ "default": false
+ },
+ "const-require-grouping": {
+ "type": "boolean",
+ "default": false
+ },
+ "import-require-single-import": {
+ "type": "boolean",
+ "default": false
+ },
+ "import-require-grouping": {
+ "type": "boolean",
+ "default": false
+ },
+ "type-require-single-type": {
+ "type": "boolean",
+ "default": false
+ },
+ "type-require-grouping": {
+ "type": "boolean",
+ "default": false
+ },
+ "var-require-single-var": {
+ "type": "boolean",
+ "default": false
+ },
+ "var-require-grouping": {
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "importas": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "no-unaliased": {
+ "description": "Do not allow unaliased imports of aliased packages.",
+ "type": "boolean",
+ "default": false
+ },
+ "no-extra-aliases": {
+ "description": "Do not allow non-required aliases.",
+ "type": "boolean",
+ "default": false
+ },
+ "alias": {
+ "description": "List of aliases",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "pkg": {
+ "description": "Package path e.g. knative.dev/serving/pkg/apis/autoscaling/v1alpha1",
+ "type": "string"
+ },
+ "alias": {
+ "description": "Package alias e.g. autoscalingv1alpha1",
+ "type": "string"
+ }
+ },
+ "required": ["pkg", "alias"]
+ }
+ }
+ }
+ },
+ "inamedparam": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "skip-single-param": {
+ "description": "Skips check for interface methods with only a single parameter.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "ireturn": {
+ "type": "object",
+ "additionalProperties": false,
+ "description": "Use either `reject` or `allow` properties for interfaces matching.",
+ "properties": {
+ "allow": {
+ "type": "array",
+ "items": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "enum": ["anon", "error", "empty", "stdlib"]
+ }
+ ]
+ }
+ },
+ "reject": {
+ "type": "array",
+ "items": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "enum": ["anon", "error", "empty", "stdlib"]
+ }
+ ]
+ }
+ }
+ },
+ "anyOf": [
+ {
+ "not": {
+ "properties": {
+ "allow": {
+ "const": "reject"
+ }
+ }
+ },
+ "required": ["allow"]
+ },
+ {
+ "required": ["reject"]
+ }
+ ]
+ },
+ "lll": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "tab-width": {
+ "description": "Width of \"\\t\" in spaces.",
+ "type": "integer",
+ "minimum": 0,
+ "default": 1
+ },
+ "line-length": {
+ "description": "Maximum allowed line length, lines longer will be reported.",
+ "type": "integer",
+ "minimum": 1,
+ "default": 120
+ }
+ }
+ },
+ "maintidx": {
+ "description": "Maintainability index https://docs.microsoft.com/en-us/visualstudio/code-quality/code-metrics-maintainability-index-range-and-meaning?view=vs-2022",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "under": {
+ "description": "Minimum accatpable maintainability index level (see https://docs.microsoft.com/en-us/visualstudio/code-quality/code-metrics-maintainability-index-range-and-meaning?view=vs-2022)",
+ "type": "number",
+ "default": 20
+ }
+ }
+ },
+ "makezero": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "always": {
+ "description": "Allow only slices initialized with a length of zero.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "loggercheck": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "kitlog": {
+ "description": "Allow check for the github.com/go-kit/log library.",
+ "type": "boolean",
+ "default": true
+ },
+ "klog": {
+ "description": "Allow check for the k8s.io/klog/v2 library.",
+ "type": "boolean",
+ "default": true
+ },
+ "logr": {
+ "description": "Allow check for the github.com/go-logr/logr library.",
+ "type": "boolean",
+ "default": true
+ },
+ "zap": {
+ "description": "Allow check for the \"sugar logger\" from go.uber.org/zap library.",
+ "type": "boolean",
+ "default": true
+ },
+ "require-string-key": {
+ "description": "Require all logging keys to be inlined constant strings.",
+ "type": "boolean",
+ "default": false
+ },
+ "no-printf-like": {
+ "description": "Require printf-like format specifier (%s, %d for example) not present.",
+ "type": "boolean",
+ "default": false
+ },
+ "rules": {
+ "description": "List of custom rules to check against, where each rule is a single logger pattern, useful for wrapped loggers.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "misspell": {
+ "description": "Correct spellings using locale preferences for US or UK. Default is to use a neutral variety of English.",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "locale": {
+ "enum": ["US", "UK"]
+ },
+ "ignore-words": {
+ "description": "List of words to ignore.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "mode": {
+ "description": "Mode of the analysis.",
+ "enum": ["restricted", "", "default"],
+ "default": ""
+ },
+ "extra-words": {
+ "description": "Extra word corrections.",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "correction": {
+ "type": "string"
+ },
+ "typo": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ }
+ },
+ "musttag": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "functions": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "name": {
+ "type": "string"
+ },
+ "tag": {
+ "type": "string"
+ },
+ "arg-pos": {
+ "type": "integer"
+ }
+ }
+ }
+ }
+ }
+ },
+ "nakedret": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "max-func-lines": {
+ "description": "Report if a function has more lines of code than this value and it has naked returns.",
+ "type": "integer",
+ "minimum": 0,
+ "default": 30
+ }
+ }
+ },
+ "nestif": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "min-complexity": {
+ "description": "Minimum complexity of \"if\" statements to report.",
+ "type": "integer",
+ "default": 5
+ }
+ }
+ },
+ "nilnil": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "checked-types": {
+ "type": "array",
+ "description": "List of return types to check.",
+ "items": {
+ "enum": ["ptr", "func", "iface", "map", "chan", "uintptr", "unsafeptr"]
+ },
+ "default": ["ptr", "func", "iface", "map", "chan", "uintptr", "unsafeptr"]
+ }
+ }
+ },
+ "nlreturn": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "block-size": {
+ "description": "set block size that is still ok",
+ "type": "number",
+ "default": 0,
+ "minimum": 0
+ }
+ }
+ },
+ "mnd": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "ignored-files": {
+ "description": "List of file patterns to exclude from analysis.",
+ "examples": [["magic1_.*.go"]],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ignored-functions": {
+ "description": "Comma-separated list of function patterns to exclude from the analysis.",
+ "examples": [["math.*", "http.StatusText", "make"]],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ignored-numbers": {
+ "description": "List of numbers to exclude from analysis.",
+ "examples": [["1000", "1234_567_890", "3.14159264"]],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "checks": {
+ "description": "The list of enabled checks, see https://github.com/tommy-muehle/go-mnd/#checks for description.",
+ "type": "array",
+ "items": {
+ "enum": [
+ "argument",
+ "case",
+ "condition",
+ "operation",
+ "return",
+ "assign"
+ ]
+ }
+ }
+ }
+ },
+ "nolintlint": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "allow-unused": {
+ "description": "Enable to ensure that nolint directives are all used.",
+ "type": "boolean",
+ "default": true
+ },
+ "allow-no-explanation": {
+ "description": "Exclude these linters from requiring an explanation.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/linters"
+ },
+ "default": []
+ },
+ "require-explanation": {
+ "description": "Enable to require an explanation of nonzero length after each nolint directive.",
+ "type": "boolean",
+ "default": false
+ },
+ "require-specific": {
+ "description": "Enable to require nolint directives to mention the specific linter being suppressed.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "reassign": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "patterns": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "nonamedreturns": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "report-error-in-defer": {
+ "description": "Report named error if it is assigned inside defer.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "paralleltest": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "ignore-missing": {
+ "description": "Ignore missing calls to `t.Parallel()` and only report incorrect uses of it.",
+ "type": "boolean",
+ "default": false
+ },
+ "ignore-missing-subtests": {
+ "description": "Ignore missing calls to `t.Parallel()` in subtests. Top-level tests are still required to have `t.Parallel`, but subtests are allowed to skip it.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "perfsprint": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "int-conversion": {
+ "description": "Optimizes even if it requires an int or uint type cast.",
+ "type": "boolean",
+ "default": true
+ },
+ "err-error": {
+ "description": "Optimizes into `err.Error()` even if it is only equivalent for non-nil errors.",
+ "type": "boolean",
+ "default": false
+ },
+ "errorf": {
+ "description": "Optimizes `fmt.Errorf`.",
+ "type": "boolean",
+ "default": true
+ },
+ "sprintf1": {
+ "description": "Optimizes `fmt.Sprintf` with only one argument.",
+ "type": "boolean",
+ "default": true
+ },
+ "strconcat": {
+ "description": "Optimizes into strings concatenation.",
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "prealloc": {
+ "description": "We do not recommend using this linter before doing performance profiling.\nFor most programs usage of `prealloc` will be premature optimization.",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "simple": {
+ "description": "Report preallocation suggestions only on simple loops that have no returns/breaks/continues/gotos in them.",
+ "type": "boolean",
+ "default": true
+ },
+ "range-loops": {
+ "description": "Report preallocation suggestions on range loops.",
+ "type": "boolean",
+ "default": true
+ },
+ "for-loops": {
+ "description": "Report preallocation suggestions on for loops.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "predeclared": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "ignore": {
+ "description": "Comma-separated list of predeclared identifiers to not report on.",
+ "type": "string"
+ },
+ "q": {
+ "description": "Include method names and field names (i.e., qualified names) in checks.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "promlinter": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "strict": {},
+ "disabled-linters": {
+ "type": "array",
+ "items": {
+ "enum": [
+ "Help",
+ "MetricUnits",
+ "Counter",
+ "HistogramSummaryReserved",
+ "MetricTypeInName",
+ "ReservedChars",
+ "CamelCase",
+ "UnitAbbreviations"
+ ]
+ }
+ }
+ }
+ },
+ "protogetter": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "skip-generated-by": {
+ "type": "array",
+ "items": {
+ "type": "string",
+ "examples": ["protoc-gen-go-my-own-generator"]
+ }
+ },
+ "skip-files": {
+ "type": "array",
+ "items": {
+ "type": "string",
+ "examples": ["*.pb.go"]
+ }
+ },
+ "skip-any-generated": {
+ "description": "Skip any generated files from the checking.",
+ "type": "boolean",
+ "default": false
+ },
+ "replace-first-arg-in-append": {
+ "description": "Skip first argument of append function.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "revive": {
+ "type": "object",
+ "additionalProperties": false,
+ "examples": [
+ {
+ "ignore-generated-header": true,
+ "severity": "warning",
+ "rules": [
+ {
+ "name": "indent-error-flow",
+ "severity": "warning"
+ },
+ {
+ "name": "add-constant",
+ "severity": "warning",
+ "arguments": [
+ {
+ "maxLitCount": "3",
+ "allowStrs": "\"\"",
+ "allowInts": "0,1,2",
+ "allowFloats": "0.0,0.,1.0,1.,2.0,2."
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ "properties": {
+ "max-open-files": {
+ "type": "integer"
+ },
+ "ignore-generated-header": {
+ "type": "boolean"
+ },
+ "confidence": {
+ "type": "number"
+ },
+ "severity": {
+ "type": "string",
+ "enum": ["warning", "error"]
+ },
+ "enable-all-rules": {
+ "type": "boolean",
+ "default": false
+ },
+ "directives": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "name": {
+ "type": "string",
+ "enum": ["specify-disable-reason"]
+ },
+ "severity": {
+ "type": "string",
+ "enum": ["warning", "error"]
+ },
+ "exclude": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "arguments": {
+ "type": "array"
+ }
+ }
+ }
+ },
+ "rules": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "required": ["name"],
+ "properties": {
+ "name": {
+ "$ref": "#/definitions/revive-rules",
+ "title": "The rule name"
+ },
+ "disabled": {
+ "type": "boolean"
+ },
+ "severity": {
+ "type": "string",
+ "enum": ["warning", "error"]
+ },
+ "exclude": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "arguments": {
+ "type": "array"
+ }
+ }
+ }
+ }
+ }
+ },
+ "rowserrcheck": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "packages": {
+ "type": "array",
+ "items": {
+ "description": "",
+ "type": "string",
+ "examples": ["github.com/jmoiron/sqlx"]
+ }
+ }
+ }
+ },
+ "sloglint": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "kv-only": {
+ "description": "Enforce using key-value pairs only (incompatible with attr-only).",
+ "type": "boolean",
+ "default": false
+ },
+ "no-global": {
+ "description": "Enforce not using global loggers.",
+ "enum": ["", "all", "default"],
+ "default": ""
+ },
+ "no-mixed-args": {
+ "description": "Enforce not mixing key-value pairs and attributes.",
+ "type": "boolean",
+ "default": true
+ },
+ "context": {
+ "description": "Enforce using methods that accept a context.",
+ "enum": ["", "all", "scope"],
+ "default": ""
+ },
+ "static-msg": {
+ "description": "Enforce using static values for log messages.",
+ "type": "boolean",
+ "default": false
+ },
+ "key-naming-case": {
+ "description": "Enforce a single key naming convention.",
+ "enum": ["snake", "kebab", "camel", "pascal"]
+ },
+ "attr-only": {
+ "description": "Enforce using attributes only (incompatible with kv-only).",
+ "type": "boolean",
+ "default": false
+ },
+ "no-raw-keys": {
+ "description": "Enforce using constants instead of raw keys.",
+ "type": "boolean",
+ "default": false
+ },
+ "forbidden-keys": {
+ "description": "Enforce not using specific keys.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "args-on-sep-lines": {
+ "description": "Enforce putting arguments on separate lines.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "spancheck": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "checks": {
+ "description": "Checks to enable.",
+ "type": "array",
+ "items": {
+ "enum": ["end", "record-error", "set-status"]
+ }
+ },
+ "ignore-check-signatures": {
+ "description": "A list of regexes for function signatures that silence `record-error` and `set-status` reports if found in the call path to a returned error.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "extra-start-span-signatures": {
+ "description": "A list of regexes for additional function signatures that create spans.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "staticcheck": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "checks": {
+ "type": "array",
+ "items": {
+ "anyOf": [
+ {
+ "enum": ["all"]
+ },
+ {
+ "type": "string"
+ }
+ ]
+ }
+ }
+ }
+ },
+ "stylecheck": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "checks": {
+ "type": "array",
+ "items": {
+ "anyOf": [
+ {
+ "enum": ["all"]
+ },
+ {
+ "type": "string"
+ }
+ ]
+ },
+ "default": [
+ "all",
+ "-ST1000",
+ "-ST1003",
+ "-ST1016",
+ "-ST1020",
+ "-ST1021",
+ "-ST1022"
+ ]
+ },
+ "dot-import-whitelist": {
+ "description": "By default, ST1001 forbids all uses of dot imports in non-test packages. This setting allows setting a whitelist of import paths that can be dot-imported anywhere.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "http-status-code-whitelist": {
+ "description": "ST1013 recommends using constants from the net/http package instead of hard-coding numeric HTTP status codes. This setting specifies a list of numeric status codes that this check does not complain about.",
+ "default": ["200", "400", "404", "500"],
+ "type": "array",
+ "items": {
+ "enum": [
+ "100",
+ "101",
+ "102",
+ "103",
+ "200",
+ "201",
+ "202",
+ "203",
+ "204",
+ "205",
+ "206",
+ "207",
+ "208",
+ "226",
+ "300",
+ "301",
+ "302",
+ "303",
+ "304",
+ "305",
+ "306",
+ "307",
+ "308",
+ "400",
+ "401",
+ "402",
+ "403",
+ "404",
+ "405",
+ "406",
+ "407",
+ "408",
+ "409",
+ "410",
+ "411",
+ "412",
+ "413",
+ "414",
+ "415",
+ "416",
+ "417",
+ "418",
+ "421",
+ "422",
+ "423",
+ "424",
+ "425",
+ "426",
+ "428",
+ "429",
+ "431",
+ "451",
+ "500",
+ "501",
+ "502",
+ "503",
+ "504",
+ "505",
+ "506",
+ "507",
+ "508",
+ "510",
+ "511"
+ ]
+ }
+ },
+ "initialisms": {
+ "description": "ST1003 check, among other things, for the correct capitalization of initialisms. The set of known initialisms can be configured with this option.",
+ "type": "array",
+ "items": {
+ "type": "string",
+ "default": [
+ "ACL",
+ "API",
+ "ASCII",
+ "CPU",
+ "CSS",
+ "DNS",
+ "EOF",
+ "GUID",
+ "HTML",
+ "HTTP",
+ "HTTPS",
+ "ID",
+ "IP",
+ "JSON",
+ "QPS",
+ "RAM",
+ "RPC",
+ "SLA",
+ "SMTP",
+ "SQL",
+ "SSH",
+ "TCP",
+ "TLS",
+ "TTL",
+ "UDP",
+ "UI",
+ "GID",
+ "UID",
+ "UUID",
+ "URI",
+ "URL",
+ "UTF8",
+ "VM",
+ "XML",
+ "XMPP",
+ "XSRF",
+ "XSS",
+ "SIP",
+ "RTP",
+ "AMQP",
+ "DB",
+ "TS"
+ ]
+ }
+ }
+ }
+ },
+ "tagalign": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "align": {
+ "description": "Align and sort can be used together or separately.",
+ "type": "boolean",
+ "default": true
+ },
+ "sort": {
+ "description": "Whether enable tags sort.",
+ "type": "boolean",
+ "default": true
+ },
+ "order": {
+ "description": "Specify the order of tags, the other tags will be sorted by name.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "default": [],
+ "examples": [
+ [
+ "json",
+ "yaml",
+ "yml",
+ "toml",
+ "mapstructure",
+ "binding",
+ "validate"
+ ]
+ ]
+ },
+ "strict": {
+ "description": "Whether enable strict style.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "tagliatelle": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "case": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "use-field-name": {
+ "description": "Use the struct field name to check the name of the struct tag.",
+ "type": "boolean",
+ "default": false
+ },
+ "rules": {
+ "type": "object",
+ "patternProperties": {
+ "^.+$": {
+ "enum": [
+ "camel",
+ "pascal",
+ "kebab",
+ "snake",
+ "goCamel",
+ "goPascal",
+ "goKebab",
+ "goSnake",
+ "upper",
+ "upperSnake",
+ "lower",
+ "header"
+ ]
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "tenv": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "all": {
+ "description": "The option `all` will run against whole test files (`_test.go`) regardless of method/function signatures.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "testifylint": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "enable-all": {
+ "description": "Enable all checkers.",
+ "type": "boolean",
+ "default": false
+ },
+ "disable-all": {
+ "description": "Disable all checkers.",
+ "type": "boolean",
+ "default": false
+ },
+ "enable": {
+ "description": "Enable specific checkers.",
+ "type": "array",
+ "items": {
+ "enum": [
+ "blank-import",
+ "bool-compare",
+ "compares",
+ "empty",
+ "error-is-as",
+ "error-nil",
+ "expected-actual",
+ "float-compare",
+ "formatter",
+ "go-require",
+ "len",
+ "negative-positive",
+ "nil-compare",
+ "require-error",
+ "suite-broken-parallel",
+ "suite-dont-use-pkg",
+ "suite-extra-assert-call",
+ "suite-subtest-run",
+ "suite-thelper",
+ "useless-assert"
+ ]
+ },
+ "default": [
+ "blank-import",
+ "bool-compare",
+ "compares",
+ "empty",
+ "error-is-as",
+ "error-nil",
+ "expected-actual",
+ "float-compare",
+ "float-compare",
+ "go-require",
+ "len",
+ "negative-positive",
+ "nil-compare",
+ "require-error",
+ "suite-broken-parallel",
+ "suite-dont-use-pkg",
+ "suite-extra-assert-call",
+ "suite-subtest-run",
+ "useless-assert"
+ ]
+ },
+ "disable": {
+ "description": "Disable specific checkers.",
+ "type": "array",
+ "items": {
+ "enum": [
+ "blank-import",
+ "bool-compare",
+ "compares",
+ "empty",
+ "error-is-as",
+ "error-nil",
+ "expected-actual",
+ "float-compare",
+ "formatter",
+ "go-require",
+ "len",
+ "negative-positive",
+ "nil-compare",
+ "require-error",
+ "suite-broken-parallel",
+ "suite-dont-use-pkg",
+ "suite-extra-assert-call",
+ "suite-subtest-run",
+ "suite-thelper",
+ "useless-assert"
+ ],
+ "default": [
+ "suite-thelper"
+ ]
+ }
+ },
+ "bool-compare": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "ignore-custom-types": {
+ "description": "To ignore user defined types (over builtin bool).",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "expected-actual": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "pattern": {
+ "description": "Regexp for expected variable name.",
+ "type": "string",
+ "default": "(^(exp(ected)?|want(ed)?)([A-Z]\\w*)?$)|(^(\\w*[a-z])?(Exp(ected)?|Want(ed)?)$)"
+ }
+ }
+ },
+ "formatter": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "check-format-string": {
+ "description": "To enable go vet's printf checks.",
+ "type": "boolean",
+ "default": true
+ },
+ "require-f-funcs": {
+ "description": "To require f-assertions if format string is used.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "go-require": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "ignore-http-handlers": {
+ "description": "To ignore HTTP handlers (like http.HandlerFunc).",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "require-error": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "fn-pattern": {
+ "description": "Regexp for assertions to analyze. If defined, then only matched error assertions will be reported.",
+ "type": "string",
+ "default": ""
+ }
+ }
+ },
+ "suite-extra-assert-call": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "mode": {
+ "description": "To require or remove extra Assert() call?",
+ "type": "string",
+ "enum": ["remove", "require"],
+ "default": "remove"
+ }
+ }
+ }
+ }
+ },
+ "testpackage": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "skip-regexp": {
+ "description": "Files with names matching this regular expression are skipped.",
+ "type": "string",
+ "examples": ["(export|internal)_test\\.go"]
+ },
+ "allow-packages": {
+ "description": "List of packages that don't end with _test that tests are allowed to be in.",
+ "type": "array",
+ "uniqueItems": true,
+ "items": {
+ "type": "string",
+ "examples": ["example"]
+ }
+ }
+ }
+ },
+ "thelper": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "test": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "begin": {
+ "description": "Check if `t.Helper()` begins helper function.",
+ "default": true,
+ "type": "boolean"
+ },
+ "first": {
+ "description": "Check if *testing.T is first param of helper function.",
+ "default": true,
+ "type": "boolean"
+ },
+ "name": {
+ "description": "Check if *testing.T param has t name.",
+ "default": true,
+ "type": "boolean"
+ }
+ }
+ },
+ "benchmark": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "begin": {
+ "description": "Check if `b.Helper()` begins helper function.",
+ "default": true,
+ "type": "boolean"
+ },
+ "first": {
+ "description": "Check if *testing.B is first param of helper function.",
+ "default": true,
+ "type": "boolean"
+ },
+ "name": {
+ "description": "Check if *testing.B param has b name.",
+ "default": true,
+ "type": "boolean"
+ }
+ }
+ },
+ "tb": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "begin": {
+ "description": "Check if `tb.Helper()` begins helper function.",
+ "default": true,
+ "type": "boolean"
+ },
+ "first": {
+ "description": "Check if *testing.TB is first param of helper function.",
+ "default": true,
+ "type": "boolean"
+ },
+ "name": {
+ "description": "Check if *testing.TB param has tb name.",
+ "default": true,
+ "type": "boolean"
+ }
+ }
+ },
+ "fuzz": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "begin": {
+ "description": "Check if `f.Helper()` begins helper function.",
+ "default": true,
+ "type": "boolean"
+ },
+ "first": {
+ "description": "Check if *testing.F is first param of helper function.",
+ "default": true,
+ "type": "boolean"
+ },
+ "name": {
+ "description": "Check if *testing.F param has f name.",
+ "default": true,
+ "type": "boolean"
+ }
+ }
+ }
+ }
+ },
+ "usestdlibvars": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "http-method": {
+ "description": "Suggest the use of http.MethodXX.",
+ "type": "boolean",
+ "default": true
+ },
+ "http-status-code": {
+ "description": "Suggest the use of http.StatusXX.",
+ "type": "boolean",
+ "default": true
+ },
+ "time-weekday": {
+ "description": "Suggest the use of time.Weekday.String().",
+ "type": "boolean",
+ "default": false
+ },
+ "time-month": {
+ "description": "Suggest the use of time.Month.String().",
+ "type": "boolean",
+ "default": false
+ },
+ "time-layout": {
+ "description": "Suggest the use of time.Layout.",
+ "type": "boolean",
+ "default": false
+ },
+ "crypto-hash": {
+ "description": "Suggest the use of crypto.Hash.String().",
+ "type": "boolean",
+ "default": false
+ },
+ "default-rpc-path": {
+ "description": "Suggest the use of rpc.DefaultXXPath.",
+ "type": "boolean",
+ "default": false
+ },
+ "sql-isolation-level": {
+ "description": "Suggest the use of sql.LevelXX.String().",
+ "type": "boolean",
+ "default": false
+ },
+ "tls-signature-scheme": {
+ "description": "Suggest the use of tls.SignatureScheme.String().",
+ "type": "boolean",
+ "default": false
+ },
+ "constant-kind": {
+ "description": "Suggest the use of constant.Kind.String().",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "unconvert": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "fast-math": {
+ "type": "boolean",
+ "default": false
+ },
+ "safe": {
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "unparam": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "check-exported": {
+ "description": "Inspect exported functions. Set to true if no external program/library imports your code.\n\nWARNING: if you enable this setting, unparam will report a lot of false-positives in text editors:\nif it's called for subdir of a project it can't find external interfaces. All text editor integrations\nwith golangci-lint call it on a directory with the changed file.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "unused": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "field-writes-are-uses": {
+ "description": "",
+ "type": "boolean",
+ "default": true
+ },
+ "post-statements-are-reads": {
+ "description": "",
+ "type": "boolean",
+ "default": false
+ },
+ "exported-fields-are-used": {
+ "description": "",
+ "type": "boolean",
+ "default": true
+ },
+ "parameters-are-used": {
+ "description": "",
+ "type": "boolean",
+ "default": true
+ },
+ "local-variables-are-used": {
+ "description": "",
+ "type": "boolean",
+ "default": true
+ },
+ "generated-is-used": {
+ "description": "",
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "varnamelen": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "max-distance": {
+ "description": "Variables used in at most this N-many lines will be ignored.",
+ "type": "integer",
+ "default": 5
+ },
+ "min-name-length": {
+ "description": "The minimum length of a variable's name that is considered `long`.",
+ "type": "integer",
+ "default": 3
+ },
+ "check-receiver": {
+ "description": "Check method receiver names.",
+ "default": false,
+ "type": "boolean"
+ },
+ "check-return": {
+ "description": "Check named return values.",
+ "default": false,
+ "type": "boolean"
+ },
+ "check-type-param": {
+ "description": "Check type parameters.",
+ "default": false,
+ "type": "boolean"
+ },
+ "ignore-type-assert-ok": {
+ "description": "Ignore `ok` variables that hold the bool return value of a type assertion",
+ "default": false,
+ "type": "boolean"
+ },
+ "ignore-map-index-ok": {
+ "description": "Ignore `ok` variables that hold the bool return value of a map index.",
+ "default": false,
+ "type": "boolean"
+ },
+ "ignore-chan-recv-ok": {
+ "description": "Ignore `ok` variables that hold the bool return value of a channel receive.",
+ "default": false,
+ "type": "boolean"
+ },
+ "ignore-names": {
+ "description": "Optional list of variable names that should be ignored completely.",
+ "default": [[]],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ignore-decls": {
+ "description": "Optional list of variable declarations that should be ignored completely.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "examples": [
+ ["c echo.Context", "t testing.T", "f *foo.Bar", "const C"]
+ ]
+ }
+ }
+ },
+ "whitespace": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "multi-if": {
+ "description": "Enforces newlines (or comments) after every multi-line if statement",
+ "type": "boolean",
+ "default": false
+ },
+ "multi-func": {
+ "description": "Enforces newlines (or comments) after every multi-line function signature",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "wrapcheck": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "ignoreSigs": {
+ "description": "An array of strings which specify substrings of signatures to ignore.",
+ "default": [
+ ".Errorf(",
+ "errors.New(",
+ "errors.Unwrap(",
+ ".Wrap(",
+ ".Wrapf(",
+ ".WithMessage(",
+ ".WithMessagef(",
+ ".WithStack("
+ ],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ignoreSigRegexps": {
+ "description": "An array of strings which specify regular expressions of signatures to ignore.",
+ "default": [""],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ignorePackageGlobs": {
+ "description": "An array of glob patterns which, if any match the package of the function returning the error, will skip wrapcheck analysis for this error.",
+ "default": [""],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ignoreInterfaceRegexps": {
+ "description": "An array of glob patterns which, if matched to an underlying interface name, will ignore unwrapped errors returned from a function whose call is defined on the given interface.",
+ "default": [""],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "wsl": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "allow-assign-and-anything": {
+ "description": "Controls if you may cuddle assignments and anything without needing an empty line between them.",
+ "type": "boolean",
+ "default": false
+ },
+ "allow-assign-and-call": {
+ "description": "Allow calls and assignments to be cuddled as long as the lines have any matching variables, fields or types.",
+ "type": "boolean",
+ "default": true
+ },
+ "allow-cuddle-declarations": {
+ "description": "Allow declarations (var) to be cuddled.",
+ "type": "boolean",
+ "default": false
+ },
+ "allow-cuddle-with-calls": {
+ "description": "A list of call idents that everything can be cuddled with.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "allow-cuddle-with-rhs": {
+ "description": "AllowCuddleWithRHS is a list of right hand side variables that is allowed to be cuddled with anything.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "allow-multiline-assign": {
+ "description": "Allow multiline assignments to be cuddled.",
+ "type": "boolean",
+ "default": true
+ },
+ "allow-separated-leading-comment": {
+ "description": "Allow leading comments to be separated with empty lines.",
+ "type": "boolean",
+ "default": false
+ },
+ "allow-trailing-comment": {
+ "description": "Allow trailing comments in ending of blocks.",
+ "type": "boolean",
+ "default": false
+ },
+ "error-variable-names": {
+ "description": "When force-err-cuddling is enabled this is a list of names used for error variables to check for in the conditional.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "force-case-trailing-whitespace": {
+ "description": "Force newlines in end of case at this limit (0 = never).",
+ "type": "integer",
+ "minimum": 0,
+ "default": 0
+ },
+ "force-err-cuddling": {
+ "description": "Causes an error when an If statement that checks an error variable doesn't cuddle with the assignment of that variable.",
+ "type": "boolean",
+ "default": false
+ },
+ "force-short-decl-cuddling": {
+ "description": "Causes an error if a short declaration (:=) cuddles with anything other than another short declaration.",
+ "type": "boolean",
+ "default": false
+ },
+ "strict-append": {
+ "description": "If true, append is only allowed to be cuddled if appending value is matching variables, fields or types on line above.",
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "copyloopvar": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "check-alias": {
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "custom": {
+ "description": "The custom section can be used to define linter plugins to be loaded at runtime. See README of golangci-lint for more information.\nEach custom linter should have a unique name.",
+ "type": "object",
+ "patternProperties": {
+ "^.*$": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "type": {
+ "description": "The plugin type.",
+ "enum": ["module", "goplugin"],
+ "default": "goplugin"
+ },
+ "path": {
+ "description": "The path to the plugin *.so. Can be absolute or local.",
+ "type": "string",
+ "examples": ["/path/to/example.so"]
+ },
+ "description": {
+ "description": "The description of the linter, for documentation purposes only.",
+ "type": "string"
+ },
+ "original-url": {
+ "description": "Intended to point to the repo location of the linter, for documentation purposes only.",
+ "type": "string"
+ },
+ "settings": {
+ "description": "Plugins settings/configuration. Only work with plugin based on `linterdb.PluginConstructor`.",
+ "type": "object"
+ }
+ },
+ "oneOf": [
+ {
+ "properties": {
+ "type": {"enum": ["module"] }
+ },
+ "required": ["type"]
+ },
+ {
+ "required": ["path"]
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
+ "linters": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "enable": {
+ "description": "List of enabled linters.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/linters"
+ }
+ },
+ "disable": {
+ "description": "List of disabled linters.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/linters"
+ }
+ },
+ "enable-all": {
+ "description": "Whether to enable all linters. You can re-disable them with `disable` explicitly.",
+ "type": "boolean",
+ "default": false
+ },
+ "disable-all": {
+ "description": "Whether to disable all linters. You can re-enable them with `enable` explicitly.",
+ "type": "boolean",
+ "default": false
+ },
+ "presets": {
+ "description": "Allow to use different presets of linters",
+ "type": "array",
+ "items": {
+ "enum": [
+ "bugs",
+ "comment",
+ "complexity",
+ "error",
+ "format",
+ "import",
+ "metalinter",
+ "module",
+ "performance",
+ "sql",
+ "style",
+ "test",
+ "unused"
+ ]
+ }
+ },
+ "fast": {
+ "description": "Enable run of fast linters.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "issues": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "exclude": {
+ "description": "List of regular expressions of issue texts to exclude.\nBut independently from this option we use default exclude patterns. Their usage can be controlled through `exclude-use-default`.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "exclude-rules": {
+ "description": "Exclude configuration per-path, per-linter, per-text and per-source",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "path": {
+ "type": "string"
+ },
+ "path-except": {
+ "type": "string"
+ },
+ "linters": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/linters"
+ }
+ },
+ "text": {
+ "type": "string"
+ },
+ "source": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "exclude-use-default": {
+ "description": "Independently from option `exclude` we use default exclude patterns. This behavior can be disabled by this option.",
+ "type": "boolean",
+ "default": true
+ },
+ "exclude-case-sensitive": {
+ "description": "If set to true, exclude and exclude-rules regular expressions become case sensitive.",
+ "type": "boolean",
+ "default": false
+ },
+ "exclude-generated": {
+ "description": "Mode of the generated files analysis.",
+ "enum": ["lax", "strict", "disable"],
+ "default": "lax"
+ },
+ "exclude-dirs": {
+ "description": "Which directories to exclude: issues from them won't be reported.",
+ "type": "array",
+ "items": {
+ "description": "You can use regexp here. The regexp is applied on the full path.\n\"/\" will be replaced by current OS file path separator to properly work on Windows.",
+ "type": "string",
+ "examples": ["generated.*"]
+ },
+ "default": [],
+ "examples": [["src/external_libs", "autogenerated_by_my_lib"]]
+ },
+ "exclude-dirs-use-default": {
+ "description": "Enable exclusion of directories \"vendor\", \"third_party\", \"testdata\", \"examples\", \"Godeps\", and \"builtin\".",
+ "type": "boolean",
+ "default": true
+ },
+ "exclude-files": {
+ "description": "Which files to exclude: they will be analyzed, but issues from them will not be reported.",
+ "type": "array",
+ "items": {
+ "description": "You can use regexp here. There is no need to include all autogenerated files, we confidently recognize them. If that is not the case, please let us know.\n\"/\" will be replaced by current OS file path separator to properly work on Windows.",
+ "type": "string",
+ "examples": [".*\\.my\\.go$"]
+ },
+ "default": [],
+ "examples": [[".*\\.my\\.go$", "lib/bad.go"]]
+ },
+ "include": {
+ "description": "The list of ids of default excludes to include or disable.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "default": []
+ },
+ "max-issues-per-linter": {
+ "description": "Maximum issues count per one linter. Set to 0 to disable.",
+ "type": "integer",
+ "default": 50,
+ "minimum": 0
+ },
+ "max-same-issues": {
+ "description": "Maximum count of issues with the same text. Set to 0 to disable.",
+ "type": "integer",
+ "default": 3,
+ "minimum": 0
+ },
+ "new": {
+ "description": "Show only new issues: if there are unstaged changes or untracked files, only those changes are analyzed, else only changes in HEAD~ are analyzed.",
+ "type": "boolean",
+ "default": false
+ },
+ "new-from-rev": {
+ "description": "Show only new issues created after this git revision.",
+ "type": "string"
+ },
+ "new-from-patch": {
+ "description": "Show only new issues created in git patch with this file path.",
+ "type": "string",
+ "examples": ["path/to/patch/file"]
+ },
+ "fix": {
+ "description": "Fix found issues (if it's supported by the linter).",
+ "type": "boolean",
+ "default": false
+ },
+ "whole-files": {
+ "description": "Show issues in any part of update files (requires new-from-rev or new-from-patch).",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "severity": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "default-severity": {
+ "description": "Set the default severity for issues. If severity rules are defined and the issues do not match or no severity is provided to the rule this will be the default severity applied. Severities should match the supported severity names of the selected out format.",
+ "type": "string",
+ "default": ""
+ },
+ "case-sensitive": {
+ "description": "If set to true, severity-rules regular expressions become case sensitive.",
+ "type": "boolean",
+ "default": false
+ },
+ "rules": {
+ "description": "When a list of severity rules are provided, severity information will be added to lint issues. Severity rules have the same filtering capability as exclude rules except you are allowed to specify one matcher per severity rule.\nOnly affects out formats that support setting severity information.",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "severity": {
+ "type": "string"
+ },
+ "path": {
+ "type": "string"
+ },
+ "path-except": {
+ "type": "string"
+ },
+ "linters": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/linters"
+ }
+ },
+ "text": {
+ "type": "string"
+ },
+ "source": {
+ "type": "string"
+ }
+ },
+ "required": ["severity"],
+ "anyOf": [
+ { "required": ["path"] },
+ { "required": ["path-except"] },
+ { "required": ["linters"] },
+ { "required": ["text"] },
+ { "required": ["source"] }
+ ]
+ },
+ "default": []
+ }
+ },
+ "required": ["default-severity"]
+ }
+ }
+}
diff --git a/vendor/github.com/golangci/golangci-lint/v2/jsonschema/golangci.v1.62.jsonschema.json b/vendor/github.com/golangci/golangci-lint/v2/jsonschema/golangci.v1.62.jsonschema.json
new file mode 100644
index 0000000000..3ca3593b26
--- /dev/null
+++ b/vendor/github.com/golangci/golangci-lint/v2/jsonschema/golangci.v1.62.jsonschema.json
@@ -0,0 +1,3860 @@
+{
+ "$schema": "http://json-schema.org/draft-07/schema#",
+ "$id": "https://json.schemastore.org/golangci-lint.json",
+ "definitions": {
+ "gocritic-checks": {
+ "enum": [
+ "appendAssign",
+ "appendCombine",
+ "argOrder",
+ "assignOp",
+ "badCall",
+ "badCond",
+ "badLock",
+ "badRegexp",
+ "badSorting",
+ "badSyncOnceFunc",
+ "boolExprSimplify",
+ "builtinShadow",
+ "builtinShadowDecl",
+ "captLocal",
+ "caseOrder",
+ "codegenComment",
+ "commentFormatting",
+ "commentedOutCode",
+ "commentedOutImport",
+ "defaultCaseOrder",
+ "deferInLoop",
+ "deferUnlambda",
+ "deprecatedComment",
+ "docStub",
+ "dupArg",
+ "dupBranchBody",
+ "dupCase",
+ "dupImport",
+ "dupSubExpr",
+ "dynamicFmtString",
+ "elseif",
+ "emptyDecl",
+ "emptyFallthrough",
+ "emptyStringTest",
+ "equalFold",
+ "evalOrder",
+ "exitAfterDefer",
+ "exposedSyncMutex",
+ "externalErrorReassign",
+ "filepathJoin",
+ "flagDeref",
+ "flagName",
+ "hexLiteral",
+ "httpNoBody",
+ "hugeParam",
+ "ifElseChain",
+ "importShadow",
+ "indexAlloc",
+ "initClause",
+ "ioutilDeprecated",
+ "mapKey",
+ "methodExprCall",
+ "nestingReduce",
+ "newDeref",
+ "nilValReturn",
+ "octalLiteral",
+ "offBy1",
+ "paramTypeCombine",
+ "preferDecodeRune",
+ "preferFilepathJoin",
+ "preferFprint",
+ "preferStringWriter",
+ "preferWriteByte",
+ "ptrToRefParam",
+ "rangeAppendAll",
+ "rangeExprCopy",
+ "rangeValCopy",
+ "redundantSprint",
+ "regexpMust",
+ "regexpPattern",
+ "regexpSimplify",
+ "returnAfterHttpError",
+ "ruleguard",
+ "singleCaseSwitch",
+ "sliceClear",
+ "sloppyLen",
+ "sloppyReassign",
+ "sloppyTypeAssert",
+ "sortSlice",
+ "sprintfQuotedString",
+ "sqlQuery",
+ "stringConcatSimplify",
+ "stringXbytes",
+ "stringsCompare",
+ "switchTrue",
+ "syncMapLoadAndDelete",
+ "timeExprSimplify",
+ "todoCommentWithoutDetail",
+ "tooManyResultsChecker",
+ "truncateCmp",
+ "typeAssertChain",
+ "typeDefFirst",
+ "typeSwitchVar",
+ "typeUnparen",
+ "uncheckedInlineErr",
+ "underef",
+ "unlabelStmt",
+ "unlambda",
+ "unnamedResult",
+ "unnecessaryBlock",
+ "unnecessaryDefer",
+ "unslice",
+ "valSwap",
+ "weakCond",
+ "whyNoLint",
+ "wrapperFunc",
+ "yodaStyleExpr"
+ ]
+ },
+ "gocritic-tags": {
+ "enum": [
+ "diagnostic",
+ "style",
+ "performance",
+ "experimental",
+ "opinionated",
+ "security"
+ ]
+ },
+ "gosec-rules": {
+ "enum": [
+ "G101",
+ "G102",
+ "G103",
+ "G104",
+ "G106",
+ "G107",
+ "G108",
+ "G109",
+ "G110",
+ "G111",
+ "G112",
+ "G113",
+ "G114",
+ "G115",
+ "G201",
+ "G202",
+ "G203",
+ "G204",
+ "G301",
+ "G302",
+ "G303",
+ "G304",
+ "G305",
+ "G306",
+ "G307",
+ "G401",
+ "G402",
+ "G403",
+ "G404",
+ "G405",
+ "G406",
+ "G501",
+ "G502",
+ "G503",
+ "G504",
+ "G505",
+ "G506",
+ "G507",
+ "G601",
+ "G602"
+ ]
+ },
+ "govet-analyzers": {
+ "enum": [
+ "appends",
+ "asmdecl",
+ "assign",
+ "atomic",
+ "atomicalign",
+ "bools",
+ "buildtag",
+ "cgocall",
+ "composites",
+ "copylocks",
+ "deepequalerrors",
+ "defers",
+ "directive",
+ "errorsas",
+ "fieldalignment",
+ "findcall",
+ "framepointer",
+ "httpresponse",
+ "ifaceassert",
+ "loopclosure",
+ "lostcancel",
+ "nilfunc",
+ "nilness",
+ "printf",
+ "reflectvaluecompare",
+ "shadow",
+ "shift",
+ "sigchanyzer",
+ "slog",
+ "sortslice",
+ "stdmethods",
+ "stringintconv",
+ "structtag",
+ "testinggoroutine",
+ "tests",
+ "timeformat",
+ "unmarshal",
+ "unreachable",
+ "unsafeptr",
+ "unusedresult",
+ "unusedwrite"
+ ]
+ },
+ "revive-rules": {
+ "enum": [
+ "add-constant",
+ "argument-limit",
+ "atomic",
+ "banned-characters",
+ "bare-return",
+ "blank-imports",
+ "bool-literal-in-expr",
+ "call-to-gc",
+ "cognitive-complexity",
+ "comment-spacings",
+ "comments-density",
+ "confusing-naming",
+ "confusing-results",
+ "constant-logical-expr",
+ "context-as-argument",
+ "context-keys-type",
+ "cyclomatic",
+ "datarace",
+ "deep-exit",
+ "defer",
+ "dot-imports",
+ "duplicated-imports",
+ "early-return",
+ "empty-block",
+ "empty-lines",
+ "enforce-map-style",
+ "enforce-repeated-arg-type-style",
+ "enforce-slice-style",
+ "error-naming",
+ "error-return",
+ "error-strings",
+ "errorf",
+ "exported",
+ "file-header",
+ "file-length-limit",
+ "filename-format",
+ "flag-parameter",
+ "function-length",
+ "function-result-limit",
+ "get-return",
+ "identical-branches",
+ "if-return",
+ "import-alias-naming",
+ "import-shadowing",
+ "imports-blocklist",
+ "increment-decrement",
+ "indent-error-flow",
+ "line-length-limit",
+ "max-control-nesting",
+ "max-public-structs",
+ "modifies-parameter",
+ "modifies-value-receiver",
+ "nested-structs",
+ "optimize-operands-order",
+ "package-comments",
+ "range",
+ "range-val-address",
+ "range-val-in-closure",
+ "receiver-naming",
+ "redefines-builtin-id",
+ "redundant-import-alias",
+ "string-format",
+ "string-of-int",
+ "struct-tag",
+ "superfluous-else",
+ "time-equal",
+ "time-naming",
+ "unchecked-type-assertion",
+ "unconditional-recursion",
+ "unexported-naming",
+ "unexported-return",
+ "unhandled-error",
+ "unnecessary-stmt",
+ "unreachable-code",
+ "unused-parameter",
+ "unused-receiver",
+ "use-any",
+ "useless-break",
+ "var-declaration",
+ "var-naming",
+ "waitgroup-by-value"
+ ]
+ },
+ "iface-analyzers": {
+ "enum": [
+ "identical",
+ "unused",
+ "opaque"
+ ]
+ },
+ "linters": {
+ "$comment": "anyOf with enum is used to allow auto completion of non-custom linters",
+ "description": "Linters usable.",
+ "anyOf": [
+ {
+ "enum": [
+ "asasalint",
+ "asciicheck",
+ "bidichk",
+ "bodyclose",
+ "canonicalheader",
+ "containedctx",
+ "contextcheck",
+ "copyloopvar",
+ "cyclop",
+ "decorder",
+ "depguard",
+ "dogsled",
+ "dupl",
+ "dupword",
+ "durationcheck",
+ "errcheck",
+ "errchkjson",
+ "errname",
+ "errorlint",
+ "exhaustive",
+ "exhaustruct",
+ "exportloopref",
+ "fatcontext",
+ "forbidigo",
+ "forcetypeassert",
+ "funlen",
+ "gci",
+ "ginkgolinter",
+ "gocheckcompilerdirectives",
+ "gochecknoglobals",
+ "gochecknoinits",
+ "gochecksumtype",
+ "gocognit",
+ "goconst",
+ "gocritic",
+ "gocyclo",
+ "godot",
+ "godox",
+ "err113",
+ "gofmt",
+ "gofumpt",
+ "goheader",
+ "goimports",
+ "gomoddirectives",
+ "gomodguard",
+ "goprintffuncname",
+ "gosec",
+ "gosimple",
+ "gosmopolitan",
+ "govet",
+ "grouper",
+ "iface",
+ "importas",
+ "inamedparam",
+ "ineffassign",
+ "interfacebloat",
+ "intrange",
+ "ireturn",
+ "lll",
+ "loggercheck",
+ "maintidx",
+ "makezero",
+ "mirror",
+ "misspell",
+ "mnd",
+ "musttag",
+ "nakedret",
+ "nestif",
+ "nilerr",
+ "nilnil",
+ "nlreturn",
+ "noctx",
+ "nolintlint",
+ "nonamedreturns",
+ "nosprintfhostport",
+ "paralleltest",
+ "perfsprint",
+ "prealloc",
+ "predeclared",
+ "promlinter",
+ "protogetter",
+ "reassign",
+ "recvcheck",
+ "revive",
+ "rowserrcheck",
+ "sloglint",
+ "sqlclosecheck",
+ "staticcheck",
+ "stylecheck",
+ "tagalign",
+ "tagliatelle",
+ "tenv",
+ "testableexamples",
+ "testifylint",
+ "testpackage",
+ "thelper",
+ "tparallel",
+ "unconvert",
+ "unparam",
+ "unused",
+ "usestdlibvars",
+ "varnamelen",
+ "wastedassign",
+ "whitespace",
+ "wrapcheck",
+ "wsl",
+ "zerologlint"
+ ]
+ },
+ {
+ "type": "string"
+ }
+ ]
+ }
+ },
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "run": {
+ "description": "Options for analysis running,",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "concurrency": {
+ "description": "Number of concurrent runners. Defaults to the number of available CPU cores.",
+ "type": "integer",
+ "minimum": 0,
+ "examples": [4]
+ },
+ "timeout": {
+ "description": "Timeout for the analysis.",
+ "type": "string",
+ "pattern": "^((\\d+h)?(\\d+m)?(\\d+(?:\\.\\d)?s)?|0)$",
+ "default": "1m",
+ "examples": ["30s", "5m", "5m30s"]
+ },
+ "issues-exit-code": {
+ "description": "Exit code when at least one issue was found.",
+ "type": "integer",
+ "default": 1
+ },
+ "tests": {
+ "description": "Enable inclusion of test files.",
+ "type": "boolean",
+ "default": true
+ },
+ "build-tags": {
+ "description": "List of build tags to pass to all linters.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "default": [],
+ "examples": [["mytag"]]
+ },
+ "modules-download-mode": {
+ "description": "Option to pass to \"go list -mod={option}\".\nSee \"go help modules\" for more information.",
+ "enum": ["mod", "readonly", "vendor"]
+ },
+ "allow-parallel-runners": {
+ "description": "Allow multiple parallel golangci-lint instances running. If disabled, golangci-lint acquires file lock on start.",
+ "type": "boolean",
+ "default": false
+ },
+ "allow-serial-runners": {
+ "description": "Allow multiple golangci-lint instances running, but serialize them around a lock.",
+ "type": "boolean",
+ "default": false
+ },
+ "go": {
+ "description": "Targeted Go version.",
+ "type": "string",
+ "default": "1.17"
+ }
+ }
+ },
+ "output": {
+ "description": "Output configuration options.",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "formats": {
+ "description": "Output formats to use.",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "path": {
+ "default": "stdout",
+ "anyOf": [
+ {
+ "enum": [ "stdout", "stderr" ]
+ },
+ {
+ "type": "string"
+ }
+ ]
+ },
+ "format": {
+ "default": "colored-line-number",
+ "enum": [
+ "colored-line-number",
+ "line-number",
+ "json",
+ "colored-tab",
+ "tab",
+ "html",
+ "checkstyle",
+ "code-climate",
+ "junit-xml",
+ "junit-xml-extended",
+ "github-actions",
+ "teamcity",
+ "sarif"
+ ]
+ }
+ },
+ "required": ["format"]
+ }
+ },
+ "print-issued-lines": {
+ "description": "Print lines of code with issue.",
+ "type": "boolean",
+ "default": true
+ },
+ "print-linter-name": {
+ "description": "Print linter name in the end of issue text.",
+ "type": "boolean",
+ "default": true
+ },
+ "uniq-by-line": {
+ "description": "Make issues output unique by line.",
+ "type": "boolean",
+ "default": true
+ },
+ "path-prefix": {
+ "description": "Add a prefix to the output file references.",
+ "type": "string",
+ "default": ""
+ },
+ "show-stats": {
+ "description": "Show statistics per linter.",
+ "type": "boolean",
+ "default": false
+ },
+ "sort-order": {
+ "type": "array",
+ "items": {
+ "enum": ["linter", "severity", "file"]
+ }
+ },
+ "sort-results": {
+ "description": "Sort results by: filepath, line and column.",
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "linters-settings": {
+ "description": "All available settings of specific linters.",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "dupword": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "keywords": {
+ "description": "Keywords for detecting duplicate words. If this list is not empty, only the words defined in this list will be detected.",
+ "type": "array",
+ "uniqueItems": true,
+ "items": {
+ "type": "string",
+ "examples": ["the", "and", "a"]
+ }
+ },
+ "ignore": {
+ "description": "Keywords used to ignore detection.",
+ "type": "array",
+ "uniqueItems": true,
+ "items": {
+ "type": "string",
+ "examples": ["0C0C"]
+ }
+ }
+ }
+ },
+ "asasalint": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "exclude": {
+ "description": "To specify a set of function names to exclude.",
+ "type": "array",
+ "uniqueItems": true,
+ "items": {
+ "type": "string",
+ "examples": ["\\.Wrapf"]
+ }
+ },
+ "use-builtin-exclusions": {
+ "description": "To enable/disable the asasalint builtin exclusions of function names.",
+ "type": "boolean",
+ "default": true
+ },
+ "ignore-test": {
+ "description": "Ignore *_test.go files.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "bidichk": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "left-to-right-embedding": {
+ "description": "Disallow: LEFT-TO-RIGHT-EMBEDDING",
+ "type": "boolean",
+ "default": false
+ },
+ "right-to-left-embedding": {
+ "description": "Disallow: RIGHT-TO-LEFT-EMBEDDING",
+ "type": "boolean",
+ "default": false
+ },
+ "pop-directional-formatting": {
+ "description": "Disallow: POP-DIRECTIONAL-FORMATTING",
+ "type": "boolean",
+ "default": false
+ },
+ "left-to-right-override": {
+ "description": "Disallow: LEFT-TO-RIGHT-OVERRIDE",
+ "type": "boolean",
+ "default": false
+ },
+ "right-to-left-override": {
+ "description": "Disallow: RIGHT-TO-LEFT-OVERRIDE",
+ "type": "boolean",
+ "default": false
+ },
+ "left-to-right-isolate": {
+ "description": "Disallow: LEFT-TO-RIGHT-ISOLATE",
+ "type": "boolean",
+ "default": false
+ },
+ "right-to-left-isolate": {
+ "description": "Disallow: RIGHT-TO-LEFT-ISOLATE",
+ "type": "boolean",
+ "default": false
+ },
+ "first-strong-isolate": {
+ "description": "Disallow: FIRST-STRONG-ISOLATE",
+ "type": "boolean",
+ "default": false
+ },
+ "pop-directional-isolate": {
+ "description": "Disallow: POP-DIRECTIONAL-ISOLATE",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "cyclop": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "skip-tests": {
+ "description": "Should the linter execute on test files as well",
+ "type": "boolean",
+ "default": false
+ },
+ "max-complexity": {
+ "description": "Max complexity the function can have",
+ "type": "integer",
+ "default": 10,
+ "minimum": 0
+ },
+ "package-average": {
+ "description": "Max average complexity in package",
+ "type": "number",
+ "default": 0,
+ "minimum": 0
+ }
+ }
+ },
+ "decorder": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "dec-order": {
+ "type": "array",
+ "default": [["type", "const", "var", "func"]],
+ "items": {
+ "enum": ["type", "const", "var", "func"]
+ }
+ },
+ "ignore-underscore-vars": {
+ "description": "Underscore vars (vars with \"_\" as the name) will be ignored at all checks",
+ "default": true,
+ "type": "boolean"
+ },
+ "disable-dec-order-check": {
+ "description": "Order of declarations is not checked",
+ "default": true,
+ "type": "boolean"
+ },
+ "disable-init-func-first-check": {
+ "description": "Allow init func to be anywhere in file",
+ "default": true,
+ "type": "boolean"
+ },
+ "disable-dec-num-check": {
+ "description": "Multiple global type, const and var declarations are allowed",
+ "default": true,
+ "type": "boolean"
+ },
+ "disable-type-dec-num-check": {
+ "description": "Type declarations will be ignored for dec num check",
+ "default": true,
+ "type": "boolean"
+ },
+ "disable-const-dec-num-check": {
+ "description": "Const declarations will be ignored for dec num check",
+ "default": true,
+ "type": "boolean"
+ },
+ "disable-var-dec-num-check": {
+ "description": "Var declarations will be ignored for dec num check",
+ "default": true,
+ "type": "boolean"
+ }
+ }
+ },
+ "depguard": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "rules": {
+ "description": "Rules to apply.",
+ "type": "object",
+ "additionalProperties": false,
+ "patternProperties": {
+ "^[^.]+$": {
+ "description": "Name of a rule.",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "list-mode": {
+ "description": "Used to determine the package matching priority.",
+ "enum": ["original", "strict", "lax"],
+ "default": "original"
+ },
+ "files": {
+ "description": "List of file globs that will match this list of settings to compare against.",
+ "additionalProperties": false,
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "allow": {
+ "description": "List of allowed packages.",
+ "additionalProperties": false,
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "deny": {
+ "description": "Packages that are not allowed where the value is a suggestion.",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "desc": {
+ "description": "Description",
+ "type": "string"
+ },
+ "pkg": {
+ "description": "Package",
+ "type": "string"
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "dogsled": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "max-blank-identifiers": {
+ "description": "Check assignments with too many blank identifiers.",
+ "type": "integer",
+ "default": 2,
+ "minimum": 0
+ }
+ }
+ },
+ "dupl": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "threshold": {
+ "description": "Tokens count to trigger issue.",
+ "type": "integer",
+ "default": 150,
+ "minimum": 0
+ }
+ }
+ },
+ "errcheck": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "check-type-assertions": {
+ "description": "Report about not checking errors in type assertions, i.e.: `a := b.(MyStruct)`",
+ "type": "boolean",
+ "default": false
+ },
+ "check-blank": {
+ "description": "Report about assignment of errors to blank identifier",
+ "type": "boolean",
+ "default": false
+ },
+ "exclude-functions": {
+ "description": "List of functions to exclude from checking, where each entry is a single function to exclude",
+ "type": "array",
+ "examples": ["io/ioutil.ReadFile", "io.Copy(*bytes.Buffer)"],
+ "items": {
+ "type": "string"
+ }
+ },
+ "disable-default-exclusions": {
+ "description": "To disable the errcheck built-in exclude list",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "errchkjson": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "check-error-free-encoding": {
+ "type": "boolean",
+ "default": false
+ },
+ "report-no-exported": {
+ "description": "Issue on struct that doesn't have exported fields.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "errorlint": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "errorf": {
+ "description": "Check whether fmt.Errorf uses the %w verb for formatting errors",
+ "type": "boolean",
+ "default": true
+ },
+ "errorf-multi": {
+ "description": "Permit more than 1 %w verb, valid per Go 1.20",
+ "type": "boolean",
+ "default": true
+ },
+ "asserts": {
+ "description": "Check for plain type assertions and type switches.",
+ "type": "boolean",
+ "default": true
+ },
+ "comparison": {
+ "description": "Check for plain error comparisons",
+ "type": "boolean",
+ "default": true
+ },
+ "allowed-errors": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "err": {
+ "type": "string"
+ },
+ "fun": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "allowed-errors-wildcard": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "err": {
+ "type": "string"
+ },
+ "fun": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ }
+ },
+ "exhaustive": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "check": {
+ "description": "Program elements to check for exhaustiveness.",
+ "type": "array",
+ "uniqueItems": true,
+ "items": {
+ "type": "string",
+ "examples": ["switch", "map"]
+ }
+ },
+ "check-generated": {
+ "description": "Check switch statements in generated files",
+ "type": "boolean",
+ "default": false
+ },
+ "explicit-exhaustive-switch": {
+ "description": "Only run exhaustive check on switches with \"//exhaustive:enforce\" comment.",
+ "type": "boolean",
+ "default": false
+ },
+ "explicit-exhaustive-map": {
+ "description": "Only run exhaustive check on map literals with \"//exhaustive:enforce\" comment.",
+ "type": "boolean",
+ "default": false
+ },
+ "default-case-required": {
+ "description": "Switch statement requires default case even if exhaustive.",
+ "type": "boolean",
+ "default": false
+ },
+ "default-signifies-exhaustive": {
+ "description": "Presence of `default` case in switch statements satisfies exhaustiveness, even if all enum members are not listed.",
+ "type": "boolean",
+ "default": false
+ },
+ "ignore-enum-members": {
+ "description": "Enum members matching `regex` do not have to be listed in switch statements to satisfy exhaustiveness",
+ "type": "string"
+ },
+ "ignore-enum-types": {
+ "description": "Enum types matching the supplied regex do not have to be listed in switch statements to satisfy exhaustiveness.",
+ "type": "string"
+ },
+ "package-scope-only": {
+ "description": "Consider enums only in package scopes, not in inner scopes.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "exhaustruct": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "include": {
+ "description": "List of regular expressions to match struct packages and names.",
+ "type": "array",
+ "examples": [".*\\.Test"],
+ "items": {
+ "type": "string"
+ }
+ },
+ "exclude": {
+ "description": "List of regular expressions to exclude struct packages and names from check.",
+ "type": "array",
+ "examples": ["cobra\\.Command$"],
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "forbidigo": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "exclude-godoc-examples": {
+ "description": "Exclude code in godoc examples.",
+ "type": "boolean",
+ "default": true
+ },
+ "analyze-types": {
+ "description": "Instead of matching the literal source code, use type information to replace expressions with strings that contain the package name and (for methods and fields) the type name.",
+ "type": "boolean",
+ "default": true
+ },
+ "forbid": {
+ "description": "List of identifiers to forbid (written using `regexp`)",
+ "type": "array",
+ "examples": ["^print(ln)?$"],
+ "items": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "p": {
+ "description": "Pattern",
+ "type": "string"
+ },
+ "pkg": {
+ "description": "Package",
+ "type": "string"
+ },
+ "msg": {
+ "description": "Message",
+ "type": "string"
+ }
+ }
+ }
+ ]
+ }
+ }
+ }
+ },
+ "funlen": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "lines": {
+ "description": "Limit lines number per function.",
+ "type": "integer",
+ "default": 60
+ },
+ "statements": {
+ "description": "Limit statements number per function.",
+ "type": "integer",
+ "default": 40
+ },
+ "ignore-comments": {
+ "description": "Ignore comments when counting lines.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "gci": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "sections": {
+ "description": "Section configuration to compare against.",
+ "type": "array",
+ "items": {
+ "anyOf": [
+ {
+ "enum": [
+ "standard",
+ "default",
+ "blank",
+ "dot",
+ "alias",
+ "localmodule"
+ ]
+ },
+ {
+ "type": "string"
+ }
+ ]
+ },
+ "default": ["standard", "default"]
+ },
+ "skip-generated": {
+ "description": "Skip generated files.",
+ "type": "boolean",
+ "default": true
+ },
+ "custom-order": {
+ "description": "Enable custom order of sections.",
+ "type": "boolean",
+ "default": false
+ },
+ "no-lex-order": {
+ "description": "Drops lexical ordering for custom sections.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "ginkgolinter": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "suppress-len-assertion": {
+ "description": "Suppress the wrong length assertion warning.",
+ "type": "boolean",
+ "default": false
+ },
+ "suppress-nil-assertion": {
+ "description": "Suppress the wrong nil assertion warning.",
+ "type": "boolean",
+ "default": false
+ },
+ "suppress-err-assertion": {
+ "description": "Suppress the wrong error assertion warning.",
+ "type": "boolean",
+ "default": false
+ },
+ "suppress-compare-assertion": {
+ "description": "Suppress the wrong comparison assertion warning.",
+ "type": "boolean",
+ "default": false
+ },
+ "suppress-async-assertion": {
+ "description": "Suppress the function all in async assertion warning.",
+ "type": "boolean",
+ "default": false
+ },
+ "suppress-type-compare-assertion": {
+ "description": "Suppress warning for comparing values from different types, like int32 and uint32.",
+ "type": "boolean",
+ "default": false
+ },
+ "forbid-focus-container": {
+ "description": "Trigger warning for ginkgo focus containers like FDescribe, FContext, FWhen or FIt.",
+ "type": "boolean",
+ "default": false
+ },
+ "allow-havelen-zero": {
+ "description": "Don't trigger warnings for HaveLen(0).",
+ "type": "boolean",
+ "default": false
+ },
+ "force-expect-to": {
+ "description": "Force using `Expect` with `To`, `ToNot` or `NotTo`",
+ "type": "boolean",
+ "default": false
+ },
+ "validate-async-intervals": {
+ "description": "Best effort validation of async intervals (timeout and polling).",
+ "type": "boolean",
+ "default": false
+ },
+ "forbid-spec-pollution": {
+ "description": "Trigger a warning for variable assignments in ginkgo containers like `Describe`, `Context` and `When`, instead of in `BeforeEach()`.",
+ "type": "boolean",
+ "default": false
+ },
+ "force-succeed": {
+ "description": "Force using the Succeed matcher for error functions, and the HaveOccurred matcher for non-function error values.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "gochecksumtype": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "default-signifies-exhaustive": {
+ "description": "Presence of `default` case in switch statements satisfies exhaustiveness, if all members are not listed.",
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "gocognit": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "min-complexity": {
+ "description": "Minimal code complexity to report (we recommend 10-20).",
+ "type": "integer",
+ "default": 30
+ }
+ }
+ },
+ "goconst": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "match-constant": {
+ "description": "Look for existing constants matching the values",
+ "type": "boolean",
+ "default": true
+ },
+ "min-len": {
+ "description": "Minimum length of string constant.",
+ "type": "integer",
+ "default": 3
+ },
+ "min-occurrences": {
+ "description": "Minimum occurrences count to trigger.",
+ "type": "integer",
+ "default": 3
+ },
+ "ignore-tests": {
+ "description": "Ignore test files.",
+ "type": "boolean",
+ "default": false
+ },
+ "ignore-calls": {
+ "description": "Ignore when constant is not used as function argument",
+ "type": "boolean",
+ "default": true
+ },
+ "ignore-strings": {
+ "description": "Exclude strings matching the given regular expression",
+ "type": "string"
+ },
+ "numbers": {
+ "description": "Search also for duplicated numbers.",
+ "type": "boolean",
+ "default": false
+ },
+ "min": {
+ "description": "Minimum value, only works with `numbers`",
+ "type": "integer",
+ "default": 3
+ },
+ "max": {
+ "description": "Maximum value, only works with `numbers`",
+ "type": "integer",
+ "default": 3
+ }
+ }
+ },
+ "gocritic": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "enabled-checks": {
+ "description": "Which checks should be enabled. By default, a list of stable checks is used. To see it, run `GL_DEBUG=gocritic golangci-lint run`.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/gocritic-checks"
+ }
+ },
+ "disabled-checks": {
+ "description": "Which checks should be disabled.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/gocritic-checks"
+ },
+ "default": []
+ },
+ "enabled-tags": {
+ "description": "Enable multiple checks by tags, run `GL_DEBUG=gocritic golangci-lint run` to see all tags and checks.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/gocritic-tags"
+ }
+ },
+ "disabled-tags": {
+ "description": "Disable multiple checks by tags, run `GL_DEBUG=gocritic golangci-lint run` to see all tags and checks.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/gocritic-tags"
+ }
+ },
+ "settings": {
+ "description": "Settings passed to gocritic. Properties must be valid and enabled check names.",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "captLocal": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "paramsOnly" : {
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "commentedOutCode": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "minLength" : {
+ "type": "number",
+ "default": 15
+ }
+ }
+ },
+ "elseif": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "skipBalanced" : {
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "hugeParam": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "sizeThreshold" : {
+ "type": "number",
+ "default": 80
+ }
+ }
+ },
+ "ifElseChain": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "minThreshold" : {
+ "type": "number",
+ "default": 2
+ }
+ }
+ },
+ "nestingReduce": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "bodyWidth" : {
+ "type": "number",
+ "default": 5
+ }
+ }
+ },
+ "rangeExprCopy": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "sizeThreshold" : {
+ "type": "number",
+ "default": 512
+ },
+ "skipTestFuncs" : {
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "rangeValCopy": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "sizeThreshold" : {
+ "type": "number",
+ "default": 128
+ },
+ "skipTestFuncs" : {
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "ruleguard": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "debug" : {
+ "type": "string"
+ },
+ "enable" : {
+ "type": "string"
+ },
+ "disable" : {
+ "type": "string"
+ },
+ "failOn" : {
+ "type": "string"
+ },
+ "rules" : {
+ "type": "string"
+ }
+ }
+ },
+ "tooManyResultsChecker": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "maxResults" : {
+ "type": "number",
+ "default": 5
+ }
+ }
+ },
+ "truncateCmp": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "skipArchDependent" : {
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "underef": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "skipRecvDeref" : {
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "unnamedResult": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "checkExported" : {
+ "type": "boolean",
+ "default": false
+ }
+ }
+ }
+ }
+ },
+ "disable-all": {
+ "type": "boolean",
+ "default": false
+ },
+ "enable-all": {
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "gocyclo": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "min-complexity": {
+ "description": "Minimum code complexity to report (we recommend 10-20).",
+ "type": "integer",
+ "default": 30
+ }
+ }
+ },
+ "godot": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "scope": {
+ "description": "Comments to be checked.",
+ "enum": ["declarations", "toplevel", "all"],
+ "default": "declarations"
+ },
+ "exclude": {
+ "description": "List of regexps for excluding particular comment lines from check.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "period": {
+ "description": "Check that each sentence ends with a period.",
+ "type": "boolean",
+ "default": true
+ },
+ "capital": {
+ "description": "Check that each sentence starts with a capital letter.",
+ "type": "boolean",
+ "default": false
+ },
+ "check-all": {
+ "description": "DEPRECATED: Check all top-level comments, not only declarations.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "godox": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "keywords": {
+ "description": "Report any comments starting with one of these keywords. This is useful for TODO or FIXME comments that might be left in the code accidentally and should be resolved before merging.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "default": ["TODO", "BUG", "FIXME"]
+ }
+ }
+ },
+ "gofmt": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "simplify": {
+ "description": "Simplify code.",
+ "type": "boolean",
+ "default": true
+ },
+ "rewrite-rules": {
+ "description": "Apply the rewrite rules to the source before reformatting.",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "pattern": {
+ "type": "string"
+ },
+ "replacement": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ }
+ },
+ "interfacebloat": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "max": {
+ "description": "The maximum number of methods allowed for an interface.",
+ "type": "integer"
+ }
+ }
+ },
+ "gofumpt": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "extra-rules": {
+ "description": "Choose whether or not to use the extra rules that are disabled by default.",
+ "type": "boolean",
+ "default": false
+ },
+ "module-path": {
+ "description": " Module path which contains the source code being formatted.",
+ "type": "string"
+ }
+ }
+ },
+ "goheader": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "values": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "const": {
+ "description": "Constants to use in the template.",
+ "type": "object",
+ "patternProperties": {
+ "^.+$": {
+ "description": "Value for the constant.",
+ "type": "string"
+ }
+ },
+ "additionalProperties": false,
+ "examples": [
+ {
+ "YEAR": "2030",
+ "COMPANY": "MY FUTURISTIC COMPANY"
+ }
+ ]
+ },
+ "regexp": {
+ "description": "Regular expressions to use in your template.",
+ "type": "object",
+ "additionalProperties": false,
+ "patternProperties": {
+ "^.+$": {
+ "type": "string"
+ }
+ },
+ "examples": [
+ {
+ "AUTHOR": ".*@mycompany\\.com"
+ }
+ ]
+ }
+ }
+ },
+ "template": {
+ "description": "Template to put on top of every file.",
+ "type": "string",
+ "examples": [
+ "{{ MY COMPANY }}\nSPDX-License-Identifier: Apache-2.0\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at:\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License."
+ ]
+ },
+ "template-path": {
+ "description": "Path to the file containing the template source.",
+ "type": "string",
+ "examples": ["my_header_template.txt"]
+ }
+ },
+ "oneOf": [
+ { "required": ["template"] },
+ { "required": ["template-path"] }
+ ]
+ },
+ "goimports": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "local-prefixes": {
+ "description": "Put imports beginning with prefix after 3rd-party packages. It is a comma-separated list of prefixes.",
+ "type": "string",
+ "examples": ["github.com/org/project"]
+ }
+ }
+ },
+ "gomoddirectives": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "replace-local": {
+ "description": "Allow local `replace` directives.",
+ "type": "boolean",
+ "default": false
+ },
+ "replace-allow-list": {
+ "description": "List of allowed `replace` directives.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "retract-allow-no-explanation": {
+ "description": "Allow to not explain why the version has been retracted in the `retract` directives.",
+ "type": "boolean",
+ "default": false
+ },
+ "exclude-forbidden": {
+ "description": "Forbid the use of the `exclude` directives.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "gomodguard": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "allowed": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "modules": {
+ "description": "List of allowed modules.",
+ "type": "array",
+ "items": {
+ "type": "string",
+ "examples": ["gopkg.in/yaml.v2"]
+ }
+ },
+ "domains": {
+ "description": "List of allowed module domains.",
+ "type": "array",
+ "items": {
+ "type": "string",
+ "examples": ["golang.org"]
+ }
+ }
+ }
+ },
+ "blocked": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "modules": {
+ "description": "List of blocked modules.",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "patternProperties": {
+ "^.+$": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "recommendations": {
+ "description": "Recommended modules that should be used instead.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "reason": {
+ "description": "Reason why the recommended module should be used.",
+ "type": "string"
+ }
+ }
+ }
+ },
+ "additionalProperties": false
+ }
+ },
+ "versions": {
+ "description": "List of blocked module version constraints.",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "patternProperties": {
+ "^.*$": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "version": {
+ "description": "Version constraint.",
+ "type": "string"
+ },
+ "reason": {
+ "description": "Reason why the version constraint exists.",
+ "type": "string"
+ }
+ },
+ "required": ["reason"]
+ }
+ }
+ }
+ },
+ "local_replace_directives": {
+ "description": "Raise lint issues if loading local path with replace directive",
+ "type": "boolean",
+ "default": true
+ }
+ }
+ }
+ }
+ },
+ "gosimple": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "checks": {
+ "type": "array",
+ "items": {
+ "anyOf": [
+ {
+ "enum": ["all"]
+ },
+ {
+ "type": "string"
+ }
+ ]
+ }
+ }
+ }
+ },
+ "gosec": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "includes": {
+ "type": "array",
+ "description": "To select a subset of rules to run",
+ "examples": [["G401"]],
+ "items": {
+ "$ref": "#/definitions/gosec-rules"
+ }
+ },
+ "excludes": {
+ "type": "array",
+ "description": "To specify a set of rules to explicitly exclude",
+ "examples": [["G401"]],
+ "items": {
+ "$ref": "#/definitions/gosec-rules"
+ }
+ },
+ "exclude-generated": {
+ "description": "Exclude generated files",
+ "type": "boolean",
+ "default": false
+ },
+ "severity": {
+ "description": "Filter out the issues with a lower severity than the given value",
+ "type": "string",
+ "enum": ["low", "medium", "high"],
+ "default": "low"
+ },
+ "confidence": {
+ "description": "Filter out the issues with a lower confidence than the given value",
+ "type": "string",
+ "enum": ["low", "medium", "high"],
+ "default": "low"
+ },
+ "config": {
+ "description": "To specify the configuration of rules",
+ "type": "object"
+ },
+ "concurrency": {
+ "description": "Concurrency value",
+ "type": "integer"
+ }
+ }
+ },
+ "gosmopolitan": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "allow-time-local": {
+ "description": "Allow and ignore `time.Local` usages.",
+ "type": "boolean",
+ "default": false
+ },
+ "escape-hatches": {
+ "description": "List of fully qualified names in the `full/pkg/path.name` form, to act as \"i18n escape hatches\".",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ignore-tests": {
+ "description": "Ignore test files.",
+ "type": "boolean",
+ "default": false
+ },
+ "watch-for-scripts": {
+ "description": "List of Unicode scripts to watch for any usage in string literals.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "govet": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "settings": {
+ "description": "Settings per analyzer. Map of analyzer name to specific settings.\nRun `go tool vet help` to find out more.",
+ "type": "object",
+ "propertyNames": {
+ "$ref": "#/definitions/govet-analyzers"
+ },
+ "patternProperties": {
+ "^.*$": {
+ "description": "Run `go tool vet help ` to see all settings.",
+ "type": "object"
+ }
+ }
+ },
+ "enable": {
+ "description": "Enable analyzers by name.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/govet-analyzers"
+ }
+ },
+ "disable": {
+ "description": "Disable analyzers by name.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/govet-analyzers"
+ }
+ },
+ "enable-all": {
+ "description": "Enable all analyzers.",
+ "type": "boolean",
+ "default": false
+ },
+ "disable-all": {
+ "description": "Disable all analyzers.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "grouper": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "const-require-single-const": {
+ "type": "boolean",
+ "default": false
+ },
+ "const-require-grouping": {
+ "type": "boolean",
+ "default": false
+ },
+ "import-require-single-import": {
+ "type": "boolean",
+ "default": false
+ },
+ "import-require-grouping": {
+ "type": "boolean",
+ "default": false
+ },
+ "type-require-single-type": {
+ "type": "boolean",
+ "default": false
+ },
+ "type-require-grouping": {
+ "type": "boolean",
+ "default": false
+ },
+ "var-require-single-var": {
+ "type": "boolean",
+ "default": false
+ },
+ "var-require-grouping": {
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "iface": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "enable": {
+ "description": "Enable analyzers by name.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/iface-analyzers"
+ }
+ },
+ "settings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "unused": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "exclude": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "importas": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "no-unaliased": {
+ "description": "Do not allow unaliased imports of aliased packages.",
+ "type": "boolean",
+ "default": false
+ },
+ "no-extra-aliases": {
+ "description": "Do not allow non-required aliases.",
+ "type": "boolean",
+ "default": false
+ },
+ "alias": {
+ "description": "List of aliases",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "pkg": {
+ "description": "Package path e.g. knative.dev/serving/pkg/apis/autoscaling/v1alpha1",
+ "type": "string"
+ },
+ "alias": {
+ "description": "Package alias e.g. autoscalingv1alpha1",
+ "type": "string"
+ }
+ },
+ "required": ["pkg", "alias"]
+ }
+ }
+ }
+ },
+ "inamedparam": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "skip-single-param": {
+ "description": "Skips check for interface methods with only a single parameter.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "ireturn": {
+ "type": "object",
+ "additionalProperties": false,
+ "description": "Use either `reject` or `allow` properties for interfaces matching.",
+ "properties": {
+ "allow": {
+ "type": "array",
+ "items": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "enum": ["anon", "error", "empty", "stdlib"]
+ }
+ ]
+ }
+ },
+ "reject": {
+ "type": "array",
+ "items": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "enum": ["anon", "error", "empty", "stdlib"]
+ }
+ ]
+ }
+ }
+ },
+ "anyOf": [
+ {
+ "not": {
+ "properties": {
+ "allow": {
+ "const": "reject"
+ }
+ }
+ },
+ "required": ["allow"]
+ },
+ {
+ "required": ["reject"]
+ }
+ ]
+ },
+ "lll": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "tab-width": {
+ "description": "Width of \"\\t\" in spaces.",
+ "type": "integer",
+ "minimum": 0,
+ "default": 1
+ },
+ "line-length": {
+ "description": "Maximum allowed line length, lines longer will be reported.",
+ "type": "integer",
+ "minimum": 1,
+ "default": 120
+ }
+ }
+ },
+ "maintidx": {
+ "description": "Maintainability index https://docs.microsoft.com/en-us/visualstudio/code-quality/code-metrics-maintainability-index-range-and-meaning?view=vs-2022",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "under": {
+ "description": "Minimum accatpable maintainability index level (see https://docs.microsoft.com/en-us/visualstudio/code-quality/code-metrics-maintainability-index-range-and-meaning?view=vs-2022)",
+ "type": "number",
+ "default": 20
+ }
+ }
+ },
+ "makezero": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "always": {
+ "description": "Allow only slices initialized with a length of zero.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "loggercheck": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "kitlog": {
+ "description": "Allow check for the github.com/go-kit/log library.",
+ "type": "boolean",
+ "default": true
+ },
+ "klog": {
+ "description": "Allow check for the k8s.io/klog/v2 library.",
+ "type": "boolean",
+ "default": true
+ },
+ "logr": {
+ "description": "Allow check for the github.com/go-logr/logr library.",
+ "type": "boolean",
+ "default": true
+ },
+ "zap": {
+ "description": "Allow check for the \"sugar logger\" from go.uber.org/zap library.",
+ "type": "boolean",
+ "default": true
+ },
+ "require-string-key": {
+ "description": "Require all logging keys to be inlined constant strings.",
+ "type": "boolean",
+ "default": false
+ },
+ "no-printf-like": {
+ "description": "Require printf-like format specifier (%s, %d for example) not present.",
+ "type": "boolean",
+ "default": false
+ },
+ "rules": {
+ "description": "List of custom rules to check against, where each rule is a single logger pattern, useful for wrapped loggers.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "misspell": {
+ "description": "Correct spellings using locale preferences for US or UK. Default is to use a neutral variety of English.",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "locale": {
+ "enum": ["US", "UK"]
+ },
+ "ignore-words": {
+ "description": "List of words to ignore.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "mode": {
+ "description": "Mode of the analysis.",
+ "enum": ["restricted", "", "default"],
+ "default": ""
+ },
+ "extra-words": {
+ "description": "Extra word corrections.",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "correction": {
+ "type": "string"
+ },
+ "typo": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ }
+ },
+ "musttag": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "functions": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "name": {
+ "type": "string"
+ },
+ "tag": {
+ "type": "string"
+ },
+ "arg-pos": {
+ "type": "integer"
+ }
+ }
+ }
+ }
+ }
+ },
+ "nakedret": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "max-func-lines": {
+ "description": "Report if a function has more lines of code than this value and it has naked returns.",
+ "type": "integer",
+ "minimum": 0,
+ "default": 30
+ }
+ }
+ },
+ "nestif": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "min-complexity": {
+ "description": "Minimum complexity of \"if\" statements to report.",
+ "type": "integer",
+ "default": 5
+ }
+ }
+ },
+ "nilnil": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "detect-opposite": {
+ "type": "boolean",
+ "description": "In addition, detect opposite situation (simultaneous return of non-nil error and valid value).",
+ "default": false
+ },
+ "checked-types": {
+ "type": "array",
+ "description": "List of return types to check.",
+ "items": {
+ "enum": ["chan", "func", "iface", "map", "ptr", "uintptr", "unsafeptr"]
+ },
+ "default": ["chan", "func", "iface", "map", "ptr", "uintptr", "unsafeptr"]
+ }
+ }
+ },
+ "nlreturn": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "block-size": {
+ "description": "set block size that is still ok",
+ "type": "number",
+ "default": 0,
+ "minimum": 0
+ }
+ }
+ },
+ "mnd": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "ignored-files": {
+ "description": "List of file patterns to exclude from analysis.",
+ "examples": [["magic1_.*.go"]],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ignored-functions": {
+ "description": "Comma-separated list of function patterns to exclude from the analysis.",
+ "examples": [["math.*", "http.StatusText", "make"]],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ignored-numbers": {
+ "description": "List of numbers to exclude from analysis.",
+ "examples": [["1000", "1234_567_890", "3.14159264"]],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "checks": {
+ "description": "The list of enabled checks, see https://github.com/tommy-muehle/go-mnd/#checks for description.",
+ "type": "array",
+ "items": {
+ "enum": [
+ "argument",
+ "case",
+ "condition",
+ "operation",
+ "return",
+ "assign"
+ ]
+ }
+ }
+ }
+ },
+ "nolintlint": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "allow-unused": {
+ "description": "Enable to ensure that nolint directives are all used.",
+ "type": "boolean",
+ "default": true
+ },
+ "allow-no-explanation": {
+ "description": "Exclude these linters from requiring an explanation.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/linters"
+ },
+ "default": []
+ },
+ "require-explanation": {
+ "description": "Enable to require an explanation of nonzero length after each nolint directive.",
+ "type": "boolean",
+ "default": false
+ },
+ "require-specific": {
+ "description": "Enable to require nolint directives to mention the specific linter being suppressed.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "reassign": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "patterns": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "nonamedreturns": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "report-error-in-defer": {
+ "description": "Report named error if it is assigned inside defer.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "paralleltest": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "ignore-missing": {
+ "description": "Ignore missing calls to `t.Parallel()` and only report incorrect uses of it.",
+ "type": "boolean",
+ "default": false
+ },
+ "ignore-missing-subtests": {
+ "description": "Ignore missing calls to `t.Parallel()` in subtests. Top-level tests are still required to have `t.Parallel`, but subtests are allowed to skip it.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "perfsprint": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "int-conversion": {
+ "description": "Optimizes even if it requires an int or uint type cast.",
+ "type": "boolean",
+ "default": true
+ },
+ "err-error": {
+ "description": "Optimizes into `err.Error()` even if it is only equivalent for non-nil errors.",
+ "type": "boolean",
+ "default": false
+ },
+ "errorf": {
+ "description": "Optimizes `fmt.Errorf`.",
+ "type": "boolean",
+ "default": true
+ },
+ "sprintf1": {
+ "description": "Optimizes `fmt.Sprintf` with only one argument.",
+ "type": "boolean",
+ "default": true
+ },
+ "strconcat": {
+ "description": "Optimizes into strings concatenation.",
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "prealloc": {
+ "description": "We do not recommend using this linter before doing performance profiling.\nFor most programs usage of `prealloc` will be premature optimization.",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "simple": {
+ "description": "Report preallocation suggestions only on simple loops that have no returns/breaks/continues/gotos in them.",
+ "type": "boolean",
+ "default": true
+ },
+ "range-loops": {
+ "description": "Report preallocation suggestions on range loops.",
+ "type": "boolean",
+ "default": true
+ },
+ "for-loops": {
+ "description": "Report preallocation suggestions on for loops.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "predeclared": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "ignore": {
+ "description": "Comma-separated list of predeclared identifiers to not report on.",
+ "type": "string"
+ },
+ "q": {
+ "description": "Include method names and field names (i.e., qualified names) in checks.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "promlinter": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "strict": {},
+ "disabled-linters": {
+ "type": "array",
+ "items": {
+ "enum": [
+ "Help",
+ "MetricUnits",
+ "Counter",
+ "HistogramSummaryReserved",
+ "MetricTypeInName",
+ "ReservedChars",
+ "CamelCase",
+ "UnitAbbreviations"
+ ]
+ }
+ }
+ }
+ },
+ "protogetter": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "skip-generated-by": {
+ "type": "array",
+ "items": {
+ "type": "string",
+ "examples": ["protoc-gen-go-my-own-generator"]
+ }
+ },
+ "skip-files": {
+ "type": "array",
+ "items": {
+ "type": "string",
+ "examples": ["*.pb.go"]
+ }
+ },
+ "skip-any-generated": {
+ "description": "Skip any generated files from the checking.",
+ "type": "boolean",
+ "default": false
+ },
+ "replace-first-arg-in-append": {
+ "description": "Skip first argument of append function.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "revive": {
+ "type": "object",
+ "additionalProperties": false,
+ "examples": [
+ {
+ "ignore-generated-header": true,
+ "severity": "warning",
+ "rules": [
+ {
+ "name": "indent-error-flow",
+ "severity": "warning"
+ },
+ {
+ "name": "add-constant",
+ "severity": "warning",
+ "arguments": [
+ {
+ "maxLitCount": "3",
+ "allowStrs": "\"\"",
+ "allowInts": "0,1,2",
+ "allowFloats": "0.0,0.,1.0,1.,2.0,2."
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ "properties": {
+ "max-open-files": {
+ "type": "integer"
+ },
+ "ignore-generated-header": {
+ "type": "boolean"
+ },
+ "confidence": {
+ "type": "number"
+ },
+ "severity": {
+ "type": "string",
+ "enum": ["warning", "error"]
+ },
+ "enable-all-rules": {
+ "type": "boolean",
+ "default": false
+ },
+ "directives": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "name": {
+ "type": "string",
+ "enum": ["specify-disable-reason"]
+ },
+ "severity": {
+ "type": "string",
+ "enum": ["warning", "error"]
+ },
+ "exclude": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "arguments": {
+ "type": "array"
+ }
+ }
+ }
+ },
+ "rules": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "required": ["name"],
+ "properties": {
+ "name": {
+ "$ref": "#/definitions/revive-rules",
+ "title": "The rule name"
+ },
+ "disabled": {
+ "type": "boolean"
+ },
+ "severity": {
+ "type": "string",
+ "enum": ["warning", "error"]
+ },
+ "exclude": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "arguments": {
+ "type": "array"
+ }
+ }
+ }
+ }
+ }
+ },
+ "rowserrcheck": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "packages": {
+ "type": "array",
+ "items": {
+ "description": "",
+ "type": "string",
+ "examples": ["github.com/jmoiron/sqlx"]
+ }
+ }
+ }
+ },
+ "sloglint": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "kv-only": {
+ "description": "Enforce using key-value pairs only (incompatible with attr-only).",
+ "type": "boolean",
+ "default": false
+ },
+ "no-global": {
+ "description": "Enforce not using global loggers.",
+ "enum": ["", "all", "default"],
+ "default": ""
+ },
+ "no-mixed-args": {
+ "description": "Enforce not mixing key-value pairs and attributes.",
+ "type": "boolean",
+ "default": true
+ },
+ "context": {
+ "description": "Enforce using methods that accept a context.",
+ "enum": ["", "all", "scope"],
+ "default": ""
+ },
+ "static-msg": {
+ "description": "Enforce using static values for log messages.",
+ "type": "boolean",
+ "default": false
+ },
+ "key-naming-case": {
+ "description": "Enforce a single key naming convention.",
+ "enum": ["snake", "kebab", "camel", "pascal"]
+ },
+ "attr-only": {
+ "description": "Enforce using attributes only (incompatible with kv-only).",
+ "type": "boolean",
+ "default": false
+ },
+ "no-raw-keys": {
+ "description": "Enforce using constants instead of raw keys.",
+ "type": "boolean",
+ "default": false
+ },
+ "forbidden-keys": {
+ "description": "Enforce not using specific keys.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "args-on-sep-lines": {
+ "description": "Enforce putting arguments on separate lines.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "spancheck": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "checks": {
+ "description": "Checks to enable.",
+ "type": "array",
+ "items": {
+ "enum": ["end", "record-error", "set-status"]
+ }
+ },
+ "ignore-check-signatures": {
+ "description": "A list of regexes for function signatures that silence `record-error` and `set-status` reports if found in the call path to a returned error.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "extra-start-span-signatures": {
+ "description": "A list of regexes for additional function signatures that create spans.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "staticcheck": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "checks": {
+ "type": "array",
+ "items": {
+ "anyOf": [
+ {
+ "enum": ["all"]
+ },
+ {
+ "type": "string"
+ }
+ ]
+ }
+ }
+ }
+ },
+ "stylecheck": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "checks": {
+ "type": "array",
+ "items": {
+ "anyOf": [
+ {
+ "enum": ["all"]
+ },
+ {
+ "type": "string"
+ }
+ ]
+ },
+ "default": [
+ "all",
+ "-ST1000",
+ "-ST1003",
+ "-ST1016",
+ "-ST1020",
+ "-ST1021",
+ "-ST1022"
+ ]
+ },
+ "dot-import-whitelist": {
+ "description": "By default, ST1001 forbids all uses of dot imports in non-test packages. This setting allows setting a whitelist of import paths that can be dot-imported anywhere.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "http-status-code-whitelist": {
+ "description": "ST1013 recommends using constants from the net/http package instead of hard-coding numeric HTTP status codes. This setting specifies a list of numeric status codes that this check does not complain about.",
+ "default": ["200", "400", "404", "500"],
+ "type": "array",
+ "items": {
+ "enum": [
+ "100",
+ "101",
+ "102",
+ "103",
+ "200",
+ "201",
+ "202",
+ "203",
+ "204",
+ "205",
+ "206",
+ "207",
+ "208",
+ "226",
+ "300",
+ "301",
+ "302",
+ "303",
+ "304",
+ "305",
+ "306",
+ "307",
+ "308",
+ "400",
+ "401",
+ "402",
+ "403",
+ "404",
+ "405",
+ "406",
+ "407",
+ "408",
+ "409",
+ "410",
+ "411",
+ "412",
+ "413",
+ "414",
+ "415",
+ "416",
+ "417",
+ "418",
+ "421",
+ "422",
+ "423",
+ "424",
+ "425",
+ "426",
+ "428",
+ "429",
+ "431",
+ "451",
+ "500",
+ "501",
+ "502",
+ "503",
+ "504",
+ "505",
+ "506",
+ "507",
+ "508",
+ "510",
+ "511"
+ ]
+ }
+ },
+ "initialisms": {
+ "description": "ST1003 check, among other things, for the correct capitalization of initialisms. The set of known initialisms can be configured with this option.",
+ "type": "array",
+ "items": {
+ "type": "string",
+ "default": [
+ "ACL",
+ "API",
+ "ASCII",
+ "CPU",
+ "CSS",
+ "DNS",
+ "EOF",
+ "GUID",
+ "HTML",
+ "HTTP",
+ "HTTPS",
+ "ID",
+ "IP",
+ "JSON",
+ "QPS",
+ "RAM",
+ "RPC",
+ "SLA",
+ "SMTP",
+ "SQL",
+ "SSH",
+ "TCP",
+ "TLS",
+ "TTL",
+ "UDP",
+ "UI",
+ "GID",
+ "UID",
+ "UUID",
+ "URI",
+ "URL",
+ "UTF8",
+ "VM",
+ "XML",
+ "XMPP",
+ "XSRF",
+ "XSS",
+ "SIP",
+ "RTP",
+ "AMQP",
+ "DB",
+ "TS"
+ ]
+ }
+ }
+ }
+ },
+ "tagalign": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "align": {
+ "description": "Align and sort can be used together or separately.",
+ "type": "boolean",
+ "default": true
+ },
+ "sort": {
+ "description": "Whether enable tags sort.",
+ "type": "boolean",
+ "default": true
+ },
+ "order": {
+ "description": "Specify the order of tags, the other tags will be sorted by name.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "default": [],
+ "examples": [
+ [
+ "json",
+ "yaml",
+ "yml",
+ "toml",
+ "mapstructure",
+ "binding",
+ "validate"
+ ]
+ ]
+ },
+ "strict": {
+ "description": "Whether enable strict style.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "tagliatelle": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "case": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "use-field-name": {
+ "description": "Use the struct field name to check the name of the struct tag.",
+ "type": "boolean",
+ "default": false
+ },
+ "rules": {
+ "type": "object",
+ "patternProperties": {
+ "^.+$": {
+ "enum": [
+ "camel",
+ "pascal",
+ "kebab",
+ "snake",
+ "goCamel",
+ "goPascal",
+ "goKebab",
+ "goSnake",
+ "upper",
+ "upperSnake",
+ "lower",
+ "header"
+ ]
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "tenv": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "all": {
+ "description": "The option `all` will run against whole test files (`_test.go`) regardless of method/function signatures.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "testifylint": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "enable-all": {
+ "description": "Enable all checkers.",
+ "type": "boolean",
+ "default": false
+ },
+ "disable-all": {
+ "description": "Disable all checkers.",
+ "type": "boolean",
+ "default": false
+ },
+ "enable": {
+ "description": "Enable specific checkers.",
+ "type": "array",
+ "items": {
+ "enum": [
+ "blank-import",
+ "bool-compare",
+ "compares",
+ "contains",
+ "empty",
+ "encoded-compare",
+ "error-is-as",
+ "error-nil",
+ "expected-actual",
+ "float-compare",
+ "formatter",
+ "go-require",
+ "len",
+ "negative-positive",
+ "nil-compare",
+ "regexp",
+ "require-error",
+ "suite-broken-parallel",
+ "suite-dont-use-pkg",
+ "suite-extra-assert-call",
+ "suite-subtest-run",
+ "suite-thelper",
+ "useless-assert"
+ ]
+ },
+ "default": [
+ "blank-import",
+ "bool-compare",
+ "compares",
+ "contains",
+ "empty",
+ "encoded-compare",
+ "error-is-as",
+ "error-nil",
+ "expected-actual",
+ "float-compare",
+ "formatter",
+ "go-require",
+ "len",
+ "negative-positive",
+ "nil-compare",
+ "regexp",
+ "require-error",
+ "suite-broken-parallel",
+ "suite-dont-use-pkg",
+ "suite-extra-assert-call",
+ "suite-subtest-run",
+ "useless-assert"
+ ]
+ },
+ "disable": {
+ "description": "Disable specific checkers.",
+ "type": "array",
+ "items": {
+ "enum": [
+ "blank-import",
+ "bool-compare",
+ "compares",
+ "contains",
+ "empty",
+ "encoded-compare",
+ "error-is-as",
+ "error-nil",
+ "expected-actual",
+ "float-compare",
+ "formatter",
+ "go-require",
+ "len",
+ "negative-positive",
+ "nil-compare",
+ "regexp",
+ "require-error",
+ "suite-broken-parallel",
+ "suite-dont-use-pkg",
+ "suite-extra-assert-call",
+ "suite-subtest-run",
+ "suite-thelper",
+ "useless-assert"
+ ],
+ "default": [
+ "suite-thelper"
+ ]
+ }
+ },
+ "bool-compare": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "ignore-custom-types": {
+ "description": "To ignore user defined types (over builtin bool).",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "expected-actual": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "pattern": {
+ "description": "Regexp for expected variable name.",
+ "type": "string",
+ "default": "(^(exp(ected)?|want(ed)?)([A-Z]\\w*)?$)|(^(\\w*[a-z])?(Exp(ected)?|Want(ed)?)$)"
+ }
+ }
+ },
+ "formatter": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "check-format-string": {
+ "description": "To enable go vet's printf checks.",
+ "type": "boolean",
+ "default": true
+ },
+ "require-f-funcs": {
+ "description": "To require f-assertions (e.g. assert.Equalf) if format string is used, even if there are no variable-length variables.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "go-require": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "ignore-http-handlers": {
+ "description": "To ignore HTTP handlers (like http.HandlerFunc).",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "require-error": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "fn-pattern": {
+ "description": "Regexp for assertions to analyze. If defined, then only matched error assertions will be reported.",
+ "type": "string",
+ "default": ""
+ }
+ }
+ },
+ "suite-extra-assert-call": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "mode": {
+ "description": "To require or remove extra Assert() call?",
+ "type": "string",
+ "enum": ["remove", "require"],
+ "default": "remove"
+ }
+ }
+ }
+ }
+ },
+ "testpackage": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "skip-regexp": {
+ "description": "Files with names matching this regular expression are skipped.",
+ "type": "string",
+ "examples": ["(export|internal)_test\\.go"]
+ },
+ "allow-packages": {
+ "description": "List of packages that don't end with _test that tests are allowed to be in.",
+ "type": "array",
+ "uniqueItems": true,
+ "items": {
+ "type": "string",
+ "examples": ["example"]
+ }
+ }
+ }
+ },
+ "thelper": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "test": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "begin": {
+ "description": "Check if `t.Helper()` begins helper function.",
+ "default": true,
+ "type": "boolean"
+ },
+ "first": {
+ "description": "Check if *testing.T is first param of helper function.",
+ "default": true,
+ "type": "boolean"
+ },
+ "name": {
+ "description": "Check if *testing.T param has t name.",
+ "default": true,
+ "type": "boolean"
+ }
+ }
+ },
+ "benchmark": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "begin": {
+ "description": "Check if `b.Helper()` begins helper function.",
+ "default": true,
+ "type": "boolean"
+ },
+ "first": {
+ "description": "Check if *testing.B is first param of helper function.",
+ "default": true,
+ "type": "boolean"
+ },
+ "name": {
+ "description": "Check if *testing.B param has b name.",
+ "default": true,
+ "type": "boolean"
+ }
+ }
+ },
+ "tb": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "begin": {
+ "description": "Check if `tb.Helper()` begins helper function.",
+ "default": true,
+ "type": "boolean"
+ },
+ "first": {
+ "description": "Check if *testing.TB is first param of helper function.",
+ "default": true,
+ "type": "boolean"
+ },
+ "name": {
+ "description": "Check if *testing.TB param has tb name.",
+ "default": true,
+ "type": "boolean"
+ }
+ }
+ },
+ "fuzz": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "begin": {
+ "description": "Check if `f.Helper()` begins helper function.",
+ "default": true,
+ "type": "boolean"
+ },
+ "first": {
+ "description": "Check if *testing.F is first param of helper function.",
+ "default": true,
+ "type": "boolean"
+ },
+ "name": {
+ "description": "Check if *testing.F param has f name.",
+ "default": true,
+ "type": "boolean"
+ }
+ }
+ }
+ }
+ },
+ "usestdlibvars": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "http-method": {
+ "description": "Suggest the use of http.MethodXX.",
+ "type": "boolean",
+ "default": true
+ },
+ "http-status-code": {
+ "description": "Suggest the use of http.StatusXX.",
+ "type": "boolean",
+ "default": true
+ },
+ "time-weekday": {
+ "description": "Suggest the use of time.Weekday.String().",
+ "type": "boolean",
+ "default": false
+ },
+ "time-month": {
+ "description": "Suggest the use of time.Month.String().",
+ "type": "boolean",
+ "default": false
+ },
+ "time-layout": {
+ "description": "Suggest the use of time.Layout.",
+ "type": "boolean",
+ "default": false
+ },
+ "crypto-hash": {
+ "description": "Suggest the use of crypto.Hash.String().",
+ "type": "boolean",
+ "default": false
+ },
+ "default-rpc-path": {
+ "description": "Suggest the use of rpc.DefaultXXPath.",
+ "type": "boolean",
+ "default": false
+ },
+ "sql-isolation-level": {
+ "description": "Suggest the use of sql.LevelXX.String().",
+ "type": "boolean",
+ "default": false
+ },
+ "tls-signature-scheme": {
+ "description": "Suggest the use of tls.SignatureScheme.String().",
+ "type": "boolean",
+ "default": false
+ },
+ "constant-kind": {
+ "description": "Suggest the use of constant.Kind.String().",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "unconvert": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "fast-math": {
+ "type": "boolean",
+ "default": false
+ },
+ "safe": {
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "unparam": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "check-exported": {
+ "description": "Inspect exported functions. Set to true if no external program/library imports your code.\n\nWARNING: if you enable this setting, unparam will report a lot of false-positives in text editors:\nif it's called for subdir of a project it can't find external interfaces. All text editor integrations\nwith golangci-lint call it on a directory with the changed file.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "unused": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "field-writes-are-uses": {
+ "description": "",
+ "type": "boolean",
+ "default": true
+ },
+ "post-statements-are-reads": {
+ "description": "",
+ "type": "boolean",
+ "default": false
+ },
+ "exported-fields-are-used": {
+ "description": "",
+ "type": "boolean",
+ "default": true
+ },
+ "parameters-are-used": {
+ "description": "",
+ "type": "boolean",
+ "default": true
+ },
+ "local-variables-are-used": {
+ "description": "",
+ "type": "boolean",
+ "default": true
+ },
+ "generated-is-used": {
+ "description": "",
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "varnamelen": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "max-distance": {
+ "description": "Variables used in at most this N-many lines will be ignored.",
+ "type": "integer",
+ "default": 5
+ },
+ "min-name-length": {
+ "description": "The minimum length of a variable's name that is considered `long`.",
+ "type": "integer",
+ "default": 3
+ },
+ "check-receiver": {
+ "description": "Check method receiver names.",
+ "default": false,
+ "type": "boolean"
+ },
+ "check-return": {
+ "description": "Check named return values.",
+ "default": false,
+ "type": "boolean"
+ },
+ "check-type-param": {
+ "description": "Check type parameters.",
+ "default": false,
+ "type": "boolean"
+ },
+ "ignore-type-assert-ok": {
+ "description": "Ignore `ok` variables that hold the bool return value of a type assertion",
+ "default": false,
+ "type": "boolean"
+ },
+ "ignore-map-index-ok": {
+ "description": "Ignore `ok` variables that hold the bool return value of a map index.",
+ "default": false,
+ "type": "boolean"
+ },
+ "ignore-chan-recv-ok": {
+ "description": "Ignore `ok` variables that hold the bool return value of a channel receive.",
+ "default": false,
+ "type": "boolean"
+ },
+ "ignore-names": {
+ "description": "Optional list of variable names that should be ignored completely.",
+ "default": [[]],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ignore-decls": {
+ "description": "Optional list of variable declarations that should be ignored completely.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "examples": [
+ ["c echo.Context", "t testing.T", "f *foo.Bar", "const C"]
+ ]
+ }
+ }
+ },
+ "whitespace": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "multi-if": {
+ "description": "Enforces newlines (or comments) after every multi-line if statement",
+ "type": "boolean",
+ "default": false
+ },
+ "multi-func": {
+ "description": "Enforces newlines (or comments) after every multi-line function signature",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "wrapcheck": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "ignoreSigs": {
+ "description": "An array of strings which specify substrings of signatures to ignore.",
+ "default": [
+ ".Errorf(",
+ "errors.New(",
+ "errors.Unwrap(",
+ ".Wrap(",
+ ".Wrapf(",
+ ".WithMessage(",
+ ".WithMessagef(",
+ ".WithStack("
+ ],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ignoreSigRegexps": {
+ "description": "An array of strings which specify regular expressions of signatures to ignore.",
+ "default": [""],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ignorePackageGlobs": {
+ "description": "An array of glob patterns which, if any match the package of the function returning the error, will skip wrapcheck analysis for this error.",
+ "default": [""],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ignoreInterfaceRegexps": {
+ "description": "An array of glob patterns which, if matched to an underlying interface name, will ignore unwrapped errors returned from a function whose call is defined on the given interface.",
+ "default": [""],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "wsl": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "allow-assign-and-anything": {
+ "description": "Controls if you may cuddle assignments and anything without needing an empty line between them.",
+ "type": "boolean",
+ "default": false
+ },
+ "allow-assign-and-call": {
+ "description": "Allow calls and assignments to be cuddled as long as the lines have any matching variables, fields or types.",
+ "type": "boolean",
+ "default": true
+ },
+ "allow-cuddle-declarations": {
+ "description": "Allow declarations (var) to be cuddled.",
+ "type": "boolean",
+ "default": false
+ },
+ "allow-cuddle-with-calls": {
+ "description": "A list of call idents that everything can be cuddled with.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "allow-cuddle-with-rhs": {
+ "description": "AllowCuddleWithRHS is a list of right hand side variables that is allowed to be cuddled with anything.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "allow-multiline-assign": {
+ "description": "Allow multiline assignments to be cuddled.",
+ "type": "boolean",
+ "default": true
+ },
+ "allow-separated-leading-comment": {
+ "description": "Allow leading comments to be separated with empty lines.",
+ "type": "boolean",
+ "default": false
+ },
+ "allow-trailing-comment": {
+ "description": "Allow trailing comments in ending of blocks.",
+ "type": "boolean",
+ "default": false
+ },
+ "error-variable-names": {
+ "description": "When force-err-cuddling is enabled this is a list of names used for error variables to check for in the conditional.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "force-case-trailing-whitespace": {
+ "description": "Force newlines in end of case at this limit (0 = never).",
+ "type": "integer",
+ "minimum": 0,
+ "default": 0
+ },
+ "force-err-cuddling": {
+ "description": "Causes an error when an If statement that checks an error variable doesn't cuddle with the assignment of that variable.",
+ "type": "boolean",
+ "default": false
+ },
+ "force-short-decl-cuddling": {
+ "description": "Causes an error if a short declaration (:=) cuddles with anything other than another short declaration.",
+ "type": "boolean",
+ "default": false
+ },
+ "strict-append": {
+ "description": "If true, append is only allowed to be cuddled if appending value is matching variables, fields or types on line above.",
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "copyloopvar": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "check-alias": {
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "custom": {
+ "description": "The custom section can be used to define linter plugins to be loaded at runtime. See README of golangci-lint for more information.\nEach custom linter should have a unique name.",
+ "type": "object",
+ "patternProperties": {
+ "^.*$": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "type": {
+ "description": "The plugin type.",
+ "enum": ["module", "goplugin"],
+ "default": "goplugin"
+ },
+ "path": {
+ "description": "The path to the plugin *.so. Can be absolute or local.",
+ "type": "string",
+ "examples": ["/path/to/example.so"]
+ },
+ "description": {
+ "description": "The description of the linter, for documentation purposes only.",
+ "type": "string"
+ },
+ "original-url": {
+ "description": "Intended to point to the repo location of the linter, for documentation purposes only.",
+ "type": "string"
+ },
+ "settings": {
+ "description": "Plugins settings/configuration. Only work with plugin based on `linterdb.PluginConstructor`.",
+ "type": "object"
+ }
+ },
+ "oneOf": [
+ {
+ "properties": {
+ "type": {"enum": ["module"] }
+ },
+ "required": ["type"]
+ },
+ {
+ "required": ["path"]
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
+ "linters": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "enable": {
+ "description": "List of enabled linters.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/linters"
+ }
+ },
+ "disable": {
+ "description": "List of disabled linters.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/linters"
+ }
+ },
+ "enable-all": {
+ "description": "Whether to enable all linters. You can re-disable them with `disable` explicitly.",
+ "type": "boolean",
+ "default": false
+ },
+ "disable-all": {
+ "description": "Whether to disable all linters. You can re-enable them with `enable` explicitly.",
+ "type": "boolean",
+ "default": false
+ },
+ "presets": {
+ "description": "Allow to use different presets of linters",
+ "type": "array",
+ "items": {
+ "enum": [
+ "bugs",
+ "comment",
+ "complexity",
+ "error",
+ "format",
+ "import",
+ "metalinter",
+ "module",
+ "performance",
+ "sql",
+ "style",
+ "test",
+ "unused"
+ ]
+ }
+ },
+ "fast": {
+ "description": "Enable run of fast linters.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "issues": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "exclude": {
+ "description": "List of regular expressions of issue texts to exclude.\nBut independently from this option we use default exclude patterns. Their usage can be controlled through `exclude-use-default`.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "exclude-rules": {
+ "description": "Exclude configuration per-path, per-linter, per-text and per-source",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "path": {
+ "type": "string"
+ },
+ "path-except": {
+ "type": "string"
+ },
+ "linters": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/linters"
+ }
+ },
+ "text": {
+ "type": "string"
+ },
+ "source": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "exclude-use-default": {
+ "description": "Independently from option `exclude` we use default exclude patterns. This behavior can be disabled by this option.",
+ "type": "boolean",
+ "default": true
+ },
+ "exclude-case-sensitive": {
+ "description": "If set to true, exclude and exclude-rules regular expressions become case sensitive.",
+ "type": "boolean",
+ "default": false
+ },
+ "exclude-generated": {
+ "description": "Mode of the generated files analysis.",
+ "enum": ["lax", "strict", "disable"],
+ "default": "lax"
+ },
+ "exclude-dirs": {
+ "description": "Which directories to exclude: issues from them won't be reported.",
+ "type": "array",
+ "items": {
+ "description": "You can use regexp here. The regexp is applied on the full path.\n\"/\" will be replaced by current OS file path separator to properly work on Windows.",
+ "type": "string",
+ "examples": ["generated.*"]
+ },
+ "default": [],
+ "examples": [["src/external_libs", "autogenerated_by_my_lib"]]
+ },
+ "exclude-dirs-use-default": {
+ "description": "Enable exclusion of directories \"vendor\", \"third_party\", \"testdata\", \"examples\", \"Godeps\", and \"builtin\".",
+ "type": "boolean",
+ "default": true
+ },
+ "exclude-files": {
+ "description": "Which files to exclude: they will be analyzed, but issues from them will not be reported.",
+ "type": "array",
+ "items": {
+ "description": "You can use regexp here. There is no need to include all autogenerated files, we confidently recognize them. If that is not the case, please let us know.\n\"/\" will be replaced by current OS file path separator to properly work on Windows.",
+ "type": "string",
+ "examples": [".*\\.my\\.go$"]
+ },
+ "default": [],
+ "examples": [[".*\\.my\\.go$", "lib/bad.go"]]
+ },
+ "include": {
+ "description": "The list of ids of default excludes to include or disable.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "default": []
+ },
+ "max-issues-per-linter": {
+ "description": "Maximum issues count per one linter. Set to 0 to disable.",
+ "type": "integer",
+ "default": 50,
+ "minimum": 0
+ },
+ "max-same-issues": {
+ "description": "Maximum count of issues with the same text. Set to 0 to disable.",
+ "type": "integer",
+ "default": 3,
+ "minimum": 0
+ },
+ "new": {
+ "description": "Show only new issues: if there are unstaged changes or untracked files, only those changes are analyzed, else only changes in HEAD~ are analyzed.",
+ "type": "boolean",
+ "default": false
+ },
+ "new-from-rev": {
+ "description": "Show only new issues created after this git revision.",
+ "type": "string"
+ },
+ "new-from-patch": {
+ "description": "Show only new issues created in git patch with this file path.",
+ "type": "string",
+ "examples": ["path/to/patch/file"]
+ },
+ "fix": {
+ "description": "Fix found issues (if it's supported by the linter).",
+ "type": "boolean",
+ "default": false
+ },
+ "whole-files": {
+ "description": "Show issues in any part of update files (requires new-from-rev or new-from-patch).",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "severity": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "default-severity": {
+ "description": "Set the default severity for issues. If severity rules are defined and the issues do not match or no severity is provided to the rule this will be the default severity applied. Severities should match the supported severity names of the selected out format.",
+ "type": "string",
+ "default": ""
+ },
+ "case-sensitive": {
+ "description": "If set to true, severity-rules regular expressions become case sensitive.",
+ "type": "boolean",
+ "default": false
+ },
+ "rules": {
+ "description": "When a list of severity rules are provided, severity information will be added to lint issues. Severity rules have the same filtering capability as exclude rules except you are allowed to specify one matcher per severity rule.\nOnly affects out formats that support setting severity information.",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "severity": {
+ "type": "string"
+ },
+ "path": {
+ "type": "string"
+ },
+ "path-except": {
+ "type": "string"
+ },
+ "linters": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/linters"
+ }
+ },
+ "text": {
+ "type": "string"
+ },
+ "source": {
+ "type": "string"
+ }
+ },
+ "required": ["severity"],
+ "anyOf": [
+ { "required": ["path"] },
+ { "required": ["path-except"] },
+ { "required": ["linters"] },
+ { "required": ["text"] },
+ { "required": ["source"] }
+ ]
+ },
+ "default": []
+ }
+ },
+ "required": ["default-severity"]
+ }
+ }
+}
diff --git a/vendor/github.com/golangci/golangci-lint/v2/jsonschema/golangci.v1.63.jsonschema.json b/vendor/github.com/golangci/golangci-lint/v2/jsonschema/golangci.v1.63.jsonschema.json
new file mode 100644
index 0000000000..c54dd6904d
--- /dev/null
+++ b/vendor/github.com/golangci/golangci-lint/v2/jsonschema/golangci.v1.63.jsonschema.json
@@ -0,0 +1,4082 @@
+{
+ "$schema": "http://json-schema.org/draft-07/schema#",
+ "$id": "https://json.schemastore.org/golangci-lint.json",
+ "definitions": {
+ "gocritic-checks": {
+ "enum": [
+ "appendAssign",
+ "appendCombine",
+ "argOrder",
+ "assignOp",
+ "badCall",
+ "badCond",
+ "badLock",
+ "badRegexp",
+ "badSorting",
+ "badSyncOnceFunc",
+ "boolExprSimplify",
+ "builtinShadow",
+ "builtinShadowDecl",
+ "captLocal",
+ "caseOrder",
+ "codegenComment",
+ "commentFormatting",
+ "commentedOutCode",
+ "commentedOutImport",
+ "defaultCaseOrder",
+ "deferInLoop",
+ "deferUnlambda",
+ "deprecatedComment",
+ "docStub",
+ "dupArg",
+ "dupBranchBody",
+ "dupCase",
+ "dupImport",
+ "dupSubExpr",
+ "dynamicFmtString",
+ "elseif",
+ "emptyDecl",
+ "emptyFallthrough",
+ "emptyStringTest",
+ "equalFold",
+ "evalOrder",
+ "exitAfterDefer",
+ "exposedSyncMutex",
+ "externalErrorReassign",
+ "filepathJoin",
+ "flagDeref",
+ "flagName",
+ "hexLiteral",
+ "httpNoBody",
+ "hugeParam",
+ "ifElseChain",
+ "importShadow",
+ "indexAlloc",
+ "initClause",
+ "ioutilDeprecated",
+ "mapKey",
+ "methodExprCall",
+ "nestingReduce",
+ "newDeref",
+ "nilValReturn",
+ "octalLiteral",
+ "offBy1",
+ "paramTypeCombine",
+ "preferDecodeRune",
+ "preferFilepathJoin",
+ "preferFprint",
+ "preferStringWriter",
+ "preferWriteByte",
+ "ptrToRefParam",
+ "rangeAppendAll",
+ "rangeExprCopy",
+ "rangeValCopy",
+ "redundantSprint",
+ "regexpMust",
+ "regexpPattern",
+ "regexpSimplify",
+ "returnAfterHttpError",
+ "ruleguard",
+ "singleCaseSwitch",
+ "sliceClear",
+ "sloppyLen",
+ "sloppyReassign",
+ "sloppyTypeAssert",
+ "sortSlice",
+ "sprintfQuotedString",
+ "sqlQuery",
+ "stringConcatSimplify",
+ "stringXbytes",
+ "stringsCompare",
+ "switchTrue",
+ "syncMapLoadAndDelete",
+ "timeExprSimplify",
+ "todoCommentWithoutDetail",
+ "tooManyResultsChecker",
+ "truncateCmp",
+ "typeAssertChain",
+ "typeDefFirst",
+ "typeSwitchVar",
+ "typeUnparen",
+ "uncheckedInlineErr",
+ "underef",
+ "unlabelStmt",
+ "unlambda",
+ "unnamedResult",
+ "unnecessaryBlock",
+ "unnecessaryDefer",
+ "unslice",
+ "valSwap",
+ "weakCond",
+ "whyNoLint",
+ "wrapperFunc",
+ "yodaStyleExpr"
+ ]
+ },
+ "gocritic-tags": {
+ "enum": [
+ "diagnostic",
+ "style",
+ "performance",
+ "experimental",
+ "opinionated",
+ "security"
+ ]
+ },
+ "gosec-rules": {
+ "enum": [
+ "G101",
+ "G102",
+ "G103",
+ "G104",
+ "G106",
+ "G107",
+ "G108",
+ "G109",
+ "G110",
+ "G111",
+ "G112",
+ "G113",
+ "G114",
+ "G115",
+ "G201",
+ "G202",
+ "G203",
+ "G204",
+ "G301",
+ "G302",
+ "G303",
+ "G304",
+ "G305",
+ "G306",
+ "G307",
+ "G401",
+ "G402",
+ "G403",
+ "G404",
+ "G405",
+ "G406",
+ "G501",
+ "G502",
+ "G503",
+ "G504",
+ "G505",
+ "G506",
+ "G507",
+ "G601",
+ "G602"
+ ]
+ },
+ "govet-analyzers": {
+ "enum": [
+ "appends",
+ "asmdecl",
+ "assign",
+ "atomic",
+ "atomicalign",
+ "bools",
+ "buildtag",
+ "cgocall",
+ "composites",
+ "copylocks",
+ "deepequalerrors",
+ "defers",
+ "directive",
+ "errorsas",
+ "fieldalignment",
+ "findcall",
+ "framepointer",
+ "httpresponse",
+ "ifaceassert",
+ "loopclosure",
+ "lostcancel",
+ "nilfunc",
+ "nilness",
+ "printf",
+ "reflectvaluecompare",
+ "shadow",
+ "shift",
+ "sigchanyzer",
+ "slog",
+ "sortslice",
+ "stdmethods",
+ "stdversion",
+ "stringintconv",
+ "structtag",
+ "testinggoroutine",
+ "tests",
+ "timeformat",
+ "unmarshal",
+ "unreachable",
+ "unsafeptr",
+ "unusedresult",
+ "unusedwrite",
+ "waitgroup"
+ ]
+ },
+ "revive-rules": {
+ "enum": [
+ "add-constant",
+ "argument-limit",
+ "atomic",
+ "banned-characters",
+ "bare-return",
+ "blank-imports",
+ "bool-literal-in-expr",
+ "call-to-gc",
+ "cognitive-complexity",
+ "comment-spacings",
+ "comments-density",
+ "confusing-naming",
+ "confusing-results",
+ "constant-logical-expr",
+ "context-as-argument",
+ "context-keys-type",
+ "cyclomatic",
+ "datarace",
+ "deep-exit",
+ "defer",
+ "dot-imports",
+ "duplicated-imports",
+ "early-return",
+ "empty-block",
+ "empty-lines",
+ "enforce-map-style",
+ "enforce-repeated-arg-type-style",
+ "enforce-slice-style",
+ "error-naming",
+ "error-return",
+ "error-strings",
+ "errorf",
+ "exported",
+ "file-header",
+ "file-length-limit",
+ "filename-format",
+ "flag-parameter",
+ "function-length",
+ "function-result-limit",
+ "get-return",
+ "identical-branches",
+ "if-return",
+ "import-alias-naming",
+ "import-shadowing",
+ "imports-blocklist",
+ "increment-decrement",
+ "indent-error-flow",
+ "line-length-limit",
+ "max-control-nesting",
+ "max-public-structs",
+ "modifies-parameter",
+ "modifies-value-receiver",
+ "nested-structs",
+ "optimize-operands-order",
+ "package-comments",
+ "range",
+ "range-val-address",
+ "range-val-in-closure",
+ "receiver-naming",
+ "redefines-builtin-id",
+ "redundant-import-alias",
+ "string-format",
+ "string-of-int",
+ "struct-tag",
+ "superfluous-else",
+ "time-equal",
+ "time-naming",
+ "unchecked-type-assertion",
+ "unconditional-recursion",
+ "unexported-naming",
+ "unexported-return",
+ "unhandled-error",
+ "unnecessary-stmt",
+ "unreachable-code",
+ "unused-parameter",
+ "unused-receiver",
+ "use-any",
+ "useless-break",
+ "var-declaration",
+ "var-naming",
+ "waitgroup-by-value"
+ ]
+ },
+ "iface-analyzers": {
+ "enum": [
+ "identical",
+ "unused",
+ "opaque"
+ ]
+ },
+ "tagliatelle-cases": {
+ "enum": [
+ "camel",
+ "pascal",
+ "kebab",
+ "snake",
+ "goCamel",
+ "goPascal",
+ "goKebab",
+ "goSnake",
+ "upper",
+ "upperSnake",
+ "lower",
+ "header"
+ ]
+ },
+ "linters": {
+ "$comment": "anyOf with enum is used to allow auto completion of non-custom linters",
+ "description": "Linters usable.",
+ "anyOf": [
+ {
+ "enum": [
+ "asasalint",
+ "asciicheck",
+ "bidichk",
+ "bodyclose",
+ "canonicalheader",
+ "containedctx",
+ "contextcheck",
+ "copyloopvar",
+ "cyclop",
+ "decorder",
+ "depguard",
+ "dogsled",
+ "dupl",
+ "dupword",
+ "durationcheck",
+ "errcheck",
+ "errchkjson",
+ "errname",
+ "errorlint",
+ "exhaustive",
+ "exhaustruct",
+ "exportloopref",
+ "exptostd",
+ "fatcontext",
+ "forbidigo",
+ "forcetypeassert",
+ "funlen",
+ "gci",
+ "ginkgolinter",
+ "gocheckcompilerdirectives",
+ "gochecknoglobals",
+ "gochecknoinits",
+ "gochecksumtype",
+ "gocognit",
+ "goconst",
+ "gocritic",
+ "gocyclo",
+ "godot",
+ "godox",
+ "err113",
+ "gofmt",
+ "gofumpt",
+ "goheader",
+ "goimports",
+ "gomoddirectives",
+ "gomodguard",
+ "goprintffuncname",
+ "gosec",
+ "gosimple",
+ "gosmopolitan",
+ "govet",
+ "grouper",
+ "iface",
+ "importas",
+ "inamedparam",
+ "ineffassign",
+ "interfacebloat",
+ "intrange",
+ "ireturn",
+ "lll",
+ "loggercheck",
+ "maintidx",
+ "makezero",
+ "mirror",
+ "misspell",
+ "mnd",
+ "musttag",
+ "nakedret",
+ "nestif",
+ "nilerr",
+ "nilnesserr",
+ "nilnil",
+ "nlreturn",
+ "noctx",
+ "nolintlint",
+ "nonamedreturns",
+ "nosprintfhostport",
+ "paralleltest",
+ "perfsprint",
+ "prealloc",
+ "predeclared",
+ "promlinter",
+ "protogetter",
+ "reassign",
+ "recvcheck",
+ "revive",
+ "rowserrcheck",
+ "sloglint",
+ "sqlclosecheck",
+ "staticcheck",
+ "stylecheck",
+ "tagalign",
+ "tagliatelle",
+ "tenv",
+ "testableexamples",
+ "testifylint",
+ "testpackage",
+ "thelper",
+ "tparallel",
+ "unconvert",
+ "unparam",
+ "unused",
+ "usestdlibvars",
+ "usetesting",
+ "varnamelen",
+ "wastedassign",
+ "whitespace",
+ "wrapcheck",
+ "wsl",
+ "zerologlint"
+ ]
+ },
+ {
+ "type": "string"
+ }
+ ]
+ }
+ },
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "run": {
+ "description": "Options for analysis running,",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "concurrency": {
+ "description": "Number of concurrent runners. Defaults to the number of available CPU cores.",
+ "type": "integer",
+ "minimum": 0,
+ "examples": [4]
+ },
+ "timeout": {
+ "description": "Timeout for the analysis.",
+ "type": "string",
+ "pattern": "^((\\d+h)?(\\d+m)?(\\d+(?:\\.\\d)?s)?|0)$",
+ "default": "1m",
+ "examples": ["30s", "5m", "5m30s"]
+ },
+ "issues-exit-code": {
+ "description": "Exit code when at least one issue was found.",
+ "type": "integer",
+ "default": 1
+ },
+ "tests": {
+ "description": "Enable inclusion of test files.",
+ "type": "boolean",
+ "default": true
+ },
+ "build-tags": {
+ "description": "List of build tags to pass to all linters.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "default": [],
+ "examples": [["mytag"]]
+ },
+ "modules-download-mode": {
+ "description": "Option to pass to \"go list -mod={option}\".\nSee \"go help modules\" for more information.",
+ "enum": ["mod", "readonly", "vendor"]
+ },
+ "allow-parallel-runners": {
+ "description": "Allow multiple parallel golangci-lint instances running. If disabled, golangci-lint acquires file lock on start.",
+ "type": "boolean",
+ "default": false
+ },
+ "allow-serial-runners": {
+ "description": "Allow multiple golangci-lint instances running, but serialize them around a lock.",
+ "type": "boolean",
+ "default": false
+ },
+ "go": {
+ "description": "Targeted Go version.",
+ "type": "string",
+ "default": "1.17"
+ }
+ }
+ },
+ "output": {
+ "description": "Output configuration options.",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "formats": {
+ "description": "Output formats to use.",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "path": {
+ "default": "stdout",
+ "anyOf": [
+ {
+ "enum": [ "stdout", "stderr" ]
+ },
+ {
+ "type": "string"
+ }
+ ]
+ },
+ "format": {
+ "default": "colored-line-number",
+ "enum": [
+ "colored-line-number",
+ "line-number",
+ "json",
+ "colored-tab",
+ "tab",
+ "html",
+ "checkstyle",
+ "code-climate",
+ "junit-xml",
+ "junit-xml-extended",
+ "github-actions",
+ "teamcity",
+ "sarif"
+ ]
+ }
+ },
+ "required": ["format"]
+ }
+ },
+ "print-issued-lines": {
+ "description": "Print lines of code with issue.",
+ "type": "boolean",
+ "default": true
+ },
+ "print-linter-name": {
+ "description": "Print linter name in the end of issue text.",
+ "type": "boolean",
+ "default": true
+ },
+ "path-prefix": {
+ "description": "Add a prefix to the output file references.",
+ "type": "string",
+ "default": ""
+ },
+ "show-stats": {
+ "description": "Show statistics per linter.",
+ "type": "boolean",
+ "default": false
+ },
+ "sort-order": {
+ "type": "array",
+ "items": {
+ "enum": ["linter", "severity", "file"]
+ }
+ },
+ "sort-results": {
+ "description": "Sort results by: filepath, line and column.",
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "linters-settings": {
+ "description": "All available settings of specific linters.",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "dupword": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "keywords": {
+ "description": "Keywords for detecting duplicate words. If this list is not empty, only the words defined in this list will be detected.",
+ "type": "array",
+ "uniqueItems": true,
+ "items": {
+ "type": "string",
+ "examples": ["the", "and", "a"]
+ }
+ },
+ "ignore": {
+ "description": "Keywords used to ignore detection.",
+ "type": "array",
+ "uniqueItems": true,
+ "items": {
+ "type": "string",
+ "examples": ["0C0C"]
+ }
+ }
+ }
+ },
+ "asasalint": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "exclude": {
+ "description": "To specify a set of function names to exclude.",
+ "type": "array",
+ "uniqueItems": true,
+ "items": {
+ "type": "string",
+ "examples": ["\\.Wrapf"]
+ }
+ },
+ "use-builtin-exclusions": {
+ "description": "To enable/disable the asasalint builtin exclusions of function names.",
+ "type": "boolean",
+ "default": true
+ },
+ "ignore-test": {
+ "description": "Ignore *_test.go files.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "bidichk": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "left-to-right-embedding": {
+ "description": "Disallow: LEFT-TO-RIGHT-EMBEDDING",
+ "type": "boolean",
+ "default": false
+ },
+ "right-to-left-embedding": {
+ "description": "Disallow: RIGHT-TO-LEFT-EMBEDDING",
+ "type": "boolean",
+ "default": false
+ },
+ "pop-directional-formatting": {
+ "description": "Disallow: POP-DIRECTIONAL-FORMATTING",
+ "type": "boolean",
+ "default": false
+ },
+ "left-to-right-override": {
+ "description": "Disallow: LEFT-TO-RIGHT-OVERRIDE",
+ "type": "boolean",
+ "default": false
+ },
+ "right-to-left-override": {
+ "description": "Disallow: RIGHT-TO-LEFT-OVERRIDE",
+ "type": "boolean",
+ "default": false
+ },
+ "left-to-right-isolate": {
+ "description": "Disallow: LEFT-TO-RIGHT-ISOLATE",
+ "type": "boolean",
+ "default": false
+ },
+ "right-to-left-isolate": {
+ "description": "Disallow: RIGHT-TO-LEFT-ISOLATE",
+ "type": "boolean",
+ "default": false
+ },
+ "first-strong-isolate": {
+ "description": "Disallow: FIRST-STRONG-ISOLATE",
+ "type": "boolean",
+ "default": false
+ },
+ "pop-directional-isolate": {
+ "description": "Disallow: POP-DIRECTIONAL-ISOLATE",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "cyclop": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "skip-tests": {
+ "description": "Should the linter execute on test files as well",
+ "type": "boolean",
+ "default": false
+ },
+ "max-complexity": {
+ "description": "Max complexity the function can have",
+ "type": "integer",
+ "default": 10,
+ "minimum": 0
+ },
+ "package-average": {
+ "description": "Max average complexity in package",
+ "type": "number",
+ "default": 0,
+ "minimum": 0
+ }
+ }
+ },
+ "decorder": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "dec-order": {
+ "type": "array",
+ "default": [["type", "const", "var", "func"]],
+ "items": {
+ "enum": ["type", "const", "var", "func"]
+ }
+ },
+ "ignore-underscore-vars": {
+ "description": "Underscore vars (vars with \"_\" as the name) will be ignored at all checks",
+ "default": true,
+ "type": "boolean"
+ },
+ "disable-dec-order-check": {
+ "description": "Order of declarations is not checked",
+ "default": true,
+ "type": "boolean"
+ },
+ "disable-init-func-first-check": {
+ "description": "Allow init func to be anywhere in file",
+ "default": true,
+ "type": "boolean"
+ },
+ "disable-dec-num-check": {
+ "description": "Multiple global type, const and var declarations are allowed",
+ "default": true,
+ "type": "boolean"
+ },
+ "disable-type-dec-num-check": {
+ "description": "Type declarations will be ignored for dec num check",
+ "default": true,
+ "type": "boolean"
+ },
+ "disable-const-dec-num-check": {
+ "description": "Const declarations will be ignored for dec num check",
+ "default": true,
+ "type": "boolean"
+ },
+ "disable-var-dec-num-check": {
+ "description": "Var declarations will be ignored for dec num check",
+ "default": true,
+ "type": "boolean"
+ }
+ }
+ },
+ "depguard": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "rules": {
+ "description": "Rules to apply.",
+ "type": "object",
+ "additionalProperties": false,
+ "patternProperties": {
+ "^[^.]+$": {
+ "description": "Name of a rule.",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "list-mode": {
+ "description": "Used to determine the package matching priority.",
+ "enum": ["original", "strict", "lax"],
+ "default": "original"
+ },
+ "files": {
+ "description": "List of file globs that will match this list of settings to compare against.",
+ "additionalProperties": false,
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "allow": {
+ "description": "List of allowed packages.",
+ "additionalProperties": false,
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "deny": {
+ "description": "Packages that are not allowed where the value is a suggestion.",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "desc": {
+ "description": "Description",
+ "type": "string"
+ },
+ "pkg": {
+ "description": "Package",
+ "type": "string"
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "dogsled": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "max-blank-identifiers": {
+ "description": "Check assignments with too many blank identifiers.",
+ "type": "integer",
+ "default": 2,
+ "minimum": 0
+ }
+ }
+ },
+ "dupl": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "threshold": {
+ "description": "Tokens count to trigger issue.",
+ "type": "integer",
+ "default": 150,
+ "minimum": 0
+ }
+ }
+ },
+ "errcheck": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "check-type-assertions": {
+ "description": "Report about not checking errors in type assertions, i.e.: `a := b.(MyStruct)`",
+ "type": "boolean",
+ "default": false
+ },
+ "check-blank": {
+ "description": "Report about assignment of errors to blank identifier",
+ "type": "boolean",
+ "default": false
+ },
+ "exclude-functions": {
+ "description": "List of functions to exclude from checking, where each entry is a single function to exclude",
+ "type": "array",
+ "examples": ["io/ioutil.ReadFile", "io.Copy(*bytes.Buffer)"],
+ "items": {
+ "type": "string"
+ }
+ },
+ "disable-default-exclusions": {
+ "description": "To disable the errcheck built-in exclude list",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "errchkjson": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "check-error-free-encoding": {
+ "type": "boolean",
+ "default": false
+ },
+ "report-no-exported": {
+ "description": "Issue on struct that doesn't have exported fields.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "errorlint": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "errorf": {
+ "description": "Check whether fmt.Errorf uses the %w verb for formatting errors",
+ "type": "boolean",
+ "default": true
+ },
+ "errorf-multi": {
+ "description": "Permit more than 1 %w verb, valid per Go 1.20",
+ "type": "boolean",
+ "default": true
+ },
+ "asserts": {
+ "description": "Check for plain type assertions and type switches.",
+ "type": "boolean",
+ "default": true
+ },
+ "comparison": {
+ "description": "Check for plain error comparisons",
+ "type": "boolean",
+ "default": true
+ },
+ "allowed-errors": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "err": {
+ "type": "string"
+ },
+ "fun": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "allowed-errors-wildcard": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "err": {
+ "type": "string"
+ },
+ "fun": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ }
+ },
+ "exhaustive": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "check": {
+ "description": "Program elements to check for exhaustiveness.",
+ "type": "array",
+ "uniqueItems": true,
+ "items": {
+ "type": "string",
+ "examples": ["switch", "map"]
+ }
+ },
+ "check-generated": {
+ "description": "Check switch statements in generated files",
+ "type": "boolean",
+ "default": false
+ },
+ "explicit-exhaustive-switch": {
+ "description": "Only run exhaustive check on switches with \"//exhaustive:enforce\" comment.",
+ "type": "boolean",
+ "default": false
+ },
+ "explicit-exhaustive-map": {
+ "description": "Only run exhaustive check on map literals with \"//exhaustive:enforce\" comment.",
+ "type": "boolean",
+ "default": false
+ },
+ "default-case-required": {
+ "description": "Switch statement requires default case even if exhaustive.",
+ "type": "boolean",
+ "default": false
+ },
+ "default-signifies-exhaustive": {
+ "description": "Presence of `default` case in switch statements satisfies exhaustiveness, even if all enum members are not listed.",
+ "type": "boolean",
+ "default": false
+ },
+ "ignore-enum-members": {
+ "description": "Enum members matching `regex` do not have to be listed in switch statements to satisfy exhaustiveness",
+ "type": "string"
+ },
+ "ignore-enum-types": {
+ "description": "Enum types matching the supplied regex do not have to be listed in switch statements to satisfy exhaustiveness.",
+ "type": "string"
+ },
+ "package-scope-only": {
+ "description": "Consider enums only in package scopes, not in inner scopes.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "exhaustruct": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "include": {
+ "description": "List of regular expressions to match struct packages and names.",
+ "type": "array",
+ "examples": [".*\\.Test"],
+ "items": {
+ "type": "string"
+ }
+ },
+ "exclude": {
+ "description": "List of regular expressions to exclude struct packages and names from check.",
+ "type": "array",
+ "examples": ["cobra\\.Command$"],
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "forbidigo": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "exclude-godoc-examples": {
+ "description": "Exclude code in godoc examples.",
+ "type": "boolean",
+ "default": true
+ },
+ "analyze-types": {
+ "description": "Instead of matching the literal source code, use type information to replace expressions with strings that contain the package name and (for methods and fields) the type name.",
+ "type": "boolean",
+ "default": true
+ },
+ "forbid": {
+ "description": "List of identifiers to forbid (written using `regexp`)",
+ "type": "array",
+ "examples": ["^print(ln)?$"],
+ "items": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "p": {
+ "description": "Pattern",
+ "type": "string"
+ },
+ "pkg": {
+ "description": "Package",
+ "type": "string"
+ },
+ "msg": {
+ "description": "Message",
+ "type": "string"
+ }
+ }
+ }
+ ]
+ }
+ }
+ }
+ },
+ "funlen": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "lines": {
+ "description": "Limit lines number per function.",
+ "type": "integer",
+ "default": 60
+ },
+ "statements": {
+ "description": "Limit statements number per function.",
+ "type": "integer",
+ "default": 40
+ },
+ "ignore-comments": {
+ "description": "Ignore comments when counting lines.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "gci": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "sections": {
+ "description": "Section configuration to compare against.",
+ "type": "array",
+ "items": {
+ "anyOf": [
+ {
+ "enum": [
+ "standard",
+ "default",
+ "blank",
+ "dot",
+ "alias",
+ "localmodule"
+ ]
+ },
+ {
+ "type": "string"
+ }
+ ]
+ },
+ "default": ["standard", "default"]
+ },
+ "skip-generated": {
+ "description": "Skip generated files.",
+ "type": "boolean",
+ "default": true
+ },
+ "no-inline-comments": {
+ "description": "Checks that no inline Comments are present.",
+ "type": "boolean",
+ "default": false
+ },
+ "no-prefix-comments": {
+ "description": "Checks that no prefix Comments(comment lines above an import) are present.",
+ "type": "boolean",
+ "default": false
+ },
+ "custom-order": {
+ "description": "Enable custom order of sections.",
+ "type": "boolean",
+ "default": false
+ },
+ "no-lex-order": {
+ "description": "Drops lexical ordering for custom sections.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "ginkgolinter": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "suppress-len-assertion": {
+ "description": "Suppress the wrong length assertion warning.",
+ "type": "boolean",
+ "default": false
+ },
+ "suppress-nil-assertion": {
+ "description": "Suppress the wrong nil assertion warning.",
+ "type": "boolean",
+ "default": false
+ },
+ "suppress-err-assertion": {
+ "description": "Suppress the wrong error assertion warning.",
+ "type": "boolean",
+ "default": false
+ },
+ "suppress-compare-assertion": {
+ "description": "Suppress the wrong comparison assertion warning.",
+ "type": "boolean",
+ "default": false
+ },
+ "suppress-async-assertion": {
+ "description": "Suppress the function all in async assertion warning.",
+ "type": "boolean",
+ "default": false
+ },
+ "suppress-type-compare-assertion": {
+ "description": "Suppress warning for comparing values from different types, like int32 and uint32.",
+ "type": "boolean",
+ "default": false
+ },
+ "forbid-focus-container": {
+ "description": "Trigger warning for ginkgo focus containers like FDescribe, FContext, FWhen or FIt.",
+ "type": "boolean",
+ "default": false
+ },
+ "allow-havelen-zero": {
+ "description": "Don't trigger warnings for HaveLen(0).",
+ "type": "boolean",
+ "default": false
+ },
+ "force-expect-to": {
+ "description": "Force using `Expect` with `To`, `ToNot` or `NotTo`",
+ "type": "boolean",
+ "default": false
+ },
+ "validate-async-intervals": {
+ "description": "Best effort validation of async intervals (timeout and polling).",
+ "type": "boolean",
+ "default": false
+ },
+ "forbid-spec-pollution": {
+ "description": "Trigger a warning for variable assignments in ginkgo containers like `Describe`, `Context` and `When`, instead of in `BeforeEach()`.",
+ "type": "boolean",
+ "default": false
+ },
+ "force-succeed": {
+ "description": "Force using the Succeed matcher for error functions, and the HaveOccurred matcher for non-function error values.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "gochecksumtype": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "default-signifies-exhaustive": {
+ "description": "Presence of `default` case in switch statements satisfies exhaustiveness, if all members are not listed.",
+ "type": "boolean",
+ "default": true
+ },
+ "include-shared-interfaces": {
+ "description": "Include shared interfaces in the exhaustiviness check.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "gocognit": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "min-complexity": {
+ "description": "Minimal code complexity to report (we recommend 10-20).",
+ "type": "integer",
+ "default": 30
+ }
+ }
+ },
+ "goconst": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "match-constant": {
+ "description": "Look for existing constants matching the values",
+ "type": "boolean",
+ "default": true
+ },
+ "min-len": {
+ "description": "Minimum length of string constant.",
+ "type": "integer",
+ "default": 3
+ },
+ "min-occurrences": {
+ "description": "Minimum occurrences count to trigger.",
+ "type": "integer",
+ "default": 3
+ },
+ "ignore-tests": {
+ "description": "Ignore test files.",
+ "type": "boolean",
+ "default": false
+ },
+ "ignore-calls": {
+ "description": "Ignore when constant is not used as function argument",
+ "type": "boolean",
+ "default": true
+ },
+ "ignore-strings": {
+ "description": "Exclude strings matching the given regular expression",
+ "type": "string"
+ },
+ "numbers": {
+ "description": "Search also for duplicated numbers.",
+ "type": "boolean",
+ "default": false
+ },
+ "min": {
+ "description": "Minimum value, only works with `numbers`",
+ "type": "integer",
+ "default": 3
+ },
+ "max": {
+ "description": "Maximum value, only works with `numbers`",
+ "type": "integer",
+ "default": 3
+ }
+ }
+ },
+ "gocritic": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "enabled-checks": {
+ "description": "Which checks should be enabled. By default, a list of stable checks is used. To see it, run `GL_DEBUG=gocritic golangci-lint run`.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/gocritic-checks"
+ }
+ },
+ "disabled-checks": {
+ "description": "Which checks should be disabled.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/gocritic-checks"
+ },
+ "default": []
+ },
+ "enabled-tags": {
+ "description": "Enable multiple checks by tags, run `GL_DEBUG=gocritic golangci-lint run` to see all tags and checks.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/gocritic-tags"
+ }
+ },
+ "disabled-tags": {
+ "description": "Disable multiple checks by tags, run `GL_DEBUG=gocritic golangci-lint run` to see all tags and checks.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/gocritic-tags"
+ }
+ },
+ "settings": {
+ "description": "Settings passed to gocritic. Properties must be valid and enabled check names.",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "captLocal": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "paramsOnly" : {
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "commentedOutCode": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "minLength" : {
+ "type": "number",
+ "default": 15
+ }
+ }
+ },
+ "elseif": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "skipBalanced" : {
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "hugeParam": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "sizeThreshold" : {
+ "type": "number",
+ "default": 80
+ }
+ }
+ },
+ "ifElseChain": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "minThreshold" : {
+ "type": "number",
+ "default": 2
+ }
+ }
+ },
+ "nestingReduce": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "bodyWidth" : {
+ "type": "number",
+ "default": 5
+ }
+ }
+ },
+ "rangeExprCopy": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "sizeThreshold" : {
+ "type": "number",
+ "default": 512
+ },
+ "skipTestFuncs" : {
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "rangeValCopy": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "sizeThreshold" : {
+ "type": "number",
+ "default": 128
+ },
+ "skipTestFuncs" : {
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "ruleguard": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "debug" : {
+ "type": "string"
+ },
+ "enable" : {
+ "type": "string"
+ },
+ "disable" : {
+ "type": "string"
+ },
+ "failOn" : {
+ "type": "string"
+ },
+ "rules" : {
+ "type": "string"
+ }
+ }
+ },
+ "tooManyResultsChecker": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "maxResults" : {
+ "type": "number",
+ "default": 5
+ }
+ }
+ },
+ "truncateCmp": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "skipArchDependent" : {
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "underef": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "skipRecvDeref" : {
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "unnamedResult": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "checkExported" : {
+ "type": "boolean",
+ "default": false
+ }
+ }
+ }
+ }
+ },
+ "disable-all": {
+ "type": "boolean",
+ "default": false
+ },
+ "enable-all": {
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "gocyclo": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "min-complexity": {
+ "description": "Minimum code complexity to report (we recommend 10-20).",
+ "type": "integer",
+ "default": 30
+ }
+ }
+ },
+ "godot": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "scope": {
+ "description": "Comments to be checked.",
+ "enum": ["declarations", "toplevel", "all"],
+ "default": "declarations"
+ },
+ "exclude": {
+ "description": "List of regexps for excluding particular comment lines from check.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "period": {
+ "description": "Check that each sentence ends with a period.",
+ "type": "boolean",
+ "default": true
+ },
+ "capital": {
+ "description": "Check that each sentence starts with a capital letter.",
+ "type": "boolean",
+ "default": false
+ },
+ "check-all": {
+ "description": "DEPRECATED: Check all top-level comments, not only declarations.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "godox": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "keywords": {
+ "description": "Report any comments starting with one of these keywords. This is useful for TODO or FIXME comments that might be left in the code accidentally and should be resolved before merging.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "default": ["TODO", "BUG", "FIXME"]
+ }
+ }
+ },
+ "gofmt": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "simplify": {
+ "description": "Simplify code.",
+ "type": "boolean",
+ "default": true
+ },
+ "rewrite-rules": {
+ "description": "Apply the rewrite rules to the source before reformatting.",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "pattern": {
+ "type": "string"
+ },
+ "replacement": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ }
+ },
+ "interfacebloat": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "max": {
+ "description": "The maximum number of methods allowed for an interface.",
+ "type": "integer"
+ }
+ }
+ },
+ "gofumpt": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "extra-rules": {
+ "description": "Choose whether or not to use the extra rules that are disabled by default.",
+ "type": "boolean",
+ "default": false
+ },
+ "module-path": {
+ "description": " Module path which contains the source code being formatted.",
+ "type": "string"
+ }
+ }
+ },
+ "goheader": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "values": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "const": {
+ "description": "Constants to use in the template.",
+ "type": "object",
+ "patternProperties": {
+ "^.+$": {
+ "description": "Value for the constant.",
+ "type": "string"
+ }
+ },
+ "additionalProperties": false,
+ "examples": [
+ {
+ "YEAR": "2030",
+ "COMPANY": "MY FUTURISTIC COMPANY"
+ }
+ ]
+ },
+ "regexp": {
+ "description": "Regular expressions to use in your template.",
+ "type": "object",
+ "additionalProperties": false,
+ "patternProperties": {
+ "^.+$": {
+ "type": "string"
+ }
+ },
+ "examples": [
+ {
+ "AUTHOR": ".*@mycompany\\.com"
+ }
+ ]
+ }
+ }
+ },
+ "template": {
+ "description": "Template to put on top of every file.",
+ "type": "string",
+ "examples": [
+ "{{ MY COMPANY }}\nSPDX-License-Identifier: Apache-2.0\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at:\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License."
+ ]
+ },
+ "template-path": {
+ "description": "Path to the file containing the template source.",
+ "type": "string",
+ "examples": ["my_header_template.txt"]
+ }
+ },
+ "oneOf": [
+ { "required": ["template"] },
+ { "required": ["template-path"] }
+ ]
+ },
+ "goimports": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "local-prefixes": {
+ "description": "Put imports beginning with prefix after 3rd-party packages. It is a comma-separated list of prefixes.",
+ "type": "string",
+ "examples": ["github.com/org/project"]
+ }
+ }
+ },
+ "gomoddirectives": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "replace-local": {
+ "description": "Allow local `replace` directives.",
+ "type": "boolean",
+ "default": true
+ },
+ "replace-allow-list": {
+ "description": "List of allowed `replace` directives.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "retract-allow-no-explanation": {
+ "description": "Allow to not explain why the version has been retracted in the `retract` directives.",
+ "type": "boolean",
+ "default": false
+ },
+ "exclude-forbidden": {
+ "description": "Forbid the use of the `exclude` directives.",
+ "type": "boolean",
+ "default": false
+ },
+ "toolchain-forbidden": {
+ "description": "Forbid the use of the `toolchain` directive.",
+ "type": "boolean",
+ "default": false
+ },
+ "toolchain-pattern": {
+ "description": "Defines a pattern to validate `toolchain` directive.",
+ "type": "string"
+ },
+ "tool-forbidden": {
+ "description": "Forbid the use of the `tool` directives.",
+ "type": "boolean",
+ "default": false
+ },
+ "go-debug-forbidden": {
+ "description": "Forbid the use of the `godebug` directive.",
+ "type": "boolean",
+ "default": false
+ },
+ "go-version-pattern": {
+ "description": "Defines a pattern to validate `go` minimum version directive.",
+ "type": "string",
+ "default": ""
+ }
+ }
+ },
+ "gomodguard": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "allowed": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "modules": {
+ "description": "List of allowed modules.",
+ "type": "array",
+ "items": {
+ "type": "string",
+ "examples": ["gopkg.in/yaml.v2"]
+ }
+ },
+ "domains": {
+ "description": "List of allowed module domains.",
+ "type": "array",
+ "items": {
+ "type": "string",
+ "examples": ["golang.org"]
+ }
+ }
+ }
+ },
+ "blocked": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "modules": {
+ "description": "List of blocked modules.",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "patternProperties": {
+ "^.+$": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "recommendations": {
+ "description": "Recommended modules that should be used instead.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "reason": {
+ "description": "Reason why the recommended module should be used.",
+ "type": "string"
+ }
+ }
+ }
+ },
+ "additionalProperties": false
+ }
+ },
+ "versions": {
+ "description": "List of blocked module version constraints.",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "patternProperties": {
+ "^.*$": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "version": {
+ "description": "Version constraint.",
+ "type": "string"
+ },
+ "reason": {
+ "description": "Reason why the version constraint exists.",
+ "type": "string"
+ }
+ },
+ "required": ["reason"]
+ }
+ }
+ }
+ },
+ "local_replace_directives": {
+ "description": "Raise lint issues if loading local path with replace directive",
+ "type": "boolean",
+ "default": true
+ }
+ }
+ }
+ }
+ },
+ "gosimple": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "checks": {
+ "type": "array",
+ "items": {
+ "anyOf": [
+ {
+ "enum": ["all"]
+ },
+ {
+ "type": "string"
+ }
+ ]
+ }
+ }
+ }
+ },
+ "gosec": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "includes": {
+ "type": "array",
+ "description": "To select a subset of rules to run",
+ "examples": [["G401"]],
+ "items": {
+ "$ref": "#/definitions/gosec-rules"
+ }
+ },
+ "excludes": {
+ "type": "array",
+ "description": "To specify a set of rules to explicitly exclude",
+ "examples": [["G401"]],
+ "items": {
+ "$ref": "#/definitions/gosec-rules"
+ }
+ },
+ "exclude-generated": {
+ "description": "Exclude generated files",
+ "type": "boolean",
+ "default": false
+ },
+ "severity": {
+ "description": "Filter out the issues with a lower severity than the given value",
+ "type": "string",
+ "enum": ["low", "medium", "high"],
+ "default": "low"
+ },
+ "confidence": {
+ "description": "Filter out the issues with a lower confidence than the given value",
+ "type": "string",
+ "enum": ["low", "medium", "high"],
+ "default": "low"
+ },
+ "config": {
+ "description": "To specify the configuration of rules",
+ "type": "object"
+ },
+ "concurrency": {
+ "description": "Concurrency value",
+ "type": "integer"
+ }
+ }
+ },
+ "gosmopolitan": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "allow-time-local": {
+ "description": "Allow and ignore `time.Local` usages.",
+ "type": "boolean",
+ "default": false
+ },
+ "escape-hatches": {
+ "description": "List of fully qualified names in the `full/pkg/path.name` form, to act as \"i18n escape hatches\".",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ignore-tests": {
+ "description": "Ignore test files.",
+ "type": "boolean",
+ "default": false
+ },
+ "watch-for-scripts": {
+ "description": "List of Unicode scripts to watch for any usage in string literals.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "govet": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "settings": {
+ "description": "Settings per analyzer. Map of analyzer name to specific settings.\nRun `go tool vet help` to find out more.",
+ "type": "object",
+ "propertyNames": {
+ "$ref": "#/definitions/govet-analyzers"
+ },
+ "patternProperties": {
+ "^.*$": {
+ "description": "Run `go tool vet help ` to see all settings.",
+ "type": "object"
+ }
+ }
+ },
+ "enable": {
+ "description": "Enable analyzers by name.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/govet-analyzers"
+ }
+ },
+ "disable": {
+ "description": "Disable analyzers by name.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/govet-analyzers"
+ }
+ },
+ "enable-all": {
+ "description": "Enable all analyzers.",
+ "type": "boolean",
+ "default": false
+ },
+ "disable-all": {
+ "description": "Disable all analyzers.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "grouper": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "const-require-single-const": {
+ "type": "boolean",
+ "default": false
+ },
+ "const-require-grouping": {
+ "type": "boolean",
+ "default": false
+ },
+ "import-require-single-import": {
+ "type": "boolean",
+ "default": false
+ },
+ "import-require-grouping": {
+ "type": "boolean",
+ "default": false
+ },
+ "type-require-single-type": {
+ "type": "boolean",
+ "default": false
+ },
+ "type-require-grouping": {
+ "type": "boolean",
+ "default": false
+ },
+ "var-require-single-var": {
+ "type": "boolean",
+ "default": false
+ },
+ "var-require-grouping": {
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "iface": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "enable": {
+ "description": "Enable analyzers by name.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/iface-analyzers"
+ }
+ },
+ "settings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "unused": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "exclude": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "importas": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "no-unaliased": {
+ "description": "Do not allow unaliased imports of aliased packages.",
+ "type": "boolean",
+ "default": false
+ },
+ "no-extra-aliases": {
+ "description": "Do not allow non-required aliases.",
+ "type": "boolean",
+ "default": false
+ },
+ "alias": {
+ "description": "List of aliases",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "pkg": {
+ "description": "Package path e.g. knative.dev/serving/pkg/apis/autoscaling/v1alpha1",
+ "type": "string"
+ },
+ "alias": {
+ "description": "Package alias e.g. autoscalingv1alpha1",
+ "type": "string"
+ }
+ },
+ "required": ["pkg", "alias"]
+ }
+ }
+ }
+ },
+ "inamedparam": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "skip-single-param": {
+ "description": "Skips check for interface methods with only a single parameter.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "ireturn": {
+ "type": "object",
+ "additionalProperties": false,
+ "description": "Use either `reject` or `allow` properties for interfaces matching.",
+ "properties": {
+ "allow": {
+ "type": "array",
+ "items": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "enum": ["anon", "error", "empty", "stdlib"]
+ }
+ ]
+ }
+ },
+ "reject": {
+ "type": "array",
+ "items": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "enum": ["anon", "error", "empty", "stdlib"]
+ }
+ ]
+ }
+ }
+ },
+ "anyOf": [
+ {
+ "not": {
+ "properties": {
+ "allow": {
+ "const": "reject"
+ }
+ }
+ },
+ "required": ["allow"]
+ },
+ {
+ "required": ["reject"]
+ }
+ ]
+ },
+ "lll": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "tab-width": {
+ "description": "Width of \"\\t\" in spaces.",
+ "type": "integer",
+ "minimum": 0,
+ "default": 1
+ },
+ "line-length": {
+ "description": "Maximum allowed line length, lines longer will be reported.",
+ "type": "integer",
+ "minimum": 1,
+ "default": 120
+ }
+ }
+ },
+ "maintidx": {
+ "description": "Maintainability index https://docs.microsoft.com/en-us/visualstudio/code-quality/code-metrics-maintainability-index-range-and-meaning?view=vs-2022",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "under": {
+ "description": "Minimum accatpable maintainability index level (see https://docs.microsoft.com/en-us/visualstudio/code-quality/code-metrics-maintainability-index-range-and-meaning?view=vs-2022)",
+ "type": "number",
+ "default": 20
+ }
+ }
+ },
+ "makezero": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "always": {
+ "description": "Allow only slices initialized with a length of zero.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "loggercheck": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "kitlog": {
+ "description": "Allow check for the github.com/go-kit/log library.",
+ "type": "boolean",
+ "default": true
+ },
+ "klog": {
+ "description": "Allow check for the k8s.io/klog/v2 library.",
+ "type": "boolean",
+ "default": true
+ },
+ "logr": {
+ "description": "Allow check for the github.com/go-logr/logr library.",
+ "type": "boolean",
+ "default": true
+ },
+ "slog": {
+ "description": "Allow check for the log/slog library.",
+ "type": "boolean",
+ "default": true
+ },
+ "zap": {
+ "description": "Allow check for the \"sugar logger\" from go.uber.org/zap library.",
+ "type": "boolean",
+ "default": true
+ },
+ "require-string-key": {
+ "description": "Require all logging keys to be inlined constant strings.",
+ "type": "boolean",
+ "default": false
+ },
+ "no-printf-like": {
+ "description": "Require printf-like format specifier (%s, %d for example) not present.",
+ "type": "boolean",
+ "default": false
+ },
+ "rules": {
+ "description": "List of custom rules to check against, where each rule is a single logger pattern, useful for wrapped loggers.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "misspell": {
+ "description": "Correct spellings using locale preferences for US or UK. Default is to use a neutral variety of English.",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "locale": {
+ "enum": ["US", "UK"]
+ },
+ "ignore-words": {
+ "description": "List of words to ignore.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "mode": {
+ "description": "Mode of the analysis.",
+ "enum": ["restricted", "", "default"],
+ "default": ""
+ },
+ "extra-words": {
+ "description": "Extra word corrections.",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "correction": {
+ "type": "string"
+ },
+ "typo": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ }
+ },
+ "musttag": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "functions": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "name": {
+ "type": "string"
+ },
+ "tag": {
+ "type": "string"
+ },
+ "arg-pos": {
+ "type": "integer"
+ }
+ }
+ }
+ }
+ }
+ },
+ "nakedret": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "max-func-lines": {
+ "description": "Report if a function has more lines of code than this value and it has naked returns.",
+ "type": "integer",
+ "minimum": 0,
+ "default": 30
+ }
+ }
+ },
+ "nestif": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "min-complexity": {
+ "description": "Minimum complexity of \"if\" statements to report.",
+ "type": "integer",
+ "default": 5
+ }
+ }
+ },
+ "nilnil": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "detect-opposite": {
+ "type": "boolean",
+ "description": "In addition, detect opposite situation (simultaneous return of non-nil error and valid value).",
+ "default": false
+ },
+ "checked-types": {
+ "type": "array",
+ "description": "List of return types to check.",
+ "items": {
+ "enum": ["chan", "func", "iface", "map", "ptr", "uintptr", "unsafeptr"]
+ },
+ "default": ["chan", "func", "iface", "map", "ptr", "uintptr", "unsafeptr"]
+ }
+ }
+ },
+ "nlreturn": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "block-size": {
+ "description": "set block size that is still ok",
+ "type": "number",
+ "default": 0,
+ "minimum": 0
+ }
+ }
+ },
+ "mnd": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "ignored-files": {
+ "description": "List of file patterns to exclude from analysis.",
+ "examples": [["magic1_.*.go"]],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ignored-functions": {
+ "description": "Comma-separated list of function patterns to exclude from the analysis.",
+ "examples": [["math.*", "http.StatusText", "make"]],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ignored-numbers": {
+ "description": "List of numbers to exclude from analysis.",
+ "examples": [["1000", "1234_567_890", "3.14159264"]],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "checks": {
+ "description": "The list of enabled checks, see https://github.com/tommy-muehle/go-mnd/#checks for description.",
+ "type": "array",
+ "items": {
+ "enum": [
+ "argument",
+ "case",
+ "condition",
+ "operation",
+ "return",
+ "assign"
+ ]
+ }
+ }
+ }
+ },
+ "nolintlint": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "allow-unused": {
+ "description": "Enable to ensure that nolint directives are all used.",
+ "type": "boolean",
+ "default": true
+ },
+ "allow-no-explanation": {
+ "description": "Exclude these linters from requiring an explanation.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/linters"
+ },
+ "default": []
+ },
+ "require-explanation": {
+ "description": "Enable to require an explanation of nonzero length after each nolint directive.",
+ "type": "boolean",
+ "default": false
+ },
+ "require-specific": {
+ "description": "Enable to require nolint directives to mention the specific linter being suppressed.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "reassign": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "patterns": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "recvcheck": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "disable-builtin": {
+ "description": "Disables the built-in method exclusions.",
+ "type": "boolean",
+ "default": true
+ },
+ "exclusions": {
+ "description": "User-defined method exclusions.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "nonamedreturns": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "report-error-in-defer": {
+ "description": "Report named error if it is assigned inside defer.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "paralleltest": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "ignore-missing": {
+ "description": "Ignore missing calls to `t.Parallel()` and only report incorrect uses of it.",
+ "type": "boolean",
+ "default": false
+ },
+ "ignore-missing-subtests": {
+ "description": "Ignore missing calls to `t.Parallel()` in subtests. Top-level tests are still required to have `t.Parallel`, but subtests are allowed to skip it.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "perfsprint": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "int-conversion": {
+ "description": "Optimizes even if it requires an int or uint type cast.",
+ "type": "boolean",
+ "default": true
+ },
+ "err-error": {
+ "description": "Optimizes into `err.Error()` even if it is only equivalent for non-nil errors.",
+ "type": "boolean",
+ "default": false
+ },
+ "errorf": {
+ "description": "Optimizes `fmt.Errorf`.",
+ "type": "boolean",
+ "default": true
+ },
+ "sprintf1": {
+ "description": "Optimizes `fmt.Sprintf` with only one argument.",
+ "type": "boolean",
+ "default": true
+ },
+ "strconcat": {
+ "description": "Optimizes into strings concatenation.",
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "prealloc": {
+ "description": "We do not recommend using this linter before doing performance profiling.\nFor most programs usage of `prealloc` will be premature optimization.",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "simple": {
+ "description": "Report preallocation suggestions only on simple loops that have no returns/breaks/continues/gotos in them.",
+ "type": "boolean",
+ "default": true
+ },
+ "range-loops": {
+ "description": "Report preallocation suggestions on range loops.",
+ "type": "boolean",
+ "default": true
+ },
+ "for-loops": {
+ "description": "Report preallocation suggestions on for loops.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "predeclared": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "ignore": {
+ "description": "Comma-separated list of predeclared identifiers to not report on.",
+ "type": "string"
+ },
+ "q": {
+ "description": "Include method names and field names (i.e., qualified names) in checks.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "promlinter": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "strict": {},
+ "disabled-linters": {
+ "type": "array",
+ "items": {
+ "enum": [
+ "Help",
+ "MetricUnits",
+ "Counter",
+ "HistogramSummaryReserved",
+ "MetricTypeInName",
+ "ReservedChars",
+ "CamelCase",
+ "UnitAbbreviations"
+ ]
+ }
+ }
+ }
+ },
+ "protogetter": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "skip-generated-by": {
+ "type": "array",
+ "items": {
+ "type": "string",
+ "examples": ["protoc-gen-go-my-own-generator"]
+ }
+ },
+ "skip-files": {
+ "type": "array",
+ "items": {
+ "type": "string",
+ "examples": ["*.pb.go"]
+ }
+ },
+ "skip-any-generated": {
+ "description": "Skip any generated files from the checking.",
+ "type": "boolean",
+ "default": false
+ },
+ "replace-first-arg-in-append": {
+ "description": "Skip first argument of append function.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "revive": {
+ "type": "object",
+ "additionalProperties": false,
+ "examples": [
+ {
+ "ignore-generated-header": true,
+ "severity": "warning",
+ "rules": [
+ {
+ "name": "indent-error-flow",
+ "severity": "warning"
+ },
+ {
+ "name": "add-constant",
+ "severity": "warning",
+ "arguments": [
+ {
+ "maxLitCount": "3",
+ "allowStrs": "\"\"",
+ "allowInts": "0,1,2",
+ "allowFloats": "0.0,0.,1.0,1.,2.0,2."
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ "properties": {
+ "max-open-files": {
+ "type": "integer"
+ },
+ "ignore-generated-header": {
+ "type": "boolean"
+ },
+ "confidence": {
+ "type": "number"
+ },
+ "severity": {
+ "type": "string",
+ "enum": ["warning", "error"]
+ },
+ "enable-all-rules": {
+ "type": "boolean",
+ "default": false
+ },
+ "directives": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "name": {
+ "type": "string",
+ "enum": ["specify-disable-reason"]
+ },
+ "severity": {
+ "type": "string",
+ "enum": ["warning", "error"]
+ },
+ "exclude": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "arguments": {
+ "type": "array"
+ }
+ }
+ }
+ },
+ "rules": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "required": ["name"],
+ "properties": {
+ "name": {
+ "$ref": "#/definitions/revive-rules",
+ "title": "The rule name"
+ },
+ "disabled": {
+ "type": "boolean"
+ },
+ "severity": {
+ "type": "string",
+ "enum": ["warning", "error"]
+ },
+ "exclude": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "arguments": {
+ "type": "array"
+ }
+ }
+ }
+ }
+ }
+ },
+ "rowserrcheck": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "packages": {
+ "type": "array",
+ "items": {
+ "description": "",
+ "type": "string",
+ "examples": ["github.com/jmoiron/sqlx"]
+ }
+ }
+ }
+ },
+ "sloglint": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "kv-only": {
+ "description": "Enforce using key-value pairs only (incompatible with attr-only).",
+ "type": "boolean",
+ "default": false
+ },
+ "no-global": {
+ "description": "Enforce not using global loggers.",
+ "enum": ["", "all", "default"],
+ "default": ""
+ },
+ "no-mixed-args": {
+ "description": "Enforce not mixing key-value pairs and attributes.",
+ "type": "boolean",
+ "default": true
+ },
+ "context": {
+ "description": "Enforce using methods that accept a context.",
+ "enum": ["", "all", "scope"],
+ "default": ""
+ },
+ "static-msg": {
+ "description": "Enforce using static values for log messages.",
+ "type": "boolean",
+ "default": false
+ },
+ "key-naming-case": {
+ "description": "Enforce a single key naming convention.",
+ "enum": ["snake", "kebab", "camel", "pascal"]
+ },
+ "attr-only": {
+ "description": "Enforce using attributes only (incompatible with kv-only).",
+ "type": "boolean",
+ "default": false
+ },
+ "no-raw-keys": {
+ "description": "Enforce using constants instead of raw keys.",
+ "type": "boolean",
+ "default": false
+ },
+ "forbidden-keys": {
+ "description": "Enforce not using specific keys.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "args-on-sep-lines": {
+ "description": "Enforce putting arguments on separate lines.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "spancheck": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "checks": {
+ "description": "Checks to enable.",
+ "type": "array",
+ "items": {
+ "enum": ["end", "record-error", "set-status"]
+ }
+ },
+ "ignore-check-signatures": {
+ "description": "A list of regexes for function signatures that silence `record-error` and `set-status` reports if found in the call path to a returned error.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "extra-start-span-signatures": {
+ "description": "A list of regexes for additional function signatures that create spans.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "staticcheck": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "checks": {
+ "type": "array",
+ "items": {
+ "anyOf": [
+ {
+ "enum": ["all"]
+ },
+ {
+ "type": "string"
+ }
+ ]
+ }
+ }
+ }
+ },
+ "stylecheck": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "checks": {
+ "type": "array",
+ "items": {
+ "anyOf": [
+ {
+ "enum": ["all"]
+ },
+ {
+ "type": "string"
+ }
+ ]
+ },
+ "default": [
+ "all",
+ "-ST1000",
+ "-ST1003",
+ "-ST1016",
+ "-ST1020",
+ "-ST1021",
+ "-ST1022"
+ ]
+ },
+ "dot-import-whitelist": {
+ "description": "By default, ST1001 forbids all uses of dot imports in non-test packages. This setting allows setting a whitelist of import paths that can be dot-imported anywhere.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "http-status-code-whitelist": {
+ "description": "ST1013 recommends using constants from the net/http package instead of hard-coding numeric HTTP status codes. This setting specifies a list of numeric status codes that this check does not complain about.",
+ "default": ["200", "400", "404", "500"],
+ "type": "array",
+ "items": {
+ "enum": [
+ "100",
+ "101",
+ "102",
+ "103",
+ "200",
+ "201",
+ "202",
+ "203",
+ "204",
+ "205",
+ "206",
+ "207",
+ "208",
+ "226",
+ "300",
+ "301",
+ "302",
+ "303",
+ "304",
+ "305",
+ "306",
+ "307",
+ "308",
+ "400",
+ "401",
+ "402",
+ "403",
+ "404",
+ "405",
+ "406",
+ "407",
+ "408",
+ "409",
+ "410",
+ "411",
+ "412",
+ "413",
+ "414",
+ "415",
+ "416",
+ "417",
+ "418",
+ "421",
+ "422",
+ "423",
+ "424",
+ "425",
+ "426",
+ "428",
+ "429",
+ "431",
+ "451",
+ "500",
+ "501",
+ "502",
+ "503",
+ "504",
+ "505",
+ "506",
+ "507",
+ "508",
+ "510",
+ "511"
+ ]
+ }
+ },
+ "initialisms": {
+ "description": "ST1003 check, among other things, for the correct capitalization of initialisms. The set of known initialisms can be configured with this option.",
+ "type": "array",
+ "items": {
+ "type": "string",
+ "default": [
+ "ACL",
+ "API",
+ "ASCII",
+ "CPU",
+ "CSS",
+ "DNS",
+ "EOF",
+ "GUID",
+ "HTML",
+ "HTTP",
+ "HTTPS",
+ "ID",
+ "IP",
+ "JSON",
+ "QPS",
+ "RAM",
+ "RPC",
+ "SLA",
+ "SMTP",
+ "SQL",
+ "SSH",
+ "TCP",
+ "TLS",
+ "TTL",
+ "UDP",
+ "UI",
+ "GID",
+ "UID",
+ "UUID",
+ "URI",
+ "URL",
+ "UTF8",
+ "VM",
+ "XML",
+ "XMPP",
+ "XSRF",
+ "XSS",
+ "SIP",
+ "RTP",
+ "AMQP",
+ "DB",
+ "TS"
+ ]
+ }
+ }
+ }
+ },
+ "tagalign": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "align": {
+ "description": "Align and sort can be used together or separately.",
+ "type": "boolean",
+ "default": true
+ },
+ "sort": {
+ "description": "Whether enable tags sort.",
+ "type": "boolean",
+ "default": true
+ },
+ "order": {
+ "description": "Specify the order of tags, the other tags will be sorted by name.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "default": [],
+ "examples": [
+ [
+ "json",
+ "yaml",
+ "yml",
+ "toml",
+ "mapstructure",
+ "binding",
+ "validate"
+ ]
+ ]
+ },
+ "strict": {
+ "description": "Whether enable strict style.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "tagliatelle": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "case": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "use-field-name": {
+ "description": "Use the struct field name to check the name of the struct tag.",
+ "type": "boolean",
+ "default": false
+ },
+ "ignored-fields": {
+ "description": "The field names to ignore.",
+ "type": "array",
+ "items": {
+ "type": "string",
+ "examples": ["example"]
+ }
+ },
+ "rules": {
+ "type": "object",
+ "patternProperties": {
+ "^.+$": {
+ "$ref": "#/definitions/tagliatelle-cases"
+ }
+ }
+ },
+ "extended-rules": {
+ "description": "Defines the association between tag name and case.",
+ "type": "object",
+ "patternProperties": {
+ "^.+$": {
+ "type": "object",
+ "additionalProperties": false,
+ "required": ["case"],
+ "properties": {
+ "case": {
+ "$ref": "#/definitions/tagliatelle-cases"
+ },
+ "extra-initialisms": {
+ "type": "boolean",
+ "default": false
+ },
+ "initialism-overrides": {
+ "type": "object",
+ "patternProperties": {
+ "^.+$": {
+ "type": "boolean",
+ "default": false
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "overrides": {
+ "description": "Overrides the default/root configuration.",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "required": ["pkg"],
+ "properties": {
+ "pkg": {
+ "description": "A package path.",
+ "type": "string"
+ },
+ "use-field-name": {
+ "description": "Use the struct field name to check the name of the struct tag.",
+ "type": "boolean",
+ "default": false
+ },
+ "ignored-fields": {
+ "description": "The field names to ignore.",
+ "type": "array",
+ "items": {
+ "type": "string",
+ "examples": ["example"]
+ }
+ },
+ "ignore": {
+ "description": "Ignore the package (takes precedence over all other configurations).",
+ "type": "boolean",
+ "default": false
+ },
+ "rules": {
+ "type": "object",
+ "patternProperties": {
+ "^.+$": {
+ "$ref": "#/definitions/tagliatelle-cases"
+ }
+ }
+ },
+ "extended-rules": {
+ "description": "Defines the association between tag name and case.",
+ "type": "object",
+ "patternProperties": {
+ "^.+$": {
+ "type": "object",
+ "additionalProperties": false,
+ "required": ["case"],
+ "properties": {
+ "case": {
+ "$ref": "#/definitions/tagliatelle-cases"
+ },
+ "extra-initialisms": {
+ "type": "boolean",
+ "default": false
+ },
+ "initialism-overrides": {
+ "type": "object",
+ "patternProperties": {
+ "^.+$": {
+ "type": "boolean",
+ "default": false
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "tenv": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "all": {
+ "description": "The option `all` will run against whole test files (`_test.go`) regardless of method/function signatures.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "testifylint": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "enable-all": {
+ "description": "Enable all checkers.",
+ "type": "boolean",
+ "default": false
+ },
+ "disable-all": {
+ "description": "Disable all checkers.",
+ "type": "boolean",
+ "default": false
+ },
+ "enable": {
+ "description": "Enable specific checkers.",
+ "type": "array",
+ "items": {
+ "enum": [
+ "blank-import",
+ "bool-compare",
+ "compares",
+ "contains",
+ "empty",
+ "encoded-compare",
+ "error-is-as",
+ "error-nil",
+ "expected-actual",
+ "float-compare",
+ "formatter",
+ "go-require",
+ "len",
+ "negative-positive",
+ "nil-compare",
+ "regexp",
+ "require-error",
+ "suite-broken-parallel",
+ "suite-dont-use-pkg",
+ "suite-extra-assert-call",
+ "suite-subtest-run",
+ "suite-thelper",
+ "useless-assert"
+ ]
+ },
+ "default": [
+ "blank-import",
+ "bool-compare",
+ "compares",
+ "contains",
+ "empty",
+ "encoded-compare",
+ "error-is-as",
+ "error-nil",
+ "expected-actual",
+ "float-compare",
+ "formatter",
+ "go-require",
+ "len",
+ "negative-positive",
+ "nil-compare",
+ "regexp",
+ "require-error",
+ "suite-broken-parallel",
+ "suite-dont-use-pkg",
+ "suite-extra-assert-call",
+ "suite-subtest-run",
+ "useless-assert"
+ ]
+ },
+ "disable": {
+ "description": "Disable specific checkers.",
+ "type": "array",
+ "items": {
+ "enum": [
+ "blank-import",
+ "bool-compare",
+ "compares",
+ "contains",
+ "empty",
+ "encoded-compare",
+ "error-is-as",
+ "error-nil",
+ "expected-actual",
+ "float-compare",
+ "formatter",
+ "go-require",
+ "len",
+ "negative-positive",
+ "nil-compare",
+ "regexp",
+ "require-error",
+ "suite-broken-parallel",
+ "suite-dont-use-pkg",
+ "suite-extra-assert-call",
+ "suite-subtest-run",
+ "suite-thelper",
+ "useless-assert"
+ ],
+ "default": [
+ "suite-thelper"
+ ]
+ }
+ },
+ "bool-compare": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "ignore-custom-types": {
+ "description": "To ignore user defined types (over builtin bool).",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "expected-actual": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "pattern": {
+ "description": "Regexp for expected variable name.",
+ "type": "string",
+ "default": "(^(exp(ected)?|want(ed)?)([A-Z]\\w*)?$)|(^(\\w*[a-z])?(Exp(ected)?|Want(ed)?)$)"
+ }
+ }
+ },
+ "formatter": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "check-format-string": {
+ "description": "To enable go vet's printf checks.",
+ "type": "boolean",
+ "default": true
+ },
+ "require-f-funcs": {
+ "description": "To require f-assertions (e.g. assert.Equalf) if format string is used, even if there are no variable-length variables.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "go-require": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "ignore-http-handlers": {
+ "description": "To ignore HTTP handlers (like http.HandlerFunc).",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "require-error": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "fn-pattern": {
+ "description": "Regexp for assertions to analyze. If defined, then only matched error assertions will be reported.",
+ "type": "string",
+ "default": ""
+ }
+ }
+ },
+ "suite-extra-assert-call": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "mode": {
+ "description": "To require or remove extra Assert() call?",
+ "type": "string",
+ "enum": ["remove", "require"],
+ "default": "remove"
+ }
+ }
+ }
+ }
+ },
+ "testpackage": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "skip-regexp": {
+ "description": "Files with names matching this regular expression are skipped.",
+ "type": "string",
+ "examples": ["(export|internal)_test\\.go"]
+ },
+ "allow-packages": {
+ "description": "List of packages that don't end with _test that tests are allowed to be in.",
+ "type": "array",
+ "uniqueItems": true,
+ "items": {
+ "type": "string",
+ "examples": ["example"]
+ }
+ }
+ }
+ },
+ "thelper": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "test": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "begin": {
+ "description": "Check if `t.Helper()` begins helper function.",
+ "default": true,
+ "type": "boolean"
+ },
+ "first": {
+ "description": "Check if *testing.T is first param of helper function.",
+ "default": true,
+ "type": "boolean"
+ },
+ "name": {
+ "description": "Check if *testing.T param has t name.",
+ "default": true,
+ "type": "boolean"
+ }
+ }
+ },
+ "benchmark": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "begin": {
+ "description": "Check if `b.Helper()` begins helper function.",
+ "default": true,
+ "type": "boolean"
+ },
+ "first": {
+ "description": "Check if *testing.B is first param of helper function.",
+ "default": true,
+ "type": "boolean"
+ },
+ "name": {
+ "description": "Check if *testing.B param has b name.",
+ "default": true,
+ "type": "boolean"
+ }
+ }
+ },
+ "tb": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "begin": {
+ "description": "Check if `tb.Helper()` begins helper function.",
+ "default": true,
+ "type": "boolean"
+ },
+ "first": {
+ "description": "Check if *testing.TB is first param of helper function.",
+ "default": true,
+ "type": "boolean"
+ },
+ "name": {
+ "description": "Check if *testing.TB param has tb name.",
+ "default": true,
+ "type": "boolean"
+ }
+ }
+ },
+ "fuzz": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "begin": {
+ "description": "Check if `f.Helper()` begins helper function.",
+ "default": true,
+ "type": "boolean"
+ },
+ "first": {
+ "description": "Check if *testing.F is first param of helper function.",
+ "default": true,
+ "type": "boolean"
+ },
+ "name": {
+ "description": "Check if *testing.F param has f name.",
+ "default": true,
+ "type": "boolean"
+ }
+ }
+ }
+ }
+ },
+ "usestdlibvars": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "http-method": {
+ "description": "Suggest the use of http.MethodXX.",
+ "type": "boolean",
+ "default": true
+ },
+ "http-status-code": {
+ "description": "Suggest the use of http.StatusXX.",
+ "type": "boolean",
+ "default": true
+ },
+ "time-weekday": {
+ "description": "Suggest the use of time.Weekday.String().",
+ "type": "boolean",
+ "default": false
+ },
+ "time-month": {
+ "description": "Suggest the use of time.Month.String().",
+ "type": "boolean",
+ "default": false
+ },
+ "time-layout": {
+ "description": "Suggest the use of time.Layout.",
+ "type": "boolean",
+ "default": false
+ },
+ "crypto-hash": {
+ "description": "Suggest the use of crypto.Hash.String().",
+ "type": "boolean",
+ "default": false
+ },
+ "default-rpc-path": {
+ "description": "Suggest the use of rpc.DefaultXXPath.",
+ "type": "boolean",
+ "default": false
+ },
+ "sql-isolation-level": {
+ "description": "Suggest the use of sql.LevelXX.String().",
+ "type": "boolean",
+ "default": false
+ },
+ "tls-signature-scheme": {
+ "description": "Suggest the use of tls.SignatureScheme.String().",
+ "type": "boolean",
+ "default": false
+ },
+ "constant-kind": {
+ "description": "Suggest the use of constant.Kind.String().",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "usetesting": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "context-background": {
+ "type": "boolean",
+ "default": true
+ },
+ "context-todo": {
+ "type": "boolean",
+ "default": true
+ },
+ "os-chdir": {
+ "type": "boolean",
+ "default": true
+ },
+ "os-mkdir-temp": {
+ "type": "boolean",
+ "default": true
+ },
+ "os-setenv": {
+ "type": "boolean",
+ "default": false
+ },
+ "os-create-temp": {
+ "type": "boolean",
+ "default": true
+ },
+ "os-temp-dir": {
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "unconvert": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "fast-math": {
+ "type": "boolean",
+ "default": false
+ },
+ "safe": {
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "unparam": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "check-exported": {
+ "description": "Inspect exported functions. Set to true if no external program/library imports your code.\n\nWARNING: if you enable this setting, unparam will report a lot of false-positives in text editors:\nif it's called for subdir of a project it can't find external interfaces. All text editor integrations\nwith golangci-lint call it on a directory with the changed file.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "unused": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "field-writes-are-uses": {
+ "description": "",
+ "type": "boolean",
+ "default": true
+ },
+ "post-statements-are-reads": {
+ "description": "",
+ "type": "boolean",
+ "default": false
+ },
+ "exported-fields-are-used": {
+ "description": "",
+ "type": "boolean",
+ "default": true
+ },
+ "parameters-are-used": {
+ "description": "",
+ "type": "boolean",
+ "default": true
+ },
+ "local-variables-are-used": {
+ "description": "",
+ "type": "boolean",
+ "default": true
+ },
+ "generated-is-used": {
+ "description": "",
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "varnamelen": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "max-distance": {
+ "description": "Variables used in at most this N-many lines will be ignored.",
+ "type": "integer",
+ "default": 5
+ },
+ "min-name-length": {
+ "description": "The minimum length of a variable's name that is considered `long`.",
+ "type": "integer",
+ "default": 3
+ },
+ "check-receiver": {
+ "description": "Check method receiver names.",
+ "default": false,
+ "type": "boolean"
+ },
+ "check-return": {
+ "description": "Check named return values.",
+ "default": false,
+ "type": "boolean"
+ },
+ "check-type-param": {
+ "description": "Check type parameters.",
+ "default": false,
+ "type": "boolean"
+ },
+ "ignore-type-assert-ok": {
+ "description": "Ignore `ok` variables that hold the bool return value of a type assertion",
+ "default": false,
+ "type": "boolean"
+ },
+ "ignore-map-index-ok": {
+ "description": "Ignore `ok` variables that hold the bool return value of a map index.",
+ "default": false,
+ "type": "boolean"
+ },
+ "ignore-chan-recv-ok": {
+ "description": "Ignore `ok` variables that hold the bool return value of a channel receive.",
+ "default": false,
+ "type": "boolean"
+ },
+ "ignore-names": {
+ "description": "Optional list of variable names that should be ignored completely.",
+ "default": [[]],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ignore-decls": {
+ "description": "Optional list of variable declarations that should be ignored completely.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "examples": [
+ ["c echo.Context", "t testing.T", "f *foo.Bar", "const C"]
+ ]
+ }
+ }
+ },
+ "whitespace": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "multi-if": {
+ "description": "Enforces newlines (or comments) after every multi-line if statement",
+ "type": "boolean",
+ "default": false
+ },
+ "multi-func": {
+ "description": "Enforces newlines (or comments) after every multi-line function signature",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "wrapcheck": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "extra-ignore-sigs": {
+ "description": "An array of strings specifying additional substrings of signatures to ignore.",
+ "default": [
+ ".CustomError(",
+ ".SpecificWrap("
+ ],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ignoreSigs": {
+ "description": "An array of strings which specify substrings of signatures to ignore.",
+ "default": [
+ ".Errorf(",
+ "errors.New(",
+ "errors.Unwrap(",
+ ".Wrap(",
+ ".Wrapf(",
+ ".WithMessage(",
+ ".WithMessagef(",
+ ".WithStack("
+ ],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ignoreSigRegexps": {
+ "description": "An array of strings which specify regular expressions of signatures to ignore.",
+ "default": [""],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ignorePackageGlobs": {
+ "description": "An array of glob patterns which, if any match the package of the function returning the error, will skip wrapcheck analysis for this error.",
+ "default": [""],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ignoreInterfaceRegexps": {
+ "description": "An array of glob patterns which, if matched to an underlying interface name, will ignore unwrapped errors returned from a function whose call is defined on the given interface.",
+ "default": [""],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "wsl": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "allow-assign-and-anything": {
+ "description": "Controls if you may cuddle assignments and anything without needing an empty line between them.",
+ "type": "boolean",
+ "default": false
+ },
+ "allow-assign-and-call": {
+ "description": "Allow calls and assignments to be cuddled as long as the lines have any matching variables, fields or types.",
+ "type": "boolean",
+ "default": true
+ },
+ "allow-cuddle-declarations": {
+ "description": "Allow declarations (var) to be cuddled.",
+ "type": "boolean",
+ "default": false
+ },
+ "allow-cuddle-with-calls": {
+ "description": "A list of call idents that everything can be cuddled with.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "allow-cuddle-with-rhs": {
+ "description": "AllowCuddleWithRHS is a list of right hand side variables that is allowed to be cuddled with anything.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "allow-multiline-assign": {
+ "description": "Allow multiline assignments to be cuddled.",
+ "type": "boolean",
+ "default": true
+ },
+ "allow-separated-leading-comment": {
+ "description": "Allow leading comments to be separated with empty lines.",
+ "type": "boolean",
+ "default": false
+ },
+ "allow-trailing-comment": {
+ "description": "Allow trailing comments in ending of blocks.",
+ "type": "boolean",
+ "default": false
+ },
+ "error-variable-names": {
+ "description": "When force-err-cuddling is enabled this is a list of names used for error variables to check for in the conditional.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "force-case-trailing-whitespace": {
+ "description": "Force newlines in end of case at this limit (0 = never).",
+ "type": "integer",
+ "minimum": 0,
+ "default": 0
+ },
+ "force-err-cuddling": {
+ "description": "Causes an error when an If statement that checks an error variable doesn't cuddle with the assignment of that variable.",
+ "type": "boolean",
+ "default": false
+ },
+ "force-short-decl-cuddling": {
+ "description": "Causes an error if a short declaration (:=) cuddles with anything other than another short declaration.",
+ "type": "boolean",
+ "default": false
+ },
+ "strict-append": {
+ "description": "If true, append is only allowed to be cuddled if appending value is matching variables, fields or types on line above.",
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "copyloopvar": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "check-alias": {
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "custom": {
+ "description": "The custom section can be used to define linter plugins to be loaded at runtime. See README of golangci-lint for more information.\nEach custom linter should have a unique name.",
+ "type": "object",
+ "patternProperties": {
+ "^.*$": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "type": {
+ "description": "The plugin type.",
+ "enum": ["module", "goplugin"],
+ "default": "goplugin"
+ },
+ "path": {
+ "description": "The path to the plugin *.so. Can be absolute or local.",
+ "type": "string",
+ "examples": ["/path/to/example.so"]
+ },
+ "description": {
+ "description": "The description of the linter, for documentation purposes only.",
+ "type": "string"
+ },
+ "original-url": {
+ "description": "Intended to point to the repo location of the linter, for documentation purposes only.",
+ "type": "string"
+ },
+ "settings": {
+ "description": "Plugins settings/configuration. Only work with plugin based on `linterdb.PluginConstructor`.",
+ "type": "object"
+ }
+ },
+ "oneOf": [
+ {
+ "properties": {
+ "type": {"enum": ["module"] }
+ },
+ "required": ["type"]
+ },
+ {
+ "required": ["path"]
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
+ "linters": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "enable": {
+ "description": "List of enabled linters.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/linters"
+ }
+ },
+ "disable": {
+ "description": "List of disabled linters.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/linters"
+ }
+ },
+ "enable-all": {
+ "description": "Whether to enable all linters. You can re-disable them with `disable` explicitly.",
+ "type": "boolean",
+ "default": false
+ },
+ "disable-all": {
+ "description": "Whether to disable all linters. You can re-enable them with `enable` explicitly.",
+ "type": "boolean",
+ "default": false
+ },
+ "presets": {
+ "description": "Allow to use different presets of linters",
+ "type": "array",
+ "items": {
+ "enum": [
+ "bugs",
+ "comment",
+ "complexity",
+ "error",
+ "format",
+ "import",
+ "metalinter",
+ "module",
+ "performance",
+ "sql",
+ "style",
+ "test",
+ "unused"
+ ]
+ }
+ },
+ "fast": {
+ "description": "Enable run of fast linters.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "issues": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "exclude": {
+ "description": "List of regular expressions of issue texts to exclude.\nBut independently from this option we use default exclude patterns. Their usage can be controlled through `exclude-use-default`.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "exclude-rules": {
+ "description": "Exclude configuration per-path, per-linter, per-text and per-source",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "path": {
+ "type": "string"
+ },
+ "path-except": {
+ "type": "string"
+ },
+ "linters": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/linters"
+ }
+ },
+ "text": {
+ "type": "string"
+ },
+ "source": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "exclude-use-default": {
+ "description": "Independently from option `exclude` we use default exclude patterns. This behavior can be disabled by this option.",
+ "type": "boolean",
+ "default": true
+ },
+ "exclude-case-sensitive": {
+ "description": "If set to true, exclude and exclude-rules regular expressions become case sensitive.",
+ "type": "boolean",
+ "default": false
+ },
+ "exclude-generated": {
+ "description": "Mode of the generated files analysis.",
+ "enum": ["lax", "strict", "disable"],
+ "default": "lax"
+ },
+ "exclude-dirs": {
+ "description": "Which directories to exclude: issues from them won't be reported.",
+ "type": "array",
+ "items": {
+ "description": "You can use regexp here. The regexp is applied on the full path.\n\"/\" will be replaced by current OS file path separator to properly work on Windows.",
+ "type": "string",
+ "examples": ["generated.*"]
+ },
+ "default": [],
+ "examples": [["src/external_libs", "autogenerated_by_my_lib"]]
+ },
+ "exclude-dirs-use-default": {
+ "description": "Enable exclusion of directories \"vendor\", \"third_party\", \"testdata\", \"examples\", \"Godeps\", and \"builtin\".",
+ "type": "boolean",
+ "default": true
+ },
+ "exclude-files": {
+ "description": "Which files to exclude: they will be analyzed, but issues from them will not be reported.",
+ "type": "array",
+ "items": {
+ "description": "You can use regexp here. There is no need to include all autogenerated files, we confidently recognize them. If that is not the case, please let us know.\n\"/\" will be replaced by current OS file path separator to properly work on Windows.",
+ "type": "string",
+ "examples": [".*\\.my\\.go$"]
+ },
+ "default": [],
+ "examples": [[".*\\.my\\.go$", "lib/bad.go"]]
+ },
+ "include": {
+ "description": "The list of ids of default excludes to include or disable.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "default": []
+ },
+ "max-issues-per-linter": {
+ "description": "Maximum issues count per one linter. Set to 0 to disable.",
+ "type": "integer",
+ "default": 50,
+ "minimum": 0
+ },
+ "max-same-issues": {
+ "description": "Maximum count of issues with the same text. Set to 0 to disable.",
+ "type": "integer",
+ "default": 3,
+ "minimum": 0
+ },
+ "new": {
+ "description": "Show only new issues: if there are unstaged changes or untracked files, only those changes are analyzed, else only changes in HEAD~ are analyzed.",
+ "type": "boolean",
+ "default": false
+ },
+ "new-from-rev": {
+ "description": "Show only new issues created after this git revision.",
+ "type": "string"
+ },
+ "new-from-patch": {
+ "description": "Show only new issues created in git patch with this file path.",
+ "type": "string",
+ "examples": ["path/to/patch/file"]
+ },
+ "fix": {
+ "description": "Fix found issues (if it's supported by the linter).",
+ "type": "boolean",
+ "default": false
+ },
+ "uniq-by-line": {
+ "description": "Make issues output unique by line.",
+ "type": "boolean",
+ "default": true
+ },
+ "whole-files": {
+ "description": "Show issues in any part of update files (requires new-from-rev or new-from-patch).",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "severity": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "default-severity": {
+ "description": "Set the default severity for issues. If severity rules are defined and the issues do not match or no severity is provided to the rule this will be the default severity applied. Severities should match the supported severity names of the selected out format.",
+ "type": "string",
+ "default": ""
+ },
+ "case-sensitive": {
+ "description": "If set to true, severity-rules regular expressions become case sensitive.",
+ "type": "boolean",
+ "default": false
+ },
+ "rules": {
+ "description": "When a list of severity rules are provided, severity information will be added to lint issues. Severity rules have the same filtering capability as exclude rules except you are allowed to specify one matcher per severity rule.\nOnly affects out formats that support setting severity information.",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "severity": {
+ "type": "string"
+ },
+ "path": {
+ "type": "string"
+ },
+ "path-except": {
+ "type": "string"
+ },
+ "linters": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/linters"
+ }
+ },
+ "text": {
+ "type": "string"
+ },
+ "source": {
+ "type": "string"
+ }
+ },
+ "required": ["severity"],
+ "anyOf": [
+ { "required": ["path"] },
+ { "required": ["path-except"] },
+ { "required": ["linters"] },
+ { "required": ["text"] },
+ { "required": ["source"] }
+ ]
+ },
+ "default": []
+ }
+ },
+ "required": ["default-severity"]
+ }
+ }
+}
diff --git a/vendor/github.com/golangci/golangci-lint/v2/jsonschema/golangci.v1.64.jsonschema.json b/vendor/github.com/golangci/golangci-lint/v2/jsonschema/golangci.v1.64.jsonschema.json
new file mode 100644
index 0000000000..b265c1a823
--- /dev/null
+++ b/vendor/github.com/golangci/golangci-lint/v2/jsonschema/golangci.v1.64.jsonschema.json
@@ -0,0 +1,4224 @@
+{
+ "$schema": "http://json-schema.org/draft-07/schema#",
+ "$id": "https://json.schemastore.org/golangci-lint.json",
+ "definitions": {
+ "gocritic-checks": {
+ "enum": [
+ "appendAssign",
+ "appendCombine",
+ "argOrder",
+ "assignOp",
+ "badCall",
+ "badCond",
+ "badLock",
+ "badRegexp",
+ "badSorting",
+ "badSyncOnceFunc",
+ "boolExprSimplify",
+ "builtinShadow",
+ "builtinShadowDecl",
+ "captLocal",
+ "caseOrder",
+ "codegenComment",
+ "commentFormatting",
+ "commentedOutCode",
+ "commentedOutImport",
+ "defaultCaseOrder",
+ "deferInLoop",
+ "deferUnlambda",
+ "deprecatedComment",
+ "docStub",
+ "dupArg",
+ "dupBranchBody",
+ "dupCase",
+ "dupImport",
+ "dupSubExpr",
+ "dynamicFmtString",
+ "elseif",
+ "emptyDecl",
+ "emptyFallthrough",
+ "emptyStringTest",
+ "equalFold",
+ "evalOrder",
+ "exitAfterDefer",
+ "exposedSyncMutex",
+ "externalErrorReassign",
+ "filepathJoin",
+ "flagDeref",
+ "flagName",
+ "hexLiteral",
+ "httpNoBody",
+ "hugeParam",
+ "ifElseChain",
+ "importShadow",
+ "indexAlloc",
+ "initClause",
+ "ioutilDeprecated",
+ "mapKey",
+ "methodExprCall",
+ "nestingReduce",
+ "newDeref",
+ "nilValReturn",
+ "octalLiteral",
+ "offBy1",
+ "paramTypeCombine",
+ "preferDecodeRune",
+ "preferFilepathJoin",
+ "preferFprint",
+ "preferStringWriter",
+ "preferWriteByte",
+ "ptrToRefParam",
+ "rangeAppendAll",
+ "rangeExprCopy",
+ "rangeValCopy",
+ "redundantSprint",
+ "regexpMust",
+ "regexpPattern",
+ "regexpSimplify",
+ "returnAfterHttpError",
+ "ruleguard",
+ "singleCaseSwitch",
+ "sliceClear",
+ "sloppyLen",
+ "sloppyReassign",
+ "sloppyTypeAssert",
+ "sortSlice",
+ "sprintfQuotedString",
+ "sqlQuery",
+ "stringConcatSimplify",
+ "stringXbytes",
+ "stringsCompare",
+ "switchTrue",
+ "syncMapLoadAndDelete",
+ "timeExprSimplify",
+ "todoCommentWithoutDetail",
+ "tooManyResultsChecker",
+ "truncateCmp",
+ "typeAssertChain",
+ "typeDefFirst",
+ "typeSwitchVar",
+ "typeUnparen",
+ "uncheckedInlineErr",
+ "underef",
+ "unlabelStmt",
+ "unlambda",
+ "unnamedResult",
+ "unnecessaryBlock",
+ "unnecessaryDefer",
+ "unslice",
+ "valSwap",
+ "weakCond",
+ "whyNoLint",
+ "wrapperFunc",
+ "yodaStyleExpr"
+ ]
+ },
+ "gocritic-tags": {
+ "enum": [
+ "diagnostic",
+ "style",
+ "performance",
+ "experimental",
+ "opinionated",
+ "security"
+ ]
+ },
+ "gosec-rules": {
+ "enum": [
+ "G101",
+ "G102",
+ "G103",
+ "G104",
+ "G106",
+ "G107",
+ "G108",
+ "G109",
+ "G110",
+ "G111",
+ "G112",
+ "G113",
+ "G114",
+ "G115",
+ "G201",
+ "G202",
+ "G203",
+ "G204",
+ "G301",
+ "G302",
+ "G303",
+ "G304",
+ "G305",
+ "G306",
+ "G307",
+ "G401",
+ "G402",
+ "G403",
+ "G404",
+ "G405",
+ "G406",
+ "G501",
+ "G502",
+ "G503",
+ "G504",
+ "G505",
+ "G506",
+ "G507",
+ "G601",
+ "G602"
+ ]
+ },
+ "govet-analyzers": {
+ "enum": [
+ "appends",
+ "asmdecl",
+ "assign",
+ "atomic",
+ "atomicalign",
+ "bools",
+ "buildtag",
+ "cgocall",
+ "composites",
+ "copylocks",
+ "deepequalerrors",
+ "defers",
+ "directive",
+ "errorsas",
+ "fieldalignment",
+ "findcall",
+ "framepointer",
+ "httpresponse",
+ "ifaceassert",
+ "loopclosure",
+ "lostcancel",
+ "nilfunc",
+ "nilness",
+ "printf",
+ "reflectvaluecompare",
+ "shadow",
+ "shift",
+ "sigchanyzer",
+ "slog",
+ "sortslice",
+ "stdmethods",
+ "stdversion",
+ "stringintconv",
+ "structtag",
+ "testinggoroutine",
+ "tests",
+ "timeformat",
+ "unmarshal",
+ "unreachable",
+ "unsafeptr",
+ "unusedresult",
+ "unusedwrite",
+ "waitgroup"
+ ]
+ },
+ "revive-rules": {
+ "enum": [
+ "add-constant",
+ "argument-limit",
+ "atomic",
+ "banned-characters",
+ "bare-return",
+ "blank-imports",
+ "bool-literal-in-expr",
+ "call-to-gc",
+ "cognitive-complexity",
+ "comment-spacings",
+ "comments-density",
+ "confusing-naming",
+ "confusing-results",
+ "constant-logical-expr",
+ "context-as-argument",
+ "context-keys-type",
+ "cyclomatic",
+ "datarace",
+ "deep-exit",
+ "defer",
+ "dot-imports",
+ "duplicated-imports",
+ "early-return",
+ "empty-block",
+ "empty-lines",
+ "enforce-map-style",
+ "enforce-repeated-arg-type-style",
+ "enforce-slice-style",
+ "error-naming",
+ "error-return",
+ "error-strings",
+ "errorf",
+ "exported",
+ "file-header",
+ "file-length-limit",
+ "filename-format",
+ "flag-parameter",
+ "function-length",
+ "function-result-limit",
+ "get-return",
+ "identical-branches",
+ "if-return",
+ "import-alias-naming",
+ "import-shadowing",
+ "imports-blocklist",
+ "increment-decrement",
+ "indent-error-flow",
+ "line-length-limit",
+ "max-control-nesting",
+ "max-public-structs",
+ "modifies-parameter",
+ "modifies-value-receiver",
+ "nested-structs",
+ "optimize-operands-order",
+ "package-comments",
+ "range-val-address",
+ "range-val-in-closure",
+ "range",
+ "receiver-naming",
+ "redefines-builtin-id",
+ "redundant-build-tag",
+ "redundant-import-alias",
+ "string-format",
+ "string-of-int",
+ "struct-tag",
+ "superfluous-else",
+ "time-equal",
+ "time-naming",
+ "unchecked-type-assertion",
+ "unconditional-recursion",
+ "unexported-naming",
+ "unexported-return",
+ "unhandled-error",
+ "unnecessary-stmt",
+ "unreachable-code",
+ "unused-parameter",
+ "unused-receiver",
+ "use-any",
+ "use-errors-new",
+ "useless-break",
+ "var-declaration",
+ "var-naming",
+ "waitgroup-by-value"
+ ]
+ },
+ "iface-analyzers": {
+ "enum": [
+ "identical",
+ "unused",
+ "opaque"
+ ]
+ },
+ "tagliatelle-cases": {
+ "enum": [
+ "",
+ "camel",
+ "pascal",
+ "kebab",
+ "snake",
+ "goCamel",
+ "goPascal",
+ "goKebab",
+ "goSnake",
+ "upper",
+ "upperSnake",
+ "lower",
+ "header"
+ ]
+ },
+ "linters": {
+ "$comment": "anyOf with enum is used to allow auto completion of non-custom linters",
+ "description": "Linters usable.",
+ "anyOf": [
+ {
+ "enum": [
+ "asasalint",
+ "asciicheck",
+ "bidichk",
+ "bodyclose",
+ "canonicalheader",
+ "containedctx",
+ "contextcheck",
+ "copyloopvar",
+ "cyclop",
+ "decorder",
+ "depguard",
+ "dogsled",
+ "dupl",
+ "dupword",
+ "durationcheck",
+ "errcheck",
+ "errchkjson",
+ "errname",
+ "errorlint",
+ "exhaustive",
+ "exhaustruct",
+ "exptostd",
+ "fatcontext",
+ "forbidigo",
+ "forcetypeassert",
+ "funlen",
+ "gci",
+ "ginkgolinter",
+ "gocheckcompilerdirectives",
+ "gochecknoglobals",
+ "gochecknoinits",
+ "gochecksumtype",
+ "gocognit",
+ "goconst",
+ "gocritic",
+ "gocyclo",
+ "godot",
+ "godox",
+ "err113",
+ "gofmt",
+ "gofumpt",
+ "goheader",
+ "goimports",
+ "gomoddirectives",
+ "gomodguard",
+ "goprintffuncname",
+ "gosec",
+ "gosimple",
+ "gosmopolitan",
+ "govet",
+ "grouper",
+ "iface",
+ "importas",
+ "inamedparam",
+ "ineffassign",
+ "interfacebloat",
+ "intrange",
+ "ireturn",
+ "lll",
+ "loggercheck",
+ "maintidx",
+ "makezero",
+ "mirror",
+ "misspell",
+ "mnd",
+ "musttag",
+ "nakedret",
+ "nestif",
+ "nilerr",
+ "nilnesserr",
+ "nilnil",
+ "nlreturn",
+ "noctx",
+ "nolintlint",
+ "nonamedreturns",
+ "nosprintfhostport",
+ "paralleltest",
+ "perfsprint",
+ "prealloc",
+ "predeclared",
+ "promlinter",
+ "protogetter",
+ "reassign",
+ "recvcheck",
+ "revive",
+ "rowserrcheck",
+ "sloglint",
+ "sqlclosecheck",
+ "staticcheck",
+ "stylecheck",
+ "tagalign",
+ "tagliatelle",
+ "tenv",
+ "testableexamples",
+ "testifylint",
+ "testpackage",
+ "thelper",
+ "tparallel",
+ "unconvert",
+ "unparam",
+ "unused",
+ "usestdlibvars",
+ "usetesting",
+ "varnamelen",
+ "wastedassign",
+ "whitespace",
+ "wrapcheck",
+ "wsl",
+ "zerologlint"
+ ]
+ },
+ {
+ "type": "string"
+ }
+ ]
+ },
+ "relative-path-modes": {
+ "enum": [
+ "gomod",
+ "gitroot",
+ "cfg",
+ "wd"
+ ]
+ }
+ },
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "run": {
+ "description": "Options for analysis running,",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "concurrency": {
+ "description": "Number of concurrent runners. Defaults to the number of available CPU cores.",
+ "type": "integer",
+ "minimum": 0,
+ "examples": [4]
+ },
+ "timeout": {
+ "description": "Timeout for the analysis.",
+ "type": "string",
+ "pattern": "^((\\d+h)?(\\d+m)?(\\d+(?:\\.\\d)?s)?|0)$",
+ "default": "1m",
+ "examples": ["30s", "5m", "5m30s"]
+ },
+ "issues-exit-code": {
+ "description": "Exit code when at least one issue was found.",
+ "type": "integer",
+ "default": 1
+ },
+ "tests": {
+ "description": "Enable inclusion of test files.",
+ "type": "boolean",
+ "default": true
+ },
+ "build-tags": {
+ "description": "List of build tags to pass to all linters.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "default": [],
+ "examples": [["mytag"]]
+ },
+ "modules-download-mode": {
+ "description": "Option to pass to \"go list -mod={option}\".\nSee \"go help modules\" for more information.",
+ "enum": ["mod", "readonly", "vendor"]
+ },
+ "allow-parallel-runners": {
+ "description": "Allow multiple parallel golangci-lint instances running. If disabled, golangci-lint acquires file lock on start.",
+ "type": "boolean",
+ "default": false
+ },
+ "allow-serial-runners": {
+ "description": "Allow multiple golangci-lint instances running, but serialize them around a lock.",
+ "type": "boolean",
+ "default": false
+ },
+ "go": {
+ "description": "Targeted Go version.",
+ "type": "string",
+ "default": "1.17"
+ },
+ "relative-path-mode": {
+ "description": "The mode used to evaluate relative paths.",
+ "type": "string",
+ "$ref": "#/definitions/relative-path-modes",
+ "default": "wd"
+ }
+ }
+ },
+ "output": {
+ "description": "Output configuration options.",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "formats": {
+ "description": "Output formats to use.",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "path": {
+ "default": "stdout",
+ "anyOf": [
+ {
+ "enum": [ "stdout", "stderr" ]
+ },
+ {
+ "type": "string"
+ }
+ ]
+ },
+ "format": {
+ "default": "colored-line-number",
+ "enum": [
+ "colored-line-number",
+ "line-number",
+ "json",
+ "colored-tab",
+ "tab",
+ "html",
+ "checkstyle",
+ "code-climate",
+ "junit-xml",
+ "junit-xml-extended",
+ "github-actions",
+ "teamcity",
+ "sarif"
+ ]
+ }
+ },
+ "required": ["format"]
+ }
+ },
+ "print-issued-lines": {
+ "description": "Print lines of code with issue.",
+ "type": "boolean",
+ "default": true
+ },
+ "print-linter-name": {
+ "description": "Print linter name in the end of issue text.",
+ "type": "boolean",
+ "default": true
+ },
+ "path-prefix": {
+ "description": "Add a prefix to the output file references.",
+ "type": "string",
+ "default": ""
+ },
+ "show-stats": {
+ "description": "Show statistics per linter.",
+ "type": "boolean",
+ "default": false
+ },
+ "sort-order": {
+ "type": "array",
+ "items": {
+ "enum": ["linter", "severity", "file"]
+ }
+ },
+ "sort-results": {
+ "description": "Sort results by: filepath, line and column.",
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "linters-settings": {
+ "description": "All available settings of specific linters.",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "dupword": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "keywords": {
+ "description": "Keywords for detecting duplicate words. If this list is not empty, only the words defined in this list will be detected.",
+ "type": "array",
+ "uniqueItems": true,
+ "items": {
+ "type": "string",
+ "examples": ["the", "and", "a"]
+ }
+ },
+ "ignore": {
+ "description": "Keywords used to ignore detection.",
+ "type": "array",
+ "uniqueItems": true,
+ "items": {
+ "type": "string",
+ "examples": ["0C0C"]
+ }
+ }
+ }
+ },
+ "asasalint": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "exclude": {
+ "description": "To specify a set of function names to exclude.",
+ "type": "array",
+ "uniqueItems": true,
+ "items": {
+ "type": "string",
+ "examples": ["\\.Wrapf"]
+ }
+ },
+ "use-builtin-exclusions": {
+ "description": "To enable/disable the asasalint builtin exclusions of function names.",
+ "type": "boolean",
+ "default": true
+ },
+ "ignore-test": {
+ "description": "Ignore *_test.go files.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "bidichk": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "left-to-right-embedding": {
+ "description": "Disallow: LEFT-TO-RIGHT-EMBEDDING",
+ "type": "boolean",
+ "default": false
+ },
+ "right-to-left-embedding": {
+ "description": "Disallow: RIGHT-TO-LEFT-EMBEDDING",
+ "type": "boolean",
+ "default": false
+ },
+ "pop-directional-formatting": {
+ "description": "Disallow: POP-DIRECTIONAL-FORMATTING",
+ "type": "boolean",
+ "default": false
+ },
+ "left-to-right-override": {
+ "description": "Disallow: LEFT-TO-RIGHT-OVERRIDE",
+ "type": "boolean",
+ "default": false
+ },
+ "right-to-left-override": {
+ "description": "Disallow: RIGHT-TO-LEFT-OVERRIDE",
+ "type": "boolean",
+ "default": false
+ },
+ "left-to-right-isolate": {
+ "description": "Disallow: LEFT-TO-RIGHT-ISOLATE",
+ "type": "boolean",
+ "default": false
+ },
+ "right-to-left-isolate": {
+ "description": "Disallow: RIGHT-TO-LEFT-ISOLATE",
+ "type": "boolean",
+ "default": false
+ },
+ "first-strong-isolate": {
+ "description": "Disallow: FIRST-STRONG-ISOLATE",
+ "type": "boolean",
+ "default": false
+ },
+ "pop-directional-isolate": {
+ "description": "Disallow: POP-DIRECTIONAL-ISOLATE",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "cyclop": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "skip-tests": {
+ "description": "Should the linter execute on test files as well",
+ "type": "boolean",
+ "default": false
+ },
+ "max-complexity": {
+ "description": "Max complexity the function can have",
+ "type": "integer",
+ "default": 10,
+ "minimum": 0
+ },
+ "package-average": {
+ "description": "Max average complexity in package",
+ "type": "number",
+ "default": 0,
+ "minimum": 0
+ }
+ }
+ },
+ "decorder": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "dec-order": {
+ "type": "array",
+ "default": [["type", "const", "var", "func"]],
+ "items": {
+ "enum": ["type", "const", "var", "func"]
+ }
+ },
+ "ignore-underscore-vars": {
+ "description": "Underscore vars (vars with \"_\" as the name) will be ignored at all checks",
+ "default": true,
+ "type": "boolean"
+ },
+ "disable-dec-order-check": {
+ "description": "Order of declarations is not checked",
+ "default": true,
+ "type": "boolean"
+ },
+ "disable-init-func-first-check": {
+ "description": "Allow init func to be anywhere in file",
+ "default": true,
+ "type": "boolean"
+ },
+ "disable-dec-num-check": {
+ "description": "Multiple global type, const and var declarations are allowed",
+ "default": true,
+ "type": "boolean"
+ },
+ "disable-type-dec-num-check": {
+ "description": "Type declarations will be ignored for dec num check",
+ "default": true,
+ "type": "boolean"
+ },
+ "disable-const-dec-num-check": {
+ "description": "Const declarations will be ignored for dec num check",
+ "default": true,
+ "type": "boolean"
+ },
+ "disable-var-dec-num-check": {
+ "description": "Var declarations will be ignored for dec num check",
+ "default": true,
+ "type": "boolean"
+ }
+ }
+ },
+ "depguard": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "rules": {
+ "description": "Rules to apply.",
+ "type": "object",
+ "additionalProperties": false,
+ "patternProperties": {
+ "^[^.]+$": {
+ "description": "Name of a rule.",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "list-mode": {
+ "description": "Used to determine the package matching priority.",
+ "enum": ["original", "strict", "lax"],
+ "default": "original"
+ },
+ "files": {
+ "description": "List of file globs that will match this list of settings to compare against.",
+ "additionalProperties": false,
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "allow": {
+ "description": "List of allowed packages.",
+ "additionalProperties": false,
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "deny": {
+ "description": "Packages that are not allowed where the value is a suggestion.",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "desc": {
+ "description": "Description",
+ "type": "string"
+ },
+ "pkg": {
+ "description": "Package",
+ "type": "string"
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "dogsled": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "max-blank-identifiers": {
+ "description": "Check assignments with too many blank identifiers.",
+ "type": "integer",
+ "default": 2,
+ "minimum": 0
+ }
+ }
+ },
+ "dupl": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "threshold": {
+ "description": "Tokens count to trigger issue.",
+ "type": "integer",
+ "default": 150,
+ "minimum": 0
+ }
+ }
+ },
+ "errcheck": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "check-type-assertions": {
+ "description": "Report about not checking errors in type assertions, i.e.: `a := b.(MyStruct)`",
+ "type": "boolean",
+ "default": false
+ },
+ "check-blank": {
+ "description": "Report about assignment of errors to blank identifier",
+ "type": "boolean",
+ "default": false
+ },
+ "exclude-functions": {
+ "description": "List of functions to exclude from checking, where each entry is a single function to exclude",
+ "type": "array",
+ "examples": ["io/ioutil.ReadFile", "io.Copy(*bytes.Buffer)"],
+ "items": {
+ "type": "string"
+ }
+ },
+ "disable-default-exclusions": {
+ "description": "To disable the errcheck built-in exclude list",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "errchkjson": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "check-error-free-encoding": {
+ "type": "boolean",
+ "default": false
+ },
+ "report-no-exported": {
+ "description": "Issue on struct that doesn't have exported fields.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "errorlint": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "errorf": {
+ "description": "Check whether fmt.Errorf uses the %w verb for formatting errors",
+ "type": "boolean",
+ "default": true
+ },
+ "errorf-multi": {
+ "description": "Permit more than 1 %w verb, valid per Go 1.20",
+ "type": "boolean",
+ "default": true
+ },
+ "asserts": {
+ "description": "Check for plain type assertions and type switches.",
+ "type": "boolean",
+ "default": true
+ },
+ "comparison": {
+ "description": "Check for plain error comparisons",
+ "type": "boolean",
+ "default": true
+ },
+ "allowed-errors": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "err": {
+ "type": "string"
+ },
+ "fun": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "allowed-errors-wildcard": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "err": {
+ "type": "string"
+ },
+ "fun": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ }
+ },
+ "exhaustive": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "check": {
+ "description": "Program elements to check for exhaustiveness.",
+ "type": "array",
+ "uniqueItems": true,
+ "items": {
+ "type": "string",
+ "examples": ["switch", "map"]
+ }
+ },
+ "check-generated": {
+ "description": "Check switch statements in generated files",
+ "type": "boolean",
+ "default": false
+ },
+ "explicit-exhaustive-switch": {
+ "description": "Only run exhaustive check on switches with \"//exhaustive:enforce\" comment.",
+ "type": "boolean",
+ "default": false
+ },
+ "explicit-exhaustive-map": {
+ "description": "Only run exhaustive check on map literals with \"//exhaustive:enforce\" comment.",
+ "type": "boolean",
+ "default": false
+ },
+ "default-case-required": {
+ "description": "Switch statement requires default case even if exhaustive.",
+ "type": "boolean",
+ "default": false
+ },
+ "default-signifies-exhaustive": {
+ "description": "Presence of `default` case in switch statements satisfies exhaustiveness, even if all enum members are not listed.",
+ "type": "boolean",
+ "default": false
+ },
+ "ignore-enum-members": {
+ "description": "Enum members matching `regex` do not have to be listed in switch statements to satisfy exhaustiveness",
+ "type": "string"
+ },
+ "ignore-enum-types": {
+ "description": "Enum types matching the supplied regex do not have to be listed in switch statements to satisfy exhaustiveness.",
+ "type": "string"
+ },
+ "package-scope-only": {
+ "description": "Consider enums only in package scopes, not in inner scopes.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "exhaustruct": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "include": {
+ "description": "List of regular expressions to match struct packages and names.",
+ "type": "array",
+ "examples": [".*\\.Test"],
+ "items": {
+ "type": "string"
+ }
+ },
+ "exclude": {
+ "description": "List of regular expressions to exclude struct packages and names from check.",
+ "type": "array",
+ "examples": ["cobra\\.Command$"],
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "fatcontext": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "check-struct-pointers": {
+ "description": "Check for potential fat contexts in struct pointers.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "forbidigo": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "exclude-godoc-examples": {
+ "description": "Exclude code in godoc examples.",
+ "type": "boolean",
+ "default": true
+ },
+ "analyze-types": {
+ "description": "Instead of matching the literal source code, use type information to replace expressions with strings that contain the package name and (for methods and fields) the type name.",
+ "type": "boolean",
+ "default": true
+ },
+ "forbid": {
+ "description": "List of identifiers to forbid (written using `regexp`)",
+ "type": "array",
+ "examples": ["^print(ln)?$"],
+ "items": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "p": {
+ "description": "Pattern",
+ "type": "string"
+ },
+ "pkg": {
+ "description": "Package",
+ "type": "string"
+ },
+ "msg": {
+ "description": "Message",
+ "type": "string"
+ }
+ }
+ }
+ ]
+ }
+ }
+ }
+ },
+ "funlen": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "lines": {
+ "description": "Limit lines number per function.",
+ "type": "integer",
+ "default": 60
+ },
+ "statements": {
+ "description": "Limit statements number per function.",
+ "type": "integer",
+ "default": 40
+ },
+ "ignore-comments": {
+ "description": "Ignore comments when counting lines.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "gci": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "sections": {
+ "description": "Section configuration to compare against.",
+ "type": "array",
+ "items": {
+ "anyOf": [
+ {
+ "enum": [
+ "standard",
+ "default",
+ "blank",
+ "dot",
+ "alias",
+ "localmodule"
+ ]
+ },
+ {
+ "type": "string"
+ }
+ ]
+ },
+ "default": ["standard", "default"]
+ },
+ "skip-generated": {
+ "description": "Skip generated files.",
+ "type": "boolean",
+ "default": true
+ },
+ "no-inline-comments": {
+ "description": "Checks that no inline Comments are present.",
+ "type": "boolean",
+ "default": false
+ },
+ "no-prefix-comments": {
+ "description": "Checks that no prefix Comments(comment lines above an import) are present.",
+ "type": "boolean",
+ "default": false
+ },
+ "custom-order": {
+ "description": "Enable custom order of sections.",
+ "type": "boolean",
+ "default": false
+ },
+ "no-lex-order": {
+ "description": "Drops lexical ordering for custom sections.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "ginkgolinter": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "suppress-len-assertion": {
+ "description": "Suppress the wrong length assertion warning.",
+ "type": "boolean",
+ "default": false
+ },
+ "suppress-nil-assertion": {
+ "description": "Suppress the wrong nil assertion warning.",
+ "type": "boolean",
+ "default": false
+ },
+ "suppress-err-assertion": {
+ "description": "Suppress the wrong error assertion warning.",
+ "type": "boolean",
+ "default": false
+ },
+ "suppress-compare-assertion": {
+ "description": "Suppress the wrong comparison assertion warning.",
+ "type": "boolean",
+ "default": false
+ },
+ "suppress-async-assertion": {
+ "description": "Suppress the function all in async assertion warning.",
+ "type": "boolean",
+ "default": false
+ },
+ "suppress-type-compare-assertion": {
+ "description": "Suppress warning for comparing values from different types, like int32 and uint32.",
+ "type": "boolean",
+ "default": false
+ },
+ "forbid-focus-container": {
+ "description": "Trigger warning for ginkgo focus containers like FDescribe, FContext, FWhen or FIt.",
+ "type": "boolean",
+ "default": false
+ },
+ "allow-havelen-zero": {
+ "description": "Don't trigger warnings for HaveLen(0).",
+ "type": "boolean",
+ "default": false
+ },
+ "force-expect-to": {
+ "description": "Force using `Expect` with `To`, `ToNot` or `NotTo`",
+ "type": "boolean",
+ "default": false
+ },
+ "validate-async-intervals": {
+ "description": "Best effort validation of async intervals (timeout and polling).",
+ "type": "boolean",
+ "default": false
+ },
+ "forbid-spec-pollution": {
+ "description": "Trigger a warning for variable assignments in ginkgo containers like `Describe`, `Context` and `When`, instead of in `BeforeEach()`.",
+ "type": "boolean",
+ "default": false
+ },
+ "force-succeed": {
+ "description": "Force using the Succeed matcher for error functions, and the HaveOccurred matcher for non-function error values.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "gochecksumtype": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "default-signifies-exhaustive": {
+ "description": "Presence of `default` case in switch statements satisfies exhaustiveness, if all members are not listed.",
+ "type": "boolean",
+ "default": true
+ },
+ "include-shared-interfaces": {
+ "description": "Include shared interfaces in the exhaustiviness check.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "gocognit": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "min-complexity": {
+ "description": "Minimal code complexity to report (we recommend 10-20).",
+ "type": "integer",
+ "default": 30
+ }
+ }
+ },
+ "goconst": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "match-constant": {
+ "description": "Look for existing constants matching the values",
+ "type": "boolean",
+ "default": true
+ },
+ "min-len": {
+ "description": "Minimum length of string constant.",
+ "type": "integer",
+ "default": 3
+ },
+ "min-occurrences": {
+ "description": "Minimum occurrences count to trigger.",
+ "type": "integer",
+ "default": 3
+ },
+ "ignore-tests": {
+ "description": "Ignore test files.",
+ "type": "boolean",
+ "default": false
+ },
+ "ignore-calls": {
+ "description": "Ignore when constant is not used as function argument",
+ "type": "boolean",
+ "default": true
+ },
+ "ignore-strings": {
+ "description": "Exclude strings matching the given regular expression",
+ "type": "string"
+ },
+ "numbers": {
+ "description": "Search also for duplicated numbers.",
+ "type": "boolean",
+ "default": false
+ },
+ "min": {
+ "description": "Minimum value, only works with `numbers`",
+ "type": "integer",
+ "default": 3
+ },
+ "max": {
+ "description": "Maximum value, only works with `numbers`",
+ "type": "integer",
+ "default": 3
+ }
+ }
+ },
+ "gocritic": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "enabled-checks": {
+ "description": "Which checks should be enabled. By default, a list of stable checks is used. To see it, run `GL_DEBUG=gocritic golangci-lint run`.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/gocritic-checks"
+ }
+ },
+ "disabled-checks": {
+ "description": "Which checks should be disabled.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/gocritic-checks"
+ },
+ "default": []
+ },
+ "enabled-tags": {
+ "description": "Enable multiple checks by tags, run `GL_DEBUG=gocritic golangci-lint run` to see all tags and checks.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/gocritic-tags"
+ }
+ },
+ "disabled-tags": {
+ "description": "Disable multiple checks by tags, run `GL_DEBUG=gocritic golangci-lint run` to see all tags and checks.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/gocritic-tags"
+ }
+ },
+ "settings": {
+ "description": "Settings passed to gocritic. Properties must be valid and enabled check names.",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "captLocal": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "paramsOnly" : {
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "commentedOutCode": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "minLength" : {
+ "type": "number",
+ "default": 15
+ }
+ }
+ },
+ "elseif": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "skipBalanced" : {
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "hugeParam": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "sizeThreshold" : {
+ "type": "number",
+ "default": 80
+ }
+ }
+ },
+ "ifElseChain": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "minThreshold" : {
+ "type": "number",
+ "default": 2
+ }
+ }
+ },
+ "nestingReduce": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "bodyWidth" : {
+ "type": "number",
+ "default": 5
+ }
+ }
+ },
+ "rangeExprCopy": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "sizeThreshold" : {
+ "type": "number",
+ "default": 512
+ },
+ "skipTestFuncs" : {
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "rangeValCopy": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "sizeThreshold" : {
+ "type": "number",
+ "default": 128
+ },
+ "skipTestFuncs" : {
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "ruleguard": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "debug" : {
+ "type": "string"
+ },
+ "enable" : {
+ "type": "string"
+ },
+ "disable" : {
+ "type": "string"
+ },
+ "failOn" : {
+ "type": "string"
+ },
+ "rules" : {
+ "type": "string"
+ }
+ }
+ },
+ "tooManyResultsChecker": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "maxResults" : {
+ "type": "number",
+ "default": 5
+ }
+ }
+ },
+ "truncateCmp": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "skipArchDependent" : {
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "underef": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "skipRecvDeref" : {
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "unnamedResult": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "checkExported" : {
+ "type": "boolean",
+ "default": false
+ }
+ }
+ }
+ }
+ },
+ "disable-all": {
+ "type": "boolean",
+ "default": false
+ },
+ "enable-all": {
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "gocyclo": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "min-complexity": {
+ "description": "Minimum code complexity to report (we recommend 10-20).",
+ "type": "integer",
+ "default": 30
+ }
+ }
+ },
+ "godot": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "scope": {
+ "description": "Comments to be checked.",
+ "enum": ["declarations", "toplevel", "all"],
+ "default": "declarations"
+ },
+ "exclude": {
+ "description": "List of regexps for excluding particular comment lines from check.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "period": {
+ "description": "Check that each sentence ends with a period.",
+ "type": "boolean",
+ "default": true
+ },
+ "capital": {
+ "description": "Check that each sentence starts with a capital letter.",
+ "type": "boolean",
+ "default": false
+ },
+ "check-all": {
+ "description": "DEPRECATED: Check all top-level comments, not only declarations.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "godox": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "keywords": {
+ "description": "Report any comments starting with one of these keywords. This is useful for TODO or FIXME comments that might be left in the code accidentally and should be resolved before merging.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "default": ["TODO", "BUG", "FIXME"]
+ }
+ }
+ },
+ "gofmt": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "simplify": {
+ "description": "Simplify code.",
+ "type": "boolean",
+ "default": true
+ },
+ "rewrite-rules": {
+ "description": "Apply the rewrite rules to the source before reformatting.",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "pattern": {
+ "type": "string"
+ },
+ "replacement": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ }
+ },
+ "interfacebloat": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "max": {
+ "description": "The maximum number of methods allowed for an interface.",
+ "type": "integer"
+ }
+ }
+ },
+ "gofumpt": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "extra-rules": {
+ "description": "Choose whether or not to use the extra rules that are disabled by default.",
+ "type": "boolean",
+ "default": false
+ },
+ "module-path": {
+ "description": " Module path which contains the source code being formatted.",
+ "type": "string"
+ }
+ }
+ },
+ "goheader": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "values": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "const": {
+ "description": "Constants to use in the template.",
+ "type": "object",
+ "patternProperties": {
+ "^.+$": {
+ "description": "Value for the constant.",
+ "type": "string"
+ }
+ },
+ "additionalProperties": false,
+ "examples": [
+ {
+ "YEAR": "2030",
+ "COMPANY": "MY FUTURISTIC COMPANY"
+ }
+ ]
+ },
+ "regexp": {
+ "description": "Regular expressions to use in your template.",
+ "type": "object",
+ "additionalProperties": false,
+ "patternProperties": {
+ "^.+$": {
+ "type": "string"
+ }
+ },
+ "examples": [
+ {
+ "AUTHOR": ".*@mycompany\\.com"
+ }
+ ]
+ }
+ }
+ },
+ "template": {
+ "description": "Template to put on top of every file.",
+ "type": "string",
+ "examples": [
+ "{{ MY COMPANY }}\nSPDX-License-Identifier: Apache-2.0\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at:\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License."
+ ]
+ },
+ "template-path": {
+ "description": "Path to the file containing the template source.",
+ "type": "string",
+ "examples": ["my_header_template.txt"]
+ }
+ },
+ "oneOf": [
+ { "required": ["template"] },
+ { "required": ["template-path"] }
+ ]
+ },
+ "goimports": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "local-prefixes": {
+ "description": "Put imports beginning with prefix after 3rd-party packages. It is a comma-separated list of prefixes.",
+ "type": "string",
+ "examples": ["github.com/org/project"]
+ }
+ }
+ },
+ "gomoddirectives": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "replace-local": {
+ "description": "Allow local `replace` directives.",
+ "type": "boolean",
+ "default": true
+ },
+ "replace-allow-list": {
+ "description": "List of allowed `replace` directives.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "retract-allow-no-explanation": {
+ "description": "Allow to not explain why the version has been retracted in the `retract` directives.",
+ "type": "boolean",
+ "default": false
+ },
+ "exclude-forbidden": {
+ "description": "Forbid the use of the `exclude` directives.",
+ "type": "boolean",
+ "default": false
+ },
+ "toolchain-forbidden": {
+ "description": "Forbid the use of the `toolchain` directive.",
+ "type": "boolean",
+ "default": false
+ },
+ "toolchain-pattern": {
+ "description": "Defines a pattern to validate `toolchain` directive.",
+ "type": "string"
+ },
+ "tool-forbidden": {
+ "description": "Forbid the use of the `tool` directives.",
+ "type": "boolean",
+ "default": false
+ },
+ "go-debug-forbidden": {
+ "description": "Forbid the use of the `godebug` directive.",
+ "type": "boolean",
+ "default": false
+ },
+ "go-version-pattern": {
+ "description": "Defines a pattern to validate `go` minimum version directive.",
+ "type": "string",
+ "default": ""
+ }
+ }
+ },
+ "gomodguard": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "allowed": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "modules": {
+ "description": "List of allowed modules.",
+ "type": "array",
+ "items": {
+ "type": "string",
+ "examples": ["gopkg.in/yaml.v2"]
+ }
+ },
+ "domains": {
+ "description": "List of allowed module domains.",
+ "type": "array",
+ "items": {
+ "type": "string",
+ "examples": ["golang.org"]
+ }
+ }
+ }
+ },
+ "blocked": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "modules": {
+ "description": "List of blocked modules.",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "patternProperties": {
+ "^.+$": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "recommendations": {
+ "description": "Recommended modules that should be used instead.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "reason": {
+ "description": "Reason why the recommended module should be used.",
+ "type": "string"
+ }
+ }
+ }
+ },
+ "additionalProperties": false
+ }
+ },
+ "versions": {
+ "description": "List of blocked module version constraints.",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "patternProperties": {
+ "^.*$": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "version": {
+ "description": "Version constraint.",
+ "type": "string"
+ },
+ "reason": {
+ "description": "Reason why the version constraint exists.",
+ "type": "string"
+ }
+ },
+ "required": ["reason"]
+ }
+ }
+ }
+ },
+ "local_replace_directives": {
+ "description": "Raise lint issues if loading local path with replace directive",
+ "type": "boolean",
+ "default": true
+ }
+ }
+ }
+ }
+ },
+ "gosimple": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "checks": {
+ "type": "array",
+ "items": {
+ "anyOf": [
+ {
+ "enum": ["all"]
+ },
+ {
+ "type": "string"
+ }
+ ]
+ }
+ }
+ }
+ },
+ "gosec": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "includes": {
+ "type": "array",
+ "description": "To select a subset of rules to run",
+ "examples": [["G401"]],
+ "items": {
+ "$ref": "#/definitions/gosec-rules"
+ }
+ },
+ "excludes": {
+ "type": "array",
+ "description": "To specify a set of rules to explicitly exclude",
+ "examples": [["G401"]],
+ "items": {
+ "$ref": "#/definitions/gosec-rules"
+ }
+ },
+ "exclude-generated": {
+ "description": "Exclude generated files",
+ "type": "boolean",
+ "default": false
+ },
+ "severity": {
+ "description": "Filter out the issues with a lower severity than the given value",
+ "type": "string",
+ "enum": ["low", "medium", "high"],
+ "default": "low"
+ },
+ "confidence": {
+ "description": "Filter out the issues with a lower confidence than the given value",
+ "type": "string",
+ "enum": ["low", "medium", "high"],
+ "default": "low"
+ },
+ "config": {
+ "description": "To specify the configuration of rules",
+ "type": "object"
+ },
+ "concurrency": {
+ "description": "Concurrency value",
+ "type": "integer"
+ }
+ }
+ },
+ "gosmopolitan": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "allow-time-local": {
+ "description": "Allow and ignore `time.Local` usages.",
+ "type": "boolean",
+ "default": false
+ },
+ "escape-hatches": {
+ "description": "List of fully qualified names in the `full/pkg/path.name` form, to act as \"i18n escape hatches\".",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ignore-tests": {
+ "description": "Ignore test files.",
+ "type": "boolean",
+ "default": false
+ },
+ "watch-for-scripts": {
+ "description": "List of Unicode scripts to watch for any usage in string literals.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "govet": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "settings": {
+ "description": "Settings per analyzer. Map of analyzer name to specific settings.\nRun `go tool vet help` to find out more.",
+ "type": "object",
+ "propertyNames": {
+ "$ref": "#/definitions/govet-analyzers"
+ },
+ "patternProperties": {
+ "^.*$": {
+ "description": "Run `go tool vet help ` to see all settings.",
+ "type": "object"
+ }
+ }
+ },
+ "enable": {
+ "description": "Enable analyzers by name.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/govet-analyzers"
+ }
+ },
+ "disable": {
+ "description": "Disable analyzers by name.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/govet-analyzers"
+ }
+ },
+ "enable-all": {
+ "description": "Enable all analyzers.",
+ "type": "boolean",
+ "default": false
+ },
+ "disable-all": {
+ "description": "Disable all analyzers.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "grouper": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "const-require-single-const": {
+ "type": "boolean",
+ "default": false
+ },
+ "const-require-grouping": {
+ "type": "boolean",
+ "default": false
+ },
+ "import-require-single-import": {
+ "type": "boolean",
+ "default": false
+ },
+ "import-require-grouping": {
+ "type": "boolean",
+ "default": false
+ },
+ "type-require-single-type": {
+ "type": "boolean",
+ "default": false
+ },
+ "type-require-grouping": {
+ "type": "boolean",
+ "default": false
+ },
+ "var-require-single-var": {
+ "type": "boolean",
+ "default": false
+ },
+ "var-require-grouping": {
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "iface": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "enable": {
+ "description": "Enable analyzers by name.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/iface-analyzers"
+ }
+ },
+ "settings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "unused": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "exclude": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "importas": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "no-unaliased": {
+ "description": "Do not allow unaliased imports of aliased packages.",
+ "type": "boolean",
+ "default": false
+ },
+ "no-extra-aliases": {
+ "description": "Do not allow non-required aliases.",
+ "type": "boolean",
+ "default": false
+ },
+ "alias": {
+ "description": "List of aliases",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "pkg": {
+ "description": "Package path e.g. knative.dev/serving/pkg/apis/autoscaling/v1alpha1",
+ "type": "string"
+ },
+ "alias": {
+ "description": "Package alias e.g. autoscalingv1alpha1",
+ "type": "string"
+ }
+ },
+ "required": ["pkg", "alias"]
+ }
+ }
+ }
+ },
+ "inamedparam": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "skip-single-param": {
+ "description": "Skips check for interface methods with only a single parameter.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "ireturn": {
+ "type": "object",
+ "additionalProperties": false,
+ "description": "Use either `reject` or `allow` properties for interfaces matching.",
+ "properties": {
+ "allow": {
+ "type": "array",
+ "items": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "enum": ["anon", "error", "empty", "stdlib"]
+ }
+ ]
+ }
+ },
+ "reject": {
+ "type": "array",
+ "items": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "enum": ["anon", "error", "empty", "stdlib"]
+ }
+ ]
+ }
+ }
+ },
+ "anyOf": [
+ {
+ "not": {
+ "properties": {
+ "allow": {
+ "const": "reject"
+ }
+ }
+ },
+ "required": ["allow"]
+ },
+ {
+ "required": ["reject"]
+ }
+ ]
+ },
+ "lll": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "tab-width": {
+ "description": "Width of \"\\t\" in spaces.",
+ "type": "integer",
+ "minimum": 0,
+ "default": 1
+ },
+ "line-length": {
+ "description": "Maximum allowed line length, lines longer will be reported.",
+ "type": "integer",
+ "minimum": 1,
+ "default": 120
+ }
+ }
+ },
+ "maintidx": {
+ "description": "Maintainability index https://docs.microsoft.com/en-us/visualstudio/code-quality/code-metrics-maintainability-index-range-and-meaning?view=vs-2022",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "under": {
+ "description": "Minimum accatpable maintainability index level (see https://docs.microsoft.com/en-us/visualstudio/code-quality/code-metrics-maintainability-index-range-and-meaning?view=vs-2022)",
+ "type": "number",
+ "default": 20
+ }
+ }
+ },
+ "makezero": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "always": {
+ "description": "Allow only slices initialized with a length of zero.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "loggercheck": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "kitlog": {
+ "description": "Allow check for the github.com/go-kit/log library.",
+ "type": "boolean",
+ "default": true
+ },
+ "klog": {
+ "description": "Allow check for the k8s.io/klog/v2 library.",
+ "type": "boolean",
+ "default": true
+ },
+ "logr": {
+ "description": "Allow check for the github.com/go-logr/logr library.",
+ "type": "boolean",
+ "default": true
+ },
+ "slog": {
+ "description": "Allow check for the log/slog library.",
+ "type": "boolean",
+ "default": true
+ },
+ "zap": {
+ "description": "Allow check for the \"sugar logger\" from go.uber.org/zap library.",
+ "type": "boolean",
+ "default": true
+ },
+ "require-string-key": {
+ "description": "Require all logging keys to be inlined constant strings.",
+ "type": "boolean",
+ "default": false
+ },
+ "no-printf-like": {
+ "description": "Require printf-like format specifier (%s, %d for example) not present.",
+ "type": "boolean",
+ "default": false
+ },
+ "rules": {
+ "description": "List of custom rules to check against, where each rule is a single logger pattern, useful for wrapped loggers.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "misspell": {
+ "description": "Correct spellings using locale preferences for US or UK. Default is to use a neutral variety of English.",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "locale": {
+ "enum": ["US", "UK"]
+ },
+ "ignore-words": {
+ "description": "List of words to ignore.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "mode": {
+ "description": "Mode of the analysis.",
+ "enum": ["restricted", "", "default"],
+ "default": ""
+ },
+ "extra-words": {
+ "description": "Extra word corrections.",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "correction": {
+ "type": "string"
+ },
+ "typo": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ }
+ },
+ "musttag": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "functions": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "name": {
+ "type": "string"
+ },
+ "tag": {
+ "type": "string"
+ },
+ "arg-pos": {
+ "type": "integer"
+ }
+ }
+ }
+ }
+ }
+ },
+ "nakedret": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "max-func-lines": {
+ "description": "Report if a function has more lines of code than this value and it has naked returns.",
+ "type": "integer",
+ "minimum": 0,
+ "default": 30
+ }
+ }
+ },
+ "nestif": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "min-complexity": {
+ "description": "Minimum complexity of \"if\" statements to report.",
+ "type": "integer",
+ "default": 5
+ }
+ }
+ },
+ "nilnil": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "detect-opposite": {
+ "type": "boolean",
+ "description": "In addition, detect opposite situation (simultaneous return of non-nil error and valid value).",
+ "default": false
+ },
+ "checked-types": {
+ "type": "array",
+ "description": "List of return types to check.",
+ "items": {
+ "enum": ["chan", "func", "iface", "map", "ptr", "uintptr", "unsafeptr"]
+ },
+ "default": ["chan", "func", "iface", "map", "ptr", "uintptr", "unsafeptr"]
+ }
+ }
+ },
+ "nlreturn": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "block-size": {
+ "description": "set block size that is still ok",
+ "type": "number",
+ "default": 0,
+ "minimum": 0
+ }
+ }
+ },
+ "mnd": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "ignored-files": {
+ "description": "List of file patterns to exclude from analysis.",
+ "examples": [["magic1_.*.go"]],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ignored-functions": {
+ "description": "Comma-separated list of function patterns to exclude from the analysis.",
+ "examples": [["math.*", "http.StatusText", "make"]],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ignored-numbers": {
+ "description": "List of numbers to exclude from analysis.",
+ "examples": [["1000", "1234_567_890", "3.14159264"]],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "checks": {
+ "description": "The list of enabled checks, see https://github.com/tommy-muehle/go-mnd/#checks for description.",
+ "type": "array",
+ "items": {
+ "enum": [
+ "argument",
+ "case",
+ "condition",
+ "operation",
+ "return",
+ "assign"
+ ]
+ }
+ }
+ }
+ },
+ "nolintlint": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "allow-unused": {
+ "description": "Enable to ensure that nolint directives are all used.",
+ "type": "boolean",
+ "default": true
+ },
+ "allow-no-explanation": {
+ "description": "Exclude these linters from requiring an explanation.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/linters"
+ },
+ "default": []
+ },
+ "require-explanation": {
+ "description": "Enable to require an explanation of nonzero length after each nolint directive.",
+ "type": "boolean",
+ "default": false
+ },
+ "require-specific": {
+ "description": "Enable to require nolint directives to mention the specific linter being suppressed.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "reassign": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "patterns": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "recvcheck": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "disable-builtin": {
+ "description": "Disables the built-in method exclusions.",
+ "type": "boolean",
+ "default": true
+ },
+ "exclusions": {
+ "description": "User-defined method exclusions.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "nonamedreturns": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "report-error-in-defer": {
+ "description": "Report named error if it is assigned inside defer.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "paralleltest": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "ignore-missing": {
+ "description": "Ignore missing calls to `t.Parallel()` and only report incorrect uses of it.",
+ "type": "boolean",
+ "default": false
+ },
+ "ignore-missing-subtests": {
+ "description": "Ignore missing calls to `t.Parallel()` in subtests. Top-level tests are still required to have `t.Parallel`, but subtests are allowed to skip it.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "perfsprint": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "integer-format": {
+ "description": "Enable/disable optimization of integer formatting.",
+ "type": "boolean",
+ "default": true
+ },
+ "int-conversion": {
+ "description": "Optimizes even if it requires an int or uint type cast.",
+ "type": "boolean",
+ "default": true
+ },
+ "error-format": {
+ "description": "Enable/disable optimization of error formatting.",
+ "type": "boolean",
+ "default": true
+ },
+ "err-error": {
+ "description": "Optimizes into `err.Error()` even if it is only equivalent for non-nil errors.",
+ "type": "boolean",
+ "default": false
+ },
+ "errorf": {
+ "description": "Optimizes `fmt.Errorf`.",
+ "type": "boolean",
+ "default": true
+ },
+ "string-format": {
+ "description": "Enable/disable optimization of string formatting.",
+ "type": "boolean",
+ "default": true
+ },
+ "sprintf1": {
+ "description": "Optimizes `fmt.Sprintf` with only one argument.",
+ "type": "boolean",
+ "default": true
+ },
+ "strconcat": {
+ "description": "Optimizes into strings concatenation.",
+ "type": "boolean",
+ "default": true
+ },
+ "bool-format": {
+ "description": "Enable/disable optimization of bool formatting.",
+ "type": "boolean",
+ "default": true
+ },
+ "hex-format": {
+ "description": "Enable/disable optimization of hex formatting.",
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "prealloc": {
+ "description": "We do not recommend using this linter before doing performance profiling.\nFor most programs usage of `prealloc` will be premature optimization.",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "simple": {
+ "description": "Report preallocation suggestions only on simple loops that have no returns/breaks/continues/gotos in them.",
+ "type": "boolean",
+ "default": true
+ },
+ "range-loops": {
+ "description": "Report preallocation suggestions on range loops.",
+ "type": "boolean",
+ "default": true
+ },
+ "for-loops": {
+ "description": "Report preallocation suggestions on for loops.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "predeclared": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "ignore": {
+ "description": "Comma-separated list of predeclared identifiers to not report on.",
+ "type": "string"
+ },
+ "q": {
+ "description": "Include method names and field names (i.e., qualified names) in checks.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "promlinter": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "strict": {},
+ "disabled-linters": {
+ "type": "array",
+ "items": {
+ "enum": [
+ "Help",
+ "MetricUnits",
+ "Counter",
+ "HistogramSummaryReserved",
+ "MetricTypeInName",
+ "ReservedChars",
+ "CamelCase",
+ "UnitAbbreviations"
+ ]
+ }
+ }
+ }
+ },
+ "protogetter": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "skip-generated-by": {
+ "type": "array",
+ "items": {
+ "type": "string",
+ "examples": ["protoc-gen-go-my-own-generator"]
+ }
+ },
+ "skip-files": {
+ "type": "array",
+ "items": {
+ "type": "string",
+ "examples": ["*.pb.go"]
+ }
+ },
+ "skip-any-generated": {
+ "description": "Skip any generated files from the checking.",
+ "type": "boolean",
+ "default": false
+ },
+ "replace-first-arg-in-append": {
+ "description": "Skip first argument of append function.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "revive": {
+ "type": "object",
+ "additionalProperties": false,
+ "examples": [
+ {
+ "ignore-generated-header": true,
+ "severity": "warning",
+ "rules": [
+ {
+ "name": "indent-error-flow",
+ "severity": "warning"
+ },
+ {
+ "name": "add-constant",
+ "severity": "warning",
+ "arguments": [
+ {
+ "maxLitCount": "3",
+ "allowStrs": "\"\"",
+ "allowInts": "0,1,2",
+ "allowFloats": "0.0,0.,1.0,1.,2.0,2."
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ "properties": {
+ "max-open-files": {
+ "type": "integer"
+ },
+ "ignore-generated-header": {
+ "type": "boolean"
+ },
+ "confidence": {
+ "type": "number"
+ },
+ "severity": {
+ "type": "string",
+ "enum": ["warning", "error"]
+ },
+ "enable-all-rules": {
+ "type": "boolean",
+ "default": false
+ },
+ "directives": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "name": {
+ "type": "string",
+ "enum": ["specify-disable-reason"]
+ },
+ "severity": {
+ "type": "string",
+ "enum": ["warning", "error"]
+ },
+ "exclude": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "arguments": {
+ "type": "array"
+ }
+ }
+ }
+ },
+ "rules": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "required": ["name"],
+ "properties": {
+ "name": {
+ "$ref": "#/definitions/revive-rules",
+ "title": "The rule name"
+ },
+ "disabled": {
+ "type": "boolean"
+ },
+ "severity": {
+ "type": "string",
+ "enum": ["warning", "error"]
+ },
+ "exclude": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "arguments": {
+ "type": "array"
+ }
+ }
+ }
+ }
+ }
+ },
+ "rowserrcheck": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "packages": {
+ "type": "array",
+ "items": {
+ "description": "",
+ "type": "string",
+ "examples": ["github.com/jmoiron/sqlx"]
+ }
+ }
+ }
+ },
+ "sloglint": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "kv-only": {
+ "description": "Enforce using key-value pairs only (incompatible with attr-only).",
+ "type": "boolean",
+ "default": false
+ },
+ "no-global": {
+ "description": "Enforce not using global loggers.",
+ "enum": ["", "all", "default"],
+ "default": ""
+ },
+ "no-mixed-args": {
+ "description": "Enforce not mixing key-value pairs and attributes.",
+ "type": "boolean",
+ "default": true
+ },
+ "context": {
+ "description": "Enforce using methods that accept a context.",
+ "enum": ["", "all", "scope"],
+ "default": ""
+ },
+ "static-msg": {
+ "description": "Enforce using static values for log messages.",
+ "type": "boolean",
+ "default": false
+ },
+ "key-naming-case": {
+ "description": "Enforce a single key naming convention.",
+ "enum": ["snake", "kebab", "camel", "pascal"]
+ },
+ "attr-only": {
+ "description": "Enforce using attributes only (incompatible with kv-only).",
+ "type": "boolean",
+ "default": false
+ },
+ "no-raw-keys": {
+ "description": "Enforce using constants instead of raw keys.",
+ "type": "boolean",
+ "default": false
+ },
+ "forbidden-keys": {
+ "description": "Enforce not using specific keys.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "args-on-sep-lines": {
+ "description": "Enforce putting arguments on separate lines.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "spancheck": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "checks": {
+ "description": "Checks to enable.",
+ "type": "array",
+ "items": {
+ "enum": ["end", "record-error", "set-status"]
+ }
+ },
+ "ignore-check-signatures": {
+ "description": "A list of regexes for function signatures that silence `record-error` and `set-status` reports if found in the call path to a returned error.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "extra-start-span-signatures": {
+ "description": "A list of regexes for additional function signatures that create spans.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "staticcheck": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "checks": {
+ "type": "array",
+ "items": {
+ "anyOf": [
+ {
+ "enum": ["all"]
+ },
+ {
+ "type": "string"
+ }
+ ]
+ }
+ }
+ }
+ },
+ "stylecheck": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "checks": {
+ "type": "array",
+ "items": {
+ "anyOf": [
+ {
+ "enum": ["all"]
+ },
+ {
+ "type": "string"
+ }
+ ]
+ },
+ "default": [
+ "all",
+ "-ST1000",
+ "-ST1003",
+ "-ST1016",
+ "-ST1020",
+ "-ST1021",
+ "-ST1022"
+ ]
+ },
+ "dot-import-whitelist": {
+ "description": "By default, ST1001 forbids all uses of dot imports in non-test packages. This setting allows setting a whitelist of import paths that can be dot-imported anywhere.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "http-status-code-whitelist": {
+ "description": "ST1013 recommends using constants from the net/http package instead of hard-coding numeric HTTP status codes. This setting specifies a list of numeric status codes that this check does not complain about.",
+ "default": ["200", "400", "404", "500"],
+ "type": "array",
+ "items": {
+ "enum": [
+ "100",
+ "101",
+ "102",
+ "103",
+ "200",
+ "201",
+ "202",
+ "203",
+ "204",
+ "205",
+ "206",
+ "207",
+ "208",
+ "226",
+ "300",
+ "301",
+ "302",
+ "303",
+ "304",
+ "305",
+ "306",
+ "307",
+ "308",
+ "400",
+ "401",
+ "402",
+ "403",
+ "404",
+ "405",
+ "406",
+ "407",
+ "408",
+ "409",
+ "410",
+ "411",
+ "412",
+ "413",
+ "414",
+ "415",
+ "416",
+ "417",
+ "418",
+ "421",
+ "422",
+ "423",
+ "424",
+ "425",
+ "426",
+ "428",
+ "429",
+ "431",
+ "451",
+ "500",
+ "501",
+ "502",
+ "503",
+ "504",
+ "505",
+ "506",
+ "507",
+ "508",
+ "510",
+ "511"
+ ]
+ }
+ },
+ "initialisms": {
+ "description": "ST1003 check, among other things, for the correct capitalization of initialisms. The set of known initialisms can be configured with this option.",
+ "type": "array",
+ "items": {
+ "type": "string",
+ "default": [
+ "ACL",
+ "API",
+ "ASCII",
+ "CPU",
+ "CSS",
+ "DNS",
+ "EOF",
+ "GUID",
+ "HTML",
+ "HTTP",
+ "HTTPS",
+ "ID",
+ "IP",
+ "JSON",
+ "QPS",
+ "RAM",
+ "RPC",
+ "SLA",
+ "SMTP",
+ "SQL",
+ "SSH",
+ "TCP",
+ "TLS",
+ "TTL",
+ "UDP",
+ "UI",
+ "GID",
+ "UID",
+ "UUID",
+ "URI",
+ "URL",
+ "UTF8",
+ "VM",
+ "XML",
+ "XMPP",
+ "XSRF",
+ "XSS",
+ "SIP",
+ "RTP",
+ "AMQP",
+ "DB",
+ "TS"
+ ]
+ }
+ }
+ }
+ },
+ "tagalign": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "align": {
+ "description": "Align and sort can be used together or separately.",
+ "type": "boolean",
+ "default": true
+ },
+ "sort": {
+ "description": "Whether enable tags sort.",
+ "type": "boolean",
+ "default": true
+ },
+ "order": {
+ "description": "Specify the order of tags, the other tags will be sorted by name.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "default": [],
+ "examples": [
+ [
+ "json",
+ "yaml",
+ "yml",
+ "toml",
+ "mapstructure",
+ "binding",
+ "validate"
+ ]
+ ]
+ },
+ "strict": {
+ "description": "Whether enable strict style.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "tagliatelle": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "case": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "use-field-name": {
+ "description": "Use the struct field name to check the name of the struct tag.",
+ "type": "boolean",
+ "default": false
+ },
+ "ignored-fields": {
+ "description": "The field names to ignore.",
+ "type": "array",
+ "items": {
+ "type": "string",
+ "examples": ["example"]
+ }
+ },
+ "rules": {
+ "type": "object",
+ "patternProperties": {
+ "^.+$": {
+ "$ref": "#/definitions/tagliatelle-cases"
+ }
+ }
+ },
+ "extended-rules": {
+ "description": "Defines the association between tag name and case.",
+ "type": "object",
+ "patternProperties": {
+ "^.+$": {
+ "type": "object",
+ "additionalProperties": false,
+ "required": ["case"],
+ "properties": {
+ "case": {
+ "$ref": "#/definitions/tagliatelle-cases"
+ },
+ "extra-initialisms": {
+ "type": "boolean",
+ "default": false
+ },
+ "initialism-overrides": {
+ "type": "object",
+ "patternProperties": {
+ "^.+$": {
+ "type": "boolean",
+ "default": false
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "overrides": {
+ "description": "Overrides the default/root configuration.",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "required": ["pkg"],
+ "properties": {
+ "pkg": {
+ "description": "A package path.",
+ "type": "string"
+ },
+ "use-field-name": {
+ "description": "Use the struct field name to check the name of the struct tag.",
+ "type": "boolean",
+ "default": false
+ },
+ "ignored-fields": {
+ "description": "The field names to ignore.",
+ "type": "array",
+ "items": {
+ "type": "string",
+ "examples": ["example"]
+ }
+ },
+ "ignore": {
+ "description": "Ignore the package (takes precedence over all other configurations).",
+ "type": "boolean",
+ "default": false
+ },
+ "rules": {
+ "type": "object",
+ "patternProperties": {
+ "^.+$": {
+ "$ref": "#/definitions/tagliatelle-cases"
+ }
+ }
+ },
+ "extended-rules": {
+ "description": "Defines the association between tag name and case.",
+ "type": "object",
+ "patternProperties": {
+ "^.+$": {
+ "type": "object",
+ "additionalProperties": false,
+ "required": ["case"],
+ "properties": {
+ "case": {
+ "$ref": "#/definitions/tagliatelle-cases"
+ },
+ "extra-initialisms": {
+ "type": "boolean",
+ "default": false
+ },
+ "initialism-overrides": {
+ "type": "object",
+ "patternProperties": {
+ "^.+$": {
+ "type": "boolean",
+ "default": false
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "tenv": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "all": {
+ "description": "The option `all` will run against whole test files (`_test.go`) regardless of method/function signatures.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "testifylint": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "enable-all": {
+ "description": "Enable all checkers.",
+ "type": "boolean",
+ "default": false
+ },
+ "disable-all": {
+ "description": "Disable all checkers.",
+ "type": "boolean",
+ "default": false
+ },
+ "enable": {
+ "description": "Enable specific checkers.",
+ "type": "array",
+ "items": {
+ "enum": [
+ "blank-import",
+ "bool-compare",
+ "compares",
+ "contains",
+ "empty",
+ "encoded-compare",
+ "error-is-as",
+ "error-nil",
+ "expected-actual",
+ "float-compare",
+ "formatter",
+ "go-require",
+ "len",
+ "negative-positive",
+ "nil-compare",
+ "regexp",
+ "require-error",
+ "suite-broken-parallel",
+ "suite-dont-use-pkg",
+ "suite-extra-assert-call",
+ "suite-subtest-run",
+ "suite-thelper",
+ "useless-assert"
+ ]
+ },
+ "default": [
+ "blank-import",
+ "bool-compare",
+ "compares",
+ "contains",
+ "empty",
+ "encoded-compare",
+ "error-is-as",
+ "error-nil",
+ "expected-actual",
+ "float-compare",
+ "formatter",
+ "go-require",
+ "len",
+ "negative-positive",
+ "nil-compare",
+ "regexp",
+ "require-error",
+ "suite-broken-parallel",
+ "suite-dont-use-pkg",
+ "suite-extra-assert-call",
+ "suite-subtest-run",
+ "useless-assert"
+ ]
+ },
+ "disable": {
+ "description": "Disable specific checkers.",
+ "type": "array",
+ "items": {
+ "enum": [
+ "blank-import",
+ "bool-compare",
+ "compares",
+ "contains",
+ "empty",
+ "encoded-compare",
+ "error-is-as",
+ "error-nil",
+ "expected-actual",
+ "float-compare",
+ "formatter",
+ "go-require",
+ "len",
+ "negative-positive",
+ "nil-compare",
+ "regexp",
+ "require-error",
+ "suite-broken-parallel",
+ "suite-dont-use-pkg",
+ "suite-extra-assert-call",
+ "suite-subtest-run",
+ "suite-thelper",
+ "useless-assert"
+ ],
+ "default": [
+ "suite-thelper"
+ ]
+ }
+ },
+ "bool-compare": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "ignore-custom-types": {
+ "description": "To ignore user defined types (over builtin bool).",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "expected-actual": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "pattern": {
+ "description": "Regexp for expected variable name.",
+ "type": "string",
+ "default": "(^(exp(ected)?|want(ed)?)([A-Z]\\w*)?$)|(^(\\w*[a-z])?(Exp(ected)?|Want(ed)?)$)"
+ }
+ }
+ },
+ "formatter": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "check-format-string": {
+ "description": "To enable go vet's printf checks.",
+ "type": "boolean",
+ "default": true
+ },
+ "require-f-funcs": {
+ "description": "To require f-assertions (e.g. assert.Equalf) if format string is used, even if there are no variable-length variables.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "go-require": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "ignore-http-handlers": {
+ "description": "To ignore HTTP handlers (like http.HandlerFunc).",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "require-error": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "fn-pattern": {
+ "description": "Regexp for assertions to analyze. If defined, then only matched error assertions will be reported.",
+ "type": "string",
+ "default": ""
+ }
+ }
+ },
+ "suite-extra-assert-call": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "mode": {
+ "description": "To require or remove extra Assert() call?",
+ "type": "string",
+ "enum": ["remove", "require"],
+ "default": "remove"
+ }
+ }
+ }
+ }
+ },
+ "testpackage": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "skip-regexp": {
+ "description": "Files with names matching this regular expression are skipped.",
+ "type": "string",
+ "examples": ["(export|internal)_test\\.go"]
+ },
+ "allow-packages": {
+ "description": "List of packages that don't end with _test that tests are allowed to be in.",
+ "type": "array",
+ "uniqueItems": true,
+ "items": {
+ "type": "string",
+ "examples": ["example"]
+ }
+ }
+ }
+ },
+ "thelper": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "test": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "begin": {
+ "description": "Check if `t.Helper()` begins helper function.",
+ "default": true,
+ "type": "boolean"
+ },
+ "first": {
+ "description": "Check if *testing.T is first param of helper function.",
+ "default": true,
+ "type": "boolean"
+ },
+ "name": {
+ "description": "Check if *testing.T param has t name.",
+ "default": true,
+ "type": "boolean"
+ }
+ }
+ },
+ "benchmark": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "begin": {
+ "description": "Check if `b.Helper()` begins helper function.",
+ "default": true,
+ "type": "boolean"
+ },
+ "first": {
+ "description": "Check if *testing.B is first param of helper function.",
+ "default": true,
+ "type": "boolean"
+ },
+ "name": {
+ "description": "Check if *testing.B param has b name.",
+ "default": true,
+ "type": "boolean"
+ }
+ }
+ },
+ "tb": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "begin": {
+ "description": "Check if `tb.Helper()` begins helper function.",
+ "default": true,
+ "type": "boolean"
+ },
+ "first": {
+ "description": "Check if *testing.TB is first param of helper function.",
+ "default": true,
+ "type": "boolean"
+ },
+ "name": {
+ "description": "Check if *testing.TB param has tb name.",
+ "default": true,
+ "type": "boolean"
+ }
+ }
+ },
+ "fuzz": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "begin": {
+ "description": "Check if `f.Helper()` begins helper function.",
+ "default": true,
+ "type": "boolean"
+ },
+ "first": {
+ "description": "Check if *testing.F is first param of helper function.",
+ "default": true,
+ "type": "boolean"
+ },
+ "name": {
+ "description": "Check if *testing.F param has f name.",
+ "default": true,
+ "type": "boolean"
+ }
+ }
+ }
+ }
+ },
+ "usestdlibvars": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "http-method": {
+ "description": "Suggest the use of http.MethodXX.",
+ "type": "boolean",
+ "default": true
+ },
+ "http-status-code": {
+ "description": "Suggest the use of http.StatusXX.",
+ "type": "boolean",
+ "default": true
+ },
+ "time-weekday": {
+ "description": "Suggest the use of time.Weekday.String().",
+ "type": "boolean",
+ "default": false
+ },
+ "time-month": {
+ "description": "Suggest the use of time.Month.String().",
+ "type": "boolean",
+ "default": false
+ },
+ "time-layout": {
+ "description": "Suggest the use of time.Layout.",
+ "type": "boolean",
+ "default": false
+ },
+ "crypto-hash": {
+ "description": "Suggest the use of crypto.Hash.String().",
+ "type": "boolean",
+ "default": false
+ },
+ "default-rpc-path": {
+ "description": "Suggest the use of rpc.DefaultXXPath.",
+ "type": "boolean",
+ "default": false
+ },
+ "sql-isolation-level": {
+ "description": "Suggest the use of sql.LevelXX.String().",
+ "type": "boolean",
+ "default": false
+ },
+ "tls-signature-scheme": {
+ "description": "Suggest the use of tls.SignatureScheme.String().",
+ "type": "boolean",
+ "default": false
+ },
+ "constant-kind": {
+ "description": "Suggest the use of constant.Kind.String().",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "usetesting": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "context-background": {
+ "type": "boolean",
+ "default": true
+ },
+ "context-todo": {
+ "type": "boolean",
+ "default": true
+ },
+ "os-chdir": {
+ "type": "boolean",
+ "default": true
+ },
+ "os-mkdir-temp": {
+ "type": "boolean",
+ "default": true
+ },
+ "os-setenv": {
+ "type": "boolean",
+ "default": true
+ },
+ "os-create-temp": {
+ "type": "boolean",
+ "default": true
+ },
+ "os-temp-dir": {
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "unconvert": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "fast-math": {
+ "type": "boolean",
+ "default": false
+ },
+ "safe": {
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "unparam": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "check-exported": {
+ "description": "Inspect exported functions. Set to true if no external program/library imports your code.\n\nWARNING: if you enable this setting, unparam will report a lot of false-positives in text editors:\nif it's called for subdir of a project it can't find external interfaces. All text editor integrations\nwith golangci-lint call it on a directory with the changed file.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "unused": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "field-writes-are-uses": {
+ "description": "",
+ "type": "boolean",
+ "default": true
+ },
+ "post-statements-are-reads": {
+ "description": "",
+ "type": "boolean",
+ "default": false
+ },
+ "exported-fields-are-used": {
+ "description": "",
+ "type": "boolean",
+ "default": true
+ },
+ "parameters-are-used": {
+ "description": "",
+ "type": "boolean",
+ "default": true
+ },
+ "local-variables-are-used": {
+ "description": "",
+ "type": "boolean",
+ "default": true
+ },
+ "generated-is-used": {
+ "description": "",
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "varnamelen": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "max-distance": {
+ "description": "Variables used in at most this N-many lines will be ignored.",
+ "type": "integer",
+ "default": 5
+ },
+ "min-name-length": {
+ "description": "The minimum length of a variable's name that is considered `long`.",
+ "type": "integer",
+ "default": 3
+ },
+ "check-receiver": {
+ "description": "Check method receiver names.",
+ "default": false,
+ "type": "boolean"
+ },
+ "check-return": {
+ "description": "Check named return values.",
+ "default": false,
+ "type": "boolean"
+ },
+ "check-type-param": {
+ "description": "Check type parameters.",
+ "default": false,
+ "type": "boolean"
+ },
+ "ignore-type-assert-ok": {
+ "description": "Ignore `ok` variables that hold the bool return value of a type assertion",
+ "default": false,
+ "type": "boolean"
+ },
+ "ignore-map-index-ok": {
+ "description": "Ignore `ok` variables that hold the bool return value of a map index.",
+ "default": false,
+ "type": "boolean"
+ },
+ "ignore-chan-recv-ok": {
+ "description": "Ignore `ok` variables that hold the bool return value of a channel receive.",
+ "default": false,
+ "type": "boolean"
+ },
+ "ignore-names": {
+ "description": "Optional list of variable names that should be ignored completely.",
+ "default": [[]],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ignore-decls": {
+ "description": "Optional list of variable declarations that should be ignored completely.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "examples": [
+ ["c echo.Context", "t testing.T", "f *foo.Bar", "const C"]
+ ]
+ }
+ }
+ },
+ "whitespace": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "multi-if": {
+ "description": "Enforces newlines (or comments) after every multi-line if statement",
+ "type": "boolean",
+ "default": false
+ },
+ "multi-func": {
+ "description": "Enforces newlines (or comments) after every multi-line function signature",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "wrapcheck": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "extra-ignore-sigs": {
+ "description": "An array of strings specifying additional substrings of signatures to ignore.",
+ "default": [
+ ".CustomError(",
+ ".SpecificWrap("
+ ],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ignoreSigs": {
+ "description": "An array of strings which specify substrings of signatures to ignore.",
+ "default": [
+ ".Errorf(",
+ "errors.New(",
+ "errors.Unwrap(",
+ ".Wrap(",
+ ".Wrapf(",
+ ".WithMessage(",
+ ".WithMessagef(",
+ ".WithStack("
+ ],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ignoreSigRegexps": {
+ "description": "An array of strings which specify regular expressions of signatures to ignore.",
+ "default": [""],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ignorePackageGlobs": {
+ "description": "An array of glob patterns which, if any match the package of the function returning the error, will skip wrapcheck analysis for this error.",
+ "default": [""],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ignoreInterfaceRegexps": {
+ "description": "An array of glob patterns which, if matched to an underlying interface name, will ignore unwrapped errors returned from a function whose call is defined on the given interface.",
+ "default": [""],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "wsl": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "allow-assign-and-anything": {
+ "description": "Controls if you may cuddle assignments and anything without needing an empty line between them.",
+ "type": "boolean",
+ "default": false
+ },
+ "allow-assign-and-call": {
+ "description": "Allow calls and assignments to be cuddled as long as the lines have any matching variables, fields or types.",
+ "type": "boolean",
+ "default": true
+ },
+ "allow-cuddle-declarations": {
+ "description": "Allow declarations (var) to be cuddled.",
+ "type": "boolean",
+ "default": false
+ },
+ "allow-cuddle-with-calls": {
+ "description": "A list of call idents that everything can be cuddled with.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "allow-cuddle-with-rhs": {
+ "description": "AllowCuddleWithRHS is a list of right hand side variables that is allowed to be cuddled with anything.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "allow-multiline-assign": {
+ "description": "Allow multiline assignments to be cuddled.",
+ "type": "boolean",
+ "default": true
+ },
+ "allow-separated-leading-comment": {
+ "description": "Allow leading comments to be separated with empty lines.",
+ "type": "boolean",
+ "default": false
+ },
+ "allow-trailing-comment": {
+ "description": "Allow trailing comments in ending of blocks.",
+ "type": "boolean",
+ "default": false
+ },
+ "error-variable-names": {
+ "description": "When force-err-cuddling is enabled this is a list of names used for error variables to check for in the conditional.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "force-case-trailing-whitespace": {
+ "description": "Force newlines in end of case at this limit (0 = never).",
+ "type": "integer",
+ "minimum": 0,
+ "default": 0
+ },
+ "force-err-cuddling": {
+ "description": "Causes an error when an If statement that checks an error variable doesn't cuddle with the assignment of that variable.",
+ "type": "boolean",
+ "default": false
+ },
+ "force-short-decl-cuddling": {
+ "description": "Causes an error if a short declaration (:=) cuddles with anything other than another short declaration.",
+ "type": "boolean",
+ "default": false
+ },
+ "strict-append": {
+ "description": "If true, append is only allowed to be cuddled if appending value is matching variables, fields or types on line above.",
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "copyloopvar": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "check-alias": {
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "custom": {
+ "description": "The custom section can be used to define linter plugins to be loaded at runtime. See README of golangci-lint for more information.\nEach custom linter should have a unique name.",
+ "type": "object",
+ "patternProperties": {
+ "^.*$": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "type": {
+ "description": "The plugin type.",
+ "enum": ["module", "goplugin"],
+ "default": "goplugin"
+ },
+ "path": {
+ "description": "The path to the plugin *.so. Can be absolute or local.",
+ "type": "string",
+ "examples": ["/path/to/example.so"]
+ },
+ "description": {
+ "description": "The description of the linter, for documentation purposes only.",
+ "type": "string"
+ },
+ "original-url": {
+ "description": "Intended to point to the repo location of the linter, for documentation purposes only.",
+ "type": "string"
+ },
+ "settings": {
+ "description": "Plugins settings/configuration. Only work with plugin based on `linterdb.PluginConstructor`.",
+ "type": "object"
+ }
+ },
+ "oneOf": [
+ {
+ "properties": {
+ "type": {"enum": ["module"] }
+ },
+ "required": ["type"]
+ },
+ {
+ "required": ["path"]
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
+ "linters": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "enable": {
+ "description": "List of enabled linters.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/linters"
+ }
+ },
+ "disable": {
+ "description": "List of disabled linters.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/linters"
+ }
+ },
+ "enable-all": {
+ "description": "Whether to enable all linters. You can re-disable them with `disable` explicitly.",
+ "type": "boolean",
+ "default": false
+ },
+ "disable-all": {
+ "description": "Whether to disable all linters. You can re-enable them with `enable` explicitly.",
+ "type": "boolean",
+ "default": false
+ },
+ "presets": {
+ "description": "Allow to use different presets of linters",
+ "type": "array",
+ "items": {
+ "enum": [
+ "bugs",
+ "comment",
+ "complexity",
+ "error",
+ "format",
+ "import",
+ "metalinter",
+ "module",
+ "performance",
+ "sql",
+ "style",
+ "test",
+ "unused"
+ ]
+ }
+ },
+ "fast": {
+ "description": "Enable run of fast linters.",
+ "type": "boolean",
+ "default": false
+ },
+ "exclusions":{
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "generated": {
+ "enum": ["strict", "lax", "disable"],
+ "default": "lax"
+ },
+ "warn-unused": {
+ "type": "boolean",
+ "default": false
+ },
+ "default": {
+ "type": "array",
+ "items": {
+ "enum": [
+ "comments",
+ "stdErrorHandling",
+ "commonFalsePositives",
+ "legacy"
+ ]
+ }
+ },
+ "rules": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "properties": {
+ "path": {
+ "type": "string"
+ },
+ "path-except": {
+ "type": "string"
+ },
+ "linters": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/linters"
+ }
+ },
+ "text": {
+ "type": "string"
+ },
+ "source": {
+ "type": "string"
+ }
+ },
+ "anyOf": [
+ { "required": ["path"] },
+ { "required": ["path-except"] },
+ { "required": ["linters"] },
+ { "required": ["text"] },
+ { "required": ["source"] }
+ ]
+ }
+ },
+ "paths": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "paths-except": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ }
+ },
+ "issues": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "exclude": {
+ "description": "List of regular expressions of issue texts to exclude.\nBut independently from this option we use default exclude patterns. Their usage can be controlled through `exclude-use-default`.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "exclude-rules": {
+ "description": "Exclude configuration per-path, per-linter, per-text and per-source",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "path": {
+ "type": "string"
+ },
+ "path-except": {
+ "type": "string"
+ },
+ "linters": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/linters"
+ }
+ },
+ "text": {
+ "type": "string"
+ },
+ "source": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "exclude-use-default": {
+ "description": "Independently from option `exclude` we use default exclude patterns. This behavior can be disabled by this option.",
+ "type": "boolean",
+ "default": true
+ },
+ "exclude-case-sensitive": {
+ "description": "If set to true, exclude and exclude-rules regular expressions become case sensitive.",
+ "type": "boolean",
+ "default": false
+ },
+ "exclude-generated": {
+ "description": "Mode of the generated files analysis.",
+ "enum": ["lax", "strict", "disable"],
+ "default": "lax"
+ },
+ "exclude-dirs": {
+ "description": "Which directories to exclude: issues from them won't be reported.",
+ "type": "array",
+ "items": {
+ "description": "You can use regexp here. The regexp is applied on the full path.\n\"/\" will be replaced by current OS file path separator to properly work on Windows.",
+ "type": "string",
+ "examples": ["generated.*"]
+ },
+ "default": [],
+ "examples": [["src/external_libs", "autogenerated_by_my_lib"]]
+ },
+ "exclude-dirs-use-default": {
+ "description": "Enable exclusion of directories \"vendor\", \"third_party\", \"testdata\", \"examples\", \"Godeps\", and \"builtin\".",
+ "type": "boolean",
+ "default": true
+ },
+ "exclude-files": {
+ "description": "Which files to exclude: they will be analyzed, but issues from them will not be reported.",
+ "type": "array",
+ "items": {
+ "description": "You can use regexp here. There is no need to include all autogenerated files, we confidently recognize them. If that is not the case, please let us know.\n\"/\" will be replaced by current OS file path separator to properly work on Windows.",
+ "type": "string",
+ "examples": [".*\\.my\\.go$"]
+ },
+ "default": [],
+ "examples": [[".*\\.my\\.go$", "lib/bad.go"]]
+ },
+ "include": {
+ "description": "The list of ids of default excludes to include or disable.",
+ "type": "array",
+ "items": {
+ "enum": [
+ "EXC0001",
+ "EXC0002",
+ "EXC0003",
+ "EXC0004",
+ "EXC0005",
+ "EXC0006",
+ "EXC0007",
+ "EXC0008",
+ "EXC0009",
+ "EXC0010",
+ "EXC0011",
+ "EXC0012",
+ "EXC0013",
+ "EXC0014",
+ "EXC0015"
+ ]
+ },
+ "default": []
+ },
+ "max-issues-per-linter": {
+ "description": "Maximum issues count per one linter. Set to 0 to disable.",
+ "type": "integer",
+ "default": 50,
+ "minimum": 0
+ },
+ "max-same-issues": {
+ "description": "Maximum count of issues with the same text. Set to 0 to disable.",
+ "type": "integer",
+ "default": 3,
+ "minimum": 0
+ },
+ "new": {
+ "description": "Show only new issues: if there are unstaged changes or untracked files, only those changes are analyzed, else only changes in HEAD~ are analyzed.",
+ "type": "boolean",
+ "default": false
+ },
+ "new-from-merge-base": {
+ "description": "Show only new issues created after the best common ancestor (merge-base against HEAD).",
+ "type": "string"
+ },
+ "new-from-rev": {
+ "description": "Show only new issues created after this git revision.",
+ "type": "string"
+ },
+ "new-from-patch": {
+ "description": "Show only new issues created in git patch with this file path.",
+ "type": "string",
+ "examples": ["path/to/patch/file"]
+ },
+ "fix": {
+ "description": "Fix found issues (if it's supported by the linter).",
+ "type": "boolean",
+ "default": false
+ },
+ "uniq-by-line": {
+ "description": "Make issues output unique by line.",
+ "type": "boolean",
+ "default": true
+ },
+ "whole-files": {
+ "description": "Show issues in any part of update files (requires new-from-rev or new-from-patch).",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "severity": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "default-severity": {
+ "description": "Set the default severity for issues. If severity rules are defined and the issues do not match or no severity is provided to the rule this will be the default severity applied. Severities should match the supported severity names of the selected out format.",
+ "type": "string",
+ "default": ""
+ },
+ "case-sensitive": {
+ "description": "If set to true, severity-rules regular expressions become case sensitive.",
+ "type": "boolean",
+ "default": false
+ },
+ "rules": {
+ "description": "When a list of severity rules are provided, severity information will be added to lint issues. Severity rules have the same filtering capability as exclude rules except you are allowed to specify one matcher per severity rule.\nOnly affects out formats that support setting severity information.",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "severity": {
+ "type": "string"
+ },
+ "path": {
+ "type": "string"
+ },
+ "path-except": {
+ "type": "string"
+ },
+ "linters": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/linters"
+ }
+ },
+ "text": {
+ "type": "string"
+ },
+ "source": {
+ "type": "string"
+ }
+ },
+ "required": ["severity"],
+ "anyOf": [
+ { "required": ["path"] },
+ { "required": ["path-except"] },
+ { "required": ["linters"] },
+ { "required": ["text"] },
+ { "required": ["source"] }
+ ]
+ },
+ "default": []
+ }
+ },
+ "required": ["default-severity"]
+ }
+ }
+}
diff --git a/vendor/github.com/golangci/golangci-lint/v2/jsonschema/golangci.v1.jsonschema.json b/vendor/github.com/golangci/golangci-lint/v2/jsonschema/golangci.v1.jsonschema.json
new file mode 100644
index 0000000000..b265c1a823
--- /dev/null
+++ b/vendor/github.com/golangci/golangci-lint/v2/jsonschema/golangci.v1.jsonschema.json
@@ -0,0 +1,4224 @@
+{
+ "$schema": "http://json-schema.org/draft-07/schema#",
+ "$id": "https://json.schemastore.org/golangci-lint.json",
+ "definitions": {
+ "gocritic-checks": {
+ "enum": [
+ "appendAssign",
+ "appendCombine",
+ "argOrder",
+ "assignOp",
+ "badCall",
+ "badCond",
+ "badLock",
+ "badRegexp",
+ "badSorting",
+ "badSyncOnceFunc",
+ "boolExprSimplify",
+ "builtinShadow",
+ "builtinShadowDecl",
+ "captLocal",
+ "caseOrder",
+ "codegenComment",
+ "commentFormatting",
+ "commentedOutCode",
+ "commentedOutImport",
+ "defaultCaseOrder",
+ "deferInLoop",
+ "deferUnlambda",
+ "deprecatedComment",
+ "docStub",
+ "dupArg",
+ "dupBranchBody",
+ "dupCase",
+ "dupImport",
+ "dupSubExpr",
+ "dynamicFmtString",
+ "elseif",
+ "emptyDecl",
+ "emptyFallthrough",
+ "emptyStringTest",
+ "equalFold",
+ "evalOrder",
+ "exitAfterDefer",
+ "exposedSyncMutex",
+ "externalErrorReassign",
+ "filepathJoin",
+ "flagDeref",
+ "flagName",
+ "hexLiteral",
+ "httpNoBody",
+ "hugeParam",
+ "ifElseChain",
+ "importShadow",
+ "indexAlloc",
+ "initClause",
+ "ioutilDeprecated",
+ "mapKey",
+ "methodExprCall",
+ "nestingReduce",
+ "newDeref",
+ "nilValReturn",
+ "octalLiteral",
+ "offBy1",
+ "paramTypeCombine",
+ "preferDecodeRune",
+ "preferFilepathJoin",
+ "preferFprint",
+ "preferStringWriter",
+ "preferWriteByte",
+ "ptrToRefParam",
+ "rangeAppendAll",
+ "rangeExprCopy",
+ "rangeValCopy",
+ "redundantSprint",
+ "regexpMust",
+ "regexpPattern",
+ "regexpSimplify",
+ "returnAfterHttpError",
+ "ruleguard",
+ "singleCaseSwitch",
+ "sliceClear",
+ "sloppyLen",
+ "sloppyReassign",
+ "sloppyTypeAssert",
+ "sortSlice",
+ "sprintfQuotedString",
+ "sqlQuery",
+ "stringConcatSimplify",
+ "stringXbytes",
+ "stringsCompare",
+ "switchTrue",
+ "syncMapLoadAndDelete",
+ "timeExprSimplify",
+ "todoCommentWithoutDetail",
+ "tooManyResultsChecker",
+ "truncateCmp",
+ "typeAssertChain",
+ "typeDefFirst",
+ "typeSwitchVar",
+ "typeUnparen",
+ "uncheckedInlineErr",
+ "underef",
+ "unlabelStmt",
+ "unlambda",
+ "unnamedResult",
+ "unnecessaryBlock",
+ "unnecessaryDefer",
+ "unslice",
+ "valSwap",
+ "weakCond",
+ "whyNoLint",
+ "wrapperFunc",
+ "yodaStyleExpr"
+ ]
+ },
+ "gocritic-tags": {
+ "enum": [
+ "diagnostic",
+ "style",
+ "performance",
+ "experimental",
+ "opinionated",
+ "security"
+ ]
+ },
+ "gosec-rules": {
+ "enum": [
+ "G101",
+ "G102",
+ "G103",
+ "G104",
+ "G106",
+ "G107",
+ "G108",
+ "G109",
+ "G110",
+ "G111",
+ "G112",
+ "G113",
+ "G114",
+ "G115",
+ "G201",
+ "G202",
+ "G203",
+ "G204",
+ "G301",
+ "G302",
+ "G303",
+ "G304",
+ "G305",
+ "G306",
+ "G307",
+ "G401",
+ "G402",
+ "G403",
+ "G404",
+ "G405",
+ "G406",
+ "G501",
+ "G502",
+ "G503",
+ "G504",
+ "G505",
+ "G506",
+ "G507",
+ "G601",
+ "G602"
+ ]
+ },
+ "govet-analyzers": {
+ "enum": [
+ "appends",
+ "asmdecl",
+ "assign",
+ "atomic",
+ "atomicalign",
+ "bools",
+ "buildtag",
+ "cgocall",
+ "composites",
+ "copylocks",
+ "deepequalerrors",
+ "defers",
+ "directive",
+ "errorsas",
+ "fieldalignment",
+ "findcall",
+ "framepointer",
+ "httpresponse",
+ "ifaceassert",
+ "loopclosure",
+ "lostcancel",
+ "nilfunc",
+ "nilness",
+ "printf",
+ "reflectvaluecompare",
+ "shadow",
+ "shift",
+ "sigchanyzer",
+ "slog",
+ "sortslice",
+ "stdmethods",
+ "stdversion",
+ "stringintconv",
+ "structtag",
+ "testinggoroutine",
+ "tests",
+ "timeformat",
+ "unmarshal",
+ "unreachable",
+ "unsafeptr",
+ "unusedresult",
+ "unusedwrite",
+ "waitgroup"
+ ]
+ },
+ "revive-rules": {
+ "enum": [
+ "add-constant",
+ "argument-limit",
+ "atomic",
+ "banned-characters",
+ "bare-return",
+ "blank-imports",
+ "bool-literal-in-expr",
+ "call-to-gc",
+ "cognitive-complexity",
+ "comment-spacings",
+ "comments-density",
+ "confusing-naming",
+ "confusing-results",
+ "constant-logical-expr",
+ "context-as-argument",
+ "context-keys-type",
+ "cyclomatic",
+ "datarace",
+ "deep-exit",
+ "defer",
+ "dot-imports",
+ "duplicated-imports",
+ "early-return",
+ "empty-block",
+ "empty-lines",
+ "enforce-map-style",
+ "enforce-repeated-arg-type-style",
+ "enforce-slice-style",
+ "error-naming",
+ "error-return",
+ "error-strings",
+ "errorf",
+ "exported",
+ "file-header",
+ "file-length-limit",
+ "filename-format",
+ "flag-parameter",
+ "function-length",
+ "function-result-limit",
+ "get-return",
+ "identical-branches",
+ "if-return",
+ "import-alias-naming",
+ "import-shadowing",
+ "imports-blocklist",
+ "increment-decrement",
+ "indent-error-flow",
+ "line-length-limit",
+ "max-control-nesting",
+ "max-public-structs",
+ "modifies-parameter",
+ "modifies-value-receiver",
+ "nested-structs",
+ "optimize-operands-order",
+ "package-comments",
+ "range-val-address",
+ "range-val-in-closure",
+ "range",
+ "receiver-naming",
+ "redefines-builtin-id",
+ "redundant-build-tag",
+ "redundant-import-alias",
+ "string-format",
+ "string-of-int",
+ "struct-tag",
+ "superfluous-else",
+ "time-equal",
+ "time-naming",
+ "unchecked-type-assertion",
+ "unconditional-recursion",
+ "unexported-naming",
+ "unexported-return",
+ "unhandled-error",
+ "unnecessary-stmt",
+ "unreachable-code",
+ "unused-parameter",
+ "unused-receiver",
+ "use-any",
+ "use-errors-new",
+ "useless-break",
+ "var-declaration",
+ "var-naming",
+ "waitgroup-by-value"
+ ]
+ },
+ "iface-analyzers": {
+ "enum": [
+ "identical",
+ "unused",
+ "opaque"
+ ]
+ },
+ "tagliatelle-cases": {
+ "enum": [
+ "",
+ "camel",
+ "pascal",
+ "kebab",
+ "snake",
+ "goCamel",
+ "goPascal",
+ "goKebab",
+ "goSnake",
+ "upper",
+ "upperSnake",
+ "lower",
+ "header"
+ ]
+ },
+ "linters": {
+ "$comment": "anyOf with enum is used to allow auto completion of non-custom linters",
+ "description": "Linters usable.",
+ "anyOf": [
+ {
+ "enum": [
+ "asasalint",
+ "asciicheck",
+ "bidichk",
+ "bodyclose",
+ "canonicalheader",
+ "containedctx",
+ "contextcheck",
+ "copyloopvar",
+ "cyclop",
+ "decorder",
+ "depguard",
+ "dogsled",
+ "dupl",
+ "dupword",
+ "durationcheck",
+ "errcheck",
+ "errchkjson",
+ "errname",
+ "errorlint",
+ "exhaustive",
+ "exhaustruct",
+ "exptostd",
+ "fatcontext",
+ "forbidigo",
+ "forcetypeassert",
+ "funlen",
+ "gci",
+ "ginkgolinter",
+ "gocheckcompilerdirectives",
+ "gochecknoglobals",
+ "gochecknoinits",
+ "gochecksumtype",
+ "gocognit",
+ "goconst",
+ "gocritic",
+ "gocyclo",
+ "godot",
+ "godox",
+ "err113",
+ "gofmt",
+ "gofumpt",
+ "goheader",
+ "goimports",
+ "gomoddirectives",
+ "gomodguard",
+ "goprintffuncname",
+ "gosec",
+ "gosimple",
+ "gosmopolitan",
+ "govet",
+ "grouper",
+ "iface",
+ "importas",
+ "inamedparam",
+ "ineffassign",
+ "interfacebloat",
+ "intrange",
+ "ireturn",
+ "lll",
+ "loggercheck",
+ "maintidx",
+ "makezero",
+ "mirror",
+ "misspell",
+ "mnd",
+ "musttag",
+ "nakedret",
+ "nestif",
+ "nilerr",
+ "nilnesserr",
+ "nilnil",
+ "nlreturn",
+ "noctx",
+ "nolintlint",
+ "nonamedreturns",
+ "nosprintfhostport",
+ "paralleltest",
+ "perfsprint",
+ "prealloc",
+ "predeclared",
+ "promlinter",
+ "protogetter",
+ "reassign",
+ "recvcheck",
+ "revive",
+ "rowserrcheck",
+ "sloglint",
+ "sqlclosecheck",
+ "staticcheck",
+ "stylecheck",
+ "tagalign",
+ "tagliatelle",
+ "tenv",
+ "testableexamples",
+ "testifylint",
+ "testpackage",
+ "thelper",
+ "tparallel",
+ "unconvert",
+ "unparam",
+ "unused",
+ "usestdlibvars",
+ "usetesting",
+ "varnamelen",
+ "wastedassign",
+ "whitespace",
+ "wrapcheck",
+ "wsl",
+ "zerologlint"
+ ]
+ },
+ {
+ "type": "string"
+ }
+ ]
+ },
+ "relative-path-modes": {
+ "enum": [
+ "gomod",
+ "gitroot",
+ "cfg",
+ "wd"
+ ]
+ }
+ },
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "run": {
+ "description": "Options for analysis running,",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "concurrency": {
+ "description": "Number of concurrent runners. Defaults to the number of available CPU cores.",
+ "type": "integer",
+ "minimum": 0,
+ "examples": [4]
+ },
+ "timeout": {
+ "description": "Timeout for the analysis.",
+ "type": "string",
+ "pattern": "^((\\d+h)?(\\d+m)?(\\d+(?:\\.\\d)?s)?|0)$",
+ "default": "1m",
+ "examples": ["30s", "5m", "5m30s"]
+ },
+ "issues-exit-code": {
+ "description": "Exit code when at least one issue was found.",
+ "type": "integer",
+ "default": 1
+ },
+ "tests": {
+ "description": "Enable inclusion of test files.",
+ "type": "boolean",
+ "default": true
+ },
+ "build-tags": {
+ "description": "List of build tags to pass to all linters.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "default": [],
+ "examples": [["mytag"]]
+ },
+ "modules-download-mode": {
+ "description": "Option to pass to \"go list -mod={option}\".\nSee \"go help modules\" for more information.",
+ "enum": ["mod", "readonly", "vendor"]
+ },
+ "allow-parallel-runners": {
+ "description": "Allow multiple parallel golangci-lint instances running. If disabled, golangci-lint acquires file lock on start.",
+ "type": "boolean",
+ "default": false
+ },
+ "allow-serial-runners": {
+ "description": "Allow multiple golangci-lint instances running, but serialize them around a lock.",
+ "type": "boolean",
+ "default": false
+ },
+ "go": {
+ "description": "Targeted Go version.",
+ "type": "string",
+ "default": "1.17"
+ },
+ "relative-path-mode": {
+ "description": "The mode used to evaluate relative paths.",
+ "type": "string",
+ "$ref": "#/definitions/relative-path-modes",
+ "default": "wd"
+ }
+ }
+ },
+ "output": {
+ "description": "Output configuration options.",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "formats": {
+ "description": "Output formats to use.",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "path": {
+ "default": "stdout",
+ "anyOf": [
+ {
+ "enum": [ "stdout", "stderr" ]
+ },
+ {
+ "type": "string"
+ }
+ ]
+ },
+ "format": {
+ "default": "colored-line-number",
+ "enum": [
+ "colored-line-number",
+ "line-number",
+ "json",
+ "colored-tab",
+ "tab",
+ "html",
+ "checkstyle",
+ "code-climate",
+ "junit-xml",
+ "junit-xml-extended",
+ "github-actions",
+ "teamcity",
+ "sarif"
+ ]
+ }
+ },
+ "required": ["format"]
+ }
+ },
+ "print-issued-lines": {
+ "description": "Print lines of code with issue.",
+ "type": "boolean",
+ "default": true
+ },
+ "print-linter-name": {
+ "description": "Print linter name in the end of issue text.",
+ "type": "boolean",
+ "default": true
+ },
+ "path-prefix": {
+ "description": "Add a prefix to the output file references.",
+ "type": "string",
+ "default": ""
+ },
+ "show-stats": {
+ "description": "Show statistics per linter.",
+ "type": "boolean",
+ "default": false
+ },
+ "sort-order": {
+ "type": "array",
+ "items": {
+ "enum": ["linter", "severity", "file"]
+ }
+ },
+ "sort-results": {
+ "description": "Sort results by: filepath, line and column.",
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "linters-settings": {
+ "description": "All available settings of specific linters.",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "dupword": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "keywords": {
+ "description": "Keywords for detecting duplicate words. If this list is not empty, only the words defined in this list will be detected.",
+ "type": "array",
+ "uniqueItems": true,
+ "items": {
+ "type": "string",
+ "examples": ["the", "and", "a"]
+ }
+ },
+ "ignore": {
+ "description": "Keywords used to ignore detection.",
+ "type": "array",
+ "uniqueItems": true,
+ "items": {
+ "type": "string",
+ "examples": ["0C0C"]
+ }
+ }
+ }
+ },
+ "asasalint": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "exclude": {
+ "description": "To specify a set of function names to exclude.",
+ "type": "array",
+ "uniqueItems": true,
+ "items": {
+ "type": "string",
+ "examples": ["\\.Wrapf"]
+ }
+ },
+ "use-builtin-exclusions": {
+ "description": "To enable/disable the asasalint builtin exclusions of function names.",
+ "type": "boolean",
+ "default": true
+ },
+ "ignore-test": {
+ "description": "Ignore *_test.go files.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "bidichk": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "left-to-right-embedding": {
+ "description": "Disallow: LEFT-TO-RIGHT-EMBEDDING",
+ "type": "boolean",
+ "default": false
+ },
+ "right-to-left-embedding": {
+ "description": "Disallow: RIGHT-TO-LEFT-EMBEDDING",
+ "type": "boolean",
+ "default": false
+ },
+ "pop-directional-formatting": {
+ "description": "Disallow: POP-DIRECTIONAL-FORMATTING",
+ "type": "boolean",
+ "default": false
+ },
+ "left-to-right-override": {
+ "description": "Disallow: LEFT-TO-RIGHT-OVERRIDE",
+ "type": "boolean",
+ "default": false
+ },
+ "right-to-left-override": {
+ "description": "Disallow: RIGHT-TO-LEFT-OVERRIDE",
+ "type": "boolean",
+ "default": false
+ },
+ "left-to-right-isolate": {
+ "description": "Disallow: LEFT-TO-RIGHT-ISOLATE",
+ "type": "boolean",
+ "default": false
+ },
+ "right-to-left-isolate": {
+ "description": "Disallow: RIGHT-TO-LEFT-ISOLATE",
+ "type": "boolean",
+ "default": false
+ },
+ "first-strong-isolate": {
+ "description": "Disallow: FIRST-STRONG-ISOLATE",
+ "type": "boolean",
+ "default": false
+ },
+ "pop-directional-isolate": {
+ "description": "Disallow: POP-DIRECTIONAL-ISOLATE",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "cyclop": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "skip-tests": {
+ "description": "Should the linter execute on test files as well",
+ "type": "boolean",
+ "default": false
+ },
+ "max-complexity": {
+ "description": "Max complexity the function can have",
+ "type": "integer",
+ "default": 10,
+ "minimum": 0
+ },
+ "package-average": {
+ "description": "Max average complexity in package",
+ "type": "number",
+ "default": 0,
+ "minimum": 0
+ }
+ }
+ },
+ "decorder": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "dec-order": {
+ "type": "array",
+ "default": [["type", "const", "var", "func"]],
+ "items": {
+ "enum": ["type", "const", "var", "func"]
+ }
+ },
+ "ignore-underscore-vars": {
+ "description": "Underscore vars (vars with \"_\" as the name) will be ignored at all checks",
+ "default": true,
+ "type": "boolean"
+ },
+ "disable-dec-order-check": {
+ "description": "Order of declarations is not checked",
+ "default": true,
+ "type": "boolean"
+ },
+ "disable-init-func-first-check": {
+ "description": "Allow init func to be anywhere in file",
+ "default": true,
+ "type": "boolean"
+ },
+ "disable-dec-num-check": {
+ "description": "Multiple global type, const and var declarations are allowed",
+ "default": true,
+ "type": "boolean"
+ },
+ "disable-type-dec-num-check": {
+ "description": "Type declarations will be ignored for dec num check",
+ "default": true,
+ "type": "boolean"
+ },
+ "disable-const-dec-num-check": {
+ "description": "Const declarations will be ignored for dec num check",
+ "default": true,
+ "type": "boolean"
+ },
+ "disable-var-dec-num-check": {
+ "description": "Var declarations will be ignored for dec num check",
+ "default": true,
+ "type": "boolean"
+ }
+ }
+ },
+ "depguard": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "rules": {
+ "description": "Rules to apply.",
+ "type": "object",
+ "additionalProperties": false,
+ "patternProperties": {
+ "^[^.]+$": {
+ "description": "Name of a rule.",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "list-mode": {
+ "description": "Used to determine the package matching priority.",
+ "enum": ["original", "strict", "lax"],
+ "default": "original"
+ },
+ "files": {
+ "description": "List of file globs that will match this list of settings to compare against.",
+ "additionalProperties": false,
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "allow": {
+ "description": "List of allowed packages.",
+ "additionalProperties": false,
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "deny": {
+ "description": "Packages that are not allowed where the value is a suggestion.",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "desc": {
+ "description": "Description",
+ "type": "string"
+ },
+ "pkg": {
+ "description": "Package",
+ "type": "string"
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "dogsled": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "max-blank-identifiers": {
+ "description": "Check assignments with too many blank identifiers.",
+ "type": "integer",
+ "default": 2,
+ "minimum": 0
+ }
+ }
+ },
+ "dupl": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "threshold": {
+ "description": "Tokens count to trigger issue.",
+ "type": "integer",
+ "default": 150,
+ "minimum": 0
+ }
+ }
+ },
+ "errcheck": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "check-type-assertions": {
+ "description": "Report about not checking errors in type assertions, i.e.: `a := b.(MyStruct)`",
+ "type": "boolean",
+ "default": false
+ },
+ "check-blank": {
+ "description": "Report about assignment of errors to blank identifier",
+ "type": "boolean",
+ "default": false
+ },
+ "exclude-functions": {
+ "description": "List of functions to exclude from checking, where each entry is a single function to exclude",
+ "type": "array",
+ "examples": ["io/ioutil.ReadFile", "io.Copy(*bytes.Buffer)"],
+ "items": {
+ "type": "string"
+ }
+ },
+ "disable-default-exclusions": {
+ "description": "To disable the errcheck built-in exclude list",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "errchkjson": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "check-error-free-encoding": {
+ "type": "boolean",
+ "default": false
+ },
+ "report-no-exported": {
+ "description": "Issue on struct that doesn't have exported fields.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "errorlint": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "errorf": {
+ "description": "Check whether fmt.Errorf uses the %w verb for formatting errors",
+ "type": "boolean",
+ "default": true
+ },
+ "errorf-multi": {
+ "description": "Permit more than 1 %w verb, valid per Go 1.20",
+ "type": "boolean",
+ "default": true
+ },
+ "asserts": {
+ "description": "Check for plain type assertions and type switches.",
+ "type": "boolean",
+ "default": true
+ },
+ "comparison": {
+ "description": "Check for plain error comparisons",
+ "type": "boolean",
+ "default": true
+ },
+ "allowed-errors": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "err": {
+ "type": "string"
+ },
+ "fun": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "allowed-errors-wildcard": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "err": {
+ "type": "string"
+ },
+ "fun": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ }
+ },
+ "exhaustive": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "check": {
+ "description": "Program elements to check for exhaustiveness.",
+ "type": "array",
+ "uniqueItems": true,
+ "items": {
+ "type": "string",
+ "examples": ["switch", "map"]
+ }
+ },
+ "check-generated": {
+ "description": "Check switch statements in generated files",
+ "type": "boolean",
+ "default": false
+ },
+ "explicit-exhaustive-switch": {
+ "description": "Only run exhaustive check on switches with \"//exhaustive:enforce\" comment.",
+ "type": "boolean",
+ "default": false
+ },
+ "explicit-exhaustive-map": {
+ "description": "Only run exhaustive check on map literals with \"//exhaustive:enforce\" comment.",
+ "type": "boolean",
+ "default": false
+ },
+ "default-case-required": {
+ "description": "Switch statement requires default case even if exhaustive.",
+ "type": "boolean",
+ "default": false
+ },
+ "default-signifies-exhaustive": {
+ "description": "Presence of `default` case in switch statements satisfies exhaustiveness, even if all enum members are not listed.",
+ "type": "boolean",
+ "default": false
+ },
+ "ignore-enum-members": {
+ "description": "Enum members matching `regex` do not have to be listed in switch statements to satisfy exhaustiveness",
+ "type": "string"
+ },
+ "ignore-enum-types": {
+ "description": "Enum types matching the supplied regex do not have to be listed in switch statements to satisfy exhaustiveness.",
+ "type": "string"
+ },
+ "package-scope-only": {
+ "description": "Consider enums only in package scopes, not in inner scopes.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "exhaustruct": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "include": {
+ "description": "List of regular expressions to match struct packages and names.",
+ "type": "array",
+ "examples": [".*\\.Test"],
+ "items": {
+ "type": "string"
+ }
+ },
+ "exclude": {
+ "description": "List of regular expressions to exclude struct packages and names from check.",
+ "type": "array",
+ "examples": ["cobra\\.Command$"],
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "fatcontext": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "check-struct-pointers": {
+ "description": "Check for potential fat contexts in struct pointers.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "forbidigo": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "exclude-godoc-examples": {
+ "description": "Exclude code in godoc examples.",
+ "type": "boolean",
+ "default": true
+ },
+ "analyze-types": {
+ "description": "Instead of matching the literal source code, use type information to replace expressions with strings that contain the package name and (for methods and fields) the type name.",
+ "type": "boolean",
+ "default": true
+ },
+ "forbid": {
+ "description": "List of identifiers to forbid (written using `regexp`)",
+ "type": "array",
+ "examples": ["^print(ln)?$"],
+ "items": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "p": {
+ "description": "Pattern",
+ "type": "string"
+ },
+ "pkg": {
+ "description": "Package",
+ "type": "string"
+ },
+ "msg": {
+ "description": "Message",
+ "type": "string"
+ }
+ }
+ }
+ ]
+ }
+ }
+ }
+ },
+ "funlen": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "lines": {
+ "description": "Limit lines number per function.",
+ "type": "integer",
+ "default": 60
+ },
+ "statements": {
+ "description": "Limit statements number per function.",
+ "type": "integer",
+ "default": 40
+ },
+ "ignore-comments": {
+ "description": "Ignore comments when counting lines.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "gci": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "sections": {
+ "description": "Section configuration to compare against.",
+ "type": "array",
+ "items": {
+ "anyOf": [
+ {
+ "enum": [
+ "standard",
+ "default",
+ "blank",
+ "dot",
+ "alias",
+ "localmodule"
+ ]
+ },
+ {
+ "type": "string"
+ }
+ ]
+ },
+ "default": ["standard", "default"]
+ },
+ "skip-generated": {
+ "description": "Skip generated files.",
+ "type": "boolean",
+ "default": true
+ },
+ "no-inline-comments": {
+ "description": "Checks that no inline Comments are present.",
+ "type": "boolean",
+ "default": false
+ },
+ "no-prefix-comments": {
+ "description": "Checks that no prefix Comments(comment lines above an import) are present.",
+ "type": "boolean",
+ "default": false
+ },
+ "custom-order": {
+ "description": "Enable custom order of sections.",
+ "type": "boolean",
+ "default": false
+ },
+ "no-lex-order": {
+ "description": "Drops lexical ordering for custom sections.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "ginkgolinter": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "suppress-len-assertion": {
+ "description": "Suppress the wrong length assertion warning.",
+ "type": "boolean",
+ "default": false
+ },
+ "suppress-nil-assertion": {
+ "description": "Suppress the wrong nil assertion warning.",
+ "type": "boolean",
+ "default": false
+ },
+ "suppress-err-assertion": {
+ "description": "Suppress the wrong error assertion warning.",
+ "type": "boolean",
+ "default": false
+ },
+ "suppress-compare-assertion": {
+ "description": "Suppress the wrong comparison assertion warning.",
+ "type": "boolean",
+ "default": false
+ },
+ "suppress-async-assertion": {
+ "description": "Suppress the function all in async assertion warning.",
+ "type": "boolean",
+ "default": false
+ },
+ "suppress-type-compare-assertion": {
+ "description": "Suppress warning for comparing values from different types, like int32 and uint32.",
+ "type": "boolean",
+ "default": false
+ },
+ "forbid-focus-container": {
+ "description": "Trigger warning for ginkgo focus containers like FDescribe, FContext, FWhen or FIt.",
+ "type": "boolean",
+ "default": false
+ },
+ "allow-havelen-zero": {
+ "description": "Don't trigger warnings for HaveLen(0).",
+ "type": "boolean",
+ "default": false
+ },
+ "force-expect-to": {
+ "description": "Force using `Expect` with `To`, `ToNot` or `NotTo`",
+ "type": "boolean",
+ "default": false
+ },
+ "validate-async-intervals": {
+ "description": "Best effort validation of async intervals (timeout and polling).",
+ "type": "boolean",
+ "default": false
+ },
+ "forbid-spec-pollution": {
+ "description": "Trigger a warning for variable assignments in ginkgo containers like `Describe`, `Context` and `When`, instead of in `BeforeEach()`.",
+ "type": "boolean",
+ "default": false
+ },
+ "force-succeed": {
+ "description": "Force using the Succeed matcher for error functions, and the HaveOccurred matcher for non-function error values.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "gochecksumtype": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "default-signifies-exhaustive": {
+ "description": "Presence of `default` case in switch statements satisfies exhaustiveness, if all members are not listed.",
+ "type": "boolean",
+ "default": true
+ },
+ "include-shared-interfaces": {
+ "description": "Include shared interfaces in the exhaustiviness check.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "gocognit": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "min-complexity": {
+ "description": "Minimal code complexity to report (we recommend 10-20).",
+ "type": "integer",
+ "default": 30
+ }
+ }
+ },
+ "goconst": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "match-constant": {
+ "description": "Look for existing constants matching the values",
+ "type": "boolean",
+ "default": true
+ },
+ "min-len": {
+ "description": "Minimum length of string constant.",
+ "type": "integer",
+ "default": 3
+ },
+ "min-occurrences": {
+ "description": "Minimum occurrences count to trigger.",
+ "type": "integer",
+ "default": 3
+ },
+ "ignore-tests": {
+ "description": "Ignore test files.",
+ "type": "boolean",
+ "default": false
+ },
+ "ignore-calls": {
+ "description": "Ignore when constant is not used as function argument",
+ "type": "boolean",
+ "default": true
+ },
+ "ignore-strings": {
+ "description": "Exclude strings matching the given regular expression",
+ "type": "string"
+ },
+ "numbers": {
+ "description": "Search also for duplicated numbers.",
+ "type": "boolean",
+ "default": false
+ },
+ "min": {
+ "description": "Minimum value, only works with `numbers`",
+ "type": "integer",
+ "default": 3
+ },
+ "max": {
+ "description": "Maximum value, only works with `numbers`",
+ "type": "integer",
+ "default": 3
+ }
+ }
+ },
+ "gocritic": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "enabled-checks": {
+ "description": "Which checks should be enabled. By default, a list of stable checks is used. To see it, run `GL_DEBUG=gocritic golangci-lint run`.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/gocritic-checks"
+ }
+ },
+ "disabled-checks": {
+ "description": "Which checks should be disabled.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/gocritic-checks"
+ },
+ "default": []
+ },
+ "enabled-tags": {
+ "description": "Enable multiple checks by tags, run `GL_DEBUG=gocritic golangci-lint run` to see all tags and checks.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/gocritic-tags"
+ }
+ },
+ "disabled-tags": {
+ "description": "Disable multiple checks by tags, run `GL_DEBUG=gocritic golangci-lint run` to see all tags and checks.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/gocritic-tags"
+ }
+ },
+ "settings": {
+ "description": "Settings passed to gocritic. Properties must be valid and enabled check names.",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "captLocal": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "paramsOnly" : {
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "commentedOutCode": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "minLength" : {
+ "type": "number",
+ "default": 15
+ }
+ }
+ },
+ "elseif": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "skipBalanced" : {
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "hugeParam": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "sizeThreshold" : {
+ "type": "number",
+ "default": 80
+ }
+ }
+ },
+ "ifElseChain": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "minThreshold" : {
+ "type": "number",
+ "default": 2
+ }
+ }
+ },
+ "nestingReduce": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "bodyWidth" : {
+ "type": "number",
+ "default": 5
+ }
+ }
+ },
+ "rangeExprCopy": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "sizeThreshold" : {
+ "type": "number",
+ "default": 512
+ },
+ "skipTestFuncs" : {
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "rangeValCopy": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "sizeThreshold" : {
+ "type": "number",
+ "default": 128
+ },
+ "skipTestFuncs" : {
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "ruleguard": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "debug" : {
+ "type": "string"
+ },
+ "enable" : {
+ "type": "string"
+ },
+ "disable" : {
+ "type": "string"
+ },
+ "failOn" : {
+ "type": "string"
+ },
+ "rules" : {
+ "type": "string"
+ }
+ }
+ },
+ "tooManyResultsChecker": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "maxResults" : {
+ "type": "number",
+ "default": 5
+ }
+ }
+ },
+ "truncateCmp": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "skipArchDependent" : {
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "underef": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "skipRecvDeref" : {
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "unnamedResult": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "checkExported" : {
+ "type": "boolean",
+ "default": false
+ }
+ }
+ }
+ }
+ },
+ "disable-all": {
+ "type": "boolean",
+ "default": false
+ },
+ "enable-all": {
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "gocyclo": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "min-complexity": {
+ "description": "Minimum code complexity to report (we recommend 10-20).",
+ "type": "integer",
+ "default": 30
+ }
+ }
+ },
+ "godot": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "scope": {
+ "description": "Comments to be checked.",
+ "enum": ["declarations", "toplevel", "all"],
+ "default": "declarations"
+ },
+ "exclude": {
+ "description": "List of regexps for excluding particular comment lines from check.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "period": {
+ "description": "Check that each sentence ends with a period.",
+ "type": "boolean",
+ "default": true
+ },
+ "capital": {
+ "description": "Check that each sentence starts with a capital letter.",
+ "type": "boolean",
+ "default": false
+ },
+ "check-all": {
+ "description": "DEPRECATED: Check all top-level comments, not only declarations.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "godox": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "keywords": {
+ "description": "Report any comments starting with one of these keywords. This is useful for TODO or FIXME comments that might be left in the code accidentally and should be resolved before merging.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "default": ["TODO", "BUG", "FIXME"]
+ }
+ }
+ },
+ "gofmt": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "simplify": {
+ "description": "Simplify code.",
+ "type": "boolean",
+ "default": true
+ },
+ "rewrite-rules": {
+ "description": "Apply the rewrite rules to the source before reformatting.",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "pattern": {
+ "type": "string"
+ },
+ "replacement": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ }
+ },
+ "interfacebloat": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "max": {
+ "description": "The maximum number of methods allowed for an interface.",
+ "type": "integer"
+ }
+ }
+ },
+ "gofumpt": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "extra-rules": {
+ "description": "Choose whether or not to use the extra rules that are disabled by default.",
+ "type": "boolean",
+ "default": false
+ },
+ "module-path": {
+ "description": " Module path which contains the source code being formatted.",
+ "type": "string"
+ }
+ }
+ },
+ "goheader": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "values": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "const": {
+ "description": "Constants to use in the template.",
+ "type": "object",
+ "patternProperties": {
+ "^.+$": {
+ "description": "Value for the constant.",
+ "type": "string"
+ }
+ },
+ "additionalProperties": false,
+ "examples": [
+ {
+ "YEAR": "2030",
+ "COMPANY": "MY FUTURISTIC COMPANY"
+ }
+ ]
+ },
+ "regexp": {
+ "description": "Regular expressions to use in your template.",
+ "type": "object",
+ "additionalProperties": false,
+ "patternProperties": {
+ "^.+$": {
+ "type": "string"
+ }
+ },
+ "examples": [
+ {
+ "AUTHOR": ".*@mycompany\\.com"
+ }
+ ]
+ }
+ }
+ },
+ "template": {
+ "description": "Template to put on top of every file.",
+ "type": "string",
+ "examples": [
+ "{{ MY COMPANY }}\nSPDX-License-Identifier: Apache-2.0\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at:\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License."
+ ]
+ },
+ "template-path": {
+ "description": "Path to the file containing the template source.",
+ "type": "string",
+ "examples": ["my_header_template.txt"]
+ }
+ },
+ "oneOf": [
+ { "required": ["template"] },
+ { "required": ["template-path"] }
+ ]
+ },
+ "goimports": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "local-prefixes": {
+ "description": "Put imports beginning with prefix after 3rd-party packages. It is a comma-separated list of prefixes.",
+ "type": "string",
+ "examples": ["github.com/org/project"]
+ }
+ }
+ },
+ "gomoddirectives": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "replace-local": {
+ "description": "Allow local `replace` directives.",
+ "type": "boolean",
+ "default": true
+ },
+ "replace-allow-list": {
+ "description": "List of allowed `replace` directives.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "retract-allow-no-explanation": {
+ "description": "Allow to not explain why the version has been retracted in the `retract` directives.",
+ "type": "boolean",
+ "default": false
+ },
+ "exclude-forbidden": {
+ "description": "Forbid the use of the `exclude` directives.",
+ "type": "boolean",
+ "default": false
+ },
+ "toolchain-forbidden": {
+ "description": "Forbid the use of the `toolchain` directive.",
+ "type": "boolean",
+ "default": false
+ },
+ "toolchain-pattern": {
+ "description": "Defines a pattern to validate `toolchain` directive.",
+ "type": "string"
+ },
+ "tool-forbidden": {
+ "description": "Forbid the use of the `tool` directives.",
+ "type": "boolean",
+ "default": false
+ },
+ "go-debug-forbidden": {
+ "description": "Forbid the use of the `godebug` directive.",
+ "type": "boolean",
+ "default": false
+ },
+ "go-version-pattern": {
+ "description": "Defines a pattern to validate `go` minimum version directive.",
+ "type": "string",
+ "default": ""
+ }
+ }
+ },
+ "gomodguard": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "allowed": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "modules": {
+ "description": "List of allowed modules.",
+ "type": "array",
+ "items": {
+ "type": "string",
+ "examples": ["gopkg.in/yaml.v2"]
+ }
+ },
+ "domains": {
+ "description": "List of allowed module domains.",
+ "type": "array",
+ "items": {
+ "type": "string",
+ "examples": ["golang.org"]
+ }
+ }
+ }
+ },
+ "blocked": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "modules": {
+ "description": "List of blocked modules.",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "patternProperties": {
+ "^.+$": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "recommendations": {
+ "description": "Recommended modules that should be used instead.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "reason": {
+ "description": "Reason why the recommended module should be used.",
+ "type": "string"
+ }
+ }
+ }
+ },
+ "additionalProperties": false
+ }
+ },
+ "versions": {
+ "description": "List of blocked module version constraints.",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "patternProperties": {
+ "^.*$": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "version": {
+ "description": "Version constraint.",
+ "type": "string"
+ },
+ "reason": {
+ "description": "Reason why the version constraint exists.",
+ "type": "string"
+ }
+ },
+ "required": ["reason"]
+ }
+ }
+ }
+ },
+ "local_replace_directives": {
+ "description": "Raise lint issues if loading local path with replace directive",
+ "type": "boolean",
+ "default": true
+ }
+ }
+ }
+ }
+ },
+ "gosimple": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "checks": {
+ "type": "array",
+ "items": {
+ "anyOf": [
+ {
+ "enum": ["all"]
+ },
+ {
+ "type": "string"
+ }
+ ]
+ }
+ }
+ }
+ },
+ "gosec": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "includes": {
+ "type": "array",
+ "description": "To select a subset of rules to run",
+ "examples": [["G401"]],
+ "items": {
+ "$ref": "#/definitions/gosec-rules"
+ }
+ },
+ "excludes": {
+ "type": "array",
+ "description": "To specify a set of rules to explicitly exclude",
+ "examples": [["G401"]],
+ "items": {
+ "$ref": "#/definitions/gosec-rules"
+ }
+ },
+ "exclude-generated": {
+ "description": "Exclude generated files",
+ "type": "boolean",
+ "default": false
+ },
+ "severity": {
+ "description": "Filter out the issues with a lower severity than the given value",
+ "type": "string",
+ "enum": ["low", "medium", "high"],
+ "default": "low"
+ },
+ "confidence": {
+ "description": "Filter out the issues with a lower confidence than the given value",
+ "type": "string",
+ "enum": ["low", "medium", "high"],
+ "default": "low"
+ },
+ "config": {
+ "description": "To specify the configuration of rules",
+ "type": "object"
+ },
+ "concurrency": {
+ "description": "Concurrency value",
+ "type": "integer"
+ }
+ }
+ },
+ "gosmopolitan": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "allow-time-local": {
+ "description": "Allow and ignore `time.Local` usages.",
+ "type": "boolean",
+ "default": false
+ },
+ "escape-hatches": {
+ "description": "List of fully qualified names in the `full/pkg/path.name` form, to act as \"i18n escape hatches\".",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ignore-tests": {
+ "description": "Ignore test files.",
+ "type": "boolean",
+ "default": false
+ },
+ "watch-for-scripts": {
+ "description": "List of Unicode scripts to watch for any usage in string literals.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "govet": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "settings": {
+ "description": "Settings per analyzer. Map of analyzer name to specific settings.\nRun `go tool vet help` to find out more.",
+ "type": "object",
+ "propertyNames": {
+ "$ref": "#/definitions/govet-analyzers"
+ },
+ "patternProperties": {
+ "^.*$": {
+ "description": "Run `go tool vet help ` to see all settings.",
+ "type": "object"
+ }
+ }
+ },
+ "enable": {
+ "description": "Enable analyzers by name.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/govet-analyzers"
+ }
+ },
+ "disable": {
+ "description": "Disable analyzers by name.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/govet-analyzers"
+ }
+ },
+ "enable-all": {
+ "description": "Enable all analyzers.",
+ "type": "boolean",
+ "default": false
+ },
+ "disable-all": {
+ "description": "Disable all analyzers.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "grouper": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "const-require-single-const": {
+ "type": "boolean",
+ "default": false
+ },
+ "const-require-grouping": {
+ "type": "boolean",
+ "default": false
+ },
+ "import-require-single-import": {
+ "type": "boolean",
+ "default": false
+ },
+ "import-require-grouping": {
+ "type": "boolean",
+ "default": false
+ },
+ "type-require-single-type": {
+ "type": "boolean",
+ "default": false
+ },
+ "type-require-grouping": {
+ "type": "boolean",
+ "default": false
+ },
+ "var-require-single-var": {
+ "type": "boolean",
+ "default": false
+ },
+ "var-require-grouping": {
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "iface": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "enable": {
+ "description": "Enable analyzers by name.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/iface-analyzers"
+ }
+ },
+ "settings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "unused": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "exclude": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "importas": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "no-unaliased": {
+ "description": "Do not allow unaliased imports of aliased packages.",
+ "type": "boolean",
+ "default": false
+ },
+ "no-extra-aliases": {
+ "description": "Do not allow non-required aliases.",
+ "type": "boolean",
+ "default": false
+ },
+ "alias": {
+ "description": "List of aliases",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "pkg": {
+ "description": "Package path e.g. knative.dev/serving/pkg/apis/autoscaling/v1alpha1",
+ "type": "string"
+ },
+ "alias": {
+ "description": "Package alias e.g. autoscalingv1alpha1",
+ "type": "string"
+ }
+ },
+ "required": ["pkg", "alias"]
+ }
+ }
+ }
+ },
+ "inamedparam": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "skip-single-param": {
+ "description": "Skips check for interface methods with only a single parameter.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "ireturn": {
+ "type": "object",
+ "additionalProperties": false,
+ "description": "Use either `reject` or `allow` properties for interfaces matching.",
+ "properties": {
+ "allow": {
+ "type": "array",
+ "items": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "enum": ["anon", "error", "empty", "stdlib"]
+ }
+ ]
+ }
+ },
+ "reject": {
+ "type": "array",
+ "items": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "enum": ["anon", "error", "empty", "stdlib"]
+ }
+ ]
+ }
+ }
+ },
+ "anyOf": [
+ {
+ "not": {
+ "properties": {
+ "allow": {
+ "const": "reject"
+ }
+ }
+ },
+ "required": ["allow"]
+ },
+ {
+ "required": ["reject"]
+ }
+ ]
+ },
+ "lll": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "tab-width": {
+ "description": "Width of \"\\t\" in spaces.",
+ "type": "integer",
+ "minimum": 0,
+ "default": 1
+ },
+ "line-length": {
+ "description": "Maximum allowed line length, lines longer will be reported.",
+ "type": "integer",
+ "minimum": 1,
+ "default": 120
+ }
+ }
+ },
+ "maintidx": {
+ "description": "Maintainability index https://docs.microsoft.com/en-us/visualstudio/code-quality/code-metrics-maintainability-index-range-and-meaning?view=vs-2022",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "under": {
+ "description": "Minimum accatpable maintainability index level (see https://docs.microsoft.com/en-us/visualstudio/code-quality/code-metrics-maintainability-index-range-and-meaning?view=vs-2022)",
+ "type": "number",
+ "default": 20
+ }
+ }
+ },
+ "makezero": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "always": {
+ "description": "Allow only slices initialized with a length of zero.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "loggercheck": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "kitlog": {
+ "description": "Allow check for the github.com/go-kit/log library.",
+ "type": "boolean",
+ "default": true
+ },
+ "klog": {
+ "description": "Allow check for the k8s.io/klog/v2 library.",
+ "type": "boolean",
+ "default": true
+ },
+ "logr": {
+ "description": "Allow check for the github.com/go-logr/logr library.",
+ "type": "boolean",
+ "default": true
+ },
+ "slog": {
+ "description": "Allow check for the log/slog library.",
+ "type": "boolean",
+ "default": true
+ },
+ "zap": {
+ "description": "Allow check for the \"sugar logger\" from go.uber.org/zap library.",
+ "type": "boolean",
+ "default": true
+ },
+ "require-string-key": {
+ "description": "Require all logging keys to be inlined constant strings.",
+ "type": "boolean",
+ "default": false
+ },
+ "no-printf-like": {
+ "description": "Require printf-like format specifier (%s, %d for example) not present.",
+ "type": "boolean",
+ "default": false
+ },
+ "rules": {
+ "description": "List of custom rules to check against, where each rule is a single logger pattern, useful for wrapped loggers.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "misspell": {
+ "description": "Correct spellings using locale preferences for US or UK. Default is to use a neutral variety of English.",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "locale": {
+ "enum": ["US", "UK"]
+ },
+ "ignore-words": {
+ "description": "List of words to ignore.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "mode": {
+ "description": "Mode of the analysis.",
+ "enum": ["restricted", "", "default"],
+ "default": ""
+ },
+ "extra-words": {
+ "description": "Extra word corrections.",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "correction": {
+ "type": "string"
+ },
+ "typo": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ }
+ },
+ "musttag": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "functions": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "name": {
+ "type": "string"
+ },
+ "tag": {
+ "type": "string"
+ },
+ "arg-pos": {
+ "type": "integer"
+ }
+ }
+ }
+ }
+ }
+ },
+ "nakedret": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "max-func-lines": {
+ "description": "Report if a function has more lines of code than this value and it has naked returns.",
+ "type": "integer",
+ "minimum": 0,
+ "default": 30
+ }
+ }
+ },
+ "nestif": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "min-complexity": {
+ "description": "Minimum complexity of \"if\" statements to report.",
+ "type": "integer",
+ "default": 5
+ }
+ }
+ },
+ "nilnil": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "detect-opposite": {
+ "type": "boolean",
+ "description": "In addition, detect opposite situation (simultaneous return of non-nil error and valid value).",
+ "default": false
+ },
+ "checked-types": {
+ "type": "array",
+ "description": "List of return types to check.",
+ "items": {
+ "enum": ["chan", "func", "iface", "map", "ptr", "uintptr", "unsafeptr"]
+ },
+ "default": ["chan", "func", "iface", "map", "ptr", "uintptr", "unsafeptr"]
+ }
+ }
+ },
+ "nlreturn": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "block-size": {
+ "description": "set block size that is still ok",
+ "type": "number",
+ "default": 0,
+ "minimum": 0
+ }
+ }
+ },
+ "mnd": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "ignored-files": {
+ "description": "List of file patterns to exclude from analysis.",
+ "examples": [["magic1_.*.go"]],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ignored-functions": {
+ "description": "Comma-separated list of function patterns to exclude from the analysis.",
+ "examples": [["math.*", "http.StatusText", "make"]],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ignored-numbers": {
+ "description": "List of numbers to exclude from analysis.",
+ "examples": [["1000", "1234_567_890", "3.14159264"]],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "checks": {
+ "description": "The list of enabled checks, see https://github.com/tommy-muehle/go-mnd/#checks for description.",
+ "type": "array",
+ "items": {
+ "enum": [
+ "argument",
+ "case",
+ "condition",
+ "operation",
+ "return",
+ "assign"
+ ]
+ }
+ }
+ }
+ },
+ "nolintlint": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "allow-unused": {
+ "description": "Enable to ensure that nolint directives are all used.",
+ "type": "boolean",
+ "default": true
+ },
+ "allow-no-explanation": {
+ "description": "Exclude these linters from requiring an explanation.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/linters"
+ },
+ "default": []
+ },
+ "require-explanation": {
+ "description": "Enable to require an explanation of nonzero length after each nolint directive.",
+ "type": "boolean",
+ "default": false
+ },
+ "require-specific": {
+ "description": "Enable to require nolint directives to mention the specific linter being suppressed.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "reassign": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "patterns": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "recvcheck": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "disable-builtin": {
+ "description": "Disables the built-in method exclusions.",
+ "type": "boolean",
+ "default": true
+ },
+ "exclusions": {
+ "description": "User-defined method exclusions.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "nonamedreturns": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "report-error-in-defer": {
+ "description": "Report named error if it is assigned inside defer.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "paralleltest": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "ignore-missing": {
+ "description": "Ignore missing calls to `t.Parallel()` and only report incorrect uses of it.",
+ "type": "boolean",
+ "default": false
+ },
+ "ignore-missing-subtests": {
+ "description": "Ignore missing calls to `t.Parallel()` in subtests. Top-level tests are still required to have `t.Parallel`, but subtests are allowed to skip it.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "perfsprint": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "integer-format": {
+ "description": "Enable/disable optimization of integer formatting.",
+ "type": "boolean",
+ "default": true
+ },
+ "int-conversion": {
+ "description": "Optimizes even if it requires an int or uint type cast.",
+ "type": "boolean",
+ "default": true
+ },
+ "error-format": {
+ "description": "Enable/disable optimization of error formatting.",
+ "type": "boolean",
+ "default": true
+ },
+ "err-error": {
+ "description": "Optimizes into `err.Error()` even if it is only equivalent for non-nil errors.",
+ "type": "boolean",
+ "default": false
+ },
+ "errorf": {
+ "description": "Optimizes `fmt.Errorf`.",
+ "type": "boolean",
+ "default": true
+ },
+ "string-format": {
+ "description": "Enable/disable optimization of string formatting.",
+ "type": "boolean",
+ "default": true
+ },
+ "sprintf1": {
+ "description": "Optimizes `fmt.Sprintf` with only one argument.",
+ "type": "boolean",
+ "default": true
+ },
+ "strconcat": {
+ "description": "Optimizes into strings concatenation.",
+ "type": "boolean",
+ "default": true
+ },
+ "bool-format": {
+ "description": "Enable/disable optimization of bool formatting.",
+ "type": "boolean",
+ "default": true
+ },
+ "hex-format": {
+ "description": "Enable/disable optimization of hex formatting.",
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "prealloc": {
+ "description": "We do not recommend using this linter before doing performance profiling.\nFor most programs usage of `prealloc` will be premature optimization.",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "simple": {
+ "description": "Report preallocation suggestions only on simple loops that have no returns/breaks/continues/gotos in them.",
+ "type": "boolean",
+ "default": true
+ },
+ "range-loops": {
+ "description": "Report preallocation suggestions on range loops.",
+ "type": "boolean",
+ "default": true
+ },
+ "for-loops": {
+ "description": "Report preallocation suggestions on for loops.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "predeclared": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "ignore": {
+ "description": "Comma-separated list of predeclared identifiers to not report on.",
+ "type": "string"
+ },
+ "q": {
+ "description": "Include method names and field names (i.e., qualified names) in checks.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "promlinter": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "strict": {},
+ "disabled-linters": {
+ "type": "array",
+ "items": {
+ "enum": [
+ "Help",
+ "MetricUnits",
+ "Counter",
+ "HistogramSummaryReserved",
+ "MetricTypeInName",
+ "ReservedChars",
+ "CamelCase",
+ "UnitAbbreviations"
+ ]
+ }
+ }
+ }
+ },
+ "protogetter": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "skip-generated-by": {
+ "type": "array",
+ "items": {
+ "type": "string",
+ "examples": ["protoc-gen-go-my-own-generator"]
+ }
+ },
+ "skip-files": {
+ "type": "array",
+ "items": {
+ "type": "string",
+ "examples": ["*.pb.go"]
+ }
+ },
+ "skip-any-generated": {
+ "description": "Skip any generated files from the checking.",
+ "type": "boolean",
+ "default": false
+ },
+ "replace-first-arg-in-append": {
+ "description": "Skip first argument of append function.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "revive": {
+ "type": "object",
+ "additionalProperties": false,
+ "examples": [
+ {
+ "ignore-generated-header": true,
+ "severity": "warning",
+ "rules": [
+ {
+ "name": "indent-error-flow",
+ "severity": "warning"
+ },
+ {
+ "name": "add-constant",
+ "severity": "warning",
+ "arguments": [
+ {
+ "maxLitCount": "3",
+ "allowStrs": "\"\"",
+ "allowInts": "0,1,2",
+ "allowFloats": "0.0,0.,1.0,1.,2.0,2."
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ "properties": {
+ "max-open-files": {
+ "type": "integer"
+ },
+ "ignore-generated-header": {
+ "type": "boolean"
+ },
+ "confidence": {
+ "type": "number"
+ },
+ "severity": {
+ "type": "string",
+ "enum": ["warning", "error"]
+ },
+ "enable-all-rules": {
+ "type": "boolean",
+ "default": false
+ },
+ "directives": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "name": {
+ "type": "string",
+ "enum": ["specify-disable-reason"]
+ },
+ "severity": {
+ "type": "string",
+ "enum": ["warning", "error"]
+ },
+ "exclude": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "arguments": {
+ "type": "array"
+ }
+ }
+ }
+ },
+ "rules": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "required": ["name"],
+ "properties": {
+ "name": {
+ "$ref": "#/definitions/revive-rules",
+ "title": "The rule name"
+ },
+ "disabled": {
+ "type": "boolean"
+ },
+ "severity": {
+ "type": "string",
+ "enum": ["warning", "error"]
+ },
+ "exclude": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "arguments": {
+ "type": "array"
+ }
+ }
+ }
+ }
+ }
+ },
+ "rowserrcheck": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "packages": {
+ "type": "array",
+ "items": {
+ "description": "",
+ "type": "string",
+ "examples": ["github.com/jmoiron/sqlx"]
+ }
+ }
+ }
+ },
+ "sloglint": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "kv-only": {
+ "description": "Enforce using key-value pairs only (incompatible with attr-only).",
+ "type": "boolean",
+ "default": false
+ },
+ "no-global": {
+ "description": "Enforce not using global loggers.",
+ "enum": ["", "all", "default"],
+ "default": ""
+ },
+ "no-mixed-args": {
+ "description": "Enforce not mixing key-value pairs and attributes.",
+ "type": "boolean",
+ "default": true
+ },
+ "context": {
+ "description": "Enforce using methods that accept a context.",
+ "enum": ["", "all", "scope"],
+ "default": ""
+ },
+ "static-msg": {
+ "description": "Enforce using static values for log messages.",
+ "type": "boolean",
+ "default": false
+ },
+ "key-naming-case": {
+ "description": "Enforce a single key naming convention.",
+ "enum": ["snake", "kebab", "camel", "pascal"]
+ },
+ "attr-only": {
+ "description": "Enforce using attributes only (incompatible with kv-only).",
+ "type": "boolean",
+ "default": false
+ },
+ "no-raw-keys": {
+ "description": "Enforce using constants instead of raw keys.",
+ "type": "boolean",
+ "default": false
+ },
+ "forbidden-keys": {
+ "description": "Enforce not using specific keys.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "args-on-sep-lines": {
+ "description": "Enforce putting arguments on separate lines.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "spancheck": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "checks": {
+ "description": "Checks to enable.",
+ "type": "array",
+ "items": {
+ "enum": ["end", "record-error", "set-status"]
+ }
+ },
+ "ignore-check-signatures": {
+ "description": "A list of regexes for function signatures that silence `record-error` and `set-status` reports if found in the call path to a returned error.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "extra-start-span-signatures": {
+ "description": "A list of regexes for additional function signatures that create spans.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "staticcheck": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "checks": {
+ "type": "array",
+ "items": {
+ "anyOf": [
+ {
+ "enum": ["all"]
+ },
+ {
+ "type": "string"
+ }
+ ]
+ }
+ }
+ }
+ },
+ "stylecheck": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "checks": {
+ "type": "array",
+ "items": {
+ "anyOf": [
+ {
+ "enum": ["all"]
+ },
+ {
+ "type": "string"
+ }
+ ]
+ },
+ "default": [
+ "all",
+ "-ST1000",
+ "-ST1003",
+ "-ST1016",
+ "-ST1020",
+ "-ST1021",
+ "-ST1022"
+ ]
+ },
+ "dot-import-whitelist": {
+ "description": "By default, ST1001 forbids all uses of dot imports in non-test packages. This setting allows setting a whitelist of import paths that can be dot-imported anywhere.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "http-status-code-whitelist": {
+ "description": "ST1013 recommends using constants from the net/http package instead of hard-coding numeric HTTP status codes. This setting specifies a list of numeric status codes that this check does not complain about.",
+ "default": ["200", "400", "404", "500"],
+ "type": "array",
+ "items": {
+ "enum": [
+ "100",
+ "101",
+ "102",
+ "103",
+ "200",
+ "201",
+ "202",
+ "203",
+ "204",
+ "205",
+ "206",
+ "207",
+ "208",
+ "226",
+ "300",
+ "301",
+ "302",
+ "303",
+ "304",
+ "305",
+ "306",
+ "307",
+ "308",
+ "400",
+ "401",
+ "402",
+ "403",
+ "404",
+ "405",
+ "406",
+ "407",
+ "408",
+ "409",
+ "410",
+ "411",
+ "412",
+ "413",
+ "414",
+ "415",
+ "416",
+ "417",
+ "418",
+ "421",
+ "422",
+ "423",
+ "424",
+ "425",
+ "426",
+ "428",
+ "429",
+ "431",
+ "451",
+ "500",
+ "501",
+ "502",
+ "503",
+ "504",
+ "505",
+ "506",
+ "507",
+ "508",
+ "510",
+ "511"
+ ]
+ }
+ },
+ "initialisms": {
+ "description": "ST1003 check, among other things, for the correct capitalization of initialisms. The set of known initialisms can be configured with this option.",
+ "type": "array",
+ "items": {
+ "type": "string",
+ "default": [
+ "ACL",
+ "API",
+ "ASCII",
+ "CPU",
+ "CSS",
+ "DNS",
+ "EOF",
+ "GUID",
+ "HTML",
+ "HTTP",
+ "HTTPS",
+ "ID",
+ "IP",
+ "JSON",
+ "QPS",
+ "RAM",
+ "RPC",
+ "SLA",
+ "SMTP",
+ "SQL",
+ "SSH",
+ "TCP",
+ "TLS",
+ "TTL",
+ "UDP",
+ "UI",
+ "GID",
+ "UID",
+ "UUID",
+ "URI",
+ "URL",
+ "UTF8",
+ "VM",
+ "XML",
+ "XMPP",
+ "XSRF",
+ "XSS",
+ "SIP",
+ "RTP",
+ "AMQP",
+ "DB",
+ "TS"
+ ]
+ }
+ }
+ }
+ },
+ "tagalign": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "align": {
+ "description": "Align and sort can be used together or separately.",
+ "type": "boolean",
+ "default": true
+ },
+ "sort": {
+ "description": "Whether enable tags sort.",
+ "type": "boolean",
+ "default": true
+ },
+ "order": {
+ "description": "Specify the order of tags, the other tags will be sorted by name.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "default": [],
+ "examples": [
+ [
+ "json",
+ "yaml",
+ "yml",
+ "toml",
+ "mapstructure",
+ "binding",
+ "validate"
+ ]
+ ]
+ },
+ "strict": {
+ "description": "Whether enable strict style.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "tagliatelle": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "case": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "use-field-name": {
+ "description": "Use the struct field name to check the name of the struct tag.",
+ "type": "boolean",
+ "default": false
+ },
+ "ignored-fields": {
+ "description": "The field names to ignore.",
+ "type": "array",
+ "items": {
+ "type": "string",
+ "examples": ["example"]
+ }
+ },
+ "rules": {
+ "type": "object",
+ "patternProperties": {
+ "^.+$": {
+ "$ref": "#/definitions/tagliatelle-cases"
+ }
+ }
+ },
+ "extended-rules": {
+ "description": "Defines the association between tag name and case.",
+ "type": "object",
+ "patternProperties": {
+ "^.+$": {
+ "type": "object",
+ "additionalProperties": false,
+ "required": ["case"],
+ "properties": {
+ "case": {
+ "$ref": "#/definitions/tagliatelle-cases"
+ },
+ "extra-initialisms": {
+ "type": "boolean",
+ "default": false
+ },
+ "initialism-overrides": {
+ "type": "object",
+ "patternProperties": {
+ "^.+$": {
+ "type": "boolean",
+ "default": false
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "overrides": {
+ "description": "Overrides the default/root configuration.",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "required": ["pkg"],
+ "properties": {
+ "pkg": {
+ "description": "A package path.",
+ "type": "string"
+ },
+ "use-field-name": {
+ "description": "Use the struct field name to check the name of the struct tag.",
+ "type": "boolean",
+ "default": false
+ },
+ "ignored-fields": {
+ "description": "The field names to ignore.",
+ "type": "array",
+ "items": {
+ "type": "string",
+ "examples": ["example"]
+ }
+ },
+ "ignore": {
+ "description": "Ignore the package (takes precedence over all other configurations).",
+ "type": "boolean",
+ "default": false
+ },
+ "rules": {
+ "type": "object",
+ "patternProperties": {
+ "^.+$": {
+ "$ref": "#/definitions/tagliatelle-cases"
+ }
+ }
+ },
+ "extended-rules": {
+ "description": "Defines the association between tag name and case.",
+ "type": "object",
+ "patternProperties": {
+ "^.+$": {
+ "type": "object",
+ "additionalProperties": false,
+ "required": ["case"],
+ "properties": {
+ "case": {
+ "$ref": "#/definitions/tagliatelle-cases"
+ },
+ "extra-initialisms": {
+ "type": "boolean",
+ "default": false
+ },
+ "initialism-overrides": {
+ "type": "object",
+ "patternProperties": {
+ "^.+$": {
+ "type": "boolean",
+ "default": false
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "tenv": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "all": {
+ "description": "The option `all` will run against whole test files (`_test.go`) regardless of method/function signatures.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "testifylint": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "enable-all": {
+ "description": "Enable all checkers.",
+ "type": "boolean",
+ "default": false
+ },
+ "disable-all": {
+ "description": "Disable all checkers.",
+ "type": "boolean",
+ "default": false
+ },
+ "enable": {
+ "description": "Enable specific checkers.",
+ "type": "array",
+ "items": {
+ "enum": [
+ "blank-import",
+ "bool-compare",
+ "compares",
+ "contains",
+ "empty",
+ "encoded-compare",
+ "error-is-as",
+ "error-nil",
+ "expected-actual",
+ "float-compare",
+ "formatter",
+ "go-require",
+ "len",
+ "negative-positive",
+ "nil-compare",
+ "regexp",
+ "require-error",
+ "suite-broken-parallel",
+ "suite-dont-use-pkg",
+ "suite-extra-assert-call",
+ "suite-subtest-run",
+ "suite-thelper",
+ "useless-assert"
+ ]
+ },
+ "default": [
+ "blank-import",
+ "bool-compare",
+ "compares",
+ "contains",
+ "empty",
+ "encoded-compare",
+ "error-is-as",
+ "error-nil",
+ "expected-actual",
+ "float-compare",
+ "formatter",
+ "go-require",
+ "len",
+ "negative-positive",
+ "nil-compare",
+ "regexp",
+ "require-error",
+ "suite-broken-parallel",
+ "suite-dont-use-pkg",
+ "suite-extra-assert-call",
+ "suite-subtest-run",
+ "useless-assert"
+ ]
+ },
+ "disable": {
+ "description": "Disable specific checkers.",
+ "type": "array",
+ "items": {
+ "enum": [
+ "blank-import",
+ "bool-compare",
+ "compares",
+ "contains",
+ "empty",
+ "encoded-compare",
+ "error-is-as",
+ "error-nil",
+ "expected-actual",
+ "float-compare",
+ "formatter",
+ "go-require",
+ "len",
+ "negative-positive",
+ "nil-compare",
+ "regexp",
+ "require-error",
+ "suite-broken-parallel",
+ "suite-dont-use-pkg",
+ "suite-extra-assert-call",
+ "suite-subtest-run",
+ "suite-thelper",
+ "useless-assert"
+ ],
+ "default": [
+ "suite-thelper"
+ ]
+ }
+ },
+ "bool-compare": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "ignore-custom-types": {
+ "description": "To ignore user defined types (over builtin bool).",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "expected-actual": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "pattern": {
+ "description": "Regexp for expected variable name.",
+ "type": "string",
+ "default": "(^(exp(ected)?|want(ed)?)([A-Z]\\w*)?$)|(^(\\w*[a-z])?(Exp(ected)?|Want(ed)?)$)"
+ }
+ }
+ },
+ "formatter": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "check-format-string": {
+ "description": "To enable go vet's printf checks.",
+ "type": "boolean",
+ "default": true
+ },
+ "require-f-funcs": {
+ "description": "To require f-assertions (e.g. assert.Equalf) if format string is used, even if there are no variable-length variables.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "go-require": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "ignore-http-handlers": {
+ "description": "To ignore HTTP handlers (like http.HandlerFunc).",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "require-error": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "fn-pattern": {
+ "description": "Regexp for assertions to analyze. If defined, then only matched error assertions will be reported.",
+ "type": "string",
+ "default": ""
+ }
+ }
+ },
+ "suite-extra-assert-call": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "mode": {
+ "description": "To require or remove extra Assert() call?",
+ "type": "string",
+ "enum": ["remove", "require"],
+ "default": "remove"
+ }
+ }
+ }
+ }
+ },
+ "testpackage": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "skip-regexp": {
+ "description": "Files with names matching this regular expression are skipped.",
+ "type": "string",
+ "examples": ["(export|internal)_test\\.go"]
+ },
+ "allow-packages": {
+ "description": "List of packages that don't end with _test that tests are allowed to be in.",
+ "type": "array",
+ "uniqueItems": true,
+ "items": {
+ "type": "string",
+ "examples": ["example"]
+ }
+ }
+ }
+ },
+ "thelper": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "test": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "begin": {
+ "description": "Check if `t.Helper()` begins helper function.",
+ "default": true,
+ "type": "boolean"
+ },
+ "first": {
+ "description": "Check if *testing.T is first param of helper function.",
+ "default": true,
+ "type": "boolean"
+ },
+ "name": {
+ "description": "Check if *testing.T param has t name.",
+ "default": true,
+ "type": "boolean"
+ }
+ }
+ },
+ "benchmark": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "begin": {
+ "description": "Check if `b.Helper()` begins helper function.",
+ "default": true,
+ "type": "boolean"
+ },
+ "first": {
+ "description": "Check if *testing.B is first param of helper function.",
+ "default": true,
+ "type": "boolean"
+ },
+ "name": {
+ "description": "Check if *testing.B param has b name.",
+ "default": true,
+ "type": "boolean"
+ }
+ }
+ },
+ "tb": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "begin": {
+ "description": "Check if `tb.Helper()` begins helper function.",
+ "default": true,
+ "type": "boolean"
+ },
+ "first": {
+ "description": "Check if *testing.TB is first param of helper function.",
+ "default": true,
+ "type": "boolean"
+ },
+ "name": {
+ "description": "Check if *testing.TB param has tb name.",
+ "default": true,
+ "type": "boolean"
+ }
+ }
+ },
+ "fuzz": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "begin": {
+ "description": "Check if `f.Helper()` begins helper function.",
+ "default": true,
+ "type": "boolean"
+ },
+ "first": {
+ "description": "Check if *testing.F is first param of helper function.",
+ "default": true,
+ "type": "boolean"
+ },
+ "name": {
+ "description": "Check if *testing.F param has f name.",
+ "default": true,
+ "type": "boolean"
+ }
+ }
+ }
+ }
+ },
+ "usestdlibvars": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "http-method": {
+ "description": "Suggest the use of http.MethodXX.",
+ "type": "boolean",
+ "default": true
+ },
+ "http-status-code": {
+ "description": "Suggest the use of http.StatusXX.",
+ "type": "boolean",
+ "default": true
+ },
+ "time-weekday": {
+ "description": "Suggest the use of time.Weekday.String().",
+ "type": "boolean",
+ "default": false
+ },
+ "time-month": {
+ "description": "Suggest the use of time.Month.String().",
+ "type": "boolean",
+ "default": false
+ },
+ "time-layout": {
+ "description": "Suggest the use of time.Layout.",
+ "type": "boolean",
+ "default": false
+ },
+ "crypto-hash": {
+ "description": "Suggest the use of crypto.Hash.String().",
+ "type": "boolean",
+ "default": false
+ },
+ "default-rpc-path": {
+ "description": "Suggest the use of rpc.DefaultXXPath.",
+ "type": "boolean",
+ "default": false
+ },
+ "sql-isolation-level": {
+ "description": "Suggest the use of sql.LevelXX.String().",
+ "type": "boolean",
+ "default": false
+ },
+ "tls-signature-scheme": {
+ "description": "Suggest the use of tls.SignatureScheme.String().",
+ "type": "boolean",
+ "default": false
+ },
+ "constant-kind": {
+ "description": "Suggest the use of constant.Kind.String().",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "usetesting": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "context-background": {
+ "type": "boolean",
+ "default": true
+ },
+ "context-todo": {
+ "type": "boolean",
+ "default": true
+ },
+ "os-chdir": {
+ "type": "boolean",
+ "default": true
+ },
+ "os-mkdir-temp": {
+ "type": "boolean",
+ "default": true
+ },
+ "os-setenv": {
+ "type": "boolean",
+ "default": true
+ },
+ "os-create-temp": {
+ "type": "boolean",
+ "default": true
+ },
+ "os-temp-dir": {
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "unconvert": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "fast-math": {
+ "type": "boolean",
+ "default": false
+ },
+ "safe": {
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "unparam": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "check-exported": {
+ "description": "Inspect exported functions. Set to true if no external program/library imports your code.\n\nWARNING: if you enable this setting, unparam will report a lot of false-positives in text editors:\nif it's called for subdir of a project it can't find external interfaces. All text editor integrations\nwith golangci-lint call it on a directory with the changed file.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "unused": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "field-writes-are-uses": {
+ "description": "",
+ "type": "boolean",
+ "default": true
+ },
+ "post-statements-are-reads": {
+ "description": "",
+ "type": "boolean",
+ "default": false
+ },
+ "exported-fields-are-used": {
+ "description": "",
+ "type": "boolean",
+ "default": true
+ },
+ "parameters-are-used": {
+ "description": "",
+ "type": "boolean",
+ "default": true
+ },
+ "local-variables-are-used": {
+ "description": "",
+ "type": "boolean",
+ "default": true
+ },
+ "generated-is-used": {
+ "description": "",
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "varnamelen": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "max-distance": {
+ "description": "Variables used in at most this N-many lines will be ignored.",
+ "type": "integer",
+ "default": 5
+ },
+ "min-name-length": {
+ "description": "The minimum length of a variable's name that is considered `long`.",
+ "type": "integer",
+ "default": 3
+ },
+ "check-receiver": {
+ "description": "Check method receiver names.",
+ "default": false,
+ "type": "boolean"
+ },
+ "check-return": {
+ "description": "Check named return values.",
+ "default": false,
+ "type": "boolean"
+ },
+ "check-type-param": {
+ "description": "Check type parameters.",
+ "default": false,
+ "type": "boolean"
+ },
+ "ignore-type-assert-ok": {
+ "description": "Ignore `ok` variables that hold the bool return value of a type assertion",
+ "default": false,
+ "type": "boolean"
+ },
+ "ignore-map-index-ok": {
+ "description": "Ignore `ok` variables that hold the bool return value of a map index.",
+ "default": false,
+ "type": "boolean"
+ },
+ "ignore-chan-recv-ok": {
+ "description": "Ignore `ok` variables that hold the bool return value of a channel receive.",
+ "default": false,
+ "type": "boolean"
+ },
+ "ignore-names": {
+ "description": "Optional list of variable names that should be ignored completely.",
+ "default": [[]],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ignore-decls": {
+ "description": "Optional list of variable declarations that should be ignored completely.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "examples": [
+ ["c echo.Context", "t testing.T", "f *foo.Bar", "const C"]
+ ]
+ }
+ }
+ },
+ "whitespace": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "multi-if": {
+ "description": "Enforces newlines (or comments) after every multi-line if statement",
+ "type": "boolean",
+ "default": false
+ },
+ "multi-func": {
+ "description": "Enforces newlines (or comments) after every multi-line function signature",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "wrapcheck": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "extra-ignore-sigs": {
+ "description": "An array of strings specifying additional substrings of signatures to ignore.",
+ "default": [
+ ".CustomError(",
+ ".SpecificWrap("
+ ],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ignoreSigs": {
+ "description": "An array of strings which specify substrings of signatures to ignore.",
+ "default": [
+ ".Errorf(",
+ "errors.New(",
+ "errors.Unwrap(",
+ ".Wrap(",
+ ".Wrapf(",
+ ".WithMessage(",
+ ".WithMessagef(",
+ ".WithStack("
+ ],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ignoreSigRegexps": {
+ "description": "An array of strings which specify regular expressions of signatures to ignore.",
+ "default": [""],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ignorePackageGlobs": {
+ "description": "An array of glob patterns which, if any match the package of the function returning the error, will skip wrapcheck analysis for this error.",
+ "default": [""],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ignoreInterfaceRegexps": {
+ "description": "An array of glob patterns which, if matched to an underlying interface name, will ignore unwrapped errors returned from a function whose call is defined on the given interface.",
+ "default": [""],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "wsl": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "allow-assign-and-anything": {
+ "description": "Controls if you may cuddle assignments and anything without needing an empty line between them.",
+ "type": "boolean",
+ "default": false
+ },
+ "allow-assign-and-call": {
+ "description": "Allow calls and assignments to be cuddled as long as the lines have any matching variables, fields or types.",
+ "type": "boolean",
+ "default": true
+ },
+ "allow-cuddle-declarations": {
+ "description": "Allow declarations (var) to be cuddled.",
+ "type": "boolean",
+ "default": false
+ },
+ "allow-cuddle-with-calls": {
+ "description": "A list of call idents that everything can be cuddled with.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "allow-cuddle-with-rhs": {
+ "description": "AllowCuddleWithRHS is a list of right hand side variables that is allowed to be cuddled with anything.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "allow-multiline-assign": {
+ "description": "Allow multiline assignments to be cuddled.",
+ "type": "boolean",
+ "default": true
+ },
+ "allow-separated-leading-comment": {
+ "description": "Allow leading comments to be separated with empty lines.",
+ "type": "boolean",
+ "default": false
+ },
+ "allow-trailing-comment": {
+ "description": "Allow trailing comments in ending of blocks.",
+ "type": "boolean",
+ "default": false
+ },
+ "error-variable-names": {
+ "description": "When force-err-cuddling is enabled this is a list of names used for error variables to check for in the conditional.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "force-case-trailing-whitespace": {
+ "description": "Force newlines in end of case at this limit (0 = never).",
+ "type": "integer",
+ "minimum": 0,
+ "default": 0
+ },
+ "force-err-cuddling": {
+ "description": "Causes an error when an If statement that checks an error variable doesn't cuddle with the assignment of that variable.",
+ "type": "boolean",
+ "default": false
+ },
+ "force-short-decl-cuddling": {
+ "description": "Causes an error if a short declaration (:=) cuddles with anything other than another short declaration.",
+ "type": "boolean",
+ "default": false
+ },
+ "strict-append": {
+ "description": "If true, append is only allowed to be cuddled if appending value is matching variables, fields or types on line above.",
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "copyloopvar": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "check-alias": {
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "custom": {
+ "description": "The custom section can be used to define linter plugins to be loaded at runtime. See README of golangci-lint for more information.\nEach custom linter should have a unique name.",
+ "type": "object",
+ "patternProperties": {
+ "^.*$": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "type": {
+ "description": "The plugin type.",
+ "enum": ["module", "goplugin"],
+ "default": "goplugin"
+ },
+ "path": {
+ "description": "The path to the plugin *.so. Can be absolute or local.",
+ "type": "string",
+ "examples": ["/path/to/example.so"]
+ },
+ "description": {
+ "description": "The description of the linter, for documentation purposes only.",
+ "type": "string"
+ },
+ "original-url": {
+ "description": "Intended to point to the repo location of the linter, for documentation purposes only.",
+ "type": "string"
+ },
+ "settings": {
+ "description": "Plugins settings/configuration. Only work with plugin based on `linterdb.PluginConstructor`.",
+ "type": "object"
+ }
+ },
+ "oneOf": [
+ {
+ "properties": {
+ "type": {"enum": ["module"] }
+ },
+ "required": ["type"]
+ },
+ {
+ "required": ["path"]
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
+ "linters": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "enable": {
+ "description": "List of enabled linters.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/linters"
+ }
+ },
+ "disable": {
+ "description": "List of disabled linters.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/linters"
+ }
+ },
+ "enable-all": {
+ "description": "Whether to enable all linters. You can re-disable them with `disable` explicitly.",
+ "type": "boolean",
+ "default": false
+ },
+ "disable-all": {
+ "description": "Whether to disable all linters. You can re-enable them with `enable` explicitly.",
+ "type": "boolean",
+ "default": false
+ },
+ "presets": {
+ "description": "Allow to use different presets of linters",
+ "type": "array",
+ "items": {
+ "enum": [
+ "bugs",
+ "comment",
+ "complexity",
+ "error",
+ "format",
+ "import",
+ "metalinter",
+ "module",
+ "performance",
+ "sql",
+ "style",
+ "test",
+ "unused"
+ ]
+ }
+ },
+ "fast": {
+ "description": "Enable run of fast linters.",
+ "type": "boolean",
+ "default": false
+ },
+ "exclusions":{
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "generated": {
+ "enum": ["strict", "lax", "disable"],
+ "default": "lax"
+ },
+ "warn-unused": {
+ "type": "boolean",
+ "default": false
+ },
+ "default": {
+ "type": "array",
+ "items": {
+ "enum": [
+ "comments",
+ "stdErrorHandling",
+ "commonFalsePositives",
+ "legacy"
+ ]
+ }
+ },
+ "rules": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "properties": {
+ "path": {
+ "type": "string"
+ },
+ "path-except": {
+ "type": "string"
+ },
+ "linters": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/linters"
+ }
+ },
+ "text": {
+ "type": "string"
+ },
+ "source": {
+ "type": "string"
+ }
+ },
+ "anyOf": [
+ { "required": ["path"] },
+ { "required": ["path-except"] },
+ { "required": ["linters"] },
+ { "required": ["text"] },
+ { "required": ["source"] }
+ ]
+ }
+ },
+ "paths": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "paths-except": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ }
+ },
+ "issues": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "exclude": {
+ "description": "List of regular expressions of issue texts to exclude.\nBut independently from this option we use default exclude patterns. Their usage can be controlled through `exclude-use-default`.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "exclude-rules": {
+ "description": "Exclude configuration per-path, per-linter, per-text and per-source",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "path": {
+ "type": "string"
+ },
+ "path-except": {
+ "type": "string"
+ },
+ "linters": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/linters"
+ }
+ },
+ "text": {
+ "type": "string"
+ },
+ "source": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "exclude-use-default": {
+ "description": "Independently from option `exclude` we use default exclude patterns. This behavior can be disabled by this option.",
+ "type": "boolean",
+ "default": true
+ },
+ "exclude-case-sensitive": {
+ "description": "If set to true, exclude and exclude-rules regular expressions become case sensitive.",
+ "type": "boolean",
+ "default": false
+ },
+ "exclude-generated": {
+ "description": "Mode of the generated files analysis.",
+ "enum": ["lax", "strict", "disable"],
+ "default": "lax"
+ },
+ "exclude-dirs": {
+ "description": "Which directories to exclude: issues from them won't be reported.",
+ "type": "array",
+ "items": {
+ "description": "You can use regexp here. The regexp is applied on the full path.\n\"/\" will be replaced by current OS file path separator to properly work on Windows.",
+ "type": "string",
+ "examples": ["generated.*"]
+ },
+ "default": [],
+ "examples": [["src/external_libs", "autogenerated_by_my_lib"]]
+ },
+ "exclude-dirs-use-default": {
+ "description": "Enable exclusion of directories \"vendor\", \"third_party\", \"testdata\", \"examples\", \"Godeps\", and \"builtin\".",
+ "type": "boolean",
+ "default": true
+ },
+ "exclude-files": {
+ "description": "Which files to exclude: they will be analyzed, but issues from them will not be reported.",
+ "type": "array",
+ "items": {
+ "description": "You can use regexp here. There is no need to include all autogenerated files, we confidently recognize them. If that is not the case, please let us know.\n\"/\" will be replaced by current OS file path separator to properly work on Windows.",
+ "type": "string",
+ "examples": [".*\\.my\\.go$"]
+ },
+ "default": [],
+ "examples": [[".*\\.my\\.go$", "lib/bad.go"]]
+ },
+ "include": {
+ "description": "The list of ids of default excludes to include or disable.",
+ "type": "array",
+ "items": {
+ "enum": [
+ "EXC0001",
+ "EXC0002",
+ "EXC0003",
+ "EXC0004",
+ "EXC0005",
+ "EXC0006",
+ "EXC0007",
+ "EXC0008",
+ "EXC0009",
+ "EXC0010",
+ "EXC0011",
+ "EXC0012",
+ "EXC0013",
+ "EXC0014",
+ "EXC0015"
+ ]
+ },
+ "default": []
+ },
+ "max-issues-per-linter": {
+ "description": "Maximum issues count per one linter. Set to 0 to disable.",
+ "type": "integer",
+ "default": 50,
+ "minimum": 0
+ },
+ "max-same-issues": {
+ "description": "Maximum count of issues with the same text. Set to 0 to disable.",
+ "type": "integer",
+ "default": 3,
+ "minimum": 0
+ },
+ "new": {
+ "description": "Show only new issues: if there are unstaged changes or untracked files, only those changes are analyzed, else only changes in HEAD~ are analyzed.",
+ "type": "boolean",
+ "default": false
+ },
+ "new-from-merge-base": {
+ "description": "Show only new issues created after the best common ancestor (merge-base against HEAD).",
+ "type": "string"
+ },
+ "new-from-rev": {
+ "description": "Show only new issues created after this git revision.",
+ "type": "string"
+ },
+ "new-from-patch": {
+ "description": "Show only new issues created in git patch with this file path.",
+ "type": "string",
+ "examples": ["path/to/patch/file"]
+ },
+ "fix": {
+ "description": "Fix found issues (if it's supported by the linter).",
+ "type": "boolean",
+ "default": false
+ },
+ "uniq-by-line": {
+ "description": "Make issues output unique by line.",
+ "type": "boolean",
+ "default": true
+ },
+ "whole-files": {
+ "description": "Show issues in any part of update files (requires new-from-rev or new-from-patch).",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "severity": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "default-severity": {
+ "description": "Set the default severity for issues. If severity rules are defined and the issues do not match or no severity is provided to the rule this will be the default severity applied. Severities should match the supported severity names of the selected out format.",
+ "type": "string",
+ "default": ""
+ },
+ "case-sensitive": {
+ "description": "If set to true, severity-rules regular expressions become case sensitive.",
+ "type": "boolean",
+ "default": false
+ },
+ "rules": {
+ "description": "When a list of severity rules are provided, severity information will be added to lint issues. Severity rules have the same filtering capability as exclude rules except you are allowed to specify one matcher per severity rule.\nOnly affects out formats that support setting severity information.",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "severity": {
+ "type": "string"
+ },
+ "path": {
+ "type": "string"
+ },
+ "path-except": {
+ "type": "string"
+ },
+ "linters": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/linters"
+ }
+ },
+ "text": {
+ "type": "string"
+ },
+ "source": {
+ "type": "string"
+ }
+ },
+ "required": ["severity"],
+ "anyOf": [
+ { "required": ["path"] },
+ { "required": ["path-except"] },
+ { "required": ["linters"] },
+ { "required": ["text"] },
+ { "required": ["source"] }
+ ]
+ },
+ "default": []
+ }
+ },
+ "required": ["default-severity"]
+ }
+ }
+}
diff --git a/vendor/github.com/golangci/golangci-lint/v2/jsonschema/golangci.v2.0.jsonschema.json b/vendor/github.com/golangci/golangci-lint/v2/jsonschema/golangci.v2.0.jsonschema.json
new file mode 100644
index 0000000000..437943b5f3
--- /dev/null
+++ b/vendor/github.com/golangci/golangci-lint/v2/jsonschema/golangci.v2.0.jsonschema.json
@@ -0,0 +1,4738 @@
+{
+ "$schema": "http://json-schema.org/draft-07/schema#",
+ "$id": "https://json.schemastore.org/golangci-lint.json",
+ "definitions": {
+ "gocritic-checks": {
+ "enum": [
+ "appendAssign",
+ "appendCombine",
+ "argOrder",
+ "assignOp",
+ "badCall",
+ "badCond",
+ "badLock",
+ "badRegexp",
+ "badSorting",
+ "badSyncOnceFunc",
+ "boolExprSimplify",
+ "builtinShadow",
+ "builtinShadowDecl",
+ "captLocal",
+ "caseOrder",
+ "codegenComment",
+ "commentFormatting",
+ "commentedOutCode",
+ "commentedOutImport",
+ "defaultCaseOrder",
+ "deferInLoop",
+ "deferUnlambda",
+ "deprecatedComment",
+ "docStub",
+ "dupArg",
+ "dupBranchBody",
+ "dupCase",
+ "dupImport",
+ "dupSubExpr",
+ "dynamicFmtString",
+ "elseif",
+ "emptyDecl",
+ "emptyFallthrough",
+ "emptyStringTest",
+ "equalFold",
+ "evalOrder",
+ "exitAfterDefer",
+ "exposedSyncMutex",
+ "externalErrorReassign",
+ "filepathJoin",
+ "flagDeref",
+ "flagName",
+ "hexLiteral",
+ "httpNoBody",
+ "hugeParam",
+ "ifElseChain",
+ "importShadow",
+ "indexAlloc",
+ "initClause",
+ "ioutilDeprecated",
+ "mapKey",
+ "methodExprCall",
+ "nestingReduce",
+ "newDeref",
+ "nilValReturn",
+ "octalLiteral",
+ "offBy1",
+ "paramTypeCombine",
+ "preferDecodeRune",
+ "preferFilepathJoin",
+ "preferFprint",
+ "preferStringWriter",
+ "preferWriteByte",
+ "ptrToRefParam",
+ "rangeAppendAll",
+ "rangeExprCopy",
+ "rangeValCopy",
+ "redundantSprint",
+ "regexpMust",
+ "regexpPattern",
+ "regexpSimplify",
+ "returnAfterHttpError",
+ "ruleguard",
+ "singleCaseSwitch",
+ "sliceClear",
+ "sloppyLen",
+ "sloppyReassign",
+ "sloppyTypeAssert",
+ "sortSlice",
+ "sprintfQuotedString",
+ "sqlQuery",
+ "stringConcatSimplify",
+ "stringXbytes",
+ "stringsCompare",
+ "switchTrue",
+ "syncMapLoadAndDelete",
+ "timeExprSimplify",
+ "todoCommentWithoutDetail",
+ "tooManyResultsChecker",
+ "truncateCmp",
+ "typeAssertChain",
+ "typeDefFirst",
+ "typeSwitchVar",
+ "typeUnparen",
+ "uncheckedInlineErr",
+ "underef",
+ "unlabelStmt",
+ "unlambda",
+ "unnamedResult",
+ "unnecessaryBlock",
+ "unnecessaryDefer",
+ "unslice",
+ "valSwap",
+ "weakCond",
+ "whyNoLint",
+ "wrapperFunc",
+ "yodaStyleExpr"
+ ]
+ },
+ "gocritic-tags": {
+ "enum": [
+ "diagnostic",
+ "style",
+ "performance",
+ "experimental",
+ "opinionated",
+ "security"
+ ]
+ },
+ "staticcheck-checks": {
+ "enum": [
+ "*",
+ "all",
+ "SA*",
+ "-SA*",
+ "SA1*",
+ "-SA1*",
+ "SA1000",
+ "-SA1000",
+ "SA1001",
+ "-SA1001",
+ "SA1002",
+ "-SA1002",
+ "SA1003",
+ "-SA1003",
+ "SA1004",
+ "-SA1004",
+ "SA1005",
+ "-SA1005",
+ "SA1006",
+ "-SA1006",
+ "SA1007",
+ "-SA1007",
+ "SA1008",
+ "-SA1008",
+ "SA1010",
+ "-SA1010",
+ "SA1011",
+ "-SA1011",
+ "SA1012",
+ "-SA1012",
+ "SA1013",
+ "-SA1013",
+ "SA1014",
+ "-SA1014",
+ "SA1015",
+ "-SA1015",
+ "SA1016",
+ "-SA1016",
+ "SA1017",
+ "-SA1017",
+ "SA1018",
+ "-SA1018",
+ "SA1019",
+ "-SA1019",
+ "SA1020",
+ "-SA1020",
+ "SA1021",
+ "-SA1021",
+ "SA1023",
+ "-SA1023",
+ "SA1024",
+ "-SA1024",
+ "SA1025",
+ "-SA1025",
+ "SA1026",
+ "-SA1026",
+ "SA1027",
+ "-SA1027",
+ "SA1028",
+ "-SA1028",
+ "SA1029",
+ "-SA1029",
+ "SA1030",
+ "-SA1030",
+ "SA1031",
+ "-SA1031",
+ "SA1032",
+ "-SA1032",
+ "SA2*",
+ "-SA2*",
+ "SA2000",
+ "-SA2000",
+ "SA2001",
+ "-SA2001",
+ "SA2002",
+ "-SA2002",
+ "SA2003",
+ "-SA2003",
+ "SA3*",
+ "-SA3*",
+ "SA3000",
+ "-SA3000",
+ "SA3001",
+ "-SA3001",
+ "SA4*",
+ "-SA4*",
+ "SA4000",
+ "-SA4000",
+ "SA4001",
+ "-SA4001",
+ "SA4003",
+ "-SA4003",
+ "SA4004",
+ "-SA4004",
+ "SA4005",
+ "-SA4005",
+ "SA4006",
+ "-SA4006",
+ "SA4008",
+ "-SA4008",
+ "SA4009",
+ "-SA4009",
+ "SA4010",
+ "-SA4010",
+ "SA4011",
+ "-SA4011",
+ "SA4012",
+ "-SA4012",
+ "SA4013",
+ "-SA4013",
+ "SA4014",
+ "-SA4014",
+ "SA4015",
+ "-SA4015",
+ "SA4016",
+ "-SA4016",
+ "SA4017",
+ "-SA4017",
+ "SA4018",
+ "-SA4018",
+ "SA4019",
+ "-SA4019",
+ "SA4020",
+ "-SA4020",
+ "SA4021",
+ "-SA4021",
+ "SA4022",
+ "-SA4022",
+ "SA4023",
+ "-SA4023",
+ "SA4024",
+ "-SA4024",
+ "SA4025",
+ "-SA4025",
+ "SA4026",
+ "-SA4026",
+ "SA4027",
+ "-SA4027",
+ "SA4028",
+ "-SA4028",
+ "SA4029",
+ "-SA4029",
+ "SA4030",
+ "-SA4030",
+ "SA4031",
+ "-SA4031",
+ "SA4032",
+ "-SA4032",
+ "SA5*",
+ "-SA5*",
+ "SA5000",
+ "-SA5000",
+ "SA5001",
+ "-SA5001",
+ "SA5002",
+ "-SA5002",
+ "SA5003",
+ "-SA5003",
+ "SA5004",
+ "-SA5004",
+ "SA5005",
+ "-SA5005",
+ "SA5007",
+ "-SA5007",
+ "SA5008",
+ "-SA5008",
+ "SA5009",
+ "-SA5009",
+ "SA5010",
+ "-SA5010",
+ "SA5011",
+ "-SA5011",
+ "SA5012",
+ "-SA5012",
+ "SA6*",
+ "-SA6*",
+ "SA6000",
+ "-SA6000",
+ "SA6001",
+ "-SA6001",
+ "SA6002",
+ "-SA6002",
+ "SA6003",
+ "-SA6003",
+ "SA6005",
+ "-SA6005",
+ "SA6006",
+ "-SA6006",
+ "SA9*",
+ "-SA9*",
+ "SA9001",
+ "-SA9001",
+ "SA9002",
+ "-SA9002",
+ "SA9003",
+ "-SA9003",
+ "SA9004",
+ "-SA9004",
+ "SA9005",
+ "-SA9005",
+ "SA9006",
+ "-SA9006",
+ "SA9007",
+ "-SA9007",
+ "SA9008",
+ "-SA9008",
+ "SA9009",
+ "-SA9009",
+ "ST*",
+ "-ST*",
+ "ST1*",
+ "-ST1*",
+ "ST1000",
+ "-ST1000",
+ "ST1001",
+ "-ST1001",
+ "ST1003",
+ "-ST1003",
+ "ST1005",
+ "-ST1005",
+ "ST1006",
+ "-ST1006",
+ "ST1008",
+ "-ST1008",
+ "ST1011",
+ "-ST1011",
+ "ST1012",
+ "-ST1012",
+ "ST1013",
+ "-ST1013",
+ "ST1015",
+ "-ST1015",
+ "ST1016",
+ "-ST1016",
+ "ST1017",
+ "-ST1017",
+ "ST1018",
+ "-ST1018",
+ "ST1019",
+ "-ST1019",
+ "ST1020",
+ "-ST1020",
+ "ST1021",
+ "-ST1021",
+ "ST1022",
+ "-ST1022",
+ "ST1023",
+ "-ST1023",
+ "S*",
+ "-S*",
+ "S1*",
+ "-S1*",
+ "S1000",
+ "-S1000",
+ "S1001",
+ "-S1001",
+ "S1002",
+ "-S1002",
+ "S1003",
+ "-S1003",
+ "S1004",
+ "-S1004",
+ "S1005",
+ "-S1005",
+ "S1006",
+ "-S1006",
+ "S1007",
+ "-S1007",
+ "S1008",
+ "-S1008",
+ "S1009",
+ "-S1009",
+ "S1010",
+ "-S1010",
+ "S1011",
+ "-S1011",
+ "S1012",
+ "-S1012",
+ "S1016",
+ "-S1016",
+ "S1017",
+ "-S1017",
+ "S1018",
+ "-S1018",
+ "S1019",
+ "-S1019",
+ "S1020",
+ "-S1020",
+ "S1021",
+ "-S1021",
+ "S1023",
+ "-S1023",
+ "S1024",
+ "-S1024",
+ "S1025",
+ "-S1025",
+ "S1028",
+ "-S1028",
+ "S1029",
+ "-S1029",
+ "S1030",
+ "-S1030",
+ "S1031",
+ "-S1031",
+ "S1032",
+ "-S1032",
+ "S1033",
+ "-S1033",
+ "S1034",
+ "-S1034",
+ "S1035",
+ "-S1035",
+ "S1036",
+ "-S1036",
+ "S1037",
+ "-S1037",
+ "S1038",
+ "-S1038",
+ "S1039",
+ "-S1039",
+ "S1040",
+ "-S1040",
+ "QF*",
+ "-QF*",
+ "QF1*",
+ "-QF1*",
+ "QF1001",
+ "-QF1001",
+ "QF1002",
+ "-QF1002",
+ "QF1003",
+ "-QF1003",
+ "QF1004",
+ "-QF1004",
+ "QF1005",
+ "-QF1005",
+ "QF1006",
+ "-QF1006",
+ "QF1007",
+ "-QF1007",
+ "QF1008",
+ "-QF1008",
+ "QF1009",
+ "-QF1009",
+ "QF1010",
+ "-QF1010",
+ "QF1011",
+ "-QF1011",
+ "QF1012",
+ "-QF1012"
+ ]
+ },
+ "gosec-rules": {
+ "enum": [
+ "G101",
+ "G102",
+ "G103",
+ "G104",
+ "G106",
+ "G107",
+ "G108",
+ "G109",
+ "G110",
+ "G111",
+ "G112",
+ "G113",
+ "G114",
+ "G115",
+ "G201",
+ "G202",
+ "G203",
+ "G204",
+ "G301",
+ "G302",
+ "G303",
+ "G304",
+ "G305",
+ "G306",
+ "G307",
+ "G401",
+ "G402",
+ "G403",
+ "G404",
+ "G405",
+ "G406",
+ "G501",
+ "G502",
+ "G503",
+ "G504",
+ "G505",
+ "G506",
+ "G507",
+ "G601",
+ "G602"
+ ]
+ },
+ "govet-analyzers": {
+ "enum": [
+ "appends",
+ "asmdecl",
+ "assign",
+ "atomic",
+ "atomicalign",
+ "bools",
+ "buildtag",
+ "cgocall",
+ "composites",
+ "copylocks",
+ "deepequalerrors",
+ "defers",
+ "directive",
+ "errorsas",
+ "fieldalignment",
+ "findcall",
+ "framepointer",
+ "httpresponse",
+ "ifaceassert",
+ "loopclosure",
+ "lostcancel",
+ "nilfunc",
+ "nilness",
+ "printf",
+ "reflectvaluecompare",
+ "shadow",
+ "shift",
+ "sigchanyzer",
+ "slog",
+ "sortslice",
+ "stdmethods",
+ "stdversion",
+ "stringintconv",
+ "structtag",
+ "testinggoroutine",
+ "tests",
+ "timeformat",
+ "unmarshal",
+ "unreachable",
+ "unsafeptr",
+ "unusedresult",
+ "unusedwrite",
+ "waitgroup"
+ ]
+ },
+ "revive-rules": {
+ "enum": [
+ "add-constant",
+ "argument-limit",
+ "atomic",
+ "banned-characters",
+ "bare-return",
+ "blank-imports",
+ "bool-literal-in-expr",
+ "call-to-gc",
+ "cognitive-complexity",
+ "comment-spacings",
+ "comments-density",
+ "confusing-naming",
+ "confusing-results",
+ "constant-logical-expr",
+ "context-as-argument",
+ "context-keys-type",
+ "cyclomatic",
+ "datarace",
+ "deep-exit",
+ "defer",
+ "dot-imports",
+ "duplicated-imports",
+ "early-return",
+ "empty-block",
+ "empty-lines",
+ "enforce-map-style",
+ "enforce-repeated-arg-type-style",
+ "enforce-slice-style",
+ "error-naming",
+ "error-return",
+ "error-strings",
+ "errorf",
+ "exported",
+ "file-header",
+ "file-length-limit",
+ "filename-format",
+ "flag-parameter",
+ "function-length",
+ "function-result-limit",
+ "get-return",
+ "identical-branches",
+ "if-return",
+ "import-alias-naming",
+ "import-shadowing",
+ "imports-blocklist",
+ "increment-decrement",
+ "indent-error-flow",
+ "line-length-limit",
+ "max-control-nesting",
+ "max-public-structs",
+ "modifies-parameter",
+ "modifies-value-receiver",
+ "nested-structs",
+ "optimize-operands-order",
+ "package-comments",
+ "range-val-address",
+ "range-val-in-closure",
+ "range",
+ "receiver-naming",
+ "redefines-builtin-id",
+ "redundant-build-tag",
+ "redundant-import-alias",
+ "redundant-test-main-exit",
+ "string-format",
+ "string-of-int",
+ "struct-tag",
+ "superfluous-else",
+ "time-equal",
+ "time-naming",
+ "unchecked-type-assertion",
+ "unconditional-recursion",
+ "unexported-naming",
+ "unexported-return",
+ "unhandled-error",
+ "unnecessary-stmt",
+ "unreachable-code",
+ "unused-parameter",
+ "unused-receiver",
+ "use-any",
+ "use-errors-new",
+ "useless-break",
+ "var-declaration",
+ "var-naming",
+ "waitgroup-by-value"
+ ]
+ },
+ "iface-analyzers": {
+ "enum": [
+ "identical",
+ "unused",
+ "opaque"
+ ]
+ },
+ "tagliatelle-cases": {
+ "enum": [
+ "",
+ "camel",
+ "pascal",
+ "kebab",
+ "snake",
+ "goCamel",
+ "goPascal",
+ "goKebab",
+ "goSnake",
+ "upper",
+ "upperSnake",
+ "lower",
+ "header"
+ ]
+ },
+ "relative-path-modes": {
+ "enum": [
+ "gomod",
+ "gitroot",
+ "cfg",
+ "wd"
+ ]
+ },
+ "simple-format": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "path": {
+ "$ref": "#/definitions/formats-path",
+ "default": "stdout"
+ }
+ }
+ },
+ "formats-path" : {
+ "anyOf": [
+ {
+ "enum": [
+ "stdout",
+ "stderr"
+ ]
+ },
+ {
+ "type": "string"
+ }
+ ]
+ },
+ "linter-names": {
+ "$comment": "anyOf with enum is used to allow auto-completion of non-custom linters",
+ "description": "Usable linter names.",
+ "anyOf": [
+ {
+ "enum": [
+ "asasalint",
+ "asciicheck",
+ "bidichk",
+ "bodyclose",
+ "canonicalheader",
+ "containedctx",
+ "contextcheck",
+ "copyloopvar",
+ "cyclop",
+ "decorder",
+ "depguard",
+ "dogsled",
+ "dupl",
+ "dupword",
+ "durationcheck",
+ "errcheck",
+ "errchkjson",
+ "errname",
+ "errorlint",
+ "exhaustive",
+ "exhaustruct",
+ "exptostd",
+ "fatcontext",
+ "forbidigo",
+ "forcetypeassert",
+ "funlen",
+ "ginkgolinter",
+ "gocheckcompilerdirectives",
+ "gochecknoglobals",
+ "gochecknoinits",
+ "gochecksumtype",
+ "gocognit",
+ "goconst",
+ "gocritic",
+ "gocyclo",
+ "godot",
+ "godox",
+ "err113",
+ "goheader",
+ "gomoddirectives",
+ "gomodguard",
+ "goprintffuncname",
+ "gosec",
+ "gosimple",
+ "gosmopolitan",
+ "govet",
+ "grouper",
+ "iface",
+ "importas",
+ "inamedparam",
+ "ineffassign",
+ "interfacebloat",
+ "intrange",
+ "ireturn",
+ "lll",
+ "loggercheck",
+ "maintidx",
+ "makezero",
+ "mirror",
+ "misspell",
+ "mnd",
+ "musttag",
+ "nakedret",
+ "nestif",
+ "nilerr",
+ "nilnesserr",
+ "nilnil",
+ "nlreturn",
+ "noctx",
+ "nolintlint",
+ "nonamedreturns",
+ "nosprintfhostport",
+ "paralleltest",
+ "perfsprint",
+ "prealloc",
+ "predeclared",
+ "promlinter",
+ "protogetter",
+ "reassign",
+ "recvcheck",
+ "revive",
+ "rowserrcheck",
+ "sloglint",
+ "sqlclosecheck",
+ "staticcheck",
+ "stylecheck",
+ "tagalign",
+ "tagliatelle",
+ "testableexamples",
+ "testifylint",
+ "testpackage",
+ "thelper",
+ "tparallel",
+ "unconvert",
+ "unparam",
+ "unused",
+ "usestdlibvars",
+ "usetesting",
+ "varnamelen",
+ "wastedassign",
+ "whitespace",
+ "wrapcheck",
+ "wsl",
+ "zerologlint"
+ ]
+ },
+ {
+ "type": "string"
+ }
+ ]
+ },
+ "formatter-names": {
+ "description": "Usable formatter names.",
+ "enum": [
+ "gci",
+ "gofmt",
+ "gofumpt",
+ "goimports",
+ "golines"
+ ]
+ },
+ "settings": {
+ "definitions": {
+ "dupwordSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "keywords": {
+ "description": "Keywords for detecting duplicate words. If this list is not empty, only the words defined in this list will be detected.",
+ "type": "array",
+ "uniqueItems": true,
+ "items": {
+ "type": "string",
+ "examples": ["the", "and", "a"]
+ }
+ },
+ "ignore": {
+ "description": "Keywords used to ignore detection.",
+ "type": "array",
+ "uniqueItems": true,
+ "items": {
+ "type": "string",
+ "examples": ["0C0C"]
+ }
+ }
+ }
+ },
+ "asasalintSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "exclude": {
+ "description": "To specify a set of function names to exclude.",
+ "type": "array",
+ "uniqueItems": true,
+ "items": {
+ "type": "string",
+ "examples": ["\\.Wrapf"]
+ }
+ },
+ "use-builtin-exclusions": {
+ "description": "To enable/disable the asasalint builtin exclusions of function names.",
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "bidichkSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "left-to-right-embedding": {
+ "description": "Disallow: LEFT-TO-RIGHT-EMBEDDING",
+ "type": "boolean",
+ "default": false
+ },
+ "right-to-left-embedding": {
+ "description": "Disallow: RIGHT-TO-LEFT-EMBEDDING",
+ "type": "boolean",
+ "default": false
+ },
+ "pop-directional-formatting": {
+ "description": "Disallow: POP-DIRECTIONAL-FORMATTING",
+ "type": "boolean",
+ "default": false
+ },
+ "left-to-right-override": {
+ "description": "Disallow: LEFT-TO-RIGHT-OVERRIDE",
+ "type": "boolean",
+ "default": false
+ },
+ "right-to-left-override": {
+ "description": "Disallow: RIGHT-TO-LEFT-OVERRIDE",
+ "type": "boolean",
+ "default": false
+ },
+ "left-to-right-isolate": {
+ "description": "Disallow: LEFT-TO-RIGHT-ISOLATE",
+ "type": "boolean",
+ "default": false
+ },
+ "right-to-left-isolate": {
+ "description": "Disallow: RIGHT-TO-LEFT-ISOLATE",
+ "type": "boolean",
+ "default": false
+ },
+ "first-strong-isolate": {
+ "description": "Disallow: FIRST-STRONG-ISOLATE",
+ "type": "boolean",
+ "default": false
+ },
+ "pop-directional-isolate": {
+ "description": "Disallow: POP-DIRECTIONAL-ISOLATE",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "cyclopSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "max-complexity": {
+ "description": "Max complexity the function can have",
+ "type": "integer",
+ "default": 10,
+ "minimum": 0
+ },
+ "package-average": {
+ "description": "Max average complexity in package",
+ "type": "number",
+ "default": 0,
+ "minimum": 0
+ }
+ }
+ },
+ "decorderSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "dec-order": {
+ "type": "array",
+ "default": [["type", "const", "var", "func"]],
+ "items": {
+ "enum": ["type", "const", "var", "func"]
+ }
+ },
+ "ignore-underscore-vars": {
+ "description": "Underscore vars (vars with \"_\" as the name) will be ignored at all checks",
+ "default": true,
+ "type": "boolean"
+ },
+ "disable-dec-order-check": {
+ "description": "Order of declarations is not checked",
+ "default": true,
+ "type": "boolean"
+ },
+ "disable-init-func-first-check": {
+ "description": "Allow init func to be anywhere in file",
+ "default": true,
+ "type": "boolean"
+ },
+ "disable-dec-num-check": {
+ "description": "Multiple global type, const and var declarations are allowed",
+ "default": true,
+ "type": "boolean"
+ },
+ "disable-type-dec-num-check": {
+ "description": "Type declarations will be ignored for dec num check",
+ "default": true,
+ "type": "boolean"
+ },
+ "disable-const-dec-num-check": {
+ "description": "Const declarations will be ignored for dec num check",
+ "default": true,
+ "type": "boolean"
+ },
+ "disable-var-dec-num-check": {
+ "description": "Var declarations will be ignored for dec num check",
+ "default": true,
+ "type": "boolean"
+ }
+ }
+ },
+ "depguardSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "rules": {
+ "description": "Rules to apply.",
+ "type": "object",
+ "additionalProperties": false,
+ "patternProperties": {
+ "^[^.]+$": {
+ "description": "Name of a rule.",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "list-mode": {
+ "description": "Used to determine the package matching priority.",
+ "enum": ["original", "strict", "lax"],
+ "default": "original"
+ },
+ "files": {
+ "description": "List of file globs that will match this list of settings to compare against.",
+ "additionalProperties": false,
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "allow": {
+ "description": "List of allowed packages.",
+ "additionalProperties": false,
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "deny": {
+ "description": "Packages that are not allowed where the value is a suggestion.",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "desc": {
+ "description": "Description",
+ "type": "string"
+ },
+ "pkg": {
+ "description": "Package",
+ "type": "string"
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "dogsledSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "max-blank-identifiers": {
+ "description": "Check assignments with too many blank identifiers.",
+ "type": "integer",
+ "default": 2,
+ "minimum": 0
+ }
+ }
+ },
+ "duplSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "threshold": {
+ "description": "Tokens count to trigger issue.",
+ "type": "integer",
+ "default": 150,
+ "minimum": 0
+ }
+ }
+ },
+ "errcheckSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "check-type-assertions": {
+ "description": "Report about not checking errors in type assertions, i.e.: `a := b.(MyStruct)`",
+ "type": "boolean",
+ "default": false
+ },
+ "check-blank": {
+ "description": "Report about assignment of errors to blank identifier",
+ "type": "boolean",
+ "default": false
+ },
+ "exclude-functions": {
+ "description": "List of functions to exclude from checking, where each entry is a single function to exclude",
+ "type": "array",
+ "examples": ["io/ioutil.ReadFile", "io.Copy(*bytes.Buffer)"],
+ "items": {
+ "type": "string"
+ }
+ },
+ "disable-default-exclusions": {
+ "description": "To disable the errcheck built-in exclude list",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "errchkjsonSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "check-error-free-encoding": {
+ "type": "boolean",
+ "default": false
+ },
+ "report-no-exported": {
+ "description": "Issue on struct that doesn't have exported fields.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "errorlintSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "errorf": {
+ "description": "Check whether fmt.Errorf uses the %w verb for formatting errors",
+ "type": "boolean",
+ "default": true
+ },
+ "errorf-multi": {
+ "description": "Permit more than 1 %w verb, valid per Go 1.20",
+ "type": "boolean",
+ "default": true
+ },
+ "asserts": {
+ "description": "Check for plain type assertions and type switches.",
+ "type": "boolean",
+ "default": true
+ },
+ "comparison": {
+ "description": "Check for plain error comparisons",
+ "type": "boolean",
+ "default": true
+ },
+ "allowed-errors": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "err": {
+ "type": "string"
+ },
+ "fun": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "allowed-errors-wildcard": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "err": {
+ "type": "string"
+ },
+ "fun": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ }
+ },
+ "exhaustiveSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "check": {
+ "description": "Program elements to check for exhaustiveness.",
+ "type": "array",
+ "uniqueItems": true,
+ "items": {
+ "type": "string",
+ "examples": ["switch", "map"]
+ }
+ },
+ "explicit-exhaustive-switch": {
+ "description": "Only run exhaustive check on switches with \"//exhaustive:enforce\" comment.",
+ "type": "boolean",
+ "default": false
+ },
+ "explicit-exhaustive-map": {
+ "description": "Only run exhaustive check on map literals with \"//exhaustive:enforce\" comment.",
+ "type": "boolean",
+ "default": false
+ },
+ "default-case-required": {
+ "description": "Switch statement requires default case even if exhaustive.",
+ "type": "boolean",
+ "default": false
+ },
+ "default-signifies-exhaustive": {
+ "description": "Presence of `default` case in switch statements satisfies exhaustiveness, even if all enum members are not listed.",
+ "type": "boolean",
+ "default": false
+ },
+ "ignore-enum-members": {
+ "description": "Enum members matching `regex` do not have to be listed in switch statements to satisfy exhaustiveness",
+ "type": "string"
+ },
+ "ignore-enum-types": {
+ "description": "Enum types matching the supplied regex do not have to be listed in switch statements to satisfy exhaustiveness.",
+ "type": "string"
+ },
+ "package-scope-only": {
+ "description": "Consider enums only in package scopes, not in inner scopes.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "exhaustructSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "include": {
+ "description": "List of regular expressions to match struct packages and names.",
+ "type": "array",
+ "examples": [".*\\.Test"],
+ "items": {
+ "type": "string"
+ }
+ },
+ "exclude": {
+ "description": "List of regular expressions to exclude struct packages and names from check.",
+ "type": "array",
+ "examples": ["cobra\\.Command$"],
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "fatcontextSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "check-struct-pointers": {
+ "description": "Check for potential fat contexts in struct pointers.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "forbidigoSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "exclude-godoc-examples": {
+ "description": "Exclude code in godoc examples.",
+ "type": "boolean",
+ "default": true
+ },
+ "analyze-types": {
+ "description": "Instead of matching the literal source code, use type information to replace expressions with strings that contain the package name and (for methods and fields) the type name.",
+ "type": "boolean",
+ "default": true
+ },
+ "forbid": {
+ "description": "List of identifiers to forbid (written using `regexp`)",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "pattern": {
+ "description": "Pattern",
+ "type": "string"
+ },
+ "pkg": {
+ "description": "Package",
+ "type": "string"
+ },
+ "msg": {
+ "description": "Message",
+ "type": "string"
+ }
+ }
+ }
+ }
+ }
+ },
+ "funlenSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "lines": {
+ "description": "Limit lines number per function.",
+ "type": "integer",
+ "default": 60
+ },
+ "statements": {
+ "description": "Limit statements number per function.",
+ "type": "integer",
+ "default": 40
+ },
+ "ignore-comments": {
+ "description": "Ignore comments when counting lines.",
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "gciSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "sections": {
+ "description": "Section configuration to compare against.",
+ "type": "array",
+ "items": {
+ "anyOf": [
+ {
+ "enum": [
+ "standard",
+ "default",
+ "blank",
+ "dot",
+ "alias",
+ "localmodule"
+ ]
+ },
+ {
+ "type": "string"
+ }
+ ]
+ },
+ "default": ["standard", "default"]
+ },
+ "no-inline-comments": {
+ "description": "Checks that no inline Comments are present.",
+ "type": "boolean",
+ "default": false
+ },
+ "no-prefix-comments": {
+ "description": "Checks that no prefix Comments(comment lines above an import) are present.",
+ "type": "boolean",
+ "default": false
+ },
+ "custom-order": {
+ "description": "Enable custom order of sections.",
+ "type": "boolean",
+ "default": false
+ },
+ "no-lex-order": {
+ "description": "Drops lexical ordering for custom sections.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "ginkgolinterSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "suppress-len-assertion": {
+ "description": "Suppress the wrong length assertion warning.",
+ "type": "boolean",
+ "default": false
+ },
+ "suppress-nil-assertion": {
+ "description": "Suppress the wrong nil assertion warning.",
+ "type": "boolean",
+ "default": false
+ },
+ "suppress-err-assertion": {
+ "description": "Suppress the wrong error assertion warning.",
+ "type": "boolean",
+ "default": false
+ },
+ "suppress-compare-assertion": {
+ "description": "Suppress the wrong comparison assertion warning.",
+ "type": "boolean",
+ "default": false
+ },
+ "suppress-async-assertion": {
+ "description": "Suppress the function all in async assertion warning.",
+ "type": "boolean",
+ "default": false
+ },
+ "suppress-type-compare-assertion": {
+ "description": "Suppress warning for comparing values from different types, like int32 and uint32.",
+ "type": "boolean",
+ "default": false
+ },
+ "forbid-focus-container": {
+ "description": "Trigger warning for ginkgo focus containers like FDescribe, FContext, FWhen or FIt.",
+ "type": "boolean",
+ "default": false
+ },
+ "allow-havelen-zero": {
+ "description": "Don't trigger warnings for HaveLen(0).",
+ "type": "boolean",
+ "default": false
+ },
+ "force-expect-to": {
+ "description": "Force using `Expect` with `To`, `ToNot` or `NotTo`",
+ "type": "boolean",
+ "default": false
+ },
+ "validate-async-intervals": {
+ "description": "Best effort validation of async intervals (timeout and polling).",
+ "type": "boolean",
+ "default": false
+ },
+ "forbid-spec-pollution": {
+ "description": "Trigger a warning for variable assignments in ginkgo containers like `Describe`, `Context` and `When`, instead of in `BeforeEach()`.",
+ "type": "boolean",
+ "default": false
+ },
+ "force-succeed": {
+ "description": "Force using the Succeed matcher for error functions, and the HaveOccurred matcher for non-function error values.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "gochecksumtypeSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "default-signifies-exhaustive": {
+ "description": "Presence of `default` case in switch statements satisfies exhaustiveness, if all members are not listed.",
+ "type": "boolean",
+ "default": true
+ },
+ "include-shared-interfaces": {
+ "description": "Include shared interfaces in the exhaustiviness check.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "gocognitSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "min-complexity": {
+ "description": "Minimal code complexity to report (we recommend 10-20).",
+ "type": "integer",
+ "default": 30
+ }
+ }
+ },
+ "goconstSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "match-constant": {
+ "description": "Look for existing constants matching the values",
+ "type": "boolean",
+ "default": true
+ },
+ "min-len": {
+ "description": "Minimum length of string constant.",
+ "type": "integer",
+ "default": 3
+ },
+ "min-occurrences": {
+ "description": "Minimum occurrences count to trigger.",
+ "type": "integer",
+ "default": 3
+ },
+ "ignore-calls": {
+ "description": "Ignore when constant is not used as function argument",
+ "type": "boolean",
+ "default": true
+ },
+ "ignore-strings": {
+ "description": "Exclude strings matching the given regular expression",
+ "type": "string"
+ },
+ "numbers": {
+ "description": "Search also for duplicated numbers.",
+ "type": "boolean",
+ "default": false
+ },
+ "min": {
+ "description": "Minimum value, only works with `numbers`",
+ "type": "integer",
+ "default": 3
+ },
+ "max": {
+ "description": "Maximum value, only works with `numbers`",
+ "type": "integer",
+ "default": 3
+ }
+ }
+ },
+ "gocriticSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "enabled-checks": {
+ "description": "Which checks should be enabled. By default, a list of stable checks is used. To see it, run `GL_DEBUG=gocritic golangci-lint run`.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/gocritic-checks"
+ }
+ },
+ "disabled-checks": {
+ "description": "Which checks should be disabled.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/gocritic-checks"
+ },
+ "default": []
+ },
+ "enabled-tags": {
+ "description": "Enable multiple checks by tags, run `GL_DEBUG=gocritic golangci-lint run` to see all tags and checks.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/gocritic-tags"
+ }
+ },
+ "disabled-tags": {
+ "description": "Disable multiple checks by tags, run `GL_DEBUG=gocritic golangci-lint run` to see all tags and checks.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/gocritic-tags"
+ }
+ },
+ "settings": {
+ "description": "Settings passed to gocritic. Properties must be valid and enabled check names.",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "captLocal": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "paramsOnly" : {
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "commentedOutCode": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "minLength" : {
+ "type": "number",
+ "default": 15
+ }
+ }
+ },
+ "elseif": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "skipBalanced" : {
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "hugeParam": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "sizeThreshold" : {
+ "type": "number",
+ "default": 80
+ }
+ }
+ },
+ "ifElseChain": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "minThreshold" : {
+ "type": "number",
+ "default": 2
+ }
+ }
+ },
+ "nestingReduce": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "bodyWidth" : {
+ "type": "number",
+ "default": 5
+ }
+ }
+ },
+ "rangeExprCopy": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "sizeThreshold" : {
+ "type": "number",
+ "default": 512
+ },
+ "skipTestFuncs" : {
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "rangeValCopy": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "sizeThreshold" : {
+ "type": "number",
+ "default": 128
+ },
+ "skipTestFuncs" : {
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "ruleguard": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "debug" : {
+ "type": "string"
+ },
+ "enable" : {
+ "type": "string"
+ },
+ "disable" : {
+ "type": "string"
+ },
+ "failOn" : {
+ "type": "string"
+ },
+ "rules" : {
+ "type": "string"
+ }
+ }
+ },
+ "tooManyResultsChecker": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "maxResults" : {
+ "type": "number",
+ "default": 5
+ }
+ }
+ },
+ "truncateCmp": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "skipArchDependent" : {
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "underef": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "skipRecvDeref" : {
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "unnamedResult": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "checkExported" : {
+ "type": "boolean",
+ "default": false
+ }
+ }
+ }
+ }
+ },
+ "disable-all": {
+ "type": "boolean",
+ "default": false
+ },
+ "enable-all": {
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "gocycloSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "min-complexity": {
+ "description": "Minimum code complexity to report (we recommend 10-20).",
+ "type": "integer",
+ "default": 30
+ }
+ }
+ },
+ "godotSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "scope": {
+ "description": "Comments to be checked.",
+ "enum": ["declarations", "toplevel", "all"],
+ "default": "declarations"
+ },
+ "exclude": {
+ "description": "List of regexps for excluding particular comment lines from check.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "period": {
+ "description": "Check that each sentence ends with a period.",
+ "type": "boolean",
+ "default": true
+ },
+ "capital": {
+ "description": "Check that each sentence starts with a capital letter.",
+ "type": "boolean",
+ "default": false
+ },
+ "check-all": {
+ "description": "DEPRECATED: Check all top-level comments, not only declarations.",
+ "type": "boolean",
+ "default": false
+ }
+ }
+ },
+ "godoxSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "keywords": {
+ "description": "Report any comments starting with one of these keywords. This is useful for TODO or FIXME comments that might be left in the code accidentally and should be resolved before merging.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "default": ["TODO", "BUG", "FIXME"]
+ }
+ }
+ },
+ "gofmtSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "simplify": {
+ "description": "Simplify code.",
+ "type": "boolean",
+ "default": true
+ },
+ "rewrite-rules": {
+ "description": "Apply the rewrite rules to the source before reformatting.",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "pattern": {
+ "type": "string"
+ },
+ "replacement": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ }
+ },
+ "golinesSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "max-len": {
+ "type": "integer",
+ "default": 100
+ },
+ "tab-len": {
+ "type": "integer",
+ "default": 4
+ },
+ "shorten-comments": {
+ "type": "boolean",
+ "default": false
+ },
+ "reformat-tags": {
+ "type": "boolean",
+ "default": true
+ },
+ "chain-split-dots": {
+ "type": "boolean",
+ "default": true
+ }
+ }
+ },
+ "interfacebloatSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "max": {
+ "description": "The maximum number of methods allowed for an interface.",
+ "type": "integer"
+ }
+ }
+ },
+ "gofumptSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "extra-rules": {
+ "description": "Choose whether or not to use the extra rules that are disabled by default.",
+ "type": "boolean",
+ "default": false
+ },
+ "module-path": {
+ "description": " Module path which contains the source code being formatted.",
+ "type": "string"
+ }
+ }
+ },
+ "goheaderSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "values": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "const": {
+ "description": "Constants to use in the template.",
+ "type": "object",
+ "patternProperties": {
+ "^.+$": {
+ "description": "Value for the constant.",
+ "type": "string"
+ }
+ },
+ "additionalProperties": false,
+ "examples": [
+ {
+ "YEAR": "2030",
+ "COMPANY": "MY FUTURISTIC COMPANY"
+ }
+ ]
+ },
+ "regexp": {
+ "description": "Regular expressions to use in your template.",
+ "type": "object",
+ "additionalProperties": false,
+ "patternProperties": {
+ "^.+$": {
+ "type": "string"
+ }
+ },
+ "examples": [
+ {
+ "AUTHOR": ".*@mycompany\\.com"
+ }
+ ]
+ }
+ }
+ },
+ "template": {
+ "description": "Template to put on top of every file.",
+ "type": "string",
+ "examples": [
+ "{{ MY COMPANY }}\nSPDX-License-Identifier: Apache-2.0\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at:\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License."
+ ]
+ },
+ "template-path": {
+ "description": "Path to the file containing the template source.",
+ "type": "string",
+ "examples": ["my_header_template.txt"]
+ }
+ },
+ "oneOf": [
+ { "required": ["template"] },
+ { "required": ["template-path"] }
+ ]
+ },
+ "goimportsSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "local-prefixes": {
+ "description": "Put imports beginning with prefix after 3rd-party packages. It is a list of prefixes.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "gomoddirectivesSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "replace-local": {
+ "description": "Allow local `replace` directives.",
+ "type": "boolean",
+ "default": true
+ },
+ "replace-allow-list": {
+ "description": "List of allowed `replace` directives.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "retract-allow-no-explanation": {
+ "description": "Allow to not explain why the version has been retracted in the `retract` directives.",
+ "type": "boolean",
+ "default": false
+ },
+ "exclude-forbidden": {
+ "description": "Forbid the use of the `exclude` directives.",
+ "type": "boolean",
+ "default": false
+ },
+ "toolchain-forbidden": {
+ "description": "Forbid the use of the `toolchain` directive.",
+ "type": "boolean",
+ "default": false
+ },
+ "toolchain-pattern": {
+ "description": "Defines a pattern to validate `toolchain` directive.",
+ "type": "string"
+ },
+ "tool-forbidden": {
+ "description": "Forbid the use of the `tool` directives.",
+ "type": "boolean",
+ "default": false
+ },
+ "go-debug-forbidden": {
+ "description": "Forbid the use of the `godebug` directive.",
+ "type": "boolean",
+ "default": false
+ },
+ "go-version-pattern": {
+ "description": "Defines a pattern to validate `go` minimum version directive.",
+ "type": "string",
+ "default": ""
+ }
+ }
+ },
+ "gomodguardSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "allowed": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "modules": {
+ "description": "List of allowed modules.",
+ "type": "array",
+ "items": {
+ "type": "string",
+ "examples": ["gopkg.in/yaml.v2"]
+ }
+ },
+ "domains": {
+ "description": "List of allowed module domains.",
+ "type": "array",
+ "items": {
+ "type": "string",
+ "examples": ["golang.org"]
+ }
+ }
+ }
+ },
+ "blocked": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "modules": {
+ "description": "List of blocked modules.",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "patternProperties": {
+ "^.+$": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "recommendations": {
+ "description": "Recommended modules that should be used instead.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "reason": {
+ "description": "Reason why the recommended module should be used.",
+ "type": "string"
+ }
+ }
+ }
+ },
+ "additionalProperties": false
+ }
+ },
+ "versions": {
+ "description": "List of blocked module version constraints.",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "patternProperties": {
+ "^.*$": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "version": {
+ "description": "Version constraint.",
+ "type": "string"
+ },
+ "reason": {
+ "description": "Reason why the version constraint exists.",
+ "type": "string"
+ }
+ },
+ "required": ["reason"]
+ }
+ }
+ }
+ },
+ "local-replace-directives": {
+ "description": "Raise lint issues if loading local path with replace directive",
+ "type": "boolean",
+ "default": true
+ }
+ }
+ }
+ }
+ },
+ "gosecSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "includes": {
+ "type": "array",
+ "description": "To select a subset of rules to run",
+ "examples": [["G401"]],
+ "items": {
+ "$ref": "#/definitions/gosec-rules"
+ }
+ },
+ "excludes": {
+ "type": "array",
+ "description": "To specify a set of rules to explicitly exclude",
+ "examples": [["G401"]],
+ "items": {
+ "$ref": "#/definitions/gosec-rules"
+ }
+ },
+ "severity": {
+ "description": "Filter out the issues with a lower severity than the given value",
+ "type": "string",
+ "enum": ["low", "medium", "high"],
+ "default": "low"
+ },
+ "confidence": {
+ "description": "Filter out the issues with a lower confidence than the given value",
+ "type": "string",
+ "enum": ["low", "medium", "high"],
+ "default": "low"
+ },
+ "config": {
+ "description": "To specify the configuration of rules",
+ "type": "object"
+ },
+ "concurrency": {
+ "description": "Concurrency value",
+ "type": "integer"
+ }
+ }
+ },
+ "gosmopolitanSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "allow-time-local": {
+ "description": "Allow and ignore `time.Local` usages.",
+ "type": "boolean",
+ "default": false
+ },
+ "escape-hatches": {
+ "description": "List of fully qualified names in the `full/pkg/path.name` form, to act as \"i18n escape hatches\".",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "watch-for-scripts": {
+ "description": "List of Unicode scripts to watch for any usage in string literals.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "govetSettings": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "settings": {
+ "description": "Settings per analyzer. Map of analyzer name to specific settings.\nRun `go tool vet help` to find out more.",
+ "type": "object",
+ "propertyNames": {
+ "$ref": "#/definitions/govet-analyzers"
+ },
+ "patternProperties": {
+ "^.*$": {
+ "description": "Run `go tool vet help