feat: Project Started 🎉
All checks were successful
CI / build (push) Successful in 2m59s

This commit is contained in:
2024-08-30 12:21:09 +12:00
parent 0cd89c0707
commit 2f43e96904
20 changed files with 77 additions and 50 deletions

View File

@@ -16,7 +16,9 @@ jobs:
go-version: '1.22'
- name: Copy go-semantic-release plugins and release
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 \
--hooks goreleaser \
--provider=gitea

View File

@@ -11,7 +11,7 @@ builds:
main: main.go
ldflags:
- -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:
api: https://hub.cybercinch.nz/api/v1

View File

@@ -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">
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.
```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
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
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
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
@@ -82,4 +82,4 @@ For the example above it would be `viper.GetString(key.EmojiType)`. See [viper](
## 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

View File

@@ -6,12 +6,12 @@ import (
"github.com/samber/lo"
"github.com/spf13/cobra"
"hub.cybercinch.nz/guisea/go-template/internal/app"
"hub.cybercinch.nz/guisea/go-template/internal/color"
"hub.cybercinch.nz/guisea/go-template/internal/filesystem"
"hub.cybercinch.nz/guisea/go-template/internal/icon"
"hub.cybercinch.nz/guisea/go-template/internal/util"
"hub.cybercinch.nz/guisea/go-template/internal/where"
"hub.cybercinch.nz/guisea/gosqldump/internal/app"
"hub.cybercinch.nz/guisea/gosqldump/internal/color"
"hub.cybercinch.nz/guisea/gosqldump/internal/filesystem"
"hub.cybercinch.nz/guisea/gosqldump/internal/icon"
"hub.cybercinch.nz/guisea/gosqldump/internal/util"
"hub.cybercinch.nz/guisea/gosqldump/internal/where"
)
type clearTarget struct {

View File

@@ -3,6 +3,7 @@ package cmd
import (
"errors"
"fmt"
"github.com/charmbracelet/log"
"os"
"path/filepath"
"slices"
@@ -11,19 +12,19 @@ import (
"unsafe"
"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"
"github.com/samber/lo"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"hub.cybercinch.nz/guisea/go-template/internal/color"
"hub.cybercinch.nz/guisea/go-template/internal/config"
"hub.cybercinch.nz/guisea/go-template/internal/filesystem"
"hub.cybercinch.nz/guisea/go-template/internal/icon"
"hub.cybercinch.nz/guisea/go-template/internal/where"
"hub.cybercinch.nz/guisea/gosqldump/internal/color"
"hub.cybercinch.nz/guisea/gosqldump/internal/config"
"hub.cybercinch.nz/guisea/gosqldump/internal/filesystem"
"hub.cybercinch.nz/guisea/gosqldump/internal/icon"
"hub.cybercinch.nz/guisea/gosqldump/internal/where"
)
// 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 {
handleErr(fmt.Errorf("invalid integer value: %s", value))
}
v = int(parsedInt)
case bool:
parsedBool, err := strconv.ParseBool(value)
@@ -136,6 +136,7 @@ var configSetCmd = &cobra.Command{
}
v = parsedBool
log.Debug("Parsed Bool Value: %v", parsedBool)
}
write:

View File

@@ -3,17 +3,17 @@ package cmd
import (
"fmt"
"github.com/charmbracelet/log"
"hub.cybercinch.nz/guisea/go-template/internal/style"
"hub.cybercinch.nz/guisea/gosqldump/internal/style"
"os"
"strings"
cc "github.com/ivanpirog/coloredcobra"
"github.com/samber/lo"
"github.com/spf13/cobra"
"hub.cybercinch.nz/guisea/go-template/internal/app"
"hub.cybercinch.nz/guisea/go-template/internal/filesystem"
"hub.cybercinch.nz/guisea/go-template/internal/icon"
"hub.cybercinch.nz/guisea/go-template/internal/where"
"hub.cybercinch.nz/guisea/gosqldump/internal/app"
"hub.cybercinch.nz/guisea/gosqldump/internal/filesystem"
"hub.cybercinch.nz/guisea/gosqldump/internal/icon"
"hub.cybercinch.nz/guisea/gosqldump/internal/where"
)
func init() {

View File

@@ -6,8 +6,8 @@ import (
"runtime"
"github.com/samber/lo"
"hub.cybercinch.nz/guisea/go-template/internal/app"
"hub.cybercinch.nz/guisea/go-template/internal/color"
"hub.cybercinch.nz/guisea/gosqldump/internal/app"
"hub.cybercinch.nz/guisea/gosqldump/internal/color"
"github.com/spf13/cobra"
)

View File

@@ -6,9 +6,9 @@ import (
"github.com/samber/lo"
"github.com/spf13/cobra"
"hub.cybercinch.nz/guisea/go-template/internal/app"
"hub.cybercinch.nz/guisea/go-template/internal/color"
"hub.cybercinch.nz/guisea/go-template/internal/where"
"hub.cybercinch.nz/guisea/gosqldump/internal/app"
"hub.cybercinch.nz/guisea/gosqldump/internal/color"
"hub.cybercinch.nz/guisea/gosqldump/internal/where"
)
type whereTarget struct {

2
go.mod
View File

@@ -1,4 +1,4 @@
module hub.cybercinch.nz/guisea/go-template
module hub.cybercinch.nz/guisea/gosqldump
go 1.22.1

View File

@@ -5,7 +5,7 @@ const Version = "0.0.1"
const (
// App is the name of the application
Name = "app"
Name = "gosqldump"
// DescriptionShort short description of the app
DescriptionShort = Name + " description"

View File

@@ -2,7 +2,7 @@ package config
import (
"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
@@ -25,6 +25,26 @@ fatal, error, warn, info, debug`,
false,
"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,
// "some_client_id",

View File

@@ -11,9 +11,9 @@ import (
"github.com/samber/lo"
"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 {

View File

@@ -4,9 +4,9 @@ import (
"strings"
"github.com/spf13/viper"
"hub.cybercinch.nz/guisea/go-template/internal/app"
"hub.cybercinch.nz/guisea/go-template/internal/filesystem"
"hub.cybercinch.nz/guisea/go-template/internal/where"
"hub.cybercinch.nz/guisea/gosqldump/internal/app"
"hub.cybercinch.nz/guisea/gosqldump/internal/filesystem"
"hub.cybercinch.nz/guisea/gosqldump/internal/where"
)
// ConfigFormat is the format of the config file

View File

@@ -4,4 +4,8 @@ const (
LogsWrite = "logs.write"
LogsLevel = "logs.level"
LogsReportCaller = "logs.show_caller"
MySQLUser = "mysql.user"
MySQLPassword = "mysql.password"
MySQLHost = "mysql.host"
MySQLPort = "mysql.port"
)

View File

@@ -5,14 +5,14 @@ import (
"fmt"
"github.com/charmbracelet/log"
"github.com/spf13/viper"
"hub.cybercinch.nz/guisea/go-template/internal/config/key"
"hub.cybercinch.nz/guisea/gosqldump/internal/config/key"
"os"
"path/filepath"
"time"
"github.com/samber/lo"
"hub.cybercinch.nz/guisea/go-template/internal/filesystem"
"hub.cybercinch.nz/guisea/go-template/internal/where"
"hub.cybercinch.nz/guisea/gosqldump/internal/filesystem"
"hub.cybercinch.nz/guisea/gosqldump/internal/where"
)
func Init() error {

View File

@@ -2,7 +2,7 @@ package style
import (
"github.com/charmbracelet/lipgloss"
"hub.cybercinch.nz/guisea/go-template/internal/color"
"hub.cybercinch.nz/guisea/gosqldump/internal/color"
)
var (

View File

@@ -3,7 +3,7 @@ package where
import (
"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

View File

@@ -2,7 +2,7 @@ package where
import (
"github.com/samber/lo"
"hub.cybercinch.nz/guisea/go-template/internal/filesystem"
"hub.cybercinch.nz/guisea/gosqldump/internal/filesystem"
"os"
)

View File

@@ -5,7 +5,7 @@ import (
"path/filepath"
"runtime"
"hub.cybercinch.nz/guisea/go-template/internal/app"
"hub.cybercinch.nz/guisea/gosqldump/internal/app"
)
func home() string {

View File

@@ -3,9 +3,9 @@ package main
import (
"github.com/charmbracelet/log"
"github.com/samber/lo"
"hub.cybercinch.nz/guisea/go-template/cmd"
"hub.cybercinch.nz/guisea/go-template/internal/config"
"hub.cybercinch.nz/guisea/go-template/internal/logger"
"hub.cybercinch.nz/guisea/gosqldump/cmd"
"hub.cybercinch.nz/guisea/gosqldump/internal/config"
"hub.cybercinch.nz/guisea/gosqldump/internal/logger"
"os"
)