Просмотр исходного кода

Syntax coloring for Readme

I think it helps readability.
Mustafa Akın 9 лет назад
Родитель
Сommit
502e17a0cb
1 измененных файлов с 4 добавлено и 4 удалено
  1. 4 4
      README.md

+ 4 - 4
README.md

@@ -3,7 +3,7 @@
 Package errors implements functions for manipulating errors.
 Package errors implements functions for manipulating errors.
 
 
 The traditional error handling idiom in Go is roughly akin to
 The traditional error handling idiom in Go is roughly akin to
-```
+```go
 if err != nil {
 if err != nil {
         return err
         return err
 }
 }
@@ -13,7 +13,7 @@ which applied recursively up the call stack results in error reports without con
 ## Adding context to an error
 ## Adding context to an error
 
 
 The errors.Wrap function returns a new error that adds context to the original error. For example
 The errors.Wrap function returns a new error that adds context to the original error. For example
-```
+```go
 _, err := ioutil.ReadAll(r)
 _, err := ioutil.ReadAll(r)
 if err != nil {
 if err != nil {
         return errors.Wrap(err, "read failed")
         return errors.Wrap(err, "read failed")
@@ -24,13 +24,13 @@ In addition, `errors.Wrap` records the file and line where it was called, allowi
 ## Retrieving the cause of an error
 ## Retrieving the cause of an error
 
 
 Using `errors.Wrap` constructs a stack of errors, adding context to the preceding error. Depending on the nature of the error it may be necessary to recurse the operation of errors.Wrap to retrieve the original error for inspection. Any error value which implements this interface can be inspected by `errors.Cause`.
 Using `errors.Wrap` constructs a stack of errors, adding context to the preceding error. Depending on the nature of the error it may be necessary to recurse the operation of errors.Wrap to retrieve the original error for inspection. Any error value which implements this interface can be inspected by `errors.Cause`.
-```
+```go
 type causer interface {
 type causer interface {
      Cause() error
      Cause() error
 }
 }
 ```
 ```
 `errors.Cause` will recursively retrieve the topmost error which does not implement `causer`, which is assumed to be the original cause. For example:
 `errors.Cause` will recursively retrieve the topmost error which does not implement `causer`, which is assumed to be the original cause. For example:
-```
+```go
 switch err := errors.Cause(err).(type) {
 switch err := errors.Cause(err).(type) {
 case *MyError:
 case *MyError:
         // handle specifically
         // handle specifically