Skip to content

Commit

Permalink
Merge pull request #11 from goark/debug-and-refactoring
Browse files Browse the repository at this point in the history
Replace external packages
  • Loading branch information
spiegel-im-spiegel authored Aug 7, 2022
2 parents 9a5ab06 + a601338 commit 0568f23
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 31 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/vulns.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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.
Expand Down
Binary file modified dependency.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 4 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
@@ -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
)
21 changes: 8 additions & 13 deletions go.sum
Original file line number Diff line number Diff line change
@@ -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=
47 changes: 47 additions & 0 deletions sample/sample0.go
Original file line number Diff line number Diff line change
@@ -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.
*/
18 changes: 9 additions & 9 deletions source.go
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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)
Expand Down

0 comments on commit 0568f23

Please sign in to comment.