namespace :go do desc <<-DESC Compile the go application locally You can override any of these defaults by setting the variables shown below. set :go_input, 'api.go' set :go_output, 'api' set :go_os, 'linux' set :go_arch, 'amd64' set :go_roles, :app set :go_servers, -> { release_roles(fetch(:go_roles)) } set :go_target, -> { release_path.join(fetch(:go_output)) } DESC task :build do on fetch(:go_servers) do run_locally do go_flags = { 'GOOS' => fetch(:go_os), 'GOARCH' => fetch(:go_arch) } with(go_flags) do execute :go, 'build', '-o', fetch(:go_output), fetch(:go_input) end end end end desc 'Upload compiled application to the server' task :upload do on fetch(:go_servers) do upload! fetch(:go_output), fetch(:go_target) end end end namespace :load do task :defaults do set :go_input, 'api.go' set :go_output, 'api' set :go_os, 'linux' set :go_arch, 'amd64' set :go_roles, :app set :go_servers, -> { release_roles(fetch(:go_roles)) } set :go_target, -> { release_path.join(fetch(:go_output)) } end end