-
Notifications
You must be signed in to change notification settings - Fork 296
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
contrib: Add Go multimod workspace setup script.
This adds a script to the contrib directory that initializes a Go multi-module workspace and adds all of the modules provided by the dcrd repository to it on an as needed basis. Note that workspaces require Go 1.18+. This is useful when developing across multiple modules in the repository and allows development environments that make use of the Go language server (aka gopls), such as VSCode, to provide full support without also needing to temporarily create replacements in the various go.mod files or individually add every module. Do note, however, that workspaces are local, so final submissions to the repository will still require the appropriate changes to the relevant go.mod files to ensure resolution outside of the workspace. Finally, it also updates the README.md in the contrib directory accordingly.
- Loading branch information
Showing
2 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# Copyright (c) 2022 The Decred developers | ||
# Use of this source code is governed by an ISC | ||
# license that can be found in the LICENSE file. | ||
# | ||
# Script to initialize a multi-module workspace that includes all of the modules | ||
# provided by the dcrd repository. | ||
|
||
set -e | ||
|
||
# Ensure the script is run from either the root of the repo or the contrib dir | ||
SCRIPT=$(basename $0) | ||
MAIN_CODE_FILE="dcrd.go" | ||
if [ -f "../${MAIN_CODE_FILE}" ]; then | ||
cd .. | ||
fi | ||
if [ ! -f "${MAIN_CODE_FILE}" ]; then | ||
echo "$SCRIPT: error: ${MAIN_CODE_FILE} not found in the current directory" | ||
exit 1 | ||
fi | ||
|
||
# Verify Go is available | ||
if ! type go >/dev/null 2>&1; then | ||
echo -n "$SCRIPT: error: Unable to find 'go' in the system path." | ||
exit 1 | ||
fi | ||
|
||
# Create workspace unless one already exists | ||
if [ ! -f "go.work" ]; then | ||
go work init | ||
fi | ||
|
||
# Add all of the modules as needed | ||
go work use . ./addrmgr ./bech32 ./blockchain ./blockchain/stake | ||
go work use ./blockchain/standalone ./certgen ./chaincfg ./chaincfg/chainhash | ||
go work use ./connmgr ./container/apbf ./crypto/blake256 ./crypto/ripemd160 | ||
go work use ./database ./dcrec ./dcrec/edwards ./dcrec/secp256k1 ./dcrjson | ||
go work use ./dcrutil ./gcs ./hdkeychain ./lru ./math/uint256 ./peer | ||
go work use ./rpc/jsonrpc/types ./rpcclient ./txscript ./wire |