Skip to content

Commit

Permalink
chore: Bump to GoLang v1.19 (#818)
Browse files Browse the repository at this point in the history
- Resolves #817
- Resolves #1070 

- This PR was initially started as: `ci: Bump workflow's golang-ci lint version` to fix the golang-ci lint issue. This work that was done in this PR was the following:
  - Remove the `deadcode` and `varcheck` linters that are now deprecated with `v1.49`
  - Remove all `nolint` directives where the deprecated linters were being referenced.
  - Update CI's linter version to use the latest version.

However as the golang-ci lint team still didn't fix that issue but golang1.19 was released we can just fix those errors and bump the GoLang version for defradb and keeping the previous linter fixes.

Inaddtion also re-enabling the `goheader` linter rule as the change was somehow dropped when we released defradb v0.4.
  • Loading branch information
shahzadlone authored Feb 15, 2023
1 parent 9a0fe20 commit 07dfd1e
Show file tree
Hide file tree
Showing 24 changed files with 114 additions and 123 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-dependencies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
- name: Setup Go environment explicitly
uses: actions/setup-go@v3
with:
go-version: "1.18"
go-version: "1.19"
check-latest: true

- name: Build all dependencies
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/code-test-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: "1.18"
go-version: "1.19"
check-latest: true

- name: Generate full test coverage report using go-acc
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/detect-change.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
- name: Setup Go environment explicitly
uses: actions/setup-go@v3
with:
go-version: "1.18"
go-version: "1.19"
check-latest: true

- name: Build dependencies
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/lint-then-benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
- name: Setup Go environment explicitly
uses: actions/setup-go@v3
with:
go-version: "1.18"
go-version: "1.19"
check-latest: true

- name: Run the golangci-lint
Expand All @@ -67,7 +67,7 @@ jobs:
# Required: the version of golangci-lint is required.
# Note: The version should not pick the patch version as the latest patch
# version is what will always be used.
version: v1.47
version: v1.51

# Optional: working directory, useful for monorepos or if we wanted to run this
# on a non-root directory.
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- name: Setup Go environment explicitly
uses: actions/setup-go@v3
with:
go-version: "1.18"
go-version: "1.19"
check-latest: true

- name: Build dependencies
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/start-binary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
- name: Setup Go environment explicitly
uses: actions/setup-go@v3
with:
go-version: "1.18"
go-version: "1.19"
check-latest: true

- name: Build modules
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ client\:add-schema:

.PHONY: deps\:lint
deps\:lint:
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.47.3
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.51

.PHONY: deps\:test
deps\:test:
Expand Down Expand Up @@ -118,7 +118,7 @@ verify:

.PHONY: tidy
tidy:
go mod tidy -go=1.18
go mod tidy -go=1.19

.PHONY: clean
clean:
Expand Down
1 change: 0 additions & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ How to use, e.g. without using a rootdir:
err := cfg.LoadWithoutRootDir()
if err != nil {
...
*/
package config

Expand Down
10 changes: 5 additions & 5 deletions db/collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -886,11 +886,11 @@ func (c *collection) getTxn(ctx context.Context, readonly bool) (datastore.Txn,
}

// discardImplicitTxn is a proxy function used by the collection to execute the Discard()
// transaction function only if its an implicit transaction.
// Implicit transactions are transactions that are created *during* an operation
// execution as a side effect.
// Explicit transactions are provided to the collection object via
// the "WithTxn(...)" function.
// transaction function only if its an implicit transaction.
//
// Implicit transactions are transactions that are created *during* an operation execution as a side effect.
//
// Explicit transactions are provided to the collection object via the "WithTxn(...)" function.
func (c *collection) discardImplicitTxn(ctx context.Context, txn datastore.Txn) {
if c.txn == nil {
txn.Discard(ctx)
Expand Down
38 changes: 23 additions & 15 deletions db/collection_delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,11 @@ import (
"github.com/sourcenetwork/defradb/merkle/clock"
)

// DeleteWith deletes a target document. Target can be a Filter statement,
// a single docKey, a single document, an array of docKeys, or an array of documents.
// DeleteWith deletes a target document.
//
// Target can be a Filter statement, a single docKey, a single document,
// an array of docKeys, or an array of documents.
//
// If you want more type safety, use the respective typed versions of Delete.
// Eg: DeleteWithFilter or DeleteWithKey
func (c *collection) DeleteWith(
Expand Down Expand Up @@ -250,16 +253,20 @@ func newDagDeleter(bstore datastore.DAGStore) dagDeleter {
}
}

// applyFullDelete deletes from all the stores.
//
// Stores the deletion will act upon:
// 1. Deleting the actual blocks (blockstore).
// 2. Deleting datastore state.
// 3. Deleting headstore state.
//
// Here is what our db stores look like:
// /db
// -> block /blocks => /db/blocks
// -> datastore /data => /db/data
// -> headstore /heads => /db/heads
// -> systemstore /system => /db/system
// For the delete operation we are concerned with:
// 1) Deleting the actual blocks (blockstore).
// 2) Deleting datastore state.
// 3) Deleting headstore state.
//
// /db
// -> block /blocks => /db/blocks
// -> datastore /data => /db/data
// -> headstore /heads => /db/heads
// -> systemstore /system => /db/system
func (c *collection) applyFullDelete(
ctx context.Context,
txn datastore.Txn, dockey core.PrimaryDataStoreKey) error {
Expand Down Expand Up @@ -353,10 +360,11 @@ func (d dagDeleter) run(ctx context.Context, targetCid cid.Cid) error {
return d.delete(ctx, targetCid, block)
}

// (ipld.Block
// (ipldProtobufNode{
// Data: (cbor(crdt deltaPayload)),
// Links: (_head => parentCid, fieldName => fieldCid)))
// (ipld.Block
// (ipldProtobufNode{
// Data: (cbor(crdt deltaPayload)),
// Links: (_head => parentCid, fieldName => fieldCid)))

func (d dagDeleter) delete(
ctx context.Context,
targetCid cid.Cid,
Expand Down
12 changes: 5 additions & 7 deletions db/fetcher/versioned.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,12 @@ var (
// to a specific version in the documents history graph, and return the fetched
// state at that point exactly.
//
// Given the following Document state graph
//
// Given the following Document state graph:
// {} --> V1 --> V2 --> V3 --> V4
//
// ^ ^
// | |
// Target Version Current State
//
// Target Version Current State
//
// A regular DocumentFetcher fetches and returns the state at V4, but the
// VersionsedFetcher would step backwards through the update graph, recompose
Expand All @@ -64,10 +63,9 @@ var (
// the scanNode request planner system.
//
// Current limitations:
// - We can only return a single record from an VersionedFetcher
// instance.
// - We can only return a single record from an VersionedFetcher instance.
// - We can't request related sub objects (at the moment, as related objects
// ids aren't in the state graphs.
// ids aren't in the state graphs.
// - Probably more...
//
// Future optimizations:
Expand Down
4 changes: 4 additions & 0 deletions errors/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ func NewKV(key string, value any) KV {
// A stacktrace will be yielded if formatting with a `+`, e.g `fmt.Sprintf("%+v", err)`.
// This function will not be inlined by the compiler as it will spoil any stacktrace
// generated.
//
//go:noinline
func New(message string, keyvals ...KV) error {
return withStackTrace(message, 1, keyvals...)
Expand All @@ -54,6 +55,7 @@ func New(message string, keyvals ...KV) error {
// the given inner error, suffixing any key-value pairs provided.
// This function will not be inlined by the compiler as it will spoil any stacktrace
// generated.
//
//go:noinline
func Wrap(message string, inner error, keyvals ...KV) error {
err := withStackTrace(message, 1, keyvals...)
Expand All @@ -67,6 +69,7 @@ func Is(err, target error) bool {

// This function will not be inlined by the compiler as it will spoil any stacktrace
// generated.
//
//go:noinline
func WithStack(err error, keyvals ...KV) error {
return withStackTrace(err.Error(), 1, keyvals...)
Expand All @@ -79,6 +82,7 @@ func WithStack(err error, keyvals ...KV) error {
//
// This function will not be inlined by the compiler as it will spoil any stacktrace
// generated.
//
//go:noinline
func withStackTrace(message string, depthToSkip int, keyvals ...KV) *defraError {
stackBuffer := make([]uintptr, MaxStackDepth)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/sourcenetwork/defradb

go 1.18
go 1.19

require (
github.com/bxcodec/faker v2.0.1+incompatible
Expand Down
2 changes: 1 addition & 1 deletion net/pb/custom.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func (id ProtoPeerID) Size() int {
}

// ProtoAddr is a custom type used by gogo to serde raw multiaddresses into
// the ma.Multiaddr type, and back.
// the ma.Multiaddr type, and back.
type ProtoAddr struct {
ma.Multiaddr
}
Expand Down
50 changes: 26 additions & 24 deletions planner/explain.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,31 +55,33 @@ const (
// buildSimpleExplainGraph builds the explainGraph from the given top level plan.
//
// Request:
// query @explain {
// user {
// _key
// age
// name
// }
// }
//
// Response:
// {
// "data": [
// {
// "explain": {
// "selectTopNode": {
// "selectNode": {
// ...
// "scanNode": {
// ...
// }
// }
// }
// }
// }
// ]
// }
// query @explain {
// user {
// _key
// age
// name
// }
// }
//
// Response:
//
// {
// "data": [
// {
// "explain": {
// "selectTopNode": {
// "selectNode": {
// ...
// "scanNode": {
// ...
// }
// }
// }
// }
// }
// ]
// }
func buildSimpleExplainGraph(source planNode) (map[string]any, error) {
explainGraph := map[string]any{}

Expand Down
7 changes: 4 additions & 3 deletions planner/group.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,10 @@ type groupNode struct {
currentIndex int
}

// Creates a new group node. The function is recursive and will construct the node-chain for any
// child (`_group`) collections. `groupSelect` is optional and will typically be nil if the
// child `_group` is not requested.
// Creates a new group node.

// The function is recursive and will construct the node-chain for any child (`_group`) collections.
// `groupSelect` is optional and will typically be nil if the child `_group` is not requested.
func (p *Planner) GroupBy(n *mapper.GroupBy, parsed *mapper.Select, childSelects []*mapper.Select) (*groupNode, error) {
if n == nil {
return nil, nil
Expand Down
22 changes: 11 additions & 11 deletions planner/multi.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,22 +54,22 @@ type appendNode interface {
// if a single request has multiple Select statements at the
// same depth in the request.
// Eg:
// user {
// _key
// name
// friends {
// name
// }
// _version {
// cid
// }
// }
//
// user {
// _key
// name
// friends {
// name
// }
// _version {
// cid
// }
// }
//
// In this example, both the friends selection and the _version
// selection require their own planNode sub graphs to complete.
// However, they are entirely independent graphs, so they can
// be executed in parallel.
//
type parallelNode struct { // serialNode?
documentIterator
docMapper
Expand Down
2 changes: 1 addition & 1 deletion planner/planner.go
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ func walkAndFindPlanType[T planNode](plan planNode) (T, bool) {
}

// explainRequest walks through the plan graph, and outputs the concrete planNodes that should
// be executed, maintaing their order in the plan graph (does not actually execute them).
// be executed, maintaing their order in the plan graph (does not actually execute them).
func (p *Planner) explainRequest(
ctx context.Context,
plan planNode,
Expand Down
2 changes: 1 addition & 1 deletion request/graphql/schema/descriptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ var (
// directly. As it will yield incorrect and unexpected
// results

//nolint:deadcode,unused,varcheck
//nolint:unused
gqlTypeToFieldKindReference = map[gql.Type]client.FieldKind{
gql.ID: client.FieldKind_DocKey,
gql.Boolean: client.FieldKind_BOOL,
Expand Down
2 changes: 1 addition & 1 deletion tests/bench/query/simple/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
)

var (
//log = logging.MustNewLogger("defra.bench")
// log = logging.MustNewLogger("defra.bench")
)

func runQueryBenchGet(
Expand Down
Loading

0 comments on commit 07dfd1e

Please sign in to comment.