Skip to content

Commit

Permalink
improve the package (#50)
Browse files Browse the repository at this point in the history
  • Loading branch information
LinuxSuRen committed Jul 28, 2023
1 parent d66f720 commit 854133c
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 15 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/pull-request.yaml
Expand Up @@ -10,10 +10,10 @@ jobs:
name: Build
runs-on: macos-10.15
steps:
- name: Set up Go 1.13
- name: Set up Go 1.18
uses: actions/setup-go@v2.1.3
with:
go-version: 1.13
go-version: 1.18
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v2.3.4
Expand All @@ -29,10 +29,10 @@ jobs:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.13
- name: Set up Go 1.18
uses: actions/setup-go@v2.1.3
with:
go-version: 1.13
go-version: 1.18
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v2.3.4
Expand Down
1 change: 1 addition & 0 deletions Makefile
Expand Up @@ -6,6 +6,7 @@ run:
go run main.go

fmt:
go mod tidy
go fmt ./...

copy: build
Expand Down
13 changes: 13 additions & 0 deletions cmd/root.go
@@ -0,0 +1,13 @@
package cmd

import "github.com/spf13/cobra"

// NewRoot returns the root command of github-go
func NewRoot() *cobra.Command {
return &cobra.Command{
Use: "github-go",
Run: func(cmd *cobra.Command, args []string) {
cmd.Println("hello")
},
}
}
7 changes: 6 additions & 1 deletion go.mod
@@ -1,5 +1,10 @@
module github.com/linuxsuren/github-go

go 1.15
go 1.18

require github.com/spf13/cobra v1.1.1

require (
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
)
2 changes: 2 additions & 0 deletions hack/init.sh
Expand Up @@ -9,3 +9,5 @@ find . -name "*.yaml" -exec sed -i '' s/github-go/"$1"/ {} +
find . -name "*.yml" -exec sed -i '' s/github-go/"$1"/ {} +
find . -name "*.md" -exec sed -i '' s/github-go/"$1"/ {} +
find . -name "*.mod" -exec sed -i '' s/github-go/"$1"/ {} +

make install-pre-commit
16 changes: 6 additions & 10 deletions main.go
@@ -1,17 +1,13 @@
package main

import (
"github.com/spf13/cobra"
"os"

"github.com/linuxsuren/github-go/cmd"
)

func main() {
cmd := &cobra.Command{
Use: "github-go",
Run: func(cmd *cobra.Command, args []string) {
cmd.Println("hello")
},
}
if err := cmd.Execute(); err != nil {
panic(err)
func main() {
if err := cmd.NewRoot().Execute(); err != nil {
os.Exit(1)
}
}
3 changes: 3 additions & 0 deletions pkg/doc.go
@@ -0,0 +1,3 @@
// package pkg provides the placeholder of pkg

package pkg

0 comments on commit 854133c

Please sign in to comment.