Skip to content

Commit cbcb9af

Browse files
committed
docs: remove old Init section
1 parent 124184b commit cbcb9af

File tree

1 file changed

+0
-84
lines changed

1 file changed

+0
-84
lines changed

docs/src/docs/contributing/architecture.mdx

Lines changed: 0 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -22,90 +22,6 @@ graph LR
2222

2323
</ResponsiveContainer>
2424

25-
## Init
26-
27-
The execution starts here:
28-
29-
```go title=cmd/golangci-lint/main.go
30-
func main() {
31-
e := commands.NewExecutor(info)
32-
33-
if err := e.Execute(); err != nil {
34-
fmt.Fprintf(os.Stderr, "failed executing command with error %v\n", err)
35-
os.Exit(exitcodes.Failure)
36-
}
37-
}
38-
```
39-
40-
The **executer** is our abstraction:
41-
42-
```go title=pkg/commands/executor.go
43-
type Executor struct {
44-
rootCmd *cobra.Command
45-
runCmd *cobra.Command
46-
lintersCmd *cobra.Command
47-
48-
exitCode int
49-
buildInfo BuildInfo
50-
51-
cfg *config.Config
52-
log logutils.Log
53-
reportData report.Data
54-
DBManager *lintersdb.Manager
55-
EnabledLintersSet *lintersdb.EnabledSet
56-
contextLoader *lint.ContextLoader
57-
goenv *goutil.Env
58-
fileCache *fsutils.FileCache
59-
lineCache *fsutils.LineCache
60-
pkgCache *pkgcache.Cache
61-
debugf logutils.DebugFunc
62-
sw *timeutils.Stopwatch
63-
64-
loadGuard *load.Guard
65-
flock *flock.Flock
66-
}
67-
```
68-
69-
We use dependency injection and all root dependencies are stored in this executor.
70-
71-
In the function `NewExecutor` we do the following:
72-
73-
1. Initialize dependencies.
74-
2. Initialize [cobra](https://github.com/spf13/cobra) commands.
75-
3. Parse the config file using [viper](https://github.com/spf13/viper) and merge it with command line arguments.
76-
77-
The following execution is controlled by `cobra`. If a user executes `golangci-lint run`
78-
then `cobra` executes `e.runCmd`.
79-
80-
Different `cobra` commands have different runners, e.g. a `run` command is configured in the following way:
81-
82-
```go title=pkg/commands/run.go
83-
func (e *Executor) initRun() {
84-
e.runCmd = &cobra.Command{
85-
Use: "run",
86-
Short: "Run the linters",
87-
Run: e.executeRun,
88-
PreRunE: func(_ *cobra.Command, _ []string) error {
89-
if ok := e.acquireFileLock(); !ok {
90-
return errors.New("parallel golangci-lint is running")
91-
}
92-
return nil
93-
},
94-
PostRun: func(_ *cobra.Command, _ []string) {
95-
e.releaseFileLock()
96-
},
97-
}
98-
e.rootCmd.AddCommand(e.runCmd)
99-
100-
e.runCmd.SetOut(logutils.StdOut) // use custom output to properly color it in Windows terminals
101-
e.runCmd.SetErr(logutils.StdErr)
102-
103-
e.initRunConfiguration(e.runCmd)
104-
}
105-
```
106-
107-
The primary execution function of the `run` command is `executeRun`.
108-
10925
## Load Packages
11026

11127
Loading packages is listing all packages and their recursive dependencies for analysis.

0 commit comments

Comments
 (0)