Skip to content

Instantly share code, notes, and snippets.

Avatar

Velotio Technologies velotiotech

View GitHub Profile
View quiz.py
def my_func(number):
try:
number = number / 0
except ZeroDivisionError:
print('Division by 0 is not allowed ', end='')
else:
print('Division successful ', end='')
try:
number = number / 5
except:
View sudogstruct.go
type sudog struct{
g *g
isSelect bool
next *sudog
prev *sudog
elem unsafe.Pointer //data element
...
}
View memCopyOutput.go
Main started...
Value of b before putting into channel 10
Updated value of a: 20
Updated value of b: 20
Data in channel is: 10
Main ended...
View memCopy.go
func printData(c chan *int) {
time.Sleep(time.Second * 3)
data := <-c
fmt.Println("Data in channel is: ", *data)
}
func main() {
fmt.Println("Main started...")
var a = 10
b := &a
View hchanStruct.go
type hchan struct {
qcount uint // total data in the queue
dataqsiz uint // size of the circular queue
buf unsafe.Pointer // points to an array of dataqsiz elements
elemsize uint16
closed uint32
elemtype *_type // element type
sendx uint // send index
recvx uint // receive index
recvq waitq // list of recv waiters
View output.go
Main started...
Data in channel is: 10
Main ended...
View mainFunc.go
func main() {
fmt.Println("Main started...")
//create channel of int
c := make(chan int)
// call to goroutine
go printChannelData(c)
// put the data in channel
c <- 10
fmt.Println("Main ended...")
}
View printChannelDataFunc.go
func printChannelData(c chan int) {
fmt.Println("Data in channel is: ", <-c)
}