Skip to content

Commit e2d6921

Browse files
authored
Merge pull request piquette#13 from piquette/develop
Modules migration and Go 1.13 support.
2 parents 35659a5 + 33256a3 commit e2d6921

47 files changed

Lines changed: 83 additions & 10538 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.travis.yml

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,28 @@
1+
language: go
2+
3+
matrix:
4+
allow_failures:
5+
- go: tip
6+
fast_finish: true
7+
include:
8+
- go: 1.11.x
9+
env: GO111MODULE=on
10+
- go: 1.12.x
11+
env: GO111MODULE=on
12+
- go: 1.13.x
13+
- go: tip
14+
115
before_install:
2-
# Install code coverage / coveralls tooling
3-
- go get -u golang.org/x/tools/cmd/cover
4-
- go get -u github.com/modocache/gover
5-
- go get -u github.com/mattn/goveralls
16+
- if [[ "${GO111MODULE}" = "on" ]]; then mkdir "${HOME}/go"; export GOPATH="${HOME}/go"; fi
17+
- go mod download
18+
- if [[ "${GO111MODULE}" = "on" ]]; then export PATH="${GOPATH}/bin:${GOROOT}/bin:${PATH}"; fi
19+
20+
# Install lint / code coverage / coveralls tooling
21+
- travis_retry go get -u golang.org/x/net/http2
22+
- travis_retry go get -u golang.org/x/tools/cmd/cover
23+
- travis_retry go get -u github.com/modocache/gover
24+
- travis_retry go get -u github.com/mattn/goveralls
25+
- travis_retry go get -u golang.org/x/lint/golint
626

727
# Unpack and start test server so that the test suite can talk to it
828
- |
@@ -23,17 +43,6 @@ env:
2343
global:
2444
- FINANCE_MOCK_VERSION=0.0.5
2545

26-
go:
27-
- "1.10"
28-
- tip
29-
30-
language: go
31-
32-
matrix:
33-
allow_failures:
34-
- go: tip
35-
fast_finish: true
36-
3746
script:
3847
- make
3948
- make coverage
@@ -44,4 +53,4 @@ after_script:
4453
# Send code coverage report to coveralls.io
4554
- goveralls -service=travis-ci -coverprofile=gover.coverprofile
4655

47-
sudo: false
56+
sudo: false

Gopkg.lock

Lines changed: 0 additions & 36 deletions
This file was deleted.

Gopkg.toml

Lines changed: 0 additions & 38 deletions
This file was deleted.

Makefile

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
1-
all: test vet
1+
all: test bench vet lint check-gofmt
22

33
bench:
44
go test -race -bench . -run "Benchmark" ./form
55

66
build:
77
go build ./...
88

9+
check-gofmt:
10+
scripts/check_gofmt.sh
11+
12+
lint:
13+
golint -set_exit_status ./...
14+
915
test:
1016
go test -v ./...
1117

@@ -18,4 +24,4 @@ coverage:
1824
go list ./... | xargs -n1 -I {} -P 4 go test -covermode=count -coverprofile=../../../{}/profile.coverprofile {}
1925

2026
clean:
21-
find . -name \*.coverprofile -delete
27+
find . -name \*.coverprofile -delete

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ For now, for details on all the functionality in this library, see the [GoDoc][g
3232

3333
## Installation
3434

35-
It is best to use a dependency management tool, but if you want to retrieve it manually, use -
35+
This project supports modules and Go 1.13+. Add `finance-go` to your own project the usual way -
3636

3737
```sh
3838
go get github.com/piquette/finance-go

go.mod

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module github.com/piquette/finance-go
2+
3+
go 1.13
4+
5+
require (
6+
github.com/davecgh/go-spew v1.1.1
7+
github.com/pmezard/go-difflib v1.0.0
8+
github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24
9+
github.com/stretchr/testify v1.2.2
10+
)

go.sum

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
2+
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
3+
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
4+
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
5+
github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24 h1:pntxY8Ary0t43dCZ5dqY4YTJCObLY1kIXl0uzMv+7DE=
6+
github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24/go.mod h1:M+9NzErvs504Cn4c5DxATwIqPbtswREoFCre64PpcG4=
7+
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
8+
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=

quote/client.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ import (
44
"context"
55
"strings"
66

7-
chart "github.com/piquette/finance-go/chart"
87
finance "github.com/piquette/finance-go"
8+
chart "github.com/piquette/finance-go/chart"
9+
"github.com/piquette/finance-go/datetime"
910
"github.com/piquette/finance-go/form"
1011
"github.com/piquette/finance-go/iter"
11-
"github.com/piquette/finance-go/datetime"
1212
)
1313

1414
// Client is used to invoke quote APIs.
@@ -42,14 +42,14 @@ func (i *Iter) Quote() *finance.Quote {
4242
return i.Current().(*finance.Quote)
4343
}
4444

45-
//Gives the Day's Close when you input a historical date
45+
// GetHistoricalQuote provides a single chart bar for a historical date.
4646
func GetHistoricalQuote(symbol string, month int, day int, year int) (*finance.ChartBar, error) {
4747
p := &chart.Params{
4848
Symbol: symbol,
4949
Start: &datetime.Datetime{Month: month, Day: day, Year: year},
5050
End: &datetime.Datetime{Month: month, Day: day, Year: year},
5151
Interval: datetime.OneDay,
52-
}
52+
}
5353
iter := chart.Get(p)
5454
for iter.Next() {
5555
b := iter.Bar()

quote/client_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ func TestHistoricalQuote(t *testing.T) {
2323
TestMonth := 1
2424
TestDay := 11
2525
TestYear := 2018
26-
26+
2727
q, err := GetHistoricalQuote(tests.TestEquitySymbol, TestMonth, TestDay, TestYear)
28-
28+
2929
assert.Nil(t, err)
3030
assert.NotNil(t, q)
3131
high, _ := q.High.Float64()

scripts/check_gofmt.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
3+
find_files() {
4+
find . -not \( \
5+
\( \
6+
-name 'vendor' \
7+
\) -prune \
8+
\) -name '*.go'
9+
}
10+
11+
bad_files=$(find_files | xargs gofmt -s -l)
12+
if [[ -n "${bad_files}" ]]; then
13+
echo "!!! gofmt -s needs to be run on the following files: "
14+
echo "${bad_files}"
15+
exit 1
16+
fi

0 commit comments

Comments
 (0)