From d00f8eef568298bc111f6d1d2525c6c87a95b7d1 Mon Sep 17 00:00:00 2001
From: Darien Raymond <admin@v2ray.com>
Date: Sun, 27 Nov 2016 17:01:44 +0100
Subject: [PATCH] remove use of 'v' as a variable name

---
 app/dns/config.go                         |  4 ++--
 common/alloc/buffer.go                    | 16 ++++++++--------
 common/log/log.go                         | 16 ++++++++--------
 common/net/port.go                        | 10 +++++-----
 common/predicate/arrays.go                |  4 ++--
 common/protocol/time_test.go              |  6 +++---
 tools/build/build.go                      |  8 ++++----
 tools/conf/dns.go                         |  4 ++--
 tools/geoip/geoip_gen.go                  |  4 ++--
 transport/internet/kcp/sending.go         |  4 ++--
 transport/internet/udp/hub_linux_test.go  |  8 ++++----
 transport/internet/ws/connection_cache.go |  6 +++---
 12 files changed, 45 insertions(+), 45 deletions(-)

diff --git a/app/dns/config.go b/app/dns/config.go
index 63a7acd6..b1be154c 100644
--- a/app/dns/config.go
+++ b/app/dns/config.go
@@ -6,9 +6,9 @@ import (
 	"v2ray.com/core/common/log"
 )
 
-func (this *Config) GetInternalHosts() map[string]net.IP {
+func (v *Config) GetInternalHosts() map[string]net.IP {
 	hosts := make(map[string]net.IP)
-	for domain, ipOrDomain := range this.GetHosts() {
+	for domain, ipOrDomain := range v.GetHosts() {
 		address := ipOrDomain.AsAddress()
 		if address.Family().IsDomain() {
 			log.Warning("DNS: Ignoring domain address in static hosts: ", address.Domain())
diff --git a/common/alloc/buffer.go b/common/alloc/buffer.go
index 70162425..bbc359ed 100644
--- a/common/alloc/buffer.go
+++ b/common/alloc/buffer.go
@@ -77,13 +77,13 @@ func (b *Buffer) AppendString(s string) *Buffer {
 	return b
 }
 
-func (b *Buffer) AppendUint16(v uint16) *Buffer {
-	b.Value = serial.Uint16ToBytes(v, b.Value)
+func (b *Buffer) AppendUint16(val uint16) *Buffer {
+	b.Value = serial.Uint16ToBytes(val, b.Value)
 	return b
 }
 
-func (b *Buffer) AppendUint32(v uint32) *Buffer {
-	b.Value = serial.Uint32ToBytes(v, b.Value)
+func (b *Buffer) AppendUint32(val uint32) *Buffer {
+	b.Value = serial.Uint32ToBytes(val, b.Value)
 	return b
 }
 
@@ -99,15 +99,15 @@ func (b *Buffer) PrependBytes(data ...byte) *Buffer {
 	return b.Prepend(data)
 }
 
-func (b *Buffer) PrependUint16(v uint16) *Buffer {
+func (b *Buffer) PrependUint16(val uint16) *Buffer {
 	b.SliceBack(2)
-	serial.Uint16ToBytes(v, b.Value[:0])
+	serial.Uint16ToBytes(val, b.Value[:0])
 	return b
 }
 
-func (b *Buffer) PrependUint32(v uint32) *Buffer {
+func (b *Buffer) PrependUint32(val uint32) *Buffer {
 	b.SliceBack(4)
-	serial.Uint32ToBytes(v, b.Value[:0])
+	serial.Uint32ToBytes(val, b.Value[:0])
 	return b
 }
 
diff --git a/common/log/log.go b/common/log/log.go
index fb3cbb5e..c736996f 100644
--- a/common/log/log.go
+++ b/common/log/log.go
@@ -46,34 +46,34 @@ func InitErrorLogger(file string) error {
 }
 
 // Debug outputs a debug log with given format and optional arguments.
-func Debug(v ...interface{}) {
+func Debug(val ...interface{}) {
 	debugLogger.Log(&internal.ErrorLog{
 		Prefix: "[Debug]",
-		Values: v,
+		Values: val,
 	})
 }
 
 // Info outputs an info log with given format and optional arguments.
-func Info(v ...interface{}) {
+func Info(val ...interface{}) {
 	infoLogger.Log(&internal.ErrorLog{
 		Prefix: "[Info]",
-		Values: v,
+		Values: val,
 	})
 }
 
 // Warning outputs a warning log with given format and optional arguments.
-func Warning(v ...interface{}) {
+func Warning(val ...interface{}) {
 	warningLogger.Log(&internal.ErrorLog{
 		Prefix: "[Warning]",
-		Values: v,
+		Values: val,
 	})
 }
 
 // Error outputs an error log with given format and optional arguments.
-func Error(v ...interface{}) {
+func Error(val ...interface{}) {
 	errorLogger.Log(&internal.ErrorLog{
 		Prefix: "[Error]",
-		Values: v,
+		Values: val,
 	})
 }
 
diff --git a/common/net/port.go b/common/net/port.go
index 3571b545..3dbfe985 100644
--- a/common/net/port.go
+++ b/common/net/port.go
@@ -23,21 +23,21 @@ func PortFromBytes(port []byte) Port {
 
 // PortFromInt converts an integer to a Port.
 // @error when the integer is not positive or larger then 65535
-func PortFromInt(v uint32) (Port, error) {
-	if v > 65535 {
+func PortFromInt(val uint32) (Port, error) {
+	if val > 65535 {
 		return Port(0), ErrInvalidPortRange
 	}
-	return Port(v), nil
+	return Port(val), nil
 }
 
 // PortFromString converts a string to a Port.
 // @error when the string is not an integer or the integral value is a not a valid Port.
 func PortFromString(s string) (Port, error) {
-	v, err := strconv.ParseUint(s, 10, 32)
+	val, err := strconv.ParseUint(s, 10, 32)
 	if err != nil {
 		return Port(0), ErrInvalidPortRange
 	}
-	return PortFromInt(uint32(v))
+	return PortFromInt(uint32(val))
 }
 
 // Value return the correspoding uint16 value of this Port.
diff --git a/common/predicate/arrays.go b/common/predicate/arrays.go
index 0b4427f7..03e04321 100644
--- a/common/predicate/arrays.go
+++ b/common/predicate/arrays.go
@@ -1,8 +1,8 @@
 package predicate
 
 func BytesAll(array []byte, b byte) bool {
-	for _, v := range array {
-		if v != b {
+	for _, val := range array {
+		if val != b {
 			return false
 		}
 	}
diff --git a/common/protocol/time_test.go b/common/protocol/time_test.go
index 10290dd0..1ee1084f 100644
--- a/common/protocol/time_test.go
+++ b/common/protocol/time_test.go
@@ -16,8 +16,8 @@ func TestGenerateRandomInt64InRange(t *testing.T) {
 	generator := NewTimestampGenerator(Timestamp(base), delta)
 
 	for i := 0; i < 100; i++ {
-		v := int64(generator())
-		assert.Int64(v).AtMost(base + int64(delta))
-		assert.Int64(v).AtLeast(base - int64(delta))
+		val := int64(generator())
+		assert.Int64(val).AtMost(base + int64(delta))
+		assert.Int64(val).AtLeast(base - int64(delta))
 	}
 }
diff --git a/tools/build/build.go b/tools/build/build.go
index 9d63af2d..33e54669 100644
--- a/tools/build/build.go
+++ b/tools/build/build.go
@@ -61,15 +61,15 @@ func build(targetOS, targetArch string, archive bool, version string, metadataFi
 	v2rayArch := parseArch(targetArch)
 
 	if len(version) == 0 {
-		v, err := git.RepoVersionHead()
-		if v == git.VersionUndefined {
-			v = "custom"
+		headVer, err := git.RepoVersionHead()
+		if headVer == git.VersionUndefined {
+			headVer = "custom"
 		}
 		if err != nil {
 			fmt.Println("Unable to detect V2Ray version: " + err.Error())
 			return
 		}
-		version = v
+		version = headVer
 	}
 	fmt.Printf("Building V2Ray (%s) for %s %s\n", version, v2rayOS, v2rayArch)
 
diff --git a/tools/conf/dns.go b/tools/conf/dns.go
index 9ca0af94..38280991 100644
--- a/tools/conf/dns.go
+++ b/tools/conf/dns.go
@@ -23,8 +23,8 @@ func (this *DnsConfig) Build() *dns.Config {
 
 	if this.Hosts != nil {
 		config.Hosts = make(map[string]*v2net.IPOrDomain)
-		for k, v := range this.Hosts {
-			config.Hosts[k] = v.Build()
+		for domain, ip := range this.Hosts {
+			config.Hosts[domain] = ip.Build()
 		}
 	}
 
diff --git a/tools/geoip/geoip_gen.go b/tools/geoip/geoip_gen.go
index 87cbf391..cd992c97 100644
--- a/tools/geoip/geoip_gen.go
+++ b/tools/geoip/geoip_gen.go
@@ -81,11 +81,11 @@ func main() {
 
 func formatArray(a []byte) string {
 	r := "[]byte{"
-	for idx, v := range a {
+	for idx, val := range a {
 		if idx > 0 {
 			r += ","
 		}
-		r += fmt.Sprintf("%d", v)
+		r += fmt.Sprintf("%d", val)
 	}
 	r += "}"
 	return r
diff --git a/transport/internet/kcp/sending.go b/transport/internet/kcp/sending.go
index 23f3aa49..646cca2e 100644
--- a/transport/internet/kcp/sending.go
+++ b/transport/internet/kcp/sending.go
@@ -219,13 +219,13 @@ func (this *SendingWorker) ProcessReceivingNextWithoutLock(nextNumber uint32) {
 
 // Private: Visible for testing.
 func (this *SendingWorker) FindFirstUnacknowledged() {
-	v := this.firstUnacknowledged
+	first := this.firstUnacknowledged
 	if !this.window.IsEmpty() {
 		this.firstUnacknowledged = this.window.FirstNumber()
 	} else {
 		this.firstUnacknowledged = this.nextNumber
 	}
-	if v != this.firstUnacknowledged {
+	if first != this.firstUnacknowledged {
 		this.firstUnacknowledgedUpdated = true
 	}
 }
diff --git a/transport/internet/udp/hub_linux_test.go b/transport/internet/udp/hub_linux_test.go
index 5c4f0af2..eaf11a18 100644
--- a/transport/internet/udp/hub_linux_test.go
+++ b/transport/internet/udp/hub_linux_test.go
@@ -32,11 +32,11 @@ func TestHubSocksOption(t *testing.T) {
 	fd, err := internal.GetSysFd(conn)
 	assert.Error(err).IsNil()
 
-	v, err := syscall.GetsockoptInt(fd, syscall.SOL_IP, syscall.IP_TRANSPARENT)
+	val, err := syscall.GetsockoptInt(fd, syscall.SOL_IP, syscall.IP_TRANSPARENT)
 	assert.Error(err).IsNil()
-	assert.Int(v).Equals(1)
+	assert.Int(val).Equals(1)
 
-	v, err = syscall.GetsockoptInt(fd, syscall.SOL_IP, syscall.IP_RECVORIGDSTADDR)
+	val, err = syscall.GetsockoptInt(fd, syscall.SOL_IP, syscall.IP_RECVORIGDSTADDR)
 	assert.Error(err).IsNil()
-	assert.Int(v).Equals(1)
+	assert.Int(val).Equals(1)
 }
diff --git a/transport/internet/ws/connection_cache.go b/transport/internet/ws/connection_cache.go
index 284a707b..f53a27bb 100644
--- a/transport/internet/ws/connection_cache.go
+++ b/transport/internet/ws/connection_cache.go
@@ -71,9 +71,9 @@ func (this *ConnectionCache) Recycle(dest string, conn *wsconn) {
 	}
 
 	var list []*AwaitingConnection
-	if v, found := this.cache[dest]; found {
-		v = append(v, aconn)
-		list = v
+	if val, found := this.cache[dest]; found {
+		val = append(val, aconn)
+		list = val
 	} else {
 		list = []*AwaitingConnection{aconn}
 	}