# list of containers
docker ps
# stop container
docker stop <container id>
# list of images
docker image ls
# remove images
docker rm <image id>
# add to docker images
docker load < image_latest.tar.gz
# list of containers
docker ps
# stop container
docker stop <container id>
# list of images
docker image ls
# remove images
docker rm <image id>
# add to docker images
docker load < image_latest.tar.gz
https://forum.golangbridge.org/t/dereferencing-pointer/21201/4
//Manual derefenrece only need for map
func myProcess(a *map[string]string) { t := (*a)["whatever"] ... }
// GO auto deference if struct is pointer :
Yes, but don’t write it in that complicated way. In Go, we value readability and simplicity. Simply write:
func happyBirthday(p *person) {
p.age++
}
--------------------------------------------------------------------------------------------------------
receiver , receiver with pointer
https://go.dev/tour/methods/4
package main
import (
"fmt"
"math"
)
type Vertex struct {
X, Y float64
}
func (v Vertex) Abs() float64 {
return math.Sqrt(v.X*v.X + v.Y*v.Y)
}
func (v *Vertex) Scale(f float64) {
v.X = v.X * f
v.Y = v.Y * f
}
func main() {
v := Vertex{3, 4}
//result is 5
fmt.Println(v.Abs())
v.Scale(10)
//result is 50
fmt.Println(v.Abs())
}
# reciever with pointer changes the address of original value due to auto dereferncing
-------------------------------
https://medium.com/@jamal.kaksouri/a-comprehensive-guide-to-pointers-in-go-4acc58eb1f4d
var x int = 10---------------------
var ptr *int = new(int)
fmt.Println(ptr) // output: 0xc0000160c0
fmt.Println(*ptr) // output: 0
*ptr = 10
fmt.Println(*ptr) // output: 10
ptr = nil
In this example,
we declare a pointer variable ptr
of type *int and use the new function to allocate memory for an integer value.
We then print the memory address stored in ptr,
which is the address of the newly allocated memory block.
We also print the value of *ptr, which is the value stored at the memory address,
which is initially set to 0.
We then assign the value 10 to the memory location pointed to
by ptr using the * operator. Finally, we set the pointer variable to nil,
which frees the memory block allocated by new.
-----------------------------------------------------------------------
error will occur when derefencing nil pointer
The error occurs if you try to dereference (*ptr
) a nil pointer:
https://stackoverflow.com/questions/59964619/difference-using-pointer-in-struct-fields
use pointer in struct to allow nil
allow pointer type *string to allow nil value
*namePtr derference the pointet
var namePtr *string // namePtr is nil
fmt.Println(*namePtr) // ❌ ERROR: nil pointer dereference
Check nil
package main
import "fmt"
func main() {
var namePtr *string // initialized pointer (nil)
if namePtr == nil {
fmt.Println("Pointer is nil, cannot dereference")
} else {
fmt.Println(*namePtr) // This won't execute// dereferencing pointer
}
}
// Make a pointer
namePtr := new(string)
*namePtr = "Bob" // Assign value to the dereferenced pointer
Using a Pointer for Nested Structs
type User struct {
Name string `json:"name"`
Email string `json:"email"`
Age int `json:"age"`
Address *Address `json:"address,omitempty"` // Pointer to Address struct
}
Address *Address
means the Address
field is a pointer to an Address
struct, not the actual struct itself.- The
*
in the struct definition does not dereference the pointer—it just defines the type as a pointer.
If Address
is optional, use a pointer (*Address
):
gotype User struct {
Name string `json:"name"`
Email string `json:"email"`
Age int `json:"age"`
Address *Address `json:"address,omitempty"` // Omits field if nil
}
📌 Response when Address
is nil
json{
"name": "John Doe",
"email": "john@example.com",
"age": 30
}
permanet:
In your seondaryproject :
angular.json
"architect": { "build": { "options": { "outputPath": "dist/your-app-name", "baseHref": "/demo/", "deployUrl": "/demo/" }
--base-href=/demo/
: Specifies the base URL for the application’s routing (i.e., how Angular handles navigation).--deploy-url=/demo/
: Specifies the URL path for static assets (JavaScript, CSS, images, fonts, etc.).https://www.techonthenet.com/mysql/union_all.php
UNION ALL
The MySQL UNION ALL operator is used to combine the result sets of 2 or more SELECT statements. It returns all rows from the query and it does not remove duplicate rows between the various SELECT statements.
Each SELECT statement within the MySQL UNION ALL operator must have the same number of fields in the result sets with similar data types.
https://stackoverflow.com/questions/18840998/recursive-in-sql
The syntax that you are using looks like Postgres. "Recursion" in SQL is not really recursion, it is iteration. Your statement is:
WITH RECURSIVE t(n) AS (
SELECT 1
UNION ALL
SELECT n+1 FROM t WHERE n < 100
)
SELECT sum(n) FROM t;
The statement for t is evaluated as:
Evaluate the non-self-referring part (select 1).
Then evaluate the self-referring part. (Initially this gives 2.)
Then evaluation the self-referring part again. (3).
And so on while the condition is still valid (n < 100).
When this is done the t subquery is finished, and the final statement can be evaluated.
The RECURSIVE from the query doesn't mean anything: it's just another name like n or t. What makes things recursive is that the CTE named t references itself inside the expression. To produce the result of the expression, the query engine must therefore recursively build the result, where each evaluation triggers the next. It reaches this point: SELECT n+1 FROM t... and has to stop and evaluate t. To do that, it has to call itself again, and so on, until the condition (n < 100) no longer holds. The SELECT 1 provides a starting point, and the WHERE n < 100 makes it so that the query does not recur forever.
https://www.techtarget.com/searchsecurity/definition/Certificate-Revocation-List#:~:text=A%20certificate%20revocation%20list%20(CRL)%20is%20a%20list%20of%20digital,actual%20or%20assigned%20expiration%20date.
https://www.baeldung.com/linux/vim-search-replace
To search and replace all occurrences on every line of the file, we need to slightly modify the previous command:
:%s/article/tutorial/g
The % symbol lets us access all the content in the file, and we can replace all occurrences in each line.
The sample.txt file should match this after replacing all occurrences:
https://dev.to/alumassy/how-to-access-the-erd-entity-relationship-diagram-of-your-database-schema-in-mysql-workbench-5813
Below are steps you can follow to view the ERD (Entity-Relationship Diagram) of your database schema in MySQL Workbench: