From 6f3b25281926067d006c87537ea12128a066d79c Mon Sep 17 00:00:00 2001 From: Max Date: Fri, 26 Dec 2025 00:00:10 -0500 Subject: [PATCH] style: no "this" or "self" as receiver --- internal/config/get_logger.go | 4 ++-- internal/config/source.go | 4 ++-- pkg/lambda/expression.go | 24 ++++++++++++------------ pkg/lambda/stringify.go | 26 +++++++++++++------------- pkg/set/set.go | 20 ++++++++++---------- 5 files changed, 39 insertions(+), 39 deletions(-) diff --git a/internal/config/get_logger.go b/internal/config/get_logger.go index ea7fb5e..6f959ad 100644 --- a/internal/config/get_logger.go +++ b/internal/config/get_logger.go @@ -6,9 +6,9 @@ import ( ) // Define the correct logger for the program to use. -func (this Config) GetLogger() *slog.Logger { +func (c Config) GetLogger() *slog.Logger { var level slog.Level - if this.Verbose { + if c.Verbose { level = slog.LevelInfo } else { level = slog.LevelError diff --git a/internal/config/source.go b/internal/config/source.go index f4b07b3..7e78a98 100644 --- a/internal/config/source.go +++ b/internal/config/source.go @@ -14,12 +14,12 @@ type Source interface { // A source coming from a string. type StringSource struct{ data string } -func (this StringSource) Pull() (string, error) { return this.data, nil } +func (s StringSource) Pull() (string, error) { return s.data, nil } // A source coming from standard input. type StdinSource struct{} -func (this StdinSource) Pull() (string, error) { +func (s StdinSource) Pull() (string, error) { data, err := io.ReadAll(os.Stdin) if err != nil { return "", err diff --git a/pkg/lambda/expression.go b/pkg/lambda/expression.go index dc0c08b..e2814b2 100644 --- a/pkg/lambda/expression.go +++ b/pkg/lambda/expression.go @@ -12,12 +12,12 @@ type Abstraction struct { Body Expression } -func (this *Abstraction) Copy() Expression { - return NewAbstraction(this.Parameter, this.Body.Copy()) +func (a *Abstraction) Copy() Expression { + return NewAbstraction(a.Parameter, a.Body.Copy()) } -func (this *Abstraction) Accept(v Visitor) { - v.VisitAbstraction(this) +func (a *Abstraction) Accept(v Visitor) { + v.VisitAbstraction(a) } func NewAbstraction(parameter string, body Expression) *Abstraction { @@ -31,12 +31,12 @@ type Application struct { Argument Expression } -func (this *Application) Copy() Expression { - return NewApplication(this.Abstraction.Copy(), this.Argument.Copy()) +func (a *Application) Copy() Expression { + return NewApplication(a.Abstraction.Copy(), a.Argument.Copy()) } -func (this *Application) Accept(v Visitor) { - v.VisitApplication(this) +func (a *Application) Accept(v Visitor) { + v.VisitApplication(a) } func NewApplication(function Expression, argument Expression) *Application { @@ -49,12 +49,12 @@ type Variable struct { Value string } -func (this *Variable) Copy() Expression { - return NewVariable(this.Value) +func (v *Variable) Copy() Expression { + return NewVariable(v.Value) } -func (this *Variable) Accept(v Visitor) { - v.VisitVariable(this) +func (v *Variable) Accept(visitor Visitor) { + visitor.VisitVariable(v) } func NewVariable(name string) *Variable { diff --git a/pkg/lambda/stringify.go b/pkg/lambda/stringify.go index 88f9c3f..53c64f5 100644 --- a/pkg/lambda/stringify.go +++ b/pkg/lambda/stringify.go @@ -6,23 +6,23 @@ type stringifyVisitor struct { builder strings.Builder } -func (this *stringifyVisitor) VisitVariable(a *Variable) { - this.builder.WriteString(a.Value) +func (v *stringifyVisitor) VisitVariable(a *Variable) { + v.builder.WriteString(a.Value) } -func (this *stringifyVisitor) VisitAbstraction(f *Abstraction) { - this.builder.WriteRune('\\') - this.builder.WriteString(f.Parameter) - this.builder.WriteRune('.') - f.Body.Accept(this) +func (v *stringifyVisitor) VisitAbstraction(f *Abstraction) { + v.builder.WriteRune('\\') + v.builder.WriteString(f.Parameter) + v.builder.WriteRune('.') + f.Body.Accept(v) } -func (this *stringifyVisitor) VisitApplication(c *Application) { - this.builder.WriteRune('(') - c.Abstraction.Accept(this) - this.builder.WriteRune(' ') - c.Argument.Accept(this) - this.builder.WriteRune(')') +func (v *stringifyVisitor) VisitApplication(c *Application) { + v.builder.WriteRune('(') + c.Abstraction.Accept(v) + v.builder.WriteRune(' ') + c.Argument.Accept(v) + v.builder.WriteRune(')') } func Stringify(e Expression) string { diff --git a/pkg/set/set.go b/pkg/set/set.go index e8be639..c6127c8 100644 --- a/pkg/set/set.go +++ b/pkg/set/set.go @@ -2,32 +2,32 @@ package set type Set[T comparable] map[T]bool -func (this *Set[T]) Add(items ...T) { +func (s *Set[T]) Add(items ...T) { for _, item := range items { - (*this)[item] = true + (*s)[item] = true } } -func (this Set[T]) Has(item T) bool { - return this[item] == true +func (s Set[T]) Has(item T) bool { + return s[item] == true } -func (this *Set[T]) Remove(items ...T) { +func (s *Set[T]) Remove(items ...T) { for _, item := range items { - delete(*this, item) + delete(*s, item) } } -func (this *Set[T]) Union(o Set[T]) { +func (s *Set[T]) Union(o Set[T]) { for item := range o { - this.Add(item) + s.Add(item) } } -func (this Set[T]) ToList() []T { +func (s Set[T]) ToList() []T { list := []T{} - for item := range this { + for item := range s { list = append(list, item) }