Showing preview only (2,041K chars total). Download the full file or copy to clipboard to get everything.
Repository: go-park-mail-ru/lectures
Branch: master
Commit: ba3aaf243a75
Files: 487
Total size: 1.8 MB
Directory structure:
gitextract_cnldqe8r/
├── .gitignore
├── .gitmodules
├── 1-basics/
│ ├── 1_basics/
│ │ ├── 01_vars_1/
│ │ │ └── 01_vars_1.go
│ │ ├── 02_vars_2/
│ │ │ └── 02_vars_2.go
│ │ ├── 03_const/
│ │ │ └── 03_const.go
│ │ ├── 04_pointers/
│ │ │ └── 04_pointers.go
│ │ ├── 05_array/
│ │ │ └── 05_array.go
│ │ ├── 06_slice_1/
│ │ │ └── 06_slice_1.go
│ │ ├── 07_slice_2/
│ │ │ └── 07_slice_2.go
│ │ ├── 08_strings/
│ │ │ └── 08_strings.go
│ │ ├── 09_map/
│ │ │ └── 09_map.go
│ │ ├── 10_control/
│ │ │ └── 10_control.go
│ │ ├── 11_loop/
│ │ │ └── 11_loop.go
│ │ ├── 12_types/
│ │ │ └── 12_types.go
│ │ └── 13_generic/
│ │ ├── 1_generic/
│ │ │ └── main.go
│ │ └── 2_methods/
│ │ └── methods.go
│ ├── 2_functions/
│ │ ├── 1_functions/
│ │ │ └── 1_functions.go
│ │ ├── 2_firstclass/
│ │ │ └── 2_firstclass.go
│ │ ├── 3_defer/
│ │ │ └── 3_defer.go
│ │ └── 4_recover/
│ │ └── 4_recover.go
│ ├── 3_structs/
│ │ ├── 1_structs/
│ │ │ └── 1_structs.go
│ │ └── 2_methods/
│ │ └── 2_methods.go
│ ├── 4_interfaces/
│ │ ├── 1.2_basic_sort/
│ │ │ └── 1_sort.go
│ │ ├── 1_basic/
│ │ │ └── 1_basic.go
│ │ ├── 2_many/
│ │ │ └── 2_many.go
│ │ ├── 3_embed/
│ │ │ └── 3_embed.go
│ │ ├── 4_cast/
│ │ │ └── 4_cast.go
│ │ ├── 5_empty_1/
│ │ │ └── 5_empty_1.go
│ │ └── 6_empty_2/
│ │ └── 6_empty_2.go
│ ├── 5_visibility/
│ │ ├── dir.txt
│ │ ├── main.go
│ │ └── person/
│ │ ├── func.go
│ │ └── person.go
│ ├── 6_uniq/
│ │ ├── basic/
│ │ │ ├── data.txt
│ │ │ ├── data_bad.txt
│ │ │ ├── data_map.txt
│ │ │ └── main.go
│ │ └── with_tests/
│ │ ├── data.txt
│ │ ├── data_bad.txt
│ │ ├── data_map.txt
│ │ ├── main.go
│ │ └── main_test.go
│ ├── go-intro.key
│ ├── homework/
│ │ └── readme.md
│ └── readme.md
├── 10-performance/
│ ├── 1_reflect/
│ │ ├── 1_print/
│ │ │ └── reflect_1.go
│ │ └── 2_unpack/
│ │ └── reflect_2.go
│ ├── 2_codegen/
│ │ ├── gen/
│ │ │ └── codegen.go
│ │ └── pack/
│ │ ├── marshaller.go
│ │ └── unpack.go
│ ├── 3_perfomance_1/
│ │ ├── 1_unpack/
│ │ │ └── unpack_test.go
│ │ ├── 2_prealloc/
│ │ │ └── prealloc_test.go
│ │ ├── 3_pool/
│ │ │ └── pool_test.go
│ │ ├── 4_string/
│ │ │ └── string_test.go
│ │ └── 5_json/
│ │ ├── json_test.go
│ │ ├── struct.go
│ │ └── struct_easyjson.go
│ ├── 4_perfomance_2/
│ │ ├── 1_optimize/
│ │ │ ├── pprof_1.go
│ │ │ └── pprof_1.sh
│ │ ├── 2_leak_grtn/
│ │ │ ├── pprof_2.go
│ │ │ └── pprof_2.sh
│ │ ├── 3_tracing/
│ │ │ └── tracing.go
│ │ └── note.txt
│ ├── 5_testing/
│ │ ├── cover.html
│ │ ├── coverage_test.go
│ │ └── main.go
│ ├── 6_xml_stream/
│ │ ├── main.go
│ │ └── xml_test.go
│ ├── 7_inline_escape/
│ │ └── main.go
│ ├── 8_cgo/
│ │ ├── 1_example/
│ │ │ └── main.go
│ │ ├── 2_performance/
│ │ │ └── main.go
│ │ ├── 3_usage/
│ │ │ ├── README.md
│ │ │ ├── go.mod
│ │ │ ├── go.sum
│ │ │ └── main.go
│ │ └── README.md
│ └── readme.md
├── 2-async/
│ ├── 0_basic_error_handling/
│ │ ├── 1_ignore_errors/
│ │ │ └── main.go
│ │ ├── 2_panic/
│ │ │ └── main.go
│ │ ├── 3_handling/
│ │ │ └── main.go
│ │ └── 4_return/
│ │ └── main.go
│ ├── 1_async/
│ │ ├── 10_context_cancel/
│ │ │ └── context_cancel.go
│ │ ├── 10_context_timeout/
│ │ │ ├── context_parent/
│ │ │ │ └── main.go
│ │ │ └── context_timeout.go
│ │ ├── 11_errgroup_1/
│ │ │ └── errgroup_1.go
│ │ ├── 11_errgroup_2/
│ │ │ └── errgroup_2.go
│ │ ├── 12_atomic_1/
│ │ │ └── atomic_1.go
│ │ ├── 12_atomic_2/
│ │ │ ├── atomic_2.go
│ │ │ └── with_bench/
│ │ │ └── mutex_test.go
│ │ ├── 13_ratelim/
│ │ │ └── ratelim.go
│ │ ├── 14_once/
│ │ │ └── once.go
│ │ ├── 1_goroutines/
│ │ │ ├── goroutines.go
│ │ │ ├── i_ptr/
│ │ │ │ └── main.go
│ │ │ └── mem/
│ │ │ └── main.go
│ │ ├── 1_goroutines_2/
│ │ │ └── goroutines.go
│ │ ├── 2_chan/
│ │ │ └── chan_1.go
│ │ ├── 2_chan_2/
│ │ │ └── chan_2.go
│ │ ├── 3_workerpool/
│ │ │ ├── 1_workerpool.go
│ │ │ └── 2_workerpool_reusable.go
│ │ ├── 4_race_1/
│ │ │ └── race_1.go
│ │ ├── 4_race_2/
│ │ │ ├── race_2.go
│ │ │ └── race_flag/
│ │ │ └── working_race.go
│ │ ├── 4_race_3/
│ │ │ └── race_3.go
│ │ ├── 4_race_3_bench/
│ │ │ └── race_test.go
│ │ ├── 5_tick/
│ │ │ └── tick.go
│ │ ├── 5_tick_example/
│ │ │ ├── 5_ping_pong/
│ │ │ │ └── main.go
│ │ │ └── main.go
│ │ ├── 6_afterfunc/
│ │ │ └── afterfunc.go
│ │ ├── 7_select_1/
│ │ │ └── select_1.go
│ │ ├── 7_select_2/
│ │ │ └── select_2.go
│ │ ├── 7_select_2_new/
│ │ │ ├── close_buff/
│ │ │ │ └── main.go
│ │ │ └── select_2_new.go
│ │ ├── 7_select_3/
│ │ │ ├── close_all/
│ │ │ │ └── main.go
│ │ │ ├── close_signal/
│ │ │ │ └── main.go
│ │ │ └── select_3.go
│ │ ├── 8_wait_1/
│ │ │ └── wait_1.go
│ │ ├── 8_wait_2/
│ │ │ ├── ping_pong/
│ │ │ │ └── main.go
│ │ │ └── wait_2.go
│ │ ├── 8_wait_3/
│ │ │ └── wait_3.go
│ │ └── 9_timeout/
│ │ └── timeout.go
│ └── readings_2.md
├── 3-web/
│ ├── 0_json/
│ │ ├── 0_simple_json/
│ │ │ └── simple_json.go
│ │ ├── 1_struct_tags/
│ │ │ └── struct_tags.go
│ │ ├── 2_custom/
│ │ │ └── custom.go
│ │ └── 3_dynamic/
│ │ └── dynamic.go
│ ├── 1_net/
│ │ └── net_listen.go
│ ├── 2_http/
│ │ ├── 0_http_server/
│ │ │ ├── 0_basic/
│ │ │ │ └── basic.go
│ │ │ ├── 1_pages/
│ │ │ │ └── pages.go
│ │ │ ├── 2_servehttp/
│ │ │ │ └── servehttp.go
│ │ │ ├── 3_mux/
│ │ │ │ └── mux.go
│ │ │ └── 4_servers/
│ │ │ └── servers.go
│ │ ├── 1_request/
│ │ │ ├── 0_get/
│ │ │ │ └── get.go
│ │ │ ├── 1_post/
│ │ │ │ └── post.go
│ │ │ ├── 2_cookies/
│ │ │ │ └── cookies.go
│ │ │ └── 3_headers/
│ │ │ └── headers.go
│ │ ├── 2_http_client/
│ │ │ └── client.go
│ │ ├── 3_files/
│ │ │ ├── 0_file_upload/
│ │ │ │ └── file_upload.go
│ │ │ └── 1_static/
│ │ │ ├── static/
│ │ │ │ └── super_secret_password
│ │ │ └── static.go
│ │ └── 4_httptest/
│ │ ├── 0_client/
│ │ │ └── client_test.go
│ │ └── 1_server/
│ │ └── server_test.go
│ ├── 3_template/
│ │ ├── 0_inline/
│ │ │ └── inline.go
│ │ ├── 1_file/
│ │ │ ├── file.go
│ │ │ └── users.html
│ │ ├── 2_func/
│ │ │ ├── func.go
│ │ │ └── func.html
│ │ └── 3_method/
│ │ ├── method.go
│ │ └── method.html
│ ├── 4_json_http/
│ │ ├── main.go
│ │ └── main_test.go
│ └── readings_3.md
├── 4-api/
│ ├── 1_rpc/
│ │ ├── jsonrpc/
│ │ │ ├── books.go
│ │ │ └── server.go
│ │ ├── main.go
│ │ └── net-rpc/
│ │ ├── books.go
│ │ ├── client.go
│ │ └── server.go
│ ├── 2_rest/
│ │ ├── books.go
│ │ └── main.go
│ ├── 3_graphql/
│ │ ├── gqlgen/
│ │ │ ├── generated.go
│ │ │ ├── gqlgen.yml
│ │ │ ├── models_gen.go
│ │ │ ├── resolver.go
│ │ │ ├── schema.graphql
│ │ │ └── server/
│ │ │ └── server.go
│ │ ├── gqlgen_full/
│ │ │ ├── gqlgen1/
│ │ │ │ ├── generated.go
│ │ │ │ ├── go.mod
│ │ │ │ ├── go.sum
│ │ │ │ ├── gqlgen.yml
│ │ │ │ ├── models_gen.go
│ │ │ │ ├── resolver.go
│ │ │ │ ├── schema.graphql
│ │ │ │ └── server/
│ │ │ │ └── server.go
│ │ │ ├── gqlgen2/
│ │ │ │ ├── generated.go
│ │ │ │ ├── go.mod
│ │ │ │ ├── go.sum
│ │ │ │ ├── gqlgen.yml
│ │ │ │ ├── models_gen.go
│ │ │ │ ├── photo.go
│ │ │ │ ├── resolver.go
│ │ │ │ ├── schema.graphql
│ │ │ │ ├── schema_alt.graphql
│ │ │ │ └── server/
│ │ │ │ └── server.go
│ │ │ ├── gqlgen3/
│ │ │ │ ├── generated.go
│ │ │ │ ├── go.mod
│ │ │ │ ├── go.sum
│ │ │ │ ├── gqlgen.yml
│ │ │ │ ├── models_gen.go
│ │ │ │ ├── photo.go
│ │ │ │ ├── resolver.go
│ │ │ │ ├── schema.graphql
│ │ │ │ ├── schema_alt.graphql
│ │ │ │ ├── server/
│ │ │ │ │ └── server.go
│ │ │ │ └── userloader_gen.go
│ │ │ ├── gqlgen4/
│ │ │ │ ├── generated.go
│ │ │ │ ├── go.mod
│ │ │ │ ├── go.sum
│ │ │ │ ├── gqlgen.yml
│ │ │ │ ├── models_gen.go
│ │ │ │ ├── photo.go
│ │ │ │ ├── queries.txt
│ │ │ │ ├── resolver.go
│ │ │ │ ├── schema.graphql
│ │ │ │ ├── server/
│ │ │ │ │ └── server.go
│ │ │ │ └── userloader_gen.go
│ │ │ ├── gqlgen5/
│ │ │ │ ├── generated.go
│ │ │ │ ├── go.mod
│ │ │ │ ├── go.sum
│ │ │ │ ├── gqlgen.yml
│ │ │ │ ├── models_gen.go
│ │ │ │ ├── photo.go
│ │ │ │ ├── queries.txt
│ │ │ │ ├── resolver.go
│ │ │ │ ├── schema.graphql
│ │ │ │ ├── server/
│ │ │ │ │ └── server.go
│ │ │ │ ├── test_file.txt
│ │ │ │ └── userloader_gen.go
│ │ │ ├── gqlgen6/
│ │ │ │ ├── generated.go
│ │ │ │ ├── go.mod
│ │ │ │ ├── go.sum
│ │ │ │ ├── gqlgen.yml
│ │ │ │ ├── models_gen.go
│ │ │ │ ├── photo.go
│ │ │ │ ├── queries.txt
│ │ │ │ ├── resolver.go
│ │ │ │ ├── schema.graphql
│ │ │ │ ├── server/
│ │ │ │ │ └── server.go
│ │ │ │ ├── test_file.txt
│ │ │ │ └── userloader_gen.go
│ │ │ └── note.txt
│ │ ├── graphql-go/
│ │ │ └── main.go
│ │ └── intro/
│ │ ├── instagram_gql.txt
│ │ ├── instagram_sql_resp.json
│ │ ├── readme.md
│ │ └── schema.public.graphql
│ ├── 4_swagger/
│ │ ├── docs/
│ │ │ ├── docs.go
│ │ │ ├── swagger/
│ │ │ │ ├── swagger.json
│ │ │ │ └── swagger.yaml
│ │ │ ├── swagger.json
│ │ │ └── swagger.yaml
│ │ ├── main.go
│ │ └── model/
│ │ └── user.go
│ ├── 5_sessions/
│ │ └── main.go
│ ├── 6_jwt/
│ │ └── main.go
│ └── 7_oauth/
│ └── main.go
├── 5-architecture/
│ ├── 0_bad_example/
│ │ └── api.go
│ ├── 10_crudapp/
│ │ ├── cmd/
│ │ │ └── crudapp/
│ │ │ └── main.go
│ │ ├── file_tree.txt
│ │ ├── go.mod
│ │ ├── go.sum
│ │ ├── internal/
│ │ │ ├── crudapp/
│ │ │ │ └── middleware/
│ │ │ │ ├── accesslog.go
│ │ │ │ ├── auth.go
│ │ │ │ └── panic.go
│ │ │ └── pkg/
│ │ │ ├── items/
│ │ │ │ ├── delivery/
│ │ │ │ │ └── items.go
│ │ │ │ ├── items.go
│ │ │ │ └── repository/
│ │ │ │ └── repo.go
│ │ │ ├── models/
│ │ │ │ ├── item.go
│ │ │ │ ├── session.go
│ │ │ │ └── user.go
│ │ │ ├── session/
│ │ │ │ └── manager.go
│ │ │ └── user/
│ │ │ ├── delivery/
│ │ │ │ ├── user.go
│ │ │ │ └── user_test.go
│ │ │ ├── mock/
│ │ │ │ └── mock_repo.go
│ │ │ ├── repository/
│ │ │ │ └── user.go
│ │ │ └── user.go
│ │ ├── readme.md
│ │ └── templates/
│ │ ├── create.html
│ │ ├── edit.html
│ │ ├── index.html
│ │ └── login.html
│ ├── 1_routers/
│ │ ├── 0_httprouter/
│ │ │ └── 0_httprouter.go
│ │ ├── 1_fasthttp/
│ │ │ └── 1_fasthttp.go
│ │ ├── 2_gorilla/
│ │ │ └── 2_gorilla.go
│ │ └── 3_multiple/
│ │ └── 3_multiple.go
│ ├── 2_middleware/
│ │ ├── 1_middleware/
│ │ │ └── 1_middleware.go
│ │ └── 2_context_value/
│ │ └── 2_context_value.go
│ ├── 3_errors/
│ │ ├── 1_basic_err/
│ │ │ └── 1_basic_err.go
│ │ ├── 2_named_err/
│ │ │ └── 2_named_err.go
│ │ ├── 3_pkg_err/
│ │ │ └── 3_pkg_err.go
│ │ ├── 4_own_err/
│ │ │ └── 4_own_err.go
│ │ └── 5_new_errors/
│ │ └── 5_new_errors.go
│ ├── 4_validation/
│ │ └── validation.go
│ ├── 5_logging/
│ │ └── main.go
│ ├── 6_websockets/
│ │ ├── index.html
│ │ └── main.go
│ ├── 7_frameworks/
│ │ └── echo/
│ │ ├── main.go
│ │ ├── middleware/
│ │ │ ├── error.go
│ │ │ ├── panic.go
│ │ │ ├── request_id.go
│ │ │ └── session.go
│ │ ├── model/
│ │ │ └── user.go
│ │ └── user/
│ │ ├── delivery/
│ │ │ └── http/
│ │ │ ├── hander_test.go
│ │ │ └── handler.go
│ │ ├── repository/
│ │ │ └── memory.go
│ │ ├── repository.go
│ │ ├── usecase/
│ │ │ └── usecase.go
│ │ ├── usecase.go
│ │ └── usecase_mock.go
│ └── readings_5.md
├── 6-databases/
│ ├── 00_databases/
│ │ ├── _kafka/
│ │ │ └── setup.sh
│ │ ├── _mysql/
│ │ │ ├── injection_db.sql
│ │ │ └── items.sql
│ │ ├── _postgres/
│ │ │ └── items.sql
│ │ └── docker-compose.yml
│ ├── 01_mysql/
│ │ ├── main.go
│ │ └── templates/
│ │ ├── create.html
│ │ ├── edit.html
│ │ └── index.html
│ ├── 02_postgresql/
│ │ ├── main.go
│ │ └── templates/
│ │ ├── create.html
│ │ ├── edit.html
│ │ └── index.html
│ ├── 03_mysql_sql_injection/
│ │ └── main.go
│ ├── 04_mysql_sqlmock/
│ │ ├── item_repo.go
│ │ ├── item_repo_test.go
│ │ ├── main.go
│ │ └── templates/
│ │ ├── create.html
│ │ ├── edit.html
│ │ └── index.html
│ ├── 05_gorm/
│ │ ├── main.go
│ │ └── templates/
│ │ ├── create.html
│ │ ├── edit.html
│ │ └── index.html
│ ├── 06_crudapp_db_tests/
│ │ ├── cmd/
│ │ │ └── crudapp/
│ │ │ └── main.go
│ │ ├── pkg/
│ │ │ ├── handlers/
│ │ │ │ ├── handler.html
│ │ │ │ ├── items.go
│ │ │ │ ├── items_mock.go
│ │ │ │ ├── items_test.go
│ │ │ │ └── user.go
│ │ │ ├── items/
│ │ │ │ ├── item.go
│ │ │ │ ├── item_repo_test.go
│ │ │ │ ├── repo_gorm.go
│ │ │ │ ├── repo_mysql.go
│ │ │ │ ├── repo_pgx.go
│ │ │ │ └── repo_sqlx.go
│ │ │ ├── middleware/
│ │ │ │ ├── accesslog.go
│ │ │ │ ├── auth.go
│ │ │ │ └── panic.go
│ │ │ ├── session/
│ │ │ │ ├── manager.go
│ │ │ │ └── session.go
│ │ │ └── user/
│ │ │ └── user.go
│ │ ├── readme.md
│ │ └── templates/
│ │ ├── create.html
│ │ ├── edit.html
│ │ ├── index.html
│ │ └── login.html
│ ├── 07_mongodb/
│ │ ├── main.go
│ │ └── templates/
│ │ ├── create.html
│ │ ├── edit.html
│ │ └── index.html
│ ├── 08_memcache/
│ │ └── memcache.go
│ ├── 09_redis_simple/
│ │ └── cmds.go
│ ├── 10_redis/
│ │ ├── main.go
│ │ └── session.go
│ ├── 11_rabbit/
│ │ ├── form/
│ │ │ └── form.go
│ │ └── resizer/
│ │ └── resize_worker.go
│ ├── 12_kafka/
│ │ ├── form/
│ │ │ └── form.go
│ │ └── resizer/
│ │ └── resize_worker.go
│ ├── 13_tarantool_simple/
│ │ ├── Dockerfile
│ │ ├── app.lua
│ │ └── main.go
│ ├── 14_tarantool/
│ │ ├── main.go
│ │ └── session.go
│ ├── crudapp_mongo/
│ │ ├── cmd/
│ │ │ └── crudapp/
│ │ │ └── main.go
│ │ ├── file_tree.txt
│ │ ├── pkg/
│ │ │ ├── handlers/
│ │ │ │ ├── items.go
│ │ │ │ ├── items_mock.go
│ │ │ │ ├── items_test.go
│ │ │ │ └── user.go
│ │ │ ├── items/
│ │ │ │ ├── item.go
│ │ │ │ └── repo_mongo.go
│ │ │ ├── middleware/
│ │ │ │ ├── accesslog.go
│ │ │ │ ├── auth.go
│ │ │ │ └── panic.go
│ │ │ ├── session/
│ │ │ │ ├── manager.go
│ │ │ │ └── session.go
│ │ │ └── user/
│ │ │ └── user.go
│ │ ├── readme.md
│ │ └── templates/
│ │ ├── create.html
│ │ ├── edit.html
│ │ ├── index.html
│ │ └── login.html
│ ├── readings_6.md
│ ├── readme.md
│ └── tcache/
│ ├── cache.go
│ ├── main.go
│ └── posts.go
├── 7-security/
│ ├── 1_passwords/
│ │ ├── 0_password.txt
│ │ ├── 1_salt.go
│ │ ├── 2_pass.go
│ │ └── 2_pass_bench_test.go
│ ├── 2_csrf/
│ │ ├── csrf.go
│ │ └── csrf.txt
│ ├── 3_csrf_token/
│ │ ├── csrf.go
│ │ ├── token_crypt.go
│ │ ├── token_jwt.go
│ │ └── tokjen_hash.go
│ ├── 4_xss/
│ │ └── xss.go
│ ├── 5_xss_clean/
│ │ ├── login.txt
│ │ └── xss_clean.go
│ ├── 6_acl/
│ │ ├── acl_rbac.txt
│ │ └── casbin/
│ │ ├── basic_model.conf
│ │ ├── basic_policy.csv
│ │ └── rbac.go
│ └── 7_docker/
│ ├── .dockerignore
│ ├── Dockerfile
│ ├── Dockerfile.Multistage
│ ├── code/
│ │ ├── go.mod
│ │ └── main.go
│ ├── docker-compose.yml
│ ├── nginx/
│ │ └── nginx.conf
│ └── readme.md
├── 8-microservices/
│ ├── 0_service/
│ │ ├── 1_step/
│ │ │ ├── main.go
│ │ │ ├── run_test.go
│ │ │ └── session.go
│ │ └── 2_step/
│ │ ├── main.go
│ │ ├── run_test.go
│ │ └── session.go
│ ├── 1_net-rpc/
│ │ ├── client/
│ │ │ ├── client.go
│ │ │ ├── run_test.go
│ │ │ └── session.go
│ │ └── server/
│ │ ├── server.go
│ │ └── session.go
│ ├── 2_json-rpc/
│ │ ├── client/
│ │ │ ├── client.go
│ │ │ ├── run_test.go
│ │ │ └── session.go
│ │ └── server/
│ │ ├── server.go
│ │ └── session.go
│ ├── 3_protobuf/
│ │ ├── main.go
│ │ ├── session.pb.go
│ │ └── session.proto
│ ├── 4_grpc/
│ │ ├── client/
│ │ │ ├── main.go
│ │ │ └── run_test.go
│ │ ├── readme.md
│ │ ├── server/
│ │ │ ├── server.go
│ │ │ └── session.go
│ │ └── session/
│ │ ├── session.pb.go
│ │ ├── session.proto
│ │ └── session_grpc.pb.go
│ ├── 5_grpc_features/
│ │ ├── client/
│ │ │ └── client.go
│ │ └── server/
│ │ ├── server.go
│ │ └── session.go
│ ├── 6_grpc_stream/
│ │ ├── client/
│ │ │ ├── client.go
│ │ │ └── run_test.go
│ │ ├── server/
│ │ │ ├── main.go
│ │ │ ├── server.go
│ │ │ └── translit.go
│ │ └── translit/
│ │ ├── translit.pb.go
│ │ ├── translit.proto
│ │ └── translit_grpc.pb.go
│ └── 7_grpc_loadbalance/
│ ├── client/
│ │ └── main.go
│ ├── docker-compose.yml
│ ├── readme.md
│ └── server/
│ ├── server.go
│ └── session.go
├── 9-monitoring/
│ ├── 0_services/
│ │ ├── alertmanager/
│ │ │ └── alertmanager.yml
│ │ ├── alertmanager-bot/
│ │ │ └── templates/
│ │ │ └── default.tmpl
│ │ ├── docker-compose.yml
│ │ └── prometheus/
│ │ ├── alerts.yml
│ │ └── prometheus.yml
│ ├── 1_config/
│ │ ├── 1_flag/
│ │ │ └── flag.go
│ │ ├── 2_json/
│ │ │ ├── config.json
│ │ │ └── json_config.go
│ │ ├── 3_ldflags/
│ │ │ └── ldflags.go
│ │ ├── 4_viper/
│ │ │ ├── config.yml
│ │ │ └── main.go
│ │ └── 5_consul/
│ │ └── consul_config.go
│ ├── 2_vault/
│ │ ├── main.go
│ │ └── readme.md
│ ├── 3_monitoring/
│ │ ├── expvars/
│ │ │ └── expvars.go
│ │ ├── metrics/
│ │ │ └── context_monitoring.go
│ │ ├── prometheus/
│ │ │ ├── alertmanager/
│ │ │ │ └── alertmanager.yml
│ │ │ ├── main.go
│ │ │ ├── prometheus/
│ │ │ │ ├── alerts.yml
│ │ │ │ └── prometheus.yml
│ │ │ └── readme.md
│ │ └── sentry/
│ │ ├── echo/
│ │ │ └── main.go
│ │ └── simple/
│ │ └── main.go
│ └── 4_tracing/
│ └── jaeger_grpc/
│ ├── client/
│ │ └── main.go
│ ├── readme.md
│ ├── server/
│ │ ├── server.go
│ │ └── session.go
│ └── session/
│ ├── session.pb.go
│ └── session.proto
├── README.md
├── go.mod
└── go.sum
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitignore
================================================
.DS_Store
.idea
.vscode
# Tarantool output files
*.xlog
*.snap
# Test data files
6-databases/10_rabbit/images/*.jpg
# Ignore binary files
*.exe
# Ignore tmp output files
*.out
================================================
FILE: .gitmodules
================================================
[submodule "5-architecture/8_clean_arch"]
path = 5-architecture/8_clean_arch
url = https://github.com/bxcodec/go-clean-arch
[submodule "5-architecture/9_go_project_layout"]
path = 5-architecture/9_go_project_layout
url = https://github.com/golang-standards/project-layout
================================================
FILE: 1-basics/1_basics/01_vars_1/01_vars_1.go
================================================
package main
import "fmt"
func main() {
// значение по умолчанию
var num0 int
// значение при инициализации
var num1 int = 1
// пропуск типа
var num2 = 20
fmt.Println(num0, num1, num2)
// короткое объявление переменной
num := 30
// только для новых переменных
// no new variables on left side of :=
// num := 31
num += 1
fmt.Println("+=", num)
// ++num нету
num++
fmt.Println("++", num)
// camelCase - принятый стиль
userIndex := 10
// under_score - не принято
user_index := 10
fmt.Println(userIndex, user_index)
// объявление нескольких переменных
var weight, height int = 10, 20
// присваивание в существующие переменные
weight, height = 11, 21
// короткое присваивание
// хотя-бы одна переменная должна быть новой!
weight, age := 12, 22
fmt.Println(weight, height, age)
}
================================================
FILE: 1-basics/1_basics/02_vars_2/02_vars_2.go
================================================
package main
import "fmt"
func main() {
// int - платформозависимый тип, 32/64
var i int = 10
// автоматически выбранный int
var autoInt = -10
// int8, int16, int32, int64
var bigInt int64 = 1<<32 - 1
// платформозависимый тип, 32/64
var unsignedInt uint = 123
// uint8, unit16, uint32, unit64
var unsignedBigInt uint64 = 1<<64 - 1
unsignedBigInt = 0x01fe
unsignedBigInt = 0b00001010101
fmt.Println(i, autoInt, bigInt, unsignedInt, unsignedBigInt)
// вывод в других системах счисления
fmt.Printf("в 16-ричной: %x\n", unsignedBigInt)
fmt.Printf("в двоичной: %b\n", unsignedBigInt)
fmt.Printf("в 8-ричной: %o\n", unsignedBigInt)
// float32, float64
var pi float32 = 3.141
var e = 2.718
goldenRatio := 1.618
fmt.Println(pi, e, goldenRatio)
// bool
var b bool // false по-умолчанию
var isOk bool = true
var success = false
cond := true
fmt.Println(b, isOk, success, cond)
// complex64, complex128
var c complex128 = -1.1 + 7.12i
c2 := -1.1 + 7.12i
fmt.Println(c, c2)
}
================================================
FILE: 1-basics/1_basics/03_const/03_const.go
================================================
package main
import "fmt"
const pi = 3.141
const (
hello = "Привет"
e = 2.718
)
const (
zero = iota
_ // пустая переменная, пропуск iota
two
three // = 3
)
const (
_ = iota // пропускаем первое значение
KB uint64 = 1 << (10 * iota) // 1 << (10 * 1) = 1024
MB // 1 << (10 * 2) = 1048576
)
const (
// нетипизированная константа
year = 2017
// типизированная константа
yearTyped int = 2017
)
func main() {
var month int32 = 13
fmt.Println(month + year)
// month + yearTyped (mismatched types int32 and int)
// fmt.Println( month + yearTyped )
}
================================================
FILE: 1-basics/1_basics/04_pointers/04_pointers.go
================================================
package main
func main() {
a := 2
b := &a
*b = 3 // a = 3
c := &a // новый указатель на переменную a
// получение указателя на переменнут типа int
// инициализировано значением по-умолчанию
d := new(int)
*d = 12
*c = *d // c = 12 -> a = 12
*d = 13 // c и a не изменились
// nil указатель
var n *int
_ = n
c = d // теперь с указывает туда же, куда d
*c = 14 // с = 14 -> d = 14, a = 12
}
================================================
FILE: 1-basics/1_basics/05_array/05_array.go
================================================
package main
import "fmt"
func main() {
// размер массива является частью его типа
// инициализация значениями по-умолчанию
var a1 [3]int // [0,0,0]
fmt.Println("a1 short", a1)
fmt.Printf("a1 short %v\n", a1)
fmt.Printf("a1 full %#v\n", a1)
const size = 2
var a2 [2 * size]bool // [false,false,false,false]
fmt.Println("a2", a2)
// определение размера при объявлении
a3 := [...]int{1, 2, 3}
fmt.Println("a2", a3)
// проверка при компиляции или при выполнении
// invalid array index 4 (out of bounds for 3-element array)
// a3[idx] = 12
}
================================================
FILE: 1-basics/1_basics/06_slice_1/06_slice_1.go
================================================
package main
import "fmt"
func main() {
// создание
var buf0 []int // len=0, cap=0
buf1 := []int{} // len=0, cap=0
buf2 := []int{42} // len=1, cap=1
buf3 := make([]int, 0) // len=0, cap=0
buf4 := make([]int, 5) // len=5, cap=5
buf5 := make([]int, 5, 10) // len=5, cap=10
println("buffers ", buf0, buf1, buf2, buf3, buf4, buf5)
// обращение к элементам
someInt := buf2[0]
// ошибка при выполнении
// panic: runtime error: index out of range
// someOtherInt := buf2[1]
fmt.Println(someInt)
// добавление элементов
var buf []int // len=0, cap=0
buf = append(buf, 9, 10) // len=2, cap=2
buf = append(buf, 12) // len=3, cap=4
// добавление друго слайса
otherBuf := make([]int, 3) // [0,0,0]
buf = append(buf, otherBuf...) // len=6, cap=8
fmt.Println(buf, otherBuf)
// просмотр информации о слайсе
var bufLen, bufCap int = len(buf), cap(buf)
fmt.Println(bufLen, bufCap)
}
================================================
FILE: 1-basics/1_basics/07_slice_2/07_slice_2.go
================================================
package main
import "fmt"
func main() {
buf := []int{1, 2, 3, 4, 5}
fmt.Println(buf)
/*
buf: [1, 2, 3, 4, 5] ← базовый массив
↑ ↑ ↑ ↑ ↑
│ │ │ │ │
sl2[:2]: │───│ │ │ │ → len=2, cap=5
sl1[1:4]: │───┼───┤ │ → len=3, cap=4
sl3[2:]: │───┼───┼───┤ → len=3, cap=3
*/
// получение среза, указывающего на ту же память
sl1 := buf[1:4] // [2, 3, 4] (с 1-го до 4-го, не включая 4-й)
sl2 := buf[:2] // [1, 2] (с начала до 2-го, не включая 2-й)
sl3 := buf[2:] // [3, 4, 5] (со 2-го до конца)
fmt.Println(sl1, sl2, sl3)
fmt.Println()
newBuf := buf[:] // [1, 2, 3, 4, 5]
// buf = [9, 2, 3, 4, 5], т.к. та же память
newBuf[0] = 9
// newBuf теперь указывает на другие данные
newBuf = append(newBuf, 6)
// buf = [9, 2, 3, 4, 5], не изменился
// newBuf = [1, 2, 3, 4, 5, 6], изменился
newBuf[0] = 1
fmt.Println("buf", buf)
fmt.Println("newBuf", newBuf)
fmt.Println()
// копирование одного слайса в другой
var emptyBuf []int // len=0, cap=0
// неправильно - скопирует меньшее (по len) из 2-х слайсов
copied := copy(emptyBuf, buf) // copied = 0
fmt.Println("Invalid copy ", copied, emptyBuf)
// правильно
newBuf = make([]int, len(buf), len(buf))
copy(newBuf, buf)
fmt.Println("Valid copy ", newBuf)
// можно копировать в часть существующего слайса
ints := []int{1, 2, 3, 4}
copy(ints[1:3], []int{5, 6}) // ints = [1, 5, 6, 4]
fmt.Println("Part copy ", ints)
}
================================================
FILE: 1-basics/1_basics/08_strings/08_strings.go
================================================
package main
import (
"fmt"
"unicode/utf8"
)
func main() {
// пустая строка по-умолчанию
var str string
// со спец символами
var hello string = "Привет\n\t"
// без спец символов
var world string = `Мир\n\t`
fmt.Println("str", str)
fmt.Println("hello", hello)
fmt.Println("world", world)
// UTF-8 из коробки
var helloWorld = "Привет, Мир!"
hi := "你好,世界"
fmt.Println("helloWorld", helloWorld)
fmt.Println("hi", hi)
// одинарные кавычки для байт (uint8)
var rawBinary byte = '\x27'
// rune (uint32) для UTF-8 символов
var someChinese rune = '茶'
fmt.Println(rawBinary, someChinese)
helloWorld = "Привет Мир"
// конкатенация строк
andGoodMorning := helloWorld + " и доброе утро!"
fmt.Println(helloWorld, andGoodMorning)
// строки неизменяемы
// cannot assign to helloWorld[0]
// helloWorld[0] = 72
// получение длины строки
byteLen := len(helloWorld) // 19 байт
symbols := utf8.RuneCountInString(helloWorld) // 10 рун
fmt.Println(byteLen, symbols)
// получение подстроки, в байтах, не символах!
hello = helloWorld[:12] // Привет, 0-11 байты
H := helloWorld[0] // byte, 72, не "П"
fmt.Println(H)
// конвертация в слайс байт и обратно
byteString := []byte(helloWorld)
helloWorld = string(byteString)
fmt.Println(byteString, helloWorld)
}
================================================
FILE: 1-basics/1_basics/09_map/09_map.go
================================================
package main
import "fmt"
func main() {
// инициализация при создании
var user map[string]string = map[string]string{
"name": "Anton",
"lastName": "Sulaev",
}
// сразу с нужной ёмкостью
profile := make(map[string]string, 10)
// nil мапа
//var profileEmpty map[string]string
//fmt.Println("profileEmpty get ", profileEmpty["key"])
//profileEmpty["key"] = "1" // panic
//fmt.Println("profileEmpty set ", profileEmpty["key"])
// количество элементов
mapLength := len(user)
fmt.Printf("%d %+v\n", mapLength, profile)
/*
1. Ключ всегда comparable
= !=
2.
sha1, crc32, crc64
Fh = func (toHash Comparable, d int) int
Vasya -> Fh(Vasya) -> 10
Kolya -> Fh(Kolya) -> 10
-----------&----- 15 адресов
V
K
O(1)
Может быть не конкурентно
*/
// если ключа нет - вернёт значение по умолчанию для типа
mName := user["middleName"]
fmt.Println("mName:", mName)
// проверка на существование ключа
mName, mNameExist := user["middleName"]
fmt.Println("mName:", mName, "mNameExist:", mNameExist)
// пустая переменная - только проверяем что ключ есть
_, mNameExist2 := user["middleName"]
fmt.Println("mNameExist2", mNameExist2)
// удаление ключа
delete(user, "lastName")
fmt.Printf("%#v\n", user)
}
================================================
FILE: 1-basics/1_basics/10_control/10_control.go
================================================
package main
import "fmt"
func main() {
// простое условие
boolVal := true
if boolVal {
fmt.Println("boolVal is true")
}
mapVal := map[string]string{"name": "vasya"}
// условие с блоком инициализации
if keyValue, keyExist := mapVal["name"]; keyExist {
fmt.Println("name =", keyValue)
}
// получаем только признак сущестования ключа
if _, keyExist := mapVal["name"]; keyExist {
fmt.Println("key 'name' exist")
}
cond := 1
// множественные if else
if cond == 1 {
fmt.Println("cond is 1")
} else if cond == 2 {
fmt.Println("cond is 2")
}
// switch по 1 переменной
strVal := "name"
switch strVal {
case "name":
fallthrough
case "test", "lastName":
// some work
default:
// some work
}
// switch как замена многим ifelse
var val1, val2 = 2, 2
switch {
case val1 > 1 || val2 < 11:
fmt.Println("first block")
case val2 > 10:
fmt.Println("second block")
}
// выход из цикла, находясь внутри switch
Loop:
for key, val := range mapVal {
println("switch in loop", key, val)
switch {
case key == "lastName":
break
println("dont pront this")
case key == "firstName" && val == "Vasily":
println("switch - break loop here")
break Loop
}
} // конец for
}
================================================
FILE: 1-basics/1_basics/11_loop/11_loop.go
================================================
package main
import "fmt"
func main() {
// цикл без условия, while(true) OR for(;;;)
for {
fmt.Println("loop iteration")
break
}
// цикл без условия, while(isRun)
isRun := true
for isRun {
fmt.Println("loop iteration with condition")
isRun = false
}
// цикл с условие и блоком инициализации
for i := 0; i < 2; i++ {
fmt.Println("loop iteration", i)
if i == 1 {
continue
}
}
// операции по slice
sl := []int{1, 2, 3}
idx := 0
for idx < len(sl) {
fmt.Println("while-stype loop, idx:", idx, "value:", sl[idx])
idx++
}
for i := 0; i < len(sl); i++ {
fmt.Println("c-style loop", i, sl[i])
}
for idx := range sl {
fmt.Println("range slice by index", sl[idx])
}
for idx, val := range sl {
val = idx + 1 // не поменяем
sl[idx] = idx + 2 // поменяем
fmt.Println("range slice by idx-value", idx, val)
}
fmt.Printf("slice by idx-value %v\n", sl)
// операции по map
profile := map[int]string{1: "Vasily", 2: "Romanov"}
for key := range profile {
fmt.Println("range map by key", key)
}
for key, val := range profile {
fmt.Println("range map by key-val", key, val)
}
for _, val := range profile {
fmt.Println("range map by val", val)
}
//added in go 1.22
for i := range 10 {
println(i)
}
str := "Привет, Мир!"
for pos, char := range str {
fmt.Printf("%#U at pos %d\n", char, pos)
}
}
================================================
FILE: 1-basics/1_basics/12_types/12_types.go
================================================
package main
type UserID int
func main() {
idx := 1
var uid UserID = 42
// даже если базовый тип одинаковый, разные типы несовместимы
// cannot use uid (type UserID) as type int64 in assignment
// myID := idx
myID := UserID(idx)
println(uid, myID)
}
================================================
FILE: 1-basics/1_basics/13_generic/1_generic/main.go
================================================
package main
// Зачем нужны?
// ДУБЛИРОВАНИЕ КОДА!
func equalInt(a, b int) bool {
return a == b
}
func equalFloat(a, b float64) bool {
return a == b
}
// одна функция для многих типов
// [T int | float64] - объявление типа-параметра (Type parameter)
func equal[T int | float64](a, b T) bool {
return a == b
}
// Алиасы
type MyType int
func equalWithAlias[T ~int | ~float64](a, b T) bool {
return a == b
}
func KeyExists[T any](m map[string]T, key string) bool {
_, exists := m[key]
return exists
}
func main() {
println(equalInt(1, 2))
println(equalFloat(1.0, 2.0))
// Компилятор сам подставит нужный тип
println(equal(1, 2)) // T - int
println(equal(1.0, 2.0)) // T - float64
// Cannot use MyType as the type interface{ int | float64 }
// Type does not implement constraint interface{ int | float64 } because type is not included in type set (int, float64)
//
//
//println(equal(MyType(1),MyType(2)))
println(equalWithAlias(MyType(1), MyType(2)))
m1 := make(map[string]int)
m2 := make(map[string]bool)
println(KeyExists(m2, "test"))
println(KeyExists(m1, "test"))
}
================================================
FILE: 1-basics/1_basics/13_generic/2_methods/methods.go
================================================
package main
import (
"encoding/json"
"fmt"
)
// 1. Базовая дженерик-структура с методами
type Box[T any] struct {
Value T
}
// Метод получает значение. T уже объявлен в структуре.
func (b Box[T]) GetValue() T {
return b.Value
}
// Метод устанавливает значение
func (b *Box[T]) SetValue(v T) {
b.Value = v
}
// 2. Структура с ограничением типов
type Number interface {
~int | ~float64
}
type Calculator[T Number] struct {
Value T
}
// Методы используют то же ограничение T Number
func (c Calculator[T]) Add(a T) T {
return c.Value + a
}
func (c Calculator[T]) Multiply(a T) T {
return c.Value * a
}
// 3. Методы с преобразованием данных
type Container[T any] struct {
Data T
}
func (c Container[T]) ToJSON() ([]byte, error) {
return json.Marshal(c.Data)
}
func (c *Container[T]) FromJSON(data []byte) error {
return json.Unmarshal(data, &c.Data)
}
// 4. Функция с дополнительным generic-параметром (методы не могут иметь свои параметры типов)
func CompareWith[T any, U any](b Box[T], other U, compareFunc func(T, U) bool) bool {
return compareFunc(b.Value, other)
}
// 5. Практический пример: кэш с разными типами значений
type Cache[K comparable, V any] struct {
data map[K]V
}
func NewCache[K comparable, V any]() *Cache[K, V] {
return &Cache[K, V]{
data: make(map[K]V),
}
}
func (c *Cache[K, V]) Set(key K, value V) {
c.data[key] = value
}
func (c *Cache[K, V]) Get(key K) (V, bool) {
val, exists := c.data[key]
return val, exists
}
func (c *Cache[K, V]) Delete(key K) {
delete(c.data, key)
}
// 6. Пример с интерфейсным ограничением
type Stringer interface {
String() string
}
type Printer[T Stringer] struct {
Item T
}
func (p Printer[T]) Print() string {
return p.Item.String()
}
// Реализуем интерфейс Stringer для кастомного типа
type MyInt int
func (m MyInt) String() string {
return fmt.Sprintf("MyInt: %d", m)
}
func main() {
// 1. Работа с Box
intBox := Box[int]{Value: 42}
strBox := Box[string]{Value: "hello"}
fmt.Printf("intBox value: %d\n", intBox.GetValue())
fmt.Printf("strBox value: %s\n", strBox.GetValue())
intBox.SetValue(100)
fmt.Printf("New intBox value: %d\n", intBox.GetValue())
// 2. Работа с Calculator
intCalc := Calculator[int]{Value: 10}
floatCalc := Calculator[float64]{Value: 3.14}
fmt.Printf("10 * 2 = %d\n", intCalc.Multiply(2))
fmt.Printf("3.14 + 1.5 = %.2f\n", floatCalc.Add(1.5))
// 3. Работа с Cache
stringCache := NewCache[string, string]()
stringCache.Set("name", "Alice")
stringCache.Set("city", "Moscow")
if name, exists := stringCache.Get("name"); exists {
fmt.Printf("Name from cache: %s\n", name)
}
intCache := NewCache[string, int]()
intCache.Set("age", 25)
intCache.Set("score", 100)
if age, exists := intCache.Get("age"); exists {
fmt.Printf("Age from cache: %d\n", age)
}
// 4. Работа с методом, имеющим дополнительный generic-параметр
box := Box[int]{Value: 42}
result := CompareWith(box, "42", func(a int, b string) bool {
return fmt.Sprint(a) == b
})
fmt.Printf("Compare 42 with '42': %t\n", result)
// 5. Работа с интерфейсным ограничением
myInt := MyInt(42)
printer := Printer[MyInt]{Item: myInt}
fmt.Println(printer.Print())
}
================================================
FILE: 1-basics/2_functions/1_functions/1_functions.go
================================================
package main
import "fmt"
// обычное объявление
func singleIn(in int) int {
return in
}
// много параметров
func multIn(a, b int, c int) int {
return a + b + c
}
// именованный результат
func namedReturn() (out int) {
out = 2
return
}
// несколько результатов
func multipleReturn(in int) (int, error) {
if in > 2 {
return 0, fmt.Errorf("some error happend")
}
return in, nil
}
// несколько именованных результатов
func multipleNamedReturn(ok bool) (rez int, err error) {
rez = 1
if ok {
err = fmt.Errorf("some error happend")
// аналогично return rez, err
return 3, fmt.Errorf("some error happend")
}
rez = 2
return
}
// не фиксированное количество параметров
func sum(in ...int) (result int) {
fmt.Printf("in := %#v \n", in)
for _, val := range in {
result += val
}
return
}
func main() {
// fmt.Println(multipleNamedReturn(false))
// return
nums := []int{1, 2, 3, 4}
fmt.Println(nums, sum(nums...))
return
}
================================================
FILE: 1-basics/2_functions/2_firstclass/2_firstclass.go
================================================
package main
import "fmt"
// обычная функция
func doNothing() {
fmt.Println("i'm regular function")
}
func main() {
// анонимная функция
func(in string) {
fmt.Println("anon func out:", in)
}("nobody")
// присванивание анонимной функции в переменную
printer := func(in string) {
fmt.Println("printer outs:", in)
}
printer("as variable")
// определяем тип функции
type strFuncType func(string)
// функция принимает коллбек
worker := func(callback strFuncType) {
callback("as callback")
}
worker(printer)
// функиция возвращает замыкание
prefixer := func(prefix string) strFuncType {
return func(in string) {
fmt.Printf("[%s] %s\n", prefix, in)
}
}
successLogger := prefixer("SUCCESS")
successLogger("expected behaviour")
}
================================================
FILE: 1-basics/2_functions/3_defer/3_defer.go
================================================
package main
import "fmt"
func getSomeVars() string {
fmt.Println("getSomeVars execution")
return "getSomeVars result"
}
func main() {
defer fmt.Println("After work")
defer func() {
fmt.Println(getSomeVars())
}()
fmt.Println("Some userful work")
}
================================================
FILE: 1-basics/2_functions/4_recover/4_recover.go
================================================
package main
import (
"fmt"
)
func deferTest() {
defer func() {
if err := recover(); err != nil {
fmt.Println("panic happend FIRST:", err)
}
}()
defer func() {
if err := recover(); err != nil {
fmt.Println("panic happend SECOND:", err)
// panic("second panic")
}
}()
fmt.Println("Some userful work")
panic("something bad happend")
return
}
func main() {
deferTest()
return
}
================================================
FILE: 1-basics/3_structs/1_structs/1_structs.go
================================================
package main
import "fmt"
type Person struct {
Id int
Name string
Address string
}
type Account struct {
Id int
// Name string
Cleaner func(string) string
Owner Person
Person
}
func main() {
// полное объявление структуры
var acc Account = Account{
Id: 1,
// Name: "vasya",
Person: Person{
Name: "Василий",
Address: "Москва",
},
}
fmt.Printf("%#v\n", acc)
// короткое объявление структуры
acc.Owner = Person{2, "Romanov Vasily", "Moscow"}
fmt.Printf("%#v\n", acc)
fmt.Println(acc.Name)
fmt.Println(acc.Person.Name)
}
================================================
FILE: 1-basics/3_structs/2_methods/2_methods.go
================================================
package main
import "fmt"
type Person struct {
Id int
Name string
}
// не изменит оригинальной структуры, для который вызван
func (p Person) UpdateName(name string) {
p.Name = name
}
// изменяет оригинальную структуру
func (p *Person) SetName(name string) {
p.Name = name
}
type Account struct {
Id int
Name string
Person
}
func (p *Account) SetName(name string) {
p.Name = name
}
type MySlice []int
func (sl *MySlice) Add(val int) {
*sl = append(*sl, val)
}
func (sl *MySlice) Count() int {
return len(*sl)
}
func main() {
// pers := &Person{1, "Vasily"}
pers := new(Person)
pers.SetName("Vasily Romanov")
// (&pers).SetName("Vasily Romanov")
// fmt.Printf("updated person: %#v\n", pers)
var acc Account = Account{
Id: 1,
Name: "vasya",
Person: Person{
Id: 2,
Name: "Vasily Romanov",
},
}
acc.SetName("romanov.vasily")
acc.Person.SetName("Test")
// fmt.Printf("%#v \n", acc)
sl := MySlice([]int{1, 2})
sl.Add(5)
fmt.Println(sl.Count(), sl)
}
================================================
FILE: 1-basics/4_interfaces/1.2_basic_sort/1_sort.go
================================================
package main
import (
"fmt"
"sort"
)
type Student struct {
Age int
Name string
}
type Students []Student
func (sts Students) Len() int { return len(sts) }
func (sts Students) Swap(a, b int) { sts[a], sts[b] = sts[b], sts[a] }
func (sts Students) Less(a, b int) bool { return sts[a].Age < sts[b].Age }
func main() {
students := Students{
{Age: 18, Name: "Harry"},
{Age: 76, Name: "Benjamin"},
{Age: 20, Name: "Bob"},
{Age: 19, Name: "Alice"},
}
sort.Sort(students)
for _, s := range students {
fmt.Printf("%d %s\n", s.Age, s.Name)
}
}
================================================
FILE: 1-basics/4_interfaces/1_basic/1_basic.go
================================================
package main
import (
"fmt"
)
type Payer interface {
Pay(int) error
}
type Wallet struct {
Cash int
}
func (w *Wallet) Pay(amount int) error {
if w.Cash < amount {
return fmt.Errorf("Не хватает денег в кошельке")
}
w.Cash -= amount
return nil
}
func Buy(p Payer) {
err := p.Pay(10)
if err != nil {
panic(err)
}
fmt.Printf("Спасибо за покупку через %T\n\n", p)
}
func main() {
myWallet := &Wallet{Cash: 100}
Buy(myWallet)
}
================================================
FILE: 1-basics/4_interfaces/2_many/2_many.go
================================================
package main
import (
"fmt"
)
// --------------
type Wallet struct {
Cash int
}
func (w *Wallet) Pay(amount int) error {
if w.Cash < amount {
return fmt.Errorf("Не хватает денег в кошельке")
}
w.Cash -= amount
return nil
}
// --------------
type Card struct {
Balance int
ValidUntil string
Cardholder string
CVV string
Number string
}
func (c *Card) Pay(amount int) error {
if c.Balance < amount {
return fmt.Errorf("Не хватает денег на карте")
}
c.Balance -= amount
return nil
}
// --------------
type ApplePay struct {
Money int
AppleID string
}
func (a *ApplePay) Pay(amount int) error {
if a.Money < amount {
return fmt.Errorf("Не хватает денег на аккаунте")
}
a.Money -= amount
return nil
}
// --------------
type Payer interface {
Pay(int) error
}
func Buy(p Payer) {
err := p.Pay(10)
if err != nil {
fmt.Printf("Ошибка при оплате %T: %v\n\n", p, err)
return
}
fmt.Printf("Спасибо за покупку через %T\n\n", p)
}
// --------------
func main() {
myWallet := &Wallet{Cash: 100}
Buy(myWallet)
var myMoney Payer
myMoney = &Card{Balance: 100, Cardholder: "vasya"}
Buy(myMoney)
myMoney = &ApplePay{Money: 9}
Buy(myMoney)
}
================================================
FILE: 1-basics/4_interfaces/3_embed/3_embed.go
================================================
package main
import (
"fmt"
)
type Phone struct {
Money int
AppleID string
}
func (p *Phone) Pay(amount int) error {
if p.Money < amount {
return fmt.Errorf("Not enough money on account")
}
p.Money -= amount
return nil
}
func (p *Phone) Ring(number string) error {
if number == "" {
return fmt.Errorf("PLease, enter phone")
}
return nil
}
// --------------
type Payer interface {
Pay(int) error
}
type Ringer interface {
Ring(string) error
}
type NFCPhone interface {
Payer
Ringer
}
// --------------
func PayForMetwiWithPhone(phone NFCPhone) {
err := phone.Pay(1)
if err != nil {
fmt.Printf("Ошибка при оплате %v\n\n", err)
return
}
fmt.Printf("Турникет открыт через %T\n\n", phone)
}
// --------------
func main() {
myPhone := &Phone{Money: 9}
PayForMetwiWithPhone(myPhone)
}
================================================
FILE: 1-basics/4_interfaces/4_cast/4_cast.go
================================================
package main
import (
"fmt"
)
// --------------
type Wallet struct {
Cash int
}
func (w *Wallet) Pay(amount int) error {
if w.Cash < amount {
return fmt.Errorf("Not enough cash")
}
w.Cash -= amount
return nil
}
// --------------
type Card struct {
Balance int
ValidUntil string
Cardholder string
CVV string
Number string
}
func (c *Card) Pay(amount int) error {
if c.Balance < amount {
return fmt.Errorf("Not enough money on balance")
}
c.Balance -= amount
return nil
}
// --------------
type ApplePay struct {
Money int
AppleID string
}
func (a *ApplePay) Pay(amount int) error {
if a.Money < amount {
return fmt.Errorf("Not enough money on account")
}
a.Money -= amount
return nil
}
// --------------
type Payer interface {
Pay(int) error
}
// --------------
func Buy(p Payer) {
switch p.(type) {
case *Wallet:
fmt.Println("Оплата наличными?")
case *Card:
plasticCard, ok := p.(*Card)
if !ok {
fmt.Println("Не удалось преобразовать к типу *Card")
}
fmt.Println("Вставляйте карту,", plasticCard.Cardholder)
default:
fmt.Println("Что-то новое!")
}
err := p.Pay(10)
if err != nil {
fmt.Printf("Ошибка при оплате %T: %v\n\n", p, err)
return
}
fmt.Printf("Спасибо за покупку через %T\n\n", p)
}
// --------------
func main() {
myWallet := &Wallet{Cash: 100}
Buy(myWallet)
var myMoney Payer
myMoney = &Card{Balance: 100, Cardholder: "vasya"}
Buy(myMoney)
myMoney = &ApplePay{Money: 9}
Buy(myMoney)
}
================================================
FILE: 1-basics/4_interfaces/5_empty_1/5_empty_1.go
================================================
package main
import (
"fmt"
"strconv"
)
type Wallet struct {
Cash int
}
func (w *Wallet) Pay(amount int) error {
if w.Cash < amount {
return fmt.Errorf("Not enough cash")
}
w.Cash -= amount
return nil
}
func (w *Wallet) String() string {
return "Кошелёк в котором " + strconv.Itoa(w.Cash) + " денег"
}
// -----
func main() {
myWallet := &Wallet{Cash: 100}
fmt.Printf("Raw payment : %#v\n", myWallet)
fmt.Printf("Способ оплаты: %s\n", myWallet)
}
================================================
FILE: 1-basics/4_interfaces/6_empty_2/6_empty_2.go
================================================
package main
import (
"fmt"
"strconv"
)
// --------------
type Wallet struct {
Cash int
}
func (w *Wallet) Pay(amount int) error {
if w.Cash < amount {
return fmt.Errorf("Not enough cash")
}
w.Cash -= amount
return nil
}
func (w *Wallet) String() string {
return "Кошелёк в котором " + strconv.Itoa(w.Cash) + " денег"
}
// --------------
type Payer interface {
Pay(int) error
}
// --------------
func Buy(in interface{}) {
var p Payer
var ok bool
if p, ok = in.(Payer); !ok {
fmt.Printf("%T не не является платежным средством\n\n", in)
return
}
err := p.Pay(10)
if err != nil {
fmt.Printf("Ошибка при оплате %T: %v\n\n", p, err)
return
}
fmt.Printf("Спасибо за покупку через %T\n\n", p)
}
// --------------
func main() {
myWallet := &Wallet{Cash: 100}
Buy(myWallet)
Buy([]int{1, 2, 3})
Buy(3.14)
}
================================================
FILE: 1-basics/5_visibility/dir.txt
================================================
C:\Users\User\go
├───bin
├───pkg
└───src
├───coursera
│ ├───visibility
│ │ │───person
│ │ │ │───person.go
│ │ │ └───func.go
│ │ └───main.go
└───github.com
└───rvasily
└───examplerepo
================================================
FILE: 1-basics/5_visibility/main.go
================================================
package main
import (
"fmt"
prsonModule "github.com/go-park-mail-ru/lectures/1-basics/5_visibility/person"
)
func init() {
fmt.Println("I am init in main")
}
func main() {
person := 1
fmt.Println("I am main", person, prsonModule.Person{})
}
================================================
FILE: 1-basics/5_visibility/person/func.go
================================================
package person
import (
"fmt"
)
func NewPerson(id int, name, secret string) *Person {
return &Person{
ID: 1,
Name: "rvasily",
secret: "secret",
}
}
func GetSecret(p *Person) string {
return p.secret
}
func printSecret(p *Person) {
fmt.Println(p.secret)
}
================================================
FILE: 1-basics/5_visibility/person/person.go
================================================
package person
import "fmt"
var (
Public = 1
private = 1
)
func init() {
fmt.Println("I am init 1")
}
func init() {
fmt.Println("I am init 2")
}
type Person struct {
ID int
Name string
secret string
}
func (p Person) UpdateSecret(secret string) {
fmt.Println(private)
p.secret = secret
}
================================================
FILE: 1-basics/6_uniq/basic/data.txt
================================================
1
2
3
3
3
3
4
5
================================================
FILE: 1-basics/6_uniq/basic/data_bad.txt
================================================
1
1
2
1
================================================
FILE: 1-basics/6_uniq/basic/data_map.txt
================================================
1
3
2
1
2
================================================
FILE: 1-basics/6_uniq/basic/main.go
================================================
package main
import (
"bufio"
"fmt"
"os"
)
func main() {
in := bufio.NewScanner(os.Stdin)
var prev string
for in.Scan() {
txt := in.Text()
if txt == prev {
continue
}
if txt < prev {
panic("file not sorted")
}
prev = txt
fmt.Println(txt)
}
}
================================================
FILE: 1-basics/6_uniq/with_tests/data.txt
================================================
1
2
3
3
3
3
4
5
================================================
FILE: 1-basics/6_uniq/with_tests/data_bad.txt
================================================
1
1
2
1
================================================
FILE: 1-basics/6_uniq/with_tests/data_map.txt
================================================
1
3
2
1
2
================================================
FILE: 1-basics/6_uniq/with_tests/main.go
================================================
package main
import (
"bufio"
"fmt"
"io"
"os"
)
func uniq(input io.Reader, output io.Writer) error {
in := bufio.NewScanner(input)
var prev string
for in.Scan() {
txt := in.Text()
if txt == prev {
continue
}
if txt < prev {
return fmt.Errorf("file not sorted")
}
prev = txt
fmt.Fprintln(output, txt)
}
return nil
}
func main() {
err := uniq(os.Stdin, os.Stdout)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
}
================================================
FILE: 1-basics/6_uniq/with_tests/main_test.go
================================================
package main
import (
"bytes"
"testing"
)
var testOkInput = `1
2
3
3
4
5`
var testOkResult = `1
2
3
4
5
`
var testFailInput = `1
2
1`
func TestOK(t *testing.T) {
in := bytes.NewBufferString(testOkInput)
out := bytes.NewBuffer(nil)
err := uniq(in, out)
if err != nil {
t.Errorf("Test OK failed: %s", err)
}
result := out.String()
if result != testOkResult {
t.Errorf("Test OK failed, result not match")
}
}
func TestFail(t *testing.T) {
in := bytes.NewBufferString(testFailInput)
out := bytes.NewBuffer(nil)
err := uniq(in, out)
if err == nil {
t.Errorf("Test FAIL failed: expected error")
}
}
================================================
FILE: 1-basics/homework/readme.md
================================================
# Домашнее задание 1
## Дисклеймер
Это задание состоит из 2х частей, которые нужно сдавать вместе.
Отдельно первая часть, как и отдельно вторая часть, не оценивается
как половина задания.
Задачи включают в себя как написание функциональности, так и её
тестирование.
Все домашние задания должны выполняться в приватных репозиториях.
## Часть 1. Uniq
Нужно реализовать утилиту, с помощью которой можно вывести или отфильтровать
повторяющиеся строки в файле (аналог UNIX утилиты `uniq`). Причём повторяющиеся
входные строки не должны распозноваться, если они не следуют строго друг за другом.
Сама утилита имеет набор параметров, которые необходимо поддержать.
### Параметры
`-с` - подсчитать количество встречаний строки во входных данных.
Вывести это число перед строкой отделив пробелом.
`-d` - вывести только те строки, которые повторились во входных данных.
`-u` - вывести только те строки, которые не повторились во входных данных.
`-f num_fields` - не учитывать первые `num_fields` полей в строке.
Полем в строке является непустой набор символов отделённый пробелом.
`-s num_chars` - не учитывать первые `num_chars` символов в строке.
При использовании вместе с параметром `-f` учитываются первые символы
после `num_fields` полей (не учитывая пробел-разделитель после
последнего поля).
`-i` - не учитывать регистр букв.
### Использование
`uniq [-c | -d | -u] [-i] [-f num] [-s chars] [input_file [output_file]]`
1. Все параметры опциональны. Поведения утилиты без параметров --
простой вывод уникальных строк из входных данных.
2. Параметры c, d, u взаимозаменяемы. Необходимо учитывать,
что параллельно эти параметры не имеют никакого смысла. При
передаче одного вместе с другим нужно отобразить пользователю
правильное использование утилиты
3. Если не передан input_file, то входным потоком считать stdin
4. Если не передан output_file, то выходным потоком считать stdout
### Пример работы
<details>
<summary>Без параметров</summary>
```bash
$cat input.txt
I love music.
I love music.
I love music.
I love music of Kartik.
I love music of Kartik.
Thanks.
I love music of Kartik.
I love music of Kartik.
$cat input.txt | go run uniq.go
I love music.
I love music of Kartik.
Thanks.
I love music of Kartik.
```
</details>
<details>
<summary>С параметром input_file</summary>
```bash
$cat input.txt
I love music.
I love music.
I love music.
I love music of Kartik.
I love music of Kartik.
Thanks.
I love music of Kartik.
I love music of Kartik.
$go run uniq.go input.txt
I love music.
I love music of Kartik.
Thanks.
I love music of Kartik.
```
</details>
<details>
<summary>С параметрами input_file и output_file</summary>
```bash
$cat input.txt
I love music.
I love music.
I love music.
I love music of Kartik.
I love music of Kartik.
Thanks.
I love music of Kartik.
I love music of Kartik.
$go run uniq.go input.txt output.txt
$cat output.txt
I love music.
I love music of Kartik.
Thanks.
I love music of Kartik.
```
</details>
<details>
<summary>С параметром -c</summary>
```bash
$cat input.txt
I love music.
I love music.
I love music.
I love music of Kartik.
I love music of Kartik.
Thanks.
I love music of Kartik.
I love music of Kartik.
$cat input.txt | go run uniq.go -c
3 I love music.
1
2 I love music of Kartik.
1 Thanks.
2 I love music of Kartik.
```
</details>
<details>
<summary>С параметром -d</summary>
```bash
$cat input.txt
I love music.
I love music.
I love music.
I love music of Kartik.
I love music of Kartik.
Thanks.
I love music of Kartik.
I love music of Kartik.
$cat input.txt | go run uniq.go -d
I love music.
I love music of Kartik.
I love music of Kartik.
```
</details>
<details>
<summary>С параметром -u</summary>
```bash
$cat input.txt
I love music.
I love music.
I love music.
I love music of Kartik.
I love music of Kartik.
Thanks.
I love music of Kartik.
I love music of Kartik.
$cat input.txt | go run uniq.go -u
Thanks.
```
</details>
<details>
<summary>С параметром -i</summary>
```bash
$cat input.txt
I LOVE MUSIC.
I love music.
I LoVe MuSiC.
I love MuSIC of Kartik.
I love music of kartik.
Thanks.
I love music of kartik.
I love MuSIC of Kartik.
$cat input.txt | go run uniq.go -i
I LOVE MUSIC.
I love MuSIC of Kartik.
Thanks.
I love music of kartik.
```
</details>
<details>
<summary>С параметром -f num</summary>
```bash
$cat input.txt
We love music.
I love music.
They love music.
I love music of Kartik.
We love music of Kartik.
Thanks.
$cat input.txt | go run uniq.go -f 1
We love music.
I love music of Kartik.
Thanks.
```
</details>
<details>
<summary>С параметром -s num</summary>
```bash
$cat input.txt
I love music.
A love music.
C love music.
I love music of Kartik.
We love music of Kartik.
Thanks.
$cat input.txt | go run uniq.go -s 1
I love music.
I love music of Kartik.
We love music of Kartik.
Thanks.
```
</details>
### Тестирование
Нужно протестировать поведение написанной функциональности
с различными параметрами. Для тестирования нужно написать unit-тесты
на эту функциональность. Тесты нужны как для успешных случаев,
так и для неуспешных. Примеры с тестами мы будем показывать ещё на
следующих лекциях, но сейчас можно посмотреть в [шестом примере первой лекции](https://github.com/go-park-mail-ru/lectures/blob/master/1-basics/6_is_sorted/sorted/sorted_test.go).
### Материалы в помощь
В `1-basics/readme.md` есть список книг по го, а так же по всем частым и нужным операциям, там вы можете найти многие примеры кода, которые вам пригодятся.
Материалы в помощь:
* https://habrahabr.ru/post/306914/ - пакет io
* https://golang.org/pkg/sort/
* https://golang.org/pkg/io/
* https://golang.org/pkg/io/ioutil/
* https://godoc.org/flag - пакет для флагов
* https://godoc.org/github.com/stretchr/testify - удобный набор
пакетов для тестирования
* https://golang.org/pkg/bufio/#Scanner - удобный способ прочитать
линии из потока данных
### Best practices
1. Уникализация строк может понадобиться не только как утилита,
но и как часть более крупной логики. Для этого саму функцию
уникализации можно вынести в отдельный пакет. Поскольку
более крупная логика не всегда связана с чтением аргументов
и данных из файла или stdin, то на вход этой функции нужно
передавать слайс строк и аргументы.
2. Множество параметров, которые вдобавок и опциональны, лучше
передавать структурой (например Options). Так проще расширять
функциональность, а внешнему пользователю функции (не всей утилиты)
будет проще передать правильные аргументы внутрь.
3. Как файл, так и stdin удовлетворяет интерфейсу io.Reader.
Поэтому логику по чтению можно сделать универсальной. Аналогично
и с записью -- io.Writer
4. Для написания однотипных тестовых случаев используется
[табличное тестирование](https://github.com/golang/go/wiki/TableDrivenTests). Получается, что можно написать две функции
тестов: успешные тестовые случаи и неуспешные тестовые случаи.
5. Для сравнения ожидаемого и действительного можно использовать
пакет [require](https://godoc.org/github.com/stretchr/testify/require).
Кроме простых сравнений на равенство пакет предоставляет много
других ассертов.
6. Тесты не должны зависеть от внешних ресурсов. Не нужно читать
файлы внутри теста. Так же не нужно тестировать передачу параметров
при вызове утилиты. Никакого внешнего взаимодействия. Тестирование
функции должно быть построено на том, что мы передаём некоторые
входные данные в функцию и сравниваем ответ функции с ожидаемыми
выходными данными.
## Часть 2. Calc
Нужно написать калькулятор, умеющий вычислять выражение, подаваемое на STDIN.
Достаточно реализовать сложение, вычитание, умножение, деление (поддержать дробное), поддержку скобок и унарный минус.
Тут также нужны тесты 🙂 Тестами нужно покрыть все операции.
### Пример работы
```bash
$ go run calc.go "(1+2)-3"
0
$ go run calc.go "(1+2)*3"
9
```
================================================
FILE: 1-basics/readme.md
================================================
Материалы для дополнительного чтения на английском:
* https://golang.org/ref/spec - спецификация по язык
* https://golang.org/ref/mem - модель памяти го. на начальном этапе не надо, но знать полезно
* https://golang.org/doc/code.html - про организацию кода. GOPATH и пакеты
* https://golang.org/cmd/go/
* https://blog.golang.org/strings
* https://blog.golang.org/slices
* https://blog.golang.org/go-slices-usage-and-internals
* https://github.com/golang/go/wiki - вики го на гитхабе. очень много полезной информации
* https://blog.golang.org/go-maps-in-action
* https://blog.golang.org/organizing-go-code
* https://golang.org/doc/effective_go.html - основной сборник тайного знания, сюда вы будуте обращатсья в первое время часто
* https://github.com/golang/go/wiki/CodeReviewComments как ревьювить (и писать код). обязательно к прочтению
* https://divan.github.io/posts/avoid_gotchas/ - материал аналогичный 50 оттенков го
* https://research.swtch.com/interfaces
* https://research.swtch.com/godata
* http://jordanorelli.com/post/42369331748/function-types-in-go-golang
* https://www.devdungeon.com/content/working-files-go - работа с файлами
* http://www.golangprograms.com - много how-to касательно базовых вещей в go
* http://yourbasic.org/golang/ - ещё большой набор how-to где можно получить углублённую информацию по всем базовым вещам. очень полезны http://yourbasic.org/golang/blueprint/
* https://github.com/Workiva/go-datastructures
* https://github.com/enocom/gopher-reading-list - большая подборка статей по многим темам ( не только данной лекции )
Материалы для дополнительного чтения на русском:
* https://habrahabr.ru/company/mailru/blog/314804/ - 50 оттенков го. обязательно к прочтению. многое оттуда мы ещё не проходили, но на будущее - имейте ввиду
* https://habrahabr.ru/post/306914/ - Разбираемся в Go: пакет io
* https://habrahabr.ru/post/272383/ - постулаты go. Маленькая статья об основными принципах языка
* https://habrahabr.ru/company/mailru/blog/301036/ - лучшие практики go
* https://habrahabr.ru/post/308198/ - организация кода в go
* https://habrahabr.ru/post/339192/ - Зачем в Go амперсанд и звёздочка (& и *)
* https://habrahabr.ru/post/325468/ - как не наступать на грабли в Go
* https://habrahabr.ru/post/276981/ - Краш-курс по интерфейсам в Go
* http://golang-book.ru
Литература по го на русском языке:
* Язык программирования Go, Алан А. А. Донован, Брайан У. Керниган
* Go на практике, Matt Butcher, Мэтт Фарина Мэтт
* Программирование на Go. Разработка приложений XXI века, Марк Саммерфильд
Дополнительные упражнения:
* https://go-tour-ru-ru.appspot.com/list - упражнения на овладение базовым синтаксисом, на случай если вам нужна небольшая практика перед первым заданием курса
================================================
FILE: 10-performance/1_reflect/1_print/reflect_1.go
================================================
package main
import (
"fmt"
"reflect"
)
type UserID int
type UserID2 UserID
type User struct {
ID UserID2
RealName string `unpack:"-"`
Login string
Flags int
}
func PrintReflect(u interface{}) error {
val := reflect.ValueOf(u).Elem()
fmt.Printf("%T have %d fields:\n", u, val.NumField())
for i := 0; i < val.NumField(); i++ {
valueField := val.Field(i)
typeField := val.Type().Field(i)
fmt.Printf("\tname=%v, type=%v, value=%v, tag=`%v`\n", typeField.Name,
typeField.Type.Kind(),
valueField,
typeField.Tag.Get("unpack"),
)
}
return nil
}
func main() {
u := &User{
ID: 42,
RealName: "unrealname",
Flags: 32,
}
err := PrintReflect(u)
if err != nil {
panic(err)
}
}
================================================
FILE: 10-performance/1_reflect/2_unpack/reflect_2.go
================================================
package main
import (
"bytes"
"encoding/binary"
"fmt"
"reflect"
)
type User struct {
ID int
RealName string `unpack:"-"`
Login string
Flags int
}
func UnpackReflect(u interface{}, data []byte) error {
r := bytes.NewReader(data)
val := reflect.ValueOf(u)
if val.Kind() != reflect.Ptr {
return fmt.Errorf("input is not pointer")
}
val = val.Elem()
for i := 0; i < val.NumField(); i++ {
valueField := val.Field(i)
typeField := val.Type().Field(i)
if typeField.Tag.Get("unpack") == "-" {
continue
}
switch typeField.Type.Kind() {
case reflect.Int:
var value uint32
binary.Read(r, binary.LittleEndian, &value)
valueField.SetInt(int64(value))
case reflect.String:
var lenRaw uint32
binary.Read(r, binary.LittleEndian, &lenRaw)
dataRaw := make([]byte, lenRaw)
binary.Read(r, binary.LittleEndian, &dataRaw)
valueField.SetString(string(dataRaw))
default:
return fmt.Errorf("bad type: %v for field %v", typeField.Type.Kind(), typeField.Name)
}
}
return nil
}
func main() {
/*
perl -E '$b = pack("L L/a* L", 1_123_456, "kek.kekovitch", 16);
print map { ord.", " } split("", $b); '
*/
data := []byte{
128, 36, 17, 0,
13, 0, 0, 0,
107, 101, 107, 46, 107, 101, 107, 111, 118, 105, 116, 99, 104,
16, 0, 0, 0,
}
u := &User{}
err := UnpackReflect(u, data)
if err != nil {
panic(err)
}
fmt.Printf("%#v", u)
}
================================================
FILE: 10-performance/2_codegen/gen/codegen.go
================================================
// go build gen/* && ./codegen.exe pack/unpack.go pack/marshaller.go
// go run pack/*
package main
import (
"fmt"
"go/ast"
"go/parser"
"go/token"
"log"
"os"
"reflect"
"strings"
"text/template"
)
type tpl struct {
FieldName string
}
var (
intTpl = template.Must(template.New("intTpl").Parse(`
// {{.FieldName}}
var {{.FieldName}}Raw uint32
binary.Read(r, binary.LittleEndian, &{{.FieldName}}Raw)
in.{{.FieldName}} = int({{.FieldName}}Raw)
`))
strTpl = template.Must(template.New("strTpl").Parse(`
// {{.FieldName}}
var {{.FieldName}}LenRaw uint32
binary.Read(r, binary.LittleEndian, &{{.FieldName}}LenRaw)
{{.FieldName}}Raw := make([]byte, {{.FieldName}}LenRaw)
binary.Read(r, binary.LittleEndian, &{{.FieldName}}Raw)
in.{{.FieldName}} = string({{.FieldName}}Raw)
`))
)
func main() {
fset := token.NewFileSet()
node, err := parser.ParseFile(fset, os.Args[1], nil, parser.ParseComments)
if err != nil {
log.Fatal(err)
}
out, _ := os.Create(os.Args[2])
fmt.Fprintln(out, `package `+node.Name.Name)
fmt.Fprintln(out) // empty line
fmt.Fprintln(out, `import "encoding/binary"`)
fmt.Fprintln(out, `import "bytes"`)
fmt.Fprintln(out) // empty line
for _, f := range node.Decls {
g, ok := f.(*ast.GenDecl)
if !ok {
fmt.Printf("SKIP %#T is not *ast.GenDecl\n", f)
continue
}
SPECS_LOOP:
for _, spec := range g.Specs {
currType, ok := spec.(*ast.TypeSpec)
if !ok {
fmt.Printf("SKIP %#T is not ast.TypeSpec\n", spec)
continue
}
currStruct, ok := currType.Type.(*ast.StructType)
if !ok {
fmt.Printf("SKIP %#T is not ast.StructType\n", currStruct)
continue
}
if g.Doc == nil {
fmt.Printf("SKIP struct %#v doesnt have comments\n", currType.Name.Name)
continue
}
needCodegen := false
for _, comment := range g.Doc.List {
needCodegen = needCodegen || strings.HasPrefix(comment.Text, "// cgen: binpack")
}
if !needCodegen {
fmt.Printf("SKIP struct %#v doesnt have cgen mark\n", currType.Name.Name)
continue SPECS_LOOP
}
fmt.Printf("process struct %s\n", currType.Name.Name)
fmt.Printf("\tgenerating Unpack method\n")
fmt.Fprintln(out, "func (in *"+currType.Name.Name+") Unpack(data []byte) error {")
fmt.Fprintln(out, " r := bytes.NewReader(data)")
FIELDS_LOOP:
for _, field := range currStruct.Fields.List {
if field.Tag != nil {
tag := reflect.StructTag(field.Tag.Value[1 : len(field.Tag.Value)-1])
if tag.Get("cgen") == "-" {
continue FIELDS_LOOP
}
}
fieldName := field.Names[0].Name
fieldType := field.Type.(*ast.Ident).Name
fmt.Printf("\tgenerating code for field %s.%s\n", currType.Name.Name, fieldName)
switch fieldType {
case "int":
intTpl.Execute(out, tpl{fieldName})
case "string":
strTpl.Execute(out, tpl{fieldName})
default:
log.Fatalln("unsupported", fieldType)
}
}
fmt.Fprintln(out, " return nil")
fmt.Fprintln(out, "}") // end of Unpack func
fmt.Fprintln(out) // empty line
}
}
}
// go build gen/* && ./codegen.exe pack/unpack.go pack/marshaller.go
// go run pack/*
================================================
FILE: 10-performance/2_codegen/pack/marshaller.go
================================================
package main
import "encoding/binary"
import "bytes"
func (in *User) Unpack(data []byte) error {
r := bytes.NewReader(data)
// ID
var IDRaw uint32
binary.Read(r, binary.LittleEndian, &IDRaw)
in.ID = int(IDRaw)
// Name
var NameLenRaw uint32
binary.Read(r, binary.LittleEndian, &NameLenRaw)
NameRaw := make([]byte, NameLenRaw)
binary.Read(r, binary.LittleEndian, &NameRaw)
in.Name = string(NameRaw)
// Flags
var FlagsRaw uint32
binary.Read(r, binary.LittleEndian, &FlagsRaw)
in.Flags = int(FlagsRaw)
return nil
}
================================================
FILE: 10-performance/2_codegen/pack/unpack.go
================================================
// go build -o ./codegen.exe gen/* && ./codegen.exe pack/unpack.go pack/marshaller.go
package main
import "fmt"
// lets generate code for this struct
// cgen: binpack
type User struct {
ID int
RealName string `cgen:"-"`
Name string
Flags int
}
type Avatar struct {
ID int
Url string
}
var test = 42
func main() {
/*
perl -E '$b = pack("L L/a* L", 1_123_456, "kek.kekovitch", 16);
print map { ord.", " } split("", $b); '
*/
data := []byte{
128, 36, 17, 0,
13, 0, 0, 0,
107, 101, 107, 46, 107, 101, 107, 111, 118, 105, 116, 99, 104,
16, 0, 0, 0,
}
u := User{}
u.Unpack(data)
fmt.Printf("Unpacked user %#v", u)
}
================================================
FILE: 10-performance/3_perfomance_1/1_unpack/unpack_test.go
================================================
package unpack
import (
"bytes"
"encoding/binary"
"fmt"
"reflect"
"testing"
)
/*
go test -bench . unpack_test.go
go test -bench . -benchmem unpack_test.go
*/
var (
data = []byte{
128, 36, 17, 0,
9, 0, 0, 0,
118, 46, 114, 111, 109, 97, 110, 111, 118,
16, 0, 0, 0,
}
)
type User struct {
ID int
RealName string `cgen:"-"`
Login string
Flags int
}
func BenchmarkCodegen(b *testing.B) {
u := &User{}
for i := 0; i < b.N; i++ {
u = &User{}
u.UnpackBin(data)
}
}
func BenchmarkReflect(b *testing.B) {
u := &User{}
for i := 0; i < b.N; i++ {
u = &User{}
UnpackReflect(u, data)
}
}
func (in *User) UnpackBin(data []byte) error {
r := bytes.NewReader(data)
// ID
var IDRaw uint32
binary.Read(r, binary.LittleEndian, &IDRaw)
in.ID = int(IDRaw)
// Login
var LoginLenRaw uint32
binary.Read(r, binary.LittleEndian, &LoginLenRaw)
LoginRaw := make([]byte, LoginLenRaw)
binary.Read(r, binary.LittleEndian, &LoginRaw)
in.Login = string(LoginRaw)
// Flags
var FlagsRaw uint32
binary.Read(r, binary.LittleEndian, &FlagsRaw)
in.Flags = int(FlagsRaw)
return nil
}
func UnpackReflect(u interface{}, data []byte) error {
r := bytes.NewReader(data)
val := reflect.ValueOf(u).Elem()
for i := 0; i < val.NumField(); i++ {
valueField := val.Field(i)
typeField := val.Type().Field(i)
if typeField.Tag.Get("unpack") == "-" {
continue
}
switch typeField.Type.Kind() {
case reflect.Int:
var value int
binary.Read(r, binary.LittleEndian, &value)
valueField.Set(reflect.ValueOf(value))
case reflect.String:
var lenRaw int
binary.Read(r, binary.LittleEndian, &lenRaw)
dataRaw := make([]byte, lenRaw)
binary.Read(r, binary.LittleEndian, &dataRaw)
valueField.SetString(string(dataRaw))
default:
return fmt.Errorf("bad type: %v for field %v", typeField.Type.Kind(), typeField.Name)
}
}
return nil
}
/*
go test -bench . unpack_test.go
go test -bench . -benchmem unpack_test.go
go test -bench . -benchmem -cpuprofile=cpu.out -memprofile=mem.out -memprofilerate=1 unpack_test.go
go tool pprof -http=:8083 unpack.test cpu.out
go tool pprof unpack.test cpu.out
go tool pprof unpack.test mem.out
go get github.com/uber/go-torch
go-torch unpack.test cpu.out
*/
================================================
FILE: 10-performance/3_perfomance_1/2_prealloc/prealloc_test.go
================================================
// go test -bench . -benchmem prealloc_test.go
package prealloc
import (
"testing"
)
const iterNum = 1000
func BenchmarkEmptyAppend(b *testing.B) {
for i := 0; i < b.N; i++ {
data := make([]int, 0)
for j := 0; j < iterNum; j++ {
data = append(data, j)
}
}
}
func BenchmarkPreallocAppend(b *testing.B) {
for i := 0; i < b.N; i++ {
data := make([]int, 0, iterNum)
for j := 0; j < iterNum; j++ {
data = append(data, j)
}
}
}
/*
go test -bench . -benchmem -cpuprofile=cpu.out -memprofile=mem.out -memprofilerate=1 prealloc/prealloc_test.go
go tool pprof -http=:8083 prealloc.test cpu.out
go tool pprof prealloc.test cpu.out
go tool pprof prealloc.test mem.out
go tool pprof -svg -inuse_space prealloc.test mem.out > mem_is.svg
go tool pprof -svg -inuse_objects prealloc.test mem.out > mem_io.svg
go tool pprof -svg prealloc.test cpu.out > cpu.svg
go tool pprof -png prealloc.test cpu.out > cpu.png
*/
================================================
FILE: 10-performance/3_perfomance_1/3_pool/pool_test.go
================================================
package pool
import (
"bytes"
"encoding/json"
"sync"
"testing"
)
const iterNum = 100
type PublicPage struct {
ID int
Name string
Url string
OwnerID int
ImageUrl string
Tags []string
Description string
Rules string
}
var CoolGolangPublic = PublicPage{
ID: 1,
Name: "CoolGolangPublic",
Url: "http://example.com",
OwnerID: 100500,
ImageUrl: "http://example.com/img.png",
Tags: []string{"programming", "go", "golang"},
Description: "Best page about golang programming",
Rules: "",
}
var Pages = []PublicPage{
CoolGolangPublic,
CoolGolangPublic,
CoolGolangPublic,
}
func BenchmarkAllocNew(b *testing.B) {
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
data := bytes.NewBuffer(make([]byte, 0, 64))
_ = json.NewEncoder(data).Encode(Pages)
}
})
}
var dataPool = sync.Pool{
New: func() interface{} {
return bytes.NewBuffer(make([]byte, 0, 64))
},
}
func BenchmarkAllocPool(b *testing.B) {
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
data := dataPool.Get().(*bytes.Buffer)
_ = json.NewEncoder(data).Encode(Pages)
data.Reset()
dataPool.Put(data)
}
})
}
/*
go test -bench . -benchmem pool/pool_test.go
*/
================================================
FILE: 10-performance/3_perfomance_1/4_string/string_test.go
================================================
package string
import (
"regexp"
"strings"
"testing"
)
var (
browser = "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36"
re = regexp.MustCompile("Android")
)
// regexp.MatchString компилирует регулярку каждый раз
func BenchmarkRegExp(b *testing.B) {
for i := 0; i < b.N; i++ {
_, _ = regexp.MatchString("Android", browser)
}
}
// используем прекомпилированную регулярку
func BenchmarkRegCompiled(b *testing.B) {
for i := 0; i < b.N; i++ {
re.MatchString(browser)
}
}
// просто ищем вхождение подстроки
func BenchmarkStrContains(b *testing.B) {
for i := 0; i < b.N; i++ {
_ = strings.Contains(browser, "Android")
}
}
/*
go test -bench . string/string_test.go
go test -bench . -benchmem string/string_test.go
go test -bench . -benchmem -benchtime=100000x -cpuprofile=cpu.out -memprofile=mem.out -memprofilerate=1 string/string_test.go
go tool pprof -http=:8083 string.test cpu.out
go tool pprof string.test cpu.out
go tool pprof string.test mem.out
go tool pprof -svg -inuse_space string.test mem.out > mem_is.svg
go tool pprof -svg -inuse_objects string.test mem.out > mem_io.svg
go tool pprof -svg string.test cpu.out > cpu.svg
go tool pprof -png string.test cpu.out > cpu.png
*/
================================================
FILE: 10-performance/3_perfomance_1/5_json/json_test.go
================================================
package json
import (
"encoding/json"
"testing"
)
var (
data = []byte(`{"RealName":"Vasily", "Login":"v.romanov", "Status":1, "Flags": 1}`)
u = User{}
c = Client{}
)
// go test -v -bench=. -benchmem json/*.go
// go test -v -bench=. json/*.go
func BenchmarkDecodeStandart(b *testing.B) {
for i := 0; i < b.N; i++ {
_ = json.Unmarshal(data, &c)
}
}
func BenchmarkDecodeEasyjson(b *testing.B) {
for i := 0; i < b.N; i++ {
_ = u.UnmarshalJSON(data)
}
}
func BenchmarkEncodeStandart(b *testing.B) {
for i := 0; i < b.N; i++ {
_, _ = json.Marshal(&c)
}
}
func BenchmarkEncodeEasyjson(b *testing.B) {
for i := 0; i < b.N; i++ {
_, _ = u.MarshalJSON()
}
}
================================================
FILE: 10-performance/3_perfomance_1/5_json/struct.go
================================================
package json
//easyjson:json
type User struct {
Id int
RealName string
Login string
Flags int
Status int
}
type Client struct {
Id int
RealName string
Login string
Flags int
Status int
}
================================================
FILE: 10-performance/3_perfomance_1/5_json/struct_easyjson.go
================================================
// Code generated by easyjson for marshaling/unmarshaling. DO NOT EDIT.
package json
import (
json "encoding/json"
easyjson "github.com/mailru/easyjson"
jlexer "github.com/mailru/easyjson/jlexer"
jwriter "github.com/mailru/easyjson/jwriter"
)
// suppress unused package warning
var (
_ *json.RawMessage
_ *jlexer.Lexer
_ *jwriter.Writer
_ easyjson.Marshaler
)
func easyjson9f2eff5fDecodeSt(in *jlexer.Lexer, out *User) {
isTopLevel := in.IsStart()
if in.IsNull() {
if isTopLevel {
in.Consumed()
}
in.Skip()
return
}
in.Delim('{')
for !in.IsDelim('}') {
key := in.UnsafeString()
in.WantColon()
if in.IsNull() {
in.Skip()
in.WantComma()
continue
}
switch key {
case "Id":
out.Id = int(in.Int())
case "RealName":
out.RealName = string(in.String())
case "Login":
out.Login = string(in.String())
case "Flags":
out.Flags = int(in.Int())
case "Status":
out.Status = int(in.Int())
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjson9f2eff5fEncodeSt(out *jwriter.Writer, in User) {
out.RawByte('{')
first := true
_ = first
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"Id\":")
out.Int(int(in.Id))
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"RealName\":")
out.String(string(in.RealName))
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"Login\":")
out.String(string(in.Login))
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"Flags\":")
out.Int(int(in.Flags))
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"Status\":")
out.Int(int(in.Status))
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v User) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjson9f2eff5fEncodeSt(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v User) MarshalEasyJSON(w *jwriter.Writer) {
easyjson9f2eff5fEncodeSt(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *User) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjson9f2eff5fDecodeSt(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *User) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjson9f2eff5fDecodeSt(l, v)
}
================================================
FILE: 10-performance/4_perfomance_2/1_optimize/pprof_1.go
================================================
package main
import (
"bytes"
"fmt"
"net/http"
_ "net/http/pprof"
"sync"
"time"
)
type Post struct {
ID int
Text string
Author string
Comments int
Time time.Time
}
func handleSlow(w http.ResponseWriter, req *http.Request) {
s := ""
for i := 0; i < 1000; i++ {
p := &Post{ID: i, Text: "new post"}
s += fmt.Sprintf("%#v", p)
}
w.Write([]byte(s))
}
func main() {
http.HandleFunc("/", handleSlow)
http.HandleFunc("/fast", handleFast)
fmt.Println("starting server at :8080")
fmt.Println(http.ListenAndServe(":8080", nil))
}
/*
go build -o pprof_1.exe pprof_1.go && ./pprof_1.exe
hey -z 20s http://127.0.0.1:8080
hey -z 20s http://127.0.0.1:8080/fast
curl http://127.0.0.1:8080/debug/pprof/heap -o mem_out.txt
curl http://127.0.0.1:8080/debug/pprof/profile?seconds=5 -o cpu_out.txt
go tool pprof -svg -inuse_space pprof_1.exe mem_out.txt > mem_is.svg
go tool pprof -svg -inuse_objects pprof_1.exe mem_out.txt > mem_oo.svg
go tool pprof -svg -alloc_space pprof_1.exe mem_out.txt > mem_as.svg
go tool pprof -svg -alloc_objects pprof_1.exe mem_out.txt > mem_ao.svg
go tool pprof -svg pprof_1.exe cpu_out.txt > cpu.svg
*/
var dataPool = sync.Pool{
New: func() interface{} {
return &Post{}
},
}
var bufPool = sync.Pool{
New: func() interface{} {
return bytes.NewBuffer(make([]byte, 0, 50000))
},
}
func handleFast(w http.ResponseWriter, req *http.Request) {
buf := bufPool.Get().(*bytes.Buffer)
for i := 0; i < 1000; i++ {
p := dataPool.Get().(*Post)
p.ID = i
p.Text = "new post"
fmt.Fprintf(buf, "%#v", p)
*p = Post{}
dataPool.Put(p)
}
buf.Reset()
bufPool.Put(buf)
w.Write(buf.Bytes())
}
================================================
FILE: 10-performance/4_perfomance_2/1_optimize/pprof_1.sh
================================================
curl http://127.0.0.1:8080/debug/pprof/profile?seconds=5 -o cpu_out.txt
curl http://127.0.0.1:8080/debug/pprof/heap -o mem_out.txt
# go tool pprof -svg -alloc_objects pprof_1.exe mem_out.txt > mem_ao.svg
# go tool pprof -svg -alloc_space pprof_1.exe mem_out.txt > mem_as.svg
# go tool pprof -svg -inuse_objects pprof_1.exe mem_out.txt > mem_io.svg
# go tool pprof -svg -inuse_space pprof_1.exe mem_out.txt > mem_is.svg
# go tool pprof -svg pprof_1.exe cpu_out.txt > cpu.svg
# go tool pprof pprof_1.exe mem_out.txt
# go tool pprof pprof_1.exe cpu_out.txt
# go tool pprof -http=:8081 -alloc_objects pprof_1.exe mem_out.txt
# go tool pprof -http=:8081 pprof_1.exe cpu_out.txt
================================================
FILE: 10-performance/4_perfomance_2/2_leak_grtn/pprof_2.go
================================================
package main
import (
"fmt"
"net/http"
_ "net/http/pprof"
"time"
)
type Post struct {
ID int
Text string
Author string
Comments int
Time time.Time
}
func getPost(out chan []Post) {
posts := []Post{}
for i := 1; i < 10; i++ {
post := Post{ID: 1, Text: "text"}
posts = append(posts, post)
}
out <- posts
}
func longHeavyWork(ch chan bool) {
time.Sleep(1 * time.Minute)
ch <- true
}
func handleLeak(w http.ResponseWriter, req *http.Request) {
res := make(chan []Post)
go getPost(res)
return
<-res
}
func main() {
http.HandleFunc("/", handleLeak)
fmt.Println("starting server at :8080")
http.ListenAndServe(":8080", nil)
}
/*
go build -o pprof_2.exe pprof_2.go && ./pprof_2.exe
hey -z 30s -q 100 http://127.0.0.1:8080/
./pprof_2.sh
*/
================================================
FILE: 10-performance/4_perfomance_2/2_leak_grtn/pprof_2.sh
================================================
curl http://localhost:8080/debug/pprof/goroutine?debug=2 -o goroutines.txt
curl http://127.0.0.1:8080/debug/pprof/heap -o mem_out.txt
# go tool pprof -svg -inuse_objects pprof_2.exe mem_out.txt > mem_io.svg
# go tool pprof -svg -inuse_space pprof_2.exe mem_out.txt > mem_is.svg
================================================
FILE: 10-performance/4_perfomance_2/3_tracing/tracing.go
================================================
package main
import (
"encoding/json"
"fmt"
"net/http"
_ "net/http/pprof"
"runtime"
"time"
)
type Post struct {
ID int
Text string
Author string
Comments int
Time time.Time
}
func handle(w http.ResponseWriter, req *http.Request) {
result := ""
for i := 0; i < 100; i++ {
currPost := &Post{ID: i, Text: "new post", Time: time.Now()}
jsonRaw, _ := json.Marshal(currPost)
result += string(jsonRaw)
}
time.Sleep(3 * time.Millisecond)
w.Write([]byte(result))
}
func main() {
runtime.GOMAXPROCS(4)
http.HandleFunc("/", handle)
fmt.Println("starting server at :8080")
fmt.Println(http.ListenAndServe(":8080", nil))
}
/*
go build -o tracing.exe tracing.go && ./tracing.exe
ab -t 300 -n 10000000 -c 10 http://127.0.0.1:8080/
curl http://localhost:8080/debug/pprof/trace?seconds=10 -o trace.out
go tool trace -http "0.0.0.0:8081" tracing.exe trace.out
*/
================================================
FILE: 10-performance/4_perfomance_2/note.txt
================================================
go tool pprof -http=:8080 pprof_2.exe cpu_out.txt
================================================
FILE: 10-performance/5_testing/cover.html
================================================
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style>
body {
background: black;
color: rgb(80, 80, 80);
}
body, pre, #legend span {
font-family: Menlo, monospace;
font-weight: bold;
}
#topbar {
background: black;
position: fixed;
top: 0; left: 0; right: 0;
height: 42px;
border-bottom: 1px solid rgb(80, 80, 80);
}
#content {
margin-top: 50px;
}
#nav, #legend {
float: left;
margin-left: 10px;
}
#legend {
margin-top: 12px;
}
#nav {
margin-top: 10px;
}
#legend span {
margin: 0 5px;
}
.cov0 { color: rgb(192, 0, 0) }
.cov1 { color: rgb(128, 128, 128) }
.cov2 { color: rgb(116, 140, 131) }
.cov3 { color: rgb(104, 152, 134) }
.cov4 { color: rgb(92, 164, 137) }
.cov5 { color: rgb(80, 176, 140) }
.cov6 { color: rgb(68, 188, 143) }
.cov7 { color: rgb(56, 200, 146) }
.cov8 { color: rgb(44, 212, 149) }
.cov9 { color: rgb(32, 224, 152) }
.cov10 { color: rgb(20, 236, 155) }
</style>
</head>
<body>
<div id="topbar">
<div id="nav">
<select id="files">
<option value="file0">coursera\testing\main.go (85.7%)</option>
</select>
</div>
<div id="legend">
<span>not tracked</span>
<span class="cov0">not covered</span>
<span class="cov8">covered</span>
</div>
</div>
<div id="content">
<pre class="file" id="file0" style="display: none">package main
import (
"encoding/json"
"fmt"
)
type User struct {
ID int
}
var data = map[string][]byte{
"ok": []byte(`{"ID": 27}`),
"fail": []byte(`{"ID": 27`),
}
func GetUser(key string) (*User, error) <span class="cov8" title="1">{
if jsonStr, ok := data[key]; ok </span><span class="cov8" title="1">{
user := &User{}
err := json.Unmarshal(jsonStr, user)
if err != nil </span><span class="cov0" title="0">{
return nil, fmt.Errorf("Cant decode json")
}</span>
<span class="cov8" title="1">return user, nil</span>
}
<span class="cov8" title="1">return nil, fmt.Errorf("User doesnt exist")</span>
}
</pre>
</div>
</body>
<script>
(function() {
var files = document.getElementById('files');
var visible;
files.addEventListener('change', onChange, false);
function select(part) {
if (visible)
visible.style.display = 'none';
visible = document.getElementById(part);
if (!visible)
return;
files.value = part;
visible.style.display = 'block';
location.hash = part;
}
function onChange() {
select(files.value);
window.scrollTo(0, 0);
}
if (location.hash != "") {
select(location.hash.substr(1));
}
if (!visible) {
select("file0");
}
})();
</script>
</html>
================================================
FILE: 10-performance/5_testing/coverage_test.go
================================================
package main
import (
"testing"
"reflect"
)
type TestCase struct{
Key string
User *User
IsError bool
}
func TestGetUser(t *testing.T) {
cases := []TestCase{
TestCase{"ok", &User{ID: 27}, false},
// TestCase{"fail", nil, true},
TestCase{"not_exist", nil, true},
}
for caseNum, item := range cases {
u, err := GetUser(item.Key)
if item.IsError && err == nil {
t.Errorf("[%d] expected error, got nil", caseNum)
}
if !item.IsError && err != nil {
t.Errorf("[%d] unexpected error", caseNum, err)
}
if !reflect.DeepEqual(u, item.User) {
t.Errorf("[%d] wrong results: got %+v, expected %+v",
caseNum, u, item.User)
}
}
}
/*
go test -coverprofile=cover.out
go tool cover -html=cover.out -o cover.html
*/
================================================
FILE: 10-performance/5_testing/main.go
================================================
package main
import (
"encoding/json"
"fmt"
)
type User struct {
ID int
}
var data = map[string][]byte{
"ok": []byte(`{"ID": 27}`),
"fail": []byte(`{"ID": 27`),
}
func GetUser(key string) (*User, error) {
if jsonStr, ok := data[key]; ok {
user := &User{}
err := json.Unmarshal(jsonStr, user)
if err != nil {
return nil, fmt.Errorf("Cant decode json")
}
return user, nil
}
return nil, fmt.Errorf("User doesnt exist")
}
================================================
FILE: 10-performance/6_xml_stream/main.go
================================================
package main
import (
"encoding/xml"
"fmt"
"bytes"
"io"
)
type User struct {
ID int `xml:"id,attr"`
Login string `xml:"login"`
Name string `xml:"name"`
Browser string `xml:"browser"`
}
type Users struct {
Version string `xml:"version,attr"`
List []User `xml:"user"`
}
var xmlData = []byte(`<?xml version="1.0" encoding="utf-8"?>
<users>
<user id="1">
<login>user1</login>
<name>Василий Романов</name>
<browser>Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36
</browser>
</user>
<user id="2">
<login>user2</login>
<name>Иван Иванов</name>
<browser>Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36
</browser>
</user>
<user id="2">
<login>user3</login>
<name>Иван Петров</name>
<browser>Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0; Trident/5.0)</browser>
</user>
<user id="1">
<login>user1</login>
<name>Василий Романов</name>
<browser>Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36
</browser>
</user>
<user id="2">
<login>user2</login>
<name>Иван Иванов</name>
<browser>Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36
</browser>
</user>
<user id="2">
<login>user3</login>
<name>Иван Петров</name>
<browser>Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0; Trident/5.0)</browser>
</user>
</users>`)
func CountStruct() {
logins := make([]string, 0)
v := new(Users)
err := xml.Unmarshal(xmlData, &v)
if err != nil {
fmt.Printf("error: %v", err)
return
}
for _, u := range v.List {
logins = append(logins, u.Login)
}
}
func CountDecoder() {
input := bytes.NewReader(xmlData)
decoder := xml.NewDecoder(input)
logins := make([]string, 0)
var login string
for {
tok, tokenErr := decoder.Token()
if tokenErr != nil && tokenErr != io.EOF {
fmt.Println("error happend", tokenErr)
break
} else if tokenErr == io.EOF {
break
}
if tok == nil {
fmt.Println("t is nil break")
}
switch tok := tok.(type) {
case xml.StartElement:
if tok.Name.Local == "login" {
if err := decoder.DecodeElement(&login, &tok); err != nil {
fmt.Println("error happend", err)
}
logins = append(logins, login)
}
}
}
}
/*
go test -bench . -benchmem xml_test.go
*/
func main() {
CountStruct()
CountDecoder()
}
================================================
FILE: 10-performance/6_xml_stream/xml_test.go
================================================
package main
import (
"testing"
)
func BenchmarkCountStruct(b *testing.B) {
for i := 0; i < b.N; i++ {
CountStruct()
}
}
func BenchmarkCountDecoder(b *testing.B) {
for i := 0; i < b.N; i++ {
CountDecoder()
}
}
================================================
FILE: 10-performance/7_inline_escape/main.go
================================================
package main
import (
"fmt"
)
/*
go run -gcflags -m main.go
go run -gcflags '-m -m' main.go
*/
type User struct {
ID int
Login string
}
func (u *User) GetID() int {
return u.ID
}
func newUser(login string) *User {
return &User{123, login}
}
func setToZero(in *int) {
// for i := 0; i<3; i++ {
// *in = 1
// }
*in = 0
}
func main() {
u := newUser("test")
u.ID = 1
data := make([]string, 20)
data = append(data, "test")
i := 1
setToZero(&i)
// _ = fmt.Sprint(data)
// _ = fmt.Sprint(u)
fmt.Println("test")
}
================================================
FILE: 10-performance/8_cgo/1_example/main.go
================================================
package main
/*
#include <math.h>
*/
import "C"
import "fmt"
func main() {
num := C.double(16)
result := C.sqrt(num)
fmt.Printf("Квадратный корень из %.2f равен %.2f\n", num, result)
}
================================================
FILE: 10-performance/8_cgo/2_performance/main.go
================================================
package main
/*
#include <stdio.h>
long long factorialC(long long n) {
long long result = 1;
for (long long i = 2; i <= n; i++) {
result *= i;
}
return result;
}
*/
import "C"
import (
"fmt"
"math/big"
)
func factorialCGo(n int64) int64 {
return int64(C.factorialC(C.longlong(n)))
}
func factorialGo(n int64) *big.Int {
result := big.NewInt(1)
for i := int64(2); i <= n; i++ {
result.Mul(result, big.NewInt(i))
}
return result
}
func main() {
n := int64(20)
fmt.Println("Факториал на C через CGO:", factorialCGo(n))
}
================================================
FILE: 10-performance/8_cgo/3_usage/README.md
================================================
```
brew install pkg-config
```
https://github.com/klippa-app/go-pdfium
================================================
FILE: 10-performance/8_cgo/3_usage/go.mod
================================================
module pdfium
go 1.23.3
require github.com/klippa-app/go-pdfium v1.13.0
require (
github.com/fatih/color v1.13.0 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/hashicorp/go-hclog v1.6.3 // indirect
github.com/hashicorp/go-plugin v1.6.1 // indirect
github.com/hashicorp/yamux v0.1.1 // indirect
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/mitchellh/go-testing-interface v0.0.0-20171004221916-a61a99592b77 // indirect
github.com/oklog/run v1.0.0 // indirect
golang.org/x/net v0.29.0 // indirect
golang.org/x/sys v0.25.0 // indirect
golang.org/x/text v0.18.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98 // indirect
google.golang.org/grpc v1.58.3 // indirect
google.golang.org/protobuf v1.34.1 // indirect
)
================================================
FILE: 10-performance/8_cgo/3_usage/go.sum
================================================
github.com/bufbuild/protocompile v0.4.0 h1:LbFKd2XowZvQ/kajzguUp2DC9UEIQhIq77fZZlaQsNA=
github.com/bufbuild/protocompile v0.4.0/go.mod h1:3v93+mbWn/v3xzN+31nwkJfrEpAUwp+BagBSZWx+TP8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w=
github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI=
github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/pprof v0.0.0-20240727154555-813a5fbdbec8 h1:FKHo8hFI3A+7w0aUQuYXQ+6EN5stWmeY/AZqtM8xk9k=
github.com/google/pprof v0.0.0-20240727154555-813a5fbdbec8/go.mod h1:K1liHPHnj73Fdn/EKuT8nrFqBihUSKXoLYU0BuatOYo=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/hashicorp/go-hclog v1.6.3 h1:Qr2kF+eVWjTiYmU7Y31tYlP1h0q/X3Nl3tPGdaB11/k=
github.com/hashicorp/go-hclog v1.6.3/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M=
github.com/hashicorp/go-plugin v1.6.1 h1:P7MR2UP6gNKGPp+y7EZw2kOiq4IR9WiqLvp0XOsVdwI=
github.com/hashicorp/go-plugin v1.6.1/go.mod h1:XPHFku2tFo3o3QKFgSYo+cghcUhw1NA1hZyMK0PWAw0=
github.com/hashicorp/yamux v0.1.1 h1:yrQxtgseBDrq9Y652vSRDvsKCJKOUD+GzTS4Y0Y8pvE=
github.com/hashicorp/yamux v0.1.1/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbgIO0SLnQ=
github.com/jhump/protoreflect v1.15.1 h1:HUMERORf3I3ZdX05WaQ6MIpd/NJ434hTp5YiKgfCL6c=
github.com/jhump/protoreflect v1.15.1/go.mod h1:jD/2GMKKE6OqX8qTjhADU1e6DShO+gavG9e0Q693nKo=
github.com/klippa-app/go-pdfium v1.13.0 h1:Ow9+cPhhcmKdxp3GCwds79zWyOZHyJIJGGt70R/nUWc=
github.com/klippa-app/go-pdfium v1.13.0/go.mod h1:eVVeeXJkk+W6KLaJy4fizsERYUaMqJulSXD9JQjx+8s=
github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
github.com/mattn/go-colorable v0.1.12 h1:jF+Du6AlPIjs2BiUiQlKOX0rt3SujHxPnksPKZbaA40=
github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
github.com/mitchellh/go-testing-interface v0.0.0-20171004221916-a61a99592b77 h1:7GoSOOW2jpsfkntVKaS2rAr1TJqfcxotyaUcuxoZSzg=
github.com/mitchellh/go-testing-interface v0.0.0-20171004221916-a61a99592b77/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI=
github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw=
github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA=
github.com/onsi/ginkgo/v2 v2.20.0 h1:PE84V2mHqoT1sglvHc8ZdQtPcwmvvt29WLEEO3xmdZw=
github.com/onsi/ginkgo/v2 v2.20.0/go.mod h1:lG9ey2Z29hR41WMVthyJBGUBcBhGOtoPF2VFMvBXFCI=
github.com/onsi/gomega v1.34.1 h1:EUMJIKUjM8sKjYbtxQI9A4z2o+rruxnzNvpknOXie6k=
github.com/onsi/gomega v1.34.1/go.mod h1:kU1QgUvBDLXBJq618Xvm2LUX6rSAfRaFRTcdOeDLwwY=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/tetratelabs/wazero v1.8.1 h1:NrcgVbWfkWvVc4UtT4LRLDf91PsOzDzefMdwhLfA550=
github.com/tetratelabs/wazero v1.8.1/go.mod h1:yAI0XTsMBhREkM/YDAK/zNou3GoiAce1P6+rp/wQhjs=
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 h1:2dVuKD2vS7b0QIHQbpyTISPd0LeHDbnYEryqj5Q1ug8=
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56/go.mod h1:M4RDyNAINzryxdtnbRXRL/OHtkFuWGRjvuhBJpk2IlY=
golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo=
golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0=
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224=
golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
golang.org/x/tools v0.24.0 h1:J1shsA93PJUEVaUSaay7UXAyE8aimq3GW0pjlolpa24=
golang.org/x/tools v0.24.0/go.mod h1:YhNqVBIfWHdzvTLs0d8LCuMhkKUgSUKldakyV7W/WDQ=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98 h1:bVf09lpb+OJbByTj913DRJioFFAjf/ZGxEz7MajTp2U=
google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98/go.mod h1:TUfxEVdsvPg18p6AslUXFoLdpED4oBnGwyqk3dV1XzM=
google.golang.org/grpc v1.58.3 h1:BjnpXut1btbtgN/6sp+brB2Kbm2LjNXnidYujAVbSoQ=
google.golang.org/grpc v1.58.3/go.mod h1:tgX3ZQDlNJGU96V6yHh1T/JeoBQ2TXdr43YbYSsCJk0=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg=
google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
================================================
FILE: 10-performance/8_cgo/3_usage/main.go
================================================
package main
import (
"image/png"
"io/ioutil"
"log"
"os"
"time"
"github.com/klippa-app/go-pdfium"
"github.com/klippa-app/go-pdfium/requests"
"github.com/klippa-app/go-pdfium/single_threaded"
)
// Be sure to close pools/instances when you're done with them.
var pool pdfium.Pool
var instance pdfium.Pdfium
func init() {
// Init the PDFium library and return the instance to open documents.
pool = single_threaded.Init(single_threaded.Config{})
var err error
instance, err = pool.GetInstance(time.Second * 30)
if err != nil {
log.Fatal(err)
}
}
func main() {
filePath := "example.pdf"
output := "example.pdf.png"
err := renderPage(filePath, 1, output)
if err != nil {
log.Fatal(err)
}
}
func renderPage(filePath string, page int, output string) error {
// Load the PDF file into a byte array.
pdfBytes, err := ioutil.ReadFile(filePath)
if err != nil {
return err
}
// Open the PDF using PDFium (and claim a worker)
doc, err := instance.OpenDocument(&requests.OpenDocument{
File: &pdfBytes,
})
if err != nil {
return err
}
// Always close the document, this will release its resources.
defer instance.FPDF_CloseDocument(&requests.FPDF_CloseDocument{
Document: doc.Document,
})
// Render the page in DPI 200.
pageRender, err := instance.RenderPageInDPI(&requests.RenderPageInDPI{
DPI: 200, // The DPI to render the page in.
Page: requests.Page{
ByIndex: &requests.PageByIndex{
Document: doc,
Index: 0,
},
}, // The page to render, 0-indexed.
})
if err != nil {
return err
}
// Write the output to a file.
f, err := os.Create(output)
if err != nil {
return err
}
defer f.Close()
err = png.Encode(f, pageRender.Image)
if err != nil {
return err
}
return nil
}
================================================
FILE: 10-performance/8_cgo/README.md
================================================
# CGO
- Wiki: https://go.dev/wiki/cgo
CGO мощный инструмент, используемый в основном для использования
логики библиотек, которые изначально написаны на C и включают сложную логику.
================================================
FILE: 10-performance/readme.md
================================================
go test -bench . -benchmem -cpuprofile=cpu.out -memprofile=mem.out -memprofilerate=1 -benchtime=50000x unpack_test.go
go tool pprof -http=:8083 main.test cpu.out
go tool pprof -http=:8083 main.test mem.out
================================================
FILE: 2-async/0_basic_error_handling/1_ignore_errors/main.go
================================================
package main
import (
"fmt"
)
var idToUsername = map[int]string{
0: "romanov",
1: "sulaev",
2: "dorofeev",
}
func main() {
var id int
for {
_, err := fmt.Scanf("%d", &id)
if err != nil {
fmt.Printf("err scanf %v\n", err)
continue
}
fmt.Printf("username for id %d: %s\n", id, idToUsername[id])
}
}
================================================
FILE: 2-async/0_basic_error_handling/2_panic/main.go
================================================
package main
import (
"fmt"
)
var idToUsername = map[int]string{
0: "romanov",
1: "sulaev",
2: "dorofeev",
}
func main() {
var id int
for {
_, err := fmt.Scanf("%d", &id)
if err != nil {
panic(err)
}
username, ok := idToUsername[id]
if !ok {
panic(fmt.Sprintf("no user with id %d", id))
}
fmt.Printf("username for id %d: %s\n", id, username)
}
}
================================================
FILE: 2-async/0_basic_error_handling/3_handling/main.go
================================================
package main
import (
"fmt"
)
var idToUsername = map[int]string{
0: "romanov",
1: "sulaev",
2: "dorofeev",
}
func handling() error {
var id int
_, err := fmt.Scanf("%d", &id) // ask, why so many errors?
if err != nil {
return fmt.Errorf("failed to get username: %w", err)
}
username, ok := idToUsername[id]
if !ok {
return fmt.Errorf("no user with id %d", id)
}
fmt.Printf("username for id %d: %s\n", id, username)
return nil
}
func main() {
for {
err := handling()
if err != nil {
fmt.Printf("error happened: %v\n", err)
}
}
}
================================================
FILE: 2-async/0_basic_error_handling/4_return/main.go
================================================
package main
import (
"errors"
"fmt"
)
type MyError struct {
Code int
}
func (e MyError) Error() string {
return fmt.Sprintf("my error, code=%d", e.Code)
}
func bad() error {
var err *MyError = nil
fmt.Println("in bad", err == nil)
return nil // явно указываем nil
}
func main() {
err := bad()
var me MyError
fmt.Println("errors as: ", errors.As(err, &me))
fmt.Println("in main", err == nil)
fmt.Printf("err: %#v\n", err)
}
================================================
FILE: 2-async/1_async/10_context_cancel/context_cancel.go
================================================
package main
import (
"context"
"fmt"
"math/rand"
"time"
)
func student(ctx context.Context, workerNum int, out chan<- int) {
waitTime := time.Duration(rand.Intn(100)+10) * time.Millisecond
fmt.Println(workerNum, "студент думает", waitTime)
select {
case <-ctx.Done():
fmt.Println("студент", workerNum, "не успел придумать вопрос")
return
case <-time.After(waitTime):
fmt.Println("студент", workerNum, "придумал")
out <- workerNum
}
}
func main() {
ctx, cancel := context.WithCancel(context.Background())
result := make(chan int, 1)
for i := 0; i <= 10; i++ {
go student(ctx, i, result)
}
foundBy := <-result
fmt.Println("вопрос был задан студентом", foundBy)
cancel()
time.Sleep(time.Second)
}
================================================
FILE: 2-async/1_async/10_context_timeout/context_parent/main.go
================================================
package main
import (
"context"
"fmt"
"time"
)
func worker(ctx context.Context, name string) {
fmt.Println(name, "стартовал")
select {
case <-ctx.Done():
fmt.Println(name, "остановлен:", ctx.Err())
case <-time.After(3 * time.Second):
fmt.Println(name, "успел закончить работу", ctx.Err())
}
}
func main() {
parentCtx, cancelParent := context.WithCancel(context.Background())
// parentCtx, cancelParent := context.WithTimeout(context.Background(), 500*time.Millisecond)
childCtx1, _ := context.WithCancel(parentCtx)
//childCtx2, _ := context.WithTimeout(parentCtx, 3*time.Second)
go worker(childCtx1, "child-1")
go worker(childCtx1, "child-2")
time.Sleep(4 * time.Second)
fmt.Println("main: отменяем родительский контекст")
cancelParent()
time.Sleep(1 * time.Second)
}
================================================
FILE: 2-async/1_async/10_context_timeout/context_timeout.go
================================================
package main
import (
"context"
"fmt"
"math/rand"
"time"
)
func worker(ctx context.Context, workerNum int, out chan<- int) {
waitTime := time.Duration(rand.Intn(100)+10) * time.Millisecond
fmt.Println(workerNum, "студент ", waitTime)
select {
case <-ctx.Done():
fmt.Println("студент", workerNum, "не успел придумать вопрос")
return
case <-time.After(waitTime):
fmt.Println("студент", workerNum, "придумал вопрос")
out <- workerNum
}
}
func main() {
workTime := 50 * time.Millisecond
ctx, _ := context.WithTimeout(context.Background(), workTime)
result := make(chan int, 1)
for i := 0; i <= 10; i++ {
go worker(ctx, i, result)
}
totalFound := 0
LOOP:
for {
select {
case <-ctx.Done():
break LOOP
case foundBy := <-result:
totalFound++
fmt.Println("студент", foundBy, "задал вопрос")
}
}
fmt.Println("всего вопросов", totalFound)
time.Sleep(time.Second)
}
================================================
FILE: 2-async/1_async/11_errgroup_1/errgroup_1.go
================================================
package main
import (
"fmt"
"time"
"golang.org/x/sync/errgroup"
)
const (
goroutinesNum = 3
badGorutineNum = 2
)
func printGorutineNum(num int) error {
fmt.Println(num, "gorutine will work after")
if num == badGorutineNum {
fmt.Println("error found in gorutine", num)
return fmt.Errorf("bad gorutine number %d", num)
}
fmt.Println("goroutine number", num)
return nil
}
func main() {
eg := errgroup.Group{} // Инициализируем группу
for i := 0; i < goroutinesNum; i++ {
eg.Go(func() error {
return printGorutineNum(i + 1)
})
}
time.Sleep(time.Millisecond)
err := eg.Wait()
if err != nil {
fmt.Println(err)
} else {
fmt.Println("done")
}
}
================================================
FILE: 2-async/1_async/11_errgroup_2/errgroup_2.go
================================================
package main
import (
"context"
"fmt"
"golang.org/x/sync/errgroup"
"time"
)
const (
goroutinesNum = 3
badGorutineNum = 2
)
func printGorutineNum(ctx context.Context, num int) error {
waitTime := time.Duration(10*(num+1)) * time.Millisecond
fmt.Println(num, "gorutine wil work after", waitTime)
select {
case <-ctx.Done():
fmt.Printf("gorutine %d cancelled\n", num)
return nil
case <-time.After(waitTime):
if num == badGorutineNum {
fmt.Println("error found in gorutine", num)
return fmt.Errorf("bad gorutine number %d", num)
}
fmt.Println("goroutine number", num)
}
return nil
}
func main() {
eg, ctx := errgroup.WithContext(context.Background()) // Инициализируем группу с контекстом
for i := 0; i < goroutinesNum; i++ {
eg.Go(func() error {
return printGorutineNum(ctx, i+1)
})
}
time.Sleep(time.Millisecond)
err := eg.Wait()
if err != nil {
fmt.Println(err)
} else {
fmt.Println("done")
}
}
================================================
FILE: 2-async/1_async/12_atomic_1/atomic_1.go
================================================
package main
import (
"fmt"
"sync"
"time"
)
var totalOperations int32 = 0
var mu = &sync.Mutex{}
func inc() {
//mu.Lock()
//defer mu.Unlock()
// Не атомарная операция
totalOperations++
}
func main() {
//runtime.GOMAXPROCS(1)
for i := 0; i < 1000; i++ {
go inc()
}
time.Sleep(100 * time.Millisecond)
// Ожидается 1000
//mu.Lock()
fmt.Println("total operation = ", totalOperations)
//mu.Unlock()
}
================================================
FILE: 2-async/1_async/12_atomic_2/atomic_2.go
================================================
package main
import (
"fmt"
"sync/atomic" // atomic_2.go
"time"
)
var totalOperations int32
func inc() {
atomic.AddInt32(&totalOperations, 1) // атомарно
}
func main() {
for i := 0; i < 1000; i++ {
go inc()
}
time.Sleep(2 * time.Millisecond)
fmt.Println("total operation = ", totalOperations)
}
================================================
FILE: 2-async/1_async/12_atomic_2/with_bench/mutex_test.go
================================================
package main
import (
"sync"
"sync/atomic"
"testing"
)
var (
totalMutex int32
totalAtomic int32
mutex = &sync.Mutex{}
)
func BenchmarkMutexParallel(b *testing.B) {
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
mutex.Lock()
totalMutex++
mutex.Unlock()
}
})
}
func BenchmarkAtomicParallel(b *testing.B) {
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
atomic.AddInt32(&totalAtomic, 1)
}
})
}
func BenchmarkLocalCounter(b *testing.B) {
var localCounter int64
for i := 0; i < b.N; i++ {
localCounter++
}
_ = localCounter
}
================================================
FILE: 2-async/1_async/13_ratelim/ratelim.go
================================================
package main
import (
"fmt"
"runtime"
"strings"
"sync"
"time"
)
const (
iterationsNum = 6
goroutinesNum = 5
quotaLimit = 2
)
func startWorker(in int, wg *sync.WaitGroup, quotaCh chan struct{}) {
defer wg.Done()
fmt.Printf("start %d\n", in)
time.Sleep(time.Millisecond)
quotaCh <- struct{}{}
defer func() { <-quotaCh }()
for j := 0; j < iterationsNum; j++ {
fmt.Println(formatWork(in, j))
// if j%2 == 0 {
// <-quotaCh // ratelim.go, возвращаем слот
// quotaCh <- struct{}{} // ratelim.go, берём слот
// }
runtime.Gosched() // даём поработать другим горутинам
}
}
func main() {
wg := &sync.WaitGroup{}
quotaCh := make(chan struct{}, quotaLimit)
for i := 0; i < goroutinesNum; i++ {
wg.Add(1)
go startWorker(i, wg, quotaCh)
}
time.Sleep(time.Millisecond)
wg.Wait()
}
func formatWork(in, j int) string {
return fmt.Sprintln(strings.Repeat(" ", in), "█",
strings.Repeat(" ", goroutinesNum-in),
"th", in,
"iter", j, strings.Repeat("■", j))
}
================================================
FILE: 2-async/1_async/14_once/once.go
================================================
package main
import (
"fmt"
"sync"
)
func Init() {
fmt.Println("Init once")
}
func init() {
fmt.Println("Init at start of program")
}
func main() {
const routinesNum = 10
once := &sync.Once{}
wg := &sync.WaitGroup{}
wg.Add(routinesNum)
for i := 0; i < routinesNum; i++ {
go func() {
defer wg.Done()
once.Do(Init)
}()
}
wg.Wait()
}
================================================
FILE: 2-async/1_async/1_goroutines/goroutines.go
================================================
package main
import (
"fmt"
"time"
)
const goroutinesNum = 7
func main() {
for i := 0; i < goroutinesNum; i++ {
//i := i
go func() { // А если go < 1.22?
fmt.Println(i)
}()
}
time.Sleep(time.Second)
}
================================================
FILE: 2-async/1_async/1_goroutines/i_ptr/main.go
================================================
package main
import (
"fmt"
)
const goroutinesNum = 7
func main() {
var ptrs []*int
for i := 0; i < goroutinesNum; i++ {
//i := i
fmt.Println("адрес i:", &i)
ptrs = append(ptrs, &i)
}
for i, pt := range ptrs {
fmt.Println("адрес в range i:", &i)
ptrs = append(ptrs, &i)
fmt.Println(*pt)
}
}
================================================
FILE: 2-async/1_async/1_goroutines/mem/main.go
================================================
package main
import (
"fmt"
"runtime"
"time"
)
func main() {
var m1, m2 runtime.MemStats
runtime.ReadMemStats(&m1)
for i := 0; i < 10; i++ {
go func() {
//var b [2048]byte
//_ = b
//fmt.Println(b)
//fmt.Println(i)
}()
}
time.Sleep(time.Second)
runtime.ReadMemStats(&m2)
fmt.Printf("Allocated before: %d KB\n", m1.Alloc/1024)
fmt.Printf("Allocated after : %d KB\n", m2.Alloc/1024)
fmt.Printf("Per goroutine : ~%d bytes\n", (m2.Alloc-m1.Alloc)/10)
}
================================================
FILE: 2-async/1_async/1_goroutines_2/goroutines.go
================================================
package main
import (
"fmt"
"strings"
"time"
)
const (
iterationsNum = 6
goroutinesNum = 6
)
func doWork(th int) {
for j := 0; j < iterationsNum; j++ {
/*if j%2 != 0 {
time.Sleep(1 * time.Millisecond)
}*/
fmt.Printf(formatWork(th, j))
//runtime.Gosched()
}
}
func main() {
//runtime.GOMAXPROCS(1)
for i := 0; i < goroutinesNum; i++ {
go doWork(i)
}
time.Sleep(time.Second)
}
func formatWork(in, j int) string {
return fmt.Sprintln(strings.Repeat(" ", in), "█",
strings.Repeat(" ", goroutinesNum-in),
"th", in,
"iter", j, strings.Repeat("■", j))
}
================================================
FILE: 2-async/1_async/2_chan/chan_1.go
================================================
package main
import (
"fmt"
)
func main() {
ch1 := make(chan int)
go func(in chan int) {
fmt.Println("GO: before read from chan")
// time.Sleep(1000 * time.Millisecond)
val := <-in
fmt.Println("GO: get from chan", val)
fmt.Println("GO: after read from chan")
}(ch1)
fmt.Println("MAIN: before put to chan")
// time.Sleep(1000 * time.Millisecond)
ch1 <- 42
//ch1 <- 100500
fmt.Println("MAIN: after put to chan")
fmt.Scanln()
}
================================================
FILE: 2-async/1_async/2_chan_2/chan_2.go
================================================
package main
import (
"fmt"
"time"
)
func main() {
in := make(chan int)
go func(out chan<- int) {
for i := 0; i <= 10; i++ {
fmt.Println("before", i)
out <- i
fmt.Println("after", i)
}
close(out)
fmt.Println("generator finish")
}(in)
time.Sleep(2 * time.Second)
for i := range in {
fmt.Println("\tget", i)
}
/* for {
v, ok := <-in
if !ok {
break
}
fmt.Println("\tget", v)
}*/
fmt.Scanln()
}
================================================
FILE: 2-async/1_async/3_workerpool/1_workerpool.go
================================================
package main
import (
"fmt"
"runtime"
"strings"
"time"
)
const goroutinesNum = 3
func startWorker(workerNum int, in <-chan string) {
for input := range in {
fmt.Println(formatWork(workerNum, input))
time.Sleep(10 * time.Millisecond)
}
printFinishWork(workerNum)
}
func formatWork(in int, input string) string {
return fmt.Sprintln(strings.Repeat(" ", in), "█",
strings.Repeat(" ", goroutinesNum-in),
"th", in,
"recieved", input)
}
func printFinishWork(in int) {
fmt.Println(strings.Repeat("==", in), "█",
strings.Repeat("==", goroutinesNum-in),
"===", in,
"finished")
}
func main() {
runtime.GOMAXPROCS(0)
workerInput := make(chan string)
for i := 0; i < goroutinesNum; i++ {
go startWorker(i, workerInput)
}
months := []string{"Январь", "Февраль", "Март",
"Апрель", "Май", "Июнь",
"Июль", "Август", "Сентябрь",
"Октябрь", "Ноябрь", "Декабрь",
"123",
}
for _, monthName := range months {
workerInput <- monthName
}
close(workerInput) // попробуйте закомментировать
time.Sleep(time.Second)
}
================================================
FILE: 2-async/1_async/3_workerpool/2_workerpool_reusable.go
================================================
package main
type workerPool struct {
locker chan struct{}
queue chan func()
}
func NewWorkerPool(maxWorkers int) workerPool {
wp := workerPool{
locker: make(chan struct{}, maxWorkers),
queue: make(chan func(), maxWorkers),
}
go wp.work()
return wp
}
func (wp workerPool) work() {
for {
task := <-wp.queue
wp.locker <- struct{}{}
go func() {
defer func() { <-wp.locker }()
task()
}()
}
}
func (wp workerPool) PutTask(task func()) {
wp.queue <- task
}
================================================
FILE: 2-async/1_async/4_race_1/race_1.go
================================================
package main
import "fmt"
func main() {
var counters = map[int]int{}
for i := 0; i < 5; i++ {
go func(counters map[int]int, th int) {
for j := 0; j < 5; j++ {
counters[th*10+j]++
}
}(counters, i)
}
fmt.Scanln()
fmt.Println("counters result", counters)
}
================================================
FILE: 2-async/1_async/4_race_2/race_2.go
================================================
package main
import (
"fmt"
"sync"
)
func main() {
var counters = map[int]int{}
mu := &sync.Mutex{}
for i := 0; i < 5; i++ {
go func(counters map[int]int, th int, mu *sync.Mutex) {
for j := 0; j < 5; j++ {
mu.Lock()
counters[th*10+j]++
mu.Unlock()
}
}(counters, i, mu)
}
fmt.Scanln()
mu.Lock()
fmt.Println("counters result", counters)
mu.Unlock()
}
// -race
================================================
FILE: 2-async/1_async/4_race_2/race_flag/working_race.go
================================================
package main
import (
"fmt"
"time"
)
// add race flag
func main() {
var counter int
for i := 0; i < 4; i++ {
go func() {
for j := 0; j < 1000; j++ {
counter++
}
}()
}
time.Sleep(2 * time.Second)
fmt.Println("counter =", counter)
}
================================================
FILE: 2-async/1_async/4_race_3/race_3.go
================================================
package main
import (
"fmt"
"sync"
"time"
)
// look sync.Map
func main() {
var counters = map[int]int{}
mu := &sync.RWMutex{}
for i := 0; i < 5; i++ {
go func(counters map[int]int, th int, mu *sync.RWMutex) {
for j := 0; j < 5; j++ {
if (th*10+j)%7 == 0 {
mu.Lock()
counters[th*10+j]++
mu.Unlock()
} else {
mu.RLock()
fmt.Printf("[%d,%d] result %v\n", th, j, counters)
mu.RUnlock()
}
}
}(counters, i, mu)
}
time.Sleep(100 * time.Millisecond)
mu.RLock()
fmt.Println("counters result", counters)
mu.RUnlock()
}
================================================
FILE: 2-async/1_async/4_race_3_bench/race_test.go
================================================
package main
import (
"sync"
"testing"
)
func BenchmarkMapWithRWMutex(b *testing.B) {
counters := make(map[int]int)
var mu sync.RWMutex
b.ResetTimer()
b.RunParallel(func(pb *testing.PB) {
i := 0
for pb.Next() {
key := i % 1000
if key%7 == 0 {
mu.Lock()
counters[key]++
mu.Unlock()
} else {
mu.RLock()
_ = counters[key]
mu.RUnlock()
}
i++
}
})
}
func BenchmarkMapWithMutex(b *testing.B) {
counters := make(map[int]int)
var mu sync.Mutex
b.ResetTimer()
b.RunParallel(func(pb *testing.PB) {
i := 0
for pb.Next() {
key := i % 1000
if key%7 == 0 {
mu.Lock()
counters[key]++
mu.Unlock()
} else {
mu.Lock()
_ = counters[key]
mu.Unlock()
}
i++
}
})
}
================================================
FILE: 2-async/1_async/5_tick/tick.go
================================================
package main
import (
"fmt"
"time"
)
func main() {
ticker := time.NewTicker(time.Second)
i := 0
for tickTime := range ticker.C {
i++
fmt.Println("step", i, "time", tickTime)
if i >= 5 {
// Надо останавливать, иначе потечет (но с Go 1.23 не надо 🙂)
ticker.Stop()
//os.Exit(3)
break
}
}
fmt.Println("total", i)
return
// Не может быть остановлен и собран сборщиком мусора
// Используйте, если должен работать вечно
c := time.Tick(time.Second)
i = 0
for tickTime := range c {
i++
fmt.Println("step", i, "time", tickTime)
if i >= 5 {
break
}
}
}
//while true; do echo "Starting program..."; go run tick.go; echo "Program exited with code $?"; sleep 1; done;
================================================
FILE: 2-async/1_async/5_tick_example/5_ping_pong/main.go
================================================
package main
import (
"fmt"
)
func main() {
ch := make(chan string)
go func() {
for pong := range ch {
fmt.Println(pong)
ch <- "ping"
}
}()
go func() {
for ping := range ch {
fmt.Println(ping)
ch <- "pong"
}
}()
ch <- "ping"
var blockNil chan int
<-blockNil
}
================================================
FILE: 2-async/1_async/5_tick_example/main.go
================================================
package main
import (
"fmt"
"time"
)
func main() {
tick1s := time.Tick(1 * time.Second)
tick3s := time.Tick(3 * time.Second)
tick4s := time.Tick(4 * time.Second)
//var blockNil chan int
//done := make(chan struct{})
go func() {
for t := range tick1s {
fmt.Println("worker-1s tick at", t.Format("15:04:05"))
}
}()
go func() {
for t := range tick3s {
fmt.Println("worker-3s tick at", t.Format("15:04:05"))
}
}()
go func() {
for t := range tick4s {
fmt.Println("worker-4s start", t.Format("15:04:05"))
//close(blockNil) //panic
//close(done) // "сигнал" для завершения
//done <- struct{}{}
//var blockInGo chan int
//blockInGo <- 1
fmt.Println("worker-4s finish", t.Format("15:04:05"))
}
}()
//select {}
//var blockNil chan int
//<-blockNil
/* var ch chan string
if ch == nil {
}*/
//blockNil <- 1
//<-done
//valCh := <-done
//fmt.Println("valCh", valCh)
//fmt.Println(<-done)
}
================================================
FILE: 2-async/1_async/6_afterfunc/afterfunc.go
================================================
package main
import (
"fmt"
"time"
)
func sayHello() {
fmt.Println("Hello World")
}
func main() {
timer := time.AfterFunc(1*time.Second, sayHello)
fmt.Scanln()
timer.Stop()
fmt.Scanln()
}
================================================
FILE: 2-async/1_async/7_select_1/select_1.go
================================================
package main
import (
"fmt"
)
func main() {
ch1 := make(chan int, 1)
ch2 := make(chan int, 1)
ch1 <- 1
//ch2 <- 1
select {
case val := <-ch1:
fmt.Println("ch1 val", val)
case ch2 <- 1:
fmt.Println("put val to ch2")
default:
fmt.Println("default case")
}
fmt.Println("finish")
}
================================================
FILE: 2-async/1_async/7_select_2/select_2.go
================================================
package main
import (
"fmt"
)
func main() {
ch1 := make(chan int, 2)
ch1 <- 1
ch1 <- 2
ch2 := make(chan int, 2)
ch2 <- 3
LOOP:
for {
select {
case v1 := <-ch1:
fmt.Println("chan1 val", v1)
case v2 := <-ch2:
fmt.Println("chan2 val", v2)
default:
break LOOP
}
}
}
================================================
FILE: 2-async/1_async/7_select_2_new/close_buff/main.go
================================================
package main
import (
"fmt"
)
func main() {
ch := make(chan int, 3)
ch <- 1
ch <- 2
ch <- 3
close(ch)
fmt.Println("channel closed")
/* for v := range ch {
fmt.Println("read:", v)
}*/
for {
select {
case v, ok := <-ch:
if !ok {
fmt.Println("select: channel empty and closed — exit")
return
}
fmt.Println("select: read value", v)
}
}
}
================================================
FILE: 2-async/1_async/7_select_2_new/select_2_new.go
================================================
package main
import (
"fmt"
)
// Read 2 channels till they are closed
func main() {
ch1 := make(chan int)
ch2 := make(chan int)
go func() {
ch2 <- 0
close(ch2)
ch1 <- 1
ch1 <- 2
ch1 <- 3
ch1 <- 4
ch1 <- 5
ch1 <- 6
close(ch1)
}()
for {
select {
case v1, ok := <-ch1:
if !ok {
fmt.Println("ch1 closed")
ch1 = nil
}
fmt.Println("chan1 val", v1)
case v2, ok := <-ch2:
if !ok {
fmt.Println("ch2 closed")
ch2 = nil
}
fmt.Println("chan2 val", v2)
}
if ch1 == nil && ch2 == nil {
fmt.Print("Two channels closed")
break
}
}
}
================================================
FILE: 2-async/1_async/7_select_3/close_all/main.go
================================================
package main
import (
"fmt"
"time"
)
func worker(id int, cancelCh chan struct{}) {
fmt.Println("worker", id, "started")
for {
select {
case <-cancelCh:
fmt.Println("worker", id, "stopped")
return
default:
time.Sleep(300 * time.Millisecond)
}
}
}
func main() {
cancelCh := make(chan struct{})
for i := 1; i <= 3; i++ {
go worker(i, cancelCh)
}
time.Sleep(1 * time.Second)
fmt.Println("sending cancel signal")
//cancelCh <- struct{}{}
close(cancelCh)
time.Sleep(1 * time.Second)
}
================================================
FILE: 2-async/1_async/7_select_3/close_signal/main.go
================================================
package main
import (
"fmt"
"os"
"os/signal"
"syscall"
"time"
)
func worker(id int, done <-chan struct{}) {
for {
select {
case <-done:
fmt.Println("worker", id, "stopped")
return
default:
fmt.Println("worker", id, "working")
time.Sleep(1 * time.Second)
}
}
}
func main() {
done := make(chan struct{})
go worker(1, done)
go worker(2, done)
// канал для сигналов ОС
sigCh := make(chan os.Signal)
signal.Notify(sigCh, os.Interrupt, syscall.SIGTERM)
// ждём Ctrl+C
<-sigCh
fmt.Println("\nCtrl+C pressed")
// оповещаем все горутины
// можем обновить конфиг и т.д.
close(done)
time.Sleep(1 * time.Second) //подождем вывод
fmt.Println("main exit")
}
================================================
FILE: 2-async/1_async/7_select_3/select_3.go
================================================
package main
import (
"fmt"
)
func main() {
cancelCh := make(chan bool)
dataCh := make(chan int)
go func(cancelCh chan bool, dataCh chan int) {
val := 0
for {
select {
case <-cancelCh:
// Закрываем канал там, где пишем
// А что если много генераторов?
close(dataCh)
return
case dataCh <- val:
val++
}
}
}(cancelCh, dataCh)
for curVal := range dataCh {
fmt.Println("read", curVal)
if curVal > 3 {
fmt.Println("send cancel")
cancelCh <- true
// Что если этот канал должен остановить множество генераторов?
// close(cancelCh)
}
}
}
================================================
FILE: 2-async/1_async/8_wait_1/wait_1.go
================================================
package main
import (
"log"
"time"
)
func main() {
result := make(chan string)
go func(out chan<- string) {
time.Sleep(1 * time.Second)
log.Println("async operation ready, return result")
out <- "success"
}(result)
time.Sleep(2 * time.Second)
log.Println("some useful work done")
opStatus := <-result
log.Println("main goroutine:", opStatus)
}
================================================
FILE: 2-async/1_async/8_wait_2/ping_pong/main.go
================================================
package main
import (
"fmt"
"sync"
"time"
)
func main() {
ballCh := make(chan string)
wg := &sync.WaitGroup{}
wg.Add(1)
// Ping
go func() {
defer wg.Done()
for {
select {
case ball := <-ballCh:
fmt.Println(ball)
time.Sleep(500 * time.Millisecond)
ballCh <- "ping"
}
}
}()
wg.Add(1)
// Pong
go func() {
defer wg.Done()
for {
select {
case ball := <-ballCh:
fmt.Println(ball)
time.Sleep(500 * time.Millisecond)
ballCh <- "pong"
}
}
}()
// Стартовый удар
ballCh <- "ping"
//select {}
wg.Wait()
}
================================================
FILE: 2-async/1_async/8_wait_2/wait_2.go
================================================
package main
import (
"fmt"
"strings"
"sync"
"time"
)
const (
iterationsNum = 7
goroutinesNum = 5
)
func doWork(in int, wg *sync.WaitGroup) {
defer wg.Done() // Уменьшаем счетчик на 1
for j := 0; j < iterationsNum; j++ {
fmt.Printf(formatWork(in, j))
time.Sleep(time.Millisecond)
}
}
func main() {
wg := &sync.WaitGroup{} // Инициализируем группу
for i := 0; i < goroutinesNum; i++ {
// wg.Add надо вызывать в той горутине, которая порождает воркеров
// В ином случае другая горутина может не успеть запуститься и выполнится Wait
wg.Add(1) // Добавляем 1 к счетчику
go doWork(i, wg)
}
time.Sleep(time.Millisecond)
wg.Wait() // Ожидаем, пока wg.Done() не приведёт счетчик к 0
}
func formatWork(in, j int) string {
return fmt.Sprintln(strings.Repeat(" ", in), "█",
strings.Repeat(" ", goroutinesNum-in),
"th", in,
"iter", j, strings.Repeat("■", j))
}
================================================
FILE: 2-async/1_async/8_wait_3/wait_3.go
================================================
package main
import (
"fmt"
"strings"
"sync"
"time"
//github.com/neonxp/rutina
)
const (
iterationsNum = 7
goroutinesNum = 5
)
func doWork(in int) {
for j := 0; j < iterationsNum; j++ {
fmt.Printf(formatWork(in, j))
time.Sleep(time.Millisecond)
}
}
func main() {
wg := &sync.WaitGroup{} // Инициализируем группу
for i := 0; i < goroutinesNum; i++ {
wg.Go(func() { // С go 1.25
doWork(i)
})
}
time.Sleep(time.Millisecond)
wg.Wait() // Ожидаем, пока wg.Done() не приведёт счетчик к 0
}
func formatWork(in, j int) string {
return fmt.Sprintln(strings.Repeat(" ", in), "█",
strings.Repeat(" ", goroutinesNum-in),
"th", in,
"iter", j, strings.Repeat("■", j))
}
================================================
FILE: 2-async/1_async/9_timeout/timeout.go
================================================
package main
import (
"fmt"
"time"
)
func longSQLQuery() chan bool {
ch := make(chan bool, 1)
go func() {
time.Sleep(2 * time.Second)
ch <- true
}()
return ch
}
func main() {
// При 1 выполнится таймаут, при 3 - выполнится операция
timer := time.NewTimer(3 * time.Second)
select {
case <-timer.C:
fmt.Println("timer.C timeout happend")
case result := <-longSQLQuery():
// Освобождаем ресурс
if !timer.Stop() {
<-timer.C
}
fmt.Println("operation result:", result)
}
}
================================================
FILE: 2-async/readings_2.md
================================================
На русском:
* https://habrahabr.ru/post/141853/ - как работают горутины
* https://habrahabr.ru/post/308070/ - как работают каналы
* https://habrahabr.ru/post/333654/ - как работает планировщик ( https://rakyll.org/scheduler/ )
* https://habrahabr.ru/post/271789/ - танцы с мютексами
На английском:
* https://blog.golang.org/race-detector
* https://blog.golang.org/pipelines
* https://blog.golang.org/advanced-go-concurrency-patterns
* https://blog.golang.org/go-concurrency-patterns-timing-out-and
* https://talks.golang.org/2012/concurrency.slide#1
* https://www.goinggo.net/2017/10/the-behavior-of-channels.html
* http://marcio.io/2015/07/handling-1-million-requests-per-minute-with-golang/ - рассказ про оптимизацию воркер пула
* http://www.tapirgames.com/blog/golang-channel
* http://www.tapirgames.com/blog/golang-channel-closing
* https://github.com/golang/go/wiki/CommonMistakes
Видео:
* https://www.youtube.com/watch?v=5buaPyJ0XeQ - классное выступление Dave Cheney про функции первого класса и использование их с горутинами, очень рекомендую, оно небольшое
* https://www.youtube.com/watch?v=f6kdp27TYZs - Google I/O 2012 - Go Concurrency Patterns - очень рекомендую
* https://www.youtube.com/watch?v=rDRa23k70CU&list=PLDWZ5uzn69eyM81omhIZLzvRhTOXvpeX9&index=15 - ещё одно хорошее видео про паттерны конкуренции в го
* https://www.youtube.com/watch?v=KAWeC9evbGM - видео Андрея Смирнова с конференции Highload - в нём вы можете получить более детальную информацию по теме вводного видео (методы обработки запросов и плюсы неблокирующего подхода), о том, что там творится на системном уровне. На русском, не про go
Книги:
* Язык программирования Go, Алан А. А. Донован, Брайан У. Керниган - глава 8
* Concurrency in Go: Tools and Techniques for Developers, by Katherine Cox-Buday
================================================
FILE: 3-web/0_json/0_simple_json/simple_json.go
================================================
package main
import (
"encoding/json"
"fmt"
)
type User struct {
ID int
Username string
phone string
}
var jsonStr = `{"id": 42, "username": "rvasily", "phone": "123"}`
func main() {
data := []byte(jsonStr)
u := &User{}
json.Unmarshal(data, u)
fmt.Printf("struct:\n\t%#v\n\n", u)
u.phone = "987654321"
result, err := json.Marshal(u)
if err != nil {
panic(err)
}
fmt.Printf("json string:\n\t%s\n", string(result))
}
================================================
FILE: 3-web/0_json/1_struct_tags/struct_tags.go
================================================
package main
import (
"encoding/json"
"fmt"
)
type User struct {
ID int `json:"user_id,string"`
Username string
Address string `json:",omitempty"`
Company string `json:"-"`
}
func main() {
u := &User{
ID: 42,
Username: "rvasily",
Address: "test",
Company: "Mail.Ru Group",
}
result, _ := json.Marshal(u)
fmt.Printf("json string: %s\n", string(result))
}
================================================
FILE: 3-web/0_json/2_custom/custom.go
================================================
package main
import (
"encoding/json"
"fmt"
"strconv"
"strings"
)
type Company string
// MarshalJSON удовлетворяет интерфейсу json.Marshaler
func (c Company) MarshalJSON() ([]byte, error) {
return json.Marshal(fmt.Sprintf("ООО «%s»", c))
}
// UnmarshalJSON удовлетворяет интерфейсу json.Unmarshaler
func (c *Company) UnmarshalJSON(data []byte) error {
var company string
if err := json.Unmarshal(data, &company); err != nil {
return err
}
*c = Company(strings.TrimSuffix(strings.TrimPrefix(company, "ООО «"), "»"))
return nil
}
type User struct {
ID int
PassportSeries int
PassportNumber int
Company Company
}
// MarshalJSON удовлетворяет интерфейсу json.Marshaler
func (u *User) MarshalJSON() ([]byte, error) {
return json.Marshal(struct {
ID int `json:"user_id"`
Passport string `json:"passport"`
Company Company `json:"company"`
}{
ID: u.ID,
Passport: fmt.Sprintf("%d %d", u.PassportSeries, u.PassportNumber),
Company: u.Company,
})
}
// UnmarshalJSON удовлетворяет интерфейсу json.Unmarshaler
func (u *User) UnmarshalJSON(data []byte) error {
var temp struct {
ID int `json:"user_id"`
Passport string `json:"passport"`
Company Company `json:"company"`
}
if err := json.Unmarshal(data, &temp); err != nil {
return err
}
u.ID = temp.ID
u.Company = temp.Company
passportParts := strings.SplitN(temp.Passport, " ", 2)
u.PassportSeries, _ = strconv.Atoi(passportParts[0])
u.PassportNumber, _ = strconv.Atoi(passportParts[1])
return nil
}
func main() {
u := &User{
ID: 42,
PassportSeries: 4512,
PassportNumber: 123456,
Company: "VK",
}
result, err := json.Marshal(u)
if err != nil {
panic(err)
}
fmt.Printf("json string: %s\n", string(result))
var unmarshalledUser User
err = json.Unmarshal(result, &unmarshalledUser)
if err != nil {
panic(err)
}
fmt.Printf("unmarshalledUser: %+v\n", unmarshalledUser)
}
================================================
FILE: 3-web/0_json/3_dynamic/dynamic.go
================================================
package main
import (
"encoding/json"
"fmt"
)
var jsonStr = `[
{"id": 17, "username": "iivan", "phone": 0},
{"id": "17", "address": "none", "company": "Mail.ru"},
5,
[]
]`
func main() {
data := []byte(jsonStr)
var users interface{}
json.Unmarshal(data, &users)
fmt.Printf("unpacked in empty interface:\n%#v\n\n", users)
user2 := map[string]interface{}{
"id": 42,
"username": "rvasily",
}
var user2i interface{} = user2
result, _ := json.Marshal(user2i)
fmt.Printf("json string from map:\n %s\n", string(result))
}
================================================
FILE: 3-web/1_net/net_listen.go
================================================
package main
import (
"bufio"
"fmt"
"net"
)
func handleConnection(conn net.Conn) {
name := conn.RemoteAddr().String()
fmt.Printf("%+v connected\n", name)
conn.Write([]byte("Hello, " + name + "\n\r"))
defer conn.Close()
scanner := bufio.NewScanner(conn)
for scanner.Scan() {
text := scanner.Text()
if text == "Exit" {
conn.Write([]byte("Bye\n\r"))
fmt.Println(name, "disconnected")
break
} else if text != "" {
fmt.Println(name, "enters", text)
conn.Write([]byte("You enter " + text + "\n\r"))
}
}
}
func main() {
listener, err := net.Listen("tcp", ":8080")
if err != nil {
panic(err)
}
for {
conn, err := listener.Accept()
if err != nil {
panic(err)
}
go handleConnection(conn)
}
}
================================================
FILE: 3-web/2_http/0_http_server/0_basic/basic.go
================================================
package main
import (
"fmt"
"net/http"
)
func handler(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
// fmt.Fprintln(w, "<h1>Привет, мир!</h1>")
w.Write([]byte("{}"))
}
func main() {
http.HandleFunc("/", handler)
fmt.Println("starting server at :8080")
http.ListenAndServe(":8080", nil)
}
================================================
FILE: 3-web/2_http/0_http_server/1_pages/pages.go
================================================
package main
import (
"fmt"
"net/http"
)
func handler(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, "Main page")
}
func main() {
http.HandleFunc("/page",
func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, "Single page:", r.URL.String())
})
http.HandleFunc("/pages/",
func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, "Multiple pages:", r.URL.String())
})
http.HandleFunc("/", handler)
fmt.Println("starting server at :8080")
http.ListenAndServe(":8080", nil)
}
================================================
FILE: 3-web/2_http/0_http_server/2_servehttp/servehttp.go
================================================
package main
import (
"fmt"
"net/http"
)
type Handler struct {
Name string
}
func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, "Name:", h.Name, "URL:", r.URL.String())
}
func main() {
testHandler := &Handler{Name: "test"}
http.Handle("/test/", testHandler)
rootHandler := &Handler{Name: "root"}
http.Handle("/", rootHandler)
fmt.Println("starting server at :8080")
http.ListenAndServe(":8080", nil)
}
================================================
FILE: 3-web/2_http/0_http_server/3_mux/mux.go
================================================
package main
import (
"fmt"
"net/http"
"time"
)
func handler(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, "URL:", r.URL.String())
}
func main() {
mux := http.NewServeMux()
mux.HandleFunc("/", handler)
server := http.Server{
Addr: ":8080",
Handler: mux,
ReadTimeout: 10 * time.Second,
WriteTimeout: 10 * time.Second,
}
fmt.Println("starting server at :8080")
server.ListenAndServe()
}
================================================
FILE: 3-web/2_http/0_http_server/4_servers/servers.go
================================================
package main
import (
"fmt"
"net/http"
)
func runServer(addr string) {
mux := http.NewServeMux()
mux.HandleFunc("/",
func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, "Addr:", addr, "URL:", r.URL.String())
})
server := http.Server{
Addr: addr,
Handler: mux,
}
fmt.Println("starting server at", addr)
server.ListenAndServe()
}
func main() {
go runServer(":8081")
runServer(":8080")
}
================================================
FILE: 3-web/2_http/1_request/0_get/get.go
================================================
package main
import (
"fmt"
"net/http"
)
func handler(w http.ResponseWriter, r *http.Request) {
for key, value := range r.URL.Query() {
fmt.Println(key, value)
}
}
func main() {
http.HandleFunc("/", handler)
fmt.Println("starting server at :8080")
http.ListenAndServe(":8080", nil)
}
================================================
FILE: 3-web/2_http/1_request/1_post/post.go
================================================
package main
import (
"fmt"
"net/http"
)
var loginFormTmpl = []byte(`
<html>
<body>
<form action="/" method="post">
Login: <input type="text" name="login">
Password: <input type="password" name="password">
<input type="submit" value="Login">
</form>
</body>
</html>
`)
func mainPage(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodPost {
w.Write(loginFormTmpl)
return
}
r.ParseForm()
inputLogin := r.Form["login"][0]
//inputLogin := r.FormValue("login")
fmt.Fprintln(w, "you enter: ", inputLogin)
}
func main() {
http.HandleFunc("/", mainPage)
fmt.Println("starting server at :8080")
http.ListenAndServe(":8080", nil)
}
================================================
FILE: 3-web/2_http/1_request/2_cookies/cookies.go
================================================
package main
import (
"fmt"
"net/http"
"time"
)
func mainPage(w http.ResponseWriter, r *http.Request) {
session, err := r.Cookie("session_id")
loggedIn := (err != http.ErrNoCookie)
if loggedIn {
fmt.Fprintln(w, `<a href="/logout">logout</a>`)
fmt.Fprintln(w, "Welcome, "+session.Value)
} else {
fmt.Fprintln(w, `<a href="/login">login</a>`)
fmt.Fprintln(w, "You need to login")
}
}
func loginPage(w http.ResponseWriter, r *http.Request) {
expiration := time.Now().Add(10 * time.Hour)
cookie := http.Cookie{
Name: "session_id",
Value: "Dmitry",
Expires: expiration,
HttpOnly: true,
}
http.SetCookie(w, &cookie)
http.Redirect(w, r, "/", http.StatusFound)
}
func logoutPage(w http.ResponseWriter, r *http.Request) {
session, err := r.Cookie("session_id")
if err == http.ErrNoCookie {
http.Redirect(w, r, "/", http.StatusFound)
return
}
session.Expires = time.Now().AddDate(0, 0, -1)
http.SetCookie(w, session)
http.Redirect(w, r, "/", http.StatusFound)
}
func main() {
http.HandleFunc("/login", loginPage)
http.HandleFunc("/logout", logoutPage)
http.HandleFunc("/", mainPage)
fmt.Println("starting server at :8080")
http.ListenAndServe(":8080", nil)
}
================================================
FILE: 3-web/2_http/1_request/3_headers/headers.go
================================================
package main
import (
"fmt"
"net/http"
)
func handler(w http.ResponseWriter, r *http.Request) {
w.Header().Set("RequestID", "d41d8cd98f00b204")
fmt.Fprintln(w, "You browser is", r.UserAgent())
fmt.Fprintln(w, "You accept", r.Header.Get("Accept"))
}
func main() {
http.HandleFunc("/", handler)
fmt.Println("starting server at :8080")
http.ListenAndServe(":8080", nil)
}
================================================
FILE: 3-web/2_http/2_http_client/client.go
================================================
package main
import (
"bytes"
"fmt"
"io"
"net"
"net/http"
"net/url"
"strconv"
"time"
)
func startServer() {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "getHandler: incoming request %#v\n", r)
fmt.Fprintf(w, "getHandler: r.Url %#v\n", r.URL)
})
http.HandleFunc("/raw_body", func(w http.ResponseWriter, r *http.Request) {
body, err := io.ReadAll(r.Body)
defer r.Body.Close() // важный пункт!
if err != nil {
http.Error(w, err.Error(), 500)
return
}
fmt.Fprintf(w, "postHandler: raw body %s\n", string(body))
})
fmt.Println("starting server at :8080")
http.ListenAndServe(":8080", nil)
}
func runGet() {
url := "http://127.0.0.1:8080/?param=123¶m2=test"
resp, err := http.Get(url)
if err != nil {
fmt.Println("error happend", err)
return
}
defer resp.Body.Close() // важный пункт!
respBody, err := io.ReadAll(resp.Body)
fmt.Printf("http.Get body %#v\n\n\n", string(respBody))
}
func runGetFullReq() {
req := &http.Request{
Method: http.MethodGet,
Header: http.Header{
"User-Agent": {"coursera/golang"},
},
}
req.URL, _ = url.Parse("http://127.0.0.1:8080/?id=42")
req.URL.Query().Set("user", "rvasily")
resp, err := http.DefaultClient.Do(req)
if err != nil {
fmt.Println("error happend", err)
return
}
defer resp.Body.Close() // важный пункт!
respBody, err := io.ReadAll(resp.Body)
fmt.Printf("testGetFullReq resp %#v\n\n\n", string(respBody))
}
func runTransportAndPost() {
transport := &http.Transport{
DialContext: (&net.Dialer{
Timeout: 30 * time.Second,
KeepAlive: 30 * time.Second,
DualStack: true,
}).DialContext,
MaxIdleConns: 100,
IdleConnTimeout: 90 * time.Second,
TLSHandshakeTimeout: 10 * time.Second,
ExpectContinueTimeout: 1 * time.Second,
}
client := &http.Client{
Timeout: time.Second * 10,
Transport: transport,
}
data := `{"id": 42, "user": "rvasily"}`
body := bytes.NewBufferString(data)
url := "http://127.0.0.1:8080/raw_body"
req, _ := http.NewRequest(http.MethodPost, url, body)
req.Header.Add("Content-Type", "application/json")
req.Header.Add("Content-Length", strconv.Itoa(len(data)))
resp, err := client.Do(req)
if err != nil {
fmt.Println("error happend", err)
return
}
defer resp.Body.Close() // важный пункт!
respBody, err := io.ReadAll(resp.Body)
fmt.Printf("runTransport %#v\n\n\n", string(respBody))
}
func main() {
go startServer()
time.Sleep(100 * time.Millisecond)
runGet()
runGetFullReq()
runTransportAndPost()
}
================================================
FILE: 3-web/2_http/3_files/0_file_upload/file_upload.go
================================================
package main
import (
"crypto/md5"
"encoding/json"
"fmt"
"io"
"net/http"
)
var uploadFormTmpl = []byte(`
<html>
<body>
<form action="/upload" method="post" enctype="multipart/form-data">
Image: <input type="file" name="my_file">
<input type="submit" value="Upload">
</form>
</body>
</html>
`)
func mainPage(w http.ResponseWriter, r *http.Request) {
w.Write(uploadFormTmpl)
}
func uploadPage(w http.ResponseWriter, r *http.Request) {
r.ParseMultipartForm(5 * 1024 * 1025)
file, header, err := r.FormFile("my_file")
if err != nil {
fmt.Println(err)
return
}
defer file.Close()
fmt.Fprintf(w, "header.Filename %v\n", header.Filename)
fmt.Fprintf(w, "header.Header %#v\n", header.Header)
hasher := md5.New()
io.Copy(hasher, file)
fmt.Fprintf(w, "md5 %x\n", hasher.Sum(nil))
}
type Params struct {
ID int
User string
}
/*
curl -v -X POST -H "Content-Type: application/json" -d '{"id": 2, "user": "rvasily"}' http://localhost:8080/raw_body
*/
func uploadRawBody(w http.ResponseWriter, r *http.Request) {
body, err := io.ReadAll(r.Body)
defer r.Body.Close()
p := &Params{}
err = json.Unmarshal(body, p)
if err != nil {
http.Error(w, err.Error(), 500)
return
}
fmt.Fprintf(w, "content-type %#v\n",
r.Header.Get("Content-Type"))
fmt.Fprintf(w, "params %#v\n", p)
}
func main() {
http.HandleFunc("/", mainPage)
http.HandleFunc("/upload", uploadPage)
http.HandleFunc("/raw_body", uploadRawBody)
fmt.Println("starting server at :8080")
http.ListenAndServe(":8080", nil)
}
================================================
FILE: 3-web/2_http/3_files/1_static/static/super_secret_password
================================================
BestPassword!
qwerty1234567890
================================================
FILE: 3-web/2_http/3_files/1_static/static.go
================================================
package main
import (
"fmt"
"net/http"
)
func handler(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "text/html")
w.Write([]byte(`
Hello World! <br />
<img src="/data/img/gopher.png" />
`))
}
func main() {
http.HandleFunc("/", handler)
staticHandler := http.StripPrefix(
"/data/",
http.FileServer(http.Dir("./static")),
)
http.Handle("/data/", staticHandler)
fmt.Println("starting server at :8080")
http.ListenAndServe(":8080", nil)
}
================================================
FILE: 3-web/2_http/4_httptest/0_client/client_test.go
================================================
package client
import (
"io"
"net/http"
"net/http/httptest"
"testing"
)
type TestCase struct {
ID string
Response string
StatusCode int
}
func GetUser(w http.ResponseWriter, r *http.Request) {
key := r.FormValue("id")
if key == "42" {
w.WriteHeader(http.StatusOK)
io.WriteString(w, `{"status": 200, "resp": {"user": 42}}`)
} else {
w.WriteHeader(http.StatusInternalServerError)
io.WriteString(w, `{"status": 500, "err": "db_error"}`)
}
}
func TestGetUser(t *testing.T) {
cases := []TestCase{
TestCase{
ID: "42",
Response: `{"status": 200, "resp": {"user": 42}}`,
StatusCode: http.StatusOK,
},
TestCase{
ID: "500",
Response: `{"status": 500, "err": "db_error"}`,
StatusCode: http.StatusInternalServerError,
},
}
for caseNum, item := range cases {
url := "http://example.com/api/user?id=" + item.ID
req := httptest.NewRequest("GET", url, nil)
w := httptest.NewRecorder()
GetUser(w, req)
if w.Code != item.StatusCode {
t.Errorf("[%d] wrong StatusCode: got %d, expected %d",
caseNum, w.Code, item.StatusCode)
}
resp := w.Result()
body, _ := io.ReadAll(resp.Body)
bodyStr := string(body)
if bodyStr != item.Response {
t.Errorf("[%d] wrong Response: got %+v, expected %+v",
caseNum, bodyStr, item.Response)
}
}
}
================================================
FILE: 3-web/2_http/4_httptest/1_server/server_test.go
================================================
package server
import (
"encoding/json"
"io"
"net/http"
"net/http/httptest"
"reflect"
"testing"
)
type TestCase struct {
ID string
Result *CheckoutResult
IsError bool
}
type CheckoutResult struct {
Status int
Balance int
Err string
}
func CheckoutDummy(w http.ResponseWriter, r *http.Request) {
key := r.FormValue("id")
switch key {
case "42":
w.WriteHeader(http.StatusOK)
io.WriteString(w, `{"status": 200, "balance": 100500}`)
case "100500":
w.WriteHeader(http.StatusOK)
io.WriteString(w, `{"status": 400, "err": "bad_balance"}`)
case "__broken_json":
w.WriteHeader(http.StatusOK)
io.WriteString(w, `{"status": 400`) //broken json
case "__internal_error":
fallthrough
default:
w.WriteHeader(http.StatusInternalServerError)
}
}
type Cart struct {
PaymentApiURL string
}
func (c *Cart) Checkout(id string) (*CheckoutResult, error) {
url := c.PaymentApiURL + "?id=" + id
resp, err := http.Get(url)
if err != nil {
return nil, err
}
defer resp.Body.Close()
data, err := io.ReadAll(resp.Body)
if err != nil {
return nil, err
}
result := &CheckoutResult{}
err = json.Unmarshal(data, result)
if err != nil {
return nil, err
}
return result, nil
}
func TestCartCheckout(t *testing.T) {
cases := []TestCase{
TestCase{
ID: "42",
Result: &CheckoutResult{
Status: 200,
Balance: 100500,
Err: "",
},
IsError: false,
},
TestCase{
ID: "100500",
Result: &CheckoutResult{
Status: 400,
Balance: 0,
Err: "bad_balance",
},
IsError: false,
},
TestCase{
ID: "__broken_json",
Result: nil,
IsError: true,
},
TestCase{
ID: "__internal_error",
Result: nil,
IsError: true,
},
}
ts := httptest.NewServer(http.HandlerFunc(CheckoutDummy))
for caseNum, item := range cases {
c := &Cart{
PaymentApiURL: ts.URL,
}
result, err := c.Checkout(item.ID)
if err != nil && !item.IsError {
t.Errorf("[%d] unexpected error: %#v", caseNum, err)
}
if err == nil && item.IsError {
t.Errorf("[%d] expected error, got nil", caseNum)
}
if !reflect.DeepEqual(item.Result, result) {
t.Errorf("[%d] wrong result, expected %#v, got %#v", caseNum, item.Result, result)
}
}
ts.Close()
}
================================================
FILE: 3-web/3_template/0_inline/inline.go
================================================
package main
import (
"fmt"
"net/http"
"text/template"
)
type tplParams struct {
URL string
Browser string
}
const EXAMPLE = `
Browser {{.Browser}}
you at {{.URL}}
`
func handle(w http.ResponseWriter, r *http.Request) {
tmpl := template.New(`example`)
tmpl, _ = tmpl.Parse(EXAMPLE)
params := tplParams{
URL: r.URL.String(),
Browser: r.UserAgent(),
}
tmpl.Execute(w, params)
}
func main() {
http.HandleFunc("/", handle)
fmt.Println("starting server at :8080")
http.ListenAndServe(":8080", nil)
}
================================================
FILE: 3-web/3_template/1_file/file.go
================================================
package main
import (
"fmt"
"html/template"
"net/http"
)
type User struct {
ID int
Name string
Active bool
}
func main() {
tmpl := template.Must(template.ParseFiles("users.html"))
users := []User{
User{1, "Vasily", true},
User{2, "<i>Ivan</i>", false},
User{3, "Dmitry", true},
}
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
tmpl.Execute(w,
struct {
Users []User
}{
users,
})
})
fmt.Println("starting server at :8080")
http.ListenAndServe(":8080", nil)
}
================================================
FILE: 3-web/3_template/1_file/users.html
================================================
<html>
<body>
<h1>Users</h1>
{{range .Users}}
<b>{{.Name}}</b>
{{if .Active}}active{{end}}
<br />
{{end}}
</body>
</html>
================================================
FILE: 3-web/3_template/2_func/func.go
================================================
package main
import (
"fmt"
"html/template"
"net/http"
)
type User struct {
ID int
Name string
Active bool
}
func IsUserOdd(u *User) bool {
return u.ID%2 != 0
}
func main() {
tmplFuncs := template.FuncMap{
"OddUser": IsUserOdd,
}
tmpl, err := template.
New("").
Funcs(tmplFuncs).
ParseFiles("func.html")
if err != nil {
panic(err)
}
users := []User{
User{1, "Vasily", true},
User{2, "Ivan", false},
User{3, "Dmitry", true},
}
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
err := tmpl.ExecuteTemplate(w, "func.html",
struct {
Users []User
}{
users,
})
if err != nil {
panic(err)
}
})
fmt.Println("starting server at :8080")
http.ListenAndServe(":8080", nil)
}
================================================
FILE: 3-web/3_template/2_func/func.html
================================================
<html>
<body>
<h1>Users</h1>
{{range .Users}}
<b>{{.Name}}</b>,
{{if OddUser .}}
id {{.ID}} is odd
{{end}}
<br />
{{end}}
</body>
</html>
================================================
FILE: 3-web/3_template/3_method/method.go
================================================
package main
import (
"fmt"
"html/template"
"net/http"
)
type User struct {
ID int
Name string
Active bool
}
func (u *User) PrintActive() string {
if !u.Active {
return ""
}
return "method says user " + u.Name + " active"
}
func main() {
tmpl, err := template.
New("").
ParseFiles("method.html")
if err != nil {
panic(err)
}
users := []User{
User{1, "Vasily", true},
User{2, "Ivan", false},
User{3, "Dmitry", true},
}
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
err := tmpl.ExecuteTemplate(w, "method.html",
struct {
Users []User
}{
users,
})
if err != nil {
panic(err)
}
})
fmt.Println("starting server at :8080")
http.ListenAndServe(":8080", nil)
}
================================================
FILE: 3-web/3_template/3_method/method.html
================================================
<html>
<body>
<h1>Users</h1>
{{range .Users}}
<b>{{.Name}}</b>
{{.PrintActive}}
<br />
{{end}}
</body>
</html>
================================================
FILE: 3-web/4_json_http/main.go
================================================
package main
import (
"encoding/json"
"fmt"
"log"
"net/http"
"sync"
)
type UserInput struct {
Name string `json:"name"`
Password string `json:"password"`
}
type User struct {
ID uint64 `json:"id"`
Name string `json:"name"`
Password string `json:"-"`
}
type Handlers struct {
users []User
mu *sync.Mutex
}
func (h *Handlers) HandleCreateUser(w http.ResponseWriter, r *http.Request) {
defer r.Body.Close()
decoder := json.NewDecoder(r.Body)
newUserInput := new(UserInput)
err := decoder.Decode(newUserInput)
if err != nil {
log.Printf("error while unmarshalling JSON: %s", err)
w.Write([]byte("{}"))
return
}
fmt.Println(newUserInput)
h.mu.Lock()
var id uint64 = 0
if len(h.users) > 0 {
id = h.users[len(h.users)-1].ID + 1
}
h.users = append(h.users, User{
ID: id,
Name: newUserInput.Name,
Password: newUserInput.Password,
})
h.mu.Unlock()
}
func (h *Handlers) HandleListUsers(w http.ResponseWriter, r *http.Request) {
encoder := json.NewEncoder(w)
h.mu.Lock()
err := encoder.Encode(h.users)
h.mu.Unlock()
if err != nil {
log.Printf("error while marshalling JSON: %s", err)
w.Write([]byte("{}"))
return
}
}
func main() {
handlers := Handlers{
users: make([]User, 0),
mu: &sync.Mutex{},
}
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
w.Write([]byte("{}"))
})
http.HandleFunc("/users/", func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
log.Println(r.URL.Path)
if r.Method == http.MethodPost {
handlers.HandleCreateUser(w, r)
return
}
handlers.HandleListUsers(w, r)
})
http.ListenAndServe(":8080", nil)
}
================================================
FILE: 3-web/4_json_http/main_test.go
================================================
package main
import (
"bytes"
"io"
"net/http"
"net/http/httptest"
"reflect"
"strings"
"sync"
"testing"
)
func TestCreateUsers(t *testing.T) {
t.Parallel()
h := Handlers{
users: []User{},
mu: &sync.Mutex{},
}
body := bytes.NewReader([]byte(`{"name": "Vasily", "password": "qwerty"}`))
expectedUsers := []User{
{
ID: 3,
Name: "Vasily",
Password: "qwerty",
},
}
r := httptest.NewRequest("POST", "/users/", body)
w := httptest.NewRecorder()
h.HandleCreateUser(w, r)
if w.Code != http.StatusOK {
t.Error("status is not ok")
}
reflect.DeepEqual(h.users, expectedUsers)
}
var expectedJSON = `[{"id":1,"name":"Afanasiy"},{"id":2,"name":"Ka"}]`
func TestGetUsers(t *testing.T) {
h := Handlers{
users: []User{
{
ID: 1,
Name: "Afanasiy",
Password: "1234",
},
{
ID: 2,
Name: "Ka",
Password: "jdjfaljhfljehfs;l3345354",
},
},
mu: &sync.Mutex{},
}
t.Parallel()
r := httptest.NewRequest("GET", "/users/", nil)
w := httptest.NewRecorder()
h.HandleListUsers(w, r)
if w.Code != http.StatusOK {
t.Error("status is not ok")
}
bytes, _ := io.ReadAll(w.Body)
if strings.Trim(string(bytes), "\n") != expectedJSON {
t.Errorf("expected: [%s], got: [%s]", expectedJSON, string(bytes))
}
}
================================================
FILE: 3-web/readings_3.md
================================================
Конечно же документация:
* https://golang.org/pkg/net/http/
Дополнительные материалы
* https://gowebexamples.github.io/ - примеры касательно разработки веба
* https://golang.org/doc/articles/wiki/
* https://astaxie.gitbooks.io/build-web-application-with-golang/
* https://github.com/thewhitetulip/web-dev-golang-anti-textbook/
* https://codegangsta.gitbooks.io/building-web-apps-with-go/content/
* http://www.golangprograms.com/
* http://marcio.io/2015/07/cheap-mapreduce-in-go/
* https://www.rzaluska.com/blog/important-go-interfaces/
* https://blog.cloudflare.com/the-complete-guide-to-golang-net-http-timeouts/ - про таймауты
* http://polyglot.ninja/golang-making-http-requests/
* http://tumregels.github.io/Network-Programming-with-Go/
На русском:
* https://habrahabr.ru/post/330512/ - Многопользовательская игра на Go через telnet - чисто сеть
================================================
FILE: 4-api/1_rpc/jsonrpc/books.go
================================================
package main
import (
"log"
"sync"
)
type Book struct {
ID uint `json:"id"`
Title string `json:"title"`
Price uint `json:"price"`
}
type BookStore struct {
books []*Book
mu sync.RWMutex
}
func NewBookStore() *BookStore {
return &BookStore{
mu: sync.RWMutex{},
books: []*Book{},
}
}
func (bs *BookStore) AddBook(in *Book, out *Book) error {
log.Println("AddBook called")
bs.mu.Lock()
bs.books = append(bs.books, in)
bs.mu.Unlock()
*out = *in
return nil
}
func (bs *BookStore) GetBooks(in int, out *[]*Book) error {
log.Println("GetBooks called")
bs.mu.Lock()
defer bs.mu.Unlock()
*out = bs.books
return nil
}
================================================
FILE: 4-api/1_rpc/jsonrpc/server.go
================================================
package main
import (
"fmt"
"io"
"log"
"net/http"
"net/rpc"
"net/rpc/jsonrpc"
)
type HttpConn struct {
in io.Reader
out io.Writer
}
func (c *HttpConn) Read(p []byte) (n int, err error) { return c.in.Read(p) }
func (c *HttpConn) Write(d []byte) (n int, err error) { return c.out.Write(d) }
func (c *HttpConn) Close() error { return nil }
/*
{
"jsonrpc":"2.0",
"id":1,
"method":"BookStore.AddBook",
"params":[
{
"title": "The Moon is a harsh mistress",
"price": 200
}
]
}
*/
/*
curl -v -X POST -H "Content-Type: application/json" -H "X-Auth: 123" -d '{"jsonrpc":"2.0", "id": 1, "method": "BookStore.AddBook", "params": [{"title":"The Moon is a harsh mistress", "price": 200}]}' http://localhost:8081/rpc
curl -v -X POST -H "Content-Type: application/json" -H "X-Auth: 123" -d '{"jsonrpc":"2.0", "id": 2, "method": "BookStore.GetBooks", "params": []}' http://localhost:8081/rpc
*/
type Handler struct {
rpcServer *rpc.Server
}
func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
fmt.Println("rpc auth: ", r.Header.Get("X-Auth"))
serverCodec := jsonrpc.NewServerCodec(&HttpConn{
in: r.Body,
out: w,
})
w.Header().Set("Content-Type", "application/json")
err := h.rpcServer.ServeRequest(serverCodec)
if err != nil {
log.Printf("Error while serving JSON request: %v", err)
http.Error(w, `{"error":"cant serve request"}`, 500)
} else {
w.WriteHeader(200)
}
}
func main() {
bookStore := NewBookStore()
server := rpc.NewServer()
server.Register(bookStore)
sessionHandler := &Handler{
rpcServer: server,
}
http.Handle("/rpc", sessionHandler)
fmt.Println("starting server at :8081")
http.ListenAndServe(":8081", nil)
}
================================================
FILE: 4-api/1_rpc/main.go
================================================
package main
import (
"fmt"
"net/http"
)
func login(w http.ResponseWriter, r *http.Request) {
fmt.Println("login")
w.Write([]byte("login"))
}
func signup(w http.ResponseWriter, r *http.Request) {
fmt.Println("signup")
w.Write([]byte("signup"))
}
func main() {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
method := r.FormValue("method")
switch method {
case "login":
login(w, r)
case "signup":
signup(w, r)
}
})
http.ListenAndServe(":9090", nil)
}
================================================
FILE: 4-api/1_rpc/net-rpc/books.go
================================================
package main
import (
"log"
"sync"
)
type Book struct {
ID uint
Title string
Price uint
}
type BookStore struct {
books []*Book
mu sync.RWMutex
}
func NewBookStore() *BookStore {
return &BookStore{
mu: sync.RWMutex{},
books: []*Book{},
}
}
func (bs *BookStore) AddBook(in *Book, out *Book) error {
log.Println("AddBook called")
bs.mu.Lock()
bs.books = append(bs.books, in)
bs.mu.Unlock()
*out = *in
return nil
}
func (bs *BookStore) GetBooks(in int, out *[]*Book) error {
log.Println("GetBooks called")
bs.mu.Lock()
defer bs.mu.Unlock()
*out = bs.books
return nil
}
================================================
FILE: 4-api/1_rpc/net-rpc/client.go
================================================
package main
import (
"log"
"net/rpc"
)
func main() {
client, err := rpc.DialHTTP("tcp", "localhost:8081")
if err != nil {
log.Fatal("dialing:", err)
}
res := new(Book)
client.Call("BookStore.AddBook", &Book{Title: "The Moon is a harsh mistress"}, res)
if err != nil {
log.Printf("AddBook error: %s\n", err)
}
log.Printf("AddBook: %#v", res)
books := &[]*Book{}
err = client.Call("BookStore.GetBooks", 0, books)
if err != nil {
log.Printf("GetBooks error: %s\n", err)
}
log.Printf("GetBooks: %#v", *books)
}
================================================
FILE: 4-api/1_rpc/net-rpc/server.go
================================================
package main
import (
"fmt"
"log"
"net"
"net/http"
"net/rpc"
)
func main() {
bookStore := NewBookStore()
rpc.Register(bookStore)
rpc.HandleHTTP()
l, e := net.Listen("tcp", ":8081")
if e != nil {
log.Fatal("listen error:", e)
}
fmt.Println("starting server at :8081")
http.Serve(l, nil)
}
================================================
FILE: 4-api/2_rest/books.go
================================================
package main
import (
"log"
"sync"
)
type Book struct {
ID uint `json:"id"`
Title string `json:"title"`
Price uint `json:"price"`
}
type BookStore struct {
books []*Book
mu sync.RWMutex
nextID uint
}
func NewBookStore() *BookStore {
return &BookStore{
mu: sync.RWMutex{},
books: []*Book{},
}
}
func (bs *BookStore) AddBook(in *Book) (uint, error) {
log.Println("AddBook called")
bs.mu.Lock()
bs.nextID++
in.ID = bs.nextID
log.Println("nextID", bs.nextID)
bs.books = append(bs.books, in)
bs.mu.Unlock()
return in.ID, nil
}
func (bs *BookStore) GetBooks() ([]*Book, error) {
log.Println("GetBooks called")
bs.mu.RLock()
defer bs.mu.RUnlock()
return bs.books, nil
}
================================================
FILE: 4-api/2_rest/main.go
================================================
package main
import (
"encoding/json"
"log"
"net/http"
"strconv"
"github.com/gorilla/mux"
)
type Result struct {
Body interface{} `json:"body,omitempty"`
Err string `json:"err,omitempty"`
}
type BooksHandler struct {
store *BookStore
}
func (api *BooksHandler) List(w http.ResponseWriter, r *http.Request) {
books, err := api.store.GetBooks()
if err != nil {
http.Error(w, `{"error":"db"}`, 500)
return
}
body := map[string]interface{}{
"books": books,
}
json.NewEncoder(w).Encode(&Result{Body: body})
}
// http://127.0.0.1:8080/add?title=test&price=123
func (api *BooksHandler) Add(w http.ResponseWriter, r *http.Request) {
title := r.FormValue("title")
price, _ := strconv.Atoi(r.FormValue("price"))
in := &Book{
Title: title,
Price: uint(price),
}
id, err := api.store.AddBook(in)
if err != nil {
http.Error(w, `{"error":"db"}`, 500)
return
}
body := map[string]interface{}{
"id": id,
}
json.NewEncoder(w).Encode(&Result{Body: body})
}
func (api *BooksHandler) BookByID(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
id, err := strconv.Atoi(vars["id"])
if err != nil {
http.Error(w, `{"error":"bad id"}`, 400)
return
}
books, err := api.store.GetBooks()
if err != nil {
http.Error(w, `{"error":"db"}`, 500)
return
}
var book *Book
for _, b := range books {
if b.ID == uint(id) {
book = b
break
}
}
if book == nil {
http.Error(w, `{"body":{"book":null}}`, 404)
return
}
body := map[string]interface{}{
"book": book,
}
json.NewEncoder(w).Encode(&Result{Body: body})
}
func main() {
r := mux.NewRouter()
api := &BooksHandler{
store: NewBookStore(),
}
r.HandleFunc("/", api.List)
r.HandleFunc("/add", api.Add)
r.HandleFunc("/book/{id:[0-9]+}", api.BookByID)
log.Println("start serving :8080")
http.ListenAndServe(":8080", r)
}
================================================
FILE: 4-api/3_graphql/gqlgen/generated.go
================================================
// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
package gqlgen
import (
"bytes"
"context"
"errors"
"strconv"
"sync"
"sync/atomic"
"github.com/99designs/gqlgen/graphql"
"github.com/99designs/gqlgen/graphql/introspection"
"github.com/vektah/gqlparser"
"github.com/vektah/gqlparser/ast"
)
// region ************************** generated!.gotpl **************************
// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface.
func NewExecutableSchema(cfg Config) graphql.ExecutableSchema {
return &executableSchema{
resolvers: cfg.Resolvers,
directives: cfg.Directives,
complexity: cfg.Complexity,
}
}
type Config struct {
Resolvers ResolverRoot
Directives DirectiveRoot
Complexity ComplexityRoot
}
type ResolverRoot interface {
Query() QueryResolver
}
type DirectiveRoot struct {
}
type ComplexityRoot struct {
Author struct {
Name func(childComplexity int) int
}
Book struct {
Author func(childComplexity int) int
ID func(childComplexity int) int
Price func(childComplexity int) int
Title func(childComplexity int) int
}
Query struct {
Books func(childComplexity int) int
}
}
type QueryResolver interface {
Books(ctx context.Context) ([]*Book, error)
}
type executableSchema struct {
resolvers ResolverRoot
directives DirectiveRoot
complexity ComplexityRoot
}
func (e *executableSchema) Schema() *ast.Schema {
return parsedSchema
}
func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) {
ec := executionContext{nil, e}
_ = ec
switch typeName + "." + field {
case "Author.name":
if e.complexity.Author.Name == nil {
break
}
return e.complexity.Author.Name(childComplexity), true
case "Book.author":
if e.complexity.Book.Author == nil {
break
}
return e.complexity.Book.Author(childComplexity), true
case "Book.id":
if e.complexity.Book.ID == nil {
break
}
return e.complexity.Book.ID(childComplexity), true
case "Book.price":
if e.complexity.Book.Price == nil {
break
}
return e.complexity.Book.Price(childComplexity), true
case "Book.title":
if e.complexity.Book.Title == nil {
break
}
return e.complexity.Book.Title(childComplexity), true
case "Query.books":
if e.complexity.Query.Books == nil {
break
}
return e.complexity.Query.Books(childComplexity), true
}
return 0, false
}
func (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response {
ec := executionContext{graphql.GetRequestContext(ctx), e}
buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {
data := ec._Query(ctx, op.SelectionSet)
var buf bytes.Buffer
data.MarshalGQL(&buf)
return buf.Bytes()
})
return &graphql.Response{
Data: buf,
Errors: ec.Errors,
Extensions: ec.Extensions,
}
}
func (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response {
return graphql.ErrorResponse(ctx, "mutations are not supported")
}
func (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response {
return graphql.OneShot(graphql.ErrorResponse(ctx, "subscriptions are not supported"))
}
type executionContext struct {
*graphql.RequestContext
*executableSchema
}
func (ec *executionContext) introspectSchema() (*introspection.Schema, error) {
if ec.DisableIntrospection {
return nil, errors.New("introspection disabled")
}
return introspection.WrapSchema(parsedSchema), nil
}
func (ec *executionContext) introspectType(name string) (*introspection.Type, error) {
if ec.DisableIntrospection {
return nil, errors.New("introspection disabled")
}
return introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil
}
var parsedSchema = gqlparser.MustLoadSchema(
&ast.Source{Name: "schema.graphql", Input: `type Author {
name: String!
}
type Book {
id: ID!
title: String!
price: Float!
author: Author
}
type Query {
books: [Book!]!
}
`},
)
// endregion ************************** generated!.gotpl **************************
// region ***************************** args.gotpl *****************************
func (ec *executionContext) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
var err error
args := map[string]interface{}{}
var arg0 string
if tmp, ok := rawArgs["name"]; ok {
arg0, err = ec.unmarshalNString2string(ctx, tmp)
if err != nil {
return nil, err
}
}
args["name"] = arg0
return args, nil
}
func (ec *executionContext) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
var err error
args := map[string]interface{}{}
var arg0 bool
if tmp, ok := rawArgs["includeDeprecated"]; ok {
arg0, err = ec.unmarshalOBoolean2bool(ctx, tmp)
if err != nil {
return nil, err
}
}
args["includeDeprecated"] = arg0
return args, nil
}
func (ec *executionContext) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
var err error
args := map[string]interface{}{}
var arg0 bool
if tmp, ok := rawArgs["includeDeprecated"]; ok {
arg0, err = ec.unmarshalOBoolean2bool(ctx, tmp)
if err != nil {
return nil, err
}
}
args["includeDeprecated"] = arg0
return args, nil
}
// endregion ***************************** args.gotpl *****************************
// region ************************** directives.gotpl **************************
// endregion ************************** directives.gotpl **************************
// region **************************** field.gotpl *****************************
func (ec *executionContext) _Author_name(ctx context.Context, field graphql.CollectedField, obj *Author) (ret graphql.Marshaler) {
ctx = ec.Tracer.StartFieldExecution(ctx, field)
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = graphql.Null
}
ec.Tracer.EndFieldExecution(ctx)
}()
rctx := &graphql.ResolverContext{
Object: "Author",
Field: field,
Args: nil,
IsMethod: false,
}
ctx = graphql.WithResolverContext(ctx, rctx)
ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx)
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
return obj.Name, nil
})
if err != nil {
ec.Error(ctx, err)
return graphql.Null
}
if resTmp == nil {
if !ec.HasError(rctx) {
ec.Errorf(ctx, "must not be null")
}
return graphql.Null
}
res := resTmp.(string)
rctx.Result = res
ctx = ec.Tracer.StartFieldChildExecution(ctx)
return ec.marshalNString2string(ctx, field.Selections, res)
}
func (ec *executionContext) _Book_id(ctx context.Context, field graphql.CollectedField, obj *Book) (ret graphql.Marshaler) {
ctx = ec.Tracer.StartFieldExecution(ctx, field)
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = graphql.Null
}
ec.Tracer.EndFieldExecution(ctx)
}()
rctx := &graphql.ResolverContext{
Object: "Book",
Field: field,
Args: nil,
IsMethod: false,
}
ctx = graphql.WithResolverContext(ctx, rctx)
ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx)
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
return obj.ID, nil
})
if err != nil {
ec.Error(ctx, err)
return graphql.Null
}
if resTmp == nil {
if !ec.HasError(rctx) {
ec.Errorf(ctx, "must not be null")
}
return graphql.Null
}
res := resTmp.(string)
rctx.Result = res
ctx = ec.Tracer.StartFieldChildExecution(ctx)
return ec.marshalNID2string(ctx, field.Selections, res)
}
func (ec *executionContext) _Book_title(ctx context.Context, field graphql.CollectedField, obj *Book) (ret graphql.Marshaler) {
ctx = ec.Tracer.StartFieldExecution(ctx, field)
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = graphql.Null
}
ec.Tracer.EndFieldExecution(ctx)
}()
rctx := &graphql.ResolverContext{
Object: "Book",
Field: field,
Args: nil,
IsMethod: false,
}
ctx = graphql.WithResolverContext(ctx, rctx)
ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx)
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
return obj.Title, nil
})
if err != nil {
ec.Error(ctx, err)
return graphql.Null
}
if resTmp == nil {
if !ec.HasError(rctx) {
ec.Errorf(ctx, "must not be null")
}
return graphql.Null
}
res := resTmp.(string)
rctx.Result = res
ctx = ec.Tracer.StartFieldChildExecution(ctx)
return ec.marshalNString2string(ctx, field.Selections, res)
}
func (ec *executionContext) _Book_price(ctx context.Context, field graphql.CollectedField, obj *Book) (ret graphql.Marshaler) {
ctx = ec.Tracer.StartFieldExecution(ctx, field)
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = graphql.Null
}
ec.Tracer.EndFieldExecution(ctx)
}()
rctx := &graphql.ResolverContext{
Object: "Book",
Field: field,
Args: nil,
IsMethod: false,
}
ctx = graphql.WithResolverContext(ctx, rctx)
ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx)
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
return obj.Price, nil
})
if err != nil {
ec.Error(ctx, err)
return graphql.Null
}
if resTmp == nil {
if !ec.HasError(rctx) {
ec.Errorf(ctx, "must not be null")
}
return graphql.Null
}
res := resTmp.(float64)
rctx.Result = res
ctx = ec.Tracer.StartFieldChildExecution(ctx)
return ec.marshalNFloat2float64(ctx, field.Selections, res)
}
func (ec *executionContext) _Book_author(ctx context.Context, field graphql.CollectedField, obj *Book) (ret graphql.Marshaler) {
ctx = ec.Tracer.StartFieldExecution(ctx, field)
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = graphql.Null
}
ec.Tracer.EndFieldExecution(ctx)
}()
rctx := &graphql.ResolverContext{
Object: "Book",
Field: field,
Args: nil,
IsMethod: false,
}
ctx = graphql.WithResolverContext(ctx, rctx)
ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx)
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
return obj.Author, nil
})
if err != nil {
ec.Error(ctx, err)
return graphql.Null
}
if resTmp == nil {
return graphql.Null
}
res := resTmp.(*Author)
rctx.Result = res
ctx = ec.Tracer.StartFieldChildExecution(ctx)
return ec.marshalOAuthor2ᚖgithubᚗcomᚋgoᚑparkᚑmailᚑruᚋlecturesᚋ4ᚋ3_graphqlᚋgqlgenᚐAuthor(ctx, field.Selections, res)
}
func (ec *executionContext) _Query_books(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
ctx = ec.Tracer.StartFieldExecution(ctx, field)
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = graphql.Null
}
ec.Tracer.EndFieldExecution(ctx)
}()
rctx := &graphql.ResolverContext{
Object: "Query",
Field: field,
Args: nil,
IsMethod: true,
}
ctx = graphql.WithResolverContext(ctx, rctx)
ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx)
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
return ec.resolvers.Query().Books(rctx)
})
if err != nil {
ec.Error(ctx, err)
return graphql.Null
}
if resTmp == nil {
if !ec.HasError(rctx) {
ec.Errorf(ctx, "must not be null")
}
return graphql.Null
}
res := resTmp.([]*Book)
rctx.Result = res
ctx = ec.Tracer.StartFieldChildExecution(ctx)
return ec.marshalNBook2ᚕᚖgithubᚗcomᚋgoᚑparkᚑmailᚑruᚋlecturesᚋ4ᚋ3_graphqlᚋgqlgenᚐBook(ctx, field.Selections, res)
}
func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
ctx = ec.Tracer.StartFieldExecution(ctx, field)
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = graphql.Null
}
ec.Tracer.EndFieldExecution(ctx)
}()
rctx := &graphql.ResolverContext{
Object: "Query",
Field: field,
Args: nil,
IsMethod: true,
}
ctx = graphql.WithResolverContext(ctx, rctx)
rawArgs := field.ArgumentMap(ec.Variables)
args, err := ec.field_Query___type_args(ctx, rawArgs)
if err != nil {
ec.Error(ctx, err)
return graphql.Null
}
rctx.Args = args
ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx)
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
return ec.introspectType(args["name"].(string))
})
if err != nil {
ec.Error(ctx, err)
return graphql.Null
}
if resTmp == nil {
return graphql.Null
}
res := resTmp.(*introspection.Type)
rctx.Result = res
ctx = ec.Tracer.StartFieldChildExecution(ctx)
return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res)
}
func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
ctx = ec.Tracer.StartFieldExecution(ctx, field)
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = graphql.Null
}
ec.Tracer.EndFieldExecution(ctx)
}()
rctx := &graphql.ResolverContext{
Object: "Query",
Field: field,
Args: nil,
IsMethod: true,
}
ctx = graphql.WithResolverContext(ctx, rctx)
ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx)
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
return ec.introspectSchema()
})
if err != nil {
ec.Error(ctx, err)
return graphql.Null
}
if resTmp == nil {
return graphql.Null
}
res := resTmp.(*introspection.Schema)
rctx.Result = res
ctx = ec.Tracer.StartFieldChildExecution(ctx)
return ec.marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res)
}
func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) {
ctx = ec.Tracer.StartFieldExecution(ctx, field)
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = graphql.Null
}
ec.Tracer.EndFieldExecution(ctx)
}()
rctx := &graphql.ResolverContext{
Object: "__Directive",
Field: field,
Args: nil,
IsMethod: false,
}
ctx = graphql.WithResolverContext(ctx, rctx)
ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx)
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
return obj.Name, nil
})
if err != nil {
ec.Error(ctx, err)
return graphql.Null
}
if resTmp == nil {
if !ec.HasError(rctx) {
ec.Errorf(ctx, "must not be null")
}
return graphql.Null
}
res := resTmp.(string)
rctx.Result = res
ctx = ec.Tracer.StartFieldChildExecution(ctx)
return ec.marshalNString2string(ctx, field.Selections, res)
}
func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) {
ctx = ec.Tracer.StartFieldExecution(ctx, field)
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = graphql.Null
}
ec.Tracer.EndFieldExecution(ctx)
}()
rctx := &graphql.ResolverContext{
Object: "__Directive",
Field: field,
Args: nil,
IsMethod: false,
}
ctx = graphql.WithResolverContext(ctx, rctx)
ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx)
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
return obj.Description, nil
})
if err != nil {
ec.Error(ctx, err)
return graphql.Null
}
if resTmp == nil {
return graphql.Null
}
res := resTmp.(string)
rctx.Result = res
ctx = ec.Tracer.StartFieldChildExecution(ctx)
return ec.marshalOString2string(ctx, field.Selections, res)
}
func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) {
ctx = ec.Tracer.StartFieldExecution(ctx, field)
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = graphql.Null
}
ec.Tracer.EndFieldExecution(ctx)
}()
rctx := &graphql.ResolverContext{
Object: "__Directive",
Field: field,
Args: nil,
IsMethod: false,
}
ctx = graphql.WithResolverContext(ctx, rctx)
ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx)
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
return obj.Locations, nil
})
if err != nil {
ec.Error(ctx, err)
return graphql.Null
}
if resTmp == nil {
if !ec.HasError(rctx) {
ec.Errorf(ctx, "must not be null")
}
return graphql.Null
}
res := resTmp.([]string)
rctx.Result = res
ctx = ec.Tracer.StartFieldChildExecution(ctx)
return ec.marshalN__DirectiveLocation2ᚕstring(ctx, field.Selections, res)
}
func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) {
ctx = ec.Tracer.StartFieldExecution(ctx, field)
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = graphql.Null
}
ec.Tracer.EndFieldExecution(ctx)
}()
rctx := &graphql.ResolverContext{
Object: "__Directive",
Field: field,
Args: nil,
IsMethod: false,
}
ctx = graphql.WithResolverContext(ctx, rctx)
ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx)
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
return obj.Args, nil
})
if err != nil {
ec.Error(ctx, err)
return graphql.Null
}
if resTmp == nil {
if !ec.HasError(rctx) {
ec.Errorf(ctx, "must not be null")
}
return graphql.Null
}
res := resTmp.([]introspection.InputValue)
rctx.Result = res
ctx = ec.Tracer.StartFieldChildExecution(ctx)
return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res)
}
func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) {
ctx = ec.Tracer.StartFieldExecution(ctx, field)
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = graphql.Null
}
ec.Tracer.EndFieldExecution(ctx)
}()
rctx := &graphql.ResolverContext{
Object: "__EnumValue",
Field: field,
Args: nil,
IsMethod: false,
}
ctx = graphql.WithResolverContext(ctx, rctx)
ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx)
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
return obj.Name, nil
})
if err != nil {
ec.Error(ctx, err)
return graphql.Null
}
if resTmp == nil {
if !ec.HasError(rctx) {
ec.Errorf(ctx, "must not be null")
}
return graphql.Null
}
res := resTmp.(string)
rctx.Result = res
ctx = ec.Tracer.StartFieldChildExecution(ctx)
return ec.marshalNString2string(ctx, field.Selections, res)
}
func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) {
ctx = ec.Tracer.StartFieldExecution(ctx, field)
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = graphql.Null
}
ec.Tracer.EndFieldExecution(ctx)
}()
rctx := &graphql.ResolverContext{
Object: "__EnumValue",
Field: field,
Args: nil,
IsMethod: false,
}
ctx = graphql.WithResolverContext(ctx, rctx)
ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx)
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
return obj.Description, nil
})
if err != nil {
ec.Error(ctx, err)
return graphql.Null
}
if resTmp == nil {
return graphql.Null
}
res := resTmp.(string)
rctx.Result = res
ctx = ec.Tracer.StartFieldChildExecution(ctx)
return ec.marshalOString2string(ctx, field.Selections, res)
}
func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) {
ctx = ec.Tracer.StartFieldExecution(ctx, field)
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = graphql.Null
}
ec.Tracer.EndFieldExecution(ctx)
}()
rctx := &graphql.ResolverContext{
Object: "__EnumValue",
Field: field,
Args: nil,
IsMethod: true,
}
ctx = graphql.WithResolverContext(ctx, rctx)
ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx)
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
return obj.IsDeprecated(), nil
})
if err != nil {
ec.Error(ctx, err)
return graphql.Null
}
if resTmp == nil {
if !ec.HasError(rctx) {
ec.Errorf(ctx, "must not be null")
}
return graphql.Null
}
res := resTmp.(bool)
rctx.Result = res
ctx = ec.Tracer.StartFieldChildExecution(ctx)
return ec.marshalNBoolean2bool(ctx, field.Selections, res)
}
func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) {
ctx = ec.Tracer.StartFieldExecution(ctx, field)
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = graphql.Null
}
ec.Tracer.EndFieldExecution(ctx)
}()
rctx := &graphql.ResolverContext{
Object: "__EnumValue",
Field: field,
Args: nil,
IsMethod: true,
}
ctx = graphql.WithResolverContext(ctx, rctx)
ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx)
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
return obj.DeprecationReason(), nil
})
if err != nil {
ec.Error(ctx, err)
return graphql.Null
}
if resTmp == nil {
return graphql.Null
}
res := resTmp.(*string)
rctx.Result = res
ctx = ec.Tracer.StartFieldChildExecution(ctx)
return ec.marshalOString2ᚖstring(ctx, field.Selections, res)
}
func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) {
ctx = ec.Tracer.StartFieldExecution(ctx, field)
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = graphql.Null
}
ec.Tracer.EndFieldExecution(ctx)
}()
rctx := &graphql.ResolverContext{
Object: "__Field",
Field: field,
Args: nil,
IsMethod: false,
}
ctx = graphql.WithResolverContext(ctx, rctx)
ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx)
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
return obj.Name, nil
})
if err != nil {
ec.Error(ctx, err)
return graphql.Null
}
if resTmp == nil {
if !ec.HasError(rctx) {
ec.Errorf(ctx, "must not be null")
}
return graphql.Null
}
res := resTmp.(string)
rctx.Result = res
ctx = ec.Tracer.StartFieldChildExecution(ctx)
return ec.marshalNString2string(ctx, field.Selections, res)
}
func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) {
ctx = ec.Tracer.StartFieldExecution(ctx, field)
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = graphql.Null
}
ec.Tracer.EndFieldExecution(ctx)
}()
rctx := &graphql.ResolverContext{
Object: "__Field",
Field: field,
Args: nil,
IsMethod: false,
}
ctx = graphql.WithResolverContext(ctx, rctx)
ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx)
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
return obj.Description, nil
})
if err != nil {
ec.Error(ctx, err)
return graphql.Null
}
if resTmp == nil {
return graphql.Null
}
res := resTmp.(string)
rctx.Result = res
ctx = ec.Tracer.StartFieldChildExecution(ctx)
return ec.marshalOString2string(ctx, field.Selections, res)
}
func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) {
ctx = ec.Tracer.StartFieldExecution(ctx, field)
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = graphql.Null
}
ec.Tracer.EndFieldExecution(ctx)
}()
rctx := &graphql.ResolverContext{
Object: "__Field",
Field: field,
Args: nil,
IsMethod: false,
}
ctx = graphql.WithResolverContext(ctx, rctx)
ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx)
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
return obj.Args, nil
})
if err != nil {
ec.Error(ctx, err)
return graphql.Null
}
if resTmp == nil {
if !ec.HasError(rctx) {
ec.Errorf(ctx, "must not be null")
}
return graphql.Null
}
res := resTmp.([]introspection.InputValue)
rctx.Result = res
ctx = ec.Tracer.StartFieldChildExecution(ctx)
return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res)
}
func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) {
ctx = ec.Tracer.StartFieldExecution(ctx, field)
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = graphql.Null
}
ec.Tracer.EndFieldExecution(ctx)
}()
rctx := &graphql.ResolverContext{
Object: "__Field",
Field: field,
Args: nil,
IsMethod: false,
}
ctx = graphql.WithResolverContext(ctx, rctx)
ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx)
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
return obj.Type, nil
})
if err != nil {
ec.Error(ctx, err)
return graphql.Null
}
if resTmp == nil {
if !ec.HasError(rctx) {
ec.Errorf(ctx, "must not be null")
}
return graphql.Null
}
res := resTmp.(*introspection.Type)
rctx.Result = res
ctx = ec.Tracer.StartFieldChildExecution(ctx)
return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res)
}
func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) {
ctx = ec.Tracer.StartFieldExecution(ctx, field)
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = graphql.Null
}
ec.Tracer.EndFieldExecution(ctx)
}()
rctx := &graphql.ResolverContext{
Object: "__Field",
Field: field,
Args: nil,
IsMethod: true,
}
ctx = graphql.WithResolverContext(ctx, rctx)
ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx)
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
return obj.IsDeprecated(), nil
})
if err != nil {
ec.Error(ctx, err)
return graphql.Null
}
if resTmp == nil {
if !ec.HasError(rctx) {
ec.Errorf(ctx, "must not be null")
}
return graphql.Null
}
res := resTmp.(bool)
rctx.Result = res
ctx = ec.Tracer.StartFieldChildExecution(ctx)
return ec.marshalNBoolean2bool(ctx, field.Selections, res)
}
func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) {
ctx = ec.Tracer.StartFieldExecution(ctx, field)
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = graphql.Null
}
ec.Tracer.EndFieldExecution(ctx)
}()
rctx := &graphql.ResolverContext{
Object: "__Field",
Field: field,
Args: nil,
IsMethod: true,
}
ctx = graphql.WithResolverContext(ctx, rctx)
ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx)
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
return obj.DeprecationReason(), nil
})
if err != nil {
ec.Error(ctx, err)
return graphql.Null
}
if resTmp == nil {
return graphql.Null
}
res := resTmp.(*string)
rctx.Result = res
ctx = ec.Tracer.StartFieldChildExecution(ctx)
return ec.marshalOString2ᚖstring(ctx, field.Selections, res)
}
func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) {
ctx = ec.Tracer.StartFieldExecution(ctx, field)
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = graphql.Null
}
ec.Tracer.EndFieldExecution(ctx)
}()
rctx := &graphql.ResolverContext{
Object: "__InputValue",
Field: field,
Args: nil,
IsMethod: false,
}
ctx = graphql.WithResolverContext(ctx, rctx)
ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx)
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
return obj.Name, nil
})
if err != nil {
ec.Error(ctx, err)
return graphql.Null
}
if resTmp == nil {
if !ec.HasError(rctx) {
ec.Errorf(ctx, "must not be null")
}
return graphql.Null
}
res := resTmp.(string)
rctx.Result = res
ctx = ec.Tracer.StartFieldChildExecution(ctx)
return ec.marshalNString2string(ctx, field.Selections, res)
}
func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) {
ctx = ec.Tracer.StartFieldExecution(ctx, field)
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = graphql.Null
}
ec.Tracer.EndFieldExecution(ctx)
}()
rctx := &graphql.ResolverContext{
Object: "__InputValue",
Field: field,
Args: nil,
IsMethod: false,
}
ctx = graphql.WithResolverContext(ctx, rctx)
ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx)
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
return obj.Description, nil
})
if err != nil {
ec.Error(ctx, err)
return graphql.Null
}
if resTmp == nil {
return graphql.Null
}
res := resTmp.(string)
rctx.Result = res
ctx = ec.Tracer.StartFieldChildExecution(ctx)
return ec.marshalOString2string(ctx, field.Selections, res)
}
func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) {
ctx = ec.Tracer.StartFieldExecution(ctx, field)
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = graphql.Null
}
ec.Tracer.EndFieldExecution(ctx)
}()
rctx := &graphql.ResolverContext{
Object: "__InputValue",
Field: field,
Args: nil,
IsMethod: false,
}
ctx = graphql.WithResolverContext(ctx, rctx)
ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx)
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
return obj.Type, nil
})
if err != nil {
ec.Error(ctx, err)
return graphql.Null
}
if resTmp == nil {
if !ec.HasError(rctx) {
ec.Errorf(ctx, "must not be null")
}
return graphql.Null
}
res := resTmp.(*introspection.Type)
rctx.Result = res
ctx = ec.Tracer.StartFieldChildExecution(ctx)
return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res)
}
func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) {
ctx = ec.Tracer.StartFieldExecution(ctx, field)
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = graphql.Null
}
ec.Tracer.EndFieldExecution(ctx)
}()
rctx := &graphql.ResolverContext{
Object: "__InputValue",
Field: field,
Args: nil,
IsMethod: false,
}
ctx = graphql.WithResolverContext(ctx, rctx)
ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx)
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
return obj.DefaultValue, nil
})
if err != nil {
ec.Error(ctx, err)
return graphql.Null
}
if resTmp == nil {
return graphql.Null
}
res := resTmp.(*string)
rctx.Result = res
ctx = ec.Tracer.StartFieldChildExecution(ctx)
return ec.marshalOString2ᚖstring(ctx, field.Selections, res)
}
func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) {
ctx = ec.Tracer.StartFieldExecution(ctx, field)
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = graphql.Null
}
ec.Tracer.EndFieldExecution(ctx)
}()
rctx := &graphql.ResolverContext{
Object: "__Schema",
Field: field,
Args: nil,
IsMethod: true,
}
ctx = graphql.WithResolverContext(ctx, rctx)
ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx)
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
return obj.Types(), nil
})
if err != nil {
ec.Error(ctx, err)
return graphql.Null
}
if resTmp == nil {
if !ec.HasError(rctx) {
ec.Errorf(ctx, "must not be null")
}
return graphql.Null
}
res := resTmp.([]introspection.Type)
rctx.Result = res
ctx = ec.Tracer.StartFieldChildExecution(ctx)
return ec.marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res)
}
func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) {
ctx = ec.Tracer.StartFieldExecution(ctx, field)
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = graphql.Null
}
ec.Tracer.EndFieldExecution(ctx)
}()
rctx := &graphql.ResolverContext{
Object: "__Schema",
Field: field,
Args: nil,
IsMethod: true,
}
ctx = graphql.WithResolverContext(ctx, rctx)
ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx)
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
return obj.QueryType(), nil
})
if err != nil {
ec.Error(ctx, err)
return graphql.Null
}
if resTmp == nil {
if !ec.HasError(rctx) {
ec.Errorf(ctx, "must not be null")
}
return graphql.Null
}
res := resTmp.(*introspection.Type)
rctx.Result = res
ctx = ec.Tracer.StartFieldChildExecution(ctx)
return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res)
}
func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) {
ctx = ec.Tracer.StartFieldExecution(ctx, field)
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = graphql.Null
}
ec.Tracer.EndFieldExecution(ctx)
}()
rctx := &graphql.ResolverContext{
Object: "__Schema",
Field: field,
Args: nil,
IsMethod: true,
}
ctx = graphql.WithResolverContext(ctx, rctx)
ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx)
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
return obj.MutationType(), nil
})
if err != nil {
ec.Error(ctx, err)
return graphql.Null
}
if resTmp == nil {
return graphql.Null
}
res := resTmp.(*introspection.Type)
rctx.Result = res
ctx = ec.Tracer.StartFieldChildExecution(ctx)
return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res)
}
func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) {
ctx = ec.Tracer.StartFieldExecution(ctx, field)
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = graphql.Null
}
ec.Tracer.EndFieldExecution(ctx)
}()
rctx := &graphql.ResolverContext{
Object: "__Schema",
Field: field,
Args: nil,
IsMethod: true,
}
ctx = graphql.WithResolverContext(ctx, rctx)
ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx)
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
return obj.SubscriptionType(), nil
})
if err != nil {
ec.Error(ctx, err)
return graphql.Null
}
if resTmp == nil {
return graphql.Null
}
res := resTmp.(*introspection.Type)
rctx.Result = res
ctx = ec.Tracer.StartFieldChildExecution(ctx)
return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res)
}
func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) {
ctx = ec.Tracer.StartFieldExecution(ctx, field)
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = graphql.Null
}
ec.Tracer.EndFieldExecution(ctx)
}()
rctx := &graphql.ResolverContext{
Object: "__Schema",
Field: field,
Args: nil,
IsMethod: true,
}
ctx = graphql.WithResolverContext(ctx, rctx)
ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx)
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
return obj.Directives(), nil
})
if err != nil {
ec.Error(ctx, err)
return graphql.Null
}
if resTmp == nil {
if !ec.HasError(rctx) {
ec.Errorf(ctx, "must not be null")
}
return graphql.Null
}
res := resTmp.([]introspection.Directive)
rctx.Result = res
ctx = ec.Tracer.StartFieldChildExecution(ctx)
return ec.marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx, field.Selections, res)
}
func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) {
ctx = ec.Tracer.StartFieldExecution(ctx, field)
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = graphql.Null
}
ec.Tracer.EndFieldExecution(ctx)
}()
rctx := &graphql.ResolverContext{
Object: "__Type",
Field: field,
Args: nil,
IsMethod: true,
}
ctx = graphql.WithResolverContext(ctx, rctx)
ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx)
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
return obj.Kind(), nil
})
if err != nil {
ec.Error(ctx, err)
return graphql.Null
}
if resTmp == nil {
if !ec.HasError(rctx) {
ec.Errorf(ctx, "must not be null")
}
return graphql.Null
}
res := resTmp.(string)
rctx.Result = res
ctx = ec.Tracer.StartFieldChildExecution(ctx)
return ec.marshalN__TypeKind2string(ctx, field.Selections, res)
}
func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) {
ctx = ec.Tracer.StartFieldExecution(ctx, field)
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = graphql.Null
}
ec.Tracer.EndFieldExecution(ctx)
}()
rctx := &graphql.ResolverContext{
Object: "__Type",
Field: field,
Args: nil,
IsMethod: true,
}
ctx = graphql.WithResolverContext(ctx, rctx)
ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx)
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
return obj.Name(), nil
})
if err != nil {
ec.Error(ctx, err)
return graphql.Null
}
if resTmp == nil {
return graphql.Null
}
res := resTmp.(*string)
rctx.Result = res
ctx = ec.Tracer.StartFieldChildExecution(ctx)
return ec.marshalOString2ᚖstring(ctx, field.Selections, res)
}
func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) {
ctx = ec.Tracer.StartFieldExecution(ctx, field)
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = graphql.Null
}
ec.Tracer.EndFieldExecution(ctx)
}()
rctx := &graphql.ResolverContext{
Object: "__Type",
Field: field,
Args: nil,
IsMethod: true,
}
ctx = graphql.WithResolverContext(ctx, rctx)
ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx)
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
return obj.Description(), nil
})
if err != nil {
ec.Error(ctx, err)
return graphql.Null
}
if resTmp == nil {
return graphql.Null
}
res := resTmp.(string)
rctx.Result = res
ctx = ec.Tracer.StartFieldChildExecution(ctx)
return ec.marshalOString2string(ctx, field.Selections, res)
}
func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) {
ctx = ec.Tracer.StartFieldExecution(ctx, field)
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recove
gitextract_cnldqe8r/ ├── .gitignore ├── .gitmodules ├── 1-basics/ │ ├── 1_basics/ │ │ ├── 01_vars_1/ │ │ │ └── 01_vars_1.go │ │ ├── 02_vars_2/ │ │ │ └── 02_vars_2.go │ │ ├── 03_const/ │ │ │ └── 03_const.go │ │ ├── 04_pointers/ │ │ │ └── 04_pointers.go │ │ ├── 05_array/ │ │ │ └── 05_array.go │ │ ├── 06_slice_1/ │ │ │ └── 06_slice_1.go │ │ ├── 07_slice_2/ │ │ │ └── 07_slice_2.go │ │ ├── 08_strings/ │ │ │ └── 08_strings.go │ │ ├── 09_map/ │ │ │ └── 09_map.go │ │ ├── 10_control/ │ │ │ └── 10_control.go │ │ ├── 11_loop/ │ │ │ └── 11_loop.go │ │ ├── 12_types/ │ │ │ └── 12_types.go │ │ └── 13_generic/ │ │ ├── 1_generic/ │ │ │ └── main.go │ │ └── 2_methods/ │ │ └── methods.go │ ├── 2_functions/ │ │ ├── 1_functions/ │ │ │ └── 1_functions.go │ │ ├── 2_firstclass/ │ │ │ └── 2_firstclass.go │ │ ├── 3_defer/ │ │ │ └── 3_defer.go │ │ └── 4_recover/ │ │ └── 4_recover.go │ ├── 3_structs/ │ │ ├── 1_structs/ │ │ │ └── 1_structs.go │ │ └── 2_methods/ │ │ └── 2_methods.go │ ├── 4_interfaces/ │ │ ├── 1.2_basic_sort/ │ │ │ └── 1_sort.go │ │ ├── 1_basic/ │ │ │ └── 1_basic.go │ │ ├── 2_many/ │ │ │ └── 2_many.go │ │ ├── 3_embed/ │ │ │ └── 3_embed.go │ │ ├── 4_cast/ │ │ │ └── 4_cast.go │ │ ├── 5_empty_1/ │ │ │ └── 5_empty_1.go │ │ └── 6_empty_2/ │ │ └── 6_empty_2.go │ ├── 5_visibility/ │ │ ├── dir.txt │ │ ├── main.go │ │ └── person/ │ │ ├── func.go │ │ └── person.go │ ├── 6_uniq/ │ │ ├── basic/ │ │ │ ├── data.txt │ │ │ ├── data_bad.txt │ │ │ ├── data_map.txt │ │ │ └── main.go │ │ └── with_tests/ │ │ ├── data.txt │ │ ├── data_bad.txt │ │ ├── data_map.txt │ │ ├── main.go │ │ └── main_test.go │ ├── go-intro.key │ ├── homework/ │ │ └── readme.md │ └── readme.md ├── 10-performance/ │ ├── 1_reflect/ │ │ ├── 1_print/ │ │ │ └── reflect_1.go │ │ └── 2_unpack/ │ │ └── reflect_2.go │ ├── 2_codegen/ │ │ ├── gen/ │ │ │ └── codegen.go │ │ └── pack/ │ │ ├── marshaller.go │ │ └── unpack.go │ ├── 3_perfomance_1/ │ │ ├── 1_unpack/ │ │ │ └── unpack_test.go │ │ ├── 2_prealloc/ │ │ │ └── prealloc_test.go │ │ ├── 3_pool/ │ │ │ └── pool_test.go │ │ ├── 4_string/ │ │ │ └── string_test.go │ │ └── 5_json/ │ │ ├── json_test.go │ │ ├── struct.go │ │ └── struct_easyjson.go │ ├── 4_perfomance_2/ │ │ ├── 1_optimize/ │ │ │ ├── pprof_1.go │ │ │ └── pprof_1.sh │ │ ├── 2_leak_grtn/ │ │ │ ├── pprof_2.go │ │ │ └── pprof_2.sh │ │ ├── 3_tracing/ │ │ │ └── tracing.go │ │ └── note.txt │ ├── 5_testing/ │ │ ├── cover.html │ │ ├── coverage_test.go │ │ └── main.go │ ├── 6_xml_stream/ │ │ ├── main.go │ │ └── xml_test.go │ ├── 7_inline_escape/ │ │ └── main.go │ ├── 8_cgo/ │ │ ├── 1_example/ │ │ │ └── main.go │ │ ├── 2_performance/ │ │ │ └── main.go │ │ ├── 3_usage/ │ │ │ ├── README.md │ │ │ ├── go.mod │ │ │ ├── go.sum │ │ │ └── main.go │ │ └── README.md │ └── readme.md ├── 2-async/ │ ├── 0_basic_error_handling/ │ │ ├── 1_ignore_errors/ │ │ │ └── main.go │ │ ├── 2_panic/ │ │ │ └── main.go │ │ ├── 3_handling/ │ │ │ └── main.go │ │ └── 4_return/ │ │ └── main.go │ ├── 1_async/ │ │ ├── 10_context_cancel/ │ │ │ └── context_cancel.go │ │ ├── 10_context_timeout/ │ │ │ ├── context_parent/ │ │ │ │ └── main.go │ │ │ └── context_timeout.go │ │ ├── 11_errgroup_1/ │ │ │ └── errgroup_1.go │ │ ├── 11_errgroup_2/ │ │ │ └── errgroup_2.go │ │ ├── 12_atomic_1/ │ │ │ └── atomic_1.go │ │ ├── 12_atomic_2/ │ │ │ ├── atomic_2.go │ │ │ └── with_bench/ │ │ │ └── mutex_test.go │ │ ├── 13_ratelim/ │ │ │ └── ratelim.go │ │ ├── 14_once/ │ │ │ └── once.go │ │ ├── 1_goroutines/ │ │ │ ├── goroutines.go │ │ │ ├── i_ptr/ │ │ │ │ └── main.go │ │ │ └── mem/ │ │ │ └── main.go │ │ ├── 1_goroutines_2/ │ │ │ └── goroutines.go │ │ ├── 2_chan/ │ │ │ └── chan_1.go │ │ ├── 2_chan_2/ │ │ │ └── chan_2.go │ │ ├── 3_workerpool/ │ │ │ ├── 1_workerpool.go │ │ │ └── 2_workerpool_reusable.go │ │ ├── 4_race_1/ │ │ │ └── race_1.go │ │ ├── 4_race_2/ │ │ │ ├── race_2.go │ │ │ └── race_flag/ │ │ │ └── working_race.go │ │ ├── 4_race_3/ │ │ │ └── race_3.go │ │ ├── 4_race_3_bench/ │ │ │ └── race_test.go │ │ ├── 5_tick/ │ │ │ └── tick.go │ │ ├── 5_tick_example/ │ │ │ ├── 5_ping_pong/ │ │ │ │ └── main.go │ │ │ └── main.go │ │ ├── 6_afterfunc/ │ │ │ └── afterfunc.go │ │ ├── 7_select_1/ │ │ │ └── select_1.go │ │ ├── 7_select_2/ │ │ │ └── select_2.go │ │ ├── 7_select_2_new/ │ │ │ ├── close_buff/ │ │ │ │ └── main.go │ │ │ └── select_2_new.go │ │ ├── 7_select_3/ │ │ │ ├── close_all/ │ │ │ │ └── main.go │ │ │ ├── close_signal/ │ │ │ │ └── main.go │ │ │ └── select_3.go │ │ ├── 8_wait_1/ │ │ │ └── wait_1.go │ │ ├── 8_wait_2/ │ │ │ ├── ping_pong/ │ │ │ │ └── main.go │ │ │ └── wait_2.go │ │ ├── 8_wait_3/ │ │ │ └── wait_3.go │ │ └── 9_timeout/ │ │ └── timeout.go │ └── readings_2.md ├── 3-web/ │ ├── 0_json/ │ │ ├── 0_simple_json/ │ │ │ └── simple_json.go │ │ ├── 1_struct_tags/ │ │ │ └── struct_tags.go │ │ ├── 2_custom/ │ │ │ └── custom.go │ │ └── 3_dynamic/ │ │ └── dynamic.go │ ├── 1_net/ │ │ └── net_listen.go │ ├── 2_http/ │ │ ├── 0_http_server/ │ │ │ ├── 0_basic/ │ │ │ │ └── basic.go │ │ │ ├── 1_pages/ │ │ │ │ └── pages.go │ │ │ ├── 2_servehttp/ │ │ │ │ └── servehttp.go │ │ │ ├── 3_mux/ │ │ │ │ └── mux.go │ │ │ └── 4_servers/ │ │ │ └── servers.go │ │ ├── 1_request/ │ │ │ ├── 0_get/ │ │ │ │ └── get.go │ │ │ ├── 1_post/ │ │ │ │ └── post.go │ │ │ ├── 2_cookies/ │ │ │ │ └── cookies.go │ │ │ └── 3_headers/ │ │ │ └── headers.go │ │ ├── 2_http_client/ │ │ │ └── client.go │ │ ├── 3_files/ │ │ │ ├── 0_file_upload/ │ │ │ │ └── file_upload.go │ │ │ └── 1_static/ │ │ │ ├── static/ │ │ │ │ └── super_secret_password │ │ │ └── static.go │ │ └── 4_httptest/ │ │ ├── 0_client/ │ │ │ └── client_test.go │ │ └── 1_server/ │ │ └── server_test.go │ ├── 3_template/ │ │ ├── 0_inline/ │ │ │ └── inline.go │ │ ├── 1_file/ │ │ │ ├── file.go │ │ │ └── users.html │ │ ├── 2_func/ │ │ │ ├── func.go │ │ │ └── func.html │ │ └── 3_method/ │ │ ├── method.go │ │ └── method.html │ ├── 4_json_http/ │ │ ├── main.go │ │ └── main_test.go │ └── readings_3.md ├── 4-api/ │ ├── 1_rpc/ │ │ ├── jsonrpc/ │ │ │ ├── books.go │ │ │ └── server.go │ │ ├── main.go │ │ └── net-rpc/ │ │ ├── books.go │ │ ├── client.go │ │ └── server.go │ ├── 2_rest/ │ │ ├── books.go │ │ └── main.go │ ├── 3_graphql/ │ │ ├── gqlgen/ │ │ │ ├── generated.go │ │ │ ├── gqlgen.yml │ │ │ ├── models_gen.go │ │ │ ├── resolver.go │ │ │ ├── schema.graphql │ │ │ └── server/ │ │ │ └── server.go │ │ ├── gqlgen_full/ │ │ │ ├── gqlgen1/ │ │ │ │ ├── generated.go │ │ │ │ ├── go.mod │ │ │ │ ├── go.sum │ │ │ │ ├── gqlgen.yml │ │ │ │ ├── models_gen.go │ │ │ │ ├── resolver.go │ │ │ │ ├── schema.graphql │ │ │ │ └── server/ │ │ │ │ └── server.go │ │ │ ├── gqlgen2/ │ │ │ │ ├── generated.go │ │ │ │ ├── go.mod │ │ │ │ ├── go.sum │ │ │ │ ├── gqlgen.yml │ │ │ │ ├── models_gen.go │ │ │ │ ├── photo.go │ │ │ │ ├── resolver.go │ │ │ │ ├── schema.graphql │ │ │ │ ├── schema_alt.graphql │ │ │ │ └── server/ │ │ │ │ └── server.go │ │ │ ├── gqlgen3/ │ │ │ │ ├── generated.go │ │ │ │ ├── go.mod │ │ │ │ ├── go.sum │ │ │ │ ├── gqlgen.yml │ │ │ │ ├── models_gen.go │ │ │ │ ├── photo.go │ │ │ │ ├── resolver.go │ │ │ │ ├── schema.graphql │ │ │ │ ├── schema_alt.graphql │ │ │ │ ├── server/ │ │ │ │ │ └── server.go │ │ │ │ └── userloader_gen.go │ │ │ ├── gqlgen4/ │ │ │ │ ├── generated.go │ │ │ │ ├── go.mod │ │ │ │ ├── go.sum │ │ │ │ ├── gqlgen.yml │ │ │ │ ├── models_gen.go │ │ │ │ ├── photo.go │ │ │ │ ├── queries.txt │ │ │ │ ├── resolver.go │ │ │ │ ├── schema.graphql │ │ │ │ ├── server/ │ │ │ │ │ └── server.go │ │ │ │ └── userloader_gen.go │ │ │ ├── gqlgen5/ │ │ │ │ ├── generated.go │ │ │ │ ├── go.mod │ │ │ │ ├── go.sum │ │ │ │ ├── gqlgen.yml │ │ │ │ ├── models_gen.go │ │ │ │ ├── photo.go │ │ │ │ ├── queries.txt │ │ │ │ ├── resolver.go │ │ │ │ ├── schema.graphql │ │ │ │ ├── server/ │ │ │ │ │ └── server.go │ │ │ │ ├── test_file.txt │ │ │ │ └── userloader_gen.go │ │ │ ├── gqlgen6/ │ │ │ │ ├── generated.go │ │ │ │ ├── go.mod │ │ │ │ ├── go.sum │ │ │ │ ├── gqlgen.yml │ │ │ │ ├── models_gen.go │ │ │ │ ├── photo.go │ │ │ │ ├── queries.txt │ │ │ │ ├── resolver.go │ │ │ │ ├── schema.graphql │ │ │ │ ├── server/ │ │ │ │ │ └── server.go │ │ │ │ ├── test_file.txt │ │ │ │ └── userloader_gen.go │ │ │ └── note.txt │ │ ├── graphql-go/ │ │ │ └── main.go │ │ └── intro/ │ │ ├── instagram_gql.txt │ │ ├── instagram_sql_resp.json │ │ ├── readme.md │ │ └── schema.public.graphql │ ├── 4_swagger/ │ │ ├── docs/ │ │ │ ├── docs.go │ │ │ ├── swagger/ │ │ │ │ ├── swagger.json │ │ │ │ └── swagger.yaml │ │ │ ├── swagger.json │ │ │ └── swagger.yaml │ │ ├── main.go │ │ └── model/ │ │ └── user.go │ ├── 5_sessions/ │ │ └── main.go │ ├── 6_jwt/ │ │ └── main.go │ └── 7_oauth/ │ └── main.go ├── 5-architecture/ │ ├── 0_bad_example/ │ │ └── api.go │ ├── 10_crudapp/ │ │ ├── cmd/ │ │ │ └── crudapp/ │ │ │ └── main.go │ │ ├── file_tree.txt │ │ ├── go.mod │ │ ├── go.sum │ │ ├── internal/ │ │ │ ├── crudapp/ │ │ │ │ └── middleware/ │ │ │ │ ├── accesslog.go │ │ │ │ ├── auth.go │ │ │ │ └── panic.go │ │ │ └── pkg/ │ │ │ ├── items/ │ │ │ │ ├── delivery/ │ │ │ │ │ └── items.go │ │ │ │ ├── items.go │ │ │ │ └── repository/ │ │ │ │ └── repo.go │ │ │ ├── models/ │ │ │ │ ├── item.go │ │ │ │ ├── session.go │ │ │ │ └── user.go │ │ │ ├── session/ │ │ │ │ └── manager.go │ │ │ └── user/ │ │ │ ├── delivery/ │ │ │ │ ├── user.go │ │ │ │ └── user_test.go │ │ │ ├── mock/ │ │ │ │ └── mock_repo.go │ │ │ ├── repository/ │ │ │ │ └── user.go │ │ │ └── user.go │ │ ├── readme.md │ │ └── templates/ │ │ ├── create.html │ │ ├── edit.html │ │ ├── index.html │ │ └── login.html │ ├── 1_routers/ │ │ ├── 0_httprouter/ │ │ │ └── 0_httprouter.go │ │ ├── 1_fasthttp/ │ │ │ └── 1_fasthttp.go │ │ ├── 2_gorilla/ │ │ │ └── 2_gorilla.go │ │ └── 3_multiple/ │ │ └── 3_multiple.go │ ├── 2_middleware/ │ │ ├── 1_middleware/ │ │ │ └── 1_middleware.go │ │ └── 2_context_value/ │ │ └── 2_context_value.go │ ├── 3_errors/ │ │ ├── 1_basic_err/ │ │ │ └── 1_basic_err.go │ │ ├── 2_named_err/ │ │ │ └── 2_named_err.go │ │ ├── 3_pkg_err/ │ │ │ └── 3_pkg_err.go │ │ ├── 4_own_err/ │ │ │ └── 4_own_err.go │ │ └── 5_new_errors/ │ │ └── 5_new_errors.go │ ├── 4_validation/ │ │ └── validation.go │ ├── 5_logging/ │ │ └── main.go │ ├── 6_websockets/ │ │ ├── index.html │ │ └── main.go │ ├── 7_frameworks/ │ │ └── echo/ │ │ ├── main.go │ │ ├── middleware/ │ │ │ ├── error.go │ │ │ ├── panic.go │ │ │ ├── request_id.go │ │ │ └── session.go │ │ ├── model/ │ │ │ └── user.go │ │ └── user/ │ │ ├── delivery/ │ │ │ └── http/ │ │ │ ├── hander_test.go │ │ │ └── handler.go │ │ ├── repository/ │ │ │ └── memory.go │ │ ├── repository.go │ │ ├── usecase/ │ │ │ └── usecase.go │ │ ├── usecase.go │ │ └── usecase_mock.go │ └── readings_5.md ├── 6-databases/ │ ├── 00_databases/ │ │ ├── _kafka/ │ │ │ └── setup.sh │ │ ├── _mysql/ │ │ │ ├── injection_db.sql │ │ │ └── items.sql │ │ ├── _postgres/ │ │ │ └── items.sql │ │ └── docker-compose.yml │ ├── 01_mysql/ │ │ ├── main.go │ │ └── templates/ │ │ ├── create.html │ │ ├── edit.html │ │ └── index.html │ ├── 02_postgresql/ │ │ ├── main.go │ │ └── templates/ │ │ ├── create.html │ │ ├── edit.html │ │ └── index.html │ ├── 03_mysql_sql_injection/ │ │ └── main.go │ ├── 04_mysql_sqlmock/ │ │ ├── item_repo.go │ │ ├── item_repo_test.go │ │ ├── main.go │ │ └── templates/ │ │ ├── create.html │ │ ├── edit.html │ │ └── index.html │ ├── 05_gorm/ │ │ ├── main.go │ │ └── templates/ │ │ ├── create.html │ │ ├── edit.html │ │ └── index.html │ ├── 06_crudapp_db_tests/ │ │ ├── cmd/ │ │ │ └── crudapp/ │ │ │ └── main.go │ │ ├── pkg/ │ │ │ ├── handlers/ │ │ │ │ ├── handler.html │ │ │ │ ├── items.go │ │ │ │ ├── items_mock.go │ │ │ │ ├── items_test.go │ │ │ │ └── user.go │ │ │ ├── items/ │ │ │ │ ├── item.go │ │ │ │ ├── item_repo_test.go │ │ │ │ ├── repo_gorm.go │ │ │ │ ├── repo_mysql.go │ │ │ │ ├── repo_pgx.go │ │ │ │ └── repo_sqlx.go │ │ │ ├── middleware/ │ │ │ │ ├── accesslog.go │ │ │ │ ├── auth.go │ │ │ │ └── panic.go │ │ │ ├── session/ │ │ │ │ ├── manager.go │ │ │ │ └── session.go │ │ │ └── user/ │ │ │ └── user.go │ │ ├── readme.md │ │ └── templates/ │ │ ├── create.html │ │ ├── edit.html │ │ ├── index.html │ │ └── login.html │ ├── 07_mongodb/ │ │ ├── main.go │ │ └── templates/ │ │ ├── create.html │ │ ├── edit.html │ │ └── index.html │ ├── 08_memcache/ │ │ └── memcache.go │ ├── 09_redis_simple/ │ │ └── cmds.go │ ├── 10_redis/ │ │ ├── main.go │ │ └── session.go │ ├── 11_rabbit/ │ │ ├── form/ │ │ │ └── form.go │ │ └── resizer/ │ │ └── resize_worker.go │ ├── 12_kafka/ │ │ ├── form/ │ │ │ └── form.go │ │ └── resizer/ │ │ └── resize_worker.go │ ├── 13_tarantool_simple/ │ │ ├── Dockerfile │ │ ├── app.lua │ │ └── main.go │ ├── 14_tarantool/ │ │ ├── main.go │ │ └── session.go │ ├── crudapp_mongo/ │ │ ├── cmd/ │ │ │ └── crudapp/ │ │ │ └── main.go │ │ ├── file_tree.txt │ │ ├── pkg/ │ │ │ ├── handlers/ │ │ │ │ ├── items.go │ │ │ │ ├── items_mock.go │ │ │ │ ├── items_test.go │ │ │ │ └── user.go │ │ │ ├── items/ │ │ │ │ ├── item.go │ │ │ │ └── repo_mongo.go │ │ │ ├── middleware/ │ │ │ │ ├── accesslog.go │ │ │ │ ├── auth.go │ │ │ │ └── panic.go │ │ │ ├── session/ │ │ │ │ ├── manager.go │ │ │ │ └── session.go │ │ │ └── user/ │ │ │ └── user.go │ │ ├── readme.md │ │ └── templates/ │ │ ├── create.html │ │ ├── edit.html │ │ ├── index.html │ │ └── login.html │ ├── readings_6.md │ ├── readme.md │ └── tcache/ │ ├── cache.go │ ├── main.go │ └── posts.go ├── 7-security/ │ ├── 1_passwords/ │ │ ├── 0_password.txt │ │ ├── 1_salt.go │ │ ├── 2_pass.go │ │ └── 2_pass_bench_test.go │ ├── 2_csrf/ │ │ ├── csrf.go │ │ └── csrf.txt │ ├── 3_csrf_token/ │ │ ├── csrf.go │ │ ├── token_crypt.go │ │ ├── token_jwt.go │ │ └── tokjen_hash.go │ ├── 4_xss/ │ │ └── xss.go │ ├── 5_xss_clean/ │ │ ├── login.txt │ │ └── xss_clean.go │ ├── 6_acl/ │ │ ├── acl_rbac.txt │ │ └── casbin/ │ │ ├── basic_model.conf │ │ ├── basic_policy.csv │ │ └── rbac.go │ └── 7_docker/ │ ├── .dockerignore │ ├── Dockerfile │ ├── Dockerfile.Multistage │ ├── code/ │ │ ├── go.mod │ │ └── main.go │ ├── docker-compose.yml │ ├── nginx/ │ │ └── nginx.conf │ └── readme.md ├── 8-microservices/ │ ├── 0_service/ │ │ ├── 1_step/ │ │ │ ├── main.go │ │ │ ├── run_test.go │ │ │ └── session.go │ │ └── 2_step/ │ │ ├── main.go │ │ ├── run_test.go │ │ └── session.go │ ├── 1_net-rpc/ │ │ ├── client/ │ │ │ ├── client.go │ │ │ ├── run_test.go │ │ │ └── session.go │ │ └── server/ │ │ ├── server.go │ │ └── session.go │ ├── 2_json-rpc/ │ │ ├── client/ │ │ │ ├── client.go │ │ │ ├── run_test.go │ │ │ └── session.go │ │ └── server/ │ │ ├── server.go │ │ └── session.go │ ├── 3_protobuf/ │ │ ├── main.go │ │ ├── session.pb.go │ │ └── session.proto │ ├── 4_grpc/ │ │ ├── client/ │ │ │ ├── main.go │ │ │ └── run_test.go │ │ ├── readme.md │ │ ├── server/ │ │ │ ├── server.go │ │ │ └── session.go │ │ └── session/ │ │ ├── session.pb.go │ │ ├── session.proto │ │ └── session_grpc.pb.go │ ├── 5_grpc_features/ │ │ ├── client/ │ │ │ └── client.go │ │ └── server/ │ │ ├── server.go │ │ └── session.go │ ├── 6_grpc_stream/ │ │ ├── client/ │ │ │ ├── client.go │ │ │ └── run_test.go │ │ ├── server/ │ │ │ ├── main.go │ │ │ ├── server.go │ │ │ └── translit.go │ │ └── translit/ │ │ ├── translit.pb.go │ │ ├── translit.proto │ │ └── translit_grpc.pb.go │ └── 7_grpc_loadbalance/ │ ├── client/ │ │ └── main.go │ ├── docker-compose.yml │ ├── readme.md │ └── server/ │ ├── server.go │ └── session.go ├── 9-monitoring/ │ ├── 0_services/ │ │ ├── alertmanager/ │ │ │ └── alertmanager.yml │ │ ├── alertmanager-bot/ │ │ │ └── templates/ │ │ │ └── default.tmpl │ │ ├── docker-compose.yml │ │ └── prometheus/ │ │ ├── alerts.yml │ │ └── prometheus.yml │ ├── 1_config/ │ │ ├── 1_flag/ │ │ │ └── flag.go │ │ ├── 2_json/ │ │ │ ├── config.json │ │ │ └── json_config.go │ │ ├── 3_ldflags/ │ │ │ └── ldflags.go │ │ ├── 4_viper/ │ │ │ ├── config.yml │ │ │ └── main.go │ │ └── 5_consul/ │ │ └── consul_config.go │ ├── 2_vault/ │ │ ├── main.go │ │ └── readme.md │ ├── 3_monitoring/ │ │ ├── expvars/ │ │ │ └── expvars.go │ │ ├── metrics/ │ │ │ └── context_monitoring.go │ │ ├── prometheus/ │ │ │ ├── alertmanager/ │ │ │ │ └── alertmanager.yml │ │ │ ├── main.go │ │ │ ├── prometheus/ │ │ │ │ ├── alerts.yml │ │ │ │ └── prometheus.yml │ │ │ └── readme.md │ │ └── sentry/ │ │ ├── echo/ │ │ │ └── main.go │ │ └── simple/ │ │ └── main.go │ └── 4_tracing/ │ └── jaeger_grpc/ │ ├── client/ │ │ └── main.go │ ├── readme.md │ ├── server/ │ │ ├── server.go │ │ └── session.go │ └── session/ │ ├── session.pb.go │ └── session.proto ├── README.md ├── go.mod └── go.sum
Showing preview only (231K chars total). Download the full file or copy to clipboard to get everything.
SYMBOL INDEX (2307 symbols across 337 files)
FILE: 1-basics/1_basics/01_vars_1/01_vars_1.go
function main (line 5) | func main() {
FILE: 1-basics/1_basics/02_vars_2/02_vars_2.go
function main (line 5) | func main() {
FILE: 1-basics/1_basics/03_const/03_const.go
constant pi (line 5) | pi = 3.141
constant hello (line 7) | hello = "Привет"
constant e (line 8) | e = 2.718
constant zero (line 11) | zero = iota
constant _ (line 12) | _
constant two (line 13) | two
constant three (line 14) | three
constant _ (line 17) | _ = iota
constant KB (line 18) | KB uint64 = 1 << (10 * iota)
constant MB (line 19) | MB
constant year (line 23) | year = 2017
constant yearTyped (line 25) | yearTyped int = 2017
function main (line 28) | func main() {
FILE: 1-basics/1_basics/04_pointers/04_pointers.go
function main (line 3) | func main() {
FILE: 1-basics/1_basics/05_array/05_array.go
function main (line 5) | func main() {
FILE: 1-basics/1_basics/06_slice_1/06_slice_1.go
function main (line 5) | func main() {
FILE: 1-basics/1_basics/07_slice_2/07_slice_2.go
function main (line 5) | func main() {
FILE: 1-basics/1_basics/08_strings/08_strings.go
function main (line 8) | func main() {
FILE: 1-basics/1_basics/09_map/09_map.go
function main (line 5) | func main() {
FILE: 1-basics/1_basics/10_control/10_control.go
function main (line 5) | func main() {
FILE: 1-basics/1_basics/11_loop/11_loop.go
function main (line 5) | func main() {
FILE: 1-basics/1_basics/12_types/12_types.go
type UserID (line 3) | type UserID
function main (line 5) | func main() {
FILE: 1-basics/1_basics/13_generic/1_generic/main.go
function equalInt (line 5) | func equalInt(a, b int) bool {
function equalFloat (line 9) | func equalFloat(a, b float64) bool {
function equal (line 15) | func equal[T int | float64](a, b T) bool {
type MyType (line 20) | type MyType
function equalWithAlias (line 22) | func equalWithAlias[T ~int | ~float64](a, b T) bool {
function KeyExists (line 26) | func KeyExists[T any](m map[string]T, key string) bool {
function main (line 31) | func main() {
FILE: 1-basics/1_basics/13_generic/2_methods/methods.go
type Box (line 9) | type Box struct
method GetValue (line 14) | func (b Box[T]) GetValue() T {
method SetValue (line 19) | func (b *Box[T]) SetValue(v T) {
type Number (line 24) | type Number interface
type Calculator (line 28) | type Calculator struct
method Add (line 33) | func (c Calculator[T]) Add(a T) T {
method Multiply (line 37) | func (c Calculator[T]) Multiply(a T) T {
type Container (line 42) | type Container struct
method ToJSON (line 46) | func (c Container[T]) ToJSON() ([]byte, error) {
method FromJSON (line 50) | func (c *Container[T]) FromJSON(data []byte) error {
function CompareWith (line 55) | func CompareWith[T any, U any](b Box[T], other U, compareFunc func(T, U)...
type Cache (line 60) | type Cache struct
function NewCache (line 64) | func NewCache[K comparable, V any]() *Cache[K, V] {
method Set (line 70) | func (c *Cache[K, V]) Set(key K, value V) {
method Get (line 74) | func (c *Cache[K, V]) Get(key K) (V, bool) {
method Delete (line 79) | func (c *Cache[K, V]) Delete(key K) {
type Stringer (line 84) | type Stringer interface
type Printer (line 88) | type Printer struct
method Print (line 92) | func (p Printer[T]) Print() string {
type MyInt (line 97) | type MyInt
method String (line 99) | func (m MyInt) String() string {
function main (line 103) | func main() {
FILE: 1-basics/2_functions/1_functions/1_functions.go
function singleIn (line 6) | func singleIn(in int) int {
function multIn (line 11) | func multIn(a, b int, c int) int {
function namedReturn (line 16) | func namedReturn() (out int) {
function multipleReturn (line 22) | func multipleReturn(in int) (int, error) {
function multipleNamedReturn (line 30) | func multipleNamedReturn(ok bool) (rez int, err error) {
function sum (line 42) | func sum(in ...int) (result int) {
function main (line 50) | func main() {
FILE: 1-basics/2_functions/2_firstclass/2_firstclass.go
function doNothing (line 6) | func doNothing() {
function main (line 10) | func main() {
FILE: 1-basics/2_functions/3_defer/3_defer.go
function getSomeVars (line 5) | func getSomeVars() string {
function main (line 10) | func main() {
FILE: 1-basics/2_functions/4_recover/4_recover.go
function deferTest (line 7) | func deferTest() {
function main (line 24) | func main() {
FILE: 1-basics/3_structs/1_structs/1_structs.go
type Person (line 5) | type Person struct
type Account (line 11) | type Account struct
function main (line 19) | func main() {
FILE: 1-basics/3_structs/2_methods/2_methods.go
type Person (line 5) | type Person struct
method UpdateName (line 11) | func (p Person) UpdateName(name string) {
method SetName (line 16) | func (p *Person) SetName(name string) {
type Account (line 20) | type Account struct
method SetName (line 26) | func (p *Account) SetName(name string) {
type MySlice (line 30) | type MySlice
method Add (line 32) | func (sl *MySlice) Add(val int) {
method Count (line 36) | func (sl *MySlice) Count() int {
function main (line 40) | func main() {
FILE: 1-basics/4_interfaces/1.2_basic_sort/1_sort.go
type Student (line 8) | type Student struct
type Students (line 13) | type Students
method Len (line 15) | func (sts Students) Len() int { return len(sts) }
method Swap (line 16) | func (sts Students) Swap(a, b int) { sts[a], sts[b] = sts[b], sts...
method Less (line 17) | func (sts Students) Less(a, b int) bool { return sts[a].Age < sts[b].A...
function main (line 19) | func main() {
FILE: 1-basics/4_interfaces/1_basic/1_basic.go
type Payer (line 7) | type Payer interface
type Wallet (line 11) | type Wallet struct
method Pay (line 15) | func (w *Wallet) Pay(amount int) error {
function Buy (line 23) | func Buy(p Payer) {
function main (line 31) | func main() {
FILE: 1-basics/4_interfaces/2_many/2_many.go
type Wallet (line 9) | type Wallet struct
method Pay (line 13) | func (w *Wallet) Pay(amount int) error {
type Card (line 23) | type Card struct
method Pay (line 31) | func (c *Card) Pay(amount int) error {
type ApplePay (line 41) | type ApplePay struct
method Pay (line 46) | func (a *ApplePay) Pay(amount int) error {
type Payer (line 56) | type Payer interface
function Buy (line 60) | func Buy(p Payer) {
function main (line 71) | func main() {
FILE: 1-basics/4_interfaces/3_embed/3_embed.go
type Phone (line 7) | type Phone struct
method Pay (line 12) | func (p *Phone) Pay(amount int) error {
method Ring (line 20) | func (p *Phone) Ring(number string) error {
type Payer (line 29) | type Payer interface
type Ringer (line 33) | type Ringer interface
type NFCPhone (line 37) | type NFCPhone interface
function PayForMetwiWithPhone (line 44) | func PayForMetwiWithPhone(phone NFCPhone) {
function main (line 55) | func main() {
FILE: 1-basics/4_interfaces/4_cast/4_cast.go
type Wallet (line 9) | type Wallet struct
method Pay (line 13) | func (w *Wallet) Pay(amount int) error {
type Card (line 23) | type Card struct
method Pay (line 31) | func (c *Card) Pay(amount int) error {
type ApplePay (line 41) | type ApplePay struct
method Pay (line 46) | func (a *ApplePay) Pay(amount int) error {
type Payer (line 56) | type Payer interface
function Buy (line 62) | func Buy(p Payer) {
function main (line 86) | func main() {
FILE: 1-basics/4_interfaces/5_empty_1/5_empty_1.go
type Wallet (line 8) | type Wallet struct
method Pay (line 12) | func (w *Wallet) Pay(amount int) error {
method String (line 20) | func (w *Wallet) String() string {
function main (line 26) | func main() {
FILE: 1-basics/4_interfaces/6_empty_2/6_empty_2.go
type Wallet (line 10) | type Wallet struct
method Pay (line 14) | func (w *Wallet) Pay(amount int) error {
method String (line 22) | func (w *Wallet) String() string {
type Payer (line 28) | type Payer interface
function Buy (line 34) | func Buy(in interface{}) {
function main (line 53) | func main() {
FILE: 1-basics/5_visibility/main.go
function init (line 9) | func init() {
function main (line 13) | func main() {
FILE: 1-basics/5_visibility/person/func.go
function NewPerson (line 7) | func NewPerson(id int, name, secret string) *Person {
function GetSecret (line 15) | func GetSecret(p *Person) string {
function printSecret (line 19) | func printSecret(p *Person) {
FILE: 1-basics/5_visibility/person/person.go
function init (line 10) | func init() {
function init (line 14) | func init() {
type Person (line 18) | type Person struct
method UpdateSecret (line 24) | func (p Person) UpdateSecret(secret string) {
FILE: 1-basics/6_uniq/basic/main.go
function main (line 9) | func main() {
FILE: 1-basics/6_uniq/with_tests/main.go
function uniq (line 10) | func uniq(input io.Reader, output io.Writer) error {
function main (line 27) | func main() {
FILE: 1-basics/6_uniq/with_tests/main_test.go
function TestOK (line 26) | func TestOK(t *testing.T) {
function TestFail (line 39) | func TestFail(t *testing.T) {
FILE: 10-performance/1_reflect/1_print/reflect_1.go
type UserID (line 8) | type UserID
type UserID2 (line 10) | type UserID2
type User (line 12) | type User struct
function PrintReflect (line 19) | func PrintReflect(u interface{}) error {
function main (line 36) | func main() {
FILE: 10-performance/1_reflect/2_unpack/reflect_2.go
type User (line 10) | type User struct
function UnpackReflect (line 17) | func UnpackReflect(u interface{}, data []byte) error {
function main (line 56) | func main() {
FILE: 10-performance/2_codegen/gen/codegen.go
type tpl (line 17) | type tpl struct
function main (line 39) | func main() {
FILE: 10-performance/2_codegen/pack/marshaller.go
method Unpack (line 6) | func (in *User) Unpack(data []byte) error {
FILE: 10-performance/2_codegen/pack/unpack.go
type User (line 8) | type User struct
type Avatar (line 15) | type Avatar struct
function main (line 22) | func main() {
FILE: 10-performance/3_perfomance_1/1_unpack/unpack_test.go
type User (line 27) | type User struct
method UnpackBin (line 50) | func (in *User) UnpackBin(data []byte) error {
function BenchmarkCodegen (line 34) | func BenchmarkCodegen(b *testing.B) {
function BenchmarkReflect (line 42) | func BenchmarkReflect(b *testing.B) {
function UnpackReflect (line 72) | func UnpackReflect(u interface{}, data []byte) error {
FILE: 10-performance/3_perfomance_1/2_prealloc/prealloc_test.go
constant iterNum (line 8) | iterNum = 1000
function BenchmarkEmptyAppend (line 10) | func BenchmarkEmptyAppend(b *testing.B) {
function BenchmarkPreallocAppend (line 19) | func BenchmarkPreallocAppend(b *testing.B) {
FILE: 10-performance/3_perfomance_1/3_pool/pool_test.go
constant iterNum (line 10) | iterNum = 100
type PublicPage (line 12) | type PublicPage struct
function BenchmarkAllocNew (line 40) | func BenchmarkAllocNew(b *testing.B) {
function BenchmarkAllocPool (line 55) | func BenchmarkAllocPool(b *testing.B) {
FILE: 10-performance/3_perfomance_1/4_string/string_test.go
function BenchmarkRegExp (line 15) | func BenchmarkRegExp(b *testing.B) {
function BenchmarkRegCompiled (line 22) | func BenchmarkRegCompiled(b *testing.B) {
function BenchmarkStrContains (line 29) | func BenchmarkStrContains(b *testing.B) {
FILE: 10-performance/3_perfomance_1/5_json/json_test.go
function BenchmarkDecodeStandart (line 17) | func BenchmarkDecodeStandart(b *testing.B) {
function BenchmarkDecodeEasyjson (line 23) | func BenchmarkDecodeEasyjson(b *testing.B) {
function BenchmarkEncodeStandart (line 29) | func BenchmarkEncodeStandart(b *testing.B) {
function BenchmarkEncodeEasyjson (line 35) | func BenchmarkEncodeEasyjson(b *testing.B) {
FILE: 10-performance/3_perfomance_1/5_json/struct.go
type User (line 4) | type User struct
type Client (line 12) | type Client struct
FILE: 10-performance/3_perfomance_1/5_json/struct_easyjson.go
function easyjson9f2eff5fDecodeSt (line 20) | func easyjson9f2eff5fDecodeSt(in *jlexer.Lexer, out *User) {
function easyjson9f2eff5fEncodeSt (line 59) | func easyjson9f2eff5fEncodeSt(out *jwriter.Writer, in User) {
method MarshalJSON (line 97) | func (v User) MarshalJSON() ([]byte, error) {
method MarshalEasyJSON (line 104) | func (v User) MarshalEasyJSON(w *jwriter.Writer) {
method UnmarshalJSON (line 109) | func (v *User) UnmarshalJSON(data []byte) error {
method UnmarshalEasyJSON (line 116) | func (v *User) UnmarshalEasyJSON(l *jlexer.Lexer) {
FILE: 10-performance/4_perfomance_2/1_optimize/pprof_1.go
type Post (line 12) | type Post struct
function handleSlow (line 20) | func handleSlow(w http.ResponseWriter, req *http.Request) {
function main (line 29) | func main() {
function handleFast (line 66) | func handleFast(w http.ResponseWriter, req *http.Request) {
FILE: 10-performance/4_perfomance_2/2_leak_grtn/pprof_2.go
type Post (line 10) | type Post struct
function getPost (line 18) | func getPost(out chan []Post) {
function longHeavyWork (line 27) | func longHeavyWork(ch chan bool) {
function handleLeak (line 32) | func handleLeak(w http.ResponseWriter, req *http.Request) {
function main (line 39) | func main() {
FILE: 10-performance/4_perfomance_2/3_tracing/tracing.go
type Post (line 12) | type Post struct
function handle (line 20) | func handle(w http.ResponseWriter, req *http.Request) {
function main (line 31) | func main() {
FILE: 10-performance/5_testing/coverage_test.go
type TestCase (line 8) | type TestCase struct
function TestGetUser (line 14) | func TestGetUser(t *testing.T) {
FILE: 10-performance/5_testing/main.go
type User (line 8) | type User struct
function GetUser (line 17) | func GetUser(key string) (*User, error) {
FILE: 10-performance/6_xml_stream/main.go
type User (line 10) | type User struct
type Users (line 17) | type Users struct
function CountStruct (line 60) | func CountStruct() {
function CountDecoder (line 73) | func CountDecoder() {
function main (line 105) | func main() {
FILE: 10-performance/6_xml_stream/xml_test.go
function BenchmarkCountStruct (line 7) | func BenchmarkCountStruct(b *testing.B) {
function BenchmarkCountDecoder (line 13) | func BenchmarkCountDecoder(b *testing.B) {
FILE: 10-performance/7_inline_escape/main.go
type User (line 12) | type User struct
method GetID (line 17) | func (u *User) GetID() int {
function newUser (line 21) | func newUser(login string) *User {
function setToZero (line 25) | func setToZero(in *int) {
function main (line 32) | func main() {
FILE: 10-performance/8_cgo/1_example/main.go
function main (line 9) | func main() {
FILE: 10-performance/8_cgo/2_performance/main.go
function factorialCGo (line 20) | func factorialCGo(n int64) int64 {
function factorialGo (line 24) | func factorialGo(n int64) *big.Int {
function main (line 32) | func main() {
FILE: 10-performance/8_cgo/3_usage/main.go
function init (line 19) | func init() {
function main (line 30) | func main() {
function renderPage (line 39) | func renderPage(filePath string, page int, output string) error {
FILE: 2-async/0_basic_error_handling/1_ignore_errors/main.go
function main (line 13) | func main() {
FILE: 2-async/0_basic_error_handling/2_panic/main.go
function main (line 13) | func main() {
FILE: 2-async/0_basic_error_handling/3_handling/main.go
function handling (line 13) | func handling() error {
function main (line 30) | func main() {
FILE: 2-async/0_basic_error_handling/4_return/main.go
type MyError (line 8) | type MyError struct
method Error (line 12) | func (e MyError) Error() string {
function bad (line 16) | func bad() error {
function main (line 22) | func main() {
FILE: 2-async/1_async/10_context_cancel/context_cancel.go
function student (line 10) | func student(ctx context.Context, workerNum int, out chan<- int) {
function main (line 23) | func main() {
FILE: 2-async/1_async/10_context_timeout/context_parent/main.go
function worker (line 9) | func worker(ctx context.Context, name string) {
function main (line 20) | func main() {
FILE: 2-async/1_async/10_context_timeout/context_timeout.go
function worker (line 10) | func worker(ctx context.Context, workerNum int, out chan<- int) {
function main (line 23) | func main() {
FILE: 2-async/1_async/11_errgroup_1/errgroup_1.go
constant goroutinesNum (line 11) | goroutinesNum = 3
constant badGorutineNum (line 12) | badGorutineNum = 2
function printGorutineNum (line 15) | func printGorutineNum(num int) error {
function main (line 27) | func main() {
FILE: 2-async/1_async/11_errgroup_2/errgroup_2.go
constant goroutinesNum (line 11) | goroutinesNum = 3
constant badGorutineNum (line 12) | badGorutineNum = 2
function printGorutineNum (line 15) | func printGorutineNum(ctx context.Context, num int) error {
function main (line 34) | func main() {
FILE: 2-async/1_async/12_atomic_1/atomic_1.go
function inc (line 12) | func inc() {
function main (line 20) | func main() {
FILE: 2-async/1_async/12_atomic_2/atomic_2.go
function inc (line 11) | func inc() {
function main (line 15) | func main() {
FILE: 2-async/1_async/12_atomic_2/with_bench/mutex_test.go
function BenchmarkMutexParallel (line 15) | func BenchmarkMutexParallel(b *testing.B) {
function BenchmarkAtomicParallel (line 25) | func BenchmarkAtomicParallel(b *testing.B) {
function BenchmarkLocalCounter (line 33) | func BenchmarkLocalCounter(b *testing.B) {
FILE: 2-async/1_async/13_ratelim/ratelim.go
constant iterationsNum (line 12) | iterationsNum = 6
constant goroutinesNum (line 13) | goroutinesNum = 5
constant quotaLimit (line 14) | quotaLimit = 2
function startWorker (line 17) | func startWorker(in int, wg *sync.WaitGroup, quotaCh chan struct{}) {
function main (line 37) | func main() {
function formatWork (line 48) | func formatWork(in, j int) string {
FILE: 2-async/1_async/14_once/once.go
function Init (line 8) | func Init() {
function init (line 12) | func init() {
function main (line 16) | func main() {
FILE: 2-async/1_async/1_goroutines/goroutines.go
constant goroutinesNum (line 8) | goroutinesNum = 7
function main (line 10) | func main() {
FILE: 2-async/1_async/1_goroutines/i_ptr/main.go
constant goroutinesNum (line 7) | goroutinesNum = 7
function main (line 9) | func main() {
FILE: 2-async/1_async/1_goroutines/mem/main.go
function main (line 9) | func main() {
FILE: 2-async/1_async/1_goroutines_2/goroutines.go
constant iterationsNum (line 10) | iterationsNum = 6
constant goroutinesNum (line 11) | goroutinesNum = 6
function doWork (line 14) | func doWork(th int) {
function main (line 24) | func main() {
function formatWork (line 33) | func formatWork(in, j int) string {
FILE: 2-async/1_async/2_chan/chan_1.go
function main (line 7) | func main() {
FILE: 2-async/1_async/2_chan_2/chan_2.go
function main (line 8) | func main() {
FILE: 2-async/1_async/3_workerpool/1_workerpool.go
constant goroutinesNum (line 10) | goroutinesNum = 3
function startWorker (line 12) | func startWorker(workerNum int, in <-chan string) {
function formatWork (line 20) | func formatWork(in int, input string) string {
function printFinishWork (line 27) | func printFinishWork(in int) {
function main (line 34) | func main() {
FILE: 2-async/1_async/3_workerpool/2_workerpool_reusable.go
type workerPool (line 3) | type workerPool struct
method work (line 18) | func (wp workerPool) work() {
method PutTask (line 30) | func (wp workerPool) PutTask(task func()) {
function NewWorkerPool (line 8) | func NewWorkerPool(maxWorkers int) workerPool {
FILE: 2-async/1_async/4_race_1/race_1.go
function main (line 5) | func main() {
FILE: 2-async/1_async/4_race_2/race_2.go
function main (line 8) | func main() {
FILE: 2-async/1_async/4_race_2/race_flag/working_race.go
function main (line 9) | func main() {
FILE: 2-async/1_async/4_race_3/race_3.go
function main (line 11) | func main() {
FILE: 2-async/1_async/4_race_3_bench/race_test.go
function BenchmarkMapWithRWMutex (line 8) | func BenchmarkMapWithRWMutex(b *testing.B) {
function BenchmarkMapWithMutex (line 34) | func BenchmarkMapWithMutex(b *testing.B) {
FILE: 2-async/1_async/5_tick/tick.go
function main (line 8) | func main() {
FILE: 2-async/1_async/5_tick_example/5_ping_pong/main.go
function main (line 7) | func main() {
FILE: 2-async/1_async/5_tick_example/main.go
function main (line 8) | func main() {
FILE: 2-async/1_async/6_afterfunc/afterfunc.go
function sayHello (line 8) | func sayHello() {
function main (line 12) | func main() {
FILE: 2-async/1_async/7_select_1/select_1.go
function main (line 7) | func main() {
FILE: 2-async/1_async/7_select_2/select_2.go
function main (line 7) | func main() {
FILE: 2-async/1_async/7_select_2_new/close_buff/main.go
function main (line 7) | func main() {
FILE: 2-async/1_async/7_select_2_new/select_2_new.go
function main (line 9) | func main() {
FILE: 2-async/1_async/7_select_3/close_all/main.go
function worker (line 8) | func worker(id int, cancelCh chan struct{}) {
function main (line 22) | func main() {
FILE: 2-async/1_async/7_select_3/close_signal/main.go
function worker (line 11) | func worker(id int, done <-chan struct{}) {
function main (line 24) | func main() {
FILE: 2-async/1_async/7_select_3/select_3.go
function main (line 7) | func main() {
FILE: 2-async/1_async/8_wait_1/wait_1.go
function main (line 8) | func main() {
FILE: 2-async/1_async/8_wait_2/ping_pong/main.go
function main (line 9) | func main() {
FILE: 2-async/1_async/8_wait_2/wait_2.go
constant iterationsNum (line 11) | iterationsNum = 7
constant goroutinesNum (line 12) | goroutinesNum = 5
function doWork (line 15) | func doWork(in int, wg *sync.WaitGroup) {
function main (line 23) | func main() {
function formatWork (line 35) | func formatWork(in, j int) string {
FILE: 2-async/1_async/8_wait_3/wait_3.go
constant iterationsNum (line 12) | iterationsNum = 7
constant goroutinesNum (line 13) | goroutinesNum = 5
function doWork (line 16) | func doWork(in int) {
function main (line 23) | func main() {
function formatWork (line 34) | func formatWork(in, j int) string {
FILE: 2-async/1_async/9_timeout/timeout.go
function longSQLQuery (line 8) | func longSQLQuery() chan bool {
function main (line 17) | func main() {
FILE: 3-web/0_json/0_simple_json/simple_json.go
type User (line 8) | type User struct
function main (line 16) | func main() {
FILE: 3-web/0_json/1_struct_tags/struct_tags.go
type User (line 8) | type User struct
function main (line 15) | func main() {
FILE: 3-web/0_json/2_custom/custom.go
type Company (line 10) | type Company
method MarshalJSON (line 13) | func (c Company) MarshalJSON() ([]byte, error) {
method UnmarshalJSON (line 18) | func (c *Company) UnmarshalJSON(data []byte) error {
type User (line 28) | type User struct
method MarshalJSON (line 36) | func (u *User) MarshalJSON() ([]byte, error) {
method UnmarshalJSON (line 49) | func (u *User) UnmarshalJSON(data []byte) error {
function main (line 70) | func main() {
FILE: 3-web/0_json/3_dynamic/dynamic.go
function main (line 15) | func main() {
FILE: 3-web/1_net/net_listen.go
function handleConnection (line 9) | func handleConnection(conn net.Conn) {
function main (line 31) | func main() {
FILE: 3-web/2_http/0_http_server/0_basic/basic.go
function handler (line 8) | func handler(w http.ResponseWriter, r *http.Request) {
function main (line 14) | func main() {
FILE: 3-web/2_http/0_http_server/1_pages/pages.go
function handler (line 8) | func handler(w http.ResponseWriter, r *http.Request) {
function main (line 12) | func main() {
FILE: 3-web/2_http/0_http_server/2_servehttp/servehttp.go
type Handler (line 8) | type Handler struct
method ServeHTTP (line 12) | func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
function main (line 16) | func main() {
FILE: 3-web/2_http/0_http_server/3_mux/mux.go
function handler (line 9) | func handler(w http.ResponseWriter, r *http.Request) {
function main (line 13) | func main() {
FILE: 3-web/2_http/0_http_server/4_servers/servers.go
function runServer (line 8) | func runServer(addr string) {
function main (line 24) | func main() {
FILE: 3-web/2_http/1_request/0_get/get.go
function handler (line 8) | func handler(w http.ResponseWriter, r *http.Request) {
function main (line 14) | func main() {
FILE: 3-web/2_http/1_request/1_post/post.go
function mainPage (line 20) | func mainPage(w http.ResponseWriter, r *http.Request) {
function main (line 33) | func main() {
FILE: 3-web/2_http/1_request/2_cookies/cookies.go
function mainPage (line 9) | func mainPage(w http.ResponseWriter, r *http.Request) {
function loginPage (line 22) | func loginPage(w http.ResponseWriter, r *http.Request) {
function logoutPage (line 34) | func logoutPage(w http.ResponseWriter, r *http.Request) {
function main (line 47) | func main() {
FILE: 3-web/2_http/1_request/3_headers/headers.go
function handler (line 8) | func handler(w http.ResponseWriter, r *http.Request) {
function main (line 15) | func main() {
FILE: 3-web/2_http/2_http_client/client.go
function startServer (line 14) | func startServer() {
function runGet (line 34) | func runGet() {
function runGetFullReq (line 48) | func runGetFullReq() {
function runTransportAndPost (line 72) | func runTransportAndPost() {
function main (line 110) | func main() {
FILE: 3-web/2_http/3_files/0_file_upload/file_upload.go
function mainPage (line 22) | func mainPage(w http.ResponseWriter, r *http.Request) {
function uploadPage (line 26) | func uploadPage(w http.ResponseWriter, r *http.Request) {
type Params (line 44) | type Params struct
function uploadRawBody (line 53) | func uploadRawBody(w http.ResponseWriter, r *http.Request) {
function main (line 70) | func main() {
FILE: 3-web/2_http/3_files/1_static/static.go
function handler (line 8) | func handler(w http.ResponseWriter, r *http.Request) {
function main (line 16) | func main() {
FILE: 3-web/2_http/4_httptest/0_client/client_test.go
type TestCase (line 10) | type TestCase struct
function GetUser (line 16) | func GetUser(w http.ResponseWriter, r *http.Request) {
function TestGetUser (line 27) | func TestGetUser(t *testing.T) {
FILE: 3-web/2_http/4_httptest/1_server/server_test.go
type TestCase (line 12) | type TestCase struct
type CheckoutResult (line 18) | type CheckoutResult struct
function CheckoutDummy (line 24) | func CheckoutDummy(w http.ResponseWriter, r *http.Request) {
type Cart (line 43) | type Cart struct
method Checkout (line 47) | func (c *Cart) Checkout(id string) (*CheckoutResult, error) {
function TestCartCheckout (line 69) | func TestCartCheckout(t *testing.T) {
FILE: 3-web/3_template/0_inline/inline.go
type tplParams (line 9) | type tplParams struct
constant EXAMPLE (line 14) | EXAMPLE = `
function handle (line 20) | func handle(w http.ResponseWriter, r *http.Request) {
function main (line 32) | func main() {
FILE: 3-web/3_template/1_file/file.go
type User (line 9) | type User struct
function main (line 15) | func main() {
FILE: 3-web/3_template/2_func/func.go
type User (line 9) | type User struct
function IsUserOdd (line 15) | func IsUserOdd(u *User) bool {
function main (line 19) | func main() {
FILE: 3-web/3_template/3_method/method.go
type User (line 9) | type User struct
method PrintActive (line 15) | func (u *User) PrintActive() string {
function main (line 22) | func main() {
FILE: 3-web/4_json_http/main.go
type UserInput (line 11) | type UserInput struct
type User (line 16) | type User struct
type Handlers (line 22) | type Handlers struct
method HandleCreateUser (line 27) | func (h *Handlers) HandleCreateUser(w http.ResponseWriter, r *http.Req...
method HandleListUsers (line 56) | func (h *Handlers) HandleListUsers(w http.ResponseWriter, r *http.Requ...
function main (line 68) | func main() {
FILE: 3-web/4_json_http/main_test.go
function TestCreateUsers (line 14) | func TestCreateUsers(t *testing.T) {
function TestGetUsers (line 46) | func TestGetUsers(t *testing.T) {
FILE: 4-api/1_rpc/jsonrpc/books.go
type Book (line 8) | type Book struct
type BookStore (line 14) | type BookStore struct
method AddBook (line 26) | func (bs *BookStore) AddBook(in *Book, out *Book) error {
method GetBooks (line 36) | func (bs *BookStore) GetBooks(in int, out *[]*Book) error {
function NewBookStore (line 19) | func NewBookStore() *BookStore {
FILE: 4-api/1_rpc/jsonrpc/server.go
type HttpConn (line 12) | type HttpConn struct
method Read (line 17) | func (c *HttpConn) Read(p []byte) (n int, err error) { return c.in.Re...
method Write (line 18) | func (c *HttpConn) Write(d []byte) (n int, err error) { return c.out.W...
method Close (line 19) | func (c *HttpConn) Close() error { return nil }
type Handler (line 43) | type Handler struct
method ServeHTTP (line 47) | func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
function main (line 64) | func main() {
FILE: 4-api/1_rpc/main.go
function login (line 8) | func login(w http.ResponseWriter, r *http.Request) {
function signup (line 13) | func signup(w http.ResponseWriter, r *http.Request) {
function main (line 18) | func main() {
FILE: 4-api/1_rpc/net-rpc/books.go
type Book (line 8) | type Book struct
type BookStore (line 14) | type BookStore struct
method AddBook (line 26) | func (bs *BookStore) AddBook(in *Book, out *Book) error {
method GetBooks (line 36) | func (bs *BookStore) GetBooks(in int, out *[]*Book) error {
function NewBookStore (line 19) | func NewBookStore() *BookStore {
FILE: 4-api/1_rpc/net-rpc/client.go
function main (line 8) | func main() {
FILE: 4-api/1_rpc/net-rpc/server.go
function main (line 11) | func main() {
FILE: 4-api/2_rest/books.go
type Book (line 8) | type Book struct
type BookStore (line 14) | type BookStore struct
method AddBook (line 27) | func (bs *BookStore) AddBook(in *Book) (uint, error) {
method GetBooks (line 40) | func (bs *BookStore) GetBooks() ([]*Book, error) {
function NewBookStore (line 20) | func NewBookStore() *BookStore {
FILE: 4-api/2_rest/main.go
type Result (line 12) | type Result struct
type BooksHandler (line 17) | type BooksHandler struct
method List (line 21) | func (api *BooksHandler) List(w http.ResponseWriter, r *http.Request) {
method Add (line 37) | func (api *BooksHandler) Add(w http.ResponseWriter, r *http.Request) {
method BookByID (line 57) | func (api *BooksHandler) BookByID(w http.ResponseWriter, r *http.Reque...
function main (line 89) | func main() {
FILE: 4-api/3_graphql/gqlgen/generated.go
function NewExecutableSchema (line 22) | func NewExecutableSchema(cfg Config) graphql.ExecutableSchema {
type Config (line 30) | type Config struct
type ResolverRoot (line 36) | type ResolverRoot interface
type DirectiveRoot (line 40) | type DirectiveRoot struct
type ComplexityRoot (line 43) | type ComplexityRoot struct
type QueryResolver (line 60) | type QueryResolver interface
type executableSchema (line 64) | type executableSchema struct
method Schema (line 70) | func (e *executableSchema) Schema() *ast.Schema {
method Complexity (line 74) | func (e *executableSchema) Complexity(typeName, field string, childCom...
method Query (line 125) | func (e *executableSchema) Query(ctx context.Context, op *ast.Operatio...
method Mutation (line 142) | func (e *executableSchema) Mutation(ctx context.Context, op *ast.Opera...
method Subscription (line 146) | func (e *executableSchema) Subscription(ctx context.Context, op *ast.O...
type executionContext (line 150) | type executionContext struct
method introspectSchema (line 155) | func (ec *executionContext) introspectSchema() (*introspection.Schema,...
method introspectType (line 162) | func (ec *executionContext) introspectType(name string) (*introspectio...
method field_Query___type_args (line 191) | func (ec *executionContext) field_Query___type_args(ctx context.Contex...
method field___Type_enumValues_args (line 205) | func (ec *executionContext) field___Type_enumValues_args(ctx context.C...
method field___Type_fields_args (line 219) | func (ec *executionContext) field___Type_fields_args(ctx context.Conte...
method _Author_name (line 241) | func (ec *executionContext) _Author_name(ctx context.Context, field gr...
method _Book_id (line 278) | func (ec *executionContext) _Book_id(ctx context.Context, field graphq...
method _Book_title (line 315) | func (ec *executionContext) _Book_title(ctx context.Context, field gra...
method _Book_price (line 352) | func (ec *executionContext) _Book_price(ctx context.Context, field gra...
method _Book_author (line 389) | func (ec *executionContext) _Book_author(ctx context.Context, field gr...
method _Query_books (line 423) | func (ec *executionContext) _Query_books(ctx context.Context, field gr...
method _Query___type (line 460) | func (ec *executionContext) _Query___type(ctx context.Context, field g...
method _Query___schema (line 501) | func (ec *executionContext) _Query___schema(ctx context.Context, field...
method ___Directive_name (line 535) | func (ec *executionContext) ___Directive_name(ctx context.Context, fie...
method ___Directive_description (line 572) | func (ec *executionContext) ___Directive_description(ctx context.Conte...
method ___Directive_locations (line 606) | func (ec *executionContext) ___Directive_locations(ctx context.Context...
method ___Directive_args (line 643) | func (ec *executionContext) ___Directive_args(ctx context.Context, fie...
method ___EnumValue_name (line 680) | func (ec *executionContext) ___EnumValue_name(ctx context.Context, fie...
method ___EnumValue_description (line 717) | func (ec *executionContext) ___EnumValue_description(ctx context.Conte...
method ___EnumValue_isDeprecated (line 751) | func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Cont...
method ___EnumValue_deprecationReason (line 788) | func (ec *executionContext) ___EnumValue_deprecationReason(ctx context...
method ___Field_name (line 822) | func (ec *executionContext) ___Field_name(ctx context.Context, field g...
method ___Field_description (line 859) | func (ec *executionContext) ___Field_description(ctx context.Context, ...
method ___Field_args (line 893) | func (ec *executionContext) ___Field_args(ctx context.Context, field g...
method ___Field_type (line 930) | func (ec *executionContext) ___Field_type(ctx context.Context, field g...
method ___Field_isDeprecated (line 967) | func (ec *executionContext) ___Field_isDeprecated(ctx context.Context,...
method ___Field_deprecationReason (line 1004) | func (ec *executionContext) ___Field_deprecationReason(ctx context.Con...
method ___InputValue_name (line 1038) | func (ec *executionContext) ___InputValue_name(ctx context.Context, fi...
method ___InputValue_description (line 1075) | func (ec *executionContext) ___InputValue_description(ctx context.Cont...
method ___InputValue_type (line 1109) | func (ec *executionContext) ___InputValue_type(ctx context.Context, fi...
method ___InputValue_defaultValue (line 1146) | func (ec *executionContext) ___InputValue_defaultValue(ctx context.Con...
method ___Schema_types (line 1180) | func (ec *executionContext) ___Schema_types(ctx context.Context, field...
method ___Schema_queryType (line 1217) | func (ec *executionContext) ___Schema_queryType(ctx context.Context, f...
method ___Schema_mutationType (line 1254) | func (ec *executionContext) ___Schema_mutationType(ctx context.Context...
method ___Schema_subscriptionType (line 1288) | func (ec *executionContext) ___Schema_subscriptionType(ctx context.Con...
method ___Schema_directives (line 1322) | func (ec *executionContext) ___Schema_directives(ctx context.Context, ...
method ___Type_kind (line 1359) | func (ec *executionContext) ___Type_kind(ctx context.Context, field gr...
method ___Type_name (line 1396) | func (ec *executionContext) ___Type_name(ctx context.Context, field gr...
method ___Type_description (line 1430) | func (ec *executionContext) ___Type_description(ctx context.Context, f...
method ___Type_fields (line 1464) | func (ec *executionContext) ___Type_fields(ctx context.Context, field ...
method ___Type_interfaces (line 1505) | func (ec *executionContext) ___Type_interfaces(ctx context.Context, fi...
method ___Type_possibleTypes (line 1539) | func (ec *executionContext) ___Type_possibleTypes(ctx context.Context,...
method ___Type_enumValues (line 1573) | func (ec *executionContext) ___Type_enumValues(ctx context.Context, fi...
method ___Type_inputFields (line 1614) | func (ec *executionContext) ___Type_inputFields(ctx context.Context, f...
method ___Type_ofType (line 1648) | func (ec *executionContext) ___Type_ofType(ctx context.Context, field ...
method _Author (line 1696) | func (ec *executionContext) _Author(ctx context.Context, sel ast.Selec...
method _Book (line 1723) | func (ec *executionContext) _Book(ctx context.Context, sel ast.Selecti...
method _Query (line 1762) | func (ec *executionContext) _Query(ctx context.Context, sel ast.Select...
method ___Directive (line 1806) | func (ec *executionContext) ___Directive(ctx context.Context, sel ast....
method ___EnumValue (line 1845) | func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast....
method ___Field (line 1881) | func (ec *executionContext) ___Field(ctx context.Context, sel ast.Sele...
method ___InputValue (line 1927) | func (ec *executionContext) ___InputValue(ctx context.Context, sel ast...
method ___Schema (line 1963) | func (ec *executionContext) ___Schema(ctx context.Context, sel ast.Sel...
method ___Type (line 2004) | func (ec *executionContext) ___Type(ctx context.Context, sel ast.Selec...
method marshalNBook2githubᚗcomᚋgoᚑparkᚑmailᚑruᚋlecturesᚋ4ᚋ3_graphqlᚋgqlgenᚐBook (line 2049) | func (ec *executionContext) marshalNBook2githubᚗcomᚋgoᚑparkᚑmailᚑruᚋle...
method marshalNBook2ᚕᚖgithubᚗcomᚋgoᚑparkᚑmailᚑruᚋlecturesᚋ4ᚋ3_graphqlᚋgqlgenᚐBook (line 2053) | func (ec *executionContext) marshalNBook2ᚕᚖgithubᚗcomᚋgoᚑparkᚑmailᚑruᚋ...
method marshalNBook2ᚖgithubᚗcomᚋgoᚑparkᚑmailᚑruᚋlecturesᚋ4ᚋ3_graphqlᚋgqlgenᚐBook (line 2090) | func (ec *executionContext) marshalNBook2ᚖgithubᚗcomᚋgoᚑparkᚑmailᚑruᚋl...
method unmarshalNBoolean2bool (line 2100) | func (ec *executionContext) unmarshalNBoolean2bool(ctx context.Context...
method marshalNBoolean2bool (line 2104) | func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, ...
method unmarshalNFloat2float64 (line 2114) | func (ec *executionContext) unmarshalNFloat2float64(ctx context.Contex...
method marshalNFloat2float64 (line 2118) | func (ec *executionContext) marshalNFloat2float64(ctx context.Context,...
method unmarshalNID2string (line 2128) | func (ec *executionContext) unmarshalNID2string(ctx context.Context, v...
method marshalNID2string (line 2132) | func (ec *executionContext) marshalNID2string(ctx context.Context, sel...
method unmarshalNString2string (line 2142) | func (ec *executionContext) unmarshalNString2string(ctx context.Contex...
method marshalNString2string (line 2146) | func (ec *executionContext) marshalNString2string(ctx context.Context,...
method marshalN__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective (line 2156) | func (ec *executionContext) marshalN__Directive2githubᚗcomᚋ99designsᚋg...
method marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective (line 2160) | func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋ...
method unmarshalN__DirectiveLocation2string (line 2197) | func (ec *executionContext) unmarshalN__DirectiveLocation2string(ctx c...
method marshalN__DirectiveLocation2string (line 2201) | func (ec *executionContext) marshalN__DirectiveLocation2string(ctx con...
method unmarshalN__DirectiveLocation2ᚕstring (line 2211) | func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstring(ctx ...
method marshalN__DirectiveLocation2ᚕstring (line 2231) | func (ec *executionContext) marshalN__DirectiveLocation2ᚕstring(ctx co...
method marshalN__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue (line 2268) | func (ec *executionContext) marshalN__EnumValue2githubᚗcomᚋ99designsᚋg...
method marshalN__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField (line 2272) | func (ec *executionContext) marshalN__Field2githubᚗcomᚋ99designsᚋgqlge...
method marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue (line 2276) | func (ec *executionContext) marshalN__InputValue2githubᚗcomᚋ99designsᚋ...
method marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue (line 2280) | func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designs...
method marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType (line 2317) | func (ec *executionContext) marshalN__Type2githubᚗcomᚋ99designsᚋgqlgen...
method marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType (line 2321) | func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlge...
method marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType (line 2358) | func (ec *executionContext) marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlge...
method unmarshalN__TypeKind2string (line 2368) | func (ec *executionContext) unmarshalN__TypeKind2string(ctx context.Co...
method marshalN__TypeKind2string (line 2372) | func (ec *executionContext) marshalN__TypeKind2string(ctx context.Cont...
method marshalOAuthor2githubᚗcomᚋgoᚑparkᚑmailᚑruᚋlecturesᚋ4ᚋ3_graphqlᚋgqlgenᚐAuthor (line 2382) | func (ec *executionContext) marshalOAuthor2githubᚗcomᚋgoᚑparkᚑmailᚑruᚋ...
method marshalOAuthor2ᚖgithubᚗcomᚋgoᚑparkᚑmailᚑruᚋlecturesᚋ4ᚋ3_graphqlᚋgqlgenᚐAuthor (line 2386) | func (ec *executionContext) marshalOAuthor2ᚖgithubᚗcomᚋgoᚑparkᚑmailᚑru...
method unmarshalOBoolean2bool (line 2393) | func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context...
method marshalOBoolean2bool (line 2397) | func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, ...
method unmarshalOBoolean2ᚖbool (line 2401) | func (ec *executionContext) unmarshalOBoolean2ᚖbool(ctx context.Contex...
method marshalOBoolean2ᚖbool (line 2409) | func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context,...
method unmarshalOString2string (line 2416) | func (ec *executionContext) unmarshalOString2string(ctx context.Contex...
method marshalOString2string (line 2420) | func (ec *executionContext) marshalOString2string(ctx context.Context,...
method unmarshalOString2ᚖstring (line 2424) | func (ec *executionContext) unmarshalOString2ᚖstring(ctx context.Conte...
method marshalOString2ᚖstring (line 2432) | func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context...
method marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue (line 2439) | func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋ...
method marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField (line 2479) | func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlg...
method marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue (line 2519) | func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designs...
method marshalO__Schema2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema (line 2559) | func (ec *executionContext) marshalO__Schema2githubᚗcomᚋ99designsᚋgqlg...
method marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema (line 2563) | func (ec *executionContext) marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgql...
method marshalO__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType (line 2570) | func (ec *executionContext) marshalO__Type2githubᚗcomᚋ99designsᚋgqlgen...
method marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType (line 2574) | func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlge...
method marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType (line 2614) | func (ec *executionContext) marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlge...
FILE: 4-api/3_graphql/gqlgen/models_gen.go
type Author (line 5) | type Author struct
type Book (line 9) | type Book struct
FILE: 4-api/3_graphql/gqlgen/resolver.go
type Resolver (line 7) | type Resolver struct
method Query (line 9) | func (r *Resolver) Query() QueryResolver {
type queryResolver (line 13) | type queryResolver struct
method Books (line 15) | func (r *queryResolver) Books(ctx context.Context) ([]*Book, error) {
FILE: 4-api/3_graphql/gqlgen/server/server.go
constant defaultPort (line 13) | defaultPort = "8080"
function main (line 15) | func main() {
FILE: 4-api/3_graphql/gqlgen_full/gqlgen1/generated.go
function NewExecutableSchema (line 22) | func NewExecutableSchema(cfg Config) graphql.ExecutableSchema {
type Config (line 30) | type Config struct
type ResolverRoot (line 36) | type ResolverRoot interface
type DirectiveRoot (line 41) | type DirectiveRoot struct
type ComplexityRoot (line 44) | type ComplexityRoot struct
type MutationResolver (line 72) | type MutationResolver interface
type QueryResolver (line 75) | type QueryResolver interface
type executableSchema (line 81) | type executableSchema struct
method Schema (line 87) | func (e *executableSchema) Schema() *ast.Schema {
method Complexity (line 91) | func (e *executableSchema) Complexity(typeName, field string, childCom...
method Exec (line 213) | func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseH...
type executionContext (line 253) | type executionContext struct
method introspectSchema (line 258) | func (ec *executionContext) introspectSchema() (*introspection.Schema,...
method introspectType (line 265) | func (ec *executionContext) introspectType(name string) (*introspectio...
method field_Mutation_ratePhoto_args (line 316) | func (ec *executionContext) field_Mutation_ratePhoto_args(ctx context....
method field_Query___type_args (line 338) | func (ec *executionContext) field_Query___type_args(ctx context.Contex...
method field_Query_photos_args (line 352) | func (ec *executionContext) field_Query_photos_args(ctx context.Contex...
method field_Query_user_args (line 366) | func (ec *executionContext) field_Query_user_args(ctx context.Context,...
method field___Type_enumValues_args (line 380) | func (ec *executionContext) field___Type_enumValues_args(ctx context.C...
method field___Type_fields_args (line 394) | func (ec *executionContext) field___Type_fields_args(ctx context.Conte...
method _Mutation_ratePhoto (line 416) | func (ec *executionContext) _Mutation_ratePhoto(ctx context.Context, f...
method _Photo_id (line 457) | func (ec *executionContext) _Photo_id(ctx context.Context, field graph...
method _Photo_user (line 491) | func (ec *executionContext) _Photo_user(ctx context.Context, field gra...
method _Photo_url (line 525) | func (ec *executionContext) _Photo_url(ctx context.Context, field grap...
method _Photo_comment (line 559) | func (ec *executionContext) _Photo_comment(ctx context.Context, field ...
method _Photo_rating (line 593) | func (ec *executionContext) _Photo_rating(ctx context.Context, field g...
method _Photo_liked (line 627) | func (ec *executionContext) _Photo_liked(ctx context.Context, field gr...
method _Photo_followed (line 661) | func (ec *executionContext) _Photo_followed(ctx context.Context, field...
method _Query_timeline (line 695) | func (ec *executionContext) _Query_timeline(ctx context.Context, field...
method _Query_user (line 729) | func (ec *executionContext) _Query_user(ctx context.Context, field gra...
method _Query_photos (line 770) | func (ec *executionContext) _Query_photos(ctx context.Context, field g...
method _Query___type (line 811) | func (ec *executionContext) _Query___type(ctx context.Context, field g...
method _Query___schema (line 849) | func (ec *executionContext) _Query___schema(ctx context.Context, field...
method _User_id (line 880) | func (ec *executionContext) _User_id(ctx context.Context, field graphq...
method _User_name (line 914) | func (ec *executionContext) _User_name(ctx context.Context, field grap...
method _User_avatar (line 948) | func (ec *executionContext) _User_avatar(ctx context.Context, field gr...
method ___Directive_name (line 982) | func (ec *executionContext) ___Directive_name(ctx context.Context, fie...
method ___Directive_description (line 1016) | func (ec *executionContext) ___Directive_description(ctx context.Conte...
method ___Directive_locations (line 1047) | func (ec *executionContext) ___Directive_locations(ctx context.Context...
method ___Directive_args (line 1081) | func (ec *executionContext) ___Directive_args(ctx context.Context, fie...
method ___EnumValue_name (line 1115) | func (ec *executionContext) ___EnumValue_name(ctx context.Context, fie...
method ___EnumValue_description (line 1149) | func (ec *executionContext) ___EnumValue_description(ctx context.Conte...
method ___EnumValue_isDeprecated (line 1180) | func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Cont...
method ___EnumValue_deprecationReason (line 1214) | func (ec *executionContext) ___EnumValue_deprecationReason(ctx context...
method ___Field_name (line 1245) | func (ec *executionContext) ___Field_name(ctx context.Context, field g...
method ___Field_description (line 1279) | func (ec *executionContext) ___Field_description(ctx context.Context, ...
method ___Field_args (line 1310) | func (ec *executionContext) ___Field_args(ctx context.Context, field g...
method ___Field_type (line 1344) | func (ec *executionContext) ___Field_type(ctx context.Context, field g...
method ___Field_isDeprecated (line 1378) | func (ec *executionContext) ___Field_isDeprecated(ctx context.Context,...
method ___Field_deprecationReason (line 1412) | func (ec *executionContext) ___Field_deprecationReason(ctx context.Con...
method ___InputValue_name (line 1443) | func (ec *executionContext) ___InputValue_name(ctx context.Context, fi...
method ___InputValue_description (line 1477) | func (ec *executionContext) ___InputValue_description(ctx context.Cont...
method ___InputValue_type (line 1508) | func (ec *executionContext) ___InputValue_type(ctx context.Context, fi...
method ___InputValue_defaultValue (line 1542) | func (ec *executionContext) ___InputValue_defaultValue(ctx context.Con...
method ___Schema_types (line 1573) | func (ec *executionContext) ___Schema_types(ctx context.Context, field...
method ___Schema_queryType (line 1607) | func (ec *executionContext) ___Schema_queryType(ctx context.Context, f...
method ___Schema_mutationType (line 1641) | func (ec *executionContext) ___Schema_mutationType(ctx context.Context...
method ___Schema_subscriptionType (line 1672) | func (ec *executionContext) ___Schema_subscriptionType(ctx context.Con...
method ___Schema_directives (line 1703) | func (ec *executionContext) ___Schema_directives(ctx context.Context, ...
method ___Type_kind (line 1737) | func (ec *executionContext) ___Type_kind(ctx context.Context, field gr...
method ___Type_name (line 1771) | func (ec *executionContext) ___Type_name(ctx context.Context, field gr...
method ___Type_description (line 1802) | func (ec *executionContext) ___Type_description(ctx context.Context, f...
method ___Type_fields (line 1833) | func (ec *executionContext) ___Type_fields(ctx context.Context, field ...
method ___Type_interfaces (line 1871) | func (ec *executionContext) ___Type_interfaces(ctx context.Context, fi...
method ___Type_possibleTypes (line 1902) | func (ec *executionContext) ___Type_possibleTypes(ctx context.Context,...
method ___Type_enumValues (line 1933) | func (ec *executionContext) ___Type_enumValues(ctx context.Context, fi...
method ___Type_inputFields (line 1971) | func (ec *executionContext) ___Type_inputFields(ctx context.Context, f...
method ___Type_ofType (line 2002) | func (ec *executionContext) ___Type_ofType(ctx context.Context, field ...
method _Mutation (line 2047) | func (ec *executionContext) _Mutation(ctx context.Context, sel ast.Sel...
method _Photo (line 2078) | func (ec *executionContext) _Photo(ctx context.Context, sel ast.Select...
method _Query (line 2135) | func (ec *executionContext) _Query(ctx context.Context, sel ast.Select...
method _User (line 2207) | func (ec *executionContext) _User(ctx context.Context, sel ast.Selecti...
method ___Directive (line 2244) | func (ec *executionContext) ___Directive(ctx context.Context, sel ast....
method ___EnumValue (line 2283) | func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast....
method ___Field (line 2319) | func (ec *executionContext) ___Field(ctx context.Context, sel ast.Sele...
method ___InputValue (line 2365) | func (ec *executionContext) ___InputValue(ctx context.Context, sel ast...
method ___Schema (line 2401) | func (ec *executionContext) ___Schema(ctx context.Context, sel ast.Sel...
method ___Type (line 2442) | func (ec *executionContext) ___Type(ctx context.Context, sel ast.Selec...
method unmarshalNBoolean2bool (line 2487) | func (ec *executionContext) unmarshalNBoolean2bool(ctx context.Context...
method marshalNBoolean2bool (line 2491) | func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, ...
method unmarshalNID2string (line 2501) | func (ec *executionContext) unmarshalNID2string(ctx context.Context, v...
method marshalNID2string (line 2505) | func (ec *executionContext) marshalNID2string(ctx context.Context, sel...
method unmarshalNInt2int (line 2515) | func (ec *executionContext) unmarshalNInt2int(ctx context.Context, v i...
method marshalNInt2int (line 2519) | func (ec *executionContext) marshalNInt2int(ctx context.Context, sel a...
method marshalNPhoto2gqlgen1ᚐPhoto (line 2529) | func (ec *executionContext) marshalNPhoto2gqlgen1ᚐPhoto(ctx context.Co...
method marshalNPhoto2ᚕᚖgqlgen1ᚐPhotoᚄ (line 2533) | func (ec *executionContext) marshalNPhoto2ᚕᚖgqlgen1ᚐPhotoᚄ(ctx context...
method marshalNPhoto2ᚖgqlgen1ᚐPhoto (line 2570) | func (ec *executionContext) marshalNPhoto2ᚖgqlgen1ᚐPhoto(ctx context.C...
method unmarshalNString2string (line 2580) | func (ec *executionContext) unmarshalNString2string(ctx context.Contex...
method marshalNString2string (line 2584) | func (ec *executionContext) marshalNString2string(ctx context.Context,...
method marshalNUser2gqlgen1ᚐUser (line 2594) | func (ec *executionContext) marshalNUser2gqlgen1ᚐUser(ctx context.Cont...
method marshalNUser2ᚖgqlgen1ᚐUser (line 2598) | func (ec *executionContext) marshalNUser2ᚖgqlgen1ᚐUser(ctx context.Con...
method marshalN__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective (line 2608) | func (ec *executionContext) marshalN__Directive2githubᚗcomᚋ99designsᚋg...
method marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ (line 2612) | func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋ...
method unmarshalN__DirectiveLocation2string (line 2649) | func (ec *executionContext) unmarshalN__DirectiveLocation2string(ctx c...
method marshalN__DirectiveLocation2string (line 2653) | func (ec *executionContext) marshalN__DirectiveLocation2string(ctx con...
method unmarshalN__DirectiveLocation2ᚕstringᚄ (line 2663) | func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstringᚄ(ctx...
method marshalN__DirectiveLocation2ᚕstringᚄ (line 2683) | func (ec *executionContext) marshalN__DirectiveLocation2ᚕstringᚄ(ctx c...
method marshalN__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue (line 2720) | func (ec *executionContext) marshalN__EnumValue2githubᚗcomᚋ99designsᚋg...
method marshalN__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField (line 2724) | func (ec *executionContext) marshalN__Field2githubᚗcomᚋ99designsᚋgqlge...
method marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue (line 2728) | func (ec *executionContext) marshalN__InputValue2githubᚗcomᚋ99designsᚋ...
method marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ (line 2732) | func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designs...
method marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType (line 2769) | func (ec *executionContext) marshalN__Type2githubᚗcomᚋ99designsᚋgqlgen...
method marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ (line 2773) | func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlge...
method marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType (line 2810) | func (ec *executionContext) marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlge...
method unmarshalN__TypeKind2string (line 2820) | func (ec *executionContext) unmarshalN__TypeKind2string(ctx context.Co...
method marshalN__TypeKind2string (line 2824) | func (ec *executionContext) marshalN__TypeKind2string(ctx context.Cont...
method unmarshalOBoolean2bool (line 2834) | func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context...
method marshalOBoolean2bool (line 2838) | func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, ...
method unmarshalOBoolean2ᚖbool (line 2842) | func (ec *executionContext) unmarshalOBoolean2ᚖbool(ctx context.Contex...
method marshalOBoolean2ᚖbool (line 2850) | func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context,...
method unmarshalOString2string (line 2857) | func (ec *executionContext) unmarshalOString2string(ctx context.Contex...
method marshalOString2string (line 2861) | func (ec *executionContext) marshalOString2string(ctx context.Context,...
method unmarshalOString2ᚖstring (line 2865) | func (ec *executionContext) unmarshalOString2ᚖstring(ctx context.Conte...
method marshalOString2ᚖstring (line 2873) | func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context...
method marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ (line 2880) | func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋ...
method marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ (line 2920) | func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlg...
method marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ (line 2960) | func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designs...
method marshalO__Schema2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema (line 3000) | func (ec *executionContext) marshalO__Schema2githubᚗcomᚋ99designsᚋgqlg...
method marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema (line 3004) | func (ec *executionContext) marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgql...
method marshalO__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType (line 3011) | func (ec *executionContext) marshalO__Type2githubᚗcomᚋ99designsᚋgqlgen...
method marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ (line 3015) | func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlge...
method marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType (line 3055) | func (ec *executionContext) marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlge...
FILE: 4-api/3_graphql/gqlgen_full/gqlgen1/models_gen.go
type Photo (line 5) | type Photo struct
type User (line 15) | type User struct
FILE: 4-api/3_graphql/gqlgen_full/gqlgen1/resolver.go
type Resolver (line 7) | type Resolver struct
method Mutation (line 9) | func (r *Resolver) Mutation() MutationResolver {
method Query (line 12) | func (r *Resolver) Query() QueryResolver {
type mutationResolver (line 16) | type mutationResolver struct
method RatePhoto (line 18) | func (r *mutationResolver) RatePhoto(ctx context.Context, photoID stri...
type queryResolver (line 22) | type queryResolver struct
method Timeline (line 24) | func (r *queryResolver) Timeline(ctx context.Context) ([]*Photo, error) {
method User (line 27) | func (r *queryResolver) User(ctx context.Context, userID string) (*Use...
method Photos (line 30) | func (r *queryResolver) Photos(ctx context.Context, userID string) ([]...
FILE: 4-api/3_graphql/gqlgen_full/gqlgen1/server/server.go
constant defaultPort (line 12) | defaultPort = "8080"
function main (line 14) | func main() {
FILE: 4-api/3_graphql/gqlgen_full/gqlgen2/generated.go
function NewExecutableSchema (line 22) | func NewExecutableSchema(cfg Config) graphql.ExecutableSchema {
type Config (line 30) | type Config struct
type ResolverRoot (line 36) | type ResolverRoot interface
type DirectiveRoot (line 42) | type DirectiveRoot struct
type ComplexityRoot (line 45) | type ComplexityRoot struct
type MutationResolver (line 73) | type MutationResolver interface
type PhotoResolver (line 76) | type PhotoResolver interface
type QueryResolver (line 80) | type QueryResolver interface
type executableSchema (line 86) | type executableSchema struct
method Schema (line 92) | func (e *executableSchema) Schema() *ast.Schema {
method Complexity (line 96) | func (e *executableSchema) Complexity(typeName, field string, childCom...
method Exec (line 218) | func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseH...
type executionContext (line 258) | type executionContext struct
method introspectSchema (line 263) | func (ec *executionContext) introspectSchema() (*introspection.Schema,...
method introspectType (line 270) | func (ec *executionContext) introspectType(name string) (*introspectio...
method field_Mutation_ratePhoto_args (line 320) | func (ec *executionContext) field_Mutation_ratePhoto_args(ctx context....
method field_Query___type_args (line 342) | func (ec *executionContext) field_Query___type_args(ctx context.Contex...
method field_Query_photos_args (line 356) | func (ec *executionContext) field_Query_photos_args(ctx context.Contex...
method field_Query_user_args (line 370) | func (ec *executionContext) field_Query_user_args(ctx context.Context,...
method field___Type_enumValues_args (line 384) | func (ec *executionContext) field___Type_enumValues_args(ctx context.C...
method field___Type_fields_args (line 398) | func (ec *executionContext) field___Type_fields_args(ctx context.Conte...
method _Mutation_ratePhoto (line 420) | func (ec *executionContext) _Mutation_ratePhoto(ctx context.Context, f...
method _Photo_id (line 461) | func (ec *executionContext) _Photo_id(ctx context.Context, field graph...
method _Photo_user (line 495) | func (ec *executionContext) _Photo_user(ctx context.Context, field gra...
method _Photo_url (line 529) | func (ec *executionContext) _Photo_url(ctx context.Context, field grap...
method _Photo_comment (line 563) | func (ec *executionContext) _Photo_comment(ctx context.Context, field ...
method _Photo_rating (line 597) | func (ec *executionContext) _Photo_rating(ctx context.Context, field g...
method _Photo_liked (line 631) | func (ec *executionContext) _Photo_liked(ctx context.Context, field gr...
method _Photo_followed (line 665) | func (ec *executionContext) _Photo_followed(ctx context.Context, field...
method _Query_timeline (line 699) | func (ec *executionContext) _Query_timeline(ctx context.Context, field...
method _Query_user (line 733) | func (ec *executionContext) _Query_user(ctx context.Context, field gra...
method _Query_photos (line 774) | func (ec *executionContext) _Query_photos(ctx context.Context, field g...
method _Query___type (line 815) | func (ec *executionContext) _Query___type(ctx context.Context, field g...
method _Query___schema (line 853) | func (ec *executionContext) _Query___schema(ctx context.Context, field...
method _User_id (line 884) | func (ec *executionContext) _User_id(ctx context.Context, field graphq...
method _User_name (line 918) | func (ec *executionContext) _User_name(ctx context.Context, field grap...
method _User_avatar (line 952) | func (ec *executionContext) _User_avatar(ctx context.Context, field gr...
method ___Directive_name (line 986) | func (ec *executionContext) ___Directive_name(ctx context.Context, fie...
method ___Directive_description (line 1020) | func (ec *executionContext) ___Directive_description(ctx context.Conte...
method ___Directive_locations (line 1051) | func (ec *executionContext) ___Directive_locations(ctx context.Context...
method ___Directive_args (line 1085) | func (ec *executionContext) ___Directive_args(ctx context.Context, fie...
method ___EnumValue_name (line 1119) | func (ec *executionContext) ___EnumValue_name(ctx context.Context, fie...
method ___EnumValue_description (line 1153) | func (ec *executionContext) ___EnumValue_description(ctx context.Conte...
method ___EnumValue_isDeprecated (line 1184) | func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Cont...
method ___EnumValue_deprecationReason (line 1218) | func (ec *executionContext) ___EnumValue_deprecationReason(ctx context...
method ___Field_name (line 1249) | func (ec *executionContext) ___Field_name(ctx context.Context, field g...
method ___Field_description (line 1283) | func (ec *executionContext) ___Field_description(ctx context.Context, ...
method ___Field_args (line 1314) | func (ec *executionContext) ___Field_args(ctx context.Context, field g...
method ___Field_type (line 1348) | func (ec *executionContext) ___Field_type(ctx context.Context, field g...
method ___Field_isDeprecated (line 1382) | func (ec *executionContext) ___Field_isDeprecated(ctx context.Context,...
method ___Field_deprecationReason (line 1416) | func (ec *executionContext) ___Field_deprecationReason(ctx context.Con...
method ___InputValue_name (line 1447) | func (ec *executionContext) ___InputValue_name(ctx context.Context, fi...
method ___InputValue_description (line 1481) | func (ec *executionContext) ___InputValue_description(ctx context.Cont...
method ___InputValue_type (line 1512) | func (ec *executionContext) ___InputValue_type(ctx context.Context, fi...
method ___InputValue_defaultValue (line 1546) | func (ec *executionContext) ___InputValue_defaultValue(ctx context.Con...
method ___Schema_types (line 1577) | func (ec *executionContext) ___Schema_types(ctx context.Context, field...
method ___Schema_queryType (line 1611) | func (ec *executionContext) ___Schema_queryType(ctx context.Context, f...
method ___Schema_mutationType (line 1645) | func (ec *executionContext) ___Schema_mutationType(ctx context.Context...
method ___Schema_subscriptionType (line 1676) | func (ec *executionContext) ___Schema_subscriptionType(ctx context.Con...
method ___Schema_directives (line 1707) | func (ec *executionContext) ___Schema_directives(ctx context.Context, ...
method ___Type_kind (line 1741) | func (ec *executionContext) ___Type_kind(ctx context.Context, field gr...
method ___Type_name (line 1775) | func (ec *executionContext) ___Type_name(ctx context.Context, field gr...
method ___Type_description (line 1806) | func (ec *executionContext) ___Type_description(ctx context.Context, f...
method ___Type_fields (line 1837) | func (ec *executionContext) ___Type_fields(ctx context.Context, field ...
method ___Type_interfaces (line 1875) | func (ec *executionContext) ___Type_interfaces(ctx context.Context, fi...
method ___Type_possibleTypes (line 1906) | func (ec *executionContext) ___Type_possibleTypes(ctx context.Context,...
method ___Type_enumValues (line 1937) | func (ec *executionContext) ___Type_enumValues(ctx context.Context, fi...
method ___Type_inputFields (line 1975) | func (ec *executionContext) ___Type_inputFields(ctx context.Context, f...
method ___Type_ofType (line 2006) | func (ec *executionContext) ___Type_ofType(ctx context.Context, field ...
method _Mutation (line 2051) | func (ec *executionContext) _Mutation(ctx context.Context, sel ast.Sel...
method _Photo (line 2082) | func (ec *executionContext) _Photo(ctx context.Context, sel ast.Select...
method _Query (line 2157) | func (ec *executionContext) _Query(ctx context.Context, sel ast.Select...
method _User (line 2229) | func (ec *executionContext) _User(ctx context.Context, sel ast.Selecti...
method ___Directive (line 2266) | func (ec *executionContext) ___Directive(ctx context.Context, sel ast....
method ___EnumValue (line 2305) | func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast....
method ___Field (line 2341) | func (ec *executionContext) ___Field(ctx context.Context, sel ast.Sele...
method ___InputValue (line 2387) | func (ec *executionContext) ___InputValue(ctx context.Context, sel ast...
method ___Schema (line 2423) | func (ec *executionContext) ___Schema(ctx context.Context, sel ast.Sel...
method ___Type (line 2464) | func (ec *executionContext) ___Type(ctx context.Context, sel ast.Selec...
method unmarshalNBoolean2bool (line 2509) | func (ec *executionContext) unmarshalNBoolean2bool(ctx context.Context...
method marshalNBoolean2bool (line 2513) | func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, ...
method unmarshalNID2string (line 2523) | func (ec *executionContext) unmarshalNID2string(ctx context.Context, v...
method marshalNID2string (line 2527) | func (ec *executionContext) marshalNID2string(ctx context.Context, sel...
method unmarshalNInt2int (line 2537) | func (ec *executionContext) unmarshalNInt2int(ctx context.Context, v i...
method marshalNInt2int (line 2541) | func (ec *executionContext) marshalNInt2int(ctx context.Context, sel a...
method marshalNPhoto2gqlgen2ᚐPhoto (line 2551) | func (ec *executionContext) marshalNPhoto2gqlgen2ᚐPhoto(ctx context.Co...
method marshalNPhoto2ᚕᚖgqlgen2ᚐPhotoᚄ (line 2555) | func (ec *executionContext) marshalNPhoto2ᚕᚖgqlgen2ᚐPhotoᚄ(ctx context...
method marshalNPhoto2ᚖgqlgen2ᚐPhoto (line 2592) | func (ec *executionContext) marshalNPhoto2ᚖgqlgen2ᚐPhoto(ctx context.C...
method unmarshalNString2string (line 2602) | func (ec *executionContext) unmarshalNString2string(ctx context.Contex...
method marshalNString2string (line 2606) | func (ec *executionContext) marshalNString2string(ctx context.Context,...
method marshalNUser2gqlgen2ᚐUser (line 2616) | func (ec *executionContext) marshalNUser2gqlgen2ᚐUser(ctx context.Cont...
method marshalNUser2ᚖgqlgen2ᚐUser (line 2620) | func (ec *executionContext) marshalNUser2ᚖgqlgen2ᚐUser(ctx context.Con...
method marshalN__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective (line 2630) | func (ec *executionContext) marshalN__Directive2githubᚗcomᚋ99designsᚋg...
method marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ (line 2634) | func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋ...
method unmarshalN__DirectiveLocation2string (line 2671) | func (ec *executionContext) unmarshalN__DirectiveLocation2string(ctx c...
method marshalN__DirectiveLocation2string (line 2675) | func (ec *executionContext) marshalN__DirectiveLocation2string(ctx con...
method unmarshalN__DirectiveLocation2ᚕstringᚄ (line 2685) | func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstringᚄ(ctx...
method marshalN__DirectiveLocation2ᚕstringᚄ (line 2705) | func (ec *executionContext) marshalN__DirectiveLocation2ᚕstringᚄ(ctx c...
method marshalN__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue (line 2742) | func (ec *executionContext) marshalN__EnumValue2githubᚗcomᚋ99designsᚋg...
method marshalN__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField (line 2746) | func (ec *executionContext) marshalN__Field2githubᚗcomᚋ99designsᚋgqlge...
method marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue (line 2750) | func (ec *executionContext) marshalN__InputValue2githubᚗcomᚋ99designsᚋ...
method marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ (line 2754) | func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designs...
method marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType (line 2791) | func (ec *executionContext) marshalN__Type2githubᚗcomᚋ99designsᚋgqlgen...
method marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ (line 2795) | func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlge...
method marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType (line 2832) | func (ec *executionContext) marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlge...
method unmarshalN__TypeKind2string (line 2842) | func (ec *executionContext) unmarshalN__TypeKind2string(ctx context.Co...
method marshalN__TypeKind2string (line 2846) | func (ec *executionContext) marshalN__TypeKind2string(ctx context.Cont...
method unmarshalOBoolean2bool (line 2856) | func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context...
method marshalOBoolean2bool (line 2860) | func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, ...
method unmarshalOBoolean2ᚖbool (line 2864) | func (ec *executionContext) unmarshalOBoolean2ᚖbool(ctx context.Contex...
method marshalOBoolean2ᚖbool (line 2872) | func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context,...
method unmarshalOString2string (line 2879) | func (ec *executionContext) unmarshalOString2string(ctx context.Contex...
method marshalOString2string (line 2883) | func (ec *executionContext) marshalOString2string(ctx context.Context,...
method unmarshalOString2ᚖstring (line 2887) | func (ec *executionContext) unmarshalOString2ᚖstring(ctx context.Conte...
method marshalOString2ᚖstring (line 2895) | func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context...
method marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ (line 2902) | func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋ...
method marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ (line 2942) | func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlg...
method marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ (line 2982) | func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designs...
method marshalO__Schema2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema (line 3022) | func (ec *executionContext) marshalO__Schema2githubᚗcomᚋ99designsᚋgqlg...
method marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema (line 3026) | func (ec *executionContext) marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgql...
method marshalO__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType (line 3033) | func (ec *executionContext) marshalO__Type2githubᚗcomᚋ99designsᚋgqlgen...
method marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ (line 3037) | func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlge...
method marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType (line 3077) | func (ec *executionContext) marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlge...
FILE: 4-api/3_graphql/gqlgen_full/gqlgen2/models_gen.go
type User (line 5) | type User struct
FILE: 4-api/3_graphql/gqlgen_full/gqlgen2/photo.go
type Photo (line 8) | type Photo struct
method Id (line 19) | func (ph *Photo) Id() string {
FILE: 4-api/3_graphql/gqlgen_full/gqlgen2/resolver.go
type Resolver (line 12) | type Resolver struct
method Mutation (line 17) | func (r *Resolver) Mutation() MutationResolver {
method Photo (line 20) | func (r *Resolver) Photo() PhotoResolver {
method Query (line 23) | func (r *Resolver) Query() QueryResolver {
type mutationResolver (line 27) | type mutationResolver struct
method RatePhoto (line 29) | func (r *mutationResolver) RatePhoto(ctx context.Context, id string, d...
type photoResolver (line 43) | type photoResolver struct
method ID (line 45) | func (r *photoResolver) ID(ctx context.Context, obj *Photo) (string, e...
method User (line 49) | func (r *photoResolver) User(ctx context.Context, obj *Photo) (*User, ...
type queryResolver (line 55) | type queryResolver struct
method Timeline (line 57) | func (r *queryResolver) Timeline(ctx context.Context) ([]*Photo, error) {
method User (line 66) | func (r *queryResolver) User(ctx context.Context, userID string) (*Use...
method Photos (line 72) | func (r *queryResolver) Photos(ctx context.Context, userID string) ([]...
FILE: 4-api/3_graphql/gqlgen_full/gqlgen2/server/server.go
function AuthMiddleware (line 61) | func AuthMiddleware(next http.Handler) http.Handler {
function main (line 70) | func main() {
FILE: 4-api/3_graphql/gqlgen_full/gqlgen3/generated.go
function NewExecutableSchema (line 22) | func NewExecutableSchema(cfg Config) graphql.ExecutableSchema {
type Config (line 30) | type Config struct
type ResolverRoot (line 36) | type ResolverRoot interface
type DirectiveRoot (line 42) | type DirectiveRoot struct
type ComplexityRoot (line 45) | type ComplexityRoot struct
type MutationResolver (line 73) | type MutationResolver interface
type PhotoResolver (line 76) | type PhotoResolver interface
type QueryResolver (line 80) | type QueryResolver interface
type executableSchema (line 86) | type executableSchema struct
method Schema (line 92) | func (e *executableSchema) Schema() *ast.Schema {
method Complexity (line 96) | func (e *executableSchema) Complexity(typeName, field string, childCom...
method Exec (line 218) | func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseH...
type executionContext (line 258) | type executionContext struct
method introspectSchema (line 263) | func (ec *executionContext) introspectSchema() (*introspection.Schema,...
method introspectType (line 270) | func (ec *executionContext) introspectType(name string) (*introspectio...
method field_Mutation_ratePhoto_args (line 320) | func (ec *executionContext) field_Mutation_ratePhoto_args(ctx context....
method field_Query___type_args (line 342) | func (ec *executionContext) field_Query___type_args(ctx context.Contex...
method field_Query_photos_args (line 356) | func (ec *executionContext) field_Query_photos_args(ctx context.Contex...
method field_Query_user_args (line 370) | func (ec *executionContext) field_Query_user_args(ctx context.Context,...
method field___Type_enumValues_args (line 384) | func (ec *executionContext) field___Type_enumValues_args(ctx context.C...
method field___Type_fields_args (line 398) | func (ec *executionContext) field___Type_fields_args(ctx context.Conte...
method _Mutation_ratePhoto (line 420) | func (ec *executionContext) _Mutation_ratePhoto(ctx context.Context, f...
method _Photo_id (line 461) | func (ec *executionContext) _Photo_id(ctx context.Context, field graph...
method _Photo_user (line 495) | func (ec *executionContext) _Photo_user(ctx context.Context, field gra...
method _Photo_url (line 529) | func (ec *executionContext) _Photo_url(ctx context.Context, field grap...
method _Photo_comment (line 563) | func (ec *executionContext) _Photo_comment(ctx context.Context, field ...
method _Photo_rating (line 597) | func (ec *executionContext) _Photo_rating(ctx context.Context, field g...
method _Photo_liked (line 631) | func (ec *executionContext) _Photo_liked(ctx context.Context, field gr...
method _Query_timeline (line 665) | func (ec *executionContext) _Query_timeline(ctx context.Context, field...
method _Query_user (line 699) | func (ec *executionContext) _Query_user(ctx context.Context, field gra...
method _Query_photos (line 740) | func (ec *executionContext) _Query_photos(ctx context.Context, field g...
method _Query___type (line 781) | func (ec *executionContext) _Query___type(ctx context.Context, field g...
method _Query___schema (line 819) | func (ec *executionContext) _Query___schema(ctx context.Context, field...
method _User_id (line 850) | func (ec *executionContext) _User_id(ctx context.Context, field graphq...
method _User_name (line 884) | func (ec *executionContext) _User_name(ctx context.Context, field grap...
method _User_avatar (line 918) | func (ec *executionContext) _User_avatar(ctx context.Context, field gr...
method _User_followed (line 952) | func (ec *executionContext) _User_followed(ctx context.Context, field ...
method ___Directive_name (line 986) | func (ec *executionContext) ___Directive_name(ctx context.Context, fie...
method ___Directive_description (line 1020) | func (ec *executionContext) ___Directive_description(ctx context.Conte...
method ___Directive_locations (line 1051) | func (ec *executionContext) ___Directive_locations(ctx context.Context...
method ___Directive_args (line 1085) | func (ec *executionContext) ___Directive_args(ctx context.Context, fie...
method ___EnumValue_name (line 1119) | func (ec *executionContext) ___EnumValue_name(ctx context.Context, fie...
method ___EnumValue_description (line 1153) | func (ec *executionContext) ___EnumValue_description(ctx context.Conte...
method ___EnumValue_isDeprecated (line 1184) | func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Cont...
method ___EnumValue_deprecationReason (line 1218) | func (ec *executionContext) ___EnumValue_deprecationReason(ctx context...
method ___Field_name (line 1249) | func (ec *executionContext) ___Field_name(ctx context.Context, field g...
method ___Field_description (line 1283) | func (ec *executionContext) ___Field_description(ctx context.Context, ...
method ___Field_args (line 1314) | func (ec *executionContext) ___Field_args(ctx context.Context, field g...
method ___Field_type (line 1348) | func (ec *executionContext) ___Field_type(ctx context.Context, field g...
method ___Field_isDeprecated (line 1382) | func (ec *executionContext) ___Field_isDeprecated(ctx context.Context,...
method ___Field_deprecationReason (line 1416) | func (ec *executionContext) ___Field_deprecationReason(ctx context.Con...
method ___InputValue_name (line 1447) | func (ec *executionContext) ___InputValue_name(ctx context.Context, fi...
method ___InputValue_description (line 1481) | func (ec *executionContext) ___InputValue_description(ctx context.Cont...
method ___InputValue_type (line 1512) | func (ec *executionContext) ___InputValue_type(ctx context.Context, fi...
method ___InputValue_defaultValue (line 1546) | func (ec *executionContext) ___InputValue_defaultValue(ctx context.Con...
method ___Schema_types (line 1577) | func (ec *executionContext) ___Schema_types(ctx context.Context, field...
method ___Schema_queryType (line 1611) | func (ec *executionContext) ___Schema_queryType(ctx context.Context, f...
method ___Schema_mutationType (line 1645) | func (ec *executionContext) ___Schema_mutationType(ctx context.Context...
method ___Schema_subscriptionType (line 1676) | func (ec *executionContext) ___Schema_subscriptionType(ctx context.Con...
method ___Schema_directives (line 1707) | func (ec *executionContext) ___Schema_directives(ctx context.Context, ...
method ___Type_kind (line 1741) | func (ec *executionContext) ___Type_kind(ctx context.Context, field gr...
method ___Type_name (line 1775) | func (ec *executionContext) ___Type_name(ctx context.Context, field gr...
method ___Type_description (line 1806) | func (ec *executionContext) ___Type_description(ctx context.Context, f...
method ___Type_fields (line 1837) | func (ec *executionContext) ___Type_fields(ctx context.Context, field ...
method ___Type_interfaces (line 1875) | func (ec *executionContext) ___Type_interfaces(ctx context.Context, fi...
method ___Type_possibleTypes (line 1906) | func (ec *executionContext) ___Type_possibleTypes(ctx context.Context,...
method ___Type_enumValues (line 1937) | func (ec *executionContext) ___Type_enumValues(ctx context.Context, fi...
method ___Type_inputFields (line 1975) | func (ec *executionContext) ___Type_inputFields(ctx context.Context, f...
method ___Type_ofType (line 2006) | func (ec *executionContext) ___Type_ofType(ctx context.Context, field ...
method _Mutation (line 2051) | func (ec *executionContext) _Mutation(ctx context.Context, sel ast.Sel...
method _Photo (line 2082) | func (ec *executionContext) _Photo(ctx context.Context, sel ast.Select...
method _Query (line 2152) | func (ec *executionContext) _Query(ctx context.Context, sel ast.Select...
method _User (line 2224) | func (ec *executionContext) _User(ctx context.Context, sel ast.Selecti...
method ___Directive (line 2266) | func (ec *executionContext) ___Directive(ctx context.Context, sel ast....
method ___EnumValue (line 2305) | func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast....
method ___Field (line 2341) | func (ec *executionContext) ___Field(ctx context.Context, sel ast.Sele...
method ___InputValue (line 2387) | func (ec *executionContext) ___InputValue(ctx context.Context, sel ast...
method ___Schema (line 2423) | func (ec *executionContext) ___Schema(ctx context.Context, sel ast.Sel...
method ___Type (line 2464) | func (ec *executionContext) ___Type(ctx context.Context, sel ast.Selec...
method unmarshalNBoolean2bool (line 2509) | func (ec *executionContext) unmarshalNBoolean2bool(ctx context.Context...
method marshalNBoolean2bool (line 2513) | func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, ...
method unmarshalNID2string (line 2523) | func (ec *executionContext) unmarshalNID2string(ctx context.Context, v...
method marshalNID2string (line 2527) | func (ec *executionContext) marshalNID2string(ctx context.Context, sel...
method unmarshalNInt2int (line 2537) | func (ec *executionContext) unmarshalNInt2int(ctx context.Context, v i...
method marshalNInt2int (line 2541) | func (ec *executionContext) marshalNInt2int(ctx context.Context, sel a...
method marshalNPhoto2gqlgen3ᚐPhoto (line 2551) | func (ec *executionContext) marshalNPhoto2gqlgen3ᚐPhoto(ctx context.Co...
method marshalNPhoto2ᚕᚖgqlgen3ᚐPhotoᚄ (line 2555) | func (ec *executionContext) marshalNPhoto2ᚕᚖgqlgen3ᚐPhotoᚄ(ctx context...
method marshalNPhoto2ᚖgqlgen3ᚐPhoto (line 2592) | func (ec *executionContext) marshalNPhoto2ᚖgqlgen3ᚐPhoto(ctx context.C...
method unmarshalNString2string (line 2602) | func (ec *executionContext) unmarshalNString2string(ctx context.Contex...
method marshalNString2string (line 2606) | func (ec *executionContext) marshalNString2string(ctx context.Context,...
method marshalNUser2gqlgen3ᚐUser (line 2616) | func (ec *executionContext) marshalNUser2gqlgen3ᚐUser(ctx context.Cont...
method marshalNUser2ᚖgqlgen3ᚐUser (line 2620) | func (ec *executionContext) marshalNUser2ᚖgqlgen3ᚐUser(ctx context.Con...
method marshalN__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective (line 2630) | func (ec *executionContext) marshalN__Directive2githubᚗcomᚋ99designsᚋg...
method marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ (line 2634) | func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋ...
method unmarshalN__DirectiveLocation2string (line 2671) | func (ec *executionContext) unmarshalN__DirectiveLocation2string(ctx c...
method marshalN__DirectiveLocation2string (line 2675) | func (ec *executionContext) marshalN__DirectiveLocation2string(ctx con...
method unmarshalN__DirectiveLocation2ᚕstringᚄ (line 2685) | func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstringᚄ(ctx...
method marshalN__DirectiveLocation2ᚕstringᚄ (line 2705) | func (ec *executionContext) marshalN__DirectiveLocation2ᚕstringᚄ(ctx c...
method marshalN__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue (line 2742) | func (ec *executionContext) marshalN__EnumValue2githubᚗcomᚋ99designsᚋg...
method marshalN__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField (line 2746) | func (ec *executionContext) marshalN__Field2githubᚗcomᚋ99designsᚋgqlge...
method marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue (line 2750) | func (ec *executionContext) marshalN__InputValue2githubᚗcomᚋ99designsᚋ...
method marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ (line 2754) | func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designs...
method marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType (line 2791) | func (ec *executionContext) marshalN__Type2githubᚗcomᚋ99designsᚋgqlgen...
method marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ (line 2795) | func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlge...
method marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType (line 2832) | func (ec *executionContext) marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlge...
method unmarshalN__TypeKind2string (line 2842) | func (ec *executionContext) unmarshalN__TypeKind2string(ctx context.Co...
method marshalN__TypeKind2string (line 2846) | func (ec *executionContext) marshalN__TypeKind2string(ctx context.Cont...
method unmarshalOBoolean2bool (line 2856) | func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context...
method marshalOBoolean2bool (line 2860) | func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, ...
method unmarshalOBoolean2ᚖbool (line 2864) | func (ec *executionContext) unmarshalOBoolean2ᚖbool(ctx context.Contex...
method marshalOBoolean2ᚖbool (line 2872) | func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context,...
method unmarshalOString2string (line 2879) | func (ec *executionContext) unmarshalOString2string(ctx context.Contex...
method marshalOString2string (line 2883) | func (ec *executionContext) marshalOString2string(ctx context.Context,...
method unmarshalOString2ᚖstring (line 2887) | func (ec *executionContext) unmarshalOString2ᚖstring(ctx context.Conte...
method marshalOString2ᚖstring (line 2895) | func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context...
method marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ (line 2902) | func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋ...
method marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ (line 2942) | func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlg...
method marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ (line 2982) | func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designs...
method marshalO__Schema2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema (line 3022) | func (ec *executionContext) marshalO__Schema2githubᚗcomᚋ99designsᚋgqlg...
method marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema (line 3026) | func (ec *executionContext) marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgql...
method marshalO__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType (line 3033) | func (ec *executionContext) marshalO__Type2githubᚗcomᚋ99designsᚋgqlgen...
method marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ (line 3037) | func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlge...
method marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType (line 3077) | func (ec *executionContext) marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlge...
FILE: 4-api/3_graphql/gqlgen_full/gqlgen3/models_gen.go
type User (line 5) | type User struct
FILE: 4-api/3_graphql/gqlgen_full/gqlgen3/photo.go
type Photo (line 8) | type Photo struct
method Id (line 18) | func (ph *Photo) Id() string {
FILE: 4-api/3_graphql/gqlgen_full/gqlgen3/resolver.go
type Resolver (line 13) | type Resolver struct
method Mutation (line 18) | func (r *Resolver) Mutation() MutationResolver {
method Photo (line 21) | func (r *Resolver) Photo() PhotoResolver {
method Query (line 24) | func (r *Resolver) Query() QueryResolver {
type mutationResolver (line 28) | type mutationResolver struct
method RatePhoto (line 30) | func (r *mutationResolver) RatePhoto(ctx context.Context, id string, d...
type photoResolver (line 44) | type photoResolver struct
method ID (line 46) | func (r *photoResolver) ID(ctx context.Context, obj *Photo) (string, e...
method User (line 50) | func (r *photoResolver) User(ctx context.Context, obj *Photo) (*User, ...
type queryResolver (line 59) | type queryResolver struct
method Timeline (line 61) | func (r *queryResolver) Timeline(ctx context.Context) ([]*Photo, error) {
method User (line 70) | func (r *queryResolver) User(ctx context.Context, userID string) (*Use...
method Photos (line 76) | func (r *queryResolver) Photos(ctx context.Context, userID string) ([]...
FILE: 4-api/3_graphql/gqlgen_full/gqlgen3/server/server.go
function UserLoaderMiddleware (line 61) | func UserLoaderMiddleware(resolver *gqlgen.Resolver, next http.Handler) ...
function AuthMiddleware (line 92) | func AuthMiddleware(next http.Handler) http.Handler {
function main (line 101) | func main() {
FILE: 4-api/3_graphql/gqlgen_full/gqlgen3/userloader_gen.go
type UserLoaderConfig (line 11) | type UserLoaderConfig struct
function NewUserLoader (line 23) | func NewUserLoader(config UserLoaderConfig) *UserLoader {
type UserLoader (line 32) | type UserLoader struct
method Load (line 64) | func (l *UserLoader) Load(key uint) (*User, error) {
method LoadThunk (line 71) | func (l *UserLoader) LoadThunk(key uint) func() (*User, error) {
method LoadAll (line 114) | func (l *UserLoader) LoadAll(keys []uint) ([]*User, []error) {
method LoadAllThunk (line 132) | func (l *UserLoader) LoadAllThunk(keys []uint) func() ([]*User, []erro...
method Prime (line 150) | func (l *UserLoader) Prime(key uint, value *User) bool {
method Clear (line 164) | func (l *UserLoader) Clear(key uint) {
method unsafeSet (line 170) | func (l *UserLoader) unsafeSet(key uint, value *User) {
type userLoaderBatch (line 55) | type userLoaderBatch struct
method keyIndex (line 179) | func (b *userLoaderBatch) keyIndex(l *UserLoader, key uint) int {
method startTimer (line 203) | func (b *userLoaderBatch) startTimer(l *UserLoader) {
method end (line 219) | func (b *userLoaderBatch) end(l *UserLoader) {
FILE: 4-api/3_graphql/gqlgen_full/gqlgen4/generated.go
function NewExecutableSchema (line 22) | func NewExecutableSchema(cfg Config) graphql.ExecutableSchema {
type Config (line 30) | type Config struct
type ResolverRoot (line 36) | type ResolverRoot interface
type DirectiveRoot (line 43) | type DirectiveRoot struct
type ComplexityRoot (line 46) | type ComplexityRoot struct
type MutationResolver (line 75) | type MutationResolver interface
type PhotoResolver (line 78) | type PhotoResolver interface
type QueryResolver (line 82) | type QueryResolver interface
type UserResolver (line 87) | type UserResolver interface
type executableSchema (line 91) | type executableSchema struct
method Schema (line 97) | func (e *executableSchema) Schema() *ast.Schema {
method Complexity (line 101) | func (e *executableSchema) Complexity(typeName, field string, childCom...
method Exec (line 235) | func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseH...
type executionContext (line 275) | type executionContext struct
method introspectSchema (line 280) | func (ec *executionContext) introspectSchema() (*introspection.Schema,...
method introspectType (line 287) | func (ec *executionContext) introspectType(name string) (*introspectio...
method field_Mutation_ratePhoto_args (line 345) | func (ec *executionContext) field_Mutation_ratePhoto_args(ctx context....
method field_Query___type_args (line 367) | func (ec *executionContext) field_Query___type_args(ctx context.Contex...
method field_Query_photos_args (line 381) | func (ec *executionContext) field_Query_photos_args(ctx context.Contex...
method field_Query_user_args (line 395) | func (ec *executionContext) field_Query_user_args(ctx context.Context,...
method field_User_photos_args (line 409) | func (ec *executionContext) field_User_photos_args(ctx context.Context...
method field___Type_enumValues_args (line 423) | func (ec *executionContext) field___Type_enumValues_args(ctx context.C...
method field___Type_fields_args (line 437) | func (ec *executionContext) field___Type_fields_args(ctx context.Conte...
method _Mutation_ratePhoto (line 459) | func (ec *executionContext) _Mutation_ratePhoto(ctx context.Context, f...
method _Photo_id (line 500) | func (ec *executionContext) _Photo_id(ctx context.Context, field graph...
method _Photo_user (line 534) | func (ec *executionContext) _Photo_user(ctx context.Context, field gra...
method _Photo_url (line 568) | func (ec *executionContext) _Photo_url(ctx context.Context, field grap...
method _Photo_comment (line 602) | func (ec *executionContext) _Photo_comment(ctx context.Context, field ...
method _Photo_rating (line 636) | func (ec *executionContext) _Photo_rating(ctx context.Context, field g...
method _Photo_liked (line 670) | func (ec *executionContext) _Photo_liked(ctx context.Context, field gr...
method _Query_timeline (line 704) | func (ec *executionContext) _Query_timeline(ctx context.Context, field...
method _Query_user (line 738) | func (ec *executionContext) _Query_user(ctx context.Context, field gra...
method _Query_photos (line 779) | func (ec *executionContext) _Query_photos(ctx context.Context, field g...
method _Query___type (line 820) | func (ec *executionContext) _Query___type(ctx context.Context, field g...
method _Query___schema (line 858) | func (ec *executionContext) _Query___schema(ctx context.Context, field...
method _User_id (line 889) | func (ec *executionContext) _User_id(ctx context.Context, field graphq...
method _User_name (line 923) | func (ec *executionContext) _User_name(ctx context.Context, field grap...
method _User_avatar (line 957) | func (ec *executionContext) _User_avatar(ctx context.Context, field gr...
method _User_followed (line 991) | func (ec *executionContext) _User_followed(ctx context.Context, field ...
method _User_photos (line 1025) | func (ec *executionContext) _User_photos(ctx context.Context, field gr...
method ___Directive_name (line 1066) | func (ec *executionContext) ___Directive_name(ctx context.Context, fie...
method ___Directive_description (line 1100) | func (ec *executionContext) ___Directive_description(ctx context.Conte...
method ___Directive_locations (line 1131) | func (ec *executionContext) ___Directive_locations(ctx context.Context...
method ___Directive_args (line 1165) | func (ec *executionContext) ___Directive_args(ctx context.Context, fie...
method ___EnumValue_name (line 1199) | func (ec *executionContext) ___EnumValue_name(ctx context.Context, fie...
method ___EnumValue_description (line 1233) | func (ec *executionContext) ___EnumValue_description(ctx context.Conte...
method ___EnumValue_isDeprecated (line 1264) | func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Cont...
method ___EnumValue_deprecationReason (line 1298) | func (ec *executionContext) ___EnumValue_deprecationReason(ctx context...
method ___Field_name (line 1329) | func (ec *executionContext) ___Field_name(ctx context.Context, field g...
method ___Field_description (line 1363) | func (ec *executionContext) ___Field_description(ctx context.Context, ...
method ___Field_args (line 1394) | func (ec *executionContext) ___Field_args(ctx context.Context, field g...
method ___Field_type (line 1428) | func (ec *executionContext) ___Field_type(ctx context.Context, field g...
method ___Field_isDeprecated (line 1462) | func (ec *executionContext) ___Field_isDeprecated(ctx context.Context,...
method ___Field_deprecationReason (line 1496) | func (ec *executionContext) ___Field_deprecationReason(ctx context.Con...
method ___InputValue_name (line 1527) | func (ec *executionContext) ___InputValue_name(ctx context.Context, fi...
method ___InputValue_description (line 1561) | func (ec *executionContext) ___InputValue_description(ctx context.Cont...
method ___InputValue_type (line 1592) | func (ec *executionContext) ___InputValue_type(ctx context.Context, fi...
method ___InputValue_defaultValue (line 1626) | func (ec *executionContext) ___InputValue_defaultValue(ctx context.Con...
method ___Schema_types (line 1657) | func (ec *executionContext) ___Schema_types(ctx context.Context, field...
method ___Schema_queryType (line 1691) | func (ec *executionContext) ___Schema_queryType(ctx context.Context, f...
method ___Schema_mutationType (line 1725) | func (ec *executionContext) ___Schema_mutationType(ctx context.Context...
method ___Schema_subscriptionType (line 1756) | func (ec *executionContext) ___Schema_subscriptionType(ctx context.Con...
method ___Schema_directives (line 1787) | func (ec *executionContext) ___Schema_directives(ctx context.Context, ...
method ___Type_kind (line 1821) | func (ec *executionContext) ___Type_kind(ctx context.Context, field gr...
method ___Type_name (line 1855) | func (ec *executionContext) ___Type_name(ctx context.Context, field gr...
method ___Type_description (line 1886) | func (ec *executionContext) ___Type_description(ctx context.Context, f...
method ___Type_fields (line 1917) | func (ec *executionContext) ___Type_fields(ctx context.Context, field ...
method ___Type_interfaces (line 1955) | func (ec *executionContext) ___Type_interfaces(ctx context.Context, fi...
method ___Type_possibleTypes (line 1986) | func (ec *executionContext) ___Type_possibleTypes(ctx context.Context,...
method ___Type_enumValues (line 2017) | func (ec *executionContext) ___Type_enumValues(ctx context.Context, fi...
method ___Type_inputFields (line 2055) | func (ec *executionContext) ___Type_inputFields(ctx context.Context, f...
method ___Type_ofType (line 2086) | func (ec *executionContext) ___Type_ofType(ctx context.Context, field ...
method _Mutation (line 2131) | func (ec *executionContext) _Mutation(ctx context.Context, sel ast.Sel...
method _Photo (line 2162) | func (ec *executionContext) _Photo(ctx context.Context, sel ast.Select...
method _Query (line 2232) | func (ec *executionContext) _Query(ctx context.Context, sel ast.Select...
method _User (line 2304) | func (ec *executionContext) _User(ctx context.Context, sel ast.Selecti...
method ___Directive (line 2360) | func (ec *executionContext) ___Directive(ctx context.Context, sel ast....
method ___EnumValue (line 2399) | func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast....
method ___Field (line 2435) | func (ec *executionContext) ___Field(ctx context.Context, sel ast.Sele...
method ___InputValue (line 2481) | func (ec *executionContext) ___InputValue(ctx context.Context, sel ast...
method ___Schema (line 2517) | func (ec *executionContext) ___Schema(ctx context.Context, sel ast.Sel...
method ___Type (line 2558) | func (ec *executionContext) ___Type(ctx context.Context, sel ast.Selec...
method unmarshalNBoolean2bool (line 2603) | func (ec *executionContext) unmarshalNBoolean2bool(ctx context.Context...
method marshalNBoolean2bool (line 2607) | func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, ...
method unmarshalNID2string (line 2617) | func (ec *executionContext) unmarshalNID2string(ctx context.Context, v...
method marshalNID2string (line 2621) | func (ec *executionContext) marshalNID2string(ctx context.Context, sel...
method unmarshalNInt2int (line 2631) | func (ec *executionContext) unmarshalNInt2int(ctx context.Context, v i...
method marshalNInt2int (line 2635) | func (ec *executionContext) marshalNInt2int(ctx context.Context, sel a...
method marshalNPhoto2gqlgen4ᚐPhoto (line 2645) | func (ec *executionContext) marshalNPhoto2gqlgen4ᚐPhoto(ctx context.Co...
method marshalNPhoto2ᚕᚖgqlgen4ᚐPhotoᚄ (line 2649) | func (ec *executionContext) marshalNPhoto2ᚕᚖgqlgen4ᚐPhotoᚄ(ctx context...
method marshalNPhoto2ᚖgqlgen4ᚐPhoto (line 2686) | func (ec *executionContext) marshalNPhoto2ᚖgqlgen4ᚐPhoto(ctx context.C...
method unmarshalNString2string (line 2696) | func (ec *executionContext) unmarshalNString2string(ctx context.Contex...
method marshalNString2string (line 2700) | func (ec *executionContext) marshalNString2string(ctx context.Context,...
method marshalNUser2gqlgen4ᚐUser (line 2710) | func (ec *executionContext) marshalNUser2gqlgen4ᚐUser(ctx context.Cont...
method marshalNUser2ᚖgqlgen4ᚐUser (line 2714) | func (ec *executionContext) marshalNUser2ᚖgqlgen4ᚐUser(ctx context.Con...
method marshalN__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective (line 2724) | func (ec *executionContext) marshalN__Directive2githubᚗcomᚋ99designsᚋg...
method marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ (line 2728) | func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋ...
method unmarshalN__DirectiveLocation2string (line 2765) | func (ec *executionContext) unmarshalN__DirectiveLocation2string(ctx c...
method marshalN__DirectiveLocation2string (line 2769) | func (ec *executionContext) marshalN__DirectiveLocation2string(ctx con...
method unmarshalN__DirectiveLocation2ᚕstringᚄ (line 2779) | func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstringᚄ(ctx...
method marshalN__DirectiveLocation2ᚕstringᚄ (line 2799) | func (ec *executionContext) marshalN__DirectiveLocation2ᚕstringᚄ(ctx c...
method marshalN__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue (line 2836) | func (ec *executionContext) marshalN__EnumValue2githubᚗcomᚋ99designsᚋg...
method marshalN__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField (line 2840) | func (ec *executionContext) marshalN__Field2githubᚗcomᚋ99designsᚋgqlge...
method marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue (line 2844) | func (ec *executionContext) marshalN__InputValue2githubᚗcomᚋ99designsᚋ...
method marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ (line 2848) | func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designs...
method marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType (line 2885) | func (ec *executionContext) marshalN__Type2githubᚗcomᚋ99designsᚋgqlgen...
method marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ (line 2889) | func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlge...
method marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType (line 2926) | func (ec *executionContext) marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlge...
method unmarshalN__TypeKind2string (line 2936) | func (ec *executionContext) unmarshalN__TypeKind2string(ctx context.Co...
method marshalN__TypeKind2string (line 2940) | func (ec *executionContext) marshalN__TypeKind2string(ctx context.Cont...
method unmarshalOBoolean2bool (line 2950) | func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context...
method marshalOBoolean2bool (line 2954) | func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, ...
method unmarshalOBoolean2ᚖbool (line 2958) | func (ec *executionContext) unmarshalOBoolean2ᚖbool(ctx context.Contex...
method marshalOBoolean2ᚖbool (line 2966) | func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context,...
method unmarshalOString2string (line 2973) | func (ec *executionContext) unmarshalOString2string(ctx context.Contex...
method marshalOString2string (line 2977) | func (ec *executionContext) marshalOString2string(ctx context.Context,...
method unmarshalOString2ᚖstring (line 2981) | func (ec *executionContext) unmarshalOString2ᚖstring(ctx context.Conte...
method marshalOString2ᚖstring (line 2989) | func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context...
method marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ (line 2996) | func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋ...
method marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ (line 3036) | func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlg...
method marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ (line 3076) | func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designs...
method marshalO__Schema2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema (line 3116) | func (ec *executionContext) marshalO__Schema2githubᚗcomᚋ99designsᚋgqlg...
method marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema (line 3120) | func (ec *executionContext) marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgql...
method marshalO__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType (line 3127) | func (ec *executionContext) marshalO__Type2githubᚗcomᚋ99designsᚋgqlgen...
method marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ (line 3131) | func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlge...
method marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType (line 3171) | func (ec *executionContext) marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlge...
FILE: 4-api/3_graphql/gqlgen_full/gqlgen4/models_gen.go
type User (line 5) | type User struct
FILE: 4-api/3_graphql/gqlgen_full/gqlgen4/photo.go
type Photo (line 8) | type Photo struct
method Id (line 18) | func (ph *Photo) Id() string {
FILE: 4-api/3_graphql/gqlgen_full/gqlgen4/resolver.go
type Resolver (line 13) | type Resolver struct
method Mutation (line 18) | func (r *Resolver) Mutation() MutationResolver {
method Photo (line 21) | func (r *Resolver) Photo() PhotoResolver {
method User (line 24) | func (r *Resolver) User() UserResolver {
method Query (line 27) | func (r *Resolver) Query() QueryResolver {
type mutationResolver (line 31) | type mutationResolver struct
method RatePhoto (line 33) | func (r *mutationResolver) RatePhoto(ctx context.Context, id string, d...
type userResolver (line 47) | type userResolver struct
method Photos (line 49) | func (r *userResolver) Photos(ctx context.Context, obj *User, count in...
type photoResolver (line 62) | type photoResolver struct
method ID (line 64) | func (r *photoResolver) ID(ctx context.Context, obj *Photo) (string, e...
method User (line 68) | func (r *photoResolver) User(ctx context.Context, obj *Photo) (*User, ...
type queryResolver (line 77) | type queryResolver struct
method Timeline (line 79) | func (r *queryResolver) Timeline(ctx context.Context) ([]*Photo, error) {
method User (line 88) | func (r *queryResolver) User(ctx context.Context, userID string) (*Use...
method Photos (line 94) | func (r *queryResolver) Photos(ctx context.Context, userID string) ([]...
FILE: 4-api/3_graphql/gqlgen_full/gqlgen4/server/server.go
function UserLoaderMiddleware (line 61) | func UserLoaderMiddleware(resolver *gqlgen.Resolver, next http.Handler) ...
function AuthMiddleware (line 86) | func AuthMiddleware(next http.Handler) http.Handler {
function main (line 95) | func main() {
FILE: 4-api/3_graphql/gqlgen_full/gqlgen4/userloader_gen.go
type UserLoaderConfig (line 11) | type UserLoaderConfig struct
function NewUserLoader (line 23) | func NewUserLoader(config UserLoaderConfig) *UserLoader {
type UserLoader (line 32) | type UserLoader struct
method Load (line 64) | func (l *UserLoader) Load(key uint) (*User, error) {
method LoadThunk (line 71) | func (l *UserLoader) LoadThunk(key uint) func() (*User, error) {
method LoadAll (line 114) | func (l *UserLoader) LoadAll(keys []uint) ([]*User, []error) {
method LoadAllThunk (line 132) | func (l *UserLoader) LoadAllThunk(keys []uint) func() ([]*User, []erro...
method Prime (line 150) | func (l *UserLoader) Prime(key uint, value *User) bool {
method Clear (line 164) | func (l *UserLoader) Clear(key uint) {
method unsafeSet (line 170) | func (l *UserLoader) unsafeSet(key uint, value *User) {
type userLoaderBatch (line 55) | type userLoaderBatch struct
method keyIndex (line 179) | func (b *userLoaderBatch) keyIndex(l *UserLoader, key uint) int {
method startTimer (line 203) | func (b *userLoaderBatch) startTimer(l *UserLoader) {
method end (line 219) | func (b *userLoaderBatch) end(l *UserLoader) {
FILE: 4-api/3_graphql/gqlgen_full/gqlgen5/generated.go
function NewExecutableSchema (line 22) | func NewExecutableSchema(cfg Config) graphql.ExecutableSchema {
type Config (line 30) | type Config struct
type ResolverRoot (line 36) | type ResolverRoot interface
type DirectiveRoot (line 43) | type DirectiveRoot struct
type ComplexityRoot (line 46) | type ComplexityRoot struct
type MutationResolver (line 76) | type MutationResolver interface
type PhotoResolver (line 80) | type PhotoResolver interface
type QueryResolver (line 84) | type QueryResolver interface
type UserResolver (line 89) | type UserResolver interface
type executableSchema (line 93) | type executableSchema struct
method Schema (line 99) | func (e *executableSchema) Schema() *ast.Schema {
method Complexity (line 103) | func (e *executableSchema) Complexity(typeName, field string, childCom...
method Exec (line 249) | func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseH...
type executionContext (line 289) | type executionContext struct
method introspectSchema (line 294) | func (ec *executionContext) introspectSchema() (*introspection.Schema,...
method introspectType (line 301) | func (ec *executionContext) introspectType(name string) (*introspectio...
method field_Mutation_ratePhoto_args (line 364) | func (ec *executionContext) field_Mutation_ratePhoto_args(ctx context....
method field_Mutation_uploadPhoto_args (line 386) | func (ec *executionContext) field_Mutation_uploadPhoto_args(ctx contex...
method field_Query___type_args (line 408) | func (ec *executionContext) field_Query___type_args(ctx context.Contex...
method field_Query_photos_args (line 422) | func (ec *executionContext) field_Query_photos_args(ctx context.Contex...
method field_Query_user_args (line 436) | func (ec *executionContext) field_Query_user_args(ctx context.Context,...
method field_User_photos_args (line 450) | func (ec *executionContext) field_User_photos_args(ctx context.Context...
method field___Type_enumValues_args (line 464) | func (ec *executionContext) field___Type_enumValues_args(ctx context.C...
method field___Type_fields_args (line 478) | func (ec *executionContext) field___Type_fields_args(ctx context.Conte...
method _Mutation_ratePhoto (line 500) | func (ec *executionContext) _Mutation_ratePhoto(ctx context.Context, f...
method _Mutation_uploadPhoto (line 541) | func (ec *executionContext) _Mutation_uploadPhoto(ctx context.Context,...
method _Photo_id (line 582) | func (ec *executionContext) _Photo_id(ctx context.Context, field graph...
method _Photo_user (line 616) | func (ec *executionContext) _Photo_user(ctx context.Context, field gra...
method _Photo_url (line 650) | func (ec *executionContext) _Photo_url(ctx context.Context, field grap...
method _Photo_comment (line 684) | func (ec *executionContext) _Photo_comment(ctx context.Context, field ...
method _Photo_rating (line 718) | func (ec *executionContext) _Photo_rating(ctx context.Context, field g...
method _Photo_liked (line 752) | func (ec *executionContext) _Photo_liked(ctx context.Context, field gr...
method _Query_timeline (line 786) | func (ec *executionContext) _Query_timeline(ctx context.Context, field...
method _Query_user (line 820) | func (ec *executionContext) _Query_user(ctx context.Context, field gra...
method _Query_photos (line 861) | func (ec *executionContext) _Query_photos(ctx context.Context, field g...
method _Query___type (line 902) | func (ec *executionContext) _Query___type(ctx context.Context, field g...
method _Query___schema (line 940) | func (ec *executionContext) _Query___schema(ctx context.Context, field...
method _User_id (line 971) | func (ec *executionContext) _User_id(ctx context.Context, field graphq...
method _User_name (line 1005) | func (ec *executionContext) _User_name(ctx context.Context, field grap...
method _User_avatar (line 1039) | func (ec *executionContext) _User_avatar(ctx context.Context, field gr...
method _User_followed (line 1073) | func (ec *executionContext) _User_followed(ctx context.Context, field ...
method _User_photos (line 1107) | func (ec *executionContext) _User_photos(ctx context.Context, field gr...
method ___Directive_name (line 1148) | func (ec *executionContext) ___Directive_name(ctx context.Context, fie...
method ___Directive_description (line 1182) | func (ec *executionContext) ___Directive_description(ctx context.Conte...
method ___Directive_locations (line 1213) | func (ec *executionContext) ___Directive_locations(ctx context.Context...
method ___Directive_args (line 1247) | func (ec *executionContext) ___Directive_args(ctx context.Context, fie...
method ___EnumValue_name (line 1281) | func (ec *executionContext) ___EnumValue_name(ctx context.Context, fie...
method ___EnumValue_description (line 1315) | func (ec *executionContext) ___EnumValue_description(ctx context.Conte...
method ___EnumValue_isDeprecated (line 1346) | func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Cont...
method ___EnumValue_deprecationReason (line 1380) | func (ec *executionContext) ___EnumValue_deprecationReason(ctx context...
method ___Field_name (line 1411) | func (ec *executionContext) ___Field_name(ctx context.Context, field g...
method ___Field_description (line 1445) | func (ec *executionContext) ___Field_description(ctx context.Context, ...
method ___Field_args (line 1476) | func (ec *executionContext) ___Field_args(ctx context.Context, field g...
method ___Field_type (line 1510) | func (ec *executionContext) ___Field_type(ctx context.Context, field g...
method ___Field_isDeprecated (line 1544) | func (ec *executionContext) ___Field_isDeprecated(ctx context.Context,...
method ___Field_deprecationReason (line 1578) | func (ec *executionContext) ___Field_deprecationReason(ctx context.Con...
method ___InputValue_name (line 1609) | func (ec *executionContext) ___InputValue_name(ctx context.Context, fi...
method ___InputValue_description (line 1643) | func (ec *executionContext) ___InputValue_description(ctx context.Cont...
method ___InputValue_type (line 1674) | func (ec *executionContext) ___InputValue_type(ctx context.Context, fi...
method ___InputValue_defaultValue (line 1708) | func (ec *executionContext) ___InputValue_defaultValue(ctx context.Con...
method ___Schema_types (line 1739) | func (ec *executionContext) ___Schema_types(ctx context.Context, field...
method ___Schema_queryType (line 1773) | func (ec *executionContext) ___Schema_queryType(ctx context.Context, f...
method ___Schema_mutationType (line 1807) | func (ec *executionContext) ___Schema_mutationType(ctx context.Context...
method ___Schema_subscriptionType (line 1838) | func (ec *executionContext) ___Schema_subscriptionType(ctx context.Con...
method ___Schema_directives (line 1869) | func (ec *executionContext) ___Schema_directives(ctx context.Context, ...
method ___Type_kind (line 1903) | func (ec *executionContext) ___Type_kind(ctx context.Context, field gr...
method ___Type_name (line 1937) | func (ec *executionContext) ___Type_name(ctx context.Context, field gr...
method ___Type_description (line 1968) | func (ec *executionContext) ___Type_description(ctx context.Context, f...
method ___Type_fields (line 1999) | func (ec *executionContext) ___Type_fields(ctx context.Context, field ...
method ___Type_interfaces (line 2037) | func (ec *executionContext) ___Type_interfaces(ctx context.Context, fi...
method ___Type_possibleTypes (line 2068) | func (ec *executionContext) ___Type_possibleTypes(ctx context.Context,...
method ___Type_enumValues (line 2099) | func (ec *executionContext) ___Type_enumValues(ctx context.Context, fi...
method ___Type_inputFields (line 2137) | func (ec *executionContext) ___Type_inputFields(ctx context.Context, f...
method ___Type_ofType (line 2168) | func (ec *executionContext) ___Type_ofType(ctx context.Context, field ...
method _Mutation (line 2213) | func (ec *executionContext) _Mutation(ctx context.Context, sel ast.Sel...
method _Photo (line 2249) | func (ec *executionContext) _Photo(ctx context.Context, sel ast.Select...
method _Query (line 2319) | func (ec *executionContext) _Query(ctx context.Context, sel ast.Select...
method _User (line 2391) | func (ec *executionContext) _User(ctx context.Context, sel ast.Selecti...
method ___Directive (line 2447) | func (ec *executionContext) ___Directive(ctx context.Context, sel ast....
method ___EnumValue (line 2486) | func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast....
method ___Field (line 2522) | func (ec *executionContext) ___Field(ctx context.Context, sel ast.Sele...
method ___InputValue (line 2568) | func (ec *executionContext) ___InputValue(ctx context.Context, sel ast...
method ___Schema (line 2604) | func (ec *executionContext) ___Schema(ctx context.Context, sel ast.Sel...
method ___Type (line 2645) | func (ec *executionContext) ___Type(ctx context.Context, sel ast.Selec...
method unmarshalNBoolean2bool (line 2690) | func (ec *executionContext) unmarshalNBoolean2bool(ctx context.Context...
method marshalNBoolean2bool (line 2694) | func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, ...
method unmarshalNID2string (line 2704) | func (ec *executionContext) unmarshalNID2string(ctx context.Context, v...
method marshalNID2string (line 2708) | func (ec *executionContext) marshalNID2string(ctx context.Context, sel...
method unmarshalNInt2int (line 2718) | func (ec *executionContext) unmarshalNInt2int(ctx context.Context, v i...
method marshalNInt2int (line 2722) | func (ec *executionContext) marshalNInt2int(ctx context.Context, sel a...
method marshalNPhoto2gqlgen5ᚐPhoto (line 2732) | func (ec *executionContext) marshalNPhoto2gqlgen5ᚐPhoto(ctx context.Co...
method marshalNPhoto2ᚕᚖgqlgen5ᚐPhotoᚄ (line 2736) | func (ec *executionContext) marshalNPhoto2ᚕᚖgqlgen5ᚐPhotoᚄ(ctx context...
method marshalNPhoto2ᚖgqlgen5ᚐPhoto (line 2773) | func (ec *executionContext) marshalNPhoto2ᚖgqlgen5ᚐPhoto(ctx context.C...
method unmarshalNString2string (line 2783) | func (ec *executionContext) unmarshalNString2string(ctx context.Contex...
method marshalNString2string (line 2787) | func (ec *executionContext) marshalNString2string(ctx context.Context,...
method unmarshalNUpload2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚐUpload (line 2797) | func (ec *executionContext) unmarshalNUpload2githubᚗcomᚋ99designsᚋgqlg...
method marshalNUpload2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚐUpload (line 2801) | func (ec *executionContext) marshalNUpload2githubᚗcomᚋ99designsᚋgqlgen...
method marshalNUser2gqlgen5ᚐUser (line 2811) | func (ec *executionContext) marshalNUser2gqlgen5ᚐUser(ctx context.Cont...
method marshalNUser2ᚖgqlgen5ᚐUser (line 2815) | func (ec *executionContext) marshalNUser2ᚖgqlgen5ᚐUser(ctx context.Con...
method marshalN__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective (line 2825) | func (ec *executionContext) marshalN__Directive2githubᚗcomᚋ99designsᚋg...
method marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ (line 2829) | func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋ...
method unmarshalN__DirectiveLocation2string (line 2866) | func (ec *executionContext) unmarshalN__DirectiveLocation2string(ctx c...
method marshalN__DirectiveLocation2string (line 2870) | func (ec *executionContext) marshalN__DirectiveLocation2string(ctx con...
method unmarshalN__DirectiveLocation2ᚕstringᚄ (line 2880) | func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstringᚄ(ctx...
method marshalN__DirectiveLocation2ᚕstringᚄ (line 2900) | func (ec *executionContext) marshalN__DirectiveLocation2ᚕstringᚄ(ctx c...
method marshalN__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue (line 2937) | func (ec *executionContext) marshalN__EnumValue2githubᚗcomᚋ99designsᚋg...
method marshalN__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField (line 2941) | func (ec *executionContext) marshalN__Field2githubᚗcomᚋ99designsᚋgqlge...
method marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue (line 2945) | func (ec *executionContext) marshalN__InputValue2githubᚗcomᚋ99designsᚋ...
method marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ (line 2949) | func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designs...
method marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType (line 2986) | func (ec *executionContext) marshalN__Type2githubᚗcomᚋ99designsᚋgqlgen...
method marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ (line 2990) | func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlge...
method marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType (line 3027) | func (ec *executionContext) marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlge...
method unmarshalN__TypeKind2string (line 3037) | func (ec *executionContext) unmarshalN__TypeKind2string(ctx context.Co...
method marshalN__TypeKind2string (line 3041) | func (ec *executionContext) marshalN__TypeKind2string(ctx context.Cont...
method unmarshalOBoolean2bool (line 3051) | func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context...
method marshalOBoolean2bool (line 3055) | func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, ...
method unmarshalOBoolean2ᚖbool (line 3059) | func (ec *executionContext) unmarshalOBoolean2ᚖbool(ctx context.Contex...
method marshalOBoolean2ᚖbool (line 3067) | func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context,...
method unmarshalOString2string (line 3074) | func (ec *executionContext) unmarshalOString2string(ctx context.Contex...
method marshalOString2string (line 3078) | func (ec *executionContext) marshalOString2string(ctx context.Context,...
method unmarshalOString2ᚖstring (line 3082) | func (ec *executionContext) unmarshalOString2ᚖstring(ctx context.Conte...
method marshalOString2ᚖstring (line 3090) | func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context...
method marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ (line 3097) | func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋ...
method marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ (line 3137) | func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlg...
method marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ (line 3177) | func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designs...
method marshalO__Schema2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema (line 3217) | func (ec *executionContext) marshalO__Schema2githubᚗcomᚋ99designsᚋgqlg...
method marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema (line 3221) | func (ec *executionContext) marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgql...
method marshalO__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType (line 3228) | func (ec *executionContext) marshalO__Type2githubᚗcomᚋ99designsᚋgqlgen...
method marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ (line 3232) | func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlge...
method marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType (line 3272) | func (ec *executionContext) marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlge...
FILE: 4-api/3_graphql/gqlgen_full/gqlgen5/models_gen.go
type User (line 5) | type User struct
FILE: 4-api/3_graphql/gqlgen_full/gqlgen5/photo.go
type Photo (line 8) | type Photo struct
method Id (line 18) | func (ph *Photo) Id() string {
FILE: 4-api/3_graphql/gqlgen_full/gqlgen5/resolver.go
type Resolver (line 17) | type Resolver struct
method Mutation (line 22) | func (r *Resolver) Mutation() MutationResolver {
method Photo (line 25) | func (r *Resolver) Photo() PhotoResolver {
method User (line 28) | func (r *Resolver) User() UserResolver {
method Query (line 31) | func (r *Resolver) Query() QueryResolver {
type mutationResolver (line 35) | type mutationResolver struct
method RatePhoto (line 37) | func (r *mutationResolver) RatePhoto(ctx context.Context, id string, d...
method UploadPhoto (line 51) | func (r *mutationResolver) UploadPhoto(ctx context.Context, comment st...
type userResolver (line 72) | type userResolver struct
method Photos (line 74) | func (r *userResolver) Photos(ctx context.Context, obj *User, count in...
type photoResolver (line 87) | type photoResolver struct
method ID (line 89) | func (r *photoResolver) ID(ctx context.Context, obj *Photo) (string, e...
method User (line 93) | func (r *photoResolver) User(ctx context.Context, obj *Photo) (*User, ...
type queryResolver (line 102) | type queryResolver struct
method Timeline (line 104) | func (r *queryResolver) Timeline(ctx context.Context) ([]*Photo, error) {
method User (line 113) | func (r *queryResolver) User(ctx context.Context, userID string) (*Use...
method Photos (line 119) | func (r *queryResolver) Photos(ctx context.Context, userID string) ([]...
FILE: 4-api/3_graphql/gqlgen_full/gqlgen5/server/server.go
function UserLoaderMiddleware (line 81) | func UserLoaderMiddleware(resolver *gqlgen.Resolver, next http.Handler) ...
function AuthMiddleware (line 109) | func AuthMiddleware(next http.Handler) http.Handler {
function main (line 118) | func main() {
FILE: 4-api/3_graphql/gqlgen_full/gqlgen5/userloader_gen.go
type UserLoaderConfig (line 11) | type UserLoaderConfig struct
function NewUserLoader (line 23) | func NewUserLoader(config UserLoaderConfig) *UserLoader {
type UserLoader (line 32) | type UserLoader struct
method Load (line 64) | func (l *UserLoader) Load(key uint) (*User, error) {
method LoadThunk (line 71) | func (l *UserLoader) LoadThunk(key uint) func() (*User, error) {
method LoadAll (line 114) | func (l *UserLoader) LoadAll(keys []uint) ([]*User, []error) {
method LoadAllThunk (line 132) | func (l *UserLoader) LoadAllThunk(keys []uint) func() ([]*User, []erro...
method Prime (line 150) | func (l *UserLoader) Prime(key uint, value *User) bool {
method Clear (line 164) | func (l *UserLoader) Clear(key uint) {
method unsafeSet (line 170) | func (l *UserLoader) unsafeSet(key uint, value *User) {
type userLoaderBatch (line 55) | type userLoaderBatch struct
method keyIndex (line 179) | func (b *userLoaderBatch) keyIndex(l *UserLoader, key uint) int {
method startTimer (line 203) | func (b *userLoaderBatch) startTimer(l *UserLoader) {
method end (line 219) | func (b *userLoaderBatch) end(l *UserLoader) {
FILE: 4-api/3_graphql/gqlgen_full/gqlgen6/generated.go
function NewExecutableSchema (line 23) | func NewExecutableSchema(cfg Config) graphql.ExecutableSchema {
type Config (line 31) | type Config struct
type ResolverRoot (line 37) | type ResolverRoot interface
type DirectiveRoot (line 44) | type DirectiveRoot struct
type ComplexityRoot (line 50) | type ComplexityRoot struct
type MutationResolver (line 80) | type MutationResolver interface
type PhotoResolver (line 84) | type PhotoResolver interface
type QueryResolver (line 88) | type QueryResolver interface
type UserResolver (line 93) | type UserResolver interface
type executableSchema (line 97) | type executableSchema struct
method Schema (line 103) | func (e *executableSchema) Schema() *ast.Schema {
method Complexity (line 107) | func (e *executableSchema) Complexity(typeName, field string, childCom...
method Query (line 253) | func (e *executableSchema) Query(ctx context.Context, op *ast.Operatio...
method Mutation (line 270) | func (e *executableSchema) Mutation(ctx context.Context, op *ast.Opera...
method Subscription (line 287) | func (e *executableSchema) Subscription(ctx context.Context, op *ast.O...
type executionContext (line 291) | type executionContext struct
method introspectSchema (line 296) | func (ec *executionContext) introspectSchema() (*introspection.Schema,...
method introspectType (line 303) | func (ec *executionContext) introspectType(name string) (*introspectio...
method dir_validation_args (line 371) | func (ec *executionContext) dir_validation_args(ctx context.Context, r...
method field_Mutation_ratePhoto_args (line 385) | func (ec *executionContext) field_Mutation_ratePhoto_args(ctx context....
method field_Mutation_uploadPhoto_args (line 407) | func (ec *executionContext) field_Mutation_uploadPhoto_args(ctx contex...
method field_Query___type_args (line 446) | func (ec *executionContext) field_Query___type_args(ctx context.Contex...
method field_Query_photos_args (line 460) | func (ec *executionContext) field_Query_photos_args(ctx context.Contex...
method field_Query_user_args (line 474) | func (ec *executionContext) field_Query_user_args(ctx context.Context,...
method field_User_photos_args (line 488) | func (ec *executionContext) field_User_photos_args(ctx context.Context...
method field___Type_enumValues_args (line 502) | func (ec *executionContext) field___Type_enumValues_args(ctx context.C...
method field___Type_fields_args (line 516) | func (ec *executionContext) field___Type_fields_args(ctx context.Conte...
method _Mutation_ratePhoto (line 538) | func (ec *executionContext) _Mutation_ratePhoto(ctx context.Context, f...
method _Mutation_uploadPhoto (line 582) | func (ec *executionContext) _Mutation_uploadPhoto(ctx context.Context,...
method _Photo_id (line 626) | func (ec *executionContext) _Photo_id(ctx context.Context, field graph...
method _Photo_user (line 663) | func (ec *executionContext) _Photo_user(ctx context.Context, field gra...
method _Photo_url (line 700) | func (ec *executionContext) _Photo_url(ctx context.Context, field grap...
method _Photo_comment (line 737) | func (ec *executionContext) _Photo_comment(ctx context.Context, field ...
method _Photo_rating (line 774) | func (ec *executionContext) _Photo_rating(ctx context.Context, field g...
method _Photo_liked (line 811) | func (ec *executionContext) _Photo_liked(ctx context.Context, field gr...
method _Query_timeline (line 848) | func (ec *executionContext) _Query_timeline(ctx context.Context, field...
method _Query_user (line 885) | func (ec *executionContext) _Query_user(ctx context.Context, field gra...
method _Query_photos (line 929) | func (ec *executionContext) _Query_photos(ctx context.Context, field g...
method _Query___type (line 973) | func (ec *executionContext) _Query___type(ctx context.Context, field g...
method _Query___schema (line 1014) | func (ec *executionContext) _Query___schema(ctx context.Context, field...
method _User_id (line 1048) | func (ec *executionContext) _User_id(ctx context.Context, field graphq...
method _User_name (line 1085) | func (ec *executionContext) _User_name(ctx context.Context, field grap...
method _User_avatar (line 1122) | func (ec *executionContext) _User_avatar(ctx context.Context, field gr...
method _User_followed (line 1159) | func (ec *executionContext) _User_followed(ctx context.Context, field ...
method _User_photos (line 1196) | func (ec *executionContext) _User_photos(ctx context.Context, field gr...
method ___Directive_name (line 1260) | func (ec *executionContext) ___Directive_name(ctx context.Context, fie...
method ___Directive_description (line 1297) | func (ec *executionContext) ___Directive_description(ctx context.Conte...
method ___Directive_locations (line 1331) | func (ec *executionContext) ___Directive_locations(ctx context.Context...
method ___Directive_args (line 1368) | func (ec *executionContext) ___Directive_args(ctx context.Context, fie...
method ___EnumValue_name (line 1405) | func (ec *executionContext) ___EnumValue_name(ctx context.Context, fie...
method ___EnumValue_description (line 1442) | func (ec *executionContext) ___EnumValue_description(ctx context.Conte...
method ___EnumValue_isDeprecated (line 1476) | func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Cont...
method ___EnumValue_deprecationReason (line 1513) | func (ec *executionContext) ___EnumValue_deprecationReason(ctx context...
method ___Field_name (line 1547) | func (ec *executionContext) ___Field_name(ctx context.Context, field g...
method ___Field_description (line 1584) | func (ec *executionContext) ___Field_description(ctx context.Context, ...
method ___Field_args (line 1618) | func (ec *executionContext) ___Field_args(ctx context.Context, field g...
method ___Field_type (line 1655) | func (ec *executionContext) ___Field_type(ctx context.Context, field g...
method ___Field_isDeprecated (line 1692) | func (ec *executionContext) ___Field_isDeprecated(ctx context.Context,...
method ___Field_deprecationReason (line 1729) | func (ec *executionContext) ___Field_deprecationReason(ctx context.Con...
method ___InputValue_name (line 1763) | func (ec *executionContext) ___InputValue_name(ctx context.Context, fi...
method ___InputValue_description (line 1800) | func (ec *executionContext) ___InputValue_description(ctx context.Cont...
method ___InputValue_type (line 1834) | func (ec *executionContext) ___InputValue_type(ctx context.Context, fi...
method ___InputValue_defaultValue (line 1871) | func (ec *executionContext) ___InputValue_defaultValue(ctx context.Con...
method ___Schema_types (line 1905) | func (ec *executionContext) ___Schema_types(ctx context.Context, field...
method ___Schema_queryType (line 1942) | func (ec *executionContext) ___Schema_queryType(ctx context.Context, f...
method ___Schema_mutationType (line 1979) | func (ec *executionContext) ___Schema_mutationType(ctx context.Context...
method ___Schema_subscriptionType (line 2013) | func (ec *executionContext) ___Schema_subscriptionType(ctx context.Con...
method ___Schema_directives (line 2047) | func (ec *executionContext) ___Schema_directives(ctx context.Context, ...
method ___Type_kind (line 2084) | func (ec *executionContext) ___Type_kind(ctx context.Context, field gr...
method ___Type_name (line 2121) | func (ec *executionContext) ___Type_name(ctx context.Context, field gr...
method ___Type_description (line 2155) | func (ec *executionContext) ___Type_description(ctx context.Context, f...
method ___Type_fields (line 2189) | func (ec *executionContext) ___Type_fields(ctx context.Context, field ...
method ___Type_interfaces (line 2230) | func (ec *executionContext) ___Type_interfaces(ctx context.Context, fi...
method ___Type_possibleTypes (line 2264) | func (ec *executionContext) ___Type_possibleTypes(ctx context.Context,...
method ___Type_enumValues (line 2298) | func (ec *executionContext) ___Type_enumValues(ctx context.Context, fi...
method ___Type_inputFields (line 2339) | func (ec *executionContext) ___Type_inputFields(ctx context.Context, f...
method ___Type_ofType (line 2373) | func (ec *executionContext) ___Type_ofType(ctx context.Context, field ...
method _Mutation (line 2421) | func (ec *executionContext) _Mutation(ctx context.Context, sel ast.Sel...
method _Photo (line 2457) | func (ec *executionContext) _Photo(ctx context.Context, sel ast.Select...
method _Query (line 2527) | func (ec *executionContext) _Query(ctx context.Context, sel ast.Select...
method _User (line 2599) | func (ec *executionContext) _User(ctx context.Context, sel ast.Selecti...
method ___Directive (line 2655) | func (ec *executionContext) ___Directive(ctx context.Context, sel ast....
method ___EnumValue (line 2694) | func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast....
method ___Field (line 2730) | func (ec *executionContext) ___Field(ctx context.Context, sel ast.Sele...
method ___InputValue (line 2776) | func (ec *executionContext) ___InputValue(ctx context.Context, sel ast...
method ___Schema (line 2812) | func (ec *executionContext) ___Schema(ctx context.Context, sel ast.Sel...
method ___Type (line 2853) | func (ec *executionContext) ___Type(ctx context.Context, sel ast.Selec...
method unmarshalNBoolean2bool (line 2898) | func (ec *executionContext) unmarshalNBoolean2bool(ctx context.Context...
method marshalNBoolean2bool (line 2902) | func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, ...
method unmarshalNID2string (line 2912) | func (ec *executionContext) unmarshalNID2string(ctx context.Context, v...
method marshalNID2string (line 2916) | func (ec *executionContext) marshalNID2string(ctx context.Context, sel...
method unmarshalNInt2int (line 2926) | func (ec *executionContext) unmarshalNInt2int(ctx context.Context, v i...
method marshalNInt2int (line 2930) | func (ec *executionContext) marshalNInt2int(ctx context.Context, sel a...
method marshalNPhoto2gqlgen6ᚐPhoto (line 2940) | func (ec *executionContext) marshalNPhoto2gqlgen6ᚐPhoto(ctx context.Co...
method marshalNPhoto2ᚕᚖgqlgen6ᚐPhotoᚄ (line 2944) | func (ec *executionContext) marshalNPhoto2ᚕᚖgqlgen6ᚐPhotoᚄ(ctx context...
method marshalNPhoto2ᚖgqlgen6ᚐPhoto (line 2981) | func (ec *executionContext) marshalNPhoto2ᚖgqlgen6ᚐPhoto(ctx context.C...
method unmarshalNString2string (line 2991) | func (ec *executionContext) unmarshalNString2string(ctx context.Contex...
method marshalNString2string (line 2995) | func (ec *executionContext) marshalNString2string(ctx context.Context,...
method unmarshalNString2ᚕstringᚄ (line 3005) | func (ec *executionContext) unmarshalNString2ᚕstringᚄ(ctx context.Cont...
method marshalNString2ᚕstringᚄ (line 3025) | func (ec *executionContext) marshalNString2ᚕstringᚄ(ctx context.Contex...
method unmarshalNUpload2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚐUpload (line 3034) | func (ec *executionContext) unmarshalNUpload2githubᚗcomᚋ99designsᚋgqlg...
method marshalNUpload2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚐUpload (line 3038) | func (ec *executionContext) marshalNUpload2githubᚗcomᚋ99designsᚋgqlgen...
method marshalNUser2gqlgen6ᚐUser (line 3048) | func (ec *executionContext) marshalNUser2gqlgen6ᚐUser(ctx context.Cont...
method marshalNUser2ᚖgqlgen6ᚐUser (line 3052) | func (ec *executionContext) marshalNUser2ᚖgqlgen6ᚐUser(ctx context.Con...
method marshalN__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective (line 3062) | func (ec *executionContext) marshalN__Directive2githubᚗcomᚋ99designsᚋg...
method marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ (line 3066) | func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋ...
method unmarshalN__DirectiveLocation2string (line 3103) | func (ec *executionContext) unmarshalN__DirectiveLocation2string(ctx c...
method marshalN__DirectiveLocation2string (line 3107) | func (ec *executionContext) marshalN__DirectiveLocation2string(ctx con...
method unmarshalN__DirectiveLocation2ᚕstringᚄ (line 3117) | func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstringᚄ(ctx...
method marshalN__DirectiveLocation2ᚕstringᚄ (line 3137) | func (ec *executionContext) marshalN__DirectiveLocation2ᚕstringᚄ(ctx c...
method marshalN__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue (line 3174) | func (ec *executionContext) marshalN__EnumValue2githubᚗcomᚋ99designsᚋg...
method marshalN__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField (line 3178) | func (ec *executionContext) marshalN__Field2githubᚗcomᚋ99designsᚋgqlge...
method marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue (line 3182) | func (ec *executionContext) marshalN__InputValue2githubᚗcomᚋ99designsᚋ...
method marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ (line 3186) | func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designs...
method marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType (line 3223) | func (ec *executionContext) marshalN__Type2githubᚗcomᚋ99designsᚋgqlgen...
method marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ (line 3227) | func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlge...
method marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType (line 3264) | func (ec *executionContext) marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlge...
method unmarshalN__TypeKind2string (line 3274) | func (ec *executionContext) unmarshalN__TypeKind2string(ctx context.Co...
method marshalN__TypeKind2string (line 3278) | func (ec *executionContext) marshalN__TypeKind2string(ctx context.Cont...
method unmarshalOBoolean2bool (line 3288) | func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context...
method marshalOBoolean2bool (line 3292) | func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, ...
method unmarshalOBoolean2ᚖbool (line 3296) | func (ec *executionContext) unmarshalOBoolean2ᚖbool(ctx context.Contex...
method marshalOBoolean2ᚖbool (line 3304) | func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context,...
method unmarshalOString2string (line 3311) | func (ec *executionContext) unmarshalOString2string(ctx context.Contex...
method marshalOString2string (line 3315) | func (ec *executionContext) marshalOString2string(ctx context.Context,...
method unmarshalOString2ᚖstring (line 3319) | func (ec *executionContext) unmarshalOString2ᚖstring(ctx context.Conte...
method marshalOString2ᚖstring (line 3327) | func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context...
method marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ (line 3334) | func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋ...
method marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ (line 3374) | func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlg...
method marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ (line 3414) | func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designs...
method marshalO__Schema2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema (line 3454) | func (ec *executionContext) marshalO__Schema2githubᚗcomᚋ99designsᚋgqlg...
method marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema (line 3458) | func (ec *executionContext) marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgql...
method marshalO__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType (line 3465) | func (ec *executionContext) marshalO__Type2githubᚗcomᚋ99designsᚋgqlgen...
method marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ (line 3469) | func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlge...
method marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType (line 3509) | func (ec *executionContext) marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlge...
FILE: 4-api/3_graphql/gqlgen_full/gqlgen6/models_gen.go
type User (line 5) | type User struct
FILE: 4-api/3_graphql/gqlgen_full/gqlgen6/photo.go
type Photo (line 8) | type Photo struct
method Id (line 18) | func (ph *Photo) Id() string {
FILE: 4-api/3_graphql/gqlgen_full/gqlgen6/resolver.go
type Resolver (line 17) | type Resolver struct
method Mutation (line 22) | func (r *Resolver) Mutation() MutationResolver {
method Photo (line 25) | func (r *Resolver) Photo() PhotoResolver {
method User (line 28) | func (r *Resolver) User() UserResolver {
method Query (line 31) | func (r *Resolver) Query() QueryResolver {
type mutationResolver (line 35) | type mutationResolver struct
method RatePhoto (line 37) | func (r *mutationResolver) RatePhoto(ctx context.Context, id string, d...
method UploadPhoto (line 51) | func (r *mutationResolver) UploadPhoto(ctx context.Context, comment st...
type userResolver (line 72) | type userResolver struct
method Photos (line 74) | func (r *userResolver) Photos(ctx context.Context, obj *User, count in...
type photoResolver (line 87) | type photoResolver struct
method ID (line 89) | func (r *photoResolver) ID(ctx context.Context, obj *Photo) (string, e...
method User (line 93) | func (r *photoResolver) User(ctx context.Context, obj *Photo) (*User, ...
type queryResolver (line 102) | type queryResolver struct
method Timeline (line 104) | func (r *queryResolver) Timeline(ctx context.Context) ([]*Photo, error) {
method User (line 113) | func (r *queryResolver) User(ctx context.Context, userID string) (*Use...
method Photos (line 119) | func (r *queryResolver) Photos(ctx context.Context, userID string) ([]...
FILE: 4-api/3_graphql/gqlgen_full/gqlgen6/server/server.go
function UserLoaderMiddleware (line 109) | func UserLoaderMiddleware(resolver *gqlgen.Resolver, next http.Handler) ...
function AuthMiddleware (line 137) | func AuthMiddleware(next http.Handler) http.Handler {
function IsFollowed (line 153) | func IsFollowed(userID, currUserID uint) bool {
function CheckIsSubscribed (line 162) | func CheckIsSubscribed(ctx context.Context, obj interface{}, next graphq...
function noBadUrls (line 179) | func noBadUrls(vars map[string]interface{}) bool {
function noMatureLanguage (line 187) | func noMatureLanguage(vars map[string]interface{}) bool {
function CheckValidation (line 200) | func CheckValidation(ctx context.Context, obj interface{}, next graphql....
function main (line 220) | func main() {
FILE: 4-api/3_graphql/gqlgen_full/gqlgen6/userloader_gen.go
type UserLoaderConfig (line 11) | type UserLoaderConfig struct
function NewUserLoader (line 23) | func NewUserLoader(config UserLoaderConfig) *UserLoader {
type UserLoader (line 32) | type UserLoader struct
method Load (line 64) | func (l *UserLoader) Load(key uint) (*User, error) {
method LoadThunk (line 71) | func (l *UserLoader) LoadThunk(key uint) func() (*User, error) {
method LoadAll (line 114) | func (l *UserLoader) LoadAll(keys []uint) ([]*User, []error) {
method LoadAllThunk (line 132) | func (l *UserLoader) LoadAllThunk(keys []uint) func() ([]*User, []erro...
method Prime (line 150) | func (l *UserLoader) Prime(key uint, value *User) bool {
method Clear (line 164) | func (l *UserLoader) Clear(key uint) {
method unsafeSet (line 170) | func (l *UserLoader) unsafeSet(key uint, value *User) {
type userLoaderBatch (line 55) | type userLoaderBatch struct
method keyIndex (line 179) | func (b *userLoaderBatch) keyIndex(l *UserLoader, key uint) int {
method startTimer (line 203) | func (b *userLoaderBatch) startTimer(l *UserLoader) {
method end (line 219) | func (b *userLoaderBatch) end(l *UserLoader) {
FILE: 4-api/3_graphql/graphql-go/main.go
type Author (line 29) | type Author struct
type Book (line 33) | type Book struct
function executeQuery (line 234) | func executeQuery(query string, schema graphql.Schema) *graphql.Result {
function main (line 245) | func main() {
FILE: 4-api/4_swagger/docs/docs.go
type swaggerInfo (line 123) | type swaggerInfo struct
type s (line 142) | type s struct
method ReadDoc (line 144) | func (s *s) ReadDoc() string {
function init (line 166) | func init() {
FILE: 4-api/4_swagger/main.go
type myError (line 13) | type myError struct
function handleUsers (line 30) | func handleUsers(w http.ResponseWriter, r *http.Request) {
function main (line 48) | func main() {
FILE: 4-api/4_swagger/model/user.go
type User (line 3) | type User struct
type Error (line 9) | type Error struct
FILE: 4-api/5_sessions/main.go
type User (line 11) | type User struct
function RandStringRunes (line 21) | func RandStringRunes(n int) string {
type MyHandler (line 29) | type MyHandler struct
method Login (line 45) | func (api *MyHandler) Login(w http.ResponseWriter, r *http.Request) {
method Logout (line 72) | func (api *MyHandler) Logout(w http.ResponseWriter, r *http.Request) {
method Root (line 91) | func (api *MyHandler) Root(w http.ResponseWriter, r *http.Request) {
function NewMyHandler (line 34) | func NewMyHandler() *MyHandler {
function main (line 105) | func main() {
FILE: 4-api/6_jwt/main.go
function main (line 14) | func main() {
FILE: 4-api/7_oauth/main.go
constant APP_ID (line 15) | APP_ID = "7065390"
constant APP_KEY (line 16) | APP_KEY = "cQZe3Vvo4mHotmetUdXK"
constant APP_SECRET (line 17) | APP_SECRET = "1bbf49951bbf49951bbf49953b1bd486bb11bbf1bbf4995468b3d76e2c...
constant API_URL (line 18) | API_URL = "https://api.vk.com/method/users.get?fields=email,photo_50&...
type Response (line 21) | type Response struct
function main (line 30) | func main() {
FILE: 5-architecture/0_bad_example/api.go
type User (line 12) | type User struct
type TODO (line 17) | type TODO struct
function genRequestID (line 36) | func genRequestID() string {
function createUserHandler (line 40) | func createUserHandler(w http.ResponseWriter, r *http.Request) {
function allUsersHandler (line 106) | func allUsersHandler(w http.ResponseWriter, r *http.Request) {
function todoHandler (line 133) | func todoHandler(w http.ResponseWriter, r *http.Request) {
function main (line 179) | func main() {
FILE: 5-architecture/10_crudapp/cmd/crudapp/main.go
function main (line 18) | func main() {
FILE: 5-architecture/10_crudapp/internal/crudapp/middleware/accesslog.go
function AccessLog (line 11) | func AccessLog(logger *zap.SugaredLogger, next http.Handler) http.Handler {
FILE: 5-architecture/10_crudapp/internal/crudapp/middleware/auth.go
function Auth (line 21) | func Auth(sm *session.SessionsManager, next http.Handler) http.Handler {
FILE: 5-architecture/10_crudapp/internal/crudapp/middleware/panic.go
function Panic (line 8) | func Panic(next http.Handler) http.Handler {
FILE: 5-architecture/10_crudapp/internal/pkg/items/delivery/items.go
type ItemsHandler (line 17) | type ItemsHandler struct
method List (line 23) | func (h *ItemsHandler) List(w http.ResponseWriter, r *http.Request) {
method AddForm (line 41) | func (h *ItemsHandler) AddForm(w http.ResponseWriter, r *http.Request) {
method Add (line 49) | func (h *ItemsHandler) Add(w http.ResponseWriter, r *http.Request) {
method Edit (line 72) | func (h *ItemsHandler) Edit(w http.ResponseWriter, r *http.Request) {
method Update (line 97) | func (h *ItemsHandler) Update(w http.ResponseWriter, r *http.Request) {
method Delete (line 127) | func (h *ItemsHandler) Delete(w http.ResponseWriter, r *http.Request) {
FILE: 5-architecture/10_crudapp/internal/pkg/items/items.go
type Repository (line 5) | type Repository interface
FILE: 5-architecture/10_crudapp/internal/pkg/items/repository/repo.go
type itemsRepo (line 7) | type itemsRepo struct
method GetAll (line 18) | func (repo *itemsRepo) GetAll() ([]*models.Item, error) {
method GetByID (line 22) | func (repo *itemsRepo) GetByID(id uint32) (*models.Item, error) {
method Add (line 31) | func (repo *itemsRepo) Add(item *models.Item) (uint32, error) {
method Update (line 38) | func (repo *itemsRepo) Update(newItem *models.Item) (bool, error) {
method Delete (line 50) | func (repo *itemsRepo) Delete(id uint32) (bool, error) {
function NewRepo (line 12) | func NewRepo() *itemsRepo {
FILE: 5-architecture/10_crudapp/internal/pkg/models/item.go
type Item (line 3) | type Item struct
FILE: 5-architecture/10_crudapp/internal/pkg/models/session.go
type Session (line 10) | type Session struct
function NewSession (line 15) | func NewSession(userID uint32) *Session {
type sessKey (line 30) | type sessKey
function SessionFromContext (line 34) | func SessionFromContext(ctx context.Context) (*Session, error) {
FILE: 5-architecture/10_crudapp/internal/pkg/models/user.go
type User (line 5) | type User struct
FILE: 5-architecture/10_crudapp/internal/pkg/session/manager.go
type SessionsManager (line 10) | type SessionsManager struct
method Check (line 22) | func (sm *SessionsManager) Check(r *http.Request) (*models.Session, er...
method Create (line 39) | func (sm *SessionsManager) Create(w http.ResponseWriter, userID uint32...
method DestroyCurrent (line 56) | func (sm *SessionsManager) DestroyCurrent(w http.ResponseWriter, r *ht...
function NewSessionsMem (line 15) | func NewSessionsMem() *SessionsManager {
FILE: 5-architecture/10_crudapp/internal/pkg/user/delivery/user.go
type UserHandler (line 15) | type UserHandler struct
method Index (line 22) | func (h *UserHandler) Index(w http.ResponseWriter, r *http.Request) {
method Login (line 36) | func (h *UserHandler) Login(w http.ResponseWriter, r *http.Request) {
method Logout (line 52) | func (h *UserHandler) Logout(w http.ResponseWriter, r *http.Request) {
method GetUserByID (line 57) | func (h *UserHandler) GetUserByID(login string) (*models.User, error) {
FILE: 5-architecture/10_crudapp/internal/pkg/user/delivery/user_test.go
function TestGetByID (line 13) | func TestGetByID(t *testing.T) {
FILE: 5-architecture/10_crudapp/internal/pkg/user/mock/mock_repo.go
type MockRepository (line 14) | type MockRepository struct
method EXPECT (line 32) | func (m *MockRepository) EXPECT() *MockRepositoryMockRecorder {
method Authorize (line 37) | func (m *MockRepository) Authorize(arg0, arg1 string) (*models.User, e...
method GetByLogin (line 52) | func (m *MockRepository) GetByLogin(arg0 string) (*models.User, error) {
type MockRepositoryMockRecorder (line 20) | type MockRepositoryMockRecorder struct
method Authorize (line 46) | func (mr *MockRepositoryMockRecorder) Authorize(arg0, arg1 interface{}...
method GetByLogin (line 61) | func (mr *MockRepositoryMockRecorder) GetByLogin(arg0 interface{}) *go...
function NewMockRepository (line 25) | func NewMockRepository(ctrl *gomock.Controller) *MockRepository {
FILE: 5-architecture/10_crudapp/internal/pkg/user/repository/user.go
type UserRepo (line 7) | type UserRepo struct
method Authorize (line 23) | func (repo *UserRepo) Authorize(login, pass string) (*models.User, err...
function NewUserRepo (line 11) | func NewUserRepo() *UserRepo {
FILE: 5-architecture/10_crudapp/internal/pkg/user/user.go
type Repository (line 7) | type Repository interface
FILE: 5-architecture/1_routers/0_httprouter/0_httprouter.go
function List (line 11) | func List(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
function Get (line 15) | func Get(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
function Create (line 23) | func Create(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
function Update (line 31) | func Update(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
function main (line 35) | func main() {
FILE: 5-architecture/1_routers/1_fasthttp/1_fasthttp.go
function Index (line 12) | func Index(ctx *fasthttp.RequestCtx) {
function GetUser (line 23) | func GetUser(ctx *fasthttp.RequestCtx) {
function main (line 27) | func main() {
FILE: 5-architecture/1_routers/2_gorilla/2_gorilla.go
function List (line 11) | func List(w http.ResponseWriter, r *http.Request) {
function Get (line 15) | func Get(w http.ResponseWriter, r *http.Request) {
function Create (line 24) | func Create(w http.ResponseWriter, r *http.Request) {
function Update (line 32) | func Update(w http.ResponseWriter, r *http.Request) {
function main (line 37) | func main() {
FILE: 5-architecture/1_routers/3_multiple/3_multiple.go
function RegularRequest (line 12) | func RegularRequest(w http.ResponseWriter, r *http.Request) {
function FastRequest (line 16) | func FastRequest(w http.ResponseWriter, r *http.Request, params httprout...
function ComplexRequest (line 20) | func ComplexRequest(w http.ResponseWriter, r *http.Request) {
function main (line 24) | func main() {
FILE: 5-architecture/2_middleware/1_middleware/1_middleware.go
function mainPage (line 9) | func mainPage(w http.ResponseWriter, r *http.Request) {
function loginPage (line 23) | func loginPage(w http.ResponseWriter, r *http.Request) {
function logoutPage (line 34) | func logoutPage(w http.ResponseWriter, r *http.Request) {
function adminIndex (line 47) | func adminIndex(w http.ResponseWriter, r *http.Request) {
function panicPage (line 52) | func panicPage(w http.ResponseWriter, r *http.Request) {
function pageWithAllChecks (line 58) | func pageWithAllChecks(w http.ResponseWriter, r *http.Request) {
function adminAuthMiddleware (line 83) | func adminAuthMiddleware(next http.Handler) http.Handler {
function accessLogMiddleware (line 97) | func accessLogMiddleware(next http.Handler) http.Handler {
function panicMiddleware (line 107) | func panicMiddleware(next http.Handler) http.Handler {
function main (line 122) | func main() {
FILE: 5-architecture/2_middleware/2_context_value/2_context_value.go
constant AvgSleep (line 14) | AvgSleep = 50
function trackContextTimings (line 16) | func trackContextTimings(ctx context.Context, metricName string, start t...
type Timing (line 39) | type Timing struct
type ctxTimings (line 44) | type ctxTimings struct
type key (line 51) | type key
constant timingsKey (line 53) | timingsKey key = 1
function logContextTimings (line 55) | func logContextTimings(ctx context.Context, path string, start time.Time) {
function timingMiddleware (line 76) | func timingMiddleware(next http.Handler) http.Handler {
function emulateWork (line 89) | func emulateWork(ctx context.Context, workName string) {
function loadPostsHandle (line 96) | func loadPostsHandle(w http.ResponseWriter, req *http.Request) {
function main (line 110) | func main() {
FILE: 5-architecture/3_errors/1_basic_err/1_basic_err.go
function getRemoteResource (line 13) | func getRemoteResource() error {
function handler (line 28) | func handler(w http.ResponseWriter, r *http.Request) {
function main (line 40) | func main() {
FILE: 5-architecture/3_errors/2_named_err/2_named_err.go
function getRemoteResource (line 16) | func getRemoteResource() error {
function handler (line 25) | func handler(w http.ResponseWriter, r *http.Request) {
function main (line 40) | func main() {
FILE: 5-architecture/3_errors/3_pkg_err/3_pkg_err.go
function getRemoteResource (line 16) | func getRemoteResource() error {
function handler (line 26) | func handler(w http.ResponseWriter, r *http.Request) {
function main (line 43) | func main() {
FILE: 5-architecture/3_errors/4_own_err/4_own_err.go
type HTTPError (line 13) | type HTTPError struct
type ResourceError (line 19) | type ResourceError struct
method Error (line 25) | func (re *ResourceError) Error() string {
function getRemoteResource (line 33) | func getRemoteResource() error {
function handler (line 42) | func handler(w http.ResponseWriter, r *http.Request) {
function main (line 59) | func main() {
FILE: 5-architecture/3_errors/5_new_errors/5_new_errors.go
type MyOwnError (line 12) | type MyOwnError struct
method Error (line 17) | func (e MyOwnError) Error() string {
function someJob (line 28) | func someJob() error {
function jobWrapper (line 43) | func jobWrapper() error {
function main (line 48) | func main() {
FILE: 5-architecture/4_validation/validation.go
type SendMessage (line 16) | type SendMessage struct
function handler (line 25) | func handler(w http.ResponseWriter, r *http.Request) {
function main (line 55) | func main() {
function init (line 61) | func init() {
FILE: 5-architecture/5_logging/main.go
function mainPage (line 14) | func mainPage(w http.ResponseWriter, r *http.Request) {
type AccessLogger (line 18) | type AccessLogger struct
method accessLogMiddleware (line 24) | func (ac *AccessLogger) accessLogMiddleware(next http.Handler) http.Ha...
function main (line 55) | func main() {
FILE: 5-architecture/6_websockets/main.go
function sendNewMsgNotifications (line 23) | func sendNewMsgNotifications(client *websocket.Conn) {
function main (line 40) | func main() {
function newMessage (line 60) | func newMessage() []byte {
FILE: 5-architecture/7_frameworks/echo/main.go
constant listenAddr (line 13) | listenAddr = "127.0.0.1:8080"
function main (line 15) | func main() {
FILE: 5-architecture/7_frameworks/echo/middleware/error.go
function ErrorHandler (line 11) | func ErrorHandler(err error, ctx echo.Context) {
FILE: 5-architecture/7_frameworks/echo/middleware/panic.go
function PanicMiddleware (line 9) | func PanicMiddleware(next echo.HandlerFunc) echo.HandlerFunc {
FILE: 5-architecture/7_frameworks/echo/middleware/request_id.go
function RequestIDMiddleware (line 10) | func RequestIDMiddleware(next echo.HandlerFunc) echo.HandlerFunc {
FILE: 5-architecture/7_frameworks/echo/model/user.go
type User (line 3) | type User struct
FILE: 5-architecture/7_frameworks/echo/user/delivery/http/hander_test.go
function TestGetUser (line 16) | func TestGetUser(t *testing.T) {
FILE: 5-architecture/7_frameworks/echo/user/delivery/http/handler.go
type userHandler (line 11) | type userHandler struct
method GetUser (line 24) | func (h *userHandler) GetUser(ctx echo.Context) error {
method GetAllUsers (line 28) | func (h *userHandler) GetAllUsers(ctx echo.Context) error {
method CreateUser (line 32) | func (h *userHandler) CreateUser(ctx echo.Context) error {
function NewUserHandler (line 15) | func NewUserHandler(e *echo.Echo, us user.Usecase) {
FILE: 5-architecture/7_frameworks/echo/user/repository.go
type Repository (line 11) | type Repository interface
FILE: 5-architecture/7_frameworks/echo/user/repository/memory.go
function NewUserMemoryRepository (line 10) | func NewUserMemoryRepository() user.Repository {
type UserMemoryRepository (line 16) | type UserMemoryRepository struct
method GetUser (line 21) | func (db *UserMemoryRepository) GetUser(username string) (model.User, ...
method GetAllUsers (line 25) | func (db *UserMemoryRepository) GetAllUsers() ([]model.User, error) {
method InsertUser (line 38) | func (db *UserMemoryRepository) InsertUser(u model.User) error {
FILE: 5-architecture/7_frameworks/echo/user/usecase.go
type Usecase (line 5) | type Usecase interface
FILE: 5-architecture/7_frameworks/echo/user/usecase/usecase.go
function NewUserUsecase (line 8) | func NewUserUsecase(userRepo user.Repository) user.Usecase {
type userUsecase (line 12) | type userUsecase struct
method GetUser (line 16) | func (u userUsecase) GetUser(username string) (model.User, error) {
method GetAllUsers (line 20) | func (u userUsecase) GetAllUsers() ([]model.User, error) {
method CreateUser (line 24) | func (u userUsecase) CreateUser(user model.User) error {
FILE: 5-architecture/7_frameworks/echo/user/usecase_mock.go
type MockUsecase (line 14) | type MockUsecase struct
method EXPECT (line 32) | func (m *MockUsecase) EXPECT() *MockUsecaseMockRecorder {
method GetUser (line 37) | func (m *MockUsecase) GetUser(username string) (model.User, error) {
method GetAllUsers (line 52) | func (m *MockUsecase) GetAllUsers() ([]model.User, error) {
method CreateUser (line 67) | func (m *MockUsecase) CreateUser(user model.User) error {
type MockUsecaseMockRecorder (line 20) | type MockUsecaseMockRecorder struct
method GetUser (line 46) | func (mr *MockUsecaseMockRecorder) GetUser(username interface{}) *gomo...
method GetAllUsers (line 61) | func (mr *MockUsecaseMockRecorder) GetAllUsers() *gomock.Call {
method CreateUser (line 75) | func (mr *MockUsecaseMockRecorder) CreateUser(user interface{}) *gomoc...
function NewMockUsecase (line 25) | func NewMockUsecase(ctrl *gomock.Controller) *MockUsecase {
FILE: 6-databases/00_databases/_mysql/injection_db.sql
type `users` (line 2) | CREATE TABLE `users` (
FILE: 6-databases/00_databases/_mysql/items.sql
type `items` (line 7) | CREATE TABLE `items` (
FILE: 6-databases/00_databases/_postgres/items.sql
type items (line 5) | CREATE TABLE items (
FILE: 6-databases/01_mysql/main.go
type Item (line 15) | type Item struct
type Handler (line 22) | type Handler struct
method List (line 27) | func (h *Handler) List(w http.ResponseWriter, r *http.Request) {
method AddForm (line 54) | func (h *Handler) AddForm(w http.ResponseWriter, r *http.Request) {
method Add (line 62) | func (h *Handler) Add(w http.ResponseWriter, r *http.Request) {
method Edit (line 81) | func (h *Handler) Edit(w http.ResponseWriter, r *http.Request) {
method Update (line 101) | func (h *Handler) Update(w http.ResponseWriter, r *http.Request) {
method Delete (line 121) | func (h *Handler) Delete(w http.ResponseWriter, r *http.Request) {
function main (line 142) | func main() {
function panicOnErr (line 181) | func panicOnErr(err error) {
FILE: 6-databases/02_postgresql/main.go
type Item (line 15) | type Item struct
type Handler (line 22) | type Handler struct
method List (line 27) | func (h *Handler) List(w http.ResponseWriter, r *http.Request) {
method AddForm (line 55) | func (h *Handler) AddForm(w http.ResponseWriter, r *http.Request) {
method Add (line 63) | func (h *Handler) Add(w http.ResponseWriter, r *http.Request) {
method Edit (line 78) | func (h *Handler) Edit(w http.ResponseWriter, r *http.Request) {
method Update (line 97) | func (h *Handler) Update(w http.ResponseWriter, r *http.Request) {
method Delete (line 117) | func (h *Handler) Delete(w http.ResponseWriter, r *http.Request) {
function main (line 138) | func main() {
function panicOnErr (line 176) | func panicOnErr(err error) {
FILE: 6-databases/03_mysql_sql_injection/main.go
function main (line 24) | func main() {
function PanicOnErr (line 93) | func PanicOnErr(err error) {
FILE: 6-databases/04_mysql_sqlmock/item_repo.go
type Item (line 7) | type Item struct
type ItemRepository (line 14) | type ItemRepository struct
method ListAll (line 18) | func (repo *ItemRepository) ListAll() ([]*Item, error) {
method SelectByID (line 36) | func (repo *ItemRepository) SelectByID(id int64) (*Item, error) {
method Create (line 48) | func (repo *ItemRepository) Create(elem *Item) (int64, error) {
method Update (line 60) | func (repo *ItemRepository) Update(elem *Item) (int64, error) {
method Delete (line 78) | func (repo *ItemRepository) Delete(id int64) (int64, error) {
FILE: 6-databases/04_mysql_sqlmock/item_repo_test.go
function TestSelectByID (line 14) | func TestSelectByID(t *testing.T) {
function TestCreate (line 90) | func TestCreate(t *testing.T) {
FILE: 6-databases/04_mysql_sqlmock/main.go
type ItemCRUD (line 16) | type ItemCRUD interface
type Handler (line 24) | type Handler struct
method List (line 29) | func (h *Handler) List(w http.ResponseWriter, r *http.Request) {
method AddForm (line 48) | func (h *Handler) AddForm(w http.ResponseWriter, r *http.Request) {
method Add (line 56) | func (h *Handler) Add(w http.ResponseWriter, r *http.Request) {
method Edit (line 73) | func (h *Handler) Edit(w http.ResponseWriter, r *http.Request) {
method Update (line 96) | func (h *Handler) Update(w http.ResponseWriter, r *http.Request) {
method Delete (line 118) | func (h *Handler) Delete(w http.ResponseWriter, r *http.Request) {
function main (line 131) | func main() {
function panicOnErr (line 175) | func panicOnErr(err error) {
FILE: 6-databases/05_gorm/main.go
type Item (line 16) | type Item struct
method TableName (line 23) | func (Item) TableName() string {
method BeforeSave (line 27) | func (Item) BeforeSave() (err error) {
type Handler (line 33) | type Handler struct
method List (line 38) | func (h *Handler) List(w http.ResponseWriter, r *http.Request) {
method AddForm (line 57) | func (h *Handler) AddForm(w http.ResponseWriter, r *http.Request) {
method Add (line 65) | func (h *Handler) Add(w http.ResponseWriter, r *http.Request) {
method Edit (line 81) | func (h *Handler) Edit(w http.ResponseWriter, r *http.Request) {
method Update (line 105) | func (h *Handler) Update(w http.ResponseWriter, r *http.Request) {
method Delete (line 127) | func (h *Handler) Delete(w http.ResponseWriter, r *http.Request) {
function main (line 144) | func main() {
function __err_panic (line 180) | func __err_panic(err error) {
FILE: 6-databases/06_crudapp_db_tests/cmd/crudapp/main.go
function getMysql (line 25) | func getMysql() *sql.DB {
function getPostgres (line 36) | func getPostgres() *sql.DB {
function getSqlx (line 51) | func getSqlx() *sqlx.DB {
function getGorm (line 56) | func getGorm() *gorm.DB {
function main (line 66) | func main() {
FILE: 6-databases/06_crudapp_db_tests/pkg/handlers/items.go
type ItemRepositoryInterface (line 18) | type ItemRepositoryInterface interface
type ItemsHandler (line 26) | type ItemsHandler struct
method List (line 32) | func (h *ItemsHandler) List(w http.ResponseWriter, r *http.Request) {
method AddForm (line 52) | func (h *ItemsHandler) AddForm(w http.ResponseWriter, r *http.Request) {
method Add (line 65) | func (h *ItemsHandler) Add(w http.ResponseWriter, r *http.Request) {
method Edit (line 90) | func (h *ItemsHandler) Edit(w http.ResponseWriter, r *http.Request) {
method Update (line 117) | func (h *ItemsHandler) Update(w http.ResponseWriter, r *http.Request) {
method Delete (line 152) | func (h *ItemsHandler) Delete(w http.ResponseWriter, r *http.Request) {
FILE: 6-databases/06_crudapp_db_tests/pkg/handlers/items_mock.go
type MockItemRepositoryInterface (line 20) | type MockItemRepositoryInterface struct
method EXPECT (line 39) | func (m *MockItemRepositoryInterface) EXPECT() *MockItemRepositoryInte...
method Add (line 44) | func (m *MockItemRepositoryInterface) Add(arg0 *items.Item) (int64, er...
method Delete (line 59) | func (m *MockItemRepositoryInterface) Delete(arg0 int64) (int64, error) {
method GetAll (line 74) | func (m *MockItemRepositoryInterface) GetAll() ([]*items.Item, error) {
method GetByID (line 89) | func (m *MockItemRepositoryInterface) GetByID(arg0 int64) (*items.Item...
method Update (line 104) | func (m *MockItemRepositoryInterface) Update(arg0 *items.Item) (int64,...
type MockItemRepositoryInterfaceMockRecorder (line 27) | type MockItemRepositoryInterfaceMockRecorder struct
method Add (line 53) | func (mr *MockItemRepositoryInterfaceMockRecorder) Add(arg0 any) *gomo...
method Delete (line 68) | func (mr *MockItemRepositoryInterfaceMockRecorder) Delete(arg0 any) *g...
method GetAll (line 83) | func (mr *MockItemRepositoryInterfaceMockRecorder) GetAll() *gomock.Ca...
method GetByID (line 98) | func (mr *MockItemRepositoryInterfaceMockRecorder) GetByID(arg0 any) *...
method Update (line 113) | func (mr *MockItemRepositoryInterfaceMockRecorder) Update(arg0 any) *g...
function NewMockItemRepositoryInterface (line 32) | func NewMockItemRepositoryInterface(ctrl *gomock.Controller) *MockItemRe...
FILE: 6-databases/06_crudapp_db_tests/pkg/handlers/items_test.go
function TestItemsHandlerList (line 28) | func TestItemsHandlerList(t *testing.T) {
FILE: 6-databases/06_crudapp_db_tests/pkg/handlers/user.go
type UserHandler (line 13) | type UserHandler struct
method Index (line 20) | func (h *UserHandler) Index(w http.ResponseWriter, r *http.Request) {
method Login (line 34) | func (h *UserHandler) Login(w http.ResponseWriter, r *http.Request) {
method Logout (line 50) | func (h *UserHandler) Logout(w http.ResponseWriter, r *http.Request) {
FILE: 6-databases/06_crudapp_db_tests/pkg/items/item.go
type ItemZero (line 11) | type ItemZero struct
type Item (line 18) | type Item struct
method SetUpdated (line 26) | func (it *Item) SetUpdated(val uint32) {
method TableName (line 34) | func (i *Item) TableName() string {
method BeforeSave (line 38) | func (i *Item) BeforeSave(*gorm.DB) (err error) {
type Item0 (line 43) | type Item0 struct
FILE: 6-databases/06_crudapp_db_tests/pkg/items/item_repo_test.go
function TestGetByID (line 23) | func TestGetByID(t *testing.T) {
function TestCreate (line 102) | func TestCreate(t *testing.T) {
FILE: 6-databases/06_crudapp_db_tests/pkg/items/repo_gorm.go
type RepoGorm (line 9) | type RepoGorm struct
method GetAll (line 17) | func (repo *RepoGorm) GetAll() ([]*Item, error) {
method GetByID (line 27) | func (repo *RepoGorm) GetByID(id int64) (*Item, error) {
method Add (line 36) | func (repo *RepoGorm) Add(elem *Item) (int64, error) {
method Update (line 45) | func (repo *RepoGorm) Update(elem *Item) (int64, error) {
method Delete (line 57) | func (repo *RepoGorm) Delete(id int64) (int64, error) {
function NewGormRepository (line 13) | func NewGormRepository(db *gorm.DB) *RepoGorm {
FILE: 6-databases/06_crudapp_db_tests/pkg/items/repo_mysql.go
type RepoMysql (line 7) | type RepoMysql struct
method GetAll (line 15) | func (repo *RepoMysql) GetAll(limit int) ([]*Item, error) {
method GetByID (line 60) | func (repo *RepoMysql) GetByID(id int64) (*Item, error) {
method Add (line 73) | func (repo *RepoMysql) Add(elem *Item) (int64, error) {
method Update (line 85) | func (repo *RepoMysql) Update(elem *Item) (int64, error) {
method Delete (line 103) | func (repo *RepoMysql) Delete(id int64) (int64, error) {
function NewMysqlRepository (line 11) | func NewMysqlRepository(db *sql.DB) *RepoMysql {
FILE: 6-databases/06_crudapp_db_tests/pkg/items/repo_pgx.go
type RepoPgx (line 7) | type RepoPgx struct
method GetAll (line 15) | func (repo *RepoPgx) GetAll() ([]*Item, error) {
method GetByID (line 58) | func (repo *RepoPgx) GetByID(id int64) (*Item, error) {
method Add (line 70) | func (repo *RepoPgx) Add(elem *Item) (int64, error) {
method Update (line 83) | func (repo *RepoPgx) Update(elem *Item) (int64, error) {
method Delete (line 100) | func (repo *RepoPgx) Delete(id int64) (int64, error) {
function NewPgxRepository (line 11) | func NewPgxRepository(db *sql.DB) *RepoPgx {
FILE: 6-databases/06_crudapp_db_tests/pkg/items/repo_sqlx.go
type RepoSqlx (line 8) | type RepoSqlx struct
method GetAll (line 16) | func (repo *RepoSqlx) GetAll() ([]*Item, error) {
method GetAll_0 (line 25) | func (repo *RepoSqlx) GetAll_0() ([]*Item, error) {
method GetByID (line 43) | func (repo *RepoSqlx) GetByID(id int64) (*Item, error) {
method Add (line 52) | func (repo *RepoSqlx) Add(elem *Item) (int64, error) {
method Update (line 65) | func (repo *RepoSqlx) Update(elem *Item) (int64, error) {
method Delete (line 83) | func (repo *RepoSqlx) Delete(id int64) (int64, error) {
function NewSqlxRepository (line 12) | func NewSqlxRepository(db *sqlx.DB) *RepoSqlx {
FILE: 6-databases/06_crudapp_db_tests/pkg/middleware/accesslog.go
function AccessLog (line 11) | func AccessLog(logger *zap.SugaredLogger, next http.Handler) http.Handler {
FILE: 6-databases/06_crudapp_db_tests/pkg/middleware/auth.go
function Auth (line 20) | func Auth(sm *session.SessionsManager, next http.Handler) http.Handler {
FILE: 6-databases/06_crudapp_db_tests/pkg/middleware/panic.go
function Panic (line 7) | func Panic(next http.Handler) http.Handler {
FILE: 6-databases/06_crudapp_db_tests/pkg/session/manager.go
type SessionsManager (line 9) | type SessionsManager struct
method Check (line 21) | func (sm *SessionsManager) Check(r *http.Request) (*Session, error) {
method Create (line 38) | func (sm *SessionsManager) Create(w http.ResponseWriter, userID uint32...
method DestroyCurrent (line 55) | func (sm *SessionsManager) DestroyCurrent(w http.ResponseWriter, r *ht...
function NewSessionsMem (line 14) | func NewSessionsMem() *SessionsManager {
FILE: 6-databases/06_crudapp_db_tests/pkg/session/session.go
type Session (line 10) | type Session struct
function NewSession (line 15) | func NewSession(userID uint32) *Session {
type sessKey (line 30) | type sessKey
function SessionFromContext (line 34) | func SessionFromContext(ctx context.Context) (*Session, error) {
FILE: 6-databases/06_crudapp_db_tests/pkg/user/user.go
type User (line 5) | type User struct
type UserRepo (line 11) | type UserRepo struct
method Authorize (line 32) | func (repo *UserRepo) Authorize(login, pass string) (*User, error) {
function NewUserRepo (line 15) | func NewUserRepo() *UserRepo {
FILE: 6-databases/07_mongodb/main.go
type Item (line 18) | type Item struct
type Handler (line 25) | type Handler struct
method List (line 31) | func (h *Handler) List(w http.ResponseWriter, r *http.Request) {
method AddForm (line 52) | func (h *Handler) AddForm(w http.ResponseWriter, r *http.Request) {
method Add (line 60) | func (h *Handler) Add(w http.ResponseWriter, r *http.Request) {
method Edit (line 76) | func (h *Handler) Edit(w http.ResponseWriter, r *http.Request) {
method Update (line 99) | func (h *Handler) Update(w http.ResponseWriter, r *http.Request) {
method Delete (line 143) | func (h *Handler) Delete(w http.ResponseWriter, r *http.Request) {
function main (line 168) | func main() {
function panicOnError (line 214) | func panicOnError(err error) {
FILE: 6-databases/08_memcache/memcache.go
function main (line 10) | func main() {
FILE: 6-databases/09_redis_simple/cmds.go
function getRecord (line 15) | func getRecord(mkey string) (string, error) {
function main (line 30) | func main() {
function PanicOnErr (line 83) | func PanicOnErr(err error) {
FILE: 6-databases/10_redis/main.go
function checkSession (line 25) | func checkSession(r *http.Request) (*Session, error) {
function innerPage (line 39) | func innerPage(w http.ResponseWriter, r *http.Request) {
function loginPage (line 56) | func loginPage(w http.ResponseWriter, r *http.Request) {
function main (line 86) | func main() {
function logoutPage (line 105) | func logoutPage(w http.ResponseWriter, r *http.Request) {
FILE: 6-databases/10_redis/session.go
type Session (line 12) | type Session struct
type SessionID (line 17) | type SessionID struct
constant sessKeyLen (line 21) | sessKeyLen = 10
type SessionManager (line 23) | type SessionManager struct
method Create (line 33) | func (sm *SessionManager) Create(in *Session) (*SessionID, error) {
method Check (line 47) | func (sm *SessionManager) Check(in *SessionID) *Session {
method Delete (line 63) | func (sm *SessionManager) Delete(in *SessionID) {
function NewSessionManager (line 27) | func NewSessionManager(conn redis.Conn) *SessionManager {
function RandStringRunes (line 73) | func RandStringRunes(n int) string {
FILE: 6-databases/11_rabbit/form/form.go
type ImgResizeTask (line 28) | type ImgResizeTask struct
function mainPage (line 33) | func mainPage(w http.ResponseWriter, r *http.Request) {
function uploadPage (line 37) | func uploadPage(w http.ResponseWriter, r *http.Request) {
constant ImageResizeQueueName (line 96) | ImageResizeQueueName = "image_resize"
function main (line 107) | func main() {
function panicOnError (line 144) | func panicOnError(msg string, err error) {
function RandStringRunes (line 152) | func RandStringRunes(n int) string {
FILE: 6-databases/11_rabbit/resizer/resize_worker.go
type ImgResizeTask (line 16) | type ImgResizeTask struct
constant ImageResizeQueueName (line 22) | ImageResizeQueueName = "image_resize"
function main (line 33) | func main() {
function ResizeWorker (line 84) | func ResizeWorker(tasks <-chan amqp.Delivery) {
function ResizeImage (line 112) | func ResizeImage(originalPath string, resizedPath string, size uint) err...
function panicOnError (line 138) | func panicOnError(msg string, err error) {
FILE: 6-databases/12_kafka/form/form.go
type ImgResizeTask (line 28) | type ImgResizeTask struct
function mainPage (line 33) | func mainPage(w http.ResponseWriter, r *http.Request) {
function uploadPage (line 37) | func uploadPage(w http.ResponseWriter, r *http.Request) {
constant ImageResizeTopicName (line 91) | ImageResizeTopicName = "cool_topic"
function main (line 99) | func main() {
function panicOnError (line 131) | func panicOnError(msg string, err error) {
function RandStringRunes (line 139) | func RandStringRunes(n int) string {
FILE: 6-databases/12_kafka/resizer/resize_worker.go
type ImgResizeTask (line 19) | type ImgResizeTask struct
constant ImageResizeTopicName (line 25) | ImageResizeTopicName = "cool_topic"
type Consumer (line 37) | type Consumer struct
method Setup (line 41) | func (c *Consumer) Setup(sarama.ConsumerGroupSession) error {
method Cleanup (line 45) | func (c *Consumer) Cleanup(sarama.ConsumerGroupSession) error { return...
method ConsumeClaim (line 47) | func (c *Consumer) ConsumeClaim(sess sarama.ConsumerGroupSession, clai...
function main (line 75) | func main() {
function ResizeImage (line 131) | func ResizeImage(originalPath string, resizedPath string, size uint) err...
function panicOnError (line 157) | func panicOnError(msg string, err error) {
FILE: 6-databases/13_tarantool_simple/main.go
function main (line 17) | func main() {
FILE: 6-databases/14_tarantool/main.go
function checkSession (line 28) | func checkSession(r *http.Request) (*Session, error) {
function innerPage (line 46) | func innerPage(w http.ResponseWriter, r *http.Request) {
function loginPage (line 64) | func loginPage(w http.ResponseWriter, r *http.Request) {
function main (line 95) | func main() {
function logoutPage (line 118) | func logoutPage(w http.ResponseWriter, r *http.Request) {
FILE: 6-databases/14_tarantool/session.go
type Session (line 11) | type Session struct
type SessionID (line 16) | type SessionID struct
type SessionManager (line 20) | type SessionManager struct
method Create (line 30) | func (sm *SessionManager) Create(in *Session) (*SessionID, error) {
method Check (line 54) | func (sm *SessionManager) Check(in *SessionID) (*Session, error) {
method Delete (line 90) | func (sm *SessionManager) Delete(in *SessionID) {
function NewSessionManager (line 24) | func NewSessionManager(conn *tarantool.Connection) *SessionManager {
FILE: 6-databases/crudapp_mongo/cmd/crudapp/main.go
function getMongo (line 23) | func getMongo(cfg string) *mongo.Client {
function main (line 37) | func main() {
FILE: 6-databases/crudapp_mongo/pkg/handlers/items.go
type ItemRepositoryInterface (line 18) | type ItemRepositoryInterface interface
type ItemsHandler (line 26) | type ItemsHandler struct
method List (line 32) | func (h *ItemsHandler) List(w http.ResponseWriter, r *http.Request) {
method AddForm (line 52) | func (h *ItemsHandler) AddForm(w http.ResponseWriter, r *http.Request) {
method Add (line 65) | func (h *ItemsHandler) Add(w http.ResponseWriter, r *http.Request) {
method Edit (line 91) | func (h *ItemsHandler) Edit(w http.ResponseWriter, r *http.Request) {
method Update (line 118) | func (h *ItemsHandler) Update(w http.ResponseWriter, r *http.Request) {
method Delete (line 153) | func (h *ItemsHandler) Delete(w http.ResponseWriter, r *http.Request) {
FILE: 6-databases/crudapp_mongo/pkg/handlers/items_mock.go
type MockItemRepositoryInterface (line 16) | type MockItemRepositoryInterface struct
method EXPECT (line 34) | func (m *MockItemRepositoryInterface) EXPECT() *MockItemRepositoryInte...
method Add (line 39) | func (m *MockItemRepositoryInterface) Add(arg0 context.Context, arg1 *...
method Delete (line 54) | func (m *MockItemRepositoryInterface) Delete(arg0 string) (int64, erro...
method GetAll (line 69) | func (m *MockItemRepositoryInterface) GetAll() ([]*items.Item, error) {
method GetByID (line 84) | func (m *MockItemRepositoryInterface) GetByID(arg0 string) (*items.Ite...
method Update (line 99) | func (m *MockItemRepositoryInterface) Update(arg0 *items.Item) (int64,...
type MockItemRepositoryInterfaceMockRecorder (line 22) | type MockItemRepositoryInterfaceMockRecorder struct
method Add (line 48) | func (mr *MockItemRepositoryInterfaceMockRecorder) Add(arg0, arg1 inte...
method Delete (line 63) | func (mr *MockItemRepositoryInterfaceMockRecorder) Delete(arg0 interfa...
method GetAll (line 78) | func (mr *MockItemRepositoryInterfaceMockRecorder) GetAll() *gomock.Ca...
method GetByID (line 93) | func (mr *MockItemRepositoryInterfaceMockRecorder) GetByID(arg0 interf...
method Update (line 108) | func (mr *MockItemRepositoryInterfaceMockRecorder) Update(arg0 interfa...
function NewMockItemRepositoryInterface (line 27) | func NewMockItemRepositoryInterface(ctrl *gomock.Controller) *MockItemRe...
FILE: 6-databases/crudapp_mongo/pkg/handlers/items_test.go
function TestItemsHandlerList (line 29) | func TestItemsHandlerList(t *testing.T) {
FILE: 6-databases/crudapp_mongo/pkg/handlers/user.go
type UserHandler (line 13) | type UserHandler struct
method Index (line 20) | func (h *UserHandler) Index(w http.ResponseWriter, r *http.Request) {
method Login (line 34) | func (h *UserHandler) Login(w http.ResponseWriter, r *http.Request) {
method Logout (line 50) | func (h *UserHandler) Logout(w http.ResponseWriter, r *http.Request) {
FILE: 6-databases/crudapp_mongo/pkg/items/item.go
type Item (line 9) | type Item struct
method SetUpdated (line 17) | func (it *Item) SetUpdated(val uint32) {
FILE: 6-databases/crudapp_mongo/pkg/items/repo_mongo.go
type RepoMongo (line 11) | type RepoMongo struct
method GetAll (line 19) | func (repo *RepoMongo) GetAll() ([]*Item, error) {
method GetByID (line 29) | func (repo *RepoMongo) GetByID(id string) (*Item, error) {
method Add (line 39) | func (repo *RepoMongo) Add(ctx context.Context, elem *Item) (string, e...
method Update (line 49) | func (repo *RepoMongo) Update(elem *Item) (int64, error) {
method Delete (line 67) | func (repo *RepoMongo) Delete(id string) (int64, error) {
function NewMongoRepository (line 15) | func NewMongoRepository(coll *mongo.Collection) *RepoMongo {
FILE: 6-databases/crudapp_mongo/pkg/middleware/accesslog.go
function AccessLog (line 11) | func AccessLog(logger *zap.SugaredLogger, next http.Handler) http.Handler {
FILE: 6-databases/crudapp_mongo/pkg/middleware/auth.go
function Auth (line 20) | func Auth(sm *session.SessionsManager, next http.Handler) http.Handler {
FILE: 6-databases/crudapp_mongo/pkg/middleware/panic.go
function Panic (line 7) | func Panic(next http.Handler) http.Handler {
FILE: 6-databases/crudapp_mongo/pkg/session/manager.go
type SessionsManager (line 9) | type SessionsManager struct
method Check (line 21) | func (sm *SessionsManager) Check(r *http.Request) (*Session, error) {
method Create (line 38) | func (sm *SessionsManager) Create(w http.ResponseWriter, userID uint32...
method DestroyCurrent (line 55) | func (sm *SessionsManager) DestroyCurrent(w http.ResponseWriter, r *ht...
function NewSessionsMem (line 14) | func NewSessionsMem() *SessionsManager {
FILE: 6-databases/crudapp_mongo/pkg/session/session.go
type Session (line 10) | type Session struct
function NewSession (line 15) | func NewSession(userID uint32) *Session {
type sessKey (line 30) | type sessKey
function SessionFromContext (line 34) | func SessionFromContext(ctx context.Context) (*Session, error) {
FILE: 6-databases/crudapp_mongo/pkg/user/user.go
type User (line 5) | type User struct
type UserRepo (line 11) | type UserRepo struct
method Authorize (line 32) | func (repo *UserRepo) Authorize(login, pass string) (*User, error) {
function NewUserRepo (line 15) | func NewUserRepo() *UserRepo {
FILE: 6-databases/tcache/cache.go
type CacheItem (line 13) | type CacheItem struct
type CacheItemStore (line 18) | type CacheItemStore struct
type RebuildFunc (line 23) | type RebuildFunc
type TCache (line 25) | type TCache struct
method TGet (line 29) | func (tc *TCache) TGet(
method isTagsValid (line 69) | func (tc *TCache) isTagsValid(itemTags map[string]int) (bool, error) {
method rebuild (line 90) | func (tc *TCache) rebuild(
method checkLock (line 135) | func (tc *TCache) checkLock(mkey string) error {
method lockRebuild (line 149) | func (tc *TCache) lockRebuild(mkey string) (bool, error) {
method unlockRebuild (line 179) | func (tc *TCache) unlockRebuild(mkey string) {
method getCurrentItemTags (line 183) | func (tc *TCache) getCurrentItemTags(tags []string, ttl int32) (map[st...
FILE: 6-databases/tcache/main.go
function main (line 15) | func main() {
FILE: 6-databases/tcache/posts.go
type RSS (line 10) | type RSS struct
type Item (line 14) | type Item struct
function GetHabrPosts (line 19) | func GetHabrPosts() (*RSS, error) {
FILE: 7-security/1_passwords/1_salt.go
function hashPass (line 11) | func hashPass(salt []byte, plainPassword string) []byte {
function checkPass (line 17) | func checkPass(passHash []byte, plainPassword string) bool {
function passExample (line 24) | func passExample() {
FILE: 7-security/1_passwords/2_pass.go
function PasswordMD5 (line 22) | func PasswordMD5(plainPassword []byte) []byte {
function PasswordBcrypt (line 27) | func PasswordBcrypt(plainPassword []byte) []byte {
function PasswordPBKDF2 (line 33) | func PasswordPBKDF2(plainPassword []byte) []byte {
function PasswordScrypt (line 38) | func PasswordScrypt(plainPassword []byte) []byte {
function PasswordArgon2 (line 44) | func PasswordArgon2(plainPassword []byte) []byte {
function main (line 50) | func main() {
FILE: 7-security/1_passwords/2_pass_bench_test.go
function BenchmarkMD5 (line 9) | func BenchmarkMD5(b *testing.B) {
function BenchmarkBcrypt (line 15) | func BenchmarkBcrypt(b *testing.B) {
function BenchmarkPBKDF2 (line 21) | func BenchmarkPBKDF2(b *testing.B) {
function BenchmarkScrypt (line 27) | func BenchmarkScrypt(b *testing.B) {
function BenchmarkArgon2 (line 33) | func BenchmarkArgon2(b *testing.B) {
FILE: 7-security/2_csrf/csrf.go
type Msg (line 23) | type Msg struct
function main (line 83) | func main() {
function loginHandler (line 165) | func loginHandler(w http.ResponseWriter, r *http.Request) {
function checkSession (line 178) | func checkSession(r *http.Request) bool {
function PanicOnErr (line 195) | func PanicOnErr(err error) {
function RandStringRunes (line 203) | func RandStringRunes(n int) string {
FILE: 7-security/3_csrf_token/csrf.go
type Msg (line 24) | type Msg struct
type Session (line 30) | type Session struct
function main (line 89) | func main() {
function loginHandler (line 209) | func loginHandler(w http.ResponseWriter, r *http.Request) {
function checkSession (line 222) | func checkSession(r *http.Request) (*Session, error) {
function PanicOnErr (line 239) | func PanicOnErr(err error) {
function RandStringRunes (line 247) | func RandStringRunes(n int) string {
FILE: 7-security/3_csrf_token/token_crypt.go
type CryptToken (line 16) | type CryptToken struct
method Create (line 35) | func (tk *CryptToken) Create(s *Session, tokenExpTime int64) (string, ...
method Check (line 62) | func (tk *CryptToken) Check(s *Session, inputToken string) (bool, erro...
type TokenData (line 20) | type TokenData struct
function NewAesCryptHashToken (line 26) | func NewAesCryptHashToken(secret string) (*CryptToken, error) {
FILE: 7-security/3_csrf_token/token_jwt.go
type JwtToken (line 10) | type JwtToken struct
method Create (line 24) | func (tk *JwtToken) Create(s *Session, tokenExpTime int64) (string, er...
method parseSecretGetter (line 37) | func (tk *JwtToken) parseSecretGetter(token *jwt.Token) (interface{}, ...
method Check (line 45) | func (tk *JwtToken) Check(s *Session, inputToken string) (bool, error) {
function NewJwtToken (line 14) | func NewJwtToken(secret string) (*JwtToken, error) {
type JwtCsrfClaims (line 18) | type JwtCsrfClaims struct
FILE: 7-security/3_csrf_token/tokjen_hash.go
type HashToken (line 18) | type HashToken struct
method Create (line 26) | func (tk *HashToken) Create(s *Session, tokenExpTime int64) (string, e...
method Check (line 34) | func (tk *HashToken) Check(s *Session, inputToken string) (bool, error) {
function NewHMACHashToken (line 22) | func NewHMACHashToken(secret string) (*HashToken, error) {
FILE: 7-security/4_xss/xss.go
function checkSession (line 58) | func checkSession(r *http.Request) bool {
function main (line 74) | func main() {
function PanicOnErr (line 147) | func PanicOnErr(err error) {
function RandStringRunes (line 155) | func RandStringRunes(n int) string {
FILE: 7-security/5_xss_clean/xss_clean.go
function main (li
Condensed preview — 487 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (2,151K chars).
[
{
"path": ".gitignore",
"chars": 180,
"preview": ".DS_Store\n.idea\n.vscode\n\n# Tarantool output files\n*.xlog\n*.snap\n\n# Test data files\n6-databases/10_rabbit/images/*.jpg\n\n\n"
},
{
"path": ".gitmodules",
"chars": 276,
"preview": "[submodule \"5-architecture/8_clean_arch\"]\n\tpath = 5-architecture/8_clean_arch\n\turl = https://github.com/bxcodec/go-clean"
},
{
"path": "1-basics/1_basics/01_vars_1/01_vars_1.go",
"chars": 817,
"preview": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\t// значение по умолчанию\n\tvar num0 int\n\n\t// значение при инициализации\n\tvar n"
},
{
"path": "1-basics/1_basics/02_vars_2/02_vars_2.go",
"chars": 1011,
"preview": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\t// int - платформозависимый тип, 32/64\n\tvar i int = 10\n\n\t// автоматически выб"
},
{
"path": "1-basics/1_basics/03_const/03_const.go",
"chars": 616,
"preview": "package main\n\nimport \"fmt\"\n\nconst pi = 3.141\nconst (\n\thello = \"Привет\"\n\te = 2.718\n)\nconst (\n\tzero = iota\n\t_ // пу"
},
{
"path": "1-basics/1_basics/04_pointers/04_pointers.go",
"chars": 409,
"preview": "package main\n\nfunc main() {\n\ta := 2\n\tb := &a\n\t*b = 3 // a = 3\n\tc := &a // новый указатель на переменную a\n\n\t// получени"
},
{
"path": "1-basics/1_basics/05_array/05_array.go",
"chars": 559,
"preview": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\t// размер массива является частью его типа\n\n\t// инициализация значениями по-у"
},
{
"path": "1-basics/1_basics/06_slice_1/06_slice_1.go",
"chars": 960,
"preview": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\t// создание\n\tvar buf0 []int // len=0, cap=0\n\tbuf1 := []int{} "
},
{
"path": "1-basics/1_basics/07_slice_2/07_slice_2.go",
"chars": 1473,
"preview": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tbuf := []int{1, 2, 3, 4, 5}\n\tfmt.Println(buf)\n\n\t/*\n\t\t buf: [1, 2, 3, 4, 5]"
},
{
"path": "1-basics/1_basics/08_strings/08_strings.go",
"chars": 1313,
"preview": "package main\n\nimport (\n\t\"fmt\"\n\t\"unicode/utf8\"\n)\n\nfunc main() {\n\t// пустая строка по-умолчанию\n\tvar str string\n\n\t// со сп"
},
{
"path": "1-basics/1_basics/09_map/09_map.go",
"chars": 1275,
"preview": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\t// инициализация при создании\n\tvar user map[string]string = map[string]string"
},
{
"path": "1-basics/1_basics/10_control/10_control.go",
"chars": 1221,
"preview": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\t// простое условие\n\tboolVal := true\n\tif boolVal {\n\t\tfmt.Println(\"boolVal is t"
},
{
"path": "1-basics/1_basics/11_loop/11_loop.go",
"chars": 1366,
"preview": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\t// цикл без условия, while(true) OR for(;;;)\n\tfor {\n\t\tfmt.Println(\"loop itera"
},
{
"path": "1-basics/1_basics/12_types/12_types.go",
"chars": 263,
"preview": "package main \n\ntype UserID int\n\nfunc main() {\n\tidx := 1\n\tvar uid UserID = 42\n\n\t// даже если базовый тип одинаковый, разн"
},
{
"path": "1-basics/1_basics/13_generic/1_generic/main.go",
"chars": 1104,
"preview": "package main\n\n// Зачем нужны?\n// ДУБЛИРОВАНИЕ КОДА!\nfunc equalInt(a, b int) bool {\n\treturn a == b\n}\n\nfunc equalFloat(a, "
},
{
"path": "1-basics/1_basics/13_generic/2_methods/methods.go",
"chars": 3180,
"preview": "package main\n\nimport (\n\t\"encoding/json\"\n\t\"fmt\"\n)\n\n// 1. Базовая дженерик-структура с методами\ntype Box[T any] struct {\n\t"
},
{
"path": "1-basics/2_functions/1_functions/1_functions.go",
"chars": 950,
"preview": "package main\n\nimport \"fmt\"\n\n// обычное объявление\nfunc singleIn(in int) int {\n\treturn in\n}\n\n// много параметров\nfunc mul"
},
{
"path": "1-basics/2_functions/2_firstclass/2_firstclass.go",
"chars": 760,
"preview": "package main\n\nimport \"fmt\"\n\n// обычная функция\nfunc doNothing() {\n\tfmt.Println(\"i'm regular function\")\n}\n\nfunc main() {\n"
},
{
"path": "1-basics/2_functions/3_defer/3_defer.go",
"chars": 259,
"preview": "package main\n\nimport \"fmt\"\n\nfunc getSomeVars() string {\n\tfmt.Println(\"getSomeVars execution\")\n\treturn \"getSomeVars resul"
},
{
"path": "1-basics/2_functions/4_recover/4_recover.go",
"chars": 405,
"preview": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc deferTest() {\n\tdefer func() {\n\t\tif err := recover(); err != nil {\n\t\t\tfmt.Println(\""
},
{
"path": "1-basics/3_structs/1_structs/1_structs.go",
"chars": 571,
"preview": "package main\n\nimport \"fmt\"\n\ntype Person struct {\n\tId int\n\tName string\n\tAddress string\n}\n\ntype Account struct {\n\t"
},
{
"path": "1-basics/3_structs/2_methods/2_methods.go",
"chars": 1002,
"preview": "package main\n\nimport \"fmt\"\n\ntype Person struct {\n\tId int\n\tName string\n}\n\n// не изменит оригинальной структуры, для кот"
},
{
"path": "1-basics/4_interfaces/1.2_basic_sort/1_sort.go",
"chars": 576,
"preview": "package main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n)\n\ntype Student struct {\n\tAge int\n\tName string\n}\n\ntype Students []Student\n\nfunc ("
},
{
"path": "1-basics/4_interfaces/1_basic/1_basic.go",
"chars": 446,
"preview": "package main\n\nimport (\n\t\"fmt\"\n)\n\ntype Payer interface {\n\tPay(int) error\n}\n\ntype Wallet struct {\n\tCash int\n}\n\nfunc (w *Wa"
},
{
"path": "1-basics/4_interfaces/2_many/2_many.go",
"chars": 1199,
"preview": "package main\n\nimport (\n\t\"fmt\"\n)\n\n// --------------\n\ntype Wallet struct {\n\tCash int\n}\n\nfunc (w *Wallet) Pay(amount int) e"
},
{
"path": "1-basics/4_interfaces/3_embed/3_embed.go",
"chars": 820,
"preview": "package main\n\nimport (\n\t\"fmt\"\n)\n\ntype Phone struct {\n\tMoney int\n\tAppleID string\n}\n\nfunc (p *Phone) Pay(amount int) err"
},
{
"path": "1-basics/4_interfaces/4_cast/4_cast.go",
"chars": 1495,
"preview": "package main\n\nimport (\n\t\"fmt\"\n)\n\n// --------------\n\ntype Wallet struct {\n\tCash int\n}\n\nfunc (w *Wallet) Pay(amount int) e"
},
{
"path": "1-basics/4_interfaces/5_empty_1/5_empty_1.go",
"chars": 465,
"preview": "package main\n\nimport (\n\t\"fmt\"\n\t\"strconv\"\n)\n\ntype Wallet struct {\n\tCash int\n}\n\nfunc (w *Wallet) Pay(amount int) error {\n\t"
},
{
"path": "1-basics/4_interfaces/6_empty_2/6_empty_2.go",
"chars": 842,
"preview": "package main\n\nimport (\n\t\"fmt\"\n\t\"strconv\"\n)\n\n// --------------\n\ntype Wallet struct {\n\tCash int\n}\n\nfunc (w *Wallet) Pay(am"
},
{
"path": "1-basics/5_visibility/dir.txt",
"chars": 252,
"preview": "C:\\Users\\User\\go\n├───bin\n├───pkg\n└───src\n ├───coursera\n │ ├───visibility\n │ │ │───person\n │ │ │ "
},
{
"path": "1-basics/5_visibility/main.go",
"chars": 250,
"preview": "package main\n\nimport (\n\t\"fmt\"\n\n\tprsonModule \"github.com/go-park-mail-ru/lectures/1-basics/5_visibility/person\"\n)\n\nfunc i"
},
{
"path": "1-basics/5_visibility/person/func.go",
"chars": 276,
"preview": "package person\n\nimport (\n\t\"fmt\"\n)\n\nfunc NewPerson(id int, name, secret string) *Person {\n\treturn &Person{\n\t\tID: 1,\n\t"
},
{
"path": "1-basics/5_visibility/person/person.go",
"chars": 310,
"preview": "package person\n\nimport \"fmt\"\n\nvar (\n\tPublic = 1\n\tprivate = 1\n)\n\nfunc init() {\n\tfmt.Println(\"I am init 1\")\n}\n\nfunc init("
},
{
"path": "1-basics/6_uniq/basic/data.txt",
"chars": 15,
"preview": "1\n2\n3\n3\n3\n3\n4\n5"
},
{
"path": "1-basics/6_uniq/basic/data_bad.txt",
"chars": 7,
"preview": "1\n1\n2\n1"
},
{
"path": "1-basics/6_uniq/basic/data_map.txt",
"chars": 9,
"preview": "1\n3\n2\n1\n2"
},
{
"path": "1-basics/6_uniq/basic/main.go",
"chars": 271,
"preview": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tin := bufio.NewScanner(os.Stdin)\n\tvar prev string\n\tfor in"
},
{
"path": "1-basics/6_uniq/with_tests/data.txt",
"chars": 15,
"preview": "1\n2\n3\n3\n3\n3\n4\n5"
},
{
"path": "1-basics/6_uniq/with_tests/data_bad.txt",
"chars": 7,
"preview": "1\n1\n2\n1"
},
{
"path": "1-basics/6_uniq/with_tests/data_map.txt",
"chars": 9,
"preview": "1\n3\n2\n1\n2"
},
{
"path": "1-basics/6_uniq/with_tests/main.go",
"chars": 449,
"preview": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n)\n\nfunc uniq(input io.Reader, output io.Writer) error {\n\tin := bufio."
},
{
"path": "1-basics/6_uniq/with_tests/main_test.go",
"chars": 620,
"preview": "package main\n\nimport (\n\t\"bytes\"\n\t\"testing\"\n)\n\nvar testOkInput = `1\n2\n3\n3\n4\n5`\n\nvar testOkResult = `1\n2\n3\n4\n5\n`\n\nvar test"
},
{
"path": "1-basics/homework/readme.md",
"chars": 7857,
"preview": "# Домашнее задание 1\n\n## Дисклеймер\n\nЭто задание состоит из 2х частей, которые нужно сдавать вместе.\nОтдельно первая час"
},
{
"path": "1-basics/readme.md",
"chars": 2780,
"preview": "Материалы для дополнительного чтения на английском:\r\n\r\n* https://golang.org/ref/spec - спецификация по язык\r\n* https://g"
},
{
"path": "10-performance/1_reflect/1_print/reflect_1.go",
"chars": 779,
"preview": "package main\r\n\r\nimport (\r\n\t\"fmt\"\r\n\t\"reflect\"\r\n)\r\n\r\ntype UserID int\r\n\r\ntype UserID2 UserID\r\n\r\ntype User struct {\r\n\tID "
},
{
"path": "10-performance/1_reflect/2_unpack/reflect_2.go",
"chars": 1485,
"preview": "package main\r\n\r\nimport (\r\n\t\"bytes\"\r\n\t\"encoding/binary\"\r\n\t\"fmt\"\r\n\t\"reflect\"\r\n)\r\n\r\ntype User struct {\r\n\tID int\r\n\tRea"
},
{
"path": "10-performance/2_codegen/gen/codegen.go",
"chars": 3253,
"preview": "// go build gen/* && ./codegen.exe pack/unpack.go pack/marshaller.go\r\n// go run pack/*\r\npackage main\r\n\r\nimport (\r\n\t\"fmt"
},
{
"path": "10-performance/2_codegen/pack/marshaller.go",
"chars": 533,
"preview": "package main\n\nimport \"encoding/binary\"\nimport \"bytes\"\n\nfunc (in *User) Unpack(data []byte) error {\n\tr := bytes.NewReader"
},
{
"path": "10-performance/2_codegen/pack/unpack.go",
"chars": 661,
"preview": "// go build -o ./codegen.exe gen/* && ./codegen.exe pack/unpack.go pack/marshaller.go\npackage main\n\nimport \"fmt\"\n\n// l"
},
{
"path": "10-performance/3_perfomance_1/1_unpack/unpack_test.go",
"chars": 2266,
"preview": "package unpack\n\nimport (\n\t\"bytes\"\n\t\"encoding/binary\"\n\t\"fmt\"\n\t\"reflect\"\n\t\"testing\"\n)\n\n/*\n\tgo test -bench . unpack_test.go"
},
{
"path": "10-performance/3_perfomance_1/2_prealloc/prealloc_test.go",
"chars": 937,
"preview": "// go test -bench . -benchmem prealloc_test.go\npackage prealloc\n\nimport (\n\t\"testing\"\n)\n\nconst iterNum = 1000\n\nfunc Bench"
},
{
"path": "10-performance/3_perfomance_1/3_pool/pool_test.go",
"chars": 1331,
"preview": "package pool\r\n\r\nimport (\r\n\t\"bytes\"\r\n\t\"encoding/json\"\r\n\t\"sync\"\r\n\t\"testing\"\r\n)\r\n\r\nconst iterNum = 100\r\n\r\ntype PublicPage s"
},
{
"path": "10-performance/3_perfomance_1/4_string/string_test.go",
"chars": 1283,
"preview": "package string\n\nimport (\n\t\"regexp\"\n\t\"strings\"\n\t\"testing\"\n)\n\nvar (\n\tbrowser = \"Mozilla/5.0 (Windows NT 6.3; WOW64) AppleW"
},
{
"path": "10-performance/3_perfomance_1/5_json/json_test.go",
"chars": 682,
"preview": "package json\n\nimport (\n\t\"encoding/json\"\n\t\"testing\"\n)\n\nvar (\n\tdata = []byte(`{\"RealName\":\"Vasily\", \"Login\":\"v.romanov\", \""
},
{
"path": "10-performance/3_perfomance_1/5_json/struct.go",
"chars": 227,
"preview": "package json\n\n//easyjson:json\ntype User struct {\n\tId int\n\tRealName string\n\tLogin string\n\tFlags int\n\tStatus "
},
{
"path": "10-performance/3_perfomance_1/5_json/struct_easyjson.go",
"chars": 2382,
"preview": "// Code generated by easyjson for marshaling/unmarshaling. DO NOT EDIT.\n\npackage json\n\nimport (\n\tjson \"encoding/json\"\n\te"
},
{
"path": "10-performance/4_perfomance_2/1_optimize/pprof_1.go",
"chars": 1656,
"preview": "package main\n\nimport (\n\t\"bytes\"\n\t\"fmt\"\n\t\"net/http\"\n\t_ \"net/http/pprof\"\n\t\"sync\"\n\t\"time\"\n)\n\ntype Post struct {\n\tID i"
},
{
"path": "10-performance/4_perfomance_2/1_optimize/pprof_1.sh",
"chars": 676,
"preview": "curl http://127.0.0.1:8080/debug/pprof/profile?seconds=5 -o cpu_out.txt\ncurl http://127.0.0.1:8080/debug/pprof/heap -o m"
},
{
"path": "10-performance/4_perfomance_2/2_leak_grtn/pprof_2.go",
"chars": 785,
"preview": "package main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\t_ \"net/http/pprof\"\n\t\"time\"\n)\n\ntype Post struct {\n\tID int\n\tText stri"
},
{
"path": "10-performance/4_perfomance_2/2_leak_grtn/pprof_2.sh",
"chars": 279,
"preview": "curl http://localhost:8080/debug/pprof/goroutine?debug=2 -o goroutines.txt\ncurl http://127.0.0.1:8080/debug/pprof/heap -"
},
{
"path": "10-performance/4_perfomance_2/3_tracing/tracing.go",
"chars": 903,
"preview": "package main\n\nimport (\n\t\"encoding/json\"\n\t\"fmt\"\n\t\"net/http\"\n\t_ \"net/http/pprof\"\n\t\"runtime\"\n\t\"time\"\n)\n\ntype Post struct {\n"
},
{
"path": "10-performance/4_perfomance_2/note.txt",
"chars": 50,
"preview": "go tool pprof -http=:8080 pprof_2.exe cpu_out.txt\n"
},
{
"path": "10-performance/5_testing/cover.html",
"chars": 2993,
"preview": "\r\n<!DOCTYPE html>\r\n<html>\r\n\t<head>\r\n\t\t<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\r\n\t\t<style>\r\n\t\t"
},
{
"path": "10-performance/5_testing/coverage_test.go",
"chars": 787,
"preview": "package main\r\n\r\nimport (\r\n\t\"testing\"\r\n\t\"reflect\"\r\n)\r\n\r\ntype TestCase struct{\r\n\tKey string\r\n\tUser *User\r\n\tIsError bool\r\n}"
},
{
"path": "10-performance/5_testing/main.go",
"chars": 472,
"preview": "package main\r\n\r\nimport (\r\n\t\"encoding/json\"\r\n\t\"fmt\"\r\n)\r\n\r\ntype User struct {\r\n\tID int\r\n}\r\n\r\nvar data = map[string][]byte{"
},
{
"path": "10-performance/6_xml_stream/main.go",
"chars": 2654,
"preview": "package main\r\n\r\nimport (\r\n\t\"encoding/xml\"\r\n\t\"fmt\"\r\n\t\"bytes\"\r\n\t\"io\"\r\n)\r\n\r\ntype User struct {\r\n\tID int `xml:\"id,attr\"`\r\n\tL"
},
{
"path": "10-performance/6_xml_stream/xml_test.go",
"chars": 239,
"preview": "package main\r\n\r\nimport (\r\n\t\"testing\"\r\n)\r\n\r\nfunc BenchmarkCountStruct(b *testing.B) {\r\n\tfor i := 0; i < b.N; i++ {\r\n\t\tCou"
},
{
"path": "10-performance/7_inline_escape/main.go",
"chars": 584,
"preview": "package main\r\n\r\nimport (\r\n\t\"fmt\"\r\n)\r\n\r\n/*\r\n\tgo run -gcflags -m main.go\r\n\tgo run -gcflags '-m -m' main.go\r\n*/\r\n\r\ntype Use"
},
{
"path": "10-performance/8_cgo/1_example/main.go",
"chars": 190,
"preview": "package main\n\n/*\n#include <math.h>\n*/\nimport \"C\"\nimport \"fmt\"\n\nfunc main() {\n\tnum := C.double(16)\n\tresult := C.sqrt(num)"
},
{
"path": "10-performance/8_cgo/2_performance/main.go",
"chars": 558,
"preview": "package main\n\n/*\n#include <stdio.h>\n\nlong long factorialC(long long n) {\n long long result = 1;\n for (long long i "
},
{
"path": "10-performance/8_cgo/3_usage/README.md",
"chars": 71,
"preview": "```\nbrew install pkg-config\n```\nhttps://github.com/klippa-app/go-pdfium"
},
{
"path": "10-performance/8_cgo/3_usage/go.mod",
"chars": 896,
"preview": "module pdfium\n\ngo 1.23.3\n\nrequire github.com/klippa-app/go-pdfium v1.13.0\n\nrequire (\n\tgithub.com/fatih/color v1.13.0 // "
},
{
"path": "10-performance/8_cgo/3_usage/go.sum",
"chars": 7243,
"preview": "github.com/bufbuild/protocompile v0.4.0 h1:LbFKd2XowZvQ/kajzguUp2DC9UEIQhIq77fZZlaQsNA=\ngithub.com/bufbuild/protocompile"
},
{
"path": "10-performance/8_cgo/3_usage/main.go",
"chars": 1753,
"preview": "package main\n\nimport (\n\t\"image/png\"\n\t\"io/ioutil\"\n\t\"log\"\n\t\"os\"\n\t\"time\"\n\n\t\"github.com/klippa-app/go-pdfium\"\n\t\"github.com/k"
},
{
"path": "10-performance/8_cgo/README.md",
"chars": 182,
"preview": "# CGO\n\n- Wiki: https://go.dev/wiki/cgo\n\nCGO мощный инструмент, используемый в основном для использования\nлогики библиоте"
},
{
"path": "10-performance/readme.md",
"chars": 205,
"preview": "go test -bench . -benchmem -cpuprofile=cpu.out -memprofile=mem.out -memprofilerate=1 -benchtime=50000x unpack_test.go\ngo"
},
{
"path": "2-async/0_basic_error_handling/1_ignore_errors/main.go",
"chars": 321,
"preview": "package main\n\nimport (\n\t\"fmt\"\n)\n\nvar idToUsername = map[int]string{\n\t0: \"romanov\",\n\t1: \"sulaev\",\n\t2: \"dorofeev\",\n}\n\nfunc"
},
{
"path": "2-async/0_basic_error_handling/2_panic/main.go",
"chars": 378,
"preview": "package main\n\nimport (\n\t\"fmt\"\n)\n\nvar idToUsername = map[int]string{\n\t0: \"romanov\",\n\t1: \"sulaev\",\n\t2: \"dorofeev\",\n}\n\nfunc"
},
{
"path": "2-async/0_basic_error_handling/3_handling/main.go",
"chars": 563,
"preview": "package main\n\nimport (\n\t\"fmt\"\n)\n\nvar idToUsername = map[int]string{\n\t0: \"romanov\",\n\t1: \"sulaev\",\n\t2: \"dorofeev\",\n}\n\nfunc"
},
{
"path": "2-async/0_basic_error_handling/4_return/main.go",
"chars": 441,
"preview": "package main\n\nimport (\n\t\"errors\"\n\t\"fmt\"\n)\n\ntype MyError struct {\n\tCode int\n}\n\nfunc (e MyError) Error() string {\n\treturn "
},
{
"path": "2-async/1_async/10_context_cancel/context_cancel.go",
"chars": 729,
"preview": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"math/rand\"\n\t\"time\"\n)\n\nfunc student(ctx context.Context, workerNum int, out ch"
},
{
"path": "2-async/1_async/10_context_timeout/context_parent/main.go",
"chars": 799,
"preview": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"time\"\n)\n\nfunc worker(ctx context.Context, name string) {\n\tfmt.Println(name, \""
},
{
"path": "2-async/1_async/10_context_timeout/context_timeout.go",
"chars": 906,
"preview": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"math/rand\"\n\t\"time\"\n)\n\nfunc worker(ctx context.Context, workerNum int, out cha"
},
{
"path": "2-async/1_async/11_errgroup_1/errgroup_1.go",
"chars": 678,
"preview": "package main\n\nimport (\n\t\"fmt\"\n\t\"time\"\n\n\t\"golang.org/x/sync/errgroup\"\n)\n\nconst (\n\tgoroutinesNum = 3\n\tbadGorutineNum = 2\n"
},
{
"path": "2-async/1_async/11_errgroup_2/errgroup_2.go",
"chars": 949,
"preview": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"golang.org/x/sync/errgroup\"\n\t\"time\"\n)\n\nconst (\n\tgoroutinesNum = 3\n\tbadGoruti"
},
{
"path": "2-async/1_async/12_atomic_1/atomic_1.go",
"chars": 419,
"preview": "package main\n\nimport (\n\t\"fmt\"\n\t\"sync\"\n\t\"time\"\n)\n\nvar totalOperations int32 = 0\nvar mu = &sync.Mutex{}\n\nfunc inc() {\n\t//m"
},
{
"path": "2-async/1_async/12_atomic_2/atomic_2.go",
"chars": 309,
"preview": "package main\n\nimport (\n\t\"fmt\"\n\t\"sync/atomic\" // atomic_2.go\n\t\"time\"\n)\n\nvar totalOperations int32\n\nfunc inc() {\n\tatomic.A"
},
{
"path": "2-async/1_async/12_atomic_2/with_bench/mutex_test.go",
"chars": 580,
"preview": "package main\n\nimport (\n\t\"sync\"\n\t\"sync/atomic\"\n\t\"testing\"\n)\n\nvar (\n\ttotalMutex int32\n\ttotalAtomic int32\n\tmutex = &"
},
{
"path": "2-async/1_async/13_ratelim/ratelim.go",
"chars": 1009,
"preview": "package main\n\nimport (\n\t\"fmt\"\n\t\"runtime\"\n\t\"strings\"\n\t\"sync\"\n\t\"time\"\n)\n\nconst (\n\titerationsNum = 6\n\tgoroutinesNum = 5\n\tqu"
},
{
"path": "2-async/1_async/14_once/once.go",
"chars": 358,
"preview": "package main\n\nimport (\n\t\"fmt\"\n\t\"sync\"\n)\n\nfunc Init() {\n\tfmt.Println(\"Init once\")\n}\n\nfunc init() {\n\tfmt.Println(\"Init at "
},
{
"path": "2-async/1_async/1_goroutines/goroutines.go",
"chars": 219,
"preview": "package main\n\nimport (\n\t\"fmt\"\n\t\"time\"\n)\n\nconst goroutinesNum = 7\n\nfunc main() {\n\tfor i := 0; i < goroutinesNum; i++ {\n\t\t"
},
{
"path": "2-async/1_async/1_goroutines/i_ptr/main.go",
"chars": 314,
"preview": "package main\n\nimport (\n\t\"fmt\"\n)\n\nconst goroutinesNum = 7\n\nfunc main() {\n\tvar ptrs []*int\n\n\tfor i := 0; i < goroutinesNum"
},
{
"path": "2-async/1_async/1_goroutines/mem/main.go",
"chars": 484,
"preview": "package main\n\nimport (\n\t\"fmt\"\n\t\"runtime\"\n\t\"time\"\n)\n\nfunc main() {\n\tvar m1, m2 runtime.MemStats\n\truntime.ReadMemStats(&m1"
},
{
"path": "2-async/1_async/1_goroutines_2/goroutines.go",
"chars": 586,
"preview": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n\t\"time\"\n)\n\nconst (\n\titerationsNum = 6\n\tgoroutinesNum = 6\n)\n\nfunc doWork(th int)"
},
{
"path": "2-async/1_async/2_chan/chan_1.go",
"chars": 450,
"preview": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tch1 := make(chan int)\n\n\tgo func(in chan int) {\n\t\tfmt.Println(\"GO: before"
},
{
"path": "2-async/1_async/2_chan_2/chan_2.go",
"chars": 440,
"preview": "package main\n\nimport (\n\t\"fmt\"\n\t\"time\"\n)\n\nfunc main() {\n\tin := make(chan int)\n\n\tgo func(out chan<- int) {\n\t\tfor i := 0; i"
},
{
"path": "2-async/1_async/3_workerpool/1_workerpool.go",
"chars": 1049,
"preview": "package main\n\nimport (\n\t\"fmt\"\n\t\"runtime\"\n\t\"strings\"\n\t\"time\"\n)\n\nconst goroutinesNum = 3\n\nfunc startWorker(workerNum int, "
},
{
"path": "2-async/1_async/3_workerpool/2_workerpool_reusable.go",
"chars": 486,
"preview": "package main\n\ntype workerPool struct {\n\tlocker chan struct{}\n\tqueue chan func()\n}\n\nfunc NewWorkerPool(maxWorkers int) w"
},
{
"path": "2-async/1_async/4_race_1/race_1.go",
"chars": 275,
"preview": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar counters = map[int]int{}\n\tfor i := 0; i < 5; i++ {\n\t\tgo func(counters map"
},
{
"path": "2-async/1_async/4_race_2/race_2.go",
"chars": 393,
"preview": "package main\n\nimport (\n\t\"fmt\"\n\t\"sync\"\n)\n\nfunc main() {\n\tvar counters = map[int]int{}\n\tmu := &sync.Mutex{}\n\tfor i := 0; i"
},
{
"path": "2-async/1_async/4_race_2/race_flag/working_race.go",
"chars": 254,
"preview": "package main\n\nimport (\n\t\"fmt\"\n\t\"time\"\n)\n\n// add race flag\nfunc main() {\n\tvar counter int\n\tfor i := 0; i < 4; i++ {\n\t\tgo "
},
{
"path": "2-async/1_async/4_race_3/race_3.go",
"chars": 575,
"preview": "package main\n\nimport (\n\t\"fmt\"\n\t\"sync\"\n\t\"time\"\n)\n\n// look sync.Map\n\nfunc main() {\n\tvar counters = map[int]int{}\n\tmu := &s"
},
{
"path": "2-async/1_async/4_race_3_bench/race_test.go",
"chars": 756,
"preview": "package main\n\nimport (\n\t\"sync\"\n\t\"testing\"\n)\n\nfunc BenchmarkMapWithRWMutex(b *testing.B) {\n\tcounters := make(map[int]int)"
},
{
"path": "2-async/1_async/5_tick/tick.go",
"chars": 705,
"preview": "package main\n\nimport (\n\t\"fmt\"\n\t\"time\"\n)\n\nfunc main() {\n\tticker := time.NewTicker(time.Second)\n\ti := 0\n\tfor tickTime := r"
},
{
"path": "2-async/1_async/5_tick_example/5_ping_pong/main.go",
"chars": 295,
"preview": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tch := make(chan string)\n\n\tgo func() {\n\t\tfor pong := range ch {\n\t\t\tfmt.Pr"
},
{
"path": "2-async/1_async/5_tick_example/main.go",
"chars": 950,
"preview": "package main\n\nimport (\n\t\"fmt\"\n\t\"time\"\n)\n\nfunc main() {\n\ttick1s := time.Tick(1 * time.Second)\n\ttick3s := time.Tick(3 * ti"
},
{
"path": "2-async/1_async/6_afterfunc/afterfunc.go",
"chars": 200,
"preview": "package main\n\nimport (\n\t\"fmt\"\n\t\"time\"\n)\n\nfunc sayHello() {\n\tfmt.Println(\"Hello World\")\n}\n\nfunc main() {\n\ttimer := time.A"
},
{
"path": "2-async/1_async/7_select_1/select_1.go",
"chars": 299,
"preview": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tch1 := make(chan int, 1)\n\tch2 := make(chan int, 1)\n\n\tch1 <- 1\n\t//ch2 <- "
},
{
"path": "2-async/1_async/7_select_2/select_2.go",
"chars": 292,
"preview": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tch1 := make(chan int, 2)\n\tch1 <- 1\n\tch1 <- 2\n\tch2 := make(chan int, 2)\n\t"
},
{
"path": "2-async/1_async/7_select_2_new/close_buff/main.go",
"chars": 375,
"preview": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tch := make(chan int, 3)\n\n\tch <- 1\n\tch <- 2\n\tch <- 3\n\n\tclose(ch)\n\tfmt.Pri"
},
{
"path": "2-async/1_async/7_select_2_new/select_2_new.go",
"chars": 598,
"preview": "package main\n\nimport (\n\t\"fmt\"\n)\n\n// Read 2 channels till they are closed\n\nfunc main() {\n\tch1 := make(chan int)\n\tch2 := m"
},
{
"path": "2-async/1_async/7_select_3/close_all/main.go",
"chars": 519,
"preview": "package main\n\nimport (\n\t\"fmt\"\n\t\"time\"\n)\n\nfunc worker(id int, cancelCh chan struct{}) {\n\tfmt.Println(\"worker\", id, \"start"
},
{
"path": "2-async/1_async/7_select_3/close_signal/main.go",
"chars": 693,
"preview": "package main\n\nimport (\n\t\"fmt\"\n\t\"os\"\n\t\"os/signal\"\n\t\"syscall\"\n\t\"time\"\n)\n\nfunc worker(id int, done <-chan struct{}) {\n\tfor "
},
{
"path": "2-async/1_async/7_select_3/select_3.go",
"chars": 596,
"preview": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tcancelCh := make(chan bool)\n\tdataCh := make(chan int)\n\n\tgo func(cancelCh"
},
{
"path": "2-async/1_async/8_wait_1/wait_1.go",
"chars": 363,
"preview": "package main\n\nimport (\n\t\"log\"\n\t\"time\"\n)\n\nfunc main() {\n\tresult := make(chan string)\n\tgo func(out chan<- string) {\n\t\ttime"
},
{
"path": "2-async/1_async/8_wait_2/ping_pong/main.go",
"chars": 570,
"preview": "package main\n\nimport (\n\t\"fmt\"\n\t\"sync\"\n\t\"time\"\n)\n\nfunc main() {\n\tballCh := make(chan string)\n\twg := &sync.WaitGroup{}\n\n\tw"
},
{
"path": "2-async/1_async/8_wait_2/wait_2.go",
"chars": 889,
"preview": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n\t\"sync\"\n\t\"time\"\n)\n\nconst (\n\titerationsNum = 7\n\tgoroutinesNum = 5\n)\n\nfunc doWork"
},
{
"path": "2-async/1_async/8_wait_3/wait_3.go",
"chars": 695,
"preview": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n\t\"sync\"\n\t\"time\"\n\t//github.com/neonxp/rutina\n)\n\nconst (\n\titerationsNum = 7\n\tgoro"
},
{
"path": "2-async/1_async/9_timeout/timeout.go",
"chars": 499,
"preview": "package main\n\nimport (\n\t\"fmt\"\n\t\"time\"\n)\n\nfunc longSQLQuery() chan bool {\n\tch := make(chan bool, 1)\n\tgo func() {\n\t\ttime.S"
},
{
"path": "2-async/readings_2.md",
"chars": 1817,
"preview": "На русском:\r\n* https://habrahabr.ru/post/141853/ - как работают горутины\r\n* https://habrahabr.ru/post/308070/ - как рабо"
},
{
"path": "3-web/0_json/0_simple_json/simple_json.go",
"chars": 446,
"preview": "package main\n\nimport (\n\t\"encoding/json\"\n\t\"fmt\"\n)\n\ntype User struct {\n\tID int\n\tUsername string\n\tphone string\n}\n\n"
},
{
"path": "3-web/0_json/1_struct_tags/struct_tags.go",
"chars": 391,
"preview": "package main\n\nimport (\n\t\"encoding/json\"\n\t\"fmt\"\n)\n\ntype User struct {\n\tID int `json:\"user_id,string\"`\n\tUsername str"
},
{
"path": "3-web/0_json/2_custom/custom.go",
"chars": 1959,
"preview": "package main\n\nimport (\n\t\"encoding/json\"\n\t\"fmt\"\n\t\"strconv\"\n\t\"strings\"\n)\n\ntype Company string\n\n// MarshalJSON удовлетворяе"
},
{
"path": "3-web/0_json/3_dynamic/dynamic.go",
"chars": 544,
"preview": "package main\n\nimport (\n\t\"encoding/json\"\n\t\"fmt\"\n)\n\nvar jsonStr = `[\n\t{\"id\": 17, \"username\": \"iivan\", \"phone\": 0},\n\t{\"id\":"
},
{
"path": "3-web/1_net/net_listen.go",
"chars": 739,
"preview": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"net\"\n)\n\nfunc handleConnection(conn net.Conn) {\n\tname := conn.RemoteAddr().Strin"
},
{
"path": "3-web/2_http/0_http_server/0_basic/basic.go",
"chars": 347,
"preview": "package main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n)\n\nfunc handler(w http.ResponseWriter, r *http.Request) {\n\tw.Header().Set(\"Con"
},
{
"path": "3-web/2_http/0_http_server/1_pages/pages.go",
"chars": 526,
"preview": "package main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n)\n\nfunc handler(w http.ResponseWriter, r *http.Request) {\n\tfmt.Fprintln(w, \"Ma"
},
{
"path": "3-web/2_http/0_http_server/2_servehttp/servehttp.go",
"chars": 453,
"preview": "package main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n)\n\ntype Handler struct {\n\tName string\n}\n\nfunc (h *Handler) ServeHTTP(w http.Re"
},
{
"path": "3-web/2_http/0_http_server/3_mux/mux.go",
"chars": 434,
"preview": "package main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\t\"time\"\n)\n\nfunc handler(w http.ResponseWriter, r *http.Request) {\n\tfmt.Fprintl"
},
{
"path": "3-web/2_http/0_http_server/4_servers/servers.go",
"chars": 425,
"preview": "package main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n)\n\nfunc runServer(addr string) {\n\tmux := http.NewServeMux()\n\tmux.HandleFunc(\"/"
},
{
"path": "3-web/2_http/1_request/0_get/get.go",
"chars": 297,
"preview": "package main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n)\n\nfunc handler(w http.ResponseWriter, r *http.Request) {\n\tfor key, value := r"
},
{
"path": "3-web/2_http/1_request/1_post/post.go",
"chars": 672,
"preview": "package main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n)\n\nvar loginFormTmpl = []byte(`\n<html>\n\t<body>\n\t<form action=\"/\" method=\"post\""
},
{
"path": "3-web/2_http/1_request/2_cookies/cookies.go",
"chars": 1207,
"preview": "package main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\t\"time\"\n)\n\nfunc mainPage(w http.ResponseWriter, r *http.Request) {\n\tsession, e"
},
{
"path": "3-web/2_http/1_request/3_headers/headers.go",
"chars": 382,
"preview": "package main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n)\n\nfunc handler(w http.ResponseWriter, r *http.Request) {\n\tw.Header().Set(\"Req"
},
{
"path": "3-web/2_http/2_http_client/client.go",
"chars": 2551,
"preview": "package main\n\nimport (\n\t\"bytes\"\n\t\"fmt\"\n\t\"io\"\n\t\"net\"\n\t\"net/http\"\n\t\"net/url\"\n\t\"strconv\"\n\t\"time\"\n)\n\nfunc startServer() {\n\th"
},
{
"path": "3-web/2_http/3_files/0_file_upload/file_upload.go",
"chars": 1526,
"preview": "package main\n\nimport (\n\t\"crypto/md5\"\n\t\"encoding/json\"\n\t\"fmt\"\n\t\"io\"\n\t\"net/http\"\n)\n\nvar uploadFormTmpl = []byte(`\n<html>\n\t"
},
{
"path": "3-web/2_http/3_files/1_static/static/super_secret_password",
"chars": 30,
"preview": "BestPassword!\nqwerty1234567890"
},
{
"path": "3-web/2_http/3_files/1_static/static.go",
"chars": 485,
"preview": "package main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n)\n\nfunc handler(w http.ResponseWriter, r *http.Request) {\n\tw.Header().Set(\"Con"
},
{
"path": "3-web/2_http/4_httptest/0_client/client_test.go",
"chars": 1330,
"preview": "package client\n\nimport (\n\t\"io\"\n\t\"net/http\"\n\t\"net/http/httptest\"\n\t\"testing\"\n)\n\ntype TestCase struct {\n\tID string\n"
},
{
"path": "3-web/2_http/4_httptest/1_server/server_test.go",
"chars": 2254,
"preview": "package server\n\nimport (\n\t\"encoding/json\"\n\t\"io\"\n\t\"net/http\"\n\t\"net/http/httptest\"\n\t\"reflect\"\n\t\"testing\"\n)\n\ntype TestCase "
},
{
"path": "3-web/3_template/0_inline/inline.go",
"chars": 529,
"preview": "package main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\t\"text/template\"\n)\n\ntype tplParams struct {\n\tURL string\n\tBrowser string\n}\n"
},
{
"path": "3-web/3_template/1_file/file.go",
"chars": 528,
"preview": "package main\n\nimport (\n\t\"fmt\"\n\t\"html/template\"\n\t\"net/http\"\n)\n\ntype User struct {\n\tID int\n\tName string\n\tActive bool"
},
{
"path": "3-web/3_template/1_file/users.html",
"chars": 131,
"preview": "<html>\n<body>\n\t<h1>Users</h1>\n\t{{range .Users}}\n\t\t<b>{{.Name}}</b>\n\t\t{{if .Active}}active{{end}}\n\t\t<br />\n\t{{end}}\n</bod"
},
{
"path": "3-web/3_template/2_func/func.go",
"chars": 755,
"preview": "package main\n\nimport (\n\t\"fmt\"\n\t\"html/template\"\n\t\"net/http\"\n)\n\ntype User struct {\n\tID int\n\tName string\n\tActive bool"
},
{
"path": "3-web/3_template/2_func/func.html",
"chars": 152,
"preview": "<html>\n<body>\n\t<h1>Users</h1>\n\t{{range .Users}}\n\t\t<b>{{.Name}}</b>,\n\t\t{{if OddUser .}}\n\t\t\tid {{.ID}} is odd\n\t\t{{end}}\n\t\t"
},
{
"path": "3-web/3_template/3_method/method.go",
"chars": 746,
"preview": "package main\n\nimport (\n\t\"fmt\"\n\t\"html/template\"\n\t\"net/http\"\n)\n\ntype User struct {\n\tID int\n\tName string\n\tActive bool"
},
{
"path": "3-web/3_template/3_method/method.html",
"chars": 121,
"preview": "<html>\n<body>\n\t<h1>Users</h1>\n\t{{range .Users}}\n\t\t<b>{{.Name}}</b> \n\t\t{{.PrintActive}}\n\t\t<br />\n\t{{end}}\n</body>\n</html>"
},
{
"path": "3-web/4_json_http/main.go",
"chars": 1754,
"preview": "package main\n\nimport (\n\t\"encoding/json\"\n\t\"fmt\"\n\t\"log\"\n\t\"net/http\"\n\t\"sync\"\n)\n\ntype UserInput struct {\n\tName string `j"
},
{
"path": "3-web/4_json_http/main_test.go",
"chars": 1309,
"preview": "package main\n\nimport (\n\t\"bytes\"\n\t\"io\"\n\t\"net/http\"\n\t\"net/http/httptest\"\n\t\"reflect\"\n\t\"strings\"\n\t\"sync\"\n\t\"testing\"\n)\n\nfunc "
},
{
"path": "3-web/readings_3.md",
"chars": 852,
"preview": "Конечно же документация:\n* https://golang.org/pkg/net/http/\n\nДополнительные материалы\n\n* https://gowebexamples.github.io"
},
{
"path": "4-api/1_rpc/jsonrpc/books.go",
"chars": 653,
"preview": "package main\n\nimport (\n\t\"log\"\n\t\"sync\"\n)\n\ntype Book struct {\n\tID uint `json:\"id\"`\n\tTitle string `json:\"title\"`\n\tPric"
},
{
"path": "4-api/1_rpc/jsonrpc/server.go",
"chars": 1747,
"preview": "package main\n\nimport (\n\t\"fmt\"\n\t\"io\"\n\t\"log\"\n\t\"net/http\"\n\t\"net/rpc\"\n\t\"net/rpc/jsonrpc\"\n)\n\ntype HttpConn struct {\n\tin io.R"
},
{
"path": "4-api/1_rpc/main.go",
"chars": 502,
"preview": "package main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n)\n\nfunc login(w http.ResponseWriter, r *http.Request) {\n\tfmt.Println(\"login\")\n"
},
{
"path": "4-api/1_rpc/net-rpc/books.go",
"chars": 607,
"preview": "package main\n\nimport (\n\t\"log\"\n\t\"sync\"\n)\n\ntype Book struct {\n\tID uint\n\tTitle string\n\tPrice uint\n}\n\ntype BookStore stru"
},
{
"path": "4-api/1_rpc/net-rpc/client.go",
"chars": 536,
"preview": "package main\n\nimport (\n\t\"log\"\n\t\"net/rpc\"\n)\n\nfunc main() {\n\n\tclient, err := rpc.DialHTTP(\"tcp\", \"localhost:8081\")\n\tif err"
},
{
"path": "4-api/1_rpc/net-rpc/server.go",
"chars": 308,
"preview": "package main\n\nimport (\n\t\"fmt\"\n\t\"log\"\n\t\"net\"\n\t\"net/http\"\n\t\"net/rpc\"\n)\n\nfunc main() {\n\tbookStore := NewBookStore()\n\n\trpc.R"
},
{
"path": "4-api/2_rest/books.go",
"chars": 714,
"preview": "package main\n\nimport (\n\t\"log\"\n\t\"sync\"\n)\n\ntype Book struct {\n\tID uint `json:\"id\"`\n\tTitle string `json:\"title\"`\n\tPric"
},
{
"path": "4-api/2_rest/main.go",
"chars": 1855,
"preview": "package main\n\nimport (\n\t\"encoding/json\"\n\t\"log\"\n\t\"net/http\"\n\t\"strconv\"\n\n\t\"github.com/gorilla/mux\"\n)\n\ntype Result struct {"
},
{
"path": "4-api/3_graphql/gqlgen/generated.go",
"chars": 75802,
"preview": "// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.\n\npackage gqlgen\n\nimport (\n\t\"bytes\"\n\t\"context\"\n\t\"errors\"\n\t"
},
{
"path": "4-api/3_graphql/gqlgen/gqlgen.yml",
"chars": 258,
"preview": "# .gqlgen.yml example\n#\n# Refer to https://gqlgen.com/config/\n# for detailed .gqlgen.yml documentation.\n\nschema:\n- schem"
},
{
"path": "4-api/3_graphql/gqlgen/models_gen.go",
"chars": 274,
"preview": "// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.\n\npackage gqlgen\n\ntype Author struct {\n\tName string `json:"
},
{
"path": "4-api/3_graphql/gqlgen/resolver.go",
"chars": 473,
"preview": "package gqlgen\n\nimport (\n\t\"context\"\n) // THIS CODE IS A STARTING POINT ONLY. IT WILL NOT BE UPDATED WITH SCHEMA CHANGES."
},
{
"path": "4-api/3_graphql/gqlgen/schema.graphql",
"chars": 141,
"preview": "type Author {\n name: String!\n}\n\ntype Book {\n id: ID!\n title: String!\n price: Float!\n author: Author\n}\n\ntype Query {"
},
{
"path": "4-api/3_graphql/gqlgen/server/server.go",
"chars": 570,
"preview": "package main\n\nimport (\n\t\"log\"\n\t\"net/http\"\n\t\"os\"\n\n\tgql \"github.com/go-park-mail-ru/lectures/4-api/3_graphql/gqlgen\"\n\n\t\"gi"
},
{
"path": "4-api/3_graphql/gqlgen_full/gqlgen1/generated.go",
"chars": 82032,
"preview": "// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.\n\npackage gqlgen1\n\nimport (\n\t\"bytes\"\n\t\"context\"\n\t\"errors\"\n"
},
{
"path": "4-api/3_graphql/gqlgen_full/gqlgen1/go.mod",
"chars": 149,
"preview": "module gqlgen1\n\ngo 1.13\n\nrequire (\n\tgithub.com/99designs/gqlgen v0.11.1\n\tgithub.com/vektah/gqlparser v1.3.1\n\tgithub.com/"
},
{
"path": "4-api/3_graphql/gqlgen_full/gqlgen1/go.sum",
"chars": 7156,
"preview": "github.com/99designs/gqlgen v0.11.1 h1:QoSL8/AAJ2T3UOeQbdnBR32JcG4pO08+P/g5jdbFkUg=\ngithub.com/99designs/gqlgen v0.11.1/"
},
{
"path": "4-api/3_graphql/gqlgen_full/gqlgen1/gqlgen.yml",
"chars": 258,
"preview": "# .gqlgen.yml example\n#\n# Refer to https://gqlgen.com/config/\n# for detailed .gqlgen.yml documentation.\n\nschema:\n- schem"
},
{
"path": "4-api/3_graphql/gqlgen_full/gqlgen1/models_gen.go",
"chars": 436,
"preview": "// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.\n\npackage gqlgen1\n\ntype Photo struct {\n\tID string `j"
},
{
"path": "4-api/3_graphql/gqlgen_full/gqlgen1/resolver.go",
"chars": 848,
"preview": "package gqlgen1\n\nimport (\n\t\"context\"\n) // THIS CODE IS A STARTING POINT ONLY. IT WILL NOT BE UPDATED WITH SCHEMA CHANGES"
},
{
"path": "4-api/3_graphql/gqlgen_full/gqlgen1/schema.graphql",
"chars": 750,
"preview": "type User {\n id: ID!\n name: String!\n avatar: String!\n}\n\ntype Photo {\n id: ID!\n user: User!\n url: String!\n comment"
},
{
"path": "4-api/3_graphql/gqlgen_full/gqlgen1/server/server.go",
"chars": 530,
"preview": "package main\n\nimport (\n\tgqlgen \"gqlgen1\"\n\t\"log\"\n\t\"net/http\"\n\t\"os\"\n\n\t\"github.com/99designs/gqlgen/handler\"\n)\n\nconst defau"
},
{
"path": "4-api/3_graphql/gqlgen_full/gqlgen2/generated.go",
"chars": 82667,
"preview": "// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.\n\npackage gqlgen2\n\nimport (\n\t\"bytes\"\n\t\"context\"\n\t\"errors\"\n"
},
{
"path": "4-api/3_graphql/gqlgen_full/gqlgen2/go.mod",
"chars": 113,
"preview": "module gqlgen2\n\ngo 1.13\n\nrequire (\n\tgithub.com/99designs/gqlgen v0.11.1\n\tgithub.com/vektah/gqlparser/v2 v2.0.1\n)\n"
},
{
"path": "4-api/3_graphql/gqlgen_full/gqlgen2/go.sum",
"chars": 6806,
"preview": "github.com/99designs/gqlgen v0.11.1 h1:QoSL8/AAJ2T3UOeQbdnBR32JcG4pO08+P/g5jdbFkUg=\ngithub.com/99designs/gqlgen v0.11.1/"
},
{
"path": "4-api/3_graphql/gqlgen_full/gqlgen2/gqlgen.yml",
"chars": 349,
"preview": "# .gqlgen.yml example\n#\n# Refer to https://gqlgen.com/config/\n# for detailed .gqlgen.yml documentation.\n\nschema:\n- schem"
},
{
"path": "4-api/3_graphql/gqlgen_full/gqlgen2/models_gen.go",
"chars": 189,
"preview": "// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.\n\npackage gqlgen2\n\ntype User struct {\n\tID string `json"
},
{
"path": "4-api/3_graphql/gqlgen_full/gqlgen2/photo.go",
"chars": 427,
"preview": "package gqlgen2\n\nimport (\n\t\"log\"\n\t\"strconv\"\n)\n\ntype Photo struct {\n\tID uint `json:\"id\"`\n\tUserID uint `json:\"-\"`\n\t// "
},
{
"path": "4-api/3_graphql/gqlgen_full/gqlgen2/resolver.go",
"chars": 2127,
"preview": "package gqlgen2\n\n//go:generate go run github.com/99designs/gqlgen\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"log\"\n\t\"strconv\"\n) // THI"
},
{
"path": "4-api/3_graphql/gqlgen_full/gqlgen2/schema.graphql",
"chars": 662,
"preview": "type User {\n id: ID!\n name: String!\n avatar: String!\n}\n\ntype Photo {\n id: ID!\n user: User!\n url: String!\n comment"
},
{
"path": "4-api/3_graphql/gqlgen_full/gqlgen2/schema_alt.graphql",
"chars": 908,
"preview": "directive @goModel(model: String, models: [String!]) on OBJECT \n | INPUT_OBJECT \n | SCALAR \n | ENUM \n | INTE"
},
{
"path": "4-api/3_graphql/gqlgen_full/gqlgen2/server/server.go",
"chars": 1777,
"preview": "package main\n\nimport (\n\t\"context\"\n\tgqlgen \"gqlgen2\"\n\t\"log\"\n\t\"net/http\"\n\n\t\"github.com/99designs/gqlgen/handler\"\n)\n\n/*\nque"
},
{
"path": "4-api/3_graphql/gqlgen_full/gqlgen3/generated.go",
"chars": 82640,
"preview": "// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.\n\npackage gqlgen3\n\nimport (\n\t\"bytes\"\n\t\"context\"\n\t\"errors\"\n"
},
{
"path": "4-api/3_graphql/gqlgen_full/gqlgen3/go.mod",
"chars": 113,
"preview": "module gqlgen3\n\ngo 1.13\n\nrequire (\n\tgithub.com/99designs/gqlgen v0.11.1\n\tgithub.com/vektah/gqlparser/v2 v2.0.1\n)\n"
},
{
"path": "4-api/3_graphql/gqlgen_full/gqlgen3/go.sum",
"chars": 6806,
"preview": "github.com/99designs/gqlgen v0.11.1 h1:QoSL8/AAJ2T3UOeQbdnBR32JcG4pO08+P/g5jdbFkUg=\ngithub.com/99designs/gqlgen v0.11.1/"
},
{
"path": "4-api/3_graphql/gqlgen_full/gqlgen3/gqlgen.yml",
"chars": 349,
"preview": "# .gqlgen.yml example\n#\n# Refer to https://gqlgen.com/config/\n# for detailed .gqlgen.yml documentation.\n\nschema:\n- schem"
},
{
"path": "4-api/3_graphql/gqlgen_full/gqlgen3/models_gen.go",
"chars": 230,
"preview": "// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.\n\npackage gqlgen3\n\ntype User struct {\n\tID string `js"
},
{
"path": "4-api/3_graphql/gqlgen_full/gqlgen3/photo.go",
"chars": 394,
"preview": "package gqlgen3\n\nimport (\n\t// \"log\"\n\t\"strconv\"\n)\n\ntype Photo struct {\n\tID uint `json:\"id\"`\n\tUserID uint `json:\"-\"`\n\t"
},
{
"path": "4-api/3_graphql/gqlgen_full/gqlgen3/resolver.go",
"chars": 2253,
"preview": "package gqlgen3\n\n//go:generate go run github.com/99designs/gqlgen\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"log\"\n\t\"strconv\"\n\t\"time\"\n"
},
{
"path": "4-api/3_graphql/gqlgen_full/gqlgen3/schema.graphql",
"chars": 662,
"preview": "type User {\n id: ID!\n name: String!\n avatar: String!\n followed: Boolean!\n}\n\ntype Photo {\n id: ID!\n user: User!\n u"
},
{
"path": "4-api/3_graphql/gqlgen_full/gqlgen3/schema_alt.graphql",
"chars": 908,
"preview": "directive @goModel(model: String, models: [String!]) on OBJECT \n | INPUT_OBJECT \n | SCALAR \n | ENUM \n | INTE"
},
{
"path": "4-api/3_graphql/gqlgen_full/gqlgen3/server/server.go",
"chars": 3034,
"preview": "package main\n\nimport (\n\t\"context\"\n\tgqlgen \"gqlgen3\"\n\t\"log\"\n\t\"net/http\"\n\t\"time\"\n\n\t\"github.com/99designs/gqlgen/handler\"\n)"
},
{
"path": "4-api/3_graphql/gqlgen_full/gqlgen3/userloader_gen.go",
"chars": 5430,
"preview": "// Code generated by github.com/vektah/dataloaden, DO NOT EDIT.\n\npackage gqlgen3\n\nimport (\n\t\"sync\"\n\t\"time\"\n)\n\n// UserLoa"
},
{
"path": "4-api/3_graphql/gqlgen_full/gqlgen4/generated.go",
"chars": 85314,
"preview": "// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.\n\npackage gqlgen4\n\nimport (\n\t\"bytes\"\n\t\"context\"\n\t\"errors\"\n"
},
{
"path": "4-api/3_graphql/gqlgen_full/gqlgen4/go.mod",
"chars": 113,
"preview": "module gqlgen4\n\ngo 1.13\n\nrequire (\n\tgithub.com/99designs/gqlgen v0.11.1\n\tgithub.com/vektah/gqlparser/v2 v2.0.1\n)\n"
},
{
"path": "4-api/3_graphql/gqlgen_full/gqlgen4/go.sum",
"chars": 6806,
"preview": "github.com/99designs/gqlgen v0.11.1 h1:QoSL8/AAJ2T3UOeQbdnBR32JcG4pO08+P/g5jdbFkUg=\ngithub.com/99designs/gqlgen v0.11.1/"
},
{
"path": "4-api/3_graphql/gqlgen_full/gqlgen4/gqlgen.yml",
"chars": 301,
"preview": "schema:\n- schema.graphql\nexec:\n filename: generated.go\nmodel:\n filename: models_gen.go\nresolver:\n filename: resolver."
},
{
"path": "4-api/3_graphql/gqlgen_full/gqlgen4/models_gen.go",
"chars": 310,
"preview": "// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.\n\npackage gqlgen4\n\ntype User struct {\n\tID string `js"
},
{
"path": "4-api/3_graphql/gqlgen_full/gqlgen4/photo.go",
"chars": 394,
"preview": "package gqlgen4\n\nimport (\n\t// \"log\"\n\t\"strconv\"\n)\n\ntype Photo struct {\n\tID uint `json:\"id\"`\n\tUserID uint `json:\"-\"`\n\t"
},
{
"path": "4-api/3_graphql/gqlgen_full/gqlgen4/queries.txt",
"chars": 875,
"preview": "query {\n user(userID: \"1\") {\n id\n name\n avatar\n }\n}\n\n# -----\n\nquery {\n user(userID: \"1\") {\n id\n name\n "
}
]
// ... and 287 more files (download for full content)
About this extraction
This page contains the full source code of the go-park-mail-ru/lectures GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 487 files (1.8 MB), approximately 591.9k tokens, and a symbol index with 2307 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.