You are given a Go package named `gorhsm` that includes the import statement for the `encoding/json` package. Your task is to create a function that serializes a Go struct into a JSON string.

Write a function with the following signature:

```
func SerializeToJSON(input interface{}) (string, error)
```

**Input**
- The function takes a single input parameter `input`, which can be of any valid Go data type.

**Output**
- The function should return a string that represents the JSON serialization of the input struct.
- If there is an error during the serialization process, return an empty string (`""`) and an appropriate error.

**Examples**
Example 1:
```go
type Person struct {
	Name string
	Age  int
}

p := Person{Name: "John Doe", Age: 25}
result, err := SerializeToJSON(p)
fmt.Println(result) // {"Name":"John Doe","Age":25}
fmt.Println(err)   // nil
```

Example 2:
```go
type Book struct {
	Title  string
	Author string
}

b := Book{Title: "The Great Gatsby", Author: "F. Scott Fitzgerald"}
result, err := SerializeToJSON(b)
fmt.Println(result) // {"Title":"The Great Gatsby","Author":"F. Scott Fitzgerald"}
fmt.Println(err)   // nil
```

Example 3:
```go
type InvalidStruct struct {
	InvalidChan chan int
}

i := InvalidStruct{InvalidChan: make(chan int)}
result, err := SerializeToJSON(i)
fmt.Println(result) // ""
fmt.Println(err)   // json: unsupported type: chan int
```
user
Sure, here's a simple implementation for the `SerializeToJSON` function. You can add more error handling logic as needed.

```go
package gorhsm

import (
	"encoding/json"
	"errors"
)

func SerializeToJSON(input interface{}) (string, error) {
	js, err := json.Marshal(input)
	if err != nil {
		return "", errors.Wrap(err, "serialization failed")
	}

	return string(js), nil
}
```

This function works for structs, maps, slices, and pointers to them. It uses the `json.Marshal` function to convert the input into JSON bytes. If there's any error during this operation, it returns an empty string and an error. If the marshaling is successful, it converts the JSON bytes to a string and returns that along with nil.
assistant
You are given a Go package named `gorhsm` that includes the import statement for the `encoding/json` package. Your task is to create a function that serializes a Go struct into a JSON string.

Write a function with the following signature:

```
func SerializeToJSON(input interface{}) (string, error)
```

**Input**
- The function takes a single input parameter `input`, which can be of any valid Go data type.

**Output**
- The function should return a string that represents the JSON serialization of the input struct.
- If there is an error during the serialization process, return an empty string (`""`) and an appropriate error.

**Examples**
Example 1:
```go
type Person struct {
	Name string
	Age  int
}

p := Person{Name: "John Doe", Age: 25}
result, err := SerializeToJSON(p)
fmt.Println(result) // {"Name":"John Doe","Age":25}
fmt.Println(err)   // nil
```

Example 2:
```go
type Book struct {
	Title  string
	Author string
}

b := Book{Title: "The Great Gatsby", Author: "F. Scott Fitzgerald"}
result, err := SerializeToJSON(b)
fmt.Println(result) // {"Title":"The Great Gatsby","Author":"F. Scott Fitzgerald"}
fmt.Println(err)   // nil
```

Example 3:
```go
type InvalidStruct struct {
	InvalidChan chan int
}

i := InvalidStruct{InvalidChan: make(chan int)}
result, err := SerializeToJSON(i)
fmt.Println(result) // ""
fmt.Println(err)   // json: unsupported type: chan int
```
user
Sure, here is the implementation of the `SerializeToJSON` function:

```go
package gorhsm

import (
	"encoding/json"
	"errors"
)

func SerializeToJSON(input interface{}) (string, error) {
	jsonData, err := json.Marshal(input)
	if err != nil {
		return "", err
	}
	return string(jsonData), nil
}
```

This function uses the `json.Marshal` function from the `encoding/json` package to convert the input into a JSON byte Slice. If the marshaling fails, it returns an empty string and the error. If the marshaling is successful, it converts the JSON byte Slice into a string and returns it with a nil error.
assistant