Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Lint

on:
push:
branches: [master]
branches: [ master, v2 ]
pull_request:
branches: [master]
branches: [ master, v2 ]

jobs:
lint:
Expand All @@ -14,7 +14,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ">=1.22.0"
go-version-file: 'go.mod'

- name: golangci-lint
uses: golangci/golangci-lint-action@v8
Expand Down
26 changes: 20 additions & 6 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
version: "2"
issues:
fix: true
linters:
default: none
enable:
Expand All @@ -10,8 +12,7 @@ linters:
- legacy
- std-error-handling
paths:
- internal/example
- cmds
- internal/examples
- vendor
- third_party$
- builtin$
Expand All @@ -20,11 +21,24 @@ formatters:
enable:
- goimports
- gofmt
- gofumpt
settings:
gofumpt:
extra-rules: true
goimports:
local-prefixes:
- github.com/pubgo/dix
gofmt:
simplify: false
rewrite-rules:
- pattern: 'interface{}'
replacement: 'any'
- pattern: 'a[b:len(a)]'
replacement: 'a[b:]'

exclusions:
paths:
- internal/example
- cmds
- internal/examples
- vendor
- third_party$
- builtin$
- examples$
- proto
File renamed without changes.
4 changes: 2 additions & 2 deletions dix.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import (
"github.com/pubgo/dix/v2/dixrender"
)

//go:embed .version
//go:embed .version/VERSION
var version string

func ReleaseVersion() string { return version }
func Version() string { return version }

type (
Option = dixinternal.Option
Expand Down
12 changes: 6 additions & 6 deletions dixhttp/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ func NewServer(dix *dixinternal.Dix) *Server {

// setupRoutes configures all HTTP routes
func (s *Server) setupRoutes() {
s.mux.HandleFunc("/", s.handleIndex)
s.mux.HandleFunc("/api/dependencies", s.handleDependencies)
s.mux.HandleFunc("/", s.HandleIndex)
s.mux.HandleFunc("/api/dependencies", s.HandleDependencies)
}

// ServeHTTP implements http.Handler interface
Expand All @@ -44,15 +44,15 @@ func (s *Server) ListenAndServe(addr string) error {
return http.ListenAndServe(addr, s)
}

// handleIndex serves the HTML visualization page
func (s *Server) handleIndex(w http.ResponseWriter, r *http.Request) {
// HandleIndex serves the HTML visualization page
func (s *Server) HandleIndex(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "text/html; charset=utf-8")
w.WriteHeader(http.StatusOK)
fmt.Fprint(w, htmlTemplate)
}

// handleDependencies returns JSON data about providers and objects relationships
func (s *Server) handleDependencies(w http.ResponseWriter, r *http.Request) {
// HandleDependencies returns JSON data about providers and objects relationships
func (s *Server) HandleDependencies(w http.ResponseWriter, r *http.Request) {
data := s.extractDependencyData()

w.Header().Set("Content-Type", "application/json; charset=utf-8")
Expand Down
Loading
Loading