Skip to content

Commit

Permalink
all: Bumps minimum Golang version to 1.18 (#4499)
Browse files Browse the repository at this point in the history
* Run `go fmt` with go-1.19 to conform to new stds
* Now ran `go generate ./...` to conform to go-1.19
* Run `go fmt` after `go generate` in checks
  • Loading branch information
Shaptic authored Aug 10, 2022
1 parent 6ecfa3f commit 9d5b585
Show file tree
Hide file tree
Showing 52 changed files with 3,405 additions and 3,661 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
go: [1.18]
go: [1.19]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
Expand All @@ -31,7 +31,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
go: [1.17, 1.18]
go: [1.18, 1.19]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
Expand All @@ -47,7 +47,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
go: [1.17, 1.18]
go: [1.18, 1.19]
pg: [9.6.5, 10]
runs-on: ${{ matrix.os }}
services:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/horizon-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:

- uses: ./.github/actions/setup-go
with:
go-version: 1.17
go-version: 1.18

- name: Check dependencies
run: ./gomod.sh
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/horizon.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
go: [1.17, 1.18]
go: [1.18, 1.19]
pg: [9.6.5]
ingestion-backend: [db, captive-core, captive-core-remote-storage]
protocol-version: [18, 19]
Expand Down
4 changes: 2 additions & 2 deletions exp/orderbook/pools.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func makeTrade(
// CalculatePoolPayout calculates the amount of `reserveB` disbursed from the
// pool for a `received` amount of `reserveA` . From CAP-38:
//
// y = floor[(1 - F) Yx / (X + x - Fx)]
// y = floor[(1 - F) Yx / (X + x - Fx)]
//
// It returns false if the calculation overflows.
func CalculatePoolPayout(reserveA, reserveB, received xdr.Int64, feeBips xdr.Int32, calculateRoundingSlippage bool) (xdr.Int64, xdr.Int64, bool) {
Expand Down Expand Up @@ -160,7 +160,7 @@ func CalculatePoolPayout(reserveA, reserveB, received xdr.Int64, feeBips xdr.Int
// CalculatePoolExpectation determines how much of `reserveA` you would need to
// put into a pool to get the `disbursed` amount of `reserveB`.
//
// x = ceil[Xy / ((Y - y)(1 - F))]
// x = ceil[Xy / ((Y - y)(1 - F))]
//
// It returns false if the calculation overflows.
func CalculatePoolExpectation(
Expand Down
4 changes: 2 additions & 2 deletions exp/orderbook/pools_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ func TestCalculatePoolPayoutRoundingSlippage(t *testing.T) {
// CalculatePoolPayout calculates the amount of `reserveB` disbursed from the
// pool for a `received` amount of `reserveA` . From CAP-38:
//
// y = floor[(1 - F) Yx / (X + x - Fx)]
// y = floor[(1 - F) Yx / (X + x - Fx)]
//
// It returns false if the calculation overflows.
func calculatePoolPayoutBig(reserveA, reserveB, received xdr.Int64, feeBips xdr.Int32) (xdr.Int64, xdr.Int64, bool) {
Expand Down Expand Up @@ -387,7 +387,7 @@ func calculatePoolPayoutBig(reserveA, reserveB, received xdr.Int64, feeBips xdr.
// calculatePoolExpectation determines how much of `reserveA` you would need to
// put into a pool to get the `disbursed` amount of `reserveB`.
//
// x = ceil[Xy / ((Y - y)(1 - F))]
// x = ceil[Xy / ((Y - y)(1 - F))]
//
// It returns false if the calculation overflows.
func calculatePoolExpectationBig(
Expand Down
18 changes: 9 additions & 9 deletions exp/orderbook/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,11 +237,11 @@ func search(
// edges in `graph.edgesForSellingAsset` are traversed.
//
// The DFS maintains the following invariants:
// - no node is repeated
// - no offers are consumed from the `ignoreOffersFrom` account
// - each payment path must begin with an asset in `targetAssets`
// - also, the required source asset amount cannot exceed the balance in
// `targetAssets`
// - no node is repeated
// - no offers are consumed from the `ignoreOffersFrom` account
// - each payment path must begin with an asset in `targetAssets`
// - also, the required source asset amount cannot exceed the balance in
// `targetAssets`
type sellingGraphSearchState struct {
graph *OrderBookGraph
destinationAssetString string
Expand Down Expand Up @@ -339,10 +339,10 @@ func (state *sellingGraphSearchState) consumePool(
// edges in `graph.edgesForBuyingAsset` are traversed.
//
// The DFS maintains the following invariants:
// - no node is repeated
// - no offers are consumed from the `ignoreOffersFrom` account
// - each payment path must terminate with an asset in `targetAssets`
// - each payment path must begin with `sourceAsset`
// - no node is repeated
// - no offers are consumed from the `ignoreOffersFrom` account
// - each payment path must terminate with an asset in `targetAssets`
// - each payment path must begin with `sourceAsset`
type buyingGraphSearchState struct {
graph *OrderBookGraph
sourceAssetString string
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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/stellar/go

go 1.17
go 1.18

require (
firebase.google.com/go v3.12.0+incompatible
Expand Down
2 changes: 1 addition & 1 deletion gogenerate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
set -e

printf "Running go generate...\n"
go generate ./...
go generate ./... && go fmt ./...

printf "Checking for no diff...\n"
git diff --exit-code || (echo "Files changed after running go generate. Run go generate ./... locally and update generated files." && exit 1)
Loading

0 comments on commit 9d5b585

Please sign in to comment.