From eb033bc1cde300f728c786b13b351675e04252b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luka=20Zakraj=C5=A1ek?= Date: Mon, 20 May 2024 17:07:28 +0200 Subject: [PATCH] Add go.mod and GH actions --- .github/workflows/test.yml | 33 +++++++++++++++++++++++++++++++++ LICENSE | 2 +- README.md | 10 +++++++++- example_test.go | 3 ++- go.mod | 3 +++ safeonce_test.go | 3 ++- 6 files changed, 50 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/test.yml create mode 100644 go.mod diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..ffc40a5 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,33 @@ +on: + push: + tags: + - v* + branches: + - master + pull_request: +name: Test +jobs: + test: + strategy: + matrix: + go-version: [1.21.x, 1.22.x] + platform: [ubuntu-latest] + runs-on: ${{ matrix.platform }} + steps: + - name: Install Go + uses: actions/setup-go@v4 + with: + go-version: ${{ matrix.go-version }} + - name: Checkout code + uses: actions/checkout@v3 + - uses: actions/cache@v3 + with: + path: ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + - name: Get dependencies + run: go get ./... + - name: Test + run: | + go test ./... diff --git a/LICENSE b/LICENSE index 505740e..cb672d4 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2015 Koofr +Copyright (c) 2024 Koofr Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index f69b142..b721dc4 100644 --- a/README.md +++ b/README.md @@ -6,4 +6,12 @@ SafeOnce Go package ## Install - go get github.com/koofr/safeonce +```sh +go get github.com/koofr/safeonce +``` + +## Test + +```sh +go test +``` diff --git a/example_test.go b/example_test.go index a37ee39..ff02435 100644 --- a/example_test.go +++ b/example_test.go @@ -2,10 +2,11 @@ package safeonce_test import ( "fmt" + "github.com/koofr/safeonce" ) -func ExampleOnce() { +func ExampleSafeOnce() { var safeOnce safeonce.SafeOnce err := safeOnce.Do(func() error { diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..a82003f --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module github.com/koofr/safeonce + +go 1.21 diff --git a/safeonce_test.go b/safeonce_test.go index 8fec6ba..4168679 100644 --- a/safeonce_test.go +++ b/safeonce_test.go @@ -2,8 +2,9 @@ package safeonce_test import ( "fmt" - . "github.com/koofr/safeonce" "testing" + + . "github.com/koofr/safeonce" ) type one int