Skip to content

Latest commit

 

History

History
414 lines (320 loc) · 8.49 KB

readme.md

File metadata and controls

414 lines (320 loc) · 8.49 KB

Go lang demos

Table of Contents

Modules:

Overview

Bunch of demos for GoLang . All is ran from console

Basic

Some basic golanf staff

Run: ./main basic

demo:

  • defer
  • dirs list
  • json
  • pipes
  • spinner
  • surface
  • toposort
  • utils-echo
  • utils-sha
  • utils-anon
  • utils-slow For mandelbrot see below.

Methods

Defer panic - shows deffered action and throws panic
Directory traversal - shows volume and files number in specified dirs
Files - count and show duplicate lines in files
JsonMarshaller - marshalls struct to json
MandelBrot - draws a fractal picture.run: ./main web web-server. In browser localhost:8000/fractal
Pipeline - shows go routine interaction via pipes 
Spinner - counts fibonacci numbers with delay 
Surface - draws and svg 
Toposort - sorts a map   
Utils: 
   #small util and demo functions
   Echo - shows cmd arguments
   SHA - counts sha sum of specified string
   AnonFunc - show a call of a anon func
   BigSlow - turns on a slow operation and traces it
     

Geometry

Type struct and methods demo

run: ./main geometry x1 y1 x2 y2

Types

Point:
   X: float64
   Y: float64

ColoredPoint:
   Color: color.RGBA

Methods

PointDistance - distance between two points
ScaleBy - scale point coordinates by factor
Add - add one point to another
Sub - substract one point from another
TranslateBy - move point with offset
Distance - perimeter distance
GeometryDemo - run all methods with specified coordinates

IssueReporter

Shows list of issues in htmll or list mode.

run: ./main issues

mode: - HTML - Console

Types

IssuesSearchResult: 
    TotalCount: int 
    Items:      []Issue

Issue:
    Number:     int
    HTMLURL:    string 
    Title:      string
    State:      string
    User:       User
    CreatedAt:  time.Time
    Body:       string
    
User:
    Login:      string
	HTMLURL:    string

Methods

SearchIssues - search from source in selected mode

Links

Fetch data from url and parse it to get links run: ./main links list

action:

  • fetch-console
  • fetch-file
  • fetch-concurent
  • links-from-url
  • links-from-urls
  • links-breadth
  • links-tags
  • links-tags-tree

Methods

FetchToConsole - fetch list of urls and show it in console
FetchToFile - fetch a single url to file
ConcurentFetcher - fetch list of urls and show fetch time
FindLinks - show list of links from the list of urls
FindLinksFromUrl - show list of links from a single url
FindLinksBreadthFirst - show links in console from a single url
ShowTags - outline stack of tags from the list of urls
ShowTagsTree - outline tree of tags from the list of urls

Lissajous

Creates a lissajous figures gif run: ./main server web-server. In browser localhost:8000/lissajous

Methods

Lissajous - create a gif

Server

Runs different servers run: ./main server

If you want to use chat server : ./main server chat client-type

server-type:

  • web-server
  • clock
  • echo
  • chat
  • rest
  • daytime-tcp
  • daytime-udp
  • daytime-asn1
  • multi
  • json
  • gob
  • ftp
  • utf16
  • tls
  • file
  • rpc-http
  • rpc-tcp
  • rpc-json
  • websocket
  • websocket-json
  • websocket-xml

Methods

RunWebServer - run web server.
   Modes:
        - check server is operational: localhost:8000
        - run enties counter: localhost:8000/counter
        - draw lissajous: localhost:8000/lissajous  
        - draw fractal: localhost:8000/fractal

ClockServer - run clock server.
    Run: localhost:8080

EchoServer - run echo server.
    Run: localhost:5000

ChatServer - run chat server.
    Run: localhost:8090
    
RestServer - run rest server.
    Run: localhost:8080
    REST methods: 
      - /getPerson/{person_id}, GET
      - /getPersons, GET
      - /insertPerson, POST
      - /getJob/{job_id}, GET
      - /getJobForPerson/{person_id}, GET
      - /insertJob, POST

DaytimeTcpServer - run daytime tcp server.
    Run: localhost:1200
    
DaytimeUdpServer - run daytime udp server.
    Run: localhost:1300    
    
DaytimeAsn1Server - run daytime server sending data in asn1 format.
    Run: localhost:1400    
    

MultithreadServer -run multithread server.
    Run: localhost:1201    

JsonServer - run json server.
    Run: localhost:1500   
    
GobServer - run gob server.
    Run: localhost:1600  
    
FtpServer - run ftp server.
    Run: localhsot:1700   
    
Utf16Server - run server which sends message in utf16
    Run: localhost:1800    
    
TlsServer - run server with x509 certificate(certificate requrired)
    Run: localhost:1900      
    
FileServer - run fileserver
    Run: localhost:2000    
    
HttpRpcServer - run http-based rpc server
    Run: localhost:2100
    
TcpRpcServer - run tcp-based rpc server
    Run: localhost:2200   
     
JsonRpcServer - run json rpc server
    Run: localhost:2300    

WebSocketServer - run websocket server
    Run: localhost:2400 
    
WebSocketJsonServer - run websocket server which accepts data in json
    Run: localhost:2500     
    
WebSocketXmlServer - run websocket server which accepts data in xml
    Run: localhost:2600                         

Client

Runs different client run: ./main client

client-type:

  • tcp :
  • netcat
  • concurrent
  • daytime-udp :
  • daytime-asn1 :
  • json :
  • gob :
  • ftp
  • utf16 :
  • tls :
  • http
  • rpc-http :
  • rpc-tcp :
  • rpc-json :
  • websocket :
  • websocket-json :
  • websocket-xml :

Methods

     
TcpClient - run tcp client

Netcat - run netcat client

NetcatChannel - run concurrent tcp client based on go routines and channels.  

DaytimeUdpClient - run daytime udp client

DaytimeAsn1Client - run daytime asn1 client

JsonClient - run json client

FtpClient - run ftp client

Utf16Client - run client which accepts message in utf16

TlsClient - run client to connect to tls server

HttpClient - run a http client

HttpRpcClient - run a http rpc client

TcpRpcClient - run a tcp rpc client

JsonRpcClient - run a json rpc client 

WebSocketClient - run a websocket client which sends a message

WebSocketJsonClient - run a websocket client which sends data in json

WebSocketXmlClient - run a websocket client which sends data in xml
         

Network

Basic network operations run: ./main network

operations: - get-mask - resolve-ip - host-lookup - port-lookup - ping - asn1 - json - base64 - http-header - http-get

Methods

GetMask - get mask of ip address
ResolveIP - get ip address of hostname
HostLookup - get ip addresses of host
PortLookup - get port of service
Ping - send icmp request to host
Asn1Marschall - marshalls and unmarshalls value to/from byte array
JsonMarshall - marshalls and unmarshalls value to/from json
Base64Encoder - encodes and decodes a byte array which consists of 8 digigts
ReadHttpHeader - reades headers of http response
ReadHttpGet - make a get request to url

Security

Basic security examples related to network run: ./main security

examples: - md5 - blowfish - gen-rsa - load-rsa - x509-gen - x509-load

Methods

Md5Hash - calculates and outputs hashvalue of incoming string
BlowFish - uses blofish to encode/decode string
GenRsaKey - generates a rsa key and saves to the file
LoadRsaKey - loads a rsa kay from file(you need to have private.key and public.key files)
GenX509 - generates a new x509 certificate based on private.key
LoadX509 - loads and parses x509 certificate

XML

XML related examples run: ./main xml

examples: - parse - unmarshal

Methods

ParseXML - parses incoming file and shows its tree
UnmarshalXML - unmarshals xml to struct