@upset directive doesn't ensure uniqueness

for example:

<id>: string @index(exact) @upsert .

upsert {
  query {
    v as var(func: eq(id, "1"))
  }

  mutation {
    set {
      uid(v) <id> "1" .
      uid(v) <name> "first node" .
    }
  }
}

upsert {
  query {
    v as var(func: eq(id, "2"))
  }

  mutation {
    set {
      uid(v) <id> "2" .
      uid(v) <name> "second node" .
    }
  }
}

upsert {
  query {
    v as var(func: eq(id, "2"))
  }

  mutation {
    set {
      uid(v) <id> "1" .
      uid(v) <name> "second node" .
    }
  }
}

then I got two nodes with same id, one name “first node”, another name “second node”.

use “Conditional Upsert” for this case https://docs.dgraph.io/mutations/#conditional-upsert

Could you please give an example of Conditional Upsert with golang dgo2 library syntax? I’ve tried several times but still get syntax errors about “if” or “@if” etc.

Found: api.Mutation.Cond