[Golang] Binary Index Tree
\ntype NumArray struct {\n    BitArr []int\n}\n\n\nfunc Constructor(nums []int) NumArray {\n    bitArr := make([]int, len(nums)+1)\n    build(bitArr, nums)\n   
```\ntype NumArray struct {\n    BitArr []int\n}\n\n\nfunc Constructor(nums []int) NumArray {\n    bitArr := make([]int, len(nums)+1)\n    build(bitArr, nums)\n    return NumArray{bitArr}\n}\n\n\nfunc (this *NumArray) Update(index int, val int)  {\n    oldValue := query(this.BitArr, index+1) - query(this.BitArr, index)\n    update(this.BitArr, index+1, val-oldValue)\n}\n\n\nfunc (this *NumArray) SumRange(left int, right int) int {\n    return query(this.BitArr, right+1) - query(this.BitArr, left)\n}\n\nfunc build(bitArr, nums []int) {\n    for i := 0; i < len(nums); i++ {\n        update(bitArr, i+1, nums[i])\n    }\n}\n\nfunc update(bitArr []int, idx, value int) {\n    for i := idx; i < len(bitArr); i += next(i) {\n        bitArr[i] += value\n    }\n}\n\nfunc query(bitArr []int, idx int) int {\n    sum := 0\n    for i := idx; i > 0; i -= next(i) {\n        sum += bitArr[i]\n    }\n    return sum\n}\n\nfunc next(n int) int {\n    return n & (-n)\n}\n\n/**\n * Your NumArray object will be instantiated and called as such:\n * obj := Constructor(nums);\n * obj.Update(index,val);\n * param_2 := obj.SumRange(left,right);\n */\n```
['Binary Tree', 'Go']