摘要:
Creating a unit test In Go, it’s standard practice to write your tests in *_test.go files which live directly alongside the code that you’re testing.
阅读全文
posted @ 2024-09-07 16:29
ZhangZhihuiAAA
阅读(17)
推荐(0)
摘要:
autocommit Command-Line Format --autocommit[={OFF|ON}] System Variable autocommit Scope Global, Session Dynamic Yes SET_VAR Hint Applies No Type Boole
阅读全文
posted @ 2024-09-07 10:31
ZhangZhihuiAAA
阅读(29)
推荐(0)
摘要:
Using request context At the moment our logic for authenticating a user consists of simply checking whether a "authenticatedUserID" value exists in th
阅读全文
posted @ 2024-09-07 09:22
ZhangZhihuiAAA
阅读(12)
推荐(0)
摘要:
User authentication Open up your handlers.go file and add placeholders for the five new handler functions as follows: func (app *application) userSign
阅读全文
posted @ 2024-09-05 21:19
ZhangZhihuiAAA
阅读(15)
推荐(0)
摘要:
The http.Server struct Although http.ListenAndServe() is very useful in short examples and tutorials, in real-world applications it’s more common to m
阅读全文
posted @ 2024-09-05 19:27
ZhangZhihuiAAA
阅读(10)
推荐(0)
摘要:
Stateful HTTP A nice touch to improve our user experience would be to display a one-time confirmation message which the user sees after they’ve added
阅读全文
posted @ 2024-09-05 15:17
ZhangZhihuiAAA
阅读(11)
推荐(0)
摘要:
Processing forms We’re going to add an HTML form for creating new snippets. The form will look a bit like this: The high-level flow for processing thi
阅读全文
posted @ 2024-09-04 22:36
ZhangZhihuiAAA
阅读(17)
推荐(0)
摘要:
How middleware works In fact, we’re actually already using some middleware in our application — the http.StripPrefix() function from serving static fi
阅读全文
posted @ 2024-09-04 19:05
ZhangZhihuiAAA
阅读(22)
推荐(0)
摘要:
Displaying dynamic data func (app *application) snippetView(w http.ResponseWriter, r *http.Request) { id, err := strconv.Atoi(r.PathValue("id")) if er
阅读全文
posted @ 2024-09-03 20:00
ZhangZhihuiAAA
阅读(10)
推荐(0)
摘要:
Creating a database connection pool // The sql.Open() function initializes a new sql.DB object, which is essentially a // pool of database connections
阅读全文
posted @ 2024-09-03 17:12
ZhangZhihuiAAA
阅读(24)
推荐(0)