Skip to content

Commit

Permalink
Remove usage of x/exp package (#162)
Browse files Browse the repository at this point in the history
Need to inline one particular function for maps, which can also be removed once Go 1.22 is out.

Fixes #161
  • Loading branch information
oxisto authored Oct 6, 2023
1 parent 2eb70fd commit b6b706a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 15 deletions.
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ require (
github.com/bufbuild/connect-go v1.10.0
github.com/mattn/go-sqlite3 v1.14.17
github.com/oxisto/assert v0.0.6
golang.org/x/exp v0.0.0-20230905200255-921286631fa9
golang.org/x/net v0.16.0
golang.org/x/text v0.13.0
google.golang.org/protobuf v1.31.0
Expand Down
12 changes: 0 additions & 12 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,8 @@ github.com/mattn/go-sqlite3 v1.14.17 h1:mCRHCLDUBXgpKAqIKsaAaAsrAlbkeomtRFKXh2L6
github.com/mattn/go-sqlite3 v1.14.17/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg=
github.com/oxisto/assert v0.0.6 h1:Z/wRt0qndURRof+eOGr7GbcJ6BHZT2nyZd9diuZHS8o=
github.com/oxisto/assert v0.0.6/go.mod h1:07ANKfyBm6j+pZk1qArFueno6fCoEGKvPbPeJSQkH3s=
golang.org/x/exp v0.0.0-20230811145659-89c5cff77bcb h1:mIKbk8weKhSeLH2GmUTrvx8CjkyJmnU1wFmg59CUjFA=
golang.org/x/exp v0.0.0-20230811145659-89c5cff77bcb/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc=
golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63 h1:m64FZMko/V45gv0bNmrNYoDEq8U5YUhetc9cBWKS1TQ=
golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63/go.mod h1:0v4NqG35kSWCMzLaMeX+IQrlSnVE/bqGSyC2cz/9Le8=
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 h1:GoHiUyI/Tp2nVkLI2mCxVkOjsbSXD66ic0XW0js0R9g=
golang.org/x/exp v0.0.0-20230905200255-921286631fa9/go.mod h1:S2oDrQGGwySpoQPVqRShND87VCbxmc6bL1Yd2oYrm6k=
golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14=
golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI=
golang.org/x/net v0.15.0 h1:ugBLEUaxABaB5AJqW9enI0ACdci2RUd4eP51NTBvuJ8=
golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk=
golang.org/x/net v0.16.0 h1:7eBu7KsSvFDtSXUIDbh3aqlK4DPsZ1rByC8PFfBThos=
golang.org/x/net v0.16.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc=
golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
Expand Down
13 changes: 11 additions & 2 deletions service/portfolio/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
portfoliov1 "github.com/oxisto/money-gopher/gen"

"github.com/bufbuild/connect-go"
"golang.org/x/exp/maps"
"google.golang.org/protobuf/types/known/timestamppb"
)

Expand Down Expand Up @@ -62,7 +61,7 @@ func (svc *service) GetPortfolioSnapshot(ctx context.Context, req *connect.Reque

// Retrieve the event map; a map of events indexed by their security name
m = p.EventMap()
names = maps.Keys(m)
names = keys(m)

// Retrieve market value of filtered securities
secres, err = svc.securities.ListSecurities(
Expand Down Expand Up @@ -119,3 +118,13 @@ func marketPrice(secmap map[string]*portfoliov1.Security, name string, netPrice
return *ls[0].LatestQuote
}
}

func keys[M ~map[K]V, K comparable, V any](m M) (keys []K) {
keys = make([]K, 0, len(m))

for k := range m {
keys = append(keys, k)
}

return keys
}

0 comments on commit b6b706a

Please sign in to comment.