From b2e534fa67f89f18c2a68771757c72504940cf11 Mon Sep 17 00:00:00 2001 From: Manuel Doncel Martos Date: Mon, 14 Apr 2025 16:11:37 +0200 Subject: [PATCH 01/13] feat: adding uber style guidelines (WIP) --- 04-uber/.golangci.yml | 233 ++++++++++++++++++++++++++++++++++++++++++ 04-uber/README.md | 135 ++++++++++++++++++++++++ 2 files changed, 368 insertions(+) create mode 100644 04-uber/.golangci.yml create mode 100644 04-uber/README.md diff --git a/04-uber/.golangci.yml b/04-uber/.golangci.yml new file mode 100644 index 0000000..fa0546f --- /dev/null +++ b/04-uber/.golangci.yml @@ -0,0 +1,233 @@ +--- +# golangci-lint configuration file made by @ccoVeille +# Source: https://github.com/ccoVeille/golangci-lint-config-examples/ +# Author: @ccoVeille +# License: MIT +# Variant: 03-safe +# Version: v2.0.0 +# +version: "2" + +formatters: + enable: + # format the code + - gofmt + # format the block of imports + - gci + + settings: + # format the code with Go standard library + gofmt: + # simplify the code + # https://pkg.go.dev/cmd/gofmt#hdr-The_simplify_command + simplify: true + rewrite-rules: + # replace `interface{}` with `any` in the code on format + - pattern: 'interface{}' + replacement: 'any' + + # make sure imports are always in a deterministic order + # https://github.com/daixiang0/gci/ + gci: # define the section orders for imports + sections: + # Standard section: captures all standard packages. + - standard + # Default section: catchall that is not standard or custom + - default + # linters that related to local tool, so they should be separated + - localmodule + +linters: + exclusions: + # these presets where present in the v1 version of golangci-lint + # it's interesting to keep them when migrating, but removing them should be the goal + presets: + # exclude check on comments format in godoc + # These are common false positives in poor code + # you should not use this on recent code you write from scratch + # More information: https://golangci-lint.run/usage/false-positives/#comments + # + # Please uncomment the following line if your code is not using the godoc format + - comments + + # Common false positives + # feel free to remove this if you don't have any false positives + # More information: https://golangci-lint.run/usage/false-positives/#common-false-positives + - common-false-positives + + # Legacy preset is not recommended anymore + # More information: https://golangci-lint.run/usage/false-positives/#legacy + - legacy + + # std-error-handling is a set of rules that avoid reporting unhandled errors on common functions/methods + # More information: https://golangci-lint.run/usage/false-positives/#std-error-handling + - std-error-handling + + # some linters are enabled by default + # https://golangci-lint.run/usage/linters/ + # + # enable some extra linters + enable: + # Errcheck is a program for checking for unchecked errors in Go code. + - errcheck + + # Vet examines Go source code and reports suspicious constructs. + - govet + + # Detects when assignments to existing variables are not used. + - ineffassign + + # It's a set of rules from staticcheck. See https://staticcheck.io/ + - staticcheck + + # Checks Go code for unused constants, variables, functions and types. + - unused + + # Fast, configurable, extensible, flexible, and beautiful linter for Go. + # Drop-in replacement of golint. + - revive + + # make sure to use t.Helper() when needed + - thelper + + # mirror suggests rewrites to avoid unnecessary []byte/string conversion + - mirror + + # detect the possibility to use variables/constants from the Go standard library. + - usestdlibvars + + # Finds commonly misspelled English words. + - misspell + + # Checks for duplicate words in the source code. + - dupword + + # linter to detect errors invalid key values count + - loggercheck + + # detect when a package or method could be replaced by one from the standard library + - exptostd + + # detects nested contexts in loops or function literals + - fatcontext + + # Reports uses of functions with replacement inside the testing package. + - usetesting + + # Follows function/method order described in https://github.com/uber-go/guide/blob/master/style.md#function-grouping-and-ordering + - funcorder + + settings: + revive: + rules: + # these are the default revive rules + # you can remove the whole "rules" node if you want + # BUT + # ! /!\ they all need to be present when you want to add more rules than the default ones + # otherwise, you won't have the default rules, but only the ones you define in the "rules" node + + # Blank import should be only in a main or test package, or have a comment justifying it. + - name: blank-imports + + # context.Context() should be the first parameter of a function when provided as argument. + - name: context-as-argument + arguments: + - allowTypesBefore: "*testing.T" + + # Basic types should not be used as a key in `context.WithValue` + - name: context-keys-type + + # Importing with `.` makes the programs much harder to understand + - name: dot-imports + + # Empty blocks make code less readable and could be a symptom of a bug or unfinished refactoring. + - name: empty-block + + # for better readability, variables of type `error` must be named with the prefix `err`. + - name: error-naming + + # for better readability, the errors should be last in the list of returned values by a function. + - name: error-return + + # for better readability, error messages should not be capitalized or end with punctuation or a newline. + - name: error-strings + + # report when replacing `errors.New(fmt.Sprintf())` with `fmt.Errorf()` is possible + - name: errorf + + # check naming and commenting conventions on exported symbols. + - name: exported + arguments: + # make error messages clearer + - "sayRepetitiveInsteadOfStutters" + + # incrementing an integer variable by 1 is recommended to be done using the `++` operator + - name: increment-decrement + + # highlights redundant else-blocks that can be eliminated from the code + - name: indent-error-flow + + # This rule suggests a shorter way of writing ranges that do not use the second value. + - name: range + + # receiver names in a method should reflect the struct name (p for Person, for example) + - name: receiver-naming + + # redefining built in names (true, false, append, make) can lead to bugs very difficult to detect. + - name: redefines-builtin-id + + # redundant else-blocks that can be eliminated from the code. + - name: superfluous-else + + # prevent confusing name for variables when using `time` package + - name: time-naming + + # warns when an exported function or method returns a value of an un-exported type. + - name: unexported-return + + # spots and proposes to remove unreachable code. also helps to spot errors + - name: unreachable-code + + # Functions or methods with unused parameters can be a symptom of an unfinished refactoring or a bug. + - name: unused-parameter + + # report when a variable declaration can be simplified + - name: var-declaration + + # warns when initialism, variable or package naming conventions are not followed. + - name: var-naming + + misspell: + # Correct spellings using locale preferences for US or UK. + # Setting locale to US will correct the British spelling of 'colour' to 'color'. + # Default ("") is to use a neutral variety of English. + locale: US + + # List of words to ignore + # among the one defined in https://github.com/golangci/misspell/blob/master/words.go + ignore-rules: [] + # - valor + # - and + + # Extra word corrections. + extra-words: [] + # - typo: "whattever" + # correction: "whatever" + +output: + # Order to use when sorting results. + # Possible values: `file`, `linter`, and `severity`. + # + # If the severity values are inside the following list, they are ordered in this order: + # 1. error + # 2. warning + # 3. high + # 4. medium + # 5. low + # Either they are sorted alphabetically. + # + # Default: ["file"] + sort-order: + - linter + - severity + - file # filepath, line, and column. diff --git a/04-uber/README.md b/04-uber/README.md new file mode 100644 index 0000000..cbb92a3 --- /dev/null +++ b/04-uber/README.md @@ -0,0 +1,135 @@ +# Safe Settings + +See [.golangci.yml](.golangci.yml) + +Linter that tries to follow [Uber Style Guidelines](https://github.com/uber-go/guide/blob/master/style.md) + +## License + +License: MIT + +Source: [@ccoVeille](https://github.com/ccoVeille/golangci-lint-config-examples) + +## Enabled formatters +### gofmt + format the code with Go standard library + +### gci + make sure imports are always in a deterministic order + +## Enabled linters + +### errcheck + Errcheck is a program for checking for unchecked errors in Go code. + +### govet + Vet examines Go source code and reports suspicious constructs. + +### ineffassign + Detects when assignments to existing variables are not used. + +### staticcheck + It's a set of rules from staticcheck. See https://staticcheck.io/ + +### unused + Checks Go code for unused constants, variables, functions, and types. + +### thelper + make sure to use `t.Helper()` when needed + +### mirror + mirror suggests rewrites to avoid unnecessary []byte/string conversion + +### usestdlibvars + detect the possibility to use variables/constants from the Go standard library. + +### misspell +Finds commonly misspelled English words. + +### dupword +Checks for duplicate words in the source code. + +### loggercheck +Detects errors invalid key values count + +### fatcontext +Detects nested contexts in loops or function literals + +### exptostd +detect when a package or method could be replaced by one from the standard library + +### usetesting +Reports uses of functions with replacement inside the testing package. + +### revive + Fast, configurable, extensible, flexible, and beautiful linter for Go. + Drop-in replacement of golint. + +#### blank-imports +Blank import should be only in a main or test package, or have a comment justifying it. + +#### context-as-argument +`context.Context()` should be the first parameter of a function when provided as argument. + +#### context-keys-type +Basic types should not be used as a key in `context.WithValue` + +#### dot-imports +Importing with `.` makes the programs much harder to understand + +#### empty-block +Empty blocks make code less readable and could be a symptom of a bug or unfinished refactoring. + +#### error-naming +for better readability, variables of type `error` must be named with the prefix `err`. + +#### error-return +for better readability, the errors should be last in the list of returned values by a function. + +#### error-strings +for better readability, error messages should not be capitalized or end with punctuation or a newline. + +#### errorf +report when replacing `errors.New(fmt.Sprintf())` with `fmt.Errorf()` is possible + +#### exported +check naming and commenting conventions on exported symbols. + +#### increment-decrement +incrementing an integer variable by 1 is recommended to be done using the `++` operator + +#### indent-error-flow +highlights redundant else-blocks that can be eliminated from the code + +#### range +This rule suggests a shorter way of writing ranges that do not use the second value. + +#### receiver-naming +receiver names in a method should reflect the struct name (p for Person, for example) + +#### redefines-builtin-id +redefining built-in names (true, false, append, make) can lead to bugs very difficult to detect. + +#### superfluous-else +redundant else-blocks that can be eliminated from the code. + +#### time-naming +prevent confusing name for variables when using `time` package + +#### unexported-return +warns when an exported function or method returns a value of an un-exported type. + +#### unreachable-code +spots and proposes to remove unreachable code. also helps to spot errors + +#### unused-parameter +Functions or methods with unused parameters can be a symptom of an unfinished refactoring or a bug. + +#### var-declaration +report when a variable declaration can be simplified + +#### var-naming +warns when initialism, variable or package naming conventions are not followed. + +#### funcorder +linter that checks function and method order. From 4039e8a6ce67fee8a1c89f06ece9569316c0a166 Mon Sep 17 00:00:00 2001 From: Manuel Doncel Martos Date: Tue, 15 Apr 2025 01:39:26 +0200 Subject: [PATCH 02/13] WIP: applying some comments --- 04-uber/.golangci.yml | 10 ++- 04-uber/README.md | 187 +++++++++++++++--------------------------- 2 files changed, 71 insertions(+), 126 deletions(-) diff --git a/04-uber/.golangci.yml b/04-uber/.golangci.yml index fa0546f..8a14e6f 100644 --- a/04-uber/.golangci.yml +++ b/04-uber/.golangci.yml @@ -1,10 +1,10 @@ --- # golangci-lint configuration file made by @ccoVeille # Source: https://github.com/ccoVeille/golangci-lint-config-examples/ -# Author: @ccoVeille +# Author: @ccoVeille & @manuelarte # License: MIT -# Variant: 03-safe -# Version: v2.0.0 +# Variant: 04-uber +# Version: v2.1.0 # version: "2" @@ -137,6 +137,10 @@ linters: # Basic types should not be used as a key in `context.WithValue` - name: context-keys-type + # This rule looks for program exits in functions other than main() or init() + # https://github.com/uber-go/guide/blob/master/style.md#exit-in-main + - name: deep-exit + # Importing with `.` makes the programs much harder to understand - name: dot-imports diff --git a/04-uber/README.md b/04-uber/README.md index cbb92a3..f20dc89 100644 --- a/04-uber/README.md +++ b/04-uber/README.md @@ -10,126 +10,67 @@ License: MIT Source: [@ccoVeille](https://github.com/ccoVeille/golangci-lint-config-examples) -## Enabled formatters -### gofmt - format the code with Go standard library - -### gci - make sure imports are always in a deterministic order - -## Enabled linters - -### errcheck - Errcheck is a program for checking for unchecked errors in Go code. - -### govet - Vet examines Go source code and reports suspicious constructs. - -### ineffassign - Detects when assignments to existing variables are not used. - -### staticcheck - It's a set of rules from staticcheck. See https://staticcheck.io/ - -### unused - Checks Go code for unused constants, variables, functions, and types. - -### thelper - make sure to use `t.Helper()` when needed - -### mirror - mirror suggests rewrites to avoid unnecessary []byte/string conversion - -### usestdlibvars - detect the possibility to use variables/constants from the Go standard library. - -### misspell -Finds commonly misspelled English words. - -### dupword -Checks for duplicate words in the source code. - -### loggercheck -Detects errors invalid key values count - -### fatcontext -Detects nested contexts in loops or function literals - -### exptostd -detect when a package or method could be replaced by one from the standard library - -### usetesting -Reports uses of functions with replacement inside the testing package. - -### revive - Fast, configurable, extensible, flexible, and beautiful linter for Go. - Drop-in replacement of golint. - -#### blank-imports -Blank import should be only in a main or test package, or have a comment justifying it. - -#### context-as-argument -`context.Context()` should be the first parameter of a function when provided as argument. - -#### context-keys-type -Basic types should not be used as a key in `context.WithValue` - -#### dot-imports -Importing with `.` makes the programs much harder to understand - -#### empty-block -Empty blocks make code less readable and could be a symptom of a bug or unfinished refactoring. - -#### error-naming -for better readability, variables of type `error` must be named with the prefix `err`. - -#### error-return -for better readability, the errors should be last in the list of returned values by a function. - -#### error-strings -for better readability, error messages should not be capitalized or end with punctuation or a newline. - -#### errorf -report when replacing `errors.New(fmt.Sprintf())` with `fmt.Errorf()` is possible - -#### exported -check naming and commenting conventions on exported symbols. - -#### increment-decrement -incrementing an integer variable by 1 is recommended to be done using the `++` operator - -#### indent-error-flow -highlights redundant else-blocks that can be eliminated from the code - -#### range -This rule suggests a shorter way of writing ranges that do not use the second value. - -#### receiver-naming -receiver names in a method should reflect the struct name (p for Person, for example) - -#### redefines-builtin-id -redefining built-in names (true, false, append, make) can lead to bugs very difficult to detect. - -#### superfluous-else -redundant else-blocks that can be eliminated from the code. - -#### time-naming -prevent confusing name for variables when using `time` package - -#### unexported-return -warns when an exported function or method returns a value of an un-exported type. - -#### unreachable-code -spots and proposes to remove unreachable code. also helps to spot errors - -#### unused-parameter -Functions or methods with unused parameters can be a symptom of an unfinished refactoring or a bug. - -#### var-declaration -report when a variable declaration can be simplified - -#### var-naming -warns when initialism, variable or package naming conventions are not followed. - -#### funcorder -linter that checks function and method order. +## Uber Style Guidelines + +- [Guidelines](#guidelines) + - [Pointers to Interfaces](#pointers-to-interfaces) + - [Verify Interface Compliance](#verify-interface-compliance) + - [Receivers and Interfaces](#receivers-and-interfaces) + - [Zero-value Mutexes are Valid](#zero-value-mutexes-are-valid) + - [Copy Slices and Maps at Boundaries](#copy-slices-and-maps-at-boundaries) + - [Defer to Clean Up](#defer-to-clean-up) + - [Channel Size is One or None](#channel-size-is-one-or-none) + - [Start Enums at One](#start-enums-at-one) + - [Use `"time"` to handle time](#use-time-to-handle-time) + - [Errors](#errors) + - [Error Types](#error-types) + - [Error Wrapping](#error-wrapping) + - [Error Naming](#error-naming) + - [Handle Errors Once](#handle-errors-once) + - [Handle Type Assertion Failures](#handle-type-assertion-failures) + - [Don't Panic](#dont-panic) + - [Use go.uber.org/atomic](#use-gouberorgatomic) + - [Avoid Mutable Globals](#avoid-mutable-globals) + - [Avoid Embedding Types in Public Structs](#avoid-embedding-types-in-public-structs) + - [Avoid Using Built-In Names](#avoid-using-built-in-names) + - [Avoid `init()`](#avoid-init) + [x] [Exit in Main](#exit-in-main) - Style applied through revive.deep-exit. + - [Use field tags in marshaled structs](#use-field-tags-in-marshaled-structs) + - [Don't fire-and-forget goroutines](#dont-fire-and-forget-goroutines) + - [Wait for goroutines to exit](#wait-for-goroutines-to-exit) + - [No goroutines in `init()`](#no-goroutines-in-init) +- [Performance](#performance) + - [Prefer strconv over fmt](#prefer-strconv-over-fmt) + - [Avoid repeated string-to-byte conversions](#avoid-repeated-string-to-byte-conversions) + - [Prefer Specifying Container Capacity](#prefer-specifying-container-capacity) +- [Style](#style) + - [Avoid overly long lines](#avoid-overly-long-lines) + - [Be Consistent](#be-consistent) + - [Group Similar Declarations](#group-similar-declarations) + - [Import Group Ordering](#import-group-ordering) + - [Package Names](#package-names) + - [Function Names](#function-names) + - [Import Aliasing](#import-aliasing) + [x] [Function Grouping and Ordering](#function-grouping-and-ordering) - Style applied through linter `funcorder`. + - [Reduce Nesting](#reduce-nesting) + - [Unnecessary Else](#unnecessary-else) + - [Top-level Variable Declarations](#top-level-variable-declarations) + - [Prefix Unexported Globals with _](#prefix-unexported-globals-with-_) + - [Embedding in Structs](#embedding-in-structs) + - [Local Variable Declarations](#local-variable-declarations) + - [nil is a valid slice](#nil-is-a-valid-slice) + - [Reduce Scope of Variables](#reduce-scope-of-variables) + - [Avoid Naked Parameters](#avoid-naked-parameters) + - [Use Raw String Literals to Avoid Escaping](#use-raw-string-literals-to-avoid-escaping) + - [Initializing Structs](#initializing-structs) + - [Use Field Names to Initialize Structs](#use-field-names-to-initialize-structs) + - [Omit Zero Value Fields in Structs](#omit-zero-value-fields-in-structs) + - [Use `var` for Zero Value Structs](#use-var-for-zero-value-structs) + - [Initializing Struct References](#initializing-struct-references) + - [Initializing Maps](#initializing-maps) + - [Format Strings outside Printf](#format-strings-outside-printf) + - [Naming Printf-style Functions](#naming-printf-style-functions) +- [Patterns](#patterns) + - [Test Tables](#test-tables) + - [Functional Options](#functional-options) +- [Linting](#linting) From 555891d171ea8e4cddd2a70fe8135ffbc2ab7d22 Mon Sep 17 00:00:00 2001 From: Manuel Doncel Martos Date: Wed, 16 Apr 2025 15:03:41 +0200 Subject: [PATCH 03/13] feat: adding uber style guidelines (WIP) (don't panic and avoid init()) --- 04-uber/.golangci.yml | 10 ++++++++++ 04-uber/README.md | 6 +++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/04-uber/.golangci.yml b/04-uber/.golangci.yml index 8a14e6f..7e5792a 100644 --- a/04-uber/.golangci.yml +++ b/04-uber/.golangci.yml @@ -118,6 +118,16 @@ linters: - funcorder settings: + forbidigo: + forbid: + # Don't panic https://github.com/uber-go/guide/blob/master/style.md#dont-panic + - pattern: ^panic(ln)$ + msg: Panics are a major source of cascading failures. + # Avoid init() https://github.com/uber-go/guide/blob/master/style.md#avoid-init + - pattern: ^init(ln)$ + msg: Panics are a major source of cascading failures. + + revive: rules: # these are the default revive rules diff --git a/04-uber/README.md b/04-uber/README.md index f20dc89..dc34b57 100644 --- a/04-uber/README.md +++ b/04-uber/README.md @@ -28,13 +28,13 @@ Source: [@ccoVeille](https://github.com/ccoVeille/golangci-lint-config-examples) - [Error Naming](#error-naming) - [Handle Errors Once](#handle-errors-once) - [Handle Type Assertion Failures](#handle-type-assertion-failures) - - [Don't Panic](#dont-panic) + [x] [Don't Panic](#dont-panic) - Style applied through `forbidigo`. - [Use go.uber.org/atomic](#use-gouberorgatomic) - [Avoid Mutable Globals](#avoid-mutable-globals) - [Avoid Embedding Types in Public Structs](#avoid-embedding-types-in-public-structs) - [Avoid Using Built-In Names](#avoid-using-built-in-names) - - [Avoid `init()`](#avoid-init) - [x] [Exit in Main](#exit-in-main) - Style applied through revive.deep-exit. + [x] [Avoid `init()`](#avoid-init) - Style applied through `forbidigo`. + [x] [Exit in Main](#exit-in-main) - Style applied through `revive.deep-exit`. - [Use field tags in marshaled structs](#use-field-tags-in-marshaled-structs) - [Don't fire-and-forget goroutines](#dont-fire-and-forget-goroutines) - [Wait for goroutines to exit](#wait-for-goroutines-to-exit) From 2ca57d63221d24146d01960db5ddf518a10143a1 Mon Sep 17 00:00:00 2001 From: Manuel Doncel Martos Date: Wed, 16 Apr 2025 18:16:49 +0200 Subject: [PATCH 04/13] WIP: applying some comments --- 04-uber/.golangci.yml | 7 +++---- 04-uber/README.md | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/04-uber/.golangci.yml b/04-uber/.golangci.yml index 7e5792a..3e2cf0d 100644 --- a/04-uber/.golangci.yml +++ b/04-uber/.golangci.yml @@ -117,16 +117,15 @@ linters: # Follows function/method order described in https://github.com/uber-go/guide/blob/master/style.md#function-grouping-and-ordering - funcorder + # Avoid init() https://github.com/uber-go/guide/blob/master/style.md#avoid-init + - gochecknoinits + settings: forbidigo: forbid: # Don't panic https://github.com/uber-go/guide/blob/master/style.md#dont-panic - pattern: ^panic(ln)$ msg: Panics are a major source of cascading failures. - # Avoid init() https://github.com/uber-go/guide/blob/master/style.md#avoid-init - - pattern: ^init(ln)$ - msg: Panics are a major source of cascading failures. - revive: rules: diff --git a/04-uber/README.md b/04-uber/README.md index dc34b57..edade31 100644 --- a/04-uber/README.md +++ b/04-uber/README.md @@ -33,7 +33,7 @@ Source: [@ccoVeille](https://github.com/ccoVeille/golangci-lint-config-examples) - [Avoid Mutable Globals](#avoid-mutable-globals) - [Avoid Embedding Types in Public Structs](#avoid-embedding-types-in-public-structs) - [Avoid Using Built-In Names](#avoid-using-built-in-names) - [x] [Avoid `init()`](#avoid-init) - Style applied through `forbidigo`. + [x] [Avoid `init()`](#avoid-init) - Style applied through `gochecknoinits`. [x] [Exit in Main](#exit-in-main) - Style applied through `revive.deep-exit`. - [Use field tags in marshaled structs](#use-field-tags-in-marshaled-structs) - [Don't fire-and-forget goroutines](#dont-fire-and-forget-goroutines) From 48f46dab9852e616ae0ed80cca0f000fa6b8dc4d Mon Sep 17 00:00:00 2001 From: Manuel Doncel Martos Date: Thu, 24 Apr 2025 21:29:09 +0200 Subject: [PATCH 05/13] WIP: applying some comments --- 04-uber/.golangci.yml | 24 ------------------------ 04-uber/README.md | 2 +- 2 files changed, 1 insertion(+), 25 deletions(-) diff --git a/04-uber/.golangci.yml b/04-uber/.golangci.yml index 3e2cf0d..193d617 100644 --- a/04-uber/.golangci.yml +++ b/04-uber/.golangci.yml @@ -129,12 +129,6 @@ linters: revive: rules: - # these are the default revive rules - # you can remove the whole "rules" node if you want - # BUT - # ! /!\ they all need to be present when you want to add more rules than the default ones - # otherwise, you won't have the default rules, but only the ones you define in the "rules" node - # Blank import should be only in a main or test package, or have a comment justifying it. - name: blank-imports @@ -226,21 +220,3 @@ linters: extra-words: [] # - typo: "whattever" # correction: "whatever" - -output: - # Order to use when sorting results. - # Possible values: `file`, `linter`, and `severity`. - # - # If the severity values are inside the following list, they are ordered in this order: - # 1. error - # 2. warning - # 3. high - # 4. medium - # 5. low - # Either they are sorted alphabetically. - # - # Default: ["file"] - sort-order: - - linter - - severity - - file # filepath, line, and column. diff --git a/04-uber/README.md b/04-uber/README.md index edade31..8ed604d 100644 --- a/04-uber/README.md +++ b/04-uber/README.md @@ -12,7 +12,7 @@ Source: [@ccoVeille](https://github.com/ccoVeille/golangci-lint-config-examples) ## Uber Style Guidelines -- [Guidelines](#guidelines) +- [Guidelines](https://github.com/uber-go/guide/blob/master/style.md#guidelines) - [Pointers to Interfaces](#pointers-to-interfaces) - [Verify Interface Compliance](#verify-interface-compliance) - [Receivers and Interfaces](#receivers-and-interfaces) From ae4a09c3b296e0bddc257d0764bf3ca2b4289500 Mon Sep 17 00:00:00 2001 From: Manuel Doncel Martos Date: Thu, 24 Apr 2025 21:40:20 +0200 Subject: [PATCH 06/13] WIP: errname and lll --- 04-uber/.golangci.yml | 13 ++++++++++--- 04-uber/README.md | 4 ++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/04-uber/.golangci.yml b/04-uber/.golangci.yml index 193d617..f4c5f3a 100644 --- a/04-uber/.golangci.yml +++ b/04-uber/.golangci.yml @@ -71,6 +71,9 @@ linters: # Errcheck is a program for checking for unchecked errors in Go code. - errcheck + # Errname Checks that sentinel errors are prefixed with the Err and error types are suffixed with the Error + - errname + # Vet examines Go source code and reports suspicious constructs. - govet @@ -102,6 +105,9 @@ linters: # Checks for duplicate words in the source code. - dupword + # LLL Reports long lines. + - lll + # linter to detect errors invalid key values count - loggercheck @@ -114,10 +120,10 @@ linters: # Reports uses of functions with replacement inside the testing package. - usetesting - # Follows function/method order described in https://github.com/uber-go/guide/blob/master/style.md#function-grouping-and-ordering + # Funcorder Follows function/method order described in https://github.com/uber-go/guide/blob/master/style.md#function-grouping-and-ordering - funcorder - # Avoid init() https://github.com/uber-go/guide/blob/master/style.md#avoid-init + # GoCheckNoInits Avoid init() https://github.com/uber-go/guide/blob/master/style.md#avoid-init - gochecknoinits settings: @@ -126,7 +132,8 @@ linters: # Don't panic https://github.com/uber-go/guide/blob/master/style.md#dont-panic - pattern: ^panic(ln)$ msg: Panics are a major source of cascading failures. - + lll: + line-length: 99 revive: rules: # Blank import should be only in a main or test package, or have a comment justifying it. diff --git a/04-uber/README.md b/04-uber/README.md index 8ed604d..e181aa7 100644 --- a/04-uber/README.md +++ b/04-uber/README.md @@ -25,7 +25,7 @@ Source: [@ccoVeille](https://github.com/ccoVeille/golangci-lint-config-examples) - [Errors](#errors) - [Error Types](#error-types) - [Error Wrapping](#error-wrapping) - - [Error Naming](#error-naming) + [x] [Error Naming](#error-naming) - Style applied through `errname` - [Handle Errors Once](#handle-errors-once) - [Handle Type Assertion Failures](#handle-type-assertion-failures) [x] [Don't Panic](#dont-panic) - Style applied through `forbidigo`. @@ -44,7 +44,7 @@ Source: [@ccoVeille](https://github.com/ccoVeille/golangci-lint-config-examples) - [Avoid repeated string-to-byte conversions](#avoid-repeated-string-to-byte-conversions) - [Prefer Specifying Container Capacity](#prefer-specifying-container-capacity) - [Style](#style) - - [Avoid overly long lines](#avoid-overly-long-lines) + [x] [Avoid overly long lines](#avoid-overly-long-lines) - Style applied through `lll` - [Be Consistent](#be-consistent) - [Group Similar Declarations](#group-similar-declarations) - [Import Group Ordering](#import-group-ordering) From d17483d93647aaf13528514c261a8ab7b2aeef63 Mon Sep 17 00:00:00 2001 From: Manuel Doncel Martos Date: Thu, 24 Apr 2025 21:45:47 +0200 Subject: [PATCH 07/13] WIP: perfsprint --- 04-uber/.golangci.yml | 3 +++ 04-uber/README.md | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/04-uber/.golangci.yml b/04-uber/.golangci.yml index f4c5f3a..da454f7 100644 --- a/04-uber/.golangci.yml +++ b/04-uber/.golangci.yml @@ -126,6 +126,9 @@ linters: # GoCheckNoInits Avoid init() https://github.com/uber-go/guide/blob/master/style.md#avoid-init - gochecknoinits + # Perfsprint Checks that fmt.Sprintf can be replaced with a faster alternative. + - perfsprint + settings: forbidigo: forbid: diff --git a/04-uber/README.md b/04-uber/README.md index e181aa7..796b9dd 100644 --- a/04-uber/README.md +++ b/04-uber/README.md @@ -40,7 +40,7 @@ Source: [@ccoVeille](https://github.com/ccoVeille/golangci-lint-config-examples) - [Wait for goroutines to exit](#wait-for-goroutines-to-exit) - [No goroutines in `init()`](#no-goroutines-in-init) - [Performance](#performance) - - [Prefer strconv over fmt](#prefer-strconv-over-fmt) + [x] [Prefer strconv over fmt](#prefer-strconv-over-fmt) - Style applied through `perfsprint` - [Avoid repeated string-to-byte conversions](#avoid-repeated-string-to-byte-conversions) - [Prefer Specifying Container Capacity](#prefer-specifying-container-capacity) - [Style](#style) From eb3a374caf848168431f094e3e725edb481f0b34 Mon Sep 17 00:00:00 2001 From: Manuel Doncel Martos Date: Thu, 24 Apr 2025 21:48:26 +0200 Subject: [PATCH 08/13] WIP: formatting README.md --- 04-uber/README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/04-uber/README.md b/04-uber/README.md index 796b9dd..7a25e2e 100644 --- a/04-uber/README.md +++ b/04-uber/README.md @@ -25,33 +25,33 @@ Source: [@ccoVeille](https://github.com/ccoVeille/golangci-lint-config-examples) - [Errors](#errors) - [Error Types](#error-types) - [Error Wrapping](#error-wrapping) - [x] [Error Naming](#error-naming) - Style applied through `errname` + - [x] [Error Naming](#error-naming) - Style applied through `errname` - [Handle Errors Once](#handle-errors-once) - [Handle Type Assertion Failures](#handle-type-assertion-failures) - [x] [Don't Panic](#dont-panic) - Style applied through `forbidigo`. + - [x] [Don't Panic](#dont-panic) - Style applied through `forbidigo`. - [Use go.uber.org/atomic](#use-gouberorgatomic) - [Avoid Mutable Globals](#avoid-mutable-globals) - [Avoid Embedding Types in Public Structs](#avoid-embedding-types-in-public-structs) - [Avoid Using Built-In Names](#avoid-using-built-in-names) - [x] [Avoid `init()`](#avoid-init) - Style applied through `gochecknoinits`. - [x] [Exit in Main](#exit-in-main) - Style applied through `revive.deep-exit`. + - [x] [Avoid `init()`](#avoid-init) - Style applied through `gochecknoinits`. + - [x] [Exit in Main](#exit-in-main) - Style applied through `revive.deep-exit`. - [Use field tags in marshaled structs](#use-field-tags-in-marshaled-structs) - [Don't fire-and-forget goroutines](#dont-fire-and-forget-goroutines) - [Wait for goroutines to exit](#wait-for-goroutines-to-exit) - [No goroutines in `init()`](#no-goroutines-in-init) - [Performance](#performance) - [x] [Prefer strconv over fmt](#prefer-strconv-over-fmt) - Style applied through `perfsprint` + - [x] [Prefer strconv over fmt](#prefer-strconv-over-fmt) - Style applied through `perfsprint` - [Avoid repeated string-to-byte conversions](#avoid-repeated-string-to-byte-conversions) - [Prefer Specifying Container Capacity](#prefer-specifying-container-capacity) - [Style](#style) - [x] [Avoid overly long lines](#avoid-overly-long-lines) - Style applied through `lll` + - [x] [Avoid overly long lines](#avoid-overly-long-lines) - Style applied through `lll` - [Be Consistent](#be-consistent) - [Group Similar Declarations](#group-similar-declarations) - [Import Group Ordering](#import-group-ordering) - [Package Names](#package-names) - [Function Names](#function-names) - [Import Aliasing](#import-aliasing) - [x] [Function Grouping and Ordering](#function-grouping-and-ordering) - Style applied through linter `funcorder`. + - [x] [Function Grouping and Ordering](#function-grouping-and-ordering) - Style applied through linter `funcorder`. - [Reduce Nesting](#reduce-nesting) - [Unnecessary Else](#unnecessary-else) - [Top-level Variable Declarations](#top-level-variable-declarations) From 2880c7bca584f398d350ea1dd37d6194e9e2070f Mon Sep 17 00:00:00 2001 From: Manuel Doncel Martos Date: Thu, 24 Apr 2025 22:32:59 +0200 Subject: [PATCH 09/13] WIP: fixing readme links --- 04-uber/README.md | 118 +++++++++++++++++++++++----------------------- 1 file changed, 59 insertions(+), 59 deletions(-) diff --git a/04-uber/README.md b/04-uber/README.md index 7a25e2e..9795a9a 100644 --- a/04-uber/README.md +++ b/04-uber/README.md @@ -13,64 +13,64 @@ Source: [@ccoVeille](https://github.com/ccoVeille/golangci-lint-config-examples) ## Uber Style Guidelines - [Guidelines](https://github.com/uber-go/guide/blob/master/style.md#guidelines) - - [Pointers to Interfaces](#pointers-to-interfaces) - - [Verify Interface Compliance](#verify-interface-compliance) - - [Receivers and Interfaces](#receivers-and-interfaces) - - [Zero-value Mutexes are Valid](#zero-value-mutexes-are-valid) - - [Copy Slices and Maps at Boundaries](#copy-slices-and-maps-at-boundaries) - - [Defer to Clean Up](#defer-to-clean-up) - - [Channel Size is One or None](#channel-size-is-one-or-none) - - [Start Enums at One](#start-enums-at-one) - - [Use `"time"` to handle time](#use-time-to-handle-time) - - [Errors](#errors) - - [Error Types](#error-types) - - [Error Wrapping](#error-wrapping) - - [x] [Error Naming](#error-naming) - Style applied through `errname` + - [Pointers to Interfaces](https://github.com/uber-go/guide/blob/master/style.md#pointers-to-interfaces) + - [Verify Interface Compliance](https://github.com/uber-go/guide/blob/master/style.md#verify-interface-compliance) + - [Receivers and Interfaces](https://github.com/uber-go/guide/blob/master/style.md#receivers-and-interfaces) + - [Zero-value Mutexes are Valid](https://github.com/uber-go/guide/blob/master/style.md#zero-value-mutexes-are-valid) + - [Copy Slices and Maps at Boundaries](https://github.com/uber-go/guide/blob/master/style.md#copy-slices-and-maps-at-boundaries) + - [Defer to Clean Up](https://github.com/uber-go/guide/blob/master/style.md#defer-to-clean-up) + - [Channel Size is One or None](https://github.com/uber-go/guide/blob/master/style.md#channel-size-is-one-or-none) + - [Start Enums at One](https://github.com/uber-go/guide/blob/master/style.md#start-enums-at-one) + - [Use `"time"` to handle time](https://github.com/uber-go/guide/blob/master/style.md#use-time-to-handle-time) + - [Errors](https://github.com/uber-go/guide/blob/master/style.md#errors) + - [Error Types](https://github.com/uber-go/guide/blob/master/style.md#error-types) + - [Error Wrapping](https://github.com/uber-go/guide/blob/master/style.md#error-wrapping) + - [x] [Error Naming](https://github.com/uber-go/guide/blob/master/style.md#error-naming) - Style applied through `errname` - [Handle Errors Once](#handle-errors-once) - [Handle Type Assertion Failures](#handle-type-assertion-failures) - - [x] [Don't Panic](#dont-panic) - Style applied through `forbidigo`. - - [Use go.uber.org/atomic](#use-gouberorgatomic) - - [Avoid Mutable Globals](#avoid-mutable-globals) - - [Avoid Embedding Types in Public Structs](#avoid-embedding-types-in-public-structs) - - [Avoid Using Built-In Names](#avoid-using-built-in-names) - - [x] [Avoid `init()`](#avoid-init) - Style applied through `gochecknoinits`. - - [x] [Exit in Main](#exit-in-main) - Style applied through `revive.deep-exit`. - - [Use field tags in marshaled structs](#use-field-tags-in-marshaled-structs) - - [Don't fire-and-forget goroutines](#dont-fire-and-forget-goroutines) - - [Wait for goroutines to exit](#wait-for-goroutines-to-exit) - - [No goroutines in `init()`](#no-goroutines-in-init) -- [Performance](#performance) - - [x] [Prefer strconv over fmt](#prefer-strconv-over-fmt) - Style applied through `perfsprint` - - [Avoid repeated string-to-byte conversions](#avoid-repeated-string-to-byte-conversions) - - [Prefer Specifying Container Capacity](#prefer-specifying-container-capacity) -- [Style](#style) - - [x] [Avoid overly long lines](#avoid-overly-long-lines) - Style applied through `lll` - - [Be Consistent](#be-consistent) - - [Group Similar Declarations](#group-similar-declarations) - - [Import Group Ordering](#import-group-ordering) - - [Package Names](#package-names) - - [Function Names](#function-names) - - [Import Aliasing](#import-aliasing) - - [x] [Function Grouping and Ordering](#function-grouping-and-ordering) - Style applied through linter `funcorder`. - - [Reduce Nesting](#reduce-nesting) - - [Unnecessary Else](#unnecessary-else) - - [Top-level Variable Declarations](#top-level-variable-declarations) - - [Prefix Unexported Globals with _](#prefix-unexported-globals-with-_) - - [Embedding in Structs](#embedding-in-structs) - - [Local Variable Declarations](#local-variable-declarations) - - [nil is a valid slice](#nil-is-a-valid-slice) - - [Reduce Scope of Variables](#reduce-scope-of-variables) - - [Avoid Naked Parameters](#avoid-naked-parameters) - - [Use Raw String Literals to Avoid Escaping](#use-raw-string-literals-to-avoid-escaping) - - [Initializing Structs](#initializing-structs) - - [Use Field Names to Initialize Structs](#use-field-names-to-initialize-structs) - - [Omit Zero Value Fields in Structs](#omit-zero-value-fields-in-structs) - - [Use `var` for Zero Value Structs](#use-var-for-zero-value-structs) - - [Initializing Struct References](#initializing-struct-references) - - [Initializing Maps](#initializing-maps) - - [Format Strings outside Printf](#format-strings-outside-printf) - - [Naming Printf-style Functions](#naming-printf-style-functions) -- [Patterns](#patterns) - - [Test Tables](#test-tables) - - [Functional Options](#functional-options) -- [Linting](#linting) + - [x] [Don't Panic](https://github.com/uber-go/guide/blob/master/style.md#dont-panic) - Style applied through `forbidigo`. + - [Use go.uber.org/atomic](https://github.com/uber-go/guide/blob/master/style.md#use-gouberorgatomic) + - [Avoid Mutable Globals](https://github.com/uber-go/guide/blob/master/style.md#avoid-mutable-globals) + - [Avoid Embedding Types in Public Structs](https://github.com/uber-go/guide/blob/master/style.md#avoid-embedding-types-in-public-structs) + - [Avoid Using Built-In Names](https://github.com/uber-go/guide/blob/master/style.md#avoid-using-built-in-names) + - [x] [Avoid `init()`](https://github.com/uber-go/guide/blob/master/style.md#avoid-init) - Style applied through `gochecknoinits`. + - [x] [Exit in Main](https://github.com/uber-go/guide/blob/master/style.md#exit-in-main) - Style applied through `revive.deep-exit`. + - [Use field tags in marshaled structs](https://github.com/uber-go/guide/blob/master/style.md#use-field-tags-in-marshaled-structs) + - [Don't fire-and-forget goroutines](https://github.com/uber-go/guide/blob/master/style.md#dont-fire-and-forget-goroutines) + - [Wait for goroutines to exit](https://github.com/uber-go/guide/blob/master/style.md#wait-for-goroutines-to-exit) + - [No goroutines in `init()`](https://github.com/uber-go/guide/blob/master/style.md#no-goroutines-in-init) +- [Performance](https://github.com/uber-go/guide/blob/master/style.md#performance) + - [x] [Prefer strconv over fmt](https://github.com/uber-go/guide/blob/master/style.md#prefer-strconv-over-fmt) - Style applied through `perfsprint` + - [Avoid repeated string-to-byte conversions](https://github.com/uber-go/guide/blob/master/style.md#avoid-repeated-string-to-byte-conversions) + - [Prefer Specifying Container Capacity](https://github.com/uber-go/guide/blob/master/style.md#prefer-specifying-container-capacity) +- [Style](https://github.com/uber-go/guide/blob/master/style.md#style) + - [x] [Avoid overly long lines](https://github.com/uber-go/guide/blob/master/style.md#avoid-overly-long-lines) - Style applied through `lll` + - [Be Consistent](https://github.com/uber-go/guide/blob/master/style.md#be-consistent) + - [Group Similar Declarations](https://github.com/uber-go/guide/blob/master/style.md#group-similar-declarations) + - [Import Group Ordering](https://github.com/uber-go/guide/blob/master/style.md#import-group-ordering) + - [Package Names](https://github.com/uber-go/guide/blob/master/style.md#package-names) + - [Function Names](https://github.com/uber-go/guide/blob/master/style.md#function-names) + - [Import Aliasing](https://github.com/uber-go/guide/blob/master/style.md#import-aliasing) + - [x] [Function Grouping and Ordering](https://github.com/uber-go/guide/blob/master/style.md#function-grouping-and-ordering) - Style applied through linter `funcorder`. + - [Reduce Nesting](https://github.com/uber-go/guide/blob/master/style.md#reduce-nesting) + - [Unnecessary Else](https://github.com/uber-go/guide/blob/master/style.md#unnecessary-else) + - [Top-level Variable Declarations](https://github.com/uber-go/guide/blob/master/style.md#top-level-variable-declarations) + - [Prefix Unexported Globals with _](https://github.com/uber-go/guide/blob/master/style.md#prefix-unexported-globals-with-_) + - [Embedding in Structs](https://github.com/uber-go/guide/blob/master/style.md#embedding-in-structs) + - [Local Variable Declarations](https://github.com/uber-go/guide/blob/master/style.md#local-variable-declarations) + - [nil is a valid slice](https://github.com/uber-go/guide/blob/master/style.md#nil-is-a-valid-slice) + - [Reduce Scope of Variables](https://github.com/uber-go/guide/blob/master/style.md#reduce-scope-of-variables) + - [Avoid Naked Parameters](https://github.com/uber-go/guide/blob/master/style.md#avoid-naked-parameters) + - [Use Raw String Literals to Avoid Escaping](https://github.com/uber-go/guide/blob/master/style.md#use-raw-string-literals-to-avoid-escaping) + - [Initializing Structs](https://github.com/uber-go/guide/blob/master/style.md#initializing-structs) + - [Use Field Names to Initialize Structs](https://github.com/uber-go/guide/blob/master/style.md#use-field-names-to-initialize-structs) + - [Omit Zero Value Fields in Structs](https://github.com/uber-go/guide/blob/master/style.md#omit-zero-value-fields-in-structs) + - [Use `var` for Zero Value Structs](https://github.com/uber-go/guide/blob/master/style.md#use-var-for-zero-value-structs) + - [Initializing Struct References](https://github.com/uber-go/guide/blob/master/style.md#initializing-struct-references) + - [Initializing Maps](https://github.com/uber-go/guide/blob/master/style.md#initializing-maps) + - [Format Strings outside Printf](https://github.com/uber-go/guide/blob/master/style.md#format-strings-outside-printf) + - [Naming Printf-style Functions](https://github.com/uber-go/guide/blob/master/style.md#naming-printf-style-functions) +- [Patterns](https://github.com/uber-go/guide/blob/master/style.md#patterns) + - [Test Tables](https://github.com/uber-go/guide/blob/master/style.md#test-tables) + - [Functional Options](https://github.com/uber-go/guide/blob/master/style.md#functional-options) +- [Linting](https://github.com/uber-go/guide/blob/master/style.md#linting) From 9ab406e1ffbb77f827209dd0cc41b85231bffafc Mon Sep 17 00:00:00 2001 From: Manuel Doncel Martos Date: Fri, 25 Apr 2025 11:37:15 +0200 Subject: [PATCH 10/13] adding errorlinter --- 04-uber/.golangci.yml | 9 ++++++--- 04-uber/README.md | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/04-uber/.golangci.yml b/04-uber/.golangci.yml index da454f7..b9d2743 100644 --- a/04-uber/.golangci.yml +++ b/04-uber/.golangci.yml @@ -23,12 +23,12 @@ formatters: simplify: true rewrite-rules: # replace `interface{}` with `any` in the code on format - - pattern: 'interface{}' - replacement: 'any' + - pattern: "interface{}" + replacement: "any" # make sure imports are always in a deterministic order # https://github.com/daixiang0/gci/ - gci: # define the section orders for imports + gci: # define the section orders for imports sections: # Standard section: captures all standard packages. - standard @@ -71,6 +71,9 @@ linters: # Errcheck is a program for checking for unchecked errors in Go code. - errcheck + # Errorlint is a linter for that can be used to find code that will cause problems with the error wrapping scheme introduced in Go 1.13. + - errorlint + # Errname Checks that sentinel errors are prefixed with the Err and error types are suffixed with the Error - errname diff --git a/04-uber/README.md b/04-uber/README.md index 9795a9a..8da8919 100644 --- a/04-uber/README.md +++ b/04-uber/README.md @@ -24,7 +24,7 @@ Source: [@ccoVeille](https://github.com/ccoVeille/golangci-lint-config-examples) - [Use `"time"` to handle time](https://github.com/uber-go/guide/blob/master/style.md#use-time-to-handle-time) - [Errors](https://github.com/uber-go/guide/blob/master/style.md#errors) - [Error Types](https://github.com/uber-go/guide/blob/master/style.md#error-types) - - [Error Wrapping](https://github.com/uber-go/guide/blob/master/style.md#error-wrapping) + - [x] [Error Wrapping](https://github.com/uber-go/guide/blob/master/style.md#error-wrapping) - Sytle applied through `errorlint` - [x] [Error Naming](https://github.com/uber-go/guide/blob/master/style.md#error-naming) - Style applied through `errname` - [Handle Errors Once](#handle-errors-once) - [Handle Type Assertion Failures](#handle-type-assertion-failures) From 92f9705bcad298f7ebeefbf65b2d8890574be6ce Mon Sep 17 00:00:00 2001 From: Manuel Doncel Martos Date: Fri, 25 Apr 2025 11:48:52 +0200 Subject: [PATCH 11/13] adding musttag --- 04-uber/.golangci.yml | 3 +++ 04-uber/README.md | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/04-uber/.golangci.yml b/04-uber/.golangci.yml index b9d2743..b5b5084 100644 --- a/04-uber/.golangci.yml +++ b/04-uber/.golangci.yml @@ -96,6 +96,9 @@ linters: # make sure to use t.Helper() when needed - thelper + # Enforce field tags in (un)marshaled structs. + - musttag + # mirror suggests rewrites to avoid unnecessary []byte/string conversion - mirror diff --git a/04-uber/README.md b/04-uber/README.md index 8da8919..5ef22b8 100644 --- a/04-uber/README.md +++ b/04-uber/README.md @@ -35,7 +35,7 @@ Source: [@ccoVeille](https://github.com/ccoVeille/golangci-lint-config-examples) - [Avoid Using Built-In Names](https://github.com/uber-go/guide/blob/master/style.md#avoid-using-built-in-names) - [x] [Avoid `init()`](https://github.com/uber-go/guide/blob/master/style.md#avoid-init) - Style applied through `gochecknoinits`. - [x] [Exit in Main](https://github.com/uber-go/guide/blob/master/style.md#exit-in-main) - Style applied through `revive.deep-exit`. - - [Use field tags in marshaled structs](https://github.com/uber-go/guide/blob/master/style.md#use-field-tags-in-marshaled-structs) + - [x] [Use field tags in marshaled structs](https://github.com/uber-go/guide/blob/master/style.md#use-field-tags-in-marshaled-structs) - Style applied through `musttag` - [Don't fire-and-forget goroutines](https://github.com/uber-go/guide/blob/master/style.md#dont-fire-and-forget-goroutines) - [Wait for goroutines to exit](https://github.com/uber-go/guide/blob/master/style.md#wait-for-goroutines-to-exit) - [No goroutines in `init()`](https://github.com/uber-go/guide/blob/master/style.md#no-goroutines-in-init) From ab5a793807bf443e105032b2b8c77d043f8000c0 Mon Sep 17 00:00:00 2001 From: Manuel Doncel Martos Date: Sat, 26 Apr 2025 19:41:47 +0200 Subject: [PATCH 12/13] WIP: renaming to uberstyle --- {04-uber => uberstyle}/.golangci.yml | 2 +- {04-uber => uberstyle}/README.md | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename {04-uber => uberstyle}/.golangci.yml (99%) rename {04-uber => uberstyle}/README.md (100%) diff --git a/04-uber/.golangci.yml b/uberstyle/.golangci.yml similarity index 99% rename from 04-uber/.golangci.yml rename to uberstyle/.golangci.yml index da454f7..3a3946d 100644 --- a/04-uber/.golangci.yml +++ b/uberstyle/.golangci.yml @@ -3,7 +3,7 @@ # Source: https://github.com/ccoVeille/golangci-lint-config-examples/ # Author: @ccoVeille & @manuelarte # License: MIT -# Variant: 04-uber +# Variant: uberstyle # Version: v2.1.0 # version: "2" diff --git a/04-uber/README.md b/uberstyle/README.md similarity index 100% rename from 04-uber/README.md rename to uberstyle/README.md From a8481786a30734050ec993d965ec6d95915df7c1 Mon Sep 17 00:00:00 2001 From: Manuel Doncel Martos Date: Sat, 26 Apr 2025 19:54:21 +0200 Subject: [PATCH 13/13] WIP: adding goimports --- uberstyle/.golangci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/uberstyle/.golangci.yml b/uberstyle/.golangci.yml index d1264d3..f4c9df7 100644 --- a/uberstyle/.golangci.yml +++ b/uberstyle/.golangci.yml @@ -14,6 +14,8 @@ formatters: - gofmt # format the block of imports - gci + # checks if the code and import statements are formatted according to the 'goimports' command. + - goimports settings: # format the code with Go standard library