File tree 7 files changed +124
-27
lines changed
7 files changed +124
-27
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ run :
3
+ concurrency : 6
4
+ deadline : 5m
5
+ skip-files :
6
+ - " .*_test\\ .go"
7
+ - " lib/.*"
8
+ linters :
9
+ disable-all : true
10
+ enable :
11
+ - deadcode
12
+ - depguard
13
+ - dupl
14
+ - goconst
15
+ - gocritic
16
+ - gofmt
17
+ - goimports
18
+ - golint
19
+ - govet
20
+ - ineffassign
21
+ - misspell
22
+ - staticcheck
23
+ - structcheck
24
+ - typecheck
25
+ - unconvert
26
+ - unparam
27
+ - varcheck
28
+ - gocyclo
29
+ linters-settings :
30
+ gocritic :
31
+ enabled-checks :
32
+ # Diagnostic
33
+ - argOrder
34
+ - badCond
35
+ - caseOrder
36
+ - codegenComment
37
+ - commentedOutCode
38
+ - deprecatedComment
39
+ - dupArg
40
+ - dupBranchBody
41
+ - dupCase
42
+ - dupSubExpr
43
+ - exitAfterDefer
44
+ - flagDeref
45
+ - flagName
46
+ - nilValReturn
47
+ - offBy1
48
+ - weakCond
49
+ # - appendAssign
50
+ - octalLiteral
51
+ - sloppyReassign
52
+
53
+ # Performance
54
+ - equalFold
55
+ # - hugeParam
56
+ - indexAlloc
57
+ - rangeExprCopy
58
+ # - rangeValCopy
59
+ - appendCombine
60
+
61
+ # Style
62
+ - assignOp
63
+ - boolExprSimplify
64
+ - captLocal
65
+ - commentFormatting
66
+ - commentedOutImport
67
+ - defaultCaseOrder
68
+ - docStub
69
+ - elseif
70
+ - emptyFallthrough
71
+ - emptyStringTest
72
+ - hexLiteral
73
+ # - ifElseChain
74
+ - methodExprCall
75
+ - regexpMust
76
+ - singleCaseSwitch
77
+ - sloppyLen
78
+ - stringXbytes
79
+ - switchTrue
80
+ - typeAssertChain
81
+ - typeSwitchVar
82
+ - underef
83
+ - unlabelStmt
84
+ - unlambda
85
+ - unslice
86
+ - valSwap
87
+ - yodaStyleExpr
88
+ - wrapperFunc
89
+
90
+ # Opinionated
91
+ - initClause
92
+ - nestingReduce
93
+ - ptrToRefParam
94
+ - typeUnparen
95
+ - unnecessaryBlock
96
+ # - builtinShadow
97
+ # - importShadow
98
+ - paramTypeCombine
99
+ # - unnamedResult
Original file line number Diff line number Diff line change @@ -78,8 +78,8 @@ var serveCmd = &cobra.Command{
78
78
}
79
79
}()
80
80
81
- // gracefull shutdown
82
- sigChan := make (chan os.Signal )
81
+ // graceful shutdown
82
+ sigChan := make (chan os.Signal , 1 )
83
83
signal .Notify (sigChan , syscall .SIGINT , syscall .SIGTERM )
84
84
<- sigChan
85
85
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ import (
11
11
type Job struct {
12
12
}
13
13
14
- /// Crawler
14
+ // Crawler
15
15
type Crawler struct {
16
16
db * gorm.DB
17
17
workerChan chan * Job
@@ -29,7 +29,7 @@ func NewCrawler(db *gorm.DB) *Crawler {
29
29
return crawler
30
30
}
31
31
32
- /// Run intended to be run from a go routine
32
+ // Run intended to be run from a go routine
33
33
func (c * Crawler ) Run (concurrency int , stopCh <- chan struct {}) {
34
34
go c .Scheduler (stopCh )
35
35
for i := 0 ; i < concurrency ; i ++ {
@@ -38,7 +38,7 @@ func (c *Crawler) Run(concurrency int, stopCh <-chan struct{}) {
38
38
<- stopCh
39
39
}
40
40
41
- /// Scheduler intended to be run from a goroutine
41
+ // Scheduler intended to be run from a goroutine
42
42
func (c * Crawler ) Scheduler (stopCh <- chan struct {}) {
43
43
log .Debug ("Starting scheduler" )
44
44
defer log .Debug ("Stopping scheduler" )
Original file line number Diff line number Diff line change @@ -5,25 +5,18 @@ import (
5
5
"strings"
6
6
7
7
"github.com/jinzhu/gorm"
8
+ // import postgres
8
9
_ "github.com/jinzhu/gorm/dialects/postgres"
10
+ // import sqlite
9
11
_ "github.com/jinzhu/gorm/dialects/sqlite"
10
12
"github.com/labstack/gommon/log"
11
13
"github.com/spf13/viper"
12
14
13
15
"github.com/rphillips/escapepod/pkg/models"
14
16
)
15
17
16
- type DBParams struct {
17
- Host string
18
- Port int
19
- User string
20
- Password string
21
- DBName string
22
- SSLMode string
23
- }
24
-
25
18
func openPostgres (dbURL string ) (* gorm.DB , error ) {
26
- if len ( dbURL ) == 0 {
19
+ if dbURL == "" {
27
20
dbURL = strings .Join ([]string {
28
21
"host=" + viper .GetString ("db.host" ),
29
22
"port=" + viper .GetString ("db.port" ),
Original file line number Diff line number Diff line change @@ -83,12 +83,16 @@ func PodcastsImport(c echo.Context) error {
83
83
if err != nil {
84
84
return c .JSON (http .StatusBadRequest , err )
85
85
}
86
- go importFromOPML (app , parsed )
86
+ go func () {
87
+ if err := importFromOPML (app , parsed ); err != nil {
88
+ c .Logger ().Errorf ("could not import OPML: %v" , err )
89
+ }
90
+ }()
87
91
return c .JSON (http .StatusOK , "OK" )
88
92
}
89
93
90
94
func importFromOPML (app * app.App , o * opml.OPML ) error {
91
- if len (o .Body .Outline ) < = 0 {
95
+ if len (o .Body .Outline ) = = 0 {
92
96
return fmt .Errorf ("invalid opml" )
93
97
}
94
98
if o .Body .Outline [0 ].Text != "feeds" {
Original file line number Diff line number Diff line change @@ -5,7 +5,10 @@ import (
5
5
"bytes"
6
6
"image"
7
7
"image/jpeg"
8
+
9
+ // import png to support png
8
10
_ "image/png"
11
+
9
12
"io"
10
13
"io/ioutil"
11
14
"net/http"
@@ -36,8 +39,8 @@ type Podcast struct {
36
39
func (p * Podcast ) Crawl () error {
37
40
parser := gofeed .NewParser ()
38
41
var feed * gofeed.Feed
39
- if strings .HasPrefix ("file://" , * p . FeedURL ) {
40
- fileData , err := ioutil .ReadFile (strings .TrimPrefix ("file://" , * p . FeedURL ))
42
+ if strings .HasPrefix (* p . FeedURL , "file://" ) {
43
+ fileData , err := ioutil .ReadFile (strings .TrimPrefix (* p . FeedURL , "file://" ))
41
44
if err != nil {
42
45
return err
43
46
}
Original file line number Diff line number Diff line change @@ -15,14 +15,12 @@ func RegisterRoutes(r *echo.Echo, fs stuffbin.FileSystem) {
15
15
r .GET ("/*" , echo .WrapHandler (fs .FileServer ()))
16
16
17
17
api := r .Group ("/api/v1" )
18
- {
19
- api .POST ("/podcasts" , handlers .PodcastsCreate )
20
- api .POST ("/podcasts/import" , handlers .PodcastsImport )
21
- api .GET ("/podcasts" , handlers .PodcastsList )
22
- api .GET ("/podcasts/:id" , handlers .PodcastsGet )
23
- api .GET ("/podcasts/:id/episodes" , handlers .PodcastsGetEpisodes )
24
- api .GET ("/podcasts/:id/image" , handlers .PodcastsImageGet )
25
- }
18
+ api .POST ("/podcasts" , handlers .PodcastsCreate )
19
+ api .POST ("/podcasts/import" , handlers .PodcastsImport )
20
+ api .GET ("/podcasts" , handlers .PodcastsList )
21
+ api .GET ("/podcasts/:id" , handlers .PodcastsGet )
22
+ api .GET ("/podcasts/:id/episodes" , handlers .PodcastsGetEpisodes )
23
+ api .GET ("/podcasts/:id/image" , handlers .PodcastsImageGet )
26
24
}
27
25
28
26
func handleIndexPage (c echo.Context ) error {
You can’t perform that action at this time.
0 commit comments