Skip to content

Commit

Permalink
add code
Browse files Browse the repository at this point in the history
  • Loading branch information
liuxiaomeiG committed Sep 18, 2021
1 parent 34e462d commit 2436e5b
Show file tree
Hide file tree
Showing 268 changed files with 15,215 additions and 1 deletion.
24 changes: 24 additions & 0 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash
set -e
# 这里请根据实际项目进行设置
cd $GOPATH/src/github.com/ultramesh/frigate

st=0
counter=0
# if ! type golangci-lint > /dev/null; then
# curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh \
# | sh -s -- -b $(go env GOPATH)/bin v1.15.0
#fi
# echo "go linter"
# ce38d637 special revision
# CGO_LDFLAGS_ALLOW=.* CGO_CFLAGS_ALLOW=.* golangci-lint run --new-from-rev ce38d637

# [ $? -ne 0 ] && exit 1

# echo "go formatting"
# find . -path '*/vendor/*' -prune -o -name '*.go' -type f -exec gofmt -s -w {} \;
#[ $? -ne 0 ] && exit 1

# add formatted files
# git add -u

51 changes: 51 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: CI
on: [push,pull_request]
jobs:
lint:
name: Golangci-lint
runs-on: ubuntu-18.04
steps:
- name: Set up Go 1.15
uses: actions/setup-go@v2
with:
go-version: 1.15
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v2

- name: Run golangci-lint
uses: Mushus/golangci-linter@v1

- name: Go report card
uses: creekorful/[email protected]
# - name: Run Golangci-lint
# uses: golangci/golangci-lint-action@v2
# with:
# version: v1.29
test:
name: Unit Testing
runs-on: ubuntu-18.04
steps:
- name: Set up Go 1.15
uses: actions/setup-go@v2
with:
go-version: 1.15
id: go
# - name: Get failpoint
# run: |
# git clone https://github.com/pingcap/failpoint.git
# ls -al
# pwd
# cd failpoint/failpoint-ctl
# go build
# sudo cp failpoint-ctl $GOPATH/bin
- name: Checkout
uses: actions/checkout@v2
- name: Enable failpoint
run: make test
# - name: Enable failpoint
# run : failpoint-ctl enable
# - name: Go Test
# run: go test -v ./...
# - name: Disable failpoint
# run: failpoint-ctl disable
26 changes: 26 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
.DS_Store
.idea
agile
frigate
hyperbench
result.html
detail.js
*.[oa]

assets
visual
vendor/github.com/mattn/go-sqlite3/
logs/*
db/*
keystore/*
debug
**/go.sum
**/*.log
**/*.db
**/*.csv
packrd
lua/testImpl.lua
dist

node_modules

113 changes: 113 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
# This file contains all available configuration options
# with their default values.

# options for analysis running
run:
# default concurrency is a available CPU number
concurrency: 4

# timeout for analysis, e.g. 30s, 5m, default is 1m
deadline: 5m

# exit code when at least one issue was found, default is 1
issues-exit-code: 1

# include test files or not, default is true
tests: true

# which dirs to skip: they won't be analyzed;
# can use regexp here: generated.*, regexp is applied on full path;
# default value is empty list, but next dirs are always skipped independently
# from this option's value:
# vendor$, third_party$, testdata$, examples$, Godeps$, builtin$
skip-dirs:
- vendor$

skip-files:
- asn1.go
- chacha_generic.go
- sum_ref.go
- chacha_test.go


# all available settings of specific linters
linters-settings:
govet:
# report about shadowed variables
check-shadowing: true
golint:
# minimalfor issues, default is 0.8
min-: 0.8
gofmt:
# simplify code: gofmt with `-s` option, true by default
simplify: true
gocyclo:
# minimal code complexity to report, 30 by default (but we recommend 10-20)
min-complexity: 19
maligned:
# print struct with more effective memory layout or not, false by default
suggest-new: true
dupl:
# tokens count to trigger issue, 150 by default
threshold: 100
goconst:
# minimal length of string constant, 3 by default
min-len: 3
# minimal occurrences count to trigger, 3 by default
min-occurrences: 3
unused:
# treat code as a program (not a library) and report unused exported identifiers; default is false.
# XXX: if you enable this setting, unused will report a lot of false-positives in text editors:
# if it's called for subdir of a project it can't find funcs usages. All text editor integrations
# with golangci-lint call it on a directory with the changed file.
check-exported: false
unparam:
# call graph construction algorithm (cha, rta). In general, use cha for libraries,
# and rta for programs with main packages. Default is cha.
algo: cha

# Inspect exported functions, default is false. Set to true if no external program/library imports your code.
# XXX: if you enable this setting, unparam will report a lot of false-positives in text editors:
# if it's called for subdir of a project it can't find external interfaces. All text editor integrations
# with golangci-lint call it on a directory with the changed file.
check-exported: false
nakedret:
# make an issue if func has more lines of code than this setting and it has naked returns; default is 30
max-func-lines: 30
prealloc:
# XXX: we don't recommend using this linter before doing performance profiling.
# For most programs usage of prealloc will be a premature optimization.

# Report preallocation suggestions only on simple loops that have no returns/breaks/continues/gotos in them.
# True by default.
simple: true
range-loops: true # Report preallocation suggestions on range loops, true by default
for-loops: false # Report preallocation suggestions on for loops, false by default


linters:
enable:
- gofmt
- golint
disable:
- megacheck
- typecheck
- gocyclo


issues:
exclude:
- "don't use ALL_CAPS in Go names; use CamelCase"
- "and that stutters; consider calling this"
- "package comment should be of the form"
# Independently from option `exclude` we use default exclude patterns,
# it can be disabled by this option. To list all
# excluded by default patterns execute `golangci-lint run --help`.
# Default value for this option is true.
exclude-use-default: false

# Maximum issues count per one linter. Set to 0 to disable. Default is 50.
max-per-linter: 10

# Maximum count of issues with the same text. Set to 0 to disable. Default is 3.
max-same-issues: 2
Loading

0 comments on commit 2436e5b

Please sign in to comment.