aboutsummaryrefslogtreecommitdiff
path: root/lib/text
AgeCommit message (Collapse)Author
2 daystext/diff: update comments on BytesRatioHEADmaindevShulhan
Explain the second and third return values: match and maxlen.
3 daystext/diff: skip writing Unified if no difference foundShulhan
3 daystext/diff: rename LevelWords to LevelChunksShulhan
Using Words seems like misleading since we capture the characters difference, not a word as in human language.
3 daystext/diff: rewrite TestText to test Files with LevelWordsShulhan
In the struct Data, we add new method WriteLineChunks to print the LineChunks data into [io.Writer] w.
3 daystext/diff: rename LineChange to LineChunkShulhan
In the struct Data we also rename field Changes to LineChunks.
3 daystext/diff: remove LineChangesShulhan
Defining []T as new type does not help on readability only make it confusing for future maintenances.
3 daystext/diff: add example for Files, Lines, Text, and UnifiedShulhan
While at it, - reorganize the order of functions alphabetically, following the order from doc. - changes the [Line.String] to print text in double quoted to help human compare the changes for non-printable characters.
3 daystext/diff: add an examples for Bytes and BytesRatioShulhan
While at it, rename the source file to reflect the content, instead of diffinterface.go name it func.go.
3 daystext/diff: stores the old and new file names for showing in WriteUnifiedShulhan
While at it, use consistent receiver "diff" for Data and return *Data from Text, Lines, Files, and Unified.
3 daystext/diff: replace IsEqual with [bytes.Equal]Shulhan
I cannot remember the use case for implementing IsEqual. Seems like the original purpose of IsEqual is to compare minimum length between two slices of bytes.
3 daystext/diff: implements unified diffShulhan
5 daystext/diff: refactoring to use local Line instead from text packageShulhan
The reason for refactoring is we will add more fields to the Line type to handle unified diff. In the ParseLines, we changes the line number to start from 1, to make it consistent with ReadLines and file line numbering. This causes a lot of changes in the expectation files in testdata.
10 daysall: apply go fixShulhan
2026-01-15all: convert license and copyright to use SPDX identifiersShulhan
With help of spdxconv tool [1], we able to bulk update all files license and copyright format to comply with SPDX formats. [1] https://kilabit.info/project/spdxconv/
2025-01-23all: use for-range with numericShulhan
Go 1.22 now support for-range on numeric value.
2024-03-05all: comply with linter recommendations #2Shulhan
HTTP request now implicitly create request with context. Any false positive related to not closing HTTP response body has been annotated with "nolint:bodyclose". In the example code, use consistent "// Output:" comment format, by prefixing with single space. Any comment on code now also prefixing with single space. An error returned without variables now use [errors.New] instead of [fmt.Errorf]. Any error returned using [fmt.Errorf] now wrapped using "%w" instead of "%s". Also, replace error checking using [errors.Is] or [errors.As], instead of using equal/not-equal operator. Any statement like "x = x OP y" now replaced with "x OP= y". Also, swap statement is simplified using "x, y = y, x". Any switch statement with single case now replaced with if-condition. Any call to defer on function or program that call [os.Exit], now replaced by calling the deferred function directly. Any if-else condition now replaced with switch statement, if possible.
2024-03-02all: move the repository to "git.sr.ht/~shulhan/pakakeh.go"Shulhan
There are several reasons that why we move from github.com. First, related to the name of package. We accidentally name the package with "share" a common word in English that does not reflect the content of repository. By moving to other repository, we can rename it to better and unique name, in this "pakakeh.go". Pakakeh is Minang word for tools, and ".go" suffix indicate that the repository related to Go programming language. Second, supporting open source. The new repository is hosted under sourcehut.org, the founder is known to support open source, and all their services are licensed under AGPL, unlike GitHub that are closed sources. Third, regarding GitHub CoPilot. The GitHub Terms of Service [1], allow any public content that are hosted there granted them to parse the content. On one side, GitHub helps and flourish the open source, but on another side have an issues regarding scraping the copyleft license [2]. [1]: https://docs.github.com/en/site-policy/github-terms/github-terms-of-service#4-license-grant-to-us [2]: https://githubcopilotinvestigation.com
2023-09-14all: fix variable shadowing as reported by shadow toolShulhan
The shadow tool [1] report a variable where its name is declared twice or more, in different scope. [1] https://pkg.go.dev/golang.org/x/tools@v0.13.0/go/analysis/passes/shadow
2023-09-11lib/text: fix linter warningsShulhan
Some changes, * add missing comment to method MarshalJSON in Chunk and Line * use consistent receiver name on Chunk and Line * rename variable "new" to "newline" to fix "redefinition of the built-in function new"
2023-09-11lib/text: realign struct for better size allocationShulhan
The realignment reduce the cost of the following struct, * Chunk: from 16 to 8 bytes (-8) * struct in TestChunk_MarshalJSON: from 40 to 32 bytes (-8) * diff.LineChange: from 96 to 88 bytes (-8) * Line: from 16 to 8 bytes (-8) * struct in TestLine_MarshalJSON: from 40 to 32 bytes (-8)
2023-04-03lib/bytes: copy TokenFind to internal/bytes#TokenFindShulhan
This is to prevent import cycle later when we use lib/test in bytes.
2022-09-21text/diff: add field to indicate no difference found after diff-ingShulhan
2022-09-08text/diff: rewrite the test again by reading from filesShulhan
The goal is to remove dependency to lib/test so we can use text/diff in the lib/test in the future.
2022-09-07lib/text: replace test.Assert with reflect.DeepEqualShulhan
We want to prevent import cycle in the future, when the test package use the text/diff for display difference between string.
2022-09-07lib/text: replace json.Escape with strconv.QuoteShulhan
We want to prevent import cycle in the future, when the test package use the text/diff for display difference between string.
2022-08-29text/diff: rewrite the test using test.DataShulhan
Using test.Data provide much more readable input and outputs and simplify modifying the test data instead of manually define the expected output in struct.
2022-08-28lib/text: add custom MarshalJSON to type Chunk and LineShulhan
2022-05-09all: reformat all codes using gofmt 1.19 (the Go tip)Shulhan
2021-07-30text/diff: add functions to compare raw bytes as text and text.LinesShulhan
This changes refactoring some functions, notably, * Rename Bytes function to IsEqual * Rename Lines function to Bytes * Add function Text that compare two text (raw bytes) * Add function Lines that compare two instances of text.Lines
2021-07-30lib/text: implement function to parse raw bytes into LinesShulhan
2021-07-30lib/text: implement Stringer on Chunk and Line typesShulhan
2020-06-06all: use default linter optionsShulhan
2019-09-27all: remove unnecessary trailing newlineShulhan
2019-06-14all: fix nolint formatShulhan
The valid syntax to suppress linter warnings is "//nolint:<name>" with no space between comment and "nolint" and between ":". Also, we move the placement of nolint directive to the top of statements for multiple nolint in the same scope. While at it, fix and supress some linter warnings.
2019-03-01all: fix warnings from linterShulhan
Most of the warnings caused by update to linter which cause global variables declared with grouping "( ... )" and that has been suppressed, are become false-positive again.
2019-01-29lib/text: simplify if-else conditionShulhan
2018-11-30all: fix and suppress linter warnings on long linesShulhan
2018-11-30all: minimize and suppress linter warnings for global variablesShulhan
2018-11-30all: fix linter warnings on naked returnShulhan
2018-11-29all: disable lint on functions that have cyclomatix complexity > 15Shulhan
2018-11-29all: fix warnings from lintersShulhan
2018-11-29all: fixes warning from lintersShulhan
2018-11-29all: fix warning from lintersShulhan
2018-09-17Merge package "github.com/shuLhan/tekstus/diff" to "text/diff"Shulhan
2018-09-03Rename package text to stringShulhan
2018-09-03Move all byte(s) related constant and functions from package text to bytesShulhan
2018-09-03lib/text: add function to check if all bytes are digitShulhan
2018-09-01Add package time with Day and Week as durationShulhan
2018-08-29lib/text: move exported constants to file named as package nameShulhan
2018-08-28lib/text: add function to generate fixed random charactersShulhan