Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve the package #50

Merged
merged 1 commit into from
Jul 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/pull-request.yaml
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// package pkg provides the placeholder of pkg

package pkg
Loading