RHEL requires the source code for dependencies to be included in the srpm. The spec file already expects that, but we've only included the vendored modules (i.e., the `vendor` directory) in the `rhel-8.2.` branch. Move vendoring to master, so that we can build RHEL packages from it as well. This commit is the result of running `go mod vendor`, which includes the vendored sources and updates go.mod and go.sum files. Fedora requires the opposite: dependencies should not be vendored. The spec file already ignores the `vendor` directory by default.
45 lines
717 B
Go
45 lines
717 B
Go
package match
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
"unicode/utf8"
|
|
)
|
|
|
|
// raw represents raw string to match
|
|
type Text struct {
|
|
Str string
|
|
RunesLength int
|
|
BytesLength int
|
|
Segments []int
|
|
}
|
|
|
|
func NewText(s string) Text {
|
|
return Text{
|
|
Str: s,
|
|
RunesLength: utf8.RuneCountInString(s),
|
|
BytesLength: len(s),
|
|
Segments: []int{len(s)},
|
|
}
|
|
}
|
|
|
|
func (self Text) Match(s string) bool {
|
|
return self.Str == s
|
|
}
|
|
|
|
func (self Text) Len() int {
|
|
return self.RunesLength
|
|
}
|
|
|
|
func (self Text) Index(s string) (int, []int) {
|
|
index := strings.Index(s, self.Str)
|
|
if index == -1 {
|
|
return -1, nil
|
|
}
|
|
|
|
return index, self.Segments
|
|
}
|
|
|
|
func (self Text) String() string {
|
|
return fmt.Sprintf("<text:`%v`>", self.Str)
|
|
}
|