├── .github └── workflows │ └── stale.yml ├── workspace.sh ├── README.md └── .gitmodules /.github/workflows/stale.yml: -------------------------------------------------------------------------------- 1 | name: Close and mark stale issue 2 | 3 | on: 4 | schedule: 5 | - cron: '0 0 * * *' 6 | 7 | jobs: 8 | stale: 9 | 10 | runs-on: ubuntu-latest 11 | permissions: 12 | issues: write 13 | pull-requests: write 14 | 15 | steps: 16 | - uses: actions/stale@v3 17 | with: 18 | repo-token: ${{ secrets.GITHUB_TOKEN }} 19 | stale-issue-message: 'Oops, seems like we needed more information for this issue, please comment with more details or this issue will be closed in 7 days.' 20 | close-issue-message: 'This issue was closed because it is missing author input.' 21 | stale-issue-label: 'kind/stale' 22 | any-of-labels: 'need/author-input' 23 | exempt-issue-labels: 'need/triage,need/community-input,need/maintainer-input,need/maintainers-input,need/analysis,status/blocked,status/in-progress,status/ready,status/deferred,status/inactive' 24 | days-before-issue-stale: 6 25 | days-before-issue-close: 7 26 | enable-statistics: true 27 | -------------------------------------------------------------------------------- /workspace.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # vim: set expandtab sw=4 ts=4: 3 | 4 | ## This little script accompanies a go mod uber repo, that is, a Git repo that aggregates modules pertaining 5 | ## to a single project linearly through git submodules. 6 | 7 | set -euo pipefail 8 | IFS=$'\n' 9 | 10 | ## Load all subdirectories siblings of this script. 11 | mods=() 12 | while IFS='' read -r line; do mods+=("$line"); done < \ 13 | <(find "$(dirname "${0}")" -mindepth 1 -maxdepth 1 -type d -not -name '.*' -exec basename {} ';' | sort) 14 | 15 | ## Return the repo name of origin remote 16 | ## It expect the origin to be `git@github.com:/.git` (ssh format). 17 | get_repo() { 18 | git -C "${1}" remote get-url origin | cut -d':' -f2 | cut -d'.' -f1 19 | } 20 | 21 | ## Edits a module gomod. Args: 22 | ## $1: module to edit 23 | ##  $2: array of flags to go mod edit 24 | edit_mod() { 25 | local mod="${1}" 26 | shift 27 | local flags=("$@") 28 | go mod edit "${flags[@]}" "$mod/go.mod" 29 | echo $mod 30 | } 31 | 32 | do_local() { 33 | local flags=() 34 | for mod in "${mods[@]}"; do 35 | flags+=("-replace=github.com/$(get_repo $mod)=../$mod") 36 | done 37 | for i in "${!mods[@]}"; do 38 | local rep=("${flags[@]}") 39 | unset 'rep['"$i"']' 40 | rep=("${rep[@]}") 41 | 42 | edit_mod "${mods[$i]}" "${rep[@]}" 43 | done 44 | } 45 | 46 | do_remote() { 47 | local flags=() 48 | for mod in "${mods[@]}"; do 49 | flags+=("-dropreplace=github.com/$(get_repo $mod)") 50 | done 51 | for i in "${!mods[@]}"; do 52 | local rep=("${flags[@]}") 53 | unset 'rep['"$i"']' 54 | rep=("${rep[@]}") 55 | 56 | edit_mod "${mods[$i]}" "${rep[@]}" 57 | done 58 | } 59 | 60 | do_refresh() { 61 | cd "$(dirname "${0}")" 62 | echo "::: Stashing all changes :::" 63 | git submodule foreach git stash 64 | 65 | echo "::: Checking out master on all submodules :::" 66 | git submodule foreach git checkout master 67 | 68 | echo "::: Rebasing all submodules origin/master :::" 69 | exec 3>&1 70 | if ! git submodule update --jobs 10 --remote --rebase 1>&3 2>&3; then 71 | echo "WARN: upgrade git for faster submodule updates from origin" 72 | git submodule update --remote --rebase 73 | fi 74 | 75 | echo "::: Pulling all modules in case new dependencies have been added :::" 76 | # We might have to do multiple passes in case a new dependency adds another new dependency 77 | added=1 78 | while [ ${added} -eq 1 ]; do 79 | added=0 80 | for repo in $( 81 | awk '/^\s\s*github.com\/(libp2p|ipld|multiformats)/ { print gensub(/^github.com\/([^/]*\/[^/]*).*/, "\\1", "g", $1) }' ./*/go.mod \ 82 | | sort -u 83 | ); do 84 | if git submodule add "git@github.com:${repo}.git"; then 85 | added=1 86 | fi 87 | done 88 | done 89 | 90 | echo "Done" 91 | } 92 | 93 | git-branch-name () { 94 | git status 2> /dev/null | \ 95 | head -1 | \ 96 | sed 's/^# //' | \ 97 | sed 's/^On branch //' |\ 98 | sed 's/HEAD detached at //' 99 | } 100 | 101 | do_branches() { 102 | for D in *; 103 | do 104 | if [ -d "${D}" ]; then 105 | cd "${D}" 106 | printf "${D}\t" 107 | git-branch-name 108 | cd .. 109 | fi 110 | done 111 | } 112 | 113 | do_branches_col() { 114 | if which column &>/dev/null; then 115 | do_branches | column -t 116 | else 117 | do_branches 118 | fi 119 | } 120 | 121 | print_usage() { 122 | echo "Usage: $0 {local|remote|master}" >&2 123 | echo 124 | echo " [l]ocal adds \`replace\` directives to all go.mod files to make dependencies point to the local workspace" 125 | echo " [r]emote removes the \`replace\` directives introduced by \`local\`" 126 | echo " [re]fresh refreshes all submodules from origin/master, stashing all local changes first, then checking out master" 127 | echo " [b]ranches lists all the repos and the branch checked out" 128 | echo "" 129 | } 130 | 131 | if [[ -z ${1:-} ]]; then 132 | print_usage 133 | exit 1 134 | fi 135 | 136 | case "$1" in 137 | local | l) do_local ;; 138 | remote | r) do_remote ;; 139 | refresh | re) do_refresh ;; 140 | branches | b) do_branches_col ;; 141 | *) print_usage; exit 1; ;; 142 | esac 143 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | > This repository is deprecated following the repository consolidation work that happened in [go-libp2p](https://github.com/libp2p/go-libp2p). 2 | 3 | # go-libp2p workspace 4 | 5 | go-libp2p is a p2p networking stack based on the principle of modularity. Its 6 | modules are scattered across a number of Git repos. We have recently migrated 7 | from gx to gomod as the primary dependency and build management tool. 8 | 9 | To make developing with gomod easy, this meta-repository aggregates all 10 | go-libp2p repos under a single roof via git submodules, and provides a 11 | management script (`./workspace.sh`) for automating common workflows. 12 | 13 | ## ⚠️ Work in progress 14 | 15 | This setup is currently at pilot stage and heavily WIP. Feedback and 16 | contributions are welcome. Some wishlist items include: 17 | 18 | - [ ] go mod <> IPFS integration, to consume and publish content-addressed 19 | dependencies easily. [Stebalien/ipgo](https://github.com/Stebalien/ipgo) is 20 | one possible direction. 21 | - [ ] Automating the "bubbling" and update workflow, via scripts or tooling 22 | such as [renovate](https://renovatebot.com). 23 | - [ ] Shared libp2p/IPFS workspace. 24 | - [ ] Nightly master builds. 25 | 26 | ## 👉 Prerequisite: Git pre-commit hook 27 | 28 | This [pre-commit 29 | hook](https://gist.github.com/Kubuxu/3fc5639db27f4b072b33a84b51048ff8) will 30 | alert you when you are trying to commit go.mod file with local replace 31 | directives. This is useful pattern for developing, but has no place on remote. 32 | 33 | It is best to install it as global githook. Instructions 34 | [here](https://stackoverflow.com/questions/1977610/change-default-git-hooks/37293001#37293001). 35 | 36 | ## Usage 37 | 38 | **Getting started** 39 | 40 | This will initialise the submodules by cloning repos into their relevant 41 | subdirectories. 42 | 43 | ``` 44 | $ git clone --recursive 45 | ``` 46 | 47 | **Switch to local module resolution** 48 | 49 | Interlinks all repos for local development through `replace` directives. 50 | 51 | ``` 52 | $ ./workspace.sh local 53 | ``` 54 | 55 | **Switch to remote module resolution** 56 | 57 | Removes the `replace` directives added by `local`. 58 | 59 | ``` 60 | $ ./workspace.sh remote 61 | ``` 62 | 63 | **Stash local changes and update all repos from origin/master** 64 | 65 | ``` 66 | $ ./workspace.sh remote   # to reset go.mod files to original 67 | $ ./workspace.sh refresh 68 | ``` 69 | 70 | ## Background: Why is this necessary? 71 | 72 | Gomod is great for mono-repo projects that depend on 3rd party dependencies, 73 | but there are some challenges when working with an intervowen set of 74 | modularised packages: 75 | 76 | * Go tools resolve module versions from remotes. 77 | * Developers want to make changesets across a number of local repos and have 78 | them visible by interdependent modules. 79 | 80 | Aggregating modules under one roof, and using go mod `replace` directives to 81 | interlink them locally via `replace` directives, provides a neat `GOPATH`-like 82 | development experience. 83 | 84 | **Detour: GOPATH vs go modules** 85 | 86 | The `GOPATH` monolith is irrelevant in the Go modules universe. Now you can 87 | check out modules anywhere in the filesystem. 88 | 89 | Running `go get` from inside a Go module will download packages into the global 90 | go mod cache (`$GOPATH/pkg/mod`), where they are indexed by module path and 91 | version. 92 | 93 | All go tools (go build, go test, etc.) are now module-friendly. They 94 | automatically add `require` directives go `go.mod` for new imports in code, 95 | download packages from remotes, and more. It's like magic. 96 | 97 | _NOTE: Running `go get` in a tree without a `go.mod` will still place that 98 | package under your `GOPATH`. Running `go` commands from within your `GOPATH` 99 | will behave like before (i.e. no module-based builds) even if the package has a 100 | `go.mod`, unless you explicitly set `GO111MODULE=on`._ 101 | 102 | _Fun fact: Go mod makes bold assertions about immutability, and this transpires 103 | even to file permissions under the module cache. A quick `ls -l` therein shows 104 | that go strips away write permissions from downloaded modules, even for the 105 | owner._ 106 | 107 | ## Recommended reading 108 | 109 | Familiarise yourself with [Go 110 | modules](https://github.com/golang/go/wiki/Modules). In particular, pay 111 | attention to how minimal version selection works. 112 | 113 | Reacquaint yourself with go commands. Most of the commands you know and have 114 | come to love (`go get`, `go build`, `go test`) now deal with modules 115 | transparently. Suggested read: [go command manual](https://golang.org/cmd/go/), 116 | and pay special attention to the sections dedicated to modules behaviour. 117 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "go-sockaddr"] 2 | path = go-sockaddr 3 | url = git@github.com:libp2p/go-sockaddr.git 4 | [submodule "go-reuseport"] 5 | path = go-reuseport 6 | url = git@github.com:libp2p/go-reuseport.git 7 | [submodule "go-mplex"] 8 | path = go-mplex 9 | url = git@github.com:libp2p/go-mplex.git 10 | [submodule "go-libp2p"] 11 | path = go-libp2p 12 | url = git@github.com:libp2p/go-libp2p.git 13 | [submodule "go-libp2p-loggables"] 14 | path = go-libp2p-loggables 15 | url = git@github.com:libp2p/go-libp2p-loggables.git 16 | [submodule "go-ws-transport"] 17 | path = go-ws-transport 18 | url = git@github.com:libp2p/go-ws-transport.git 19 | [submodule "go-libp2p-peerstore"] 20 | path = go-libp2p-peerstore 21 | url = git@github.com:libp2p/go-libp2p-peerstore.git 22 | [submodule "go-libp2p-kad-dht"] 23 | path = go-libp2p-kad-dht 24 | url = git@github.com:libp2p/go-libp2p-kad-dht.git 25 | [submodule "go-libp2p-kbucket"] 26 | path = go-libp2p-kbucket 27 | url = git@github.com:libp2p/go-libp2p-kbucket.git 28 | [submodule "go-libp2p-record"] 29 | path = go-libp2p-record 30 | url = git@github.com:libp2p/go-libp2p-record.git 31 | [submodule "go-libp2p-pubsub"] 32 | path = go-libp2p-pubsub 33 | url = git@github.com:libp2p/go-libp2p-pubsub.git 34 | [submodule "go-tcp-transport"] 35 | path = go-tcp-transport 36 | url = git@github.com:libp2p/go-tcp-transport.git 37 | [submodule "go-addr-util"] 38 | path = go-addr-util 39 | url = git@github.com:libp2p/go-addr-util.git 40 | [submodule "go-libp2p-swarm"] 41 | path = go-libp2p-swarm 42 | url = git@github.com:libp2p/go-libp2p-swarm.git 43 | [submodule "go-libp2p-nat"] 44 | path = go-libp2p-nat 45 | url = git@github.com:libp2p/go-libp2p-nat.git 46 | [submodule "go-libp2p-pnet"] 47 | path = go-libp2p-pnet 48 | url = git@github.com:libp2p/go-libp2p-pnet.git 49 | [submodule "go-libp2p-consensus"] 50 | path = go-libp2p-consensus 51 | url = git@github.com:libp2p/go-libp2p-consensus.git 52 | [submodule "go-libp2p-raft"] 53 | path = go-libp2p-raft 54 | url = git@github.com:libp2p/go-libp2p-raft.git 55 | [submodule "go-libp2p-netutil"] 56 | path = go-libp2p-netutil 57 | url = git@github.com:libp2p/go-libp2p-netutil.git 58 | [submodule "go-libp2p-blankhost"] 59 | path = go-libp2p-blankhost 60 | url = git@github.com:libp2p/go-libp2p-blankhost.git 61 | [submodule "go-libp2p-gorpc"] 62 | path = go-libp2p-gorpc 63 | url = git@github.com:libp2p/go-libp2p-gorpc.git 64 | [submodule "go-libp2p-circuit"] 65 | path = go-libp2p-circuit 66 | url = git@github.com:libp2p/go-libp2p-circuit.git 67 | [submodule "go-libp2p-quic-transport"] 68 | path = go-libp2p-quic-transport 69 | url = git@github.com:libp2p/go-libp2p-quic-transport.git 70 | [submodule "go-libp2p-connmgr"] 71 | path = go-libp2p-connmgr 72 | url = git@github.com:libp2p/go-libp2p-connmgr.git 73 | [submodule "go-msgio"] 74 | path = go-msgio 75 | url = git@github.com:libp2p/go-msgio.git 76 | [submodule "go-flow-metrics"] 77 | path = go-flow-metrics 78 | url = git@github.com:libp2p/go-flow-metrics.git 79 | [submodule "go-buffer-pool"] 80 | path = go-buffer-pool 81 | url = git@github.com:libp2p/go-buffer-pool.git 82 | [submodule "go-conn-security-multistream"] 83 | path = go-conn-security-multistream 84 | url = git@github.com:libp2p/go-conn-security-multistream.git 85 | [submodule "go-reuseport-transport"] 86 | path = go-reuseport-transport 87 | url = git@github.com:libp2p/go-reuseport-transport.git 88 | [submodule "go-libp2p-transport-upgrader"] 89 | path = go-libp2p-transport-upgrader 90 | url = git@github.com:libp2p/go-libp2p-transport-upgrader.git 91 | [submodule "go-libp2p-routing-helpers"] 92 | path = go-libp2p-routing-helpers 93 | url = git@github.com:libp2p/go-libp2p-routing-helpers.git 94 | [submodule "go-libp2p-pubsub-router"] 95 | path = go-libp2p-pubsub-router 96 | url = git@github.com:libp2p/go-libp2p-pubsub-router.git 97 | [submodule "go-libp2p-autonat"] 98 | path = go-libp2p-autonat 99 | url = git@github.com:libp2p/go-libp2p-autonat.git 100 | [submodule "go-libp2p-examples"] 101 | path = go-libp2p-examples 102 | url = git@github.com:libp2p/go-libp2p-examples.git 103 | [submodule "go-libp2p-daemon"] 104 | path = go-libp2p-daemon 105 | url = git@github.com:libp2p/go-libp2p-daemon.git 106 | [submodule "go-nat"] 107 | path = go-nat 108 | url = git@github.com:libp2p/go-nat.git 109 | [submodule "go-libp2p-discovery"] 110 | path = go-libp2p-discovery 111 | url = git@github.com:libp2p/go-libp2p-discovery.git 112 | [submodule "go-libp2p-autonat-svc"] 113 | path = go-libp2p-autonat-svc 114 | url = git@github.com:libp2p/go-libp2p-autonat-svc.git 115 | [submodule "go-libp2p-tls"] 116 | path = go-libp2p-tls 117 | url = git@github.com:libp2p/go-libp2p-tls.git 118 | [submodule "go-libp2p-core"] 119 | path = go-libp2p-core 120 | url = git@github.com:libp2p/go-libp2p-core.git 121 | [submodule "go-multistream"] 122 | path = go-multistream 123 | url = git@github.com:multiformats/go-multistream 124 | [submodule "go-libp2p-testing"] 125 | path = go-libp2p-testing 126 | url = git@github.com:libp2p/go-libp2p-testing.git 127 | [submodule "go-libp2p-mplex"] 128 | path = go-libp2p-mplex 129 | url = git@github.com:libp2p/go-libp2p-mplex.git 130 | [submodule "go-stream-muxer-multistream"] 131 | path = go-stream-muxer-multistream 132 | url = git@github.com:libp2p/go-stream-muxer-multistream.git 133 | [submodule "go-yamux"] 134 | path = go-yamux 135 | url = git@github.com:libp2p/go-yamux.git 136 | [submodule "go-libp2p-yamux"] 137 | path = go-libp2p-yamux 138 | url = git@github.com:libp2p/go-libp2p-yamux.git 139 | [submodule "go-multiaddr"] 140 | path = go-multiaddr 141 | url = git@github.com:multiformats/go-multiaddr.git 142 | [submodule "go-multiaddr-dns"] 143 | path = go-multiaddr-dns 144 | url = git@github.com:multiformats/go-multiaddr-dns.git 145 | [submodule "go-multiaddr-fmt"] 146 | path = go-multiaddr-fmt 147 | url = git@github.com:multiformats/go-multiaddr-fmt.git 148 | [submodule "go-libp2p-webrtc-direct"] 149 | path = go-libp2p-webrtc-direct 150 | url = git@github.com:libp2p/go-libp2p-webrtc-direct.git 151 | [submodule "go-eventbus"] 152 | path = go-eventbus 153 | url = git@github.com:libp2p/go-eventbus.git 154 | [submodule "go-libp2p-noise"] 155 | path = go-libp2p-noise 156 | url = git@github.com:libp2p/go-libp2p-noise.git 157 | [submodule "go-libp2p-introspection"] 158 | path = go-libp2p-introspection 159 | url = git@github.com:libp2p/go-libp2p-introspection.git 160 | [submodule "go-libp2p-pubsub-tracer"] 161 | path = go-libp2p-pubsub-tracer 162 | url = git@github.com:libp2p/go-libp2p-pubsub-tracer.git 163 | [submodule "go-cidranger"] 164 | path = go-cidranger 165 | url = git@github.com:libp2p/go-cidranger.git 166 | [submodule "go-libp2p-asn-util"] 167 | path = go-libp2p-asn-util 168 | url = git@github.com:libp2p/go-libp2p-asn-util.git 169 | [submodule "go-libp2p-gostream"] 170 | path = go-libp2p-gostream 171 | url = git@github.com:libp2p/go-libp2p-gostream.git 172 | [submodule "go-libp2p-resource-manager"] 173 | path = go-libp2p-resource-manager 174 | url = git@github.com:libp2p/go-libp2p-resource-manager.git 175 | [submodule "go-libp2p-xor"] 176 | path = go-libp2p-xor 177 | url = git@github.com:libp2p/go-libp2p-xor.git 178 | [submodule "go-netroute"] 179 | path = go-netroute 180 | url = git@github.com:libp2p/go-netroute.git 181 | [submodule "go-openssl"] 182 | path = go-openssl 183 | url = git@github.com:libp2p/go-openssl.git 184 | [submodule "zeroconf"] 185 | path = zeroconf 186 | url = git@github.com:libp2p/zeroconf.git 187 | [submodule "go-base32"] 188 | path = go-base32 189 | url = git@github.com:multiformats/go-base32.git 190 | [submodule "go-multiaddr-net"] 191 | path = go-multiaddr-net 192 | url = git@github.com:multiformats/go-multiaddr-net.git 193 | [submodule "go-multibase"] 194 | path = go-multibase 195 | url = git@github.com:multiformats/go-multibase.git 196 | [submodule "go-multihash"] 197 | path = go-multihash 198 | url = git@github.com:multiformats/go-multihash.git 199 | [submodule "go-varint"] 200 | path = go-varint 201 | url = git@github.com:multiformats/go-varint.git 202 | [submodule "go-base36"] 203 | path = go-base36 204 | url = git@github.com:multiformats/go-base36.git 205 | --------------------------------------------------------------------------------