Golang: Find two number index where the sum of these two numbers equals to target number
<p>The problem is: find the index of two numbers that <code>nums[index1] + nums[index2] == target</code>. Here is my attempt in <code>golang</code> (index starts from 1):</p>

<pre><code>package main

import (
    "fmt"
)

var nums = []int{0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 25182, 25184, 25186, 25188, 25190, 25192, 25194, 25196} // The number list is too long, I put the whole numbers in a gist: https://gist.github.com/nickleeh/8eedb39e008da8b47864
var target int = 16021

func twoSum(nums []int, target int) (int, int) {
    if len(nums) &lt;= 1 {
        return 0, 0
    }
    hdict := make(map[int]int)
    for i := 1; i &lt; len(nums); i++ {
        if val, ok := hdict[nums[i+1]]; ok {
            return val, i + 1
        } else {
            hdict[target-nums[i+1]] = i + 1
        }
    }
    return 0, 0
}

func main() {
    fmt.Println(twoSum(nums, target))
}
</code></pre>

<p>The nums list is too long, I put it into a gist:
<a href="https://gist.github.com/nickleeh/8eedb39e008da8b47864" rel="nofollow">https://gist.github.com/nickleeh/8eedb39e008da8b47864</a></p>

<p>This code works fine, but I find the <code>return 0,0</code> part is ugly, and it runs ten times slower than the <code>Julia</code> translation. I would like to know is there any part that is written terrible and affect the performance?</p>

<p><strong>Edit:</strong>
Julia's translation:</p>

<pre><code>function two_sum(nums, target)
    if length(nums) &lt;= 1
        return false
    end
    hdict = Dict()
    for i in 1:length(nums)
        if haskey(hdict, nums[i])
            return [hdict[nums[i]], i]
        else
            hdict[target - nums[i]] = i
        end
    end
end
</code></pre>