- First goto project folder
- Initialize git by git init command
- Set username with git config user.name "username” command
- Set email with git config user.email "some@email.com” command
- Now create a repository in GitHub
- Now we will either set or add origin based on project status
- As github disabled using plain password in git url we need to get github personal access token from here
- Newly added git project git remote add origin https://username:accesstoken@github.com/saiumesh535/chi-http.git
- Existing git project
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "encoding/json" | |
| "fmt" | |
| "net/http" | |
| ) | |
| type InfoData struct { | |
| Seed string |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fn main() { | |
| // first let's define vector/array of numbers | |
| let numbers = vec![1, 2, 4]; | |
| // now let's try to read value from vector | |
| let index_one = numbers[1]; | |
| println!("value at index {}", index_one); | |
| // now let's try to read 10th index which doesn't exists | |
| // since Rust doesn't have neither null nor try/catch to handle error |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fn read_from_vec(input: &Vec<i32>, index: usize) -> Result<i32, &'static str> { | |
| return match input.get(index) { | |
| Some(value) => Ok(*value), | |
| None => Err("Out of bound exception") | |
| } | |
| } | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use std::io; | |
| use std::io::Read; | |
| use std::fs::File; | |
| fn read_from_file(file_path: &'static str) -> Result<String, io::Error> { | |
| let mut file_data = String::new(); | |
| // now let's try to read file |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
| { | |
| "compilerOptions": { | |
| "incremental": true, | |
| "target": "es2017", | |
| "module": "commonjs", | |
| "lib": ["es2017"], | |
| "types": ["node"], | |
| "outDir": "./build", | |
| "rootDir": "./", | |
| "strict": true, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "defaultSeverity": "error", | |
| "extends": "./node_modules/tslint/lib/configs/recommended", | |
| "linterOptions": { | |
| "exclude": [ | |
| "node_modules/**" | |
| ] | |
| }, | |
| "jsRules": {}, | |
| "rules": { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| "scripts": { | |
| "dev": "tsc-watch --onSuccess \"cross-env NODE_ENV=development node build/src/index.js\"", | |
| "prod":"tsc && cross-env NODE_ENV=production node build/src/index.js", | |
| "lint": "tslint --project tslint.json" | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import "fmt" | |
| type Http struct { | |
| } | |
| func (http *Http) Get(url string) string { | |
| return fmt.Sprintf("the result from %s is nothing", url) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Re-clone | |
| GIT=$(git rev-parse --show-toplevel) | |
| cd $GIT/.. | |
| rm -rf $GIT | |
| git clone ... | |
| ✅ Deletes local, non-pushed commits | |
| ✅ Reverts changes you made to tracked files | |
| ✅ Restores tracked files you deleted | |
| ✅ Deletes files/dirs listed in .gitignore (like build files) | |
| ✅ Deletes files/dirs that are not tracked and not in .gitignore |