Skip to content

Commit

Permalink
fix: remove default format verb in strings
Browse files Browse the repository at this point in the history
  • Loading branch information
bastean committed Jun 19, 2024
1 parent acc9047 commit 57beb5e
Show file tree
Hide file tree
Showing 16 changed files with 35 additions and 35 deletions.
4 changes: 2 additions & 2 deletions cmd/codexgo/codex.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ const cli = "codexgo"
var port string

func usage() {
fmt.Printf("Usage: %v [OPTIONS]\n", cli)
fmt.Printf("\nE.g.: %v -p 8080\n\n", cli)
fmt.Printf("Usage: %s [OPTIONS]\n", cli)
fmt.Printf("\nE.g.: %s -p 8080\n\n", cli)
flag.PrintDefaults()
}

Expand Down
8 changes: 4 additions & 4 deletions pkg/cmd/server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,25 +35,25 @@ func InitializePlaywright() {
pw, err = playwright.Run()

if err != nil {
log.Fatalf("could not start playwright: %v", err)
log.Fatalf("could not start playwright: %s", err)
}

browser, err = pw.Chromium.Launch(playwright.BrowserTypeLaunchOptions{Headless: &headless})

if err != nil {
log.Fatalf("could not launch browser: %v", err)
log.Fatalf("could not launch browser: %s", err)
}

browserCtx, err = browser.NewContext(playwright.BrowserNewContextOptions{BaseURL: &testURL})

if err != nil {
log.Fatalf("could not create context: %v", err)
log.Fatalf("could not create context: %s", err)
}

page, err = browserCtx.NewPage()

if err != nil {
log.Fatalf("could not create page: %v", err)
log.Fatalf("could not create page: %s", err)
}
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/server/util/errs/binding.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func BindingJSON(who error, where string) error {
if errors.As(who, &err) {
return errors.NewFailure(
where,
fmt.Sprintf("invalid type field [%v] required type is [%v] and [%v] was obtained", err.Field, err.Type, err.Value),
fmt.Sprintf("invalid type field [%s] required type is [%s] and [%s] was obtained", err.Field, err.Type, err.Value),
who,
)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/server/util/errs/missing.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
func MissingKey(what, where string) error {
return errors.NewInternal(
where,
fmt.Sprintf("failure to obtain the value of the key [%v]", what),
fmt.Sprintf("failure to obtain the value of the key [%s]", what),
nil,
)
}
8 changes: 4 additions & 4 deletions pkg/context/shared/domain/errors/bubble.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,20 @@ type Bubble struct {
}

func (err *Bubble) Error() string {
message := fmt.Sprintf("%v (%v): %v", err.When.Format(time.RFC3339Nano), err.Where, err.What)
message := fmt.Sprintf("%s (%s): %s", err.When.Format(time.RFC3339Nano), err.Where, err.What)

if err.Why != nil {
why, err := json.Marshal(err.Why)

if err != nil {
Panic(fmt.Sprintf("cannot json encoding \"why\" from error bubble: %v: [%v]", message, err.Error()), "Error")
Panic(fmt.Sprintf("cannot json encoding \"why\" from error bubble: %s: [%s]", message, err.Error()), "Error")
}

message = fmt.Sprintf("%v: %v", message, why)
message = fmt.Sprintf("%s: %s", message, why)
}

if err.Who != nil {
message = fmt.Sprintf("%v: [%v]", message, err.Who)
message = fmt.Sprintf("%s: [%s]", message, err.Who)
}

return message
Expand Down
2 changes: 1 addition & 1 deletion pkg/context/shared/domain/errors/bubbleup.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ import (
)

func BubbleUp(who error, where string) error {
return fmt.Errorf("(%v): [%w]", where, who)
return fmt.Errorf("(%s): [%w]", where, who)
}
2 changes: 1 addition & 1 deletion pkg/context/shared/domain/errors/panic.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ import (
)

func Panic(what, where string) {
log.Panicf("(%v): [%v]", where, what)
log.Panicf("(%s): [%s]", where, what)
}
2 changes: 1 addition & 1 deletion pkg/context/shared/domain/queues/naming.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func NewQueueName(queueName *QueueName) string {
}

if trigger != "" {
name = fmt.Sprintf("%v_on_%v", name, trigger)
name = fmt.Sprintf("%s_on_%s", name, trigger)
}

name = strings.ToLower(name)
Expand Down
2 changes: 1 addition & 1 deletion pkg/context/shared/domain/services/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func (create *mother) Email() string {
username := strings.Split(create.Faker.Email(), "@")[0]
domain := "example.com"

return fmt.Sprintf("%v@%v", username, domain)
return fmt.Sprintf("%s@%s", username, domain)
}

var Create = &mother{
Expand Down
6 changes: 3 additions & 3 deletions pkg/context/shared/infrastructure/communications/rabbitmq.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func (rmq *RabbitMQ) AddQueueMessageBind(queue *queues.Queue, bindingKeys []stri
var errWrap error

for _, bindingKey := range bindingKeys {
log.Printf("binding queue %v to exchange %v with routing key %v", queue.Name, rmq.exchange, bindingKey)
log.Printf("binding queue %s to exchange %s with routing key %s", queue.Name, rmq.exchange, bindingKey)

err := rmq.Channel.QueueBind(
queue.Name,
Expand Down Expand Up @@ -148,14 +148,14 @@ func (rmq *RabbitMQ) AddQueueConsumer(consumer models.Consumer) error {
err := json.Unmarshal(delivery.Body, message)

if err != nil {
rmq.Logger.Error(fmt.Sprintf("failed to deliver a message with Id:%v from Queue:%v", message.Id, queue.Name))
rmq.Logger.Error(fmt.Sprintf("failed to deliver a message with Id:%s from Queue:%s", message.Id, queue.Name))
continue
}

err = consumer.On(message)

if err != nil {
rmq.Logger.Error(fmt.Sprintf("failed to consume a message with Id:%v from Queue:%v", message.Id, queue.Name))
rmq.Logger.Error(fmt.Sprintf("failed to consume a message with Id:%s from Queue:%s", message.Id, queue.Name))
continue
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/context/user/domain/valueobj/verified.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func NewVerified(verified bool) (models.ValueObject[bool], error) {
Where: "NewVerified",
What: "invalid verified value",
Why: errors.Meta{
"Verified": fmt.Sprintf("%v", verified),
"Verified": fmt.Sprintf("%s", verified),

Check failure on line 32 in pkg/context/user/domain/valueobj/verified.go

View workflow job for this annotation

GitHub Actions / Lint

Printf format %s has arg #1 of wrong type bool (SA5009)

Check failure on line 32 in pkg/context/user/domain/valueobj/verified.go

View workflow job for this annotation

GitHub Actions / Test

fmt.Sprintf format %s has arg verified of wrong type bool
},
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ func (client *Confirmation) Submit(data any) error {

var message bytes.Buffer

headers := fmt.Sprintf("From: %v\n"+"To: %v\n"+"Subject: Account Confirmation", client.Username, user.Email)
headers := fmt.Sprintf("From: %s\n"+"To: %s\n"+"Subject: Account Confirmation", client.Username, user.Email)

_, _ = message.Write([]byte(fmt.Sprintf("%v\n%v\n", headers, client.MIMEHeaders)))
_, _ = message.Write([]byte(fmt.Sprintf("%s\n%s\n", headers, client.MIMEHeaders)))

link := fmt.Sprintf("%v/verify/%v", client.ServerURL, user.Id)
link := fmt.Sprintf("%s/verify/%s", client.ServerURL, user.Id)

ConfirmationTemplate(user.Username, link).Render(context.Background(), &message)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func (client *Confirmation) Submit(data any) error {
})
}

link := fmt.Sprintf("Hi %v, please confirm your account through this link: %v/verify/%v", user.Username, client.ServerURL, user.Id)
link := fmt.Sprintf("Hi %s, please confirm your account through this link: %s/verify/%s", user.Username, client.ServerURL, user.Id)

client.Logger.Info(link)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func (suite *TerminalConfirmationTransportTestSuite) TestSubmit() {

_ = json.Unmarshal(message.Attributes, user.Attributes)

link := fmt.Sprintf("Hi %v, please confirm your account through this link: %v/verify/%v", user.Attributes.Username, suite.serverURL, user.Attributes.Id)
link := fmt.Sprintf("Hi %s, please confirm your account through this link: %s/verify/%s", user.Attributes.Username, suite.serverURL, user.Attributes.Id)

suite.logger.Mock.On("Info", link)

Expand Down
16 changes: 8 additions & 8 deletions scripts/copydeps/copydeps.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,41 +26,41 @@ const lodashStaticPath = staticPath + "/lodash.com"

func Panic(msg string, err error) {
if err != nil {
log.Panicf("%v: [%v]", msg, err)
log.Panicf("%s: [%s]", msg, err)
}
}

func createDirectory(path string) {
err := os.MkdirAll(path, os.ModePerm)

if err != nil {
Panic(fmt.Sprintf("Failed to create \"%v\"", path), err)
Panic(fmt.Sprintf("Failed to create \"%s\"", path), err)
}

log.Printf("Created: \"%v\"", path)
log.Printf("Created: \"%s\"", path)
}

func copyFile(filename, sourcePath, targetPath string) {
data, err := os.ReadFile(filepath.Join(sourcePath, filepath.Base(filename)))

if err != nil {
Panic(fmt.Sprintf("Failed to read \"%v\" from \"%v\"", filename, sourcePath), err)
Panic(fmt.Sprintf("Failed to read \"%s\" from \"%s\"", filename, sourcePath), err)
}

err = os.WriteFile(filepath.Join(targetPath, filepath.Base(filename)), data, os.ModePerm)

if err != nil {
Panic(fmt.Sprintf("Failed to write \"%v\" on \"%v\"", filename, targetPath), err)
Panic(fmt.Sprintf("Failed to write \"%s\" on \"%s\"", filename, targetPath), err)
}

log.Printf("Created: \"%v\"", filepath.Join(targetPath, filepath.Base(filename)))
log.Printf("Created: \"%s\"", filepath.Join(targetPath, filepath.Base(filename)))
}

func copyDeps(filenames []string, sourcePath, targetPath string) {
files, err := os.ReadDir(sourcePath)

if err != nil {
Panic(fmt.Sprintf("Failed to copy \"%v\" from \"%v\"", filenames, sourcePath), err)
Panic(fmt.Sprintf("Failed to copy \"%s\" from \"%s\"", filenames, sourcePath), err)
}

createDirectory(targetPath)
Expand Down Expand Up @@ -90,7 +90,7 @@ func main() {
err := os.RemoveAll(staticPath)

if err != nil && !errors.Is(err, os.ErrNotExist) {
Panic(fmt.Sprintf("Failed to remove \"%v\"", staticPath), err)
Panic(fmt.Sprintf("Failed to remove \"%s\"", staticPath), err)
}

createDirectory(staticPath)
Expand Down
4 changes: 2 additions & 2 deletions scripts/syncenv/syncenv.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ var envFileModel string
var envFileBackupRegex = regexp.MustCompile(`\.env\..*\.tmp`)

func usage() {
fmt.Printf("Usage: %v [OPTIONS]\n", cli)
fmt.Printf("\nE.g.: %v -dir . -model .env.example\n\n", cli)
fmt.Printf("Usage: %s [OPTIONS]\n", cli)
fmt.Printf("\nE.g.: %s -dir . -model .env.example\n\n", cli)
flag.PrintDefaults()
}

Expand Down

0 comments on commit 57beb5e

Please sign in to comment.