From f810c7470c07a1ad5bd4ae9a144316937f2d87ae Mon Sep 17 00:00:00 2001 From: xushiwei Date: Tue, 9 Apr 2024 17:28:03 +0800 Subject: [PATCH] gop/printer: static method --- printer/nodes.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/printer/nodes.go b/printer/nodes.go index 5b8314490..876ec7a8e 100644 --- a/printer/nodes.go +++ b/printer/nodes.go @@ -2016,8 +2016,13 @@ func (p *printer) funcDecl(d *ast.FuncDecl) { // FUNC is emitted). startCol := p.out.Column - len("func ") if d.Recv != nil && !d.IsClass { - p.parameters(d.Recv) // method: print receiver - p.print(blank) + if d.Static { // static method + p.expr(d.Recv.List[0].Type) + p.print(token.PERIOD) + } else { + p.parameters(d.Recv) // method: print receiver + p.print(blank) + } } p.expr(d.Name) if d.Operator && d.Recv != nil {