This Code is a User Input , writefile and readfile

package main

import (

type data struct {
name string
surname string
contact string
id string
count int

var stringsetWM = " <<<<>>>>"
var stringsetMM = " <<<>>>"
var stringsetBE = " <<<<< >>>>>"
var stringsetOM = " <<<< Options >>>>“
var stringsetIM = " <<>>”

//I need a user controlled interface for use through out multiple application
//||I created a simple and stable user interface
//Now I need 3 working inner applications. Control, Read and Write

func input(in string) (out string) {
out = in
return out

func main() {



func subMain() {

var in string

//thinking of useing some if and switch code//So far so good on the for switch statement

fmt.Println(stringsetWM+"\n", stringsetBE+"\n", stringsetIM+"\n", stringsetBE+"\n")

//the for loop should start here

for {
	sInput := input(in)
	switch sInput {

	case "1":

		//if there is only read a write and build logic then
		//this option must be something with build logic
	case "2":
		//this will be option two. I dont know if i had a choice

	case "3":
		// console applications 3 options fmt no http package here

		//so i can read files and probably ports as well
		//i can write files and to ports
		//if any other key is inputed this message appears and it waites again
		fmt.Println("Sorry Command invalid.")


//With these the options as part of the base core of the application
//the options from then on could be endless

func option1() {
//this first option is to be part of a control system
fmt.Println(“This is something special it leans on the power of the command prompt”)
//lets think! the most important power of the console to talk to ports!!

func option2() {
//this second option is to be the read from part
fmt.Println(“Welcome to option 2. Where you can read a text file”)


func option3() {
//This third option is to be the write to part
fmt.Println(“This option is to write to file as an output some how”)

func readfile() {

//readfile was code i made the other day then I pasted it in here
//Process : recieve the file name from the user input
//Process : read the file that the user has pointed to
//Process : read the data and process it in some way

var filepath string
fmt.Println("Please Enter the Name of the File you are looking for?")
fileinput := input(filepath) + ".txt" //works Now

file, err := ioutil.ReadFile(fileinput)
if err != nil {
	fmt.Println("Error finding file.", err)

var sFile = string(file)
// string converts the target data to string data

var theCount int
var unSpec int
var sKey string
var oKey string

//first we create scanner as a NewScanner and point it to the sFile
scanner := bufio.NewScanner(strings.NewReader(sFile))
//here is where we split the scanner data file to scan word by word
//declareing oKey data and asking for input from the user
fmt.Println("Please Enter the word you are looking for?")
oKey = input(sKey)
// the for scanner.Scan() will run through each line of the text data and loop

//until it reaches the EOF condition as true.
for scanner.Scan() {

	var stringScan = scanner.Text()

	switch stringScan {

	case oKey:
		//Word Counter
		//Word finder and Counter




if theCount < 1 {
	fmt.Println("Sorry the word you where looking for could not be found")
if theCount > 0 {
	fmt.Printf("The word %s was found %d time(s).\n", oKey, theCount)


func writefile() {

var name string

var in = input(name)

file, err := os.Create(in + ".txt") //This code piece should create a file called ...
if err != nil {
	fmt.Println("Failed to create file.", err)
if err == nil {
	fmt.Println("Created File Successfully.")
defer file.Close()
//after creating the file, I need to now write some data to it

var path = in + ".txt"
// open file using READ & WRITE permission
var oFile, error = os.OpenFile(path, os.O_RDWR, 0644)
if error != nil {
defer oFile.Close()

var person data = "Name\n"
person.surname = "Surname\n" = "ID Number\n" = "Tel No\n"


// write some text line-by-line to file
var hello, _ = oFile.WriteString("Hello Golang Programmer\n")
fmt.Println("Hello Here and Hello there", hello)
//if err != nil { return }

var message = "Example only. Imagine more\n"
var msg, _ = oFile.WriteString(message)
fmt.Println("Printing..", msg)

_, err = oFile.WriteString("This is the end\n")
if err != nil {

// save changes
err = file.Sync()
if err != nil {

fmt.Println("==> Done writing to file <==")


//Most likely going to be called writefile()

//Then after that there will be

Can you please phrase a proper question and format your code in a more readable way? This forum uses markdown to format posts.