trying to fix markdown bug

This commit is contained in:
Jeffrey Paul 2024-06-10 04:24:21 -07:00
parent e7548045be
commit dc211342c3

121
README.md
View File

@ -186,97 +186,96 @@
`io.Reader` instead of `*os.File`. Tailor these to the needs of the `io.Reader` instead of `*os.File`. Tailor these to the needs of the
specific function or method. Examples: specific function or method. Examples:
1. **`io.Reader`** instead of `*os.File`: - **`io.Reader`** instead of `*os.File`:
- `io.Reader` is a common interface for reading data, which can be - `io.Reader` is a common interface for reading data, which can be
implemented by many types, including `*os.File`, `bytes.Buffer`, implemented by many types, including `*os.File`, `bytes.Buffer`,
`strings.Reader`, and network connections like `net.Conn`. `strings.Reader`, and network connections like `net.Conn`.
2. **`io.Writer`** instead of `*os.File` or `*bytes.Buffer`: - **`io.Writer`** instead of `*os.File` or `*bytes.Buffer`:
- `io.Writer` is used for writing data. It can be implemented by - `io.Writer` is used for writing data. It can be implemented by
`*os.File`, `bytes.Buffer`, `net.Conn`, and more. `*os.File`, `bytes.Buffer`, `net.Conn`, and more.
3. **`io.ReadWriter`** instead of `*os.File`: - **`io.ReadWriter`** instead of `*os.File`:
- `io.ReadWriter` combines `io.Reader` and `io.Writer`. It is often - `io.ReadWriter` combines `io.Reader` and `io.Writer`. It is often
used for types that can both read and write, such as `*os.File` used for types that can both read and write, such as `*os.File`
and `net.Conn`. and `net.Conn`.
4. **`io.Closer`** instead of `*os.File` or `*net.Conn`: - **`io.Closer`** instead of `*os.File` or `*net.Conn`:
- `io.Closer` is used for types that need to be closed, including - `io.Closer` is used for types that need to be closed, including
`*os.File`, `net.Conn`, and other resources that require cleanup. `*os.File`, `net.Conn`, and other resources that require cleanup.
5. **`io.ReadCloser`** instead of `*os.File` or `http.Response.Body`: - **`io.ReadCloser`** instead of `*os.File` or `http.Response.Body`:
- `io.ReadCloser` combines `io.Reader` and `io.Closer`, and is - `io.ReadCloser` combines `io.Reader` and `io.Closer`, and is
commonly used for types like `*os.File` and `http.Response.Body`. commonly used for types like `*os.File` and `http.Response.Body`.
6. **`io.WriteCloser`** instead of `*os.File` or `*gzip.Writer`: - **`io.WriteCloser`** instead of `*os.File` or `*gzip.Writer`:
- `io.WriteCloser` combines `io.Writer` and `io.Closer`. It is used - `io.WriteCloser` combines `io.Writer` and `io.Closer`. It is used
for types like `*os.File` and `gzip.Writer`. for types like `*os.File` and `gzip.Writer`.
7. **`io.ReadWriteCloser`** instead of `*os.File` or `*net.TCPConn`: - **`io.ReadWriteCloser`** instead of `*os.File` or `*net.TCPConn`:
- `io.ReadWriteCloser` combines `io.Reader`, `io.Writer`, and - `io.ReadWriteCloser` combines `io.Reader`, `io.Writer`, and
`io.Closer`. Examples include `*os.File` and `net.TCPConn`. `io.Closer`. Examples include `*os.File` and `net.TCPConn`.
8. **`fmt.Stringer`** instead of implementing a custom `String` method: - **`fmt.Stringer`** instead of implementing a custom `String` method:
- `fmt.Stringer` is an interface for types that can convert - `fmt.Stringer` is an interface for types that can convert
themselves to a string. Any type that implements the `String() themselves to a string. Any type that implements the `String()
string` method satisfies this interface.
string` method satisfies this interface. - **`error`** instead of custom error types:
9. **`error`** instead of custom error types: - The `error` interface is used for representing errors. Instead of
defining custom error types, you can use the `errors.New`
function or the `fmt.Errorf` function to create errors.
- The `error` interface is used for representing errors. Instead of - **`net.Conn`** instead of `*net.TCPConn` or `*net.UDPConn`:
defining custom error types, you can use the `errors.New`
function or the `fmt.Errorf` function to create errors.
10. **`net.Conn`** instead of `*net.TCPConn` or `*net.UDPConn`: - `net.Conn` is a generic network connection interface that can be
implemented by TCP, UDP, and other types of network connections.
- `net.Conn` is a generic network connection interface that can be - **`http.Handler`** instead of custom HTTP handlers:
implemented by TCP, UDP, and other types of network connections.
11. **`http.Handler`** instead of custom HTTP handlers: - `http.Handler` is an interface for handling HTTP requests.
Instead of creating custom handler types, you can use types that
implement the `ServeHTTP(http.ResponseWriter, *http.Request)`
method.
- `http.Handler` is an interface for handling HTTP requests. - **`http.HandlerFunc`** instead of creating a new type:
Instead of creating custom handler types, you can use types that
implement the `ServeHTTP(http.ResponseWriter, *http.Request)`
method.
12. **`http.HandlerFunc`** instead of creating a new type: - `http.HandlerFunc` is a type that allows you to use functions as
HTTP handlers by implementing the `http.Handler` interface.
- `http.HandlerFunc` is a type that allows you to use functions as - **`encoding.BinaryMarshaler` and `encoding.BinaryUnmarshaler`**
HTTP handlers by implementing the `http.Handler` interface. instead of custom marshal/unmarshal methods:
13. **`encoding.BinaryMarshaler` and `encoding.BinaryUnmarshaler`** - These interfaces are used for binary serialization and
instead of custom marshal/unmarshal methods: deserialization. Implementing these interfaces allows types to
be encoded and decoded in a standard way.
- These interfaces are used for binary serialization and - **`encoding.TextMarshaler` and `encoding.TextUnmarshaler`** instead
deserialization. Implementing these interfaces allows types to of custom text marshal/unmarshal methods:
be encoded and decoded in a standard way.
14. **`encoding.TextMarshaler` and `encoding.TextUnmarshaler`** instead - These interfaces are used for text-based serialization and
of custom text marshal/unmarshal methods: deserialization. They are useful for types that need to be
represented as text.
- These interfaces are used for text-based serialization and - **`sort.Interface`** instead of custom sorting logic:
deserialization. They are useful for types that need to be
represented as text.
15. **`sort.Interface`** instead of custom sorting logic: - `sort.Interface` is an interface for sorting collections. By
implementing the `Len`, `Less`, and `Swap` methods, you can sort
any collection using the `sort.Sort` function.
- `sort.Interface` is an interface for sorting collections. By - **`flag.Value`** instead of custom flag parsing:
implementing the `Len`, `Less`, and `Swap` methods, you can sort - `flag.Value` is an interface for defining custom command-line
any collection using the `sort.Sort` function. flags. Implementing the `String` and `Set` methods allows you to
use custom types with the `flag` package.
16. **`flag.Value`** instead of custom flag parsing:
- `flag.Value` is an interface for defining custom command-line
flags. Implementing the `String` and `Set` methods allows you to
use custom types with the `flag` package.
39. Avoid using `panic` in library code. Instead, return errors to allow 39. Avoid using `panic` in library code. Instead, return errors to allow
the caller to handle them. Reserve `panic` for truly exceptional the caller to handle them. Reserve `panic` for truly exceptional