Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

functionality refactoring #6

Merged
merged 15 commits into from
May 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ jobs:
fail-fast: true
matrix:
go:
- "1.17"
- "1.16"
- "1.20"
steps:

- uses: actions/checkout@v2
Expand All @@ -40,11 +39,11 @@ jobs:

- name: Install goveralls
env: { GO111MODULE: "off" }
if: matrix.go == '1.17'
if: matrix.go == '1.20'
run: go get github.com/mattn/goveralls

- name: Coverage - Sending Report to Coveral
if: matrix.go == '1.17'
if: matrix.go == '1.20'
env:
COVERALLS_TOKEN: ${{ secrets.github_token }}
run: goveralls -coverprofile=coverage.cov -service=github
Expand Down
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,9 @@ coverage.cov
bin/*
dist/*
tmp/*
out*
new_funcs*
demo*
.task*
.ipynb*
.jupyter*
53 changes: 53 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
project_name: mirror

before:
hooks:
- go mod tidy

builds:
- binary: mirror
env:
- CGO_ENABLED=0
goos:
- darwin
- linux
- windows
goarch:
- amd64
- 386
- arm64
- arm
goarm:
- 6
ignore:
- goos: windows
goarm: 6
- goos: windows
goarch: arm64
- goos: linux
goarm: 6
- goos: darwin
goarch: 386
main: ./cmd/mirror/
flags:
- -trimpath
ldflags: -s -w

checksum:
name_template: 'checksums.txt'

archives:
- name_template: '{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}{{ if .Mips }}_{{ .Mips }}{{ end }}'
replacements:
darwin: darwin
linux: linux
windows: windows
386: i386
amd64: x86_64
format_overrides:
- goos: windows
format: zip
files:
- LICENSE
- readme.md
File renamed without changes.
141 changes: 141 additions & 0 deletions MIRROR_FUNCS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
<table><tr>
<td><code>func (b *bufio.Writer) Write(p []byte) (int, error)</code></td>
<td><code>func (b *bufio.Writer) WriteString(s string) (int, error)</code></td>
</tr>
<tr>
<td><code>func (b *bytes.Buffer) Write(p []byte) (int, error)</code></td>
<td><code>func (b *bytes.Buffer) WriteString(s string) (int, error)</code></td>
</tr>
<tr>
<td><code>func bytes.Compare(a, b []byte) int</code></td>
<td><code>func strings.Compare(a, b string) int</code></td>
</tr>
<tr>
<td><code>func bytes.Contains(b, subslice []byte) bool</code></td>
<td><code>func strings.Contains(s, substr string) bool</code></td>
</tr>
<tr>
<td><code>func bytes.ContainsAny(b []byte, chars string) bool</code></td>
<td><code>func strings.ContainsAny(s, chars string) bool</code></td>
</tr>
<tr>
<td><code>func bytes.ContainsRune(b []byte, r rune) bool</code></td>
<td><code>func strings.ContainsRune(s string, r rune) bool</code></td>
</tr>
<tr>
<td><code>func bytes.Count(s, sep []byte) int</code></td>
<td><code>func strings.Count(s, substr string) int</code></td>
</tr>
<tr>
<td><code>func bytes.EqualFold(s, t []byte) bool</code></td>
<td><code>func strings.EqualFold(s, t string) bool</code></td>
</tr>
<tr>
<td><code>func bytes.HasPrefix(s, prefix []byte) bool</code></td>
<td><code>func strings.HasPrefix(s, prefix string) bool</code></td>
</tr>
<tr>
<td><code>func bytes.HasSuffix(s, suffix []byte) bool</code></td>
<td><code>func strings.HasSuffix(s, suffix string) bool</code></td>
</tr>
<tr>
<td><code>func bytes.Index(s, sep []byte) int</code></td>
<td><code>func strings.Index(s, substr string) int</code></td>
</tr>
<tr>
<td><code>func bytes.IndexAny(s []byte, chars string) int</code></td>
<td><code>func strings.IndexAny(s, chars string) int</code></td>
</tr>
<tr>
<td><code>func bytes.IndexByte(b []byte, c byte) int</code></td>
<td><code>func strings.IndexByte(s string, c byte) int</code></td>
</tr>
<tr>
<td><code>func bytes.IndexFunc(s []byte, f func(r rune) bool) int</code></td>
<td><code>func strings.IndexFunc(s string, f func(rune) bool) int</code></td>
</tr>
<tr>
<td><code>func bytes.IndexRune(s []byte, r rune) int</code></td>
<td><code>func strings.IndexRune(s string, r rune) int</code></td>
</tr>
<tr>
<td><code>func bytes.LastIndex(s, sep []byte) int</code></td>
<td><code>func strings.LastIndex(s, sep string) int</code></td>
</tr>
<tr>
<td><code>func bytes.LastIndexAny(s []byte, chars string) int</code></td>
<td><code>func strings.LastIndexAny(s, chars string) int</code></td>
</tr>
<tr>
<td><code>func bytes.LastIndexByte(s []byte, c byte) int</code></td>
<td><code>func strings.LastIndexByte(s string, c byte) int</code></td>
</tr>
<tr>
<td><code>func bytes.LastIndexFunc(s []byte, f func(r rune) bool) int</code></td>
<td><code>func strings.LastIndexFunc(s string, f func(rune) bool) int</code></td>
</tr>
<tr>
<td><code>func bytes.NewBuffer(buf []byte *bytes.Buffer</code></td>
<td><code>func bytes.NewBufferString(s string) *bytes.Buffer</code></td>
</tr>
<tr>
<td><code>func (h *hash/maphash.Hash) Write(b []byte) (int, error)</code></td>
<td><code>func (h *hash/maphash.Hash) WriteString(s string) (int, error)</code></td>
</tr>
<tr>
<td><code>func (rw *net/http/httptest.ResponseRecorder) Write(buf []byte) (int, error)</code></td>
<td><code>func (rw *net/http/httptest.ResponseRecorder) WriteString(str string) (int, error)</code></td>
</tr>
<tr>
<td><code>func (f *os.File) Write(b []byte) (n int, err error)</code></td>
<td><code>func (f *os.File) WriteString(s string) (n int, err error)</code></td>
</tr>
<tr>
<td><code>func regexp.Match(pattern string, b []byte) (bool, error)</code></td>
<td><code>func regexp.MatchString(pattern string, s string) (bool, error)</code></td>
</tr>
<tr>
<td><code>func (re *regexp.Regexp) FindAllIndex(b []byte, n int) [][]int</code></td>
<td><code>func (re *regexp.Regexp) FindAllStringIndex(s string, n int) [][]int</code></td>
</tr>
<tr>
<td><code>func (re *regexp.Regexp) FindAllSubmatch(b []byte, n int) [][][]byte</code></td>
<td><code>func (re *regexp.Regexp) FindAllStringSubmatch(s string, n int) [][]string</code></td>
</tr>
<tr>
<td><code>func (re *regexp.Regexp) FindIndex(b []byte) (loc []int)</code></td>
<td><code>func (re *regexp.Regexp) FindStringIndex(s string) (loc []int)</code></td>
</tr>
<tr>
<td><code>func (re *regexp.Regexp) FindSubmatchIndex(b []byte) []int</code></td>
<td><code>func (re *regexp.Regexp) FindStringSubmatchIndex(s string) []int</code></td>
</tr>
<tr>
<td><code>func (re *regexp.Regexp) Match(b []byte) bool</code></td>
<td><code>func (re *regexp.Regexp) MatchString(s string) bool</code></td>
</tr>
<tr>
<td><code>func (b *strings.Builder) Write(p []byte) (int, error)</code></td>
<td><code>func (b *strings.Builder) WriteByte(c byte) error</code></td>
</tr>
<tr>
<td><code>func utf8.Valid(p []byte) bool</code></td>
<td><code>func utf8.ValidString(s string) bool</code></td>
</tr>
<tr>
<td><code>func utf8.FullRune(p []byte) bool</code></td>
<td><code>func utf8.FullRuneInString(s string) bool</code></td>
</tr>
<tr>
<td><code>func utf8.RuneCount(p []byte) int</code></td>
<td><code>func utf8.RuneCountInString(s string) (n int)</code></td>
</tr>
<tr>
<td><code>func utf8.DecodeLastRune(p []byte) (rune, int)</code></td>
<td><code>func utf8.DecodeLastRuneInString(s string) (rune, int)</code></td>
</tr>
<tr>
<td><code>func utf8.DecodeRune(p []byte) (rune, int)</code></td>
<td><code>func utf8.DecodeRuneInString(s string) (une, int)</code></td>
</tr>
</table>
23 changes: 22 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
export PATH := $(PWD)/bin:$(PATH) # ./bin to $PATH
export SHELL := bash # Default Shell

GOPKGS := $(shell go list ./... | grep -vE "(cmd|examples|plugin|testdata)" | tr -s '\n' ',' | sed 's/.\{1\}$$//' )
GOPKGS := $(shell go list ./... | grep -vE "(cmd|examples|plugin|testdata|backup)" | tr -s '\n' ',' | sed 's/.\{1\}$$//' )


build:
Expand All @@ -17,6 +17,14 @@ tests:
-covermode=atomic \
-coverpkg=$(GOPKGS) -coverprofile=coverage.cov ./...

tests-summary:
go test -v -count=1 -race \
-failfast \
-parallel=2 \
-timeout=1m \
-covermode=atomic \
-coverpkg=$(GOPKGS) -coverprofile=coverage.cov --json ./... | tparse -all

generate:
go run ./cmd/internal/generate-tests/ "$(PWD)/testdata"

Expand All @@ -31,3 +39,16 @@ install:
go install -trimpath -v -ldflags="-w -s" \
./cmd/mirror

funcs:
echo "" > "out/results.txt"
go list std | grep -v "vendor" | grep -v "internal" | \
xargs -I {} sh -c 'go doc -all {} > out/$(basename {}).txt'

bin/goreleaser:
@curl -Ls https://github.com/goreleaser/goreleaser/releases/download/v1.17.2/goreleaser_Darwin_all.tar.gz | tar -zOxf - goreleaser > ./bin/goreleaser
chmod 0755 ./bin/goreleaser

test-release: bin/goreleaser
goreleaser release --help
goreleaser release -f .goreleaser.yaml \
--skip-validate --skip-publish --clean
10 changes: 5 additions & 5 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@ tasks:
default:
sources:
- "./**/*.go"
method: timestamp
method: checksum
cmds:
- clear
- make build
- ls -lah bin/
- make tests
- make lints
- make build
- ls -lah bin/

testcase: go test -v -failfast -count=1 -run "TestAll/{{ .Case }}" ./...

regen:
sources:
- ./cmd/internal/generate-tests/*.go
- ./internal/rules/*.go
- ./cmd/internal/generate-tests/tempaltes/*.tmpl
- ./checkers_*.go
- ./cmd/internal/generate-tests/templates/*.tmpl
method: timestamp
cmds:
- go build -o bin/genrate-tests ./cmd/internal/generate-tests/
Expand Down
Loading
Loading