Correct all complaints from golint
* i.e. * go get golang.org/x/lint/golint * go list ./... | xargs golint
This commit is contained in:
committed by
Albert Nigmatzianov
parent
9334a46bd6
commit
51f06c7dd1
@ -2,9 +2,10 @@ package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/spf13/cobra/cobra/tpl"
|
||||
"os"
|
||||
"text/template"
|
||||
|
||||
"github.com/spf13/cobra/cobra/tpl"
|
||||
)
|
||||
|
||||
// Project contains name, license and paths to projects.
|
||||
@ -18,14 +19,15 @@ type Project struct {
|
||||
AppName string
|
||||
}
|
||||
|
||||
// Command structure
|
||||
type Command struct {
|
||||
CmdName string
|
||||
CmdParent string
|
||||
*Project
|
||||
}
|
||||
|
||||
// Create project receiver
|
||||
func (p *Project) Create() error {
|
||||
|
||||
// check if AbsolutePath exists
|
||||
if _, err := os.Stat(p.AbsolutePath); os.IsNotExist(err) {
|
||||
// create directory
|
||||
@ -80,6 +82,7 @@ func (p *Project) createLicenseFile() error {
|
||||
return licenseTemplate.Execute(licenseFile, data)
|
||||
}
|
||||
|
||||
// Create command receiver
|
||||
func (c *Command) Create() error {
|
||||
cmdFile, err := os.Create(fmt.Sprintf("%s/cmd/%s.go", c.AbsolutePath, c.CmdName))
|
||||
if err != nil {
|
||||
|
@ -1,5 +1,6 @@
|
||||
package tpl
|
||||
|
||||
// MainTemplate defines main template string
|
||||
func MainTemplate() []byte {
|
||||
return []byte(`/*
|
||||
{{ .Copyright }}
|
||||
@ -15,6 +16,7 @@ func main() {
|
||||
`)
|
||||
}
|
||||
|
||||
// RootTemplate defines root template string
|
||||
func RootTemplate() []byte {
|
||||
return []byte(`/*
|
||||
{{ .Copyright }}
|
||||
@ -108,6 +110,7 @@ func initConfig() {
|
||||
`)
|
||||
}
|
||||
|
||||
// AddCommandTemplate defines add command template string
|
||||
func AddCommandTemplate() []byte {
|
||||
return []byte(`/*
|
||||
{{ .Project.Copyright }}
|
||||
|
Reference in New Issue
Block a user