# E-LINT-009: name not allowed

Some packages that app code may import hold names that would let it leave the building blocks, so app code may use only some of their names. From `net/http`, it may use `Cookie`, `Handler`, `Header`, `Request`, `ResponseWriter`, the type `SameSite` and its `SameSite...` constants, `ErrNoCookie`, `StatusText`, `DetectContentType`, `CanonicalHeaderKey`, `TimeFormat`, and the `Method...` and `Status...` constants, and, to call outside services with the client that `outbound.Client()` returns, `Client` as `*http.Client`, `NewRequest`, `NewRequestWithContext`, `NoBody` and `Response`: not a client of its own (`Get`, `Post`, `Head`, `PostForm`, `DefaultClient`, `DefaultTransport`, `Transport`, `RoundTripper`), servers and muxes (`ListenAndServe`, `Serve`, `NewServeMux`), files (`Dir`, `FileServer`, `ServeFile`), `Error`, `Redirect` or `NewResponseController`. From `database/sql`, it may use the types `ColumnType`, `Conn`, `DB`, `DBStats`, `IsolationLevel`, `NamedArg`, `Null`, `NullBool`, `NullByte`, `NullFloat64`, `NullInt16`, `NullInt32`, `NullInt64`, `NullString`, `NullTime`, `Out`, `RawBytes`, `Result`, `Row`, `Rows`, `Scanner`, `Stmt`, `Tx` and `TxOptions`, the `Level...` isolation levels, `Named`, which makes a `NamedArg`, and the errors `ErrConnDone`, `ErrNoRows` and `ErrTxDone`; `Open`, `OpenDB` and `Register` are E-LINT-006, and the `Raw` method of `*sql.Conn`, which hands out the driver's own connection, and the `ScanType` method of `*sql.ColumnType`, which hands out a `reflect.Type`, are refused here, also as methods of an interface with their names and signatures, where a type parameter in a signature stands for any type. The other methods and fields of the allowed types stay allowed. From `log/slog`, `SetDefault`, `SetLogLoggerLevel` and `NewLogLogger` are refused, since the framework sets up the logger. App code may not change a variable of the standard library or of the framework either, such as `rand.Reader` or `time.Local`, by assigning to it or to a part of it, with `++` or `--`, by `range`, or by taking its address; nor may it assign through `*` to a value whose type is a named type of the standard library or the framework, whatever pointer it holds: `*slog.Default() = ...`, `*l = ...` for an `l` that `slog.With` returned, `*time.Local = ...`, and also `*out = time.Now()` through a parameter `out *time.Time` of its own, because the pointer may reach a value the app may not change; return the value instead of writing it through such a pointer. Nor may app code change a value through a pointer whose pointee is a type parameter, which could point at such a value. Nor may it convert a pointer to one of these named types into a different pointer type, such as `(*myLogger)(slog.Default())`, which would hand it a pointer it could write through. Nor may it convert to or from a pointer to a type parameter, or a type parameter whose type set holds a pointer type or cannot be listed, such as one constrained by `any` or by methods alone; the types a constraint lists are read through its embedded interfaces and unions, and a part that lists none adds nothing. Any other conversion with a type parameter stays allowed, one whose type parameters' type sets list no pointer type, such as `int(v)` or `float64(v)` for a type parameter constrained to number types or `[]byte(s)` for one constrained to `~string`; and so does a conversion to an interface type, such as `any(v)` or `fmt.Stringer(v)`, whatever it converts, unless the target is itself a type parameter, also when it is written through an alias, or the value holds an HTTP client, as below. App code cannot import `reflect` (E-LINT-001); when it gets a `reflect.Value` or `reflect.Type` from a value it is given, such as the `Type` field of a `json.UnmarshalTypeError`, reading that field is allowed, but using any method or field of the result, such as `MethodByName`, is refused, since reflection reaches any method of any value. App code calls outside services only with the `*http.Client` that `outbound.Client()` returns, which hands every request to the runner. It may not make a client of its own: `http.Client{}`, `&http.Client{}`, `new(http.Client)`, an element `{}` of a `[]*http.Client{...}` literal, or a variable, field, type or alias of type `http.Client` are refused, and so is `*c = ...` through a `*http.Client`. It may not read or set the client's fields `Transport`, `CheckRedirect`, `Jar` and `Timeout`, nor call its `Get`, `Head`, `Post` and `PostForm` methods, which send without the request's context: build the request with `http.NewRequestWithContext` and the context of the request or job it serves, and send it with `Do`. Nor may it turn a `*http.Client`, or a value that reaches one through pointers, elements, map keys or exported fields, into an interface value, as `json.Unmarshal(data, c)` or `fmt.Println(c)` would, since code that takes an interface value could change the client through it; nor instantiate a generic function or type with a type argument that holds an `http.Client`, which could make one as `new(T)` does. Keep the client in a variable, a parameter or an unexported field of type `*http.Client`. A client the app makes, with a literal or `new`, and each use of a client name of `net/http` have the fix: call outside services with outbound.Client(), which goes through the runner. A client held by value, and anything done to the client that `outbound.Client()` returns, such as setting a field, `*c = ...`, calling `Get`, turning it into an interface value or passing it as a type argument, have the fix: use the client from outbound.Client() as it is: build requests with http.NewRequestWithContext and send them with its Do method. Generated files are checked too, since they hold the code of the templates' expressions, and a problem there points to the template line that the code was written from.

**Fix:** use only the names that aicoded explain E-LINT-009 lists; return a value instead of writing it through a pointer to a standard-library or framework type, and keep values in variables of your own.
