-1

What does this code snippet do?

func funcName(para int){}
_ = funcName

first line define a function, but what does the second line?

I know many situations in which underscore assign to object, what about a function?

Here is an example from the etcd GitHub repository: link

dd.ho
  • 79
  • 4
  • 3
    The statement does not affect the Go program. I am guessing that the statement was added to the cockroach code to provide a code navigation link for the preceding comment. – Charlie Tumahai Oct 10 '22 at 03:00
  • In Go functions are _first class_, so you can assign them to variables and pass them as function parameters. Then `_ = funcName` becomes an assignment like any other. This is valid and would call the function: `foo = funcName; foo(42);` – marco.m Oct 10 '22 at 06:07

1 Answers1

1

Per codes of change commit move quorum safeguard into execChangeReplicasTxn of _ = execChangeReplicasTxn

enter image description here

The removing codes of the left side are moving to function execChangeReplicasTxn, and per the comment

NB: the replication layer ensures that the below operations don't cause unavailability

It provides a code navigation link to execChangeReplicasTxn as part of comment.

zangw
  • 43,869
  • 19
  • 177
  • 214