Skip to content
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
5 changes: 1 addition & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This workflow will build a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go

name: Build & Test
name: Build

on:
push:
Expand All @@ -23,6 +23,3 @@ jobs:

- name: Build
run: go build -v ./...

- name: Test
run: go test -v ./...
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: Release

on:
pull_request:
push:
branches: [ "main" ]
tags:
- "*"

Expand Down
21 changes: 21 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Test

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.23'

- name: Test
run: go test -v ./...
10 changes: 5 additions & 5 deletions generator/cmd/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import (
"errors"
"fmt"
"log"
"os"
"os/exec"
"strings"
Expand Down Expand Up @@ -58,7 +58,7 @@
return nil, err
}
if len(mfs) == 0 {
fmt.Printf("error: cannot find fields for model %s, cannot generate it.\n", model)
log.Printf("error: cannot find fields for model %s, cannot generate it.\n", model)
continue
}
idExists := false
Expand All @@ -68,8 +68,8 @@
break
}
}
if idExists == false {
fmt.Printf("error: cannot find ID field for model %s, cannot generate it.\n", model)
if !idExists {
log.Printf("error: cannot find ID field for model %s, cannot generate it.\n", model)
continue
}
mm = append(mm, newModel(model, mfs))
Expand Down Expand Up @@ -110,7 +110,7 @@

func (g *Generator) generateModels(models []*model) error {
for _, m := range models {
filePath := g.destFolder + "/" + strings.Replace(m.Name, ".", "_", -1) + ".go"

Check failure on line 113 in generator/cmd/generator.go

View workflow job for this annotation

GitHub Actions / lint

wrapperFunc: use strings.ReplaceAll method in `strings.Replace(m.Name, ".", "_", -1)` (gocritic)
output, err := os.Create(filePath)
if err != nil {
return err
Expand All @@ -123,7 +123,7 @@
return err
}
}
fmt.Printf("%s has been generated\n", filePath)
log.Printf("%s has been generated\n", filePath)
}
return nil
}
6 changes: 2 additions & 4 deletions generator/cmd/root.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package cmd

import (
"fmt"
"os"
"log"
"strings"
"text/template"

Expand Down Expand Up @@ -85,6 +84,5 @@ func initTemplate() {
}

func handleError(err error) {
fmt.Println(err)
os.Exit(1)
log.Fatal(err)
}
2 changes: 1 addition & 1 deletion web_editor_converter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ type WebEditorConverterTests []WebEditorConverterTest
const WebEditorConverterTestModel = "web_editor.converter.test"

// Many2One convert WebEditorConverterTest to *Many2One.
func (wct *WebEditorConverterTest) Many2One() *Many2One {
func (wct *WebEditorConverterTest) Many2OneConversion() *Many2One {
return NewMany2One(wct.Id.Get(), "")
}

Expand Down
Loading