diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index b4bb793..e3d8d34 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -16,7 +16,7 @@ jobs: steps: - uses: actions/setup-go@v3 with: - go-version: ^1.18 + go-version: ^1.19 - uses: actions/checkout@v3 - name: golangci-lint uses: golangci/golangci-lint-action@v3 diff --git a/.github/workflows/vulns.yml b/.github/workflows/vulns.yml index 19b2036..fb3a4cc 100644 --- a/.github/workflows/vulns.yml +++ b/.github/workflows/vulns.yml @@ -12,7 +12,7 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-go@v2 with: - go-version: ^1.18 + go-version: ^1.19 - name: install depm run: go install github.com/goark/depm@latest - name: WriteGoList diff --git a/Taskfile.yml b/Taskfile.yml index 9086f6e..0080bd1 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -13,7 +13,7 @@ tasks: cmds: - go mod verify - go test -shuffle on ./... - - docker run --rm -v $(pwd):/app -w /app golangci/golangci-lint:v1.45.2 golangci-lint run --enable gosec --timeout 3m0s ./... + - docker run --rm -v $(pwd):/app -w /app golangci/golangci-lint:v1.48.0 golangci-lint run --enable gosec --timeout 3m0s ./... sources: - ./go.mod - '**/*.go' @@ -32,7 +32,7 @@ tasks: - rm -f ./go.sum - go clean -cache - go clean -modcache - - go mod tidy -v -go=1.18 + - go mod tidy -v -go=1.19 graph: desc: Make grapth of dependency modules. diff --git a/dependency.png b/dependency.png index bbfc863..356eef0 100644 Binary files a/dependency.png and b/dependency.png differ diff --git a/go.mod b/go.mod index 842b499..d5eb1cd 100644 --- a/go.mod +++ b/go.mod @@ -1,14 +1,13 @@ module github.com/goark/koyomi -go 1.18 +go 1.19 require ( - github.com/PuloV/ics-golang v0.0.0-20190808201353-a3394d3bcade github.com/goark/errs v1.1.0 + github.com/spiegel-im-spiegel/ics-golang v0.1.0 ) require ( - github.com/channelmeter/iso8601duration v0.0.0-20150204201828-8da3af7a2a61 // indirect - github.com/stretchr/testify v1.7.1 // indirect - gopkg.in/yaml.v3 v3.0.1 // indirect + github.com/goark/fetch v0.3.0 // indirect + github.com/spiegel-im-spiegel/iso8601duration v0.1.0 // indirect ) diff --git a/go.sum b/go.sum index be26f64..8644f0b 100644 --- a/go.sum +++ b/go.sum @@ -1,17 +1,12 @@ -github.com/PuloV/ics-golang v0.0.0-20190808201353-a3394d3bcade h1:odEkSCl2gLWPtvraEdCyBZbeYyMMTysWPLMurnB8sUY= -github.com/PuloV/ics-golang v0.0.0-20190808201353-a3394d3bcade/go.mod h1:f1P3hjG+t54/IrnXMnnw+gRmFCDR/ryj9xSQ7MPMkQw= -github.com/channelmeter/iso8601duration v0.0.0-20150204201828-8da3af7a2a61 h1:o64h9XF42kVEUuhuer2ehqrlX8rZmvQSU0+Vpj1rF6Q= -github.com/channelmeter/iso8601duration v0.0.0-20150204201828-8da3af7a2a61/go.mod h1:Rp8e0DCtEKwXFOC6JPJQVTz8tuGoGvw6Xfexggh/ed0= -github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/goark/errs v1.1.0 h1:FKnyw4LVyRADIjM8Nj0Up6r0/y5cfADvZAd1E+tthXE= github.com/goark/errs v1.1.0/go.mod h1:TtaPEoadm2mzqzfXdkkfpN2xuniCFm2q4JH+c1qzaqw= +github.com/goark/fetch v0.3.0 h1:2m32EGOLBi99RzI5urFfmv5++CMqfenVw7NH8z/lbX8= +github.com/goark/fetch v0.3.0/go.mod h1:sqDdPbbHeIjDVeHrgvzhHpkUr8X9pVC9DgJoVwU02x0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY= -github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +github.com/spiegel-im-spiegel/ics-golang v0.1.0 h1:B+HHGJa6MqeJq15lAe2hGo7dfnx6t4jq451Nqice4mY= +github.com/spiegel-im-spiegel/ics-golang v0.1.0/go.mod h1:TpSbav1X/sYTlZq2aNDU8NZg9c8HcuAG2GnNVUy1zA4= +github.com/spiegel-im-spiegel/iso8601duration v0.1.0 h1:AL8GyapnN1uGrFg/mvimc8xpOdVNU2XoaqL/WRDxe7s= +github.com/spiegel-im-spiegel/iso8601duration v0.1.0/go.mod h1:Fe92GUFYxNfo+IRNEeJNvZHqQeH1MAz1send1zriltg= +github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= -gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/sample/sample0.go b/sample/sample0.go new file mode 100644 index 0000000..5a2d645 --- /dev/null +++ b/sample/sample0.go @@ -0,0 +1,47 @@ +//go:build run +// +build run + +package main + +import ( + "bytes" + "io" + "os" + "time" + + "github.com/goark/koyomi" +) + +func main() { + start, _ := koyomi.DateFrom("2019-05-01") + end := koyomi.NewDate(time.Date(2019, time.May, 31, 0, 0, 0, 0, koyomi.JST)) + k, err := koyomi.NewSource( + koyomi.WithCalendarID(koyomi.Holiday, koyomi.SolarTerm), + koyomi.WithStartDate(start), + koyomi.WithEndDate(end), + ).Get() + if err != nil { + return + } + + csv, err := k.EncodeCSV() + if err != nil { + return + } + io.Copy(os.Stdout, bytes.NewReader(csv)) +} + +/* Copyright 2022 Spiegel + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ diff --git a/source.go b/source.go index b6e166e..95376eb 100644 --- a/source.go +++ b/source.go @@ -1,19 +1,19 @@ package koyomi import ( - ics "github.com/PuloV/ics-golang" "github.com/goark/errs" + ics "github.com/spiegel-im-spiegel/ics-golang" ) -//Source is information of data source for koyomi +// Source is information of data source for koyomi type Source struct { cids []CalendarID start DateJp end DateJp - tempDir string //temporary directory for github.com/PuloV/ics-golang package + tempDir string //temporary directory for github.com/spiegel-im-spiegel/ics-golang package } -//optFunc is self-referential function for functional options pattern +// optFunc is self-referential function for functional options pattern type optFunc func(*Source) // NewSource creates a new Source instance @@ -27,35 +27,35 @@ func NewSource(opts ...optFunc) *Source { return s } -//WithCalendarID returns function for setting Reader +// WithCalendarID returns function for setting Reader func WithCalendarID(cid ...CalendarID) optFunc { return func(s *Source) { s.cids = append(s.cids, cid...) } } -//WithStartDate returns function for setting Reader +// WithStartDate returns function for setting Reader func WithStartDate(start DateJp) optFunc { return func(s *Source) { s.start = start } } -//WithEndDate returns function for setting Reader +// WithEndDate returns function for setting Reader func WithEndDate(end DateJp) optFunc { return func(s *Source) { s.end = end } } -//WithTempDir returns function for setting Reader +// WithTempDir returns function for setting Reader func WithTempDir(dir string) optFunc { return func(s *Source) { s.tempDir = dir } } -//Get returns koyomi data from calendar dources +// Get returns koyomi data from calendar dources func (s *Source) Get() (*Koyomi, error) { if s == nil { return nil, errs.Wrap(ErrNullPointer)