diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000000000000000000000000000000000000..4b86d7197f9a6f1a988c503defc8451392cd5e55 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,8 @@ +blank_issues_enabled: false +contact_links: + - name: Getting Help on IPFS + url: https://ipfs.io/help + about: All information about how and where to get help on IPFS. + - name: IPFS Official Forum + url: https://discuss.ipfs.io + about: Please post general questions, support requests, and discussions here. diff --git a/.github/ISSUE_TEMPLATE/open_an_issue.md b/.github/ISSUE_TEMPLATE/open_an_issue.md new file mode 100644 index 0000000000000000000000000000000000000000..4fcbd00aca0d513c2729d8df4afb5a01fdbe7d02 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/open_an_issue.md @@ -0,0 +1,19 @@ +--- +name: Open an issue +about: Only for actionable issues relevant to this repository. +title: '' +labels: need/triage +assignees: '' + +--- + diff --git a/.github/config.yml b/.github/config.yml new file mode 100644 index 0000000000000000000000000000000000000000..ed26646a0f7cdda6cf10ede2b0b98cac89cf67b0 --- /dev/null +++ b/.github/config.yml @@ -0,0 +1,68 @@ +# Configuration for welcome - https://github.com/behaviorbot/welcome + +# Configuration for new-issue-welcome - https://github.com/behaviorbot/new-issue-welcome +# Comment to be posted to on first time issues +newIssueWelcomeComment: > + Thank you for submitting your first issue to this repository! A maintainer + will be here shortly to triage and review. + + In the meantime, please double-check that you have provided all the + necessary information to make this process easy! Any information that can + help save additional round trips is useful! We currently aim to give + initial feedback within **two business days**. If this does not happen, feel + free to leave a comment. + + Please keep an eye on how this issue will be labeled, as labels give an + overview of priorities, assignments and additional actions requested by the + maintainers: + + - "Priority" labels will show how urgent this is for the team. + - "Status" labels will show if this is ready to be worked on, blocked, or in progress. + - "Need" labels will indicate if additional input or analysis is required. + + Finally, remember to use https://discuss.ipfs.io if you just need general + support. + +# Configuration for new-pr-welcome - https://github.com/behaviorbot/new-pr-welcome +# Comment to be posted to on PRs from first time contributors in your repository +newPRWelcomeComment: > + Thank you for submitting this PR! + + A maintainer will be here shortly to review it. + + We are super grateful, but we are also overloaded! Help us by making sure + that: + + * The context for this PR is clear, with relevant discussion, decisions + and stakeholders linked/mentioned. + + * Your contribution itself is clear (code comments, self-review for the + rest) and in its best form. Follow the [code contribution + guidelines](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md#code-contribution-guidelines) + if they apply. + + Getting other community members to do a review would be great help too on + complex PRs (you can ask in the chats/forums). If you are unsure about + something, just leave us a comment. + + Next steps: + + * A maintainer will triage and assign priority to this PR, commenting on + any missing things and potentially assigning a reviewer for high + priority items. + + * The PR gets reviews, discussed and approvals as needed. + + * The PR is merged by maintainers when it has been approved and comments addressed. + + We currently aim to provide initial feedback/triaging within **two business + days**. Please keep an eye on any labelling actions, as these will indicate + priorities and status of your contribution. + + We are very grateful for your contribution! + + +# Configuration for first-pr-merge - https://github.com/behaviorbot/first-pr-merge +# Comment to be posted to on pull requests merged by a first time user +# Currently disabled +#firstPRMergeComment: "" diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000000000000000000000000000000000000..dfab88961c90fd41f90c5ab42b03a552ca342c2d --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,35 @@ +stages: + - build + - test + +variables: + BUILD_DIR: "/tmp/$CI_CONCURRENT_PROJECT_ID" + +before_script: + - mkdir -p $BUILD_DIR/src + - cd $BUILD_DIR/src + - if [ -d $CI_PROJECT_DIR ] + - then + - echo "soft link $CI_PROJECT_DIR exists" + - else + - echo "creating soft link $CI_PROJECT_DIR" + - ln -s $CI_PROJECT_DIR + - fi + - cd $CI_PROJECT_DIR + +build: + stage: build + tags: + - testing + script: + - echo $CI_JOB_STAGE + - go build + +test: + stage: test + tags: + - testing + script: + - echo $CI_JOB_STAGE + - go test -cover + coverage: '/coverage: \d+.\d+% of statements/' diff --git a/.gx/lastpubver b/.gx/lastpubver new file mode 100644 index 0000000000000000000000000000000000000000..8e33029c5c70b59fcb97240b9a8b71fb4d16ff21 --- /dev/null +++ b/.gx/lastpubver @@ -0,0 +1 @@ +1.0.1: Qmf7HqcW7LtCi1W8y2bdx2eJpze74jkbKqpByxgXikdbLF diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000000000000000000000000000000000000..4cfe98c2424d60b3a50d870dc0da5df2ee9243ba --- /dev/null +++ b/.travis.yml @@ -0,0 +1,32 @@ +os: + - linux + +language: go + +go: + - 1.11.x + +env: + global: + - GOTFLAGS="-race" + matrix: + - BUILD_DEPTYPE=gx + - BUILD_DEPTYPE=gomod + + +# disable travis install +install: + - true + +script: + - bash <(curl -s https://raw.githubusercontent.com/ipfs/ci-helpers/master/travis-ci/run-standard-tests.sh) + + +cache: + directories: + - $GOPATH/src/gx + - $GOPATH/pkg/mod + - $HOME/.cache/go-build + +notifications: + email: false diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..c7386b3c940d8aa7baea2dd6fec2908fed562b89 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2014 Juan Batiz-Benet + +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/README.md b/README.md index cdd19158ec1ef642bfb220f11e200a1b5b03aed1..3fd97c6c573803ab7c4206d40253c923cb73ec36 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,36 @@ # go-detect-race +Check if the race detector is running. + +I didnt find a variable to check quickly enough so I made this. + +## Lead Maintainer + +[Steven Allen](https://github.com/Stebalien) + +## Usage + +```go +import ( + detectrace "github.com/jbenet/go-detect-race" +) + +func main() { + if detectrace.WithRace() { + // running with -race + } else { + // running without -race + } +} +``` + +## Why? + +Because the race detector doesnt like massive stress tests. Example: +https://groups.google.com/forum/#!topic/golang-nuts/XDPHUt2LE70 + +## Why didn't you just use... + +Please tell me about a better way of doing this. It wasn't +readily apparent to me, so I made this. But i would much prefer +an env var or some already existing var from the stdlib :) diff --git a/go.mod b/go.mod new file mode 100644 index 0000000000000000000000000000000000000000..1d3b7e413737b4e89f4bc77f7b72d010cee830eb --- /dev/null +++ b/go.mod @@ -0,0 +1 @@ +module gitlab.dms3.io/dms3/public/go-detect-race diff --git a/package.json b/package.json new file mode 100644 index 0000000000000000000000000000000000000000..aaa6a6821942eafd594bd73e325f6b26c0d883f5 --- /dev/null +++ b/package.json @@ -0,0 +1,16 @@ +{ + "author": "jbenet", + "bugs": { + "url": "https://github.com/ipfs/go-detect-race" + }, + "gx": { + "dvcsimport": "github.com/ipfs/go-detect-race" + }, + "gxVersion": "0.10.0", + "language": "go", + "license": "MIT", + "name": "go-detect-race", + "releaseCmd": "git commit -a -m \"gx publish $VERSION\"", + "version": "1.0.1" +} + diff --git a/race.go b/race.go new file mode 100644 index 0000000000000000000000000000000000000000..04639f4bb5da5a9e520f07c332f899e28be879db --- /dev/null +++ b/race.go @@ -0,0 +1,7 @@ +package detectrace + +// WithRace returns whether the binary was compiled +// with the race flag on. +func WithRace() bool { + return withRace +} diff --git a/race_test.go b/race_test.go new file mode 100644 index 0000000000000000000000000000000000000000..2663ba39dcf6fc8f28c4bf5b1805ee5dddea83f2 --- /dev/null +++ b/race_test.go @@ -0,0 +1,9 @@ +package detectrace + +import ( + "testing" +) + +func TestWithRace(t *testing.T) { + t.Logf("WithRace() is %v\n", WithRace()) +} diff --git a/withoutrace.go b/withoutrace.go new file mode 100644 index 0000000000000000000000000000000000000000..958498bbe37727634d676bfcbd6fddef70ac29d4 --- /dev/null +++ b/withoutrace.go @@ -0,0 +1,5 @@ +// +build !race + +package detectrace + +const withRace = false diff --git a/withrace.go b/withrace.go new file mode 100644 index 0000000000000000000000000000000000000000..59f0b03dcf625c90f93d922be935116b04f9523b --- /dev/null +++ b/withrace.go @@ -0,0 +1,5 @@ +// +build race + +package detectrace + +const withRace = true