31/01 Study Daily record

손진성·2022년 2월 1일
0

Rest API

  • API(Application Programming Interface)
    • Interface : Method which is used for communication.
      for example : TV Remote control signal -> TV function
    • API is used for communicating application.
      for example : downloading API from
      Meteorological Agency. They share how to collect information from their server.

Rest - RESTful
- Resource(URI)
- Verb(Http Method)
- Representations

how to design Rest API?
1) Use slash only for showing hierarchical relationship.
2) Do not include Slash to ending of URL
3) Use hyphen rather than underscore
4) Small letter is recommended
5) Do not include file extention to URL

Summary
Architecture that can take advantage of the web

Go

Unusual function define

 add := func(a, b int) int {
		return a + b
	}
	fmt.Println(add(1, 2))
  • I don't know when this function structure will be used
  • An anonymous function initialized to a variable is that you can use the variable name just like the name of the function.
  • Declared functions and anonymous functions are read in a different order inside the program. The declaration function are read as soon as the program starts. However, since anonymous functions are executed, they are read from where the function is executed. That is, anonymous functions are read later than declaration functions.
    -A global variable with the same name will be covered by local variable in the flow.

Closure Function

func main() {
	inc := incrementer()
	fmt.Println(inc(), inc(), inc())
}

func incrementer() func() int {
	// initializes i
	i := 0
	return func() int {
		// the new value of it will be retained
		i++
		return i
	}
  • If you check the output result value, each time icn is executed, the value is not initialized, but incremented by 1 following the previous flow.
profile
Gopyther

0개의 댓글