From 3797b35f283b6126a2c44c54d858051d6394f7c4 Mon Sep 17 00:00:00 2001 From: Shu Kutsuzawa Date: Mon, 22 Feb 2021 20:35:59 +0900 Subject: [PATCH] fix based on golint --- internal/config/config.go | 4 ++-- internal/http/server.go | 4 ++++ internal/server/server.go | 2 ++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/internal/config/config.go b/internal/config/config.go index 80adf88..4d48fe5 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -51,12 +51,12 @@ type Asset struct { Shasum string `yaml:"shasum" json:"shasum"` } -// Source desribes source for provider +// Source describes source for provider type Source struct { DownloadURL string `yaml:"download_url"` } -// Module decribes config for module +// Module describes config for module type Module struct{} // Parse parse yaml file to go struct diff --git a/internal/http/server.go b/internal/http/server.go index 23437ff..c4e216e 100644 --- a/internal/http/server.go +++ b/internal/http/server.go @@ -12,10 +12,12 @@ import ( "github.com/go-chi/chi" ) +// Server describes the http server type Server struct { server *http.Server } +// NewServer initializes the http server func NewServer(port int, c *config.Config) *Server { r := chi.NewRouter() registerRoute(r, c) @@ -57,6 +59,7 @@ func registerRoute(r *chi.Mux, c *config.Config) { }) } +// Start starts the http server func (s *Server) Start() error { if err := s.server.ListenAndServe(); err != nil && err != http.ErrServerClosed { return fmt.Errorf("http server ListenAndServe: %v", err) @@ -65,6 +68,7 @@ func (s *Server) Start() error { return nil } +// Stop stops the http server func (s *Server) Stop(ctx context.Context) error { if err := s.server.Shutdown(ctx); err != nil { return fmt.Errorf("http server Shutdown: %v", err) diff --git a/internal/server/server.go b/internal/server/server.go index ef9064a..dee4156 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -14,11 +14,13 @@ import ( "github.com/cappyzawa/terraform-registry/internal/http" ) +// Opt has options for the server type Opt struct { ConfigPATH string PIDPATH string } +// Run runs the server func Run(opt *Opt) { os.Exit(run(context.Background(), opt)) }