Skip to content
Open
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
105 changes: 105 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
name: CI

on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main ]

jobs:
test-windows:
name: Test on Windows
runs-on: windows-latest

strategy:
matrix:
go-version: [ 'stable', 'oldstable' ]

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Go ${{ matrix.go-version }}
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}

- name: Cache Go modules
uses: actions/cache@v3
with:
path: |
~\AppData\Local\go-build
~\go\pkg\mod
key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-${{ matrix.go-version }}-
${{ runner.os }}-go-

- name: Download dependencies
run: go mod download

- name: Verify dependencies
run: go mod verify

- name: Build
run: go build -v ./...

- name: Run tests
run: go test -v -race -coverprofile="coverage.out" .

- name: Run tests with short flag
run: go test -v -short ./...

- name: Check for vulnerabilities
run: |
go install golang.org/x/vuln/cmd/govulncheck@latest
govulncheck ./...

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
file: ./coverage.out
flags: windows
name: codecov-windows-go${{ matrix.go-version }}
fail_ci_if_error: false

build-cross-platform:
name: Cross-platform build verification
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 'stable'

- name: Build for Windows (amd64)
run: GOOS=windows GOARCH=amd64 go build -v ./...

- name: Build for Windows (arm64)
run: GOOS=windows GOARCH=arm64 go build -v ./...

- name: Test compilation for Windows
run: GOOS=windows go test -c ./...

lint:
name: Lint
runs-on: windows-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 'stable'

- name: Run golangci-lint
uses: golangci/golangci-lint-action@v8
with:
version: latest
args: --timeout=5m
90 changes: 71 additions & 19 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,76 @@
version: "2"
linters:
enable-all: true
default: all
disable:
- golint
- interfacer
- scopelint
- maligned
- rowserrcheck
- funlen
- depguard
- goerr113
- exhaustivestruct
- testpackage
- dupl
- err113
- exhaustruct
- gochecknoglobals
- godot
- ireturn
- mnd
- nlreturn
- paralleltest
- perfsprint
- testpackage
- varnamelen
- wrapcheck
- forbidigo
- ifshort
- cyclop
- gomoddirectives
linters-settings:
exhaustive:
default-signifies-exhaustive: true
issues:
exclude-use-default: false
- wsl
settings:
cyclop:
max-complexity: 20
gosec:
excludes:
- G103
- G115
revive:
rules:
- name: var-naming
disabled: true
- name: exported
disabled: true
exclusions:
generated: lax
rules:
- path: (.+)\.go$
text: var-naming.*VK_
- path: (.+)\.go$
text: var-naming.*FROM_LEFT
- path: (.+)\.go$
text: var-naming.*RIGHT.*_BUTTON
- path: (.+)\.go$
text: var-naming.*CAPS.*_ON
- path: (.+)\.go$
text: var-naming.*ENABLE_
- path: (.+)\.go$
text: var-naming.*MOUSE_
- path: (.+)\.go$
text: var-naming.*DOUBLE_CLICK
- path: (.+)\.go$
text: should have a package comment
- path: (.+)\.go$
text: exported.*should have comment.*VK_
- path: (.+)\.go$
text: exported.*should have comment.*Contains
- path: (.+)\.go$
text: exported.*should have comment.*IsReleased
- path: (.+)\.go$
text: exported.*should have comment.*WheelDirectionName
- path: (.+)\.go$
text: exported.*should have comment.*FlushConsoleInputBuffer
- path: (.+)\.go$
text: comment on exported function.*should be of the form
- path: (.+)\.go$
text: G103.*Use of unsafe calls
- path: (.+)\.go$
text: G115.*integer overflow conversion
- path: (.+)_test\.go$
linters:
- funlen
- wsl_v5
- path: read.go
linters:
- wsl_v5
paths:
- example/main.go
5 changes: 1 addition & 4 deletions example/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,7 @@ func run() (err error) {
ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt)
defer cancel()

for {
if ctx.Err() != nil {
break
}
for ctx.Err() == nil {

events, err := coninput.ReadNConsoleInputs(con, 16)
if err != nil {
Expand Down
6 changes: 4 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module github.com/erikgeiser/coninput

go 1.16
go 1.23.0

require golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e
toolchain go1.23.11

require golang.org/x/sys v0.30.0
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e h1:WUoyKPm6nCo1BnNUvPGnFG3T5DUVem42yDJZZ4CNxMA=
golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc=
golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
1 change: 1 addition & 0 deletions keycodes.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Package coninput provides Go bindings for Windows Console Input API.
package coninput

// VirtualKeyCode holds a virtual key code (see
Expand Down
Loading