diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml new file mode 100644 index 0000000..1f6253e --- /dev/null +++ b/.github/workflows/main.yaml @@ -0,0 +1,54 @@ +name: xconn CI + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Setup go + uses: actions/setup-go@v3 + with: + go-version-file: 'go.mod' + cache: true + - run: go version + + - name: Pull in all Go dependencies + run: | + go mod vendor + + - name: golangci-lint + uses: golangci/golangci-lint-action@v3 + with: + # version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` + version: latest + # skip all additional steps + skip-pkg-cache: true + skip-build-cache: true + + - name: Check that code is formatted via go fmt tool + run: | + if [ "$(gofmt -s -l . | grep -v vendor | wc -l)" -gt 0 ]; then + exit 1; + fi + + - name: Check that go modules are in synced state + run: | + go mod tidy -v + if [ -n "$(git status --porcelain go.mod go.sum)" ]; then + echo "Go modules are dirty or not in a good state. Please run go mod tidy" + exit 1; + fi + + - name: Run unit tests + run: | + make test diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9f11b75 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea/ diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..1c0236c --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,179 @@ +run: + # default concurrency is a available CPU number + #concurrency: 4 + + # timeout for analysis, e.g. 30s, 5m, default is 1m + timeout: 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 + + # list of build tags, all linters use it. Default is empty list. + #build-tags: + # - mytag + + # which dirs to skip: issues from them won't be reported; + # can use regexp here: generated.*, regexp is applied on full path; + # default value is empty list, but default dirs are skipped independently + # from this option's value (see skip-dirs-use-default). + # "/" will be replaced by current OS file path separator to properly work + # on Windows. + #skip-dirs: + # - src/external_libs + # - autogenerated_by_my_lib + + # default is true. Enables skipping of directories: + # vendor$, third_party$, testdata$, examples$, Godeps$, builtin$ + skip-dirs-use-default: true + + # which files to skip: they will be analyzed, but issues from them + # won't be reported. Default value is empty list, but there is + # no need to include all autogenerated files, we confidently recognize + # autogenerated files. If it's not please let us know. + # "/" will be replaced by current OS file path separator to properly work + # on Windows. + # skip-files: + # - export_test.go + + # by default isn't set. If set we pass it to "go list -mod={option}". From "go help modules": + # If invoked with -mod=readonly, the go command is disallowed from the implicit + # automatic updating of go.mod described above. Instead, it fails when any changes + # to go.mod are needed. This setting is most useful to check that go.mod does + # not need updates, such as in a continuous integration and testing system. + # If invoked with -mod=vendor, the go command assumes that the vendor + # directory holds the correct copies of dependencies and ignores + # the dependency descriptions in go.mod. + # modules-download-mode: readonly|release|vendor + + # Allow multiple parallel golangci-lint instances running. + # If false (default) - golangci-lint acquires file lock on start. + allow-parallel-runners: false + +# output configuration options +output: +# colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number" +# format: colored-line-number + +# print lines of code with issue, default is true +# print-issued-lines: true + +# print linter name in the end of issue text, default is true +# print-linter-name: true + +# make issues output unique by line, default is true +# uniq-by-line: true + +# add a prefix to the output file references; default is no prefix + path-prefix: "" + +# all available settings of specific linters +# @see all available linters and options here: https://golangci-lint.run/usage/linters/ +linters-settings: + gci: + # Section configuration to compare against. + # Section names are case-insensitive and may contain parameters in (). + # The default order of sections is `standard > default > custom > blank > dot`, + # If `custom-order` is `true`, it follows the order of `sections` option. + # Default: ["standard", "default"] + sections: + - standard # Standard section: captures all standard packages. + - default # Default section: contains all imports that could not be matched to another section type. + - prefix(github.com/xconnio) # Custom section: groups all imports with the specified Prefix. + # Skip generated files. + # Default: true + #skip-generated: false + # Enable custom order of sections. + # If `true`, make the section order the same as the order of `sections`. + # Default: false + custom-order: true + +linters: + # enable the following linters + enable: + - errcheck + - gosimple + - govet + - ineffassign + - misspell + - typecheck + - asciicheck + - bidichk + - contextcheck + - decorder + - durationcheck + - errorlint + - execinquery + - exportloopref + - gci + - gochecknoglobals + - goconst + - godot + - gofmt + #- gomnd + - gosec + - nakedret + - nilerr + - testpackage + - unused + - unconvert + - unparam + - lll + # disable everything else + disable-all: true + +issues: + # List of regexps of issue texts to exclude, empty list by default. + # But independently from this option we use default exclude patterns, + # it can be disabled by `exclude-use-default: false`. To list all + # excluded by default patterns execute `golangci-lint run --help` + # exclude: + # - abcdef + + # Excluding configuration per-path, per-linter, per-text and per-source + exclude-rules: + # Exclude some linters from running on tests files. + - path: _test\.go + linters: + - gocyclo + - errcheck + - dupl + - gosec + + - path: export.*_test\.go + linters: + - testpackage + - gochecknoglobals + + # benchmarks are little noisy + - path: benchmarks/* + linters: + - unparam + - unused + + # disable noise from errcheck + - linters: + - errcheck + text: ".AbortWithReason" + + # 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: true + + # Maximum issues count per one linter. Set to 0 to disable. Default is 50. + max-per-linter: 0 + + # Maximum count of issues with the same text. Set to 0 to disable. Default is 3. + max-same-issues: 0 + + # Show only new issues: if there are unstaged changes or untracked files, + # only those changes are analyzed, else only changes in HEAD~ are analyzed. + # It's a super-useful option for integration of golangci-lint into existing + # large codebase. It's not practical to fix all existing issues at the moment + # of integration: much better don't allow issues in new code. + # Default is false. + new: false diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..c2b3725 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024 Simple Things Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..8aa0082 --- /dev/null +++ b/Makefile @@ -0,0 +1,8 @@ +lint: + golangci-lint run + +test: + go test -count=1 ./... -v + +run: + go run ./cmd/xconn diff --git a/cmd/xconn/main.go b/cmd/xconn/main.go new file mode 100644 index 0000000..b08f27a --- /dev/null +++ b/cmd/xconn/main.go @@ -0,0 +1,14 @@ +package main + +import ( + "fmt" + "log" + + "github.com/xconnio/wampproto-go" +) + +func main() { + session := wampproto.NewSession(nil) + fmt.Println(session) + log.Println("HELLO WORLD!") +} diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..9f0acbc --- /dev/null +++ b/go.mod @@ -0,0 +1,14 @@ +module github.com/xconnio/xconn-go + +go 1.20 + +require github.com/xconnio/wampproto-go v0.0.0-20240526201820-3bc6d812a007 + +require ( + github.com/fxamacker/cbor/v2 v2.6.0 // indirect + github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect + github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect + github.com/x448/float16 v0.8.4 // indirect + golang.org/x/crypto v0.23.0 // indirect + golang.org/x/exp v0.0.0-20240525044651-4c93da0ed11d // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..c684503 --- /dev/null +++ b/go.sum @@ -0,0 +1,18 @@ +github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= +github.com/fxamacker/cbor/v2 v2.6.0 h1:sU6J2usfADwWlYDAFhZBQ6TnLFBHxgesMrQfQgk1tWA= +github.com/fxamacker/cbor/v2 v2.6.0/go.mod h1:pxXPTn3joSm21Gbwsv0w9OSA2y1HFR9qXEeXQVeNoDQ= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= +github.com/vmihailenco/msgpack/v5 v5.4.1 h1:cQriyiUvjTwOHg8QZaPihLWeRAAVoCpE00IUPn0Bjt8= +github.com/vmihailenco/msgpack/v5 v5.4.1/go.mod h1:GaZTsDaehaPpQVyxrf5mtQlH+pc21PIudVV/E3rRQok= +github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g= +github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds= +github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM= +github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg= +github.com/xconnio/wampproto-go v0.0.0-20240526201820-3bc6d812a007 h1:021IcCAUGJ/oRcWdjX2vWM5bfQY/KGXWycrbGTzUbD4= +github.com/xconnio/wampproto-go v0.0.0-20240526201820-3bc6d812a007/go.mod h1:BH0AFRLJ9POvVfxsFd9GyvA15U9o0XYQfq8TdkqO2vQ= +golang.org/x/crypto v0.23.0 h1:dIJU/v2J8Mdglj/8rJ6UUOM3Zc9zLZxVZwwxMooUSAI= +golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8= +golang.org/x/exp v0.0.0-20240525044651-4c93da0ed11d h1:N0hmiNbwsSNwHBAvR3QB5w25pUwH4tK0Y/RltD1j1h4= +golang.org/x/exp v0.0.0-20240525044651-4c93da0ed11d/go.mod h1:XtvwrStGgqGPLc4cjQfWqZHG1YFdYs6swckp8vpsjnc= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=