go: update
This commit is contained in:
parent
9b85ea8b5b
commit
44fceaf4d2
|
@ -132,10 +132,17 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Line divisions */
|
// Line divisions
|
||||||
& > *:not(:first-child) {
|
& > *:not(:first-child) {
|
||||||
border-top: solid 1px $line-color;
|
border-top: solid 1px $line-color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Collapse paragraphs together
|
||||||
|
& > p + p,
|
||||||
|
& > p + p:not(:first-child) {
|
||||||
|
margin-top: -1.5em;
|
||||||
|
border-top: 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
53
go.md
53
go.md
|
@ -233,6 +233,58 @@ By defining the return value names in the signature, a `return` (no args) will r
|
||||||
|
|
||||||
See: [Named return values](https://tour.golang.org/basics/7)
|
See: [Named return values](https://tour.golang.org/basics/7)
|
||||||
|
|
||||||
|
## Packages
|
||||||
|
{: .-three-column}
|
||||||
|
|
||||||
|
### Importing
|
||||||
|
|
||||||
|
```go
|
||||||
|
import "fmt"
|
||||||
|
import "math/rand"
|
||||||
|
```
|
||||||
|
|
||||||
|
```go
|
||||||
|
import (
|
||||||
|
"fmt" // gives fmt.Println
|
||||||
|
"math/rand" // gives rand.Intn
|
||||||
|
)
|
||||||
|
```
|
||||||
|
|
||||||
|
Both are the same.
|
||||||
|
|
||||||
|
See: [Importing](https://tour.golang.org/basics/1)
|
||||||
|
|
||||||
|
### Aliases
|
||||||
|
|
||||||
|
```go
|
||||||
|
import r "math/rand"
|
||||||
|
```
|
||||||
|
{: data-line="1"}
|
||||||
|
|
||||||
|
```go
|
||||||
|
r.Intn()
|
||||||
|
```
|
||||||
|
|
||||||
|
### Exporting names
|
||||||
|
|
||||||
|
```go
|
||||||
|
func Hello () {
|
||||||
|
···
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Exported names begin with capital letters.
|
||||||
|
|
||||||
|
See: [Exported names](https://tour.golang.org/basics/3)
|
||||||
|
|
||||||
|
### Packages
|
||||||
|
|
||||||
|
```go
|
||||||
|
package hello
|
||||||
|
```
|
||||||
|
|
||||||
|
Every package file has to start with `package`.
|
||||||
|
|
||||||
## Concurrency
|
## Concurrency
|
||||||
{: .-three-column}
|
{: .-three-column}
|
||||||
|
|
||||||
|
@ -301,6 +353,7 @@ for i := range ch {
|
||||||
···
|
···
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
{: data-line="2"}
|
||||||
|
|
||||||
```go
|
```go
|
||||||
// Closed if ok == false
|
// Closed if ok == false
|
||||||
|
|
27
react.md
27
react.md
|
@ -64,6 +64,7 @@ render () {
|
||||||
{: data-line="2"}
|
{: data-line="2"}
|
||||||
|
|
||||||
Use `this.props` to access properties passed to the component.
|
Use `this.props` to access properties passed to the component.
|
||||||
|
|
||||||
See: [Properties](https://facebook.github.io/react/docs/tutorial.html#using-props)
|
See: [Properties](https://facebook.github.io/react/docs/tutorial.html#using-props)
|
||||||
|
|
||||||
### States
|
### States
|
||||||
|
@ -81,6 +82,7 @@ render () {
|
||||||
{: data-line="2"}
|
{: data-line="2"}
|
||||||
|
|
||||||
Use states (`this.state`) to manage dynamic data.
|
Use states (`this.state`) to manage dynamic data.
|
||||||
|
|
||||||
See: [States](https://facebook.github.io/react/docs/tutorial.html#reactive-state)
|
See: [States](https://facebook.github.io/react/docs/tutorial.html#reactive-state)
|
||||||
|
|
||||||
### Nesting
|
### Nesting
|
||||||
|
@ -99,8 +101,9 @@ class Info extends React.Component {
|
||||||
```
|
```
|
||||||
{: data-line="6,7"}
|
{: data-line="6,7"}
|
||||||
|
|
||||||
Nest components to separate concerns. See: [Composing Components](https://facebook.github.io/react/docs/components-and-props.html#composing-components)
|
Nest components to separate concerns.
|
||||||
|
|
||||||
|
See: [Composing Components](https://facebook.github.io/react/docs/components-and-props.html#composing-components)
|
||||||
|
|
||||||
### Children
|
### Children
|
||||||
|
|
||||||
|
@ -168,6 +171,7 @@ function MyComponent ({ name }) {
|
||||||
{: data-line="1"}
|
{: data-line="1"}
|
||||||
|
|
||||||
Functional components have no state. Also, their `props` are passed as the first parameter to a function.
|
Functional components have no state. Also, their `props` are passed as the first parameter to a function.
|
||||||
|
|
||||||
See: [Function and Class Components](https://facebook.github.io/react/docs/components-and-props.html#functional-and-class-components)
|
See: [Function and Class Components](https://facebook.github.io/react/docs/components-and-props.html#functional-and-class-components)
|
||||||
|
|
||||||
### Pure components
|
### Pure components
|
||||||
|
@ -180,6 +184,7 @@ class MessageBox extends React.PureComponent {
|
||||||
{: data-line="1"}
|
{: data-line="1"}
|
||||||
|
|
||||||
Performance-optimized version of `React.Component`. Doesn't rerender if props/state hasn't changed.
|
Performance-optimized version of `React.Component`. Doesn't rerender if props/state hasn't changed.
|
||||||
|
|
||||||
See: [Pure components](https://facebook.github.io/react/docs/react-api.html#react.purecomponent)
|
See: [Pure components](https://facebook.github.io/react/docs/react-api.html#react.purecomponent)
|
||||||
|
|
||||||
### Component API
|
### Component API
|
||||||
|
@ -197,7 +202,9 @@ this.state
|
||||||
this.props
|
this.props
|
||||||
```
|
```
|
||||||
|
|
||||||
These methods and properies are available for `Component` instances. See: [Component API](http://facebook.github.io/react/docs/component-api.html)
|
These methods and properies are available for `Component` instances.
|
||||||
|
|
||||||
|
See: [Component API](http://facebook.github.io/react/docs/component-api.html)
|
||||||
|
|
||||||
Lifecycle
|
Lifecycle
|
||||||
---------
|
---------
|
||||||
|
@ -227,7 +234,9 @@ Add DOM event handlers, timers (etc) on `componentDidMount()`, then remove them
|
||||||
| `render()` | Render |
|
| `render()` | Render |
|
||||||
| `componentDidUpdate` *(prevProps, prevState)* | Operate on the DOM here |
|
| `componentDidUpdate` *(prevProps, prevState)* | Operate on the DOM here |
|
||||||
|
|
||||||
Called when parents change properties and `.setState()`. These are not called for initial renders. See: [Reference](http://facebook.github.io/react/docs/component-specs.html#updating-componentwillreceiveprops).
|
Called when parents change properties and `.setState()`. These are not called for initial renders.
|
||||||
|
|
||||||
|
See: [Component specs](http://facebook.github.io/react/docs/component-specs.html#updating-componentwillreceiveprops)
|
||||||
|
|
||||||
DOM nodes
|
DOM nodes
|
||||||
---------
|
---------
|
||||||
|
@ -250,7 +259,9 @@ class MyComponent extends React.Component {
|
||||||
```
|
```
|
||||||
{: data-line="4,9"}
|
{: data-line="4,9"}
|
||||||
|
|
||||||
Allows access to DOM nodes. See: [Refs and the DOM](https://facebook.github.io/react/docs/refs-and-the-dom.html)
|
Allows access to DOM nodes.
|
||||||
|
|
||||||
|
See: [Refs and the DOM](https://facebook.github.io/react/docs/refs-and-the-dom.html)
|
||||||
|
|
||||||
### DOM Events
|
### DOM Events
|
||||||
|
|
||||||
|
@ -269,7 +280,9 @@ class MyComponent extends React.Component {
|
||||||
```
|
```
|
||||||
{: data-line="5,9"}
|
{: data-line="5,9"}
|
||||||
|
|
||||||
Pass functions to attributes like `onChange`. See: [Events](https://facebook.github.io/react/docs/events.html)
|
Pass functions to attributes like `onChange`.
|
||||||
|
|
||||||
|
See: [Events](https://facebook.github.io/react/docs/events.html)
|
||||||
|
|
||||||
## Other features
|
## Other features
|
||||||
|
|
||||||
|
@ -290,7 +303,8 @@ class VideoPlayer extends React.Component {
|
||||||
{: data-line="3"}
|
{: data-line="3"}
|
||||||
|
|
||||||
Propagates `src="..."` down to the sub-component.
|
Propagates `src="..."` down to the sub-component.
|
||||||
See [Transferring props](http://facebook.github.io/react/docs/transferring-props.html).
|
|
||||||
|
See [Transferring props](http://facebook.github.io/react/docs/transferring-props.html)
|
||||||
|
|
||||||
### Top-level API
|
### Top-level API
|
||||||
|
|
||||||
|
@ -310,6 +324,7 @@ ReactDOMServer.renderToStaticMarkup(<Component />)
|
||||||
```
|
```
|
||||||
|
|
||||||
There are more, but these are most common.
|
There are more, but these are most common.
|
||||||
|
|
||||||
See: [React top-level API](https://facebook.github.io/react/docs/react-api.html)
|
See: [React top-level API](https://facebook.github.io/react/docs/react-api.html)
|
||||||
|
|
||||||
JSX patterns
|
JSX patterns
|
||||||
|
|
Loading…
Reference in New Issue