Skip to content

Commit

Permalink
added golangci lint action (g8rswimmer#80)
Browse files Browse the repository at this point in the history
* added golangci lint action

* addressed linting

* added tests

* updated action name

* updated the test workflow
  • Loading branch information
g8rswimmer authored Jan 4, 2022
1 parent 334221c commit bf235c0
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 14 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/go-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: go-test
on:
push:
tags:
- v*
branches:
- master
- main
pull_request:
permissions:
contents: read
# Optional: allow read access to pull request. Use with `only-new-issues` option.
# pull-requests: read
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: '1.17.5'

- name: Test With Coverage
run: go test -gcflags=-l -v --race --cover -coverprofile=coverage.txt -covermode=atomic ./...

- name: Run Vet & Lint
run: go vet ./...
42 changes: 42 additions & 0 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: golangci-lint
on:
push:
tags:
- v*
branches:
- master
- main
pull_request:
permissions:
contents: read
# Optional: allow read access to pull request. Use with `only-new-issues` option.
# pull-requests: read
jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
with:
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
version: v1.43.0

# Optional: working directory, useful for monorepos
# working-directory: somedir

# Optional: golangci-lint command line arguments.
# args: --issues-exit-code=0

# Optional: show only new issues if it's a pull request. The default value is `false`.
# only-new-issues: true

# Optional: if set to true then the action will use pre-installed Go.
# skip-go-installation: true

# Optional: if set to true then the action don't cache or restore ~/go/pkg.
# skip-pkg-cache: true

# Optional: if set to true then the action don't cache or restore ~/.cache/go-build.
# skip-build-cache: true
4 changes: 3 additions & 1 deletion tweet.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,9 @@ func (t *TweetRecentSearch) UnmarshalJSON(b []byte) error {
t.Meta = m.Meta

tl := TweetLookups{}
tl.lookups(json.NewDecoder(bytes.NewReader(b)))
if err := tl.lookups(json.NewDecoder(bytes.NewReader(b))); err != nil {
return err
}
t.LookUps = tl
return nil
}
Expand Down
4 changes: 2 additions & 2 deletions tweet_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ func (t TweetRecentSearchOptions) addQuery(req *http.Request) {
q := req.URL.Query()
q.Add("query", t.query)

if t.StartTime.IsZero() == false {
if !t.StartTime.IsZero() {
q.Add("start_time", t.StartTime.Format(time.RFC3339))
}
if t.EndTime.IsZero() == false {
if !t.EndTime.IsZero() {
q.Add("end_time", t.EndTime.Format(time.RFC3339))
}
if t.MaxResult >= 10 {
Expand Down
4 changes: 2 additions & 2 deletions user_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,10 @@ func (u UserTimelineOpts) addQuery(req *http.Request) {
if len(u.PaginationToken) > 0 {
q.Add("pagination_token", u.PaginationToken)
}
if u.EndTime.IsZero() == false {
if !u.EndTime.IsZero() {
q.Add("end_time", u.EndTime.Format(time.RFC3339))
}
if u.StartTime.IsZero() == false {
if !u.StartTime.IsZero() {
q.Add("start_time", u.StartTime.Format(time.RFC3339))
}
if len(q) > 0 {
Expand Down
4 changes: 2 additions & 2 deletions v2/tweet_counts_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ type TweetRecentCountsOpts struct {

func (t TweetRecentCountsOpts) addQuery(req *http.Request) {
q := req.URL.Query()
if t.StartTime.IsZero() == false {
if !t.StartTime.IsZero() {
q.Add("start_time", t.StartTime.Format(time.RFC3339))
}
if t.EndTime.IsZero() == false {
if !t.EndTime.IsZero() {
q.Add("end_time", t.EndTime.Format(time.RFC3339))
}
if len(t.SinceID) > 0 {
Expand Down
2 changes: 1 addition & 1 deletion v2/tweet_manage.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ type CreateTweetRequest struct {
DirectMessageDeepLink string `json:"direct_message_deep_link,omitempty"`
ForSuperFollowersOnly bool `json:"for_super_followers_only,omitempty"`
QuoteTweetID string `json:"quote_tweet_id,omitempty"`
Text string `json:"text,omitemtpy"`
Text string `json:"text,omitempty"`
ReplySettings string `json:"reply_settings"`
Geo CreateTweetGeo `json:"geo"`
Media CreateTweetMedia `json:"media"`
Expand Down
12 changes: 6 additions & 6 deletions v2/tweet_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ func (t TweetRecentSearchOpts) addQuery(req *http.Request) {
if len(t.UserFields) > 0 {
q.Add("user.fields", strings.Join(userFieldStringArray(t.UserFields), ","))
}
if t.StartTime.IsZero() == false {
if !t.StartTime.IsZero() {
q.Add("start_time", t.StartTime.Format(time.RFC3339))
}
if t.EndTime.IsZero() == false {
if !t.EndTime.IsZero() {
q.Add("end_time", t.EndTime.Format(time.RFC3339))
}
if t.MaxResults > 0 {
Expand Down Expand Up @@ -141,10 +141,10 @@ func (t UserTweetTimelineOpts) addQuery(req *http.Request) {
if len(t.Excludes) > 0 {
q.Add("exclude", strings.Join(excludeStringArray(t.Excludes), ","))
}
if t.StartTime.IsZero() == false {
if !t.StartTime.IsZero() {
q.Add("start_time", t.StartTime.Format(time.RFC3339))
}
if t.EndTime.IsZero() == false {
if !t.EndTime.IsZero() {
q.Add("end_time", t.EndTime.Format(time.RFC3339))
}
if t.MaxResults > 0 {
Expand Down Expand Up @@ -200,10 +200,10 @@ func (t UserMentionTimelineOpts) addQuery(req *http.Request) {
if len(t.UserFields) > 0 {
q.Add("user.fields", strings.Join(userFieldStringArray(t.UserFields), ","))
}
if t.StartTime.IsZero() == false {
if !t.StartTime.IsZero() {
q.Add("start_time", t.StartTime.Format(time.RFC3339))
}
if t.EndTime.IsZero() == false {
if !t.EndTime.IsZero() {
q.Add("end_time", t.EndTime.Format(time.RFC3339))
}
if t.MaxResults > 0 {
Expand Down

0 comments on commit bf235c0

Please sign in to comment.