Skip to content
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
190 changes: 190 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
run:
# Timeout for analysis, e.g. 30s, 5m.
# Default: 1m
timeout: 5m
# Exit code when at least one issue was found.
# Default: 1
issues-exit-code: 2
# Include test files or not.
# Default: true
tests: true
skip-files:

linters:
# Disable all linters.
# Default: false
disable-all: true
# Enable specific linter
# https://golangci-lint.run/usage/linters/#enabled-by-default-linters
enable:
- depguard
- exportloopref
- gocheckcompilerdirectives
- gofmt
- gosimple
- govet
- ineffassign
- prealloc
- reassign
- rowserrcheck
- sqlclosecheck
- staticcheck
- stylecheck
- tenv
- typecheck
- unused

linters-settings:
stylecheck:
checks:
- ST1001
- ST1005
- ST1006
- ST1008
- ST1011
- ST1012
- ST1013
- ST1015
- ST1016
- ST1017
- ST1018
- ST1019
- ST1023
gosimple:
checks:
- S1000
- S1001
- S1002
- S1003
- S1004
- S1005
- S1006
- S1007
- S1008
- S1009
- S1010
- S1011
- S1012
- S1016
- S1017
- S1018
- S1019
- S1020
- S1021
- S1023
- S1024
- S1025
- S1028
- S1029
- S1030
- S1031
- S1032
- S1033
- S1034
- S1035
- S1036
- S1037
- S1038
- S1039
- S1040

staticcheck:
checks:
- SA1000
- SA1001
- SA1002
- SA1003
- SA1004
- SA1005
- SA1006
- SA1007
- SA1008
- SA1010
- SA1011
- SA1012
- SA1013
- SA1014
- SA1015
- SA1016
- SA1017
- SA1018
- SA1019
- SA1020
- SA1021
- SA1023
- SA1024
- SA1025
- SA1026
- SA1027
- SA1028
- SA1029
- SA1030
- SA2000
- SA2001
- SA2002
- SA2003
- SA3000
- SA3001
- SA4000
- SA4001
- SA4003
- SA4004
- SA4005
- SA4006
- SA4008
- SA4009
- SA4010
- SA4011
- SA4012
- SA4013
- SA4014
- SA4015
- SA4016
- SA4017
- SA4018
- SA4019
- SA4020
- SA4021
- SA4022
- SA4023
- SA4024
- SA4025
- SA4026
- SA4027
- SA4028
- SA4029
- SA4030
- SA4031
- SA5000
- SA5001
- SA5002
- SA5003
- SA5004
- SA5005
- SA5007
- SA5008
- SA5009
- SA5010
- SA5011
- SA5012
- SA6000
- SA6001
- SA6002
- SA6003
- SA6005
- SA9001
- SA9002
- SA9003
- SA9004
- SA9005
- SA9006
- SA9007
- SA9008

issues:
exclude-use-default: false
exclude-rules:
# Exclude some linters from running on tests files.
- path: _test\.go
linters:
- stylecheck
22 changes: 22 additions & 0 deletions .licenserc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
header:
license:
spdx-id: Apache-2.0
copyright-owner: Matrix Origin
paths:
- '**/*.go'
- '**/*.c'
- '**/*.s'
- '**/*.h'
- '**/*.cpp'
- '**/*.proto'
paths-ignore:
- 'docs/'
- 'test/'
- 'optools/'
- '**/*.pb.go'
- '**/.gitignore'
- '**/goyacc.go'
comment: on-failure
dependency:
files:
- go.mod
56 changes: 56 additions & 0 deletions .markdownlint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# disable all by default
default: false

# MD003
heading-style:
style: atx

# MD012
no-multiple-blanks: true

# MD018
no-missing-space-atx: true

# MD019
no-multiple-space-atx: true

# MD022
blanks-around-headings: true

# MD023
heading-start-left: true

# MD024
no-duplicate-heading:
siblings_only: true

# MD026
no-trailing-punctuation:
punctuation: '.,;:!。,;:!'

# MD027
no-multiple-space-blockquote: true

# MD030
list-marker-space: true

# MD031
blanks-around-fences: true

# MD032
blanks-around-lists: true

# MD034
no-bare-urls: true

# MD037
no-space-in-emphasis: true

# MD038
no-space-in-code: true

# MD039
no-space-in-links: true

# MD042
no-empty-links: true
102 changes: 102 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# Copyright 2021 - 2022 Matrix Origin
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

#
# Examples
#
# By default, make builds the mo-service
#
# make
#
# To re-build MO -
#
# make clean
# make build
#
# To re-build MO in debug mode also with race detector enabled -
#
# make clean
# make debug
#
# To run static checks -
#
# make install-static-check-tools
# make static-check
#
# To construct a directory named vendor in the main module’s root directory that contains copies of all packages needed to support builds and tests of packages in the main module.
# make vendor
#

# where am I
ROOT_DIR = $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
MO_DUMP := mo-dump
UNAME_S := $(shell uname -s)
GOPATH := $(shell go env GOPATH)
GO_VERSION=$(shell go version)
BRANCH_NAME=$(shell git rev-parse --abbrev-ref HEAD)
LAST_COMMIT_ID=$(shell git rev-parse --short HEAD)
BUILD_TIME=$(shell date +%s)
MO_VERSION=$(shell git describe --always --tags $(shell git rev-list --tags --max-count=1))
GO_MODULE=$(shell go list -m)

# cross compilation has been disabled for now
ifneq ($(GOARCH)$(TARGET_ARCH)$(GOOS)$(TARGET_OS),)
$(error cross compilation has been disabled)
endif

###############################################################################
# default target
###############################################################################

all: build

###############################################################################
# build vendor directory
###############################################################################

.PHONY: vendor-build
vendor-build:
$(info [go mod vendor])
@go mod vendor


###############################################################################
# clean
###############################################################################

.PHONY: clean
clean:
$(info [Clean up])
$(info Clean go test cache)
@go clean -testcache
rm -f $(BIN_NAME)
rm -rf $(ROOT_DIR)/vendor


###############################################################################
# modump
###############################################################################

RACE_OPT :=
DEBUG_OPT :=
CGO_DEBUG_OPT :=
CGO_OPTS=CGO_CFLAGS="-I$(ROOT_DIR)/cgo " CGO_LDFLAGS="-L$(ROOT_DIR)/cgo -lmo -lm"
GOLDFLAGS=-ldflags="-X '$(GO_MODULE)/pkg/version.GoVersion=$(GO_VERSION)' -X '$(GO_MODULE)/pkg/version.BranchName=$(BRANCH_NAME)' -X '$(GO_MODULE)/pkg/version.CommitID=$(LAST_COMMIT_ID)' -X '$(GO_MODULE)/pkg/version.BuildTime=$(BUILD_TIME)' -X '$(GO_MODULE)/pkg/version.Version=$(MO_VERSION)'"
.PHONY: modump
modump:
$(CGO_OPTS) go build $(RACE_OPT) $(GOLDFLAGS) -o $(MO_DUMP) ./cmd/mo-dump

###############################################################################
# static checks
###############################################################################
Loading