Skip to content

Commit

Permalink
Fix lint warn
Browse files Browse the repository at this point in the history
  • Loading branch information
k1LoW committed Oct 5, 2023
1 parent 084ca95 commit 8f550ed
Show file tree
Hide file tree
Showing 13 changed files with 92 additions and 90 deletions.
8 changes: 4 additions & 4 deletions cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ import (
)

const (
// ExitOK for exit code
// ExitOK for exit code.
ExitOK int = 0

// ExitErr for exit code
// ExitErr for exit code.
ExitErr int = 1
)

Expand All @@ -35,7 +35,7 @@ type cli struct {
Version bool `long:"version" short:"v" description:"prints the version number"`
}

// Env struct
// Env struct.
type Env struct {
Out, Err io.Writer
Args []string
Expand All @@ -44,7 +44,7 @@ type Env struct {
Date string
}

// RunCLI runs as cli
// RunCLI runs as cli.
func RunCLI(env Env) int {
cli := &cli{env: env, Interval: -1, PreRelease: false}
return cli.run()
Expand Down
26 changes: 13 additions & 13 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ import (
"github.com/linyows/dewy/repo"
)

// Command for CLI
// Command for CLI.
type Command int

const (
// SERVER command
// SERVER command.
SERVER Command = iota
// ASSETS command
// ASSETS command.
ASSETS
)

// String to string for Command
// String to string for Command.
func (c Command) String() string {
switch c {
case SERVER:
Expand All @@ -29,17 +29,17 @@ func (c Command) String() string {
}
}

// CacheType for cache type
// CacheType for cache type.
type CacheType int

const (
// NONE cache type
// NONE cache type.
NONE CacheType = iota
// FILE cache type
// FILE cache type.
FILE
)

// String to string for CacheType
// String to string for CacheType.
func (c CacheType) String() string {
switch c {
case NONE:
Expand All @@ -51,24 +51,24 @@ func (c CacheType) String() string {
}
}

// CacheConfig struct
// CacheConfig struct.
type CacheConfig struct {
Type CacheType
Expiration int
}

// Config struct
// Config struct.
type Config struct {
Command Command
Repository repo.Config
Cache CacheConfig
Starter starter.Config
}

// OverrideWithEnv overrides by environments
// OverrideWithEnv overrides by environments.
func (c *Config) OverrideWithEnv() {
if c.Repository.Provider == repo.GITHUB {
// Support env GITHUB_ENDPOINT
// Support env GITHUB_ENDPOINT.
e := os.Getenv("GITHUB_ENDPOINT")
if e != "" {
os.Setenv("GITHUB_API_URL", e)
Expand All @@ -80,7 +80,7 @@ func (c *Config) OverrideWithEnv() {
}
}

// DefaultConfig returns default Config
// DefaultConfig returns default Config.
func DefaultConfig() Config {
return Config{
Cache: CacheConfig{
Expand Down
8 changes: 4 additions & 4 deletions dewy.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const (
keepReleases = 7
)

// Dewy struct
// Dewy struct.
type Dewy struct {
config Config
registory registory.Registory
Expand All @@ -42,7 +42,7 @@ type Dewy struct {
sync.RWMutex
}

// New returns Dewy
// New returns Dewy.
func New(c Config) (*Dewy, error) {
kv := &kvs.File{}
kv.Default()
Expand All @@ -67,7 +67,7 @@ func New(c Config) (*Dewy, error) {
}, nil
}

// Start dewy
// Start dewy.
func (d *Dewy) Start(i int) {
ctx, cancel := context.WithCancel(context.WithValue(context.Background(), notice.MetaContextKey, true))
defer cancel()
Expand Down Expand Up @@ -117,7 +117,7 @@ func (d *Dewy) waitSigs() os.Signal {
return sigReceived
}

// Run dewy
// Run dewy.
func (d *Dewy) Run() error {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
Expand Down
10 changes: 5 additions & 5 deletions kvs/consul.go
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
package kvs

// Consul struct
// Consul struct.
type Consul struct {
items map[string]*item //nolint
Host string
Port int
Password string
}

// Read data on Consul
// Read data on Consul.
func (c *Consul) Read(key string) {
}

// Write data to Consul
// Write data to Consul.
func (c *Consul) Write(data string) {
}

// Delete data on Consul
// Delete data on Consul.
func (c *Consul) Delete(key string) {
}

// List returns key from Consul
// List returns key from Consul.
func (c *Consul) List() {
}
22 changes: 11 additions & 11 deletions kvs/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import (
)

var (
// DefaultTempDir creates temp dir
// DefaultTempDir creates temp dir.
DefaultTempDir = createTempDir()
// DefaultMaxSize for data size
// DefaultMaxSize for data size.
DefaultMaxSize int64 = 64 * 1024 * 1024
)

Expand All @@ -23,7 +23,7 @@ func createTempDir() string {
return dir
}

// File struct
// File struct.
type File struct {
items map[string]*item //nolint
dir string
Expand All @@ -32,18 +32,18 @@ type File struct {
MaxSize int64
}

// GetDir returns dir
// GetDir returns dir.
func (f *File) GetDir() string {
return f.dir
}

// Default sets to struct
// Default sets to struct.
func (f *File) Default() {
f.dir = DefaultTempDir
f.MaxSize = DefaultMaxSize
}

// Read data by key from file
// Read data by key from file.
func (f *File) Read(key string) ([]byte, error) {
p := filepath.Join(f.dir, key)
if !IsFileExist(p) {
Expand All @@ -58,7 +58,7 @@ func (f *File) Read(key string) ([]byte, error) {
return content, nil
}

// Write data to file
// Write data to file.
func (f *File) Write(key string, data []byte) error {
dirstat, err := os.Stat(f.dir)
if err != nil {
Expand Down Expand Up @@ -89,7 +89,7 @@ func (f *File) Write(key string, data []byte) error {
return nil
}

// Delete data on file
// Delete data on file.
func (f *File) Delete(key string) error {
p := filepath.Join(f.dir, key)
if !IsFileExist(p) {
Expand All @@ -103,7 +103,7 @@ func (f *File) Delete(key string) error {
return nil
}

// List returns keys from file
// List returns keys from file.
func (f *File) List() ([]string, error) {
files, err := os.ReadDir(f.dir)
if err != nil {
Expand All @@ -118,7 +118,7 @@ func (f *File) List() ([]string, error) {
return list, nil
}

// ExtractArchive extracts by archive
// ExtractArchive extracts by archive.
func ExtractArchive(src, dst string) error {
if !IsFileExist(src) {
return fmt.Errorf("File not found: %s", src)
Expand All @@ -127,7 +127,7 @@ func ExtractArchive(src, dst string) error {
return archiver.Unarchive(src, dst)
}

// IsFileExist checks file exists
// IsFileExist checks file exists.
func IsFileExist(p string) bool {
_, err := os.Stat(p)

Expand Down
6 changes: 3 additions & 3 deletions kvs/kvs.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"time"
)

// KVS interface
// KVS interface.
type KVS interface {
Read(key string) ([]byte, error)
Write(key string, data []byte) error
Expand All @@ -15,11 +15,11 @@ type KVS interface {
GetDir() string
}

// Config struct
// Config struct.
type Config struct {
}

// New returns KVS
// New returns KVS.
func New(t string, c Config) (KVS, error) {
switch t {
case "file":
Expand Down
10 changes: 5 additions & 5 deletions kvs/memory.go
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
package kvs

// Memory struct
// Memory struct.
type Memory struct {
items map[string]*item //nolint
}

// Read data by key on memory
// Read data by key on memory.
func (m *Memory) Read(key string) string {
return ""
}

// Write data to memory
// Write data to memory.
func (m *Memory) Write(data string) bool {
return true
}

// Delete data by key on memory
// Delete data by key on memory.
func (m *Memory) Delete(key string) bool {
return true
}

// List returns keys from memory
// List returns keys from memory.
func (m *Memory) List() {
}
10 changes: 5 additions & 5 deletions kvs/redis.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package kvs

// Redis struct
// Redis struct.
type Redis struct {
items map[string]*item //nolint
Host string
Expand All @@ -9,18 +9,18 @@ type Redis struct {
TTL int
}

// Read data by key on redis
// Read data by key on redis.
func (r *Redis) Read(key string) {
}

// Write data to redis
// Write data to redis.
func (r *Redis) Write(data string) {
}

// Delete key on redis
// Delete key on redis.
func (r *Redis) Delete(key string) {
}

// List returns keys from redis
// List returns keys from redis.
func (r *Redis) List() {
}
8 changes: 4 additions & 4 deletions notice/notice.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@ import (
"os/user"
)

// Notice interface
// Notice interface.
type Notice interface {
String() string
Notify(ctx context.Context, message string)
}

// Field struct
// Field struct.
type Field struct {
Title string
Value string
Short bool
}

// Config struct
// Config struct.
type Config struct {
Command string
Source string
Expand All @@ -31,7 +31,7 @@ type Config struct {
RepoOwnerLink string
}

// New returns Notice
// New returns Notice.
func New(n Notice) (Notice, error) {
switch n.String() {
case "slack":
Expand Down
Loading

0 comments on commit 8f550ed

Please sign in to comment.