snippets

More or less useful code snippets
Log | Files | Refs

gol (528B)


      1 #!/bin/bash
      2 # Run go with a local mod file.
      3 # Useful when developing two modules simultaneously, where one depends on the other.
      4 # A local go.mod version, go.local.mod, can then be added next to the version controlled go.mod,
      5 # and contain a `replace` directive to make go use local source code instead of the external repo.
      6 # Remember to add `**go.local.mod` and `**go.local.sum` to .gitignore.
      7 
      8 
      9 if [ $1 == mod ]; then
     10     cmd="mod $2"
     11     args=${@:3}
     12 else
     13     cmd="$1"
     14     args=${@:2}
     15 fi
     16 
     17 go $cmd -modfile go.local.mod $args