标签 Golang 下的文章

0x00 问题描述

书接上回,由于游戏服务器的新需求,但是游戏内置引擎没有hmac和sha1加密库,并且考虑了性能问题。所以采用远程调用PHP的方式去生成一个七牛的授权凭证(Access Token)。最近刚好在看Go的web框架,挑了一个国内比较成熟的Go语言编写的web框架Beego,所以为了熟悉Beego的框架,我准备将之前的PHP脚本放到Beego里面,作为我第一个Beego程序。

- 阅读剩余部分 -

0x00 问题描述

An IP is a single IP address, a slice of bytes. Functions in this package accept either 4-byte (IPv4) or 16-byte (IPv6) slices as input.
GO的net库接受以4字节或16字节切片组成的IPv4和IPv6地址

Note that in this documentation, referring to an IP address as an IPv4 address or an IPv6 address is a semantic property of the address, not just the length of the byte slice: a 16-byte slice can still be an IPv4 address.
已知IPv4单位最大255,占8-bit,也就是1-byte,一共占4位,公共就是4-byte。
而IPv6地址单位最大65535占2-byte,一共8位,总共占16-byte.
所以无论是IPv4还是IPv6,一个16-byte长度的切片足以存储上述IP地址。所以go语言net库的IP地址是一16-byte大小的切片储存的。





- 阅读剩余部分 -

0x00 问题描述

众所周知,目前市面上的游戏加速器普遍只加速热门网游。很多冷门游戏,包括一些单机改联机的游戏都无法通过市面上主流加速器优化网络速度。之前我就遇到让我很恶心的意见事情,就是,我为了玩战术小队的国内服务器特意充值了某游戏加速器,但是登陆游戏后才发现只有服务器搜索功能被加速了,进入服务器后依然是延迟超高,丢包难以忍受。客服只是简单一句,游戏内的个人服务器是不会被加速的,并且拒绝为我退款。

- 阅读剩余部分 -

0x00 问题描述

Roman numerals are represented by seven different symbols: I, V, X, L, C, D, and M.
罗马数字以下列字母组成

Symbol       Value
I             1
V             5
X             10
L             50
C             100
D             500
M             1000

For example, “two” is written as II in Roman numeral, just two one's added together. Twelve is written as, XII, which is simply X + II. The number twenty-seven is written as XXVII, which is XX + V + II.
例如,数字2的罗马数字为II,相当于两个1相加。12则以XII表示,24的罗马数字为XXVII,相当于XX+V+II.

Roman numerals are usually written largest to smallest from left to right. However, the numeral for four is not IIII. Instead, the number four is written as IV. Because the one is before the five we subtract it making four. The same principle applies to the number nine, which is written as IX. There are six instances where subtraction is used:
罗马数字顺序是从左到右,最左边是最大值,最右为最小值。然而阿拉伯数字4并不是以IIII来表示,罗马数字中的4是以IV表示的。同样9对应的是IV。

I can be placed before V (5) and X (10) to make 4 and 9.
X can be placed before L (50) and C (100) to make 40 and 90.
C can be placed before D (500) and M (1000) to make 400 and 900.

Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999.
系统将输入一个罗马数字,将其转化为阿拉伯数字整数输出。该输入的范围将被限制在1-3999

Example:

Input: "III"
Output: 3

Input: "IV"
Output: 4

Input: "MCMXCIV"
Output: 1994
Explanation: M = 1000, CM = 900, XC = 90 and IV = 4.






- 阅读剩余部分 -

0x00 问题描述

Determine whether an integer is a palindrome. An integer is a palindrome when it reads the same backward as forward.
判断一个整数是否为palindrome (如果一个整数正序等于倒序则是palindrome)

Example:

Input: 121
Output: true

Input: 10
Output: false
Explanation: Reads 01 from right to left. Therefore it is not a palindrome.

Input: -121
Output: false
Explanation: From left to right, it reads -121. From right to left, it becomes 121-. Therefore it is not a palindrome.

- 阅读剩余部分 -