• Stars
    star
    102
  • Rank 335,584 (Top 7 %)
  • Language
    Go
  • License
    MIT License
  • Created over 6 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Check that no globals are present in Go code.

gochecknoglobals

test Go Report Card

Check that no globals are present in Go code.

Why

Global variables are an input to functions that is not visible in the functions signature, complicate testing, reduces readability and increase the complexity of code.

https://peter.bourgon.org/blog/2017/06/09/theory-of-modern-go.html https://twitter.com/davecheney/status/871939730761547776

Exceptions

There are very few exceptions to the global variable rule. This tool will ignore the following patterns:

  • Variables with an err or Err prefix that implement the error interface
  • Variables named _
  • Variables named version
  • Variables assigned from regexp.MustCompile()
  • Variables with a //go:embed comment

Install

go install 4d63.com/gochecknoglobals@latest

Usage

The linter is built on Go's analysis package and does thus support all the built in flags and features from this type. The analyzer is executed by specifying packages.

gochecknoglobals [package]
gochecknoglobals ./...

By default, test files are checked but can be excluded by adding the -test=false flag.

gochecknoglobals -test=false [package]

More Repositories

1

vagrant-docker-compose

A Vagrant provisioner for docker compose.
Ruby
656
star
2

docker-unison

A docker data container using Unison for fast folder sync. An alternative to slow boot2docker volumes on OS X.
Shell
167
star
3

AppSandboxFileAccess

A class that wraps up writing and accessing files outside a Mac apps App Sandbox files into a simple interface. The class will request permission from the user with a simple to understand dialog consistent with Apple's documentation and persist permissions across application runs.
Objective-C
112
star
4

looks.wtf

A collection of looks. (▰˘◡˘▰)
JavaScript
101
star
5

vangen

Tool for generating static HTML for Go vanity import paths.
Go
76
star
6

keywords

A list and count of keywords in programming languages.
Go
73
star
7

sshcrypt

Tool for signing/encrypting with the SSH Agent.
Go
52
star
8

gochecknoinits

Check that no init functions are present in Go code.
Go
41
star
9

middleman-cdn

Middleman extension automating invalidation of CloudFlare, MaxCDN, AWS CloudFront, Fastly and Rackspace CDN caches.
Ruby
41
star
10

go-optional

A go package for wrapping types with Optionals to represent the lack of value without pointers.
Go
38
star
11

acceptedlanguages.js

A browser abstraction JavaScript library that tells you page and visitor language information like the accepted languages of the visitor and the current, alternate and relevant languages of the current page.
JavaScript
34
star
12

tldr

Simplified and community-driven man pages (tldr-pages) in a single binary.
Go
32
star
13

go-tz

Go package to predictably load time.Locations regardless of operating system.
Go
30
star
14

dockerhost

A tool for simply creating a docker host vm on macOS.
Shell
16
star
15

embedfiles

Embedfiles embeds files into a map in a Go file.
Go
16
star
16

filecache-ruby

A ruby gem that implements a file-based cache
Ruby
15
star
17

CocoaHash

Categories for NSData and NSString for the hashing algorithms supported by CommonCrypto. MD2, MD4, MD5, SHA1, SHA224, SHA256, SHA384, SHA512.
Objective-C
13
star
18

gas

Check the state of all your git worktrees.
Go
10
star
19

githubcloneall

Clone all github repositories for a user.
Go
10
star
20

windows-10-bash-aliases

Run Bash-on-Ubuntu-on-Windows commands directly from the Windows 10 CMD prompt.
Batchfile
10
star
21

tmux-colours-superhero

A tmux colour theme that likes yellow and shades of grey.
Shell
7
star
22

gaplaylength.js

A Google Analytics plugin that measures engagement with HTML5 audio/video content.
JavaScript
6
star
23

biblestories.org

Bible Stories presents the bible as short stories. Jump in, read a story and share it.
SCSS
6
star
24

clippercard

Tools and packages relating to ClipperCard.
Go
6
star
25

vagrant-docker-login

A Vagrant provisioner for docker login. Login to your docker repository automatically as part of your Vagrant setup.
Ruby
6
star
26

google-cloud-appengine-datastore-replicator

Package and AppEngine app to replicate Datastore across regions.
Go
6
star
27

pdf-page-count

A command line application that will count the number of pages in multiple or individual PDFs. It can recursively traverse multiple directories and sum the total pages.
Ruby
6
star
28

soroban-webauthn

Soroban Webauth Account Contract
JavaScript
6
star
29

dnsovertlsproxy

A simple DNS over TLS proxy.
Go
5
star
30

5tweets

Quickly format multi-tweet tweets!
Ruby
5
star
31

spiffy

A simple to use markdown to HTML and PDF command line app. Supports Github flavored markdown and great for converting single or many documents into professional PDFs using ERB/HAML templates and CSS.
CSS
5
star
32

gocheckcompilerdirectives

Check that go directories (//go: comments) are good.
Go
4
star
33

soroban-fiddle

Displaying data for the Soroban Futurenet.
Rust
4
star
34

devenv

My personal development environment.
4
star
35

go-testparallel

Go package that provides a function for making all tests in a suite run in Parallel without adding t.Parallel() to every test.
Go
4
star
36

vim_dotfiles

My vim dotfiles.
Vim Script
3
star
37

clone

Clone personal GitHub repositories conveniently.
Go
3
star
38

go-collapsewhitespace

Compact multiple whitespace characters in a string into a single space.
Go
3
star
39

acceptedlanguagesui.js

A simple UI that offers your website to your visitor in its alternate languages.
JavaScript
3
star
40

randstr

Tool for generating random strings (e.g. passwords) supporting unicode and emojis.
Go
3
star
41

keybase-bot-weather

Keybase bot that posts weather information to a channel that has asked for it.
Go
2
star
42

dotfiles

Shell
2
star
43

4d63.com

A vanity URL for go packages by Leigh McCulloch.
Makefile
2
star
44

demo-google-cloud-appengine-twirp

A demonstration of how to use twirp on Google Cloud AppEngine.
Go
2
star
45

deno-embed

Embed files into demo applications by embedding them into a JSON file and importing natively into the demo app.
TypeScript
2
star
46

jif.wtf

An alternative to searching for gifs on Giphy.
JavaScript
1
star
47

vscode-extension-status-bar-env-var

TypeScript
1
star
48

docker-helloworld-elixir

Elixir hello world!
Elixir
1
star
49

go-makefile

A go package for parsing makefiles.
Go
1
star
50

exp-solana

Dockerfile
1
star
51

exp-lume

TypeScript
1
star
52

go-uuid

A go package for typing and generating UUIDs.
Go
1
star
53

exp-move

Dockerfile
1
star
54

stellar-quickstart-fly.io

1
star
55

helloworld

Helloworlds in each language, also compiled into minimal docker images.
Elixir
1
star
56

go-structmap

A go package for converting structs to maps, and maps to structs.
Go
1
star
57

zsh-theme-enormous

A zsh theme, that takes up an enormous amount of space in the terminal.
Makefile
1
star
58

go-biblestats

Go
1
star
59

spellingalphabet.xyz

Type a message and get the spelling alphabet to read for it.
JavaScript
1
star
60

sjc

CLI tool for prototyping contracts for Stellar Jump Cannon.
TypeScript
1
star
61

gravitybeam

Go
1
star
62

deplockgomoddiff

A tool for comparing the dependency graph of Go Dep's Gopkg.lock file and the output of Go Modules 'go list -m all' command.
Go
1
star
63

emlx

Email file (.eml) attachment and embedded file extractor.
Go
1
star
64

rssfeedreader

An online RSS feed reader.
Go
1
star
65

gocheckregex

Check that regular expressions in global `MustCompile` calls are valid.
Go
1
star
66

tcpwait

Wait for TCP ports to be open.
Go
1
star
67

makenft

JavaScript
1
star
68

JSMin

JavaScript Minification Filter
C
1
star
69

go-iszero

A go package for checking if a value is zero.
Go
1
star
70

stellar--soroban-transaction-invoke-example

Rust
1
star
71

zig-soroban-sdk

A Soroban SDK for smart contracts written in Zig. Unreleased. Unfit for use. Experimental. Use at your own risk.
Zig
1
star
72

docker-helloworld-go

Go hello world!
Go
1
star
73

kanban-everywhere

Kanban Everywhere is a Windows/Mac application for using Kanban locally without sending data elsewhere. It is an extension of Simple Kanban which saves data to disk and uses appjs to run as a desktop app. Like Simple Kanban, Kanban Everywhere is licensed under MIT. To use just go to the downloads page and download the latest tag and read the README for how to run.
HTML
1
star
74

hasdic

A hashing dictionary application that can create an SQLite based dictionary of hashing to data portions. The data hashed may be text or binary. Something I wrote for fun one way to see how easy or hard it would be without a GPU to produce such a dictionary.
C#
1
star
75

go-errors

Go
1
star
76

parcel-bundler--parcel--issue-5883

JavaScript
1
star