Help us shape the future of Go! Take the 2026 Go Developer Survey

tenv

package module
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 6, 2021 License: MIT Imports: 8 Imported by: 11

README

tenv

tenv is analyzer that detects environment variable not using t.Setenv

test_and_lint

Instruction

go install github.com/sivchari/tenv/cmd/tenv

Usage

package sandbox_test

import (
        "os"
        "testing"
)

var (
        e = os.Setenv("a", "b")
        _ = e
)

func setup() {
        os.Setenv("a", "b")
        err := os.Setenv("a", "b")
        if err != nil {
                _ = err
        }
}

func TestF(t *testing.T) {
        setup()
        os.Setenv("a", "b")
        if err := os.Setenv("a", "b"); err != nil {
                _ = err
        }
}
fish
go vet -vettool=(which tenv) sandbox_test.go

# command-line-arguments
./sandbox_test.go:9:2: variable e is not using t.Setenv
./sandbox_test.go:14:2: func setup is not using t.Setenv
./sandbox_test.go:15:2: func setup is not using t.Setenv
./sandbox_test.go:23:2: func TestF is not using t.Setenv
./sandbox_test.go:24:2: func TestF is not using t.Setenv
bash
$ go vet -vettool=`which tenv` main.go

# command-line-arguments
./sandbox_test.go:9:2: variable e is not using t.Setenv
./sandbox_test.go:14:2: func setup is not using t.Setenv
./sandbox_test.go:15:2: func setup is not using t.Setenv
./sandbox_test.go:23:2: func TestF is not using t.Setenv
./sandbox_test.go:24:2: func TestF is not using t.Setenv
option

t.Setenv can use since Go1.17. This linter diagnostics, if Go version is since 1.17. But, if you wanna exec this linter in prior Go1.17, you can use it that you set -tenv.f flag.

e.g.

fish
go vet -vettool=(which tenv) -tenv.f sandbox_test.go
bash
go vet -vettool=`which tenv` -tenv.f main.go

CI

CircleCI
- run:
    name: Install tenv
    command: go get github.com/sivchari/tenv

- run:
    name: Run tenv
    command: go vet -vettool=`which tenv` ./...
GitHub Actions
- name: Install tenv
  run: go get github.com/sivchari/tenv

- name: Run tenv
  run: go vet -vettool=`which tenv` ./...

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Analyzer = &analysis.Analyzer{
	Name: "tenv",
	Doc:  doc,
	Run:  run,
	Requires: []*analysis.Analyzer{
		inspect.Analyzer,
	},
}

Analyzer is tenv analyzer

Functions

This section is empty.

Types

This section is empty.

Directories

Path Synopsis
cmd
tenv command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL