Skip to content

Commit

Permalink
style: license header && gofumpt
Browse files Browse the repository at this point in the history
  • Loading branch information
ViolaPioggia committed Jul 7, 2024
1 parent abe176c commit 95d4523
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 10 deletions.
16 changes: 16 additions & 0 deletions cmd/static/job_flags.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright 2024 CloudWeGo Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package static

import (
Expand Down
20 changes: 11 additions & 9 deletions pkg/job/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,22 @@ import (
"bytes"
"errors"
"fmt"
"github.com/cloudwego/cwgo/config"
"github.com/cloudwego/cwgo/pkg/common/utils"
"github.com/cloudwego/cwgo/pkg/consts"
"github.com/cloudwego/kitex/tool/internal_pkg/log"
"go/ast"
"go/parser"
"go/printer"
"go/token"
"golang.org/x/tools/go/ast/astutil"
"os"
"path/filepath"
"strconv"
"strings"
"text/template"

"github.com/cloudwego/cwgo/config"
"github.com/cloudwego/cwgo/pkg/common/utils"
"github.com/cloudwego/cwgo/pkg/consts"
"github.com/cloudwego/kitex/tool/internal_pkg/log"

"golang.org/x/tools/go/ast/astutil"
)

func Job(c *config.JobArgument) error {
Expand Down Expand Up @@ -292,14 +294,14 @@ func createRunCall(jobName string) []ast.Stmt {

func generateJobFile(GoModule, PackagePrefix string, jobNames []string, outDir string) error {
// Ensure the base output directory exists
err := os.MkdirAll(outDir, 0755)
err := os.MkdirAll(outDir, 0o755)
if err != nil {
return fmt.Errorf("failed to create output directory: %w", err)
}

// Create cmd/main.go and overwrite each time
cmdDir := filepath.Join(outDir, "cmd")
err = os.MkdirAll(cmdDir, 0755)
err = os.MkdirAll(cmdDir, 0o755)
if err != nil {
return fmt.Errorf("failed to create cmd directory: %w", err)
}
Expand Down Expand Up @@ -368,7 +370,7 @@ func generateJobFile(GoModule, PackagePrefix string, jobNames []string, outDir s

// Create or append to run.sh
scriptsDir := filepath.Join(outDir, "scripts")
err = os.MkdirAll(scriptsDir, 0755)
err = os.MkdirAll(scriptsDir, 0o755)
if err != nil {
return fmt.Errorf("failed to create scripts directory: %w", err)
}
Expand Down Expand Up @@ -398,7 +400,7 @@ func generateJobFile(GoModule, PackagePrefix string, jobNames []string, outDir s
internalJobDir := filepath.Join(jobDir, "job")

// Create directories
err = os.MkdirAll(internalJobDir, 0755)
err = os.MkdirAll(internalJobDir, 0o755)
if err != nil {
return fmt.Errorf("failed to create internal job directory for %s: %w", jobName, err)
}
Expand Down
19 changes: 18 additions & 1 deletion pkg/job/template.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright 2024 CloudWeGo Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package job

const jobTemplate = `package job
Expand All @@ -9,7 +25,8 @@ func Run() {
}
`

const jobMainTemplate = `package main
const jobMainTemplate = `// Code generated by cwgo. DO NOT EDIT.
package main
import (
"log"
Expand Down

0 comments on commit 95d4523

Please sign in to comment.