Skip to content

Commit

Permalink
fix: added lint check
Browse files Browse the repository at this point in the history
  • Loading branch information
xavidop committed Dec 23, 2022
1 parent 1ec9fd2 commit 776a23f
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 12 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: golangci-lint
on:
push:
tags:
- v*
branches:
- master
pull_request:
permissions:
contents: read

jobs:
golangci:
permissions:
contents: read # for actions/checkout to fetch code
pull-requests: read # for golangci/golangci-lint-action to fetch pull requests
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v3
with:
go-version: 1.19
- uses: actions/checkout@v3
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
skip-go-installation: true
args: --timeout=5m
4 changes: 2 additions & 2 deletions .github/workflows/master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ jobs:

steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 0 # See: https://goreleaser.com/ci/actions/

- name: Set up Go 1.19
uses: actions/setup-go@v2
uses: actions/setup-go@v3
with:
go-version: 1.19
id: go
Expand Down
4 changes: 3 additions & 1 deletion cmd/agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ var agentCmd = &cobra.Command{
Aliases: []string{"agent", "a"},
Short: "Actions on agent commands",
Run: func(cmd *cobra.Command, args []string) {
cmd.Help()
if err := cmd.Help(); err != nil {
os.Exit(1)
}
os.Exit(0)
},
PersistentPreRun: func(cmd *cobra.Command, args []string) {
Expand Down
4 changes: 3 additions & 1 deletion cmd/cicd/cicd.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ var cicdCmd = &cobra.Command{
Aliases: []string{"cicd", "ci", "cd"},
Short: "Actions on CICD testings",
Run: func(cmd *cobra.Command, args []string) {
cmd.Help()
if err := cmd.Help(); err != nil {
os.Exit(1)
}
os.Exit(0)
},
PersistentPreRun: func(cmd *cobra.Command, args []string) {
Expand Down
4 changes: 3 additions & 1 deletion cmd/profilenlu/profilenlu.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ var profilenluCmd = &cobra.Command{
Aliases: []string{"test", "t", "tests"},
Short: "Actions on testing",
Run: func(cmd *cobra.Command, args []string) {
cmd.Help()
if err := cmd.Help(); err != nil {
os.Exit(1)
}
os.Exit(0)
},
PersistentPreRun: func(cmd *cobra.Command, args []string) {
Expand Down
4 changes: 3 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ You can find the documentation at https://github.com/xavidop/dialogflow-cx-cli.
Please file all bug reports on Github at https://github.com/xavidop/dialogflow-cx-cli/issues.`,
Run: func(cmd *cobra.Command, args []string) {
if len(args) == 0 {
cmd.Help()
if err := cmd.Help(); err != nil {
os.Exit(1)
}
os.Exit(0)
}
},
Expand Down
4 changes: 3 additions & 1 deletion cmd/stt/stt.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ var sttCmd = &cobra.Command{
Aliases: []string{"stt", "speech-to-text"},
Short: "Actions on speech-to-text commands",
Run: func(cmd *cobra.Command, args []string) {
cmd.Help()
if err := cmd.Help(); err != nil {
os.Exit(1)
}
os.Exit(0)
},
PersistentPreRun: func(cmd *cobra.Command, args []string) {
Expand Down
4 changes: 3 additions & 1 deletion cmd/tts/tts.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ var ttsCmd = &cobra.Command{
Aliases: []string{"tts", "text-to-speech"},
Short: "Actions on text-to-speech commands",
Run: func(cmd *cobra.Command, args []string) {
cmd.Help()
if err := cmd.Help(); err != nil {
os.Exit(1)
}
os.Exit(0)
},
PersistentPreRun: func(cmd *cobra.Command, args []string) {
Expand Down
8 changes: 4 additions & 4 deletions pkg/cx/sessionsclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func DetectIntentFromText(sessionClient *cx.SessionsClient, agent *cxpb.Agent, l
LanguageCode: localeId,
}

response, err := DetectIntent(sessionClient, agent, queryInput)
response, err := DetectIntent(sessionClient, agent, &queryInput)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -70,20 +70,20 @@ func DetectIntentFromAudio(sessionClient *cx.SessionsClient, agent *cxpb.Agent,
LanguageCode: localeId,
}

response, err := DetectIntent(sessionClient, agent, queryInput)
response, err := DetectIntent(sessionClient, agent, &queryInput)
if err != nil {
return nil, err
}

return response, nil
}

func DetectIntent(sessionClient *cx.SessionsClient, agent *cxpb.Agent, queryinput cxpb.QueryInput) (*cxpb.DetectIntentResponse, error) {
func DetectIntent(sessionClient *cx.SessionsClient, agent *cxpb.Agent, queryinput *cxpb.QueryInput) (*cxpb.DetectIntentResponse, error) {
ctx := context.Background()

sessionPath := fmt.Sprintf("%s/sessions/%s", agent.GetName(), uuid.NewString())

request := cxpb.DetectIntentRequest{Session: sessionPath, QueryInput: &queryinput}
request := cxpb.DetectIntentRequest{Session: sessionPath, QueryInput: queryinput}

response, err := sessionClient.DetectIntent(ctx, &request)
if err != nil {
Expand Down

0 comments on commit 776a23f

Please sign in to comment.