This commit is contained in:
4
.github/workflows/build.yml
vendored
4
.github/workflows/build.yml
vendored
@@ -16,7 +16,9 @@ jobs:
|
|||||||
go-version: '1.22'
|
go-version: '1.22'
|
||||||
- name: Copy go-semantic-release plugins and release
|
- name: Copy go-semantic-release plugins and release
|
||||||
run: |
|
run: |
|
||||||
/usr/local/bin/semantic-release --version-file \
|
/usr/local/bin/semantic-release \
|
||||||
|
--allow-initial-development-versions \
|
||||||
|
--version-file \
|
||||||
--changelog .generated-go-semantic-release-changelog.md \
|
--changelog .generated-go-semantic-release-changelog.md \
|
||||||
--hooks goreleaser \
|
--hooks goreleaser \
|
||||||
--provider=gitea
|
--provider=gitea
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ builds:
|
|||||||
main: main.go
|
main: main.go
|
||||||
ldflags:
|
ldflags:
|
||||||
- -extldflags '-static'
|
- -extldflags '-static'
|
||||||
- -s -w -X hub.cybercinch.nz/guisea/go-template/internal/app/meta.Version={{.Version}}
|
- -s -w -X hub.cybercinch.nz/guisea/gosqldump/internal/app/meta.Version={{.Version}}
|
||||||
|
|
||||||
gitea_urls:
|
gitea_urls:
|
||||||
api: https://hub.cybercinch.nz/api/v1
|
api: https://hub.cybercinch.nz/api/v1
|
||||||
|
|||||||
12
README.md
12
README.md
@@ -32,7 +32,7 @@ Press this shiny green button on top
|
|||||||
|
|
||||||
<img width="203" alt="Screenshot 2022-09-30 at 13 37 30" src="https://user-images.githubusercontent.com/62389790/193252456-42b966a7-2679-4868-bf25-d862524733ee.png">
|
<img width="203" alt="Screenshot 2022-09-30 at 13 37 30" src="https://user-images.githubusercontent.com/62389790/193252456-42b966a7-2679-4868-bf25-d862524733ee.png">
|
||||||
|
|
||||||
Then you would probably want to rename go mod name from `hub.cybercinch.nz/guisea/go-template` to something else.
|
Then you would probably want to rename go mod name from `hub.cybercinch.nz/guisea/gosqldump` to something else.
|
||||||
To do this you could use your IDE refactor features or run [just](https://github.com/casey/just) target.
|
To do this you could use your IDE refactor features or run [just](https://github.com/casey/just) target.
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
@@ -45,17 +45,17 @@ This will prompt you to type a new name and will replace every occurence of the
|
|||||||
|
|
||||||
### Changing name of the app
|
### Changing name of the app
|
||||||
|
|
||||||
Change the value of the constant `Name` at [internal/app/meta.go](https://hub.cybercinch.nz/guisea/go-template/src/branch/main/internal/app/meta.go)
|
Change the value of the constant `Name` at [internal/app/meta.go](https://hub.cybercinch.nz/guisea/gosqldump/src/branch/main/internal/app/meta.go)
|
||||||
|
|
||||||
### Changing config file format from TOML from YAML
|
### Changing config file format from TOML from YAML
|
||||||
|
|
||||||
Change the value of the constant `ConfigFormat` at [internal/config/init.go](https://hub.cybercinch.nz/guisea/go-template/src/branch/main/internal/config/init.go)
|
Change the value of the constant `ConfigFormat` at [internal/config/init.go](https://hub.cybercinch.nz/guisea/gosqldump/src/branch/main/internal/config/init.go)
|
||||||
|
|
||||||
### Declaring new config fields
|
### Declaring new config fields
|
||||||
|
|
||||||
Firstly, declare a field key name as a constant inside [internal/config/key/keys.go](https://hub.cybercinch.nz/guisea/go-template/src/branch/main/internal/config/key/keys.go)
|
Firstly, declare a field key name as a constant inside [internal/config/key/keys.go](https://hub.cybercinch.nz/guisea/gosqldump/src/branch/main/internal/config/key/keys.go)
|
||||||
|
|
||||||
Then put them inside [config/default.go](https://hub.cybercinch.nz/guisea/go-template/src/branch/main/internal/config/default.go) (take a predefined fields for logging as a reference)
|
Then put them inside [config/default.go](https://hub.cybercinch.nz/guisea/gosqldump/src/branch/main/internal/config/default.go) (take a predefined fields for logging as a reference)
|
||||||
|
|
||||||
For example
|
For example
|
||||||
|
|
||||||
@@ -82,4 +82,4 @@ For the example above it would be `viper.GetString(key.EmojiType)`. See [viper](
|
|||||||
|
|
||||||
## Something is not clear?
|
## Something is not clear?
|
||||||
|
|
||||||
Please, [open an issue](https://hub.cybercinch.nz/guisea/go-template/issues/new) so I could document it
|
Please, [open an issue](https://hub.cybercinch.nz/guisea/gosqldump/issues/new) so I could document it
|
||||||
|
|||||||
12
cmd/clear.go
12
cmd/clear.go
@@ -6,12 +6,12 @@ import (
|
|||||||
|
|
||||||
"github.com/samber/lo"
|
"github.com/samber/lo"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"hub.cybercinch.nz/guisea/go-template/internal/app"
|
"hub.cybercinch.nz/guisea/gosqldump/internal/app"
|
||||||
"hub.cybercinch.nz/guisea/go-template/internal/color"
|
"hub.cybercinch.nz/guisea/gosqldump/internal/color"
|
||||||
"hub.cybercinch.nz/guisea/go-template/internal/filesystem"
|
"hub.cybercinch.nz/guisea/gosqldump/internal/filesystem"
|
||||||
"hub.cybercinch.nz/guisea/go-template/internal/icon"
|
"hub.cybercinch.nz/guisea/gosqldump/internal/icon"
|
||||||
"hub.cybercinch.nz/guisea/go-template/internal/util"
|
"hub.cybercinch.nz/guisea/gosqldump/internal/util"
|
||||||
"hub.cybercinch.nz/guisea/go-template/internal/where"
|
"hub.cybercinch.nz/guisea/gosqldump/internal/where"
|
||||||
)
|
)
|
||||||
|
|
||||||
type clearTarget struct {
|
type clearTarget struct {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package cmd
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/charmbracelet/log"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"slices"
|
"slices"
|
||||||
@@ -11,19 +12,19 @@ import (
|
|||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
"github.com/charmbracelet/lipgloss"
|
"github.com/charmbracelet/lipgloss"
|
||||||
"hub.cybercinch.nz/guisea/go-template/internal/style"
|
"hub.cybercinch.nz/guisea/gosqldump/internal/style"
|
||||||
|
|
||||||
"hub.cybercinch.nz/guisea/go-template/internal/app"
|
"hub.cybercinch.nz/guisea/gosqldump/internal/app"
|
||||||
|
|
||||||
levenshtein "github.com/ka-weihe/fast-levenshtein"
|
levenshtein "github.com/ka-weihe/fast-levenshtein"
|
||||||
"github.com/samber/lo"
|
"github.com/samber/lo"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
"hub.cybercinch.nz/guisea/go-template/internal/color"
|
"hub.cybercinch.nz/guisea/gosqldump/internal/color"
|
||||||
"hub.cybercinch.nz/guisea/go-template/internal/config"
|
"hub.cybercinch.nz/guisea/gosqldump/internal/config"
|
||||||
"hub.cybercinch.nz/guisea/go-template/internal/filesystem"
|
"hub.cybercinch.nz/guisea/gosqldump/internal/filesystem"
|
||||||
"hub.cybercinch.nz/guisea/go-template/internal/icon"
|
"hub.cybercinch.nz/guisea/gosqldump/internal/icon"
|
||||||
"hub.cybercinch.nz/guisea/go-template/internal/where"
|
"hub.cybercinch.nz/guisea/gosqldump/internal/where"
|
||||||
)
|
)
|
||||||
|
|
||||||
// errUnknownKey will generate error for key that was not found and will provide a hint
|
// errUnknownKey will generate error for key that was not found and will provide a hint
|
||||||
@@ -127,7 +128,6 @@ var configSetCmd = &cobra.Command{
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
handleErr(fmt.Errorf("invalid integer value: %s", value))
|
handleErr(fmt.Errorf("invalid integer value: %s", value))
|
||||||
}
|
}
|
||||||
|
|
||||||
v = int(parsedInt)
|
v = int(parsedInt)
|
||||||
case bool:
|
case bool:
|
||||||
parsedBool, err := strconv.ParseBool(value)
|
parsedBool, err := strconv.ParseBool(value)
|
||||||
@@ -136,6 +136,7 @@ var configSetCmd = &cobra.Command{
|
|||||||
}
|
}
|
||||||
|
|
||||||
v = parsedBool
|
v = parsedBool
|
||||||
|
log.Debug("Parsed Bool Value: %v", parsedBool)
|
||||||
}
|
}
|
||||||
|
|
||||||
write:
|
write:
|
||||||
|
|||||||
10
cmd/root.go
10
cmd/root.go
@@ -3,17 +3,17 @@ package cmd
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/charmbracelet/log"
|
"github.com/charmbracelet/log"
|
||||||
"hub.cybercinch.nz/guisea/go-template/internal/style"
|
"hub.cybercinch.nz/guisea/gosqldump/internal/style"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
cc "github.com/ivanpirog/coloredcobra"
|
cc "github.com/ivanpirog/coloredcobra"
|
||||||
"github.com/samber/lo"
|
"github.com/samber/lo"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"hub.cybercinch.nz/guisea/go-template/internal/app"
|
"hub.cybercinch.nz/guisea/gosqldump/internal/app"
|
||||||
"hub.cybercinch.nz/guisea/go-template/internal/filesystem"
|
"hub.cybercinch.nz/guisea/gosqldump/internal/filesystem"
|
||||||
"hub.cybercinch.nz/guisea/go-template/internal/icon"
|
"hub.cybercinch.nz/guisea/gosqldump/internal/icon"
|
||||||
"hub.cybercinch.nz/guisea/go-template/internal/where"
|
"hub.cybercinch.nz/guisea/gosqldump/internal/where"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ import (
|
|||||||
"runtime"
|
"runtime"
|
||||||
|
|
||||||
"github.com/samber/lo"
|
"github.com/samber/lo"
|
||||||
"hub.cybercinch.nz/guisea/go-template/internal/app"
|
"hub.cybercinch.nz/guisea/gosqldump/internal/app"
|
||||||
"hub.cybercinch.nz/guisea/go-template/internal/color"
|
"hub.cybercinch.nz/guisea/gosqldump/internal/color"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -6,9 +6,9 @@ import (
|
|||||||
|
|
||||||
"github.com/samber/lo"
|
"github.com/samber/lo"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"hub.cybercinch.nz/guisea/go-template/internal/app"
|
"hub.cybercinch.nz/guisea/gosqldump/internal/app"
|
||||||
"hub.cybercinch.nz/guisea/go-template/internal/color"
|
"hub.cybercinch.nz/guisea/gosqldump/internal/color"
|
||||||
"hub.cybercinch.nz/guisea/go-template/internal/where"
|
"hub.cybercinch.nz/guisea/gosqldump/internal/where"
|
||||||
)
|
)
|
||||||
|
|
||||||
type whereTarget struct {
|
type whereTarget struct {
|
||||||
|
|||||||
2
go.mod
2
go.mod
@@ -1,4 +1,4 @@
|
|||||||
module hub.cybercinch.nz/guisea/go-template
|
module hub.cybercinch.nz/guisea/gosqldump
|
||||||
|
|
||||||
go 1.22.1
|
go 1.22.1
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ const Version = "0.0.1"
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
// App is the name of the application
|
// App is the name of the application
|
||||||
Name = "app"
|
Name = "gosqldump"
|
||||||
|
|
||||||
// DescriptionShort short description of the app
|
// DescriptionShort short description of the app
|
||||||
DescriptionShort = Name + " description"
|
DescriptionShort = Name + " description"
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package config
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
"hub.cybercinch.nz/guisea/go-template/internal/config/key"
|
"hub.cybercinch.nz/guisea/gosqldump/internal/config/key"
|
||||||
)
|
)
|
||||||
|
|
||||||
// fields is the config fields with their default values and descriptions
|
// fields is the config fields with their default values and descriptions
|
||||||
@@ -25,6 +25,26 @@ fatal, error, warn, info, debug`,
|
|||||||
false,
|
false,
|
||||||
"Whether the logger should report the caller location.",
|
"Whether the logger should report the caller location.",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Key: key.MySQLHost,
|
||||||
|
DefaultValue: "localhost",
|
||||||
|
Description: "The MySQL/MariaDB hostname",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Key: key.MySQLPort,
|
||||||
|
DefaultValue: 3306,
|
||||||
|
Description: "The MySQL/MariaDB Port to Connect to",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Key: key.MySQLUser,
|
||||||
|
DefaultValue: "~",
|
||||||
|
Description: "The MySQL/MariaDB Username to connect with",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Key: key.MySQLPassword,
|
||||||
|
DefaultValue: "~",
|
||||||
|
Description: "The MySQL/MariaDB Password to connect with",
|
||||||
|
},
|
||||||
//{
|
//{
|
||||||
// key.TenantId,
|
// key.TenantId,
|
||||||
// "some_client_id",
|
// "some_client_id",
|
||||||
|
|||||||
@@ -11,9 +11,9 @@ import (
|
|||||||
|
|
||||||
"github.com/samber/lo"
|
"github.com/samber/lo"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
"hub.cybercinch.nz/guisea/go-template/internal/app"
|
"hub.cybercinch.nz/guisea/gosqldump/internal/app"
|
||||||
|
|
||||||
"hub.cybercinch.nz/guisea/go-template/internal/color"
|
"hub.cybercinch.nz/guisea/gosqldump/internal/color"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Field struct {
|
type Field struct {
|
||||||
|
|||||||
@@ -4,9 +4,9 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
"hub.cybercinch.nz/guisea/go-template/internal/app"
|
"hub.cybercinch.nz/guisea/gosqldump/internal/app"
|
||||||
"hub.cybercinch.nz/guisea/go-template/internal/filesystem"
|
"hub.cybercinch.nz/guisea/gosqldump/internal/filesystem"
|
||||||
"hub.cybercinch.nz/guisea/go-template/internal/where"
|
"hub.cybercinch.nz/guisea/gosqldump/internal/where"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ConfigFormat is the format of the config file
|
// ConfigFormat is the format of the config file
|
||||||
|
|||||||
@@ -4,4 +4,8 @@ const (
|
|||||||
LogsWrite = "logs.write"
|
LogsWrite = "logs.write"
|
||||||
LogsLevel = "logs.level"
|
LogsLevel = "logs.level"
|
||||||
LogsReportCaller = "logs.show_caller"
|
LogsReportCaller = "logs.show_caller"
|
||||||
|
MySQLUser = "mysql.user"
|
||||||
|
MySQLPassword = "mysql.password"
|
||||||
|
MySQLHost = "mysql.host"
|
||||||
|
MySQLPort = "mysql.port"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -5,14 +5,14 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"github.com/charmbracelet/log"
|
"github.com/charmbracelet/log"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
"hub.cybercinch.nz/guisea/go-template/internal/config/key"
|
"hub.cybercinch.nz/guisea/gosqldump/internal/config/key"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/samber/lo"
|
"github.com/samber/lo"
|
||||||
"hub.cybercinch.nz/guisea/go-template/internal/filesystem"
|
"hub.cybercinch.nz/guisea/gosqldump/internal/filesystem"
|
||||||
"hub.cybercinch.nz/guisea/go-template/internal/where"
|
"hub.cybercinch.nz/guisea/gosqldump/internal/where"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Init() error {
|
func Init() error {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package style
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/charmbracelet/lipgloss"
|
"github.com/charmbracelet/lipgloss"
|
||||||
"hub.cybercinch.nz/guisea/go-template/internal/color"
|
"hub.cybercinch.nz/guisea/gosqldump/internal/color"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package where
|
|||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"hub.cybercinch.nz/guisea/go-template/internal/app"
|
"hub.cybercinch.nz/guisea/gosqldump/internal/app"
|
||||||
)
|
)
|
||||||
|
|
||||||
// EnvConfigPath is the environment variable name for the config path
|
// EnvConfigPath is the environment variable name for the config path
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package where
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/samber/lo"
|
"github.com/samber/lo"
|
||||||
"hub.cybercinch.nz/guisea/go-template/internal/filesystem"
|
"hub.cybercinch.nz/guisea/gosqldump/internal/filesystem"
|
||||||
"os"
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
|
||||||
"hub.cybercinch.nz/guisea/go-template/internal/app"
|
"hub.cybercinch.nz/guisea/gosqldump/internal/app"
|
||||||
)
|
)
|
||||||
|
|
||||||
func home() string {
|
func home() string {
|
||||||
|
|||||||
6
main.go
6
main.go
@@ -3,9 +3,9 @@ package main
|
|||||||
import (
|
import (
|
||||||
"github.com/charmbracelet/log"
|
"github.com/charmbracelet/log"
|
||||||
"github.com/samber/lo"
|
"github.com/samber/lo"
|
||||||
"hub.cybercinch.nz/guisea/go-template/cmd"
|
"hub.cybercinch.nz/guisea/gosqldump/cmd"
|
||||||
"hub.cybercinch.nz/guisea/go-template/internal/config"
|
"hub.cybercinch.nz/guisea/gosqldump/internal/config"
|
||||||
"hub.cybercinch.nz/guisea/go-template/internal/logger"
|
"hub.cybercinch.nz/guisea/gosqldump/internal/logger"
|
||||||
"os"
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user