Skip to content

Commit 9182155

Browse files
committed
Fix gosec & go-critic issues; Update copyright
1 parent f678f4a commit 9182155

File tree

11 files changed

+35
-22
lines changed

11 files changed

+35
-22
lines changed

.github/FUNDING.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# These are supported funding model platforms
22

3-
patreon: koddr
3+
liberapay: koddr
44
custom: ["https://www.producthunt.com/posts/create-go-app", "https://paypal.me/koddr"]

README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
<h1 align="center">
2-
<img src="https://raw.githubusercontent.com/create-go-app/cli/master/.github/images/cgapp_logo%402x.png" width="224px"/><br/>
2+
<img alt="cgapp logo" src="https://raw.githubusercontent.com/create-go-app/cli/master/.
3+
github/images/cgapp_logo%402x.png" width="224px"/><br/>
34
Create Go App CLI
45
</h1>
56
<p align="center">Create a new production-ready project with <b>backend</b> (Golang), <b>frontend</b> (JavaScript, TypeScript)<br/>and <b>deploy automation</b> (Ansible, Docker) by running one CLI command.<br/><br/>Focus on <b>writing</b> code and <b>thinking</b> of business-logic! The CLI will take care of the rest.</p>
67

7-
<p align="center"><a href="https://pkg.go.dev/github.com/create-go-app/cli/v3?tab=doc" target="_blank"><img src="https://img.shields.io/badge/Go-1.17+-00ADD8?style=for-the-badge&logo=go" alt="go version" /></a>&nbsp;<a href="https://gocover.io/github.com/create-go-app/cli/pkg/cgapp" target="_blank"><img src="https://img.shields.io/badge/Go_Cover-88.4%25-success?style=for-the-badge&logo=none" alt="go cover" /></a>&nbsp;<a href="https://goreportcard.com/report/github.com/create-go-app/cli" target="_blank"><img src="https://img.shields.io/badge/Go_report-A+-success?style=for-the-badge&logo=none" alt="go report" /></a>&nbsp;<img src="https://img.shields.io/badge/license-apache_2.0-red?style=for-the-badge&logo=none" alt="license" /></p>
8+
<p align="center"><a href="https://pkg.go.dev/github.com/create-go-app/cli/v3?tab=doc"
9+
target="_blank"><img src="https://img.shields.io/badge/Go-1.17+-00ADD8?style=for-the-badge&logo=go" alt="go version" /></a>&nbsp;<a href="https://gocover.io/github.com/create-go-app/cli/pkg/cgapp" target="_blank"><img src="https://img.shields.io/badge/Go_Cover-88.3%25-success?style=for-the-badge&logo=none" alt="go cover" /></a>&nbsp;<a href="https://goreportcard.com/report/github.com/create-go-app/cli" target="_blank"><img src="https://img.shields.io/badge/Go_report-A+-success?style=for-the-badge&logo=none" alt="go report" /></a>&nbsp;<img src="https://img.shields.io/badge/license-apache_2.0-red?style=for-the-badge&logo=none" alt="license" /></p>
810

911
## ⚡️ Quick start
1012

11-
First of all, [download](https://golang.org/dl/) and install **Go**. Version `1.17` or higher is required.
13+
First, [download](https://golang.org/dl/) and install **Go**. Version `1.17` or higher is required.
1214

1315
> If you're looking for the **Create Go App CLI** for Go `1.16`, you can find it [here](https://github.com/create-go-app/cli/tree/v2).
1416
@@ -67,7 +69,7 @@ cgapp create [OPTION]
6769
```
6870

6971
| Option | Description | Type | Default | Required? |
70-
| ------ | -------------------------------------------------------- | ------ | ------- | --------- |
72+
|--------|----------------------------------------------------------|--------|---------|-----------|
7173
| `-t` | Enables to define custom backend and frontend templates. | `bool` | `false` | No |
7274

7375
![cgapp_create](https://user-images.githubusercontent.com/11155743/116796937-38160080-aae9-11eb-8e21-fb1be2750aa4.gif)
@@ -86,7 +88,7 @@ cgapp deploy [OPTION]
8688
```
8789

8890
| Option | Description | Type | Default | Required? |
89-
| ------ | ------------------------------------------------------------------------------------------------------ | ------ | ------- | --------- |
91+
|--------|--------------------------------------------------------------------------------------------------------|--------|---------|-----------|
9092
| `-k` | Prompt you to provide the remote user sudo password (_a standard Ansible `--ask-become-pass` option_). | `bool` | `false` | No |
9193

9294
![cgapp_deploy](https://user-images.githubusercontent.com/11155743/116796941-3c421e00-aae9-11eb-9575-d72550814d7a.gif)

cmd/cgapp/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ frontend (JavaScript, TypeScript) and deploy automation
1010
1111
A helpful documentation and next steps -> https://create-go.app/
1212
13-
Copyright (c) 2019-present Vic Shóstak <[email protected]> (https://shostak.dev)
13+
Copyright 2022 Vic Shóstak and Create Go App Contributors
1414
1515
Licensed under the Apache License, Version 2.0 (the "License");
1616
you may not use this file except in compliance with the License.

cmd/create.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2019-present Vic Shóstak. All rights reserved.
1+
// Copyright 2022 Vic Shóstak and Create Go App Contributors. All rights reserved.
22
// Use of this source code is governed by Apache 2.0 license
33
// that can be found in the LICENSE file.
44

@@ -117,7 +117,7 @@ func runCreateCmd(cmd *cobra.Command, args []string) error {
117117
if frontend == "next-ts" {
118118
isTypeScript = "--typescript"
119119
}
120-
120+
121121
// Create a default frontend template with Next.js (React).
122122
if err := cgapp.ExecCommand(
123123
"npx", []string{"create-next-app@latest", "frontend", isTypeScript}, true,

cmd/deploy.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2019-present Vic Shóstak. All rights reserved.
1+
// Copyright 2022 Vic Shóstak and Create Go App Contributors. All rights reserved.
22
// Use of this source code is governed by Apache 2.0 license
33
// that can be found in the LICENSE file.
44

cmd/root.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2019-present Vic Shóstak. All rights reserved.
1+
// Copyright 2022 Vic Shóstak and Create Go App Contributors. All rights reserved.
22
// Use of this source code is governed by Apache 2.0 license
33
// that can be found in the LICENSE file.
44

pkg/cgapp/exec.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2019-present Vic Shóstak. All rights reserved.
1+
// Copyright 2022 Vic Shóstak and Create Go App Contributors. All rights reserved.
22
// Use of this source code is governed by Apache 2.0 license
33
// that can be found in the LICENSE file.
44

pkg/cgapp/files.go

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2019-present Vic Shóstak. All rights reserved.
1+
// Copyright 2022 Vic Shóstak and Create Go App Contributors. All rights reserved.
22
// Use of this source code is governed by Apache 2.0 license
33
// that can be found in the LICENSE file.
44

@@ -69,14 +69,24 @@ func CopyFromEmbeddedFS(efs *EmbeddedFileSystem) error {
6969

7070
// GenerateFileFromTemplate func to generate files from templates.
7171
func GenerateFileFromTemplate(fileName string, variables map[string]interface{}) error {
72+
// Checking file name.
73+
if fileName == "" {
74+
return ShowError(
75+
fmt.Sprintf("Not correct or empty file name (given: `%s`)!", fileName),
76+
)
77+
}
78+
79+
// Clean file name.
80+
cleanFileName := filepath.Clean(fileName)
81+
7282
// Parse template.
73-
tmpl, errParseFiles := template.ParseFiles(fileName)
83+
tmpl, errParseFiles := template.ParseFiles(cleanFileName)
7484
if errParseFiles != nil {
7585
return ShowError(errParseFiles.Error())
7686
}
7787

7888
// Create a new file with template data.
79-
file, errCreate := os.Create(fileName)
89+
file, errCreate := os.Create(cleanFileName)
8090
if errCreate != nil {
8191
return ShowError(errCreate.Error())
8292
}
@@ -88,8 +98,8 @@ func GenerateFileFromTemplate(fileName string, variables map[string]interface{})
8898
_ = file.Close()
8999

90100
// Rename output file.
91-
newFileName := strings.ReplaceAll(fileName, ".tmpl", "")
92-
if errRename := os.Rename(fileName, newFileName); errRename != nil {
101+
newFileName := strings.ReplaceAll(cleanFileName, ".tmpl", "")
102+
if errRename := os.Rename(cleanFileName, newFileName); errRename != nil {
93103
return ShowError(errRename.Error())
94104
}
95105

pkg/cgapp/git.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2019-present Vic Shóstak. All rights reserved.
1+
// Copyright 2022 Vic Shóstak and Create Go App Contributors. All rights reserved.
22
// Use of this source code is governed by Apache 2.0 license
33
// that can be found in the LICENSE file.
44

@@ -47,11 +47,12 @@ func GitClone(templateType, templateURL string) error {
4747
return nil
4848
}
4949

50+
// getAbsolutURL func for help define correct HTTP protocol.
5051
func getAbsoluteURL(templateURL string) string {
5152
templateURL = strings.TrimSpace(templateURL)
5253
u, _ := url.Parse(templateURL)
5354

54-
if len(u.Scheme) == 0 {
55+
if u.Scheme == "" {
5556
u.Scheme = "https"
5657
}
5758

pkg/cgapp/utils.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2019-present Vic Shóstak. All rights reserved.
1+
// Copyright 2022 Vic Shóstak and Create Go App Contributors. All rights reserved.
22
// Use of this source code is governed by Apache 2.0 license
33
// that can be found in the LICENSE file.
44

0 commit comments

Comments
 (0)