Skip to content

Commit

Permalink
Merge pull request #4 from govalues/error-management
Browse files Browse the repository at this point in the history
money: implement panic free methods
  • Loading branch information
eapenkin authored Jun 4, 2023
2 parents 7d50ee4 + 1439070 commit aa52ef6
Show file tree
Hide file tree
Showing 16 changed files with 1,021 additions and 759 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
run: go generate ./... && git diff --exit-code

- name: Verify potential issues
run: go vet ./...
uses: golangci/golangci-lint-action@v3

- name: Run tests with coverage
run: go test -race -shuffle=on -coverprofile="coverage.txt" -covermode=atomic ./...
Expand Down
15 changes: 15 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
run:
timeout: 5m

linters:
enable:
- errcheck
- gosimple
- goimports
- govet
- ineffassign
- misspell
- revive
- staticcheck
- typecheck
- unused
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## [0.1.0] - 2023-06-04

### Changed

- All methods return error instead of panicing.
- Renamed Amount.Round to Amount.Rescale.
- Renamed ExchangeRate.Round to ExchangeRate.Rescale.

## [0.0.3] - 2023-04-22

### Changed
Expand Down
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ import (
## Using Amount

To create a new amount, you can use one of the provided constructors,
such as `NewAmount`, `ParseAmount` or `MustParseAmount`.
such as `NewAmount`, `MustNewAmount`, `ParseAmount` or `MustParseAmount`.

```go
d := decimal.New(12345, 2) // d = 123.45
a, _ := money.NewAmount(money.USD, d) // a = USD 123.45
d := decimal.MustNew(12345, 2) // d = 123.45
a := money.MustNewAmount(money.USD, d) // a = USD 123.45
b := money.MustParseAmount("USD", "123.45") // b = USD 123.45
```

Expand All @@ -42,11 +42,11 @@ addition, subtraction, multiplication, division, as well
as rounding operations such as ceiling, floor, truncation, and rounding.

```go
sum := a.Add(b)
difference := a.Sub(b)
product := a.Mul(d)
quotient := a.Quo(d)
ratio := a.Rat(b)
sum, _ := a.Add(b)
difference, _ := a.Sub(b)
product, _ := a.Mul(d)
quotient, _ := a.Quo(d)
ratio, _ := a.Rat(b)
ceil := a.Ceil(2)
floor := a.Floor(2)
trunc := a.Trunc(2)
Expand Down
Loading

0 comments on commit aa52ef6

Please sign in to comment.