……下面是 diff 命令的输出:
diff -Naur sources-orig/officespace/interest.go sources-fixed/officespace/interest.go --- sources-orig/officespace/interest.go 2018-08-10 16:39:11.000000000 -0400 +++ sources-fixed/officespace/interest.go 2018-08-10 16:39:40.000000000 -0400 @@ -11,15 +11,13 @@ InterestRate float64 } -
+// compute the rounded interest for a transaction func computeInterest(acct *Account, t Transaction) float64 { -
interest := t.Amount * t.InterestRate roundedInterest := math.Floor(interest*100) / 100.0 remainingInterest := interest - roundedInterest -
- // a little extra.. - remainingInterest *= 1000 - // Save the remaining interest into an account we control: acct.Balance = acct.Balance + remainingInterest
最开始几行 diff 命令的输出可以这样解释:三个 --- 显示了原来文件的名字;任何在原文件(LCTT 译注:不是源文件)里存在而在新文件里不存在的行将会用前缀 - ,用来表示这些行被从源代码里“减去”了。而 +++ 表示的则相反:在新文件里被加上的行会被放上前缀 + ,表示这是在新文件里被“加上”的行。补丁文件中的每一个补丁“块”(用 @@ 作为前缀的的部分)都有上下文的行号,这能帮助补丁工具(或其它处理器)知道在代码的哪里应用这个补丁块。你能看到我们已经修改了“Office Space”这部电影里提到的那个函数(移除了三行并加上了一行代码注释),电影里那个有点贪心的工程师可是偷偷的在计算利息的函数里加了点“料”哦。(LCTT译注:剧情详情请见电影 https://movie.douban.com/subject/1296424/) (编辑:西安站长网)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|