使用的变量。 但是错误仍然表明“变量x未使用” [关闭]

I am new to Golang. I am trying to clean duplicates. When I try to build the go code, I get this error.

    utils.go:60:62: cleanedTransactedFrom declared and not used

I made sure that they are used. I am sorry about the naming conventions. I am very new to Golang, so I am yet to follow the conventions. As of now consider types.TransactedFrom is a simple struct that has ID and TimeStamp.

  func removeDuplicates(TransactedFrom [][]types.TransactedFrom) [][]types.TransactedFrom {
    cleanedTransactedFrom := [][]types.TransactedFrom{}
    equal := true
    for index, singleTransactedFrom := range TransactedFrom {
      for _, selectedTransactedFrom := range TransactedFrom[index:] {
        if reflect.DeepEqual(singleTransactedFrom, selectedTransactedFrom) {
          equal = false
        }
      }
      if equal {
        cleanedTransactedFrom := append(cleanedTransactedFrom, singleTransactedFrom)
      }
      equal = true
    }
    return cleanedTransactedFrom
  }

Change

equal := false

to

equal = false

because right now you're declaring a new variable in the inner block scope.

Remember than := is both a declaration and an assignment (as noticed by peterSO you have the same problem for another variable and you should probably check your whole code now that you know how it works).