8000 Appending new variable declaration in a var(...) block · Issue #134 · uber-go/gopatch · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Appending new variable declaration in a var(...) block #134
Open
@rosroble

Description

@rosroble

Hello!

I have a global var block as follows:

var (
	SystemSubsystem                   = "system"
	SystemLabelNames                  = []string{"hostname", "resource", "system_id"}
	SystemMemoryLabelNames            = []string{"hostname", "resource", "memory", "memory_id"}
// and so on
)

Let's say I want to insert a new variable SystemProcessorLabelNames after the SystemMemoryLabelNames

This doesn't work:

@@
@@
SystemMemoryLabelNames            = []string{"hostname", "resource", "memory", "memory_id"}
+SystemProcessorLabelNames         = []string{"hostname", "resource", "processor", "processor_id"}

And this doesn't work:

@@
@@
var (
...
SystemMemoryLabelNames            = []string{"hostname", "resource", "memory", "memory_id"}
+SystemProcessorLabelNames         = []string{"hostname", "resource", "processor", "processor_id"}
)

Although replacing works fine like that:

@@
@@
-[]string{"hostname", "resource", "memory", "memory_id"}
+[]string{"hostname", "resource", "processor", "processor_id"}

But I need to append a new line. Appending works fine inside functions, just like that:

@@
@@
a := 5
+b:=6

But inside var block it either fails or skips the file. Is this a bug or my mistake? Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0