Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(218)

Unified Diff: 2014/readability/val-and-error.go

Issue 176660043: code review 176660043: x/talks/2014/readability: talk for GoCon 2014 autumn in...
Patch Set: diff -r 05bdda42259e https://code.google.com/p/go.talks/ Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « 2014/readability/time_duration_good.go ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: 2014/readability/val-and-error.go
===================================================================
new file mode 100644
--- /dev/null
+++ b/2014/readability/val-and-error.go
@@ -0,0 +1,25 @@
+package sample // OMIT
+
+import ( // OMIT
+ "errors" // OMIT
+ "time" // OMIT
+) // OMIT
+
+var (
+ ErrDurationUnterminated = errors.new("duration: unterminated")
+ ErrNoDuration = errors.New("duration: not found")
+ ErrNoIteration = errors.New("duration: not interation")
+)
+
+func (it Iterator) DurationAt() (time.Duration, error) { // HL
+ // some code
+ switch durationUsec := m.GetDurationUsec(); durationUsec {
+ case -1:
+ return 0, ErrDurationUnterminated // HL
+ case -2:
+ return 0, ErrNoDuration // HL
+ default:
+ return time.Duation(durationUsec) * time.Microsecond, nil // HL
+ }
+ return 0, ErrNoIteration // HL
+}
« no previous file with comments | « 2014/readability/time_duration_good.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b